robotrock 0.6.0 → 0.8.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 +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 (${maxRounds})`);\n}\n\nexport { collectApprovalRequests };\n"],"mappings":";;;;;;;;;;;AASA,IAAM,2BAA2B;AAAA,EAC/B,EAAE,IAAI,WAAW,OAAO,UAAU;AAAA,EAClC,EAAE,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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,67 +0,0 @@
1
- // src/handler-webhook.ts
2
- function isRobotRockHandlerWebhookPayload(value) {
3
- if (typeof value !== "object" || value === null) {
4
- return false;
5
- }
6
- const v = value;
7
- if (typeof v.taskId !== "string" || typeof v.handledAt !== "string") {
8
- return false;
9
- }
10
- const action = v.action;
11
- if (typeof action !== "object" || action === null) {
12
- return false;
13
- }
14
- const a = action;
15
- return typeof a.id === "string" && "data" in a;
16
- }
17
-
18
- // src/wait-timing.ts
19
- var DEFAULT_WAIT_DURATION_MS = 7 * 24 * 60 * 60 * 1e3;
20
- function resolveWaitTiming(validUntilInput) {
21
- const validUntilMs = validUntilInput !== void 0 ? parseValidUntilMs(validUntilInput) : Date.now() + DEFAULT_WAIT_DURATION_MS;
22
- const durationMs = validUntilMs - Date.now();
23
- if (durationMs <= 0) {
24
- throw new Error("validUntil must be in the future");
25
- }
26
- return {
27
- validUntil: validUntilInput ?? new Date(validUntilMs),
28
- timeout: durationMsToTimeout(durationMs)
29
- };
30
- }
31
- function parseValidUntilMs(value) {
32
- if (value instanceof Date) {
33
- const ms = value.getTime();
34
- if (Number.isNaN(ms)) {
35
- throw new Error("Invalid validUntil: Date is invalid");
36
- }
37
- return ms;
38
- }
39
- const parsed = Date.parse(value);
40
- if (Number.isNaN(parsed)) {
41
- throw new Error("Invalid validUntil: expected a parseable date string");
42
- }
43
- return parsed;
44
- }
45
- function durationMsToTimeout(durationMs) {
46
- const seconds = Math.ceil(durationMs / 1e3);
47
- if (seconds <= 0) {
48
- throw new Error("validUntil must be in the future");
49
- }
50
- if (seconds >= 86400) {
51
- return `${Math.ceil(seconds / 86400)}d`;
52
- }
53
- if (seconds >= 3600) {
54
- return `${Math.ceil(seconds / 3600)}h`;
55
- }
56
- if (seconds >= 60) {
57
- return `${Math.ceil(seconds / 60)}m`;
58
- }
59
- return `${seconds}s`;
60
- }
61
-
62
- export {
63
- isRobotRockHandlerWebhookPayload,
64
- resolveWaitTiming,
65
- parseValidUntilMs
66
- };
67
- //# sourceMappingURL=chunk-D2FBSEZK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/handler-webhook.ts","../src/wait-timing.ts"],"sourcesContent":["/**\n * JSON body posted when a RobotRock action handler runs (webhook or Trigger wait token).\n */\nexport interface RobotRockHandlerWebhookPayload {\n taskId: string;\n action: {\n id: string;\n title: string;\n data: unknown;\n };\n handledBy?: string;\n handledAt: string;\n handlerType: string;\n}\n\nexport function isRobotRockHandlerWebhookPayload(\n value: unknown\n): value is RobotRockHandlerWebhookPayload {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const v = value as Record<string, unknown>;\n if (typeof v.taskId !== \"string\" || typeof v.handledAt !== \"string\") {\n return false;\n }\n const action = v.action;\n if (typeof action !== \"object\" || action === null) {\n return false;\n }\n const a = action as Record<string, unknown>;\n return typeof a.id === \"string\" && \"data\" in a;\n}\n","/** Default wait when `validUntil` is omitted. */\nexport const DEFAULT_WAIT_DURATION_MS = 7 * 24 * 60 * 60 * 1000;\n\nexport function resolveWaitTiming(validUntilInput?: Date | string): {\n validUntil: Date | string;\n timeout: string;\n} {\n const validUntilMs =\n validUntilInput !== undefined\n ? parseValidUntilMs(validUntilInput)\n : Date.now() + DEFAULT_WAIT_DURATION_MS;\n\n const durationMs = validUntilMs - Date.now();\n if (durationMs <= 0) {\n throw new Error(\"validUntil must be in the future\");\n }\n\n return {\n validUntil: validUntilInput ?? new Date(validUntilMs),\n timeout: durationMsToTimeout(durationMs),\n };\n}\n\nexport function parseValidUntilMs(value: Date | string): number {\n if (value instanceof Date) {\n const ms = value.getTime();\n if (Number.isNaN(ms)) {\n throw new Error(\"Invalid validUntil: Date is invalid\");\n }\n return ms;\n }\n\n const parsed = Date.parse(value);\n if (Number.isNaN(parsed)) {\n throw new Error(\"Invalid validUntil: expected a parseable date string\");\n }\n\n return parsed;\n}\n\n/** Duration string for Trigger.dev `wait.createToken` and Workflow `sleep`. */\nexport function durationMsToTimeout(durationMs: number): string {\n const seconds = Math.ceil(durationMs / 1000);\n if (seconds <= 0) {\n throw new Error(\"validUntil must be in the future\");\n }\n\n if (seconds >= 86_400) {\n return `${Math.ceil(seconds / 86_400)}d`;\n }\n if (seconds >= 3_600) {\n return `${Math.ceil(seconds / 3_600)}h`;\n }\n if (seconds >= 60) {\n return `${Math.ceil(seconds / 60)}m`;\n }\n\n return `${seconds}s`;\n}\n"],"mappings":";AAeO,SAAS,iCACd,OACyC;AACzC,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AACA,QAAM,IAAI;AACV,MAAI,OAAO,EAAE,WAAW,YAAY,OAAO,EAAE,cAAc,UAAU;AACnE,WAAO;AAAA,EACT;AACA,QAAM,SAAS,EAAE;AACjB,MAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,WAAO;AAAA,EACT;AACA,QAAM,IAAI;AACV,SAAO,OAAO,EAAE,OAAO,YAAY,UAAU;AAC/C;;;AC9BO,IAAM,2BAA2B,IAAI,KAAK,KAAK,KAAK;AAEpD,SAAS,kBAAkB,iBAGhC;AACA,QAAM,eACJ,oBAAoB,SAChB,kBAAkB,eAAe,IACjC,KAAK,IAAI,IAAI;AAEnB,QAAM,aAAa,eAAe,KAAK,IAAI;AAC3C,MAAI,cAAc,GAAG;AACnB,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AAEA,SAAO;AAAA,IACL,YAAY,mBAAmB,IAAI,KAAK,YAAY;AAAA,IACpD,SAAS,oBAAoB,UAAU;AAAA,EACzC;AACF;AAEO,SAAS,kBAAkB,OAA8B;AAC9D,MAAI,iBAAiB,MAAM;AACzB,UAAM,KAAK,MAAM,QAAQ;AACzB,QAAI,OAAO,MAAM,EAAE,GAAG;AACpB,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AACA,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,KAAK,MAAM,KAAK;AAC/B,MAAI,OAAO,MAAM,MAAM,GAAG;AACxB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AAEA,SAAO;AACT;AAGO,SAAS,oBAAoB,YAA4B;AAC9D,QAAM,UAAU,KAAK,KAAK,aAAa,GAAI;AAC3C,MAAI,WAAW,GAAG;AAChB,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AAEA,MAAI,WAAW,OAAQ;AACrB,WAAO,GAAG,KAAK,KAAK,UAAU,KAAM,CAAC;AAAA,EACvC;AACA,MAAI,WAAW,MAAO;AACpB,WAAO,GAAG,KAAK,KAAK,UAAU,IAAK,CAAC;AAAA,EACtC;AACA,MAAI,WAAW,IAAI;AACjB,WAAO,GAAG,KAAK,KAAK,UAAU,EAAE,CAAC;AAAA,EACnC;AAEA,SAAO,GAAG,OAAO;AACnB;","names":[]}
@@ -1,177 +0,0 @@
1
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __using = (stack, value, async) => {
6
- if (value != null) {
7
- if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
8
- var dispose, inner;
9
- if (async) dispose = value[__knownSymbol("asyncDispose")];
10
- if (dispose === void 0) {
11
- dispose = value[__knownSymbol("dispose")];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") __typeError("Object not disposable");
15
- if (inner) dispose = function() {
16
- try {
17
- inner.call(this);
18
- } catch (e) {
19
- return Promise.reject(e);
20
- }
21
- };
22
- stack.push([async, dispose, value]);
23
- } else if (async) {
24
- stack.push([async]);
25
- }
26
- return value;
27
- };
28
- var __callDispose = (stack, error, hasError) => {
29
- var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
30
- return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
31
- };
32
- var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
33
- var next = (it) => {
34
- while (it = stack.pop()) {
35
- try {
36
- var result = it[1] && it[1].call(it[2]);
37
- if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
38
- } catch (e) {
39
- fail(e);
40
- }
41
- }
42
- if (hasError) throw error;
43
- };
44
- return next();
45
- };
46
-
47
- // src/schemas/index.ts
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://"
51
- });
52
- var jsonSchema7Schema = z.custom(
53
- (val) => typeof val === "object" && val !== null,
54
- { message: "Must be a valid JSON Schema object" }
55
- );
56
- var uiSchemaSchema = z.custom((val) => typeof val === "object" && val !== null, {
57
- message: "Must be a valid UiSchema object"
58
- });
59
- var webhookHandlerSchema = z.object({
60
- type: z.literal("webhook"),
61
- url: safeUrlSchema,
62
- headers: z.record(z.string())
63
- });
64
- var triggerHandlerSchema = webhookHandlerSchema.extend({
65
- type: z.literal("trigger"),
66
- tokenId: z.string().min(1)
67
- });
68
- var handlerSchema = z.discriminatedUnion("type", [webhookHandlerSchema, triggerHandlerSchema]);
69
- var taskActionSchema = z.object({
70
- id: z.string().min(1),
71
- title: z.string().min(1),
72
- description: z.string().optional(),
73
- schema: jsonSchema7Schema.optional(),
74
- ui: uiSchemaSchema.optional(),
75
- data: z.record(z.unknown()).optional(),
76
- handlers: z.array(handlerSchema).min(1).optional()
77
- });
78
- var uiFieldSchemaSchema = z.object({
79
- "ui:widget": z.string().optional(),
80
- "ui:title": z.string().optional(),
81
- "ui:description": z.string().optional(),
82
- "ui:options": z.record(z.unknown()).optional(),
83
- items: z.lazy(() => z.record(uiFieldSchemaSchema)).optional()
84
- }).passthrough();
85
- var contextUiSchema = z.record(uiFieldSchemaSchema).optional();
86
- var contextDataSchema = z.object({
87
- data: z.record(z.unknown()),
88
- ui: contextUiSchema
89
- }).optional();
90
- var taskContextSchema = z.object({
91
- app: z.string().min(1).optional(),
92
- type: z.string().min(1),
93
- name: z.string().min(1),
94
- description: z.string().optional(),
95
- validUntil: z.string().optional(),
96
- context: contextDataSchema,
97
- version: z.literal(2).optional(),
98
- actions: z.array(taskActionSchema).min(1, "At least one action is required")
99
- });
100
- var assignToSchema = z.object({
101
- users: z.array(z.string().email()).optional(),
102
- groups: z.array(z.string().min(1)).optional()
103
- }).refine(
104
- (data) => {
105
- const groups = data.groups ?? [];
106
- if (groups.includes("all") && groups.length > 1) {
107
- return false;
108
- }
109
- return true;
110
- },
111
- { message: 'Cannot combine "all" with other group slugs' }
112
- );
113
- var threadUpdateMessageSchema = z.string().min(1).max(500);
114
- var threadUpdateStatuses = [
115
- "info",
116
- "queued",
117
- "running",
118
- "waiting",
119
- "succeeded",
120
- "failed",
121
- "cancelled"
122
- ];
123
- var threadUpdateStatusSchema = z.enum(threadUpdateStatuses);
124
- var DEFAULT_THREAD_UPDATE_STATUS = "info";
125
- var threadUpdateInputSchema = z.object({
126
- message: threadUpdateMessageSchema,
127
- status: threadUpdateStatusSchema.optional()
128
- });
129
- var taskPriorities = ["low", "normal", "high", "urgent"];
130
- var taskPrioritySchema = z.enum(taskPriorities);
131
- var DEFAULT_TASK_PRIORITY = "normal";
132
- var LOWEST_TASK_PRIORITY = "low";
133
- var TASK_PRIORITY_RANK = {
134
- low: 1,
135
- normal: 2,
136
- high: 3,
137
- urgent: 4
138
- };
139
- var createTaskBodySchema = taskContextSchema.extend({
140
- assignTo: assignToSchema.optional(),
141
- /**
142
- * Groups related tasks together. When omitted, the server generates one and
143
- * returns it so the caller can reuse it on later tasks in the same thread.
144
- */
145
- threadId: z.string().min(1).optional(),
146
- /**
147
- * Optional thread priority. When set, applies to the whole thread and
148
- * overwrites any previous priority. Omit on later tasks to leave unchanged.
149
- */
150
- priority: taskPrioritySchema.optional(),
151
- /**
152
- * Optional initial status update logged against the task's thread. Shows in
153
- * the inbox status bar and the thread update log.
154
- */
155
- update: threadUpdateInputSchema.optional()
156
- });
157
- var threadUpdateBodySchema = threadUpdateInputSchema;
158
-
159
- export {
160
- __using,
161
- __callDispose,
162
- taskContextSchema,
163
- assignToSchema,
164
- threadUpdateMessageSchema,
165
- threadUpdateStatuses,
166
- threadUpdateStatusSchema,
167
- DEFAULT_THREAD_UPDATE_STATUS,
168
- threadUpdateInputSchema,
169
- taskPriorities,
170
- taskPrioritySchema,
171
- DEFAULT_TASK_PRIORITY,
172
- LOWEST_TASK_PRIORITY,
173
- TASK_PRIORITY_RANK,
174
- createTaskBodySchema,
175
- threadUpdateBodySchema
176
- };
177
- //# sourceMappingURL=chunk-TAWMIQAM.js.map
@@ -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,SA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