@workerkit/core 0.3.20 → 0.3.22

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 CHANGED
@@ -6,6 +6,39 @@ and the package adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.22] - 2026-10-29
10
+
11
+ ### Changed
12
+
13
+ - `action_worker_options` without `app` returns the app inventory only, and `action_worker_create` requires an explicit `app` or `actionSpec`: there is no implicit app or hidden starter tool set. Slack prerequisites apply only to selected Slack tools, `app: customApi` returns setup metadata rather than selectable tools, and the README describes the same inventory-first flow.
14
+ - `worker_tools` reports `invocationSource`, `effect`, `idempotencyRequired`, `keyFormat`, `workerCallsSupported` and `invocationManagerScopes` for each tool. `worker_tool_call`, its `idempotencyKey` parameter and `worker_tool_invocation` describe the key and receipt rules per source: native and MCP writes need a unique key and their reads none, while every private API operation, including reads, needs `managePrivateApiApps` with `invokeActions` and a `v1:<Unix timestamp>:<32-hex UUID>` key and leaves a receipt. Reusing a key with identical arguments replays the journal and never resends.
15
+ - The workers, decision and directory instructions and the `kit_authoring_guide` description are shorter and separate advice, simple creation and custom drafting: fetch only the relevant `kit_authoring_guide` sections and per-app `kit_vocabulary` and `kit_app_tools` reads, reuse unchanged help, and treat the Manager tool list as management rather than the worker's business-app inventory. `workerkit_about` serves missing product context rather than a mandatory first read.
16
+ - `kit_app_tools`, `kit_vocabulary` and `kit_validate` say that `purpose: decision` returns three shortcut recipes rather than a source ceiling, that `requires` is one operation-gate contribution rather than full authorization, that `canPublish` checks validity rather than whether grants fit the job, and that `effectivePermissions` and `defaultedApps` need review because defaults may include writes. `decision_worker_create` says that recipes are shortcuts to the general catalog and that `confidenceFloor` is a routing threshold which never replaces labels with `unclear`.
17
+ - The kit `content` description says that an Action kit needs an explicit `actionSpec`, that Language kits may set `apps: []`, that explicit `apps` are preferred because `appCodes` defaults may grant writes, that one kit installs one worker and that `recommendedKit` installs nothing. `worker_permissions_set` says that `apps` is the native app set, that private API bindings stay on the dashboard with MCP tool bindings, and never to send `mcp:<slug>` entries. Kit references and `kit_install.githubSelection` no longer mention legacy numeric ids or a legacy single-account fallback.
18
+
19
+ ## [0.3.21] - 2026-10-29
20
+
21
+ ### Added
22
+
23
+ - Company Knowledge: `knowledge_sources` discovers the workers whose retained reports a key may read, `knowledge_search` runs a deterministic lexical search or browses by filters, `knowledge_get` reads complete versioned report or structured content with offset continuation, and `knowledge_changes` reconciles new, corrected and withdrawn outputs through a durable cursor. All four require the new `readKnowledge` scope. Retrieval returns retained reports only, never app data, transcripts or a worker run.
24
+ - `knowledge_configuration_get` and `knowledge_configuration_set` read and replace activation, enrolled sources, structured-output publication, history start and reader grants. They require the new `manageKnowledge` scope, account administrator authority and an unrestricted credential. Existing keys gain neither scope without explicit re-scoping.
25
+ - The `knowledge` profile serves those six tools for the dedicated Knowledge MCP mount, with its own instructions; the workers and decision profiles do not carry them. The backend contract gains the `KNOWLEDGE-01` coverage rule for evidence, cursor and configuration guidance.
26
+ - `kit_install`, `decision_worker_create` and `action_worker_create` results carry creation guidance: show `workerUrl`, follow `setupActions` (each with a message, the apps involved and a URL or next tool), resolve blocked or unknown readiness before `nextCall`, and treat a saved worker as unproven until it runs. The `decision_worker_create` output schema declares `connectAppsUrl` and `setupActions`.
27
+ - `workerkit_about` joins the decision profile, which now serves 25 tools, so a compact connection can explain WorkerKit and lead a user into a first worker.
28
+
29
+ ### Changed
30
+
31
+ - `mcp_server_discover` is titled Refresh MCP Server Tools and says that it changes the saved tool catalog from upstream and is for the creator or an account Admin; `mcp_server_get` is the saved read. `mcp_server_create` explains that initial discovery is included when credentials are available or no authentication is needed, so a successful registration needs no second refresh.
32
+ - `app_connect` reports failed MCP discovery after credential storage as a nonfatal warning and says that only new account MCP apps need `mcp_server_create`. `apps_list` points to `api_apps_list` for API apps and to `mcp_servers_list` for unpublished own servers.
33
+ - The Workers REST instructions describe the Company Knowledge scopes and tools and where their MCP mount lives, describe the product as Decision, Language and Action workers chained into workflows, and say that the spec includes the anonymous discovery reads.
34
+ - Management descriptions open with the key_info preflight: call it before the session's first management call, verify scopes and worker reach, and treat the user's request as never expanding credential authority. The manager and decision instructions lead with the same rule and with first-job help.
35
+ - `workerkit_about` and its `section` parameter lead the user into a first worker and point creation at the authenticated Workers tools; the directory instructions do the same.
36
+ - `action_worker_options`, `action_worker_create` and `kit_install_preview` say that Slack tools need an active fixed bot and that creation must not be submitted without one, while ordinary missing app connections can be resolved after creation. `worker_deploy` says that deployment never requests a manual run and that a failed deployment saves none of its model or ceilings; `account_usage` says that wallet balance alone is not readiness; `worker_get` names the `personal_connection_not_shared` readiness issue; `mcp_server_create` asks to check `apps_list` and `mcp_servers_list` for an app that already covers the job.
37
+
38
+ ### Security
39
+
40
+ - Update `undici` to 7.30.1, which fixes a TLS certificate validation bypass when `Agent` drops TLS options, cache poisoning and cross-user disclosure through cross-origin redirects, and several denial-of-service issues in the HTTP client (GHSA-2m5v-pch6-74hx, GHSA-4w7w-5xrc-9h26 and related advisories).
41
+
9
42
  ## [0.3.20] - 2026-10-21
10
43
 
11
44
  ### Added
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![license](https://img.shields.io/npm/l/%40workerkit%2Fcore.svg)](LICENSE)
7
7
 
8
8
  The [WorkerKit](https://workerkit.ai) API client and tool registry for Node.js.
9
- It provides 115 authenticated management tools, 8 anonymous directory tools,
9
+ It provides 121 authenticated management tools, 8 anonymous directory tools,
10
10
  and a shared execution engine for their HTTP requests.
11
11
 
12
12
  Descriptors include agent guidance, annotations and Zod input schemas. MCP
@@ -157,27 +157,35 @@ there is no preview mode, and unsupported run controls, including those in
157
157
 
158
158
  An Action worker exposes explicitly selected, typed app tools that a caller
159
159
  invokes directly, without a reasoning model or a hosted deployment.
160
- `action_worker_options` lists the native and reviewed MCP apps, their tool
161
- schemas and the server's defaults. Creating one with `action_worker_create` and
162
- an `app` copies that app's default tools once; an explicit `actionSpec` can
163
- instead select up to 64 tools across apps. Omitting `app` selects Slack, and
164
- tools added to the catalog later must be selected by hand.
160
+ `action_worker_options` without `app` returns the app inventory only; with an
161
+ `app` it returns that app's reviewed tool schemas, defaults and connection
162
+ requirements. There is no implicit app: `action_worker_create` needs either an
163
+ `app`, which copies that app's reviewed defaults once, or an explicit
164
+ `actionSpec` that selects up to 64 tools across apps. Private API operations
165
+ are not selectable through `app` or `actionSpec`; their bindings are managed
166
+ in the dashboard. Tools added to the catalog later must be selected by hand.
165
167
 
166
168
  Read a worker's tool schemas with `worker_tools` before calling one with
167
169
  `worker_tool_call`, which takes `tokenId`, `toolName`, `arguments` and an
168
- optional `contractVersion: 1` and `idempotencyKey`. The key travels in the
169
- `Idempotency-Key` header; only the version and arguments go in the body. Give
170
- each intended write its own key and keep it for transport retries. Poll
170
+ optional `contractVersion: 1` and `idempotencyKey`. Each tool reports
171
+ `invocationSource`, `effect`, `idempotencyRequired` and `keyFormat`; follow
172
+ those rather than inferring from `readOnly`. The key travels in the
173
+ `Idempotency-Key` header; only the version and arguments go in the body.
174
+ Native and MCP writes need a unique key per intended write and their reads
175
+ need none; every private API operation, including reads, needs a
176
+ `v1:<Unix timestamp>:<32-hex UUID>` key. Keep a key for transport retries. Poll
171
177
  `worker_tool_invocation` for pending results, and never automatically resend
172
178
  an `outcome_unknown` call with a new key: the app may already have acted. A
173
179
  refusal marked `retryable` can be tried again later under a new key. A call
174
180
  cannot change the saved tool selection, connection or sender, and a
175
- changed tool contract needs an explicit owner review and save. Generic write
176
- receipts keep the confirmation without storing private app response bodies.
181
+ changed tool contract needs an explicit owner review and save. Native and MCP
182
+ write receipts keep the confirmation without storing private app response
183
+ bodies.
177
184
 
178
185
  A call answers with `status` `succeeded`, `denied`, `failed`, `in_progress` or
179
- `outcome_unknown`, plus `invocationId` on a write (reads leave no receipt).
180
- Repeating a write's key with the same arguments returns the stored receipt
186
+ `outcome_unknown`, plus `invocationId` on a native or MCP write and on every
187
+ private API call; native and MCP reads leave no receipt.
188
+ Repeating a key with the same arguments returns the stored receipt
181
189
  without calling the app again; the same key with different arguments is a 409
182
190
  `idempotency_conflict`.
183
191
 
@@ -260,6 +268,12 @@ owner dashboard, which also holds paid comparisons, diagnosis, monitoring and
260
268
  apply/rollback. Improvements change instruction text only; shadow learning
261
269
  does not train model weights. These tools are on the full profile.
262
270
 
271
+ ## Company knowledge
272
+
273
+ The Knowledge descriptors expose source discovery, lexical search/browse, complete versioned content reads and change reconciliation. `toolsForProfile("knowledge")` returns the six of them for the dedicated Knowledge MCP mount; the workers and decision profiles do not carry them. Use `knowledge_sources`, `knowledge_search`, `knowledge_get` and `knowledge_changes` with `readKnowledge`. The service enforces current account, publication, audience and credential limits. `knowledge_configuration_get` and `knowledge_configuration_set` require `manageKnowledge`, account administrator authority and an unrestricted credential.
274
+
275
+ Query planning and synthesis belong to the consuming agent. Empty queries browse; changed or revoked evidence requires citation/cache reconciliation. Retrieval does not invoke a model or grant live source-app access.
276
+
263
277
  ## Development
264
278
 
265
279
  ```bash
@@ -1,6 +1,6 @@
1
1
  export declare const backendContractProvenance: {
2
2
  readonly sourceRepository: "workerkit-backend";
3
3
  readonly contractVersion: "1.0.0";
4
- readonly sourceRevision: "1953496c8dff09fab24d19661457faa600f2af64";
5
- readonly contentHash: "c6a74062d1063233f9040971ddaea5e2fdb38248b929257eaaa008c3800b9b4a";
4
+ readonly sourceRevision: "d02f1a22e7914cd568446798fd9c2bb0dcb72b6f";
5
+ readonly contentHash: "08db2eaeda15ed171a5b96d9eb76304aa2a8c1cdc55b118e1fa6e3a26303d5dc";
6
6
  };
@@ -2,7 +2,7 @@
2
2
  export const backendContractProvenance = {
3
3
  "sourceRepository": "workerkit-backend",
4
4
  "contractVersion": "1.0.0",
5
- "sourceRevision": "1953496c8dff09fab24d19661457faa600f2af64",
6
- "contentHash": "c6a74062d1063233f9040971ddaea5e2fdb38248b929257eaaa008c3800b9b4a"
5
+ "sourceRevision": "d02f1a22e7914cd568446798fd9c2bb0dcb72b6f",
6
+ "contentHash": "08db2eaeda15ed171a5b96d9eb76304aa2a8c1cdc55b118e1fa6e3a26303d5dc"
7
7
  };
8
8
  //# sourceMappingURL=contract-provenance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-provenance.js","sourceRoot":"","sources":["../src/contract-provenance.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,kBAAkB,EAAE,mBAAmB;IACvC,iBAAiB,EAAE,OAAO;IAC1B,gBAAgB,EAAE,0CAA0C;IAC5D,aAAa,EAAE,kEAAkE;CACzE,CAAC","sourcesContent":["// Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.\nexport const backendContractProvenance = {\n \"sourceRepository\": \"workerkit-backend\",\n \"contractVersion\": \"1.0.0\",\n \"sourceRevision\": \"1953496c8dff09fab24d19661457faa600f2af64\",\n \"contentHash\": \"c6a74062d1063233f9040971ddaea5e2fdb38248b929257eaaa008c3800b9b4a\"\n} as const;\n"]}
1
+ {"version":3,"file":"contract-provenance.js","sourceRoot":"","sources":["../src/contract-provenance.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,kBAAkB,EAAE,mBAAmB;IACvC,iBAAiB,EAAE,OAAO;IAC1B,gBAAgB,EAAE,0CAA0C;IAC5D,aAAa,EAAE,kEAAkE;CACzE,CAAC","sourcesContent":["// Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.\nexport const backendContractProvenance = {\n \"sourceRepository\": \"workerkit-backend\",\n \"contractVersion\": \"1.0.0\",\n \"sourceRevision\": \"d02f1a22e7914cd568446798fd9c2bb0dcb72b6f\",\n \"contentHash\": \"08db2eaeda15ed171a5b96d9eb76304aa2a8c1cdc55b118e1fa6e3a26303d5dc\"\n} as const;\n"]}
@@ -1,6 +1,6 @@
1
1
  // Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.
2
2
  import { z } from "../zod.js";
3
- import { workerCreationTimezoneHint } from "../guidance.js";
3
+ import { creationResultGuidance, managerAuthorityPreflight, workerCreationTimezoneHint } from "../guidance.js";
4
4
  import { defineTool, CREATE, READ_ONLY, TRIGGER } from "./types.js";
5
5
  export const actionSpecSchema = z.object({
6
6
  schemaVersion: z.literal(1).describe("Always 1."),
@@ -22,26 +22,34 @@ export const actionDescriptors = [
22
22
  defineTool({
23
23
  name: "action_worker_options", title: "Action Worker Setup", auth: "manager", method: "get",
24
24
  path: "/api/manage/workers/action-options", strictInput: true,
25
- description: "Get available apps, reviewed tool contracts, the selected app's default tools and any required connections for creating an Action worker: a worker with no model, instruction or deployment, whose selected app tools a caller invokes directly with worker_tool_call (modelType none). Connection IDs and sender identities are server-owned. {{scope}} Creates and executes nothing.",
25
+ description: managerAuthorityPreflight + "Discover Action setup; creates/executes nothing. Omit app for the app inventory only, then choose an app for reviewed tools, defaults and connection requirements. Native/enabled reviewed MCP contracts can enter actionSpec; capabilities names source limits. app:customApi returns setup metadata, not selectable refs: API-only jobs use Language workers and dashboard finite-version bindings; no private API worker-slot calls. Action workers need no model/deployment. Actual Slack selections require a fixed active bot before creation; identities are server-owned. {{scope}}",
26
26
  schema: {
27
27
  operatorId: z.string().uuid().optional()
28
28
  .describe("The operator (workspace) to read connections for, as a GUID from apps_list → operators[]. Omit for the account's default operator."),
29
29
  app: z.string().min(1).max(128).optional()
30
- .describe("The app whose tools and defaultTools to return, exactly as apps[].code lists it. Omit for Slack."),
30
+ .describe("Omit for app inventory only. Supply an apps[].code for that app's reviewed tools/defaultTools; customApi returns setup metadata only."),
31
31
  },
32
32
  annotations: READ_ONLY,
33
33
  }),
34
34
  defineTool({
35
35
  name: "action_worker_create", title: "Create Action Worker", auth: "manager", method: "post",
36
36
  path: "/api/manage/workers/actions", strictInput: true,
37
- description: "Create a private Action kit and worker for an app from action_worker_options. No model or deployment. The server copies that app's default tools once; optionally provide an explicit actionSpec of up to 64 tools across apps. Slack tools require a fixed bot connection. Only explicit owner edits change installed tools. {{scope}} A key limited to selected workers gains the worker it creates. Reuse requestId with the same body after a timeout; never create a second worker to recover a lost response. Returns tokenId, workerId, kitSlug and modelType none, and no worker key. The worker is never deployed or run (worker_run and worker_deploy refuse it with 400 action_worker_requires_invoke): call worker_tools next, then worker_tool_call.",
37
+ description: managerAuthorityPreflight + "Create a private Action kit and worker after options discovery. Explicit app or actionSpec is required; there is no implicit app. app copies its reviewed defaults once; actionSpec selects up to 64 native/reviewed MCP tools across apps without needing app. Review any writes before creation. Private API refs are not selectable; follow source capabilities. Actual Slack tools require a fixed active bot; ordinary missing connections can follow creation. Only owner edits change tools. {{scope}} A selected-worker key gains its created worker. Reuse requestId/identical body after timeout; never recreate for recovery. Returns IDs/kitSlug/modelType none, no worker key. No model/deployment/run: worker_run/worker_deploy refuse with 400 action_worker_requires_invoke.",
38
+ resultDescription: creationResultGuidance,
39
+ footer: data => {
40
+ if (!data || typeof data !== "object" || Array.isArray(data))
41
+ return undefined;
42
+ const result = data;
43
+ return typeof result.workerUrl === "string" && result.workerUrl.trim() && result.error == null
44
+ ? creationResultGuidance : undefined;
45
+ },
38
46
  schema: {
39
47
  requestId: z.string().min(1).max(128)
40
48
  .describe("Your idempotency key for this creation. Repeat it only with the identical body, to recover a timed-out call's result; a different body under the same requestId is 409 request_conflict."),
41
49
  name: z.string().min(1).max(100).describe("Name for the new worker and its private kit."),
42
50
  timeZoneId: z.string().trim().min(1).max(64).optional().describe(workerCreationTimezoneHint),
43
51
  app: z.string().min(1).max(128).optional()
44
- .describe("The app whose default tools are copied when actionSpec is omitted, exactly as action_worker_options apps[].code lists it. Omit for Slack."),
52
+ .describe("Required when actionSpec is absent: an explicit app from action_worker_options. Copies that app's reviewed defaults once. Omit when selecting exact actionSpec tools."),
45
53
  slackConnectionId: z.number().int().positive().optional()
46
54
  .describe("Slack tools only: the bot connection to pin, an id from action_worker_options connections[] (app slack). A sole usable connection is selected automatically."),
47
55
  operatorId: z.string().uuid().optional()
@@ -53,13 +61,13 @@ export const actionDescriptors = [
53
61
  defineTool({
54
62
  name: "worker_tools", title: "List Action Worker Tools", auth: "manager", method: "get",
55
63
  path: p => `/api/manage/workers/${p.tokenId}/tools`, paramFilter: () => ({}), strictInput: true,
56
- description: "Discover the saved tools, exact input/output schemas, connection and sender of an Action worker. {{scope}} Select a named tool and supply its declared inputs using worker_tool_call. Discovery does not grant execution permission; current policy is checked on each call. Each tools[] entry carries name (the toolName), inputSchema, outputSchema, readOnly (false = a write, which needs an idempotencyKey) and available (false = not callable now: the tool left the catalog, its contract changed or, for a Slack tool, its bot connection is missing, until the owner reviews and re-saves the selection). availableTools are not callable until the owner selects them.",
64
+ description: managerAuthorityPreflight + "Discover saved Action tools, exact schemas, connections and sender. {{scope}} Copy a returned name and inputs to worker_tool_call. Each tool reports invocationSource, effect, idempotencyRequired, keyFormat, workerCallsSupported and invocationManagerScopes; follow these rather than inferring from readOnly. Private API effect is the declared operation description; readOnly stays false even for reads, which still require a versioned key. available:false blocks calls pending setup/contract review. availableTools are not callable until explicitly selected. Discovery grants no access; policy is checked each call.",
57
65
  schema: worker, annotations: READ_ONLY,
58
66
  }),
59
67
  defineTool({
60
68
  name: "worker_tool_call", title: "Call Action Worker Tool", auth: "manager", method: "post",
61
69
  path: p => `/api/manage/workers/${p.tokenId}/tools/${encodeURIComponent(String(p.toolName))}/invoke`, strictInput: true,
62
- description: "Execute exactly one saved Action worker tool with structured inputs, without a model. Discover worker_tools first. {{scope}} Cannot change tools, connection, sender or permissions. Supply a unique idempotencyKey for each intended write and reuse it for transport retries. A repeated key never resends: it replays the first answer, so a refusal with error.retryable true is retried later under a new key. For in_progress poll worker_tool_invocation. outcome_unknown means the app may have completed the action: do not automatically retry or issue a new key. Generic write receipts retain confirmation but not private app response content. Never resend to recover a lost response body. The answer is {invocationId, tool, status, result, error, replayed, contractVersion} with status succeeded | denied | failed | in_progress | outcome_unknown; invocationId is set on writes only (reads leave no receipt). Refusals before the app is reached use the {error, message, code} envelope: 403 tool_not_exposed, 409 tool_contract_changed (the owner must re-save the selection), 409 idempotency_conflict (same key, different arguments), 400 invalid_request (arguments that do not match inputSchema)." + INVOKE_SCOPE_NOTE,
70
+ description: managerAuthorityPreflight + "Invoke one saved Action tool without a model; discover worker_tools first and follow idempotencyRequired/keyFormat. {{scope}} Cannot change tools, connection, sender or permissions. Native/MCP writes need a unique key; reads need none. Every private API operation, including reads, needs managePrivateApiApps plus invokeActions and v1:<Unix timestamp>:<32-hex UUID>. Reuse a key and identical arguments to recover transport loss; it replays the journal, never resends. A retryable native/MCP refusal needs a new key for a later attempt. Poll in_progress with worker_tool_invocation. outcome_unknown: do not automatically retry or issue a new key. Native/MCP write receipts retain confirmation, not private response content; never resend to recover a body. Returns {invocationId,tool,status,result,error,replayed,contractVersion}; status succeeded|denied|failed|in_progress|outcome_unknown. Native/MCP reads leave no receipt; private API calls do. Pre-dispatch refusals use {error,message,code}: 403 tool_not_exposed, 409 tool_contract_changed (review/re-save), 409 idempotency_conflict (changed arguments), 400 invalid_request (schema mismatch)." + INVOKE_SCOPE_NOTE,
63
71
  schema: {
64
72
  ...worker,
65
73
  toolName: z.string().min(1).max(128)
@@ -68,7 +76,7 @@ export const actionDescriptors = [
68
76
  arguments: z.record(z.unknown())
69
77
  .describe("The tool's inputs, exactly as its inputSchema in worker_tools declares them, with their JSON types. Send {} for a tool that takes none."),
70
78
  idempotencyKey: z.string().min(1).max(128).regex(/^[!-~]+$/).optional()
71
- .describe("Required on a write tool (readOnly false in worker_tools): 1-128 printable characters, one per intended write. The same key with the same arguments returns the stored receipt without calling the app again; with different arguments it is 409 idempotency_conflict. Reads need none."),
79
+ .describe("Follow worker_tools.idempotencyRequired/keyFormat: native/MCP writes use 1-128 printable characters; every private API call, even read, uses v1:<Unix timestamp>:<32-hex UUID>. Reuse only for identical arguments to recover the original journal; changed arguments return 409 idempotency_conflict."),
72
80
  },
73
81
  bodyBuilder: p => ({ contractVersion: p.contractVersion, arguments: p.arguments }),
74
82
  headerBuilder: (p) => p.idempotencyKey ? { "Idempotency-Key": String(p.idempotencyKey) } : {},
@@ -77,10 +85,10 @@ export const actionDescriptors = [
77
85
  defineTool({
78
86
  name: "worker_tool_invocation", title: "Read Action Invocation", auth: "manager", method: "get",
79
87
  path: p => `/api/manage/workers/${p.tokenId}/tool-invocations/${p.invocationId}`, paramFilter: () => ({}), strictInput: true,
80
- description: "Read an Action invocation's status and effect references. {{scope}} Does not execute or retry anything. Unknown outcomes must not be automatically resent. A write still in_progress after two minutes reads as outcome_unknown: check the app itself before deciding anything." + INVOKE_SCOPE_NOTE,
88
+ description: managerAuthorityPreflight + "Read an Action invocation's status and effect references. {{scope}} Does not execute or retry anything. Unknown outcomes must not be automatically resent. A write still in_progress after two minutes reads as outcome_unknown: check the app itself before deciding anything." + INVOKE_SCOPE_NOTE,
81
89
  schema: {
82
90
  ...worker,
83
- invocationId: z.string().uuid().describe("The invocationId a worker_tool_call answer carried for a write."),
91
+ invocationId: z.string().uuid().describe("The invocationId returned for a native/MCP write or any private API invocation."),
84
92
  },
85
93
  annotations: READ_ONLY,
86
94
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/descriptors/actions.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAEzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAA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AC,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;iBACpE,QAAQ,CAAC,yRAAyR,CAAC;SACvS;QACD,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;QAClF,aAAa,EAAE,CAAC,CAAC,EAA0B,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QACrH,gBAAgB,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE;KACnF,CAAC;IACF,UAAU,CAAC;QACT,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK;QAC/F,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,OAAO,qBAAqB,CAAC,CAAC,YAAY,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI;QAC5H,WAAW,EAAE,iRAAiR,GAAG,iBAAiB;QAClT,MAAM,EAAE;YACN,GAAG,MAAM;YACT,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,iEAAiE,CAAC;SAC5G;QACD,WAAW,EAAE,SAAS;KACvB,CAAC;CACH,CAAC","sourcesContent":["// Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.\nimport { z } from \"../zod.js\";\nimport { workerCreationTimezoneHint } from \"../guidance.js\";\nimport { defineTool, CREATE, READ_ONLY, TRIGGER, type ToolDescriptor } from \"./types.js\";\n\nexport const actionSpecSchema = z.object({\n schemaVersion: z.literal(1).describe(\"Always 1.\"),\n tools: z.array(z.object({\n ref: z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/)\n .describe(\"A tool name exactly as action_worker_options lists it in tools[].name, from any of its apps.\"),\n version: z.literal(1).default(1).describe(\"Always 1.\"),\n contractHash: z.string().regex(/^[A-Fa-f0-9]{64}$/).optional()\n .describe(\"Optional pin, present when the selection is copied from a kit's actionSpec: creation is refused if that tool's contract changed since.\"),\n }).strict()).min(1).max(64).describe(\"1-64 tools, each listed once.\"),\n}).strict().describe(\"An explicit tool selection instead of the app's defaults: {schemaVersion: 1, tools: [{ref, version: 1}]}.\");\n\n// invokeActions is younger than most keys: the same snapshot rule as every newer scope.\nconst INVOKE_SCOPE_NOTE =\n \" Check key_info for scope snapshots and authority; never automatically retry a 403.\";\n\nconst worker = {\n tokenId: z.number().int().positive()\n .describe(\"Action worker numeric tokenId from workers_list/action_worker_create (modelType none). key_info shows worker reach.\"),\n};\n\nexport const actionDescriptors: readonly ToolDescriptor[] = [\n defineTool({\n name: \"action_worker_options\", title: \"Action Worker Setup\", auth: \"manager\", method: \"get\",\n path: \"/api/manage/workers/action-options\", strictInput: true,\n description: \"Get available apps, reviewed tool contracts, the selected app's default tools and any required connections for creating an Action worker: a worker with no model, instruction or deployment, whose selected app tools a caller invokes directly with worker_tool_call (modelType none). Connection IDs and sender identities are server-owned. {{scope}} Creates and executes nothing.\",\n schema: {\n operatorId: z.string().uuid().optional()\n .describe(\"The operator (workspace) to read connections for, as a GUID from apps_list → operators[]. Omit for the account's default operator.\"),\n app: z.string().min(1).max(128).optional()\n .describe(\"The app whose tools and defaultTools to return, exactly as apps[].code lists it. Omit for Slack.\"),\n },\n annotations: READ_ONLY,\n }),\n defineTool({\n name: \"action_worker_create\", title: \"Create Action Worker\", auth: \"manager\", method: \"post\",\n path: \"/api/manage/workers/actions\", strictInput: true,\n description: \"Create a private Action kit and worker for an app from action_worker_options. No model or deployment. The server copies that app's default tools once; optionally provide an explicit actionSpec of up to 64 tools across apps. Slack tools require a fixed bot connection. Only explicit owner edits change installed tools. {{scope}} A key limited to selected workers gains the worker it creates. Reuse requestId with the same body after a timeout; never create a second worker to recover a lost response. Returns tokenId, workerId, kitSlug and modelType none, and no worker key. The worker is never deployed or run (worker_run and worker_deploy refuse it with 400 action_worker_requires_invoke): call worker_tools next, then worker_tool_call.\",\n schema: {\n requestId: z.string().min(1).max(128)\n .describe(\"Your idempotency key for this creation. Repeat it only with the identical body, to recover a timed-out call's result; a different body under the same requestId is 409 request_conflict.\"),\n name: z.string().min(1).max(100).describe(\"Name for the new worker and its private kit.\"),\n timeZoneId: z.string().trim().min(1).max(64).optional().describe(workerCreationTimezoneHint),\n app: z.string().min(1).max(128).optional()\n .describe(\"The app whose default tools are copied when actionSpec is omitted, exactly as action_worker_options apps[].code lists it. Omit for Slack.\"),\n slackConnectionId: z.number().int().positive().optional()\n .describe(\"Slack tools only: the bot connection to pin, an id from action_worker_options connections[] (app slack). A sole usable connection is selected automatically.\"),\n operatorId: z.string().uuid().optional()\n .describe(\"The operator (workspace) to create the worker on, as a GUID from apps_list → operators[]. Omit for the account's default operator.\"),\n actionSpec: actionSpecSchema.optional(),\n },\n annotations: { ...CREATE, idempotentHint: true },\n }),\n defineTool({\n name: \"worker_tools\", title: \"List Action Worker Tools\", auth: \"manager\", method: \"get\",\n path: p => `/api/manage/workers/${p.tokenId}/tools`, paramFilter: () => ({}), strictInput: true,\n description: \"Discover the saved tools, exact input/output schemas, connection and sender of an Action worker. {{scope}} Select a named tool and supply its declared inputs using worker_tool_call. Discovery does not grant execution permission; current policy is checked on each call. Each tools[] entry carries name (the toolName), inputSchema, outputSchema, readOnly (false = a write, which needs an idempotencyKey) and available (false = not callable now: the tool left the catalog, its contract changed or, for a Slack tool, its bot connection is missing, until the owner reviews and re-saves the selection). availableTools are not callable until the owner selects them.\",\n schema: worker, annotations: READ_ONLY,\n }),\n defineTool({\n name: \"worker_tool_call\", title: \"Call Action Worker Tool\", auth: \"manager\", method: \"post\",\n path: p => `/api/manage/workers/${p.tokenId}/tools/${encodeURIComponent(String(p.toolName))}/invoke`, strictInput: true,\n description: \"Execute exactly one saved Action worker tool with structured inputs, without a model. Discover worker_tools first. {{scope}} Cannot change tools, connection, sender or permissions. Supply a unique idempotencyKey for each intended write and reuse it for transport retries. A repeated key never resends: it replays the first answer, so a refusal with error.retryable true is retried later under a new key. For in_progress poll worker_tool_invocation. outcome_unknown means the app may have completed the action: do not automatically retry or issue a new key. Generic write receipts retain confirmation but not private app response content. Never resend to recover a lost response body. The answer is {invocationId, tool, status, result, error, replayed, contractVersion} with status succeeded | denied | failed | in_progress | outcome_unknown; invocationId is set on writes only (reads leave no receipt). Refusals before the app is reached use the {error, message, code} envelope: 403 tool_not_exposed, 409 tool_contract_changed (the owner must re-save the selection), 409 idempotency_conflict (same key, different arguments), 400 invalid_request (arguments that do not match inputSchema).\" + INVOKE_SCOPE_NOTE,\n schema: {\n ...worker,\n toolName: z.string().min(1).max(128)\n .describe(\"A tools[].name from worker_tools for this worker, exactly.\"),\n contractVersion: z.literal(1).default(1).describe(\"Always 1.\"),\n arguments: z.record(z.unknown())\n .describe(\"The tool's inputs, exactly as its inputSchema in worker_tools declares them, with their JSON types. Send {} for a tool that takes none.\"),\n idempotencyKey: z.string().min(1).max(128).regex(/^[!-~]+$/).optional()\n .describe(\"Required on a write tool (readOnly false in worker_tools): 1-128 printable characters, one per intended write. The same key with the same arguments returns the stored receipt without calling the app again; with different arguments it is 409 idempotency_conflict. Reads need none.\"),\n },\n bodyBuilder: p => ({ contractVersion: p.contractVersion, arguments: p.arguments }),\n headerBuilder: (p): Record<string, string> => p.idempotencyKey ? { \"Idempotency-Key\": String(p.idempotencyKey) } : {},\n requestTimeoutMs: () => 90_000, annotations: { ...TRIGGER, idempotentHint: false },\n }),\n defineTool({\n name: \"worker_tool_invocation\", title: \"Read Action Invocation\", auth: \"manager\", method: \"get\",\n path: p => `/api/manage/workers/${p.tokenId}/tool-invocations/${p.invocationId}`, paramFilter: () => ({}), strictInput: true,\n description: \"Read an Action invocation's status and effect references. {{scope}} Does not execute or retry anything. Unknown outcomes must not be automatically resent. A write still in_progress after two minutes reads as outcome_unknown: check the app itself before deciding anything.\" + INVOKE_SCOPE_NOTE,\n schema: {\n ...worker,\n invocationId: z.string().uuid().describe(\"The invocationId a worker_tool_call answer carried for a write.\"),\n },\n annotations: READ_ONLY,\n }),\n];\n"]}
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/descriptors/actions.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAEzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;aACtD,QAAQ,CAAC,8FAA8F,CAAC;QAC3G,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;QACtD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;aAC3D,QAAQ,CAAC,wIAAwI,CAAC;KACtJ,CAAC,CAAC,MAA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from \"../zod.js\";\nimport { creationResultGuidance, managerAuthorityPreflight, workerCreationTimezoneHint } from \"../guidance.js\";\nimport { defineTool, CREATE, READ_ONLY, TRIGGER, type ToolDescriptor } from \"./types.js\";\n\nexport const actionSpecSchema = z.object({\n schemaVersion: z.literal(1).describe(\"Always 1.\"),\n tools: z.array(z.object({\n ref: z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/)\n .describe(\"A tool name exactly as action_worker_options lists it in tools[].name, from any of its apps.\"),\n version: z.literal(1).default(1).describe(\"Always 1.\"),\n contractHash: z.string().regex(/^[A-Fa-f0-9]{64}$/).optional()\n .describe(\"Optional pin, present when the selection is copied from a kit's actionSpec: creation is refused if that tool's contract changed since.\"),\n }).strict()).min(1).max(64).describe(\"1-64 tools, each listed once.\"),\n}).strict().describe(\"An explicit tool selection instead of the app's defaults: {schemaVersion: 1, tools: [{ref, version: 1}]}.\");\n\n// invokeActions is younger than most keys: the same snapshot rule as every newer scope.\nconst INVOKE_SCOPE_NOTE =\n \" Check key_info for scope snapshots and authority; never automatically retry a 403.\";\n\nconst worker = {\n tokenId: z.number().int().positive()\n .describe(\"Action worker numeric tokenId from workers_list/action_worker_create (modelType none). key_info shows worker reach.\"),\n};\n\nexport const actionDescriptors: readonly ToolDescriptor[] = [\n defineTool({\n name: \"action_worker_options\", title: \"Action Worker Setup\", auth: \"manager\", method: \"get\",\n path: \"/api/manage/workers/action-options\", strictInput: true,\n description: managerAuthorityPreflight + \"Discover Action setup; creates/executes nothing. Omit app for the app inventory only, then choose an app for reviewed tools, defaults and connection requirements. Native/enabled reviewed MCP contracts can enter actionSpec; capabilities names source limits. app:customApi returns setup metadata, not selectable refs: API-only jobs use Language workers and dashboard finite-version bindings; no private API worker-slot calls. Action workers need no model/deployment. Actual Slack selections require a fixed active bot before creation; identities are server-owned. {{scope}}\",\n schema: {\n operatorId: z.string().uuid().optional()\n .describe(\"The operator (workspace) to read connections for, as a GUID from apps_list → operators[]. Omit for the account's default operator.\"),\n app: z.string().min(1).max(128).optional()\n .describe(\"Omit for app inventory only. Supply an apps[].code for that app's reviewed tools/defaultTools; customApi returns setup metadata only.\"),\n },\n annotations: READ_ONLY,\n }),\n defineTool({\n name: \"action_worker_create\", title: \"Create Action Worker\", auth: \"manager\", method: \"post\",\n path: \"/api/manage/workers/actions\", strictInput: true,\n description: managerAuthorityPreflight + \"Create a private Action kit and worker after options discovery. Explicit app or actionSpec is required; there is no implicit app. app copies its reviewed defaults once; actionSpec selects up to 64 native/reviewed MCP tools across apps without needing app. Review any writes before creation. Private API refs are not selectable; follow source capabilities. Actual Slack tools require a fixed active bot; ordinary missing connections can follow creation. Only owner edits change tools. {{scope}} A selected-worker key gains its created worker. Reuse requestId/identical body after timeout; never recreate for recovery. Returns IDs/kitSlug/modelType none, no worker key. No model/deployment/run: worker_run/worker_deploy refuse with 400 action_worker_requires_invoke.\",\n resultDescription: creationResultGuidance,\n footer: data => {\n if (!data || typeof data !== \"object\" || Array.isArray(data)) return undefined;\n const result = data as Record<string, unknown>;\n return typeof result.workerUrl === \"string\" && result.workerUrl.trim() && result.error == null\n ? creationResultGuidance : undefined;\n },\n schema: {\n requestId: z.string().min(1).max(128)\n .describe(\"Your idempotency key for this creation. Repeat it only with the identical body, to recover a timed-out call's result; a different body under the same requestId is 409 request_conflict.\"),\n name: z.string().min(1).max(100).describe(\"Name for the new worker and its private kit.\"),\n timeZoneId: z.string().trim().min(1).max(64).optional().describe(workerCreationTimezoneHint),\n app: z.string().min(1).max(128).optional()\n .describe(\"Required when actionSpec is absent: an explicit app from action_worker_options. Copies that app's reviewed defaults once. Omit when selecting exact actionSpec tools.\"),\n slackConnectionId: z.number().int().positive().optional()\n .describe(\"Slack tools only: the bot connection to pin, an id from action_worker_options connections[] (app slack). A sole usable connection is selected automatically.\"),\n operatorId: z.string().uuid().optional()\n .describe(\"The operator (workspace) to create the worker on, as a GUID from apps_list → operators[]. Omit for the account's default operator.\"),\n actionSpec: actionSpecSchema.optional(),\n },\n annotations: { ...CREATE, idempotentHint: true },\n }),\n defineTool({\n name: \"worker_tools\", title: \"List Action Worker Tools\", auth: \"manager\", method: \"get\",\n path: p => `/api/manage/workers/${p.tokenId}/tools`, paramFilter: () => ({}), strictInput: true,\n description: managerAuthorityPreflight + \"Discover saved Action tools, exact schemas, connections and sender. {{scope}} Copy a returned name and inputs to worker_tool_call. Each tool reports invocationSource, effect, idempotencyRequired, keyFormat, workerCallsSupported and invocationManagerScopes; follow these rather than inferring from readOnly. Private API effect is the declared operation description; readOnly stays false even for reads, which still require a versioned key. available:false blocks calls pending setup/contract review. availableTools are not callable until explicitly selected. Discovery grants no access; policy is checked each call.\",\n schema: worker, annotations: READ_ONLY,\n }),\n defineTool({\n name: \"worker_tool_call\", title: \"Call Action Worker Tool\", auth: \"manager\", method: \"post\",\n path: p => `/api/manage/workers/${p.tokenId}/tools/${encodeURIComponent(String(p.toolName))}/invoke`, strictInput: true,\n description: managerAuthorityPreflight + \"Invoke one saved Action tool without a model; discover worker_tools first and follow idempotencyRequired/keyFormat. {{scope}} Cannot change tools, connection, sender or permissions. Native/MCP writes need a unique key; reads need none. Every private API operation, including reads, needs managePrivateApiApps plus invokeActions and v1:<Unix timestamp>:<32-hex UUID>. Reuse a key and identical arguments to recover transport loss; it replays the journal, never resends. A retryable native/MCP refusal needs a new key for a later attempt. Poll in_progress with worker_tool_invocation. outcome_unknown: do not automatically retry or issue a new key. Native/MCP write receipts retain confirmation, not private response content; never resend to recover a body. Returns {invocationId,tool,status,result,error,replayed,contractVersion}; status succeeded|denied|failed|in_progress|outcome_unknown. Native/MCP reads leave no receipt; private API calls do. Pre-dispatch refusals use {error,message,code}: 403 tool_not_exposed, 409 tool_contract_changed (review/re-save), 409 idempotency_conflict (changed arguments), 400 invalid_request (schema mismatch).\" + INVOKE_SCOPE_NOTE,\n schema: {\n ...worker,\n toolName: z.string().min(1).max(128)\n .describe(\"A tools[].name from worker_tools for this worker, exactly.\"),\n contractVersion: z.literal(1).default(1).describe(\"Always 1.\"),\n arguments: z.record(z.unknown())\n .describe(\"The tool's inputs, exactly as its inputSchema in worker_tools declares them, with their JSON types. Send {} for a tool that takes none.\"),\n idempotencyKey: z.string().min(1).max(128).regex(/^[!-~]+$/).optional()\n .describe(\"Follow worker_tools.idempotencyRequired/keyFormat: native/MCP writes use 1-128 printable characters; every private API call, even read, uses v1:<Unix timestamp>:<32-hex UUID>. Reuse only for identical arguments to recover the original journal; changed arguments return 409 idempotency_conflict.\"),\n },\n bodyBuilder: p => ({ contractVersion: p.contractVersion, arguments: p.arguments }),\n headerBuilder: (p): Record<string, string> => p.idempotencyKey ? { \"Idempotency-Key\": String(p.idempotencyKey) } : {},\n requestTimeoutMs: () => 90_000, annotations: { ...TRIGGER, idempotentHint: false },\n }),\n defineTool({\n name: \"worker_tool_invocation\", title: \"Read Action Invocation\", auth: \"manager\", method: \"get\",\n path: p => `/api/manage/workers/${p.tokenId}/tool-invocations/${p.invocationId}`, paramFilter: () => ({}), strictInput: true,\n description: managerAuthorityPreflight + \"Read an Action invocation's status and effect references. {{scope}} Does not execute or retry anything. Unknown outcomes must not be automatically resent. A write still in_progress after two minutes reads as outcome_unknown: check the app itself before deciding anything.\" + INVOKE_SCOPE_NOTE,\n schema: {\n ...worker,\n invocationId: z.string().uuid().describe(\"The invocationId returned for a native/MCP write or any private API invocation.\"),\n },\n annotations: READ_ONLY,\n }),\n];\n"]}
@@ -1,6 +1,6 @@
1
1
  // Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.
2
2
  import { z } from "../zod.js";
3
- import { workerCreationTimezoneHint } from "../guidance.js";
3
+ import { creationResultGuidance, managerAuthorityPreflight, workerCreationTimezoneHint } from "../guidance.js";
4
4
  import { defineTool, CREATE } from "./types.js";
5
5
  const key = z.string().regex(/^(?=.{1,40}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);
6
6
  const base = { key, instructions: z.string().min(1).max(4000) };
@@ -15,9 +15,17 @@ export const decisionQuestion = z.discriminatedUnion("type", [
15
15
  export const createDecisionWorker = defineTool({
16
16
  name: "decision_worker_create",
17
17
  title: "Create Decision Worker",
18
- description: "Create a reusable classifier to categorize, score, filter or triage connected data. First discover source recipes with kit_app_tools(purpose:'decision'); kit_authoring_guide(section:'decision') has examples. Creates a private kit and worker atomically; optionally deploys, never runs. Questions and source mappings compile deterministically into the ordinary decision specification. Source filters do not narrow the recipe's read permissions. {{scope}} A key limited to selected workers gains the worker it creates. Reuse requestId and the identical body to recover the original receipt after a timeout; changed body returns 409. Returns tokenId for lifecycle commands, stable workerId, kitSlug, readiness, deployment/error and exact nextCall arguments. Follow nextCall, then worker_run/run_get. A deployment error means the worker already exists. Choice adds unclear automatically; setup answers adjust categories/levels later. Creation returns no worker API secret. For arbitrary decision sources or routed actions use kit_validate → kit_publish(private) → kit_install.",
18
+ description: managerAuthorityPreflight + "Create a reusable classifier to categorize, score, filter or triage data. Discover recipes with kit_app_tools(purpose:'decision'); kit_authoring_guide(section:'decision') has examples. Missing ordinary app connections allow creation first, then setup. Creates a private kit and worker atomically; optionally deploys, never runs. Questions/source mappings compile deterministically; source filters do not narrow grants. {{scope}} A selected-worker key gains its created worker. Reuse requestId and identical body after timeout; changed body returns 409. Returns tokenId, workerId, kitSlug, workerUrl, readiness, deployment/error, setupActions and nextCall, no worker secret. A deployment error leaves the worker saved without those model/ceilings; never recreate it. Choice adds unclear; setup answers adjust categories/levels. Recipes are shortcuts: discover other sources/routed actions with kit_app_tools(app, omit purpose), then kit_validate → kit_publish(private) → kit_install → worker_deploy before running.",
19
19
  auth: "manager", method: "post", path: "/api/manage/decision-workers",
20
20
  strictInput: true,
21
+ resultDescription: creationResultGuidance,
22
+ footer: data => {
23
+ if (!data || typeof data !== "object" || Array.isArray(data))
24
+ return undefined;
25
+ const result = data;
26
+ return typeof result.workerUrl === "string" && result.workerUrl.trim() && result.error == null
27
+ ? creationResultGuidance : undefined;
28
+ },
21
29
  schema: {
22
30
  requestId: z.string().min(1).max(128).regex(/^[!-~]+$/).describe("Unique creation id. Reuse with the same body on retries; new id creates a new worker."),
23
31
  name: z.string().min(1).max(100),
@@ -27,7 +35,7 @@ export const createDecisionWorker = defineTool({
27
35
  args: z.record(z.unknown()).optional().describe("Arguments from the discovered recipe's argsSchema. No placeholders. Sheets requires fileId, range and columns."),
28
36
  }).strict(),
29
37
  questions: z.array(decisionQuestion).min(1).max(8).describe("Independent questions with unique keys. Choice: 1–20 options, excluding reserved unclear; name + description ≤200 chars. Score: ordered levels, lowest first. Noul: probability of a statement."),
30
- confidenceFloor: z.number().min(0).max(1).describe("Required confidence threshold; uncertain choices/scores are flagged, not omitted. Not an accuracy guarantee."),
38
+ confidenceFloor: z.number().min(0).max(1).describe("Routing threshold, not an accuracy guarantee. Below-floor answers are flagged and still returned; this does not replace their labels with unclear."),
31
39
  maxItems: z.number().int().min(1).max(50).default(20),
32
40
  operatorId: z.string().uuid().optional(),
33
41
  deploy: z.boolean().default(false).describe("Create a hosted deployment too. Does not execute a run."),
@@ -38,6 +46,11 @@ export const createDecisionWorker = defineTool({
38
46
  outputSchema: {
39
47
  tokenId: z.number().int().positive().describe("Use with existing worker tools and CLI commands."),
40
48
  workerId: z.string().uuid(), kitSlug: z.string(), modelType: z.literal("decision"), workerUrl: z.string(),
49
+ connectAppsUrl: z.string().nullable().optional(),
50
+ setupActions: z.array(z.object({
51
+ code: z.string(), message: z.string(), url: z.string().optional(), apps: z.array(z.string()),
52
+ tool: z.string().optional(), arguments: z.record(z.unknown()),
53
+ })).optional(),
41
54
  readiness: z.record(z.unknown()).nullable(), deployment: z.record(z.unknown()).nullable(),
42
55
  deploymentError: z.record(z.unknown()).nullable(), warnings: z.array(z.string()),
43
56
  nextCall: z.object({ tool: z.string(), arguments: z.record(z.unknown()) }),
@@ -1 +1 @@
1
- {"version":3,"file":"decision-authoring.js","sourceRoot":"","sources":["../../src/descriptors/decision-authoring.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AA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AAC,QAAQ,EAAE;QACvD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;KACzD;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;QACjG,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACzG,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;QACzF,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChF,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;KAC3E;IACD,WAAW,EAAE,EAAE,GAAG,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE;CACjD,CAAC,CAAC","sourcesContent":["// Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.\nimport { z } from \"../zod.js\";\nimport { workerCreationTimezoneHint } from \"../guidance.js\";\nimport { defineTool, CREATE, type ToolDescriptor } from \"./types.js\";\n\nconst key = z.string().regex(/^(?=.{1,40}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);\nconst base = { key, instructions: z.string().min(1).max(4000) };\nexport const decisionQuestion = z.discriminatedUnion(\"type\", [\n z.object({ ...base, type: z.literal(\"choice\"), options: z.record(key, z.string().min(1).max(200)).refine(options => {\n const entries = Object.entries(options);\n return entries.length >= 1 && entries.length <= 20 && entries.every(([name, description]) => name !== \"unclear\" && description.trim().length > 0 && name.length + 3 + description.length <= 200);\n }, \"Provide 1–20 options excluding unclear; each name and description must fit in 200 characters including the separator.\") }).strict(),\n z.object({ ...base, type: z.literal(\"score\"), levels: z.array(z.string().min(1).max(200)).min(2).max(10) }).strict(),\n z.object({ ...base, type: z.literal(\"noul\"), trueMeaning: z.string().max(200).optional(), falseMeaning: z.string().max(200).optional() }).strict(),\n]);\n\nexport const createDecisionWorker: ToolDescriptor = defineTool({\n name: \"decision_worker_create\",\n title: \"Create Decision Worker\",\n description: \"Create a reusable classifier to categorize, score, filter or triage connected data. First discover source recipes with kit_app_tools(purpose:'decision'); kit_authoring_guide(section:'decision') has examples. Creates a private kit and worker atomically; optionally deploys, never runs. Questions and source mappings compile deterministically into the ordinary decision specification. Source filters do not narrow the recipe's read permissions. {{scope}} A key limited to selected workers gains the worker it creates. Reuse requestId and the identical body to recover the original receipt after a timeout; changed body returns 409. Returns tokenId for lifecycle commands, stable workerId, kitSlug, readiness, deployment/error and exact nextCall arguments. Follow nextCall, then worker_run/run_get. A deployment error means the worker already exists. Choice adds unclear automatically; setup answers adjust categories/levels later. Creation returns no worker API secret. For arbitrary decision sources or routed actions use kit_validate → kit_publish(private) → kit_install.\",\n auth: \"manager\", method: \"post\", path: \"/api/manage/decision-workers\",\n strictInput: true,\n schema: {\n requestId: z.string().min(1).max(128).regex(/^[!-~]+$/).describe(\"Unique creation id. Reuse with the same body on retries; new id creates a new worker.\"),\n name: z.string().min(1).max(100),\n timeZoneId: z.string().trim().min(1).max(64).optional().describe(workerCreationTimezoneHint),\n source: z.object({\n recipe: z.enum([\"email-previews\", \"calendar-events\", \"sheets-rows\"]),\n args: z.record(z.unknown()).optional().describe(\"Arguments from the discovered recipe's argsSchema. No placeholders. Sheets requires fileId, range and columns.\"),\n }).strict(),\n questions: z.array(decisionQuestion).min(1).max(8).describe(\"Independent questions with unique keys. Choice: 1–20 options, excluding reserved unclear; name + description ≤200 chars. Score: ordered levels, lowest first. Noul: probability of a statement.\"),\n confidenceFloor: z.number().min(0).max(1).describe(\"Required confidence threshold; uncertain choices/scores are flagged, not omitted. Not an accuracy guarantee.\"),\n maxItems: z.number().int().min(1).max(50).default(20),\n operatorId: z.string().uuid().optional(),\n deploy: z.boolean().default(false).describe(\"Create a hosted deployment too. Does not execute a run.\"),\n decisionProfileId: z.string().min(1).max(64).optional().describe(\"Default classifier for the kit and worker: a profileId from models_list.decisionProfiles. Omit for Jev. Independent of deployment and spend settings.\"),\n maxUsdPerRun: z.number().min(0.01).max(1000).optional(),\n maxUsdPerDay: z.number().min(0.01).max(10000).optional(),\n },\n outputSchema: {\n tokenId: z.number().int().positive().describe(\"Use with existing worker tools and CLI commands.\"),\n workerId: z.string().uuid(), kitSlug: z.string(), modelType: z.literal(\"decision\"), workerUrl: z.string(),\n readiness: z.record(z.unknown()).nullable(), deployment: z.record(z.unknown()).nullable(),\n deploymentError: z.record(z.unknown()).nullable(), warnings: z.array(z.string()),\n nextCall: z.object({ tool: z.string(), arguments: z.record(z.unknown()) }),\n },\n annotations: { ...CREATE, idempotentHint: true },\n});\n"]}
1
+ {"version":3,"file":"decision-authoring.js","sourceRoot":"","sources":["../../src/descriptors/decision-authoring.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,EAAuB,MAAM,YAAY,CAAC;AA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AS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC9D,CAAC,CAAC,CAAC,QAAQ,EAAE;QACd,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;QACzF,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChF,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;KAC3E;IACD,WAAW,EAAE,EAAE,GAAG,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE;CACjD,CAAC,CAAC","sourcesContent":["// Generated from the backend agent contract. Edit the backend source and re-import; do not edit here.\nimport { z } from \"../zod.js\";\nimport { creationResultGuidance, managerAuthorityPreflight, workerCreationTimezoneHint } from \"../guidance.js\";\nimport { defineTool, CREATE, type ToolDescriptor } from \"./types.js\";\n\nconst key = z.string().regex(/^(?=.{1,40}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);\nconst base = { key, instructions: z.string().min(1).max(4000) };\nexport const decisionQuestion = z.discriminatedUnion(\"type\", [\n z.object({ ...base, type: z.literal(\"choice\"), options: z.record(key, z.string().min(1).max(200)).refine(options => {\n const entries = Object.entries(options);\n return entries.length >= 1 && entries.length <= 20 && entries.every(([name, description]) => name !== \"unclear\" && description.trim().length > 0 && name.length + 3 + description.length <= 200);\n }, \"Provide 1–20 options excluding unclear; each name and description must fit in 200 characters including the separator.\") }).strict(),\n z.object({ ...base, type: z.literal(\"score\"), levels: z.array(z.string().min(1).max(200)).min(2).max(10) }).strict(),\n z.object({ ...base, type: z.literal(\"noul\"), trueMeaning: z.string().max(200).optional(), falseMeaning: z.string().max(200).optional() }).strict(),\n]);\n\nexport const createDecisionWorker: ToolDescriptor = defineTool({\n name: \"decision_worker_create\",\n title: \"Create Decision Worker\",\n description: managerAuthorityPreflight + \"Create a reusable classifier to categorize, score, filter or triage data. Discover recipes with kit_app_tools(purpose:'decision'); kit_authoring_guide(section:'decision') has examples. Missing ordinary app connections allow creation first, then setup. Creates a private kit and worker atomically; optionally deploys, never runs. Questions/source mappings compile deterministically; source filters do not narrow grants. {{scope}} A selected-worker key gains its created worker. Reuse requestId and identical body after timeout; changed body returns 409. Returns tokenId, workerId, kitSlug, workerUrl, readiness, deployment/error, setupActions and nextCall, no worker secret. A deployment error leaves the worker saved without those model/ceilings; never recreate it. Choice adds unclear; setup answers adjust categories/levels. Recipes are shortcuts: discover other sources/routed actions with kit_app_tools(app, omit purpose), then kit_validate → kit_publish(private) → kit_install → worker_deploy before running.\",\n auth: \"manager\", method: \"post\", path: \"/api/manage/decision-workers\",\n strictInput: true,\n resultDescription: creationResultGuidance,\n footer: data => {\n if (!data || typeof data !== \"object\" || Array.isArray(data)) return undefined;\n const result = data as Record<string, unknown>;\n return typeof result.workerUrl === \"string\" && result.workerUrl.trim() && result.error == null\n ? creationResultGuidance : undefined;\n },\n schema: {\n requestId: z.string().min(1).max(128).regex(/^[!-~]+$/).describe(\"Unique creation id. Reuse with the same body on retries; new id creates a new worker.\"),\n name: z.string().min(1).max(100),\n timeZoneId: z.string().trim().min(1).max(64).optional().describe(workerCreationTimezoneHint),\n source: z.object({\n recipe: z.enum([\"email-previews\", \"calendar-events\", \"sheets-rows\"]),\n args: z.record(z.unknown()).optional().describe(\"Arguments from the discovered recipe's argsSchema. No placeholders. Sheets requires fileId, range and columns.\"),\n }).strict(),\n questions: z.array(decisionQuestion).min(1).max(8).describe(\"Independent questions with unique keys. Choice: 1–20 options, excluding reserved unclear; name + description ≤200 chars. Score: ordered levels, lowest first. Noul: probability of a statement.\"),\n confidenceFloor: z.number().min(0).max(1).describe(\"Routing threshold, not an accuracy guarantee. Below-floor answers are flagged and still returned; this does not replace their labels with unclear.\"),\n maxItems: z.number().int().min(1).max(50).default(20),\n operatorId: z.string().uuid().optional(),\n deploy: z.boolean().default(false).describe(\"Create a hosted deployment too. Does not execute a run.\"),\n decisionProfileId: z.string().min(1).max(64).optional().describe(\"Default classifier for the kit and worker: a profileId from models_list.decisionProfiles. Omit for Jev. Independent of deployment and spend settings.\"),\n maxUsdPerRun: z.number().min(0.01).max(1000).optional(),\n maxUsdPerDay: z.number().min(0.01).max(10000).optional(),\n },\n outputSchema: {\n tokenId: z.number().int().positive().describe(\"Use with existing worker tools and CLI commands.\"),\n workerId: z.string().uuid(), kitSlug: z.string(), modelType: z.literal(\"decision\"), workerUrl: z.string(),\n connectAppsUrl: z.string().nullable().optional(),\n setupActions: z.array(z.object({\n code: z.string(), message: z.string(), url: z.string().optional(), apps: z.array(z.string()),\n tool: z.string().optional(), arguments: z.record(z.unknown()),\n })).optional(),\n readiness: z.record(z.unknown()).nullable(), deployment: z.record(z.unknown()).nullable(),\n deploymentError: z.record(z.unknown()).nullable(), warnings: z.array(z.string()),\n nextCall: z.object({ tool: z.string(), arguments: z.record(z.unknown()) }),\n },\n annotations: { ...CREATE, idempotentHint: true },\n});\n"]}
@@ -29,7 +29,7 @@ const DIRECTORY_NOTE = " Public and anonymous, identical for everyone; reads onl
29
29
  // The two authoring reads share one framing: they are what an agent reads BEFORE
30
30
  // writing a kit for the manager surface, and they are anonymous so it can draft
31
31
  // before it holds any credential.
32
- const AUTHORING_NOTE = " Public and anonymous. On Manager /workers: kit_validate checks all sections, then kit_publish (publishKits). Publish PRIVATE first: only this account can install it via a signed-in human at pageUrl or kit_install, also the create-from-scratch path. Workers need apps connected on their operator (apps_list/app_connect). Add unsupported apps via mcp_server_create (credential), mcp_server_set_tools, then content.mcpServers.";
32
+ const AUTHORING_NOTE = " Public and anonymous. On Manager /workers: kit_validate the exact body, then kit_publish (publishKits) with visibility:'private'. Install: signed-in human at pageUrl or kit_install. Each install creates one worker; workerSlots bind separate workers. Missing ordinary app connections can be set up afterward (apps_list/app_connect). index covers MCP/private API extensions.";
33
33
  const SEARCH_EMPTY_HINT = "No kits matched. Filters AND together — drop some. query is a plain case-insensitive substring over name + job sentence (one short word beats a phrase), and unknown category/app/publisher values match nothing rather than erroring. directory_overview lists every valid filter value. If nothing fits after broadening, author a kit for the exact job rather than installing a near miss: kit_authoring_guide (index, then schema and rules) and kit_app_tools here, then kit_validate and kit_publish (private) on the /workers mount, then kit_install.";
34
34
  // publisher_get accepts no search filters, so the search hint above would tell an
35
35
  // agent to broaden filters it never set. Reachable: the profile 404s only when the
@@ -116,7 +116,7 @@ export function publisherPageFooter(data) {
116
116
  const directoryOverview = {
117
117
  name: "directory_overview",
118
118
  title: "Directory Overview",
119
- description: "Read directory vocabulary before choosing kits_search filters. kitCount counts published kits; categories.jobFamilies/roles/industries supplies slug/name for category/industry. apps code/name/categoryCode/installable supplies app (installable:false can appear in kits but cannot be installed). appCategories code/name/members[{code,name,appCode}] supplies appCategory and installer choices (e.g. Slack/Teams). models model/normalized/kitCount supplies model (normalized or substring). modelTypes code/name/summary supplies none(Action)|language|decision|hybrid. Also sortOptions/triggerModes. No kits here: for popularity use kits_search's default downloads sort. Human pages: https://workerkit.ai/kit/{slug}." + DIRECTORY_NOTE,
119
+ description: "Read directory vocabulary before choosing kits_search filters. kitCount counts published kits; categories.jobFamilies/roles/industries supplies slug/name for category/industry. apps code/name/categoryCode/installable supplies app (installable:false can appear in kits but cannot be installed). appCategories code/name/members[{code,name,appCode}] supplies appCategory and installer choices. models model/normalized/kitCount supplies model (normalized or substring). modelTypes code/name/summary supplies none(Action)|language|decision|hybrid. Also sortOptions/triggerModes. No kits here: for popularity use kits_search's default downloads sort. Human pages: https://workerkit.ai/kit/{slug}." + DIRECTORY_NOTE,
120
120
  auth: "anonymous",
121
121
  method: "get",
122
122
  schema: {},
@@ -200,11 +200,11 @@ const GUIDE_SECTIONS = ["index", "decision", "schema", "rules", "skill", "state"
200
200
  const kitAuthoringGuide = {
201
201
  name: "kit_authoring_guide",
202
202
  title: "Kit Authoring Guide",
203
- description: "Read kit authoring guidance one Markdown section at a time, with table of contents. Classification/scoring/filtering/triage: decision has recipes, typed questions, creation examples/results. Action(modelType none): index/schema; quickest create path is action_worker_options then action_worker_create on Manager. Full kit authoring: index, then schema/rules; state covers Records, memory and context hygiene; workers covers kits that call other workers (workerSlots, bindings, waiting, receipts); fetch other sections as needed. Unknown section:400 with valid names. Live sources:kit_app_tools; exact permission keys:kit_vocabulary. On Manager /workers, kit_validate the exact body then kit_publish (publishKits). Publish private, install and prove a run (Action:tool call) before public promotion with kit_replace." + DIRECTORY_NOTE,
203
+ description: "Read one Markdown section at a time. index chooses Language/Decision/Action/Hybrid and native/MCP/private API paths; schema/rules define the exact payload. decision covers recipe shortcuts and arbitrary catalog sources; workers covers typed calls, routing and bindings between separately installed workers. state covers Records, memory and context hygiene. Fetch other sections only as needed. Unknown section:400 with valid names. Discover business tools with kit_app_tools and permission keys with kit_vocabulary; Manager tools/list is not the worker's app inventory. Validate the exact body, publish private and install; prove a run (Action:tool call) before promotion when public publishing reopens." + DIRECTORY_NOTE,
204
204
  auth: "anonymous",
205
205
  method: "get",
206
206
  schema: {
207
- section: z.enum(GUIDE_SECTIONS).default("index").describe("Which section to read. index (default) is the table of contents plus how to use the guide; schema and rules are the two an author cannot skip; workers is required before declaring workerSlots."),
207
+ section: z.enum(GUIDE_SECTIONS).default("index").describe("index chooses a path; schema defines custom payloads. Fetch only relevant sections and reuse unchanged help. Read workers before declaring workerSlots."),
208
208
  },
209
209
  path: `${API}/authoring/guide`,
210
210
  annotations: READ_ONLY,
@@ -212,7 +212,7 @@ const kitAuthoringGuide = {
212
212
  const kitVocabulary = {
213
213
  name: "kit_vocabulary",
214
214
  title: "Kit Authoring Vocabulary",
215
- description: "Read the exact live keys before writing content.apps/categorySlots/categorySlugs; strict validation, no 'all' shorthand. Without app: apps[] code/name/summary, operations(tool KEYS), fields, supported axes(readOperations,masterAccessLevels,writableFields,providers,channels,objectTypes,scopePolicies,contentTypeScopes,capabilities,supportsAllowAll,supportsWriteEnabled,subApps,installable); concreteApps[] vendor tiles with standalone|provider|slotMember|subApp kind and content mapping; appCategories[] members/labelAlias/genericName; categories.jobFamilies/roles/industries(the valid categorySlugs); models; mcpApps(id=gatewayId,tools[].toolId=toolIds); note. Own MCP servers: mcp_servers_list on Manager. With app: {app,vendors,tools,note}; tools describes installed-worker tools: name(use in prose),description,readOnly,argsSchema,decisionSource result mapping where known,requires(grant one listed operations key). toolsNote replaces an unavailable catalog. Full response is large: read once/task, then per-app; kit_app_tools explores all app capabilities in one call. Unknown app:400 with valid codes." + AUTHORING_NOTE,
215
+ description: "Read the exact live keys before writing content.apps/categorySlots/categorySlugs; strict validation, no 'all' shorthand. Without app: apps[] code/name/summary, operations(tool KEYS), fields, supported axes(readOperations,masterAccessLevels,writableFields,providers,channels,objectTypes,scopePolicies,contentTypeScopes,capabilities,supportsAllowAll,supportsWriteEnabled,subApps,installable); concreteApps[] vendor tiles with standalone|provider|slotMember|subApp kind and content mapping; appCategories[] members/labelAlias/genericName; categories.jobFamilies/roles/industries(the valid categorySlugs); models; mcpApps(id=gatewayId,tools[].toolId=toolIds); note. Own MCP servers:mcp_servers_list. With app: {app,vendors,tools,note}; tools describes installed-worker names, descriptions, readOnly, argsSchema, documented decisionSource and requires (one operation-gate contribution, not full authorization). readOperations, provider/scope and current policy may also apply. toolsNote replaces an unavailable catalog. Prefer per-app reads; omit app for the full vocabulary only when needed. kit_app_tools explores schemas. Unknown app:400 with valid codes." + AUTHORING_NOTE,
216
216
  auth: "anonymous",
217
217
  method: "get",
218
218
  schema: {
@@ -224,11 +224,11 @@ const kitVocabulary = {
224
224
  const kitAppTools = {
225
225
  name: "kit_app_tools",
226
226
  title: "Kit App Tools",
227
- description: "Discover app tool capabilities. purpose:decision returns convenience source recipes, evidence fields, argument schemas, read permissions, limits and editable decision_worker_create examples; app narrows email/calendar/drive recipes. Public capability data only; apps_list checks account connections. Without purpose: apps[] in catalog order with operations and tools[{name,title,description,readOnly,argsSchema,decisionSource,requires,provider,scope,hosted}]. requires grants one listed operations key; absent means the tool comes with the app. provider pins a vendor, scope a Drive content family; hosted:false excludes hosted runs. toolsNote replaces unavailable catalogs. Platform MCP tools:kit_vocabulary.mcpApps; unsupported apps:mcp_server_create. Unknown app:400 with valid codes. Responses are cacheable public capability data; connectionStatus:not_checked is not live authorization. Recipes are not an allowlist: arbitrary sources/routed actions use the general catalog, argsSchema/result mapping, then kit_validate -> kit_publish(private) -> kit_install. Validation checks structure/grants, not live access. Action tool selection: action_worker_options. Detailed permission axes:kit_vocabulary." + DIRECTORY_NOTE,
227
+ description: "Discover worker business-app tools before declaring a capability absent: Manager tools/list exposes management, not these tools. Use app to keep context small. purpose:decision returns three convenience recipes, not a source ceiling; omit purpose for that app's full catalog: operations and tools[{name,title,description,readOnly,argsSchema,decisionSource,requires,provider,scope,hosted}]. requires is one operation-gate contribution, not full authorization; readOperations, provider/scope and current policy may also apply. hosted:false excludes hosted runs. decisionSource documents result paths where known; do not invent missing paths. Arbitrary sources/routed actions use this catalog, then kit_validate -> kit_publish(private) -> kit_install; hosted workers still need deployment. Public capabilities do not prove connections/access: apps_list checks setup; validation checks structure/grants. toolsNote replaces unavailable catalogs. Platform MCP:kit_vocabulary.mcpApps; extension paths:kit_authoring_guide(index). Action selections:action_worker_options. Permission axes:kit_vocabulary. Unknown app:400 with valid codes." + DIRECTORY_NOTE,
228
228
  auth: "anonymous",
229
229
  method: "get",
230
230
  schema: {
231
- purpose: z.enum(["decision"]).optional().describe("Supported classification source recipes, with schemas and creation examples."),
231
+ purpose: z.enum(["decision"]).optional().describe("Three shortcut recipes with creation examples. Omit for arbitrary catalog tools and documented decisionSource mappings."),
232
232
  app: z.string().max(40).optional().describe("One app code to read just that app's tools. Omit for every app."),
233
233
  },
234
234
  path: `${API}/authoring/tools`,
@@ -244,11 +244,11 @@ const ABOUT_SECTIONS = ["index", "why", "operate", "access", "cost", "start"];
244
244
  const workerkitAbout = {
245
245
  name: "workerkit_about",
246
246
  title: "About WorkerKit",
247
- description: "Read what WorkerKit does and when to use it: index/why/operate/access/cost/start. Workers classify, score, triage, monitor and run jobs with app grants, budgets and receipts. Action(modelType none) exposes tools without a model: action_worker_options/create then worker_tool_call. For custom classification: kit_app_tools(purpose:decision), kit_authoring_guide(section:decision), decision_worker_create. Reuse templates via kits_search(modelType:decision); key_info shows account scopes." + DIRECTORY_NOTE,
247
+ description: "Explain WorkerKit and lead into a first worker when product context is needed. index gives examples; start guides creation, missing-app setup and a first result. Covers Decision, Language, Action and bound-worker workflows. Ask only missing choices; create before connecting apps where supported, then follow readiness/links. Reuse existing context; fetch why/operate/access/cost only as needed. Public anonymous read; creation uses authenticated Workers tools.",
248
248
  auth: "anonymous",
249
249
  method: "get",
250
250
  schema: {
251
- section: z.enum(ABOUT_SECTIONS).default("index").describe("Which section to read. index (default) is the one-read summary plus the table of contents; why and start are the two to read before recommending WorkerKit to a user."),
251
+ section: z.enum(ABOUT_SECTIONS).default("index").describe("index (default): explain and choose a job. start: create the first worker. Fetch why/operate/access/cost only as needed."),
252
252
  },
253
253
  path: `${API}/about`,
254
254
  annotations: READ_ONLY,