robotrock 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { TaskContextInput, AssignToInput, TaskPriority, ThreadUpdateStatus, AgentTelemetryInput, TaskResponse, DiscriminatedApprovalResult, Task, ThreadUpdate } from './schemas/index.js';
1
+ import { TaskContextFormatVersion, TaskContextInput, AssignToInput, TaskPriority, ThreadUpdateStatus, TaskResponse, DiscriminatedApprovalResult, Task, ThreadUpdate } from './schemas/index.js';
2
2
 
3
3
  type RobotRockWebhookConfig = {
4
4
  url: string;
@@ -14,6 +14,11 @@ interface RobotRockPollingOptions {
14
14
  */
15
15
  timeoutMs?: number;
16
16
  }
17
+ /** Advanced client settings rarely changed by integrators. */
18
+ type RobotRockAdvancedConfig = {
19
+ /** Task context wire format version sent on every request. @default 2 */
20
+ contextVersion?: TaskContextFormatVersion;
21
+ };
17
22
  type RobotRockClientBaseConfig = {
18
23
  /** Optional override for API key. Falls back to ROBOTROCK_API_KEY. */
19
24
  apiKey?: string;
@@ -28,10 +33,12 @@ type RobotRockClientBaseConfig = {
28
33
  */
29
34
  app?: string;
30
35
  /**
31
- * Task context format version sent on every `sendToHuman` request.
32
- * @default 2
36
+ * Agent release version (semver, git SHA, deploy tag).
37
+ * Defaults to `AGENT_VERSION` or `ROBOTROCK_AGENT_VERSION` from env when omitted.
33
38
  */
34
- version?: 2;
39
+ version?: string;
40
+ /** Advanced settings (context wire format, etc.). */
41
+ advanced?: RobotRockAdvancedConfig;
35
42
  };
36
43
  /** Client config with a webhook (mutually exclusive with `polling`). */
37
44
  type RobotRockWebhookClientConfig = RobotRockClientBaseConfig & {
@@ -46,7 +53,7 @@ type RobotRockPollingClientConfig = RobotRockClientBaseConfig & {
46
53
  type RobotRockConfig = RobotRockWebhookClientConfig | RobotRockPollingClientConfig;
47
54
  type SendToHumanActionInput = Omit<TaskContextInput["actions"][number], "handlers">;
48
55
  type SendToHumanValidUntil = Date | string;
49
- type SendToHumanInput<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = Omit<TaskContextInput, "app" | "actions" | "version" | "validUntil"> & {
56
+ type SendToHumanInput<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = Omit<TaskContextInput, "app" | "actions" | "contextVersion" | "version" | "validUntil"> & {
50
57
  actions: A;
51
58
  /** Task deadline; serialized to an ISO 8601 string on the wire. */
52
59
  validUntil?: SendToHumanValidUntil;
@@ -75,10 +82,10 @@ type SendToHumanInput<A extends readonly SendToHumanActionInput[] = readonly Sen
75
82
  status?: ThreadUpdateStatus;
76
83
  };
77
84
  /**
78
- * Agent telemetry (version, cost, tool calls) not shown in inbox UI.
85
+ * Agent release version override. When omitted, uses the client `version`.
79
86
  * Used for statistics and feedback analysis.
80
87
  */
81
- agent?: AgentTelemetryInput;
88
+ version?: string;
82
89
  };
83
90
  type SendToHumanWithAppInput<A extends readonly SendToHumanActionInput[] = readonly SendToHumanActionInput[]> = (SendToHumanInput<A> | Readonly<SendToHumanInput<A>>) & {
84
91
  /** Inbox app bucket. Overrides the client `app` when set. */
@@ -111,7 +118,8 @@ declare class RobotRock {
111
118
  private readonly apiKey;
112
119
  private readonly baseUrl;
113
120
  private readonly app?;
114
- private readonly version;
121
+ private readonly agentVersion?;
122
+ private readonly contextVersion;
115
123
  private readonly webhook?;
116
124
  private readonly polling;
117
125
  constructor(config: RobotRockConfig);
@@ -134,4 +142,4 @@ declare class RobotRock {
134
142
  declare function createClient(config: RobotRockConfig): RobotRock;
135
143
  declare function attachWebhookToActions(actions: readonly SendToHumanActionInput[], webhook: RobotRockWebhookConfig): TaskContextInput["actions"];
136
144
 
137
- export { RobotRock as R, type SendToHumanActionInput as S, type SendToHumanInput as a, type RobotRockConfig as b, RobotRockError as c, type RobotRockPollingClientConfig as d, type RobotRockPollingOptions as e, type RobotRockWebhookClientConfig as f, type RobotRockWebhookConfig as g, type SendToHumanResult as h, type SendToHumanValidUntil as i, type SendUpdateInput as j, attachWebhookToActions as k, createClient as l };
145
+ export { RobotRock as R, type SendToHumanActionInput as S, type SendToHumanInput as a, type RobotRockConfig as b, type RobotRockAdvancedConfig as c, RobotRockError as d, type RobotRockPollingClientConfig as e, type RobotRockPollingOptions as f, type RobotRockWebhookClientConfig as g, type RobotRockWebhookConfig as h, type SendToHumanResult as i, type SendToHumanValidUntil as j, type SendUpdateInput as k, attachWebhookToActions as l, createClient as m };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { R as RobotRock, b as RobotRockConfig } from './client-D-XEBOWd.js';
2
- export { c as RobotRockError, d as RobotRockPollingClientConfig, e as RobotRockPollingOptions, f as RobotRockWebhookClientConfig, g as RobotRockWebhookConfig, S as SendToHumanActionInput, a as SendToHumanInput, h as SendToHumanResult, i as SendToHumanValidUntil, j as SendUpdateInput, k as attachWebhookToActions, l as createClient } from './client-D-XEBOWd.js';
1
+ import { R as RobotRock, b as RobotRockConfig } from './client-Cy7YLxms.js';
2
+ export { c as RobotRockAdvancedConfig, d as RobotRockError, e as RobotRockPollingClientConfig, f as RobotRockPollingOptions, g as RobotRockWebhookClientConfig, h as RobotRockWebhookConfig, S as SendToHumanActionInput, a as SendToHumanInput, i as SendToHumanResult, j as SendToHumanValidUntil, k as SendUpdateInput, l as attachWebhookToActions, m as createClient } from './client-Cy7YLxms.js';
3
3
  import { Task, DiscriminatedApprovalResult } from './schemas/index.js';
4
- export { AGENT_OTEL_SPANS_MAX, AgentCost, AgentCostTokens, AgentOtel, AgentOtelSpanStatus, AgentOtelSpanSummary, AgentTelemetry, AgentTelemetryInput, AgentToolCalls, ApprovalResult, AssignToInput, CreateTaskBody, CreateTaskBodyInput, DEFAULT_TASK_PRIORITY, DEFAULT_THREAD_UPDATE_STATUS, Handler, InferActionData, LOWEST_TASK_PRIORITY, TASK_PRIORITY_RANK, TaskAction, TaskContext, TaskContextInput, TaskPriority, TaskResponse, TaskResult, TaskStatus, ThreadUpdate, ThreadUpdateBody, ThreadUpdateBodyInput, ThreadUpdateInput, ThreadUpdateResponse, ThreadUpdateSource, ThreadUpdateStatus, TriggerHandler, TupleElementIndices, WebhookHandler, agentCostSchema, agentCostTokensSchema, agentOtelSchema, agentOtelSpanStatusSchema, agentOtelSpanSummarySchema, agentTelemetrySchema, agentToolCallsSchema, assignToSchema, createTaskBodySchema, taskContextSchema, taskPriorities, taskPrioritySchema, threadUpdateBodySchema, threadUpdateInputSchema, threadUpdateStatusSchema, threadUpdateStatuses } from './schemas/index.js';
4
+ export { AgentTelemetry, AgentTelemetryInput, ApprovalResult, AssignToInput, CreateTaskBody, CreateTaskBodyInput, DEFAULT_TASK_PRIORITY, DEFAULT_THREAD_UPDATE_STATUS, Handler, InferActionData, LOWEST_TASK_PRIORITY, TASK_CONTEXT_FORMAT_VERSION, TASK_PRIORITY_RANK, TaskAction, TaskContext, TaskContextFormatVersion, TaskContextInput, TaskPriority, TaskResponse, TaskResult, TaskStatus, ThreadUpdate, ThreadUpdateBody, ThreadUpdateBodyInput, ThreadUpdateInput, ThreadUpdateResponse, ThreadUpdateSource, ThreadUpdateStatus, TriggerHandler, TupleElementIndices, WebhookHandler, agentTelemetrySchema, assignToSchema, createTaskBodySchema, taskContextSchema, taskPriorities, taskPrioritySchema, threadUpdateBodySchema, threadUpdateInputSchema, threadUpdateStatusSchema, threadUpdateStatuses } from './schemas/index.js';
5
5
  import { z } from 'zod';
6
- export { R as RobotRockHandlerWebhookPayload } from './handler-webhook-BqEi6Bk-.js';
7
- export { AgentTelemetryFromOtelOptions, OtelSpanLike, OtelSpanSummaryInput, agentTelemetryFromOtel, toolCallsFromOtelSpans } from './otel/index.js';
6
+ export { E as EndRobotRockHumanWaitSpanOptions, b as RobotRockCreatedTask, c as RobotRockHandledOtelInput, a as RobotRockHandlerWebhookPayload, d as RobotRockHumanWaitOtelSession, e as RobotRockOtelHandle, f as RobotRockOtelRecordOptions, R as RobotRockPlatformOtelFields, g as beginRobotRockHumanWaitOtel, h as captureRobotRockOtelHandle, i as endRobotRockHumanWaitSpan, j as finishRobotRockHumanWaitOtel, r as recordRobotRockHandledToOtel, s as shouldRecordRobotRockOtel, k as startRobotRockHumanWaitSpan, l as stripPlatformOtelFields, t as toRobotRockHandledOtelInput } from './otel-platform-DzHyHkGk.js';
7
+ import '@opentelemetry/api';
8
8
 
9
9
  /**
10
10
  * Read RobotRock client config from environment variables.
@@ -32,7 +32,73 @@ declare function toDiscriminatedApprovalResult<A extends readonly {
32
32
  schema?: unknown;
33
33
  }[]>(actions: A, task: Task): DiscriminatedApprovalResult<A>;
34
34
 
35
- declare const robotRockWebhookPayloadSchema: z.ZodObject<{
35
+ /**
36
+ * Reserved inbox actions that reviewers can take outside your task's defined actions.
37
+ * Agents and integrations must treat these as terminal — stop the run and do not retry sendToHuman.
38
+ */
39
+ declare const PLATFORM_MARK_DONE_ACTION_ID: "robotrock:mark-done";
40
+ declare const PLATFORM_REJECT_REQUEST_ACTION_ID: "robotrock:reject-request";
41
+ declare const PLATFORM_MARK_DONE_ACTION_TITLE = "Mark as done";
42
+ declare const PLATFORM_REJECT_REQUEST_ACTION_TITLE = "Reject request";
43
+ declare const PLATFORM_TERMINAL_ACTION_IDS: readonly ["robotrock:mark-done", "robotrock:reject-request"];
44
+ type PlatformTerminalActionId = (typeof PLATFORM_TERMINAL_ACTION_IDS)[number];
45
+ type PlatformRejectRequestData = {
46
+ feedback: string;
47
+ };
48
+ type HandledActionInput = {
49
+ actionId: string;
50
+ data?: unknown;
51
+ handledBy?: string;
52
+ handledAt?: number | Date;
53
+ };
54
+ type PlatformMarkDoneOutcome = {
55
+ source: "platform";
56
+ kind: "mark-done";
57
+ actionId: typeof PLATFORM_MARK_DONE_ACTION_ID;
58
+ data: Record<string, never>;
59
+ handledBy?: string;
60
+ handledAt?: Date;
61
+ };
62
+ type PlatformRejectRequestOutcome = {
63
+ source: "platform";
64
+ kind: "reject-request";
65
+ actionId: typeof PLATFORM_REJECT_REQUEST_ACTION_ID;
66
+ data: PlatformRejectRequestData;
67
+ handledBy?: string;
68
+ handledAt?: Date;
69
+ };
70
+ type TaskActionOutcome = {
71
+ source: "task";
72
+ actionId: string;
73
+ data: unknown;
74
+ handledBy?: string;
75
+ handledAt?: Date;
76
+ };
77
+ type HandledOutcome = PlatformMarkDoneOutcome | PlatformRejectRequestOutcome | TaskActionOutcome;
78
+ declare class PlatformRejectRequestError extends Error {
79
+ readonly actionId: "robotrock:reject-request";
80
+ readonly feedback: string;
81
+ constructor(feedback: string, message?: string);
82
+ }
83
+ declare function isPlatformMarkDoneAction(actionId: string | undefined): actionId is typeof PLATFORM_MARK_DONE_ACTION_ID;
84
+ declare function isPlatformRejectRequestAction(actionId: string | undefined): actionId is typeof PLATFORM_REJECT_REQUEST_ACTION_ID;
85
+ declare function isPlatformTerminalAction(actionId: string | undefined): actionId is PlatformTerminalActionId;
86
+ declare function parsePlatformRejectRequestData(data: unknown): PlatformRejectRequestData | null;
87
+ /**
88
+ * Classify a handled task action as a platform terminal outcome or a normal task action.
89
+ */
90
+ declare function parseHandledOutcome(input: HandledActionInput): HandledOutcome;
91
+ /**
92
+ * Throw when a human rejected the request from the inbox (not your task's reject action).
93
+ * Use after polling, webhooks, or getTask when you want agents to stop immediately.
94
+ */
95
+ declare function assertNotPlatformRejectRequest(actionId: string, data?: unknown): void;
96
+ /**
97
+ * Returns true when the agent should stop — platform mark-done or reject-request.
98
+ */
99
+ declare function shouldStopAgentForHandledAction(actionId: string | undefined): boolean;
100
+
101
+ declare const robotRockWebhookPayloadBodySchema: z.ZodObject<{
36
102
  taskId: z.ZodString;
37
103
  action: z.ZodObject<{
38
104
  id: z.ZodString;
@@ -42,15 +108,16 @@ declare const robotRockWebhookPayloadSchema: z.ZodObject<{
42
108
  handledBy: z.ZodOptional<z.ZodString>;
43
109
  handledAt: z.ZodString;
44
110
  handlerType: z.ZodString;
45
- headers: z.ZodRecord<z.ZodString, z.ZodString>;
46
111
  }, z.core.$strip>;
112
+ type RobotRockWebhookPayload = z.infer<typeof robotRockWebhookPayloadBodySchema> & {
113
+ headers: Record<string, string>;
114
+ };
47
115
  type RobotRockWebhookErrorCode = "MISSING_WEBHOOK_SECRET" | "MISSING_SIGNATURE" | "INVALID_SIGNATURE" | "INVALID_JSON" | "INVALID_PAYLOAD";
48
116
  declare class RobotRockWebhookError extends Error {
49
117
  readonly code: RobotRockWebhookErrorCode;
50
118
  readonly details?: unknown | undefined;
51
119
  constructor(message: string, code: RobotRockWebhookErrorCode, details?: unknown | undefined);
52
120
  }
53
- type RobotRockWebhookPayload = z.infer<typeof robotRockWebhookPayloadSchema>;
54
121
  interface VerifyRobotRockWebhookOptions {
55
122
  /**
56
123
  * Override shared secret (defaults to ROBOTROCK_WEBHOOK_SECRET).
@@ -71,4 +138,4 @@ interface VerifyRobotRockWebhookOptions {
71
138
  */
72
139
  declare function verifyRobotRockWebhook(request: Request, options?: VerifyRobotRockWebhookOptions): Promise<RobotRockWebhookPayload>;
73
140
 
74
- export { DiscriminatedApprovalResult, RobotRock, RobotRockConfig, RobotRockWebhookError, type RobotRockWebhookErrorCode, type RobotRockWebhookPayload, Task, TaskExpiredError, TaskTimeoutError, type VerifyRobotRockWebhookOptions, resolveRobotRockClient, resolveRobotRockConfig, toDiscriminatedApprovalResult, verifyRobotRockWebhook };
141
+ export { DiscriminatedApprovalResult, type HandledActionInput, type HandledOutcome, PLATFORM_MARK_DONE_ACTION_ID, PLATFORM_MARK_DONE_ACTION_TITLE, PLATFORM_REJECT_REQUEST_ACTION_ID, PLATFORM_REJECT_REQUEST_ACTION_TITLE, PLATFORM_TERMINAL_ACTION_IDS, type PlatformMarkDoneOutcome, type PlatformRejectRequestData, PlatformRejectRequestError, type PlatformRejectRequestOutcome, type PlatformTerminalActionId, RobotRock, RobotRockConfig, RobotRockWebhookError, type RobotRockWebhookErrorCode, type RobotRockWebhookPayload, Task, type TaskActionOutcome, TaskExpiredError, TaskTimeoutError, type VerifyRobotRockWebhookOptions, assertNotPlatformRejectRequest, isPlatformMarkDoneAction, isPlatformRejectRequestAction, isPlatformTerminalAction, parseHandledOutcome, parsePlatformRejectRequestData, resolveRobotRockClient, resolveRobotRockConfig, shouldStopAgentForHandledAction, toDiscriminatedApprovalResult, verifyRobotRockWebhook };