@hachej/boring-agent 0.1.80 → 0.1.82

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,6 +1,6 @@
1
1
  import {
2
2
  ErrorCode
3
- } from "./chunk-CCNXYCD5.js";
3
+ } from "./chunk-PG2WOJ22.js";
4
4
 
5
5
  // src/shared/tool-ui.ts
6
6
  function isRecord(value) {
@@ -17,6 +17,7 @@ var ErrorCode = z.enum([
17
17
  "PATH_NOT_WRITABLE",
18
18
  "WORKSPACE_UNINITIALIZED",
19
19
  "WORKSPACE_NOT_READY",
20
+ "D1_HOST_SCOPE_VIOLATION",
20
21
  // Agent runtime / provisioning
21
22
  "AGENT_RUNTIME_NOT_READY",
22
23
  "AGENT_BINDING_DISPOSED",
@@ -85,6 +86,12 @@ var AgentDeploymentErrorCode = z.enum([
85
86
  "AGENT_DEPLOYMENT_INVALID",
86
87
  "AGENT_DEPLOYMENT_UNSUPPORTED_FIELD"
87
88
  ]);
89
+ var AgentConsumptionErrorCode = z.enum([
90
+ "AGENT_CONSUMPTION_INVALID_TRANSITION",
91
+ "AGENT_CONSUMPTION_CYCLE_DETECTED",
92
+ "AGENT_CONSUMPTION_DEPTH_EXCEEDED",
93
+ "AGENT_CONSUMPTION_SCHEMA_MISMATCH"
94
+ ]);
88
95
  var ApiErrorPayloadSchema = z.object({
89
96
  code: ErrorCode,
90
97
  message: z.string().min(1),
@@ -105,6 +112,7 @@ export {
105
112
  ERROR_CODES,
106
113
  AgentDefinitionErrorCode,
107
114
  AgentDeploymentErrorCode,
115
+ AgentConsumptionErrorCode,
108
116
  ApiErrorPayloadSchema,
109
117
  ApiErrorResponseSchema,
110
118
  ErrorLogFieldsSchema
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WSQ5QNIY.js";
4
4
  import {
5
5
  ErrorCode
6
- } from "./chunk-CCNXYCD5.js";
6
+ } from "./chunk-PG2WOJ22.js";
7
7
 
8
8
  // src/core/createAgent.ts
9
9
  var DEFAULT_LIVE_BUFFER_SIZE = 1e3;
@@ -2,10 +2,75 @@ import {
2
2
  AgentDefinitionErrorCode,
3
3
  AgentDeploymentErrorCode,
4
4
  ErrorCode
5
- } from "./chunk-CCNXYCD5.js";
5
+ } from "./chunk-PG2WOJ22.js";
6
6
 
7
7
  // src/shared/agent-definition.ts
8
+ import { z as z2 } from "zod";
9
+
10
+ // src/shared/digest.ts
11
+ function toHex(bytes) {
12
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
13
+ }
14
+ async function digestBytes(bytes) {
15
+ const hash = await globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
16
+ return `sha256:${toHex(new Uint8Array(hash))}`;
17
+ }
18
+ async function sha256(value) {
19
+ return digestBytes(new TextEncoder().encode(value));
20
+ }
21
+ async function sha256Bytes(bytes) {
22
+ return digestBytes(bytes);
23
+ }
24
+ function canonicalStringify(value) {
25
+ if (value === null || typeof value !== "object") {
26
+ const encoded = JSON.stringify(value);
27
+ if (encoded === void 0) throw new TypeError("Cannot canonicalize undefined");
28
+ return encoded;
29
+ }
30
+ if (Array.isArray(value)) return `[${value.map(canonicalStringify).join(",")}]`;
31
+ const record = value;
32
+ return `{${Object.keys(record).filter((key) => record[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${canonicalStringify(record[key])}`).join(",")}}`;
33
+ }
34
+
35
+ // src/shared/schema-issue.ts
8
36
  import { z } from "zod";
37
+ function formatPath(path) {
38
+ if (path.length === 0) return "<root>";
39
+ return path.reduce(
40
+ (result, part) => typeof part === "number" ? `${result}[${part}]` : result.length === 0 ? String(part) : `${result}.${String(part)}`,
41
+ ""
42
+ );
43
+ }
44
+ function mapZodIssues(issues, invalidCode, unsupportedCode) {
45
+ return issues.flatMap((issue) => {
46
+ if (issue.code === z.ZodIssueCode.unrecognized_keys) {
47
+ const parent = formatPath(issue.path);
48
+ return [...issue.keys].sort().map((key) => ({
49
+ code: unsupportedCode,
50
+ field: parent === "<root>" ? key : `${parent}.${key}`,
51
+ message: `${key} is not supported by schema version 1`
52
+ }));
53
+ }
54
+ const field = formatPath(issue.path);
55
+ return [{
56
+ code: invalidCode,
57
+ field,
58
+ message: field === "<root>" ? issue.message : `${field} ${issue.message}`
59
+ }];
60
+ });
61
+ }
62
+ var SchemaValidationError = class extends Error {
63
+ code = ErrorCode.enum.CONFIG_INVALID;
64
+ field;
65
+ validationCode;
66
+ constructor(issue) {
67
+ super(issue.message);
68
+ this.field = issue.field;
69
+ this.validationCode = issue.code;
70
+ }
71
+ };
72
+
73
+ // src/shared/agent-definition.ts
9
74
  var SHA256_DIGEST_RE = /^sha256:[a-f0-9]{64}$/;
10
75
  function hasWellFormedUnicode(value) {
11
76
  for (let index = 0; index < value.length; index += 1) {
@@ -28,13 +93,13 @@ function isSafeAssetPath(value) {
28
93
  const segments = value.split("/");
29
94
  return hasWellFormedUnicode(value) && value.normalize("NFC") === value && !/[\0-\x1f\x7f]/.test(value) && !value.includes("\\") && !value.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(value) && !value.startsWith("./") && segments.every((segment) => segment !== "" && segment !== "." && segment !== "..");
30
95
  }
31
- var OpaqueRefSchema = z.string().min(1, "must be a non-empty reference").max(256, "must be at most 256 characters").refine(isOpaqueRef, "must be a non-empty reference");
32
- var ReferenceArraySchema = z.array(OpaqueRefSchema).superRefine((refs, ctx) => {
96
+ var OpaqueRefSchema = z2.string().min(1, "must be a non-empty reference").max(256, "must be at most 256 characters").refine(isOpaqueRef, "must be a non-empty reference");
97
+ var ReferenceArraySchema = z2.array(OpaqueRefSchema).superRefine((refs, ctx) => {
33
98
  const seen = /* @__PURE__ */ new Set();
34
99
  refs.forEach((ref, index) => {
35
100
  if (seen.has(ref)) {
36
101
  ctx.addIssue({
37
- code: z.ZodIssueCode.custom,
102
+ code: z2.ZodIssueCode.custom,
38
103
  path: [index],
39
104
  message: "must not contain duplicate references"
40
105
  });
@@ -42,60 +107,35 @@ var ReferenceArraySchema = z.array(OpaqueRefSchema).superRefine((refs, ctx) => {
42
107
  seen.add(ref);
43
108
  });
44
109
  });
45
- var SafeAssetPathSchema = z.string().min(1).refine(isSafeAssetPath, "must be a safe relative asset path");
46
- var Sha256DigestSchema = z.string().regex(SHA256_DIGEST_RE, "must be a lowercase sha256 digest").transform((value) => value);
47
- var AgentDefinitionSchema = z.object({
48
- schemaVersion: z.literal(1),
110
+ var SafeAssetPathSchema = z2.string().min(1).refine(isSafeAssetPath, "must be a safe relative asset path");
111
+ var Sha256DigestSchema = z2.string().regex(SHA256_DIGEST_RE, "must be a lowercase sha256 digest").transform((value) => value);
112
+ var AgentDefinitionSchema = z2.object({
113
+ schemaVersion: z2.literal(1),
49
114
  definitionId: OpaqueRefSchema,
50
115
  version: OpaqueRefSchema,
51
- label: z.string().refine(hasWellFormedUnicode, "must contain well-formed Unicode").optional(),
116
+ label: z2.string().refine(hasWellFormedUnicode, "must contain well-formed Unicode").optional(),
52
117
  instructionsRef: SafeAssetPathSchema,
53
118
  capabilityRequirements: ReferenceArraySchema.optional(),
54
119
  toolRefs: ReferenceArraySchema.optional(),
55
120
  skillRefs: ReferenceArraySchema.optional(),
56
121
  mcpServerRefs: ReferenceArraySchema.optional()
57
122
  }).strict();
58
- var AgentDefinitionReferenceSchema = z.object({
123
+ var AgentDefinitionReferenceSchema = z2.object({
59
124
  definitionId: OpaqueRefSchema,
60
125
  version: OpaqueRefSchema,
61
126
  digest: Sha256DigestSchema
62
127
  }).strict();
63
- var AgentDeploymentSchema = z.object({
128
+ var AgentDeploymentSchema = z2.object({
64
129
  deploymentId: OpaqueRefSchema,
65
130
  version: OpaqueRefSchema,
66
131
  agentId: OpaqueRefSchema,
67
132
  definition: AgentDefinitionReferenceSchema
68
133
  }).strict();
69
- var AgentDefinitionDigestAssetSchema = z.object({
134
+ var AgentDefinitionDigestAssetSchema = z2.object({
70
135
  path: SafeAssetPathSchema,
71
136
  digest: Sha256DigestSchema,
72
- content: z.string().refine(hasWellFormedUnicode, "must contain well-formed Unicode")
137
+ content: z2.string().refine(hasWellFormedUnicode, "must contain well-formed Unicode")
73
138
  }).strict();
74
- function formatPath(path) {
75
- if (path.length === 0) return "<root>";
76
- return path.reduce(
77
- (result, part) => typeof part === "number" ? `${result}[${part}]` : result.length === 0 ? String(part) : `${result}.${String(part)}`,
78
- ""
79
- );
80
- }
81
- function mapZodIssues(issues, invalidCode, unsupportedCode) {
82
- return issues.flatMap((issue) => {
83
- if (issue.code === z.ZodIssueCode.unrecognized_keys) {
84
- const parent = formatPath(issue.path);
85
- return [...issue.keys].sort().map((key) => ({
86
- code: unsupportedCode,
87
- field: parent === "<root>" ? key : `${parent}.${key}`,
88
- message: `${key} is not supported by schema version 1`
89
- }));
90
- }
91
- const field = formatPath(issue.path);
92
- return [{
93
- code: invalidCode,
94
- field,
95
- message: field === "<root>" ? issue.message : `${field} ${issue.message}`
96
- }];
97
- });
98
- }
99
139
  function validateAgentDefinition(raw) {
100
140
  const result = AgentDefinitionSchema.safeParse(raw);
101
141
  if (!result.success) {
@@ -124,27 +164,6 @@ function validateAgentDeployment(raw) {
124
164
  }
125
165
  return { valid: true, value: result.data };
126
166
  }
127
- function canonicalStringify(value) {
128
- if (value === null || typeof value !== "object") {
129
- const encoded = JSON.stringify(value);
130
- if (encoded === void 0) throw new TypeError("Cannot canonicalize undefined");
131
- return encoded;
132
- }
133
- if (Array.isArray(value)) return `[${value.map(canonicalStringify).join(",")}]`;
134
- const record = value;
135
- return `{${Object.keys(record).filter((key) => record[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${canonicalStringify(record[key])}`).join(",")}}`;
136
- }
137
- async function sha256(value) {
138
- const hash = await globalThis.crypto.subtle.digest(
139
- "SHA-256",
140
- new TextEncoder().encode(value)
141
- );
142
- const hex = Array.from(
143
- new Uint8Array(hash),
144
- (byte) => byte.toString(16).padStart(2, "0")
145
- ).join("");
146
- return `sha256:${hex}`;
147
- }
148
167
  async function createAgentAssetDigest(content) {
149
168
  if (!hasWellFormedUnicode(content)) {
150
169
  throw new AgentDefinitionValidationError({
@@ -155,26 +174,16 @@ async function createAgentAssetDigest(content) {
155
174
  }
156
175
  return sha256(content);
157
176
  }
158
- var AgentDefinitionValidationError = class extends Error {
159
- code = ErrorCode.enum.CONFIG_INVALID;
160
- field;
161
- validationCode;
177
+ var AgentDefinitionValidationError = class extends SchemaValidationError {
162
178
  constructor(issue) {
163
- super(issue.message);
179
+ super(issue);
164
180
  this.name = "AgentDefinitionValidationError";
165
- this.field = issue.field;
166
- this.validationCode = issue.code;
167
181
  }
168
182
  };
169
- var AgentDeploymentValidationError = class extends Error {
170
- code = ErrorCode.enum.CONFIG_INVALID;
171
- field;
172
- validationCode;
183
+ var AgentDeploymentValidationError = class extends SchemaValidationError {
173
184
  constructor(issue) {
174
- super(issue.message);
185
+ super(issue);
175
186
  this.name = "AgentDeploymentValidationError";
176
- this.field = issue.field;
177
- this.validationCode = issue.code;
178
187
  }
179
188
  };
180
189
  async function validatedDefinitionAssets(definition, assets) {
@@ -253,6 +262,10 @@ function validateTool(tool) {
253
262
  }
254
263
 
255
264
  export {
265
+ sha256Bytes,
266
+ canonicalStringify,
267
+ formatPath,
268
+ SchemaValidationError,
256
269
  OpaqueRefSchema,
257
270
  Sha256DigestSchema,
258
271
  validateAgentDefinition,
@@ -1,6 +1,6 @@
1
- import { A as AgentHarness, a as AgentReadiness, b as Agent } from '../harness-BZW5Jiy3.js';
2
- export { c as AGENT_NOT_IMPLEMENTED_UNTIL_T1, d as AgentActor, e as AgentCoreHarness, f as AgentCoreHarnessFactory, g as AgentCorePromptInput, h as AgentCoreSessionAdapter, i as AgentCoreSessionSnapshot, j as AgentEvent, k as AgentMessageContent, l as AgentMessagePart, m as AgentNotImplementedError, n as AgentReadinessStatus, o as AgentResolveInputResponse, p as AgentSendInput, q as AgentStartReceipt, r as AgentStreamOptions } from '../harness-BZW5Jiy3.js';
3
- import { S as SessionListOptions, a as SessionSummary, C as ChatModelSelection, P as PiChatSnapshot, b as PiChatEvent, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, Q as QueueClearPayload, f as QueueClearReceipt, I as InterruptPayload, g as CommandReceipt, h as StopPayload, i as StopReceipt, j as SessionStore } from '../piChatEvent-CpoTZau1.js';
1
+ import { A as AgentHarness, a as AgentReadiness, b as Agent } from '../harness-C53mjCcq.js';
2
+ export { c as AGENT_NOT_IMPLEMENTED_UNTIL_T1, d as AgentActor, e as AgentCoreHarness, f as AgentCoreHarnessFactory, g as AgentCorePromptInput, h as AgentCoreSessionAdapter, i as AgentCoreSessionSnapshot, j as AgentEvent, k as AgentMessageContent, l as AgentMessagePart, m as AgentNotImplementedError, n as AgentReadinessStatus, o as AgentResolveInputResponse, p as AgentSendInput, q as AgentStartReceipt, r as AgentStreamOptions } from '../harness-C53mjCcq.js';
3
+ import { S as SessionListOptions, a as SessionSummary, C as ChatModelSelection, P as PiChatSnapshot, b as PiChatEvent, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, Q as QueueClearPayload, f as QueueClearReceipt, I as InterruptPayload, g as CommandReceipt, h as StopPayload, i as StopReceipt, j as SessionStore } from '../piChatEvent-3pFPXYPx.js';
4
4
  import '@mariozechner/pi-coding-agent';
5
5
  import 'zod';
6
6
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createAgent
3
- } from "../chunk-BNZIE26N.js";
3
+ } from "../chunk-TNN3LPXE.js";
4
4
  import {
5
5
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
6
6
  AgentNotImplementedError
7
7
  } from "../chunk-WSQ5QNIY.js";
8
- import "../chunk-CCNXYCD5.js";
8
+ import "../chunk-PG2WOJ22.js";
9
9
  export {
10
10
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
11
11
  AgentNotImplementedError,
@@ -4,9 +4,9 @@ import {
4
4
  deriveSourcePlugin,
5
5
  mergePiPackageSources,
6
6
  withPiHarnessDefaults
7
- } from "./chunk-N4ES6PVX.js";
7
+ } from "./chunk-5NAN3TAR.js";
8
8
  import "./chunk-AQBXNPMD.js";
9
- import "./chunk-CCNXYCD5.js";
9
+ import "./chunk-PG2WOJ22.js";
10
10
  export {
11
11
  createPiCodingAgentHarness,
12
12
  createResourceSettingsManager,
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentProps, HTMLAttributes, FormEvent, ReactNode, ComponentType } from 'react';
3
3
  import { FileUIPart, ChatStatus, UIMessage } from 'ai';
4
- import { T as ToolUiMetadata, B as BoringChatPart, k as BoringChatMessage, l as PiChatStatus, m as QueuedUserMessage, n as ChatError, b as PiChatEvent, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, Q as QueueClearPayload, f as QueueClearReceipt, I as InterruptPayload, g as CommandReceipt, h as StopPayload, i as StopReceipt, a as SessionSummary } from '../piChatEvent-CpoTZau1.js';
4
+ import { T as ToolUiMetadata, B as BoringChatPart, k as BoringChatMessage, l as PiChatStatus, m as QueuedUserMessage, n as ChatError, b as PiChatEvent, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, Q as QueueClearPayload, f as QueueClearReceipt, I as InterruptPayload, g as CommandReceipt, h as StopPayload, i as StopReceipt, a as SessionSummary } from '../piChatEvent-3pFPXYPx.js';
5
5
  import { InputGroupAddon, InputGroupButton, InputGroupTextarea, Button, Collapsible, CollapsibleContent, CollapsibleTrigger } from '@hachej/boring-ui-kit';
6
6
  import { Streamdown } from 'streamdown';
7
7
  import { StickToBottom } from 'use-stick-to-bottom';
@@ -12,10 +12,10 @@ import {
12
12
  StopReceiptSchema,
13
13
  extractToolUiMetadata,
14
14
  sanitizeToolUiMetadata
15
- } from "../chunk-UJQXCOHR.js";
15
+ } from "../chunk-DC3S7SZG.js";
16
16
  import {
17
17
  ErrorCode
18
- } from "../chunk-CCNXYCD5.js";
18
+ } from "../chunk-PG2WOJ22.js";
19
19
  import {
20
20
  DebugDrawer,
21
21
  cn,
@@ -42,6 +42,7 @@
42
42
  --radius-md: var(--radius-md);
43
43
  --radius-lg: var(--radius-lg);
44
44
  --radius-xl: var(--radius-xl);
45
+ --ease-out: cubic-bezier(0, 0, 0.2, 1);
45
46
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
46
47
  --animate-spin: spin 1s linear infinite;
47
48
  --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
@@ -2827,6 +2828,7 @@
2827
2828
  --tracking-widest: 0.1em;
2828
2829
  --leading-snug: 1.375;
2829
2830
  --radius-xs: 0.125rem;
2831
+ --ease-out: cubic-bezier(0, 0, 0.2, 1);
2830
2832
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
2831
2833
  --animate-spin: spin 1s linear infinite;
2832
2834
  --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
@@ -3019,6 +3021,9 @@
3019
3021
  .h-1 {
3020
3022
  height: var(--spacing);
3021
3023
  }
3024
+ .h-2 {
3025
+ height: calc(var(--spacing) * 2);
3026
+ }
3022
3027
  .h-2\.5 {
3023
3028
  height: calc(var(--spacing) * 2.5);
3024
3029
  }
@@ -3509,6 +3514,9 @@
3509
3514
  .bg-\[color\:var\(--boring-success-soft\,var\(--secondary\)\)\] {
3510
3515
  background-color: var(--boring-success-soft,var(--secondary));
3511
3516
  }
3517
+ .bg-\[color\:var\(--boring-warning\,var\(--accent-foreground\)\)\] {
3518
+ background-color: var(--boring-warning,var(--accent-foreground));
3519
+ }
3512
3520
  .bg-\[color\:var\(--boring-warning-soft\,var\(--accent\)\)\] {
3513
3521
  background-color: var(--boring-warning-soft,var(--accent));
3514
3522
  }
@@ -3926,6 +3934,11 @@
3926
3934
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
3927
3935
  transition-duration: var(--tw-duration, var(--default-transition-duration));
3928
3936
  }
3937
+ .transition-\[width\] {
3938
+ transition-property: width;
3939
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
3940
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
3941
+ }
3929
3942
  .transition-all {
3930
3943
  transition-property: all;
3931
3944
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
@@ -3962,10 +3975,18 @@
3962
3975
  --tw-duration: 200ms;
3963
3976
  transition-duration: 200ms;
3964
3977
  }
3978
+ .duration-300 {
3979
+ --tw-duration: 300ms;
3980
+ transition-duration: 300ms;
3981
+ }
3965
3982
  .ease-in-out {
3966
3983
  --tw-ease: var(--ease-in-out);
3967
3984
  transition-timing-function: var(--ease-in-out);
3968
3985
  }
3986
+ .ease-out {
3987
+ --tw-ease: var(--ease-out);
3988
+ transition-timing-function: var(--ease-out);
3989
+ }
3969
3990
  .outline-none {
3970
3991
  --tw-outline-style: none;
3971
3992
  outline-style: none;
@@ -1,4 +1,4 @@
1
- import { o as SessionCtx, b as PiChatEvent, j as SessionStore } from './piChatEvent-CpoTZau1.js';
1
+ import { o as SessionCtx, b as PiChatEvent, j as SessionStore } from './piChatEvent-3pFPXYPx.js';
2
2
  import { AgentSessionEvent, PromptOptions } from '@mariozechner/pi-coding-agent';
3
3
 
4
4
  interface TelemetrySink {