orkestrator 2.37.3-beta → 2.37.4-beta
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/client.js +356 -16
- package/dist/main.js +111519 -102007
- package/package.json +3 -3
- package/resources/acp-bridge/dist/index.js +198 -75
- package/resources/claude-bridge/dist/index.js +364 -167
- package/resources/codex-bridge/dist/index.js +239 -88
- package/resources/cursor-bridge/dist/index.js +1344 -395
- package/resources/cursor-bridge/runtime/install.json +1 -1
- package/resources/pi-bridge/dist/index.js +351 -131
- package/resources/pi-bridge/runtime/install.json +1 -1
|
@@ -1184,12 +1184,22 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
|
|
|
1184
1184
|
denied: "A renderer asked for a permission the policy does not grant."
|
|
1185
1185
|
}
|
|
1186
1186
|
},
|
|
1187
|
+
"desktop.webrequest": {
|
|
1188
|
+
description: "Main-process webRequest listeners on Electron sessions. Listener names only; never a URL, header or error message.",
|
|
1189
|
+
events: {
|
|
1190
|
+
"listener.failed-closed": "A listener's decision threw or rejected, so it answered with its fail-closed response.",
|
|
1191
|
+
"observer.failed": "A listener with no callback (a redirect observer) threw; its fallback ran.",
|
|
1192
|
+
"callback.failed": "Electron's webRequest callback threw while a listener answered.",
|
|
1193
|
+
...THROTTLE_LOG_EVENTS
|
|
1194
|
+
}
|
|
1195
|
+
},
|
|
1187
1196
|
"desktop.dialog": {
|
|
1188
1197
|
description: "Native dialogs, whose modal loops hold the main thread while they are open.",
|
|
1189
1198
|
events: {
|
|
1190
1199
|
"attention-failed": "A dialog could not ask for the user's attention.",
|
|
1191
1200
|
closed: "A native dialog closed.",
|
|
1192
1201
|
"hidden-cancelled": "A hidden profile cancelled a dialog without opening native UI.",
|
|
1202
|
+
"no-display-cancelled": "A headless Electron with no display cancelled a dialog instead of opening native UI.",
|
|
1193
1203
|
"open-failed": "A dialog could not open; it was answered as cancelled.",
|
|
1194
1204
|
opening: "A native dialog is opening.",
|
|
1195
1205
|
"preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
|
|
@@ -1545,6 +1555,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
|
|
|
1545
1555
|
"agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
|
|
1546
1556
|
"coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
|
|
1547
1557
|
"monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
|
|
1558
|
+
"monitor.silent": "The request monitor's stream stopped heartbeating, so it is replaced. `silenceMs` only.",
|
|
1548
1559
|
"worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
|
|
1549
1560
|
"request.failed": "Handling a request event failed, so the stream restarts. Error class only.",
|
|
1550
1561
|
"credential-plugin.skipped": "A host OpenCode server started without the credential plugin, so its tools inherit its password; `reason` says why.",
|
|
@@ -1567,6 +1578,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
|
|
|
1567
1578
|
"host-server.terminate-failed": "A 2.x server that did not become ready could not be stopped; its process entry is kept for shutdown. Error class only.",
|
|
1568
1579
|
"container-server.launched": "The start script of a container environment's 2.x server was run. Container port only.",
|
|
1569
1580
|
"container-server.ready": "A container environment's 2.x server this backend started answered `/api/info` as 2.x. Environment id only.",
|
|
1581
|
+
"container-server.cleanup-failed": "Cleanup after OpenCode startup failed; step names only, while the original startup error is preserved.",
|
|
1570
1582
|
"container-server.warm-incomplete": "The first workspace request to a container's new 2.x server failed, so its plugins load on the next one. Error class only.",
|
|
1571
1583
|
"resume-list.unavailable": "The 2.x sessions could not be listed for the resume picker, so it shows the 1.x list alone. Error class only.",
|
|
1572
1584
|
"credential.mirrored": "A provider sign-in change was copied into the 2.x database. `outcome` (written, removed, unchanged, skipped) only; never a provider id or value.",
|
|
@@ -1801,6 +1813,7 @@ var TMUX_LOG_AREAS = defineLogAreas({
|
|
|
1801
1813
|
"cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
|
|
1802
1814
|
"cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
|
|
1803
1815
|
"cleanup.kill-failed": "An environment's tmux sessions could not be killed.",
|
|
1816
|
+
"cleanup.kill-incomplete": "An environment's tmux sessions could not all be shown gone (a session survived, or the socket was unreachable while another tmux process might own it), so cleanup stays incomplete.",
|
|
1804
1817
|
"hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
|
|
1805
1818
|
"hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
|
|
1806
1819
|
"naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
|
|
@@ -1930,6 +1943,7 @@ var STORAGE_LOG_AREAS = defineLogAreas({
|
|
|
1930
1943
|
"config.restrict-mode-failed": "A config file holding provider secrets could not be set to owner-only; the backend carries on.",
|
|
1931
1944
|
"legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
|
|
1932
1945
|
"legacy-json.archive-failed": "Imported JSON store files could not be archived.",
|
|
1946
|
+
"native-session-owners.backfill-failed": "Native-session rows could not be given their environment as owner at open; an environment delete then parses those rows instead, and the next open retries.",
|
|
1933
1947
|
"lease.timed-out": "A waiter gave up on a lease; `lease` and `family` name it, `holderAgeMs` is the time since its holder's last heartbeat (null when the holder had just gone), `waitedMs` how long the waiter waited.",
|
|
1934
1948
|
"lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
|
|
1935
1949
|
"scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
|
|
@@ -1979,6 +1993,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
|
|
|
1979
1993
|
"transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
|
|
1980
1994
|
"restore.skipped": "A pipeline could not be restored at startup and was skipped.",
|
|
1981
1995
|
"criteria.record-failed": "Acceptance criteria results could not be recorded on the ticket.",
|
|
1996
|
+
"completion-notes.publish-failed": "A finished pipeline's notes tab could not be added to the layout; the run stays complete.",
|
|
1982
1997
|
"workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
|
|
1983
1998
|
"rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
|
|
1984
1999
|
"kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
|
|
@@ -2020,6 +2035,8 @@ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
|
|
|
2020
2035
|
"dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
|
|
2021
2036
|
"turn.finalize-failed": "Finalizing a turn failed.",
|
|
2022
2037
|
"turn.settle-failed": "Settling a late interrupted turn failed.",
|
|
2038
|
+
"turn.end-recovery": "A background retry of a turn end capture that timed out finished: recovered, done (no longer eligible) or exhausted.",
|
|
2039
|
+
"turn.end-recovery-failed": "A background retry of a turn end capture threw; it counts as a failed attempt.",
|
|
2023
2040
|
"evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
|
|
2024
2041
|
"measurement.failed": "Recomputing a tool's measurement failed."
|
|
2025
2042
|
}
|
|
@@ -2088,6 +2105,7 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
|
|
|
2088
2105
|
"node-release.no-coordinator": "Work closed on a released node belonged to a coordinator that no longer exists, so nobody was told.",
|
|
2089
2106
|
"node-offline.notice-failed": "The notice that a node has been unreachable for a day could not be sent; the next failed read retries.",
|
|
2090
2107
|
"node-offline.check-failed": "Whether a long-unreachable node's coordinators were told could not be checked; the next read retries.",
|
|
2108
|
+
"node-reconnect.notice-failed": "The message that a node a coordinator tried while it was disconnected is back could not be sent; it is not retried, since the coordinator already holds the refusal.",
|
|
2091
2109
|
"checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
|
|
2092
2110
|
"checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
|
|
2093
2111
|
"checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded (`fast-forwarded-fetched` when the fetch was slow or failed and the upstream commit already fetched was merged), or `outcome` says why not (`timed-out`, `failed`).",
|
|
@@ -2140,7 +2158,8 @@ var REVIEW_LOG_AREAS = defineLogAreas({
|
|
|
2140
2158
|
"monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
|
|
2141
2159
|
"monitor.merged-tickets-closed": "The startup sweep moved Kanban tickets whose pull request had merged to done (`count`).",
|
|
2142
2160
|
"monitor.merged-tickets-close-failed": "The startup sweep closing Kanban tickets whose pull request merged failed; the next backend start retries.",
|
|
2143
|
-
"monitor.emit-failed": "A pull request monitor event could not be emitted to its sink."
|
|
2161
|
+
"monitor.emit-failed": "A pull request monitor event could not be emitted to its sink.",
|
|
2162
|
+
"branch-cleanup.kept": "A merge or cleanup kept a pull request's head branch because it is not the branch created for the environment (`reason`)."
|
|
2144
2163
|
}
|
|
2145
2164
|
}
|
|
2146
2165
|
});
|
|
@@ -2172,6 +2191,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
|
|
|
2172
2191
|
"kept-note.failed": "Recording why a limit stop found no account to move to failed; the stop stands.",
|
|
2173
2192
|
"container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
|
|
2174
2193
|
"last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
|
|
2194
|
+
"shared-usage.save-failed": "The shared usage readings could not be saved; they stay in memory and the next reading saves them.",
|
|
2195
|
+
"shared-usage.record-failed": "A fresh usage reading could not be kept for sharing with other machines; the account's own reading stands.",
|
|
2175
2196
|
"login-cleanup.failed": "A temporary login could not be cleaned up.",
|
|
2176
2197
|
"login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
|
|
2177
2198
|
"login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
|
|
@@ -2189,6 +2210,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2189
2210
|
"git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
|
|
2190
2211
|
"git-mirror.mount-withheld": "A new restricted container gets no project Git mirror because its firewall would not let it reach the project's remote, so it cannot read what the remote serves through the mirror either.",
|
|
2191
2212
|
"git-mirror.refreshed": "A project's Git mirror was built or updated.",
|
|
2213
|
+
"git-mirror.access-changed": "A project's Git mirror was withdrawn because containers are now given a different credential (another access kind, or a token acting as another or an unreadable account), so no reader keeps what it could not fetch itself.",
|
|
2192
2214
|
"git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
|
|
2193
2215
|
"git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
|
|
2194
2216
|
"git-mirror.refresh-failed": "A project's Git mirror could not be updated. New clones still work, from the mirror as it was or from the remote.",
|
|
@@ -2202,6 +2224,9 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2202
2224
|
"git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
|
|
2203
2225
|
"project-seed.refused": "A project .env, .env.local or opencode.json was not copied into a new container: a link, not a regular file, outside the project, too large or unreadable.",
|
|
2204
2226
|
"opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
|
|
2227
|
+
"opencode.listener-replaced": "The process on a container's OpenCode port (`provider`: `opencode` or `opencode2`) is not the server the backend launched and recorded, so its password was withheld and the next start replaces it. `stage` is `request` when the re-check after a refused connection or an unexpected answer found it (to-do 7550); that connection then sends nothing more.",
|
|
2228
|
+
"opencode.project-config-too-large": "A checkout's opencode.json or opencode.jsonc was larger than the limit, so a launched OpenCode server does not read it. File name only.",
|
|
2229
|
+
"opencode.project-config-filtered": "Values were left out of a checkout's OpenCode configuration before a launched server reads it (to-do 7550): counts of plugin keys, `{env:}` and `{file:}` references and dropped instructions (including separate instructionGlob and instructionUrl counts), and the names of files that were not a JSONC object. Never values.",
|
|
2205
2230
|
"log-driver.unbounded": "The Docker daemon offers neither the local nor the json-file log driver, so new containers keep its default driver, whose log may be uncapped. Written once per backend.",
|
|
2206
2231
|
"lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
|
|
2207
2232
|
"login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
|
|
@@ -2236,6 +2261,17 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2236
2261
|
description: "A bridge process was launched in a container, for the first time there or as a relaunch; `provider` names it. A relaunch keeps the run before it in the previous log.",
|
|
2237
2262
|
essential: true,
|
|
2238
2263
|
fields: { provider: "label", containerPort: "number" }
|
|
2264
|
+
},
|
|
2265
|
+
"bridge.listener-refused": {
|
|
2266
|
+
description: "The socket listening on a container bridge's port is not the one the bridge the backend started opened (to-do 7250), so its token is not handed out and the next start replaces it. `reason` is a fixed label: `different-socket`, `several-sockets`, `pending` (a start has not recorded its bridge yet, or failed before it did) or `scan-incomplete`.",
|
|
2267
|
+
essential: true,
|
|
2268
|
+
fields: { provider: "label", reason: "label" }
|
|
2269
|
+
},
|
|
2270
|
+
"bridge.listener-adopted": "A running container bridge had no listener record, because a backend from before the record started it, so the socket on its port was recorded as the bridge's; `provider` names it.",
|
|
2271
|
+
"bridge.listener-unrecorded": {
|
|
2272
|
+
description: "A bridge the backend just launched could not be recorded as its port's listener, for the fixed `reason` given (`no-listener`, `several-sockets`, `launch-exited` or `scan-incomplete`); what listens on the port is stopped and the start fails.",
|
|
2273
|
+
essential: true,
|
|
2274
|
+
fields: { provider: "label", reason: "label" }
|
|
2239
2275
|
}
|
|
2240
2276
|
}
|
|
2241
2277
|
},
|
|
@@ -2290,7 +2326,8 @@ var MCP_LOG_AREAS = defineLogAreas({
|
|
|
2290
2326
|
"listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
|
|
2291
2327
|
"state-listener.failed": "A Control MCP state listener threw; the others still run.",
|
|
2292
2328
|
"delegation.remote-open-failed": "A delegation could not be opened on another node.",
|
|
2293
|
-
"delegation.open-failed": "A coordinator delegation could not be opened."
|
|
2329
|
+
"delegation.open-failed": "A coordinator delegation could not be opened.",
|
|
2330
|
+
"delegation.turn-origin-unreadable": "A coordinator's last turn origin could not be read, so its delegated prompt is marked as arising from agent mail."
|
|
2294
2331
|
}
|
|
2295
2332
|
},
|
|
2296
2333
|
"mcp-management": {
|
|
@@ -2375,6 +2412,7 @@ var NODES_LOG_AREAS = defineLogAreas({
|
|
|
2375
2412
|
"ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
|
|
2376
2413
|
"ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
|
|
2377
2414
|
"ticket-sync.forget-failed": "A detached command node's ticket copies could not be released.",
|
|
2415
|
+
"usage-sync.failed": "Sharing usage readings with a node failed; the next reading or reconnect retries.",
|
|
2378
2416
|
"fleet-update.requested": "The update policy asked an older leaf to install the command node's version.",
|
|
2379
2417
|
"fleet-update.failed": "The update policy could not read or update a leaf; it retries later.",
|
|
2380
2418
|
"fleet-update.policy-load-failed": "The stored update policy could not be read; it is off."
|
|
@@ -2466,6 +2504,20 @@ var SCHEDULER_LOG_AREAS = defineLogAreas({
|
|
|
2466
2504
|
}
|
|
2467
2505
|
});
|
|
2468
2506
|
|
|
2507
|
+
// ../protocol/src/log-vocabulary/self-improvement.ts
|
|
2508
|
+
var SELF_IMPROVEMENT_LOG_AREAS = defineLogAreas({
|
|
2509
|
+
"self-improvement": {
|
|
2510
|
+
description: "Self-improvement runs: diagnostics and conversation review turned into tickets. Counts and steps only, never conversation text.",
|
|
2511
|
+
events: {
|
|
2512
|
+
"run.started": "A run started; `trigger` is manual, daily or dry-run.",
|
|
2513
|
+
"run.finished": "A run finished; `created`, `verified`, `fixFailed` and `parts` count its tickets, confirmed fixes, failed fixes and conversation parts read.",
|
|
2514
|
+
"run.failed": "A run stopped before it finished; `reason` is a fixed label.",
|
|
2515
|
+
"review.call-failed": "One conversation review call failed; the run carries on and the part is read again next run.",
|
|
2516
|
+
"daily.check-failed": "The daily run check failed; the next check retries."
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
});
|
|
2520
|
+
|
|
2469
2521
|
// ../protocol/src/log-vocabulary/web-app.ts
|
|
2470
2522
|
var WEB_APP_LOG_AREAS = defineLogAreas({
|
|
2471
2523
|
"web.app": {
|
|
@@ -2801,6 +2853,10 @@ var WEB_SETTINGS_LOG_AREAS = defineLogAreas({
|
|
|
2801
2853
|
"web.settings": {
|
|
2802
2854
|
description: "The settings screens.",
|
|
2803
2855
|
events: {
|
|
2856
|
+
"self-improvement.status-failed": "Settings → Self-improvement could not read the status.",
|
|
2857
|
+
"self-improvement.projects-failed": "Settings → Self-improvement could not list the projects.",
|
|
2858
|
+
"self-improvement.save-failed": "Settings → Self-improvement could not save a setting.",
|
|
2859
|
+
"self-improvement.run-failed": "Settings → Self-improvement could not start a run.",
|
|
2804
2860
|
"config.save-failed": "Global settings could not be saved.",
|
|
2805
2861
|
"config.load-failed": "The settings page could not load the config.",
|
|
2806
2862
|
"config.reload-failed": "Re-reading the workspace config after a save failed.",
|
|
@@ -2970,6 +3026,7 @@ var LOG_VOCABULARY = {
|
|
|
2970
3026
|
...HOST_LOG_AREAS,
|
|
2971
3027
|
...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
|
|
2972
3028
|
...SCHEDULER_LOG_AREAS,
|
|
3029
|
+
...SELF_IMPROVEMENT_LOG_AREAS,
|
|
2973
3030
|
...WEB_APP_LOG_AREAS,
|
|
2974
3031
|
...WEB_BUILD_PIPELINE_LOG_AREAS,
|
|
2975
3032
|
...WEB_CHAT_LOG_AREAS,
|
|
@@ -3091,6 +3148,14 @@ var SIGNALS = new Set([
|
|
|
3091
3148
|
"SIGXFSZ"
|
|
3092
3149
|
]);
|
|
3093
3150
|
var PROVIDERS = new Set(["claude", "codex", "opencode", "cursor", "grok", "acp", "pi"]);
|
|
3151
|
+
var BRIDGE_LISTENER_REASONS = new Set([
|
|
3152
|
+
"different-socket",
|
|
3153
|
+
"several-sockets",
|
|
3154
|
+
"pending",
|
|
3155
|
+
"scan-incomplete",
|
|
3156
|
+
"no-listener",
|
|
3157
|
+
"launch-exited"
|
|
3158
|
+
]);
|
|
3094
3159
|
var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
3095
3160
|
var SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
|
|
3096
3161
|
var STORAGE_DATABASES = new Set(["main", "ledger", "other"]);
|
|
@@ -3950,8 +4015,10 @@ function reservePromptAdmission(state, closed) {
|
|
|
3950
4015
|
function releasePromptClaim(state, claim) {
|
|
3951
4016
|
if (claim === undefined)
|
|
3952
4017
|
return;
|
|
3953
|
-
if (state.promptClaim === claim)
|
|
4018
|
+
if (state.promptClaim === claim) {
|
|
3954
4019
|
state.promptClaim = undefined;
|
|
4020
|
+
state.lastAccessed = Date.now();
|
|
4021
|
+
}
|
|
3955
4022
|
if (state.cancelRequestedClaim === claim)
|
|
3956
4023
|
state.cancelRequestedClaim = undefined;
|
|
3957
4024
|
if (state.promptStartup?.claim === claim)
|
|
@@ -4009,24 +4076,60 @@ function sessionIsWorking(state) {
|
|
|
4009
4076
|
function sessionIsBlocked(state) {
|
|
4010
4077
|
return state.approvals.size > 0;
|
|
4011
4078
|
}
|
|
4079
|
+
// ../protocol/src/node/bounded-wait.ts
|
|
4080
|
+
function boundedWait(work, timeoutMs, options = {}) {
|
|
4081
|
+
return new Promise((resolve, reject) => {
|
|
4082
|
+
let timedOut = false;
|
|
4083
|
+
const timer = setTimeout(() => {
|
|
4084
|
+
timedOut = true;
|
|
4085
|
+
resolve({ settled: false });
|
|
4086
|
+
}, timeoutMs);
|
|
4087
|
+
unrefTimer(timer);
|
|
4088
|
+
Promise.resolve(work).then((value) => {
|
|
4089
|
+
if (!timedOut) {
|
|
4090
|
+
clearTimeout(timer);
|
|
4091
|
+
resolve({ settled: true, value });
|
|
4092
|
+
return;
|
|
4093
|
+
}
|
|
4094
|
+
disposeLate(options.onLate, value);
|
|
4095
|
+
}, (error) => {
|
|
4096
|
+
if (!timedOut) {
|
|
4097
|
+
clearTimeout(timer);
|
|
4098
|
+
reject(error);
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
});
|
|
4102
|
+
}
|
|
4103
|
+
async function boundedWaitOrThrow(work, timeoutMs, timeoutError, options = {}) {
|
|
4104
|
+
const result = await boundedWait(work, timeoutMs, options);
|
|
4105
|
+
if (!result.settled)
|
|
4106
|
+
throw timeoutError();
|
|
4107
|
+
return result.value;
|
|
4108
|
+
}
|
|
4109
|
+
function unrefTimer(timer) {
|
|
4110
|
+
const handle = timer;
|
|
4111
|
+
if (typeof handle === "object" && typeof handle.unref === "function")
|
|
4112
|
+
handle.unref();
|
|
4113
|
+
}
|
|
4114
|
+
function disposeLate(onLate, value) {
|
|
4115
|
+
if (!onLate)
|
|
4116
|
+
return;
|
|
4117
|
+
try {
|
|
4118
|
+
const disposal = onLate(value);
|
|
4119
|
+
if (disposal && typeof disposal.then === "function") {
|
|
4120
|
+
Promise.resolve(disposal).catch(() => {
|
|
4121
|
+
return;
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
} catch {}
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4012
4127
|
// ../../bridges/pi-bridge/src/timeout.ts
|
|
4013
4128
|
class TimeoutError extends Error {
|
|
4014
4129
|
name = "TimeoutError";
|
|
4015
4130
|
}
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
try {
|
|
4019
|
-
return await Promise.race([
|
|
4020
|
-
work,
|
|
4021
|
-
new Promise((_, reject) => {
|
|
4022
|
-
timer = setTimeout(() => reject(new TimeoutError(message)), timeoutMs);
|
|
4023
|
-
timer.unref();
|
|
4024
|
-
})
|
|
4025
|
-
]);
|
|
4026
|
-
} finally {
|
|
4027
|
-
if (timer)
|
|
4028
|
-
clearTimeout(timer);
|
|
4029
|
-
}
|
|
4131
|
+
function withTimeout(work, timeoutMs, message) {
|
|
4132
|
+
return boundedWaitOrThrow(work, timeoutMs, () => new TimeoutError(message));
|
|
4030
4133
|
}
|
|
4031
4134
|
// ../../bridges/pi-bridge/src/pi-sdk.ts
|
|
4032
4135
|
import {
|
|
@@ -5375,6 +5478,58 @@ var PROTECTED_SEGMENTS = new Set([
|
|
|
5375
5478
|
".mcp.json"
|
|
5376
5479
|
]);
|
|
5377
5480
|
|
|
5481
|
+
// ../protocol/src/agent-mail.ts
|
|
5482
|
+
var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
|
|
5483
|
+
var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
|
|
5484
|
+
var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
|
|
5485
|
+
var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
|
|
5486
|
+
var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
5487
|
+
var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
|
|
5488
|
+
var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
|
|
5489
|
+
var AGENT_MAIL_TOOL_NAMES = Object.freeze([
|
|
5490
|
+
"list_mailboxes",
|
|
5491
|
+
"send_message",
|
|
5492
|
+
"check_inbox",
|
|
5493
|
+
"read_message",
|
|
5494
|
+
"ack_message",
|
|
5495
|
+
"reply_message",
|
|
5496
|
+
"get_message_status"
|
|
5497
|
+
]);
|
|
5498
|
+
var DEFAULT_AGENT_MESSAGING_SETTINGS = Object.freeze({
|
|
5499
|
+
enabled: true,
|
|
5500
|
+
allowCrossProject: false,
|
|
5501
|
+
defaultInjectPolicy: "off",
|
|
5502
|
+
wakePeers: false,
|
|
5503
|
+
autonomousWakeBudget: AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET,
|
|
5504
|
+
hourlyWakeLimit: AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT,
|
|
5505
|
+
coordinatorStatusWakes: "settled",
|
|
5506
|
+
retentionDays: AGENT_MAIL_DEFAULT_RETENTION_DAYS,
|
|
5507
|
+
paused: false
|
|
5508
|
+
});
|
|
5509
|
+
function agentMailCapabilities(tabType, agent, locked = true) {
|
|
5510
|
+
if (tabType === "agent-native") {
|
|
5511
|
+
if (!locked || !agent)
|
|
5512
|
+
return { canPull: false, canSend: false, canInject: false };
|
|
5513
|
+
if (agent === "claude" || agent === "codex" || agent === "opencode" || agent === "pi" || agent === "cursor" || agent === "grok") {
|
|
5514
|
+
return { canPull: true, canSend: true, canInject: true };
|
|
5515
|
+
}
|
|
5516
|
+
return { canPull: false, canSend: false, canInject: false };
|
|
5517
|
+
}
|
|
5518
|
+
if (tabType === "claude-tmux")
|
|
5519
|
+
return { canPull: true, canSend: true, canInject: true };
|
|
5520
|
+
if (tabType === "pipeline-worker") {
|
|
5521
|
+
return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
|
|
5522
|
+
}
|
|
5523
|
+
if (["claude", "codex", "opencode"].includes(tabType)) {
|
|
5524
|
+
return { canPull: true, canSend: true, canInject: false };
|
|
5525
|
+
}
|
|
5526
|
+
if (["cursor", "grok", "pi"].includes(tabType)) {
|
|
5527
|
+
return { canPull: false, canSend: false, canInject: false };
|
|
5528
|
+
}
|
|
5529
|
+
return { canPull: false, canSend: false, canInject: false };
|
|
5530
|
+
}
|
|
5531
|
+
var NATIVE_AGENT_MAIL_CAPABILITIES = Object.freeze(Object.fromEntries(AGENT_PLATFORMS.map((agent) => [agent, agentMailCapabilities("agent-native", agent)])));
|
|
5532
|
+
|
|
5378
5533
|
// ../protocol/src/review-evidence-frames.ts
|
|
5379
5534
|
var COORDINATOR_WORKER_NO_PR_INSTRUCTION = "Do not open a pull request, even if the prompt below asks you to: commit your work and report back. Orkestrator raises the pull request from a PR tab once the work has been reviewed.";
|
|
5380
5535
|
var COORDINATOR_WORKER_VALIDATION_INSTRUCTION = "Run the focused checks your changes need and report them. When the prompt below says review follows, leave the required full test suite, typecheck, lint and build passes to review preparation unless it explicitly asks you to run them. When no review follows or the prompt does not say, follow the repository's validation requirements before handoff. Report any required full validation you did not run; do not assume a later review will run it.";
|
|
@@ -5956,6 +6111,11 @@ var BACKGROUND_CAPABLE_SHELL_TOOL_NAMES = new Set([
|
|
|
5956
6111
|
"run_terminal_cmd",
|
|
5957
6112
|
"execute_command"
|
|
5958
6113
|
]);
|
|
6114
|
+
var NATIVE_AGENT_BRANCH_LIST_LIMITS = Object.freeze({
|
|
6115
|
+
branches: 50,
|
|
6116
|
+
promptChars: 280,
|
|
6117
|
+
entryIdChars: 512
|
|
6118
|
+
});
|
|
5959
6119
|
var NATIVE_AGENT_COMMAND_EXECUTION_KINDS = [
|
|
5960
6120
|
"provider-prompt",
|
|
5961
6121
|
"provider-command",
|
|
@@ -6814,6 +6974,7 @@ function applySessionEvent(state, event) {
|
|
|
6814
6974
|
break;
|
|
6815
6975
|
case "compaction_end":
|
|
6816
6976
|
state.compacting = false;
|
|
6977
|
+
state.lastAccessed = Date.now();
|
|
6817
6978
|
applyCompaction(state, event);
|
|
6818
6979
|
break;
|
|
6819
6980
|
case "thinking_level_changed":
|
|
@@ -7658,58 +7819,6 @@ var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
|
|
|
7658
7819
|
]);
|
|
7659
7820
|
var COORDINATOR_PROJECT_HOME_MESSAGE_WINDOW_MS = 3 * 60 * 60000;
|
|
7660
7821
|
|
|
7661
|
-
// ../protocol/src/agent-mail.ts
|
|
7662
|
-
var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
|
|
7663
|
-
var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
|
|
7664
|
-
var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
|
|
7665
|
-
var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
|
|
7666
|
-
var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
7667
|
-
var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
|
|
7668
|
-
var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
|
|
7669
|
-
var AGENT_MAIL_TOOL_NAMES = Object.freeze([
|
|
7670
|
-
"list_mailboxes",
|
|
7671
|
-
"send_message",
|
|
7672
|
-
"check_inbox",
|
|
7673
|
-
"read_message",
|
|
7674
|
-
"ack_message",
|
|
7675
|
-
"reply_message",
|
|
7676
|
-
"get_message_status"
|
|
7677
|
-
]);
|
|
7678
|
-
var DEFAULT_AGENT_MESSAGING_SETTINGS = Object.freeze({
|
|
7679
|
-
enabled: true,
|
|
7680
|
-
allowCrossProject: false,
|
|
7681
|
-
defaultInjectPolicy: "off",
|
|
7682
|
-
wakePeers: false,
|
|
7683
|
-
autonomousWakeBudget: AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET,
|
|
7684
|
-
hourlyWakeLimit: AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT,
|
|
7685
|
-
coordinatorStatusWakes: "settled",
|
|
7686
|
-
retentionDays: AGENT_MAIL_DEFAULT_RETENTION_DAYS,
|
|
7687
|
-
paused: false
|
|
7688
|
-
});
|
|
7689
|
-
function agentMailCapabilities(tabType, agent, locked = true) {
|
|
7690
|
-
if (tabType === "agent-native") {
|
|
7691
|
-
if (!locked || !agent)
|
|
7692
|
-
return { canPull: false, canSend: false, canInject: false };
|
|
7693
|
-
if (agent === "claude" || agent === "codex" || agent === "opencode" || agent === "pi" || agent === "cursor" || agent === "grok") {
|
|
7694
|
-
return { canPull: true, canSend: true, canInject: true };
|
|
7695
|
-
}
|
|
7696
|
-
return { canPull: false, canSend: false, canInject: false };
|
|
7697
|
-
}
|
|
7698
|
-
if (tabType === "claude-tmux")
|
|
7699
|
-
return { canPull: true, canSend: true, canInject: true };
|
|
7700
|
-
if (tabType === "pipeline-worker") {
|
|
7701
|
-
return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
|
|
7702
|
-
}
|
|
7703
|
-
if (["claude", "codex", "opencode"].includes(tabType)) {
|
|
7704
|
-
return { canPull: true, canSend: true, canInject: false };
|
|
7705
|
-
}
|
|
7706
|
-
if (["cursor", "grok", "pi"].includes(tabType)) {
|
|
7707
|
-
return { canPull: false, canSend: false, canInject: false };
|
|
7708
|
-
}
|
|
7709
|
-
return { canPull: false, canSend: false, canInject: false };
|
|
7710
|
-
}
|
|
7711
|
-
var NATIVE_AGENT_MAIL_CAPABILITIES = Object.freeze(Object.fromEntries(AGENT_PLATFORMS.map((agent) => [agent, agentMailCapabilities("agent-native", agent)])));
|
|
7712
|
-
|
|
7713
7822
|
// ../protocol/src/suborks.ts
|
|
7714
7823
|
var SUBORK_TOOL_NAME = "ask_agents";
|
|
7715
7824
|
var AGENT_SUBORK_TOOL_NAMES = Object.freeze([SUBORK_TOOL_NAME]);
|
|
@@ -31944,15 +32053,8 @@ async function closeConnections(state, connections) {
|
|
|
31944
32053
|
const settled = Promise.allSettled(connections.map(async (connection) => {
|
|
31945
32054
|
await connection.close();
|
|
31946
32055
|
}));
|
|
31947
|
-
|
|
31948
|
-
|
|
31949
|
-
timer = setTimeout(() => resolve("timeout"), closeTimeoutMs);
|
|
31950
|
-
timer.unref();
|
|
31951
|
-
});
|
|
31952
|
-
const outcome = await Promise.race([settled.then(() => "closed"), deadline]);
|
|
31953
|
-
if (timer)
|
|
31954
|
-
clearTimeout(timer);
|
|
31955
|
-
if (outcome === "timeout") {
|
|
32056
|
+
const outcome = await boundedWait(settled, closeTimeoutMs);
|
|
32057
|
+
if (!outcome.settled) {
|
|
31956
32058
|
state.health.recordNotice({
|
|
31957
32059
|
message: "An MCP server did not close in time; the bridge moved on without waiting",
|
|
31958
32060
|
method: "mcp/close",
|
|
@@ -32042,31 +32144,7 @@ function recordConnectFailure(state, server, error) {
|
|
|
32042
32144
|
};
|
|
32043
32145
|
}
|
|
32044
32146
|
async function connectWithTimeout(transport, server, context) {
|
|
32045
|
-
|
|
32046
|
-
let timedOut = false;
|
|
32047
|
-
let timer;
|
|
32048
|
-
const deadline = new Promise((_resolve, reject) => {
|
|
32049
|
-
timer = setTimeout(() => {
|
|
32050
|
-
timedOut = true;
|
|
32051
|
-
reject(new Error(`MCP server ${server.id} timed out`));
|
|
32052
|
-
}, connectTimeoutMs);
|
|
32053
|
-
timer.unref();
|
|
32054
|
-
});
|
|
32055
|
-
try {
|
|
32056
|
-
return await Promise.race([attempt, deadline]);
|
|
32057
|
-
} catch (error) {
|
|
32058
|
-
if (timedOut) {
|
|
32059
|
-
attempt.then((late) => late.close().catch(() => {
|
|
32060
|
-
return;
|
|
32061
|
-
}), () => {
|
|
32062
|
-
return;
|
|
32063
|
-
});
|
|
32064
|
-
}
|
|
32065
|
-
throw error;
|
|
32066
|
-
} finally {
|
|
32067
|
-
if (timer)
|
|
32068
|
-
clearTimeout(timer);
|
|
32069
|
-
}
|
|
32147
|
+
return await boundedWaitOrThrow(transport.connect(server, context), connectTimeoutMs, () => new Error(`MCP server ${server.id} timed out`), { onLate: (late) => late.close() });
|
|
32070
32148
|
}
|
|
32071
32149
|
function registerListedTool(server, listed, connection) {
|
|
32072
32150
|
const remoteName = listed.name.trim();
|
|
@@ -36394,6 +36472,18 @@ async function overlayCommandChanges(state, options = {}) {
|
|
|
36394
36472
|
} catch {}
|
|
36395
36473
|
}
|
|
36396
36474
|
|
|
36475
|
+
// ../../bridges/pi-bridge/src/project-extensions.ts
|
|
36476
|
+
var PROJECT_EXTENSIONS_REFUSED_NOTE = "Pi runs extensions inside the bridge process, where they could answer approvals themselves, so discovered extensions and configured packages do not load under any approval policy; local project skills and prompt templates still do.";
|
|
36477
|
+
function projectExtensionsRefusedForApprovals(policy, readOnly = false) {
|
|
36478
|
+
return policy?.projectResources === true && !readOnly;
|
|
36479
|
+
}
|
|
36480
|
+
function excludeConfiguredPackages(settingsManager) {
|
|
36481
|
+
for (const key of ["getGlobalSettings", "getProjectSettings"]) {
|
|
36482
|
+
const read = settingsManager[key].bind(settingsManager);
|
|
36483
|
+
settingsManager[key] = () => ({ ...read(), packages: [] });
|
|
36484
|
+
}
|
|
36485
|
+
}
|
|
36486
|
+
|
|
36397
36487
|
// ../../bridges/pi-bridge/src/session-list-cache.ts
|
|
36398
36488
|
import { createHash as createHash6 } from "node:crypto";
|
|
36399
36489
|
import { readdir, stat as stat2 } from "node:fs/promises";
|
|
@@ -36718,8 +36808,13 @@ function piAppendedInstructions(state) {
|
|
|
36718
36808
|
}
|
|
36719
36809
|
async function createPiSessionServices(state, options) {
|
|
36720
36810
|
const loaderPolicy = piResourceLoaderPolicy(state, options.cwd);
|
|
36811
|
+
const settingsManager = options.settingsManager ?? SettingsManager.create(options.cwd, options.agentDir, {
|
|
36812
|
+
projectTrusted: loaderPolicy.projectTrusted
|
|
36813
|
+
});
|
|
36814
|
+
excludeConfiguredPackages(settingsManager);
|
|
36721
36815
|
const services = await createAgentSessionServices({
|
|
36722
36816
|
...options,
|
|
36817
|
+
settingsManager,
|
|
36723
36818
|
resourceLoaderOptions: {
|
|
36724
36819
|
...loaderPolicy.discovery,
|
|
36725
36820
|
appendSystemPromptOverride: (base) => [...base, ...piAppendedInstructions(state)],
|
|
@@ -36948,10 +37043,10 @@ async function runDeferredCommandReload(state) {
|
|
|
36948
37043
|
return;
|
|
36949
37044
|
await reloadSessionCommands(state, session);
|
|
36950
37045
|
}
|
|
36951
|
-
function projectResourceDiscoveryOptions(enabled = false, readOnly = false) {
|
|
37046
|
+
function projectResourceDiscoveryOptions(enabled = false, readOnly = false, _approvals) {
|
|
36952
37047
|
const discoverProjectResources = enabled && !readOnly;
|
|
36953
37048
|
return {
|
|
36954
|
-
noExtensions:
|
|
37049
|
+
noExtensions: true,
|
|
36955
37050
|
noSkills: !discoverProjectResources,
|
|
36956
37051
|
noPromptTemplates: !discoverProjectResources,
|
|
36957
37052
|
noContextFiles: readOnly
|
|
@@ -36965,7 +37060,7 @@ function coordinatorProjectSkillPaths(cwd = workingDirectory) {
|
|
|
36965
37060
|
].filter((path) => existsSync2(path));
|
|
36966
37061
|
}
|
|
36967
37062
|
function piResourceLoaderPolicy(state, cwd = workingDirectory) {
|
|
36968
|
-
const discovery = projectResourceDiscoveryOptions(state.policy?.projectResources, state.readOnly === true);
|
|
37063
|
+
const discovery = projectResourceDiscoveryOptions(state.policy?.projectResources, state.readOnly === true, state.policy?.approvals);
|
|
36969
37064
|
const coordinator = state.policy?.id === "coordinator-read-only" && process.env[BRIDGE_EXECUTION_POLICY_ENV2] === "coordinator-read-only";
|
|
36970
37065
|
return {
|
|
36971
37066
|
discovery: coordinator ? { ...discovery, noSkills: false, additionalSkillPaths: coordinatorProjectSkillPaths(cwd) } : discovery,
|
|
@@ -37375,7 +37470,7 @@ async function forkSession(state, messageId) {
|
|
|
37375
37470
|
throw error;
|
|
37376
37471
|
}
|
|
37377
37472
|
}
|
|
37378
|
-
async function navigateSessionHistory(state, messageOrEntryId) {
|
|
37473
|
+
async function navigateSessionHistory(state, messageOrEntryId, position = "before") {
|
|
37379
37474
|
if (state.status === "running" || state.dispatching)
|
|
37380
37475
|
throw new SessionBusyError;
|
|
37381
37476
|
const session = await ensureSession(state);
|
|
@@ -37385,6 +37480,10 @@ async function navigateSessionHistory(state, messageOrEntryId) {
|
|
|
37385
37480
|
const result = await session.navigateTree(target, { summarize: false });
|
|
37386
37481
|
if (result.cancelled || result.aborted)
|
|
37387
37482
|
throw new Error("Pi did not change the active branch");
|
|
37483
|
+
if (position === "at" && session.sessionManager.getLeafId() !== target) {
|
|
37484
|
+
session.sessionManager.branch(target);
|
|
37485
|
+
session.refreshContext();
|
|
37486
|
+
}
|
|
37388
37487
|
rememberHistoryLeaf(state, session.sessionManager);
|
|
37389
37488
|
resetRenderedHistory(state);
|
|
37390
37489
|
hydrateHistory(state);
|
|
@@ -38446,15 +38545,15 @@ ${structuredPromptInstruction(input.schema)}` : input.prompt;
|
|
|
38446
38545
|
diagnostics?.streamSettled("rejected");
|
|
38447
38546
|
announceAccepted(false);
|
|
38448
38547
|
});
|
|
38449
|
-
const
|
|
38450
|
-
if (
|
|
38548
|
+
const startup = await boundedWait(accepted, startupDeadlineMs);
|
|
38549
|
+
if (!startup.settled) {
|
|
38451
38550
|
const error = new PromptStartupTimeoutError(startupDeadlineMs);
|
|
38452
38551
|
abandonStartup(state, session, claim, accepted, settled, input, diagnostics, error, evidenceTurnId);
|
|
38453
38552
|
throw error;
|
|
38454
38553
|
}
|
|
38455
38554
|
if (claim !== undefined && state.promptStartup?.claim === claim)
|
|
38456
38555
|
state.promptStartup = undefined;
|
|
38457
|
-
if (!
|
|
38556
|
+
if (!startup.value) {
|
|
38458
38557
|
forgetEvidenceTurn(state, evidenceTurnId);
|
|
38459
38558
|
await settled;
|
|
38460
38559
|
if (commandRun && state.commandRun === commandRun)
|
|
@@ -38528,21 +38627,6 @@ ${structuredPromptInstruction(input.schema)}` : input.prompt;
|
|
|
38528
38627
|
})
|
|
38529
38628
|
};
|
|
38530
38629
|
}
|
|
38531
|
-
async function withinStartupDeadline(accepted, deadlineMs) {
|
|
38532
|
-
let timer;
|
|
38533
|
-
try {
|
|
38534
|
-
return await Promise.race([
|
|
38535
|
-
accepted,
|
|
38536
|
-
new Promise((resolve) => {
|
|
38537
|
-
timer = setTimeout(() => resolve("timeout"), deadlineMs);
|
|
38538
|
-
timer.unref();
|
|
38539
|
-
})
|
|
38540
|
-
]);
|
|
38541
|
-
} finally {
|
|
38542
|
-
if (timer)
|
|
38543
|
-
clearTimeout(timer);
|
|
38544
|
-
}
|
|
38545
|
-
}
|
|
38546
38630
|
function abandonStartup(state, session, claim, accepted, settled, input, diagnostics, error, evidenceTurnId) {
|
|
38547
38631
|
log7.warn("turn.startup-timed-out", { sessionId: state.id });
|
|
38548
38632
|
state.status = "error";
|
|
@@ -39024,10 +39108,11 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
|
|
|
39024
39108
|
|
|
39025
39109
|
// ../../bridges/pi-bridge/src/public.ts
|
|
39026
39110
|
function piReportedPolicy(policy, readOnly) {
|
|
39027
|
-
|
|
39111
|
+
const reported = withoutProviderSandbox(policy, {
|
|
39028
39112
|
agent: "Pi",
|
|
39029
39113
|
toolsetBlocksNetwork: readOnly === true || policy.approvals === "deny"
|
|
39030
39114
|
});
|
|
39115
|
+
return projectExtensionsRefusedForApprovals(policy, readOnly === true) ? appendNativeAgentPolicyNote(reported, PROJECT_EXTENSIONS_REFUSED_NOTE) : reported;
|
|
39031
39116
|
}
|
|
39032
39117
|
function publicSession(state) {
|
|
39033
39118
|
const contextUsage = publicContextUsage(state);
|
|
@@ -39335,6 +39420,11 @@ function applyBridgeLogPolicy(value, env = process.env) {
|
|
|
39335
39420
|
return { status: 200, body: { applied: true, seq: policy.seq, diagnostics } };
|
|
39336
39421
|
}
|
|
39337
39422
|
|
|
39423
|
+
// ../protocol/src/terminal-text.ts
|
|
39424
|
+
var MAX_STRING_LENGTH = 8 * 1024;
|
|
39425
|
+
var BUDGET_FLOOR = 4 * 1024;
|
|
39426
|
+
var MAX_MOVE = 4 * 1024;
|
|
39427
|
+
|
|
39338
39428
|
// ../protocol/src/human-prompts.ts
|
|
39339
39429
|
var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
|
|
39340
39430
|
var HUMAN_PROMPT_KINDS = new Set([
|
|
@@ -39405,6 +39495,68 @@ import { createHash as createHash9, randomBytes as randomBytes9 } from "node:cry
|
|
|
39405
39495
|
import { pathToFileURL } from "node:url";
|
|
39406
39496
|
import { gzip } from "node:zlib";
|
|
39407
39497
|
|
|
39498
|
+
// ../../bridges/pi-bridge/src/liveness.ts
|
|
39499
|
+
var METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
|
39500
|
+
var FIXED_SUBJECTS = new Set(["refresh", "dispatch", "detail", "page"]);
|
|
39501
|
+
function sessionRouteLabel(request) {
|
|
39502
|
+
const method = request.method && METHODS.has(request.method) ? request.method : "OTHER";
|
|
39503
|
+
let path = request.action ?? "session";
|
|
39504
|
+
if (request.subject !== undefined) {
|
|
39505
|
+
path += `/${FIXED_SUBJECTS.has(request.subject) ? request.subject : ":id"}`;
|
|
39506
|
+
}
|
|
39507
|
+
if (request.detail !== undefined)
|
|
39508
|
+
path += "/hold";
|
|
39509
|
+
return `${method} ${path}`;
|
|
39510
|
+
}
|
|
39511
|
+
function touchesLiveness(request) {
|
|
39512
|
+
if (request.method === "GET" || request.method === "HEAD")
|
|
39513
|
+
return false;
|
|
39514
|
+
if (request.action === "title")
|
|
39515
|
+
return false;
|
|
39516
|
+
if (request.action === "approvals" && request.detail !== undefined)
|
|
39517
|
+
return false;
|
|
39518
|
+
return true;
|
|
39519
|
+
}
|
|
39520
|
+
function observeSessionRequest(state, request, now = Date.now()) {
|
|
39521
|
+
const touched = touchesLiveness(request);
|
|
39522
|
+
if (touched)
|
|
39523
|
+
state.lastAccessed = now;
|
|
39524
|
+
const label = sessionRouteLabel(request);
|
|
39525
|
+
const routes = state.routeCounts ??= new Map;
|
|
39526
|
+
const count = routes.get(label) ?? { requests: 0, touches: 0 };
|
|
39527
|
+
count.requests += 1;
|
|
39528
|
+
if (touched)
|
|
39529
|
+
count.touches += 1;
|
|
39530
|
+
routes.set(label, count);
|
|
39531
|
+
return touched;
|
|
39532
|
+
}
|
|
39533
|
+
function publicLiveness(state) {
|
|
39534
|
+
return {
|
|
39535
|
+
routes: Object.fromEntries(Array.from(state.routeCounts ?? [], ([label, count]) => [label, { ...count }]))
|
|
39536
|
+
};
|
|
39537
|
+
}
|
|
39538
|
+
|
|
39539
|
+
// ../protocol/src/contract/ipc-error.ts
|
|
39540
|
+
var REGISTERED_ERROR_CODES = {
|
|
39541
|
+
"unknown-command": { domain: "text", command: "text" },
|
|
39542
|
+
"unsupported-version": { domain: "text", range: "range", command: "text" },
|
|
39543
|
+
"unsupported-field": { domain: "text", field: "text", command: "text" },
|
|
39544
|
+
"kanban-request-id-conflict": { record: "text" },
|
|
39545
|
+
"native-job-receipt-capacity": { limit: "count" },
|
|
39546
|
+
"native-agent-provider-session-missing": {},
|
|
39547
|
+
"container-lifecycle": { reason: "text" },
|
|
39548
|
+
"mcp-management": { reason: "text" },
|
|
39549
|
+
"pane-layout-revision-conflict": {},
|
|
39550
|
+
"design-revision-conflict": {},
|
|
39551
|
+
"prompt-queue-message-conflict": {},
|
|
39552
|
+
"unknown-node": {},
|
|
39553
|
+
"node-admin-refused": {},
|
|
39554
|
+
"node-scope-closed": {},
|
|
39555
|
+
"node-unavailable": {}
|
|
39556
|
+
};
|
|
39557
|
+
var REGISTERED_ERROR_CODE_LIST = Object.keys(REGISTERED_ERROR_CODES);
|
|
39558
|
+
var MAX_COUNT = 2 ** 31 - 1;
|
|
39559
|
+
|
|
39408
39560
|
// ../protocol/src/mcp-management.ts
|
|
39409
39561
|
var MCP_CONFIG_REPORTING_VERSION = 1;
|
|
39410
39562
|
var MCP_MANAGEMENT_LIMITS = {
|
|
@@ -40044,6 +40196,7 @@ async function readResourceCommands(options) {
|
|
|
40044
40196
|
const settingsManager = SettingsManager.create(options.cwd, options.agentDir, {
|
|
40045
40197
|
projectTrusted: options.policy.projectTrusted
|
|
40046
40198
|
});
|
|
40199
|
+
excludeConfiguredPackages(settingsManager);
|
|
40047
40200
|
const loader = new DefaultResourceLoader({
|
|
40048
40201
|
...options.policy.discovery,
|
|
40049
40202
|
cwd: options.cwd,
|
|
@@ -40163,6 +40316,70 @@ async function runClose(state, budgetMs) {
|
|
|
40163
40316
|
return "closed";
|
|
40164
40317
|
}
|
|
40165
40318
|
|
|
40319
|
+
// ../../bridges/pi-bridge/src/session-branches.ts
|
|
40320
|
+
var MAX_LISTED_BRANCHES = NATIVE_AGENT_BRANCH_LIST_LIMITS.branches;
|
|
40321
|
+
var MAX_BRANCH_PROMPT_CHARS = NATIVE_AGENT_BRANCH_LIST_LIMITS.promptChars;
|
|
40322
|
+
function isConversationEntry(entry) {
|
|
40323
|
+
return entry.type === "message" || entry.type === "custom_message";
|
|
40324
|
+
}
|
|
40325
|
+
function promptText(entry) {
|
|
40326
|
+
if (entry.type !== "message" || entry.message.role !== "user")
|
|
40327
|
+
return;
|
|
40328
|
+
const text = readContentText(entry.message.content).replace(/\s+/g, " ").trim();
|
|
40329
|
+
return text.length > MAX_BRANCH_PROMPT_CHARS ? `${text.slice(0, MAX_BRANCH_PROMPT_CHARS - 1)}…` : text;
|
|
40330
|
+
}
|
|
40331
|
+
function listSessionBranches(manager) {
|
|
40332
|
+
const entries = manager.getEntries();
|
|
40333
|
+
const byId = new Map;
|
|
40334
|
+
const hasChildren = new Set;
|
|
40335
|
+
for (const entry of entries) {
|
|
40336
|
+
byId.set(entry.id, entry);
|
|
40337
|
+
if (entry.parentId)
|
|
40338
|
+
hasChildren.add(entry.parentId);
|
|
40339
|
+
}
|
|
40340
|
+
const activeEntryId = manager.getLeafId();
|
|
40341
|
+
const activePath = new Set;
|
|
40342
|
+
for (let cursor = activeEntryId ? byId.get(activeEntryId) : undefined;cursor; cursor = cursor.parentId ? byId.get(cursor.parentId) : undefined) {
|
|
40343
|
+
if (activePath.has(cursor.id))
|
|
40344
|
+
break;
|
|
40345
|
+
activePath.add(cursor.id);
|
|
40346
|
+
}
|
|
40347
|
+
const leaves = entries.map((entry, index) => ({ entry, index })).filter(({ entry }) => !hasChildren.has(entry.id) && !activePath.has(entry.id)).sort((left, right) => right.entry.timestamp.localeCompare(left.entry.timestamp) || right.index - left.index).map(({ entry }) => entry);
|
|
40348
|
+
const branches = [];
|
|
40349
|
+
let truncated = false;
|
|
40350
|
+
for (const leaf of leaves) {
|
|
40351
|
+
const own = [];
|
|
40352
|
+
const seen = new Set;
|
|
40353
|
+
let depth = 0;
|
|
40354
|
+
let newestPrompt;
|
|
40355
|
+
for (let cursor = leaf;cursor && !seen.has(cursor.id); cursor = cursor.parentId ? byId.get(cursor.parentId) : undefined) {
|
|
40356
|
+
seen.add(cursor.id);
|
|
40357
|
+
depth += 1;
|
|
40358
|
+
if (!activePath.has(cursor.id))
|
|
40359
|
+
own.push(cursor);
|
|
40360
|
+
newestPrompt ??= promptText(cursor);
|
|
40361
|
+
}
|
|
40362
|
+
if (!own.some(isConversationEntry))
|
|
40363
|
+
continue;
|
|
40364
|
+
if (branches.length >= MAX_LISTED_BRANCHES) {
|
|
40365
|
+
truncated = true;
|
|
40366
|
+
break;
|
|
40367
|
+
}
|
|
40368
|
+
const firstOwnPrompt = own.slice().reverse().map(promptText).find((text) => text !== undefined);
|
|
40369
|
+
branches.push({
|
|
40370
|
+
entryId: leaf.id,
|
|
40371
|
+
prompt: firstOwnPrompt ?? newestPrompt ?? "",
|
|
40372
|
+
entries: depth,
|
|
40373
|
+
updatedAt: leaf.timestamp
|
|
40374
|
+
});
|
|
40375
|
+
}
|
|
40376
|
+
return { activeEntryId, branches, truncated };
|
|
40377
|
+
}
|
|
40378
|
+
async function readSessionBranches(state) {
|
|
40379
|
+
const session = await ensureSession(state);
|
|
40380
|
+
return listSessionBranches(session.sessionManager);
|
|
40381
|
+
}
|
|
40382
|
+
|
|
40166
40383
|
// ../../bridges/pi-bridge/src/session-activity.ts
|
|
40167
40384
|
function sessionActivityObservation(sessionId) {
|
|
40168
40385
|
const state = sessions.get(sessionId);
|
|
@@ -40625,9 +40842,7 @@ async function routeSession(request, response, url, clientSignal) {
|
|
|
40625
40842
|
}
|
|
40626
40843
|
return json(response, 404, { error: "Session not found" });
|
|
40627
40844
|
}
|
|
40628
|
-
|
|
40629
|
-
state.lastAccessed = Date.now();
|
|
40630
|
-
}
|
|
40845
|
+
observeSessionRequest(state, { method: request.method, action, subject, detail });
|
|
40631
40846
|
if (request.method === "GET" && (!action || action === "status") || action === "config" && (request.method === "GET" || request.method === "POST")) {
|
|
40632
40847
|
await withTimeout(hydrateSessionComposer(state).catch(() => {
|
|
40633
40848
|
return;
|
|
@@ -40672,7 +40887,8 @@ async function routeSession(request, response, url, clientSignal) {
|
|
|
40672
40887
|
summary: publicRuntime(state),
|
|
40673
40888
|
...state.health.snapshot(),
|
|
40674
40889
|
mcpConfigReporting: MCP_CONFIG_REPORTING_VERSION,
|
|
40675
|
-
...mcpConfig ? { mcpConfig } : {}
|
|
40890
|
+
...mcpConfig ? { mcpConfig } : {},
|
|
40891
|
+
liveness: publicLiveness(state)
|
|
40676
40892
|
});
|
|
40677
40893
|
}
|
|
40678
40894
|
if (action === "dispatch" && request.method === "GET") {
|
|
@@ -40744,8 +40960,11 @@ async function routeSession(request, response, url, clientSignal) {
|
|
|
40744
40960
|
await persistBarrier();
|
|
40745
40961
|
return json(response, 200, { rewound: true });
|
|
40746
40962
|
}
|
|
40963
|
+
if (action === "branches" && !subject && request.method === "GET") {
|
|
40964
|
+
return json(response, 200, await readSessionBranches(state));
|
|
40965
|
+
}
|
|
40747
40966
|
if (action === "branches" && subject && request.method === "POST") {
|
|
40748
|
-
await navigateSessionHistory(state, decodeURIComponent(subject));
|
|
40967
|
+
await navigateSessionHistory(state, decodeURIComponent(subject), "at");
|
|
40749
40968
|
await persistBarrier();
|
|
40750
40969
|
return json(response, 200, { switched: true });
|
|
40751
40970
|
}
|
|
@@ -40878,6 +41097,7 @@ async function handleCompact(request, response, state) {
|
|
|
40878
41097
|
state.manualCompaction = undefined;
|
|
40879
41098
|
settle(stopped);
|
|
40880
41099
|
state.compacting = false;
|
|
41100
|
+
state.lastAccessed = Date.now();
|
|
40881
41101
|
state.dispatching = false;
|
|
40882
41102
|
state.revision += 1;
|
|
40883
41103
|
schedulePersist();
|