robotrock 0.8.1 → 0.8.3
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/dist/ai/index.js +455 -35
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/trigger.js +455 -35
- package/dist/ai/trigger.js.map +1 -1
- package/dist/ai/workflow.js +455 -35
- package/dist/ai/workflow.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +384 -38
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +5 -1
- package/dist/schemas/index.js +373 -27
- package/dist/schemas/index.js.map +1 -1
- package/dist/trigger/index.js +352 -7
- package/dist/trigger/index.js.map +1 -1
- package/dist/workflow/index.js +352 -7
- package/dist/workflow/index.js.map +1 -1
- package/package.json +1 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RobotRock, b as RobotRockConfig } from './client-D-XEBOWd.js';
|
|
2
2
|
export { c as RobotRockError, d as RobotRockPollingClientConfig, e as RobotRockPollingOptions, f as RobotRockWebhookClientConfig, g as RobotRockWebhookConfig, S as SendToHumanActionInput, a as SendToHumanInput, h as SendToHumanResult, i as SendToHumanValidUntil, j as SendUpdateInput, k as attachWebhookToActions, l as createClient } from './client-D-XEBOWd.js';
|
|
3
3
|
import { Task, DiscriminatedApprovalResult } from './schemas/index.js';
|
|
4
|
-
export { AgentCost, AgentCostTokens, AgentTelemetry, AgentTelemetryInput, ApprovalResult, AssignToInput, CreateTaskBody, CreateTaskBodyInput, DEFAULT_TASK_PRIORITY, DEFAULT_THREAD_UPDATE_STATUS, Handler, InferActionData, LOWEST_TASK_PRIORITY, TASK_PRIORITY_RANK, TaskAction, TaskContext, TaskContextInput, TaskPriority, TaskResponse, TaskResult, TaskStatus, ThreadUpdate, ThreadUpdateBody, ThreadUpdateBodyInput, ThreadUpdateInput, ThreadUpdateResponse, ThreadUpdateSource, ThreadUpdateStatus, TriggerHandler, TupleElementIndices, WebhookHandler, agentCostSchema, agentCostTokensSchema, agentTelemetrySchema, assignToSchema, createTaskBodySchema, taskContextSchema, taskPriorities, taskPrioritySchema, threadUpdateBodySchema, threadUpdateInputSchema, threadUpdateStatusSchema, threadUpdateStatuses } from './schemas/index.js';
|
|
4
|
+
export { AgentCost, AgentCostTokens, AgentTelemetry, AgentTelemetryInput, AgentToolCalls, ApprovalResult, AssignToInput, CreateTaskBody, CreateTaskBodyInput, DEFAULT_TASK_PRIORITY, DEFAULT_THREAD_UPDATE_STATUS, Handler, InferActionData, LOWEST_TASK_PRIORITY, TASK_PRIORITY_RANK, TaskAction, TaskContext, TaskContextInput, TaskPriority, TaskResponse, TaskResult, TaskStatus, ThreadUpdate, ThreadUpdateBody, ThreadUpdateBodyInput, ThreadUpdateInput, ThreadUpdateResponse, ThreadUpdateSource, ThreadUpdateStatus, TriggerHandler, TupleElementIndices, WebhookHandler, agentCostSchema, agentCostTokensSchema, agentTelemetrySchema, agentToolCallsSchema, assignToSchema, createTaskBodySchema, taskContextSchema, taskPriorities, taskPrioritySchema, threadUpdateBodySchema, threadUpdateInputSchema, threadUpdateStatusSchema, threadUpdateStatuses } from './schemas/index.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export { R as RobotRockHandlerWebhookPayload } from './handler-webhook-BqEi6Bk-.js';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,187 @@
|
|
|
1
1
|
// src/schemas/index.ts
|
|
2
|
+
import { z as z2 } from "zod";
|
|
3
|
+
|
|
4
|
+
// ../core/src/utils/safe-url.ts
|
|
5
|
+
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
6
|
+
"localhost",
|
|
7
|
+
"metadata.google.internal",
|
|
8
|
+
"metadata.goog"
|
|
9
|
+
]);
|
|
10
|
+
function normalizeHostname(hostname) {
|
|
11
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
12
|
+
}
|
|
13
|
+
function isBlockedIpv4(host) {
|
|
14
|
+
const match = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
|
|
15
|
+
if (!match) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const octets = match.slice(1, 5).map((part) => Number(part));
|
|
19
|
+
if (octets.some((octet) => Number.isNaN(octet) || octet < 0 || octet > 255)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const [a, b, _c, _d] = octets;
|
|
23
|
+
if (a === void 0 || b === void 0) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (a === 127 || a === 0) return true;
|
|
27
|
+
if (a === 10) return true;
|
|
28
|
+
if (a === 169 && b === 254) return true;
|
|
29
|
+
if (a === 192 && b === 168) return true;
|
|
30
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
31
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
function ipv4FromNumericHost(host) {
|
|
35
|
+
if (/^\d+$/.test(host)) {
|
|
36
|
+
const num = Number(host);
|
|
37
|
+
if (!Number.isFinite(num) || num < 0 || num > 4294967295) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const a = num >>> 24 & 255;
|
|
41
|
+
const b = num >>> 16 & 255;
|
|
42
|
+
const c = num >>> 8 & 255;
|
|
43
|
+
const d = num & 255;
|
|
44
|
+
return `${a}.${b}.${c}.${d}`;
|
|
45
|
+
}
|
|
46
|
+
const hexMatch = /^0x([0-9a-f]{1,8})$/i.exec(host);
|
|
47
|
+
if (hexMatch) {
|
|
48
|
+
const num = Number.parseInt(hexMatch[1], 16);
|
|
49
|
+
if (!Number.isFinite(num) || num < 0 || num > 4294967295) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const a = num >>> 24 & 255;
|
|
53
|
+
const b = num >>> 16 & 255;
|
|
54
|
+
const c = num >>> 8 & 255;
|
|
55
|
+
const d = num & 255;
|
|
56
|
+
return `${a}.${b}.${c}.${d}`;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function isBlockedIpv4Mapped(host) {
|
|
61
|
+
const mappedDotted = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(host);
|
|
62
|
+
if (mappedDotted) {
|
|
63
|
+
return isBlockedIpv4(mappedDotted[1]);
|
|
64
|
+
}
|
|
65
|
+
const mappedHex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(host);
|
|
66
|
+
if (mappedHex) {
|
|
67
|
+
const high = Number.parseInt(mappedHex[1], 16);
|
|
68
|
+
const low = Number.parseInt(mappedHex[2], 16);
|
|
69
|
+
if (Number.isFinite(high) && Number.isFinite(low)) {
|
|
70
|
+
const a = high >> 8 & 255;
|
|
71
|
+
const b = high & 255;
|
|
72
|
+
const c = low >> 8 & 255;
|
|
73
|
+
const d = low & 255;
|
|
74
|
+
return isBlockedIpv4(`${a}.${b}.${c}.${d}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
function isBlockedIpv6(host) {
|
|
80
|
+
if (host === "::1" || host === "0:0:0:0:0:0:0:1") {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (host.startsWith("fc") || host.startsWith("fd")) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (host.startsWith("fe80:")) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
if (isBlockedIpv4Mapped(host)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
function isBlockedHostname(hostname) {
|
|
95
|
+
const host = normalizeHostname(hostname);
|
|
96
|
+
if (!host) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (BLOCKED_HOSTNAMES.has(host)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (host.endsWith(".localhost") || host.endsWith(".local")) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
const numericIpv4 = ipv4FromNumericHost(host);
|
|
106
|
+
if (numericIpv4 && isBlockedIpv4(numericIpv4)) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
return isBlockedIpv4(host) || isBlockedIpv6(host);
|
|
110
|
+
}
|
|
111
|
+
function isPublicHttpUrl(urlString) {
|
|
112
|
+
let url;
|
|
113
|
+
try {
|
|
114
|
+
url = new URL(urlString);
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (url.username || url.password) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return !isBlockedHostname(url.hostname);
|
|
125
|
+
}
|
|
126
|
+
var PUBLIC_HTTP_URL_ERROR = "URL must be a public http:// or https:// address";
|
|
127
|
+
|
|
128
|
+
// ../core/src/schemas/task.ts
|
|
2
129
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
130
|
+
|
|
131
|
+
// ../core/src/schemas/context-urls.ts
|
|
132
|
+
function resolveLinkUrl(value) {
|
|
133
|
+
return value.startsWith("http://") || value.startsWith("https://") ? value : `https://${value}`;
|
|
134
|
+
}
|
|
135
|
+
function widgetType(ui, field) {
|
|
136
|
+
const fieldUi = ui?.[field];
|
|
137
|
+
if (typeof fieldUi !== "object" || fieldUi === null) {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
const widget = fieldUi["ui:widget"];
|
|
141
|
+
return typeof widget === "string" ? widget : void 0;
|
|
142
|
+
}
|
|
143
|
+
function validateUrlValue(value, widget) {
|
|
144
|
+
if (widget === "image" || widget === "link") {
|
|
145
|
+
if (typeof value !== "string") {
|
|
146
|
+
return PUBLIC_HTTP_URL_ERROR;
|
|
147
|
+
}
|
|
148
|
+
const url = widget === "link" ? resolveLinkUrl(value) : value;
|
|
149
|
+
if (!isPublicHttpUrl(url)) {
|
|
150
|
+
return PUBLIC_HTTP_URL_ERROR;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (widget === "attachments" && Array.isArray(value)) {
|
|
155
|
+
for (const item of value) {
|
|
156
|
+
if (typeof item !== "object" || item === null) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const url = item.url;
|
|
160
|
+
if (typeof url === "string" && !isPublicHttpUrl(resolveLinkUrl(url))) {
|
|
161
|
+
return PUBLIC_HTTP_URL_ERROR;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
function validateContextPublicUrls(context) {
|
|
168
|
+
if (!context?.data) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
for (const [field, value] of Object.entries(context.data)) {
|
|
172
|
+
const widget = widgetType(context.ui, field);
|
|
173
|
+
if (!widget) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const error = validateUrlValue(value, widget);
|
|
177
|
+
if (error) {
|
|
178
|
+
return `context.data.${field}: ${error}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ../core/src/schemas/task.ts
|
|
8
185
|
var safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {
|
|
9
186
|
message: PUBLIC_HTTP_URL_ERROR
|
|
10
187
|
});
|
|
@@ -32,6 +209,7 @@ var taskActionSchema = z.object({
|
|
|
32
209
|
schema: jsonSchema7Schema.optional(),
|
|
33
210
|
ui: uiSchemaSchema.optional(),
|
|
34
211
|
data: z.record(z.string(), z.unknown()).optional(),
|
|
212
|
+
// Optional handlers for this action - if present, must have at least 1
|
|
35
213
|
handlers: z.array(handlerSchema).min(1).optional()
|
|
36
214
|
});
|
|
37
215
|
var uiFieldSchemaSchema = z.object({
|
|
@@ -47,6 +225,7 @@ var contextDataSchema = z.object({
|
|
|
47
225
|
ui: contextUiSchema
|
|
48
226
|
}).optional();
|
|
49
227
|
var taskContextObjectSchema = z.object({
|
|
228
|
+
/** Source application id; omitted tasks are grouped in the default inbox. */
|
|
50
229
|
app: z.string().min(1).optional(),
|
|
51
230
|
type: z.string().min(1),
|
|
52
231
|
name: z.string().min(1),
|
|
@@ -93,21 +272,12 @@ var threadUpdateStatuses = [
|
|
|
93
272
|
"cancelled"
|
|
94
273
|
];
|
|
95
274
|
var threadUpdateStatusSchema = z.enum(threadUpdateStatuses);
|
|
96
|
-
var DEFAULT_THREAD_UPDATE_STATUS = "info";
|
|
97
275
|
var threadUpdateInputSchema = z.object({
|
|
98
276
|
message: threadUpdateMessageSchema,
|
|
99
277
|
status: threadUpdateStatusSchema.optional()
|
|
100
278
|
});
|
|
101
279
|
var taskPriorities = ["low", "normal", "high", "urgent"];
|
|
102
280
|
var taskPrioritySchema = z.enum(taskPriorities);
|
|
103
|
-
var DEFAULT_TASK_PRIORITY = "normal";
|
|
104
|
-
var LOWEST_TASK_PRIORITY = "low";
|
|
105
|
-
var TASK_PRIORITY_RANK = {
|
|
106
|
-
low: 1,
|
|
107
|
-
normal: 2,
|
|
108
|
-
high: 3,
|
|
109
|
-
urgent: 4
|
|
110
|
-
};
|
|
111
281
|
var nonNegativeInt = z.number().int().nonnegative();
|
|
112
282
|
var agentCostTokensSchema = z.object({
|
|
113
283
|
input: nonNegativeInt.optional(),
|
|
@@ -120,10 +290,17 @@ var agentCostSchema = z.object({
|
|
|
120
290
|
usd: z.number().nonnegative().optional()
|
|
121
291
|
});
|
|
122
292
|
var AGENT_INFO_MAX_KEYS = 32;
|
|
293
|
+
var AGENT_TOOL_CALLS_MAX_KEYS = 64;
|
|
294
|
+
var agentToolCallsSchema = z.record(z.string().min(1), nonNegativeInt);
|
|
123
295
|
var agentTelemetrySchema = z.object({
|
|
296
|
+
/** Agent or app version (semver, git SHA, deploy tag — caller-defined). */
|
|
124
297
|
version: z.string().min(1).optional(),
|
|
298
|
+
/** Total tool invocations. When omitted but `toolCalls` is set, the sum of counts is used. */
|
|
125
299
|
toolCallCount: nonNegativeInt.optional(),
|
|
300
|
+
/** Per-tool invocation counts keyed by tool name. */
|
|
301
|
+
toolCalls: agentToolCallsSchema.optional(),
|
|
126
302
|
cost: agentCostSchema.optional(),
|
|
303
|
+
/** Free-form metadata for experiments (model, prompt variant, etc.). */
|
|
127
304
|
info: z.record(z.string(), z.unknown()).optional()
|
|
128
305
|
}).refine(
|
|
129
306
|
(data) => {
|
|
@@ -131,6 +308,14 @@ var agentTelemetrySchema = z.object({
|
|
|
131
308
|
return keys.length <= AGENT_INFO_MAX_KEYS;
|
|
132
309
|
},
|
|
133
310
|
{ message: `agent.info may contain at most ${AGENT_INFO_MAX_KEYS} keys` }
|
|
311
|
+
).refine(
|
|
312
|
+
(data) => {
|
|
313
|
+
const keys = data.toolCalls ? Object.keys(data.toolCalls) : [];
|
|
314
|
+
return keys.length <= AGENT_TOOL_CALLS_MAX_KEYS;
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
message: `agent.toolCalls may contain at most ${AGENT_TOOL_CALLS_MAX_KEYS} tool names`
|
|
318
|
+
}
|
|
134
319
|
);
|
|
135
320
|
var createTaskBodySchema = taskContextObjectSchema.extend({
|
|
136
321
|
assignTo: assignToSchema.optional(),
|
|
@@ -149,9 +334,169 @@ var createTaskBodySchema = taskContextObjectSchema.extend({
|
|
|
149
334
|
* the inbox status bar and the thread update log.
|
|
150
335
|
*/
|
|
151
336
|
update: threadUpdateInputSchema.optional(),
|
|
337
|
+
/** Agent telemetry (version, cost, tool calls) — not shown in inbox UI. */
|
|
152
338
|
agent: agentTelemetrySchema.optional()
|
|
153
339
|
}).superRefine(refineContextPublicUrls);
|
|
154
|
-
|
|
340
|
+
|
|
341
|
+
// src/schemas/index.ts
|
|
342
|
+
var safeUrlSchema2 = z2.string().refine((url) => isPublicHttpUrl(url), {
|
|
343
|
+
message: PUBLIC_HTTP_URL_ERROR
|
|
344
|
+
});
|
|
345
|
+
var jsonSchema7Schema2 = z2.custom(
|
|
346
|
+
(val) => typeof val === "object" && val !== null,
|
|
347
|
+
{ message: "Must be a valid JSON Schema object" }
|
|
348
|
+
);
|
|
349
|
+
var uiSchemaSchema2 = z2.custom((val) => typeof val === "object" && val !== null, {
|
|
350
|
+
message: "Must be a valid UiSchema object"
|
|
351
|
+
});
|
|
352
|
+
var webhookHandlerSchema2 = z2.object({
|
|
353
|
+
type: z2.literal("webhook"),
|
|
354
|
+
url: safeUrlSchema2,
|
|
355
|
+
headers: z2.record(z2.string(), z2.string())
|
|
356
|
+
});
|
|
357
|
+
var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
|
|
358
|
+
type: z2.literal("trigger"),
|
|
359
|
+
tokenId: z2.string().min(1)
|
|
360
|
+
});
|
|
361
|
+
var handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
|
|
362
|
+
var taskActionSchema2 = z2.object({
|
|
363
|
+
id: z2.string().min(1),
|
|
364
|
+
title: z2.string().min(1),
|
|
365
|
+
description: z2.string().optional(),
|
|
366
|
+
schema: jsonSchema7Schema2.optional(),
|
|
367
|
+
ui: uiSchemaSchema2.optional(),
|
|
368
|
+
data: z2.record(z2.string(), z2.unknown()).optional(),
|
|
369
|
+
handlers: z2.array(handlerSchema2).min(1).optional()
|
|
370
|
+
});
|
|
371
|
+
var uiFieldSchemaSchema2 = z2.object({
|
|
372
|
+
"ui:widget": z2.string().optional(),
|
|
373
|
+
"ui:title": z2.string().optional(),
|
|
374
|
+
"ui:description": z2.string().optional(),
|
|
375
|
+
"ui:options": z2.record(z2.string(), z2.unknown()).optional(),
|
|
376
|
+
items: z2.lazy(() => z2.record(z2.string(), uiFieldSchemaSchema2)).optional()
|
|
377
|
+
}).passthrough();
|
|
378
|
+
var contextUiSchema2 = z2.record(z2.string(), uiFieldSchemaSchema2).optional();
|
|
379
|
+
var contextDataSchema2 = z2.object({
|
|
380
|
+
data: z2.record(z2.string(), z2.unknown()),
|
|
381
|
+
ui: contextUiSchema2
|
|
382
|
+
}).optional();
|
|
383
|
+
var taskContextObjectSchema2 = z2.object({
|
|
384
|
+
app: z2.string().min(1).optional(),
|
|
385
|
+
type: z2.string().min(1),
|
|
386
|
+
name: z2.string().min(1),
|
|
387
|
+
description: z2.string().optional(),
|
|
388
|
+
validUntil: z2.string().optional(),
|
|
389
|
+
context: contextDataSchema2,
|
|
390
|
+
version: z2.literal(2).optional(),
|
|
391
|
+
actions: z2.array(taskActionSchema2).min(1, "At least one action is required")
|
|
392
|
+
});
|
|
393
|
+
function refineContextPublicUrls2(data, ctx) {
|
|
394
|
+
const error = validateContextPublicUrls(data.context);
|
|
395
|
+
if (error) {
|
|
396
|
+
ctx.addIssue({
|
|
397
|
+
code: z2.ZodIssueCode.custom,
|
|
398
|
+
message: error,
|
|
399
|
+
path: ["context"]
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
var taskContextSchema2 = taskContextObjectSchema2.superRefine(
|
|
404
|
+
refineContextPublicUrls2
|
|
405
|
+
);
|
|
406
|
+
var assignToSchema2 = z2.object({
|
|
407
|
+
users: z2.array(z2.string().email()).optional(),
|
|
408
|
+
groups: z2.array(z2.string().min(1)).optional()
|
|
409
|
+
}).refine(
|
|
410
|
+
(data) => {
|
|
411
|
+
const groups = data.groups ?? [];
|
|
412
|
+
if (groups.includes("all") && groups.length > 1) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
},
|
|
417
|
+
{ message: 'Cannot combine "all" with other group slugs' }
|
|
418
|
+
);
|
|
419
|
+
var threadUpdateMessageSchema2 = z2.string().min(1).max(500);
|
|
420
|
+
var threadUpdateStatuses2 = [
|
|
421
|
+
"info",
|
|
422
|
+
"queued",
|
|
423
|
+
"running",
|
|
424
|
+
"waiting",
|
|
425
|
+
"succeeded",
|
|
426
|
+
"failed",
|
|
427
|
+
"cancelled"
|
|
428
|
+
];
|
|
429
|
+
var threadUpdateStatusSchema2 = z2.enum(threadUpdateStatuses2);
|
|
430
|
+
var DEFAULT_THREAD_UPDATE_STATUS = "info";
|
|
431
|
+
var threadUpdateInputSchema2 = z2.object({
|
|
432
|
+
message: threadUpdateMessageSchema2,
|
|
433
|
+
status: threadUpdateStatusSchema2.optional()
|
|
434
|
+
});
|
|
435
|
+
var taskPriorities2 = ["low", "normal", "high", "urgent"];
|
|
436
|
+
var taskPrioritySchema2 = z2.enum(taskPriorities2);
|
|
437
|
+
var DEFAULT_TASK_PRIORITY = "normal";
|
|
438
|
+
var LOWEST_TASK_PRIORITY = "low";
|
|
439
|
+
var TASK_PRIORITY_RANK = {
|
|
440
|
+
low: 1,
|
|
441
|
+
normal: 2,
|
|
442
|
+
high: 3,
|
|
443
|
+
urgent: 4
|
|
444
|
+
};
|
|
445
|
+
var nonNegativeInt2 = z2.number().int().nonnegative();
|
|
446
|
+
var agentCostTokensSchema2 = z2.object({
|
|
447
|
+
input: nonNegativeInt2.optional(),
|
|
448
|
+
output: nonNegativeInt2.optional(),
|
|
449
|
+
total: nonNegativeInt2.optional()
|
|
450
|
+
});
|
|
451
|
+
var agentCostSchema2 = z2.object({
|
|
452
|
+
tokens: agentCostTokensSchema2.optional(),
|
|
453
|
+
eur: z2.number().nonnegative().optional(),
|
|
454
|
+
usd: z2.number().nonnegative().optional()
|
|
455
|
+
});
|
|
456
|
+
var AGENT_INFO_MAX_KEYS2 = 32;
|
|
457
|
+
var AGENT_TOOL_CALLS_MAX_KEYS2 = 64;
|
|
458
|
+
var agentToolCallsSchema2 = z2.record(z2.string().min(1), nonNegativeInt2);
|
|
459
|
+
var agentTelemetrySchema2 = z2.object({
|
|
460
|
+
version: z2.string().min(1).optional(),
|
|
461
|
+
toolCallCount: nonNegativeInt2.optional(),
|
|
462
|
+
toolCalls: agentToolCallsSchema2.optional(),
|
|
463
|
+
cost: agentCostSchema2.optional(),
|
|
464
|
+
info: z2.record(z2.string(), z2.unknown()).optional()
|
|
465
|
+
}).refine(
|
|
466
|
+
(data) => {
|
|
467
|
+
const keys = data.info ? Object.keys(data.info) : [];
|
|
468
|
+
return keys.length <= AGENT_INFO_MAX_KEYS2;
|
|
469
|
+
},
|
|
470
|
+
{ message: `agent.info may contain at most ${AGENT_INFO_MAX_KEYS2} keys` }
|
|
471
|
+
).refine(
|
|
472
|
+
(data) => {
|
|
473
|
+
const keys = data.toolCalls ? Object.keys(data.toolCalls) : [];
|
|
474
|
+
return keys.length <= AGENT_TOOL_CALLS_MAX_KEYS2;
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
message: `agent.toolCalls may contain at most ${AGENT_TOOL_CALLS_MAX_KEYS2} tool names`
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
var createTaskBodySchema2 = taskContextObjectSchema2.extend({
|
|
481
|
+
assignTo: assignToSchema2.optional(),
|
|
482
|
+
/**
|
|
483
|
+
* Groups related tasks together. When omitted, the server generates one and
|
|
484
|
+
* returns it so the caller can reuse it on later tasks in the same thread.
|
|
485
|
+
*/
|
|
486
|
+
threadId: z2.string().min(1).optional(),
|
|
487
|
+
/**
|
|
488
|
+
* Optional thread priority. When set, applies to the whole thread and
|
|
489
|
+
* overwrites any previous priority. Omit on later tasks to leave unchanged.
|
|
490
|
+
*/
|
|
491
|
+
priority: taskPrioritySchema2.optional(),
|
|
492
|
+
/**
|
|
493
|
+
* Optional initial status update logged against the task's thread. Shows in
|
|
494
|
+
* the inbox status bar and the thread update log.
|
|
495
|
+
*/
|
|
496
|
+
update: threadUpdateInputSchema2.optional(),
|
|
497
|
+
agent: agentTelemetrySchema2.optional()
|
|
498
|
+
}).superRefine(refineContextPublicUrls2);
|
|
499
|
+
var threadUpdateBodySchema = threadUpdateInputSchema2;
|
|
155
500
|
|
|
156
501
|
// src/approval-result.ts
|
|
157
502
|
var TaskTimeoutError = class extends Error {
|
|
@@ -265,7 +610,7 @@ var RobotRock = class {
|
|
|
265
610
|
...task.update !== void 0 ? { update: task.update } : {},
|
|
266
611
|
...task.agent !== void 0 ? { agent: task.agent } : {}
|
|
267
612
|
};
|
|
268
|
-
const validation =
|
|
613
|
+
const validation = createTaskBodySchema2.safeParse(bodyPayload);
|
|
269
614
|
if (!validation.success) {
|
|
270
615
|
throw new RobotRockError(
|
|
271
616
|
`Invalid task: ${validation.error.issues[0]?.message}`,
|
|
@@ -513,21 +858,21 @@ function resolveRobotRockClient(client, configOverrides) {
|
|
|
513
858
|
|
|
514
859
|
// src/webhook.ts
|
|
515
860
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
516
|
-
import { z as
|
|
861
|
+
import { z as z3 } from "zod";
|
|
517
862
|
var ROBOTROCK_SIGNATURE_HEADER = "x-robotrock-signature";
|
|
518
|
-
var robotRockWebhookPayloadBodySchema =
|
|
519
|
-
taskId:
|
|
520
|
-
action:
|
|
521
|
-
id:
|
|
522
|
-
title:
|
|
523
|
-
data:
|
|
863
|
+
var robotRockWebhookPayloadBodySchema = z3.object({
|
|
864
|
+
taskId: z3.string().min(1),
|
|
865
|
+
action: z3.object({
|
|
866
|
+
id: z3.string().min(1),
|
|
867
|
+
title: z3.string().min(1),
|
|
868
|
+
data: z3.unknown()
|
|
524
869
|
}),
|
|
525
|
-
handledBy:
|
|
526
|
-
handledAt:
|
|
527
|
-
handlerType:
|
|
870
|
+
handledBy: z3.string().min(1).optional(),
|
|
871
|
+
handledAt: z3.string().min(1),
|
|
872
|
+
handlerType: z3.string().min(1)
|
|
528
873
|
});
|
|
529
874
|
var robotRockWebhookPayloadSchema = robotRockWebhookPayloadBodySchema.extend({
|
|
530
|
-
headers:
|
|
875
|
+
headers: z3.record(z3.string(), z3.string())
|
|
531
876
|
});
|
|
532
877
|
var RobotRockWebhookError = class extends Error {
|
|
533
878
|
constructor(message, code, details) {
|
|
@@ -626,22 +971,23 @@ export {
|
|
|
626
971
|
TASK_PRIORITY_RANK,
|
|
627
972
|
TaskExpiredError,
|
|
628
973
|
TaskTimeoutError,
|
|
629
|
-
agentCostSchema,
|
|
630
|
-
agentCostTokensSchema,
|
|
631
|
-
agentTelemetrySchema,
|
|
632
|
-
|
|
974
|
+
agentCostSchema2 as agentCostSchema,
|
|
975
|
+
agentCostTokensSchema2 as agentCostTokensSchema,
|
|
976
|
+
agentTelemetrySchema2 as agentTelemetrySchema,
|
|
977
|
+
agentToolCallsSchema2 as agentToolCallsSchema,
|
|
978
|
+
assignToSchema2 as assignToSchema,
|
|
633
979
|
attachWebhookToActions,
|
|
634
980
|
createClient,
|
|
635
|
-
createTaskBodySchema,
|
|
981
|
+
createTaskBodySchema2 as createTaskBodySchema,
|
|
636
982
|
resolveRobotRockClient,
|
|
637
983
|
resolveRobotRockConfig,
|
|
638
|
-
taskContextSchema,
|
|
639
|
-
taskPriorities,
|
|
640
|
-
taskPrioritySchema,
|
|
984
|
+
taskContextSchema2 as taskContextSchema,
|
|
985
|
+
taskPriorities2 as taskPriorities,
|
|
986
|
+
taskPrioritySchema2 as taskPrioritySchema,
|
|
641
987
|
threadUpdateBodySchema,
|
|
642
|
-
threadUpdateInputSchema,
|
|
643
|
-
threadUpdateStatusSchema,
|
|
644
|
-
threadUpdateStatuses,
|
|
988
|
+
threadUpdateInputSchema2 as threadUpdateInputSchema,
|
|
989
|
+
threadUpdateStatusSchema2 as threadUpdateStatusSchema,
|
|
990
|
+
threadUpdateStatuses2 as threadUpdateStatuses,
|
|
645
991
|
toDiscriminatedApprovalResult,
|
|
646
992
|
verifyRobotRockWebhook
|
|
647
993
|
};
|