poe-code 3.0.380 → 3.0.382
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/packages/toolcraft-openapi/dist/generate.js +64 -13
- package/packages/toolcraft-openapi/dist/generated-client-entrypoints.compile-check.d.ts +1 -0
- package/packages/toolcraft-openapi/dist/generated-client-entrypoints.compile-check.js +40 -0
- package/packages/toolcraft-openapi/dist/generated-manual-wiring.compile-check.d.ts +4 -0
- package/packages/toolcraft-openapi/dist/generated-manual-wiring.compile-check.js +32 -0
package/package.json
CHANGED
|
@@ -124,13 +124,12 @@ export function generate(document, options) {
|
|
|
124
124
|
return [
|
|
125
125
|
...commands.map((command) => ({
|
|
126
126
|
path: command.filePath,
|
|
127
|
-
contents: createCommandFile(
|
|
128
|
-
specSha: options.specSha,
|
|
129
|
-
...command
|
|
130
|
-
})
|
|
127
|
+
contents: createCommandFile(command)
|
|
131
128
|
})),
|
|
132
129
|
createIndexFile(commands),
|
|
133
|
-
|
|
130
|
+
createClientFile(),
|
|
131
|
+
createCliFile({ brand, label }),
|
|
132
|
+
createMcpFile()
|
|
134
133
|
];
|
|
135
134
|
}
|
|
136
135
|
export function collectGeneratedCommands(document, config) {
|
|
@@ -1486,10 +1485,7 @@ function createCommandFile(options) {
|
|
|
1486
1485
|
...(usesMultipartFileInputs ? ["prepareMultipartFileInputs"] : []),
|
|
1487
1486
|
...(usesBinaryOutput ? ["writeBinaryResponseOutput"] : [])
|
|
1488
1487
|
];
|
|
1489
|
-
const lines = createGeneratedTypeScriptFileLines([
|
|
1490
|
-
`spec-sha: ${options.specSha}`,
|
|
1491
|
-
`operation-id: ${options.operationId}`
|
|
1492
|
-
]);
|
|
1488
|
+
const lines = createGeneratedTypeScriptFileLines([`operation-id: ${options.operationId}`]);
|
|
1493
1489
|
lines.push(requiresUserError
|
|
1494
1490
|
? 'import { S, UserError } from "toolcraft";'
|
|
1495
1491
|
: 'import { S } from "toolcraft";', `import { ${openApiImports.join(", ")} } from "toolcraft-openapi";`, "", `export const ${options.exportName} = defineApiCommand({`, ` name: ${JSON.stringify(options.verb)},`);
|
|
@@ -1849,18 +1845,73 @@ function createIndexFile(commands) {
|
|
|
1849
1845
|
contents: lines.join("\n")
|
|
1850
1846
|
};
|
|
1851
1847
|
}
|
|
1848
|
+
function createClientFile() {
|
|
1849
|
+
return {
|
|
1850
|
+
path: "client.ts",
|
|
1851
|
+
contents: createGeneratedTypeScriptFile([
|
|
1852
|
+
'import { defineClient, type DefineClientOptions } from "toolcraft-openapi";',
|
|
1853
|
+
'import { generatedCommands } from "./index.js";',
|
|
1854
|
+
"",
|
|
1855
|
+
'export type GeneratedClientOptions = Omit<DefineClientOptions<object>, "commands">;',
|
|
1856
|
+
"",
|
|
1857
|
+
"export function defineGeneratedClient(options: GeneratedClientOptions) {",
|
|
1858
|
+
" return defineClient<object>({",
|
|
1859
|
+
" ...options,",
|
|
1860
|
+
" commands: [...generatedCommands],",
|
|
1861
|
+
" });",
|
|
1862
|
+
"}",
|
|
1863
|
+
""
|
|
1864
|
+
])
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1852
1867
|
function createCliFile(theme) {
|
|
1853
1868
|
return {
|
|
1854
1869
|
path: "cli.ts",
|
|
1855
1870
|
contents: [
|
|
1856
1871
|
"#!/usr/bin/env node",
|
|
1857
1872
|
...createGeneratedTypeScriptFileLines(),
|
|
1858
|
-
'import { configureTheme, runCLI } from "toolcraft/cli";',
|
|
1859
|
-
'import {
|
|
1873
|
+
'import { configureTheme, runCLI, type RunCLIOptions } from "toolcraft/cli";',
|
|
1874
|
+
'import type { OpenApiClientServices } from "toolcraft-openapi";',
|
|
1875
|
+
'import { defineGeneratedClient, type GeneratedClientOptions } from "./client.js";',
|
|
1876
|
+
"",
|
|
1877
|
+
"export type GeneratedCLIOptions = GeneratedClientOptions &",
|
|
1878
|
+
' Omit<RunCLIOptions<OpenApiClientServices>, "services">;',
|
|
1879
|
+
"",
|
|
1880
|
+
"export async function runGeneratedCLI(options: GeneratedCLIOptions) {",
|
|
1881
|
+
" const client = defineGeneratedClient(options);",
|
|
1882
|
+
` configureTheme({ brand: ${JSON.stringify(theme.brand)}, label: ${JSON.stringify(theme.label)} });`,
|
|
1883
|
+
"",
|
|
1884
|
+
" await runCLI(client.root, {",
|
|
1885
|
+
" ...options,",
|
|
1886
|
+
" services: client.services,",
|
|
1887
|
+
" });",
|
|
1888
|
+
"}",
|
|
1889
|
+
""
|
|
1890
|
+
].join("\n")
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
function createMcpFile() {
|
|
1894
|
+
return {
|
|
1895
|
+
path: "mcp.ts",
|
|
1896
|
+
contents: [
|
|
1897
|
+
"#!/usr/bin/env node",
|
|
1898
|
+
...createGeneratedTypeScriptFileLines(),
|
|
1899
|
+
'import { runMCP, type RunMCPOptions } from "toolcraft/mcp";',
|
|
1900
|
+
'import type { OpenApiClientServices } from "toolcraft-openapi";',
|
|
1901
|
+
'import { defineGeneratedClient, type GeneratedClientOptions } from "./client.js";',
|
|
1902
|
+
"",
|
|
1903
|
+
"export type GeneratedMCPOptions = GeneratedClientOptions &",
|
|
1904
|
+
' Omit<RunMCPOptions<OpenApiClientServices>, "name" | "services">;',
|
|
1860
1905
|
"",
|
|
1861
|
-
|
|
1906
|
+
"export async function runGeneratedMCP(options: GeneratedMCPOptions) {",
|
|
1907
|
+
" const client = defineGeneratedClient(options);",
|
|
1862
1908
|
"",
|
|
1863
|
-
"await
|
|
1909
|
+
" await runMCP(client.root, {",
|
|
1910
|
+
" ...options,",
|
|
1911
|
+
" name: client.name,",
|
|
1912
|
+
" services: client.services,",
|
|
1913
|
+
" });",
|
|
1914
|
+
"}",
|
|
1864
1915
|
""
|
|
1865
1916
|
].join("\n")
|
|
1866
1917
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { S, defineGroup } from "toolcraft";
|
|
2
|
+
import { runCLI } from "toolcraft/cli";
|
|
3
|
+
import { runMCP } from "toolcraft/mcp";
|
|
4
|
+
import { defineApiCommand, defineClient } from "./index.js";
|
|
5
|
+
const generatedCommands = [
|
|
6
|
+
defineGroup({
|
|
7
|
+
name: "widgets",
|
|
8
|
+
children: [
|
|
9
|
+
defineApiCommand({
|
|
10
|
+
name: "list",
|
|
11
|
+
scope: ["cli", "mcp", "sdk"],
|
|
12
|
+
params: S.Object({}),
|
|
13
|
+
handler: async () => ({ ok: true })
|
|
14
|
+
})
|
|
15
|
+
]
|
|
16
|
+
})
|
|
17
|
+
];
|
|
18
|
+
function defineGeneratedClient(options) {
|
|
19
|
+
return defineClient({
|
|
20
|
+
...options,
|
|
21
|
+
commands: [...generatedCommands]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async function runGeneratedCLI(options) {
|
|
25
|
+
const client = defineGeneratedClient(options);
|
|
26
|
+
await runCLI(client.root, {
|
|
27
|
+
...options,
|
|
28
|
+
services: client.services
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function runGeneratedMCP(options) {
|
|
32
|
+
const client = defineGeneratedClient(options);
|
|
33
|
+
await runMCP(client.root, {
|
|
34
|
+
...options,
|
|
35
|
+
name: client.name,
|
|
36
|
+
services: client.services
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
void runGeneratedCLI;
|
|
40
|
+
void runGeneratedMCP;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const generatedWidgetListCommand: import("../../toolcraft/dist/index.js").Command<import("./define-client.js").OpenApiClientServices, import("../../toolcraft/dist/index.js").ObjectSchema<{}>, undefined, unknown>;
|
|
2
|
+
export declare const widgets: import("../../toolcraft/dist/index.js").Group<import("./define-client.js").OpenApiClientServices> & {
|
|
3
|
+
readonly __agentKitGroupTypeInfo: import("../../toolcraft/dist/index.js").GroupTypeInfo<import("./define-client.js").OpenApiClientServices, "widgets", import("../../toolcraft/dist/index.js").Command<import("./define-client.js").OpenApiClientServices, import("../../toolcraft/dist/index.js").ObjectSchema<{}>, undefined, unknown>[], undefined, undefined>;
|
|
4
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { S, defineGroup } from "toolcraft";
|
|
2
|
+
import { bearerTokenAuth, defineApiCommand, defineClient } from "./index.js";
|
|
3
|
+
export const generatedWidgetListCommand = defineApiCommand({
|
|
4
|
+
name: "list",
|
|
5
|
+
scope: ["cli", "mcp", "sdk"],
|
|
6
|
+
params: S.Object({}),
|
|
7
|
+
handler: async () => ({ ok: true })
|
|
8
|
+
});
|
|
9
|
+
export const widgets = defineGroup({
|
|
10
|
+
name: "widgets",
|
|
11
|
+
children: [generatedWidgetListCommand]
|
|
12
|
+
});
|
|
13
|
+
const clientWithGeneratedGroup = defineClient({
|
|
14
|
+
name: "manual-group-client",
|
|
15
|
+
baseUrl: "https://api.example.com",
|
|
16
|
+
auth: bearerTokenAuth({
|
|
17
|
+
serviceName: "manual-group-client",
|
|
18
|
+
envVar: "MANUAL_GROUP_CLIENT_TOKEN"
|
|
19
|
+
}),
|
|
20
|
+
commands: [widgets]
|
|
21
|
+
});
|
|
22
|
+
const clientWithGeneratedLeaf = defineClient({
|
|
23
|
+
name: "manual-leaf-client",
|
|
24
|
+
baseUrl: "https://api.example.com",
|
|
25
|
+
auth: bearerTokenAuth({
|
|
26
|
+
serviceName: "manual-leaf-client",
|
|
27
|
+
envVar: "MANUAL_LEAF_CLIENT_TOKEN"
|
|
28
|
+
}),
|
|
29
|
+
commands: [generatedWidgetListCommand]
|
|
30
|
+
});
|
|
31
|
+
void clientWithGeneratedGroup;
|
|
32
|
+
void clientWithGeneratedLeaf;
|