robotrock 0.1.0 → 0.3.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.
- package/README.md +190 -33
- package/dist/ai/index.d.ts +24 -0
- package/dist/ai/index.js +46 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/trigger.d.ts +5 -0
- package/dist/ai/trigger.js +24 -0
- package/dist/ai/trigger.js.map +1 -0
- package/dist/ai/workflow.d.ts +5 -0
- package/dist/ai/workflow.js +24 -0
- package/dist/ai/workflow.js.map +1 -0
- package/dist/chunk-D2FBSEZK.js +67 -0
- package/dist/chunk-D2FBSEZK.js.map +1 -0
- package/dist/chunk-DSZ3GMT4.js +518 -0
- package/dist/chunk-DSZ3GMT4.js.map +1 -0
- package/dist/chunk-KOXJCIST.js +332 -0
- package/dist/chunk-KOXJCIST.js.map +1 -0
- package/dist/chunk-LXM7VS4Q.js +129 -0
- package/dist/chunk-LXM7VS4Q.js.map +1 -0
- package/dist/client-Dhk9qxhL.d.ts +104 -0
- package/dist/handler-webhook-BqEi6Bk-.d.ts +16 -0
- package/dist/index.d.ts +84 -33
- package/dist/index.js +117 -38
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +643 -0
- package/dist/schemas/index.js +11 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/trigger/index.d.ts +34 -37
- package/dist/trigger/index.js +44 -72
- package/dist/trigger/index.js.map +1 -1
- package/dist/workflow/index.d.ts +35 -0
- package/dist/workflow/index.js +99 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow-BYeIZgD0.d.ts +309 -0
- package/package.json +38 -8
- package/dist/chunk-TUQXDKV6.js +0 -209
- package/dist/chunk-TUQXDKV6.js.map +0 -1
- package/dist/client-BQ-j7q68.d.ts +0 -37
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
import { ToolApprovalResponse } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { b as RobotRock, a as SendToHumanInput, S as SendToHumanActionInput } from './client-Dhk9qxhL.js';
|
|
5
|
+
import { DiscriminatedApprovalResult } from './schemas/index.js';
|
|
6
|
+
|
|
7
|
+
declare const APPROVE_BY_HUMAN_ACTIONS$1: readonly [{
|
|
8
|
+
readonly id: "approve";
|
|
9
|
+
readonly title: "Approve";
|
|
10
|
+
}, {
|
|
11
|
+
readonly id: "decline";
|
|
12
|
+
readonly title: "Decline";
|
|
13
|
+
}];
|
|
14
|
+
/** How RobotRock waits for a human inside AI SDK tool `execute`. */
|
|
15
|
+
type RobotRockAiMode = "polling" | "trigger" | "workflow";
|
|
16
|
+
/**
|
|
17
|
+
* Polling: `client.sendToHuman()` blocks until handled (scripts, API routes with long timeout).
|
|
18
|
+
* Trigger: `sendToHumanTask.triggerAndWait()` uses wait tokens (Trigger.dev workers).
|
|
19
|
+
* Workflow: `sendToHumanInWorkflow()` uses workflow webhooks (Vercel Workflow).
|
|
20
|
+
*/
|
|
21
|
+
type RobotRockAiPollingContext = {
|
|
22
|
+
mode?: "polling";
|
|
23
|
+
client: RobotRock;
|
|
24
|
+
};
|
|
25
|
+
type RobotRockAiTriggerContext = {
|
|
26
|
+
mode: "trigger";
|
|
27
|
+
/** Inbox app bucket; falls back to `ROBOTROCK_APP` in the Trigger worker. */
|
|
28
|
+
app?: string;
|
|
29
|
+
};
|
|
30
|
+
type RobotRockAiWorkflowContext = {
|
|
31
|
+
mode: "workflow";
|
|
32
|
+
/** Inbox app bucket; falls back to `ROBOTROCK_APP` in the workflow run. */
|
|
33
|
+
app?: string;
|
|
34
|
+
};
|
|
35
|
+
type RobotRockAiContext = RobotRockAiPollingContext | RobotRockAiTriggerContext | RobotRockAiWorkflowContext;
|
|
36
|
+
declare function normalizeRobotRockAiContext(clientOrContext: RobotRock | RobotRockAiContext): RobotRockAiContext;
|
|
37
|
+
declare function sendToHumanForAi<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]>(context: RobotRockAiContext, payload: SendToHumanInput<A>): Promise<DiscriminatedApprovalResult<A>>;
|
|
38
|
+
declare function approveByHumanForAi(context: RobotRockAiContext, payload: Omit<SendToHumanInput, "actions"> & {
|
|
39
|
+
app?: string;
|
|
40
|
+
}): Promise<DiscriminatedApprovalResult<typeof APPROVE_BY_HUMAN_ACTIONS$1>>;
|
|
41
|
+
|
|
42
|
+
type HumanToolResult = {
|
|
43
|
+
taskId: string;
|
|
44
|
+
actionId: string;
|
|
45
|
+
data: unknown;
|
|
46
|
+
handledBy?: string;
|
|
47
|
+
handledAt: string;
|
|
48
|
+
/** Present when action ids are approve/decline (or approve/reject). */
|
|
49
|
+
approved?: boolean;
|
|
50
|
+
};
|
|
51
|
+
type RobotRockToolCallInfo = {
|
|
52
|
+
toolName: string;
|
|
53
|
+
toolCallId: string;
|
|
54
|
+
input: unknown;
|
|
55
|
+
};
|
|
56
|
+
type RobotRockToolApprovalConfig = {
|
|
57
|
+
/** Tool names that require RobotRock inbox approval before execution. */
|
|
58
|
+
tools?: readonly string[];
|
|
59
|
+
/** Custom predicate when tool names alone are not enough. */
|
|
60
|
+
when?: (toolCall: RobotRockToolCallInfo) => boolean;
|
|
61
|
+
};
|
|
62
|
+
type FormatToolApprovalTaskOptions = {
|
|
63
|
+
type?: string;
|
|
64
|
+
approveActionId?: string;
|
|
65
|
+
denyActionId?: string;
|
|
66
|
+
};
|
|
67
|
+
type ResolveToolApprovalsOptions = {
|
|
68
|
+
formatTask?: (toolCall: RobotRockToolCallInfo) => SendToHumanInput;
|
|
69
|
+
approveActionId?: string;
|
|
70
|
+
denyActionId?: string;
|
|
71
|
+
};
|
|
72
|
+
type RunWithRobotRockApprovalsOptions<T> = {
|
|
73
|
+
/** Polling mode (requires `client`). */
|
|
74
|
+
client?: RobotRock;
|
|
75
|
+
/** Polling or Trigger mode; use `{ mode: "trigger" }` inside Trigger.dev workers. */
|
|
76
|
+
context?: RobotRockAiContext;
|
|
77
|
+
/** Initial messages; updated across approval rounds. */
|
|
78
|
+
messages?: unknown[];
|
|
79
|
+
maxRounds?: number;
|
|
80
|
+
resolveOptions?: ResolveToolApprovalsOptions;
|
|
81
|
+
generate: (messages: unknown[]) => Promise<T>;
|
|
82
|
+
};
|
|
83
|
+
type ToolApprovalRequestPart = {
|
|
84
|
+
type: "tool-approval-request";
|
|
85
|
+
approvalId: string;
|
|
86
|
+
toolCallId?: string;
|
|
87
|
+
toolCall?: RobotRockToolCallInfo;
|
|
88
|
+
isAutomatic?: boolean;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare const APPROVE_BY_HUMAN_ACTIONS: readonly [{
|
|
92
|
+
readonly id: "approve";
|
|
93
|
+
readonly title: "Approve";
|
|
94
|
+
}, {
|
|
95
|
+
readonly id: "decline";
|
|
96
|
+
readonly title: "Decline";
|
|
97
|
+
}];
|
|
98
|
+
declare const approveByHumanInputSchema: z.ZodObject<{
|
|
99
|
+
type: z.ZodOptional<z.ZodString>;
|
|
100
|
+
name: z.ZodString;
|
|
101
|
+
description: z.ZodString;
|
|
102
|
+
contextSummary: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
description: string;
|
|
105
|
+
name: string;
|
|
106
|
+
type?: string | undefined;
|
|
107
|
+
contextSummary?: string | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
description: string;
|
|
110
|
+
name: string;
|
|
111
|
+
type?: string | undefined;
|
|
112
|
+
contextSummary?: string | undefined;
|
|
113
|
+
}>;
|
|
114
|
+
type ApproveByHumanToolOptions = {
|
|
115
|
+
defaultType?: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
toolName?: string;
|
|
118
|
+
};
|
|
119
|
+
type ApproveByHumanToolDurableOptions = ApproveByHumanToolOptions & RobotRockAiContext & {
|
|
120
|
+
mode: "trigger" | "workflow";
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* AI SDK tool with fixed approve/decline actions; blocks until a human decides.
|
|
124
|
+
*
|
|
125
|
+
* - `approveByHumanTool(robotrock)` — polling via `client.sendToHuman()` (default).
|
|
126
|
+
* - `approveByHumanTool({ mode: "trigger", app?: "my-agent" })` — durable wait via Trigger.dev.
|
|
127
|
+
* - `approveByHumanTool({ mode: "workflow", app?: "my-agent" })` — durable wait via Vercel Workflow.
|
|
128
|
+
*/
|
|
129
|
+
declare function approveByHumanTool(clientOrContext: RobotRock | ApproveByHumanToolDurableOptions, maybeOptions?: ApproveByHumanToolOptions): ai.Tool<{
|
|
130
|
+
description: string;
|
|
131
|
+
name: string;
|
|
132
|
+
type?: string | undefined;
|
|
133
|
+
contextSummary?: string | undefined;
|
|
134
|
+
}, HumanToolResult>;
|
|
135
|
+
|
|
136
|
+
declare const sendToHumanToolInputSchema: z.ZodObject<{
|
|
137
|
+
type: z.ZodString;
|
|
138
|
+
name: z.ZodString;
|
|
139
|
+
description: z.ZodOptional<z.ZodString>;
|
|
140
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
142
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
|
144
|
+
ui?: Record<string, unknown> | undefined;
|
|
145
|
+
data?: Record<string, unknown> | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
ui?: Record<string, unknown> | undefined;
|
|
148
|
+
data?: Record<string, unknown> | undefined;
|
|
149
|
+
}>>;
|
|
150
|
+
validUntil: z.ZodOptional<z.ZodString>;
|
|
151
|
+
assignTo: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
152
|
+
users: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
153
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
users?: string[] | undefined;
|
|
156
|
+
groups?: string[] | undefined;
|
|
157
|
+
}, {
|
|
158
|
+
users?: string[] | undefined;
|
|
159
|
+
groups?: string[] | undefined;
|
|
160
|
+
}>, {
|
|
161
|
+
users?: string[] | undefined;
|
|
162
|
+
groups?: string[] | undefined;
|
|
163
|
+
}, {
|
|
164
|
+
users?: string[] | undefined;
|
|
165
|
+
groups?: string[] | undefined;
|
|
166
|
+
}>>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
type: string;
|
|
169
|
+
name: string;
|
|
170
|
+
description?: string | undefined;
|
|
171
|
+
validUntil?: string | undefined;
|
|
172
|
+
context?: {
|
|
173
|
+
ui?: Record<string, unknown> | undefined;
|
|
174
|
+
data?: Record<string, unknown> | undefined;
|
|
175
|
+
} | undefined;
|
|
176
|
+
assignTo?: {
|
|
177
|
+
users?: string[] | undefined;
|
|
178
|
+
groups?: string[] | undefined;
|
|
179
|
+
} | undefined;
|
|
180
|
+
}, {
|
|
181
|
+
type: string;
|
|
182
|
+
name: string;
|
|
183
|
+
description?: string | undefined;
|
|
184
|
+
validUntil?: string | undefined;
|
|
185
|
+
context?: {
|
|
186
|
+
ui?: Record<string, unknown> | undefined;
|
|
187
|
+
data?: Record<string, unknown> | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
assignTo?: {
|
|
190
|
+
users?: string[] | undefined;
|
|
191
|
+
groups?: string[] | undefined;
|
|
192
|
+
} | undefined;
|
|
193
|
+
}>;
|
|
194
|
+
type CreateSendToHumanToolOptions<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = {
|
|
195
|
+
actions: A;
|
|
196
|
+
defaultType?: string;
|
|
197
|
+
description?: string;
|
|
198
|
+
toolName?: string;
|
|
199
|
+
};
|
|
200
|
+
type CreateSendToHumanToolDurableOptions<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = CreateSendToHumanToolOptions<A> & RobotRockAiContext & {
|
|
201
|
+
mode: "trigger" | "workflow";
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* AI SDK tool that blocks until a human handles a RobotRock task with developer-defined actions.
|
|
205
|
+
*
|
|
206
|
+
* - `createSendToHumanTool(robotrock, options)` — polling (default).
|
|
207
|
+
* - `createSendToHumanTool({ mode: "trigger", actions: [...], app?: "my-agent" })` — Trigger.dev wait tokens.
|
|
208
|
+
* - `createSendToHumanTool({ mode: "workflow", actions: [...], app?: "my-agent" })` — Vercel Workflow webhooks.
|
|
209
|
+
*/
|
|
210
|
+
declare function createSendToHumanTool<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]>(clientOrOptions: RobotRock | CreateSendToHumanToolDurableOptions<A>, maybeOptions?: CreateSendToHumanToolOptions<A>): ai.Tool<{
|
|
211
|
+
type: string;
|
|
212
|
+
name: string;
|
|
213
|
+
description?: string | undefined;
|
|
214
|
+
validUntil?: string | undefined;
|
|
215
|
+
context?: {
|
|
216
|
+
ui?: Record<string, unknown> | undefined;
|
|
217
|
+
data?: Record<string, unknown> | undefined;
|
|
218
|
+
} | undefined;
|
|
219
|
+
assignTo?: {
|
|
220
|
+
users?: string[] | undefined;
|
|
221
|
+
groups?: string[] | undefined;
|
|
222
|
+
} | undefined;
|
|
223
|
+
}, HumanToolResult>;
|
|
224
|
+
|
|
225
|
+
type CreateRobotRockAiToolsOptions = {
|
|
226
|
+
/** @default "polling" when `client` is passed; `"trigger"` or `"workflow"` for durable waits. */
|
|
227
|
+
mode?: "polling" | "trigger" | "workflow";
|
|
228
|
+
client?: RobotRock;
|
|
229
|
+
app?: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Build AI SDK tools for a given RobotRock execution mode.
|
|
233
|
+
*
|
|
234
|
+
* @example Polling (Next.js route, scripts)
|
|
235
|
+
* ```ts
|
|
236
|
+
* const tools = createRobotRockAiTools({ client: robotrock });
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @example Trigger.dev worker
|
|
240
|
+
* ```ts
|
|
241
|
+
* const tools = createRobotRockAiTools({ mode: "trigger", app: "my-agent" });
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @example Vercel Workflow + DurableAgent
|
|
245
|
+
* ```ts
|
|
246
|
+
* const tools = createRobotRockAiTools({ mode: "workflow", app: "my-agent" });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
declare function createRobotRockAiTools(options: CreateRobotRockAiToolsOptions): {
|
|
250
|
+
context: RobotRockAiContext;
|
|
251
|
+
approveByHuman: (toolOptions?: ApproveByHumanToolOptions) => ai.Tool<{
|
|
252
|
+
description: string;
|
|
253
|
+
name: string;
|
|
254
|
+
type?: string | undefined;
|
|
255
|
+
contextSummary?: string | undefined;
|
|
256
|
+
}, HumanToolResult>;
|
|
257
|
+
sendToHuman: <A extends readonly SendToHumanActionInput[]>(toolOptions: CreateSendToHumanToolOptions<A>) => ai.Tool<{
|
|
258
|
+
type: string;
|
|
259
|
+
name: string;
|
|
260
|
+
description?: string | undefined;
|
|
261
|
+
validUntil?: string | undefined;
|
|
262
|
+
context?: {
|
|
263
|
+
ui?: Record<string, unknown> | undefined;
|
|
264
|
+
data?: Record<string, unknown> | undefined;
|
|
265
|
+
} | undefined;
|
|
266
|
+
assignTo?: {
|
|
267
|
+
users?: string[] | undefined;
|
|
268
|
+
groups?: string[] | undefined;
|
|
269
|
+
} | undefined;
|
|
270
|
+
}, HumanToolResult>;
|
|
271
|
+
};
|
|
272
|
+
/** Shorthand for `{ mode: "trigger", app }`. */
|
|
273
|
+
declare function createRobotRockAiTriggerContext(options?: Omit<RobotRockAiTriggerContext, "mode">): RobotRockAiContext;
|
|
274
|
+
/** Shorthand for `{ mode: "workflow", app }`. */
|
|
275
|
+
declare function createRobotRockAiWorkflowContext(options?: Omit<RobotRockAiWorkflowContext, "mode">): RobotRockAiContext;
|
|
276
|
+
|
|
277
|
+
type RobotRockToolApprovalDecision = "user-approval" | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* AI SDK 7+: pass the return value to `toolApproval` on `generateText`, `streamText`, or `ToolLoopAgent`.
|
|
280
|
+
* Returns `'user-approval'` for configured tools so execution pauses until a human responds via RobotRock.
|
|
281
|
+
*/
|
|
282
|
+
declare function createRobotRockToolApproval(config: RobotRockToolApprovalConfig): (options: {
|
|
283
|
+
toolCall: RobotRockToolCallInfo;
|
|
284
|
+
}) => Promise<RobotRockToolApprovalDecision>;
|
|
285
|
+
/**
|
|
286
|
+
* AI SDK 5–6: use as `needsApproval` on tool definitions (or via {@link applyRobotRockToolApprovalToTools}).
|
|
287
|
+
*/
|
|
288
|
+
declare function createRobotRockNeedsApproval(config: RobotRockToolApprovalConfig): (_input: unknown, options: {
|
|
289
|
+
toolCallId: string;
|
|
290
|
+
messages?: unknown[];
|
|
291
|
+
}) => Promise<boolean>;
|
|
292
|
+
/**
|
|
293
|
+
* AI SDK 5–6: merge `needsApproval` into each matching tool in a tools object.
|
|
294
|
+
*/
|
|
295
|
+
declare function applyRobotRockToolApprovalToTools<T extends Record<string, object>>(tools: T, config: RobotRockToolApprovalConfig): T;
|
|
296
|
+
declare function collectApprovalRequests(source: unknown): ToolApprovalRequestPart[];
|
|
297
|
+
/**
|
|
298
|
+
* Create RobotRock tasks for pending AI SDK tool approvals and return `tool-approval-response` parts.
|
|
299
|
+
*/
|
|
300
|
+
declare function resolveToolApprovalsViaRobotRock(clientOrContext: RobotRock | RobotRockAiContext, source: unknown, options?: ResolveToolApprovalsOptions): Promise<{
|
|
301
|
+
responses: ToolApprovalResponse[];
|
|
302
|
+
messages: unknown[];
|
|
303
|
+
}>;
|
|
304
|
+
/**
|
|
305
|
+
* Run `generate` in a loop until manual tool approvals are resolved via RobotRock or `maxRounds` is reached.
|
|
306
|
+
*/
|
|
307
|
+
declare function runWithRobotRockApprovals<T>(options: RunWithRobotRockApprovalsOptions<T>): Promise<T>;
|
|
308
|
+
|
|
309
|
+
export { APPROVE_BY_HUMAN_ACTIONS as A, type ResolveToolApprovalsOptions as B, type CreateSendToHumanToolOptions as C, type RobotRockToolApprovalConfig as D, type RunWithRobotRockApprovalsOptions as E, type FormatToolApprovalTaskOptions as F, type HumanToolResult as H, type RobotRockToolCallInfo as R, 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, approveByHumanForAi as g, sendToHumanForAi as h, type RobotRockAiContext as i, type RobotRockAiMode as j, type RobotRockAiPollingContext as k, type RobotRockAiTriggerContext as l, type RobotRockAiWorkflowContext as m, normalizeRobotRockAiContext as n, createRobotRockAiTools as o, createRobotRockAiTriggerContext as p, createRobotRockAiWorkflowContext as q, type CreateRobotRockAiToolsOptions as r, sendToHumanToolInputSchema as s, applyRobotRockToolApprovalToTools as t, collectApprovalRequests as u, createRobotRockNeedsApproval as v, createRobotRockToolApproval as w, resolveToolApprovalsViaRobotRock as x, runWithRobotRockApprovals as y, type RobotRockToolApprovalDecision as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "robotrock",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Human-in-the-loop approval workflows for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,6 +14,22 @@
|
|
|
14
14
|
"./trigger": {
|
|
15
15
|
"types": "./dist/trigger/index.d.ts",
|
|
16
16
|
"import": "./dist/trigger/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./ai": {
|
|
19
|
+
"types": "./dist/ai/index.d.ts",
|
|
20
|
+
"import": "./dist/ai/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./ai/trigger": {
|
|
23
|
+
"types": "./dist/ai/trigger.d.ts",
|
|
24
|
+
"import": "./dist/ai/trigger.js"
|
|
25
|
+
},
|
|
26
|
+
"./workflow": {
|
|
27
|
+
"types": "./dist/workflow/index.d.ts",
|
|
28
|
+
"import": "./dist/workflow/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./ai/workflow": {
|
|
31
|
+
"types": "./dist/ai/workflow.d.ts",
|
|
32
|
+
"import": "./dist/ai/workflow.js"
|
|
17
33
|
}
|
|
18
34
|
},
|
|
19
35
|
"files": [
|
|
@@ -24,7 +40,8 @@
|
|
|
24
40
|
"build": "tsup",
|
|
25
41
|
"dev": "tsup --watch",
|
|
26
42
|
"typecheck": "tsc --noEmit",
|
|
27
|
-
"
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"lint": "eslint .",
|
|
28
45
|
"clean": "rm -rf dist"
|
|
29
46
|
},
|
|
30
47
|
"keywords": [
|
|
@@ -32,30 +49,43 @@
|
|
|
32
49
|
"human-in-the-loop",
|
|
33
50
|
"approval",
|
|
34
51
|
"workflow",
|
|
35
|
-
"trigger.dev"
|
|
52
|
+
"trigger.dev",
|
|
53
|
+
"vercel-ai-sdk",
|
|
54
|
+
"ai-sdk"
|
|
36
55
|
],
|
|
37
56
|
"license": "MIT",
|
|
38
57
|
"repository": {
|
|
39
58
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/robotrock/robotrock"
|
|
59
|
+
"url": "git+https://github.com/robotrock/robotrock.git"
|
|
41
60
|
},
|
|
42
61
|
"dependencies": {
|
|
43
62
|
"zod": "^3.25.0"
|
|
44
63
|
},
|
|
45
64
|
"devDependencies": {
|
|
46
|
-
"@robotrock/core": "workspace:*",
|
|
47
65
|
"@robotrock/config": "workspace:*",
|
|
48
|
-
"@
|
|
66
|
+
"@robotrock/core": "workspace:*",
|
|
49
67
|
"@trigger.dev/sdk": "4.4.6",
|
|
68
|
+
"@types/node": "^25.0.3",
|
|
69
|
+
"ai": "^6.0.196",
|
|
70
|
+
"eslint": "^9.39.2",
|
|
50
71
|
"tsup": "^8.0.0",
|
|
51
|
-
"typescript": "^5.9.3"
|
|
72
|
+
"typescript": "^5.9.3",
|
|
73
|
+
"workflow": "^4.3.1"
|
|
52
74
|
},
|
|
53
75
|
"peerDependencies": {
|
|
54
|
-
"@trigger.dev/sdk": "^3.0.0 || ^4.0.0"
|
|
76
|
+
"@trigger.dev/sdk": "^3.0.0 || ^4.0.0",
|
|
77
|
+
"ai": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
78
|
+
"workflow": "^4.0.0"
|
|
55
79
|
},
|
|
56
80
|
"peerDependenciesMeta": {
|
|
57
81
|
"@trigger.dev/sdk": {
|
|
58
82
|
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"ai": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"workflow": {
|
|
88
|
+
"optional": true
|
|
59
89
|
}
|
|
60
90
|
}
|
|
61
91
|
}
|
package/dist/chunk-TUQXDKV6.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
// ../core/src/schemas/task.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var safeUrlSchema = z.string().refine((url) => url.startsWith("http://") || url.startsWith("https://"), {
|
|
4
|
-
message: "URL must start with http:// or https://"
|
|
5
|
-
});
|
|
6
|
-
var jsonSchema7Schema = z.custom(
|
|
7
|
-
(val) => typeof val === "object" && val !== null,
|
|
8
|
-
{ message: "Must be a valid JSON Schema object" }
|
|
9
|
-
);
|
|
10
|
-
var uiSchemaSchema = z.custom((val) => typeof val === "object" && val !== null, {
|
|
11
|
-
message: "Must be a valid UiSchema object"
|
|
12
|
-
});
|
|
13
|
-
var webhookHandlerSchema = z.object({
|
|
14
|
-
type: z.literal("webhook"),
|
|
15
|
-
url: safeUrlSchema,
|
|
16
|
-
headers: z.record(z.string())
|
|
17
|
-
});
|
|
18
|
-
var triggerHandlerSchema = webhookHandlerSchema.extend({
|
|
19
|
-
type: z.literal("trigger"),
|
|
20
|
-
tokenId: z.string().min(1)
|
|
21
|
-
});
|
|
22
|
-
var handlerSchema = z.discriminatedUnion("type", [webhookHandlerSchema, triggerHandlerSchema]);
|
|
23
|
-
var taskActionSchema = z.object({
|
|
24
|
-
id: z.string().min(1),
|
|
25
|
-
title: z.string().min(1),
|
|
26
|
-
description: z.string().optional(),
|
|
27
|
-
schema: jsonSchema7Schema.optional(),
|
|
28
|
-
ui: uiSchemaSchema.optional(),
|
|
29
|
-
data: z.record(z.unknown()).optional(),
|
|
30
|
-
// Optional handlers for this action - if present, must have at least 1
|
|
31
|
-
handlers: z.array(handlerSchema).min(1).optional()
|
|
32
|
-
});
|
|
33
|
-
var uiFieldSchemaSchema = z.object({
|
|
34
|
-
"ui:widget": z.string().optional(),
|
|
35
|
-
"ui:title": z.string().optional(),
|
|
36
|
-
"ui:description": z.string().optional(),
|
|
37
|
-
"ui:options": z.record(z.unknown()).optional(),
|
|
38
|
-
items: z.lazy(() => z.record(uiFieldSchemaSchema)).optional()
|
|
39
|
-
}).passthrough();
|
|
40
|
-
var contextUiSchema = z.record(uiFieldSchemaSchema).optional();
|
|
41
|
-
var contextDataSchema = z.object({
|
|
42
|
-
data: z.record(z.unknown()),
|
|
43
|
-
ui: contextUiSchema
|
|
44
|
-
}).optional();
|
|
45
|
-
var taskContextSchema = z.object({
|
|
46
|
-
/** Source application id; omitted tasks are grouped in the default inbox. */
|
|
47
|
-
app: z.string().min(1).optional(),
|
|
48
|
-
type: z.string().min(1),
|
|
49
|
-
name: z.string().min(1),
|
|
50
|
-
description: z.string().optional(),
|
|
51
|
-
validUntil: z.string().optional(),
|
|
52
|
-
context: contextDataSchema,
|
|
53
|
-
version: z.literal(2).optional(),
|
|
54
|
-
actions: z.array(taskActionSchema).min(1, "At least one action is required")
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// src/client.ts
|
|
58
|
-
var RobotRockError = class extends Error {
|
|
59
|
-
constructor(message, statusCode, response) {
|
|
60
|
-
super(message);
|
|
61
|
-
this.statusCode = statusCode;
|
|
62
|
-
this.response = response;
|
|
63
|
-
this.name = "RobotRockError";
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
var RobotRock = class {
|
|
67
|
-
apiKey;
|
|
68
|
-
baseUrl;
|
|
69
|
-
constructor(config) {
|
|
70
|
-
if (!config.apiKey) {
|
|
71
|
-
throw new Error("API key is required");
|
|
72
|
-
}
|
|
73
|
-
this.apiKey = config.apiKey;
|
|
74
|
-
const rawBase = config.baseUrl ?? "https://api.robotrock.com/v1";
|
|
75
|
-
this.baseUrl = rawBase.replace(/\/+$/, "");
|
|
76
|
-
}
|
|
77
|
-
async createTask(task, options) {
|
|
78
|
-
const validation = taskContextSchema.safeParse(task);
|
|
79
|
-
if (!validation.success) {
|
|
80
|
-
throw new RobotRockError(
|
|
81
|
-
`Invalid task: ${validation.error.errors[0]?.message}`,
|
|
82
|
-
400,
|
|
83
|
-
validation.error.errors
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
const headers = {
|
|
87
|
-
"Content-Type": "application/json",
|
|
88
|
-
"X-Api-Key": this.apiKey
|
|
89
|
-
};
|
|
90
|
-
if (options?.idempotencyKey) {
|
|
91
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
92
|
-
}
|
|
93
|
-
const response = await fetch(`${this.baseUrl}/`, {
|
|
94
|
-
method: "POST",
|
|
95
|
-
headers,
|
|
96
|
-
body: JSON.stringify(validation.data)
|
|
97
|
-
});
|
|
98
|
-
const data = await response.json();
|
|
99
|
-
if (!response.ok) {
|
|
100
|
-
throw new RobotRockError(
|
|
101
|
-
data.message ?? "Failed to create task",
|
|
102
|
-
response.status,
|
|
103
|
-
data
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
return data;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get a task by Redis stream entry id (returned as `task.streamId` from {@link createTask}).
|
|
110
|
-
*/
|
|
111
|
-
async getTask(streamEntryId) {
|
|
112
|
-
const response = await fetch(`${this.baseUrl}/tasks/${streamEntryId}`, {
|
|
113
|
-
method: "GET",
|
|
114
|
-
headers: {
|
|
115
|
-
"X-Api-Key": this.apiKey
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
if (response.status === 404) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
const data = await response.json();
|
|
122
|
-
if (!response.ok) {
|
|
123
|
-
throw new RobotRockError(
|
|
124
|
-
data.message ?? "Failed to get task",
|
|
125
|
-
response.status,
|
|
126
|
-
data
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
return data;
|
|
130
|
-
}
|
|
131
|
-
async cancelTask(taskId) {
|
|
132
|
-
const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {
|
|
133
|
-
method: "POST",
|
|
134
|
-
headers: {
|
|
135
|
-
"X-Api-Key": this.apiKey
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
const data = await response.json();
|
|
140
|
-
throw new RobotRockError(
|
|
141
|
-
data.message ?? "Failed to cancel task",
|
|
142
|
-
response.status,
|
|
143
|
-
data
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
function createClient(config) {
|
|
149
|
-
return new RobotRock(config);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// src/env.ts
|
|
153
|
-
var DEFAULT_BASE_URL = "https://api.robotrock.com/v1";
|
|
154
|
-
function resolveRobotRockConfig(overrides) {
|
|
155
|
-
const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;
|
|
156
|
-
if (!apiKey) {
|
|
157
|
-
throw new Error(
|
|
158
|
-
"RobotRock API key is required. Set ROBOTROCK_API_KEY or pass apiKey / client to askHuman."
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
const baseUrl = overrides?.baseUrl ?? process.env.ROBOTROCK_BASE_URL ?? process.env.ROBOTROCK_API_URL ?? DEFAULT_BASE_URL;
|
|
162
|
-
return { apiKey, baseUrl };
|
|
163
|
-
}
|
|
164
|
-
function resolveRobotRockClient(client, configOverrides) {
|
|
165
|
-
if (client) {
|
|
166
|
-
return client;
|
|
167
|
-
}
|
|
168
|
-
return createClient(resolveRobotRockConfig(configOverrides));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// src/approval-result.ts
|
|
172
|
-
var AskHumanTimeoutError = class extends Error {
|
|
173
|
-
constructor(message) {
|
|
174
|
-
super(message);
|
|
175
|
-
this.name = "AskHumanTimeoutError";
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var AskHumanExpiredError = class extends Error {
|
|
179
|
-
constructor(message) {
|
|
180
|
-
super(message);
|
|
181
|
-
this.name = "AskHumanExpiredError";
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
function toDiscriminatedApprovalResult(actions, task, streamEntryId) {
|
|
185
|
-
void actions;
|
|
186
|
-
if (!task.handled) {
|
|
187
|
-
throw new Error("Task has no handled result");
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
actionId: task.handled.action.id,
|
|
191
|
-
data: task.handled.action.data,
|
|
192
|
-
handledBy: task.handled.handledBy,
|
|
193
|
-
handledAt: new Date(task.handledAt ?? Date.now()),
|
|
194
|
-
taskId: task.id || streamEntryId
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export {
|
|
199
|
-
taskContextSchema,
|
|
200
|
-
RobotRockError,
|
|
201
|
-
RobotRock,
|
|
202
|
-
createClient,
|
|
203
|
-
resolveRobotRockConfig,
|
|
204
|
-
resolveRobotRockClient,
|
|
205
|
-
AskHumanTimeoutError,
|
|
206
|
-
AskHumanExpiredError,
|
|
207
|
-
toDiscriminatedApprovalResult
|
|
208
|
-
};
|
|
209
|
-
//# sourceMappingURL=chunk-TUQXDKV6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../core/src/schemas/task.ts","../src/client.ts","../src/env.ts","../src/approval-result.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { JSONSchema7 } from \"./json-schema.js\";\n\n/**\n * Extended JSONSchema7 type that includes RJSF extensions like enumNames\n */\nexport type ExtendedJSONSchema7 = JSONSchema7 & {\n enumNames?: string[];\n [key: string]: unknown;\n};\n\n/**\n * UI Schema for RJSF form customization\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\n// Helper schemas\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\n// JSONSchema7 validation\nconst jsonSchema7Schema = z.custom<ExtendedJSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n { message: \"Must be a valid JSON Schema object\" }\n);\n\n// UiSchema validation\nconst uiSchemaSchema = z.custom<UiSchema>((val) => typeof val === \"object\" && val !== null, {\n message: \"Must be a valid UiSchema object\",\n});\n\n// Handler schemas (per-action handlers for webhooks, triggers, etc.)\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\n// Action schema with JSONSchema-based feedback and optional handlers\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 // Optional handlers for this action - if present, must have at least 1\n handlers: z.array(handlerSchema).min(1).optional(),\n});\n\n// UI Field Schema\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\n// Context UI Schema\nconst contextUiSchema = z.record(uiFieldSchemaSchema).optional();\n\n// Context data schema\nconst contextDataSchema = z\n .object({\n data: z.record(z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\n// Main TaskContext schema\nexport const taskContextSchema = z.object({\n /** Source application id; omitted tasks are grouped in the default inbox. */\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// Type exports\nexport type TaskContextInput = z.input<typeof taskContextSchema>;\nexport type TaskContextOutput = z.output<typeof taskContextSchema>;\nexport type TaskContext = TaskContextOutput;\nexport type SafeUrl = z.infer<typeof safeUrlSchema>;\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>;\nexport type ContextData = z.infer<typeof contextDataSchema>;\nexport type ContextUiSchema = z.infer<typeof contextUiSchema>;\nexport type UiFieldSchema = z.infer<typeof uiFieldSchemaSchema>;\n","import { type TaskContextInput, taskContextSchema } from \"@robotrock/core\";\nimport type { Task, TaskResponse } from \"@robotrock/core\";\n\nexport interface RobotRockConfig {\n /** Your RobotRock API key */\n apiKey: string;\n /**\n * Base URL for the RobotRock API\n * @default \"https://api.robotrock.com/v1\"\n */\n baseUrl?: string;\n}\n\nexport interface CreateTaskOptions {\n /** Optional idempotency key to prevent duplicate tasks */\n idempotencyKey?: string;\n}\n\nexport class RobotRockError extends Error {\n constructor(\n message: string,\n public readonly statusCode: number,\n public readonly response?: unknown\n ) {\n super(message);\n this.name = \"RobotRockError\";\n }\n}\n\n/**\n * RobotRock API client for creating and querying human-in-the-loop tasks.\n */\nexport class RobotRock {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n constructor(config: RobotRockConfig) {\n if (!config.apiKey) {\n throw new Error(\"API key is required\");\n }\n this.apiKey = config.apiKey;\n const rawBase = config.baseUrl ?? \"https://api.robotrock.com/v1\";\n this.baseUrl = rawBase.replace(/\\/+$/, \"\");\n }\n\n async createTask(\n task: TaskContextInput | Readonly<TaskContextInput>,\n options?: CreateTaskOptions\n ): Promise<TaskResponse> {\n const validation = taskContextSchema.safeParse(task);\n if (!validation.success) {\n throw new RobotRockError(\n `Invalid task: ${validation.error.errors[0]?.message}`,\n 400,\n validation.error.errors\n );\n }\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"X-Api-Key\": this.apiKey,\n };\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n\n const response = await fetch(`${this.baseUrl}/`, {\n method: \"POST\",\n headers,\n body: JSON.stringify(validation.data),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new RobotRockError(\n data.message ?? \"Failed to create task\",\n response.status,\n data\n );\n }\n\n return data as TaskResponse;\n }\n\n /**\n * Get a task by Redis stream entry id (returned as `task.streamId` from {@link createTask}).\n */\n async getTask(streamEntryId: string): Promise<Task | null> {\n const response = await fetch(`${this.baseUrl}/tasks/${streamEntryId}`, {\n method: \"GET\",\n headers: {\n \"X-Api-Key\": this.apiKey,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new RobotRockError(\n data.message ?? \"Failed to get task\",\n response.status,\n data\n );\n }\n\n return data as Task;\n }\n\n async cancelTask(taskId: string): Promise<void> {\n const response = await fetch(`${this.baseUrl}/tasks/${taskId}/cancel`, {\n method: \"POST\",\n headers: {\n \"X-Api-Key\": this.apiKey,\n },\n });\n\n if (!response.ok) {\n const data = await response.json();\n throw new RobotRockError(\n data.message ?? \"Failed to cancel task\",\n response.status,\n data\n );\n }\n }\n}\n\nexport function createClient(config: RobotRockConfig): RobotRock {\n return new RobotRock(config);\n}\n","import { createClient, type RobotRock, type RobotRockConfig } from \"./client.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.robotrock.com/v1\";\n\n/**\n * Read RobotRock client config from environment variables.\n *\n * - `ROBOTROCK_API_KEY` (required when not passed explicitly)\n * - `ROBOTROCK_BASE_URL` or `ROBOTROCK_API_URL` (optional)\n */\nexport function resolveRobotRockConfig(\n overrides?: Partial<RobotRockConfig>\n): RobotRockConfig {\n const apiKey = overrides?.apiKey ?? process.env.ROBOTROCK_API_KEY;\n if (!apiKey) {\n throw new Error(\n \"RobotRock API key is required. Set ROBOTROCK_API_KEY or pass apiKey / client to askHuman.\"\n );\n }\n\n const baseUrl =\n overrides?.baseUrl ??\n process.env.ROBOTROCK_BASE_URL ??\n process.env.ROBOTROCK_API_URL ??\n DEFAULT_BASE_URL;\n\n return { apiKey, baseUrl };\n}\n\n/** Use an explicit client or create one from env / optional config overrides. */\nexport function resolveRobotRockClient(\n client?: RobotRock,\n configOverrides?: Partial<RobotRockConfig>\n): RobotRock {\n if (client) {\n return client;\n }\n return createClient(resolveRobotRockConfig(configOverrides));\n}\n","import type { DiscriminatedApprovalResult, Task, TaskAction } from \"@robotrock/core\";\n\nexport class AskHumanTimeoutError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"AskHumanTimeoutError\";\n }\n}\n\nexport class AskHumanExpiredError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"AskHumanExpiredError\";\n }\n}\n\n/**\n * Map a handled API task to a discriminated approval result.\n * Runtime validation is minimal; TypeScript narrows via `task.actions` at the call site.\n */\nexport function toDiscriminatedApprovalResult<A extends readonly TaskAction[]>(\n actions: A,\n task: Task,\n streamEntryId: string\n): DiscriminatedApprovalResult<A> {\n void actions;\n\n if (!task.handled) {\n throw new Error(\"Task has no handled result\");\n }\n\n return {\n actionId: task.handled.action.id,\n data: task.handled.action.data,\n handledBy: task.handled.handledBy,\n handledAt: new Date(task.handledAt ?? Date.now()),\n taskId: task.id || streamEntryId,\n } as DiscriminatedApprovalResult<A>;\n}\n"],"mappings":";A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,QAAQ,KAAK,MAAM;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { TaskContextInput, TaskResponse, Task } from '@robotrock/core';
|
|
2
|
-
|
|
3
|
-
interface RobotRockConfig {
|
|
4
|
-
/** Your RobotRock API key */
|
|
5
|
-
apiKey: string;
|
|
6
|
-
/**
|
|
7
|
-
* Base URL for the RobotRock API
|
|
8
|
-
* @default "https://api.robotrock.com/v1"
|
|
9
|
-
*/
|
|
10
|
-
baseUrl?: string;
|
|
11
|
-
}
|
|
12
|
-
interface CreateTaskOptions {
|
|
13
|
-
/** Optional idempotency key to prevent duplicate tasks */
|
|
14
|
-
idempotencyKey?: string;
|
|
15
|
-
}
|
|
16
|
-
declare class RobotRockError extends Error {
|
|
17
|
-
readonly statusCode: number;
|
|
18
|
-
readonly response?: unknown | undefined;
|
|
19
|
-
constructor(message: string, statusCode: number, response?: unknown | undefined);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* RobotRock API client for creating and querying human-in-the-loop tasks.
|
|
23
|
-
*/
|
|
24
|
-
declare class RobotRock {
|
|
25
|
-
private readonly apiKey;
|
|
26
|
-
private readonly baseUrl;
|
|
27
|
-
constructor(config: RobotRockConfig);
|
|
28
|
-
createTask(task: TaskContextInput | Readonly<TaskContextInput>, options?: CreateTaskOptions): Promise<TaskResponse>;
|
|
29
|
-
/**
|
|
30
|
-
* Get a task by Redis stream entry id (returned as `task.streamId` from {@link createTask}).
|
|
31
|
-
*/
|
|
32
|
-
getTask(streamEntryId: string): Promise<Task | null>;
|
|
33
|
-
cancelTask(taskId: string): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
declare function createClient(config: RobotRockConfig): RobotRock;
|
|
36
|
-
|
|
37
|
-
export { type CreateTaskOptions as C, type RobotRockConfig as R, RobotRock as a, RobotRockError as b, createClient as c };
|