@hachej/boring-agent 0.1.84 → 0.1.85
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-DC3S7SZG.js → chunk-6O5ADR57.js} +1 -1
- package/dist/{chunk-PG2WOJ22.js → chunk-HDIRWHJB.js} +5 -1
- package/dist/{chunk-5IRFVKV7.js → chunk-HY7EERLW.js} +253 -16
- package/dist/{chunk-2XADUCX7.js → chunk-LYBTHR7J.js} +1 -1
- package/dist/{chunk-WODTQBXR.js → chunk-YONTHCD7.js} +108 -2
- package/dist/{chunk-5NAN3TAR.js → chunk-ZUDWQAAB.js} +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +2 -2
- package/dist/{createHarness-TGBJZISM.js → createHarness-MJ5GEL6J.js} +2 -2
- package/dist/front/index.d.ts +1 -1
- package/dist/front/index.js +2 -2
- package/dist/{harness-Dtu-WAXy.d.ts → harness-RhGbdGWY.d.ts} +1 -1
- package/dist/{piChatEvent-DLa8CgFa.d.ts → piChatEvent-CUTKRaZD.d.ts} +14 -14
- package/dist/{piChatSessionService-BuPaMB7k.d.ts → piChatSessionService-iBtx32ya.d.ts} +1 -1
- package/dist/server/index.d.ts +45 -6
- package/dist/server/index.js +12 -8
- package/dist/server/worker/index.js +6 -6
- package/dist/shared/index.d.ts +86 -38
- package/dist/shared/index.js +96 -5
- package/dist/workspaceAgentDispatcher-Dv0DocrE.d.ts +314 -0
- package/docs/ERROR_CODES.md +2 -0
- package/package.json +2 -2
- package/dist/workspaceAgentDispatcher-CBN2xxaH.d.ts +0 -151
|
@@ -73,6 +73,9 @@ var ErrorCode = z.enum([
|
|
|
73
73
|
"PROVISIONING_UV_BOOTSTRAP_FAILED",
|
|
74
74
|
"PROVISIONING_UV_INSTALL_FAILED",
|
|
75
75
|
"PROVISIONING_ARTIFACT_FAILED",
|
|
76
|
+
// Lane W same-workspace share deep-link (AR1-003)
|
|
77
|
+
"AR1_SHARE_NOT_FOUND",
|
|
78
|
+
"AR1_SHARE_TOMBSTONED",
|
|
76
79
|
// Internal
|
|
77
80
|
"ERR_NOT_IMPLEMENTED_UNTIL_T1",
|
|
78
81
|
"INTERNAL_ERROR"
|
|
@@ -90,7 +93,8 @@ var AgentConsumptionErrorCode = z.enum([
|
|
|
90
93
|
"AGENT_CONSUMPTION_INVALID_TRANSITION",
|
|
91
94
|
"AGENT_CONSUMPTION_CYCLE_DETECTED",
|
|
92
95
|
"AGENT_CONSUMPTION_DEPTH_EXCEEDED",
|
|
93
|
-
"AGENT_CONSUMPTION_SCHEMA_MISMATCH"
|
|
96
|
+
"AGENT_CONSUMPTION_SCHEMA_MISMATCH",
|
|
97
|
+
"AGENT_CONSUMPTION_LEGACY_ARTIFACT_REJECTED"
|
|
94
98
|
]);
|
|
95
99
|
var ApiErrorPayloadSchema = z.object({
|
|
96
100
|
code: ErrorCode,
|
|
@@ -3,19 +3,21 @@ import {
|
|
|
3
3
|
AgentDeploymentValidationError,
|
|
4
4
|
OpaqueRefSchema,
|
|
5
5
|
Sha256DigestSchema,
|
|
6
|
+
ShareEntryErrorCode,
|
|
6
7
|
canonicalStringify,
|
|
7
8
|
createAgentAssetDigest,
|
|
8
9
|
createAgentDefinitionDigest,
|
|
9
10
|
createAgentDeploymentDigest,
|
|
11
|
+
resolveShareEntry,
|
|
10
12
|
sha256Bytes,
|
|
11
13
|
validateAgentDefinition,
|
|
12
14
|
validateAgentDeployment,
|
|
13
15
|
validateTool
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YONTHCD7.js";
|
|
15
17
|
import {
|
|
16
18
|
AgentEffectAdmissionError,
|
|
17
19
|
createAgentRuntimeBridge
|
|
18
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LYBTHR7J.js";
|
|
19
21
|
import {
|
|
20
22
|
sessionStreamPath
|
|
21
23
|
} from "./chunk-WSQ5QNIY.js";
|
|
@@ -30,7 +32,7 @@ import {
|
|
|
30
32
|
StopReceiptSchema,
|
|
31
33
|
extractToolUiMetadata,
|
|
32
34
|
sanitizeToolUiMetadata2 as sanitizeToolUiMetadata
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-6O5ADR57.js";
|
|
34
36
|
import {
|
|
35
37
|
createLogger,
|
|
36
38
|
createPiCodingAgentHarness,
|
|
@@ -41,7 +43,7 @@ import {
|
|
|
41
43
|
registerConfiguredModelProviders,
|
|
42
44
|
setEnvDefault,
|
|
43
45
|
withPiHarnessDefaults
|
|
44
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-ZUDWQAAB.js";
|
|
45
47
|
import {
|
|
46
48
|
safeCapture
|
|
47
49
|
} from "./chunk-AQBXNPMD.js";
|
|
@@ -49,7 +51,7 @@ import {
|
|
|
49
51
|
AgentDefinitionErrorCode,
|
|
50
52
|
AgentDeploymentErrorCode,
|
|
51
53
|
ErrorCode
|
|
52
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-HDIRWHJB.js";
|
|
53
55
|
|
|
54
56
|
// src/server/sandbox/direct/createDirectSandbox.ts
|
|
55
57
|
import { spawn } from "child_process";
|
|
@@ -7310,6 +7312,19 @@ var PiChatMeteringCoordinator = class {
|
|
|
7310
7312
|
if (run2) this.release(run2, "run-rejected");
|
|
7311
7313
|
this.pruneSession(stateKey, state);
|
|
7312
7314
|
}
|
|
7315
|
+
/**
|
|
7316
|
+
* Mark the currently-active run as voluntarily user-stopped (the /stop button),
|
|
7317
|
+
* so its terminal accounting RELEASES the hold instead of charging the fallback.
|
|
7318
|
+
* Must be called before the abort so the flag is set when the native aborted
|
|
7319
|
+
* agent-end is observed. Runs with real usage recorded before the stop still
|
|
7320
|
+
* settle that usage; only the unused remainder of the hold is released. No-op if
|
|
7321
|
+
* there is no active run (e.g. the stop landed before agent-start — releasePending
|
|
7322
|
+
* handles that case).
|
|
7323
|
+
*/
|
|
7324
|
+
markActiveStopped(sessionId) {
|
|
7325
|
+
const active = this.sessions.get(sessionId)?.active;
|
|
7326
|
+
if (active && !active.terminal) active.userStopped = true;
|
|
7327
|
+
}
|
|
7313
7328
|
/**
|
|
7314
7329
|
* Release prompt runs reserved but not yet bound to an agent-start —
|
|
7315
7330
|
* e.g. a stop/interrupt landing in the window between acceptance and the
|
|
@@ -7495,6 +7510,7 @@ var PiChatMeteringCoordinator = class {
|
|
|
7495
7510
|
recordedMessageIds: /* @__PURE__ */ new Set(),
|
|
7496
7511
|
lastIdlessUsageKey: void 0,
|
|
7497
7512
|
usageWriteFailed: false,
|
|
7513
|
+
userStopped: false,
|
|
7498
7514
|
reservation: Promise.resolve(),
|
|
7499
7515
|
terminal: false,
|
|
7500
7516
|
ops: Promise.resolve()
|
|
@@ -7536,7 +7552,7 @@ var PiChatMeteringCoordinator = class {
|
|
|
7536
7552
|
if (run2.billableUsageCount > 0) {
|
|
7537
7553
|
return this.sink.settleRun({ ...run2.scope, reservationId: run2.reservationId, status });
|
|
7538
7554
|
}
|
|
7539
|
-
const didPaidWork = status === "ok";
|
|
7555
|
+
const didPaidWork = status === "ok" && !run2.userStopped;
|
|
7540
7556
|
if (didPaidWork) {
|
|
7541
7557
|
return this.sink.releaseRun({ ...run2.scope, reservationId: run2.reservationId, reason: "fallback-hold-charge" });
|
|
7542
7558
|
}
|
|
@@ -7988,6 +8004,7 @@ var HarnessPiChatService = class {
|
|
|
7988
8004
|
const sessionKey = this.sessionKey(ctx, sessionId);
|
|
7989
8005
|
const adapter = await this.getAdapter(ctx, sessionId, "");
|
|
7990
8006
|
const clearedQueue = this.clearAllFollowUps(adapter, sessionId, sessionKey);
|
|
8007
|
+
this.metering?.markActiveStopped(sessionKey);
|
|
7991
8008
|
this.metering?.releaseQueued(sessionKey);
|
|
7992
8009
|
this.metering?.releasePending(sessionKey);
|
|
7993
8010
|
await adapter.abort();
|
|
@@ -8486,7 +8503,7 @@ function createAgentRuntimeBridge2(config, options = {}) {
|
|
|
8486
8503
|
});
|
|
8487
8504
|
}
|
|
8488
8505
|
async function createRuntime(config, options) {
|
|
8489
|
-
const harnessFactory = config.harnessFactory ?? (await import("./createHarness-
|
|
8506
|
+
const harnessFactory = config.harnessFactory ?? (await import("./createHarness-MJ5GEL6J.js")).createPiCodingAgentHarness;
|
|
8490
8507
|
const harnessInput = {
|
|
8491
8508
|
tools: config.tools ?? [],
|
|
8492
8509
|
cwd: config.workdir ?? DEFAULT_WORKDIR,
|
|
@@ -9498,6 +9515,166 @@ function sameSessionCtx(a, b) {
|
|
|
9498
9515
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9499
9516
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
9500
9517
|
import { z as z2 } from "zod";
|
|
9518
|
+
|
|
9519
|
+
// src/server/mcp/shareEntryResources.ts
|
|
9520
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9521
|
+
var MAX_SHARE_READ_BYTES = 256 * 1024;
|
|
9522
|
+
var SHARE_RESOURCE_URI_TEMPLATE = "share:///{id}";
|
|
9523
|
+
var strictUtf8Decoder2 = new TextDecoder("utf-8", { fatal: true });
|
|
9524
|
+
function shareResourceUri(id) {
|
|
9525
|
+
return `share:///${encodeURIComponent(id)}`;
|
|
9526
|
+
}
|
|
9527
|
+
function registerShareEntryResources(server, options) {
|
|
9528
|
+
const template = new ResourceTemplate(SHARE_RESOURCE_URI_TEMPLATE, {
|
|
9529
|
+
list: async (extra) => listShareResources(options, requestContextFromResourceExtra(extra))
|
|
9530
|
+
});
|
|
9531
|
+
const readCallback = async (uri, variables, extra) => readShareResource(options, variables.id, requestContextFromResourceExtra(extra));
|
|
9532
|
+
server.registerResource(
|
|
9533
|
+
"share",
|
|
9534
|
+
template,
|
|
9535
|
+
{
|
|
9536
|
+
title: "Lane W share entry",
|
|
9537
|
+
description: "Same-workspace shareable file reference (AR1). Resolves live, never a blob snapshot."
|
|
9538
|
+
},
|
|
9539
|
+
readCallback
|
|
9540
|
+
);
|
|
9541
|
+
}
|
|
9542
|
+
function requestContextFromResourceExtra(extra) {
|
|
9543
|
+
return {
|
|
9544
|
+
sessionId: extra?.sessionId,
|
|
9545
|
+
authInfo: extra?.authInfo
|
|
9546
|
+
};
|
|
9547
|
+
}
|
|
9548
|
+
async function listShareResources(options, request) {
|
|
9549
|
+
const ctx = await options.resolveSessionCtx(request);
|
|
9550
|
+
if (!ctx.workspaceId) return { resources: [] };
|
|
9551
|
+
const entries = await options.store.list(ctx.workspaceId);
|
|
9552
|
+
return {
|
|
9553
|
+
resources: entries.map((entry) => ({
|
|
9554
|
+
uri: shareResourceUri(entry.id),
|
|
9555
|
+
name: entry.id
|
|
9556
|
+
}))
|
|
9557
|
+
};
|
|
9558
|
+
}
|
|
9559
|
+
async function readShareResource(options, rawId, request) {
|
|
9560
|
+
const id = typeof rawId === "string" ? rawId : Array.isArray(rawId) ? rawId[0] : void 0;
|
|
9561
|
+
if (!id) return notFoundResult(shareResourceUri(""));
|
|
9562
|
+
const uri = shareResourceUri(id);
|
|
9563
|
+
const ctx = await options.resolveSessionCtx(request);
|
|
9564
|
+
if (!ctx.workspaceId) return notFoundResult(uri);
|
|
9565
|
+
const entry = await options.store.get(id);
|
|
9566
|
+
if (!entry || entry.workspaceId !== ctx.workspaceId) {
|
|
9567
|
+
return notFoundResult(uri);
|
|
9568
|
+
}
|
|
9569
|
+
const workspace = await options.resolveWorkspace(ctx);
|
|
9570
|
+
const resolution = await resolveShareEntry(options.store, id, workspace);
|
|
9571
|
+
if (resolution.status === "not_found") return notFoundResult(uri);
|
|
9572
|
+
if (resolution.status === "tombstoned") {
|
|
9573
|
+
return tombstoneResult(uri, resolution.tombstone);
|
|
9574
|
+
}
|
|
9575
|
+
return readShareEntryContents(uri, resolution.entry, workspace);
|
|
9576
|
+
}
|
|
9577
|
+
function notFoundResult(uri) {
|
|
9578
|
+
return {
|
|
9579
|
+
contents: [
|
|
9580
|
+
{
|
|
9581
|
+
uri,
|
|
9582
|
+
mimeType: "application/json",
|
|
9583
|
+
text: JSON.stringify({
|
|
9584
|
+
status: "not_found",
|
|
9585
|
+
error: { code: ErrorCode.enum.AR1_SHARE_NOT_FOUND, message: "share not found" }
|
|
9586
|
+
})
|
|
9587
|
+
}
|
|
9588
|
+
]
|
|
9589
|
+
};
|
|
9590
|
+
}
|
|
9591
|
+
function tombstoneResult(uri, tombstone) {
|
|
9592
|
+
return {
|
|
9593
|
+
contents: [
|
|
9594
|
+
{
|
|
9595
|
+
uri,
|
|
9596
|
+
mimeType: "application/json",
|
|
9597
|
+
text: JSON.stringify({
|
|
9598
|
+
status: "tombstoned",
|
|
9599
|
+
error: { code: ErrorCode.enum.AR1_SHARE_TOMBSTONED, message: "share target is gone" },
|
|
9600
|
+
id: tombstone.id,
|
|
9601
|
+
workspaceId: tombstone.workspaceId,
|
|
9602
|
+
provenance: tombstone.provenance
|
|
9603
|
+
})
|
|
9604
|
+
}
|
|
9605
|
+
]
|
|
9606
|
+
};
|
|
9607
|
+
}
|
|
9608
|
+
async function readShareEntryContents(uri, entry, workspace) {
|
|
9609
|
+
const before = await statShareTarget(workspace, entry.path);
|
|
9610
|
+
assertShareTargetStat(before);
|
|
9611
|
+
assertWithinCap(before.size);
|
|
9612
|
+
if (!workspace.readBinaryFile) {
|
|
9613
|
+
throw new ManagedAgentMcpError(
|
|
9614
|
+
ErrorCode.enum.MCP_AGENT_ARTIFACT_UNAVAILABLE,
|
|
9615
|
+
"share target bytes are unavailable through the authorized workspace"
|
|
9616
|
+
);
|
|
9617
|
+
}
|
|
9618
|
+
const bytes = await workspace.readBinaryFile(entry.path);
|
|
9619
|
+
const after = await statShareTarget(workspace, entry.path);
|
|
9620
|
+
assertShareTargetStat(after);
|
|
9621
|
+
if (!sameStat2(before, after) || bytes.byteLength !== before.size) {
|
|
9622
|
+
throw new ManagedAgentMcpError(ErrorCode.enum.MCP_AGENT_ARTIFACT_UNAVAILABLE, "share target changed while it was being read");
|
|
9623
|
+
}
|
|
9624
|
+
assertWithinCap(bytes.byteLength);
|
|
9625
|
+
const text = decodeUtf83(bytes);
|
|
9626
|
+
const digest = await sha256Bytes(bytes);
|
|
9627
|
+
return {
|
|
9628
|
+
contents: [
|
|
9629
|
+
{
|
|
9630
|
+
uri,
|
|
9631
|
+
mimeType: "text/plain",
|
|
9632
|
+
text,
|
|
9633
|
+
_meta: {
|
|
9634
|
+
status: "ok",
|
|
9635
|
+
digest,
|
|
9636
|
+
byteSize: bytes.byteLength,
|
|
9637
|
+
provenance: entry.provenance
|
|
9638
|
+
}
|
|
9639
|
+
}
|
|
9640
|
+
]
|
|
9641
|
+
};
|
|
9642
|
+
}
|
|
9643
|
+
async function statShareTarget(workspace, path4) {
|
|
9644
|
+
try {
|
|
9645
|
+
return await workspace.stat(path4);
|
|
9646
|
+
} catch {
|
|
9647
|
+
throw new ManagedAgentMcpError(ErrorCode.enum.MCP_AGENT_ARTIFACT_UNAVAILABLE, "share target is unavailable");
|
|
9648
|
+
}
|
|
9649
|
+
}
|
|
9650
|
+
function assertShareTargetStat(stat13) {
|
|
9651
|
+
if (stat13.kind !== "file") {
|
|
9652
|
+
throw new ManagedAgentMcpError(ErrorCode.enum.MCP_AGENT_ARTIFACT_INVALID, "share target must be a file");
|
|
9653
|
+
}
|
|
9654
|
+
if (!Number.isFinite(stat13.size) || stat13.size < 0) {
|
|
9655
|
+
throw new ManagedAgentMcpError(ErrorCode.enum.MCP_AGENT_ARTIFACT_INVALID, "share target size is invalid");
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
function assertWithinCap(byteSize) {
|
|
9659
|
+
if (byteSize > MAX_SHARE_READ_BYTES) {
|
|
9660
|
+
throw new ManagedAgentMcpError(
|
|
9661
|
+
ErrorCode.enum.MCP_AGENT_ARTIFACT_TOO_LARGE,
|
|
9662
|
+
`share target must be ${MAX_SHARE_READ_BYTES} bytes or fewer`
|
|
9663
|
+
);
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
function sameStat2(left, right) {
|
|
9667
|
+
return left.kind === right.kind && left.size === right.size && left.mtimeMs === right.mtimeMs;
|
|
9668
|
+
}
|
|
9669
|
+
function decodeUtf83(bytes) {
|
|
9670
|
+
try {
|
|
9671
|
+
return strictUtf8Decoder2.decode(bytes);
|
|
9672
|
+
} catch {
|
|
9673
|
+
throw new ManagedAgentMcpError(ErrorCode.enum.MCP_AGENT_ARTIFACT_INVALID, "share target must be well-formed UTF-8");
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
|
|
9677
|
+
// src/server/mcp/managedAgentMcpServer.ts
|
|
9501
9678
|
var DEFAULT_MAX_BRIEF_SCHEMA_CHARS = 32 * 1024;
|
|
9502
9679
|
var delegateTaskStatusInputSchema = {
|
|
9503
9680
|
delegationId: z2.string().min(1)
|
|
@@ -9510,6 +9687,13 @@ function createManagedAgentMcpServerWithController(options, controller) {
|
|
|
9510
9687
|
name: options.name ?? "boring-managed-agent",
|
|
9511
9688
|
version: options.version ?? "0.0.0"
|
|
9512
9689
|
});
|
|
9690
|
+
if (options.shareEntryStore && options.resolveShareSessionCtx && options.resolveShareWorkspace) {
|
|
9691
|
+
registerShareEntryResources(server, {
|
|
9692
|
+
store: options.shareEntryStore,
|
|
9693
|
+
resolveSessionCtx: options.resolveShareSessionCtx,
|
|
9694
|
+
resolveWorkspace: options.resolveShareWorkspace
|
|
9695
|
+
});
|
|
9696
|
+
}
|
|
9513
9697
|
const registerTool = server.registerTool.bind(server);
|
|
9514
9698
|
const delegateTaskInputSchema = createDelegateTaskInputSchema(options.maxBriefChars ?? DEFAULT_MAX_BRIEF_SCHEMA_CHARS);
|
|
9515
9699
|
registerTool(
|
|
@@ -13315,6 +13499,51 @@ function buildUploadAgentTools(bundle) {
|
|
|
13315
13499
|
];
|
|
13316
13500
|
}
|
|
13317
13501
|
|
|
13502
|
+
// src/server/http/routes/deepLink.ts
|
|
13503
|
+
var DEFAULT_WORKSPACE_ID4 = "default";
|
|
13504
|
+
function getRequestWorkspaceId2(request) {
|
|
13505
|
+
return request.workspaceContext?.workspaceId ?? DEFAULT_WORKSPACE_ID4;
|
|
13506
|
+
}
|
|
13507
|
+
function sendShareNotFound(reply) {
|
|
13508
|
+
return reply.code(404).send({
|
|
13509
|
+
error: { code: ShareEntryErrorCode.enum.AR1_SHARE_NOT_FOUND, message: "share not found" }
|
|
13510
|
+
});
|
|
13511
|
+
}
|
|
13512
|
+
var deepLinkRoutes = (app, opts, done) => {
|
|
13513
|
+
async function resolveWorkspace(request) {
|
|
13514
|
+
if (opts.getWorkspace) return await opts.getWorkspace(request);
|
|
13515
|
+
if (opts.workspace) return opts.workspace;
|
|
13516
|
+
throw new Error("deep-link route requires workspace or getWorkspace");
|
|
13517
|
+
}
|
|
13518
|
+
app.get("/a/:id", async (request, reply) => {
|
|
13519
|
+
const { id } = request.params;
|
|
13520
|
+
const requestWorkspaceId = getRequestWorkspaceId2(request);
|
|
13521
|
+
const entry = await opts.store.get(id);
|
|
13522
|
+
if (!entry || entry.workspaceId !== requestWorkspaceId) {
|
|
13523
|
+
return sendShareNotFound(reply);
|
|
13524
|
+
}
|
|
13525
|
+
const workspace = await resolveWorkspace(request);
|
|
13526
|
+
const resolution = await resolveShareEntry(opts.store, id, workspace);
|
|
13527
|
+
switch (resolution.status) {
|
|
13528
|
+
case "not_found":
|
|
13529
|
+
return sendShareNotFound(reply);
|
|
13530
|
+
case "tombstoned":
|
|
13531
|
+
return reply.code(200).send({
|
|
13532
|
+
status: "tombstoned",
|
|
13533
|
+
code: resolution.code,
|
|
13534
|
+
tombstone: resolution.tombstone
|
|
13535
|
+
});
|
|
13536
|
+
case "ok":
|
|
13537
|
+
return reply.code(200).send({
|
|
13538
|
+
status: "ok",
|
|
13539
|
+
workspaceId: resolution.entry.workspaceId,
|
|
13540
|
+
id: resolution.entry.id
|
|
13541
|
+
});
|
|
13542
|
+
}
|
|
13543
|
+
});
|
|
13544
|
+
done();
|
|
13545
|
+
};
|
|
13546
|
+
|
|
13318
13547
|
// src/server/runtime/runtimeBindingLifecycle.ts
|
|
13319
13548
|
function createRuntimeBindingLifecycle(options) {
|
|
13320
13549
|
const { app } = options;
|
|
@@ -13602,7 +13831,7 @@ function createRuntimeBindingLifecycle(options) {
|
|
|
13602
13831
|
|
|
13603
13832
|
// src/server/registerAgentRoutes.ts
|
|
13604
13833
|
var DEFAULT_VERSION2 = "0.1.0-dev";
|
|
13605
|
-
var
|
|
13834
|
+
var DEFAULT_WORKSPACE_ID5 = "default";
|
|
13606
13835
|
var STANDARD_AGENT_TOOL_NAMES = ["bash", "read", "write", "edit", "find", "grep", "ls"];
|
|
13607
13836
|
function pluginNameFromPath(path4) {
|
|
13608
13837
|
const fileName = basename2(path4);
|
|
@@ -13622,8 +13851,8 @@ function getAvailableModelProviders() {
|
|
|
13622
13851
|
new Set(availableModels.map((model) => model.provider))
|
|
13623
13852
|
).sort((a, b) => a.localeCompare(b));
|
|
13624
13853
|
}
|
|
13625
|
-
function
|
|
13626
|
-
return request.workspaceContext?.workspaceId ??
|
|
13854
|
+
function getRequestWorkspaceId3(request) {
|
|
13855
|
+
return request.workspaceContext?.workspaceId ?? DEFAULT_WORKSPACE_ID5;
|
|
13627
13856
|
}
|
|
13628
13857
|
function promoteRawFileWorkspaceQueryToHeader(request) {
|
|
13629
13858
|
const pathname = request.url.split("?")[0] ?? request.url;
|
|
@@ -13716,7 +13945,7 @@ function createRuntimeReadinessCheck(workspaceId, getRuntimeDependencies) {
|
|
|
13716
13945
|
};
|
|
13717
13946
|
}
|
|
13718
13947
|
var registerAgentRoutes = async (app, opts) => {
|
|
13719
|
-
const sessionId = opts.sessionId ??
|
|
13948
|
+
const sessionId = opts.sessionId ?? DEFAULT_WORKSPACE_ID5;
|
|
13720
13949
|
const resolvedMode = opts.runtimeModeAdapter?.id ?? opts.mode ?? autoDetectMode();
|
|
13721
13950
|
const workspaceRoot = opts.workspaceRoot ?? process.cwd();
|
|
13722
13951
|
const templatePath = opts.templatePath ?? getEnv("BORING_AGENT_TEMPLATE_PATH");
|
|
@@ -14286,14 +14515,14 @@ var registerAgentRoutes = async (app, opts) => {
|
|
|
14286
14515
|
function getSkillsScopeForRequest(request) {
|
|
14287
14516
|
let promise = skillsScopeByRequest.get(request);
|
|
14288
14517
|
if (!promise) {
|
|
14289
|
-
promise = resolveSkillScope(
|
|
14518
|
+
promise = resolveSkillScope(getRequestWorkspaceId3(request), request);
|
|
14290
14519
|
skillsScopeByRequest.set(request, promise);
|
|
14291
14520
|
}
|
|
14292
14521
|
return promise;
|
|
14293
14522
|
}
|
|
14294
14523
|
async function getBindingForRequest(request, options = {}) {
|
|
14295
14524
|
if (staticBinding) return staticBinding;
|
|
14296
|
-
return await getOrCreateRuntimeBinding(
|
|
14525
|
+
return await getOrCreateRuntimeBinding(getRequestWorkspaceId3(request), request, options);
|
|
14297
14526
|
}
|
|
14298
14527
|
async function getFilesystemBindingsForRequest(request) {
|
|
14299
14528
|
const binding = await getBindingForRequest(request);
|
|
@@ -14301,7 +14530,7 @@ var registerAgentRoutes = async (app, opts) => {
|
|
|
14301
14530
|
const user = request.user;
|
|
14302
14531
|
return await opts.getFilesystemBindings({
|
|
14303
14532
|
request,
|
|
14304
|
-
workspaceId:
|
|
14533
|
+
workspaceId: getRequestWorkspaceId3(request),
|
|
14305
14534
|
workspaceRoot: binding.workspaceRoot,
|
|
14306
14535
|
userId: user?.id,
|
|
14307
14536
|
userEmail: user?.email,
|
|
@@ -14328,7 +14557,7 @@ var registerAgentRoutes = async (app, opts) => {
|
|
|
14328
14557
|
}
|
|
14329
14558
|
app.addHook("onRequest", async (request, reply) => {
|
|
14330
14559
|
const user = request.user;
|
|
14331
|
-
let workspaceId =
|
|
14560
|
+
let workspaceId = DEFAULT_WORKSPACE_ID5;
|
|
14332
14561
|
promoteRawFileWorkspaceQueryToHeader(request);
|
|
14333
14562
|
if (opts.getWorkspaceId && !isWorkspaceAgnosticAgentRequest(request, { readyStatusWorkspaceScoped: requestScopedRuntime, modelsWorkspaceScoped })) {
|
|
14334
14563
|
try {
|
|
@@ -14382,6 +14611,12 @@ var registerAgentRoutes = async (app, opts) => {
|
|
|
14382
14611
|
await app.register(searchRoutes, {
|
|
14383
14612
|
getFileSearch: async (request) => (await getBindingForRequest(request)).runtimeBundle.fileSearch
|
|
14384
14613
|
});
|
|
14614
|
+
if (opts.shareEntryStore) {
|
|
14615
|
+
await app.register(deepLinkRoutes, {
|
|
14616
|
+
store: opts.shareEntryStore,
|
|
14617
|
+
getWorkspace: async (request) => (await getBindingForRequest(request)).runtimeBundle.workspace
|
|
14618
|
+
});
|
|
14619
|
+
}
|
|
14385
14620
|
await app.register(gitRoutes, {
|
|
14386
14621
|
getWorkspace: async (request) => {
|
|
14387
14622
|
const runtimeBundle = (await getBindingForRequest(request)).runtimeBundle;
|
|
@@ -14427,7 +14662,7 @@ var registerAgentRoutes = async (app, opts) => {
|
|
|
14427
14662
|
});
|
|
14428
14663
|
await app.register(sessionChangesRoutes, { tracker: sessionChangesTracker });
|
|
14429
14664
|
app.post("/api/v1/agent/reload", async (request, reply) => {
|
|
14430
|
-
const workspaceId =
|
|
14665
|
+
const workspaceId = getRequestWorkspaceId3(request);
|
|
14431
14666
|
const binding = await getBindingForRequest(request);
|
|
14432
14667
|
if (!binding.harness.reloadSession) {
|
|
14433
14668
|
return reply.status(501).send({ ok: false, error: "Agent harness does not support reload" });
|
|
@@ -14557,6 +14792,8 @@ export {
|
|
|
14557
14792
|
ManagedAgentMcpError,
|
|
14558
14793
|
ManagedAgentMcpDelegateController,
|
|
14559
14794
|
createManagedAgentMcpDelegateController,
|
|
14795
|
+
shareResourceUri,
|
|
14796
|
+
registerShareEntryResources,
|
|
14560
14797
|
createManagedAgentMcpServer,
|
|
14561
14798
|
createManagedAgentMcpHttpHandler,
|
|
14562
14799
|
createAgentApp,
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
AgentDefinitionErrorCode,
|
|
3
3
|
AgentDeploymentErrorCode,
|
|
4
4
|
ErrorCode
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HDIRWHJB.js";
|
|
6
6
|
|
|
7
7
|
// src/shared/agent-definition.ts
|
|
8
8
|
import { z as z2 } from "zod";
|
|
@@ -261,6 +261,105 @@ function validateTool(tool) {
|
|
|
261
261
|
return t;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
// src/shared/share-entry.ts
|
|
265
|
+
import { z as z3 } from "zod";
|
|
266
|
+
var nonEmptyString = z3.string().min(1);
|
|
267
|
+
function isOpaqueLocatorId(value) {
|
|
268
|
+
return value.trim() === value && !/[\0-\x1f\x7f]/.test(value) && !value.includes("/") && !value.includes("\\") && !value.includes(":") && value !== "." && value !== "..";
|
|
269
|
+
}
|
|
270
|
+
var OpaqueShareLocatorIdSchema = z3.string().min(1, "must be a non-empty opaque id").max(256, "must be at most 256 characters").refine(isOpaqueLocatorId, "must be an opaque platform-owned id (no path separators, no scheme, no traversal)");
|
|
271
|
+
function mintShareEntryId() {
|
|
272
|
+
return globalThis.crypto.randomUUID();
|
|
273
|
+
}
|
|
274
|
+
var ShareEntryProvenanceSchema = z3.object({
|
|
275
|
+
producerPrincipalRef: nonEmptyString,
|
|
276
|
+
createdAt: nonEmptyString
|
|
277
|
+
}).strict();
|
|
278
|
+
var ShareEntryV1Schema = z3.object({
|
|
279
|
+
schemaVersion: z3.literal(1),
|
|
280
|
+
id: OpaqueShareLocatorIdSchema,
|
|
281
|
+
workspaceId: OpaqueShareLocatorIdSchema,
|
|
282
|
+
path: nonEmptyString,
|
|
283
|
+
provenance: ShareEntryProvenanceSchema
|
|
284
|
+
}).strict();
|
|
285
|
+
var ShareEntryErrorCode = z3.enum(["AR1_SHARE_NOT_FOUND", "AR1_SHARE_TOMBSTONED"]);
|
|
286
|
+
var ShareEntryValidationCode = z3.enum(["SHARE_ENTRY_INPUT_INVALID"]);
|
|
287
|
+
var ShareEntryValidationError = class extends Error {
|
|
288
|
+
code = ErrorCode.enum.CONFIG_INVALID;
|
|
289
|
+
field;
|
|
290
|
+
constructor(issue) {
|
|
291
|
+
super(issue.message);
|
|
292
|
+
this.name = "ShareEntryValidationError";
|
|
293
|
+
this.field = issue.field;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
function assertValidCreateInput(raw) {
|
|
297
|
+
const result = CreateShareEntryInputSchema.safeParse(raw);
|
|
298
|
+
if (result.success) return;
|
|
299
|
+
const issue = result.error.issues[0];
|
|
300
|
+
const field = formatPath(issue.path);
|
|
301
|
+
throw new ShareEntryValidationError({
|
|
302
|
+
code: ShareEntryValidationCode.enum.SHARE_ENTRY_INPUT_INVALID,
|
|
303
|
+
field,
|
|
304
|
+
message: field === "<root>" ? issue.message : `${field} ${issue.message}`
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
var CreateShareEntryInputSchema = z3.object({
|
|
308
|
+
workspaceId: OpaqueShareLocatorIdSchema,
|
|
309
|
+
path: nonEmptyString,
|
|
310
|
+
provenance: z3.object({
|
|
311
|
+
producerPrincipalRef: nonEmptyString,
|
|
312
|
+
createdAt: nonEmptyString.optional()
|
|
313
|
+
}).strict()
|
|
314
|
+
}).strict();
|
|
315
|
+
var InMemoryShareEntryStore = class {
|
|
316
|
+
entries = /* @__PURE__ */ new Map();
|
|
317
|
+
async create(input) {
|
|
318
|
+
assertValidCreateInput(input);
|
|
319
|
+
const entry = {
|
|
320
|
+
schemaVersion: 1,
|
|
321
|
+
id: mintShareEntryId(),
|
|
322
|
+
workspaceId: input.workspaceId,
|
|
323
|
+
path: input.path,
|
|
324
|
+
provenance: {
|
|
325
|
+
producerPrincipalRef: input.provenance.producerPrincipalRef,
|
|
326
|
+
createdAt: input.provenance.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
this.entries.set(entry.id, entry);
|
|
330
|
+
return entry;
|
|
331
|
+
}
|
|
332
|
+
async get(id) {
|
|
333
|
+
return this.entries.get(id) ?? null;
|
|
334
|
+
}
|
|
335
|
+
async delete(id) {
|
|
336
|
+
this.entries.delete(id);
|
|
337
|
+
}
|
|
338
|
+
async list(workspaceId) {
|
|
339
|
+
return Array.from(this.entries.values()).filter((entry) => entry.workspaceId === workspaceId);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
async function resolveShareEntry(store, id, workspace) {
|
|
343
|
+
const entry = await store.get(id);
|
|
344
|
+
if (!entry) {
|
|
345
|
+
return { status: "not_found", code: ShareEntryErrorCode.enum.AR1_SHARE_NOT_FOUND };
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
await workspace.stat(entry.path);
|
|
349
|
+
} catch {
|
|
350
|
+
return {
|
|
351
|
+
status: "tombstoned",
|
|
352
|
+
code: ShareEntryErrorCode.enum.AR1_SHARE_TOMBSTONED,
|
|
353
|
+
tombstone: {
|
|
354
|
+
id: entry.id,
|
|
355
|
+
workspaceId: entry.workspaceId,
|
|
356
|
+
provenance: entry.provenance
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return { status: "ok", entry };
|
|
361
|
+
}
|
|
362
|
+
|
|
264
363
|
export {
|
|
265
364
|
sha256Bytes,
|
|
266
365
|
canonicalStringify,
|
|
@@ -275,5 +374,12 @@ export {
|
|
|
275
374
|
AgentDeploymentValidationError,
|
|
276
375
|
createAgentDefinitionDigest,
|
|
277
376
|
createAgentDeploymentDigest,
|
|
278
|
-
validateTool
|
|
377
|
+
validateTool,
|
|
378
|
+
OpaqueShareLocatorIdSchema,
|
|
379
|
+
ShareEntryProvenanceSchema,
|
|
380
|
+
ShareEntryV1Schema,
|
|
381
|
+
ShareEntryErrorCode,
|
|
382
|
+
ShareEntryValidationError,
|
|
383
|
+
InMemoryShareEntryStore,
|
|
384
|
+
resolveShareEntry
|
|
279
385
|
};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as AgentHarness, a as AgentReadiness, b as Agent } from '../harness-
|
|
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-
|
|
3
|
-
import { S as SessionStore } from '../piChatEvent-
|
|
4
|
-
import { A as AgentCoreSessionService, a as AgentEffectAdmission } from '../piChatSessionService-
|
|
5
|
-
export { b as AGENT_EFFECT_METHODS, c as AgentEffectAdmissionError, P as PiChatEventStreamResult, d as PiChatEventStreamSubscription, e as PiChatEventSubscriber, f as PiChatReplayRangeError, g as PiChatSessionService, h as PiSessionCreateInit, i as PiSessionRequestContext, w as withAgentEffectAdmission } from '../piChatSessionService-
|
|
1
|
+
import { A as AgentHarness, a as AgentReadiness, b as Agent } from '../harness-RhGbdGWY.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-RhGbdGWY.js';
|
|
3
|
+
import { S as SessionStore } from '../piChatEvent-CUTKRaZD.js';
|
|
4
|
+
import { A as AgentCoreSessionService, a as AgentEffectAdmission } from '../piChatSessionService-iBtx32ya.js';
|
|
5
|
+
export { b as AGENT_EFFECT_METHODS, c as AgentEffectAdmissionError, P as PiChatEventStreamResult, d as PiChatEventStreamSubscription, e as PiChatEventSubscriber, f as PiChatReplayRangeError, g as PiChatSessionService, h as PiSessionCreateInit, i as PiSessionRequestContext, w as withAgentEffectAdmission } from '../piChatSessionService-iBtx32ya.js';
|
|
6
6
|
import '@mariozechner/pi-coding-agent';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
package/dist/core/index.js
CHANGED
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
AgentEffectAdmissionError,
|
|
4
4
|
createAgent,
|
|
5
5
|
withAgentEffectAdmission
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-LYBTHR7J.js";
|
|
7
7
|
import {
|
|
8
8
|
AGENT_NOT_IMPLEMENTED_UNTIL_T1,
|
|
9
9
|
AgentNotImplementedError
|
|
10
10
|
} from "../chunk-WSQ5QNIY.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-HDIRWHJB.js";
|
|
12
12
|
export {
|
|
13
13
|
AGENT_EFFECT_METHODS,
|
|
14
14
|
AGENT_NOT_IMPLEMENTED_UNTIL_T1,
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
deriveSourcePlugin,
|
|
5
5
|
mergePiPackageSources,
|
|
6
6
|
withPiHarnessDefaults
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZUDWQAAB.js";
|
|
8
8
|
import "./chunk-AQBXNPMD.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-HDIRWHJB.js";
|
|
10
10
|
export {
|
|
11
11
|
createPiCodingAgentHarness,
|
|
12
12
|
createResourceSettingsManager,
|
package/dist/front/index.d.ts
CHANGED
|
@@ -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, a as BoringChatMessage, P as PiChatStatus, Q as QueuedUserMessage, C as ChatError, b as PiChatEvent, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, f as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, h as CommandReceipt, i as StopPayload, j as StopReceipt, k as SessionSummary } from '../piChatEvent-
|
|
4
|
+
import { T as ToolUiMetadata, B as BoringChatPart, a as BoringChatMessage, P as PiChatStatus, Q as QueuedUserMessage, C as ChatError, b as PiChatEvent, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, f as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, h as CommandReceipt, i as StopPayload, j as StopReceipt, k as SessionSummary } from '../piChatEvent-CUTKRaZD.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';
|
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-6O5ADR57.js";
|
|
16
16
|
import {
|
|
17
17
|
ErrorCode
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-HDIRWHJB.js";
|
|
19
19
|
import {
|
|
20
20
|
DebugDrawer,
|
|
21
21
|
cn,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as SessionCtx, b as PiChatEvent, S as SessionStore } from './piChatEvent-
|
|
1
|
+
import { l as SessionCtx, b as PiChatEvent, S as SessionStore } from './piChatEvent-CUTKRaZD.js';
|
|
2
2
|
import { AgentSessionEvent, PromptOptions } from '@mariozechner/pi-coding-agent';
|
|
3
3
|
|
|
4
4
|
interface TelemetrySink {
|