Skip to content

Commit da5c25e

Browse files
committed
Share Gravity Index input schema
1 parent 7b7f0d0 commit da5c25e

3 files changed

Lines changed: 162 additions & 160 deletions

File tree

common/src/tools/params/tool/gravity-index.ts

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import z from 'zod/v4'
22

3+
import { gravityIndexInputSchema } from '../../../types/gravity-index'
34
import { $getNativeToolCallExampleString, jsonToolResultSchema } from '../utils'
45
import { jsonObjectSchema } from '../../../types/json'
56

@@ -8,73 +9,6 @@ import type { $ToolParams } from '../../constants'
89
const toolName = 'gravity_index'
910
const endsAgentStep = true
1011

11-
const inputSchema = z
12-
.discriminatedUnion('action', [
13-
z.object({
14-
action: z.literal('search').describe('Search for the best service.'),
15-
query: z
16-
.string()
17-
.min(1, 'Query cannot be empty')
18-
.max(1000, 'Query cannot exceed 1000 characters')
19-
.describe(
20-
`What the user needs, including stack, constraints, and required capabilities when known. Example: "serverless database with branching for a Next.js app".`,
21-
),
22-
search_id: z
23-
.string()
24-
.optional()
25-
.describe('Continue a previous Gravity Index search as a follow-up.'),
26-
context: z
27-
.record(z.string(), z.unknown())
28-
.optional()
29-
.describe(
30-
'Optional structured context about the project, stack, or constraints.',
31-
),
32-
}),
33-
z.object({
34-
action: z
35-
.literal('browse')
36-
.describe('Browse catalog services by category and/or keyword.'),
37-
category: z
38-
.string()
39-
.optional()
40-
.describe(
41-
'Optional category filter, e.g. Database, Auth, Payments, Hosting, Email, Cache, Monitoring, Analytics, AI, Storage, CMS, Search, Realtime, Background Jobs, Infrastructure, CRM, Support, Productivity, Commerce, Video, Webhooks, SMS.',
42-
),
43-
q: z
44-
.string()
45-
.optional()
46-
.describe('Optional keyword filter, e.g. sendgrid or postgres.'),
47-
}),
48-
z.object({
49-
action: z
50-
.literal('list_categories')
51-
.describe('List every category with service counts.'),
52-
}),
53-
z.object({
54-
action: z
55-
.literal('get_service')
56-
.describe('Fetch full detail for a single service by slug.'),
57-
slug: z
58-
.string()
59-
.min(1, 'Slug cannot be empty')
60-
.describe('Service slug, e.g. supabase, stripe, sendgrid.'),
61-
}),
62-
z.object({
63-
action: z
64-
.literal('report_integration')
65-
.describe('Report that an integration from a prior search was done.'),
66-
search_id: z
67-
.string()
68-
.min(1, 'search_id cannot be empty')
69-
.describe('search_id from the earlier search result.'),
70-
integrated_slug: z
71-
.string()
72-
.min(1, 'integrated_slug cannot be empty')
73-
.describe('Slug of the service that was actually integrated.'),
74-
}),
75-
])
76-
.describe(`Use the Gravity Index catalog and conversion API.`)
77-
7812
const description = `
7913
Purpose: Use the Gravity Index to discover, inspect, and report integrations for third-party developer services such as databases, auth, payments, hosting, email, cache, monitoring, analytics, AI, storage, CMS, search, realtime, background jobs, infrastructure, CRM, support, productivity, commerce, video, webhooks, and SMS.
8014
@@ -98,7 +32,7 @@ Implementation guidance:
9832
Examples:
9933
${$getNativeToolCallExampleString({
10034
toolName,
101-
inputSchema,
35+
inputSchema: gravityIndexInputSchema,
10236
input: {
10337
action: 'search',
10438
query:
@@ -109,7 +43,7 @@ ${$getNativeToolCallExampleString({
10943
11044
${$getNativeToolCallExampleString({
11145
toolName,
112-
inputSchema,
46+
inputSchema: gravityIndexInputSchema,
11347
input: {
11448
action: 'browse',
11549
category: 'Email',
@@ -120,7 +54,7 @@ ${$getNativeToolCallExampleString({
12054
12155
${$getNativeToolCallExampleString({
12256
toolName,
123-
inputSchema,
57+
inputSchema: gravityIndexInputSchema,
12458
input: {
12559
action: 'get_service',
12660
slug: 'sendgrid',
@@ -130,7 +64,7 @@ ${$getNativeToolCallExampleString({
13064
13165
${$getNativeToolCallExampleString({
13266
toolName,
133-
inputSchema,
67+
inputSchema: gravityIndexInputSchema,
13468
input: {
13569
action: 'report_integration',
13670
search_id: 'search_id_from_previous_search',
@@ -144,7 +78,7 @@ export const gravityIndexParams = {
14478
toolName,
14579
endsAgentStep,
14680
description,
147-
inputSchema,
81+
inputSchema: gravityIndexInputSchema,
14882
outputSchema: jsonToolResultSchema(
14983
z.union([
15084
jsonObjectSchema,

common/src/types/gravity-index.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import z from 'zod/v4'
2+
3+
import { jsonObjectSchema } from './json'
4+
5+
export const gravityIndexInputSchema = z
6+
.discriminatedUnion('action', [
7+
z.object({
8+
action: z.literal('search').describe('Search for the best service.'),
9+
query: z
10+
.string()
11+
.min(1, 'Query cannot be empty')
12+
.max(1000, 'Query cannot exceed 1000 characters')
13+
.describe(
14+
`What the user needs, including stack, constraints, and required capabilities when known. Example: "serverless database with branching for a Next.js app".`,
15+
),
16+
search_id: z
17+
.string()
18+
.optional()
19+
.describe('Continue a previous Gravity Index search as a follow-up.'),
20+
context: jsonObjectSchema
21+
.optional()
22+
.describe(
23+
'Optional structured JSON context about the project, stack, or constraints.',
24+
),
25+
}),
26+
z.object({
27+
action: z
28+
.literal('browse')
29+
.describe('Browse catalog services by category and/or keyword.'),
30+
category: z
31+
.string()
32+
.optional()
33+
.describe(
34+
'Optional category filter, e.g. Database, Auth, Payments, Hosting, Email, Cache, Monitoring, Analytics, AI, Storage, CMS, Search, Realtime, Background Jobs, Infrastructure, CRM, Support, Productivity, Commerce, Video, Webhooks, SMS.',
35+
),
36+
q: z
37+
.string()
38+
.optional()
39+
.describe('Optional keyword filter, e.g. sendgrid or postgres.'),
40+
}),
41+
z.object({
42+
action: z
43+
.literal('list_categories')
44+
.describe('List every category with service counts.'),
45+
}),
46+
z.object({
47+
action: z
48+
.literal('get_service')
49+
.describe('Fetch full detail for a single service by slug.'),
50+
slug: z
51+
.string()
52+
.min(1, 'Slug cannot be empty')
53+
.describe('Service slug, e.g. supabase, stripe, sendgrid.'),
54+
}),
55+
z.object({
56+
action: z
57+
.literal('report_integration')
58+
.describe('Report that an integration from a prior search was done.'),
59+
search_id: z
60+
.string()
61+
.min(1, 'search_id cannot be empty')
62+
.describe('search_id from the earlier search result.'),
63+
integrated_slug: z
64+
.string()
65+
.min(1, 'integrated_slug cannot be empty')
66+
.describe('Slug of the service that was actually integrated.'),
67+
}),
68+
])
69+
.describe(`Use the Gravity Index catalog and conversion API.`)
70+
71+
export type GravityIndexInput = z.infer<typeof gravityIndexInputSchema>
72+
73+
export const gravityIndexActionRequiresApiKey = (
74+
action: GravityIndexInput['action'],
75+
) => action === 'search' || action === 'report_integration'

0 commit comments

Comments
 (0)