@gajae-code/coding-agent 0.16.7 → 0.17.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 +180 -1
- package/dist/types/capability/fs.d.ts +37 -4
- package/dist/types/capability/index.d.ts +19 -0
- package/dist/types/capability/types.d.ts +9 -0
- package/dist/types/cli/doctor/args.d.ts +36 -0
- package/dist/types/cli/doctor/checks.d.ts +18 -0
- package/dist/types/cli/doctor/config-repairs.d.ts +38 -0
- package/dist/types/cli/doctor/context.d.ts +89 -0
- package/dist/types/cli/doctor/files.d.ts +27 -0
- package/dist/types/cli/doctor/ids.d.ts +20 -0
- package/dist/types/cli/doctor/install-repairs.d.ts +94 -0
- package/dist/types/cli/doctor/journal.d.ts +43 -0
- package/dist/types/cli/doctor/managed-link.d.ts +39 -0
- package/dist/types/cli/doctor/native-probe.d.ts +2 -0
- package/dist/types/cli/doctor/permission-repairs.d.ts +25 -0
- package/dist/types/cli/doctor/plugin-quarantine.d.ts +77 -0
- package/dist/types/cli/doctor/plugin-restore.d.ts +40 -0
- package/dist/types/cli/doctor/plugin-targets.d.ts +11 -0
- package/dist/types/cli/doctor/probe-client.d.ts +9 -0
- package/dist/types/cli/doctor/probe-types.d.ts +18 -0
- package/dist/types/cli/doctor/probe.d.ts +3 -0
- package/dist/types/cli/doctor/projection-probe.d.ts +2 -0
- package/dist/types/cli/doctor/repairs.d.ts +28 -0
- package/dist/types/cli/doctor/report.d.ts +27 -0
- package/dist/types/cli/doctor/runner.d.ts +4 -0
- package/dist/types/cli/doctor/safety.d.ts +10 -0
- package/dist/types/cli/doctor/service-repairs.d.ts +8 -0
- package/dist/types/cli/doctor/service-targets.d.ts +41 -0
- package/dist/types/cli/doctor/types.d.ts +145 -0
- package/dist/types/cli/doctor-cli.d.ts +7 -0
- package/dist/types/cli/doctor-supervisor.d.ts +121 -0
- package/dist/types/cli/doctor-worker.d.ts +29 -0
- package/dist/types/cli/install-activation.d.ts +158 -0
- package/dist/types/cli/macos-community-app.d.ts +41 -0
- package/dist/types/cli/mcp-cli.d.ts +0 -11
- package/dist/types/cli/update-cli.d.ts +41 -4
- package/dist/types/cli-main.d.ts +174 -0
- package/dist/types/cli.d.ts +1 -171
- package/dist/types/commands/doctor.d.ts +7 -0
- package/dist/types/commands/sdk.d.ts +17 -8
- package/dist/types/config/autorouting-tier-map.d.ts +19 -0
- package/dist/types/config/file-lock.d.ts +27 -3
- package/dist/types/config/model-preset-registry.d.ts +1 -0
- package/dist/types/config/model-registry.d.ts +12 -5
- package/dist/types/config/model-resolver.d.ts +16 -3
- package/dist/types/config/models-config-schema.d.ts +2 -0
- package/dist/types/config/settings-schema.d.ts +1 -1
- package/dist/types/coordinator-mcp/question-gate-codec.d.ts +1 -1
- package/dist/types/coordinator-mcp/session-reaper.d.ts +15 -5
- package/dist/types/cursor.d.ts +9 -9
- package/dist/types/discovery/agents-md.d.ts +6 -1
- package/dist/types/discovery/helpers.d.ts +36 -7
- package/dist/types/discovery/index.d.ts +1 -1
- package/dist/types/discovery/mcp-json.d.ts +2 -0
- package/dist/types/extensibility/extensions/loader.d.ts +22 -1
- package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +14 -1
- package/dist/types/extensibility/gjc-plugins/paths.d.ts +2 -1
- package/dist/types/extensibility/gjc-plugins/types.d.ts +25 -0
- package/dist/types/extensibility/plugins/manager.d.ts +33 -4
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +186 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +27 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +16 -1
- package/dist/types/extensibility/runtime-skill-discovery.d.ts +16 -3
- package/dist/types/gjc-runtime/autoresearch-runtime.d.ts +6 -0
- package/dist/types/gjc-runtime/launch-worktree.d.ts +53 -0
- package/dist/types/gjc-runtime/session-layout.d.ts +8 -0
- package/dist/types/gjc-runtime/session-state-lock.d.ts +15 -0
- package/dist/types/gjc-runtime/session-state-sidecar.d.ts +13 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +6 -0
- package/dist/types/main.d.ts +19 -1
- package/dist/types/modes/acp/acp-agent.d.ts +40 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +1 -0
- package/dist/types/modes/components/model-selector.d.ts +2 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -1
- package/dist/types/runtime-mcp/config-writer.d.ts +47 -0
- package/dist/types/runtime-mcp/policy-json-edit.d.ts +60 -0
- package/dist/types/runtime-mcp/startup-policy.d.ts +4 -0
- package/dist/types/runtime-mcp/types.d.ts +2 -2
- package/dist/types/sdk/acp/adapter.d.ts +5 -1
- package/dist/types/sdk/broker/broker.d.ts +51 -0
- package/dist/types/sdk/broker/daemon-entry.d.ts +39 -0
- package/dist/types/sdk/broker/discovery.d.ts +38 -0
- package/dist/types/sdk/broker/doctor-restart.d.ts +79 -0
- package/dist/types/sdk/broker/endpoint-authority.d.ts +7 -0
- package/dist/types/sdk/broker/ensure.d.ts +14 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
- package/dist/types/sdk/broker/process-incarnation.d.ts +50 -0
- package/dist/types/sdk/broker/runtime.d.ts +26 -0
- package/dist/types/sdk/broker/session-index.d.ts +13 -4
- package/dist/types/sdk/broker/worktree-occupancy.d.ts +14 -0
- package/dist/types/sdk/bus/chat-daemon-cli.d.ts +16 -0
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +101 -6
- package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +16 -0
- package/dist/types/sdk/bus/daemon-startup-exclusion.d.ts +43 -0
- package/dist/types/sdk/bus/doctor-daemon-restart-client.d.ts +51 -0
- package/dist/types/sdk/bus/doctor-daemon-restart.d.ts +39 -0
- package/dist/types/sdk/bus/index.d.ts +2 -0
- package/dist/types/sdk/bus/notification-service.d.ts +3 -0
- package/dist/types/sdk/bus/telegram-daemon-cli.d.ts +11 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -0
- package/dist/types/sdk/bus/telegram-daemon-owner-registry.d.ts +1 -0
- package/dist/types/sdk/bus/telegram-daemon.d.ts +36 -5
- package/dist/types/sdk/cli/session-cli.d.ts +1 -0
- package/dist/types/sdk/host/session-runtime.d.ts +4 -0
- package/dist/types/sdk/host/surface-policy.d.ts +3 -1
- package/dist/types/sdk/lifecycle/service.d.ts +44 -10
- package/dist/types/sdk/prompt-deadline-lease.d.ts +6 -3
- package/dist/types/sdk/prompt-deadline-manager.d.ts +2 -2
- package/dist/types/sdk/prompt-failure.d.ts +47 -0
- package/dist/types/sdk/prompt-status.d.ts +19 -0
- package/dist/types/sdk/router/session-router.d.ts +3 -4
- package/dist/types/sdk/service-artifact-paths.d.ts +16 -0
- package/dist/types/sdk/session-authority.d.ts +9 -0
- package/dist/types/sdk/session.d.ts +3 -1
- package/dist/types/session/agent-session.d.ts +1 -1
- package/dist/types/session/blob-store.d.ts +1 -1
- package/dist/types/session/fallback-chain-controller.d.ts +3 -6
- package/dist/types/session/internal/managed-session-scope.d.ts +44 -0
- package/dist/types/session/primary-control-surface.d.ts +4 -0
- package/dist/types/session/session-manager.d.ts +6 -0
- package/dist/types/system-prompt.d.ts +6 -0
- package/dist/types/tools/ask.d.ts +25 -0
- package/dist/types/tools/image-gen.d.ts +0 -4
- package/dist/types/tools/skill-discovery.d.ts +7 -5
- package/dist/types/tools/ultragoal-ask-guard.d.ts +7 -4
- package/dist/types/utils/changelog.d.ts +0 -9
- package/dist/types/utils/mupdf-wasm.d.ts +1 -0
- package/package.json +9 -8
- package/scripts/compile-args.ts +8 -4
- package/src/capability/fs.ts +395 -17
- package/src/capability/index.ts +273 -10
- package/src/capability/types.ts +9 -0
- package/src/cli/customize-doctor.ts +18 -12
- package/src/cli/doctor/args.ts +236 -0
- package/src/cli/doctor/checks.ts +431 -0
- package/src/cli/doctor/config-repairs.ts +517 -0
- package/src/cli/doctor/context.ts +149 -0
- package/src/cli/doctor/files.ts +149 -0
- package/src/cli/doctor/ids.ts +115 -0
- package/src/cli/doctor/install-repairs.ts +335 -0
- package/src/cli/doctor/journal.ts +423 -0
- package/src/cli/doctor/managed-link.ts +514 -0
- package/src/cli/doctor/native-probe.ts +13 -0
- package/src/cli/doctor/permission-repairs.ts +242 -0
- package/src/cli/doctor/plugin-quarantine.ts +377 -0
- package/src/cli/doctor/plugin-restore.ts +59 -0
- package/src/cli/doctor/plugin-targets.ts +373 -0
- package/src/cli/doctor/probe-client.ts +195 -0
- package/src/cli/doctor/probe-types.ts +21 -0
- package/src/cli/doctor/probe.ts +42 -0
- package/src/cli/doctor/projection-probe.ts +249 -0
- package/src/cli/doctor/repairs.ts +1157 -0
- package/src/cli/doctor/report.ts +176 -0
- package/src/cli/doctor/runner.ts +342 -0
- package/src/cli/doctor/safety.ts +40 -0
- package/src/cli/doctor/service-repairs.ts +452 -0
- package/src/cli/doctor/service-targets.ts +274 -0
- package/src/cli/doctor/types.ts +164 -0
- package/src/cli/doctor-cli.ts +62 -0
- package/src/cli/doctor-supervisor.ts +571 -0
- package/src/cli/doctor-worker.ts +181 -0
- package/src/cli/install-activation.ts +666 -0
- package/src/cli/macos-community-app.ts +1449 -0
- package/src/cli/mcp-cli.ts +11 -21
- package/src/cli/nofile-limit.ts +5 -1
- package/src/cli/plugin-cli.ts +6 -1
- package/src/cli/update-cli.ts +362 -264
- package/src/cli-main.ts +517 -0
- package/src/cli.ts +64 -433
- package/src/commands/autoresearch.ts +11 -5
- package/src/commands/completion.ts +1 -1
- package/src/commands/doctor.ts +13 -0
- package/src/commands/sdk.ts +58 -10
- package/src/commands/ultragoal.ts +11 -5
- package/src/config/autorouting-tier-map.ts +7 -0
- package/src/config/file-lock.ts +736 -71
- package/src/config/mcp-schema.json +3 -3
- package/src/config/model-preset-registry.ts +1 -0
- package/src/config/model-registry.ts +80 -27
- package/src/config/model-resolver.ts +33 -4
- package/src/config/models-config-schema.ts +2 -0
- package/src/config/settings-schema.ts +6 -2
- package/src/coordinator-mcp/question-gate-codec.ts +1 -0
- package/src/coordinator-mcp/server.ts +534 -51
- package/src/coordinator-mcp/session-reaper.ts +64 -8
- package/src/cursor.ts +223 -53
- package/src/discovery/agents-md.ts +74 -8
- package/src/discovery/agents.ts +32 -7
- package/src/discovery/builtin.ts +184 -75
- package/src/discovery/claude-plugins.ts +85 -17
- package/src/discovery/cline.ts +38 -10
- package/src/discovery/cursor.ts +19 -6
- package/src/discovery/gemini.ts +62 -22
- package/src/discovery/github.ts +13 -3
- package/src/discovery/helpers.ts +483 -89
- package/src/discovery/index.ts +1 -0
- package/src/discovery/mcp-json.ts +36 -10
- package/src/discovery/opencode.ts +36 -19
- package/src/discovery/ssh.ts +11 -8
- package/src/discovery/windsurf.ts +12 -3
- package/src/exec/bash-executor.ts +10 -3
- package/src/exec/isolated-shell.ts +15 -2
- package/src/extensibility/extensions/loader.ts +88 -26
- package/src/extensibility/gjc-plugins/lifecycle.ts +189 -0
- package/src/extensibility/gjc-plugins/paths.ts +4 -1
- package/src/extensibility/gjc-plugins/types.ts +27 -0
- package/src/extensibility/plugins/manager.ts +200 -22
- package/src/extensibility/plugins/marketplace/cache.ts +55 -2
- package/src/extensibility/plugins/marketplace/manager.ts +1262 -162
- package/src/extensibility/plugins/marketplace/registry.ts +153 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +116 -10
- package/src/extensibility/runtime-skill-discovery.ts +61 -9
- package/src/extensibility/skill-management.ts +7 -1
- package/src/gjc-runtime/autoresearch-runtime.ts +10 -1
- package/src/gjc-runtime/launch-worktree.test.ts +248 -0
- package/src/gjc-runtime/launch-worktree.ts +275 -38
- package/src/gjc-runtime/repository-binding.ts +26 -1
- package/src/gjc-runtime/session-layout.ts +10 -0
- package/src/gjc-runtime/session-state-lock.ts +330 -23
- package/src/gjc-runtime/session-state-sidecar.ts +328 -80
- package/src/gjc-runtime/ultragoal-runtime.ts +10 -1
- package/src/harness-control-plane/session-lease.ts +2 -2
- package/src/internal-urls/docs-index.generated.ts +28 -26
- package/src/main.ts +150 -29
- package/src/memories/index.ts +24 -2
- package/src/modes/acp/acp-agent.ts +522 -68
- package/src/modes/components/agent-dashboard.ts +3 -1
- package/src/modes/components/model-selector.ts +28 -19
- package/src/modes/components/plugin-settings.ts +2 -1
- package/src/modes/controllers/selector-controller.ts +15 -9
- package/src/modes/interactive-mode.ts +21 -3
- package/src/prompts/system/system-prompt.md +5 -1
- package/src/prompts/tools/browser.md +1 -1
- package/src/prompts/tools/move-session.md +4 -0
- package/src/prompts/tools/read.md +2 -1
- package/src/prompts/tools/skill-discovery.md +6 -5
- package/src/prompts/tools/task.md +1 -0
- package/src/runtime-mcp/config-writer.ts +228 -0
- package/src/runtime-mcp/oauth-discovery.ts +114 -14
- package/src/runtime-mcp/policy-json-edit.ts +129 -0
- package/src/runtime-mcp/startup-policy.ts +14 -0
- package/src/runtime-mcp/types.ts +2 -2
- package/src/sdk/acp/adapter.ts +27 -12
- package/src/sdk/broker/broker.ts +273 -44
- package/src/sdk/broker/daemon-entry.ts +119 -0
- package/src/sdk/broker/discovery.ts +173 -20
- package/src/sdk/broker/doctor-restart.ts +206 -0
- package/src/sdk/broker/endpoint-authority.ts +36 -0
- package/src/sdk/broker/ensure.ts +49 -14
- package/src/sdk/broker/lifecycle.ts +174 -42
- package/src/sdk/broker/process-incarnation.ts +86 -2
- package/src/sdk/broker/runtime.ts +145 -21
- package/src/sdk/broker/session-index.ts +136 -22
- package/src/sdk/broker/spawn-substrate.ts +4 -1
- package/src/sdk/broker/transport.ts +5 -0
- package/src/sdk/broker/worktree-occupancy.ts +21 -1
- package/src/sdk/bus/chat-daemon-cli.ts +63 -0
- package/src/sdk/bus/chat-daemon-control.ts +260 -64
- package/src/sdk/bus/chat-daemon-runtime.ts +141 -25
- package/src/sdk/bus/daemon-startup-exclusion.ts +119 -0
- package/src/sdk/bus/doctor-daemon-restart-client.ts +291 -0
- package/src/sdk/bus/doctor-daemon-restart.ts +92 -0
- package/src/sdk/bus/index.ts +252 -51
- package/src/sdk/bus/kind-aware-reconciliation.ts +76 -41
- package/src/sdk/bus/notification-service.ts +21 -3
- package/src/sdk/bus/reconciliation-store.ts +17 -11
- package/src/sdk/bus/telegram-daemon-cli.ts +91 -5
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/bus/telegram-daemon-control.ts +47 -0
- package/src/sdk/bus/telegram-daemon-owner-registry.ts +1 -1
- package/src/sdk/bus/telegram-daemon.ts +178 -13
- package/src/sdk/cli/session-cli.ts +100 -12
- package/src/sdk/host/host.ts +2 -7
- package/src/sdk/host/session-runtime.test.ts +329 -8
- package/src/sdk/host/session-runtime.ts +202 -50
- package/src/sdk/host/surface-policy.ts +8 -1
- package/src/sdk/lifecycle/service.ts +199 -22
- package/src/sdk/mcp/server.ts +1 -1
- package/src/sdk/prompt-deadline-lease.ts +12 -4
- package/src/sdk/prompt-deadline-manager.ts +5 -7
- package/src/sdk/prompt-failure.ts +148 -0
- package/src/sdk/prompt-status.ts +30 -1
- package/src/sdk/prompt-watchdog.ts +11 -3
- package/src/sdk/protocol/operation-inventory.generated.json +18 -0
- package/src/sdk/protocol/operation-registry.ts +20 -8
- package/src/sdk/router/session-router.ts +8 -3
- package/src/sdk/service-artifact-paths.ts +26 -0
- package/src/sdk/session-authority.ts +10 -0
- package/src/sdk/session.ts +361 -194
- package/src/session/agent-session.ts +398 -93
- package/src/session/blob-store.ts +9 -9
- package/src/session/fallback-chain-controller.ts +3 -7
- package/src/session/internal/managed-session-scope.ts +445 -29
- package/src/session/internal/managed-session-storage.ts +38 -6
- package/src/session/primary-control-surface.ts +12 -0
- package/src/session/session-manager.ts +11 -3
- package/src/session/session-storage.ts +1 -1
- package/src/session-import/codex.ts +6 -1
- package/src/session-import/redact.ts +7 -0
- package/src/skill-state/workflow-mutation-guard.ts +645 -39
- package/src/slash-commands/builtin-registry.ts +7 -3
- package/src/system-prompt.ts +8 -0
- package/src/task/executor.ts +36 -3
- package/src/task/types.ts +27 -5
- package/src/tools/ask.ts +114 -34
- package/src/tools/browser/actions.ts +2 -2
- package/src/tools/browser/tab-worker.ts +11 -8
- package/src/tools/descriptors.ts +6 -1
- package/src/tools/fetch.ts +7 -2
- package/src/tools/image-gen.ts +33 -34
- package/src/tools/read.ts +78 -32
- package/src/tools/skill-discovery.ts +17 -7
- package/src/tools/tool-catalog.generated.ts +8 -8
- package/src/tools/ultragoal-ask-guard.ts +16 -26
- package/src/utils/changelog.ts +7 -1
- package/src/utils/git.ts +3 -1
- package/src/utils/markit.ts +24 -2
- package/src/utils/mupdf-wasm.ts +26 -0
- package/src/web/search/providers/openai-compatible.ts +191 -14
|
@@ -3565,11 +3565,13 @@ export async function acquireManagedLock(
|
|
|
3565
3565
|
descriptorClosed = true;
|
|
3566
3566
|
}
|
|
3567
3567
|
};
|
|
3568
|
-
const
|
|
3568
|
+
const assertOwnedWithDescriptor = (ownedFd: number): void => {
|
|
3569
3569
|
const current = parseLock(lockPath);
|
|
3570
3570
|
let named: fs.BigIntStats;
|
|
3571
|
+
let opened: fs.BigIntStats;
|
|
3571
3572
|
try {
|
|
3572
3573
|
named = fs.lstatSync(lockPath, { bigint: true });
|
|
3574
|
+
opened = fs.fstatSync(ownedFd, { bigint: true });
|
|
3573
3575
|
} catch {
|
|
3574
3576
|
throw new Error("migration_busy");
|
|
3575
3577
|
}
|
|
@@ -3579,18 +3581,22 @@ export async function acquireManagedLock(
|
|
|
3579
3581
|
!current ||
|
|
3580
3582
|
current.released === true ||
|
|
3581
3583
|
!sameFileIdentity(lockIdentity, named) ||
|
|
3584
|
+
!named.isFile() ||
|
|
3585
|
+
named.isSymbolicLink() ||
|
|
3586
|
+
!sameFileIdentity(lockIdentity, opened) ||
|
|
3582
3587
|
current.attemptId !== attemptId
|
|
3583
3588
|
)
|
|
3584
3589
|
throw new Error("migration_busy");
|
|
3585
3590
|
const now = Date.now();
|
|
3586
3591
|
if (current.leaseExpiresAt < now + LOCK_HEARTBEAT_MS) {
|
|
3587
|
-
writeLockDescriptor(
|
|
3592
|
+
writeLockDescriptor(ownedFd, {
|
|
3588
3593
|
...record,
|
|
3589
3594
|
heartbeatAt: now,
|
|
3590
3595
|
leaseExpiresAt: now + LOCK_LEASE_MS,
|
|
3591
3596
|
});
|
|
3592
3597
|
}
|
|
3593
3598
|
};
|
|
3599
|
+
const assertOwned = (): void => assertOwnedWithDescriptor(fd);
|
|
3594
3600
|
const heartbeat = setInterval(() => {
|
|
3595
3601
|
try {
|
|
3596
3602
|
assertOwned();
|
|
@@ -3603,13 +3609,29 @@ export async function acquireManagedLock(
|
|
|
3603
3609
|
attemptId,
|
|
3604
3610
|
assertOwned,
|
|
3605
3611
|
async release(): Promise<void> {
|
|
3612
|
+
if (released) return;
|
|
3606
3613
|
clearInterval(heartbeat);
|
|
3607
3614
|
let releaseFd = fd;
|
|
3608
3615
|
let replacementFd: number | undefined;
|
|
3609
3616
|
try {
|
|
3610
|
-
|
|
3617
|
+
// A named successor means ownership was already lost. Do not let
|
|
3618
|
+
// Linux descriptor recovery mask that condition as a security error.
|
|
3619
|
+
let named: fs.BigIntStats;
|
|
3620
|
+
try {
|
|
3621
|
+
named = fs.lstatSync(lockPath, { bigint: true });
|
|
3622
|
+
} catch (error) {
|
|
3623
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") throw new Error("migration_busy");
|
|
3624
|
+
throw error;
|
|
3625
|
+
}
|
|
3626
|
+
if (!named.isFile() || named.isSymbolicLink() || !sameFileIdentity(lockIdentity, named))
|
|
3627
|
+
throw new Error("migration_busy");
|
|
3628
|
+
// Check the descriptor before native security verification: native failures
|
|
3629
|
+
// do not preserve Node's EBADF code for a closed retained descriptor.
|
|
3611
3630
|
ManagedLockTestHooks.beforeReleaseDescriptorVerification?.({ path: lockPath, fd });
|
|
3612
3631
|
try {
|
|
3632
|
+
const opened = fs.fstatSync(fd, { bigint: true });
|
|
3633
|
+
if (!sameFileIdentity(lockIdentity, opened))
|
|
3634
|
+
throw securityError(lockPath, { ok: false, code: "identity_mismatch" });
|
|
3613
3635
|
secureFileDescriptor(lockPath, fd, "verify", true);
|
|
3614
3636
|
} catch (error) {
|
|
3615
3637
|
const descriptorUnavailable = (error as NodeJS.ErrnoException).code === "EBADF";
|
|
@@ -3618,9 +3640,16 @@ export async function acquireManagedLock(
|
|
|
3618
3640
|
(!descriptorUnavailable && managedSecurityFailureClassification(error) !== "identity_mismatch")
|
|
3619
3641
|
)
|
|
3620
3642
|
throw error;
|
|
3621
|
-
|
|
3643
|
+
try {
|
|
3644
|
+
replacementFd = openVerifiedLockReleaseDescriptor(lockPath, lockIdentity);
|
|
3645
|
+
} catch (replacementError) {
|
|
3646
|
+
if (managedSecurityFailureClassification(replacementError) === "identity_mismatch")
|
|
3647
|
+
throw new Error("migration_busy");
|
|
3648
|
+
throw replacementError;
|
|
3649
|
+
}
|
|
3622
3650
|
releaseFd = replacementFd;
|
|
3623
3651
|
}
|
|
3652
|
+
assertOwnedWithDescriptor(releaseFd);
|
|
3624
3653
|
const now = Date.now();
|
|
3625
3654
|
// A released record is the only live-process reclaim authority. Expiry alone
|
|
3626
3655
|
// never authorizes stealing from a holder whose process is still present.
|
|
@@ -3638,9 +3667,12 @@ export async function acquireManagedLock(
|
|
|
3638
3667
|
}
|
|
3639
3668
|
fsyncDirectory(locksDirectory);
|
|
3640
3669
|
} finally {
|
|
3641
|
-
if (replacementFd !== undefined) fs.closeSync(replacementFd);
|
|
3642
3670
|
released = true;
|
|
3643
|
-
|
|
3671
|
+
try {
|
|
3672
|
+
if (replacementFd !== undefined) fs.closeSync(replacementFd);
|
|
3673
|
+
} finally {
|
|
3674
|
+
closeDescriptor();
|
|
3675
|
+
}
|
|
3644
3676
|
}
|
|
3645
3677
|
},
|
|
3646
3678
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type PrimaryControlSurface = "cli" | "sdk";
|
|
2
|
+
|
|
3
|
+
const primaryControlSurfaceByOptions = new WeakMap<object, PrimaryControlSurface>();
|
|
4
|
+
|
|
5
|
+
/** @internal Trusted CLI bootstrap hook; ordinary SDK callers remain SDK-owned. */
|
|
6
|
+
export function setPrimaryControlSurface(options: object, surface: PrimaryControlSurface): void {
|
|
7
|
+
primaryControlSurfaceByOptions.set(options, surface);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function primaryControlSurfaceFor(options: object): PrimaryControlSurface {
|
|
11
|
+
return primaryControlSurfaceByOptions.get(options) ?? "sdk";
|
|
12
|
+
}
|
|
@@ -18927,10 +18927,8 @@ export class SessionManager {
|
|
|
18927
18927
|
* cap are weakly held so a GC cycle can reclaim them between reads.
|
|
18928
18928
|
*/
|
|
18929
18929
|
#getSessionContextForRead(): Readonly<SessionContext> {
|
|
18930
|
-
const hasResidentSentinel = this.#fileEntries.some(entry => containsResidentSentinel(entry));
|
|
18931
18930
|
const cached = dereferenceMaterializedCache(this.#sessionContextCache);
|
|
18932
18931
|
if (
|
|
18933
|
-
!hasResidentSentinel &&
|
|
18934
18932
|
cached &&
|
|
18935
18933
|
this.#sessionContextEntryRevision === this.#entryRevision &&
|
|
18936
18934
|
this.#sessionContextLeafRevision === this.#leafRevision &&
|
|
@@ -18938,6 +18936,8 @@ export class SessionManager {
|
|
|
18938
18936
|
) {
|
|
18939
18937
|
return cached;
|
|
18940
18938
|
}
|
|
18939
|
+
// Only sentinel-free contexts are cached; revisions guard warm reads.
|
|
18940
|
+
const hasResidentSentinel = this.#fileEntries.some(entry => containsResidentSentinel(entry));
|
|
18941
18941
|
this.#pathOnlyContextBuildCount++;
|
|
18942
18942
|
let resolvedProviderState: SessionEntry[] = [];
|
|
18943
18943
|
if (this.#coldSidecarActive() && this.#sidecarRuntime) {
|
|
@@ -21886,6 +21886,12 @@ export class SessionManager {
|
|
|
21886
21886
|
|
|
21887
21887
|
/**
|
|
21888
21888
|
* List all sessions across all project directories.
|
|
21889
|
+
*
|
|
21890
|
+
* Scope re-derivation is an enrichment pass, not an admission gate: a seeded
|
|
21891
|
+
* transcript stays listed even when its recorded workspace no longer resolves
|
|
21892
|
+
* (deleted, renamed, unmounted, or recorded by another platform's checkout).
|
|
21893
|
+
* Dropping those would hide readable sessions from `--resume` with no recovery
|
|
21894
|
+
* path, which is exactly when a global lookup matters most.
|
|
21889
21895
|
*/
|
|
21890
21896
|
static async listAll(
|
|
21891
21897
|
storage: SessionStorage = new FileSessionStorage(),
|
|
@@ -21899,7 +21905,9 @@ export class SessionManager {
|
|
|
21899
21905
|
.filter(entry => entry.isDirectory())
|
|
21900
21906
|
.flatMap(entry => storage.listFilesSync(path.join(sessionsRoot, entry.name), "*.jsonl"));
|
|
21901
21907
|
const seedSessions = await collectSessionsFromFiles(seedFiles, storage);
|
|
21902
|
-
const logicalFiles = new Set<string>(
|
|
21908
|
+
const logicalFiles = new Set<string>(
|
|
21909
|
+
seedSessions.map(session => session.path).filter(sessionPath => !isStagedSessionPath(sessionPath)),
|
|
21910
|
+
);
|
|
21903
21911
|
for (const cwd of new Set(seedSessions.map(session => session.cwd).filter(Boolean))) {
|
|
21904
21912
|
const scope = resolveManagedScope({
|
|
21905
21913
|
cwd,
|
|
@@ -706,7 +706,7 @@ function secureOwnerOnlyFileDescriptor(
|
|
|
706
706
|
throw new Error("Managed writer descriptor escaped retained authority");
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
-
if (process.platform !== "linux" || !securityContext) {
|
|
709
|
+
if ((process.platform !== "linux" && process.platform !== "darwin") || !securityContext) {
|
|
710
710
|
if (operation === "apply") {
|
|
711
711
|
const applied = validateNativeSecurityResult(
|
|
712
712
|
nativeSessionStorage().applyOwnerOnlyPathSecurity(pathname, "file"),
|
|
@@ -31,7 +31,12 @@ const JWT_VALUE = /\b[A-Za-z0-9_-]{8,2048}\.[A-Za-z0-9_-]{8,8192}\.[A-Za-z0-9_-]
|
|
|
31
31
|
const SECRET_ASSIGNMENT =
|
|
32
32
|
/(\b(?:password|passwd|secret|token|api[-_]?key|access[-_]?key)\b\s*[:=]\s*)(?:"[^"\r\n]{4,4096}"|'[^'\r\n]{4,4096}'|[^\s,;]{4,4096})/giu;
|
|
33
33
|
const PRIVATE_KEY = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]{1,65536}?-----END [A-Z ]*PRIVATE KEY-----/gu;
|
|
34
|
-
|
|
34
|
+
// The scheme-character run is boundary anchored, so the unbounded suffix is
|
|
35
|
+
// attempted once per maximal run instead of once at every prefix. Keeping the
|
|
36
|
+
// leading non-letter characters in the capture preserves redaction for URLs
|
|
37
|
+
// embedded after digits or scheme punctuation without imposing an arbitrary
|
|
38
|
+
// scheme-length cap.
|
|
39
|
+
const URL_CREDENTIAL = /(?<![A-Za-z0-9+.-])([0-9+.-]*[a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu;
|
|
35
40
|
const HEADER_CREDENTIAL = /(\b(authorization|cookie|set-cookie)\b[ \t]*:[ \t]*)([^\r\n]*)/giu;
|
|
36
41
|
const JSON_AUTHORIZATION_CREDENTIAL = /((?:\\?")authorization(?:\\?")\s*:\s*(?:\\?")?)([^\\",}\r\n]+)/giu;
|
|
37
42
|
|
|
@@ -44,6 +44,13 @@ const REDACTION_RULES: readonly RedactionRule[] = [
|
|
|
44
44
|
{ id: "openai-key", pattern: /sk-(?:proj|svcacct|admin)-[A-Za-z0-9_-]{20,}|sk-[A-Za-z0-9]{20,}/g },
|
|
45
45
|
// Slack tokens.
|
|
46
46
|
{ id: "slack-token", pattern: /xox[baprs]-[A-Za-z0-9-]{10,}/g },
|
|
47
|
+
// The four shapes `crash/upstream/envelope.ts` classifies as credential-like
|
|
48
|
+
// and refuses to transmit. Stripe and Hugging Face separate with `_`, so the
|
|
49
|
+
// `sk-` rules above never matched them.
|
|
50
|
+
{ id: "npm-token", pattern: /npm_[A-Za-z0-9]{20,}/g },
|
|
51
|
+
{ id: "gitlab-token", pattern: /glpat-[A-Za-z0-9_-]{20,}/g },
|
|
52
|
+
{ id: "stripe-key", pattern: /(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}/g },
|
|
53
|
+
{ id: "huggingface-token", pattern: /hf_[A-Za-z0-9]{20,}/g },
|
|
47
54
|
// Google API keys.
|
|
48
55
|
{ id: "google-api-key", pattern: /AIza[0-9A-Za-z_-]{35}/g },
|
|
49
56
|
// Bearer tokens carried in Authorization text.
|