@hachej/boring-agent 0.1.75 → 0.1.77
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.
- package/dist/{chunk-AQVEZYLH.js → chunk-3WWLQAJB.js} +52 -13
- package/dist/{chunk-XZKU7FBV.js → chunk-6AEK34XU.js} +2 -0
- package/dist/{chunk-4LXA7OOV.js → chunk-ORURYKNY.js} +1 -1
- package/dist/{chunk-FDGWCMJD.js → chunk-TS3QGFKK.js} +3 -2
- package/dist/{chunk-WSQ5QNIY.js → chunk-ZUEITFIJ.js} +12 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +8 -4
- package/dist/{createHarness-B3MYGFVB.js → createHarness-RZUU6MJQ.js} +2 -2
- package/dist/front/index.d.ts +2 -3
- package/dist/front/index.js +2 -2
- package/dist/{harness-Dwxh6USt.d.ts → harness-OsJBlx4u.d.ts} +10 -2
- package/dist/piChatCommand-BuWXytap.d.ts +60 -0
- package/dist/server/index.d.ts +28 -6
- package/dist/server/index.js +714 -287
- package/dist/session-FUiMWsyX.d.ts +297 -0
- package/dist/shared/index.d.ts +25 -26
- package/dist/shared/index.js +7 -3
- package/dist/{agentPluginEvents-CqLTEdG2.d.ts → workspaceAgentDispatcher-Cl3EBveh.d.ts} +15 -1
- package/docs/API.md +27 -0
- package/docs/ERROR_CODES.md +2 -0
- package/docs/runtime.md +12 -0
- package/package.json +2 -2
- package/dist/chatSubmitPayload-DwOHyiqR.d.ts +0 -22
- package/dist/piChatCommand-CSepU1NX.d.ts +0 -40
- package/dist/session-DKMQNtNG.d.ts +0 -297
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AgentFilesystemRequiredError,
|
|
2
3
|
AgentNotImplementedError,
|
|
3
4
|
sessionStreamPath
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZUEITFIJ.js";
|
|
5
6
|
import {
|
|
6
7
|
extractToolUiMetadata,
|
|
7
8
|
sanitizeToolUiMetadata2 as sanitizeToolUiMetadata
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ORURYKNY.js";
|
|
9
10
|
import {
|
|
10
11
|
createLogger
|
|
11
12
|
} from "./chunk-AJZHR626.js";
|
|
12
13
|
import {
|
|
13
14
|
ErrorCode
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6AEK34XU.js";
|
|
15
16
|
|
|
16
17
|
// src/server/pi-chat/metering.ts
|
|
17
18
|
var meteringLogger = createLogger("pi-chat-metering");
|
|
@@ -1627,6 +1628,7 @@ var HarnessPiChatService = class {
|
|
|
1627
1628
|
workdir;
|
|
1628
1629
|
workspace;
|
|
1629
1630
|
eventStore;
|
|
1631
|
+
allowAttachments;
|
|
1630
1632
|
channels = /* @__PURE__ */ new Map();
|
|
1631
1633
|
// Single-flight guard so concurrent cold callers (e.g. two browser tabs each
|
|
1632
1634
|
// opening /events while the session is still being created) converge on one
|
|
@@ -1644,6 +1646,7 @@ var HarnessPiChatService = class {
|
|
|
1644
1646
|
this.workdir = options.workdir;
|
|
1645
1647
|
this.workspace = options.workspace;
|
|
1646
1648
|
this.eventStore = options.eventStore;
|
|
1649
|
+
this.allowAttachments = options.allowAttachments !== false;
|
|
1647
1650
|
this.metering = options.metering ? new PiChatMeteringCoordinator(options.metering, options.meteringLogger) : void 0;
|
|
1648
1651
|
}
|
|
1649
1652
|
/** Test/diagnostic hook: resolves once queued metering sink calls settle. */
|
|
@@ -1722,6 +1725,7 @@ var HarnessPiChatService = class {
|
|
|
1722
1725
|
return { type: "ok", unsubscribe: result.unsubscribe, closed: channel.closed };
|
|
1723
1726
|
}
|
|
1724
1727
|
async prompt(ctx, sessionId, payload) {
|
|
1728
|
+
this.assertAttachmentsAllowed(payload);
|
|
1725
1729
|
const sessionKey = this.sessionKey(ctx, sessionId);
|
|
1726
1730
|
const adapter = await this.getAdapter(ctx, sessionId, payload);
|
|
1727
1731
|
const channel = await this.ensureChannel(ctx, sessionId, adapter);
|
|
@@ -1762,6 +1766,10 @@ var HarnessPiChatService = class {
|
|
|
1762
1766
|
}
|
|
1763
1767
|
return { accepted: true, cursor: receiptCursor, clientNonce: payload.clientNonce };
|
|
1764
1768
|
}
|
|
1769
|
+
assertAttachmentsAllowed(payload) {
|
|
1770
|
+
if (this.allowAttachments || !payload.attachments || payload.attachments.length === 0) return;
|
|
1771
|
+
throw new AgentFilesystemRequiredError();
|
|
1772
|
+
}
|
|
1765
1773
|
async followUp(ctx, sessionId, payload) {
|
|
1766
1774
|
const sessionKey = this.sessionKey(ctx, sessionId);
|
|
1767
1775
|
const adapter = await this.getAdapter(ctx, sessionId, payload.message);
|
|
@@ -2160,13 +2168,13 @@ function promptCancelledError() {
|
|
|
2160
2168
|
});
|
|
2161
2169
|
}
|
|
2162
2170
|
function deferred() {
|
|
2163
|
-
let
|
|
2171
|
+
let resolve2;
|
|
2164
2172
|
let reject;
|
|
2165
2173
|
const promise = new Promise((nextResolve, nextReject) => {
|
|
2166
|
-
|
|
2174
|
+
resolve2 = nextResolve;
|
|
2167
2175
|
reject = nextReject;
|
|
2168
2176
|
});
|
|
2169
|
-
return { promise, resolve, reject };
|
|
2177
|
+
return { promise, resolve: resolve2, reject };
|
|
2170
2178
|
}
|
|
2171
2179
|
function normalizeSessionAccessError(error, sessionId) {
|
|
2172
2180
|
if (error?.code === ErrorCode.enum.SESSION_NOT_FOUND || isPlainSessionNotFound(error, sessionId)) {
|
|
@@ -2307,6 +2315,29 @@ function sessionCacheKey(sessionId, ctx) {
|
|
|
2307
2315
|
return JSON.stringify([sessionId, ctx.workspaceId ?? "", ctx.userId ?? ""]);
|
|
2308
2316
|
}
|
|
2309
2317
|
|
|
2318
|
+
// src/server/runtime/pureRuntime.ts
|
|
2319
|
+
import { chmod, mkdir, mkdtemp } from "fs/promises";
|
|
2320
|
+
import { tmpdir } from "os";
|
|
2321
|
+
import { join, resolve } from "path";
|
|
2322
|
+
var PURE_RUNTIME_CWD_NAME = ".runtime-none";
|
|
2323
|
+
var defaultPureRuntimeCwd;
|
|
2324
|
+
async function createPureRuntimeCwd(sessionRoot) {
|
|
2325
|
+
const explicitRoot = sessionRoot?.trim();
|
|
2326
|
+
if (!explicitRoot) {
|
|
2327
|
+
defaultPureRuntimeCwd ??= createDefaultPureRuntimeCwd();
|
|
2328
|
+
return defaultPureRuntimeCwd;
|
|
2329
|
+
}
|
|
2330
|
+
const cwd = join(resolve(explicitRoot), PURE_RUNTIME_CWD_NAME);
|
|
2331
|
+
await mkdir(cwd, { recursive: true, mode: 448 });
|
|
2332
|
+
await chmod(cwd, 448);
|
|
2333
|
+
return cwd;
|
|
2334
|
+
}
|
|
2335
|
+
async function createDefaultPureRuntimeCwd() {
|
|
2336
|
+
const cwd = await mkdtemp(join(tmpdir(), "boring-agent-pure-"));
|
|
2337
|
+
await chmod(cwd, 448);
|
|
2338
|
+
return cwd;
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2310
2341
|
// src/server/createAgent.ts
|
|
2311
2342
|
var DEFAULT_WORKDIR = "";
|
|
2312
2343
|
var DEFAULT_LIVE_BUFFER_SIZE = 1e3;
|
|
@@ -2363,6 +2394,7 @@ function createAgentRuntimeBridge(config, options = {}) {
|
|
|
2363
2394
|
}
|
|
2364
2395
|
}
|
|
2365
2396
|
async function start(input) {
|
|
2397
|
+
assertFilesystemAttachmentsAllowed(config, input);
|
|
2366
2398
|
const runtime = await getRuntime();
|
|
2367
2399
|
const { sessionId, sessionKey, ctx } = await ensureSession(input, runtime);
|
|
2368
2400
|
startedSessions.set(sessionKey, { sessionId, ctx });
|
|
@@ -2453,11 +2485,13 @@ function createRuntimeLoader(config, options) {
|
|
|
2453
2485
|
};
|
|
2454
2486
|
}
|
|
2455
2487
|
async function createRuntime(config, options) {
|
|
2456
|
-
const harnessFactory = config.harnessFactory ?? (await import("./createHarness-
|
|
2488
|
+
const harnessFactory = config.harnessFactory ?? (await import("./createHarness-RZUU6MJQ.js")).createPiCodingAgentHarness;
|
|
2489
|
+
const pureRuntimeCwd = config.runtime === "none" ? await createPureRuntimeCwd(config.sessionStorageRoot) : void 0;
|
|
2457
2490
|
const harnessInput = {
|
|
2458
2491
|
tools: config.tools ?? [],
|
|
2459
|
-
cwd: config.workdir ?? DEFAULT_WORKDIR,
|
|
2460
|
-
runtimeCwd: options.harness?.runtimeCwd ?? options.service?.workdir ?? config.workdir,
|
|
2492
|
+
cwd: pureRuntimeCwd ?? config.workdir ?? DEFAULT_WORKDIR,
|
|
2493
|
+
runtimeCwd: pureRuntimeCwd ?? options.harness?.runtimeCwd ?? options.service?.workdir ?? config.workdir,
|
|
2494
|
+
sessionStorageCwd: pureRuntimeCwd ? DEFAULT_WORKDIR : void 0,
|
|
2461
2495
|
systemPromptAppend: config.systemPromptAppend,
|
|
2462
2496
|
systemPromptDynamic: config.systemPromptDynamic,
|
|
2463
2497
|
sessionRoot: config.sessionStorageRoot,
|
|
@@ -2471,13 +2505,18 @@ async function createRuntime(config, options) {
|
|
|
2471
2505
|
service: new HarnessPiChatService({
|
|
2472
2506
|
harness,
|
|
2473
2507
|
sessionStore,
|
|
2474
|
-
workdir: options.service?.workdir ?? config.workdir ?? DEFAULT_WORKDIR,
|
|
2508
|
+
workdir: pureRuntimeCwd ?? options.service?.workdir ?? config.workdir ?? DEFAULT_WORKDIR,
|
|
2475
2509
|
workspace: options.service?.workspace,
|
|
2476
2510
|
eventStore: options.service?.eventStore,
|
|
2511
|
+
allowAttachments: config.runtime !== "none",
|
|
2477
2512
|
metering: config.metering
|
|
2478
2513
|
})
|
|
2479
2514
|
};
|
|
2480
2515
|
}
|
|
2516
|
+
function assertFilesystemAttachmentsAllowed(config, input) {
|
|
2517
|
+
if (config.runtime !== "none" || !input.attachments || input.attachments.length === 0) return;
|
|
2518
|
+
throw new AgentFilesystemRequiredError();
|
|
2519
|
+
}
|
|
2481
2520
|
function createReadiness(config) {
|
|
2482
2521
|
const requirements = [...config.readinessRequirements ?? []];
|
|
2483
2522
|
return {
|
|
@@ -2602,8 +2641,8 @@ async function acquireSessionLock(locks, sessionId) {
|
|
|
2602
2641
|
const previous = locks.get(sessionId) ?? Promise.resolve();
|
|
2603
2642
|
let release;
|
|
2604
2643
|
const current = previous.catch(() => {
|
|
2605
|
-
}).then(() => new Promise((
|
|
2606
|
-
release =
|
|
2644
|
+
}).then(() => new Promise((resolve2) => {
|
|
2645
|
+
release = resolve2;
|
|
2607
2646
|
}));
|
|
2608
2647
|
locks.set(sessionId, current);
|
|
2609
2648
|
await previous.catch(() => {
|
|
@@ -2735,7 +2774,7 @@ function createLiveIterator(state, startIndex) {
|
|
|
2735
2774
|
async next() {
|
|
2736
2775
|
if (queued.length > 0) return { value: queued.shift(), done: false };
|
|
2737
2776
|
if (!active || state.closed) return { value: void 0, done: true };
|
|
2738
|
-
return new Promise((
|
|
2777
|
+
return new Promise((resolve2) => waiters.push(resolve2));
|
|
2739
2778
|
},
|
|
2740
2779
|
async return() {
|
|
2741
2780
|
active = false;
|
|
@@ -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_CONTROL_RECEIPT_INVALID",
|
|
22
23
|
"RUNTIME_PROVISIONING_FAILED",
|
|
23
24
|
"RUNTIME_PROVISIONING_LOCKED",
|
|
24
25
|
// Sandbox / exec
|
|
@@ -69,6 +70,7 @@ var ErrorCode = z.enum([
|
|
|
69
70
|
"PROVISIONING_ARTIFACT_FAILED",
|
|
70
71
|
// Internal
|
|
71
72
|
"ERR_NOT_IMPLEMENTED_UNTIL_T1",
|
|
73
|
+
"ERR_NO_FILESYSTEM_FOR_ATTACHMENTS",
|
|
72
74
|
"INTERNAL_ERROR"
|
|
73
75
|
]);
|
|
74
76
|
var ERROR_CODES = ErrorCode.options;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-AJZHR626.js";
|
|
8
8
|
import {
|
|
9
9
|
ErrorCode
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6AEK34XU.js";
|
|
11
11
|
|
|
12
12
|
// src/server/harness/pi-coding-agent/createHarness.ts
|
|
13
13
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -341,6 +341,7 @@ function sessionBaseDir(explicitRoot) {
|
|
|
341
341
|
return configured ? resolve(configured) : join(homedir(), ".pi", "agent", "sessions");
|
|
342
342
|
}
|
|
343
343
|
function defaultSessionDir(cwd, explicitRoot) {
|
|
344
|
+
if (explicitRoot && cwd.trim().length === 0) return sessionBaseDir(explicitRoot);
|
|
344
345
|
const safePath = `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
345
346
|
return join(sessionBaseDir(explicitRoot), safePath);
|
|
346
347
|
}
|
|
@@ -1505,7 +1506,7 @@ function createPiCodingAgentHarness(opts) {
|
|
|
1505
1506
|
sessionNamespace: opts.sessionNamespace,
|
|
1506
1507
|
sessionRoot: opts.sessionRoot,
|
|
1507
1508
|
sessionDir: opts.sessionDir,
|
|
1508
|
-
storageCwd: opts.cwd
|
|
1509
|
+
storageCwd: opts.sessionStorageCwd ?? opts.cwd
|
|
1509
1510
|
});
|
|
1510
1511
|
const piSessions = /* @__PURE__ */ new Map();
|
|
1511
1512
|
const runContextStorage = new AsyncLocalStorage();
|
|
@@ -1,5 +1,6 @@
|
|
|
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";
|
|
3
4
|
function sessionStreamPath(sessionId) {
|
|
4
5
|
return `sessions/${sessionId}`;
|
|
5
6
|
}
|
|
@@ -10,9 +11,19 @@ var AgentNotImplementedError = class extends Error {
|
|
|
10
11
|
this.name = "AgentNotImplementedError";
|
|
11
12
|
}
|
|
12
13
|
};
|
|
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
|
+
};
|
|
13
22
|
|
|
14
23
|
export {
|
|
15
24
|
AGENT_NOT_IMPLEMENTED_UNTIL_T1,
|
|
25
|
+
AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS,
|
|
16
26
|
sessionStreamPath,
|
|
17
|
-
AgentNotImplementedError
|
|
27
|
+
AgentNotImplementedError,
|
|
28
|
+
AgentFilesystemRequiredError
|
|
18
29
|
};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { a as AGENT_NOT_IMPLEMENTED_UNTIL_T1,
|
|
3
|
-
import '../session-
|
|
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
4
|
import 'zod';
|
|
5
5
|
import '@mariozechner/pi-coding-agent';
|
|
6
6
|
|
package/dist/core/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAgent
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-3WWLQAJB.js";
|
|
4
4
|
import {
|
|
5
5
|
AGENT_NOT_IMPLEMENTED_UNTIL_T1,
|
|
6
|
+
AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS,
|
|
7
|
+
AgentFilesystemRequiredError,
|
|
6
8
|
AgentNotImplementedError
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-ZUEITFIJ.js";
|
|
10
|
+
import "../chunk-ORURYKNY.js";
|
|
9
11
|
import "../chunk-AJZHR626.js";
|
|
10
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-6AEK34XU.js";
|
|
11
13
|
export {
|
|
12
14
|
AGENT_NOT_IMPLEMENTED_UNTIL_T1,
|
|
15
|
+
AGENT_NO_FILESYSTEM_FOR_ATTACHMENTS,
|
|
16
|
+
AgentFilesystemRequiredError,
|
|
13
17
|
AgentNotImplementedError,
|
|
14
18
|
createAgent
|
|
15
19
|
};
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
deriveSourcePlugin,
|
|
5
5
|
mergePiPackageSources,
|
|
6
6
|
withPiHarnessDefaults
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TS3QGFKK.js";
|
|
8
8
|
import "./chunk-AQBXNPMD.js";
|
|
9
9
|
import "./chunk-AJZHR626.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-6AEK34XU.js";
|
|
11
11
|
export {
|
|
12
12
|
createPiCodingAgentHarness,
|
|
13
13
|
createResourceSettingsManager,
|
package/dist/front/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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-
|
|
5
|
-
import { P as PromptPayload,
|
|
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';
|
|
6
6
|
import { InputGroupAddon, InputGroupButton, InputGroupTextarea, Button, Collapsible, CollapsibleContent, CollapsibleTrigger } from '@hachej/boring-ui-kit';
|
|
7
7
|
import { Streamdown } from 'streamdown';
|
|
8
8
|
import { StickToBottom } from 'use-stick-to-bottom';
|
|
9
9
|
import { ClassValue } from 'clsx';
|
|
10
10
|
import 'zod';
|
|
11
|
-
import '../chatSubmitPayload-DwOHyiqR.js';
|
|
12
11
|
|
|
13
12
|
interface UploadFileOptions {
|
|
14
13
|
apiBaseUrl?: string;
|
package/dist/front/index.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
StopReceiptSchema,
|
|
13
13
|
extractToolUiMetadata,
|
|
14
14
|
sanitizeToolUiMetadata
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-ORURYKNY.js";
|
|
16
16
|
import {
|
|
17
17
|
ErrorCode
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-6AEK34XU.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-
|
|
1
|
+
import { S as SessionCtx, P as PiChatEvent, a as SessionStore } from './session-FUiMWsyX.js';
|
|
2
2
|
import { AgentSessionEvent, PromptOptions } from '@mariozechner/pi-coding-agent';
|
|
3
3
|
|
|
4
4
|
interface TelemetrySink {
|
|
@@ -47,6 +47,7 @@ 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";
|
|
50
51
|
interface MessageAttachment {
|
|
51
52
|
filename?: string;
|
|
52
53
|
mediaType?: string;
|
|
@@ -140,6 +141,11 @@ declare class AgentNotImplementedError extends Error {
|
|
|
140
141
|
readonly code: "ERR_NOT_IMPLEMENTED_UNTIL_T1";
|
|
141
142
|
constructor(message?: string);
|
|
142
143
|
}
|
|
144
|
+
declare class AgentFilesystemRequiredError extends Error {
|
|
145
|
+
readonly code: "ERR_NO_FILESYSTEM_FOR_ATTACHMENTS";
|
|
146
|
+
readonly statusCode = 400;
|
|
147
|
+
constructor(message?: string);
|
|
148
|
+
}
|
|
143
149
|
|
|
144
150
|
interface AgentHarnessFactoryInput {
|
|
145
151
|
tools: AgentTool[];
|
|
@@ -147,6 +153,8 @@ interface AgentHarnessFactoryInput {
|
|
|
147
153
|
cwd: string;
|
|
148
154
|
/** Agent-visible cwd used by Pi/system prompt/session metadata. */
|
|
149
155
|
runtimeCwd?: string;
|
|
156
|
+
/** Optional cwd used only to derive the default transcript storage directory. */
|
|
157
|
+
sessionStorageCwd?: string;
|
|
150
158
|
systemPromptAppend?: string;
|
|
151
159
|
sessionNamespace?: string;
|
|
152
160
|
sessionRoot?: string;
|
|
@@ -262,4 +270,4 @@ interface RunContext {
|
|
|
262
270
|
allowPromptDispatch?: boolean;
|
|
263
271
|
}
|
|
264
272
|
|
|
265
|
-
export { type AgentTool as A,
|
|
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 };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Q as QueuedUserMessage } from './session-FUiMWsyX.js';
|
|
2
|
+
|
|
3
|
+
type ThinkingLevel = 'off' | 'low' | 'medium' | 'high';
|
|
4
|
+
interface ChatModelSelection {
|
|
5
|
+
provider: string;
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
interface ChatAttachmentPayload {
|
|
9
|
+
filename?: string;
|
|
10
|
+
mediaType?: string;
|
|
11
|
+
url: string;
|
|
12
|
+
/** Workspace-relative path when the browser upload endpoint persisted the attachment. */
|
|
13
|
+
path?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ChatSubmitPayload {
|
|
16
|
+
message: string;
|
|
17
|
+
displayMessage?: string;
|
|
18
|
+
clientNonce: string;
|
|
19
|
+
model?: ChatModelSelection;
|
|
20
|
+
thinkingLevel?: ThinkingLevel;
|
|
21
|
+
attachments?: ChatAttachmentPayload[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type PromptPayload = ChatSubmitPayload;
|
|
25
|
+
interface FollowUpPayload {
|
|
26
|
+
message: string;
|
|
27
|
+
displayMessage?: string;
|
|
28
|
+
clientNonce: string;
|
|
29
|
+
clientSeq: number;
|
|
30
|
+
}
|
|
31
|
+
interface QueueClearPayload {
|
|
32
|
+
clientNonce?: string;
|
|
33
|
+
clientSeq?: number;
|
|
34
|
+
}
|
|
35
|
+
type InterruptPayload = Record<string, never>;
|
|
36
|
+
type StopPayload = Record<string, never>;
|
|
37
|
+
interface CommandReceipt {
|
|
38
|
+
accepted: true;
|
|
39
|
+
cursor: number;
|
|
40
|
+
}
|
|
41
|
+
type PromptReceipt = CommandReceipt & {
|
|
42
|
+
clientNonce: string;
|
|
43
|
+
duplicate?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type FollowUpReceipt = CommandReceipt & {
|
|
46
|
+
clientNonce: string;
|
|
47
|
+
clientSeq: number;
|
|
48
|
+
queued: true;
|
|
49
|
+
duplicate?: boolean;
|
|
50
|
+
};
|
|
51
|
+
type QueueClearReceipt = CommandReceipt & {
|
|
52
|
+
cleared: number;
|
|
53
|
+
};
|
|
54
|
+
type InterruptReceipt = CommandReceipt;
|
|
55
|
+
type StopReceipt = CommandReceipt & {
|
|
56
|
+
stopped: boolean;
|
|
57
|
+
clearedQueue: QueuedUserMessage[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type { ChatAttachmentPayload as C, FollowUpPayload as F, InterruptPayload as I, PromptPayload as P, QueueClearPayload as Q, StopPayload as S, ThinkingLevel as T, ChatModelSelection as a, ChatSubmitPayload as b, CommandReceipt as c, FollowUpReceipt as d, InterruptReceipt as e, PromptReceipt as f, QueueClearReceipt as g, StopReceipt as h };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as WorkspaceRuntimeContext, S as Sandbox, f as SandboxHandleStore, e as SandboxHandleRecord, W as Workspace, F as FileSearch, g as Stat, E as Entry, b as ExecResult, n as WorkspaceChangeEvent, a as ExecOptions, P as PluginRestartWarning, k as WorkspaceAgentDispatcherContext, j as WorkspaceAgentDispatcher } from '../workspaceAgentDispatcher-Cl3EBveh.js';
|
|
2
2
|
import { Sandbox as Sandbox$1 } from '@vercel/sandbox';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { x as TelemetrySink, E as ToolReadinessRequirement, j as AgentEvent, c as Agent, d as AgentActor, A as AgentTool, F as AgentHarnessFactory } from '../harness-OsJBlx4u.js';
|
|
4
|
+
export { w as AgentConfig, G as AgentHarnessFactoryInput } from '../harness-OsJBlx4u.js';
|
|
5
5
|
import { FastifyInstance, FastifyRequest, FastifyPluginAsync } from 'fastify';
|
|
6
6
|
export { createAgent } from '../core/index.js';
|
|
7
|
-
import { S as SessionCtx, f as ErrorCode } from '../session-
|
|
7
|
+
import { S as SessionCtx, f as ErrorCode } from '../session-FUiMWsyX.js';
|
|
8
8
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
9
9
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
10
10
|
import { PackageSource, ExtensionFactory, SettingsManager } from '@mariozechner/pi-coding-agent';
|
|
11
|
-
import {
|
|
11
|
+
import { a as ChatModelSelection } from '../piChatCommand-BuWXytap.js';
|
|
12
12
|
import 'zod';
|
|
13
13
|
|
|
14
14
|
interface CreateDirectSandboxOptions {
|
|
@@ -1083,6 +1083,13 @@ type MeteringErrorLogger = (message: string, error: unknown) => void;
|
|
|
1083
1083
|
* from an unexpected provider still meters as zeros instead of NaN. */
|
|
1084
1084
|
declare function normalizeMeteringUsage(value: unknown): MeteringUsage | undefined;
|
|
1085
1085
|
|
|
1086
|
+
interface WorkspaceAgentDispatcherResolveOptions {
|
|
1087
|
+
request?: FastifyRequest;
|
|
1088
|
+
}
|
|
1089
|
+
interface WorkspaceAgentDispatcherResolver {
|
|
1090
|
+
resolve(ctx: WorkspaceAgentDispatcherContext, options?: WorkspaceAgentDispatcherResolveOptions): Promise<WorkspaceAgentDispatcher>;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1086
1093
|
interface CreateAgentAppOptions {
|
|
1087
1094
|
workspaceRoot?: string;
|
|
1088
1095
|
sessionId?: string;
|
|
@@ -1138,6 +1145,8 @@ interface CreateAgentAppOptions {
|
|
|
1138
1145
|
}) => Promise<void>;
|
|
1139
1146
|
/** Optional explicit file-backed session directory. Mostly for tests/hosts. */
|
|
1140
1147
|
sessionDir?: string;
|
|
1148
|
+
/** Optional explicit root for file-backed session directories. */
|
|
1149
|
+
sessionRoot?: string;
|
|
1141
1150
|
/**
|
|
1142
1151
|
* Enable user/global Pi extension auto-discovery from .pi/ and ~/.pi.
|
|
1143
1152
|
* App/internal plugins should be passed through extraTools/pi instead.
|
|
@@ -1170,6 +1179,11 @@ interface CreateAgentAppOptions {
|
|
|
1170
1179
|
message: string;
|
|
1171
1180
|
pluginId?: string;
|
|
1172
1181
|
}>>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Trusted in-process host composition seam. The resolver trusts caller-supplied
|
|
1184
|
+
* workspace/user context; callers must authorize that context before resolving.
|
|
1185
|
+
*/
|
|
1186
|
+
onWorkspaceAgentDispatcher?: (resolver: WorkspaceAgentDispatcherResolver) => void;
|
|
1173
1187
|
}
|
|
1174
1188
|
declare function createAgentApp(opts?: CreateAgentAppOptions): Promise<FastifyInstance>;
|
|
1175
1189
|
|
|
@@ -1296,11 +1310,14 @@ interface RegisterAgentRoutesOptions {
|
|
|
1296
1310
|
workspaceId: string;
|
|
1297
1311
|
workspaceRoot: string;
|
|
1298
1312
|
request?: FastifyRequest;
|
|
1313
|
+
/** Verified actor id for trusted requestless dispatcher resolution. */
|
|
1314
|
+
userId?: string;
|
|
1299
1315
|
}) => string | undefined | Promise<string | undefined>;
|
|
1300
1316
|
registerHealthRoute?: boolean;
|
|
1301
1317
|
sandboxHandleStore?: SandboxHandleStore;
|
|
1302
1318
|
getWorkspaceId?: (request: FastifyRequest) => string | Promise<string>;
|
|
1303
1319
|
getWorkspaceRoot?: (workspaceId: string, request: FastifyRequest) => string | Promise<string>;
|
|
1320
|
+
getTrustedWorkspaceRoot?: (ctx: WorkspaceAgentDispatcherContext) => string | Promise<string>;
|
|
1304
1321
|
/** Generic runtime env contributors. Agent stays workspace-neutral; hosts decide env names/values. */
|
|
1305
1322
|
runtimeEnvContributions?: RuntimeEnvContribution[];
|
|
1306
1323
|
/**
|
|
@@ -1336,6 +1353,11 @@ interface RegisterAgentRoutesOptions {
|
|
|
1336
1353
|
message: string;
|
|
1337
1354
|
pluginId?: string;
|
|
1338
1355
|
}>>;
|
|
1356
|
+
/**
|
|
1357
|
+
* Trusted in-process host composition seam. The resolver trusts caller-supplied
|
|
1358
|
+
* workspace/user context; callers must authorize that context before resolving.
|
|
1359
|
+
*/
|
|
1360
|
+
onWorkspaceAgentDispatcher?: (resolver: WorkspaceAgentDispatcherResolver) => void;
|
|
1339
1361
|
}
|
|
1340
1362
|
/**
|
|
1341
1363
|
* Fastify plugin that mounts agent routes onto a host app (typically core-built).
|
|
@@ -1357,4 +1379,4 @@ interface Logger {
|
|
|
1357
1379
|
}
|
|
1358
1380
|
declare function createLogger(prefix: string): Logger;
|
|
1359
1381
|
|
|
1360
|
-
export { AgentHarnessFactory, type AgentMeteringSink, type BoringAgentRuntimePaths, type BuiltinRuntimeModeId, type BwrapResourceLimits, type CreateAgentAppOptions, type CreateBwrapSandboxOptions, type CreateVercelProvisioningAdapterOptions, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, FileHandleStore, type LogFields, type Logger, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, type ManagedAgentArtifactRef, type ManagedAgentCollectArtifactsInput, type ManagedAgentDelegateInput, type ManagedAgentDelegateProgress, type ManagedAgentDelegateRequestContext, type ManagedAgentDelegateResult, type ManagedAgentDelegateStatus, type ManagedAgentDelegateStatusResult, ManagedAgentMcpDelegateController, type ManagedAgentMcpDelegateOptions, ManagedAgentMcpError, type ManagedAgentMcpHttpHandlerOptions, type ManagedAgentMcpServerOptions, type ManagedAgentSafeError, type MeteringErrorLogger, type MeteringReleaseInput, type MeteringReleaseReason, type MeteringReservationResult, type MeteringReserveInput, type MeteringRunKind, type MeteringRunScope, type MeteringRunStatus, type MeteringSettleInput, type MeteringUsage, type MeteringUsageInput, type ModeContext, PI_PACKAGE_RESOURCE_FILTERS, type PiExtensionFactory, type PiHarnessOptions, type PiPackageSource, type PluginSkillSource, type ProvisionRuntimeWorkspaceOptions, type ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, REMOTE_WORKER_PROVIDER, REMOTE_WORKER_RUNTIME_CWD, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, type RemoteWorkerErrorPayload, type RemoteWorkerExecRequest, type RemoteWorkerExecResponse, type RemoteWorkerFsEventEnvelope, type RemoteWorkerModeAdapterOptions, type RemoteWorkerWorkspaceOp, type RemoteWorkerWorkspaceResult, type RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, type RuntimeFilesystemBinding, type RuntimeFilesystemBindingOperations, type RuntimeModeAdapter, type RuntimeModeId, type RuntimeNodePackageSpec$1 as RuntimeNodePackageSpec, type RuntimeProvisioningContribution$1 as RuntimeProvisioningContribution, type RuntimePythonSpec$1 as RuntimePythonSpec, type RuntimeTemplateContribution$1 as RuntimeTemplateContribution, type RuntimeWorkspaceProvisioningResult, type SnapshotBakeOptions, type SnapshotBakeResult, UV_SETUP_COMMANDS, VERCEL_PROVISIONING_CACHE_ROOT, VERCEL_SANDBOX_WORKSPACE_ROOT, UV_SETUP_COMMANDS as VERCEL_UV_SETUP_COMMANDS, type VercelBakeClient, type VercelBakeSandbox, type VercelDeploymentSnapshotOptions, WORKER_INTERNAL_TOKEN_HEADER, WORKER_REQUEST_ID_HEADER, WORKER_WORKSPACE_ID_HEADER, type WorkspaceProvisioningAdapter, type WorkspaceProvisioningExecResult, type WorkspaceProvisioningResult, applyCspHeaders, autoDetectMode, bakeSnapshotIfNeeded, buildDeploymentSnapshotRecipe, buildPackageHash, buildSnapshotRecipeHash, compactPiPackages, constantTimeTokenEqual, createAgentApp, createBwrapSandbox, createDirectSandbox, createLogger, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createNodeWorkspace, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResourceSettingsManager, createVercelDeploymentSnapshotProvider, createVercelProvisioningAdapter, createVercelSandboxWorkspace, decodeBytesFromWorker, encodeBytesForWorker, fileRoutes, getBoringAgentPathEntries, getBoringAgentRuntimeEnv, getBoringAgentRuntimePaths, hasBwrap, mergePiPackageSources, normalizeMeteringUsage, piPackageSourceKey, prepareDeploymentSnapshot, prepareVercelDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, resolveMode, resolveSandboxHandle };
|
|
1382
|
+
export { AgentHarnessFactory, type AgentMeteringSink, type BoringAgentRuntimePaths, type BuiltinRuntimeModeId, type BwrapResourceLimits, type CreateAgentAppOptions, type CreateBwrapSandboxOptions, type CreateVercelProvisioningAdapterOptions, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, FileHandleStore, type LogFields, type Logger, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, type ManagedAgentArtifactRef, type ManagedAgentCollectArtifactsInput, type ManagedAgentDelegateInput, type ManagedAgentDelegateProgress, type ManagedAgentDelegateRequestContext, type ManagedAgentDelegateResult, type ManagedAgentDelegateStatus, type ManagedAgentDelegateStatusResult, ManagedAgentMcpDelegateController, type ManagedAgentMcpDelegateOptions, ManagedAgentMcpError, type ManagedAgentMcpHttpHandlerOptions, type ManagedAgentMcpServerOptions, type ManagedAgentSafeError, type MeteringErrorLogger, type MeteringReleaseInput, type MeteringReleaseReason, type MeteringReservationResult, type MeteringReserveInput, type MeteringRunKind, type MeteringRunScope, type MeteringRunStatus, type MeteringSettleInput, type MeteringUsage, type MeteringUsageInput, type ModeContext, PI_PACKAGE_RESOURCE_FILTERS, type PiExtensionFactory, type PiHarnessOptions, type PiPackageSource, type PluginSkillSource, type ProvisionRuntimeWorkspaceOptions, type ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, REMOTE_WORKER_PROVIDER, REMOTE_WORKER_RUNTIME_CWD, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, type RemoteWorkerErrorPayload, type RemoteWorkerExecRequest, type RemoteWorkerExecResponse, type RemoteWorkerFsEventEnvelope, type RemoteWorkerModeAdapterOptions, type RemoteWorkerWorkspaceOp, type RemoteWorkerWorkspaceResult, type RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, type RuntimeFilesystemBinding, type RuntimeFilesystemBindingOperations, type RuntimeModeAdapter, type RuntimeModeId, type RuntimeNodePackageSpec$1 as RuntimeNodePackageSpec, type RuntimeProvisioningContribution$1 as RuntimeProvisioningContribution, type RuntimePythonSpec$1 as RuntimePythonSpec, type RuntimeTemplateContribution$1 as RuntimeTemplateContribution, type RuntimeWorkspaceProvisioningResult, type SnapshotBakeOptions, type SnapshotBakeResult, UV_SETUP_COMMANDS, VERCEL_PROVISIONING_CACHE_ROOT, VERCEL_SANDBOX_WORKSPACE_ROOT, UV_SETUP_COMMANDS as VERCEL_UV_SETUP_COMMANDS, type VercelBakeClient, type VercelBakeSandbox, type VercelDeploymentSnapshotOptions, WORKER_INTERNAL_TOKEN_HEADER, WORKER_REQUEST_ID_HEADER, WORKER_WORKSPACE_ID_HEADER, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, type WorkspaceProvisioningAdapter, type WorkspaceProvisioningExecResult, type WorkspaceProvisioningResult, applyCspHeaders, autoDetectMode, bakeSnapshotIfNeeded, buildDeploymentSnapshotRecipe, buildPackageHash, buildSnapshotRecipeHash, compactPiPackages, constantTimeTokenEqual, createAgentApp, createBwrapSandbox, createDirectSandbox, createLogger, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createNodeWorkspace, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResourceSettingsManager, createVercelDeploymentSnapshotProvider, createVercelProvisioningAdapter, createVercelSandboxWorkspace, decodeBytesFromWorker, encodeBytesForWorker, fileRoutes, getBoringAgentPathEntries, getBoringAgentRuntimeEnv, getBoringAgentRuntimePaths, hasBwrap, mergePiPackageSources, normalizeMeteringUsage, piPackageSourceKey, prepareDeploymentSnapshot, prepareVercelDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, resolveMode, resolveSandboxHandle };
|