@hachej/boring-agent 0.1.81 → 0.1.83

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-YV6D7GCQ.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",
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WSQ5QNIY.js";
4
4
  import {
5
5
  ErrorCode
6
- } from "./chunk-YV6D7GCQ.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-YV6D7GCQ.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-If4r1n-K.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-If4r1n-K.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-DtqYMcID.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-2AVRA73A.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-YV6D7GCQ.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-24VL7G32.js";
7
+ } from "./chunk-5NAN3TAR.js";
8
8
  import "./chunk-AQBXNPMD.js";
9
- import "./chunk-YV6D7GCQ.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-DtqYMcID.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-3RSYCAHO.js";
15
+ } from "../chunk-DC3S7SZG.js";
16
16
  import {
17
17
  ErrorCode
18
- } from "../chunk-YV6D7GCQ.js";
18
+ } from "../chunk-PG2WOJ22.js";
19
19
  import {
20
20
  DebugDrawer,
21
21
  cn,
@@ -2970,6 +2970,9 @@
2970
2970
  .grid {
2971
2971
  display: grid;
2972
2972
  }
2973
+ .inline {
2974
+ display: inline;
2975
+ }
2973
2976
  .inline-block {
2974
2977
  display: inline-block;
2975
2978
  }
@@ -3019,6 +3022,9 @@
3019
3022
  .h-1 {
3020
3023
  height: var(--spacing);
3021
3024
  }
3025
+ .h-2 {
3026
+ height: calc(var(--spacing) * 2);
3027
+ }
3022
3028
  .h-2\.5 {
3023
3029
  height: calc(var(--spacing) * 2.5);
3024
3030
  }
@@ -5223,6 +5229,64 @@
5223
5229
  height: calc(var(--spacing) * 4);
5224
5230
  }
5225
5231
  }
5232
+ .\[\&\:\:-moz-progress-bar\]\:rounded-full {
5233
+ &::-moz-progress-bar {
5234
+ border-radius: calc(infinity * 1px);
5235
+ }
5236
+ }
5237
+ .\[\&\:\:-moz-progress-bar\]\:bg-\[color\:var\(--boring-warning\,var\(--accent-foreground\)\)\] {
5238
+ &::-moz-progress-bar {
5239
+ background-color: var(--boring-warning,var(--accent-foreground));
5240
+ }
5241
+ }
5242
+ .\[\&\:\:-moz-progress-bar\]\:bg-destructive {
5243
+ &::-moz-progress-bar {
5244
+ background-color: var(--boring-destructive);
5245
+ }
5246
+ }
5247
+ .\[\&\:\:-moz-progress-bar\]\:bg-primary {
5248
+ &::-moz-progress-bar {
5249
+ background-color: var(--boring-primary);
5250
+ }
5251
+ }
5252
+ .\[\&\:\:-webkit-progress-bar\]\:bg-muted {
5253
+ &::-webkit-progress-bar {
5254
+ background-color: var(--boring-muted);
5255
+ }
5256
+ }
5257
+ .\[\&\:\:-webkit-progress-value\]\:rounded-full {
5258
+ &::-webkit-progress-value {
5259
+ border-radius: calc(infinity * 1px);
5260
+ }
5261
+ }
5262
+ .\[\&\:\:-webkit-progress-value\]\:bg-\[color\:var\(--boring-warning\,var\(--accent-foreground\)\)\] {
5263
+ &::-webkit-progress-value {
5264
+ background-color: var(--boring-warning,var(--accent-foreground));
5265
+ }
5266
+ }
5267
+ .\[\&\:\:-webkit-progress-value\]\:bg-destructive {
5268
+ &::-webkit-progress-value {
5269
+ background-color: var(--boring-destructive);
5270
+ }
5271
+ }
5272
+ .\[\&\:\:-webkit-progress-value\]\:bg-primary {
5273
+ &::-webkit-progress-value {
5274
+ background-color: var(--boring-primary);
5275
+ }
5276
+ }
5277
+ .\[\&\:\:-webkit-progress-value\]\:transition-all {
5278
+ &::-webkit-progress-value {
5279
+ transition-property: all;
5280
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
5281
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
5282
+ }
5283
+ }
5284
+ .\[\&\:\:-webkit-progress-value\]\:duration-300 {
5285
+ &::-webkit-progress-value {
5286
+ --tw-duration: 300ms;
5287
+ transition-duration: 300ms;
5288
+ }
5289
+ }
5226
5290
  .\[\&\:\:-webkit-scrollbar\]\:hidden {
5227
5291
  &::-webkit-scrollbar {
5228
5292
  display: none;
@@ -1,4 +1,4 @@
1
- import { o as SessionCtx, b as PiChatEvent, j as SessionStore } from './piChatEvent-DtqYMcID.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 {