@ponythewhite/base-context 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/NOTICE +0 -5
- package/README.md +44 -27
- package/dist/NOTICE +0 -5
- package/dist/base-context-runtime/pyproject.toml +1 -1
- package/dist/base-context-runtime/src/rlm/__init__.py +7 -5
- package/dist/base-context-runtime/test/test_subagent_registry.py +28 -1
- package/dist/base-context-runtime/uv.lock +1 -1
- package/dist/build-info.json +1 -1
- package/dist/bundle/amazon-bedrock.js +21 -0
- package/dist/bundle/{anthropic-YY4S534V.js → anthropic-UV5GZDGU.js} +5 -5
- package/dist/bundle/{azure-openai-responses-JRP6MIM3.js → azure-openai-responses-WSNPXLYC.js} +6 -6
- package/dist/bundle/{bundled-modules-P5HARVZA.js → bundled-modules-TXUMJ2XQ.js} +71 -16
- package/dist/bundle/chunk-27QCJ2AZ.js +2578 -0
- package/dist/bundle/{chunk-MZHTNNVA.js → chunk-4GXPNXOJ.js} +8 -0
- package/dist/bundle/{chunk-SC5KG5R4.js → chunk-DGNX7HQ3.js} +1 -7
- package/dist/bundle/{chunk-A53O363M.js → chunk-GRJFXLBM.js} +0 -1
- package/dist/bundle/chunk-HKINIBP4.js +29 -0
- package/dist/bundle/{chunk-UDSW6FNG.js → chunk-KTNETTHI.js} +1 -1
- package/dist/bundle/{chunk-BYVP7LWV.js → chunk-S3INFPZZ.js} +1861 -4662
- package/dist/bundle/{chunk-73DCPU3D.js → chunk-V3L54UD6.js} +1019 -3427
- package/dist/bundle/{chunk-U7AUVG3B.js → chunk-VSIYFWYI.js} +24 -6
- package/dist/bundle/{chunk-IW77OXFS.js → chunk-W46VZFI6.js} +0 -2099
- package/dist/bundle/{cli-main-O4X7GFGY.js → cli-main-BYMSRPH6.js} +8 -6
- package/dist/bundle/cli.js +2 -2
- package/dist/bundle/{google-AUTVGDGZ.js → google-T32FMD4G.js} +6 -6
- package/dist/bundle/{google-vertex-Q75D7RKS.js → google-vertex-56KP6I3B.js} +3 -3
- package/dist/bundle/{main-XKOW2BV6.js → main-ODOYCEQC.js} +7 -5
- package/dist/bundle/{mistral-7ESB7QUD.js → mistral-WGBMYIVU.js} +5 -5
- package/dist/bundle/{openai-codex-responses-LV3QRPN4.js → openai-codex-responses-PIV2RQ3G.js} +6 -6
- package/dist/bundle/{openai-completions-OJECLPXJ.js → openai-completions-64C3JPR4.js} +11 -22
- package/dist/bundle/{openai-responses-FN6HZMBC.js → openai-responses-UI7RSTDV.js} +6 -6
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +108 -59
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/daemon-ps.d.ts +4 -3
- package/dist/cli/daemon-ps.d.ts.map +1 -1
- package/dist/cli/daemon-ps.js +6 -1
- package/dist/cli/daemon-ps.js.map +1 -1
- package/dist/cli/product-doctor.d.ts +0 -1
- package/dist/cli/product-doctor.d.ts.map +1 -1
- package/dist/cli/product-doctor.js +6 -3
- package/dist/cli/product-doctor.js.map +1 -1
- package/dist/config.d.ts +0 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -8
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-config.d.ts +1 -2
- package/dist/core/agent-session-config.d.ts.map +1 -1
- package/dist/core/agent-session-config.js +0 -3
- package/dist/core/agent-session-config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +5 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +5 -3
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -27
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +10 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +107 -107
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +8 -35
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +33 -243
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cron-jobs.d.ts.map +1 -1
- package/dist/core/cron-jobs.js +7 -1
- package/dist/core/cron-jobs.js.map +1 -1
- package/dist/core/inference-coordinator.d.ts +6 -1
- package/dist/core/inference-coordinator.d.ts.map +1 -1
- package/dist/core/inference-coordinator.js +18 -2
- package/dist/core/inference-coordinator.js.map +1 -1
- package/dist/core/kernel/bootstrap.d.ts.map +1 -1
- package/dist/core/kernel/bootstrap.js +2 -2
- package/dist/core/kernel/bootstrap.js.map +1 -1
- package/dist/core/kernel/repl-manager.d.ts +2 -0
- package/dist/core/kernel/repl-manager.d.ts.map +1 -1
- package/dist/core/kernel/repl-manager.js +44 -1
- package/dist/core/kernel/repl-manager.js.map +1 -1
- package/dist/core/logging.d.ts +4 -3
- package/dist/core/logging.d.ts.map +1 -1
- package/dist/core/logging.js +6 -6
- package/dist/core/logging.js.map +1 -1
- package/dist/core/mcp/mcp-manager.d.ts.map +1 -1
- package/dist/core/mcp/mcp-manager.js +3 -3
- package/dist/core/mcp/mcp-manager.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -16
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +88 -196
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -19
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +36 -266
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-contracts.d.ts +5 -6
- package/dist/core/provider-contracts.d.ts.map +1 -1
- package/dist/core/provider-contracts.js +25 -36
- package/dist/core/provider-contracts.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +0 -2
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/rlm-max-subagents.d.ts +32 -0
- package/dist/core/rlm-max-subagents.d.ts.map +1 -0
- package/dist/core/rlm-max-subagents.js +50 -0
- package/dist/core/rlm-max-subagents.js.map +1 -0
- package/dist/core/rlm-runtime.d.ts +3 -3
- package/dist/core/rlm-runtime.d.ts.map +1 -1
- package/dist/core/rlm-runtime.js.map +1 -1
- package/dist/core/sdk.d.ts +4 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +27 -14
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +12 -44
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +6 -6
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.mjs +2 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +39 -34
- package/dist/main.js.map +1 -1
- package/dist/modes/acp/acp-mode.d.ts.map +1 -1
- package/dist/modes/acp/acp-mode.js +1 -1
- package/dist/modes/acp/acp-mode.js.map +1 -1
- package/dist/modes/agent-connection/daemon-agent-connection.d.ts +6 -2
- package/dist/modes/agent-connection/daemon-agent-connection.d.ts.map +1 -1
- package/dist/modes/agent-connection/daemon-agent-connection.js +13 -2
- package/dist/modes/agent-connection/daemon-agent-connection.js.map +1 -1
- package/dist/modes/agent-connection/in-process-agent-connection.d.ts +2 -0
- package/dist/modes/agent-connection/in-process-agent-connection.d.ts.map +1 -1
- package/dist/modes/agent-connection/in-process-agent-connection.js +6 -0
- package/dist/modes/agent-connection/in-process-agent-connection.js.map +1 -1
- package/dist/modes/agent-connection/types.d.ts +3 -0
- package/dist/modes/agent-connection/types.d.ts.map +1 -1
- package/dist/modes/agent-connection/types.js.map +1 -1
- package/dist/modes/agents-view/agents-view-mode.d.ts.map +1 -1
- package/dist/modes/agents-view/agents-view-mode.js +2 -19
- package/dist/modes/agents-view/agents-view-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-mode.d.ts +5 -0
- package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-mode.js +107 -12
- package/dist/modes/daemon/daemon-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-protocol.d.ts +194 -165
- package/dist/modes/daemon/daemon-protocol.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-protocol.js +16 -11
- package/dist/modes/daemon/daemon-protocol.js.map +1 -1
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts +19 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js +74 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity.d.ts +19 -0
- package/dist/modes/daemon/daemon-rlm-capacity.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity.js +85 -0
- package/dist/modes/daemon/daemon-rlm-capacity.js.map +1 -0
- package/dist/modes/daemon/daemon-session-summarizer.d.ts +2 -3
- package/dist/modes/daemon/daemon-session-summarizer.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-session-summarizer.js +32 -23
- package/dist/modes/daemon/daemon-session-summarizer.js.map +1 -1
- package/dist/modes/daemon/daemon-state-root.d.ts +15 -0
- package/dist/modes/daemon/daemon-state-root.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-state-root.js +40 -0
- package/dist/modes/daemon/daemon-state-root.js.map +1 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts +2 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor-ownership.js +27 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.js.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts +10 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.js +213 -20
- package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
- package/dist/modes/daemon/daemon-worker-protocol.d.ts +28 -1
- package/dist/modes/daemon/daemon-worker-protocol.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-worker-protocol.js +16 -2
- package/dist/modes/daemon/daemon-worker-protocol.js.map +1 -1
- package/dist/modes/daemon/saved-session-catalog.d.ts.map +1 -1
- package/dist/modes/daemon/saved-session-catalog.js +2 -0
- package/dist/modes/daemon/saved-session-catalog.js.map +1 -1
- package/dist/modes/interactive/auth-flows.d.ts +0 -6
- package/dist/modes/interactive/auth-flows.d.ts.map +1 -1
- package/dist/modes/interactive/auth-flows.js +6 -126
- package/dist/modes/interactive/auth-flows.js.map +1 -1
- package/dist/modes/interactive/components/configuration-menu.d.ts +3 -0
- package/dist/modes/interactive/components/configuration-menu.d.ts.map +1 -1
- package/dist/modes/interactive/components/configuration-menu.js +13 -2
- package/dist/modes/interactive/components/configuration-menu.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +0 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +0 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -40
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +13 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +2 -11
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/feature-hints.d.ts.map +1 -1
- package/dist/modes/interactive/feature-hints.js +0 -4
- package/dist/modes/interactive/feature-hints.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -12
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +81 -507
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/onboarding.d.ts +0 -3
- package/dist/modes/interactive/onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/onboarding.js +0 -17
- package/dist/modes/interactive/onboarding.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +2 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +24 -11
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/node/amazon-bedrock.d.ts +2 -0
- package/dist/node/amazon-bedrock.d.ts.map +1 -0
- package/dist/node/amazon-bedrock.js +6 -0
- package/dist/node/amazon-bedrock.js.map +1 -0
- package/dist/product-identity.d.ts +0 -1
- package/dist/product-identity.d.ts.map +1 -1
- package/dist/product-identity.js +0 -1
- package/dist/product-identity.js.map +1 -1
- package/docs/development.md +1 -1
- package/docs/fork-philosophy.md +4 -8
- package/docs/installation.md +83 -62
- package/docs/providers.md +23 -25
- package/docs/quickstart.md +19 -10
- package/docs/rlm-runtime.md +13 -5
- package/docs/rpc.md +4 -4
- package/docs/sdk.md +20 -11
- package/docs/sessions.md +0 -1
- package/docs/settings.md +9 -42
- package/docs/skills.md +0 -1
- package/docs/upstream-0.9.5.md +171 -0
- package/docs/usage.md +14 -10
- package/package.json +4 -4
- package/dist/core/agent-traces.d.ts +0 -149
- package/dist/core/agent-traces.d.ts.map +0 -1
- package/dist/core/agent-traces.js +0 -904
- package/dist/core/agent-traces.js.map +0 -1
- package/dist/core/prime-inference-auth.d.ts +0 -70
- package/dist/core/prime-inference-auth.d.ts.map +0 -1
- package/dist/core/prime-inference-auth.js +0 -352
- package/dist/core/prime-inference-auth.js.map +0 -1
- package/dist/core/prime-inference-model-selection.d.ts +0 -16
- package/dist/core/prime-inference-model-selection.d.ts.map +0 -1
- package/dist/core/prime-inference-model-selection.js +0 -16
- package/dist/core/prime-inference-model-selection.js.map +0 -1
- package/dist/core/prime-inference-models.d.ts +0 -6
- package/dist/core/prime-inference-models.d.ts.map +0 -1
- package/dist/core/prime-inference-models.js +0 -62
- package/dist/core/prime-inference-models.js.map +0 -1
- package/dist/core/telemetry.d.ts +0 -95
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js +0 -637
- package/dist/core/telemetry.js.map +0 -1
- package/dist/modes/interactive/components/prime-onboarding-splash.d.ts +0 -39
- package/dist/modes/interactive/components/prime-onboarding-splash.d.ts.map +0 -1
- package/dist/modes/interactive/components/prime-onboarding-splash.js +0 -286
- package/dist/modes/interactive/components/prime-onboarding-splash.js.map +0 -1
- package/dist/modes/interactive/components/prime-team-selector.d.ts +0 -30
- package/dist/modes/interactive/components/prime-team-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/prime-team-selector.js +0 -166
- package/dist/modes/interactive/components/prime-team-selector.js.map +0 -1
- package/dist/skills/prime-intellect/SKILL.md +0 -87
- package/dist/skills/prime-intellect/references/compute.md +0 -45
- package/dist/skills/prime-intellect/references/environments.md +0 -73
- package/dist/skills/prime-intellect/references/inference.md +0 -47
- package/dist/skills/prime-intellect/references/sandboxes.md +0 -75
- package/skills/prime-intellect/SKILL.md +0 -87
- package/skills/prime-intellect/references/compute.md +0 -45
- package/skills/prime-intellect/references/environments.md +0 -73
- package/skills/prime-intellect/references/inference.md +0 -47
- package/skills/prime-intellect/references/sandboxes.md +0 -75
|
@@ -46,6 +46,7 @@ import { filterClientEnv, withClientEnv } from "./daemon-client-env.js";
|
|
|
46
46
|
import { deserializeDaemonError, serializeDaemonError } from "./daemon-errors.js";
|
|
47
47
|
import { bindActiveSessionState } from "./daemon-extension-binding.js";
|
|
48
48
|
import { CANONICAL_SESSION_OWNERSHIP_COMPATIBILITY, createDaemonEventMeta, createDaemonReplayInfo, DAEMON_DEFAULT_CLIENT_CAPABILITIES, DAEMON_DEFAULT_SERVER_CAPABILITIES, DAEMON_PROTOCOL_INFO, DAEMON_SCHEMA_ID, DAEMON_SCHEMA_REVISION, DAEMON_SUPPORTED_CLIENT_CAPABILITIES, DAEMON_UPDATE_RESTART_FORMAT_VERSION, failure, isDaemonCommandEnvelope, isDaemonDialogExtensionUiRequest, isDaemonMutatingCommand, isLegacyDaemonInspection, isSessionPlaneDaemonCommand, salvageDaemonCommandId, success, UPDATE_RESTART_DRAIN_COMMANDS, } from "./daemon-protocol.js";
|
|
49
|
+
import { DaemonRlmCapacityClient } from "./daemon-rlm-capacity.js";
|
|
49
50
|
import { getDaemonRuntimeIdentity } from "./daemon-runtime-identity.js";
|
|
50
51
|
import { buildRlmChildSnapshots, buildSessionList, classifySessionRosterStatus, hasLiveSessionWork, inactiveLifecycleForSession, scheduledJobRegistrations, snapshotActiveSessionSummary, summaryForActiveSession, } from "./daemon-session-list.js";
|
|
51
52
|
import { DaemonSessionSummarizer } from "./daemon-session-summarizer.js";
|
|
@@ -150,7 +151,9 @@ const DAEMON_COMMAND_TYPES = new Set([
|
|
|
150
151
|
"export_jsonl",
|
|
151
152
|
"set_session_name",
|
|
152
153
|
"get_rlm_max_depth_status",
|
|
154
|
+
"get_rlm_max_subagents_status",
|
|
153
155
|
"set_rlm_max_depth",
|
|
156
|
+
"set_rlm_max_subagents",
|
|
154
157
|
"rename_saved_session",
|
|
155
158
|
"delete_saved_session",
|
|
156
159
|
"get_session_context",
|
|
@@ -291,6 +294,7 @@ export class AgentDaemon {
|
|
|
291
294
|
rosterFlushPending = false;
|
|
292
295
|
rosterHeartbeatTimer;
|
|
293
296
|
rlmSpawnLedgerInstance;
|
|
297
|
+
rlmCapacityClient;
|
|
294
298
|
rlmJournalOwner;
|
|
295
299
|
rlmJournalAdmissionClosed = false;
|
|
296
300
|
rlmJournalClosePromise;
|
|
@@ -711,6 +715,21 @@ export class AgentDaemon {
|
|
|
711
715
|
client.close();
|
|
712
716
|
}
|
|
713
717
|
}
|
|
718
|
+
workerRlmCapacityClient() {
|
|
719
|
+
const worker = this.options.worker;
|
|
720
|
+
if (!worker)
|
|
721
|
+
return undefined;
|
|
722
|
+
const socketPath = this.supervisorSocketPathFromEnv();
|
|
723
|
+
if (!socketPath || !worker.workerInstanceId) {
|
|
724
|
+
throw new Error("RLM capacity requires the current worker incarnation and its supervisor");
|
|
725
|
+
}
|
|
726
|
+
this.rlmCapacityClient ??= new DaemonRlmCapacityClient({
|
|
727
|
+
socketPath,
|
|
728
|
+
workerToken: worker.authenticationToken,
|
|
729
|
+
workerInstanceId: worker.workerInstanceId,
|
|
730
|
+
});
|
|
731
|
+
return this.rlmCapacityClient;
|
|
732
|
+
}
|
|
714
733
|
rlmSpawnLedger() {
|
|
715
734
|
if (!this.rlmSpawnLedgerInstance) {
|
|
716
735
|
this.rlmSpawnLedgerInstance = new RlmSpawnLedger(this.agentDir, this.rlmLedgerSessionsDir(), createRlmLedgerRegistrySeedSource(), (message) => this.log(message), { mode: "remote", mutate: (mutation) => this.sendRlmLedgerMutation(mutation) });
|
|
@@ -1199,6 +1218,63 @@ export class AgentDaemon {
|
|
|
1199
1218
|
this.cronScheduler.wake();
|
|
1200
1219
|
}
|
|
1201
1220
|
}
|
|
1221
|
+
createRuntimeWithRlmCapacity = async (options) => {
|
|
1222
|
+
const authority = this.workerRlmCapacityClient();
|
|
1223
|
+
if (!authority || options.sessionOptions?.rlmChildAdmission)
|
|
1224
|
+
return this.options.createRuntime(options);
|
|
1225
|
+
const origin = {
|
|
1226
|
+
sessionFile: options.sessionManager.getSessionFile(),
|
|
1227
|
+
sessionId: options.sessionManager.getSessionId(),
|
|
1228
|
+
};
|
|
1229
|
+
const reservation = await authority.reserveRoot(origin);
|
|
1230
|
+
let admitted;
|
|
1231
|
+
let created;
|
|
1232
|
+
const admission = {
|
|
1233
|
+
get session() {
|
|
1234
|
+
return admitted;
|
|
1235
|
+
},
|
|
1236
|
+
bind: (session) => {
|
|
1237
|
+
if (admitted && admitted !== session)
|
|
1238
|
+
throw new Error("RLM root admission already owns another session");
|
|
1239
|
+
admitted = session;
|
|
1240
|
+
},
|
|
1241
|
+
release: () => reservation.release(),
|
|
1242
|
+
};
|
|
1243
|
+
try {
|
|
1244
|
+
const result = await this.options.createRuntime({
|
|
1245
|
+
...options,
|
|
1246
|
+
sessionOptions: {
|
|
1247
|
+
...options.sessionOptions,
|
|
1248
|
+
rlmSubagentCapacity: authority.forSession(origin),
|
|
1249
|
+
rlmRootAdmission: admission,
|
|
1250
|
+
},
|
|
1251
|
+
});
|
|
1252
|
+
created = result.session;
|
|
1253
|
+
if (admission.session !== result.session)
|
|
1254
|
+
throw new Error("Runtime factory did not bind its RLM root admission");
|
|
1255
|
+
return result;
|
|
1256
|
+
}
|
|
1257
|
+
catch (error) {
|
|
1258
|
+
try {
|
|
1259
|
+
const failed = admission.session ?? created;
|
|
1260
|
+
if (failed) {
|
|
1261
|
+
await failed.disposeAsync();
|
|
1262
|
+
if (!admission.session)
|
|
1263
|
+
await reservation.release();
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
await options.sessionManager.close();
|
|
1267
|
+
await reservation.release();
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
catch (cleanupError) {
|
|
1271
|
+
if (cleanupError === error || (error instanceof AggregateError && error.errors.includes(cleanupError)))
|
|
1272
|
+
throw error;
|
|
1273
|
+
throw new AggregateError([error, cleanupError], "Root runtime creation and capacity cleanup failed");
|
|
1274
|
+
}
|
|
1275
|
+
throw error;
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1202
1278
|
async createRuntime(command, runtimeOpenGuard) {
|
|
1203
1279
|
const config = mergeAgentSessionRuntimeConfig(this.options.defaultSessionConfig, command.config);
|
|
1204
1280
|
if (!config.cwd) {
|
|
@@ -1376,7 +1452,7 @@ export class AgentDaemon {
|
|
|
1376
1452
|
// Extensions capture client env (e.g. herdr pane identity) synchronously
|
|
1377
1453
|
// while the runtime loads them, so it must be in process.env for the
|
|
1378
1454
|
// duration; withClientEnv restores it after.
|
|
1379
|
-
const runtime = await withClientEnv(clientEnv, () => createAgentSessionRuntime(this.
|
|
1455
|
+
const runtime = await withClientEnv(clientEnv, () => createAgentSessionRuntime(this.createRuntimeWithRlmCapacity, {
|
|
1380
1456
|
cwd: sessionManager.getCwd(),
|
|
1381
1457
|
agentDir,
|
|
1382
1458
|
sessionManager,
|
|
@@ -2052,7 +2128,7 @@ export class AgentDaemon {
|
|
|
2052
2128
|
: structuredClone(options.requestTokenBudget);
|
|
2053
2129
|
if (requestTokenBudget !== undefined)
|
|
2054
2130
|
options = { ...options, requestTokenBudget };
|
|
2055
|
-
const admission = options.admission ?? options.parentSession.reserveRlmChildAdmission();
|
|
2131
|
+
const admission = options.admission ?? (await options.parentSession.reserveRlmChildAdmission());
|
|
2056
2132
|
try {
|
|
2057
2133
|
if (admission.parent !== options.parentSession ||
|
|
2058
2134
|
parentState.runtime.session !== admission.parent ||
|
|
@@ -2065,7 +2141,7 @@ export class AgentDaemon {
|
|
|
2065
2141
|
}
|
|
2066
2142
|
finally {
|
|
2067
2143
|
if (!options.admission)
|
|
2068
|
-
admission.settle();
|
|
2144
|
+
await admission.settle();
|
|
2069
2145
|
}
|
|
2070
2146
|
}
|
|
2071
2147
|
async createAdmittedRlmSubagentRuntime(parentState, options) {
|
|
@@ -2088,7 +2164,7 @@ export class AgentDaemon {
|
|
|
2088
2164
|
options.admission.assertCurrent();
|
|
2089
2165
|
factoryStarted = true;
|
|
2090
2166
|
// Subagents inherit the parent's client env (e.g. herdr pane identity).
|
|
2091
|
-
runtime = await withClientEnv(parentState.clientEnv, () => createAgentSessionRuntime(this.
|
|
2167
|
+
runtime = await withClientEnv(parentState.clientEnv, () => createAgentSessionRuntime(this.createRuntimeWithRlmCapacity, {
|
|
2092
2168
|
cwd: sessionManager.getCwd(),
|
|
2093
2169
|
agentDir: parentState.runtime.services.agentDir,
|
|
2094
2170
|
sessionManager,
|
|
@@ -2163,7 +2239,7 @@ export class AgentDaemon {
|
|
|
2163
2239
|
try {
|
|
2164
2240
|
await sessionManager.close();
|
|
2165
2241
|
if (!factoryStarted)
|
|
2166
|
-
options.admission.confirmUnboundCleanup();
|
|
2242
|
+
await options.admission.confirmUnboundCleanup();
|
|
2167
2243
|
}
|
|
2168
2244
|
catch (cleanupError) {
|
|
2169
2245
|
if (cleanupError === error || (error instanceof AggregateError && error.errors.includes(cleanupError)))
|
|
@@ -2443,15 +2519,15 @@ export class AgentDaemon {
|
|
|
2443
2519
|
this.closingSessions.has(parentState.activeSessionId)) {
|
|
2444
2520
|
throw new RuntimeOpenCancelledError();
|
|
2445
2521
|
}
|
|
2446
|
-
const admission = parentState.runtime.session.reserveRlmChildAdmission();
|
|
2447
2522
|
const hydration = (async () => {
|
|
2523
|
+
const admission = await parentState.runtime.session.reserveRlmChildAdmission();
|
|
2448
2524
|
try {
|
|
2449
2525
|
if (existing)
|
|
2450
2526
|
await this.closeSession(existing, "replaced");
|
|
2451
2527
|
return await this.rehydrateCompletedRlmSubagentOnce(parentState, entry, admission, restoreActiveSessionId, clientEnv);
|
|
2452
2528
|
}
|
|
2453
2529
|
finally {
|
|
2454
|
-
admission.settle();
|
|
2530
|
+
await admission.settle();
|
|
2455
2531
|
}
|
|
2456
2532
|
})();
|
|
2457
2533
|
// Explicit opens and all lazy triggers share this path-keyed publication,
|
|
@@ -2514,7 +2590,7 @@ export class AgentDaemon {
|
|
|
2514
2590
|
assertAdmission();
|
|
2515
2591
|
admission.claimFactory();
|
|
2516
2592
|
factoryStarted = true;
|
|
2517
|
-
runtime = await withClientEnv(hydrationEnv, () => createAgentSessionRuntime(this.
|
|
2593
|
+
runtime = await withClientEnv(hydrationEnv, () => createAgentSessionRuntime(this.createRuntimeWithRlmCapacity, {
|
|
2518
2594
|
cwd: openedManager.getCwd(),
|
|
2519
2595
|
agentDir: parentState.runtime.services.agentDir,
|
|
2520
2596
|
sessionManager: openedManager,
|
|
@@ -2634,7 +2710,7 @@ export class AgentDaemon {
|
|
|
2634
2710
|
await drain(() => sessionManager?.close());
|
|
2635
2711
|
await drain(() => sessionLease?.release());
|
|
2636
2712
|
if (!factoryStarted && errors.length === initialErrorCount)
|
|
2637
|
-
admission.confirmUnboundCleanup();
|
|
2713
|
+
await admission.confirmUnboundCleanup();
|
|
2638
2714
|
if (errors.length === initialErrorCount)
|
|
2639
2715
|
throw error;
|
|
2640
2716
|
throw new AggregateError(errors, "RLM hydration and cleanup failed");
|
|
@@ -3240,6 +3316,10 @@ export class AgentDaemon {
|
|
|
3240
3316
|
setImmediate(() => void this.shutdown(0));
|
|
3241
3317
|
return;
|
|
3242
3318
|
}
|
|
3319
|
+
case "worker_get_rlm_capacity": {
|
|
3320
|
+
this.writeWorkerSuccess(client, command, this.rlmCapacityClient?.snapshot() ?? { reservations: [] });
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3243
3323
|
case "worker_passivate_idle_children": {
|
|
3244
3324
|
const count = await this.passivateIdleChildren(command.idleEvictionMinutes, command.now, command.limit);
|
|
3245
3325
|
this.writeWorkerSuccess(client, command, { count });
|
|
@@ -4375,6 +4455,14 @@ export class AgentDaemon {
|
|
|
4375
4455
|
await this.setStateSessionNameForCommand(state, name);
|
|
4376
4456
|
return success(command.id, "set_session_name");
|
|
4377
4457
|
}
|
|
4458
|
+
case "get_rlm_max_subagents_status": {
|
|
4459
|
+
const state = this.getSessionState(command.activeSessionId);
|
|
4460
|
+
return success(command.id, command.type, await state.runtime.session.getRlmMaxSubagentsStatus());
|
|
4461
|
+
}
|
|
4462
|
+
case "set_rlm_max_subagents": {
|
|
4463
|
+
const state = this.getSessionState(command.activeSessionId);
|
|
4464
|
+
return success(command.id, command.type, await state.runtime.session.setRlmMaxSubagents(command.maxSubagents));
|
|
4465
|
+
}
|
|
4378
4466
|
case "get_rlm_max_depth_status": {
|
|
4379
4467
|
const state = this.getSessionState(command.activeSessionId);
|
|
4380
4468
|
return success(command.id, "get_rlm_max_depth_status", state.runtime.session.getRlmMaxDepthStatus());
|
|
@@ -5310,16 +5398,23 @@ Use prime_context read/search with selected lines or a query.`;
|
|
|
5310
5398
|
// runs, in which case the draft is no longer abandoned and must be kept.
|
|
5311
5399
|
queueMicrotask(() => {
|
|
5312
5400
|
if (this.sessions.has(state.activeSessionId) && this.isDiscardableDraft(state)) {
|
|
5313
|
-
|
|
5401
|
+
this.discardAbandonedDraft(state);
|
|
5314
5402
|
}
|
|
5315
5403
|
});
|
|
5316
5404
|
}
|
|
5317
5405
|
}
|
|
5406
|
+
/** Best-effort discard: a teardown rejection must not stop other hosted sessions. */
|
|
5407
|
+
discardAbandonedDraft(state) {
|
|
5408
|
+
void this.closeSession(state, "killed").catch((error) => {
|
|
5409
|
+
this.log(`failed to discard abandoned empty draft ${state.activeSessionId}: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}`);
|
|
5410
|
+
});
|
|
5411
|
+
}
|
|
5318
5412
|
isDiscardableDraft(state) {
|
|
5319
5413
|
if (this.options.worker) {
|
|
5320
5414
|
return false;
|
|
5321
5415
|
}
|
|
5322
|
-
|
|
5416
|
+
// An attaching client is not in state.clients yet, but still owns the draft.
|
|
5417
|
+
if (state.clients.size > 0 || state.pendingAttaches > 0) {
|
|
5323
5418
|
return false;
|
|
5324
5419
|
}
|
|
5325
5420
|
if (state.runtime.metadata.kind === "subagent") {
|
|
@@ -5879,7 +5974,7 @@ Use prime_context read/search with selected lines or a query.`;
|
|
|
5879
5974
|
// settles so it doesn't linger in the daemon.
|
|
5880
5975
|
if ((eventType === "turn_end" || eventType === "compaction_end" || eventType === "bash_end") &&
|
|
5881
5976
|
this.isDiscardableDraft(state)) {
|
|
5882
|
-
|
|
5977
|
+
this.discardAbandonedDraft(state);
|
|
5883
5978
|
}
|
|
5884
5979
|
if (RECOVERY_CHECKPOINT_EVENTS.has(eventType)) {
|
|
5885
5980
|
this.recordWorkerRecoveryState(state, eventType);
|