@workerkit/core 0.3.5 → 0.3.7
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/CHANGELOG.md +35 -0
- package/README.md +1 -1
- package/dist/descriptors/decision-authoring.d.ts +53 -0
- package/dist/descriptors/decision-authoring.d.ts.map +1 -0
- package/dist/descriptors/decision-authoring.js +43 -0
- package/dist/descriptors/decision-authoring.js.map +1 -0
- package/dist/descriptors/decision-receipt.d.ts +3 -0
- package/dist/descriptors/decision-receipt.d.ts.map +1 -0
- package/dist/descriptors/decision-receipt.js +15 -0
- package/dist/descriptors/decision-receipt.js.map +1 -0
- package/dist/descriptors/directory.d.ts.map +1 -1
- package/dist/descriptors/directory.js +5 -7
- package/dist/descriptors/directory.js.map +1 -1
- package/dist/descriptors/index.d.ts +1 -1
- package/dist/descriptors/index.js +1 -1
- package/dist/descriptors/index.js.map +1 -1
- package/dist/descriptors/manage.d.ts.map +1 -1
- package/dist/descriptors/manage.js +10 -3
- package/dist/descriptors/manage.js.map +1 -1
- package/dist/descriptors/onboarding.d.ts +3 -0
- package/dist/descriptors/onboarding.d.ts.map +1 -0
- package/dist/descriptors/onboarding.js +55 -0
- package/dist/descriptors/onboarding.js.map +1 -0
- package/dist/descriptors/types.d.ts +6 -0
- package/dist/descriptors/types.d.ts.map +1 -1
- package/dist/descriptors/types.js.map +1 -1
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +7 -2
- package/dist/execute.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/descriptors/onboarding.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,qBAAqB,EAAE,SAAS,cAAc,EAmD1D,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "../zod.js";
|
|
2
|
+
import { READ_ONLY } from "./types.js";
|
|
3
|
+
export const onboardingDescriptors = [
|
|
4
|
+
{
|
|
5
|
+
name: "onboarding_get",
|
|
6
|
+
title: "Check onboarding requirements",
|
|
7
|
+
auth: "manager",
|
|
8
|
+
method: "get",
|
|
9
|
+
path: "/api/manage/onboarding",
|
|
10
|
+
schema: {
|
|
11
|
+
provider: z.string().max(40).optional().describe("Optional model provider to check."),
|
|
12
|
+
},
|
|
13
|
+
annotations: READ_ONLY,
|
|
14
|
+
description: "Read this credential’s scopes/expiry, account model-funding requirements and human-approved spendPolicy with remaining reserved allowance. No additional scope required. Agents cannot raise the account ceiling; it applies to scheduled and manual runs. If humanActionRequired is true, show the returned setup URL. The user enters provider keys on WorkerKit, never in chat. BYOK can still require wallet credits for platform fees and metered apps. After funding, check worker readiness, deploy and run; runtime guards remain authoritative.",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "wallet_get",
|
|
18
|
+
title: "Read wallet",
|
|
19
|
+
auth: "manager",
|
|
20
|
+
method: "get",
|
|
21
|
+
path: "/api/manage/wallet",
|
|
22
|
+
schema: {},
|
|
23
|
+
annotations: READ_ONLY,
|
|
24
|
+
description: "Read spendable wallet balance and checkout fee/amount limits. Requires readWallet. A wallet balance is not evidence that a particular checkout was credited; use wallet_checkout_get for that.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "wallet_checkout_create",
|
|
28
|
+
title: "Request wallet funding",
|
|
29
|
+
auth: "manager",
|
|
30
|
+
method: "post",
|
|
31
|
+
path: "/api/manage/wallet/checkouts",
|
|
32
|
+
schema: {
|
|
33
|
+
amountUsd: z.number().min(0.01).max(999999.99).multipleOf(0.01)
|
|
34
|
+
.describe("Credit amount in whole cents, before the returned platform fee. Read wallet_get for current purchase limits."),
|
|
35
|
+
idempotencyKey: z.string().min(1).max(200).regex(/^[\x21-\x7E]+$/)
|
|
36
|
+
.describe("Unique printable-ASCII purchase request ID. Reuse only for retries of the same amount."),
|
|
37
|
+
},
|
|
38
|
+
bodyBuilder: (params) => ({ amountUsd: params.amountUsd }),
|
|
39
|
+
headerBuilder: (params) => ({ "Idempotency-Key": String(params.idempotencyKey) }),
|
|
40
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
41
|
+
description: "Create a Stripe Checkout link for a specific wallet credit purchase. Requires requestWalletTopUp. Show the credit, fee and total and ask the user to open checkout and confirm payment. Never ask for card details or charge a saved card. Poll wallet_checkout_get after payment; only credited confirms funds reached the ledger. Reuse idempotencyKey for retries, never a different amount.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "wallet_checkout_get",
|
|
45
|
+
title: "Check wallet payment",
|
|
46
|
+
auth: "manager",
|
|
47
|
+
method: "get",
|
|
48
|
+
path: (params) => `/api/manage/wallet/checkouts/${encodeURIComponent(String(params.sessionId))}`,
|
|
49
|
+
paramFilter: () => ({}),
|
|
50
|
+
schema: { sessionId: z.string().min(1).max(255) },
|
|
51
|
+
annotations: READ_ONLY,
|
|
52
|
+
description: "Check pending, paid_pending_credit, credited or expired checkout status. Requires readWallet, or requestWalletTopUp for a checkout created by this credential. Only credited means the wallet ledger has committed. Wait at least five seconds between checks; stop on credited or expired and use bounded waits for delayed payment.",
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../src/descriptors/onboarding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAuB,MAAM,YAAY,CAAC;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAA8B;IAC9D;QACE,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,+BAA+B;QACtC,IAAI,EAAE,SAAS;QACf,MAAM,EA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AK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;QACvG,WAAW,EAAE,iYAAiY;KAC/Y;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,sBAAsB;QAC7B,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,gCAAgC,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;QAChG,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;QACvB,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACjD,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,uUAAuU;KACrV;CACF,CAAC","sourcesContent":["import { z } from \"../zod.js\";\nimport { READ_ONLY, type ToolDescriptor } from \"./types.js\";\n\nexport const onboardingDescriptors: readonly ToolDescriptor[] = [\n {\n name: \"onboarding_get\",\n title: \"Check onboarding requirements\",\n auth: \"manager\",\n method: \"get\",\n path: \"/api/manage/onboarding\",\n schema: {\n provider: z.string().max(40).optional().describe(\"Optional model provider to check.\"),\n },\n annotations: READ_ONLY,\n description: \"Read this credential’s scopes/expiry, account model-funding requirements and human-approved spendPolicy with remaining reserved allowance. No additional scope required. Agents cannot raise the account ceiling; it applies to scheduled and manual runs. If humanActionRequired is true, show the returned setup URL. The user enters provider keys on WorkerKit, never in chat. BYOK can still require wallet credits for platform fees and metered apps. After funding, check worker readiness, deploy and run; runtime guards remain authoritative.\",\n },\n {\n name: \"wallet_get\",\n title: \"Read wallet\",\n auth: \"manager\",\n method: \"get\",\n path: \"/api/manage/wallet\",\n schema: {},\n annotations: READ_ONLY,\n description: \"Read spendable wallet balance and checkout fee/amount limits. Requires readWallet. A wallet balance is not evidence that a particular checkout was credited; use wallet_checkout_get for that.\",\n },\n {\n name: \"wallet_checkout_create\",\n title: \"Request wallet funding\",\n auth: \"manager\",\n method: \"post\",\n path: \"/api/manage/wallet/checkouts\",\n schema: {\n amountUsd: z.number().min(0.01).max(999999.99).multipleOf(0.01)\n .describe(\"Credit amount in whole cents, before the returned platform fee. Read wallet_get for current purchase limits.\"),\n idempotencyKey: z.string().min(1).max(200).regex(/^[\\x21-\\x7E]+$/)\n .describe(\"Unique printable-ASCII purchase request ID. Reuse only for retries of the same amount.\"),\n },\n bodyBuilder: (params) => ({ amountUsd: params.amountUsd }),\n headerBuilder: (params) => ({ \"Idempotency-Key\": String(params.idempotencyKey) }),\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },\n description: \"Create a Stripe Checkout link for a specific wallet credit purchase. Requires requestWalletTopUp. Show the credit, fee and total and ask the user to open checkout and confirm payment. Never ask for card details or charge a saved card. Poll wallet_checkout_get after payment; only credited confirms funds reached the ledger. Reuse idempotencyKey for retries, never a different amount.\",\n },\n {\n name: \"wallet_checkout_get\",\n title: \"Check wallet payment\",\n auth: \"manager\",\n method: \"get\",\n path: (params) => `/api/manage/wallet/checkouts/${encodeURIComponent(String(params.sessionId))}`,\n paramFilter: () => ({}),\n schema: { sessionId: z.string().min(1).max(255) },\n annotations: READ_ONLY,\n description: \"Check pending, paid_pending_credit, credited or expired checkout status. Requires readWallet, or requestWalletTopUp for a checkout created by this credential. Only credited means the wallet ledger has committed. Wait at least five seconds between checks; stop on credited or expired and use bounded waits for delayed payment.\",\n },\n];\n"]}
|
|
@@ -33,6 +33,10 @@ export interface ToolDescriptor {
|
|
|
33
33
|
method: HttpMethod;
|
|
34
34
|
/** Single source for the MCP inputSchema AND future CLI flags. */
|
|
35
35
|
schema: z.ZodRawShape;
|
|
36
|
+
/** Reject unknown top-level inputs instead of silently dropping unsupported controls. */
|
|
37
|
+
strictInput?: boolean;
|
|
38
|
+
/** Structured success result. MCP adapters retain a serialized text fallback. */
|
|
39
|
+
outputSchema?: z.ZodRawShape;
|
|
36
40
|
/** Upstream path, or a builder over the validated params. */
|
|
37
41
|
path: string | ((params: Record<string, unknown>) => string);
|
|
38
42
|
/**
|
|
@@ -45,6 +49,8 @@ export interface ToolDescriptor {
|
|
|
45
49
|
* params object is the body. DELETE requests never send a body either way.
|
|
46
50
|
*/
|
|
47
51
|
bodyBuilder?: (params: Record<string, unknown>) => unknown;
|
|
52
|
+
/** Headers derived from typed inputs, e.g. a checkout idempotency key. */
|
|
53
|
+
headerBuilder?: (params: Record<string, unknown>) => Record<string, string>;
|
|
48
54
|
/** Mutations: message served on an empty (204) success body. */
|
|
49
55
|
successMessage?: string;
|
|
50
56
|
annotations: ToolAnnotations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/descriptors/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAE9B,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAMD,eAAO,MAAM,SAAS,EAAE,eAAsF,CAAC;AAC/G,eAAO,MAAM,MAAM,EAAE,eAAuF,CAAC;AAC7G,eAAO,MAAM,MAAM,EAAE,eAA6G,CAAC;AACnI,eAAO,MAAM,MAAM,EAAE,eAAsF,CAAC;AAI5G,eAAO,MAAM,OAAO,EAAE,eAAsF,CAAC;AAE7G;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,kFAA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CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,eAAe,CAAC;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IACtE;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;CACjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/descriptors/types.ts"],"names":[],"mappings":"AAiBA,gFAAgF;AAChF,mFAAmF;AACnF,oDAAoD;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAoB,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC/G,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC7G,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AACnI,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC5G,kFAAkF;AAClF,kFAAkF;AAClF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import { z } from \"../zod.js\";\n\nexport type HttpMethod = \"get\" | \"post\" | \"patch\" | \"put\" | \"delete\";\n\n/**\n * MCP-style behavior hints. Kept structurally identical to the MCP spec's\n * ToolAnnotations (minus display title, which is presentation) so an MCP\n * server can spread these straight into a tool registration — but this module\n * has no MCP dependency; a CLI can read them as plain capability flags.\n */\nexport interface ToolAnnotations {\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\n\n// ─── Annotation presets ──────────────────────────────────────────────────────\n// Every tool carries one. Clients read them to decide what may run unattended, and\n// MCP directory listings expect them to be present.\n\nexport const READ_ONLY: ToolAnnotations = { readOnlyHint: true, destructiveHint: false, openWorldHint: false };\nexport const CREATE: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };\nexport const UPDATE: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };\nexport const DELETE: ToolAnnotations = { readOnlyHint: false, destructiveHint: true, openWorldHint: false };\n// Triggering a worker run causes real-world side effects through the worker's own\n// tools (it may send email, edit CRM rows, …) — openWorld, but not destructive to\n// WorkerKit state itself.\nexport const TRIGGER: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, openWorldHint: true };\n\n/**\n * One tool, described declaratively: what it is called, what it teaches the\n * agent, and exactly how its parameters map onto one upstream HTTP request.\n * This is the single source of truth consumed by the MCP server (inputSchema,\n * annotations, wire call via executeTool) and by any future surface (CLI\n * flags, docs) — wire construction exists exactly once, in executeTool.\n */\nexport interface ToolDescriptor {\n name: string;\n title: string;\n description: string;\n /** \"manager\" tools require a bearer; \"anonymous\" tools must never forward one. */\n auth: \"manager\" | \"anonymous\";\n method: HttpMethod;\n /** Single source for the MCP inputSchema AND future CLI flags. */\n schema: z.ZodRawShape;\n /** Upstream path, or a builder over the validated params. */\n path: string | ((params: Record<string, unknown>) => string);\n /**\n * GET only: maps tool params to query params (typically stripping the ones\n * already consumed by the path builder). Omitted = all params pass through.\n */\n paramFilter?: (params: Record<string, unknown>) => Record<string, unknown>;\n /**\n * Mutations only: builds the JSON body from the params. Omitted = the raw\n * params object is the body. DELETE requests never send a body either way.\n */\n bodyBuilder?: (params: Record<string, unknown>) => unknown;\n /** Mutations: message served on an empty (204) success body. */\n successMessage?: string;\n annotations: ToolAnnotations;\n /**\n * Pure success-data transform (e.g. computed pageUrl injection). Returning\n * `undefined` means \"unexpected shape — serve the upstream body verbatim\";\n * the consumer then falls back to its plain formatting path.\n */\n mapData?: (data: unknown, params: Record<string, unknown>) => unknown;\n /**\n * Agent-guidance footer for a successful result (empty-result hints,\n * next-page pointers, omitted-bodies notes). Receives the mapData output.\n * How the footer is rendered (e.g. bracketed, appended) is the consumer's\n * presentation decision.\n */\n footer?: (data: unknown, params: Record<string, unknown>) => string | undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/descriptors/types.ts"],"names":[],"mappings":"AAiBA,gFAAgF;AAChF,mFAAmF;AACnF,oDAAoD;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAoB,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC/G,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC7G,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AACnI,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC5G,kFAAkF;AAClF,kFAAkF;AAClF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import { z } from \"../zod.js\";\n\nexport type HttpMethod = \"get\" | \"post\" | \"patch\" | \"put\" | \"delete\";\n\n/**\n * MCP-style behavior hints. Kept structurally identical to the MCP spec's\n * ToolAnnotations (minus display title, which is presentation) so an MCP\n * server can spread these straight into a tool registration — but this module\n * has no MCP dependency; a CLI can read them as plain capability flags.\n */\nexport interface ToolAnnotations {\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\n\n// ─── Annotation presets ──────────────────────────────────────────────────────\n// Every tool carries one. Clients read them to decide what may run unattended, and\n// MCP directory listings expect them to be present.\n\nexport const READ_ONLY: ToolAnnotations = { readOnlyHint: true, destructiveHint: false, openWorldHint: false };\nexport const CREATE: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };\nexport const UPDATE: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };\nexport const DELETE: ToolAnnotations = { readOnlyHint: false, destructiveHint: true, openWorldHint: false };\n// Triggering a worker run causes real-world side effects through the worker's own\n// tools (it may send email, edit CRM rows, …) — openWorld, but not destructive to\n// WorkerKit state itself.\nexport const TRIGGER: ToolAnnotations = { readOnlyHint: false, destructiveHint: false, openWorldHint: true };\n\n/**\n * One tool, described declaratively: what it is called, what it teaches the\n * agent, and exactly how its parameters map onto one upstream HTTP request.\n * This is the single source of truth consumed by the MCP server (inputSchema,\n * annotations, wire call via executeTool) and by any future surface (CLI\n * flags, docs) — wire construction exists exactly once, in executeTool.\n */\nexport interface ToolDescriptor {\n name: string;\n title: string;\n description: string;\n /** \"manager\" tools require a bearer; \"anonymous\" tools must never forward one. */\n auth: \"manager\" | \"anonymous\";\n method: HttpMethod;\n /** Single source for the MCP inputSchema AND future CLI flags. */\n schema: z.ZodRawShape;\n /** Reject unknown top-level inputs instead of silently dropping unsupported controls. */\n strictInput?: boolean;\n /** Structured success result. MCP adapters retain a serialized text fallback. */\n outputSchema?: z.ZodRawShape;\n /** Upstream path, or a builder over the validated params. */\n path: string | ((params: Record<string, unknown>) => string);\n /**\n * GET only: maps tool params to query params (typically stripping the ones\n * already consumed by the path builder). Omitted = all params pass through.\n */\n paramFilter?: (params: Record<string, unknown>) => Record<string, unknown>;\n /**\n * Mutations only: builds the JSON body from the params. Omitted = the raw\n * params object is the body. DELETE requests never send a body either way.\n */\n bodyBuilder?: (params: Record<string, unknown>) => unknown;\n /** Headers derived from typed inputs, e.g. a checkout idempotency key. */\n headerBuilder?: (params: Record<string, unknown>) => Record<string, string>;\n /** Mutations: message served on an empty (204) success body. */\n successMessage?: string;\n annotations: ToolAnnotations;\n /**\n * Pure success-data transform (e.g. computed pageUrl injection). Returning\n * `undefined` means \"unexpected shape — serve the upstream body verbatim\";\n * the consumer then falls back to its plain formatting path.\n */\n mapData?: (data: unknown, params: Record<string, unknown>) => unknown;\n /**\n * Agent-guidance footer for a successful result (empty-result hints,\n * next-page pointers, omitted-bodies notes). Receives the mapData output.\n * How the footer is rendered (e.g. bracketed, appended) is the consumer's\n * presentation decision.\n */\n footer?: (data: unknown, params: Record<string, unknown>) => string | undefined;\n}\n"]}
|
package/dist/execute.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,SAAS,CAAC,CAyBpB"}
|
package/dist/execute.js
CHANGED
|
@@ -6,18 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export async function executeTool(client, descriptor, params, opts = {}) {
|
|
8
8
|
const resolvedPath = typeof descriptor.path === "function" ? descriptor.path(params) : descriptor.path;
|
|
9
|
+
// Discovery stays anonymous even when a caller shares its authenticated client context.
|
|
10
|
+
const token = descriptor.auth === "manager" ? opts.token : undefined;
|
|
11
|
+
const extra = descriptor.headerBuilder ? { headers: descriptor.headerBuilder(params) } : {};
|
|
9
12
|
if (descriptor.method === "get") {
|
|
10
13
|
// Strip path params from query params
|
|
11
14
|
const queryParams = descriptor.paramFilter ? descriptor.paramFilter(params) : { ...params };
|
|
12
15
|
return client.get(resolvedPath, {
|
|
13
|
-
|
|
16
|
+
...extra,
|
|
17
|
+
token,
|
|
14
18
|
params: queryParams,
|
|
15
19
|
signal: opts.signal,
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
const body = descriptor.bodyBuilder ? descriptor.bodyBuilder(params) : params;
|
|
19
23
|
return client[descriptor.method](resolvedPath, {
|
|
20
|
-
|
|
24
|
+
...extra,
|
|
25
|
+
token,
|
|
21
26
|
body: descriptor.method !== "delete" ? body : undefined,
|
|
22
27
|
signal: opts.signal,
|
|
23
28
|
});
|
package/dist/execute.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,UAA0B,EAC1B,MAA+B,EAC/B,OAAwB,EAAE;IAE1B,MAAM,YAAY,GAChB,OAAO,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,UAA0B,EAC1B,MAA+B,EAC/B,OAAwB,EAAE;IAE1B,MAAM,YAAY,GAChB,OAAO,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;IACpF,wFAAwF;IACxF,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5F,IAAI,UAAU,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAChC,sCAAsC;QACtC,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;QAC5F,OAAO,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE;YAC9B,GAAG,KAAK;YACR,KAAK;YACL,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9E,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE;QAC7C,GAAG,KAAK;QACR,KAAK;QACL,IAAI,EAAE,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACvD,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ApiResult, PortEdenClient } from \"./client.js\";\nimport type { ToolDescriptor } from \"./descriptors/types.js\";\n\nexport interface ExecuteToolOpts {\n /** Bearer forwarded upstream. Omit for anonymous descriptors. */\n token?: string;\n signal?: AbortSignal;\n}\n\n/**\n * The ONE place a descriptor becomes a wire call: resolves the path, applies\n * paramFilter (GET query) or bodyBuilder (mutations), and dispatches to the\n * client. Every consumer (MCP server, CLI) goes through here, so the wire\n * contract each tool produces exists exactly once.\n */\nexport async function executeTool(\n client: PortEdenClient,\n descriptor: ToolDescriptor,\n params: Record<string, unknown>,\n opts: ExecuteToolOpts = {}\n): Promise<ApiResult> {\n const resolvedPath =\n typeof descriptor.path === \"function\" ? descriptor.path(params) : descriptor.path;\n // Discovery stays anonymous even when a caller shares its authenticated client context.\n const token = descriptor.auth === \"manager\" ? opts.token : undefined;\n const extra = descriptor.headerBuilder ? { headers: descriptor.headerBuilder(params) } : {};\n\n if (descriptor.method === \"get\") {\n // Strip path params from query params\n const queryParams = descriptor.paramFilter ? descriptor.paramFilter(params) : { ...params };\n return client.get(resolvedPath, {\n ...extra,\n token,\n params: queryParams,\n signal: opts.signal,\n });\n }\n\n const body = descriptor.bodyBuilder ? descriptor.bodyBuilder(params) : params;\n return client[descriptor.method](resolvedPath, {\n ...extra,\n token,\n body: descriptor.method !== \"delete\" ? body : undefined,\n signal: opts.signal,\n });\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @workerkit/core — the shareable WorkerKit surface: the HTTP client, the
|
|
2
|
-
// tool-descriptor registry (
|
|
2
|
+
// tool-descriptor registry (84 manager + 9 anonymous directory tools), the
|
|
3
3
|
// single wire-execution path, and the pure formatting/redaction helpers.
|
|
4
4
|
// Deliberately MCP-free: MCP (or CLI) presentation lives with the consumer.
|
|
5
5
|
export { PortEdenClient, WorkerKitClient, ResponseTooLargeError, } from "./client.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAE5E,OAAO,EACL,cAAc,EACd,eAAe,EACf,qBAAqB,GACtB,MAAM,aAAa,CAAC;AASrB,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC","sourcesContent":["// @workerkit/core — the shareable WorkerKit surface: the HTTP client, the\n// tool-descriptor registry (
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAE5E,OAAO,EACL,cAAc,EACd,eAAe,EACf,qBAAqB,GACtB,MAAM,aAAa,CAAC;AASrB,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC","sourcesContent":["// @workerkit/core — the shareable WorkerKit surface: the HTTP client, the\n// tool-descriptor registry (84 manager + 9 anonymous directory tools), the\n// single wire-execution path, and the pure formatting/redaction helpers.\n// Deliberately MCP-free: MCP (or CLI) presentation lives with the consumer.\n\nexport {\n PortEdenClient,\n WorkerKitClient,\n ResponseTooLargeError,\n} from \"./client.js\";\nexport type {\n ApiResult,\n ClientLogger,\n ClientOptions,\n QuotaInfo,\n RequestOpts,\n} from \"./client.js\";\n\nexport * from \"./descriptors/index.js\";\n\nexport { executeTool } from \"./execute.js\";\nexport type { ExecuteToolOpts } from \"./execute.js\";\n\nexport { isSuccess, quotaSuffix, retryAfterSuffix } from \"./errors.js\";\n\nexport { SECRET_PATTERNS, scrubSecrets } from \"./redact.js\";\n\nexport { z } from \"./zod.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workerkit/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "API client and tool descriptors for WorkerKit: manage AI workers and browse the public kits directory",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "22.20.1",
|
|
60
60
|
"typescript": "5.9.3",
|
|
61
|
-
"vitest": "
|
|
61
|
+
"vitest": "4.1.11"
|
|
62
62
|
}
|
|
63
63
|
}
|