Skip to content

Commit f60e07b

Browse files
committed
Always include schema TypeScript previews
1 parent 48026a0 commit f60e07b

7 files changed

Lines changed: 26 additions & 57 deletions

File tree

apps/cli/src/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,6 @@ const runCallHelp = (
10721072
scopeId: scopeInfo.id,
10731073
toolId: exactTool.id,
10741074
},
1075-
query: { includeTypeScript: "true" },
10761075
})
10771076
.pipe(Effect.catchCause(() => Effect.succeed(undefined)))
10781077
: undefined;

packages/core/api/src/handlers/tools.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ export const ToolsHandlers = HttpApiBuilder.group(ExecutorApi, "tools", (handler
2828
}),
2929
),
3030
)
31-
.handle("schema", ({ params: path, query }) =>
31+
.handle("schema", ({ params: path }) =>
3232
capture(
3333
Effect.gen(function* () {
3434
const executor = yield* ExecutorService;
35-
const schema = yield* executor.tools.schema(path.toolId, {
36-
includeTypeScript: query.includeTypeScript === "true",
37-
});
35+
const schema = yield* executor.tools.schema(path.toolId);
3836
if (schema === null) {
3937
return yield* new ToolNotFoundError({ toolId: path.toolId });
4038
}

packages/core/api/src/tools/api.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ const PathParams = {
1111
toolId: ToolId,
1212
};
1313

14-
const ToolSchemaQuery = Schema.Struct({
15-
includeTypeScript: Schema.optional(Schema.Literal("true")),
16-
});
17-
1814
// ---------------------------------------------------------------------------
1915
// Response schemas
2016
// ---------------------------------------------------------------------------
@@ -57,7 +53,6 @@ export const ToolsApi = HttpApiGroup.make("tools")
5753
.add(
5854
HttpApiEndpoint.get("schema", "/scopes/:scopeId/tools/:toolId/schema", {
5955
params: PathParams,
60-
query: ToolSchemaQuery,
6156
success: ToolSchemaResponse,
6257
error: [InternalError, ToolNotFound],
6358
}),

packages/core/sdk/src/executor.test.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ describe("createExecutor", () => {
283283

284284
yield* executor.schemaProbe.registerSource();
285285

286-
const schema = yield* executor.tools.schema("schema-source.inspect", {
287-
includeTypeScript: false,
288-
});
286+
const schema = yield* executor.tools.schema("schema-source.inspect");
289287

290288
expect(schema?.inputSchema).toEqual({
291289
type: "object",
@@ -303,14 +301,9 @@ describe("createExecutor", () => {
303301
Pet: expect.any(Object),
304302
});
305303
expect(schema?.schemaDefinitions).not.toHaveProperty("Unused");
306-
expect(schema?.inputTypeScript).toBeUndefined();
307-
expect(schema?.outputTypeScript).toBeUndefined();
308-
expect(schema?.typeScriptDefinitions).toBeUndefined();
309-
310-
const schemaWithTypes = yield* executor.tools.schema("schema-source.inspect");
311-
expect(schemaWithTypes?.inputTypeScript).toContain("pet: Pet");
312-
expect(schemaWithTypes?.outputTypeScript).toBe("Owner");
313-
expect(schemaWithTypes?.typeScriptDefinitions).toEqual(
304+
expect(schema?.inputTypeScript).toContain("pet: Pet");
305+
expect(schema?.outputTypeScript).toBe("Owner");
306+
expect(schema?.typeScriptDefinitions).toEqual(
314307
expect.objectContaining({
315308
Pet: expect.any(String),
316309
Owner: expect.any(String),

packages/core/sdk/src/executor.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ import {
121121
type SourceDetectionResult,
122122
type Tool,
123123
type ToolListFilter,
124-
type ToolSchemaOptions,
125124
} from "./types";
126125
import { buildToolTypeScriptPreview, type ToolTypeScriptPreview } from "./schema-types";
127126
import { collectReferencedDefinitions } from "./schema-refs";
@@ -183,11 +182,8 @@ export type Executor<TPlugins extends readonly AnyPlugin[] = readonly []> = {
183182
readonly list: (filter?: ToolListFilter) => Effect.Effect<readonly Tool[], StorageFailure>;
184183
/** Fetch a tool's schema view: JSON schemas with `$defs`
185184
* attached from the core `definition` table, plus TypeScript
186-
* preview strings unless disabled. Returns `null` for unknown tool ids. */
187-
readonly schema: (
188-
toolId: string,
189-
options?: ToolSchemaOptions,
190-
) => Effect.Effect<ToolSchema | null, StorageFailure>;
185+
* preview strings. Returns `null` for unknown tool ids. */
186+
readonly schema: (toolId: string) => Effect.Effect<ToolSchema | null, StorageFailure>;
191187
/** Every `$defs` entry across every source, grouped by source id.
192188
* Used for bulk schema export and downstream TypeScript rendering. */
193189
readonly definitions: () => Effect.Effect<
@@ -2984,7 +2980,6 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
29842980
sourceId: string | undefined;
29852981
rawInput: unknown;
29862982
rawOutput: unknown;
2987-
includeTypeScript: boolean;
29882983
}) =>
29892984
Effect.gen(function* () {
29902985
const defs: Record<string, unknown> = opts.sourceId
@@ -2999,25 +2994,23 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
29992994
sourceDefsMap,
30002995
);
30012996
const schemaDefsMap = new Map<string, unknown>(Object.entries(schemaDefinitions));
3002-
const preview: ToolTypeScriptPreview = opts.includeTypeScript
3003-
? yield* Effect.promise(() =>
3004-
buildToolTypeScriptPreview({
3005-
inputSchema: opts.rawInput,
3006-
outputSchema: opts.rawOutput,
3007-
defs: schemaDefsMap,
3008-
}),
3009-
).pipe(
3010-
Effect.withSpan("schema.compile.preview", {
3011-
attributes: {
3012-
"schema.kind": "tool.preview",
3013-
"schema.has_input": opts.rawInput !== undefined,
3014-
"schema.has_output": opts.rawOutput !== undefined,
3015-
"schema.def_count": schemaDefsMap.size,
3016-
"schema.source_def_count": sourceDefsMap.size,
3017-
},
3018-
}),
3019-
)
3020-
: {};
2997+
const preview: ToolTypeScriptPreview = yield* Effect.promise(() =>
2998+
buildToolTypeScriptPreview({
2999+
inputSchema: opts.rawInput,
3000+
outputSchema: opts.rawOutput,
3001+
defs: schemaDefsMap,
3002+
}),
3003+
).pipe(
3004+
Effect.withSpan("schema.compile.preview", {
3005+
attributes: {
3006+
"schema.kind": "tool.preview",
3007+
"schema.has_input": opts.rawInput !== undefined,
3008+
"schema.has_output": opts.rawOutput !== undefined,
3009+
"schema.def_count": schemaDefsMap.size,
3010+
"schema.source_def_count": sourceDefsMap.size,
3011+
},
3012+
}),
3013+
);
30213014

30223015
return ToolSchema.make({
30233016
id: ToolId.make(opts.toolId),
@@ -3033,9 +3026,8 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
30333026
});
30343027
});
30353028

3036-
const toolSchema = (toolId: string, options?: ToolSchemaOptions) =>
3029+
const toolSchema = (toolId: string) =>
30373030
Effect.gen(function* () {
3038-
const includeTypeScript = options?.includeTypeScript ?? true;
30393031
// Static pool first — static tools have no source in the DB so
30403032
// no `$defs` attach; just wrap the declared schemas.
30413033
const staticEntry = staticTools.get(toolId);
@@ -3052,7 +3044,6 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
30523044
sourceId: undefined,
30533045
rawInput: toToolJsonSchema(staticEntry.tool.inputSchema),
30543046
rawOutput: toToolJsonSchema(staticEntry.tool.outputSchema, "output"),
3055-
includeTypeScript,
30563047
});
30573048
}
30583049
// Innermost-wins lookup across every visible scope.
@@ -3075,7 +3066,6 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
30753066
sourceId: row.source_id,
30763067
rawInput: decodeJsonColumn(row.input_schema),
30773068
rawOutput: decodeJsonColumn(row.output_schema),
3078-
includeTypeScript,
30793069
});
30803070
}).pipe(
30813071
Effect.withSpan("executor.tool.schema", {

packages/core/sdk/src/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ export const ToolSchema = Schema.Struct({
8484
});
8585
export type ToolSchema = typeof ToolSchema.Type;
8686

87-
export interface ToolSchemaOptions {
88-
/** Include TypeScript preview strings. Defaults to true for SDK callers. */
89-
readonly includeTypeScript?: boolean;
90-
}
91-
9287
// ---------------------------------------------------------------------------
9388
// Source detection — optional capability on `PluginSpec.detect`. When a
9489
// user pastes a URL in the onboarding UI, `executor.sources.detect(url)`

packages/react/src/api/atoms.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const sourceToolsAtom = (sourceId: string, scopeId: ScopeId) =>
4242
export const toolSchemaAtom = (scopeId: ScopeId, toolId: ToolId) =>
4343
ExecutorApiClient.query("tools", "schema", {
4444
params: { scopeId, toolId },
45-
query: { includeTypeScript: "true" },
4645
timeToLive: "1 minute",
4746
reactivityKeys: [ReactivityKey.tools],
4847
});

0 commit comments

Comments
 (0)