@hachej/boring-agent 0.1.111 → 0.2.1

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.
Files changed (156) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +262 -51
  3. package/dist/agents.d.ts +75 -0
  4. package/dist/agents.js +91 -0
  5. package/dist/approval.d.ts +71 -0
  6. package/dist/approval.js +126 -0
  7. package/dist/artifacts.d.ts +53 -0
  8. package/dist/artifacts.js +129 -0
  9. package/dist/ask-user.d.ts +40 -0
  10. package/dist/ask-user.js +134 -0
  11. package/dist/attachment.d.ts +5 -0
  12. package/dist/attachment.js +4 -0
  13. package/dist/browser-task.d.ts +32 -0
  14. package/dist/browser-task.js +119 -0
  15. package/dist/chat-transport.d.ts +80 -0
  16. package/dist/chat-transport.js +306 -0
  17. package/dist/contracts.d.ts +40 -0
  18. package/dist/contracts.js +1 -0
  19. package/dist/conversations.d.ts +136 -0
  20. package/dist/conversations.js +366 -0
  21. package/dist/definitions.d.ts +37 -0
  22. package/dist/definitions.js +99 -0
  23. package/dist/delivery-input.d.ts +35 -0
  24. package/dist/delivery-input.js +56 -0
  25. package/dist/delivery.d.ts +33 -0
  26. package/dist/delivery.js +154 -0
  27. package/dist/durable-wait.d.ts +23 -0
  28. package/dist/durable-wait.js +79 -0
  29. package/dist/file-convert.d.ts +46 -0
  30. package/dist/file-convert.js +159 -0
  31. package/dist/file-guard.d.ts +50 -0
  32. package/dist/file-guard.js +177 -0
  33. package/dist/file-types.d.ts +17 -0
  34. package/dist/file-types.js +95 -0
  35. package/dist/gateway-provider.d.ts +24 -0
  36. package/dist/gateway-provider.js +42 -0
  37. package/dist/git.d.ts +34 -0
  38. package/dist/git.js +79 -0
  39. package/dist/harness-pool.d.ts +38 -0
  40. package/dist/harness-pool.js +134 -0
  41. package/dist/index.d.ts +4 -0
  42. package/dist/index.js +1 -0
  43. package/dist/json-schema-tool.d.ts +25 -0
  44. package/dist/json-schema-tool.js +19 -0
  45. package/dist/memory/optchat-core.d.ts +118 -0
  46. package/dist/memory/optchat-core.js +317 -0
  47. package/dist/memory/optchat.d.ts +156 -0
  48. package/dist/memory/optchat.js +432 -0
  49. package/dist/mentions.d.ts +56 -0
  50. package/dist/mentions.js +140 -0
  51. package/dist/metering.d.ts +183 -0
  52. package/dist/metering.js +443 -0
  53. package/dist/model-gateway.d.ts +86 -0
  54. package/dist/model-gateway.js +241 -0
  55. package/dist/native-version.d.ts +9 -0
  56. package/dist/native-version.js +7 -0
  57. package/dist/native.d.ts +4 -0
  58. package/dist/native.js +1 -0
  59. package/dist/presentation.d.ts +17 -0
  60. package/dist/presentation.js +39 -0
  61. package/dist/projection-format.d.ts +68 -0
  62. package/dist/projection-format.js +118 -0
  63. package/dist/projection-window.d.ts +9 -0
  64. package/dist/projection-window.js +93 -0
  65. package/dist/projection.d.ts +22 -0
  66. package/dist/projection.js +153 -0
  67. package/dist/question-response.d.ts +20 -0
  68. package/dist/question-response.js +75 -0
  69. package/dist/questions.d.ts +74 -0
  70. package/dist/questions.js +199 -0
  71. package/dist/self-evolving.d.ts +55 -0
  72. package/dist/self-evolving.js +239 -0
  73. package/dist/skills.d.ts +15 -0
  74. package/dist/skills.js +51 -0
  75. package/dist/tool-evidence.d.ts +14 -0
  76. package/dist/tool-evidence.js +54 -0
  77. package/dist/validation.d.ts +38 -0
  78. package/dist/validation.js +68 -0
  79. package/dist/workspaces.d.ts +107 -0
  80. package/dist/workspaces.js +212 -0
  81. package/package.json +145 -150
  82. package/dist/DebugDrawer-JNA43SVR.js +0 -8
  83. package/dist/admin-DORVQfLn.d.ts +0 -340
  84. package/dist/chunk-2BGLZZ7T.js +0 -10
  85. package/dist/chunk-42D6KAQV.js +0 -2882
  86. package/dist/chunk-4XOW57KJ.js +0 -343
  87. package/dist/chunk-72KT6VWV.js +0 -1338
  88. package/dist/chunk-7XAOVFSN.js +0 -28
  89. package/dist/chunk-KJIEMSQP.js +0 -198
  90. package/dist/chunk-KN72XWP7.js +0 -394
  91. package/dist/chunk-N6THTH7P.js +0 -110
  92. package/dist/chunk-V3H5A3BR.js +0 -22501
  93. package/dist/chunk-YGRQ4Q5P.js +0 -20
  94. package/dist/chunk-YTUZFKB3.js +0 -78
  95. package/dist/core/index.d.ts +0 -28
  96. package/dist/core/index.js +0 -617
  97. package/dist/createHarness-DOLOHA62.js +0 -18
  98. package/dist/eval/index.d.ts +0 -247
  99. package/dist/eval/index.js +0 -541
  100. package/dist/file-search-BUgMSKZE.d.ts +0 -289
  101. package/dist/front/artifacts.d.ts +0 -34
  102. package/dist/front/artifacts.js +0 -21
  103. package/dist/front/index.d.ts +0 -1082
  104. package/dist/front/index.js +0 -12912
  105. package/dist/front/styles.css +0 -5380
  106. package/dist/harness-qHlMJhZo.d.ts +0 -276
  107. package/dist/middleware-CaAEXpi5.d.ts +0 -115
  108. package/dist/piChatEvent-DpE0lIb9.d.ts +0 -450
  109. package/dist/piChatSessionService-CBct-hmz.d.ts +0 -86
  110. package/dist/sandbox-BMhut3kh.d.ts +0 -317
  111. package/dist/server/agent-host/testing/compositionRouteProof.d.ts +0 -8
  112. package/dist/server/agent-host/testing/compositionRouteProof.js +0 -78
  113. package/dist/server/agent-host/testing/gatewayConformance.d.ts +0 -43
  114. package/dist/server/agent-host/testing/gatewayConformance.js +0 -605
  115. package/dist/server/index.d.ts +0 -2278
  116. package/dist/server/index.js +0 -274
  117. package/dist/server/pi-session-readability.d.ts +0 -12
  118. package/dist/server/pi-session-readability.js +0 -23
  119. package/dist/server/worker/index.d.ts +0 -68
  120. package/dist/server/worker/index.js +0 -377
  121. package/dist/share-entry-CxS6UJ_L.d.ts +0 -330
  122. package/dist/shared/index.d.ts +0 -2111
  123. package/dist/shared/index.js +0 -262
  124. package/dist/types-DcWoQMn8.d.ts +0 -1377
  125. package/docs/ACCESSIBILITY.md +0 -52
  126. package/docs/AGENT_GATEWAY_V0.md +0 -212
  127. package/docs/AGENT_PACKAGES.md +0 -90
  128. package/docs/API.md +0 -123
  129. package/docs/AUTHORING.md +0 -68
  130. package/docs/CSP.md +0 -41
  131. package/docs/ERROR_CODES.md +0 -229
  132. package/docs/KNOWN_LIMITATIONS.md +0 -100
  133. package/docs/MIGRATION.md +0 -50
  134. package/docs/PERFORMANCE.md +0 -68
  135. package/docs/PLUGINS.md +0 -138
  136. package/docs/README.md +0 -98
  137. package/docs/RISKS-MULTI-TAB.md +0 -46
  138. package/docs/SESSION_IDENTITY.md +0 -91
  139. package/docs/STYLING.md +0 -73
  140. package/docs/UI-SHADCN.md +0 -56
  141. package/docs/VERCEL_COSTS.md +0 -103
  142. package/docs/plans/archive/AGENT_EVAL_FRAMEWORK.md +0 -466
  143. package/docs/plans/archive/agent-package-spec.md +0 -1777
  144. package/docs/plans/archive/harness-followup-capabilities.md +0 -440
  145. package/docs/plans/archive/harness-tool-ui-capabilities.md +0 -144
  146. package/docs/plans/archive/pi-followup-history-projection.md +0 -229
  147. package/docs/plans/archive/pi-tools-migration.md +0 -1061
  148. package/docs/plans/archive/reviews/pi-followup-history-codex-review.md +0 -11
  149. package/docs/plans/archive/reviews/pi-followup-history-gpt-review.md +0 -64
  150. package/docs/plans/archive/reviews/pi-followup-history-opus-review.md +0 -43
  151. package/docs/plans/archive/reviews/pi-followup-history-xai-review.md +0 -43
  152. package/docs/plans/archive/vercel-base-snapshot-template-plan.md +0 -527
  153. package/docs/plans/archive/vercel-persistent-sandbox-adapter.md +0 -553
  154. package/docs/runtime-provisioning.md +0 -157
  155. package/docs/runtime.md +0 -296
  156. package/docs/tools.md +0 -102
@@ -1,86 +0,0 @@
1
- import { P as PromptPayload, a as SessionListOptions, b as SessionSummary, C as ChatModelSelection, O as OriginChannel, c as PiChatSnapshot, d as PiChatEvent, e as PromptReceipt, F as FollowUpPayload, f as FollowUpReceipt, Q as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, h as CommandReceipt, i as StopPayload, j as StopReceipt } from './piChatEvent-DpE0lIb9.js';
2
-
3
- /** Server-only prompt admission selector; browser schemas never accept requireIdle. */
4
- type AgentPromptPayload = PromptPayload & {
5
- readonly requireIdle?: true;
6
- };
7
-
8
- interface PiChatAttachmentResult {
9
- data: Uint8Array;
10
- mediaType: string;
11
- filename?: string;
12
- }
13
-
14
- interface PiSessionRequestContext {
15
- workspaceId?: string;
16
- storageScope?: string;
17
- authSubject?: string;
18
- authEmail?: string;
19
- authEmailVerified?: boolean;
20
- /** Addressed Gateway binds sessions to the verified workspace/storage scope. */
21
- sessionAuthority?: 'workspace-scope';
22
- requestId: string;
23
- }
24
- interface PiSessionCreateInit {
25
- title?: string;
26
- modelDefault?: ChatModelSelection;
27
- originChannel?: OriginChannel;
28
- }
29
- type PiChatReplayRangeError = {
30
- type: 'replay_gap';
31
- latestSeq: number;
32
- minReplaySeq: number;
33
- } | {
34
- type: 'cursor_ahead';
35
- latestSeq: number;
36
- minReplaySeq: number;
37
- };
38
- interface PiChatEventStreamSubscription {
39
- type: 'ok';
40
- unsubscribe: () => void;
41
- /** Optional test/service completion hook. Real live streams normally omit it. */
42
- closed?: Promise<void>;
43
- }
44
- type PiChatEventStreamResult = PiChatEventStreamSubscription | PiChatReplayRangeError;
45
- type PiChatEventSubscriber = (event: PiChatEvent) => void;
46
- interface PiChatSessionService {
47
- listSessions?(ctx: PiSessionRequestContext, options?: SessionListOptions): Promise<SessionSummary[]>;
48
- createSession?(ctx: PiSessionRequestContext, init?: PiSessionCreateInit): Promise<SessionSummary>;
49
- deleteSession?(ctx: PiSessionRequestContext, sessionId: string): Promise<void>;
50
- readAttachment?(ctx: PiSessionRequestContext, sessionId: string, messageId: string, index: number): Promise<PiChatAttachmentResult>;
51
- readState(ctx: PiSessionRequestContext, sessionId: string): Promise<PiChatSnapshot>;
52
- subscribe(ctx: PiSessionRequestContext, sessionId: string, cursor: number, subscriber: PiChatEventSubscriber): Promise<PiChatEventStreamResult>;
53
- prompt(ctx: PiSessionRequestContext, sessionId: string, payload: AgentPromptPayload): Promise<PromptReceipt>;
54
- followUp(ctx: PiSessionRequestContext, sessionId: string, payload: FollowUpPayload): Promise<FollowUpReceipt>;
55
- clearQueue(ctx: PiSessionRequestContext, sessionId: string, payload: QueueClearPayload): Promise<QueueClearReceipt>;
56
- interrupt(ctx: PiSessionRequestContext, sessionId: string, payload: InterruptPayload): Promise<CommandReceipt>;
57
- stop(ctx: PiSessionRequestContext, sessionId: string, payload: StopPayload): Promise<StopReceipt>;
58
- }
59
- interface AgentCoreSessionService extends PiChatSessionService {
60
- /** Trusted host-only durable-tail resolver; never exposed as an HTTP route. */
61
- resolveSessionStreamPath?(ctx: PiSessionRequestContext, sessionId: string): Promise<string>;
62
- /** Trusted host-only validation/binding seam; never exposed as an HTTP route. */
63
- ensurePiSessionBound?(ctx: PiSessionRequestContext, sessionId: string): Promise<void>;
64
- createSession(ctx: PiSessionRequestContext, init?: PiSessionCreateInit): Promise<SessionSummary>;
65
- deleteSession(ctx: PiSessionRequestContext, sessionId: string): Promise<void>;
66
- dispose?(): Promise<void>;
67
- }
68
- type AgentEffectAdmission = (ctx: Pick<PiSessionRequestContext, 'workspaceId' | 'requestId'>) => Promise<void>;
69
- declare class AgentEffectAdmissionError extends Error {
70
- readonly code: string;
71
- readonly details?: unknown | undefined;
72
- readonly statusCode = 500;
73
- constructor(code: string, details?: unknown | undefined);
74
- }
75
- declare const AGENT_EFFECT_METHODS: {
76
- readonly createSession: true;
77
- readonly deleteSession: true;
78
- readonly prompt: true;
79
- readonly followUp: true;
80
- readonly clearQueue: true;
81
- readonly interrupt: true;
82
- readonly stop: true;
83
- };
84
- declare function withAgentEffectAdmission(service: AgentCoreSessionService, admit: AgentEffectAdmission): AgentCoreSessionService;
85
-
86
- export { type AgentCoreSessionService as A, type PiChatEventStreamResult as P, type AgentEffectAdmission as a, AGENT_EFFECT_METHODS as b, AgentEffectAdmissionError as c, type PiChatEventStreamSubscription as d, type PiChatEventSubscriber as e, type PiChatReplayRangeError as f, type PiChatSessionService as g, type PiSessionCreateInit as h, type PiSessionRequestContext as i, type AgentPromptPayload as j, type PiChatAttachmentResult as k, withAgentEffectAdmission as w };
@@ -1,317 +0,0 @@
1
- interface WorkspaceRuntimeContext {
2
- /** Agent-visible working directory shared by file-tree and shell execution. */
3
- readonly runtimeCwd: string;
4
- }
5
-
6
- type RuntimeFilesystemCapability = 'read' | 'write' | 'create-child' | 'delete' | 'move-from';
7
- declare const READONLY_FILESYSTEM_MUTATION_CODE: "readonly";
8
- declare const RUNTIME_FILESYSTEM_CAPABILITIES: readonly ["read", "write", "create-child", "delete", "move-from"];
9
- declare class ReadonlyFilesystemMutationError extends Error {
10
- readonly code: "readonly";
11
- readonly statusCode: 403;
12
- readonly filesystem: string;
13
- readonly operation: RuntimeFilesystemCapability;
14
- constructor(filesystem: string, operation: RuntimeFilesystemCapability);
15
- }
16
- declare function isReadonlyFilesystemMutationError(value: unknown): value is ReadonlyFilesystemMutationError;
17
- interface Workspace {
18
- /** Agent-visible workspace root; must match runtimeContext.runtimeCwd. */
19
- readonly root: string;
20
- readonly runtimeContext: WorkspaceRuntimeContext;
21
- readFile(relPath: string): Promise<string>;
22
- /** Optional binary read operation for media/document previews. */
23
- readBinaryFile?(relPath: string): Promise<Uint8Array>;
24
- writeFile(relPath: string, data: string): Promise<void>;
25
- /**
26
- * Optional binary write operation for user-uploaded assets. Shared callers use
27
- * Uint8Array so browser-safe workspace contracts do not depend on Node-only types.
28
- */
29
- writeBinaryFile?(relPath: string, data: Uint8Array): Promise<void>;
30
- /**
31
- * Atomically creates a binary file without overwriting an existing path.
32
- * Implementations must throw an error with code EEXIST on collision.
33
- */
34
- createBinaryFile?(relPath: string, data: Uint8Array): Promise<void>;
35
- /**
36
- * Optional optimized read+metadata operation. Remote workspaces should
37
- * implement this as one round trip when possible.
38
- */
39
- readFileWithStat?(relPath: string): Promise<{
40
- content: string;
41
- stat: Stat;
42
- }>;
43
- /**
44
- * Optional optimized write+metadata operation. Remote workspaces should
45
- * implement this as one round trip when possible.
46
- */
47
- writeFileWithStat?(relPath: string, data: string): Promise<Stat>;
48
- /** Optional optimized binary write+metadata operation. */
49
- writeBinaryFileWithStat?(relPath: string, data: Uint8Array): Promise<Stat>;
50
- unlink(relPath: string): Promise<void>;
51
- readdir(relPath: string): Promise<Entry[]>;
52
- stat(relPath: string): Promise<Stat>;
53
- mkdir(relPath: string, opts?: {
54
- recursive?: boolean;
55
- }): Promise<void>;
56
- rename(fromRelPath: string, toRelPath: string): Promise<void>;
57
- /**
58
- * Optional change-event channel. Implementations that can observe
59
- * out-of-band file changes (e.g. local fs via chokidar, or an
60
- * in-process EventEmitter for sandbox-driven tool writes) return a
61
- * watcher; implementations that can't observe changes (and don't
62
- * want to fake it via polling) omit this method or leave it
63
- * undefined.
64
- *
65
- * Frontends should always assume the method may be missing and
66
- * degrade to "rely on tool-reported events + window-focus refetch."
67
- * Calling `watch()` more than once on a single workspace must yield
68
- * watchers that share the same underlying observation source —
69
- * spawning N OS-level watchers per HTTP connection is not allowed.
70
- */
71
- watch?(): WorkspaceWatcher;
72
- /**
73
- * Optional control-event channel for out-of-band changes.
74
- *
75
- * The primary `watch()` subscription is for fine-grained file
76
- * events. This is a secondary channel for coarse-grained external
77
- * events that should trigger a client-side resync — e.g. a bash
78
- * tool that mutates many files, or a git pull that swaps many refs.
79
- *
80
- * Implementations that can't observe changes (and don't
81
- * want to fake it via polling) omit this method or leave it
82
- * undefined.
83
- */
84
- notifyExternalChange?(event: WorkspaceWatchControlEvent): void;
85
- /**
86
- * Capability hint for hosts that want to render a UI affordance
87
- * ("connected"/"polling"/"manual refresh"). Optional — absence
88
- * means "treat as 'none' and consult `watch?` for the truth." When
89
- * present this is purely advisory; the actual events flow through
90
- * `watch()`.
91
- */
92
- readonly fsCapability?: FsCapability;
93
- }
94
- type FsCapability = 'none' | 'best-effort' | 'strong';
95
- interface Entry {
96
- name: string;
97
- kind: 'file' | 'dir';
98
- }
99
- interface Stat {
100
- size: number;
101
- mtimeMs: number;
102
- kind: 'file' | 'dir';
103
- }
104
- /**
105
- * Single fs-event payload. `op` is the canonical mutation kind, the
106
- * paths are workspace-relative, and `mtimeMs` is filled when the
107
- * implementation can stat the result cheaply (lets the client run an
108
- * idempotent staleness check without a follow-up stat request).
109
- */
110
- interface WorkspaceChangeEvent {
111
- op: 'write' | 'unlink' | 'rename' | 'mkdir';
112
- path: string;
113
- /** Set on rename only — the path before the move. */
114
- oldPath?: string;
115
- mtimeMs?: number;
116
- }
117
- /**
118
- * Result of a watcher's readiness probe. `ok: false` means the
119
- * implementation decided it cannot observe this workspace (e.g. the
120
- * tree is too large to watch without harming the host process) —
121
- * hosts should tell clients to fall back rather than wait for events
122
- * that will never come.
123
- */
124
- type WorkspaceWatcherReadiness = {
125
- ok: true;
126
- } | {
127
- ok: false;
128
- reason: string;
129
- message?: string;
130
- };
131
- interface WorkspaceWatchControlEvent {
132
- type: 'resync-required';
133
- reason: string;
134
- }
135
- interface WorkspaceWatchSubscribeOptions {
136
- /**
137
- * Called when the watcher detects a gap where changes may have been
138
- * missed. Consumers should drop caches/refetch instead of trusting
139
- * incremental events alone.
140
- */
141
- onControlEvent?: (event: WorkspaceWatchControlEvent) => void;
142
- }
143
- interface WorkspaceWatcher {
144
- /**
145
- * Add a listener for change events. Returns an unsubscribe fn —
146
- * the underlying observation source stays open until the workspace
147
- * itself is disposed, so unsubscribing one listener is cheap and
148
- * does NOT tear down the watcher.
149
- */
150
- subscribe(listener: (event: WorkspaceChangeEvent) => void, options?: WorkspaceWatchSubscribeOptions): () => void;
151
- /**
152
- * Optional readiness probe. Implementations with a startup guard
153
- * (workspace-size check, native module availability, …) resolve it
154
- * once the underlying source is observing — or with `ok: false`
155
- * when observation was refused. Absent → assume always ready.
156
- */
157
- whenReady?(): Promise<WorkspaceWatcherReadiness>;
158
- /**
159
- * Tear down the underlying observation source (chokidar instance,
160
- * sandbox emitter binding, …). Idempotent. Subscribers added after
161
- * close are no-ops. Hosts call this on workspace disposal.
162
- */
163
- close(): void;
164
- }
165
-
166
- /**
167
- * Capabilities a sandbox advertises. Consumers use this set to decide
168
- * whether a tool can run (e.g. `executeIsolatedCodeTool` only registers
169
- * when `'isolated-code'` is present). Backends opt in by including the
170
- * capability string in their `Sandbox.capabilities` array.
171
- *
172
- * Open string union — backends and downstream packages can extend it
173
- * without modifying this file (TypeScript declaration-merging or just
174
- * casting). New capabilities to expect over time:
175
- * - `'gpu'` — backend can attach GPUs to isolated-code calls
176
- * - `'persistent-fs'` — backend retains workspace state across sessions
177
- * - `'snapshot'` — backend supports baking + restoring snapshots
178
- * - `'network-allow'` — backend can apply egress allow/deny lists
179
- */
180
- type SandboxCapability = 'exec' | 'isolated-code' | (string & {});
181
- /**
182
- * Where the sandbox actually executes — relative to the agent backend
183
- * process running pi.
184
- *
185
- * - `'server'` — same process / same host as the agent backend (e.g.
186
- * `DirectSandbox`, `BwrapSandbox`).
187
- * - `'remote'` — a separate machine reached over the network (e.g.
188
- * `VercelSandboxExec` Firecracker VM, SSH, Modal, Docker host
189
- * accessed by API). Implementations must tolerate higher latency and
190
- * handle abort by signalling the remote.
191
- * - `'browser'` — runs in the user's browser (e.g. WASM bash,
192
- * `JustBashSandbox`). Reserved for future browser-agent mode.
193
- */
194
- type SandboxPlacement = 'server' | 'remote' | 'browser';
195
- interface Sandbox {
196
- /** Stable identifier for this sandbox instance. */
197
- readonly id: string;
198
- /** Where the sandbox runs relative to the agent backend. */
199
- readonly placement: SandboxPlacement;
200
- /**
201
- * Provider name — e.g. `'direct'`, `'bwrap'`, `'vercel-sandbox'`,
202
- * `'docker'`, `'modal'`, `'apple-container'`, `'ssh'`. Used for
203
- * telemetry, diagnostics, and capability negotiation. Free-form
204
- * convention: matches the runtime mode id where one exists.
205
- */
206
- readonly provider: string;
207
- /** Capabilities this sandbox advertises (used for tool gating). */
208
- readonly capabilities: readonly SandboxCapability[];
209
- /** Agent-visible runtime cwd; must match the paired Workspace root. */
210
- readonly runtimeContext: WorkspaceRuntimeContext;
211
- /**
212
- * Optional initialization hook. Some backends bind to a workspace +
213
- * session at construction (Vercel: snapshot warm-up; Bwrap: bind
214
- * mounts). Ephemeral backends (Direct, on-demand Docker exec) can
215
- * omit this entirely.
216
- */
217
- init?(ctx: {
218
- workspace: Workspace;
219
- sessionId: string;
220
- }): Promise<void>;
221
- /**
222
- * Run a shell command. Required capability: `'exec'`.
223
- *
224
- * Implementations MUST honor `signal` for abort, `timeoutMs` for
225
- * timeout, and `maxOutputBytes` for output truncation (and set
226
- * `truncated: true` in the result when truncation fires).
227
- *
228
- * The optional `onStdout` / `onStderr` callbacks (when implemented)
229
- * stream output incrementally as bytes arrive. When omitted,
230
- * implementations buffer normally and surface output via
231
- * `ExecResult.stdout` / `stderr` only. See the `Sandbox.exec` streaming
232
- * extension added in Phase 1.0.
233
- */
234
- exec(cmd: string, opts?: ExecOptions): Promise<ExecResult>;
235
- /**
236
- * Run a self-contained snippet of code in an ephemeral sandbox
237
- * instance. Capability: `'isolated-code'`. Optional — backends that
238
- * cannot offer per-call isolation (`DirectSandbox`, `BwrapSandbox`)
239
- * omit this method entirely.
240
- */
241
- executeIsolatedCode?(input: IsolatedCodeInput): Promise<IsolatedCodeOutput>;
242
- dispose?(): Promise<void>;
243
- }
244
- interface ExecOptions {
245
- /** Runtime-visible cwd. Relative paths resolve from `runtimeContext.runtimeCwd`. */
246
- cwd?: string;
247
- env?: Record<string, string>;
248
- signal?: AbortSignal;
249
- timeoutMs?: number;
250
- maxOutputBytes?: number;
251
- onHeartbeat?: (elapsedMs: number) => void;
252
- onStdout?: (chunk: Uint8Array) => void;
253
- onStderr?: (chunk: Uint8Array) => void;
254
- }
255
- interface ExecResult {
256
- stdout: Uint8Array;
257
- stderr: Uint8Array;
258
- exitCode: number;
259
- durationMs: number;
260
- truncated: boolean;
261
- stdoutEncoding?: 'utf-8' | 'binary';
262
- stderrEncoding?: 'utf-8' | 'binary';
263
- }
264
- /**
265
- * Abstract resource hints for `executeIsolatedCode`. Backends round to
266
- * their own size tiers (Vercel: `xxs`/…/`l`; Modal: `cpu`/`memory`
267
- * floats; Docker: cgroups). Each field is a HINT, not a contract — a
268
- * backend may ignore or clamp values it cannot honor.
269
- */
270
- interface SandboxResources {
271
- /** Requested logical CPU cores. Backend rounds up. */
272
- cpuCores?: number;
273
- /** Requested memory in MB. Backend rounds up. */
274
- memoryMb?: number;
275
- /**
276
- * GPU class hint. Free-form vendor-specific token (e.g. `'t4'`,
277
- * `'a10g'`, `'h100'`). Empty/omitted means CPU-only. Only honored
278
- * when the sandbox advertises capability `'gpu'`.
279
- */
280
- gpu?: string;
281
- }
282
- interface IsolatedCodeInput {
283
- code: string;
284
- language: 'python' | 'shell';
285
- /**
286
- * Container / snapshot identifier. Format is vendor-specific:
287
- * Docker → image ref (`node:20`), Vercel → `snapshotId`, Modal →
288
- * image name, Apple-container → bundle path. Treat as opaque.
289
- */
290
- image?: string;
291
- /**
292
- * Per-call dependencies (npm/pip-style). Honored by backends that
293
- * build environments on demand (Modal, Vercel snapshot-bake).
294
- * Ignored by backends that require pre-built images (vanilla Docker
295
- * exec).
296
- */
297
- packages?: string[];
298
- /** Reuse an existing sandbox handle if the backend supports it. */
299
- sandboxId?: string;
300
- /** Generic resource request. Backends round to their own size tiers. */
301
- resources?: SandboxResources;
302
- /**
303
- * Backend-specific knobs that don't fit the generic shape — opaque
304
- * pass-through. Example: Modal's `min_containers`, Docker's
305
- * `--cap-add`, Vercel's `region`. Consumers should never read this
306
- * field; it exists so callers can target a specific provider.
307
- */
308
- vendorHints?: Record<string, unknown>;
309
- }
310
- interface IsolatedCodeOutput {
311
- sandboxId: string;
312
- stdout: string;
313
- stderr: string;
314
- exitCode: number;
315
- }
316
-
317
- export { type Entry as E, type IsolatedCodeInput as I, READONLY_FILESYSTEM_MUTATION_CODE as R, type Stat as S, type WorkspaceChangeEvent as W, type ExecResult as a, type Workspace as b, type Sandbox as c, type ExecOptions as d, type IsolatedCodeOutput as e, RUNTIME_FILESYSTEM_CAPABILITIES as f, ReadonlyFilesystemMutationError as g, type RuntimeFilesystemCapability as h, type SandboxCapability as i, type WorkspaceRuntimeContext as j, type WorkspaceWatchControlEvent as k, isReadonlyFilesystemMutationError as l };
@@ -1,8 +0,0 @@
1
- import { FastifyInstance } from 'fastify';
2
-
3
- /** Executable final route-table proof shared by every composition root. */
4
- declare function assertComposedAgentHostRouteTable(app: FastifyInstance, options?: {
5
- readonly testOnlyAllowed?: readonly string[];
6
- }): void;
7
-
8
- export { assertComposedAgentHostRouteTable };
@@ -1,78 +0,0 @@
1
- // src/server/agent-host/testing/compositionRouteProof.ts
2
- var EXPECTED_ROUTES_ENV = "BORING_AGENTHOST_EXPECTED_ROUTES";
3
- var FALLBACK_EXPECTED_ROUTES = [
4
- "GET /api/v1/agents",
5
- "GET /api/v1/agents/:agentTypeId/sessions",
6
- "POST /api/v1/agents/:agentTypeId/sessions/summaries",
7
- "POST /api/v1/agents/:agentTypeId/sessions",
8
- "DELETE /api/v1/agents/:agentTypeId/sessions/:sessionId",
9
- "GET /api/v1/agents/:agentTypeId/sessions/:sessionId/state",
10
- "GET /api/v1/agents/:agentTypeId/sessions/:sessionId/events",
11
- "POST /api/v1/agents/:agentTypeId/sessions/:sessionId/rename",
12
- "POST /api/v1/agents/:agentTypeId/sessions/:sessionId/prompt",
13
- "POST /api/v1/agents/:agentTypeId/sessions/:sessionId/followup",
14
- "POST /api/v1/agents/:agentTypeId/sessions/:sessionId/queue/clear",
15
- "POST /api/v1/agents/:agentTypeId/sessions/:sessionId/interrupt",
16
- "POST /api/v1/agents/:agentTypeId/sessions/:sessionId/stop",
17
- "GET /api/v1/agents/:agentTypeId/sessions/:sessionId/attachments/:messageId/:index",
18
- "POST /api/v1/agents/:agentTypeId/reload",
19
- "GET /api/v1/agents/:agentTypeId/skills",
20
- "GET /api/v1/agents/:agentTypeId/commands",
21
- "POST /api/v1/agents/:agentTypeId/commands/execute",
22
- "GET /api/v1/agents/:agentTypeId/models",
23
- "GET /api/v1/agents/:agentTypeId/sessions/:sessionId/system-prompt",
24
- "GET /api/v1/agents/:agentTypeId/tools",
25
- "GET /api/v1/agents/:agentTypeId/describe",
26
- "GET /api/v1/agents/:agentTypeId/sessions/:sessionId/changes",
27
- "GET /api/v1/agents/:agentTypeId/ready-status"
28
- ];
29
- function configuredContract() {
30
- const encoded = process.env[EXPECTED_ROUTES_ENV];
31
- if (!encoded) return { required: FALLBACK_EXPECTED_ROUTES, allowed: FALLBACK_EXPECTED_ROUTES, classified: FALLBACK_EXPECTED_ROUTES };
32
- const parsed = JSON.parse(encoded);
33
- if (!Array.isArray(parsed.required) || !Array.isArray(parsed.allowed) || !Array.isArray(parsed.classified)) {
34
- throw new Error("invalid Agent Host route proof contract");
35
- }
36
- return parsed;
37
- }
38
- function composedMatrixRoutes(app, classified) {
39
- const routes = /* @__PURE__ */ new Map();
40
- const parentPaths = [];
41
- for (const line of app.printRoutes({ commonPrefix: false }).split("\n")) {
42
- const match = line.match(/^((?:│ | )*)[├└]── (\/\S+) \(([^)]+)\)$/);
43
- if (!match) continue;
44
- const depth = match[1].length / 4;
45
- const path = depth === 0 ? match[2] : `${parentPaths[depth - 1]}${match[2]}`;
46
- parentPaths[depth] = path;
47
- parentPaths.length = depth + 1;
48
- for (const method of match[3].split(",").map((value) => value.trim())) {
49
- if (method === "HEAD") continue;
50
- const contract = `${method} ${path}`;
51
- if (!classified.has(contract)) continue;
52
- routes.set(contract, (routes.get(contract) ?? 0) + 1);
53
- }
54
- }
55
- return routes;
56
- }
57
- function assertComposedAgentHostRouteTable(app, options = {}) {
58
- const expected = configuredContract();
59
- if (expected.required.length === 0) throw new Error("expected Agent Host route table is empty");
60
- const observed = composedMatrixRoutes(app, new Set(expected.classified));
61
- const allowed = /* @__PURE__ */ new Set([...expected.allowed, ...options.testOnlyAllowed ?? []]);
62
- for (const contract of expected.required) {
63
- const count = observed.get(contract) ?? 0;
64
- if (count !== 1) throw new Error(
65
- `composed Agent Host route multiplicity is ${count}, expected 1: ${contract}
66
- ${app.printRoutes({ commonPrefix: false })}`
67
- );
68
- }
69
- for (const [contract, count] of observed) {
70
- if (!allowed.has(contract)) {
71
- throw new Error(`matrix route is composed but not applicable to this root: ${contract}`);
72
- }
73
- if (count !== 1) throw new Error(`duplicate Agent route is composed (${count}): ${contract}`);
74
- }
75
- }
76
- export {
77
- assertComposedAgentHostRouteTable
78
- };
@@ -1,43 +0,0 @@
1
- import { A as AgentGateway, a as AuthorizedAgentScope, b as AgentSessionRef, c as AgentSessionActivity } from '../../../admin-DORVQfLn.js';
2
- import { A as AgentGatewayEffect } from '../../../types-DcWoQMn8.js';
3
- import '../../../piChatEvent-DpE0lIb9.js';
4
- import 'zod';
5
- import '../../../harness-qHlMJhZo.js';
6
- import '@mariozechner/pi-coding-agent';
7
- import 'fastify';
8
- import '../../../file-search-BUgMSKZE.js';
9
- import '../../../sandbox-BMhut3kh.js';
10
- import '@hachej/boring-bash/agent';
11
- import '@hachej/boring-sandbox/providers/bwrap';
12
- import '@hachej/boring-sandbox/providers/node-workspace';
13
- import '@earendil-works/pi-ai';
14
-
15
- /** G1 ships only the embedded bounded-replay contract. */
16
- type GatewayReplayConformanceLevel = 'B';
17
- /** G1 ships only mutation-best-effort keyset pagination. */
18
- type GatewayPaginationConformanceLevel = 'keyset';
19
- interface GatewayConformanceFixture {
20
- readonly gateway: AgentGateway;
21
- issueScope(input?: {
22
- readonly workspaceScopeId?: string;
23
- readonly authSubjectId?: string;
24
- readonly issuer?: 'primary' | 'foreign';
25
- }): AuthorizedAgentScope;
26
- revoke(scope: AuthorizedAgentScope): void;
27
- setActivity(ref: AgentSessionRef, activity: AgentSessionActivity): void;
28
- moveSession(ref: AgentSessionRef, updatedAt: number): void;
29
- queueAdmission(operation: AgentGatewayEffect, disposition: 'strong-reject' | 'retryable'): void;
30
- }
31
- interface GatewayConformanceOptions {
32
- readonly createFixture: () => Promise<GatewayConformanceFixture>;
33
- readonly replayLevel: GatewayReplayConformanceLevel;
34
- readonly paginationLevel: GatewayPaginationConformanceLevel;
35
- }
36
- /**
37
- * Registers the placement-independent Gateway semantic contract against any
38
- * implementation. Pagination capability is intentionally independent of the
39
- * replay durability level.
40
- */
41
- declare function gatewayConformance(options: GatewayConformanceOptions): void;
42
-
43
- export { type GatewayConformanceFixture, type GatewayConformanceOptions, type GatewayPaginationConformanceLevel, type GatewayReplayConformanceLevel, gatewayConformance };