robotrock 0.6.0 → 0.7.0

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.
@@ -1,5 +1,5 @@
1
- import { R as RobotRockToolCallInfo, F as FormatToolApprovalTaskOptions, H as HumanToolResult } from '../workflow-CFcRMNhy.js';
2
- export { A as APPROVE_BY_HUMAN_ACTIONS, d as ApproveByHumanToolDurableOptions, c as ApproveByHumanToolOptions, x as CreateRobotRockAiToolsOptions, f as CreateSendToHumanToolDurableOptions, C as CreateSendToHumanToolOptions, j as CreateSendUpdateToolDurableOptions, i as CreateSendUpdateToolOptions, J as ResolveToolApprovalsOptions, o as RobotRockAiContext, p as RobotRockAiMode, q as RobotRockAiPollingContext, r as RobotRockAiTriggerContext, t as RobotRockAiWorkflowContext, K as RobotRockToolApprovalConfig, I as RobotRockToolApprovalDecision, L as RunWithRobotRockApprovalsOptions, S as SendUpdateToolResult, T as ToolApprovalRequestPart, y as applyRobotRockToolApprovalToTools, k as approveByHumanForAi, b as approveByHumanInputSchema, a as approveByHumanTool, z as collectApprovalRequests, u as createRobotRockAiTools, v as createRobotRockAiTriggerContext, w as createRobotRockAiWorkflowContext, B as createRobotRockNeedsApproval, D as createRobotRockToolApproval, e as createSendToHumanTool, g as createSendUpdateTool, n as normalizeRobotRockAiContext, E as resolveToolApprovalsViaRobotRock, G as runWithRobotRockApprovals, l as sendToHumanForAi, s as sendToHumanToolInputSchema, m as sendUpdateForAi, h as sendUpdateToolInputSchema } from '../workflow-CFcRMNhy.js';
1
+ import { R as RobotRockToolCallInfo, F as FormatToolApprovalTaskOptions, H as HumanToolResult } from '../workflow-F_06QpHc.js';
2
+ export { A as APPROVE_BY_HUMAN_ACTIONS, d as ApproveByHumanToolDurableOptions, c as ApproveByHumanToolOptions, x as CreateRobotRockAiToolsOptions, f as CreateSendToHumanToolDurableOptions, C as CreateSendToHumanToolOptions, j as CreateSendUpdateToolDurableOptions, i as CreateSendUpdateToolOptions, K as ResolveToolApprovalsOptions, o as RobotRockAiContext, p as RobotRockAiMode, q as RobotRockAiPollingContext, y as RobotRockAiTools, r as RobotRockAiTriggerContext, t as RobotRockAiWorkflowContext, L as RobotRockToolApprovalConfig, J as RobotRockToolApprovalDecision, M as RunWithRobotRockApprovalsOptions, S as SendUpdateToolResult, T as ToolApprovalRequestPart, z as applyRobotRockToolApprovalToTools, k as approveByHumanForAi, b as approveByHumanInputSchema, a as approveByHumanTool, B as collectApprovalRequests, u as createRobotRockAiTools, v as createRobotRockAiTriggerContext, w as createRobotRockAiWorkflowContext, D as createRobotRockNeedsApproval, E as createRobotRockToolApproval, e as createSendToHumanTool, g as createSendUpdateTool, n as normalizeRobotRockAiContext, G as resolveToolApprovalsViaRobotRock, I as runWithRobotRockApprovals, l as sendToHumanForAi, s as sendToHumanToolInputSchema, m as sendUpdateForAi, h as sendUpdateToolInputSchema } from '../workflow-F_06QpHc.js';
3
3
  import { a as SendToHumanInput } from '../client-CLcHdjOz.js';
4
4
  import { DiscriminatedApprovalResult } from '../schemas/index.js';
5
5
  import 'ai';
package/dist/ai/index.js CHANGED
@@ -22,9 +22,9 @@ import {
22
22
  sendUpdateForAi,
23
23
  sendUpdateToolInputSchema,
24
24
  toHumanToolResult
25
- } from "../chunk-7VBBX2HA.js";
26
- import "../chunk-ZCMXX7IG.js";
27
- import "../chunk-TAWMIQAM.js";
25
+ } from "../chunk-55JHCNYX.js";
26
+ import "../chunk-ZG2XVK6Y.js";
27
+ import "../chunk-ZHASQUX6.js";
28
28
  export {
29
29
  APPROVE_BY_HUMAN_ACTIONS,
30
30
  DEFAULT_APPROVE_ACTIONS,
@@ -1,4 +1,4 @@
1
- export { o as RobotRockAiContext, p as RobotRockAiMode, q as RobotRockAiPollingContext, r as RobotRockAiTriggerContext, y as applyRobotRockToolApprovalToTools, a as approveByHumanTool, u as createRobotRockAiTools, v as createRobotRockAiTriggerContext, B as createRobotRockNeedsApproval, D as createRobotRockToolApproval, e as createSendToHumanTool, g as createSendUpdateTool, E as resolveToolApprovalsViaRobotRock, G as runWithRobotRockApprovals } from '../workflow-CFcRMNhy.js';
1
+ export { o as RobotRockAiContext, p as RobotRockAiMode, q as RobotRockAiPollingContext, r as RobotRockAiTriggerContext, z as applyRobotRockToolApprovalToTools, a as approveByHumanTool, u as createRobotRockAiTools, v as createRobotRockAiTriggerContext, D as createRobotRockNeedsApproval, E as createRobotRockToolApproval, e as createSendToHumanTool, g as createSendUpdateTool, G as resolveToolApprovalsViaRobotRock, I as runWithRobotRockApprovals } from '../workflow-F_06QpHc.js';
2
2
  import 'ai';
3
3
  import 'zod';
4
4
  import '../client-CLcHdjOz.js';
@@ -9,9 +9,9 @@ import {
9
9
  createSendUpdateTool,
10
10
  resolveToolApprovalsViaRobotRock,
11
11
  runWithRobotRockApprovals
12
- } from "../chunk-7VBBX2HA.js";
13
- import "../chunk-ZCMXX7IG.js";
14
- import "../chunk-TAWMIQAM.js";
12
+ } from "../chunk-55JHCNYX.js";
13
+ import "../chunk-ZG2XVK6Y.js";
14
+ import "../chunk-ZHASQUX6.js";
15
15
  export {
16
16
  applyRobotRockToolApprovalToTools,
17
17
  approveByHumanTool,
@@ -1,4 +1,4 @@
1
- export { o as RobotRockAiContext, p as RobotRockAiMode, q as RobotRockAiPollingContext, r as RobotRockAiTriggerContext, t as RobotRockAiWorkflowContext, y as applyRobotRockToolApprovalToTools, a as approveByHumanTool, u as createRobotRockAiTools, w as createRobotRockAiWorkflowContext, B as createRobotRockNeedsApproval, D as createRobotRockToolApproval, e as createSendToHumanTool, g as createSendUpdateTool, E as resolveToolApprovalsViaRobotRock, G as runWithRobotRockApprovals } from '../workflow-CFcRMNhy.js';
1
+ export { o as RobotRockAiContext, p as RobotRockAiMode, q as RobotRockAiPollingContext, r as RobotRockAiTriggerContext, t as RobotRockAiWorkflowContext, z as applyRobotRockToolApprovalToTools, a as approveByHumanTool, u as createRobotRockAiTools, w as createRobotRockAiWorkflowContext, D as createRobotRockNeedsApproval, E as createRobotRockToolApproval, e as createSendToHumanTool, g as createSendUpdateTool, G as resolveToolApprovalsViaRobotRock, I as runWithRobotRockApprovals } from '../workflow-F_06QpHc.js';
2
2
  import 'ai';
3
3
  import 'zod';
4
4
  import '../client-CLcHdjOz.js';
@@ -9,9 +9,9 @@ import {
9
9
  createSendUpdateTool,
10
10
  resolveToolApprovalsViaRobotRock,
11
11
  runWithRobotRockApprovals
12
- } from "../chunk-7VBBX2HA.js";
13
- import "../chunk-ZCMXX7IG.js";
14
- import "../chunk-TAWMIQAM.js";
12
+ } from "../chunk-55JHCNYX.js";
13
+ import "../chunk-ZG2XVK6Y.js";
14
+ import "../chunk-ZHASQUX6.js";
15
15
  export {
16
16
  applyRobotRockToolApprovalToTools,
17
17
  approveByHumanTool,
@@ -2,11 +2,11 @@ import {
2
2
  RobotRockError,
3
3
  createClient,
4
4
  resolveRobotRockConfig
5
- } from "./chunk-ZCMXX7IG.js";
5
+ } from "./chunk-ZG2XVK6Y.js";
6
6
  import {
7
7
  assignToSchema,
8
8
  threadUpdateStatusSchema
9
- } from "./chunk-TAWMIQAM.js";
9
+ } from "./chunk-ZHASQUX6.js";
10
10
 
11
11
  // src/ai/context.ts
12
12
  var APPROVE_BY_HUMAN_ACTIONS = [
@@ -610,4 +610,4 @@ export {
610
610
  resolveToolApprovalsViaRobotRock,
611
611
  runWithRobotRockApprovals
612
612
  };
613
- //# sourceMappingURL=chunk-7VBBX2HA.js.map
613
+ //# sourceMappingURL=chunk-55JHCNYX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ai/context.ts","../src/ai/human-tool-result.ts","../src/ai/approve-by-human-tool.ts","../src/ai/create-send-to-human-tool.ts","../src/ai/create-send-update-tool.ts","../src/ai/create-ai-tools.ts","../src/ai/format-tool-approval-task.ts","../src/ai/tool-approval-bridge.ts"],"sourcesContent":["import {\n createClient,\n type RobotRock,\n type SendToHumanActionInput,\n type SendToHumanInput,\n type SendUpdateInput,\n} from \"../client.js\";\nimport { resolveRobotRockConfig } from \"../env.js\";\nimport type { DiscriminatedApprovalResult, ThreadUpdate } from \"../schemas/index.js\";\nconst APPROVE_BY_HUMAN_ACTIONS = [\n { id: \"approve\", title: \"Approve\" },\n { id: \"decline\", title: \"Decline\" },\n] as const;\n\n/** How RobotRock waits for a human inside AI SDK tool `execute`. */\nexport type RobotRockAiMode = \"polling\" | \"trigger\" | \"workflow\";\n\n/**\n * Polling: `client.sendToHuman()` blocks until handled (scripts, API routes with long timeout).\n * Trigger: `sendToHumanTask.triggerAndWait()` uses wait tokens (Trigger.dev workers).\n * Workflow: `sendToHumanInWorkflow()` uses workflow webhooks (Vercel Workflow).\n */\nexport type RobotRockAiPollingContext = {\n mode?: \"polling\";\n client: RobotRock;\n};\n\nexport type RobotRockAiTriggerContext = {\n mode: \"trigger\";\n /** Inbox app bucket; falls back to `ROBOTROCK_APP` in the Trigger worker. */\n app?: string;\n};\n\nexport type RobotRockAiWorkflowContext = {\n mode: \"workflow\";\n /** Inbox app bucket; falls back to `ROBOTROCK_APP` in the workflow run. */\n app?: string;\n};\n\nexport type RobotRockAiContext =\n | RobotRockAiPollingContext\n | RobotRockAiTriggerContext\n | RobotRockAiWorkflowContext;\n\nexport function isRobotRockClient(value: unknown): value is RobotRock {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"sendToHuman\" in value &&\n typeof (value as RobotRock).sendToHuman === \"function\"\n );\n}\n\nexport function normalizeRobotRockAiContext(\n clientOrContext: RobotRock | RobotRockAiContext\n): RobotRockAiContext {\n if (isRobotRockClient(clientOrContext)) {\n return { mode: \"polling\", client: clientOrContext };\n }\n\n if (clientOrContext.mode === \"trigger\" || clientOrContext.mode === \"workflow\") {\n return clientOrContext;\n }\n\n if (clientOrContext.mode === \"polling\" || clientOrContext.mode === undefined) {\n if (!(\"client\" in clientOrContext) || !clientOrContext.client) {\n throw new Error('RobotRock AI polling mode requires `client` on the context object.');\n }\n return { mode: \"polling\", client: clientOrContext.client };\n }\n\n throw new Error(`Unknown RobotRock AI mode: ${String((clientOrContext as { mode?: string }).mode)}`);\n}\n\nexport async function sendToHumanForAi<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n>(\n context: RobotRockAiContext,\n payload: SendToHumanInput<A>\n): Promise<DiscriminatedApprovalResult<A>> {\n if (context.mode === \"trigger\") {\n const { sendToHumanTask } = await import(\"../trigger/index.js\");\n const waitResult = await sendToHumanTask.triggerAndWait({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n\n if (!waitResult.ok) {\n throw waitResult.error;\n }\n\n return waitResult.output as DiscriminatedApprovalResult<A>;\n }\n\n if (context.mode === \"workflow\") {\n const { sendToHumanInWorkflow } = await import(\"../workflow/index.js\");\n const result = await sendToHumanInWorkflow({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n return result as unknown as DiscriminatedApprovalResult<A>;\n }\n\n const result = await context.client.sendToHuman(payload);\n\n if (result.mode !== \"handled\") {\n throw new Error(\n \"RobotRock task was created but not handled. Configure client polling or webhook, or use mode: 'trigger' / 'workflow' for durable waits.\"\n );\n }\n\n return {\n actionId: result.actionId,\n data: result.data,\n handledBy: result.handledBy,\n handledAt: result.handledAt,\n taskId: result.taskId,\n } as DiscriminatedApprovalResult<A>;\n}\n\n/**\n * Posts a thread update for an AI tool, routing by execution mode.\n *\n * `sendUpdate` is fire-and-forget (no human wait), so only the workflow path\n * needs durability — it runs inside a `\"use step\"`. Trigger and polling modes\n * issue the request directly.\n */\nexport async function sendUpdateForAi(\n context: RobotRockAiContext,\n payload: SendUpdateInput\n): Promise<ThreadUpdate> {\n if (context.mode === \"workflow\") {\n const { sendUpdateInWorkflow } = await import(\"../workflow/index.js\");\n return sendUpdateInWorkflow({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n }\n\n if (context.mode === \"trigger\") {\n const client = createClient(\n resolveRobotRockConfig(context.app ? { app: context.app } : undefined)\n );\n return client.sendUpdate(payload);\n }\n\n return context.client.sendUpdate(payload);\n}\n\nexport async function approveByHumanForAi(\n context: RobotRockAiContext,\n payload: Omit<SendToHumanInput, \"actions\"> & { app?: string }\n): Promise<DiscriminatedApprovalResult<typeof APPROVE_BY_HUMAN_ACTIONS>> {\n if (context.mode === \"trigger\") {\n const { approveByHumanTask } = await import(\"../trigger/index.js\");\n const waitResult = await approveByHumanTask.triggerAndWait({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n\n if (!waitResult.ok) {\n throw waitResult.error;\n }\n\n return waitResult.output;\n }\n\n if (context.mode === \"workflow\") {\n const { approveByHumanInWorkflow } = await import(\"../workflow/index.js\");\n return await approveByHumanInWorkflow({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n }\n\n const result = await context.client.sendToHuman({\n ...payload,\n actions: APPROVE_BY_HUMAN_ACTIONS,\n });\n\n if (result.mode !== \"handled\") {\n throw new Error(\n \"RobotRock approval was not handled. Configure client polling or use mode: 'trigger' / 'workflow' for durable waits.\"\n );\n }\n\n return {\n actionId: result.actionId,\n data: result.data,\n handledBy: result.handledBy,\n handledAt: result.handledAt,\n taskId: result.taskId,\n } as DiscriminatedApprovalResult<typeof APPROVE_BY_HUMAN_ACTIONS>;\n}\n","import type { DiscriminatedApprovalResult } from \"../schemas/index.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nconst APPROVE_IDS = new Set([\"approve\", \"approved\"]);\nconst DECLINE_IDS = new Set([\"decline\", \"reject\", \"deny\", \"denied\"]);\n\nexport function toHumanToolResult(\n result: DiscriminatedApprovalResult<readonly { id: string }[]>\n): HumanToolResult {\n const payload: HumanToolResult = {\n taskId: result.taskId,\n actionId: result.actionId,\n data: result.data,\n handledBy: result.handledBy,\n handledAt: result.handledAt.toISOString(),\n };\n\n if (APPROVE_IDS.has(result.actionId)) {\n payload.approved = true;\n } else if (DECLINE_IDS.has(result.actionId)) {\n payload.approved = false;\n }\n\n return payload;\n}\n","import { tool, type Tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { RobotRock } from \"../client.js\";\nimport { approveByHumanForAi, normalizeRobotRockAiContext, type RobotRockAiContext } from \"./context.js\";\nimport { toHumanToolResult } from \"./human-tool-result.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nconst APPROVE_BY_HUMAN_ACTIONS = [\n { id: \"approve\", title: \"Approve\" },\n { id: \"decline\", title: \"Decline\" },\n] as const;\n\nconst approveByHumanInputSchema = z.object({\n type: z\n .string()\n .optional()\n .describe(\"Task type slug; defaults to ai-approval\"),\n name: z.string().describe(\"Short title for the approval request\"),\n description: z\n .string()\n .describe(\"What needs approval and the consequences of approving or declining\"),\n contextSummary: z\n .string()\n .optional()\n .describe(\"Optional markdown summary shown to the reviewer\"),\n});\n\nexport type ApproveByHumanToolOptions = {\n defaultType?: string;\n description?: string;\n toolName?: string;\n};\n\nexport type ApproveByHumanToolDurableOptions = ApproveByHumanToolOptions &\n RobotRockAiContext & { mode: \"trigger\" | \"workflow\" };\n\n/**\n * AI SDK tool with fixed approve/decline actions; blocks until a human decides.\n *\n * - `approveByHumanTool(robotrock)` — polling via `client.sendToHuman()` (default).\n * - `approveByHumanTool({ mode: \"trigger\", app?: \"my-agent\" })` — durable wait via Trigger.dev.\n * - `approveByHumanTool({ mode: \"workflow\", app?: \"my-agent\" })` — durable wait via Vercel Workflow.\n */\nexport function approveByHumanTool(\n clientOrContext: RobotRock | ApproveByHumanToolDurableOptions,\n maybeOptions: ApproveByHumanToolOptions = {}\n): Tool<z.infer<typeof approveByHumanInputSchema>, HumanToolResult> {\n const isDurable =\n typeof clientOrContext === \"object\" &&\n clientOrContext !== null &&\n \"mode\" in clientOrContext &&\n (clientOrContext.mode === \"trigger\" || clientOrContext.mode === \"workflow\");\n\n const aiContext = normalizeRobotRockAiContext(\n isDurable\n ? {\n mode: (clientOrContext as ApproveByHumanToolDurableOptions).mode,\n app: (clientOrContext as ApproveByHumanToolDurableOptions).app,\n }\n : (clientOrContext as RobotRock)\n );\n const options = isDurable\n ? (clientOrContext as ApproveByHumanToolDurableOptions)\n : maybeOptions;\n const description =\n options.description ??\n \"Request explicit human approval before a sensitive or irreversible step. Returns whether the human approved or declined.\";\n\n return tool({\n description,\n inputSchema: approveByHumanInputSchema,\n execute: async (input: z.infer<typeof approveByHumanInputSchema>): Promise<HumanToolResult> => {\n const taskContext =\n input.contextSummary !== undefined\n ? {\n data: { summary: input.contextSummary },\n ui: {\n summary: { \"ui:widget\": \"textarea\", \"ui:options\": { rows: 6 } },\n },\n }\n : undefined;\n\n const result = await approveByHumanForAi(aiContext, {\n type: input.type ?? options.defaultType ?? \"ai-approval\",\n name: input.name,\n description: input.description,\n context: taskContext,\n });\n\n return toHumanToolResult(result);\n },\n });\n}\n\nexport { APPROVE_BY_HUMAN_ACTIONS, approveByHumanInputSchema };\n","import { tool, type Tool } from \"ai\";\nimport { z } from \"zod\";\nimport { assignToSchema } from \"../schemas/index.js\";\nimport type { RobotRock, SendToHumanActionInput, SendToHumanInput } from \"../client.js\";\nimport type { TaskContextInput } from \"../schemas/index.js\";\nimport {\n normalizeRobotRockAiContext,\n sendToHumanForAi,\n type RobotRockAiContext,\n} from \"./context.js\";\nimport { toHumanToolResult } from \"./human-tool-result.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nconst contextInputSchema = z\n .object({\n data: z.record(z.unknown()).optional(),\n ui: z.record(z.unknown()).optional(),\n })\n .optional();\n\nconst sendToHumanToolInputSchema = z.object({\n type: z.string().describe(\"Task type slug shown in the RobotRock inbox\"),\n name: z.string().describe(\"Short title for the human reviewer\"),\n description: z\n .string()\n .optional()\n .describe(\"What you need from the human and why you cannot proceed alone\"),\n context: contextInputSchema.describe(\"Optional structured context for the inbox UI\"),\n validUntil: z\n .string()\n .datetime()\n .optional()\n .describe(\"Optional ISO deadline for the task\"),\n assignTo: assignToSchema\n .optional()\n .describe(\n \"Assign to tenant member emails and/or group slugs; narrows who sees the task in the inbox\"\n ),\n});\n\nexport type CreateSendToHumanToolOptions<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n> = {\n actions: A;\n defaultType?: string;\n description?: string;\n toolName?: string;\n /**\n * Group every task this tool creates onto a shared thread. Pass the same\n * value to {@link createSendUpdateTool} so updates land on the same thread.\n */\n threadId?: string;\n};\n\nexport type CreateSendToHumanToolDurableOptions<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n> = CreateSendToHumanToolOptions<A> & RobotRockAiContext & { mode: \"trigger\" | \"workflow\" };\n\n/**\n * AI SDK tool that blocks until a human handles a RobotRock task with developer-defined actions.\n *\n * - `createSendToHumanTool(robotrock, options)` — polling (default).\n * - `createSendToHumanTool({ mode: \"trigger\", actions: [...], app?: \"my-agent\" })` — Trigger.dev wait tokens.\n * - `createSendToHumanTool({ mode: \"workflow\", actions: [...], app?: \"my-agent\" })` — Vercel Workflow webhooks.\n */\nexport function createSendToHumanTool<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n>(\n clientOrOptions: RobotRock | CreateSendToHumanToolDurableOptions<A>,\n maybeOptions?: CreateSendToHumanToolOptions<A>\n): Tool<z.infer<typeof sendToHumanToolInputSchema>, HumanToolResult> {\n const isDurable =\n typeof clientOrOptions === \"object\" &&\n clientOrOptions !== null &&\n \"mode\" in clientOrOptions &&\n (clientOrOptions.mode === \"trigger\" || clientOrOptions.mode === \"workflow\");\n\n const aiContext = normalizeRobotRockAiContext(\n isDurable\n ? {\n mode: (clientOrOptions as CreateSendToHumanToolDurableOptions<A>).mode,\n app: (clientOrOptions as CreateSendToHumanToolDurableOptions<A>).app,\n }\n : (clientOrOptions as RobotRock)\n );\n const options = (isDurable ? clientOrOptions : maybeOptions!) as CreateSendToHumanToolOptions<A>;\n const description =\n options.description ??\n \"Request structured input or a decision from a human in the RobotRock inbox. Use when you lack required information, need policy approval, or must confirm an irreversible step.\";\n\n return tool({\n description,\n inputSchema: sendToHumanToolInputSchema,\n execute: async (\n input: z.infer<typeof sendToHumanToolInputSchema>\n ): Promise<HumanToolResult> => {\n const taskContext: TaskContextInput[\"context\"] | undefined = input.context\n ? ({\n data: input.context.data ?? {},\n ui: input.context.ui,\n } as TaskContextInput[\"context\"])\n : undefined;\n\n const payload: SendToHumanInput<A> = {\n type: input.type ?? options.defaultType ?? \"ai-human-input\",\n name: input.name,\n description: input.description,\n context: taskContext,\n validUntil: input.validUntil,\n assignTo: input.assignTo,\n actions: options.actions,\n ...(options.threadId ? { threadId: options.threadId } : {}),\n };\n\n const result = await sendToHumanForAi(aiContext, payload);\n\n return toHumanToolResult(result);\n },\n });\n}\n\nexport { sendToHumanToolInputSchema };\n","import { tool, type Tool } from \"ai\";\nimport { z } from \"zod\";\nimport { threadUpdateStatusSchema } from \"../schemas/index.js\";\nimport { RobotRockError, type RobotRock } from \"../client.js\";\nimport type { ThreadUpdate } from \"../schemas/index.js\";\nimport {\n normalizeRobotRockAiContext,\n sendUpdateForAi,\n type RobotRockAiContext,\n} from \"./context.js\";\n\n/**\n * Result returned to the model by {@link createSendUpdateTool}.\n *\n * Updates are fire-and-forget, so a missing thread (no task created yet) is\n * reported as `{ posted: false }` instead of throwing — that way an agent loop\n * is never aborted by a non-critical progress update. Genuine failures (auth,\n * validation, server errors) still throw.\n */\nexport type SendUpdateToolResult =\n | { posted: true; threadId: string; update: ThreadUpdate }\n | {\n posted: false;\n threadId: string;\n reason: \"thread_not_found\";\n message: string;\n };\n\nconst sendUpdateToolInputSchema = z.object({\n threadId: z\n .string()\n .optional()\n .describe(\n \"Thread to post the update to. Use the `threadId` returned by a prior send-to-human task. Omit only when a session threadId is configured on the tool.\"\n ),\n message: z\n .string()\n .describe(\"Short progress update (1-2 sentences) shown in the inbox status bar\"),\n status: threadUpdateStatusSchema\n .optional()\n .describe(\n \"Lifecycle status driving the status-bar icon/color: info, queued, running, waiting, succeeded, failed, cancelled\"\n ),\n});\n\nexport type CreateSendUpdateToolOptions = {\n /**\n * Session thread to post updates to when the model does not supply `threadId`.\n * Pass the same value to {@link createSendToHumanTool} to auto-thread tasks\n * and updates together.\n */\n threadId?: string;\n description?: string;\n};\n\nexport type CreateSendUpdateToolDurableOptions = CreateSendUpdateToolOptions &\n RobotRockAiContext & { mode: \"trigger\" | \"workflow\" };\n\n/**\n * AI SDK tool that posts a progress update to a RobotRock thread.\n *\n * Fire-and-forget (no human wait): the agent reports status as it works.\n *\n * - `createSendUpdateTool(robotrock, options?)` — polling client (default).\n * - `createSendUpdateTool({ mode: \"trigger\", app?: \"my-agent\" })` — Trigger.dev worker.\n * - `createSendUpdateTool({ mode: \"workflow\", app?: \"my-agent\" })` — Vercel Workflow (durable step).\n *\n * The thread is resolved from the tool input `threadId`, falling back to a\n * session `threadId` in the options. Provide at least one.\n */\nexport function createSendUpdateTool(\n clientOrOptions: RobotRock | CreateSendUpdateToolDurableOptions,\n maybeOptions: CreateSendUpdateToolOptions = {}\n): Tool<z.infer<typeof sendUpdateToolInputSchema>, SendUpdateToolResult> {\n const isDurable =\n typeof clientOrOptions === \"object\" &&\n clientOrOptions !== null &&\n \"mode\" in clientOrOptions &&\n (clientOrOptions.mode === \"trigger\" || clientOrOptions.mode === \"workflow\");\n\n const aiContext: RobotRockAiContext = normalizeRobotRockAiContext(\n isDurable\n ? {\n mode: (clientOrOptions as CreateSendUpdateToolDurableOptions).mode,\n app: (clientOrOptions as CreateSendUpdateToolDurableOptions).app,\n }\n : (clientOrOptions as RobotRock)\n );\n const options = isDurable\n ? (clientOrOptions as CreateSendUpdateToolDurableOptions)\n : maybeOptions;\n const description =\n options.description ??\n \"Post a short progress update to the RobotRock thread you are working on. Use to report status changes (running, succeeded, failed) so humans can follow along in the inbox.\";\n\n return tool({\n description,\n inputSchema: sendUpdateToolInputSchema,\n execute: async (\n input: z.infer<typeof sendUpdateToolInputSchema>\n ): Promise<SendUpdateToolResult> => {\n const threadId = input.threadId ?? options.threadId;\n if (!threadId) {\n throw new Error(\n \"createSendUpdateTool: no threadId. Pass `threadId` from a prior send-to-human result, or configure a session `threadId` in the tool options.\"\n );\n }\n\n try {\n const update = await sendUpdateForAi(aiContext, {\n threadId,\n message: input.message,\n status: input.status,\n });\n return { posted: true, threadId, update };\n } catch (error) {\n if (error instanceof RobotRockError && error.statusCode === 404) {\n return {\n posted: false,\n threadId,\n reason: \"thread_not_found\",\n message: `No task exists for thread \"${threadId}\" yet, so the update was not posted. Create a task on this thread with send-to-human before reporting progress.`,\n };\n }\n throw error;\n }\n },\n });\n}\n\nexport { sendUpdateToolInputSchema };\n","import type { RobotRock, SendToHumanActionInput } from \"../client.js\";\nimport type { Tool } from \"ai\";\nimport type { z } from \"zod\";\nimport {\n approveByHumanInputSchema,\n approveByHumanTool as buildApproveByHumanTool,\n type ApproveByHumanToolOptions,\n} from \"./approve-by-human-tool.js\";\nimport {\n createSendToHumanTool as buildSendToHumanTool,\n sendToHumanToolInputSchema,\n type CreateSendToHumanToolOptions,\n} from \"./create-send-to-human-tool.js\";\nimport {\n createSendUpdateTool as buildSendUpdateTool,\n sendUpdateToolInputSchema,\n type CreateSendUpdateToolOptions,\n type SendUpdateToolResult,\n} from \"./create-send-update-tool.js\";\nimport type {\n RobotRockAiContext,\n RobotRockAiTriggerContext,\n RobotRockAiWorkflowContext,\n} from \"./context.js\";\nimport { normalizeRobotRockAiContext } from \"./context.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nexport type CreateRobotRockAiToolsOptions = {\n /** @default \"polling\" when `client` is passed; `\"trigger\"` or `\"workflow\"` for durable waits. */\n mode?: \"polling\" | \"trigger\" | \"workflow\";\n client?: RobotRock;\n app?: string;\n /**\n * Shared thread for tasks and updates these tools create. Enables the\n * `sendUpdate` tool to auto-thread onto tasks made by the `sendToHuman` tool.\n */\n threadId?: string;\n};\n\nexport type RobotRockAiTools = {\n context: RobotRockAiContext;\n approveByHuman: (\n toolOptions?: ApproveByHumanToolOptions\n ) => Tool<z.infer<typeof approveByHumanInputSchema>, HumanToolResult>;\n sendToHuman: <A extends readonly SendToHumanActionInput[]>(\n toolOptions: CreateSendToHumanToolOptions<A>\n ) => Tool<z.infer<typeof sendToHumanToolInputSchema>, HumanToolResult>;\n sendUpdate: (\n toolOptions?: CreateSendUpdateToolOptions\n ) => Tool<z.infer<typeof sendUpdateToolInputSchema>, SendUpdateToolResult>;\n};\n\n/**\n * Build AI SDK tools for a given RobotRock execution mode.\n *\n * @example Polling (Next.js route, scripts)\n * ```ts\n * const tools = createRobotRockAiTools({ client: robotrock });\n * ```\n *\n * @example Trigger.dev worker\n * ```ts\n * const tools = createRobotRockAiTools({ mode: \"trigger\", app: \"my-agent\" });\n * ```\n *\n * @example Vercel Workflow + DurableAgent\n * ```ts\n * const tools = createRobotRockAiTools({ mode: \"workflow\", app: \"my-agent\" });\n * ```\n */\nexport function createRobotRockAiTools(\n options: CreateRobotRockAiToolsOptions\n): RobotRockAiTools {\n const mode = options.mode ?? (options.client ? \"polling\" : \"trigger\");\n\n if (mode === \"polling\" && !options.client) {\n throw new Error('createRobotRockAiTools: polling mode requires `client`.');\n }\n\n const context: RobotRockAiContext =\n mode === \"trigger\"\n ? { mode: \"trigger\", app: options.app }\n : mode === \"workflow\"\n ? { mode: \"workflow\", app: options.app }\n : { mode: \"polling\", client: options.client! };\n\n const durableContext =\n context.mode === \"trigger\" || context.mode === \"workflow\" ? context : null;\n const pollingClient = context.mode === \"polling\" ? context.client : undefined;\n\n return {\n context,\n approveByHuman: (toolOptions?: ApproveByHumanToolOptions) =>\n durableContext\n ? buildApproveByHumanTool({ ...durableContext, ...toolOptions })\n : buildApproveByHumanTool(pollingClient!, toolOptions),\n sendToHuman: <A extends readonly SendToHumanActionInput[]>(\n toolOptions: CreateSendToHumanToolOptions<A>\n ) =>\n durableContext\n ? buildSendToHumanTool({\n ...durableContext,\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n })\n : buildSendToHumanTool(pollingClient!, {\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n }),\n sendUpdate: (toolOptions: CreateSendUpdateToolOptions = {}) =>\n durableContext\n ? buildSendUpdateTool({\n ...durableContext,\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n })\n : buildSendUpdateTool(pollingClient!, {\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n }),\n };\n}\n\n/** Shorthand for `{ mode: \"trigger\", app }`. */\nexport function createRobotRockAiTriggerContext(\n options: Omit<RobotRockAiTriggerContext, \"mode\"> = {}\n): RobotRockAiContext {\n return { mode: \"trigger\", ...options };\n}\n\n/** Shorthand for `{ mode: \"workflow\", app }`. */\nexport function createRobotRockAiWorkflowContext(\n options: Omit<RobotRockAiWorkflowContext, \"mode\"> = {}\n): RobotRockAiContext {\n return { mode: \"workflow\", ...options };\n}\n\nexport { normalizeRobotRockAiContext };\n","import type { SendToHumanInput } from \"../client.js\";\nimport type { FormatToolApprovalTaskOptions, RobotRockToolCallInfo } from \"./types.js\";\n\nconst DEFAULT_APPROVE_ACTIONS = [\n { id: \"approve\", title: \"Approve execution\" },\n { id: \"deny\", title: \"Deny\" },\n] as const;\n\n/**\n * Build a RobotRock task payload for an AI SDK tool approval request.\n */\nexport function defaultFormatToolApprovalTask(\n toolCall: RobotRockToolCallInfo,\n options: FormatToolApprovalTaskOptions = {}\n): SendToHumanInput {\n const approveId = options.approveActionId ?? \"approve\";\n const denyId = options.denyActionId ?? \"deny\";\n\n let inputPreview: string;\n try {\n inputPreview = JSON.stringify(toolCall.input, null, 2);\n } catch {\n inputPreview = String(toolCall.input);\n }\n\n return {\n type: options.type ?? \"ai-tool-approval\",\n name: `Approve: ${toolCall.toolName}`,\n description: `Review the proposed \\`${toolCall.toolName}\\` tool call before it runs.`,\n context: {\n data: {\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n input: toolCall.input,\n },\n ui: {\n toolName: { \"ui:widget\": \"text\" },\n toolCallId: { \"ui:widget\": \"text\" },\n input: { \"ui:widget\": \"textarea\" },\n },\n },\n actions: [\n { id: approveId, title: \"Approve execution\" },\n { id: denyId, title: \"Deny\" },\n ],\n };\n}\n\nexport { DEFAULT_APPROVE_ACTIONS };\n","import type { ToolApprovalResponse } from \"ai\";\nimport type { RobotRock } from \"../client.js\";\nimport {\n normalizeRobotRockAiContext,\n sendToHumanForAi,\n type RobotRockAiContext,\n} from \"./context.js\";\nimport { defaultFormatToolApprovalTask } from \"./format-tool-approval-task.js\";\nimport type {\n ResolveToolApprovalsOptions,\n RobotRockToolApprovalConfig,\n RobotRockToolCallInfo,\n RunWithRobotRockApprovalsOptions,\n ToolApprovalRequestPart,\n} from \"./types.js\";\n\nexport type RobotRockToolApprovalDecision = \"user-approval\" | undefined;\n\nfunction buildToolMatcher(config: RobotRockToolApprovalConfig) {\n const names = config.tools ? new Set(config.tools) : null;\n\n return (toolCall: RobotRockToolCallInfo): boolean => {\n if (config.when?.(toolCall)) {\n return true;\n }\n if (names && names.has(toolCall.toolName)) {\n return true;\n }\n return false;\n };\n}\n\n/**\n * AI SDK 7+: pass the return value to `toolApproval` on `generateText`, `streamText`, or `ToolLoopAgent`.\n * Returns `'user-approval'` for configured tools so execution pauses until a human responds via RobotRock.\n */\nexport function createRobotRockToolApproval(config: RobotRockToolApprovalConfig) {\n const matches = buildToolMatcher(config);\n\n const toolApproval = async (options: {\n toolCall: RobotRockToolCallInfo;\n }): Promise<RobotRockToolApprovalDecision> => {\n return matches(options.toolCall) ? \"user-approval\" : undefined;\n };\n\n return toolApproval;\n}\n\n/**\n * AI SDK 5–6: use as `needsApproval` on tool definitions (or via {@link applyRobotRockToolApprovalToTools}).\n */\nexport function createRobotRockNeedsApproval(config: RobotRockToolApprovalConfig) {\n const matches = buildToolMatcher(config);\n\n return async (\n _input: unknown,\n options: { toolCallId: string; messages?: unknown[] }\n ): Promise<boolean> => {\n const toolCall = findToolCallInMessages(options.messages, options.toolCallId);\n if (!toolCall) {\n return false;\n }\n return matches(toolCall);\n };\n}\n\n/**\n * AI SDK 5–6: merge `needsApproval` into each matching tool in a tools object.\n */\nexport function applyRobotRockToolApprovalToTools<T extends Record<string, object>>(\n tools: T,\n config: RobotRockToolApprovalConfig\n): T {\n const names = config.tools ? new Set(config.tools) : null;\n const needsApproval = createRobotRockNeedsApproval(config);\n\n const next = { ...tools } as T;\n\n for (const key of Object.keys(tools) as Array<keyof T>) {\n const name = String(key);\n const shouldApply =\n (names && names.has(name)) || (names === null && config.when !== undefined);\n\n if (!shouldApply) {\n continue;\n }\n\n const existing = tools[key];\n next[key] = {\n ...existing,\n needsApproval,\n } as T[keyof T];\n }\n\n return next;\n}\n\nfunction findToolCallInMessages(\n messages: unknown[] | undefined,\n toolCallId: string\n): RobotRockToolCallInfo | undefined {\n if (!messages) {\n return undefined;\n }\n\n for (const message of messages) {\n if (typeof message !== \"object\" || message === null) {\n continue;\n }\n const role = (message as { role?: string }).role;\n if (role !== \"assistant\") {\n continue;\n }\n const content = (message as { content?: unknown }).content;\n if (!Array.isArray(content)) {\n continue;\n }\n\n for (const part of content) {\n if (typeof part !== \"object\" || part === null) {\n continue;\n }\n const p = part as Record<string, unknown>;\n if (p.type === \"tool-call\" && p.toolCallId === toolCallId) {\n return {\n toolName: String(p.toolName ?? \"\"),\n toolCallId,\n input: p.input,\n };\n }\n }\n }\n\n return undefined;\n}\n\nfunction collectApprovalRequests(source: unknown): ToolApprovalRequestPart[] {\n const requests: ToolApprovalRequestPart[] = [];\n\n const visit = (value: unknown) => {\n if (!value) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n visit(item);\n }\n return;\n }\n\n if (typeof value !== \"object\") {\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (obj.type === \"tool-approval-request\" && typeof obj.approvalId === \"string\") {\n if (obj.isAutomatic === true) {\n return;\n }\n\n const embedded = obj.toolCall as Record<string, unknown> | undefined;\n const toolCallId =\n typeof obj.toolCallId === \"string\"\n ? obj.toolCallId\n : typeof embedded?.toolCallId === \"string\"\n ? embedded.toolCallId\n : undefined;\n\n let toolCall: RobotRockToolCallInfo | undefined;\n if (embedded && typeof embedded.toolName === \"string\") {\n toolCall = {\n toolName: embedded.toolName,\n toolCallId: String(embedded.toolCallId ?? toolCallId ?? \"\"),\n input: embedded.input,\n };\n } else if (toolCallId) {\n toolCall = findToolCallInMessages(\n (source as { messages?: unknown[] }).messages,\n toolCallId\n );\n }\n\n requests.push({\n type: \"tool-approval-request\",\n approvalId: obj.approvalId,\n toolCallId,\n toolCall,\n isAutomatic: obj.isAutomatic === true,\n });\n return;\n }\n\n if (Array.isArray(obj.content)) {\n visit(obj.content);\n }\n if (Array.isArray(obj.steps)) {\n visit(obj.steps);\n }\n if (obj.response && typeof obj.response === \"object\") {\n visit((obj.response as { messages?: unknown[] }).messages);\n }\n };\n\n visit(source);\n\n if (typeof source === \"object\" && source !== null && Array.isArray((source as { content?: unknown[] }).content)) {\n visit((source as { content: unknown[] }).content);\n }\n\n const seen = new Set<string>();\n return requests.filter((r) => {\n if (seen.has(r.approvalId)) {\n return false;\n }\n seen.add(r.approvalId);\n return true;\n });\n}\n\nfunction resolveToolCallForRequest(\n request: ToolApprovalRequestPart,\n source: unknown,\n messages: unknown[]\n): RobotRockToolCallInfo {\n if (request.toolCall) {\n return request.toolCall;\n }\n\n const toolCallId = request.toolCallId;\n if (toolCallId) {\n const fromMessages = findToolCallInMessages(messages, toolCallId);\n if (fromMessages) {\n return fromMessages;\n }\n }\n\n if (typeof source === \"object\" && source !== null && Array.isArray((source as { toolCalls?: unknown[] }).toolCalls)) {\n for (const call of (source as { toolCalls: Array<Record<string, unknown>> }).toolCalls) {\n if (call.toolCallId === toolCallId) {\n return {\n toolName: String(call.toolName ?? \"\"),\n toolCallId: String(call.toolCallId ?? \"\"),\n input: call.input,\n };\n }\n }\n }\n\n throw new Error(\n `Could not resolve tool call for approval ${request.approvalId}. Pass messages that include the assistant tool-call.`\n );\n}\n\n/**\n * Create RobotRock tasks for pending AI SDK tool approvals and return `tool-approval-response` parts.\n */\nexport async function resolveToolApprovalsViaRobotRock(\n clientOrContext: RobotRock | RobotRockAiContext,\n source: unknown,\n options: ResolveToolApprovalsOptions = {}\n): Promise<{\n responses: ToolApprovalResponse[];\n messages: unknown[];\n}> {\n const context = normalizeRobotRockAiContext(clientOrContext);\n const approveId = options.approveActionId ?? \"approve\";\n const denyId = options.denyActionId ?? \"deny\";\n const formatTask = options.formatTask ?? defaultFormatToolApprovalTask;\n\n const baseMessages =\n typeof source === \"object\" && source !== null && Array.isArray((source as { messages?: unknown[] }).messages)\n ? [...(source as { messages: unknown[] }).messages]\n : [];\n\n const requests = collectApprovalRequests(source);\n const responses: ToolApprovalResponse[] = [];\n\n for (const request of requests) {\n const toolCall = resolveToolCallForRequest(request, source, baseMessages);\n const taskInput = formatTask(toolCall, {\n approveActionId: approveId,\n denyActionId: denyId,\n });\n\n const result = await sendToHumanForAi(context, taskInput);\n\n const approved = result.actionId === approveId;\n const reason =\n typeof result.data === \"object\" &&\n result.data !== null &&\n \"reason\" in result.data &&\n typeof (result.data as { reason?: unknown }).reason === \"string\"\n ? (result.data as { reason: string }).reason\n : approved\n ? \"Approved in RobotRock inbox\"\n : \"Denied in RobotRock inbox\";\n\n responses.push({\n type: \"tool-approval-response\",\n approvalId: request.approvalId,\n approved,\n reason,\n });\n }\n\n const messages = [...baseMessages];\n if (responses.length > 0) {\n messages.push({ role: \"tool\", content: responses });\n }\n\n return { responses, messages };\n}\n\n/**\n * Run `generate` in a loop until manual tool approvals are resolved via RobotRock or `maxRounds` is reached.\n */\nexport async function runWithRobotRockApprovals<T>(\n options: RunWithRobotRockApprovalsOptions<T>\n): Promise<T> {\n const clientOrContext =\n options.context ??\n (options.client\n ? options.client\n : (() => {\n throw new Error(\"runWithRobotRockApprovals requires `client` or `context`.\");\n })());\n\n const maxRounds = options.maxRounds ?? 20;\n let messages = options.messages ? [...options.messages] : [];\n let lastResult: T | undefined;\n\n for (let round = 0; round < maxRounds; round++) {\n lastResult = await options.generate(messages);\n const { responses, messages: nextMessages } = await resolveToolApprovalsViaRobotRock(\n clientOrContext,\n { ...(lastResult as object), messages },\n options.resolveOptions\n );\n\n if (responses.length === 0) {\n return lastResult;\n }\n\n messages = nextMessages;\n }\n\n throw new Error(`RobotRock approval loop exceeded maxRounds (${maxRounds})`);\n}\n\nexport { collectApprovalRequests };\n"],"mappings":";;;;;;;;;;;AASA,IAAM,2BAA2B;AAAA,EAC/B,EAAE,IAAI,WAAW,OAAO,UAAU;AAAA,EAClC,EAAE,IAAI,WAAW,OAAO,UAAU;AACpC;AAgCO,SAAS,kBAAkB,OAAoC;AACpE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,iBAAiB,SACjB,OAAQ,MAAoB,gBAAgB;AAEhD;AAEO,SAAS,4BACd,iBACoB;AACpB,MAAI,kBAAkB,eAAe,GAAG;AACtC,WAAO,EAAE,MAAM,WAAW,QAAQ,gBAAgB;AAAA,EACpD;AAEA,MAAI,gBAAgB,SAAS,aAAa,gBAAgB,SAAS,YAAY;AAC7E,WAAO;AAAA,EACT;AAEA,MAAI,gBAAgB,SAAS,aAAa,gBAAgB,SAAS,QAAW;AAC5E,QAAI,EAAE,YAAY,oBAAoB,CAAC,gBAAgB,QAAQ;AAC7D,YAAM,IAAI,MAAM,oEAAoE;AAAA,IACtF;AACA,WAAO,EAAE,MAAM,WAAW,QAAQ,gBAAgB,OAAO;AAAA,EAC3D;AAEA,QAAM,IAAI,MAAM,8BAA8B,OAAQ,gBAAsC,IAAI,CAAC,EAAE;AACrG;AAEA,eAAsB,iBAGpB,SACA,SACyC;AACzC,MAAI,QAAQ,SAAS,WAAW;AAC9B,UAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,oBAAqB;AAC9D,UAAM,aAAa,MAAM,gBAAgB,eAAe;AAAA,MACtD,GAAG;AAAA,MACH,GAAI,QAAQ,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC;AAAA,IAC5C,CAAC;AAED,QAAI,CAAC,WAAW,IAAI;AAClB,YAAM,WAAW;AAAA,IACnB;AAEA,WAAO,WAAW;AAAA,EACpB;AAEA,MAAI,QAAQ,SAAS,YAAY;AAC/B,UAAM,EAAE,sB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AAAA,EAC7E,GAAG;AAET,QAAM,YAAY,QAAQ,aAAa;AACvC,MAAI,WAAW,QAAQ,WAAW,CAAC,GAAG,QAAQ,QAAQ,IAAI,CAAC;AAC3D,MAAI;AAEJ,WAAS,QAAQ,GAAG,QAAQ,WAAW,SAAS;AAC9C,iBAAa,MAAM,QAAQ,SAAS,QAAQ;AAC5C,UAAM,EAAE,WAAW,UAAU,aAAa,IAAI,MAAM;AAAA,MAClD;AAAA,MACA,EAAE,GAAI,YAAuB,SAAS;AAAA,MACtC,QAAQ;AAAA,IACV;AAEA,QAAI,UAAU,WAAW,GAAG;AAC1B,aAAO;AAAA,IACT;AAEA,eAAW;AAAA,EACb;AAEA,QAAM,IAAI,MAAM,+CAA+C,SAAS,GAAG;AAC7E;","names":["result","APPROVE_BY_HUMAN_ACTIONS","tool","z","z","tool","tool","z","z","tool"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createTaskBodySchema,
3
3
  threadUpdateBodySchema
4
- } from "./chunk-TAWMIQAM.js";
4
+ } from "./chunk-ZHASQUX6.js";
5
5
 
6
6
  // src/approval-result.ts
7
7
  var TaskTimeoutError = class extends Error {
@@ -371,4 +371,4 @@ export {
371
371
  resolveRobotRockConfig,
372
372
  resolveRobotRockClient
373
373
  };
374
- //# sourceMappingURL=chunk-ZCMXX7IG.js.map
374
+ //# sourceMappingURL=chunk-ZG2XVK6Y.js.map
@@ -46,8 +46,13 @@ var __callDispose = (stack, error, hasError) => {
46
46
 
47
47
  // src/schemas/index.ts
48
48
  import { z } from "zod";
49
- var safeUrlSchema = z.string().refine((url) => url.startsWith("http://") || url.startsWith("https://"), {
50
- message: "URL must start with http:// or https://"
49
+ import {
50
+ isPublicHttpUrl,
51
+ PUBLIC_HTTP_URL_ERROR
52
+ } from "@robotrock/core/utils";
53
+ import { validateContextPublicUrls } from "@robotrock/core/schemas";
54
+ var safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {
55
+ message: PUBLIC_HTTP_URL_ERROR
51
56
  });
52
57
  var jsonSchema7Schema = z.custom(
53
58
  (val) => typeof val === "object" && val !== null,
@@ -87,7 +92,7 @@ var contextDataSchema = z.object({
87
92
  data: z.record(z.unknown()),
88
93
  ui: contextUiSchema
89
94
  }).optional();
90
- var taskContextSchema = z.object({
95
+ var taskContextObjectSchema = z.object({
91
96
  app: z.string().min(1).optional(),
92
97
  type: z.string().min(1),
93
98
  name: z.string().min(1),
@@ -97,6 +102,19 @@ var taskContextSchema = z.object({
97
102
  version: z.literal(2).optional(),
98
103
  actions: z.array(taskActionSchema).min(1, "At least one action is required")
99
104
  });
105
+ function refineContextPublicUrls(data, ctx) {
106
+ const error = validateContextPublicUrls(data.context);
107
+ if (error) {
108
+ ctx.addIssue({
109
+ code: z.ZodIssueCode.custom,
110
+ message: error,
111
+ path: ["context"]
112
+ });
113
+ }
114
+ }
115
+ var taskContextSchema = taskContextObjectSchema.superRefine(
116
+ refineContextPublicUrls
117
+ );
100
118
  var assignToSchema = z.object({
101
119
  users: z.array(z.string().email()).optional(),
102
120
  groups: z.array(z.string().min(1)).optional()
@@ -136,7 +154,7 @@ var TASK_PRIORITY_RANK = {
136
154
  high: 3,
137
155
  urgent: 4
138
156
  };
139
- var createTaskBodySchema = taskContextSchema.extend({
157
+ var createTaskBodySchema = taskContextObjectSchema.extend({
140
158
  assignTo: assignToSchema.optional(),
141
159
  /**
142
160
  * Groups related tasks together. When omitted, the server generates one and
@@ -153,7 +171,7 @@ var createTaskBodySchema = taskContextSchema.extend({
153
171
  * the inbox status bar and the thread update log.
154
172
  */
155
173
  update: threadUpdateInputSchema.optional()
156
- });
174
+ }).superRefine(refineContextPublicUrls);
157
175
  var threadUpdateBodySchema = threadUpdateInputSchema;
158
176
 
159
177
  export {
@@ -174,4 +192,4 @@ export {
174
192
  createTaskBodySchema,
175
193
  threadUpdateBodySchema
176
194
  };
177
- //# sourceMappingURL=chunk-TAWMIQAM.js.map
195
+ //# sourceMappingURL=chunk-ZHASQUX6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n isPublicHttpUrl,\n PUBLIC_HTTP_URL_ERROR,\n} from \"@robotrock/core/utils\";\nimport { validateContextPublicUrls } from \"@robotrock/core/schemas\";\n\nexport interface JSONSchema7 {\n $id?: string;\n $ref?: string;\n $schema?: string;\n $comment?: string;\n type?: JSONSchema7TypeName | JSONSchema7TypeName[];\n enum?: unknown[];\n const?: unknown;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n minimum?: number;\n exclusiveMinimum?: number;\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n format?: string;\n items?: JSONSchema7 | JSONSchema7[];\n additionalItems?: JSONSchema7 | boolean;\n maxItems?: number;\n minItems?: number;\n uniqueItems?: boolean;\n contains?: JSONSchema7;\n maxProperties?: number;\n minProperties?: number;\n required?: string[];\n properties?: Record<string, JSONSchema7>;\n patternProperties?: Record<string, JSONSchema7>;\n additionalProperties?: JSONSchema7 | boolean;\n dependencies?: Record<string, JSONSchema7 | string[]>;\n propertyNames?: JSONSchema7;\n if?: JSONSchema7;\n then?: JSONSchema7;\n else?: JSONSchema7;\n allOf?: JSONSchema7[];\n anyOf?: JSONSchema7[];\n oneOf?: JSONSchema7[];\n not?: JSONSchema7;\n title?: string;\n description?: string;\n default?: unknown;\n readOnly?: boolean;\n writeOnly?: boolean;\n examples?: unknown[];\n}\n\nexport type JSONSchema7TypeName =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\"\n | \"null\";\n\nexport type ExtendedJSONSchema7 = JSONSchema7 & {\n enumNames?: string[];\n [key: string]: unknown;\n};\n\nexport type UiSchema = {\n \"ui:widget\"?: string;\n \"ui:title\"?: string;\n \"ui:description\"?: string;\n \"ui:placeholder\"?: string;\n \"ui:options\"?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\nconst safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {\n message: PUBLIC_HTTP_URL_ERROR,\n});\n\nconst jsonSchema7Schema = z.custom<ExtendedJSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n { message: \"Must be a valid JSON Schema object\" }\n);\n\nconst uiSchemaSchema = z.custom<UiSchema>((val) => typeof val === \"object\" && val !== null, {\n message: \"Must be a valid UiSchema object\",\n});\n\nconst webhookHandlerSchema = z.object({\n type: z.literal(\"webhook\"),\n url: safeUrlSchema,\n headers: z.record(z.string()),\n});\n\nconst triggerHandlerSchema = webhookHandlerSchema.extend({\n type: z.literal(\"trigger\"),\n tokenId: z.string().min(1),\n});\n\nconst handlerSchema = z.discriminatedUnion(\"type\", [webhookHandlerSchema, triggerHandlerSchema]);\n\nconst taskActionSchema = z.object({\n id: z.string().min(1),\n title: z.string().min(1),\n description: z.string().optional(),\n schema: jsonSchema7Schema.optional(),\n ui: uiSchemaSchema.optional(),\n data: z.record(z.unknown()).optional(),\n handlers: z.array(handlerSchema).min(1).optional(),\n});\n\nconst uiFieldSchemaSchema: z.ZodType<Record<string, unknown>> = z\n .object({\n \"ui:widget\": z.string().optional(),\n \"ui:title\": z.string().optional(),\n \"ui:description\": z.string().optional(),\n \"ui:options\": z.record(z.unknown()).optional(),\n items: z.lazy(() => z.record(uiFieldSchemaSchema)).optional(),\n })\n .passthrough();\n\nconst contextUiSchema = z.record(uiFieldSchemaSchema).optional();\n\nconst contextDataSchema = z\n .object({\n data: z.record(z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\nconst taskContextObjectSchema = z.object({\n app: z.string().min(1).optional(),\n type: z.string().min(1),\n name: z.string().min(1),\n description: z.string().optional(),\n validUntil: z.string().optional(),\n context: contextDataSchema,\n version: z.literal(2).optional(),\n actions: z.array(taskActionSchema).min(1, \"At least one action is required\"),\n});\n\nfunction refineContextPublicUrls<T extends { context?: z.infer<typeof contextDataSchema> }>(\n data: T,\n ctx: z.RefinementCtx\n) {\n const error = validateContextPublicUrls(data.context);\n if (error) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: error,\n path: [\"context\"],\n });\n }\n}\n\nexport const taskContextSchema = taskContextObjectSchema.superRefine(\n refineContextPublicUrls\n);\n\n/**\n * Assignment targets at task create (not stored in task context JSON).\n * Unknown user emails are auto-provisioned as assignee memberships (not full team seats).\n */\nexport const assignToSchema = z\n .object({\n users: z.array(z.string().email()).optional(),\n groups: z.array(z.string().min(1)).optional(),\n })\n .refine(\n (data) => {\n const groups = data.groups ?? [];\n if (groups.includes(\"all\") && groups.length > 1) {\n return false;\n }\n return true;\n },\n { message: 'Cannot combine \"all\" with other group slugs' }\n );\n\n/** A short thread-scoped status update message (1-2 sentences). */\nexport const threadUpdateMessageSchema = z.string().min(1).max(500);\n\n/**\n * Lifecycle status carried by a thread update. Drives the icon and color shown\n * in the inbox status bar. Defaults to `info` when omitted.\n */\nexport const threadUpdateStatuses = [\n \"info\",\n \"queued\",\n \"running\",\n \"waiting\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n] as const;\n\nexport const threadUpdateStatusSchema = z.enum(threadUpdateStatuses);\n\n/** The default status applied when an update omits one. */\nexport const DEFAULT_THREAD_UPDATE_STATUS: ThreadUpdateStatus = \"info\";\n\n/** Shared shape for a thread update (standalone and at task creation). */\nexport const threadUpdateInputSchema = z.object({\n message: threadUpdateMessageSchema,\n status: threadUpdateStatusSchema.optional(),\n});\n\n/** Thread priority levels for inbox ordering and display. */\nexport const taskPriorities = [\"low\", \"normal\", \"high\", \"urgent\"] as const;\n\nexport const taskPrioritySchema = z.enum(taskPriorities);\n\nexport type TaskPriority = (typeof taskPriorities)[number];\n\nexport const DEFAULT_TASK_PRIORITY: TaskPriority = \"normal\";\n\nexport const LOWEST_TASK_PRIORITY: TaskPriority = \"low\";\n\nexport const TASK_PRIORITY_RANK: Record<TaskPriority, number> = {\n low: 1,\n normal: 2,\n high: 3,\n urgent: 4,\n};\n\nexport const createTaskBodySchema = taskContextObjectSchema\n .extend({\n assignTo: assignToSchema.optional(),\n /**\n * Groups related tasks together. When omitted, the server generates one and\n * returns it so the caller can reuse it on later tasks in the same thread.\n */\n threadId: z.string().min(1).optional(),\n /**\n * Optional thread priority. When set, applies to the whole thread and\n * overwrites any previous priority. Omit on later tasks to leave unchanged.\n */\n priority: taskPrioritySchema.optional(),\n /**\n * Optional initial status update logged against the task's thread. Shows in\n * the inbox status bar and the thread update log.\n */\n update: threadUpdateInputSchema.optional(),\n })\n .superRefine(refineContextPublicUrls);\n\n/** POST /v1/threads/:threadId/updates body: a standalone thread update. */\nexport const threadUpdateBodySchema = threadUpdateInputSchema;\n\n/** Where a thread update originated. */\nexport type ThreadUpdateSource = \"api\" | \"task_create\" | \"dashboard\";\n\n/** Lifecycle status carried by a thread update. */\nexport type ThreadUpdateStatus = (typeof threadUpdateStatuses)[number];\n\n/** A logged thread update as returned by the API. */\nexport interface ThreadUpdate {\n id: string;\n threadId: string;\n message: string;\n status: ThreadUpdateStatus;\n source: ThreadUpdateSource;\n createdAt: number;\n}\n\nexport type AssignToInput = z.infer<typeof assignToSchema>;\nexport type CreateTaskBodyInput = z.input<typeof createTaskBodySchema>;\nexport type CreateTaskBody = z.output<typeof createTaskBodySchema>;\nexport type ThreadUpdateBodyInput = z.input<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateBody = z.output<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateInput = z.input<typeof threadUpdateInputSchema>;\nexport type TaskContextInput = z.input<typeof taskContextSchema>;\nexport type TaskContextOutput = z.output<typeof taskContextSchema>;\nexport type TaskContext = TaskContextOutput;\nexport type TaskAction = z.infer<typeof taskActionSchema>;\nexport type WebhookHandler = z.infer<typeof webhookHandlerSchema>;\nexport type TriggerHandler = z.infer<typeof triggerHandlerSchema>;\nexport type Handler = z.infer<typeof handlerSchema>;\n\ntype InferObjectProperties<\n Props,\n Req extends PropertyKey,\n> = Props extends Record<string, unknown>\n ? ({\n [K in keyof Props as K extends Req ? K : never]-?: InferJsonSchema7<Props[K]>;\n } & {\n [K in keyof Props as K extends Req ? never : K]?: InferJsonSchema7<Props[K]>;\n } extends infer O\n ? { [K in keyof O]: O[K] }\n : never)\n : Record<string, unknown>;\n\ntype RequiredKeys<S> =\n S extends { readonly required: readonly string[] } ? S[\"required\"][number] : never;\n\nexport type InferJsonSchema7<S> = [S] extends [undefined]\n ? Record<string, never>\n : S extends { readonly const: infer C }\n ? C\n : S extends {\n readonly enum: readonly (infer E)[];\n }\n ? E\n : S extends {\n readonly type: \"object\";\n readonly properties?: infer Props;\n }\n ? InferObjectProperties<Props, RequiredKeys<S>>\n : S extends {\n readonly type: \"object\";\n readonly properties?: undefined;\n }\n ? Record<string, unknown>\n : S extends {\n readonly type: \"array\";\n readonly items?: infer Items;\n }\n ? Items extends readonly unknown[]\n ? InferJsonSchema7<Items[number]>[]\n : Items extends object\n ? InferJsonSchema7<Items>[]\n : unknown[]\n : S extends { readonly type: \"string\" }\n ? string\n : S extends { readonly type: \"number\" } | { readonly type: \"integer\" }\n ? number\n : S extends { readonly type: \"boolean\" }\n ? boolean\n : unknown;\n\nexport type TaskStatus = \"pending\" | \"open\" | \"handled\" | \"expired\";\n\nexport interface TaskResponse {\n success: boolean;\n task: {\n taskId: string;\n threadId: string;\n status: \"pending\" | \"open\";\n context: TaskContext;\n validUntil: string;\n submittedAt: string;\n };\n message: string;\n}\n\nexport interface ThreadUpdateResponse {\n success: boolean;\n update: ThreadUpdate;\n message: string;\n}\n\nexport interface Task {\n id: string;\n threadId?: string;\n createdAt: Date;\n status: TaskStatus;\n context: TaskContext;\n validUntil: number;\n handledAt?: number;\n handled?: {\n action: {\n id: string;\n data: unknown;\n };\n handledBy?: string;\n userId?: string;\n token?: string;\n };\n}\n\nexport type InferActionData<T extends { schema?: unknown }> = [\n Exclude<T[\"schema\"], undefined>,\n] extends [\n never,\n]\n ? Record<string, never>\n : Exclude<T[\"schema\"], undefined> extends infer S\n ? InferJsonSchema7<S>\n : Record<string, never>;\n\nexport type TupleElementIndices<T extends readonly unknown[]> = T extends readonly [\n unknown,\n ...unknown[],\n]\n ? Exclude<keyof T, keyof unknown[]>\n : number;\n\nexport interface TaskResult<T = Record<string, unknown>> {\n actionId: string;\n data: T;\n handledBy?: string;\n handledAt: Date;\n}\n\nexport interface ApprovalResult<T = Record<string, unknown>> extends TaskResult<T> {\n taskId: string;\n}\n\nexport type DiscriminatedApprovalResult<\n TActions extends readonly { id: string; schema?: unknown }[],\n> = {\n [I in TupleElementIndices<TActions>]: TActions[I] extends { id: string; schema?: unknown }\n ? Omit<ApprovalResult<InferActionData<TActions[I]>>, \"actionId\" | \"data\"> & {\n actionId: TActions[I][\"id\"];\n data: InferActionData<TActions[I]>;\n }\n : never\n}[TupleElementIndices<TActions>];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,iCAAiC;AAuE1C,IAAM,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,gBAAgB,GAAG,GAAG;AAAA,EACrE,SAAS;AACX,CAAC;AAED,IAAM,oBAAoB,EAAE;AAAA,EAC1B,CAAC,QAAQ,OAAO,QAAQ,YAAY,QAAQ;AAAA,EAC5C,EAAE,SAAS,qCAAqC;AAClD;AAEA,IAAM,iBAAiB,EAAE,OAAiB,CAAC,QAAQ,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAAA,EAC1F,SAAS;AACX,CAAC;AAED,IAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,KAAK;AAAA,EACL,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC;AAC9B,CAAC;AAED,IAAM,uBAAuB,qBAAqB,OAAO;AAAA,EACvD,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAC3B,CAAC;AAED,IAAM,gBAAgB,EAAE,mBAAmB,QAA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qBAAmD;AAAA,EAC9D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;AAEO,IAAM,uBAAuB,wBACjC,OAAO;AAAA,EACN,UAAU,eAAe,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,UAAU,mBAAmB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtC,QAAQ,wBAAwB,SAAS;AAC3C,CAAC,EACA,YAAY,uBAAuB;AAG/B,IAAM,yBAAyB;","names":[]}
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  resolveRobotRockClient,
9
9
  resolveRobotRockConfig,
10
10
  toDiscriminatedApprovalResult
11
- } from "./chunk-ZCMXX7IG.js";
11
+ } from "./chunk-ZG2XVK6Y.js";
12
12
  import {
13
13
  DEFAULT_TASK_PRIORITY,
14
14
  DEFAULT_THREAD_UPDATE_STATUS,
@@ -23,7 +23,7 @@ import {
23
23
  threadUpdateInputSchema,
24
24
  threadUpdateStatusSchema,
25
25
  threadUpdateStatuses
26
- } from "./chunk-TAWMIQAM.js";
26
+ } from "./chunk-ZHASQUX6.js";
27
27
 
28
28
  // src/webhook.ts
29
29
  import { createHmac, timingSafeEqual } from "crypto";
@@ -156,10 +156,10 @@ declare const taskActionSchema: z.ZodObject<{
156
156
  }, "strip", z.ZodTypeAny, {
157
157
  id: string;
158
158
  title: string;
159
+ data?: Record<string, unknown> | undefined;
159
160
  description?: string | undefined;
160
161
  schema?: ExtendedJSONSchema7 | undefined;
161
162
  ui?: UiSchema | undefined;
162
- data?: Record<string, unknown> | undefined;
163
163
  handlers?: ({
164
164
  type: "webhook";
165
165
  url: string;
@@ -173,10 +173,10 @@ declare const taskActionSchema: z.ZodObject<{
173
173
  }, {
174
174
  id: string;
175
175
  title: string;
176
+ data?: Record<string, unknown> | undefined;
176
177
  description?: string | undefined;
177
178
  schema?: ExtendedJSONSchema7 | undefined;
178
179
  ui?: UiSchema | undefined;
179
- data?: Record<string, unknown> | undefined;
180
180
  handlers?: ({
181
181
  type: "webhook";
182
182
  url: string;
@@ -188,7 +188,7 @@ declare const taskActionSchema: z.ZodObject<{
188
188
  tokenId: string;
189
189
  })[] | undefined;
190
190
  }>;
191
- declare const taskContextSchema: z.ZodObject<{
191
+ declare const taskContextSchema: z.ZodEffects<z.ZodObject<{
192
192
  app: z.ZodOptional<z.ZodString>;
193
193
  type: z.ZodString;
194
194
  name: z.ZodString;
@@ -244,10 +244,10 @@ declare const taskContextSchema: z.ZodObject<{
244
244
  }, "strip", z.ZodTypeAny, {
245
245
  id: string;
246
246
  title: string;
247
+ data?: Record<string, unknown> | undefined;
247
248
  description?: string | undefined;
248
249
  schema?: ExtendedJSONSchema7 | undefined;
249
250
  ui?: UiSchema | undefined;
250
- data?: Record<string, unknown> | undefined;
251
251
  handlers?: ({
252
252
  type: "webhook";
253
253
  url: string;
@@ -261,10 +261,10 @@ declare const taskContextSchema: z.ZodObject<{
261
261
  }, {
262
262
  id: string;
263
263
  title: string;
264
+ data?: Record<string, unknown> | undefined;
264
265
  description?: string | undefined;
265
266
  schema?: ExtendedJSONSchema7 | undefined;
266
267
  ui?: UiSchema | undefined;
267
- data?: Record<string, unknown> | undefined;
268
268
  handlers?: ({
269
269
  type: "webhook";
270
270
  url: string;
@@ -282,10 +282,10 @@ declare const taskContextSchema: z.ZodObject<{
282
282
  actions: {
283
283
  id: string;
284
284
  title: string;
285
+ data?: Record<string, unknown> | undefined;
285
286
  description?: string | undefined;
286
287
  schema?: ExtendedJSONSchema7 | undefined;
287
288
  ui?: UiSchema | undefined;
288
- data?: Record<string, unknown> | undefined;
289
289
  handlers?: ({
290
290
  type: "webhook";
291
291
  url: string;
@@ -311,10 +311,68 @@ declare const taskContextSchema: z.ZodObject<{
311
311
  actions: {
312
312
  id: string;
313
313
  title: string;
314
+ data?: Record<string, unknown> | undefined;
315
+ description?: string | undefined;
316
+ schema?: ExtendedJSONSchema7 | undefined;
317
+ ui?: UiSchema | undefined;
318
+ handlers?: ({
319
+ type: "webhook";
320
+ url: string;
321
+ headers: Record<string, string>;
322
+ } | {
323
+ type: "trigger";
324
+ url: string;
325
+ headers: Record<string, string>;
326
+ tokenId: string;
327
+ })[] | undefined;
328
+ }[];
329
+ description?: string | undefined;
330
+ app?: string | undefined;
331
+ validUntil?: string | undefined;
332
+ context?: {
333
+ data: Record<string, unknown>;
334
+ ui?: Record<string, Record<string, unknown>> | undefined;
335
+ } | undefined;
336
+ version?: 2 | undefined;
337
+ }>, {
338
+ type: string;
339
+ name: string;
340
+ actions: {
341
+ id: string;
342
+ title: string;
343
+ data?: Record<string, unknown> | undefined;
314
344
  description?: string | undefined;
315
345
  schema?: ExtendedJSONSchema7 | undefined;
316
346
  ui?: UiSchema | undefined;
347
+ handlers?: ({
348
+ type: "webhook";
349
+ url: string;
350
+ headers: Record<string, string>;
351
+ } | {
352
+ type: "trigger";
353
+ url: string;
354
+ headers: Record<string, string>;
355
+ tokenId: string;
356
+ })[] | undefined;
357
+ }[];
358
+ description?: string | undefined;
359
+ app?: string | undefined;
360
+ validUntil?: string | undefined;
361
+ context?: {
362
+ data: Record<string, unknown>;
363
+ ui?: Record<string, Record<string, unknown>> | undefined;
364
+ } | undefined;
365
+ version?: 2 | undefined;
366
+ }, {
367
+ type: string;
368
+ name: string;
369
+ actions: {
370
+ id: string;
371
+ title: string;
317
372
  data?: Record<string, unknown> | undefined;
373
+ description?: string | undefined;
374
+ schema?: ExtendedJSONSchema7 | undefined;
375
+ ui?: UiSchema | undefined;
318
376
  handlers?: ({
319
377
  type: "webhook";
320
378
  url: string;
@@ -383,7 +441,7 @@ type TaskPriority = (typeof taskPriorities)[number];
383
441
  declare const DEFAULT_TASK_PRIORITY: TaskPriority;
384
442
  declare const LOWEST_TASK_PRIORITY: TaskPriority;
385
443
  declare const TASK_PRIORITY_RANK: Record<TaskPriority, number>;
386
- declare const createTaskBodySchema: z.ZodObject<{
444
+ declare const createTaskBodySchema: z.ZodEffects<z.ZodObject<{
387
445
  app: z.ZodOptional<z.ZodString>;
388
446
  type: z.ZodString;
389
447
  name: z.ZodString;
@@ -439,10 +497,10 @@ declare const createTaskBodySchema: z.ZodObject<{
439
497
  }, "strip", z.ZodTypeAny, {
440
498
  id: string;
441
499
  title: string;
500
+ data?: Record<string, unknown> | undefined;
442
501
  description?: string | undefined;
443
502
  schema?: ExtendedJSONSchema7 | undefined;
444
503
  ui?: UiSchema | undefined;
445
- data?: Record<string, unknown> | undefined;
446
504
  handlers?: ({
447
505
  type: "webhook";
448
506
  url: string;
@@ -456,10 +514,10 @@ declare const createTaskBodySchema: z.ZodObject<{
456
514
  }, {
457
515
  id: string;
458
516
  title: string;
517
+ data?: Record<string, unknown> | undefined;
459
518
  description?: string | undefined;
460
519
  schema?: ExtendedJSONSchema7 | undefined;
461
520
  ui?: UiSchema | undefined;
462
- data?: Record<string, unknown> | undefined;
463
521
  handlers?: ({
464
522
  type: "webhook";
465
523
  url: string;
@@ -518,10 +576,10 @@ declare const createTaskBodySchema: z.ZodObject<{
518
576
  actions: {
519
577
  id: string;
520
578
  title: string;
579
+ data?: Record<string, unknown> | undefined;
521
580
  description?: string | undefined;
522
581
  schema?: ExtendedJSONSchema7 | undefined;
523
582
  ui?: UiSchema | undefined;
524
- data?: Record<string, unknown> | undefined;
525
583
  handlers?: ({
526
584
  type: "webhook";
527
585
  url: string;
@@ -557,10 +615,88 @@ declare const createTaskBodySchema: z.ZodObject<{
557
615
  actions: {
558
616
  id: string;
559
617
  title: string;
618
+ data?: Record<string, unknown> | undefined;
619
+ description?: string | undefined;
620
+ schema?: ExtendedJSONSchema7 | undefined;
621
+ ui?: UiSchema | undefined;
622
+ handlers?: ({
623
+ type: "webhook";
624
+ url: string;
625
+ headers: Record<string, string>;
626
+ } | {
627
+ type: "trigger";
628
+ url: string;
629
+ headers: Record<string, string>;
630
+ tokenId: string;
631
+ })[] | undefined;
632
+ }[];
633
+ description?: string | undefined;
634
+ app?: string | undefined;
635
+ validUntil?: string | undefined;
636
+ context?: {
637
+ data: Record<string, unknown>;
638
+ ui?: Record<string, Record<string, unknown>> | undefined;
639
+ } | undefined;
640
+ version?: 2 | undefined;
641
+ assignTo?: {
642
+ users?: string[] | undefined;
643
+ groups?: string[] | undefined;
644
+ } | undefined;
645
+ threadId?: string | undefined;
646
+ priority?: "low" | "normal" | "high" | "urgent" | undefined;
647
+ update?: {
648
+ message: string;
649
+ status?: "info" | "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | undefined;
650
+ } | undefined;
651
+ }>, {
652
+ type: string;
653
+ name: string;
654
+ actions: {
655
+ id: string;
656
+ title: string;
657
+ data?: Record<string, unknown> | undefined;
560
658
  description?: string | undefined;
561
659
  schema?: ExtendedJSONSchema7 | undefined;
562
660
  ui?: UiSchema | undefined;
661
+ handlers?: ({
662
+ type: "webhook";
663
+ url: string;
664
+ headers: Record<string, string>;
665
+ } | {
666
+ type: "trigger";
667
+ url: string;
668
+ headers: Record<string, string>;
669
+ tokenId: string;
670
+ })[] | undefined;
671
+ }[];
672
+ description?: string | undefined;
673
+ app?: string | undefined;
674
+ validUntil?: string | undefined;
675
+ context?: {
676
+ data: Record<string, unknown>;
677
+ ui?: Record<string, Record<string, unknown>> | undefined;
678
+ } | undefined;
679
+ version?: 2 | undefined;
680
+ assignTo?: {
681
+ users?: string[] | undefined;
682
+ groups?: string[] | undefined;
683
+ } | undefined;
684
+ threadId?: string | undefined;
685
+ priority?: "low" | "normal" | "high" | "urgent" | undefined;
686
+ update?: {
687
+ message: string;
688
+ status?: "info" | "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | undefined;
689
+ } | undefined;
690
+ }, {
691
+ type: string;
692
+ name: string;
693
+ actions: {
694
+ id: string;
695
+ title: string;
563
696
  data?: Record<string, unknown> | undefined;
697
+ description?: string | undefined;
698
+ schema?: ExtendedJSONSchema7 | undefined;
699
+ ui?: UiSchema | undefined;
564
700
  handlers?: ({
565
701
  type: "webhook";
566
702
  url: string;
@@ -13,7 +13,7 @@ import {
13
13
  threadUpdateMessageSchema,
14
14
  threadUpdateStatusSchema,
15
15
  threadUpdateStatuses
16
- } from "../chunk-TAWMIQAM.js";
16
+ } from "../chunk-ZHASQUX6.js";
17
17
  export {
18
18
  DEFAULT_TASK_PRIORITY,
19
19
  DEFAULT_THREAD_UPDATE_STATUS,
@@ -6,8 +6,8 @@ import {
6
6
  createClient,
7
7
  resolveRobotRockConfig,
8
8
  toDiscriminatedApprovalResult
9
- } from "../chunk-ZCMXX7IG.js";
10
- import "../chunk-TAWMIQAM.js";
9
+ } from "../chunk-ZG2XVK6Y.js";
10
+ import "../chunk-ZHASQUX6.js";
11
11
 
12
12
  // src/trigger/index.ts
13
13
  import { task, wait } from "@trigger.dev/sdk";
@@ -7,11 +7,11 @@ import {
7
7
  createClient,
8
8
  resolveRobotRockConfig,
9
9
  toDiscriminatedApprovalResult
10
- } from "../chunk-ZCMXX7IG.js";
10
+ } from "../chunk-ZG2XVK6Y.js";
11
11
  import {
12
12
  __callDispose,
13
13
  __using
14
- } from "../chunk-TAWMIQAM.js";
14
+ } from "../chunk-ZHASQUX6.js";
15
15
 
16
16
  // src/workflow/index.ts
17
17
  import { createWebhook, sleep } from "workflow";
@@ -1,5 +1,4 @@
1
- import * as ai from 'ai';
2
- import { ToolApprovalResponse } from 'ai';
1
+ import { Tool, ToolApprovalResponse } from 'ai';
3
2
  import { z } from 'zod';
4
3
  import { b as RobotRock, a as SendToHumanInput, S as SendToHumanActionInput, l as SendUpdateInput } from './client-CLcHdjOz.js';
5
4
  import { DiscriminatedApprovalResult, ThreadUpdate } from './schemas/index.js';
@@ -134,12 +133,7 @@ type ApproveByHumanToolDurableOptions = ApproveByHumanToolOptions & RobotRockAiC
134
133
  * - `approveByHumanTool({ mode: "trigger", app?: "my-agent" })` — durable wait via Trigger.dev.
135
134
  * - `approveByHumanTool({ mode: "workflow", app?: "my-agent" })` — durable wait via Vercel Workflow.
136
135
  */
137
- declare function approveByHumanTool(clientOrContext: RobotRock | ApproveByHumanToolDurableOptions, maybeOptions?: ApproveByHumanToolOptions): ai.Tool<{
138
- description: string;
139
- name: string;
140
- type?: string | undefined;
141
- contextSummary?: string | undefined;
142
- }, HumanToolResult>;
136
+ declare function approveByHumanTool(clientOrContext: RobotRock | ApproveByHumanToolDurableOptions, maybeOptions?: ApproveByHumanToolOptions): Tool<z.infer<typeof approveByHumanInputSchema>, HumanToolResult>;
143
137
 
144
138
  declare const sendToHumanToolInputSchema: z.ZodObject<{
145
139
  type: z.ZodString;
@@ -149,11 +143,11 @@ declare const sendToHumanToolInputSchema: z.ZodObject<{
149
143
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
150
144
  ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
151
145
  }, "strip", z.ZodTypeAny, {
152
- ui?: Record<string, unknown> | undefined;
153
146
  data?: Record<string, unknown> | undefined;
154
- }, {
155
147
  ui?: Record<string, unknown> | undefined;
148
+ }, {
156
149
  data?: Record<string, unknown> | undefined;
150
+ ui?: Record<string, unknown> | undefined;
157
151
  }>>;
158
152
  validUntil: z.ZodOptional<z.ZodString>;
159
153
  assignTo: z.ZodOptional<z.ZodEffects<z.ZodObject<{
@@ -178,8 +172,8 @@ declare const sendToHumanToolInputSchema: z.ZodObject<{
178
172
  description?: string | undefined;
179
173
  validUntil?: string | undefined;
180
174
  context?: {
181
- ui?: Record<string, unknown> | undefined;
182
175
  data?: Record<string, unknown> | undefined;
176
+ ui?: Record<string, unknown> | undefined;
183
177
  } | undefined;
184
178
  assignTo?: {
185
179
  users?: string[] | undefined;
@@ -191,8 +185,8 @@ declare const sendToHumanToolInputSchema: z.ZodObject<{
191
185
  description?: string | undefined;
192
186
  validUntil?: string | undefined;
193
187
  context?: {
194
- ui?: Record<string, unknown> | undefined;
195
188
  data?: Record<string, unknown> | undefined;
189
+ ui?: Record<string, unknown> | undefined;
196
190
  } | undefined;
197
191
  assignTo?: {
198
192
  users?: string[] | undefined;
@@ -220,20 +214,7 @@ type CreateSendToHumanToolDurableOptions<A extends readonly SendToHumanActionInp
220
214
  * - `createSendToHumanTool({ mode: "trigger", actions: [...], app?: "my-agent" })` — Trigger.dev wait tokens.
221
215
  * - `createSendToHumanTool({ mode: "workflow", actions: [...], app?: "my-agent" })` — Vercel Workflow webhooks.
222
216
  */
223
- declare function createSendToHumanTool<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]>(clientOrOptions: RobotRock | CreateSendToHumanToolDurableOptions<A>, maybeOptions?: CreateSendToHumanToolOptions<A>): ai.Tool<{
224
- type: string;
225
- name: string;
226
- description?: string | undefined;
227
- validUntil?: string | undefined;
228
- context?: {
229
- ui?: Record<string, unknown> | undefined;
230
- data?: Record<string, unknown> | undefined;
231
- } | undefined;
232
- assignTo?: {
233
- users?: string[] | undefined;
234
- groups?: string[] | undefined;
235
- } | undefined;
236
- }, HumanToolResult>;
217
+ declare function createSendToHumanTool<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]>(clientOrOptions: RobotRock | CreateSendToHumanToolDurableOptions<A>, maybeOptions?: CreateSendToHumanToolOptions<A>): Tool<z.infer<typeof sendToHumanToolInputSchema>, HumanToolResult>;
237
218
 
238
219
  /**
239
220
  * Result returned to the model by {@link createSendUpdateTool}.
@@ -290,11 +271,7 @@ type CreateSendUpdateToolDurableOptions = CreateSendUpdateToolOptions & RobotRoc
290
271
  * The thread is resolved from the tool input `threadId`, falling back to a
291
272
  * session `threadId` in the options. Provide at least one.
292
273
  */
293
- declare function createSendUpdateTool(clientOrOptions: RobotRock | CreateSendUpdateToolDurableOptions, maybeOptions?: CreateSendUpdateToolOptions): ai.Tool<{
294
- message: string;
295
- status?: "info" | "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | undefined;
296
- threadId?: string | undefined;
297
- }, SendUpdateToolResult>;
274
+ declare function createSendUpdateTool(clientOrOptions: RobotRock | CreateSendUpdateToolDurableOptions, maybeOptions?: CreateSendUpdateToolOptions): Tool<z.infer<typeof sendUpdateToolInputSchema>, SendUpdateToolResult>;
298
275
 
299
276
  type CreateRobotRockAiToolsOptions = {
300
277
  /** @default "polling" when `client` is passed; `"trigger"` or `"workflow"` for durable waits. */
@@ -307,6 +284,12 @@ type CreateRobotRockAiToolsOptions = {
307
284
  */
308
285
  threadId?: string;
309
286
  };
287
+ type RobotRockAiTools = {
288
+ context: RobotRockAiContext;
289
+ approveByHuman: (toolOptions?: ApproveByHumanToolOptions) => Tool<z.infer<typeof approveByHumanInputSchema>, HumanToolResult>;
290
+ sendToHuman: <A extends readonly SendToHumanActionInput[]>(toolOptions: CreateSendToHumanToolOptions<A>) => Tool<z.infer<typeof sendToHumanToolInputSchema>, HumanToolResult>;
291
+ sendUpdate: (toolOptions?: CreateSendUpdateToolOptions) => Tool<z.infer<typeof sendUpdateToolInputSchema>, SendUpdateToolResult>;
292
+ };
310
293
  /**
311
294
  * Build AI SDK tools for a given RobotRock execution mode.
312
295
  *
@@ -325,34 +308,7 @@ type CreateRobotRockAiToolsOptions = {
325
308
  * const tools = createRobotRockAiTools({ mode: "workflow", app: "my-agent" });
326
309
  * ```
327
310
  */
328
- declare function createRobotRockAiTools(options: CreateRobotRockAiToolsOptions): {
329
- context: RobotRockAiContext;
330
- approveByHuman: (toolOptions?: ApproveByHumanToolOptions) => ai.Tool<{
331
- description: string;
332
- name: string;
333
- type?: string | undefined;
334
- contextSummary?: string | undefined;
335
- }, HumanToolResult>;
336
- sendToHuman: <A extends readonly SendToHumanActionInput[]>(toolOptions: CreateSendToHumanToolOptions<A>) => ai.Tool<{
337
- type: string;
338
- name: string;
339
- description?: string | undefined;
340
- validUntil?: string | undefined;
341
- context?: {
342
- ui?: Record<string, unknown> | undefined;
343
- data?: Record<string, unknown> | undefined;
344
- } | undefined;
345
- assignTo?: {
346
- users?: string[] | undefined;
347
- groups?: string[] | undefined;
348
- } | undefined;
349
- }, HumanToolResult>;
350
- sendUpdate: (toolOptions?: CreateSendUpdateToolOptions) => ai.Tool<{
351
- message: string;
352
- status?: "info" | "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | undefined;
353
- threadId?: string | undefined;
354
- }, SendUpdateToolResult>;
355
- };
311
+ declare function createRobotRockAiTools(options: CreateRobotRockAiToolsOptions): RobotRockAiTools;
356
312
  /** Shorthand for `{ mode: "trigger", app }`. */
357
313
  declare function createRobotRockAiTriggerContext(options?: Omit<RobotRockAiTriggerContext, "mode">): RobotRockAiContext;
358
314
  /** Shorthand for `{ mode: "workflow", app }`. */
@@ -390,4 +346,4 @@ declare function resolveToolApprovalsViaRobotRock(clientOrContext: RobotRock | R
390
346
  */
391
347
  declare function runWithRobotRockApprovals<T>(options: RunWithRobotRockApprovalsOptions<T>): Promise<T>;
392
348
 
393
- export { APPROVE_BY_HUMAN_ACTIONS as A, createRobotRockNeedsApproval as B, type CreateSendToHumanToolOptions as C, createRobotRockToolApproval as D, resolveToolApprovalsViaRobotRock as E, type FormatToolApprovalTaskOptions as F, runWithRobotRockApprovals as G, type HumanToolResult as H, type RobotRockToolApprovalDecision as I, type ResolveToolApprovalsOptions as J, type RobotRockToolApprovalConfig as K, type RunWithRobotRockApprovalsOptions as L, type RobotRockToolCallInfo as R, type SendUpdateToolResult as S, type ToolApprovalRequestPart as T, approveByHumanTool as a, approveByHumanInputSchema as b, type ApproveByHumanToolOptions as c, type ApproveByHumanToolDurableOptions as d, createSendToHumanTool as e, type CreateSendToHumanToolDurableOptions as f, createSendUpdateTool as g, sendUpdateToolInputSchema as h, type CreateSendUpdateToolOptions as i, type CreateSendUpdateToolDurableOptions as j, approveByHumanForAi as k, sendToHumanForAi as l, sendUpdateForAi as m, normalizeRobotRockAiContext as n, type RobotRockAiContext as o, type RobotRockAiMode as p, type RobotRockAiPollingContext as q, type RobotRockAiTriggerContext as r, sendToHumanToolInputSchema as s, type RobotRockAiWorkflowContext as t, createRobotRockAiTools as u, createRobotRockAiTriggerContext as v, createRobotRockAiWorkflowContext as w, type CreateRobotRockAiToolsOptions as x, applyRobotRockToolApprovalToTools as y, collectApprovalRequests as z };
349
+ export { APPROVE_BY_HUMAN_ACTIONS as A, collectApprovalRequests as B, type CreateSendToHumanToolOptions as C, createRobotRockNeedsApproval as D, createRobotRockToolApproval as E, type FormatToolApprovalTaskOptions as F, resolveToolApprovalsViaRobotRock as G, type HumanToolResult as H, runWithRobotRockApprovals as I, type RobotRockToolApprovalDecision as J, type ResolveToolApprovalsOptions as K, type RobotRockToolApprovalConfig as L, type RunWithRobotRockApprovalsOptions as M, type RobotRockToolCallInfo as R, type SendUpdateToolResult as S, type ToolApprovalRequestPart as T, approveByHumanTool as a, approveByHumanInputSchema as b, type ApproveByHumanToolOptions as c, type ApproveByHumanToolDurableOptions as d, createSendToHumanTool as e, type CreateSendToHumanToolDurableOptions as f, createSendUpdateTool as g, sendUpdateToolInputSchema as h, type CreateSendUpdateToolOptions as i, type CreateSendUpdateToolDurableOptions as j, approveByHumanForAi as k, sendToHumanForAi as l, sendUpdateForAi as m, normalizeRobotRockAiContext as n, type RobotRockAiContext as o, type RobotRockAiMode as p, type RobotRockAiPollingContext as q, type RobotRockAiTriggerContext as r, sendToHumanToolInputSchema as s, type RobotRockAiWorkflowContext as t, createRobotRockAiTools as u, createRobotRockAiTriggerContext as v, createRobotRockAiWorkflowContext as w, type CreateRobotRockAiToolsOptions as x, type RobotRockAiTools as y, applyRobotRockToolApprovalToTools as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robotrock",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Human-in-the-loop approval workflows for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -63,6 +63,7 @@
63
63
  "url": "https://github.com/quintenb/robotrock-sdk/issues"
64
64
  },
65
65
  "dependencies": {
66
+ "@robotrock/core": "workspace:*",
66
67
  "zod": "^3.25.0"
67
68
  },
68
69
  "devDependencies": {
@@ -70,7 +71,7 @@
70
71
  "@robotrock/core": "workspace:*",
71
72
  "@trigger.dev/sdk": "4.4.6",
72
73
  "@types/node": "^25.0.3",
73
- "ai": "^6.0.196",
74
+ "ai": "^7.0.2",
74
75
  "eslint": "^9.39.2",
75
76
  "tsup": "^8.0.0",
76
77
  "typescript": "^5.9.3",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ai/context.ts","../src/ai/human-tool-result.ts","../src/ai/approve-by-human-tool.ts","../src/ai/create-send-to-human-tool.ts","../src/ai/create-send-update-tool.ts","../src/ai/create-ai-tools.ts","../src/ai/format-tool-approval-task.ts","../src/ai/tool-approval-bridge.ts"],"sourcesContent":["import {\n createClient,\n type RobotRock,\n type SendToHumanActionInput,\n type SendToHumanInput,\n type SendUpdateInput,\n} from \"../client.js\";\nimport { resolveRobotRockConfig } from \"../env.js\";\nimport type { DiscriminatedApprovalResult, ThreadUpdate } from \"../schemas/index.js\";\nconst APPROVE_BY_HUMAN_ACTIONS = [\n { id: \"approve\", title: \"Approve\" },\n { id: \"decline\", title: \"Decline\" },\n] as const;\n\n/** How RobotRock waits for a human inside AI SDK tool `execute`. */\nexport type RobotRockAiMode = \"polling\" | \"trigger\" | \"workflow\";\n\n/**\n * Polling: `client.sendToHuman()` blocks until handled (scripts, API routes with long timeout).\n * Trigger: `sendToHumanTask.triggerAndWait()` uses wait tokens (Trigger.dev workers).\n * Workflow: `sendToHumanInWorkflow()` uses workflow webhooks (Vercel Workflow).\n */\nexport type RobotRockAiPollingContext = {\n mode?: \"polling\";\n client: RobotRock;\n};\n\nexport type RobotRockAiTriggerContext = {\n mode: \"trigger\";\n /** Inbox app bucket; falls back to `ROBOTROCK_APP` in the Trigger worker. */\n app?: string;\n};\n\nexport type RobotRockAiWorkflowContext = {\n mode: \"workflow\";\n /** Inbox app bucket; falls back to `ROBOTROCK_APP` in the workflow run. */\n app?: string;\n};\n\nexport type RobotRockAiContext =\n | RobotRockAiPollingContext\n | RobotRockAiTriggerContext\n | RobotRockAiWorkflowContext;\n\nexport function isRobotRockClient(value: unknown): value is RobotRock {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"sendToHuman\" in value &&\n typeof (value as RobotRock).sendToHuman === \"function\"\n );\n}\n\nexport function normalizeRobotRockAiContext(\n clientOrContext: RobotRock | RobotRockAiContext\n): RobotRockAiContext {\n if (isRobotRockClient(clientOrContext)) {\n return { mode: \"polling\", client: clientOrContext };\n }\n\n if (clientOrContext.mode === \"trigger\" || clientOrContext.mode === \"workflow\") {\n return clientOrContext;\n }\n\n if (clientOrContext.mode === \"polling\" || clientOrContext.mode === undefined) {\n if (!(\"client\" in clientOrContext) || !clientOrContext.client) {\n throw new Error('RobotRock AI polling mode requires `client` on the context object.');\n }\n return { mode: \"polling\", client: clientOrContext.client };\n }\n\n throw new Error(`Unknown RobotRock AI mode: ${String((clientOrContext as { mode?: string }).mode)}`);\n}\n\nexport async function sendToHumanForAi<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n>(\n context: RobotRockAiContext,\n payload: SendToHumanInput<A>\n): Promise<DiscriminatedApprovalResult<A>> {\n if (context.mode === \"trigger\") {\n const { sendToHumanTask } = await import(\"../trigger/index.js\");\n const waitResult = await sendToHumanTask.triggerAndWait({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n\n if (!waitResult.ok) {\n throw waitResult.error;\n }\n\n return waitResult.output as DiscriminatedApprovalResult<A>;\n }\n\n if (context.mode === \"workflow\") {\n const { sendToHumanInWorkflow } = await import(\"../workflow/index.js\");\n const result = await sendToHumanInWorkflow({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n return result as unknown as DiscriminatedApprovalResult<A>;\n }\n\n const result = await context.client.sendToHuman(payload);\n\n if (result.mode !== \"handled\") {\n throw new Error(\n \"RobotRock task was created but not handled. Configure client polling or webhook, or use mode: 'trigger' / 'workflow' for durable waits.\"\n );\n }\n\n return {\n actionId: result.actionId,\n data: result.data,\n handledBy: result.handledBy,\n handledAt: result.handledAt,\n taskId: result.taskId,\n } as DiscriminatedApprovalResult<A>;\n}\n\n/**\n * Posts a thread update for an AI tool, routing by execution mode.\n *\n * `sendUpdate` is fire-and-forget (no human wait), so only the workflow path\n * needs durability — it runs inside a `\"use step\"`. Trigger and polling modes\n * issue the request directly.\n */\nexport async function sendUpdateForAi(\n context: RobotRockAiContext,\n payload: SendUpdateInput\n): Promise<ThreadUpdate> {\n if (context.mode === \"workflow\") {\n const { sendUpdateInWorkflow } = await import(\"../workflow/index.js\");\n return sendUpdateInWorkflow({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n }\n\n if (context.mode === \"trigger\") {\n const client = createClient(\n resolveRobotRockConfig(context.app ? { app: context.app } : undefined)\n );\n return client.sendUpdate(payload);\n }\n\n return context.client.sendUpdate(payload);\n}\n\nexport async function approveByHumanForAi(\n context: RobotRockAiContext,\n payload: Omit<SendToHumanInput, \"actions\"> & { app?: string }\n): Promise<DiscriminatedApprovalResult<typeof APPROVE_BY_HUMAN_ACTIONS>> {\n if (context.mode === \"trigger\") {\n const { approveByHumanTask } = await import(\"../trigger/index.js\");\n const waitResult = await approveByHumanTask.triggerAndWait({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n\n if (!waitResult.ok) {\n throw waitResult.error;\n }\n\n return waitResult.output;\n }\n\n if (context.mode === \"workflow\") {\n const { approveByHumanInWorkflow } = await import(\"../workflow/index.js\");\n return await approveByHumanInWorkflow({\n ...payload,\n ...(context.app ? { app: context.app } : {}),\n });\n }\n\n const result = await context.client.sendToHuman({\n ...payload,\n actions: APPROVE_BY_HUMAN_ACTIONS,\n });\n\n if (result.mode !== \"handled\") {\n throw new Error(\n \"RobotRock approval was not handled. Configure client polling or use mode: 'trigger' / 'workflow' for durable waits.\"\n );\n }\n\n return {\n actionId: result.actionId,\n data: result.data,\n handledBy: result.handledBy,\n handledAt: result.handledAt,\n taskId: result.taskId,\n } as DiscriminatedApprovalResult<typeof APPROVE_BY_HUMAN_ACTIONS>;\n}\n","import type { DiscriminatedApprovalResult } from \"../schemas/index.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nconst APPROVE_IDS = new Set([\"approve\", \"approved\"]);\nconst DECLINE_IDS = new Set([\"decline\", \"reject\", \"deny\", \"denied\"]);\n\nexport function toHumanToolResult(\n result: DiscriminatedApprovalResult<readonly { id: string }[]>\n): HumanToolResult {\n const payload: HumanToolResult = {\n taskId: result.taskId,\n actionId: result.actionId,\n data: result.data,\n handledBy: result.handledBy,\n handledAt: result.handledAt.toISOString(),\n };\n\n if (APPROVE_IDS.has(result.actionId)) {\n payload.approved = true;\n } else if (DECLINE_IDS.has(result.actionId)) {\n payload.approved = false;\n }\n\n return payload;\n}\n","import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { RobotRock } from \"../client.js\";\nimport { approveByHumanForAi, normalizeRobotRockAiContext, type RobotRockAiContext } from \"./context.js\";\nimport { toHumanToolResult } from \"./human-tool-result.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nconst APPROVE_BY_HUMAN_ACTIONS = [\n { id: \"approve\", title: \"Approve\" },\n { id: \"decline\", title: \"Decline\" },\n] as const;\n\nconst approveByHumanInputSchema = z.object({\n type: z\n .string()\n .optional()\n .describe(\"Task type slug; defaults to ai-approval\"),\n name: z.string().describe(\"Short title for the approval request\"),\n description: z\n .string()\n .describe(\"What needs approval and the consequences of approving or declining\"),\n contextSummary: z\n .string()\n .optional()\n .describe(\"Optional markdown summary shown to the reviewer\"),\n});\n\nexport type ApproveByHumanToolOptions = {\n defaultType?: string;\n description?: string;\n toolName?: string;\n};\n\nexport type ApproveByHumanToolDurableOptions = ApproveByHumanToolOptions &\n RobotRockAiContext & { mode: \"trigger\" | \"workflow\" };\n\n/**\n * AI SDK tool with fixed approve/decline actions; blocks until a human decides.\n *\n * - `approveByHumanTool(robotrock)` — polling via `client.sendToHuman()` (default).\n * - `approveByHumanTool({ mode: \"trigger\", app?: \"my-agent\" })` — durable wait via Trigger.dev.\n * - `approveByHumanTool({ mode: \"workflow\", app?: \"my-agent\" })` — durable wait via Vercel Workflow.\n */\nexport function approveByHumanTool(\n clientOrContext: RobotRock | ApproveByHumanToolDurableOptions,\n maybeOptions: ApproveByHumanToolOptions = {}\n) {\n const isDurable =\n typeof clientOrContext === \"object\" &&\n clientOrContext !== null &&\n \"mode\" in clientOrContext &&\n (clientOrContext.mode === \"trigger\" || clientOrContext.mode === \"workflow\");\n\n const aiContext = normalizeRobotRockAiContext(\n isDurable\n ? {\n mode: (clientOrContext as ApproveByHumanToolDurableOptions).mode,\n app: (clientOrContext as ApproveByHumanToolDurableOptions).app,\n }\n : (clientOrContext as RobotRock)\n );\n const options = isDurable\n ? (clientOrContext as ApproveByHumanToolDurableOptions)\n : maybeOptions;\n const description =\n options.description ??\n \"Request explicit human approval before a sensitive or irreversible step. Returns whether the human approved or declined.\";\n\n return tool({\n description,\n inputSchema: approveByHumanInputSchema,\n execute: async (input: z.infer<typeof approveByHumanInputSchema>): Promise<HumanToolResult> => {\n const taskContext =\n input.contextSummary !== undefined\n ? {\n data: { summary: input.contextSummary },\n ui: {\n summary: { \"ui:widget\": \"textarea\", \"ui:options\": { rows: 6 } },\n },\n }\n : undefined;\n\n const result = await approveByHumanForAi(aiContext, {\n type: input.type ?? options.defaultType ?? \"ai-approval\",\n name: input.name,\n description: input.description,\n context: taskContext,\n });\n\n return toHumanToolResult(result);\n },\n });\n}\n\nexport { APPROVE_BY_HUMAN_ACTIONS, approveByHumanInputSchema };\n","import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport { assignToSchema } from \"../schemas/index.js\";\nimport type { RobotRock, SendToHumanActionInput, SendToHumanInput } from \"../client.js\";\nimport type { TaskContextInput } from \"../schemas/index.js\";\nimport {\n normalizeRobotRockAiContext,\n sendToHumanForAi,\n type RobotRockAiContext,\n} from \"./context.js\";\nimport { toHumanToolResult } from \"./human-tool-result.js\";\nimport type { HumanToolResult } from \"./types.js\";\n\nconst contextInputSchema = z\n .object({\n data: z.record(z.unknown()).optional(),\n ui: z.record(z.unknown()).optional(),\n })\n .optional();\n\nconst sendToHumanToolInputSchema = z.object({\n type: z.string().describe(\"Task type slug shown in the RobotRock inbox\"),\n name: z.string().describe(\"Short title for the human reviewer\"),\n description: z\n .string()\n .optional()\n .describe(\"What you need from the human and why you cannot proceed alone\"),\n context: contextInputSchema.describe(\"Optional structured context for the inbox UI\"),\n validUntil: z\n .string()\n .datetime()\n .optional()\n .describe(\"Optional ISO deadline for the task\"),\n assignTo: assignToSchema\n .optional()\n .describe(\n \"Assign to tenant member emails and/or group slugs; narrows who sees the task in the inbox\"\n ),\n});\n\nexport type CreateSendToHumanToolOptions<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n> = {\n actions: A;\n defaultType?: string;\n description?: string;\n toolName?: string;\n /**\n * Group every task this tool creates onto a shared thread. Pass the same\n * value to {@link createSendUpdateTool} so updates land on the same thread.\n */\n threadId?: string;\n};\n\nexport type CreateSendToHumanToolDurableOptions<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n> = CreateSendToHumanToolOptions<A> & RobotRockAiContext & { mode: \"trigger\" | \"workflow\" };\n\n/**\n * AI SDK tool that blocks until a human handles a RobotRock task with developer-defined actions.\n *\n * - `createSendToHumanTool(robotrock, options)` — polling (default).\n * - `createSendToHumanTool({ mode: \"trigger\", actions: [...], app?: \"my-agent\" })` — Trigger.dev wait tokens.\n * - `createSendToHumanTool({ mode: \"workflow\", actions: [...], app?: \"my-agent\" })` — Vercel Workflow webhooks.\n */\nexport function createSendToHumanTool<\n A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[],\n>(\n clientOrOptions: RobotRock | CreateSendToHumanToolDurableOptions<A>,\n maybeOptions?: CreateSendToHumanToolOptions<A>\n) {\n const isDurable =\n typeof clientOrOptions === \"object\" &&\n clientOrOptions !== null &&\n \"mode\" in clientOrOptions &&\n (clientOrOptions.mode === \"trigger\" || clientOrOptions.mode === \"workflow\");\n\n const aiContext = normalizeRobotRockAiContext(\n isDurable\n ? {\n mode: (clientOrOptions as CreateSendToHumanToolDurableOptions<A>).mode,\n app: (clientOrOptions as CreateSendToHumanToolDurableOptions<A>).app,\n }\n : (clientOrOptions as RobotRock)\n );\n const options = (isDurable ? clientOrOptions : maybeOptions!) as CreateSendToHumanToolOptions<A>;\n const description =\n options.description ??\n \"Request structured input or a decision from a human in the RobotRock inbox. Use when you lack required information, need policy approval, or must confirm an irreversible step.\";\n\n return tool({\n description,\n inputSchema: sendToHumanToolInputSchema,\n execute: async (\n input: z.infer<typeof sendToHumanToolInputSchema>\n ): Promise<HumanToolResult> => {\n const taskContext: TaskContextInput[\"context\"] | undefined = input.context\n ? ({\n data: input.context.data ?? {},\n ui: input.context.ui,\n } as TaskContextInput[\"context\"])\n : undefined;\n\n const payload: SendToHumanInput<A> = {\n type: input.type ?? options.defaultType ?? \"ai-human-input\",\n name: input.name,\n description: input.description,\n context: taskContext,\n validUntil: input.validUntil,\n assignTo: input.assignTo,\n actions: options.actions,\n ...(options.threadId ? { threadId: options.threadId } : {}),\n };\n\n const result = await sendToHumanForAi(aiContext, payload);\n\n return toHumanToolResult(result);\n },\n });\n}\n\nexport { sendToHumanToolInputSchema };\n","import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport { threadUpdateStatusSchema } from \"../schemas/index.js\";\nimport { RobotRockError, type RobotRock } from \"../client.js\";\nimport type { ThreadUpdate } from \"../schemas/index.js\";\nimport {\n normalizeRobotRockAiContext,\n sendUpdateForAi,\n type RobotRockAiContext,\n} from \"./context.js\";\n\n/**\n * Result returned to the model by {@link createSendUpdateTool}.\n *\n * Updates are fire-and-forget, so a missing thread (no task created yet) is\n * reported as `{ posted: false }` instead of throwing — that way an agent loop\n * is never aborted by a non-critical progress update. Genuine failures (auth,\n * validation, server errors) still throw.\n */\nexport type SendUpdateToolResult =\n | { posted: true; threadId: string; update: ThreadUpdate }\n | {\n posted: false;\n threadId: string;\n reason: \"thread_not_found\";\n message: string;\n };\n\nconst sendUpdateToolInputSchema = z.object({\n threadId: z\n .string()\n .optional()\n .describe(\n \"Thread to post the update to. Use the `threadId` returned by a prior send-to-human task. Omit only when a session threadId is configured on the tool.\"\n ),\n message: z\n .string()\n .describe(\"Short progress update (1-2 sentences) shown in the inbox status bar\"),\n status: threadUpdateStatusSchema\n .optional()\n .describe(\n \"Lifecycle status driving the status-bar icon/color: info, queued, running, waiting, succeeded, failed, cancelled\"\n ),\n});\n\nexport type CreateSendUpdateToolOptions = {\n /**\n * Session thread to post updates to when the model does not supply `threadId`.\n * Pass the same value to {@link createSendToHumanTool} to auto-thread tasks\n * and updates together.\n */\n threadId?: string;\n description?: string;\n};\n\nexport type CreateSendUpdateToolDurableOptions = CreateSendUpdateToolOptions &\n RobotRockAiContext & { mode: \"trigger\" | \"workflow\" };\n\n/**\n * AI SDK tool that posts a progress update to a RobotRock thread.\n *\n * Fire-and-forget (no human wait): the agent reports status as it works.\n *\n * - `createSendUpdateTool(robotrock, options?)` — polling client (default).\n * - `createSendUpdateTool({ mode: \"trigger\", app?: \"my-agent\" })` — Trigger.dev worker.\n * - `createSendUpdateTool({ mode: \"workflow\", app?: \"my-agent\" })` — Vercel Workflow (durable step).\n *\n * The thread is resolved from the tool input `threadId`, falling back to a\n * session `threadId` in the options. Provide at least one.\n */\nexport function createSendUpdateTool(\n clientOrOptions: RobotRock | CreateSendUpdateToolDurableOptions,\n maybeOptions: CreateSendUpdateToolOptions = {}\n) {\n const isDurable =\n typeof clientOrOptions === \"object\" &&\n clientOrOptions !== null &&\n \"mode\" in clientOrOptions &&\n (clientOrOptions.mode === \"trigger\" || clientOrOptions.mode === \"workflow\");\n\n const aiContext: RobotRockAiContext = normalizeRobotRockAiContext(\n isDurable\n ? {\n mode: (clientOrOptions as CreateSendUpdateToolDurableOptions).mode,\n app: (clientOrOptions as CreateSendUpdateToolDurableOptions).app,\n }\n : (clientOrOptions as RobotRock)\n );\n const options = isDurable\n ? (clientOrOptions as CreateSendUpdateToolDurableOptions)\n : maybeOptions;\n const description =\n options.description ??\n \"Post a short progress update to the RobotRock thread you are working on. Use to report status changes (running, succeeded, failed) so humans can follow along in the inbox.\";\n\n return tool({\n description,\n inputSchema: sendUpdateToolInputSchema,\n execute: async (\n input: z.infer<typeof sendUpdateToolInputSchema>\n ): Promise<SendUpdateToolResult> => {\n const threadId = input.threadId ?? options.threadId;\n if (!threadId) {\n throw new Error(\n \"createSendUpdateTool: no threadId. Pass `threadId` from a prior send-to-human result, or configure a session `threadId` in the tool options.\"\n );\n }\n\n try {\n const update = await sendUpdateForAi(aiContext, {\n threadId,\n message: input.message,\n status: input.status,\n });\n return { posted: true, threadId, update };\n } catch (error) {\n if (error instanceof RobotRockError && error.statusCode === 404) {\n return {\n posted: false,\n threadId,\n reason: \"thread_not_found\",\n message: `No task exists for thread \"${threadId}\" yet, so the update was not posted. Create a task on this thread with send-to-human before reporting progress.`,\n };\n }\n throw error;\n }\n },\n });\n}\n\nexport { sendUpdateToolInputSchema };\n","import type { RobotRock, SendToHumanActionInput } from \"../client.js\";\nimport type {\n RobotRockAiContext,\n RobotRockAiTriggerContext,\n RobotRockAiWorkflowContext,\n} from \"./context.js\";\nimport { normalizeRobotRockAiContext } from \"./context.js\";\nimport { approveByHumanTool as buildApproveByHumanTool } from \"./approve-by-human-tool.js\";\nimport {\n createSendToHumanTool as buildSendToHumanTool,\n type CreateSendToHumanToolOptions,\n} from \"./create-send-to-human-tool.js\";\nimport {\n createSendUpdateTool as buildSendUpdateTool,\n type CreateSendUpdateToolOptions,\n} from \"./create-send-update-tool.js\";\nimport type { ApproveByHumanToolOptions } from \"./approve-by-human-tool.js\";\n\nexport type CreateRobotRockAiToolsOptions = {\n /** @default \"polling\" when `client` is passed; `\"trigger\"` or `\"workflow\"` for durable waits. */\n mode?: \"polling\" | \"trigger\" | \"workflow\";\n client?: RobotRock;\n app?: string;\n /**\n * Shared thread for tasks and updates these tools create. Enables the\n * `sendUpdate` tool to auto-thread onto tasks made by the `sendToHuman` tool.\n */\n threadId?: string;\n};\n\n/**\n * Build AI SDK tools for a given RobotRock execution mode.\n *\n * @example Polling (Next.js route, scripts)\n * ```ts\n * const tools = createRobotRockAiTools({ client: robotrock });\n * ```\n *\n * @example Trigger.dev worker\n * ```ts\n * const tools = createRobotRockAiTools({ mode: \"trigger\", app: \"my-agent\" });\n * ```\n *\n * @example Vercel Workflow + DurableAgent\n * ```ts\n * const tools = createRobotRockAiTools({ mode: \"workflow\", app: \"my-agent\" });\n * ```\n */\nexport function createRobotRockAiTools(options: CreateRobotRockAiToolsOptions) {\n const mode = options.mode ?? (options.client ? \"polling\" : \"trigger\");\n\n if (mode === \"polling\" && !options.client) {\n throw new Error('createRobotRockAiTools: polling mode requires `client`.');\n }\n\n const context: RobotRockAiContext =\n mode === \"trigger\"\n ? { mode: \"trigger\", app: options.app }\n : mode === \"workflow\"\n ? { mode: \"workflow\", app: options.app }\n : { mode: \"polling\", client: options.client! };\n\n const durableContext =\n context.mode === \"trigger\" || context.mode === \"workflow\" ? context : null;\n const pollingClient = context.mode === \"polling\" ? context.client : undefined;\n\n return {\n context,\n approveByHuman: (toolOptions?: ApproveByHumanToolOptions) =>\n durableContext\n ? buildApproveByHumanTool({ ...durableContext, ...toolOptions })\n : buildApproveByHumanTool(pollingClient!, toolOptions),\n sendToHuman: <A extends readonly SendToHumanActionInput[]>(\n toolOptions: CreateSendToHumanToolOptions<A>\n ) =>\n durableContext\n ? buildSendToHumanTool({\n ...durableContext,\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n })\n : buildSendToHumanTool(pollingClient!, {\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n }),\n sendUpdate: (toolOptions: CreateSendUpdateToolOptions = {}) =>\n durableContext\n ? buildSendUpdateTool({\n ...durableContext,\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n })\n : buildSendUpdateTool(pollingClient!, {\n ...(options.threadId ? { threadId: options.threadId } : {}),\n ...toolOptions,\n }),\n };\n}\n\n/** Shorthand for `{ mode: \"trigger\", app }`. */\nexport function createRobotRockAiTriggerContext(\n options: Omit<RobotRockAiTriggerContext, \"mode\"> = {}\n): RobotRockAiContext {\n return { mode: \"trigger\", ...options };\n}\n\n/** Shorthand for `{ mode: \"workflow\", app }`. */\nexport function createRobotRockAiWorkflowContext(\n options: Omit<RobotRockAiWorkflowContext, \"mode\"> = {}\n): RobotRockAiContext {\n return { mode: \"workflow\", ...options };\n}\n\nexport { normalizeRobotRockAiContext };\n","import type { SendToHumanInput } from \"../client.js\";\nimport type { FormatToolApprovalTaskOptions, RobotRockToolCallInfo } from \"./types.js\";\n\nconst DEFAULT_APPROVE_ACTIONS = [\n { id: \"approve\", title: \"Approve execution\" },\n { id: \"deny\", title: \"Deny\" },\n] as const;\n\n/**\n * Build a RobotRock task payload for an AI SDK tool approval request.\n */\nexport function defaultFormatToolApprovalTask(\n toolCall: RobotRockToolCallInfo,\n options: FormatToolApprovalTaskOptions = {}\n): SendToHumanInput {\n const approveId = options.approveActionId ?? \"approve\";\n const denyId = options.denyActionId ?? \"deny\";\n\n let inputPreview: string;\n try {\n inputPreview = JSON.stringify(toolCall.input, null, 2);\n } catch {\n inputPreview = String(toolCall.input);\n }\n\n return {\n type: options.type ?? \"ai-tool-approval\",\n name: `Approve: ${toolCall.toolName}`,\n description: `Review the proposed \\`${toolCall.toolName}\\` tool call before it runs.`,\n context: {\n data: {\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n input: toolCall.input,\n },\n ui: {\n toolName: { \"ui:widget\": \"text\" },\n toolCallId: { \"ui:widget\": \"text\" },\n input: { \"ui:widget\": \"textarea\" },\n },\n },\n actions: [\n { id: approveId, title: \"Approve execution\" },\n { id: denyId, title: \"Deny\" },\n ],\n };\n}\n\nexport { DEFAULT_APPROVE_ACTIONS };\n","import type { ToolApprovalResponse } from \"ai\";\nimport type { RobotRock } from \"../client.js\";\nimport {\n normalizeRobotRockAiContext,\n sendToHumanForAi,\n type RobotRockAiContext,\n} from \"./context.js\";\nimport { defaultFormatToolApprovalTask } from \"./format-tool-approval-task.js\";\nimport type {\n ResolveToolApprovalsOptions,\n RobotRockToolApprovalConfig,\n RobotRockToolCallInfo,\n RunWithRobotRockApprovalsOptions,\n ToolApprovalRequestPart,\n} from \"./types.js\";\n\nexport type RobotRockToolApprovalDecision = \"user-approval\" | undefined;\n\nfunction buildToolMatcher(config: RobotRockToolApprovalConfig) {\n const names = config.tools ? new Set(config.tools) : null;\n\n return (toolCall: RobotRockToolCallInfo): boolean => {\n if (config.when?.(toolCall)) {\n return true;\n }\n if (names && names.has(toolCall.toolName)) {\n return true;\n }\n return false;\n };\n}\n\n/**\n * AI SDK 7+: pass the return value to `toolApproval` on `generateText`, `streamText`, or `ToolLoopAgent`.\n * Returns `'user-approval'` for configured tools so execution pauses until a human responds via RobotRock.\n */\nexport function createRobotRockToolApproval(config: RobotRockToolApprovalConfig) {\n const matches = buildToolMatcher(config);\n\n const toolApproval = async (options: {\n toolCall: RobotRockToolCallInfo;\n }): Promise<RobotRockToolApprovalDecision> => {\n return matches(options.toolCall) ? \"user-approval\" : undefined;\n };\n\n return toolApproval;\n}\n\n/**\n * AI SDK 5–6: use as `needsApproval` on tool definitions (or via {@link applyRobotRockToolApprovalToTools}).\n */\nexport function createRobotRockNeedsApproval(config: RobotRockToolApprovalConfig) {\n const matches = buildToolMatcher(config);\n\n return async (\n _input: unknown,\n options: { toolCallId: string; messages?: unknown[] }\n ): Promise<boolean> => {\n const toolCall = findToolCallInMessages(options.messages, options.toolCallId);\n if (!toolCall) {\n return false;\n }\n return matches(toolCall);\n };\n}\n\n/**\n * AI SDK 5–6: merge `needsApproval` into each matching tool in a tools object.\n */\nexport function applyRobotRockToolApprovalToTools<T extends Record<string, object>>(\n tools: T,\n config: RobotRockToolApprovalConfig\n): T {\n const names = config.tools ? new Set(config.tools) : null;\n const needsApproval = createRobotRockNeedsApproval(config);\n\n const next = { ...tools } as T;\n\n for (const key of Object.keys(tools) as Array<keyof T>) {\n const name = String(key);\n const shouldApply =\n (names && names.has(name)) || (names === null && config.when !== undefined);\n\n if (!shouldApply) {\n continue;\n }\n\n const existing = tools[key];\n next[key] = {\n ...existing,\n needsApproval,\n } as T[keyof T];\n }\n\n return next;\n}\n\nfunction findToolCallInMessages(\n messages: unknown[] | undefined,\n toolCallId: string\n): RobotRockToolCallInfo | undefined {\n if (!messages) {\n return undefined;\n }\n\n for (const message of messages) {\n if (typeof message !== \"object\" || message === null) {\n continue;\n }\n const role = (message as { role?: string }).role;\n if (role !== \"assistant\") {\n continue;\n }\n const content = (message as { content?: unknown }).content;\n if (!Array.isArray(content)) {\n continue;\n }\n\n for (const part of content) {\n if (typeof part !== \"object\" || part === null) {\n continue;\n }\n const p = part as Record<string, unknown>;\n if (p.type === \"tool-call\" && p.toolCallId === toolCallId) {\n return {\n toolName: String(p.toolName ?? \"\"),\n toolCallId,\n input: p.input,\n };\n }\n }\n }\n\n return undefined;\n}\n\nfunction collectApprovalRequests(source: unknown): ToolApprovalRequestPart[] {\n const requests: ToolApprovalRequestPart[] = [];\n\n const visit = (value: unknown) => {\n if (!value) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n visit(item);\n }\n return;\n }\n\n if (typeof value !== \"object\") {\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (obj.type === \"tool-approval-request\" && typeof obj.approvalId === \"string\") {\n if (obj.isAutomatic === true) {\n return;\n }\n\n const embedded = obj.toolCall as Record<string, unknown> | undefined;\n const toolCallId =\n typeof obj.toolCallId === \"string\"\n ? obj.toolCallId\n : typeof embedded?.toolCallId === \"string\"\n ? embedded.toolCallId\n : undefined;\n\n let toolCall: RobotRockToolCallInfo | undefined;\n if (embedded && typeof embedded.toolName === \"string\") {\n toolCall = {\n toolName: embedded.toolName,\n toolCallId: String(embedded.toolCallId ?? toolCallId ?? \"\"),\n input: embedded.input,\n };\n } else if (toolCallId) {\n toolCall = findToolCallInMessages(\n (source as { messages?: unknown[] }).messages,\n toolCallId\n );\n }\n\n requests.push({\n type: \"tool-approval-request\",\n approvalId: obj.approvalId,\n toolCallId,\n toolCall,\n isAutomatic: obj.isAutomatic === true,\n });\n return;\n }\n\n if (Array.isArray(obj.content)) {\n visit(obj.content);\n }\n if (Array.isArray(obj.steps)) {\n visit(obj.steps);\n }\n if (obj.response && typeof obj.response === \"object\") {\n visit((obj.response as { messages?: unknown[] }).messages);\n }\n };\n\n visit(source);\n\n if (typeof source === \"object\" && source !== null && Array.isArray((source as { content?: unknown[] }).content)) {\n visit((source as { content: unknown[] }).content);\n }\n\n const seen = new Set<string>();\n return requests.filter((r) => {\n if (seen.has(r.approvalId)) {\n return false;\n }\n seen.add(r.approvalId);\n return true;\n });\n}\n\nfunction resolveToolCallForRequest(\n request: ToolApprovalRequestPart,\n source: unknown,\n messages: unknown[]\n): RobotRockToolCallInfo {\n if (request.toolCall) {\n return request.toolCall;\n }\n\n const toolCallId = request.toolCallId;\n if (toolCallId) {\n const fromMessages = findToolCallInMessages(messages, toolCallId);\n if (fromMessages) {\n return fromMessages;\n }\n }\n\n if (typeof source === \"object\" && source !== null && Array.isArray((source as { toolCalls?: unknown[] }).toolCalls)) {\n for (const call of (source as { toolCalls: Array<Record<string, unknown>> }).toolCalls) {\n if (call.toolCallId === toolCallId) {\n return {\n toolName: String(call.toolName ?? \"\"),\n toolCallId: String(call.toolCallId ?? \"\"),\n input: call.input,\n };\n }\n }\n }\n\n throw new Error(\n `Could not resolve tool call for approval ${request.approvalId}. Pass messages that include the assistant tool-call.`\n );\n}\n\n/**\n * Create RobotRock tasks for pending AI SDK tool approvals and return `tool-approval-response` parts.\n */\nexport async function resolveToolApprovalsViaRobotRock(\n clientOrContext: RobotRock | RobotRockAiContext,\n source: unknown,\n options: ResolveToolApprovalsOptions = {}\n): Promise<{\n responses: ToolApprovalResponse[];\n messages: unknown[];\n}> {\n const context = normalizeRobotRockAiContext(clientOrContext);\n const approveId = options.approveActionId ?? \"approve\";\n const denyId = options.denyActionId ?? \"deny\";\n const formatTask = options.formatTask ?? defaultFormatToolApprovalTask;\n\n const baseMessages =\n typeof source === \"object\" && source !== null && Array.isArray((source as { messages?: unknown[] }).messages)\n ? [...(source as { messages: unknown[] }).messages]\n : [];\n\n const requests = collectApprovalRequests(source);\n const responses: ToolApprovalResponse[] = [];\n\n for (const request of requests) {\n const toolCall = resolveToolCallForRequest(request, source, baseMessages);\n const taskInput = formatTask(toolCall, {\n approveActionId: approveId,\n denyActionId: denyId,\n });\n\n const result = await sendToHumanForAi(context, taskInput);\n\n const approved = result.actionId === approveId;\n const reason =\n typeof result.data === \"object\" &&\n result.data !== null &&\n \"reason\" in result.data &&\n typeof (result.data as { reason?: unknown }).reason === \"string\"\n ? (result.data as { reason: string }).reason\n : approved\n ? \"Approved in RobotRock inbox\"\n : \"Denied in RobotRock inbox\";\n\n responses.push({\n type: \"tool-approval-response\",\n approvalId: request.approvalId,\n approved,\n reason,\n });\n }\n\n const messages = [...baseMessages];\n if (responses.length > 0) {\n messages.push({ role: \"tool\", content: responses });\n }\n\n return { responses, messages };\n}\n\n/**\n * Run `generate` in a loop until manual tool approvals are resolved via RobotRock or `maxRounds` is reached.\n */\nexport async function runWithRobotRockApprovals<T>(\n options: RunWithRobotRockApprovalsOptions<T>\n): Promise<T> {\n const clientOrContext =\n options.context ??\n (options.client\n ? options.client\n : (() => {\n throw new Error(\"runWithRobotRockApprovals requires `client` or `context`.\");\n })());\n\n const maxRounds = options.maxRounds ?? 20;\n let messages = options.messages ? [...options.messages] : [];\n let lastResult: T | undefined;\n\n for (let round = 0; round < maxRounds; round++) {\n lastResult = await options.generate(messages);\n const { responses, messages: nextMessages } = await resolveToolApprovalsViaRobotRock(\n clientOrContext,\n { ...(lastResult as object), messages },\n options.resolveOptions\n );\n\n if (responses.length === 0) {\n return lastResult;\n }\n\n messages = nextMessages;\n }\n\n throw new Error(`RobotRock approval loop exceeded maxRounds (${ma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AAQ,WAAW,CAAC,GAAG,QAAQ,QAAQ,IAAI,CAAC;AAC3D,MAAI;AAEJ,WAAS,QAAQ,GAAG,QAAQ,WAAW,SAAS;AAC9C,iBAAa,MAAM,QAAQ,SAAS,QAAQ;AAC5C,UAAM,EAAE,WAAW,UAAU,aAAa,IAAI,MAAM;AAAA,MAClD;AAAA,MACA,EAAE,GAAI,YAAuB,SAAS;AAAA,MACtC,QAAQ;AAAA,IACV;AAEA,QAAI,UAAU,WAAW,GAAG;AAC1B,aAAO;AAAA,IACT;AAEA,eAAW;AAAA,EACb;AAEA,QAAM,IAAI,MAAM,+CAA+C,SAAS,GAAG;AAC7E;","names":["result","APPROVE_BY_HUMAN_ACTIONS","tool","z","z","tool","tool","z","z","tool"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport interface JSONSchema7 {\n $id?: string;\n $ref?: string;\n $schema?: string;\n $comment?: string;\n type?: JSONSchema7TypeName | JSONSchema7TypeName[];\n enum?: unknown[];\n const?: unknown;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n minimum?: number;\n exclusiveMinimum?: number;\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n format?: string;\n items?: JSONSchema7 | JSONSchema7[];\n additionalItems?: JSONSchema7 | boolean;\n maxItems?: number;\n minItems?: number;\n uniqueItems?: boolean;\n contains?: JSONSchema7;\n maxProperties?: number;\n minProperties?: number;\n required?: string[];\n properties?: Record<string, JSONSchema7>;\n patternProperties?: Record<string, JSONSchema7>;\n additionalProperties?: JSONSchema7 | boolean;\n dependencies?: Record<string, JSONSchema7 | string[]>;\n propertyNames?: JSONSchema7;\n if?: JSONSchema7;\n then?: JSONSchema7;\n else?: JSONSchema7;\n allOf?: JSONSchema7[];\n anyOf?: JSONSchema7[];\n oneOf?: JSONSchema7[];\n not?: JSONSchema7;\n title?: string;\n description?: string;\n default?: unknown;\n readOnly?: boolean;\n writeOnly?: boolean;\n examples?: unknown[];\n}\n\nexport type JSONSchema7TypeName =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\"\n | \"null\";\n\nexport type ExtendedJSONSchema7 = JSONSchema7 & {\n enumNames?: string[];\n [key: string]: unknown;\n};\n\nexport type UiSchema = {\n \"ui:widget\"?: string;\n \"ui:title\"?: string;\n \"ui:description\"?: string;\n \"ui:placeholder\"?: string;\n \"ui:options\"?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\nconst safeUrlSchema = z\n .string()\n .refine((url) => url.startsWith(\"http://\") || url.startsWith(\"https://\"), {\n message: \"URL must start with http:// or https://\",\n });\n\nconst jsonSchema7Schema = z.custom<ExtendedJSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n { message: \"Must be a valid JSON Schema object\" }\n);\n\nconst uiSchemaSchema = z.custom<UiSchema>((val) => typeof val === \"object\" && val !== null, {\n message: \"Must be a valid UiSchema object\",\n});\n\nconst webhookHandlerSchema = z.object({\n type: z.literal(\"webhook\"),\n url: safeUrlSchema,\n headers: z.record(z.string()),\n});\n\nconst triggerHandlerSchema = webhookHandlerSchema.extend({\n type: z.literal(\"trigger\"),\n tokenId: z.string().min(1),\n});\n\nconst handlerSchema = z.discriminatedUnion(\"type\", [webhookHandlerSchema, triggerHandlerSchema]);\n\nconst taskActionSchema = z.object({\n id: z.string().min(1),\n title: z.string().min(1),\n description: z.string().optional(),\n schema: jsonSchema7Schema.optional(),\n ui: uiSchemaSchema.optional(),\n data: z.record(z.unknown()).optional(),\n handlers: z.array(handlerSchema).min(1).optional(),\n});\n\nconst uiFieldSchemaSchema: z.ZodType<Record<string, unknown>> = z\n .object({\n \"ui:widget\": z.string().optional(),\n \"ui:title\": z.string().optional(),\n \"ui:description\": z.string().optional(),\n \"ui:options\": z.record(z.unknown()).optional(),\n items: z.lazy(() => z.record(uiFieldSchemaSchema)).optional(),\n })\n .passthrough();\n\nconst contextUiSchema = z.record(uiFieldSchemaSchema).optional();\n\nconst contextDataSchema = z\n .object({\n data: z.record(z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\nexport const taskContextSchema = z.object({\n app: z.string().min(1).optional(),\n type: z.string().min(1),\n name: z.string().min(1),\n description: z.string().optional(),\n validUntil: z.string().optional(),\n context: contextDataSchema,\n version: z.literal(2).optional(),\n actions: z.array(taskActionSchema).min(1, \"At least one action is required\"),\n});\n\n/**\n * Assignment targets at task create (not stored in task context JSON).\n * Unknown user emails are auto-provisioned as assignee memberships (not full team seats).\n */\nexport const assignToSchema = z\n .object({\n users: z.array(z.string().email()).optional(),\n groups: z.array(z.string().min(1)).optional(),\n })\n .refine(\n (data) => {\n const groups = data.groups ?? [];\n if (groups.includes(\"all\") && groups.length > 1) {\n return false;\n }\n return true;\n },\n { message: 'Cannot combine \"all\" with other group slugs' }\n );\n\n/** A short thread-scoped status update message (1-2 sentences). */\nexport const threadUpdateMessageSchema = z.string().min(1).max(500);\n\n/**\n * Lifecycle status carried by a thread update. Drives the icon and color shown\n * in the inbox status bar. Defaults to `info` when omitted.\n */\nexport const threadUpdateStatuses = [\n \"info\",\n \"queued\",\n \"running\",\n \"waiting\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n] as const;\n\nexport const threadUpdateStatusSchema = z.enum(threadUpdateStatuses);\n\n/** The default status applied when an update omits one. */\nexport const DEFAULT_THREAD_UPDATE_STATUS: ThreadUpdateStatus = \"info\";\n\n/** Shared shape for a thread update (standalone and at task creation). */\nexport const threadUpdateInputSchema = z.object({\n message: threadUpdateMessageSchema,\n status: threadUpdateStatusSchema.optional(),\n});\n\n/** Thread priority levels for inbox ordering and display. */\nexport const taskPriorities = [\"low\", \"normal\", \"high\", \"urgent\"] as const;\n\nexport const taskPrioritySchema = z.enum(taskPriorities);\n\nexport type TaskPriority = (typeof taskPriorities)[number];\n\nexport const DEFAULT_TASK_PRIORITY: TaskPriority = \"normal\";\n\nexport const LOWEST_TASK_PRIORITY: TaskPriority = \"low\";\n\nexport const TASK_PRIORITY_RANK: Record<TaskPriority, number> = {\n low: 1,\n normal: 2,\n high: 3,\n urgent: 4,\n};\n\nexport const createTaskBodySchema = taskContextSchema.extend({\n assignTo: assignToSchema.optional(),\n /**\n * Groups related tasks together. When omitted, the server generates one and\n * returns it so the caller can reuse it on later tasks in the same thread.\n */\n threadId: z.string().min(1).optional(),\n /**\n * Optional thread priority. When set, applies to the whole thread and\n * overwrites any previous priority. Omit on later tasks to leave unchanged.\n */\n priority: taskPrioritySchema.optional(),\n /**\n * Optional initial status update logged against the task's thread. Shows in\n * the inbox status bar and the thread update log.\n */\n update: threadUpdateInputSchema.optional(),\n});\n\n/** POST /v1/threads/:threadId/updates body: a standalone thread update. */\nexport const threadUpdateBodySchema = threadUpdateInputSchema;\n\n/** Where a thread update originated. */\nexport type ThreadUpdateSource = \"api\" | \"task_create\" | \"dashboard\";\n\n/** Lifecycle status carried by a thread update. */\nexport type ThreadUpdateStatus = (typeof threadUpdateStatuses)[number];\n\n/** A logged thread update as returned by the API. */\nexport interface ThreadUpdate {\n id: string;\n threadId: string;\n message: string;\n status: ThreadUpdateStatus;\n source: ThreadUpdateSource;\n createdAt: number;\n}\n\nexport type AssignToInput = z.infer<typeof assignToSchema>;\nexport type CreateTaskBodyInput = z.input<typeof createTaskBodySchema>;\nexport type CreateTaskBody = z.output<typeof createTaskBodySchema>;\nexport type ThreadUpdateBodyInput = z.input<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateBody = z.output<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateInput = z.input<typeof threadUpdateInputSchema>;\nexport type TaskContextInput = z.input<typeof taskContextSchema>;\nexport type TaskContextOutput = z.output<typeof taskContextSchema>;\nexport type TaskContext = TaskContextOutput;\nexport type TaskAction = z.infer<typeof taskActionSchema>;\nexport type WebhookHandler = z.infer<typeof webhookHandlerSchema>;\nexport type TriggerHandler = z.infer<typeof triggerHandlerSchema>;\nexport type Handler = z.infer<typeof handlerSchema>;\n\ntype InferObjectProperties<\n Props,\n Req extends PropertyKey,\n> = Props extends Record<string, unknown>\n ? ({\n [K in keyof Props as K extends Req ? K : never]-?: InferJsonSchema7<Props[K]>;\n } & {\n [K in keyof Props as K extends Req ? never : K]?: InferJsonSchema7<Props[K]>;\n } extends infer O\n ? { [K in keyof O]: O[K] }\n : never)\n : Record<string, unknown>;\n\ntype RequiredKeys<S> =\n S extends { readonly required: readonly string[] } ? S[\"required\"][number] : never;\n\nexport type InferJsonSchema7<S> = [S] extends [undefined]\n ? Record<string, never>\n : S extends { readonly const: infer C }\n ? C\n : S extends {\n readonly enum: readonly (infer E)[];\n }\n ? E\n : S extends {\n readonly type: \"object\";\n readonly properties?: infer Props;\n }\n ? InferObjectProperties<Props, RequiredKeys<S>>\n : S extends {\n readonly type: \"object\";\n readonly properties?: undefined;\n }\n ? Record<string, unknown>\n : S extends {\n readonly type: \"array\";\n readonly items?: infer Items;\n }\n ? Items extends readonly unknown[]\n ? InferJsonSchema7<Items[number]>[]\n : Items extends object\n ? InferJsonSchema7<Items>[]\n : unknown[]\n : S extends { readonly type: \"string\" }\n ? string\n : S extends { readonly type: \"number\" } | { readonly type: \"integer\" }\n ? number\n : S extends { readonly type: \"boolean\" }\n ? boolean\n : unknown;\n\nexport type TaskStatus = \"pending\" | \"open\" | \"handled\" | \"expired\";\n\nexport interface TaskResponse {\n success: boolean;\n task: {\n taskId: string;\n threadId: string;\n status: \"pending\" | \"open\";\n context: TaskContext;\n validUntil: string;\n submittedAt: string;\n };\n message: string;\n}\n\nexport interface ThreadUpdateResponse {\n success: boolean;\n update: ThreadUpdate;\n message: string;\n}\n\nexport interface Task {\n id: string;\n threadId?: string;\n createdAt: Date;\n status: TaskStatus;\n context: TaskContext;\n validUntil: number;\n handledAt?: number;\n handled?: {\n action: {\n id: string;\n data: unknown;\n };\n handledBy?: string;\n userId?: string;\n token?: string;\n };\n}\n\nexport type InferActionData<T extends { schema?: unknown }> = [\n Exclude<T[\"schema\"], undefined>,\n] extends [\n never,\n]\n ? Record<string, never>\n : Exclude<T[\"schema\"], undefined> extends infer S\n ? InferJsonSchema7<S>\n : Record<string, never>;\n\nexport type TupleElementIndices<T extends readonly unknown[]> = T extends readonly [\n unknown,\n ...unknown[],\n]\n ? Exclude<keyof T, keyof unknown[]>\n : number;\n\nexport interface TaskResult<T = Record<string, unknown>> {\n actionId: string;\n data: T;\n handledBy?: string;\n handledAt: Date;\n}\n\nexport interface ApprovalResult<T = Record<string, unknown>> extends TaskResult<T> {\n taskId: string;\n}\n\nexport type DiscriminatedApprovalResult<\n TActions extends readonly { id: string; schema?: unknown }[],\n> = {\n [I in TupleElementIndices<TActions>]: TActions[I] extends { id: string; schema?: unknown }\n ? Omit<ApprovalResult<InferActionData<TActions[I]>>, \"actionId\" | \"data\"> & {\n actionId: TActions[I][\"id\"];\n data: InferActionData<TActions[I]>;\n }\n : never\n}[TupleElementIndices<TActions>];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAuElB,IAAM,gBAAgB,EACnB,OAAO,EACP,OAAO,CAAC,QAAQ,IAAI,WAAW,SAAS,KAAK,IAAI,WAAW,UAAU,GAAG;AAAA,EACxE,SAAS;AACX,CAAC;AAEH,IAAM,oBAAoB,EAAE;AAAA,EAC1B,CAAC,QAAQ,OAAO,QAAQ,YAAY,QAAQ;AAAA,EAC5C,EAAE,SAAS,qCAAqC;AAClD;AAEA,IAAM,iBAAiB,EAAE,OAAiB,CAAC,QAAQ,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAAA,EAC1F,SAAS;AACX,CAAC;AAED,IAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,KAAK;AAAA,EACL,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC;AAC9B,CAAC;AAED,IAAM,uBAAuB,qBAAqB,OAAO;AAAA,EACvD,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,SAA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