robotrock 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/dist/ai/index.js +33 -4
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/trigger.js +33 -4
- package/dist/ai/trigger.js.map +1 -1
- package/dist/ai/workflow.js +33 -4
- package/dist/ai/workflow.js.map +1 -1
- package/dist/index.d.ts +69 -2
- package/dist/index.js +249 -2
- package/dist/index.js.map +1 -1
- package/dist/otel/index.d.ts +49 -0
- package/dist/otel/index.js +633 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/schemas/index.d.ts +56 -1
- package/dist/schemas/index.js +35 -2
- package/dist/schemas/index.js.map +1 -1
- package/dist/trigger/index.js +31 -2
- package/dist/trigger/index.js.map +1 -1
- package/dist/workflow/index.js +31 -2
- package/dist/workflow/index.js.map +1 -1
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -186,6 +186,9 @@ await robotrock.cancelTask("task_...");
|
|
|
186
186
|
import {
|
|
187
187
|
verifyRobotRockWebhook,
|
|
188
188
|
RobotRockWebhookError,
|
|
189
|
+
isPlatformTerminalAction,
|
|
190
|
+
isPlatformRejectRequestAction,
|
|
191
|
+
parsePlatformRejectRequestData,
|
|
189
192
|
type RobotRockWebhookPayload,
|
|
190
193
|
} from "robotrock";
|
|
191
194
|
|
|
@@ -193,6 +196,19 @@ export async function POST(request: Request) {
|
|
|
193
196
|
try {
|
|
194
197
|
const payload: RobotRockWebhookPayload = await verifyRobotRockWebhook(request);
|
|
195
198
|
console.log(payload.action.id, payload.headers["x-request-id"]);
|
|
199
|
+
|
|
200
|
+
// Always stop the agent for inbox platform actions (not your task's approve/reject ids)
|
|
201
|
+
if (isPlatformRejectRequestAction(payload.action.id)) {
|
|
202
|
+
const { feedback } = parsePlatformRejectRequestData(payload.action.data) ?? {
|
|
203
|
+
feedback: "",
|
|
204
|
+
};
|
|
205
|
+
// log and abort — do not continue the workflow
|
|
206
|
+
return Response.json({ ok: true, stopped: true, feedback });
|
|
207
|
+
}
|
|
208
|
+
if (isPlatformTerminalAction(payload.action.id)) {
|
|
209
|
+
return Response.json({ ok: true, stopped: true });
|
|
210
|
+
}
|
|
211
|
+
|
|
196
212
|
return Response.json({ ok: true });
|
|
197
213
|
} catch (error) {
|
|
198
214
|
if (error instanceof RobotRockWebhookError) {
|
|
@@ -203,6 +219,46 @@ export async function POST(request: Request) {
|
|
|
203
219
|
}
|
|
204
220
|
```
|
|
205
221
|
|
|
222
|
+
## Platform terminal actions
|
|
223
|
+
|
|
224
|
+
Reviewers can close a task from the inbox **without** choosing one of your defined actions. These reserved `action.id` values arrive on webhooks, polling, and `getTask()` — **always stop your agent** when you see them:
|
|
225
|
+
|
|
226
|
+
| Constant | Action ID | Meaning |
|
|
227
|
+
|----------|-----------|---------|
|
|
228
|
+
| `PLATFORM_MARK_DONE_ACTION_ID` | `robotrock:mark-done` | Closed manually; `data` is `{}` |
|
|
229
|
+
| `PLATFORM_REJECT_REQUEST_ACTION_ID` | `robotrock:reject-request` | Bad request; `data.feedback` is required |
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import {
|
|
233
|
+
isPlatformTerminalAction,
|
|
234
|
+
parseHandledOutcome,
|
|
235
|
+
assertNotPlatformRejectRequest,
|
|
236
|
+
shouldStopAgentForHandledAction,
|
|
237
|
+
} from "robotrock";
|
|
238
|
+
|
|
239
|
+
const result = await robotrock.sendToHuman({ ... });
|
|
240
|
+
|
|
241
|
+
if (result.mode === "handled") {
|
|
242
|
+
assertNotPlatformRejectRequest(result.actionId, result.data); // throws PlatformRejectRequestError
|
|
243
|
+
|
|
244
|
+
if (shouldStopAgentForHandledAction(result.actionId)) {
|
|
245
|
+
return; // mark-done or reject-request — do not continue
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const outcome = parseHandledOutcome({
|
|
249
|
+
actionId: result.actionId,
|
|
250
|
+
data: result.data,
|
|
251
|
+
handledBy: result.handledBy,
|
|
252
|
+
handledAt: result.handledAt,
|
|
253
|
+
});
|
|
254
|
+
if (outcome.source === "platform") {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
See [Platform actions](https://docs.robotrock.io/webhooks#platform-action-ids) in the docs.
|
|
261
|
+
|
|
206
262
|
## Trigger.dev
|
|
207
263
|
|
|
208
264
|
Install `@trigger.dev/sdk`, re-export SDK tasks from your `trigger/` directory, and call them with `triggerAndWait()`:
|
package/dist/ai/index.js
CHANGED
|
@@ -294,7 +294,7 @@ function refineContextPublicUrls(data, ctx) {
|
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
var safeUrlSchema, jsonSchema7Schema, uiSchemaSchema, webhookHandlerSchema, triggerHandlerSchema, handlerSchema, taskActionSchema, uiFieldSchemaSchema, contextUiSchema, contextDataSchema, taskContextObjectSchema, taskContextSchema, assignToSchema, threadUpdateMessageSchema, threadUpdateStatuses, threadUpdateStatusSchema, threadUpdateInputSchema, taskPriorities, taskPrioritySchema, nonNegativeInt, agentCostTokensSchema, agentCostSchema, AGENT_INFO_MAX_KEYS, AGENT_TOOL_CALLS_MAX_KEYS, agentToolCallsSchema, agentTelemetrySchema, createTaskBodySchema;
|
|
297
|
+
var safeUrlSchema, jsonSchema7Schema, uiSchemaSchema, webhookHandlerSchema, triggerHandlerSchema, handlerSchema, taskActionSchema, uiFieldSchemaSchema, contextUiSchema, contextDataSchema, taskContextObjectSchema, 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;
|
|
298
298
|
var init_task = __esm({
|
|
299
299
|
"../core/src/schemas/task.ts"() {
|
|
300
300
|
"use strict";
|
|
@@ -399,7 +399,20 @@ var init_task = __esm({
|
|
|
399
399
|
});
|
|
400
400
|
AGENT_INFO_MAX_KEYS = 32;
|
|
401
401
|
AGENT_TOOL_CALLS_MAX_KEYS = 64;
|
|
402
|
+
AGENT_OTEL_SPANS_MAX = 32;
|
|
402
403
|
agentToolCallsSchema = z.record(z.string().min(1), nonNegativeInt);
|
|
404
|
+
agentOtelSpanStatusSchema = z.enum(["ok", "error"]);
|
|
405
|
+
agentOtelSpanSummarySchema = z.object({
|
|
406
|
+
name: z.string().min(1),
|
|
407
|
+
durationMs: z.number().nonnegative(),
|
|
408
|
+
status: agentOtelSpanStatusSchema
|
|
409
|
+
});
|
|
410
|
+
agentOtelSchema = z.object({
|
|
411
|
+
traceId: z.string().min(1),
|
|
412
|
+
spanId: z.string().min(1).optional(),
|
|
413
|
+
rootDurationMs: z.number().nonnegative().optional(),
|
|
414
|
+
spans: z.array(agentOtelSpanSummarySchema).max(AGENT_OTEL_SPANS_MAX).optional()
|
|
415
|
+
});
|
|
403
416
|
agentTelemetrySchema = z.object({
|
|
404
417
|
/** Agent or app version (semver, git SHA, deploy tag — caller-defined). */
|
|
405
418
|
version: z.string().min(1).optional(),
|
|
@@ -409,7 +422,9 @@ var init_task = __esm({
|
|
|
409
422
|
toolCalls: agentToolCallsSchema.optional(),
|
|
410
423
|
cost: agentCostSchema.optional(),
|
|
411
424
|
/** Free-form metadata for experiments (model, prompt variant, etc.). */
|
|
412
|
-
info: z.record(z.string(), z.unknown()).optional()
|
|
425
|
+
info: z.record(z.string(), z.unknown()).optional(),
|
|
426
|
+
/** Structured OpenTelemetry span snapshot for feedback analysis. */
|
|
427
|
+
otel: agentOtelSchema.optional()
|
|
413
428
|
}).refine(
|
|
414
429
|
(data) => {
|
|
415
430
|
const keys = data.info ? Object.keys(data.info) : [];
|
|
@@ -477,7 +492,7 @@ function refineContextPublicUrls2(data, ctx) {
|
|
|
477
492
|
});
|
|
478
493
|
}
|
|
479
494
|
}
|
|
480
|
-
var safeUrlSchema2, jsonSchema7Schema2, uiSchemaSchema2, webhookHandlerSchema2, triggerHandlerSchema2, handlerSchema2, taskActionSchema2, uiFieldSchemaSchema2, contextUiSchema2, contextDataSchema2, taskContextObjectSchema2, taskContextSchema2, assignToSchema2, threadUpdateMessageSchema2, threadUpdateStatuses2, threadUpdateStatusSchema2, threadUpdateInputSchema2, taskPriorities2, taskPrioritySchema2, nonNegativeInt2, agentCostTokensSchema2, agentCostSchema2, AGENT_INFO_MAX_KEYS2, AGENT_TOOL_CALLS_MAX_KEYS2, agentToolCallsSchema2, agentTelemetrySchema2, createTaskBodySchema2, threadUpdateBodySchema;
|
|
495
|
+
var safeUrlSchema2, jsonSchema7Schema2, uiSchemaSchema2, webhookHandlerSchema2, triggerHandlerSchema2, handlerSchema2, taskActionSchema2, uiFieldSchemaSchema2, contextUiSchema2, contextDataSchema2, taskContextObjectSchema2, taskContextSchema2, assignToSchema2, threadUpdateMessageSchema2, threadUpdateStatuses2, threadUpdateStatusSchema2, threadUpdateInputSchema2, taskPriorities2, taskPrioritySchema2, nonNegativeInt2, agentCostTokensSchema2, agentCostSchema2, AGENT_INFO_MAX_KEYS2, AGENT_TOOL_CALLS_MAX_KEYS2, AGENT_OTEL_SPANS_MAX2, agentToolCallsSchema2, agentOtelSpanStatusSchema2, agentOtelSpanSummarySchema2, agentOtelSchema2, agentTelemetrySchema2, createTaskBodySchema2, threadUpdateBodySchema;
|
|
481
496
|
var init_schemas2 = __esm({
|
|
482
497
|
"src/schemas/index.ts"() {
|
|
483
498
|
"use strict";
|
|
@@ -580,13 +595,27 @@ var init_schemas2 = __esm({
|
|
|
580
595
|
});
|
|
581
596
|
AGENT_INFO_MAX_KEYS2 = 32;
|
|
582
597
|
AGENT_TOOL_CALLS_MAX_KEYS2 = 64;
|
|
598
|
+
AGENT_OTEL_SPANS_MAX2 = 32;
|
|
583
599
|
agentToolCallsSchema2 = z2.record(z2.string().min(1), nonNegativeInt2);
|
|
600
|
+
agentOtelSpanStatusSchema2 = z2.enum(["ok", "error"]);
|
|
601
|
+
agentOtelSpanSummarySchema2 = z2.object({
|
|
602
|
+
name: z2.string().min(1),
|
|
603
|
+
durationMs: z2.number().nonnegative(),
|
|
604
|
+
status: agentOtelSpanStatusSchema2
|
|
605
|
+
});
|
|
606
|
+
agentOtelSchema2 = z2.object({
|
|
607
|
+
traceId: z2.string().min(1),
|
|
608
|
+
spanId: z2.string().min(1).optional(),
|
|
609
|
+
rootDurationMs: z2.number().nonnegative().optional(),
|
|
610
|
+
spans: z2.array(agentOtelSpanSummarySchema2).max(AGENT_OTEL_SPANS_MAX2).optional()
|
|
611
|
+
});
|
|
584
612
|
agentTelemetrySchema2 = z2.object({
|
|
585
613
|
version: z2.string().min(1).optional(),
|
|
586
614
|
toolCallCount: nonNegativeInt2.optional(),
|
|
587
615
|
toolCalls: agentToolCallsSchema2.optional(),
|
|
588
616
|
cost: agentCostSchema2.optional(),
|
|
589
|
-
info: z2.record(z2.string(), z2.unknown()).optional()
|
|
617
|
+
info: z2.record(z2.string(), z2.unknown()).optional(),
|
|
618
|
+
otel: agentOtelSchema2.optional()
|
|
590
619
|
}).refine(
|
|
591
620
|
(data) => {
|
|
592
621
|
const keys = data.info ? Object.keys(data.info) : [];
|