@hachej/boring-agent 0.1.79 → 0.1.81

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,13 +1,15 @@
1
1
  import {
2
2
  AgentDefinitionValidationError,
3
3
  AgentDeploymentValidationError,
4
+ OpaqueRefSchema,
5
+ Sha256DigestSchema,
4
6
  createAgentAssetDigest,
5
7
  createAgentDefinitionDigest,
6
8
  createAgentDeploymentDigest,
7
9
  validateAgentDefinition,
8
10
  validateAgentDeployment,
9
11
  validateTool
10
- } from "../chunk-Q42DWR3T.js";
12
+ } from "../chunk-S2HYQYJP.js";
11
13
  import {
12
14
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
13
15
  AgentNotImplementedError,
@@ -44,12 +46,13 @@ import {
44
46
  extractToolUiMetadata,
45
47
  isToolUiMetadata,
46
48
  sanitizeToolUiMetadata2 as sanitizeToolUiMetadata
47
- } from "../chunk-P23XFC4W.js";
49
+ } from "../chunk-3RSYCAHO.js";
48
50
  import {
49
51
  noopTelemetry,
50
52
  safeCapture
51
53
  } from "../chunk-AQBXNPMD.js";
52
54
  import {
55
+ AgentConsumptionErrorCode,
53
56
  AgentDefinitionErrorCode,
54
57
  AgentDeploymentErrorCode,
55
58
  ApiErrorPayloadSchema,
@@ -57,7 +60,7 @@ import {
57
60
  ERROR_CODES,
58
61
  ErrorCode,
59
62
  ErrorLogFieldsSchema
60
- } from "../chunk-YVON2BHN.js";
63
+ } from "../chunk-YV6D7GCQ.js";
61
64
 
62
65
  // src/shared/config-schema.ts
63
66
  import { z } from "zod";
@@ -122,15 +125,166 @@ var PI_AGENT_RUNTIME_CAPABILITIES = {
122
125
  nativeFollowUp: true,
123
126
  aiSdkOwnsHistory: false
124
127
  };
128
+
129
+ // src/shared/agent-consumption.ts
130
+ import { z as z2 } from "zod";
131
+ var nonEmptyString = z2.string().min(1);
132
+ var TASK_STATES = [
133
+ "submitted",
134
+ "working",
135
+ "input-required",
136
+ "completed",
137
+ "failed",
138
+ "canceled",
139
+ "rejected"
140
+ ];
141
+ var TaskStateSchema = z2.enum(TASK_STATES);
142
+ var TASK_TRANSITIONS = {
143
+ submitted: ["working", "rejected", "canceled"],
144
+ working: ["input-required", "completed", "failed", "canceled", "rejected"],
145
+ "input-required": ["working", "canceled"],
146
+ completed: [],
147
+ failed: [],
148
+ canceled: [],
149
+ rejected: []
150
+ };
151
+ function isValidTaskTransition(from, to) {
152
+ return TASK_TRANSITIONS[from].includes(to);
153
+ }
154
+ function assertValidTransition(from, to) {
155
+ if (!isValidTaskTransition(from, to)) {
156
+ throw new AgentConsumptionValidationError({
157
+ code: AgentConsumptionErrorCode.enum.AGENT_CONSUMPTION_INVALID_TRANSITION,
158
+ field: "state",
159
+ message: `invalid task state transition: '${from}' -> '${to}'`
160
+ });
161
+ }
162
+ }
163
+ var PrincipalRefSchema = z2.object({
164
+ userId: nonEmptyString,
165
+ workspaceId: nonEmptyString
166
+ }).strict();
167
+ var AgentRefSchema = z2.object({
168
+ agentId: nonEmptyString,
169
+ deploymentId: nonEmptyString.optional()
170
+ }).strict();
171
+ function agentRefEquals(a, b) {
172
+ return a.agentId === b.agentId && (a.deploymentId ?? null) === (b.deploymentId ?? null);
173
+ }
174
+ var ArtifactRefSchema = z2.object({
175
+ artifactId: nonEmptyString,
176
+ name: z2.string().optional(),
177
+ mimeType: nonEmptyString,
178
+ uri: nonEmptyString
179
+ }).strict();
180
+ var PartSchema = z2.discriminatedUnion("type", [
181
+ z2.object({ type: z2.literal("text"), text: z2.string() }).strict(),
182
+ z2.object({ type: z2.literal("file"), file: ArtifactRefSchema }).strict(),
183
+ z2.object({ type: z2.literal("data"), mimeType: nonEmptyString, data: z2.unknown() }).strict()
184
+ ]);
185
+ var AgentMessageSchema = z2.object({
186
+ role: z2.enum(["consumer", "agent"]),
187
+ parts: z2.array(PartSchema),
188
+ ts: nonEmptyString
189
+ }).strict();
190
+ var AgentTaskSchema = z2.object({
191
+ id: nonEmptyString,
192
+ contextId: nonEmptyString,
193
+ state: TaskStateSchema,
194
+ messages: z2.array(AgentMessageSchema),
195
+ artifacts: z2.array(ArtifactRefSchema),
196
+ principal: PrincipalRefSchema,
197
+ actor: AgentRefSchema.optional(),
198
+ schemaVersion: z2.literal("1"),
199
+ createdAt: nonEmptyString,
200
+ updatedAt: nonEmptyString
201
+ }).strict();
202
+ function formatIssuePath(path) {
203
+ if (path.length === 0) return "<root>";
204
+ return path.reduce(
205
+ (result, part) => typeof part === "number" ? `${result}[${part}]` : result.length === 0 ? String(part) : `${result}.${String(part)}`,
206
+ ""
207
+ );
208
+ }
209
+ function schemaMismatchIssues(issues) {
210
+ return issues.map((issue) => {
211
+ const field = formatIssuePath(issue.path);
212
+ return {
213
+ code: AgentConsumptionErrorCode.enum.AGENT_CONSUMPTION_SCHEMA_MISMATCH,
214
+ field,
215
+ message: field === "<root>" ? issue.message : `${field} ${issue.message}`
216
+ };
217
+ });
218
+ }
219
+ function validateAgentTask(raw) {
220
+ const result = AgentTaskSchema.safeParse(raw);
221
+ if (!result.success) {
222
+ return { valid: false, issues: schemaMismatchIssues(result.error.issues) };
223
+ }
224
+ return { valid: true, value: result.data };
225
+ }
226
+ var AgentConsumptionValidationError = class extends Error {
227
+ code = ErrorCode.enum.CONFIG_INVALID;
228
+ field;
229
+ validationCode;
230
+ constructor(issue) {
231
+ super(issue.message);
232
+ this.name = "AgentConsumptionValidationError";
233
+ this.field = issue.field;
234
+ this.validationCode = issue.code;
235
+ }
236
+ };
237
+ var ConsumptionGuardsSchema = z2.object({
238
+ maxDepth: z2.number().int().positive(),
239
+ inputRequiredTimeoutMs: z2.number().int().positive()
240
+ }).strict();
241
+ function validateConsumptionGuards(raw) {
242
+ const result = ConsumptionGuardsSchema.safeParse(raw);
243
+ if (!result.success) {
244
+ return { valid: false, issues: schemaMismatchIssues(result.error.issues) };
245
+ }
246
+ return { valid: true, value: result.data };
247
+ }
248
+ function detectConsumptionCycle(chain, next) {
249
+ return chain.some((ref) => agentRefEquals(ref, next));
250
+ }
251
+ function assertNoConsumptionCycle(chain, next) {
252
+ if (detectConsumptionCycle(chain, next)) {
253
+ const label = next.deploymentId ? `${next.agentId}@${next.deploymentId}` : next.agentId;
254
+ throw new AgentConsumptionValidationError({
255
+ code: AgentConsumptionErrorCode.enum.AGENT_CONSUMPTION_CYCLE_DETECTED,
256
+ field: "actor",
257
+ message: `consumption cycle detected: agent '${label}' already present in the delegation chain`
258
+ });
259
+ }
260
+ }
261
+ function isWithinConsumptionDepth(chain, guards) {
262
+ return chain.length < guards.maxDepth;
263
+ }
264
+ function assertWithinConsumptionDepth(chain, guards) {
265
+ if (!isWithinConsumptionDepth(chain, guards)) {
266
+ throw new AgentConsumptionValidationError({
267
+ code: AgentConsumptionErrorCode.enum.AGENT_CONSUMPTION_DEPTH_EXCEEDED,
268
+ field: "depth",
269
+ message: `consumption depth exceeded: chain length ${chain.length} >= max depth ${guards.maxDepth}`
270
+ });
271
+ }
272
+ }
125
273
  export {
126
274
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
275
+ AgentConsumptionErrorCode,
276
+ AgentConsumptionValidationError,
127
277
  AgentDefinitionErrorCode,
128
278
  AgentDefinitionValidationError,
129
279
  AgentDeploymentErrorCode,
130
280
  AgentDeploymentValidationError,
281
+ AgentMessageSchema,
131
282
  AgentNotImplementedError,
283
+ AgentRefSchema,
284
+ AgentTaskSchema,
132
285
  ApiErrorPayloadSchema,
133
286
  ApiErrorResponseSchema,
287
+ ArtifactRefSchema,
134
288
  BoringChatMessageSchema,
135
289
  BoringChatPartSchema,
136
290
  ChatAttachmentPayloadSchema,
@@ -138,6 +292,7 @@ export {
138
292
  ChatModelSelectionSchema,
139
293
  CommandReceiptSchema,
140
294
  ConfigSchema,
295
+ ConsumptionGuardsSchema,
141
296
  DEFAULT_AGENT_RUNTIME_CAPABILITIES,
142
297
  ERROR_CODES,
143
298
  EnvSchema,
@@ -146,35 +301,50 @@ export {
146
301
  FollowUpPayloadSchema,
147
302
  FollowUpReceiptSchema,
148
303
  InterruptPayloadSchema,
304
+ OpaqueRefSchema,
149
305
  PI_AGENT_RUNTIME_CAPABILITIES,
306
+ PartSchema,
150
307
  PiChatEventSchema,
151
308
  PiChatHeartbeatFrameSchema,
152
309
  PiChatSnapshotSchema,
153
310
  PiChatStatusSchema,
154
311
  PiChatStreamFrameSchema,
312
+ PrincipalRefSchema,
155
313
  PromptPayloadSchema,
156
314
  PromptReceiptSchema,
157
315
  QueueClearPayloadSchema,
158
316
  QueueClearReceiptSchema,
159
317
  QueuedUserMessageSchema,
160
318
  RuntimeModeSchema,
319
+ Sha256DigestSchema,
161
320
  StopPayloadSchema,
162
321
  StopReceiptSchema,
322
+ TASK_STATES,
323
+ TaskStateSchema,
163
324
  ThinkingLevelSchema,
164
325
  ToolUiMetadataSchema,
165
326
  WORKSPACE_AGENT_PLUGINS_RELOADED_EVENT,
166
327
  WORKSPACE_COMMAND_NOTIFY_EVENT,
328
+ agentRefEquals,
329
+ assertNoConsumptionCycle,
330
+ assertValidTransition,
331
+ assertWithinConsumptionDepth,
167
332
  createAgentAssetDigest,
168
333
  createAgentDefinitionDigest,
169
334
  createAgentDeploymentDigest,
335
+ detectConsumptionCycle,
170
336
  extractToolUiMetadata,
171
337
  isToolUiMetadata,
338
+ isValidTaskTransition,
339
+ isWithinConsumptionDepth,
172
340
  noopTelemetry,
173
341
  safeCapture,
174
342
  sanitizeToolUiMetadata,
175
343
  sessionStreamPath,
176
344
  validateAgentDefinition,
177
345
  validateAgentDeployment,
346
+ validateAgentTask,
178
347
  validateConfig,
348
+ validateConsumptionGuards,
179
349
  validateTool
180
350
  };
@@ -1,5 +1,6 @@
1
- import { A as AgentDefinitionErrorCode, p as AgentDeploymentErrorCode, z as InterruptReceipt, i as StopReceipt } from './piChatEvent-D0yuLiJh.js';
2
- import { p as AgentSendInput, i as AgentEvent } from './harness-DD0zj704.js';
1
+ import { z } from 'zod';
2
+ import { p as AgentDefinitionErrorCode, q as AgentDeploymentErrorCode, D as InterruptReceipt, i as StopReceipt } from './piChatEvent-DtqYMcID.js';
3
+ import { p as AgentSendInput, j as AgentEvent } from './harness-If4r1n-K.js';
3
4
 
4
5
  interface SandboxHandleRecord {
5
6
  workspaceId: string;
@@ -67,6 +68,8 @@ type AgentSchemaValidationResult<T, Code extends string> = {
67
68
  valid: false;
68
69
  issues: AgentSchemaIssue<Code>[];
69
70
  };
71
+ declare const OpaqueRefSchema: z.ZodEffects<z.ZodString, string, string>;
72
+ declare const Sha256DigestSchema: z.ZodEffects<z.ZodString, `sha256:${string}`, string>;
70
73
  declare function validateAgentDefinition(raw: unknown): AgentSchemaValidationResult<AgentDefinition, AgentDefinitionErrorCode>;
71
74
  declare function validateAgentDeployment(raw: unknown): AgentSchemaValidationResult<AgentDeployment, AgentDeploymentErrorCode>;
72
75
  declare function createAgentAssetDigest(content: string): Promise<Sha256Digest>;
@@ -143,4 +146,4 @@ interface WorkspaceAgentDispatcher {
143
146
  stop(sessionId: string): Promise<StopReceipt>;
144
147
  }
145
148
 
146
- export { type AgentDefinition as A, type CompiledAgentBundle as C, type FileSearch as F, type PluginRestartWarning as P, type SandboxHandleStore as S, type WorkspaceAgentDispatcherContext as W, type SandboxHandleRecord as a, type WorkspaceAgentDispatcher as b, type AgentDefinitionDigestAsset as c, type AgentDefinitionReference as d, AgentDefinitionValidationError as e, type AgentDeployment as f, AgentDeploymentValidationError as g, type AgentSchemaIssue as h, type AgentSchemaValidationResult as i, type CommandNotifyPayload as j, type CompiledAgentDefinition as k, type Sha256Digest as l, WORKSPACE_AGENT_PLUGINS_RELOADED_EVENT as m, WORKSPACE_COMMAND_NOTIFY_EVENT as n, type WorkspaceAgentDispatcherSendInput as o, createAgentAssetDigest as p, createAgentDefinitionDigest as q, createAgentDeploymentDigest as r, validateAgentDeployment as s, validateAgentDefinition as v };
149
+ export { type AgentDeployment as A, type CompiledAgentBundle as C, type FileSearch as F, OpaqueRefSchema as O, type PluginRestartWarning as P, type SandboxHandleStore as S, type WorkspaceAgentDispatcherContext as W, type SandboxHandleRecord as a, type Sha256Digest as b, type WorkspaceAgentDispatcher as c, type AgentSchemaIssue as d, type AgentSchemaValidationResult as e, type AgentDefinition as f, type AgentDefinitionDigestAsset as g, type AgentDefinitionReference as h, AgentDefinitionValidationError as i, AgentDeploymentValidationError as j, type CommandNotifyPayload as k, type CompiledAgentDefinition as l, Sha256DigestSchema as m, WORKSPACE_AGENT_PLUGINS_RELOADED_EVENT as n, WORKSPACE_COMMAND_NOTIFY_EVENT as o, type WorkspaceAgentDispatcherSendInput as p, createAgentAssetDigest as q, createAgentDefinitionDigest as r, createAgentDeploymentDigest as s, validateAgentDeployment as t, validateAgentDefinition as v };
@@ -61,6 +61,9 @@ All API failures must use the response envelope:
61
61
  | `TOOL_NOT_FOUND` | Requested tool name not present in catalog | 404 | user-fix | warn | stable (public API) |
62
62
  | `TOOL_INVALID_INPUT` | Tool input fails schema validation | 400 | user-fix | warn | stable (public API) |
63
63
  | `TOOL_EXECUTION_ERROR` | Tool threw or returned execution failure | 500 | report-bug | error | stable (public API) |
64
+ | `MCP_AGENT_ARTIFACT_INVALID` | Managed MCP delivery artifact is path-shaped, non-Markdown, binary, malformed UTF-8, or otherwise invalid | 400 | user-fix | warn | stable (public API) |
65
+ | `MCP_AGENT_ARTIFACT_TOO_LARGE` | Managed MCP final text, inline Markdown artifact, or serialized result exceeds the delivery v0 byte cap | 413 | user-fix | warn | stable (public API) |
66
+ | `MCP_AGENT_ARTIFACT_UNAVAILABLE` | Managed MCP artifact is missing, unreadable through the authorized workspace, or changed during read | 409 | retry | warn | stable (public API) |
64
67
  | `PLUGIN_LOAD_FAILED` | Plugin failed to load/register | 500 | report-bug | error | stable (public API) |
65
68
  | `PLUGIN_NAME_COLLISION` | Plugin name collides with existing tool/plugin | 409 | user-fix | warn | stable (public API) |
66
69
  | `PLUGIN_RUNTIME_REVISION_MISMATCH` | Browser requested a stale plugin runtime revision after reload | 409 | retry | warn | stable (public API) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hachej/boring-agent",
3
- "version": "0.1.79",
3
+ "version": "0.1.81",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Pane-embeddable coding agent. Ships direct/local/vercel-sandbox execution modes behind one interface.",
@@ -84,7 +84,7 @@
84
84
  "use-stick-to-bottom": "^1.1.6",
85
85
  "yaml": "^2.9.0",
86
86
  "zod": "^3.25.76",
87
- "@hachej/boring-ui-kit": "0.1.79"
87
+ "@hachej/boring-ui-kit": "0.1.81"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@antithesishq/bombadil": "0.6.1",