robotrock 0.8.5 → 1.0.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/dist/ai/index.d.ts +18 -7
- package/dist/ai/index.js +976 -281
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/trigger.d.ts +4 -3
- package/dist/ai/trigger.js +934 -281
- package/dist/ai/trigger.js.map +1 -1
- package/dist/ai/workflow.d.ts +15 -4
- package/dist/ai/workflow.js +854 -282
- package/dist/ai/workflow.js.map +1 -1
- package/dist/client-CzVmjXpz.d.ts +219 -0
- package/dist/index.d.ts +17 -9
- package/dist/index.js +495 -273
- package/dist/index.js.map +1 -1
- package/dist/otel-platform-DzHyHkGk.d.ts +108 -0
- package/dist/schemas/index.d.ts +172 -104
- package/dist/schemas/index.js +98 -118
- package/dist/schemas/index.js.map +1 -1
- package/dist/{tool-approval-bridge-BKDY5NAY.d.ts → tool-approval-bridge-DbwUEBHv.d.ts} +93 -2
- package/dist/trigger/index.d.ts +7 -4
- package/dist/trigger/index.js +558 -201
- package/dist/trigger/index.js.map +1 -1
- package/dist/{trigger-CsOLTjsH.d.ts → trigger-BCKBbAV7.d.ts} +64 -3
- package/dist/workflow/index.d.ts +7 -4
- package/dist/workflow/index.js +553 -199
- package/dist/workflow/index.js.map +1 -1
- package/package.json +1 -5
- package/dist/client-D-XEBOWd.d.ts +0 -137
- package/dist/handler-webhook-BqEi6Bk-.d.ts +0 -16
- package/dist/otel/index.d.ts +0 -49
- package/dist/otel/index.js +0 -633
- package/dist/otel/index.js.map +0 -1
package/dist/schemas/index.js
CHANGED
|
@@ -202,13 +202,15 @@ var triggerHandlerSchema = webhookHandlerSchema.extend({
|
|
|
202
202
|
tokenId: z.string().min(1)
|
|
203
203
|
});
|
|
204
204
|
var handlerSchema = z.discriminatedUnion("type", [webhookHandlerSchema, triggerHandlerSchema]);
|
|
205
|
-
var
|
|
205
|
+
var taskActionInputSchema = z.object({
|
|
206
206
|
id: z.string().min(1),
|
|
207
207
|
title: z.string().min(1),
|
|
208
208
|
description: z.string().optional(),
|
|
209
209
|
schema: jsonSchema7Schema.optional(),
|
|
210
210
|
ui: uiSchemaSchema.optional(),
|
|
211
|
-
data: z.record(z.string(), z.unknown()).optional()
|
|
211
|
+
data: z.record(z.string(), z.unknown()).optional()
|
|
212
|
+
});
|
|
213
|
+
var taskActionSchema = taskActionInputSchema.extend({
|
|
212
214
|
// Optional handlers for this action - if present, must have at least 1
|
|
213
215
|
handlers: z.array(handlerSchema).min(1).optional()
|
|
214
216
|
});
|
|
@@ -224,7 +226,8 @@ var contextDataSchema = z.object({
|
|
|
224
226
|
data: z.record(z.string(), z.unknown()),
|
|
225
227
|
ui: contextUiSchema
|
|
226
228
|
}).optional();
|
|
227
|
-
var
|
|
229
|
+
var TASK_CONTEXT_FORMAT_VERSION = 2;
|
|
230
|
+
var taskContextObjectBaseSchema = z.object({
|
|
228
231
|
/** Source application id; omitted tasks are grouped in the default inbox. */
|
|
229
232
|
app: z.string().min(1).optional(),
|
|
230
233
|
type: z.string().min(1),
|
|
@@ -232,9 +235,22 @@ var taskContextObjectSchema = z.object({
|
|
|
232
235
|
description: z.string().optional(),
|
|
233
236
|
validUntil: z.string().optional(),
|
|
234
237
|
context: contextDataSchema,
|
|
238
|
+
/** Task context wire format version. @default 2 */
|
|
239
|
+
contextVersion: z.literal(2).optional(),
|
|
240
|
+
/** @deprecated Use `contextVersion`. Accepted on ingest only. */
|
|
235
241
|
version: z.literal(2).optional(),
|
|
236
242
|
actions: z.array(taskActionSchema).min(1, "At least one action is required")
|
|
237
243
|
});
|
|
244
|
+
function normalizeTaskContextVersion(data) {
|
|
245
|
+
const { version: legacyVersion, contextVersion, ...rest } = data;
|
|
246
|
+
return {
|
|
247
|
+
...rest,
|
|
248
|
+
contextVersion: contextVersion ?? legacyVersion ?? TASK_CONTEXT_FORMAT_VERSION
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
var taskContextObjectSchema = taskContextObjectBaseSchema.transform(
|
|
252
|
+
normalizeTaskContextVersion
|
|
253
|
+
);
|
|
238
254
|
function refineContextPublicUrls(data, ctx) {
|
|
239
255
|
const error = validateContextPublicUrls(data.context);
|
|
240
256
|
if (error) {
|
|
@@ -278,61 +294,11 @@ var threadUpdateInputSchema = z.object({
|
|
|
278
294
|
});
|
|
279
295
|
var taskPriorities = ["low", "normal", "high", "urgent"];
|
|
280
296
|
var taskPrioritySchema = z.enum(taskPriorities);
|
|
281
|
-
var nonNegativeInt = z.number().int().nonnegative();
|
|
282
|
-
var agentCostTokensSchema = z.object({
|
|
283
|
-
input: nonNegativeInt.optional(),
|
|
284
|
-
output: nonNegativeInt.optional(),
|
|
285
|
-
total: nonNegativeInt.optional()
|
|
286
|
-
});
|
|
287
|
-
var agentCostSchema = z.object({
|
|
288
|
-
tokens: agentCostTokensSchema.optional(),
|
|
289
|
-
eur: z.number().nonnegative().optional(),
|
|
290
|
-
usd: z.number().nonnegative().optional()
|
|
291
|
-
});
|
|
292
|
-
var AGENT_INFO_MAX_KEYS = 32;
|
|
293
|
-
var AGENT_TOOL_CALLS_MAX_KEYS = 64;
|
|
294
|
-
var AGENT_OTEL_SPANS_MAX = 32;
|
|
295
|
-
var agentToolCallsSchema = z.record(z.string().min(1), nonNegativeInt);
|
|
296
|
-
var agentOtelSpanStatusSchema = z.enum(["ok", "error"]);
|
|
297
|
-
var agentOtelSpanSummarySchema = z.object({
|
|
298
|
-
name: z.string().min(1),
|
|
299
|
-
durationMs: z.number().nonnegative(),
|
|
300
|
-
status: agentOtelSpanStatusSchema
|
|
301
|
-
});
|
|
302
|
-
var agentOtelSchema = z.object({
|
|
303
|
-
traceId: z.string().min(1),
|
|
304
|
-
spanId: z.string().min(1).optional(),
|
|
305
|
-
rootDurationMs: z.number().nonnegative().optional(),
|
|
306
|
-
spans: z.array(agentOtelSpanSummarySchema).max(AGENT_OTEL_SPANS_MAX).optional()
|
|
307
|
-
});
|
|
308
297
|
var agentTelemetrySchema = z.object({
|
|
309
298
|
/** Agent or app version (semver, git SHA, deploy tag — caller-defined). */
|
|
310
|
-
version: z.string().min(1)
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
/** Per-tool invocation counts keyed by tool name. */
|
|
314
|
-
toolCalls: agentToolCallsSchema.optional(),
|
|
315
|
-
cost: agentCostSchema.optional(),
|
|
316
|
-
/** Free-form metadata for experiments (model, prompt variant, etc.). */
|
|
317
|
-
info: z.record(z.string(), z.unknown()).optional(),
|
|
318
|
-
/** Structured OpenTelemetry span snapshot for feedback analysis. */
|
|
319
|
-
otel: agentOtelSchema.optional()
|
|
320
|
-
}).refine(
|
|
321
|
-
(data) => {
|
|
322
|
-
const keys = data.info ? Object.keys(data.info) : [];
|
|
323
|
-
return keys.length <= AGENT_INFO_MAX_KEYS;
|
|
324
|
-
},
|
|
325
|
-
{ message: `agent.info may contain at most ${AGENT_INFO_MAX_KEYS} keys` }
|
|
326
|
-
).refine(
|
|
327
|
-
(data) => {
|
|
328
|
-
const keys = data.toolCalls ? Object.keys(data.toolCalls) : [];
|
|
329
|
-
return keys.length <= AGENT_TOOL_CALLS_MAX_KEYS;
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
message: `agent.toolCalls may contain at most ${AGENT_TOOL_CALLS_MAX_KEYS} tool names`
|
|
333
|
-
}
|
|
334
|
-
);
|
|
335
|
-
var createTaskBodySchema = taskContextObjectSchema.extend({
|
|
299
|
+
version: z.string().min(1)
|
|
300
|
+
});
|
|
301
|
+
var createTaskBodySchema = taskContextObjectBaseSchema.extend({
|
|
336
302
|
assignTo: assignToSchema.optional(),
|
|
337
303
|
/**
|
|
338
304
|
* Groups related tasks together. When omitted, the server generates one and
|
|
@@ -349,9 +315,59 @@ var createTaskBodySchema = taskContextObjectSchema.extend({
|
|
|
349
315
|
* the inbox status bar and the thread update log.
|
|
350
316
|
*/
|
|
351
317
|
update: threadUpdateInputSchema.optional(),
|
|
352
|
-
/** Agent
|
|
318
|
+
/** Agent release version — not shown in inbox UI. */
|
|
353
319
|
agent: agentTelemetrySchema.optional()
|
|
354
|
-
}).superRefine(refineContextPublicUrls);
|
|
320
|
+
}).transform(normalizeTaskContextVersion).superRefine(refineContextPublicUrls);
|
|
321
|
+
var agentChatSeedActionSchema = z.object({
|
|
322
|
+
/** Stable action id echoed back on submit; auto-derived from title when omitted. */
|
|
323
|
+
id: z.string().min(1).optional(),
|
|
324
|
+
title: z.string().min(1),
|
|
325
|
+
description: z.string().optional(),
|
|
326
|
+
/** JSON Schema object for the form fields. */
|
|
327
|
+
schema: z.record(z.string(), z.unknown()).optional(),
|
|
328
|
+
/** RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). */
|
|
329
|
+
ui: z.record(z.string(), z.unknown()).optional(),
|
|
330
|
+
/** Optional default field values. */
|
|
331
|
+
data: z.record(z.string(), z.unknown()).optional()
|
|
332
|
+
});
|
|
333
|
+
var agentChatSeedMessageSchema = z.object({
|
|
334
|
+
role: z.enum(["user", "assistant"]),
|
|
335
|
+
text: z.string().min(1),
|
|
336
|
+
/** Optional display-name override for the message sender. */
|
|
337
|
+
senderName: z.string().min(1).optional(),
|
|
338
|
+
/**
|
|
339
|
+
* Optional structured input request rendered as a styled RobotRock action
|
|
340
|
+
* widget below the message text. Use this instead of asking the user to reply
|
|
341
|
+
* in plain text so the request is always a proper action form.
|
|
342
|
+
*/
|
|
343
|
+
requestActionInput: z.object({
|
|
344
|
+
prompt: z.string().optional(),
|
|
345
|
+
action: agentChatSeedActionSchema
|
|
346
|
+
}).optional()
|
|
347
|
+
});
|
|
348
|
+
var createAgentChatBodySchema = z.object({
|
|
349
|
+
/** Trigger chat agent id (task slug). Required unless `parentChatId` is set. */
|
|
350
|
+
agentIdentifier: z.string().min(1).optional(),
|
|
351
|
+
/** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */
|
|
352
|
+
parentChatId: z.string().min(1).optional(),
|
|
353
|
+
/** Convex tenantTriggerConnections id; resolved from the tenant when omitted. */
|
|
354
|
+
connectionId: z.string().min(1).optional(),
|
|
355
|
+
/** Source application id; groups the chat under an inbox section. */
|
|
356
|
+
app: z.string().min(1).optional(),
|
|
357
|
+
assignTo: assignToSchema.optional(),
|
|
358
|
+
title: z.string().min(1),
|
|
359
|
+
messages: z.array(agentChatSeedMessageSchema).default([]),
|
|
360
|
+
/** Provenance label stored on the session ("cron" | "agent" | ...). */
|
|
361
|
+
source: z.string().min(1).optional()
|
|
362
|
+
}).refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {
|
|
363
|
+
message: "Provide either agentIdentifier or parentChatId"
|
|
364
|
+
});
|
|
365
|
+
var agentChatTransportBodySchema = z.object({
|
|
366
|
+
chatId: z.string().min(1),
|
|
367
|
+
publicAccessToken: z.string().min(1),
|
|
368
|
+
lastEventId: z.string().optional(),
|
|
369
|
+
isStreaming: z.boolean().optional()
|
|
370
|
+
});
|
|
355
371
|
|
|
356
372
|
// src/schemas/index.ts
|
|
357
373
|
var safeUrlSchema2 = z2.string().refine((url) => isPublicHttpUrl(url), {
|
|
@@ -374,13 +390,15 @@ var triggerHandlerSchema2 = webhookHandlerSchema2.extend({
|
|
|
374
390
|
tokenId: z2.string().min(1)
|
|
375
391
|
});
|
|
376
392
|
var handlerSchema2 = z2.discriminatedUnion("type", [webhookHandlerSchema2, triggerHandlerSchema2]);
|
|
377
|
-
var
|
|
393
|
+
var taskActionInputSchema2 = z2.object({
|
|
378
394
|
id: z2.string().min(1),
|
|
379
395
|
title: z2.string().min(1),
|
|
380
396
|
description: z2.string().optional(),
|
|
381
397
|
schema: jsonSchema7Schema2.optional(),
|
|
382
398
|
ui: uiSchemaSchema2.optional(),
|
|
383
|
-
data: z2.record(z2.string(), z2.unknown()).optional()
|
|
399
|
+
data: z2.record(z2.string(), z2.unknown()).optional()
|
|
400
|
+
});
|
|
401
|
+
var taskActionSchema2 = taskActionInputSchema2.extend({
|
|
384
402
|
handlers: z2.array(handlerSchema2).min(1).optional()
|
|
385
403
|
});
|
|
386
404
|
var uiFieldSchemaSchema2 = z2.object({
|
|
@@ -395,16 +413,29 @@ var contextDataSchema2 = z2.object({
|
|
|
395
413
|
data: z2.record(z2.string(), z2.unknown()),
|
|
396
414
|
ui: contextUiSchema2
|
|
397
415
|
}).optional();
|
|
398
|
-
var
|
|
416
|
+
var TASK_CONTEXT_FORMAT_VERSION2 = 2;
|
|
417
|
+
var taskContextObjectBaseSchema2 = z2.object({
|
|
399
418
|
app: z2.string().min(1).optional(),
|
|
400
419
|
type: z2.string().min(1),
|
|
401
420
|
name: z2.string().min(1),
|
|
402
421
|
description: z2.string().optional(),
|
|
403
422
|
validUntil: z2.string().optional(),
|
|
404
423
|
context: contextDataSchema2,
|
|
424
|
+
contextVersion: z2.literal(2).optional(),
|
|
425
|
+
/** @deprecated Use `contextVersion`. Accepted on ingest only. */
|
|
405
426
|
version: z2.literal(2).optional(),
|
|
406
427
|
actions: z2.array(taskActionSchema2).min(1, "At least one action is required")
|
|
407
428
|
});
|
|
429
|
+
function normalizeTaskContextVersion2(data) {
|
|
430
|
+
const { version: legacyVersion, contextVersion, ...rest } = data;
|
|
431
|
+
return {
|
|
432
|
+
...rest,
|
|
433
|
+
contextVersion: contextVersion ?? legacyVersion ?? TASK_CONTEXT_FORMAT_VERSION2
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
var taskContextObjectSchema2 = taskContextObjectBaseSchema2.transform(
|
|
437
|
+
normalizeTaskContextVersion2
|
|
438
|
+
);
|
|
408
439
|
function refineContextPublicUrls2(data, ctx) {
|
|
409
440
|
const error = validateContextPublicUrls(data.context);
|
|
410
441
|
if (error) {
|
|
@@ -457,56 +488,10 @@ var TASK_PRIORITY_RANK = {
|
|
|
457
488
|
high: 3,
|
|
458
489
|
urgent: 4
|
|
459
490
|
};
|
|
460
|
-
var nonNegativeInt2 = z2.number().int().nonnegative();
|
|
461
|
-
var agentCostTokensSchema2 = z2.object({
|
|
462
|
-
input: nonNegativeInt2.optional(),
|
|
463
|
-
output: nonNegativeInt2.optional(),
|
|
464
|
-
total: nonNegativeInt2.optional()
|
|
465
|
-
});
|
|
466
|
-
var agentCostSchema2 = z2.object({
|
|
467
|
-
tokens: agentCostTokensSchema2.optional(),
|
|
468
|
-
eur: z2.number().nonnegative().optional(),
|
|
469
|
-
usd: z2.number().nonnegative().optional()
|
|
470
|
-
});
|
|
471
|
-
var AGENT_INFO_MAX_KEYS2 = 32;
|
|
472
|
-
var AGENT_TOOL_CALLS_MAX_KEYS2 = 64;
|
|
473
|
-
var AGENT_OTEL_SPANS_MAX2 = 32;
|
|
474
|
-
var agentToolCallsSchema2 = z2.record(z2.string().min(1), nonNegativeInt2);
|
|
475
|
-
var agentOtelSpanStatusSchema2 = z2.enum(["ok", "error"]);
|
|
476
|
-
var agentOtelSpanSummarySchema2 = z2.object({
|
|
477
|
-
name: z2.string().min(1),
|
|
478
|
-
durationMs: z2.number().nonnegative(),
|
|
479
|
-
status: agentOtelSpanStatusSchema2
|
|
480
|
-
});
|
|
481
|
-
var agentOtelSchema2 = z2.object({
|
|
482
|
-
traceId: z2.string().min(1),
|
|
483
|
-
spanId: z2.string().min(1).optional(),
|
|
484
|
-
rootDurationMs: z2.number().nonnegative().optional(),
|
|
485
|
-
spans: z2.array(agentOtelSpanSummarySchema2).max(AGENT_OTEL_SPANS_MAX2).optional()
|
|
486
|
-
});
|
|
487
491
|
var agentTelemetrySchema2 = z2.object({
|
|
488
|
-
version: z2.string().min(1)
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
cost: agentCostSchema2.optional(),
|
|
492
|
-
info: z2.record(z2.string(), z2.unknown()).optional(),
|
|
493
|
-
otel: agentOtelSchema2.optional()
|
|
494
|
-
}).refine(
|
|
495
|
-
(data) => {
|
|
496
|
-
const keys = data.info ? Object.keys(data.info) : [];
|
|
497
|
-
return keys.length <= AGENT_INFO_MAX_KEYS2;
|
|
498
|
-
},
|
|
499
|
-
{ message: `agent.info may contain at most ${AGENT_INFO_MAX_KEYS2} keys` }
|
|
500
|
-
).refine(
|
|
501
|
-
(data) => {
|
|
502
|
-
const keys = data.toolCalls ? Object.keys(data.toolCalls) : [];
|
|
503
|
-
return keys.length <= AGENT_TOOL_CALLS_MAX_KEYS2;
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
message: `agent.toolCalls may contain at most ${AGENT_TOOL_CALLS_MAX_KEYS2} tool names`
|
|
507
|
-
}
|
|
508
|
-
);
|
|
509
|
-
var createTaskBodySchema2 = taskContextObjectSchema2.extend({
|
|
492
|
+
version: z2.string().min(1)
|
|
493
|
+
});
|
|
494
|
+
var createTaskBodySchema2 = taskContextObjectBaseSchema2.extend({
|
|
510
495
|
assignTo: assignToSchema2.optional(),
|
|
511
496
|
/**
|
|
512
497
|
* Groups related tasks together. When omitted, the server generates one and
|
|
@@ -524,23 +509,18 @@ var createTaskBodySchema2 = taskContextObjectSchema2.extend({
|
|
|
524
509
|
*/
|
|
525
510
|
update: threadUpdateInputSchema2.optional(),
|
|
526
511
|
agent: agentTelemetrySchema2.optional()
|
|
527
|
-
}).superRefine(refineContextPublicUrls2);
|
|
512
|
+
}).transform(normalizeTaskContextVersion2).superRefine(refineContextPublicUrls2);
|
|
528
513
|
var threadUpdateBodySchema = threadUpdateInputSchema2;
|
|
529
514
|
export {
|
|
530
|
-
AGENT_OTEL_SPANS_MAX2 as AGENT_OTEL_SPANS_MAX,
|
|
531
515
|
DEFAULT_TASK_PRIORITY,
|
|
532
516
|
DEFAULT_THREAD_UPDATE_STATUS,
|
|
533
517
|
LOWEST_TASK_PRIORITY,
|
|
518
|
+
TASK_CONTEXT_FORMAT_VERSION2 as TASK_CONTEXT_FORMAT_VERSION,
|
|
534
519
|
TASK_PRIORITY_RANK,
|
|
535
|
-
agentCostSchema2 as agentCostSchema,
|
|
536
|
-
agentCostTokensSchema2 as agentCostTokensSchema,
|
|
537
|
-
agentOtelSchema2 as agentOtelSchema,
|
|
538
|
-
agentOtelSpanStatusSchema2 as agentOtelSpanStatusSchema,
|
|
539
|
-
agentOtelSpanSummarySchema2 as agentOtelSpanSummarySchema,
|
|
540
520
|
agentTelemetrySchema2 as agentTelemetrySchema,
|
|
541
|
-
agentToolCallsSchema2 as agentToolCallsSchema,
|
|
542
521
|
assignToSchema2 as assignToSchema,
|
|
543
522
|
createTaskBodySchema2 as createTaskBodySchema,
|
|
523
|
+
taskActionInputSchema2 as taskActionInputSchema,
|
|
544
524
|
taskContextSchema2 as taskContextSchema,
|
|
545
525
|
taskPriorities2 as taskPriorities,
|
|
546
526
|
taskPrioritySchema2 as taskPrioritySchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schemas/index.ts","../../../core/src/utils/safe-url.ts","../../../core/src/schemas/task.ts","../../../core/src/schemas/context-urls.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n isPublicHttpUrl,\n PUBLIC_HTTP_URL_ERROR,\n} from \"@robotrock/core/utils\";\nimport { validateContextPublicUrls } from \"@robotrock/core/schemas\";\n\nexport interface JSONSchema7 {\n $id?: string;\n $ref?: string;\n $schema?: string;\n $comment?: string;\n type?: JSONSchema7TypeName | JSONSchema7TypeName[];\n enum?: unknown[];\n const?: unknown;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n minimum?: number;\n exclusiveMinimum?: number;\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n format?: string;\n items?: JSONSchema7 | JSONSchema7[];\n additionalItems?: JSONSchema7 | boolean;\n maxItems?: number;\n minItems?: number;\n uniqueItems?: boolean;\n contains?: JSONSchema7;\n maxProperties?: number;\n minProperties?: number;\n required?: string[];\n properties?: Record<string, JSONSchema7>;\n patternProperties?: Record<string, JSONSchema7>;\n additionalProperties?: JSONSchema7 | boolean;\n dependencies?: Record<string, JSONSchema7 | string[]>;\n propertyNames?: JSONSchema7;\n if?: JSONSchema7;\n then?: JSONSchema7;\n else?: JSONSchema7;\n allOf?: JSONSchema7[];\n anyOf?: JSONSchema7[];\n oneOf?: JSONSchema7[];\n not?: JSONSchema7;\n title?: string;\n description?: string;\n default?: unknown;\n readOnly?: boolean;\n writeOnly?: boolean;\n examples?: unknown[];\n}\n\nexport type JSONSchema7TypeName =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\"\n | \"null\";\n\nexport type ExtendedJSONSchema7 = JSONSchema7 & {\n enumNames?: string[];\n [key: string]: unknown;\n};\n\nexport type UiSchema = {\n \"ui:widget\"?: string;\n \"ui:title\"?: string;\n \"ui:description\"?: string;\n \"ui:placeholder\"?: string;\n \"ui:options\"?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\nconst safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {\n message: PUBLIC_HTTP_URL_ERROR,\n});\n\nconst jsonSchema7Schema = z.custom<ExtendedJSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n { message: \"Must be a valid JSON Schema object\" }\n);\n\nconst uiSchemaSchema = z.custom<UiSchema>((val) => typeof val === \"object\" && val !== null, {\n message: \"Must be a valid UiSchema object\",\n});\n\nconst webhookHandlerSchema = z.object({\n type: z.literal(\"webhook\"),\n url: safeUrlSchema,\n headers: z.record(z.string(), 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.string(), 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.string(), z.unknown()).optional(),\n items: z.lazy(() => z.record(z.string(), uiFieldSchemaSchema)).optional(),\n })\n .passthrough();\n\nconst contextUiSchema = z.record(z.string(), uiFieldSchemaSchema).optional();\n\nconst contextDataSchema = z\n .object({\n data: z.record(z.string(), z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\nconst taskContextObjectSchema = z.object({\n app: z.string().min(1).optional(),\n type: z.string().min(1),\n name: z.string().min(1),\n description: z.string().optional(),\n validUntil: z.string().optional(),\n context: contextDataSchema,\n version: z.literal(2).optional(),\n actions: z.array(taskActionSchema).min(1, \"At least one action is required\"),\n});\n\nfunction refineContextPublicUrls<T extends { context?: z.infer<typeof contextDataSchema> }>(\n data: T,\n ctx: z.RefinementCtx\n) {\n const error = validateContextPublicUrls(data.context);\n if (error) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: error,\n path: [\"context\"],\n });\n }\n}\n\nexport const taskContextSchema = taskContextObjectSchema.superRefine(\n refineContextPublicUrls\n);\n\n/**\n * Assignment targets at task create (not stored in task context JSON).\n * Unknown user emails are auto-provisioned as assignee memberships (count toward seat limits).\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\nconst nonNegativeInt = z.number().int().nonnegative();\n\nexport const agentCostTokensSchema = z.object({\n input: nonNegativeInt.optional(),\n output: nonNegativeInt.optional(),\n total: nonNegativeInt.optional(),\n});\n\nexport const agentCostSchema = z.object({\n tokens: agentCostTokensSchema.optional(),\n eur: z.number().nonnegative().optional(),\n usd: z.number().nonnegative().optional(),\n});\n\nconst AGENT_INFO_MAX_KEYS = 32;\nconst AGENT_TOOL_CALLS_MAX_KEYS = 64;\nexport const AGENT_OTEL_SPANS_MAX = 32;\n\nexport const agentToolCallsSchema = z.record(z.string().min(1), nonNegativeInt);\n\nexport const agentOtelSpanStatusSchema = z.enum([\"ok\", \"error\"]);\n\nexport const agentOtelSpanSummarySchema = z.object({\n name: z.string().min(1),\n durationMs: z.number().nonnegative(),\n status: agentOtelSpanStatusSchema,\n});\n\nexport const agentOtelSchema = z.object({\n traceId: z.string().min(1),\n spanId: z.string().min(1).optional(),\n rootDurationMs: z.number().nonnegative().optional(),\n spans: z.array(agentOtelSpanSummarySchema).max(AGENT_OTEL_SPANS_MAX).optional(),\n});\n\nexport const agentTelemetrySchema = z\n .object({\n version: z.string().min(1).optional(),\n toolCallCount: nonNegativeInt.optional(),\n toolCalls: agentToolCallsSchema.optional(),\n cost: agentCostSchema.optional(),\n info: z.record(z.string(), z.unknown()).optional(),\n otel: agentOtelSchema.optional(),\n })\n .refine(\n (data) => {\n const keys = data.info ? Object.keys(data.info) : [];\n return keys.length <= AGENT_INFO_MAX_KEYS;\n },\n { message: `agent.info may contain at most ${AGENT_INFO_MAX_KEYS} keys` }\n )\n .refine(\n (data) => {\n const keys = data.toolCalls ? Object.keys(data.toolCalls) : [];\n return keys.length <= AGENT_TOOL_CALLS_MAX_KEYS;\n },\n {\n message: `agent.toolCalls may contain at most ${AGENT_TOOL_CALLS_MAX_KEYS} tool names`,\n }\n );\n\nexport const createTaskBodySchema = taskContextObjectSchema\n .extend({\n assignTo: assignToSchema.optional(),\n /**\n * Groups related tasks together. When omitted, the server generates one and\n * returns it so the caller can reuse it on later tasks in the same thread.\n */\n threadId: z.string().min(1).optional(),\n /**\n * Optional thread priority. When set, applies to the whole thread and\n * overwrites any previous priority. Omit on later tasks to leave unchanged.\n */\n priority: taskPrioritySchema.optional(),\n /**\n * Optional initial status update logged against the task's thread. Shows in\n * the inbox status bar and the thread update log.\n */\n update: threadUpdateInputSchema.optional(),\n agent: agentTelemetrySchema.optional(),\n })\n .superRefine(refineContextPublicUrls);\n\n/** POST /v1/threads/:threadId/updates body: a standalone thread update. */\nexport const threadUpdateBodySchema = threadUpdateInputSchema;\n\n/** Where a thread update originated. */\nexport type ThreadUpdateSource = \"api\" | \"task_create\" | \"dashboard\";\n\n/** Lifecycle status carried by a thread update. */\nexport type ThreadUpdateStatus = (typeof threadUpdateStatuses)[number];\n\n/** A logged thread update as returned by the API. */\nexport interface ThreadUpdate {\n id: string;\n threadId: string;\n message: string;\n status: ThreadUpdateStatus;\n source: ThreadUpdateSource;\n createdAt: number;\n}\n\nexport type AssignToInput = z.infer<typeof assignToSchema>;\nexport type CreateTaskBodyInput = z.input<typeof createTaskBodySchema>;\nexport type CreateTaskBody = z.output<typeof createTaskBodySchema>;\nexport type ThreadUpdateBodyInput = z.input<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateBody = z.output<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateInput = z.input<typeof threadUpdateInputSchema>;\nexport type TaskContextInput = z.input<typeof taskContextSchema>;\nexport type TaskContextOutput = z.output<typeof taskContextSchema>;\nexport type TaskContext = TaskContextOutput;\nexport type TaskAction = z.infer<typeof taskActionSchema>;\nexport type WebhookHandler = z.infer<typeof webhookHandlerSchema>;\nexport type TriggerHandler = z.infer<typeof triggerHandlerSchema>;\nexport type Handler = z.infer<typeof handlerSchema>;\nexport type AgentCostTokens = z.infer<typeof agentCostTokensSchema>;\nexport type AgentCost = z.infer<typeof agentCostSchema>;\nexport type AgentToolCalls = z.infer<typeof agentToolCallsSchema>;\nexport type AgentOtelSpanStatus = z.infer<typeof agentOtelSpanStatusSchema>;\nexport type AgentOtelSpanSummary = z.infer<typeof agentOtelSpanSummarySchema>;\nexport type AgentOtel = z.infer<typeof agentOtelSchema>;\nexport type AgentTelemetry = z.infer<typeof agentTelemetrySchema>;\nexport type AgentTelemetryInput = z.input<typeof agentTelemetrySchema>;\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","const BLOCKED_HOSTNAMES = new Set([\n \"localhost\",\n \"metadata.google.internal\",\n \"metadata.goog\",\n]);\n\nfunction normalizeHostname(hostname: string): string {\n return hostname.toLowerCase().replace(/^\\[|\\]$/g, \"\");\n}\n\nfunction isBlockedIpv4(host: string): boolean {\n const match = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(host);\n if (!match) {\n return false;\n }\n\n const octets = match.slice(1, 5).map((part) => Number(part));\n if (octets.some((octet) => Number.isNaN(octet) || octet < 0 || octet > 255)) {\n return true;\n }\n\n const [a, b, _c, _d] = octets;\n if (a === undefined || b === undefined) {\n return true;\n }\n if (a === 127 || a === 0) return true;\n if (a === 10) return true;\n if (a === 169 && b === 254) return true;\n if (a === 192 && b === 168) return true;\n if (a === 172 && b >= 16 && b <= 31) return true;\n if (a === 100 && b >= 64 && b <= 127) return true;\n\n return false;\n}\n\nfunction ipv4FromNumericHost(host: string): string | null {\n if (/^\\d+$/.test(host)) {\n const num = Number(host);\n if (!Number.isFinite(num) || num < 0 || num > 0xffffffff) {\n return null;\n }\n const a = (num >>> 24) & 0xff;\n const b = (num >>> 16) & 0xff;\n const c = (num >>> 8) & 0xff;\n const d = num & 0xff;\n return `${a}.${b}.${c}.${d}`;\n }\n\n const hexMatch = /^0x([0-9a-f]{1,8})$/i.exec(host);\n if (hexMatch) {\n const num = Number.parseInt(hexMatch[1]!, 16);\n if (!Number.isFinite(num) || num < 0 || num > 0xffffffff) {\n return null;\n }\n const a = (num >>> 24) & 0xff;\n const b = (num >>> 16) & 0xff;\n const c = (num >>> 8) & 0xff;\n const d = num & 0xff;\n return `${a}.${b}.${c}.${d}`;\n }\n\n return null;\n}\n\nfunction isBlockedIpv4Mapped(host: string): boolean {\n const mappedDotted = /^::ffff:(\\d{1,3}(?:\\.\\d{1,3}){3})$/i.exec(host);\n if (mappedDotted) {\n return isBlockedIpv4(mappedDotted[1]!);\n }\n\n const mappedHex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(host);\n if (mappedHex) {\n const high = Number.parseInt(mappedHex[1]!, 16);\n const low = Number.parseInt(mappedHex[2]!, 16);\n if (Number.isFinite(high) && Number.isFinite(low)) {\n const a = (high >> 8) & 0xff;\n const b = high & 0xff;\n const c = (low >> 8) & 0xff;\n const d = low & 0xff;\n return isBlockedIpv4(`${a}.${b}.${c}.${d}`);\n }\n }\n\n return false;\n}\n\nfunction isBlockedIpv6(host: string): boolean {\n if (host === \"::1\" || host === \"0:0:0:0:0:0:0:1\") {\n return true;\n }\n if (host.startsWith(\"fc\") || host.startsWith(\"fd\")) {\n return true;\n }\n if (host.startsWith(\"fe80:\")) {\n return true;\n }\n if (isBlockedIpv4Mapped(host)) {\n return true;\n }\n return false;\n}\n\nfunction isBlockedHostname(hostname: string): boolean {\n const host = normalizeHostname(hostname);\n if (!host) {\n return true;\n }\n if (BLOCKED_HOSTNAMES.has(host)) {\n return true;\n }\n if (host.endsWith(\".localhost\") || host.endsWith(\".local\")) {\n return true;\n }\n\n const numericIpv4 = ipv4FromNumericHost(host);\n if (numericIpv4 && isBlockedIpv4(numericIpv4)) {\n return true;\n }\n\n return isBlockedIpv4(host) || isBlockedIpv6(host);\n}\n\n/**\n * Returns true when the URL uses http(s) and targets a public, non-reserved host.\n */\nexport function isPublicHttpUrl(urlString: string): boolean {\n let url: URL;\n try {\n url = new URL(urlString);\n } catch {\n return false;\n }\n\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n return false;\n }\n if (url.username || url.password) {\n return false;\n }\n\n return !isBlockedHostname(url.hostname);\n}\n\nexport const PUBLIC_HTTP_URL_ERROR =\n \"URL must be a public http:// or https:// address\";\n\nconst FORBIDDEN_HANDLER_HEADERS = new Set([\n \"host\",\n \"connection\",\n \"content-length\",\n \"transfer-encoding\",\n \"te\",\n \"trailer\",\n \"upgrade\",\n \"proxy-authorization\",\n \"proxy-connection\",\n \"keep-alive\",\n \"x-robotrock-signature\",\n \"x-robotrock-delivery-id\",\n \"x-robotrock-delivery-attempt\",\n]);\n\n/**\n * Allow only safe custom webhook headers; blocks overrides of delivery metadata.\n */\nexport function filterHandlerHeaders(\n headers: Record<string, string> | undefined\n): Record<string, string> {\n if (!headers) {\n return {};\n }\n\n const filtered: Record<string, string> = {};\n for (const [rawKey, value] of Object.entries(headers)) {\n const key = rawKey.toLowerCase().trim();\n if (!key || FORBIDDEN_HANDLER_HEADERS.has(key)) {\n continue;\n }\n if (!/^[a-z0-9][a-z0-9._-]*$/.test(key)) {\n continue;\n }\n filtered[key] = value;\n }\n return filtered;\n}\n","import { z } from \"zod\";\nimport { isPublicHttpUrl, PUBLIC_HTTP_URL_ERROR } from \"../utils/safe-url\";\nimport { validateContextPublicUrls } from \"./context-urls\";\nimport type { JSONSchema7 } from \"./json-schema\";\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.string().refine((url) => isPublicHttpUrl(url), {\n message: PUBLIC_HTTP_URL_ERROR,\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(), 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.string(), 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.string(), z.unknown()).optional(),\n items: z.lazy(() => z.record(z.string(), uiFieldSchemaSchema)).optional(),\n })\n .passthrough();\n\n// Context UI Schema\nconst contextUiSchema = z.record(z.string(), uiFieldSchemaSchema).optional();\n\n// Context data schema\nconst contextDataSchema = z\n .object({\n data: z.record(z.string(), z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\n// Main TaskContext schema\nconst taskContextObjectSchema = 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\nfunction refineContextPublicUrls<T extends { context?: z.infer<typeof contextDataSchema> }>(\n data: T,\n ctx: z.RefinementCtx\n) {\n const error = validateContextPublicUrls(data.context);\n if (error) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: error,\n path: [\"context\"],\n });\n }\n}\n\nexport const taskContextSchema = taskContextObjectSchema.superRefine(\n refineContextPublicUrls\n);\n\n/**\n * Assignment targets at task create (not stored in task context JSON).\n * Unknown user emails are auto-provisioned as assignee memberships (count toward seat limits).\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\nconst nonNegativeInt = z.number().int().nonnegative();\n\n/** Token usage for a single agent run (optional breakdown). */\nexport const agentCostTokensSchema = z.object({\n input: nonNegativeInt.optional(),\n output: nonNegativeInt.optional(),\n total: nonNegativeInt.optional(),\n});\n\n/** Monetary and token cost for a single agent run. */\nexport const agentCostSchema = z.object({\n tokens: agentCostTokensSchema.optional(),\n eur: z.number().nonnegative().optional(),\n usd: z.number().nonnegative().optional(),\n});\n\nconst AGENT_INFO_MAX_KEYS = 32;\nexport const AGENT_TOOL_CALLS_MAX_KEYS = 64;\nexport const AGENT_OTEL_SPANS_MAX = 32;\n\n/** Per-tool invocation counts keyed by tool name (e.g. `{ readFile: 3, grep: 2 }`). */\nexport const agentToolCallsSchema = z.record(z.string().min(1), nonNegativeInt);\n\nexport const agentOtelSpanStatusSchema = z.enum([\"ok\", \"error\"]);\n\n/** Compact OpenTelemetry span summary for feedback analysis. */\nexport const agentOtelSpanSummarySchema = z.object({\n name: z.string().min(1),\n durationMs: z.number().nonnegative(),\n status: agentOtelSpanStatusSchema,\n});\n\n/**\n * Structured OpenTelemetry snapshot at task create (not shown in inbox UI).\n * Pair with full traces in your observability backend via `traceId`.\n */\nexport const agentOtelSchema = z.object({\n traceId: z.string().min(1),\n spanId: z.string().min(1).optional(),\n rootDurationMs: z.number().nonnegative().optional(),\n spans: z.array(agentOtelSpanSummarySchema).max(AGENT_OTEL_SPANS_MAX).optional(),\n});\n\n/**\n * Agent-only telemetry at task create (not shown in inbox reviewer UI).\n * Use to track version, cost, tool calls, and experiment metadata.\n */\nexport const agentTelemetrySchema = z\n .object({\n /** Agent or app version (semver, git SHA, deploy tag — caller-defined). */\n version: z.string().min(1).optional(),\n /** Total tool invocations. When omitted but `toolCalls` is set, the sum of counts is used. */\n toolCallCount: nonNegativeInt.optional(),\n /** Per-tool invocation counts keyed by tool name. */\n toolCalls: agentToolCallsSchema.optional(),\n cost: agentCostSchema.optional(),\n /** Free-form metadata for experiments (model, prompt variant, etc.). */\n info: z.record(z.string(), z.unknown()).optional(),\n /** Structured OpenTelemetry span snapshot for feedback analysis. */\n otel: agentOtelSchema.optional(),\n })\n .refine(\n (data) => {\n const keys = data.info ? Object.keys(data.info) : [];\n return keys.length <= AGENT_INFO_MAX_KEYS;\n },\n { message: `agent.info may contain at most ${AGENT_INFO_MAX_KEYS} keys` }\n )\n .refine(\n (data) => {\n const keys = data.toolCalls ? Object.keys(data.toolCalls) : [];\n return keys.length <= AGENT_TOOL_CALLS_MAX_KEYS;\n },\n {\n message: `agent.toolCalls may contain at most ${AGENT_TOOL_CALLS_MAX_KEYS} tool names`,\n }\n );\n\n/** Sum invocation counts from an agent.toolCalls map. */\nexport function sumAgentToolCalls(\n toolCalls: Record<string, number> | undefined\n): number {\n if (!toolCalls) return 0;\n return Object.values(toolCalls).reduce((sum, count) => sum + count, 0);\n}\n\n/** POST /v1 body: task context plus optional assignment. */\nexport const createTaskBodySchema = taskContextObjectSchema\n .extend({\n assignTo: assignToSchema.optional(),\n /**\n * Groups related tasks together. When omitted, the server generates one and\n * returns it so the caller can reuse it on later tasks in the same thread.\n */\n threadId: z.string().min(1).optional(),\n /**\n * Optional thread priority. When set, applies to the whole thread and\n * overwrites any previous priority. Omit on later tasks to leave unchanged.\n */\n priority: taskPrioritySchema.optional(),\n /**\n * Optional initial status update logged against the task's thread. Shows in\n * the inbox status bar and the thread update log.\n */\n update: threadUpdateInputSchema.optional(),\n /** Agent telemetry (version, cost, tool calls) — not shown in inbox UI. */\n agent: agentTelemetrySchema.optional(),\n })\n .superRefine(refineContextPublicUrls);\n\n/** POST /v1/threads/:threadId/updates body: a standalone thread update. */\nexport const threadUpdateBodySchema = threadUpdateInputSchema;\n\n/** Where a thread update originated. */\nexport type ThreadUpdateSource = \"api\" | \"task_create\" | \"dashboard\";\n\n/** Lifecycle status carried by a thread update. */\nexport type ThreadUpdateStatus = (typeof threadUpdateStatuses)[number];\n\n/** A logged thread update as returned by the API. */\nexport interface ThreadUpdate {\n id: string;\n threadId: string;\n message: string;\n status: ThreadUpdateStatus;\n source: ThreadUpdateSource;\n createdAt: number;\n}\n\n// Type exports\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 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>;\nexport type AgentCostTokens = z.infer<typeof agentCostTokensSchema>;\nexport type AgentCost = z.infer<typeof agentCostSchema>;\nexport type AgentToolCalls = z.infer<typeof agentToolCallsSchema>;\nexport type AgentOtelSpanStatus = z.infer<typeof agentOtelSpanStatusSchema>;\nexport type AgentOtelSpanSummary = z.infer<typeof agentOtelSpanSummarySchema>;\nexport type AgentOtel = z.infer<typeof agentOtelSchema>;\nexport type AgentTelemetry = z.infer<typeof agentTelemetrySchema>;\nexport type AgentTelemetryInput = z.input<typeof agentTelemetrySchema>;\n","import { isPublicHttpUrl, PUBLIC_HTTP_URL_ERROR } from \"../utils/safe-url\";\n\ntype ContextInput = {\n data?: Record<string, unknown>;\n ui?: Record<string, unknown>;\n};\n\nfunction resolveLinkUrl(value: string): string {\n return value.startsWith(\"http://\") || value.startsWith(\"https://\")\n ? value\n : `https://${value}`;\n}\n\nfunction widgetType(\n ui: Record<string, unknown> | undefined,\n field: string\n): string | undefined {\n const fieldUi = ui?.[field];\n if (typeof fieldUi !== \"object\" || fieldUi === null) {\n return undefined;\n }\n const widget = (fieldUi as Record<string, unknown>)[\"ui:widget\"];\n return typeof widget === \"string\" ? widget : undefined;\n}\n\nfunction validateUrlValue(value: unknown, widget: string): string | null {\n if (widget === \"image\" || widget === \"link\") {\n if (typeof value !== \"string\") {\n return PUBLIC_HTTP_URL_ERROR;\n }\n const url = widget === \"link\" ? resolveLinkUrl(value) : value;\n if (!isPublicHttpUrl(url)) {\n return PUBLIC_HTTP_URL_ERROR;\n }\n return null;\n }\n\n if (widget === \"attachments\" && Array.isArray(value)) {\n for (const item of value) {\n if (typeof item !== \"object\" || item === null) {\n continue;\n }\n const url = (item as { url?: unknown }).url;\n if (typeof url === \"string\" && !isPublicHttpUrl(resolveLinkUrl(url))) {\n return PUBLIC_HTTP_URL_ERROR;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Validates URL-bearing context widget values (image, link, attachments).\n * Returns an error message or null when valid.\n */\nexport function validateContextPublicUrls(\n context: ContextInput | undefined\n): string | null {\n if (!context?.data) {\n return null;\n }\n\n for (const [field, value] of Object.entries(context.data)) {\n const widget = widgetType(context.ui, field);\n if (!widget) {\n continue;\n }\n const error = validateUrlValue(value, widget);\n if (error) {\n return `context.data.${field}: ${error}`;\n }\n }\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAlB,IAAM,oBAAoB,oBAAI,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,kBAAkB,UAA0B;AACnD,SAAO,SAAS,YAAY,EAAE,QAAQ,YAAY,EAAE;AACtD;AAEA,SAAS,cAAc,MAAuB;AAC5C,QAAM,QAAQ,+CAA+C,KAAK,IAAI;AACtE,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC;AAC3D,MAAI,OAAO,KAAK,CAAC,UAAU,OAAO,MAAM,KAAK,KAAK,QAAQ,KAAK,QAAQ,GAAG,GAAG;AAC3E,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,GAAG,GAAG,IAAI,EAAE,IAAI;AACvB,MAAI,MAAM,UAAa,MAAM,QAAW;AACtC,WAAO;AAAA,EACT;AACA,MAA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0B,EAAE,IAAIH,qBAAoB,EAAE,SAAS;AAChF,CAAC;AAEM,IAAMK,wBAAuB9B,GACjC,OAAO;AAAA,EACN,SAASA,GAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACpC,eAAeoB,gBAAe,SAAS;AAAA,EACvC,WAAWM,sBAAqB,SAAS;AAAA,EACzC,MAAMJ,iBAAgB,SAAS;AAAA,EAC/B,MAAMtB,GAAE,OAAOA,GAAE,OAAO,GAAGA,GAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACjD,MAAM6B,iBAAgB,SAAS;AACjC,CAAC,EACA;AAAA,EACC,CAAC,SAAS;AACR,UAAM,OAAO,KAAK,OAAO,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC;AACnD,WAAO,KAAK,UAAUN;AAAA,EACxB;AAAA,EACA,EAAE,SAAS,kCAAkCA,oBAAmB,QAAQ;AAC1E,EACC;AAAA,EACC,CAAC,SAAS;AACR,UAAM,OAAO,KAAK,YAAY,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC;AAC7D,WAAO,KAAK,UAAUC;AAAA,EACxB;AAAA,EACA;AAAA,IACE,SAAS,uCAAuCA,0BAAyB;AAAA,EAC3E;AACF;AAEK,IAAMO,wBAAuBrB,yBACjC,OAAO;AAAA,EACN,UAAUG,gBAAe,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,UAAUb,GAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,UAAUmB,oBAAmB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtC,QAAQF,yBAAwB,SAAS;AAAA,EACzC,OAAOa,sBAAqB,SAAS;AACvC,CAAC,EACA,YAAYnB,wBAAuB;AAG/B,IAAM,yBAAyBM;","names":["z","safeUrlSchema","z","jsonSchema7Schema","uiSchemaSchema","webhookHandlerSchema","triggerHandlerSchema","handlerSchema","taskActionSchema","uiFieldSchemaSchema","contextUiSchema","contextDataSchema","taskContextObjectSchema","refineContextPublicUrls","taskContextSchema","assignToSchema","threadUpdateMessageSchema","threadUpdateStatuses","threadUpdateStatusSchema","threadUpdateInputSchema","taskPriorities","taskPrioritySchema","nonNegativeInt","agentCostTokensSchema","agentCostSchema","AGENT_INFO_MAX_KEYS","AGENT_TOOL_CALLS_MAX_KEYS","AGENT_OTEL_SPANS_MAX","agentToolCallsSchema","agentOtelSpanStatusSchema","agentOtelSpanSummarySchema","agentOtelSchema","agentTelemetrySchema","createTaskBodySchema"]}
|
|
1
|
+
{"version":3,"sources":["../../src/schemas/index.ts","../../../core/src/utils/safe-url.ts","../../../core/src/schemas/task.ts","../../../core/src/schemas/context-urls.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n isPublicHttpUrl,\n PUBLIC_HTTP_URL_ERROR,\n} from \"@robotrock/core/utils\";\nimport { validateContextPublicUrls } from \"@robotrock/core/schemas\";\n\nexport interface JSONSchema7 {\n $id?: string;\n $ref?: string;\n $schema?: string;\n $comment?: string;\n type?: JSONSchema7TypeName | JSONSchema7TypeName[];\n enum?: unknown[];\n const?: unknown;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n minimum?: number;\n exclusiveMinimum?: number;\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n format?: string;\n items?: JSONSchema7 | JSONSchema7[];\n additionalItems?: JSONSchema7 | boolean;\n maxItems?: number;\n minItems?: number;\n uniqueItems?: boolean;\n contains?: JSONSchema7;\n maxProperties?: number;\n minProperties?: number;\n required?: string[];\n properties?: Record<string, JSONSchema7>;\n patternProperties?: Record<string, JSONSchema7>;\n additionalProperties?: JSONSchema7 | boolean;\n dependencies?: Record<string, JSONSchema7 | string[]>;\n propertyNames?: JSONSchema7;\n if?: JSONSchema7;\n then?: JSONSchema7;\n else?: JSONSchema7;\n allOf?: JSONSchema7[];\n anyOf?: JSONSchema7[];\n oneOf?: JSONSchema7[];\n not?: JSONSchema7;\n title?: string;\n description?: string;\n default?: unknown;\n readOnly?: boolean;\n writeOnly?: boolean;\n examples?: unknown[];\n}\n\nexport type JSONSchema7TypeName =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\"\n | \"null\";\n\nexport type ExtendedJSONSchema7 = JSONSchema7 & {\n enumNames?: string[];\n [key: string]: unknown;\n};\n\nexport type UiSchema = {\n \"ui:widget\"?: string;\n \"ui:title\"?: string;\n \"ui:description\"?: string;\n \"ui:placeholder\"?: string;\n \"ui:options\"?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\nconst safeUrlSchema = z.string().refine((url) => isPublicHttpUrl(url), {\n message: PUBLIC_HTTP_URL_ERROR,\n});\n\nconst jsonSchema7Schema = z.custom<ExtendedJSONSchema7>(\n (val) => typeof val === \"object\" && val !== null,\n { message: \"Must be a valid JSON Schema object\" }\n);\n\nconst uiSchemaSchema = z.custom<UiSchema>((val) => typeof val === \"object\" && val !== null, {\n message: \"Must be a valid UiSchema object\",\n});\n\nconst webhookHandlerSchema = z.object({\n type: z.literal(\"webhook\"),\n url: safeUrlSchema,\n headers: z.record(z.string(), 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 config without handlers — used for chat widgets and agent tool input. */\nexport const taskActionInputSchema = 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.string(), z.unknown()).optional(),\n});\n\nconst taskActionSchema = taskActionInputSchema.extend({\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.string(), z.unknown()).optional(),\n items: z.lazy(() => z.record(z.string(), uiFieldSchemaSchema)).optional(),\n })\n .passthrough();\n\nconst contextUiSchema = z.record(z.string(), uiFieldSchemaSchema).optional();\n\nconst contextDataSchema = z\n .object({\n data: z.record(z.string(), z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\n/** Task context wire format version (always `2` today). */\nexport const TASK_CONTEXT_FORMAT_VERSION = 2 as const;\nexport type TaskContextFormatVersion = typeof TASK_CONTEXT_FORMAT_VERSION;\n\nconst taskContextObjectBaseSchema = 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 contextVersion: z.literal(2).optional(),\n /** @deprecated Use `contextVersion`. Accepted on ingest only. */\n version: z.literal(2).optional(),\n actions: z.array(taskActionSchema).min(1, \"At least one action is required\"),\n});\n\nfunction normalizeTaskContextVersion<T extends { contextVersion?: 2; version?: 2 }>(\n data: T\n): Omit<T, \"version\" | \"contextVersion\"> & { contextVersion: 2 } {\n const { version: legacyVersion, contextVersion, ...rest } = data;\n return {\n ...rest,\n contextVersion: contextVersion ?? legacyVersion ?? TASK_CONTEXT_FORMAT_VERSION,\n };\n}\n\nconst taskContextObjectSchema = taskContextObjectBaseSchema.transform(\n normalizeTaskContextVersion\n);\n\nfunction refineContextPublicUrls<T extends { context?: z.infer<typeof contextDataSchema> }>(\n data: T,\n ctx: z.RefinementCtx\n) {\n const error = validateContextPublicUrls(data.context);\n if (error) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: error,\n path: [\"context\"],\n });\n }\n}\n\nexport const taskContextSchema = taskContextObjectSchema.superRefine(\n refineContextPublicUrls\n);\n\n/**\n * Assignment targets at task create (not stored in task context JSON).\n * Unknown user emails are auto-provisioned as assignee memberships (count toward seat limits).\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 agentTelemetrySchema = z.object({\n version: z.string().min(1),\n});\n\nexport const createTaskBodySchema = taskContextObjectBaseSchema\n .extend({\n assignTo: assignToSchema.optional(),\n /**\n * Groups related tasks together. When omitted, the server generates one and\n * returns it so the caller can reuse it on later tasks in the same thread.\n */\n threadId: z.string().min(1).optional(),\n /**\n * Optional thread priority. When set, applies to the whole thread and\n * overwrites any previous priority. Omit on later tasks to leave unchanged.\n */\n priority: taskPrioritySchema.optional(),\n /**\n * Optional initial status update logged against the task's thread. Shows in\n * the inbox status bar and the thread update log.\n */\n update: threadUpdateInputSchema.optional(),\n agent: agentTelemetrySchema.optional(),\n })\n .transform(normalizeTaskContextVersion)\n .superRefine(refineContextPublicUrls);\n\n/** POST /v1/threads/:threadId/updates body: a standalone thread update. */\nexport const threadUpdateBodySchema = threadUpdateInputSchema;\n\n/** Where a thread update originated. */\nexport type ThreadUpdateSource = \"api\" | \"task_create\" | \"dashboard\";\n\n/** Lifecycle status carried by a thread update. */\nexport type ThreadUpdateStatus = (typeof threadUpdateStatuses)[number];\n\n/** A logged thread update as returned by the API. */\nexport interface ThreadUpdate {\n id: string;\n threadId: string;\n message: string;\n status: ThreadUpdateStatus;\n source: ThreadUpdateSource;\n createdAt: number;\n}\n\nexport type AssignToInput = z.infer<typeof assignToSchema>;\nexport type CreateTaskBodyInput = z.input<typeof createTaskBodySchema>;\nexport type CreateTaskBody = z.output<typeof createTaskBodySchema>;\nexport type ThreadUpdateBodyInput = z.input<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateBody = z.output<typeof threadUpdateBodySchema>;\nexport type ThreadUpdateInput = z.input<typeof threadUpdateInputSchema>;\nexport type TaskContextInput = z.input<typeof taskContextSchema>;\nexport type TaskContextOutput = z.output<typeof taskContextSchema>;\nexport type TaskContext = TaskContextOutput;\nexport type TaskActionInput = z.infer<typeof taskActionInputSchema>;\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 AgentTelemetry = z.infer<typeof agentTelemetrySchema>;\nexport type AgentTelemetryInput = z.input<typeof agentTelemetrySchema>;\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","const BLOCKED_HOSTNAMES = new Set([\n \"localhost\",\n \"metadata.google.internal\",\n \"metadata.goog\",\n]);\n\nfunction normalizeHostname(hostname: string): string {\n return hostname.toLowerCase().replace(/^\\[|\\]$/g, \"\");\n}\n\nfunction isBlockedIpv4(host: string): boolean {\n const match = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(host);\n if (!match) {\n return false;\n }\n\n const octets = match.slice(1, 5).map((part) => Number(part));\n if (octets.some((octet) => Number.isNaN(octet) || octet < 0 || octet > 255)) {\n return true;\n }\n\n const [a, b, _c, _d] = octets;\n if (a === undefined || b === undefined) {\n return true;\n }\n if (a === 127 || a === 0) return true;\n if (a === 10) return true;\n if (a === 169 && b === 254) return true;\n if (a === 192 && b === 168) return true;\n if (a === 172 && b >= 16 && b <= 31) return true;\n if (a === 100 && b >= 64 && b <= 127) return true;\n\n return false;\n}\n\nfunction ipv4FromNumericHost(host: string): string | null {\n if (/^\\d+$/.test(host)) {\n const num = Number(host);\n if (!Number.isFinite(num) || num < 0 || num > 0xffffffff) {\n return null;\n }\n const a = (num >>> 24) & 0xff;\n const b = (num >>> 16) & 0xff;\n const c = (num >>> 8) & 0xff;\n const d = num & 0xff;\n return `${a}.${b}.${c}.${d}`;\n }\n\n const hexMatch = /^0x([0-9a-f]{1,8})$/i.exec(host);\n if (hexMatch) {\n const num = Number.parseInt(hexMatch[1]!, 16);\n if (!Number.isFinite(num) || num < 0 || num > 0xffffffff) {\n return null;\n }\n const a = (num >>> 24) & 0xff;\n const b = (num >>> 16) & 0xff;\n const c = (num >>> 8) & 0xff;\n const d = num & 0xff;\n return `${a}.${b}.${c}.${d}`;\n }\n\n return null;\n}\n\nfunction isBlockedIpv4Mapped(host: string): boolean {\n const mappedDotted = /^::ffff:(\\d{1,3}(?:\\.\\d{1,3}){3})$/i.exec(host);\n if (mappedDotted) {\n return isBlockedIpv4(mappedDotted[1]!);\n }\n\n const mappedHex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(host);\n if (mappedHex) {\n const high = Number.parseInt(mappedHex[1]!, 16);\n const low = Number.parseInt(mappedHex[2]!, 16);\n if (Number.isFinite(high) && Number.isFinite(low)) {\n const a = (high >> 8) & 0xff;\n const b = high & 0xff;\n const c = (low >> 8) & 0xff;\n const d = low & 0xff;\n return isBlockedIpv4(`${a}.${b}.${c}.${d}`);\n }\n }\n\n return false;\n}\n\nfunction isBlockedIpv6(host: string): boolean {\n if (host === \"::1\" || host === \"0:0:0:0:0:0:0:1\") {\n return true;\n }\n if (host.startsWith(\"fc\") || host.startsWith(\"fd\")) {\n return true;\n }\n if (host.startsWith(\"fe80:\")) {\n return true;\n }\n if (isBlockedIpv4Mapped(host)) {\n return true;\n }\n return false;\n}\n\nfunction isBlockedHostname(hostname: string): boolean {\n const host = normalizeHostname(hostname);\n if (!host) {\n return true;\n }\n if (BLOCKED_HOSTNAMES.has(host)) {\n return true;\n }\n if (host.endsWith(\".localhost\") || host.endsWith(\".local\")) {\n return true;\n }\n\n const numericIpv4 = ipv4FromNumericHost(host);\n if (numericIpv4 && isBlockedIpv4(numericIpv4)) {\n return true;\n }\n\n return isBlockedIpv4(host) || isBlockedIpv6(host);\n}\n\n/**\n * Returns true when the URL uses http(s) and targets a public, non-reserved host.\n */\nexport function isPublicHttpUrl(urlString: string): boolean {\n let url: URL;\n try {\n url = new URL(urlString);\n } catch {\n return false;\n }\n\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n return false;\n }\n if (url.username || url.password) {\n return false;\n }\n\n return !isBlockedHostname(url.hostname);\n}\n\nexport const PUBLIC_HTTP_URL_ERROR =\n \"URL must be a public http:// or https:// address\";\n\nconst FORBIDDEN_HANDLER_HEADERS = new Set([\n \"host\",\n \"connection\",\n \"content-length\",\n \"transfer-encoding\",\n \"te\",\n \"trailer\",\n \"upgrade\",\n \"proxy-authorization\",\n \"proxy-connection\",\n \"keep-alive\",\n \"x-robotrock-signature\",\n \"x-robotrock-delivery-id\",\n \"x-robotrock-delivery-attempt\",\n]);\n\n/**\n * Allow only safe custom webhook headers; blocks overrides of delivery metadata.\n */\nexport function filterHandlerHeaders(\n headers: Record<string, string> | undefined\n): Record<string, string> {\n if (!headers) {\n return {};\n }\n\n const filtered: Record<string, string> = {};\n for (const [rawKey, value] of Object.entries(headers)) {\n const key = rawKey.toLowerCase().trim();\n if (!key || FORBIDDEN_HANDLER_HEADERS.has(key)) {\n continue;\n }\n if (!/^[a-z0-9][a-z0-9._-]*$/.test(key)) {\n continue;\n }\n filtered[key] = value;\n }\n return filtered;\n}\n","import { z } from \"zod\";\nimport { isPublicHttpUrl, PUBLIC_HTTP_URL_ERROR } from \"../utils/safe-url\";\nimport { validateContextPublicUrls } from \"./context-urls\";\nimport type { JSONSchema7 } from \"./json-schema\";\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.string().refine((url) => isPublicHttpUrl(url), {\n message: PUBLIC_HTTP_URL_ERROR,\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(), 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 config without handlers — used for chat widgets and agent tool input. */\nexport const taskActionInputSchema = 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.string(), z.unknown()).optional(),\n});\n\n// Action schema with JSONSchema-based feedback and optional handlers\nconst taskActionSchema = taskActionInputSchema.extend({\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.string(), z.unknown()).optional(),\n items: z.lazy(() => z.record(z.string(), uiFieldSchemaSchema)).optional(),\n })\n .passthrough();\n\n// Context UI Schema\nconst contextUiSchema = z.record(z.string(), uiFieldSchemaSchema).optional();\n\n// Context data schema\nconst contextDataSchema = z\n .object({\n data: z.record(z.string(), z.unknown()),\n ui: contextUiSchema,\n })\n .optional();\n\nexport const TASK_CONTEXT_FORMAT_VERSION = 2 as const;\nexport type TaskContextFormatVersion = typeof TASK_CONTEXT_FORMAT_VERSION;\n\n// Main TaskContext schema\nconst taskContextObjectBaseSchema = 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 /** Task context wire format version. @default 2 */\n contextVersion: z.literal(2).optional(),\n /** @deprecated Use `contextVersion`. Accepted on ingest only. */\n version: z.literal(2).optional(),\n actions: z.array(taskActionSchema).min(1, \"At least one action is required\"),\n});\n\nfunction normalizeTaskContextVersion<T extends { contextVersion?: 2; version?: 2 }>(\n data: T\n): Omit<T, \"version\" | \"contextVersion\"> & { contextVersion: 2 } {\n const { version: legacyVersion, contextVersion, ...rest } = data;\n return {\n ...rest,\n contextVersion: contextVersion ?? legacyVersion ?? TASK_CONTEXT_FORMAT_VERSION,\n };\n}\n\nconst taskContextObjectSchema = taskContextObjectBaseSchema.transform(\n normalizeTaskContextVersion\n);\n\nfunction refineContextPublicUrls<T extends { context?: z.infer<typeof contextDataSchema> }>(\n data: T,\n ctx: z.RefinementCtx\n) {\n const error = validateContextPublicUrls(data.context);\n if (error) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: error,\n path: [\"context\"],\n });\n }\n}\n\nexport const taskContextSchema = taskContextObjectSchema.superRefine(\n refineContextPublicUrls\n);\n\n/**\n * Assignment targets at task create (not stored in task context JSON).\n * Unknown user emails are auto-provisioned as assignee memberships (count toward seat limits).\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\n/**\n * Agent release at task create (not shown in inbox reviewer UI).\n * Used for feedback analysis over deploys.\n */\nexport const agentTelemetrySchema = z.object({\n /** Agent or app version (semver, git SHA, deploy tag — caller-defined). */\n version: z.string().min(1),\n});\n\n/** POST /v1 body: task context plus optional assignment. */\nexport const createTaskBodySchema = taskContextObjectBaseSchema\n .extend({\n assignTo: assignToSchema.optional(),\n /**\n * Groups related tasks together. When omitted, the server generates one and\n * returns it so the caller can reuse it on later tasks in the same thread.\n */\n threadId: z.string().min(1).optional(),\n /**\n * Optional thread priority. When set, applies to the whole thread and\n * overwrites any previous priority. Omit on later tasks to leave unchanged.\n */\n priority: taskPrioritySchema.optional(),\n /**\n * Optional initial status update logged against the task's thread. Shows in\n * the inbox status bar and the thread update log.\n */\n update: threadUpdateInputSchema.optional(),\n /** Agent release version — not shown in inbox UI. */\n agent: agentTelemetrySchema.optional(),\n })\n .transform(normalizeTaskContextVersion)\n .superRefine(refineContextPublicUrls);\n\n/** POST /v1/threads/:threadId/updates body: a standalone thread update. */\nexport const threadUpdateBodySchema = threadUpdateInputSchema;\n\n/** Action widget config for a seeded assistant message (mirrors the `requestActionInput` tool input). */\nexport const agentChatSeedActionSchema = z.object({\n /** Stable action id echoed back on submit; auto-derived from title when omitted. */\n id: z.string().min(1).optional(),\n title: z.string().min(1),\n description: z.string().optional(),\n /** JSON Schema object for the form fields. */\n schema: z.record(z.string(), z.unknown()).optional(),\n /** RJSF ui schema overrides (ui:widget, ui:enumNames, etc.). */\n ui: z.record(z.string(), z.unknown()).optional(),\n /** Optional default field values. */\n data: z.record(z.string(), z.unknown()).optional(),\n});\n\n/** A single pre-seeded chat message injected into a programmatic agent chat. */\nexport const agentChatSeedMessageSchema = z.object({\n role: z.enum([\"user\", \"assistant\"]),\n text: z.string().min(1),\n /** Optional display-name override for the message sender. */\n senderName: z.string().min(1).optional(),\n /**\n * Optional structured input request rendered as a styled RobotRock action\n * widget below the message text. Use this instead of asking the user to reply\n * in plain text so the request is always a proper action form.\n */\n requestActionInput: z\n .object({\n prompt: z.string().optional(),\n action: agentChatSeedActionSchema,\n })\n .optional(),\n});\n\n/**\n * POST /v1/agent-chats body: create + assign one or more agent chat sessions.\n * Either `agentIdentifier` (new chat) or `parentChatId` (spawned from a chat) is required.\n */\nexport const createAgentChatBodySchema = z\n .object({\n /** Trigger chat agent id (task slug). Required unless `parentChatId` is set. */\n agentIdentifier: z.string().min(1).optional(),\n /** Inherit tenant/connection/agent from an existing chat (agent-spawned chats). */\n parentChatId: z.string().min(1).optional(),\n /** Convex tenantTriggerConnections id; resolved from the tenant when omitted. */\n connectionId: z.string().min(1).optional(),\n /** Source application id; groups the chat under an inbox section. */\n app: z.string().min(1).optional(),\n assignTo: assignToSchema.optional(),\n title: z.string().min(1),\n messages: z.array(agentChatSeedMessageSchema).default([]),\n /** Provenance label stored on the session (\"cron\" | \"agent\" | ...). */\n source: z.string().min(1).optional(),\n })\n .refine((data) => Boolean(data.agentIdentifier || data.parentChatId), {\n message: \"Provide either agentIdentifier or parentChatId\",\n });\n\n/** POST /v1/agent-chats/transport body: store a backend-minted public token. */\nexport const agentChatTransportBodySchema = z.object({\n chatId: z.string().min(1),\n publicAccessToken: z.string().min(1),\n lastEventId: z.string().optional(),\n isStreaming: z.boolean().optional(),\n});\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\n// Type exports\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 AgentChatSeedAction = z.output<typeof agentChatSeedActionSchema>;\nexport type AgentChatSeedMessage = z.output<typeof agentChatSeedMessageSchema>;\nexport type CreateAgentChatBodyInput = z.input<typeof createAgentChatBodySchema>;\nexport type CreateAgentChatBody = z.output<typeof createAgentChatBodySchema>;\nexport type AgentChatTransportBody = z.output<typeof agentChatTransportBodySchema>;\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 TaskActionInput = z.infer<typeof taskActionInputSchema>;\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>;\nexport type AgentTelemetry = z.infer<typeof agentTelemetrySchema>;\nexport type AgentTelemetryInput = z.input<typeof agentTelemetrySchema>;\n","import { isPublicHttpUrl, PUBLIC_HTTP_URL_ERROR } from \"../utils/safe-url\";\n\ntype ContextInput = {\n data?: Record<string, unknown>;\n ui?: Record<string, unknown>;\n};\n\nfunction resolveLinkUrl(value: string): string {\n return value.startsWith(\"http://\") || value.startsWith(\"https://\")\n ? value\n : `https://${value}`;\n}\n\nfunction widgetType(\n ui: Record<string, unknown> | undefined,\n field: string\n): string | undefined {\n const fieldUi = ui?.[field];\n if (typeof fieldUi !== \"object\" || fieldUi === null) {\n return undefined;\n }\n const widget = (fieldUi as Record<string, unknown>)[\"ui:widget\"];\n return typeof widget === \"string\" ? widget : undefined;\n}\n\nfunction validateUrlValue(value: unknown, widget: string): string | null {\n if (widget === \"image\" || widget === \"link\") {\n if (typeof value !== \"string\") {\n return PUBLIC_HTTP_URL_ERROR;\n }\n const url = widget === \"link\" ? resolveLinkUrl(value) : value;\n if (!isPublicHttpUrl(url)) {\n return PUBLIC_HTTP_URL_ERROR;\n }\n return null;\n }\n\n if (widget === \"attachments\" && Array.isArray(value)) {\n for (const item of value) {\n if (typeof item !== \"object\" || item === null) {\n continue;\n }\n const url = (item as { url?: unknown }).url;\n if (typeof url === \"string\" && !isPublicHttpUrl(resolveLinkUrl(url))) {\n return PUBLIC_HTTP_URL_ERROR;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Validates URL-bearing context widget values (image, link, attachments).\n * Returns an error message or null when valid.\n */\nexport function validateContextPublicUrls(\n context: ContextInput | undefined\n): string | null {\n if (!context?.data) {\n return null;\n }\n\n for (const [field, value] of Object.entries(context.data)) {\n const widget = widgetType(context.ui, field);\n if (!widget) {\n continue;\n }\n const error = validateUrlValue(value, widget);\n if (error) {\n return `context.data.${field}: ${error}`;\n }\n }\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAlB,IAAM,oBAAoB,oBAAI,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,kBAAkB,UAA0B;AACnD,SAAO,SAAS,YAAY,EAAE,QAAQ,YAAY,EAAE;AACtD;AAEA,SAAS,cAAc,MAAuB;AAC5C,QAAM,QAAQ,+CAA+C,KAAK,IAAI;AACtE,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC;AAC3D,MAAI,OAAO,KAAK,CAAC,UAAU,OAAO,MAAM,KAAK,KAAK,QAAQ,KAAK,QAAQ,GAAG,GAAG;AAC3E,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,GAAG,GAAG,IAAI,EAAE,IAAI;AACvB,MAAI,MAAM,UAAa,MAAM,QAAW;AACtC,WAAO;AAAA,EACT;AACA,MAAI,MAAM,OAAO,MAAM,EAAG,QAAO;AACjC,MAAI,MAAM,GAAI,QAAO;AACrB,MAAI,MAAM,OAAO,MAAM,IAAK,QAAO;AACnC,MAAI,MAAM,OAAO,MAAM,IAAK,QAAO;AACnC,MAAI,MAAM,OAAO,KAAK,MAAM,KAAK,GAAI,QAAO;AAC5C,MAAI,MAAM,OAAO,KAAK,MAAM,KAAK,IAAK,QAAO;AAE7C,SAAO;AACT;AAEA,SAAS,oBAAoB,MAA6B;AACxD,MAAI,QAAQ,KAAK,IAAI,GAAG;AACtB,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,OAAO,SAAS,GAAG,KAAK,MAAM,KAAK,MAAM,YAAY;AACxD,aAAO;AAAA,IACT;AACA,UAAM,IAAK,QAAQ,KAAM;AACzB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B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAMC,4BAA2BpB,GAAE,KAAKmB,qBAAoB;AAG5D,IAAM,+BAAmD;AAGzD,IAAME,2BAA0BrB,GAAE,OAAO;AAAA,EAC9C,SAASkB;AAAA,EACT,QAAQE,0BAAyB,SAAS;AAC5C,CAAC;AAGM,IAAME,kBAAiB,CAAC,OAAO,UAAU,QAAQ,QAAQ;AAEzD,IAAMC,sBAAqBvB,GAAE,KAAKsB,eAAc;AAIhD,IAAM,wBAAsC;AAE5C,IAAM,uBAAqC;AAE3C,IAAM,qBAAmD;AAAA,EAC9D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;AAEO,IAAME,wBAAuBxB,GAAE,OAAO;AAAA,EAC3C,SAASA,GAAE,OAAO,EAAE,IAAI,CAAC;AAC3B,CAAC;AAEM,IAAMyB,wBAAuBb,6BACjC,OAAO;AAAA,EACN,UAAUK,gBAAe,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,UAAUjB,GAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,UAAUuB,oBAAmB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtC,QAAQF,yBAAwB,SAAS;AAAA,EACzC,OAAOG,sBAAqB,SAAS;AACvC,CAAC,EACA,UAAUX,4BAA2B,EACrC,YAAYE,wBAAuB;AAG/B,IAAM,yBAAyBM;","names":["z","safeUrlSchema","z","jsonSchema7Schema","uiSchemaSchema","webhookHandlerSchema","triggerHandlerSchema","handlerSchema","taskActionInputSchema","taskActionSchema","uiFieldSchemaSchema","contextUiSchema","contextDataSchema","TASK_CONTEXT_FORMAT_VERSION","taskContextObjectBaseSchema","normalizeTaskContextVersion","taskContextObjectSchema","refineContextPublicUrls","taskContextSchema","assignToSchema","threadUpdateMessageSchema","threadUpdateStatuses","threadUpdateStatusSchema","threadUpdateInputSchema","taskPriorities","taskPrioritySchema","agentTelemetrySchema","createTaskBodySchema"]}
|