@hachej/boring-agent 0.1.78 → 0.1.79

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,5 @@
1
1
  // src/shared/events.ts
2
2
  var AGENT_NOT_IMPLEMENTED_UNTIL_T1 = "ERR_NOT_IMPLEMENTED_UNTIL_T1";
3
- var AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS = "ERR_NO_FILESYSTEM_FOR_ATTACHMENTS";
4
3
  function sessionStreamPath(sessionId) {
5
4
  return `sessions/${sessionId}`;
6
5
  }
@@ -11,19 +10,9 @@ var AgentNotImplementedError = class extends Error {
11
10
  this.name = "AgentNotImplementedError";
12
11
  }
13
12
  };
14
- var AgentFilesystemRequiredError = class extends Error {
15
- code = AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS;
16
- statusCode = 400;
17
- constructor(message = "Attachments require a filesystem-backed agent runtime.") {
18
- super(message);
19
- this.name = "AgentFilesystemRequiredError";
20
- }
21
- };
22
13
 
23
14
  export {
24
15
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
25
- AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS,
26
16
  sessionStreamPath,
27
- AgentNotImplementedError,
28
- AgentFilesystemRequiredError
17
+ AgentNotImplementedError
29
18
  };
@@ -2,12 +2,9 @@ import {
2
2
  noopTelemetry,
3
3
  safeCapture
4
4
  } from "./chunk-AQBXNPMD.js";
5
- import {
6
- createLogger
7
- } from "./chunk-AJZHR626.js";
8
5
  import {
9
6
  ErrorCode
10
- } from "./chunk-6AEK34XU.js";
7
+ } from "./chunk-YVON2BHN.js";
11
8
 
12
9
  // src/server/harness/pi-coding-agent/createHarness.ts
13
10
  import { AsyncLocalStorage } from "async_hooks";
@@ -24,6 +21,88 @@ import {
24
21
  loadSkills
25
22
  } from "@mariozechner/pi-coding-agent";
26
23
 
24
+ // src/server/logging.ts
25
+ var SENSITIVE_KEYS = new Set([
26
+ "apiKey",
27
+ "api_key",
28
+ "token",
29
+ "secret",
30
+ "password",
31
+ "authorization",
32
+ "cookie",
33
+ "oidcToken",
34
+ "accessToken",
35
+ "refreshToken",
36
+ "ANTHROPIC_API_KEY",
37
+ "OPENAI_API_KEY",
38
+ "VERCEL_OIDC_TOKEN",
39
+ "VERCEL_TEAM_ID"
40
+ ].map((key) => key.toLowerCase()));
41
+ function isSensitiveKey(key) {
42
+ return SENSITIVE_KEYS.has(key.toLowerCase());
43
+ }
44
+ function redactValue(key, value, seen) {
45
+ if (key && isSensitiveKey(key) && value != null) return "***";
46
+ if (value == null || typeof value !== "object") return value;
47
+ if (value instanceof Date) return value;
48
+ if (seen.has(value)) return "[Circular]";
49
+ seen.add(value);
50
+ if (Array.isArray(value)) {
51
+ const out2 = value.map((item) => redactValue(void 0, item, seen));
52
+ seen.delete(value);
53
+ return out2;
54
+ }
55
+ const out = {};
56
+ for (const [childKey, childValue] of Object.entries(value)) {
57
+ out[childKey] = redactValue(childKey, childValue, seen);
58
+ }
59
+ seen.delete(value);
60
+ return out;
61
+ }
62
+ function redact(fields) {
63
+ const out = {};
64
+ const seen = /* @__PURE__ */ new WeakSet();
65
+ for (const [k, v] of Object.entries(fields)) {
66
+ out[k] = redactValue(k, v, seen);
67
+ }
68
+ return out;
69
+ }
70
+ function isVerbose() {
71
+ return typeof process !== "undefined" && process.env?.BORING_AGENT_VERBOSE === "1";
72
+ }
73
+ function createLogger(prefix) {
74
+ function emit(level, msg, fields) {
75
+ const entry = {
76
+ level,
77
+ prefix,
78
+ msg,
79
+ ...fields ? redact(fields) : {},
80
+ t: (/* @__PURE__ */ new Date()).toISOString()
81
+ };
82
+ if (level === "error") {
83
+ console.error(JSON.stringify(entry));
84
+ } else if (level === "warn") {
85
+ console.warn(JSON.stringify(entry));
86
+ } else {
87
+ console.log(JSON.stringify(entry));
88
+ }
89
+ }
90
+ return {
91
+ debug(msg, fields) {
92
+ if (isVerbose()) emit("debug", msg, fields);
93
+ },
94
+ info(msg, fields) {
95
+ emit("info", msg, fields);
96
+ },
97
+ warn(msg, fields) {
98
+ emit("warn", msg, fields);
99
+ },
100
+ error(msg, fields) {
101
+ emit("error", msg, fields);
102
+ }
103
+ };
104
+ }
105
+
27
106
  // src/server/harness/pi-coding-agent/tool-adapter.ts
28
107
  var BORING_TOOL_ERROR_MARKER = "__boringToolError";
29
108
  function markToolResultErrorDetails(details) {
@@ -1506,7 +1585,7 @@ function createPiCodingAgentHarness(opts) {
1506
1585
  sessionNamespace: opts.sessionNamespace,
1507
1586
  sessionRoot: opts.sessionRoot,
1508
1587
  sessionDir: opts.sessionDir,
1509
- storageCwd: opts.sessionStorageCwd ?? opts.cwd
1588
+ storageCwd: opts.cwd
1510
1589
  });
1511
1590
  const piSessions = /* @__PURE__ */ new Map();
1512
1591
  const runContextStorage = new AsyncLocalStorage();
@@ -1799,7 +1878,7 @@ export {
1799
1878
  getEnv,
1800
1879
  getEnvSnapshot,
1801
1880
  setEnvDefault,
1802
- PiSessionStore,
1881
+ createLogger,
1803
1882
  registerConfiguredModelProviders,
1804
1883
  readConfiguredDefaultModel,
1805
1884
  PI_PACKAGE_RESOURCE_FILTERS,
@@ -19,6 +19,7 @@ var ErrorCode = z.enum([
19
19
  "WORKSPACE_NOT_READY",
20
20
  // Agent runtime / provisioning
21
21
  "AGENT_RUNTIME_NOT_READY",
22
+ "AGENT_BINDING_DISPOSED",
22
23
  "AGENT_CONTROL_RECEIPT_INVALID",
23
24
  "RUNTIME_PROVISIONING_FAILED",
24
25
  "RUNTIME_PROVISIONING_LOCKED",
@@ -70,10 +71,17 @@ var ErrorCode = z.enum([
70
71
  "PROVISIONING_ARTIFACT_FAILED",
71
72
  // Internal
72
73
  "ERR_NOT_IMPLEMENTED_UNTIL_T1",
73
- "ERR_NO_FILESYSTEM_FOR_ATTACHMENTS",
74
74
  "INTERNAL_ERROR"
75
75
  ]);
76
76
  var ERROR_CODES = ErrorCode.options;
77
+ var AgentDefinitionErrorCode = z.enum([
78
+ "AGENT_DEFINITION_INVALID",
79
+ "AGENT_DEFINITION_UNSUPPORTED_FIELD"
80
+ ]);
81
+ var AgentDeploymentErrorCode = z.enum([
82
+ "AGENT_DEPLOYMENT_INVALID",
83
+ "AGENT_DEPLOYMENT_UNSUPPORTED_FIELD"
84
+ ]);
77
85
  var ApiErrorPayloadSchema = z.object({
78
86
  code: ErrorCode,
79
87
  message: z.string().min(1),
@@ -92,6 +100,8 @@ var ErrorLogFieldsSchema = z.object({
92
100
  export {
93
101
  ErrorCode,
94
102
  ERROR_CODES,
103
+ AgentDefinitionErrorCode,
104
+ AgentDeploymentErrorCode,
95
105
  ApiErrorPayloadSchema,
96
106
  ApiErrorResponseSchema,
97
107
  ErrorLogFieldsSchema
@@ -1,9 +1,71 @@
1
- import { w as AgentConfig, c as Agent } from '../harness-OsJBlx4u.js';
2
- export { a as AGENT_NOT_IMPLEMENTED_UNTIL_T1, b as AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS, d as AgentActor, e as AgentCoreHarness, f as AgentCoreHarnessFactory, g as AgentCorePromptInput, h as AgentCoreSessionAdapter, i as AgentCoreSessionSnapshot, j as AgentEvent, k as AgentFilesystemRequiredError, m as AgentMessageContent, n as AgentMessagePart, o as AgentNotImplementedError, p as AgentReadiness, q as AgentReadinessStatus, r as AgentResolveInputResponse, s as AgentRuntimeAdapter, t as AgentSendInput, u as AgentStartReceipt, v as AgentStreamOptions } from '../harness-OsJBlx4u.js';
3
- import '../session-FUiMWsyX.js';
4
- import 'zod';
1
+ import { A as AgentHarness, a as Agent } from '../harness-DD0zj704.js';
2
+ export { b as AGENT_NOT_IMPLEMENTED_UNTIL_T1, c as AgentActor, d as AgentCoreHarness, e as AgentCoreHarnessFactory, f as AgentCorePromptInput, g as AgentCoreSessionAdapter, h as AgentCoreSessionSnapshot, i as AgentEvent, j as AgentMessageContent, k as AgentMessagePart, l as AgentNotImplementedError, m as AgentReadiness, n as AgentReadinessStatus, o as AgentResolveInputResponse, p as AgentSendInput, q as AgentStartReceipt, r as AgentStreamOptions } from '../harness-DD0zj704.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-D0yuLiJh.js';
5
4
  import '@mariozechner/pi-coding-agent';
5
+ import 'zod';
6
+
7
+ interface PiSessionRequestContext {
8
+ workspaceId?: string;
9
+ storageScope?: string;
10
+ authSubject?: string;
11
+ authEmail?: string;
12
+ authEmailVerified?: boolean;
13
+ requestId: string;
14
+ }
15
+ interface PiSessionCreateInit {
16
+ title?: string;
17
+ modelDefault?: ChatModelSelection;
18
+ }
19
+ type PiChatReplayRangeError = {
20
+ type: 'replay_gap';
21
+ latestSeq: number;
22
+ minReplaySeq: number;
23
+ } | {
24
+ type: 'cursor_ahead';
25
+ latestSeq: number;
26
+ minReplaySeq: number;
27
+ };
28
+ interface PiChatEventStreamSubscription {
29
+ type: 'ok';
30
+ unsubscribe: () => void;
31
+ /** Optional test/service completion hook. Real live streams normally omit it. */
32
+ closed?: Promise<void>;
33
+ }
34
+ type PiChatEventStreamResult = PiChatEventStreamSubscription | PiChatReplayRangeError;
35
+ type PiChatEventSubscriber = (event: PiChatEvent) => void;
36
+ interface PiChatSessionService {
37
+ listSessions?(ctx: PiSessionRequestContext, options?: SessionListOptions): Promise<SessionSummary[]>;
38
+ createSession?(ctx: PiSessionRequestContext, init?: PiSessionCreateInit): Promise<SessionSummary>;
39
+ deleteSession?(ctx: PiSessionRequestContext, sessionId: string): Promise<void>;
40
+ readState(ctx: PiSessionRequestContext, sessionId: string): Promise<PiChatSnapshot>;
41
+ subscribe(ctx: PiSessionRequestContext, sessionId: string, cursor: number, subscriber: PiChatEventSubscriber): Promise<PiChatEventStreamResult>;
42
+ prompt(ctx: PiSessionRequestContext, sessionId: string, payload: PromptPayload): Promise<PromptReceipt>;
43
+ followUp(ctx: PiSessionRequestContext, sessionId: string, payload: FollowUpPayload): Promise<FollowUpReceipt>;
44
+ clearQueue(ctx: PiSessionRequestContext, sessionId: string, payload: QueueClearPayload): Promise<QueueClearReceipt>;
45
+ interrupt(ctx: PiSessionRequestContext, sessionId: string, payload: InterruptPayload): Promise<CommandReceipt>;
46
+ stop(ctx: PiSessionRequestContext, sessionId: string, payload: StopPayload): Promise<StopReceipt>;
47
+ }
48
+ interface AgentCoreSessionService extends PiChatSessionService {
49
+ createSession(ctx: PiSessionRequestContext, init?: PiSessionCreateInit): Promise<SessionSummary>;
50
+ deleteSession(ctx: PiSessionRequestContext, sessionId: string): Promise<void>;
51
+ dispose?(): Promise<void>;
52
+ }
6
53
 
7
- declare function createAgent(config: AgentConfig): Agent;
54
+ interface AgentCoreRuntime {
55
+ harness: AgentHarness;
56
+ sessionStore: SessionStore;
57
+ service: AgentCoreSessionService;
58
+ }
59
+ type AgentCoreRuntimeFactory = () => AgentCoreRuntime | Promise<AgentCoreRuntime>;
60
+ interface AgentCoreConfig {
61
+ runtimeFactory: AgentCoreRuntimeFactory;
62
+ readinessRequirements?: string[];
63
+ }
64
+ interface AgentCoreRuntimeView {
65
+ harness: AgentHarness;
66
+ sessionStore: SessionStore;
67
+ service: unknown;
68
+ }
69
+ declare function createAgent(config: AgentCoreConfig): Agent;
8
70
 
9
- export { Agent, AgentConfig, createAgent };
71
+ export { Agent, type AgentCoreConfig, type AgentCoreRuntime, type AgentCoreRuntimeFactory, type AgentCoreRuntimeView, type AgentCoreSessionService, type PiChatEventStreamResult, type PiChatEventStreamSubscription, type PiChatEventSubscriber, type PiChatReplayRangeError, type PiChatSessionService, type PiSessionCreateInit, type PiSessionRequestContext, createAgent };
@@ -1,19 +1,13 @@
1
1
  import {
2
2
  createAgent
3
- } from "../chunk-3WWLQAJB.js";
3
+ } from "../chunk-LCEBDU6G.js";
4
4
  import {
5
5
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
6
- AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS,
7
- AgentFilesystemRequiredError,
8
6
  AgentNotImplementedError
9
- } from "../chunk-ZUEITFIJ.js";
10
- import "../chunk-ORURYKNY.js";
11
- import "../chunk-AJZHR626.js";
12
- import "../chunk-6AEK34XU.js";
7
+ } from "../chunk-WSQ5QNIY.js";
8
+ import "../chunk-YVON2BHN.js";
13
9
  export {
14
10
  AGENT_NOT_IMPLEMENTED_UNTIL_T1,
15
- AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS,
16
- AgentFilesystemRequiredError,
17
11
  AgentNotImplementedError,
18
12
  createAgent
19
13
  };
@@ -4,10 +4,9 @@ import {
4
4
  deriveSourcePlugin,
5
5
  mergePiPackageSources,
6
6
  withPiHarnessDefaults
7
- } from "./chunk-TS3QGFKK.js";
7
+ } from "./chunk-X4WT3TPU.js";
8
8
  import "./chunk-AQBXNPMD.js";
9
- import "./chunk-AJZHR626.js";
10
- import "./chunk-6AEK34XU.js";
9
+ import "./chunk-YVON2BHN.js";
11
10
  export {
12
11
  createPiCodingAgentHarness,
13
12
  createResourceSettingsManager,
@@ -1,8 +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, e as BoringChatMessage, k as PiChatStatus, Q as QueuedUserMessage, C as ChatError, P as PiChatEvent, n as SessionSummary } from '../session-FUiMWsyX.js';
5
- import { P as PromptPayload, f as PromptReceipt, F as FollowUpPayload, d as FollowUpReceipt, Q as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, c as CommandReceipt, S as StopPayload, h as StopReceipt } from '../piChatCommand-BuWXytap.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-D0yuLiJh.js';
6
5
  import { InputGroupAddon, InputGroupButton, InputGroupTextarea, Button, Collapsible, CollapsibleContent, CollapsibleTrigger } from '@hachej/boring-ui-kit';
7
6
  import { Streamdown } from 'streamdown';
8
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-ORURYKNY.js";
15
+ } from "../chunk-P23XFC4W.js";
16
16
  import {
17
17
  ErrorCode
18
- } from "../chunk-6AEK34XU.js";
18
+ } from "../chunk-YVON2BHN.js";
19
19
  import {
20
20
  DebugDrawer,
21
21
  cn,
@@ -1,4 +1,4 @@
1
- import { S as SessionCtx, P as PiChatEvent, a as SessionStore } from './session-FUiMWsyX.js';
1
+ import { o as SessionCtx, b as PiChatEvent, j as SessionStore } from './piChatEvent-D0yuLiJh.js';
2
2
  import { AgentSessionEvent, PromptOptions } from '@mariozechner/pi-coding-agent';
3
3
 
4
4
  interface TelemetrySink {
@@ -47,7 +47,6 @@ interface ToolResult {
47
47
  }
48
48
 
49
49
  declare const AGENT_NOT_IMPLEMENTED_UNTIL_T1: "ERR_NOT_IMPLEMENTED_UNTIL_T1";
50
- declare const AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS: "ERR_NO_FILESYSTEM_FOR_ATTACHMENTS";
51
50
  interface MessageAttachment {
52
51
  filename?: string;
53
52
  mediaType?: string;
@@ -115,7 +114,7 @@ interface AgentReadiness {
115
114
  }
116
115
  interface AgentConfig {
117
116
  harnessFactory?: AgentCoreHarnessFactory;
118
- runtime: AgentRuntimeAdapter | 'none';
117
+ runtime: AgentRuntimeAdapter;
119
118
  tools?: AgentTool[];
120
119
  readinessRequirements?: string[];
121
120
  sessions?: SessionStore;
@@ -141,11 +140,6 @@ declare class AgentNotImplementedError extends Error {
141
140
  readonly code: "ERR_NOT_IMPLEMENTED_UNTIL_T1";
142
141
  constructor(message?: string);
143
142
  }
144
- declare class AgentFilesystemRequiredError extends Error {
145
- readonly code: "ERR_NO_FILESYSTEM_FOR_ATTACHMENTS";
146
- readonly statusCode = 400;
147
- constructor(message?: string);
148
- }
149
143
 
150
144
  interface AgentHarnessFactoryInput {
151
145
  tools: AgentTool[];
@@ -153,8 +147,6 @@ interface AgentHarnessFactoryInput {
153
147
  cwd: string;
154
148
  /** Agent-visible cwd used by Pi/system prompt/session metadata. */
155
149
  runtimeCwd?: string;
156
- /** Optional cwd used only to derive the default transcript storage directory. */
157
- sessionStorageCwd?: string;
158
150
  systemPromptAppend?: string;
159
151
  sessionNamespace?: string;
160
152
  sessionRoot?: string;
@@ -270,4 +262,4 @@ interface RunContext {
270
262
  allowPromptDispatch?: boolean;
271
263
  }
272
264
 
273
- export { type AgentTool as A, noopTelemetry as B, safeCapture as C, sessionStreamPath as D, type ToolReadinessRequirement as E, type AgentHarnessFactory as F, type AgentHarnessFactoryInput as G, type JSONSchema as J, type MessageAttachment as M, type RunContext as R, type SendMessageInput as S, type TelemetryEvent as T, AGENT_NOT_IMPLEMENTED_UNTIL_T1 as a, AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS as b, type Agent as c, type AgentActor as d, type AgentCoreHarness as e, type AgentCoreHarnessFactory as f, type AgentCorePromptInput as g, type AgentCoreSessionAdapter as h, type AgentCoreSessionSnapshot as i, type AgentEvent as j, AgentFilesystemRequiredError as k, type AgentHarness as l, type AgentMessageContent as m, type AgentMessagePart as n, AgentNotImplementedError as o, type AgentReadiness as p, type AgentReadinessStatus as q, type AgentResolveInputResponse as r, type AgentRuntimeAdapter as s, type AgentSendInput as t, type AgentStartReceipt as u, type AgentStreamOptions as v, type AgentConfig as w, type TelemetrySink as x, type ToolExecContext as y, type ToolResult as z };
265
+ export { type AgentHarness as A, type ToolResult as B, noopTelemetry as C, safeCapture as D, sessionStreamPath as E, type JSONSchema as J, type MessageAttachment as M, type RunContext as R, type SendMessageInput as S, type TelemetrySink as T, type Agent as a, AGENT_NOT_IMPLEMENTED_UNTIL_T1 as b, type AgentActor as c, type AgentCoreHarness as d, type AgentCoreHarnessFactory as e, type AgentCorePromptInput as f, type AgentCoreSessionAdapter as g, type AgentCoreSessionSnapshot as h, type AgentEvent as i, type AgentMessageContent as j, type AgentMessagePart as k, AgentNotImplementedError as l, type AgentReadiness as m, type AgentReadinessStatus as n, type AgentResolveInputResponse as o, type AgentSendInput as p, type AgentStartReceipt as q, type AgentStreamOptions as r, type ToolReadinessRequirement as s, type AgentConfig as t, type AgentTool as u, type AgentHarnessFactory as v, type AgentHarnessFactoryInput as w, type AgentRuntimeAdapter as x, type TelemetryEvent as y, type ToolExecContext as z };