nova-personal-agent-server 0.4.1 → 1.0.2
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/LICENSE +674 -201
- package/README.md +10 -0
- package/bin/nova-space-host.mjs +4 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/cli.js +71 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/client.js +340 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/crypto.js +167 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/live.js +169 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/mailbox.js +217 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/media.js +320 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/pairing.js +13 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/protocol.js +50 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/security.js +305 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/server.js +477 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/source-address.js +58 -0
- package/node_modules/@nova-personal-agent/relay/package.json +1 -0
- package/package.json +11 -4
- package/runtime/dist/src/cascaded-text-provider.js +8 -3
- package/runtime/dist/src/composition/assembly.js +133 -35
- package/runtime/dist/src/composition/cascaded-realtime-assembly.js +114 -59
- package/runtime/dist/src/composition/production-composition.js +57 -21
- package/runtime/dist/src/composition/realtime-assembly.js +160 -52
- package/runtime/dist/src/composition/soul-context.js +22 -0
- package/runtime/dist/src/config/capability-registry.js +48 -3
- package/runtime/dist/src/config/cascaded-realtime-config.js +23 -10
- package/runtime/dist/src/config/config.js +541 -128
- package/runtime/dist/src/config/credential-rotation.js +26 -0
- package/runtime/dist/src/config/data-root.js +764 -0
- package/runtime/dist/src/config/diagnostics.js +3 -1
- package/runtime/dist/src/config/environment-contract.js +190 -188
- package/runtime/dist/src/config/model-routes.js +140 -0
- package/runtime/dist/src/config/voice-credentials.js +55 -0
- package/runtime/dist/src/connectors/composio/index.js +9 -0
- package/runtime/dist/src/connectors/feishu/index.js +258 -44
- package/runtime/dist/src/connectors/macos/mail.js +7 -3
- package/runtime/dist/src/connectors/macos/reader.js +3 -1
- package/runtime/dist/src/conversation-voice-provider.js +5 -2
- package/runtime/dist/src/core/causal-runtime.js +38 -3
- package/runtime/dist/src/core/context-view.js +7 -0
- package/runtime/dist/src/core/guards.js +32 -0
- package/runtime/dist/src/core/runtime.js +3 -0
- package/runtime/dist/src/core/schedule-tools.js +2 -2
- package/runtime/dist/src/core/source-processing-instructions.js +2 -2
- package/runtime/dist/src/core/source-processing-tools.js +3 -1
- package/runtime/dist/src/core/tool-schema.js +42 -7
- package/runtime/dist/src/desktop/desktop-camera.js +3 -5
- package/runtime/dist/src/desktop/desktop-control.js +41 -8
- package/runtime/dist/src/desktop/desktop-session.js +90 -19
- package/runtime/dist/src/desktop/desktop-wire.js +5 -7
- package/runtime/dist/src/desktop/startup-error.js +18 -16
- package/runtime/dist/src/desktop/workbench-acceptance.js +52 -14
- package/runtime/dist/src/desktop-entry.js +6 -2
- package/runtime/dist/src/desktop.js +5 -1
- package/runtime/dist/src/device/attempt.js +65 -0
- package/runtime/dist/src/device/authority.js +159 -0
- package/runtime/dist/src/device/gateway.js +87 -0
- package/runtime/dist/src/device/ledger.js +91 -0
- package/runtime/dist/src/device/ownership.js +92 -0
- package/runtime/dist/src/device/port.js +2 -0
- package/runtime/dist/src/device/schedule-ownership.js +103 -0
- package/runtime/dist/src/executors/acp/transport.js +2 -0
- package/runtime/dist/src/executors/browser.js +4 -3
- package/runtime/dist/src/executors/codex/adapter-project.js +58 -12
- package/runtime/dist/src/executors/codex/app-server-schema.js +12 -21
- package/runtime/dist/src/executors/codex/app-server-transport.js +32 -18
- package/runtime/dist/src/executors/codex/common.js +1 -1
- package/runtime/dist/src/executors/codex/contract.js +12 -16
- package/runtime/dist/src/executors/codex/credential-snapshot.js +1 -9
- package/runtime/dist/src/executors/codex/factory.js +54 -32
- package/runtime/dist/src/executors/codex/host-config.js +69 -20
- package/runtime/dist/src/executors/codex/launch-profile.js +3 -2
- package/runtime/dist/src/executors/codex/local-provider-credential.js +39 -0
- package/runtime/dist/src/executors/codex/process-owner.js +4 -6
- package/runtime/dist/src/executors/codex/production-host.js +33 -34
- package/runtime/dist/src/executors/codex/protocol.js +9 -14
- package/runtime/dist/src/executors/codex/session-title.js +6 -8
- package/runtime/dist/src/executors/codex/spawn-env.js +27 -6
- package/runtime/dist/src/executors/codex/turn-projection.js +12 -17
- package/runtime/dist/src/executors/codex/windows-guardian.js +4 -6
- package/runtime/dist/src/executors/coding/intake.js +12 -7
- package/runtime/dist/src/executors/computer-backend.js +18 -10
- package/runtime/dist/src/executors/computer-config.js +32 -0
- package/runtime/dist/src/executors/computer-device.js +68 -16
- package/runtime/dist/src/executors/computer-worker.js +18 -6
- package/runtime/dist/src/executors/computer.js +29 -56
- package/runtime/dist/src/executors/device-lock.js +14 -5
- package/runtime/dist/src/executors/gui-execution.js +2 -0
- package/runtime/dist/src/executors/index.js +0 -1
- package/runtime/dist/src/executors/mobile.js +9 -8
- package/runtime/dist/src/executors/native-process.js +4 -0
- package/runtime/dist/src/executors/search.js +3 -5
- package/runtime/dist/src/executors/task-resources.js +21 -0
- package/runtime/dist/src/executors/watcher.js +2 -4
- package/runtime/dist/src/experience/host.js +179 -0
- package/runtime/dist/src/index.js +2 -0
- package/runtime/dist/src/knowledge/assembly.js +3 -4
- package/runtime/dist/src/knowledge/embeddings.js +50 -34
- package/runtime/dist/src/knowledge/service.js +1 -0
- package/runtime/dist/src/knowledge/store-client.js +1 -6
- package/runtime/dist/src/knowledge/store-worker.js +1 -3
- package/runtime/dist/src/mem0/resource.js +25 -0
- package/runtime/dist/src/mem0/store-worker.js +234 -21
- package/runtime/dist/src/memory/consumer.js +31 -0
- package/runtime/dist/src/memory/engine-worker.js +210 -0
- package/runtime/dist/src/memory/entry.js +8 -1
- package/runtime/dist/src/memory/explicit-memory.js +20 -0
- package/runtime/dist/src/memory/factory.js +30 -15
- package/runtime/dist/src/memory/grounded-voicemem.js +10 -0
- package/runtime/dist/src/memory/ledger-recall-engine.js +86 -0
- package/runtime/dist/src/memory/prerecall-port.js +27 -0
- package/runtime/dist/src/memory/prerecall.js +1 -1
- package/runtime/dist/src/memory/production-engine.js +151 -0
- package/runtime/dist/src/memory/provenance.js +1 -0
- package/runtime/dist/src/memory/remote-personal-memory.js +3 -1
- package/runtime/dist/src/memory/retrieval.js +107 -22
- package/runtime/dist/src/memory/sensitivity.js +6 -2
- package/runtime/dist/src/memory/source-retrieval.js +11 -0
- package/runtime/dist/src/memory/tool-capabilities.js +46 -0
- package/runtime/dist/src/memory/voicemem-sdk/LICENSE +202 -0
- package/runtime/dist/src/memory/voicemem-sdk/NOTICE.md +97 -0
- package/runtime/dist/src/memory/voicemem-sdk/PATCH-NOTICE.md +23 -0
- package/runtime/dist/src/memory/voicemem-sdk/archive.js +12 -0
- package/runtime/dist/src/memory/voicemem-sdk/audio.js +111 -0
- package/runtime/dist/src/memory/voicemem-sdk/barge-in.js +59 -0
- package/runtime/dist/src/memory/voicemem-sdk/checkpoint.js +56 -0
- package/runtime/dist/src/memory/voicemem-sdk/cleanup.js +139 -0
- package/runtime/dist/src/memory/voicemem-sdk/dashscope-asr.js +254 -0
- package/runtime/dist/src/memory/voicemem-sdk/dashscope-tts.js +247 -0
- package/runtime/dist/src/memory/voicemem-sdk/evaluation.js +330 -0
- package/runtime/dist/src/memory/voicemem-sdk/extraction.js +220 -0
- package/runtime/dist/src/memory/voicemem-sdk/finetune-data.js +115 -0
- package/runtime/dist/src/memory/voicemem-sdk/finetune.js +170 -0
- package/runtime/dist/src/memory/voicemem-sdk/grounded-reply-preferences.js +81 -0
- package/runtime/dist/src/memory/voicemem-sdk/index.js +22 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-embedding.js +164 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-runtime.js +53 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-speaker.js +240 -0
- package/runtime/dist/src/memory/voicemem-sdk/memory.js +767 -0
- package/runtime/dist/src/memory/voicemem-sdk/model-json.js +14 -0
- package/runtime/dist/src/memory/voicemem-sdk/personamem.js +209 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/addenda.js +215 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/additive-extraction.js +478 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/index.js +32 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/update-memory.js +152 -0
- package/runtime/dist/src/memory/voicemem-sdk/providers.js +325 -0
- package/runtime/dist/src/memory/voicemem-sdk/ranking.js +65 -0
- package/runtime/dist/src/memory/voicemem-sdk/reaction.js +33 -0
- package/runtime/dist/src/memory/voicemem-sdk/realtime.js +215 -0
- package/runtime/dist/src/memory/voicemem-sdk/reply.js +68 -0
- package/runtime/dist/src/memory/voicemem-sdk/routing.js +209 -0
- package/runtime/dist/src/memory/voicemem-sdk/slots.js +61 -0
- package/runtime/dist/src/memory/voicemem-sdk/speaker-bindings.js +120 -0
- package/runtime/dist/src/memory/voicemem-sdk/speaker-profiles.js +327 -0
- package/runtime/dist/src/memory/voicemem-sdk/store.js +577 -0
- package/runtime/dist/src/memory/voicemem-sdk/stream.js +317 -0
- package/runtime/dist/src/memory/voicemem-sdk/subgraph.js +113 -0
- package/runtime/dist/src/memory/voicemem-sdk/summaries.js +56 -0
- package/runtime/dist/src/memory/voicemem-sdk/time.js +157 -0
- package/runtime/dist/src/memory/voicemem-sdk/types.js +2 -0
- package/runtime/dist/src/memory-ledger/store-client.js +235 -37
- package/runtime/dist/src/memory-ledger/store-worker.js +8 -5
- package/runtime/dist/src/memory-ledger/store.js +91 -1
- package/runtime/dist/src/memory-substrate/consolidation.js +23 -7
- package/runtime/dist/src/memory-substrate/diary.js +27 -0
- package/runtime/dist/src/memory-substrate/engine-outbox.js +107 -0
- package/runtime/dist/src/memory-substrate/explicit-memory.js +112 -0
- package/runtime/dist/src/memory-substrate/fact-fidelity.js +68 -0
- package/runtime/dist/src/memory-substrate/feishu-consent.js +41 -0
- package/runtime/dist/src/memory-substrate/file-authority.js +29 -6
- package/runtime/dist/src/memory-substrate/life-operations.js +35 -9
- package/runtime/dist/src/memory-substrate/markdown-repository.js +271 -65
- package/runtime/dist/src/memory-substrate/memory-documents.js +96 -0
- package/runtime/dist/src/memory-substrate/migration.js +2 -0
- package/runtime/dist/src/memory-substrate/purge.js +12 -2
- package/runtime/dist/src/memory-substrate/resource.js +514 -129
- package/runtime/dist/src/memory-substrate/retrieval.js +8 -5
- package/runtime/dist/src/memory-substrate/source-operations.js +9 -1
- package/runtime/dist/src/memory-substrate/source-processing.js +436 -40
- package/runtime/dist/src/memory-substrate/source-retrieval.js +28 -0
- package/runtime/dist/src/memory-substrate/source-state.js +8 -0
- package/runtime/dist/src/memory-substrate/space-source-input.js +90 -0
- package/runtime/dist/src/memory-substrate/store.js +125 -23
- package/runtime/dist/src/model/goal-checkin-writer.js +72 -0
- package/runtime/dist/src/model/goal-writer.js +80 -0
- package/runtime/dist/src/model/jev-client.js +24 -13
- package/runtime/dist/src/model/model-adapters.js +2 -3
- package/runtime/dist/src/model/model-catalog.js +80 -0
- package/runtime/dist/src/model/model-gateway.js +47 -18
- package/runtime/dist/src/model/model-purpose.js +3 -4
- package/runtime/dist/src/model/personal-writer.js +536 -44
- package/runtime/dist/src/model/proactivity.js +50 -6
- package/runtime/dist/src/model/responses-model-gateway.js +59 -0
- package/runtime/dist/src/model/task-verifier.js +3 -3
- package/runtime/dist/src/model/timeline-anchors.js +77 -0
- package/runtime/dist/src/model/timeline-perspective.js +13 -0
- package/runtime/dist/src/model/timeline-selection.js +182 -0
- package/runtime/dist/src/model/understanding-writer.js +27 -0
- package/runtime/dist/src/model/vision-capability.js +3 -1
- package/runtime/dist/src/model/workbench-writer.js +96 -0
- package/runtime/dist/src/news/feeds.js +6 -10
- package/runtime/dist/src/news/interests.js +23 -0
- package/runtime/dist/src/news/service.js +87 -31
- package/runtime/dist/src/news/sources.json +116 -0
- package/runtime/dist/src/notifications/adapters/space-relay.js +4 -0
- package/runtime/dist/src/notifications/content.js +41 -0
- package/runtime/dist/src/notifications/contracts.js +4 -2
- package/runtime/dist/src/notifications/feed.js +6 -2
- package/runtime/dist/src/notifications/service.js +27 -14
- package/runtime/dist/src/notifications/store.js +3 -1
- package/runtime/dist/src/personal-agent/app-context.js +39 -4
- package/runtime/dist/src/personal-agent/chat-failure.js +37 -0
- package/runtime/dist/src/personal-agent/computer-use/contract.js +42 -0
- package/runtime/dist/src/personal-agent/computer-use/session.js +280 -0
- package/runtime/dist/src/personal-agent/computer-use/skill.js +18 -0
- package/runtime/dist/src/personal-agent/computer-use/tools.js +15 -0
- package/runtime/dist/src/personal-agent/context-candidates.js +9 -13
- package/runtime/dist/src/personal-agent/context-dependencies.js +28 -0
- package/runtime/dist/src/personal-agent/contracts.js +24 -4
- package/runtime/dist/src/personal-agent/conversation-runtime.js +440 -42
- package/runtime/dist/src/personal-agent/conversation-tool-bridge.js +97 -0
- package/runtime/dist/src/personal-agent/conversation-tool-policy.js +22 -0
- package/runtime/dist/src/personal-agent/conversations.js +71 -15
- package/runtime/dist/src/personal-agent/daily-brief.js +5 -0
- package/runtime/dist/src/personal-agent/daily-workbench.js +558 -0
- package/runtime/dist/src/personal-agent/discovery-window.js +36 -0
- package/runtime/dist/src/personal-agent/goal-checkin.js +53 -0
- package/runtime/dist/src/personal-agent/host.js +2379 -223
- package/runtime/dist/src/personal-agent/identity-context.js +33 -0
- package/runtime/dist/src/personal-agent/life.js +129 -11
- package/runtime/dist/src/personal-agent/local-shell.js +181 -0
- package/runtime/dist/src/personal-agent/local-tools.js +234 -0
- package/runtime/dist/src/personal-agent/preferred-name-sync.js +35 -0
- package/runtime/dist/src/personal-agent/profile-warmup.js +100 -39
- package/runtime/dist/src/personal-agent/project-digests.js +7 -3
- package/runtime/dist/src/personal-agent/project-history.js +36 -0
- package/runtime/dist/src/personal-agent/reading-copies.js +183 -0
- package/runtime/dist/src/personal-agent/scheduled-tasks.js +50 -13
- package/runtime/dist/src/personal-agent/scheduled-tool-runtime.js +26 -10
- package/runtime/dist/src/personal-agent/source-processing-agent.js +239 -17
- package/runtime/dist/src/personal-agent/sources.js +9 -1
- package/runtime/dist/src/personal-agent/store.js +124 -14
- package/runtime/dist/src/personal-agent/task-loop.js +3 -0
- package/runtime/dist/src/personal-agent/tasks.js +16 -4
- package/runtime/dist/src/personal-agent/timeline-brief.js +462 -0
- package/runtime/dist/src/personal-agent/timeline-cache.js +191 -0
- package/runtime/dist/src/personal-agent/timeline-cluster.js +30 -0
- package/runtime/dist/src/personal-agent/timeline-inputs.js +47 -0
- package/runtime/dist/src/personal-agent/timeline-time.js +60 -0
- package/runtime/dist/src/personal-agent/understanding-products.js +49 -0
- package/runtime/dist/src/personal-agent/understanding.js +7 -22
- package/runtime/dist/src/personal-agent/workbench-context.js +17 -21
- package/runtime/dist/src/personal-agent/workbench-copy.js +124 -0
- package/runtime/dist/src/personal-agent/workbench-evidence.js +77 -0
- package/runtime/dist/src/personal-agent/workbench-instructions.js +21 -0
- package/runtime/dist/src/personal-agent/workbench-runtime.js +1006 -0
- package/runtime/dist/src/personal-agent/workbench-shell-class.js +304 -0
- package/runtime/dist/src/personal-agent/workbench-store.js +292 -0
- package/runtime/dist/src/personal-agent/workbench-temporal.js +66 -0
- package/runtime/dist/src/projects/project-native-resource.js +10 -8
- package/runtime/dist/src/projects/project-store.js +36 -4
- package/runtime/dist/src/realtime/bridge.js +77 -8
- package/runtime/dist/src/realtime/capabilities.js +19 -0
- package/runtime/dist/src/realtime/cascaded/adapter.js +180 -40
- package/runtime/dist/src/realtime/cascaded/ark-llm.js +150 -24
- package/runtime/dist/src/realtime/cascaded/chat-completions-llm.js +243 -83
- package/runtime/dist/src/realtime/cascaded/llm-stream-limits.js +18 -0
- package/runtime/dist/src/realtime/cascaded/llm.js +96 -0
- package/runtime/dist/src/realtime/cascaded/openai-compatible-speech.js +251 -0
- package/runtime/dist/src/realtime/cascaded/provider.js +8 -0
- package/runtime/dist/src/realtime/evidence.js +1 -1
- package/runtime/dist/src/realtime/frontend-instructions.js +76 -55
- package/runtime/dist/src/realtime/gemini.js +14 -3
- package/runtime/dist/src/realtime/host-delivery.js +37 -4
- package/runtime/dist/src/realtime/protocol.js +18 -3
- package/runtime/dist/src/realtime/provider-projection.js +4 -1
- package/runtime/dist/src/realtime/provider-session.js +73 -16
- package/runtime/dist/src/realtime/qwen-transport.js +35 -4
- package/runtime/dist/src/realtime/qwen.js +144 -9
- package/runtime/dist/src/realtime/service-state.js +0 -1
- package/runtime/dist/src/realtime/service.js +93 -7
- package/runtime/dist/src/realtime/session.js +39 -32
- package/runtime/dist/src/realtime/sglang-native.js +214 -0
- package/runtime/dist/src/realtime/system-prompts.en.js +14 -2
- package/runtime/dist/src/realtime/telemetry.js +6 -3
- package/runtime/dist/src/realtime/tool-continuations.js +84 -7
- package/runtime/dist/src/realtime/transport.js +17 -0
- package/runtime/dist/src/realtime/usage.js +33 -17
- package/runtime/dist/src/realtime/volcengine/ark.js +40 -15
- package/runtime/dist/src/realtime/volcengine/asr.js +2 -1
- package/runtime/dist/src/realtime/volcengine/silence-endpointing.js +1 -7
- package/runtime/dist/src/realtime/volcengine/tts.js +2 -1
- package/runtime/dist/src/server/aoq-chat-server.js +1 -1
- package/runtime/dist/src/server/client-server.js +21 -0
- package/runtime/dist/src/server-entry.js +3 -0
- package/runtime/dist/src/space-host/admin-socket.js +115 -0
- package/runtime/dist/src/space-host/audio-owner.js +44 -0
- package/runtime/dist/src/space-host/cli.js +195 -0
- package/runtime/dist/src/space-host/config.js +247 -0
- package/runtime/dist/src/space-host/context-input.js +12 -0
- package/runtime/dist/src/space-host/contracts.js +10 -0
- package/runtime/dist/src/space-host/host-admin.js +114 -0
- package/runtime/dist/src/space-host/key-delivery.js +28 -0
- package/runtime/dist/src/space-host/mobile-tools.js +9 -0
- package/runtime/dist/src/space-host/model-settings.js +213 -0
- package/runtime/dist/src/space-host/projection.js +37 -0
- package/runtime/dist/src/space-host/push.js +137 -0
- package/runtime/dist/src/space-host/relay-transport.js +55 -0
- package/runtime/dist/src/space-host/service.js +841 -0
- package/runtime/dist/src/space-host/voice-crypto.js +240 -0
- package/runtime/dist/src/space-host/voice.js +600 -0
- package/runtime/dist/src/space-host/windows-secret-key.js +82 -0
- package/runtime/dist/src/storage/private-database.js +7 -10
- package/runtime/dist/src/text/unicode-normalize.js +5 -1
- package/runtime/dist/src/understanding/candidates.js +8 -10
- package/runtime/dist/src/understanding/fixture.js +1 -1
- package/runtime/dist/src/understanding/pipeline.js +4 -4
- package/runtime/dist/src/usage/context.js +23 -0
- package/runtime/dist/src/usage/index.js +4 -0
- package/runtime/dist/src/usage/ledger-worker.js +90 -0
- package/runtime/dist/src/usage/ledger.js +74 -0
- package/runtime/dist/src/usage/model-call.js +63 -0
- package/runtime/dist/src/usage/pricing.js +68 -0
- package/runtime/dist/src/usage/summary.js +69 -0
- package/runtime/dist/src/voicemem/store-client.js +104 -21
- package/runtime/dist/src/voicemem/store-worker.js +5 -8
- package/runtime/dist/src/voicemem/versioned-memory.js +1 -1
- package/src/command.mjs +8 -1
- package/runtime/dist/src/executors/autoglm.js +0 -376
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { taskGrantService } from '../../personal-agent/tasks.js';
|
|
2
|
-
import { acquireTaskResources, taskResourcesBusy, quarantineTaskResources, taskResourcesUncertain } from '../task-resources.js';
|
|
2
|
+
import { acquireTaskResources, taskResourcesBusy, quarantineTaskResources, releaseQuarantinedTaskResources, taskResourcesUncertain, projectResourceKey } from '../task-resources.js';
|
|
3
3
|
import { managedMcpResources } from './managed-mcp.js';
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
import { compareCodePoints } from '../../text/canonical-json.js';
|
|
@@ -57,7 +57,7 @@ export class ProjectCodexAdapter {
|
|
|
57
57
|
#liveState = createCodexAdapterSharedState();
|
|
58
58
|
#status = new CodexLiveAdapter(NULL_TRANSPORT, undefined, { sharedState: this.#liveState });
|
|
59
59
|
#confirmedBindings = new WeakMap();
|
|
60
|
-
#retainedTransportCleanups = new
|
|
60
|
+
#retainedTransportCleanups = new Map();
|
|
61
61
|
#resourceKeys;
|
|
62
62
|
#slotWaiters = new Set();
|
|
63
63
|
taskResource() { return this.#resourceKeys?.length === 1 ? this.#resourceKeys[0] : null; }
|
|
@@ -119,7 +119,9 @@ export class ProjectCodexAdapter {
|
|
|
119
119
|
#projectCommitActive = false;
|
|
120
120
|
#closed = false;
|
|
121
121
|
#closePromise = null;
|
|
122
|
+
#defaultWorkspaceId;
|
|
122
123
|
constructor(options) {
|
|
124
|
+
this.#defaultWorkspaceId = options.defaultWorkspaceId;
|
|
123
125
|
this.manifest = options.codexApproval === undefined
|
|
124
126
|
? CODEX_PROJECT_MANIFEST
|
|
125
127
|
: CODEX_PROJECT_APPROVAL_MANIFEST;
|
|
@@ -231,6 +233,24 @@ export class ProjectCodexAdapter {
|
|
|
231
233
|
return this.#catalogRefresh;
|
|
232
234
|
}
|
|
233
235
|
targetPort = {
|
|
236
|
+
workspaces: {
|
|
237
|
+
// The host-approved default is imported; other imported executor projects are not Nova workspaces.
|
|
238
|
+
list: async () => (await this.#store.listWorkspaces())
|
|
239
|
+
.filter(item => item.origin === 'managed' || item.workspace_id === this.#defaultWorkspaceId)
|
|
240
|
+
.sort((a, b) => Number(b.workspace_id === this.#defaultWorkspaceId) - Number(a.workspace_id === this.#defaultWorkspaceId) || b.last_used_at - a.last_used_at)
|
|
241
|
+
.map(item => ({ workspace_id: item.workspace_id, name: item.display_name, is_default: item.workspace_id === this.#defaultWorkspaceId, last_used: item.last_used_at })),
|
|
242
|
+
create: async (name) => {
|
|
243
|
+
const item = await this.#store.createManaged(name, { uniqueName: true });
|
|
244
|
+
return { workspace_id: item.workspace_id, name: item.display_name, is_default: false, last_used: item.last_used_at };
|
|
245
|
+
},
|
|
246
|
+
resolve: async (id) => {
|
|
247
|
+
const selected = !id || id === 'default' ? this.#defaultWorkspaceId : id;
|
|
248
|
+
const item = (await this.#store.listWorkspaces()).find(item => item.workspace_id === selected);
|
|
249
|
+
if (!item || (item.origin !== 'managed' && selected !== this.#defaultWorkspaceId))
|
|
250
|
+
throw Error('unknown_workspace');
|
|
251
|
+
return hostWorkspacePath(await this.#store.revalidateWorkspace(item.workspace_id));
|
|
252
|
+
},
|
|
253
|
+
},
|
|
234
254
|
list: () => this.#listCodingTargets(),
|
|
235
255
|
forWork: async (workId) => {
|
|
236
256
|
const binding = this.#taskWorkspaces.get(workId);
|
|
@@ -598,16 +618,24 @@ export class ProjectCodexAdapter {
|
|
|
598
618
|
return failureHandoff('closed', 'run');
|
|
599
619
|
if (this.#resourceKeys === null)
|
|
600
620
|
return failureHandoff('computer_resource_unavailable', 'run');
|
|
621
|
+
// A failed close may own the resource quarantine. Retry it before waiting on that same lock.
|
|
622
|
+
try {
|
|
623
|
+
await this.#drainRetainedTransportCleanups();
|
|
624
|
+
}
|
|
625
|
+
catch {
|
|
626
|
+
return failureHandoff('transport_failure', 'run');
|
|
627
|
+
}
|
|
628
|
+
const resourceKeys = [...this.#resourceKeys, projectResourceKey(workspace.canonical_path)];
|
|
601
629
|
const busy = () => this.#slots.has(workspace.workspace_id) ? 'busy_project' : this.#slots.size >= MAX_CONCURRENT_WORK ? 'capacity' : null;
|
|
602
630
|
if (!context.resourceWaiting && busy()) {
|
|
603
631
|
const existing = this.#slots.get(workspace.workspace_id);
|
|
604
632
|
return existing ? refusedRunHandoff('busy_project', { project: workspace.display_name, work_id: existing.work.work_id, title: existing.work.title }) : refusedRunHandoff('capacity', { running: this.running().map(work => ({ ...work })) });
|
|
605
633
|
}
|
|
606
634
|
let release;
|
|
607
|
-
if (
|
|
608
|
-
if (taskResourcesBusy(
|
|
609
|
-
await context.resourceWaiting?.(taskResourcesUncertain(
|
|
610
|
-
release = await acquireTaskResources(
|
|
635
|
+
if (resourceKeys.length) {
|
|
636
|
+
if (taskResourcesBusy(resourceKeys))
|
|
637
|
+
await context.resourceWaiting?.(taskResourcesUncertain(resourceKeys) ? 'project_resource_uncertain' : 'project_resource_busy');
|
|
638
|
+
release = await acquireTaskResources(resourceKeys, context.signal);
|
|
611
639
|
}
|
|
612
640
|
try {
|
|
613
641
|
while (busy()) {
|
|
@@ -646,10 +674,13 @@ export class ProjectCodexAdapter {
|
|
|
646
674
|
context.signal.addEventListener('abort', onAbort, { once: true });
|
|
647
675
|
const slot = {
|
|
648
676
|
work: { work_id: context.delegate.delegate_id, project: workspace.display_name, title },
|
|
677
|
+
resourceKeys,
|
|
649
678
|
controller,
|
|
650
679
|
live: null,
|
|
651
680
|
task: null,
|
|
652
681
|
cancelled: false,
|
|
682
|
+
processStopped: true,
|
|
683
|
+
resourcesQuarantined: false,
|
|
653
684
|
};
|
|
654
685
|
this.#slots.set(workspace.workspace_id, slot);
|
|
655
686
|
if (this.#taskWorkspaces.size >= 64) {
|
|
@@ -662,8 +693,9 @@ export class ProjectCodexAdapter {
|
|
|
662
693
|
slot.task = task;
|
|
663
694
|
try {
|
|
664
695
|
const result = await task;
|
|
665
|
-
if (result.outcome === 'unknown' || this.#retainedTransportCleanups.size) {
|
|
666
|
-
quarantineTaskResources(
|
|
696
|
+
if ((result.outcome === 'unknown' && !slot.processStopped) || this.#retainedTransportCleanups.size) {
|
|
697
|
+
quarantineTaskResources(resourceKeys);
|
|
698
|
+
slot.resourcesQuarantined = true;
|
|
667
699
|
release = undefined;
|
|
668
700
|
}
|
|
669
701
|
return result;
|
|
@@ -671,8 +703,11 @@ export class ProjectCodexAdapter {
|
|
|
671
703
|
catch (error) {
|
|
672
704
|
if (error instanceof ProjectStateError)
|
|
673
705
|
return projectProblemHandoff(error.code);
|
|
674
|
-
|
|
675
|
-
|
|
706
|
+
if (!slot.processStopped || this.#retainedTransportCleanups.size) {
|
|
707
|
+
quarantineTaskResources(resourceKeys);
|
|
708
|
+
slot.resourcesQuarantined = true;
|
|
709
|
+
release = undefined;
|
|
710
|
+
}
|
|
676
711
|
throw error;
|
|
677
712
|
}
|
|
678
713
|
finally {
|
|
@@ -1036,6 +1071,7 @@ export class ProjectCodexAdapter {
|
|
|
1036
1071
|
resumeThreadId: resumed?.backend_session_id ?? null,
|
|
1037
1072
|
work: slot.work,
|
|
1038
1073
|
}));
|
|
1074
|
+
slot.processStopped = false;
|
|
1039
1075
|
}
|
|
1040
1076
|
catch (error) {
|
|
1041
1077
|
if (startRollback !== null) {
|
|
@@ -1104,11 +1140,14 @@ export class ProjectCodexAdapter {
|
|
|
1104
1140
|
slot.live = null;
|
|
1105
1141
|
try {
|
|
1106
1142
|
await active.close();
|
|
1143
|
+
// Every transport's close waits for the process tree to disappear (or throws). A verified
|
|
1144
|
+
// stop therefore releases the physical project/computer resources for both Codex and ACP.
|
|
1145
|
+
slot.processStopped = true;
|
|
1107
1146
|
}
|
|
1108
1147
|
catch {
|
|
1109
1148
|
// Completion evidence is already terminal. Retain cleanup ownership and fence the next
|
|
1110
1149
|
// process until the transport's retryable close path succeeds.
|
|
1111
|
-
this.#retainedTransportCleanups.
|
|
1150
|
+
this.#retainedTransportCleanups.set(transport, { slot, keys: slot.resourceKeys });
|
|
1112
1151
|
}
|
|
1113
1152
|
if (resumed === null) {
|
|
1114
1153
|
if (reportedThreadId !== null && !bindingMismatch) {
|
|
@@ -1205,9 +1244,16 @@ export class ProjectCodexAdapter {
|
|
|
1205
1244
|
}
|
|
1206
1245
|
async #drainRetainedTransportCleanups() {
|
|
1207
1246
|
let firstFailure = null;
|
|
1208
|
-
for (const transport of [...this.#retainedTransportCleanups]) {
|
|
1247
|
+
for (const [transport, cleanup] of [...this.#retainedTransportCleanups]) {
|
|
1209
1248
|
try {
|
|
1210
1249
|
await transport.close('shutdown');
|
|
1250
|
+
// close() proved the process tree is gone; release whatever this cleanup owns, regardless
|
|
1251
|
+
// of which backend produced the transport.
|
|
1252
|
+
cleanup.slot.processStopped = true;
|
|
1253
|
+
if (cleanup.slot.resourcesQuarantined) {
|
|
1254
|
+
cleanup.slot.resourcesQuarantined = false;
|
|
1255
|
+
releaseQuarantinedTaskResources(cleanup.keys);
|
|
1256
|
+
}
|
|
1211
1257
|
this.#retainedTransportCleanups.delete(transport);
|
|
1212
1258
|
}
|
|
1213
1259
|
catch (error) {
|
|
@@ -2,6 +2,7 @@ import { validateManagedMcpConfig } from './managed-mcp.js';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { CodexProtocolError } from './protocol.js';
|
|
4
4
|
import { snapshotJsonRecord } from './safe-json.js';
|
|
5
|
+
import { exactKeys, isPlainRecord } from '../../core/guards.js';
|
|
5
6
|
function method(file, fields, required, nullable = [], allowedTypes = {}) {
|
|
6
7
|
return deepFreeze({
|
|
7
8
|
file,
|
|
@@ -160,13 +161,13 @@ export function validateCodexSchemaBundle(bundle) {
|
|
|
160
161
|
throw new TypeError('variants');
|
|
161
162
|
const requests = new Map();
|
|
162
163
|
for (const candidate of variants) {
|
|
163
|
-
if (!
|
|
164
|
+
if (!isPlainRecord(candidate))
|
|
164
165
|
continue;
|
|
165
166
|
const properties = candidate.properties;
|
|
166
|
-
if (!
|
|
167
|
+
if (!isPlainRecord(properties))
|
|
167
168
|
continue;
|
|
168
169
|
const methodSchema = properties.method;
|
|
169
|
-
if (!
|
|
170
|
+
if (!isPlainRecord(methodSchema) || !Array.isArray(methodSchema.enum))
|
|
170
171
|
continue;
|
|
171
172
|
if (methodSchema.enum.length !== 1 || typeof methodSchema.enum[0] !== 'string')
|
|
172
173
|
continue;
|
|
@@ -302,7 +303,7 @@ function validateFileChangeItem(root) {
|
|
|
302
303
|
if (!Array.isArray(choices))
|
|
303
304
|
throw new TypeError('thread item choices');
|
|
304
305
|
const matches = choices.filter(candidate => {
|
|
305
|
-
if (!
|
|
306
|
+
if (!isPlainRecord(candidate) || !isPlainRecord(candidate.properties))
|
|
306
307
|
return false;
|
|
307
308
|
return enumValue(candidate.properties.type) === 'fileChange';
|
|
308
309
|
});
|
|
@@ -328,7 +329,7 @@ function validatePatchChangeKind(schema, root) {
|
|
|
328
329
|
throw new TypeError('patch choices');
|
|
329
330
|
for (const kind of ['add', 'delete', 'update']) {
|
|
330
331
|
const matches = choices.filter(candidate => {
|
|
331
|
-
if (!
|
|
332
|
+
if (!isPlainRecord(candidate) || !isPlainRecord(candidate.properties))
|
|
332
333
|
return false;
|
|
333
334
|
return enumValue(candidate.properties.type) === kind;
|
|
334
335
|
});
|
|
@@ -374,12 +375,12 @@ function validateDecisionResponse(root, definitionName, stringDecisions, objectD
|
|
|
374
375
|
requireExactEnum(foundObjects, objectDecisions);
|
|
375
376
|
}
|
|
376
377
|
function approvalMethod(candidate) {
|
|
377
|
-
if (!
|
|
378
|
+
if (!isPlainRecord(candidate) || !isPlainRecord(candidate.properties))
|
|
378
379
|
return null;
|
|
379
380
|
return enumValue(candidate.properties.method);
|
|
380
381
|
}
|
|
381
382
|
function enumValue(candidate) {
|
|
382
|
-
if (!
|
|
383
|
+
if (!isPlainRecord(candidate) || candidate.type !== 'string')
|
|
383
384
|
return null;
|
|
384
385
|
return Array.isArray(candidate.enum)
|
|
385
386
|
&& candidate.enum.length === 1
|
|
@@ -409,8 +410,8 @@ function requireNullableReference(candidate, reference) {
|
|
|
409
410
|
const choices = requireObject(candidate).anyOf;
|
|
410
411
|
if (!Array.isArray(choices) || choices.length !== 2)
|
|
411
412
|
throw new TypeError('nullable reference');
|
|
412
|
-
const references = choices.filter(choice =>
|
|
413
|
-
const nulls = choices.filter(choice =>
|
|
413
|
+
const references = choices.filter(choice => isPlainRecord(choice) && choice.$ref === reference);
|
|
414
|
+
const nulls = choices.filter(choice => isPlainRecord(choice) && choice.type === 'null');
|
|
414
415
|
if (references.length !== 1 || nulls.length !== 1)
|
|
415
416
|
throw new TypeError('nullable reference');
|
|
416
417
|
}
|
|
@@ -667,7 +668,7 @@ function truthy(value) {
|
|
|
667
668
|
return false;
|
|
668
669
|
if (Array.isArray(value))
|
|
669
670
|
return value.length > 0;
|
|
670
|
-
if (
|
|
671
|
+
if (isPlainRecord(value))
|
|
671
672
|
return Object.keys(value).length > 0;
|
|
672
673
|
return true;
|
|
673
674
|
}
|
|
@@ -682,26 +683,16 @@ function exactStringRecord(value, expected) {
|
|
|
682
683
|
return keys.length === expectedKeys.length
|
|
683
684
|
&& expectedKeys.every(key => Object.hasOwn(value, key) && value[key] === expected[key]);
|
|
684
685
|
}
|
|
685
|
-
function exactKeys(value, expected) {
|
|
686
|
-
const keys = Object.keys(value);
|
|
687
|
-
return keys.length === expected.length && expected.every(key => Object.hasOwn(value, key));
|
|
688
|
-
}
|
|
689
686
|
function requiredKeysWithNullExtras(value, required) {
|
|
690
687
|
const requiredSet = new Set(required);
|
|
691
688
|
return required.every(key => Object.hasOwn(value, key))
|
|
692
689
|
&& Object.entries(value).every(([key, field]) => requiredSet.has(key) || field === null);
|
|
693
690
|
}
|
|
694
691
|
function requireObject(value) {
|
|
695
|
-
if (!
|
|
692
|
+
if (!isPlainRecord(value))
|
|
696
693
|
throw new TypeError('object');
|
|
697
694
|
return value;
|
|
698
695
|
}
|
|
699
|
-
function isPlainObject(value) {
|
|
700
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
701
|
-
return false;
|
|
702
|
-
const prototype = Object.getPrototypeOf(value);
|
|
703
|
-
return prototype === Object.prototype || prototype === null;
|
|
704
|
-
}
|
|
705
696
|
function deepFreeze(value) {
|
|
706
697
|
if (typeof value !== 'object' || value === null || Object.isFrozen(value))
|
|
707
698
|
return value;
|
|
@@ -2,7 +2,7 @@ import { Readable, Writable } from 'node:stream';
|
|
|
2
2
|
import { managedMcpEnvironment, recordManagedMcpVisibility } from './managed-mcp.js';
|
|
3
3
|
import { generateSessionTitle } from './session-title.js';
|
|
4
4
|
import { sharedHomeOverrides } from './shared-home.js';
|
|
5
|
-
import { assertApiKeyProvider, assertApiKeyThread, NOVA_API_PROVIDER } from './spawn-env.js';
|
|
5
|
+
import { assertApiKeyProvider, assertApiKeyThread, NOVA_RESPONSES_PROXY_ENV, NOVA_API_PROVIDER } from './spawn-env.js';
|
|
6
6
|
import { RealClock, raceDeadline } from '../../core/clock.js';
|
|
7
7
|
import { isWellFormed, stripLikePython } from '../../text/python-text.js';
|
|
8
8
|
import { normalizeNfcPinned } from '../../text/unicode-normalize.js';
|
|
@@ -16,6 +16,7 @@ import { AppServerRequestRejected, CodexProtocolError, JsonRpcConnection, MAX_ST
|
|
|
16
16
|
import { snapshotJsonRecord } from './safe-json.js';
|
|
17
17
|
import { AppServerTurnProjection } from './turn-projection.js';
|
|
18
18
|
import { admitCodexVersion } from './version.js';
|
|
19
|
+
import { exactKeys, isPlainRecord } from '../../core/guards.js';
|
|
19
20
|
export const CODEX_PREFLIGHT_LIMIT_MS = 20_000;
|
|
20
21
|
export const CODEX_INTERRUPT_GRACE_MS = 2_000;
|
|
21
22
|
export const CODEX_TREE_GRACE_MS = 5_000;
|
|
@@ -28,6 +29,14 @@ export const CODEX_WORK_ORDER_LIMIT = 65_536;
|
|
|
28
29
|
export const CODEX_DEVELOPER_INSTRUCTIONS_LIMIT = 4000;
|
|
29
30
|
export const CODEX_THREAD_ID_LIMIT = 256;
|
|
30
31
|
export const CODEX_FINAL_TEXT_LIMIT = 4000;
|
|
32
|
+
export function approvedPlanWorkOrder(input) {
|
|
33
|
+
if (!input.approvedPlan)
|
|
34
|
+
return input.workOrder;
|
|
35
|
+
const plan = input.approvedPlan;
|
|
36
|
+
if (typeof plan.content !== 'string' || !plan.content || plan.content.length > 131072 || !Number.isSafeInteger(plan.version) || plan.version < 1)
|
|
37
|
+
throw Error('invalid_approved_plan');
|
|
38
|
+
return input.workOrder + '\n\nUser-confirmed complete plan (' + plan.id + ', version ' + plan.version + '):\n' + plan.content;
|
|
39
|
+
}
|
|
31
40
|
const REAL_SCHEDULER = {
|
|
32
41
|
clock: new RealClock(),
|
|
33
42
|
yieldIo: async () => { await new Promise(resolve => { setImmediate(resolve); }); },
|
|
@@ -45,6 +54,8 @@ export class CodexTransportError extends Error {
|
|
|
45
54
|
export class OwnedCodexAppServerTransport {
|
|
46
55
|
#config;
|
|
47
56
|
#processFactory;
|
|
57
|
+
#responsesProxy;
|
|
58
|
+
#usesLocalProvider = false;
|
|
48
59
|
#credentials;
|
|
49
60
|
#preflightRunner;
|
|
50
61
|
#schemaProbe;
|
|
@@ -164,6 +175,8 @@ export class OwnedCodexAppServerTransport {
|
|
|
164
175
|
try {
|
|
165
176
|
validateDeadline(deadline);
|
|
166
177
|
workOrder = validateBoundedText(input.workOrder, CODEX_WORK_ORDER_LIMIT, 'transport_lost');
|
|
178
|
+
if (input.approvedPlan)
|
|
179
|
+
workOrder = approvedPlanWorkOrder({ ...input, workOrder });
|
|
167
180
|
}
|
|
168
181
|
catch (error) {
|
|
169
182
|
return outcome('refused', safeTransportError(error, 'transport_lost').code, false, null);
|
|
@@ -206,7 +219,7 @@ export class OwnedCodexAppServerTransport {
|
|
|
206
219
|
launchProfile: this.#config.launchProfile,
|
|
207
220
|
});
|
|
208
221
|
if (this.#config.apiKey !== null)
|
|
209
|
-
assertApiKeyProvider(configResponse);
|
|
222
|
+
assertApiKeyProvider(configResponse, this.#responsesProxy);
|
|
210
223
|
await this.#openThread(session, deadline);
|
|
211
224
|
this.#connectionOnly = false;
|
|
212
225
|
}
|
|
@@ -287,7 +300,9 @@ export class OwnedCodexAppServerTransport {
|
|
|
287
300
|
if (this.#config.generateTitles && input.threadName !== undefined) {
|
|
288
301
|
const target = session;
|
|
289
302
|
const titleDeadline = { ...deadline, expiresAtMs: Math.min(deadline.expiresAtMs, Date.now() + 12_000) };
|
|
303
|
+
const selectedModel = snapshotJsonRecord(target.threadResponse).model;
|
|
290
304
|
titleWork = generateSessionTitle(workOrder, {
|
|
305
|
+
...(this.#usesLocalProvider ? { model: typeof selectedModel === 'string' ? selectedModel : null } : {}),
|
|
291
306
|
mcpServers: Object.keys(this.#config.managedMcp?.servers ?? {}),
|
|
292
307
|
signal: titleAbort.signal,
|
|
293
308
|
request: async (method, params) => {
|
|
@@ -295,7 +310,7 @@ export class OwnedCodexAppServerTransport {
|
|
|
295
310
|
return await this.#requestWithin(target, method, params, titleDeadline);
|
|
296
311
|
assertApiKeyProvider(await this.#requestWithin(target, 'config/read', {
|
|
297
312
|
includeLayers: true, cwd: hostWorkspacePath(this.#config.workspace),
|
|
298
|
-
}, titleDeadline));
|
|
313
|
+
}, titleDeadline), this.#responsesProxy);
|
|
299
314
|
const response = await this.#requestWithin(target, method, { ...params, modelProvider: NOVA_API_PROVIDER }, titleDeadline);
|
|
300
315
|
assertApiKeyThread(response);
|
|
301
316
|
return response;
|
|
@@ -580,6 +595,7 @@ export class OwnedCodexAppServerTransport {
|
|
|
580
595
|
if (certification !== undefined && certification.identity !== identity)
|
|
581
596
|
throw new CodexTransportError('unsupported_protocol');
|
|
582
597
|
const report = certification?.report ?? await this.#performPreflight(deadline);
|
|
598
|
+
this.#usesLocalProvider = snapshotJsonRecord(report.credential).policy === 'provider_config';
|
|
583
599
|
if (identity !== nativeCodexBinaryIdentity(this.#config.binary, this.#config.prefixArgs ?? []))
|
|
584
600
|
throw new CodexTransportError('unsupported_protocol');
|
|
585
601
|
if (this.#closed)
|
|
@@ -630,6 +646,7 @@ export class OwnedCodexAppServerTransport {
|
|
|
630
646
|
let owner;
|
|
631
647
|
try {
|
|
632
648
|
const environment = this.#credentials.environment(credentialSnapshot);
|
|
649
|
+
this.#responsesProxy = environment[NOVA_RESPONSES_PROXY_ENV];
|
|
633
650
|
if (identity !== nativeCodexBinaryIdentity(this.#config.binary, this.#config.prefixArgs ?? []))
|
|
634
651
|
throw new CodexTransportError('unsupported_protocol');
|
|
635
652
|
const spec = createCodexSpawnSpec({
|
|
@@ -639,6 +656,10 @@ export class OwnedCodexAppServerTransport {
|
|
|
639
656
|
codexHome: this.#config.codexHome,
|
|
640
657
|
environment,
|
|
641
658
|
preserveHome: this.#config.preserveHome,
|
|
659
|
+
// User provider configs may contain legacy fields accepted by the ordinary CLI.
|
|
660
|
+
// The effective permission/feature/MCP configuration is still validated below.
|
|
661
|
+
allowLegacyProviderConfig: this.#config.preserveHome === true && this.#config.apiKey === null
|
|
662
|
+
&& snapshotJsonRecord(report.credential).policy === 'provider_config',
|
|
642
663
|
sharedHomeOverrides: this.#sharedHomeOverrides ?? [],
|
|
643
664
|
...(this.#config.managedMcp === undefined ? {} : { managedMcp: this.#config.managedMcp }),
|
|
644
665
|
launchProfile: this.#config.launchProfile,
|
|
@@ -751,7 +772,7 @@ export class OwnedCodexAppServerTransport {
|
|
|
751
772
|
});
|
|
752
773
|
if (this.#config.apiKey !== null) {
|
|
753
774
|
try {
|
|
754
|
-
assertApiKeyProvider(configResponse);
|
|
775
|
+
assertApiKeyProvider(configResponse, this.#responsesProxy);
|
|
755
776
|
}
|
|
756
777
|
catch {
|
|
757
778
|
throw new CodexTransportError('config_not_isolated');
|
|
@@ -962,7 +983,10 @@ export class OwnedCodexAppServerTransport {
|
|
|
962
983
|
|| !Number.isSafeInteger(byteLength)
|
|
963
984
|
|| byteLength < 0
|
|
964
985
|
|| stdoutBytes + byteLength > MAX_STDOUT) {
|
|
965
|
-
finishStdout(new CodexTransportError('transport_lost'
|
|
986
|
+
finishStdout(new CodexTransportError('transport_lost', {
|
|
987
|
+
method: 'app-server/stdout', server_code: null,
|
|
988
|
+
message: `stdout_byte_limit_or_invalid_chunk; received_bytes=${stdoutBytes}; incoming_bytes=${typeof byteLength === 'number' ? byteLength : 'invalid'}; limit_bytes=${MAX_STDOUT}`,
|
|
989
|
+
}));
|
|
966
990
|
return;
|
|
967
991
|
}
|
|
968
992
|
let copy;
|
|
@@ -982,10 +1006,10 @@ export class OwnedCodexAppServerTransport {
|
|
|
982
1006
|
}, error => { finishStdout(mapProtocolFailure(error)); });
|
|
983
1007
|
};
|
|
984
1008
|
const onStdoutEnd = () => { finishStdout(null); };
|
|
985
|
-
const onStdoutError = () => { finishStdout(new CodexTransportError('transport_lost')); };
|
|
1009
|
+
const onStdoutError = () => { finishStdout(new CodexTransportError('transport_lost', { method: 'app-server/stdout', server_code: null, message: 'stdout_stream_error' })); };
|
|
986
1010
|
const onStdoutClose = () => {
|
|
987
1011
|
if (!stdoutTerminal)
|
|
988
|
-
finishStdout(new CodexTransportError('transport_lost'));
|
|
1012
|
+
finishStdout(new CodexTransportError('transport_lost', { method: 'app-server/stdout', server_code: null, message: 'stdout_closed_before_end' }));
|
|
989
1013
|
};
|
|
990
1014
|
const onStderrData = (chunk) => {
|
|
991
1015
|
stderrBytes += chunk.byteLength;
|
|
@@ -1663,7 +1687,7 @@ function mapProtocolFailure(error) {
|
|
|
1663
1687
|
if (!(error instanceof CodexProtocolError))
|
|
1664
1688
|
return new CodexTransportError('transport_lost');
|
|
1665
1689
|
if (error.code === 'stdout_too_large' || error.code === 'stdout_line_too_large') {
|
|
1666
|
-
return new CodexTransportError('transport_lost');
|
|
1690
|
+
return new CodexTransportError('transport_lost', { method: 'app-server/stdout', server_code: null, message: error.code });
|
|
1667
1691
|
}
|
|
1668
1692
|
if (error.code === 'config_not_isolated')
|
|
1669
1693
|
return new CodexTransportError('config_not_isolated');
|
|
@@ -1769,16 +1793,6 @@ async function settleCleanupValue(operation, milliseconds, fallback) {
|
|
|
1769
1793
|
clearTimeout(timer);
|
|
1770
1794
|
}
|
|
1771
1795
|
}
|
|
1772
|
-
function exactKeys(value, expected) {
|
|
1773
|
-
const keys = Object.keys(value);
|
|
1774
|
-
return keys.length === expected.length && expected.every(key => Object.hasOwn(value, key));
|
|
1775
|
-
}
|
|
1776
|
-
function isPlainRecord(value) {
|
|
1777
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
1778
|
-
return false;
|
|
1779
|
-
const prototype = Object.getPrototypeOf(value);
|
|
1780
|
-
return prototype === Object.prototype || prototype === null;
|
|
1781
|
-
}
|
|
1782
1796
|
function requireOwnedProcessContract(owner) {
|
|
1783
1797
|
if (typeof owner !== 'object'
|
|
1784
1798
|
|| owner === null
|
|
@@ -203,7 +203,7 @@ export class CodexAdapterCore {
|
|
|
203
203
|
}
|
|
204
204
|
let rawOutcome;
|
|
205
205
|
try {
|
|
206
|
-
rawOutcome = await awaitCodexPhase(() => this.#transport.run({ workOrder }, observer, context.beforeWrite ? { ...deadline.transport, beforeWrite: context.beforeWrite } : deadline.transport, null), deadline, false);
|
|
206
|
+
rawOutcome = await awaitCodexPhase(() => this.#transport.run({ workOrder, ...(context.approvedPlan ? { approvedPlan: context.approvedPlan } : {}) }, observer, context.beforeWrite ? { ...deadline.transport, beforeWrite: context.beforeWrite } : deadline.transport, null), deadline, false);
|
|
207
207
|
}
|
|
208
208
|
catch (error) {
|
|
209
209
|
if ((error instanceof AdapterDeadlineError || error instanceof AdapterAbortError)
|
|
@@ -6,6 +6,7 @@ import { hasOtherCategory as hasPinnedOtherCategory } from '../../text/unicode-t
|
|
|
6
6
|
import { normalizeNfcPinned } from '../../text/unicode-normalize.js';
|
|
7
7
|
import { isPythonSpace, isWellFormed, stripLikePython } from '../../text/python-text.js';
|
|
8
8
|
import { executorManifestSchema } from '../../core/ports.js';
|
|
9
|
+
import { isPlainRecord } from '../../core/guards.js';
|
|
9
10
|
export const CODEX_STARTUP_DEADLINE = 540;
|
|
10
11
|
export const MAX_CODEX_EVENTS = 16_384;
|
|
11
12
|
export const MAX_CODEX_EVIDENCE_COUNTER = 1_048_576;
|
|
@@ -314,7 +315,7 @@ export function sanitizeCodexPreflightReport(value) {
|
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
317
|
function sanitizeCodexPreflightReportChecked(value) {
|
|
317
|
-
if (!
|
|
318
|
+
if (!isPlainRecord(value))
|
|
318
319
|
return null;
|
|
319
320
|
// An ACP handshake has its own exact shape and never borrows the sandbox fields below.
|
|
320
321
|
if (Object.hasOwn(value, 'protocol'))
|
|
@@ -340,7 +341,7 @@ function sanitizeCodexPreflightReportChecked(value) {
|
|
|
340
341
|
result[name] = expected;
|
|
341
342
|
}
|
|
342
343
|
if (Object.hasOwn(value, 'credential')) {
|
|
343
|
-
if (!
|
|
344
|
+
if (!isPlainRecord(value.credential))
|
|
344
345
|
return null;
|
|
345
346
|
const credential = {};
|
|
346
347
|
if (Object.hasOwn(value.credential, 'present')) {
|
|
@@ -356,7 +357,8 @@ function sanitizeCodexPreflightReportChecked(value) {
|
|
|
356
357
|
credential.identity = value.credential.identity;
|
|
357
358
|
}
|
|
358
359
|
if (Object.hasOwn(value.credential, 'policy')) {
|
|
359
|
-
if (value.credential.policy !== 'saved_login' && value.credential.policy !== 'process_only'
|
|
360
|
+
if (value.credential.policy !== 'saved_login' && value.credential.policy !== 'process_only'
|
|
361
|
+
&& value.credential.policy !== 'provider_config') {
|
|
360
362
|
return null;
|
|
361
363
|
}
|
|
362
364
|
credential.policy = value.credential.policy;
|
|
@@ -364,7 +366,7 @@ function sanitizeCodexPreflightReportChecked(value) {
|
|
|
364
366
|
result.credential = credential;
|
|
365
367
|
}
|
|
366
368
|
if (Object.hasOwn(value, 'limits')) {
|
|
367
|
-
if (!
|
|
369
|
+
if (!isPlainRecord(value.limits))
|
|
368
370
|
return null;
|
|
369
371
|
const limits = {};
|
|
370
372
|
for (const [name, classification] of Object.entries(value.limits)) {
|
|
@@ -388,7 +390,7 @@ export function sanitizeCodexEvidence(value) {
|
|
|
388
390
|
}
|
|
389
391
|
}
|
|
390
392
|
function sanitizeCodexEvidenceChecked(value) {
|
|
391
|
-
if (!
|
|
393
|
+
if (!isPlainRecord(value))
|
|
392
394
|
return null;
|
|
393
395
|
const keys = Object.keys(value);
|
|
394
396
|
if (!sameKeySet(keys, ['events', 'protocol', 'process'])
|
|
@@ -415,7 +417,7 @@ function sanitizeEvents(value) {
|
|
|
415
417
|
const result = [];
|
|
416
418
|
let activitySeen = false;
|
|
417
419
|
for (const event of value) {
|
|
418
|
-
if (!
|
|
420
|
+
if (!isPlainRecord(event) || typeof event.type !== 'string')
|
|
419
421
|
return null;
|
|
420
422
|
if (event.type === 'internal_activity') {
|
|
421
423
|
if (activitySeen
|
|
@@ -434,7 +436,7 @@ function sanitizeEvents(value) {
|
|
|
434
436
|
return result;
|
|
435
437
|
}
|
|
436
438
|
function sanitizeProtocol(value) {
|
|
437
|
-
if (!
|
|
439
|
+
if (!isPlainRecord(value) || !sameKeySet(Object.keys(value), [
|
|
438
440
|
'thread_started', 'turn_started', 'terminal', 'transport_closed', 'unknown_event_count',
|
|
439
441
|
]))
|
|
440
442
|
return null;
|
|
@@ -455,7 +457,7 @@ function sanitizeProtocol(value) {
|
|
|
455
457
|
};
|
|
456
458
|
}
|
|
457
459
|
function sanitizeProcess(value) {
|
|
458
|
-
if (!
|
|
460
|
+
if (!isPlainRecord(value) || !sameKeySet(Object.keys(value), ['started', 'exit_code', 'stop'])) {
|
|
459
461
|
return null;
|
|
460
462
|
}
|
|
461
463
|
if (value.started !== true)
|
|
@@ -467,10 +469,10 @@ function sanitizeProcess(value) {
|
|
|
467
469
|
return { started: true, exit_code: value.exit_code, stop: value.stop };
|
|
468
470
|
}
|
|
469
471
|
function sanitizeResult(value) {
|
|
470
|
-
if (!
|
|
472
|
+
if (!isPlainRecord(value) || !sameKeySet(Object.keys(value), ['final_message']))
|
|
471
473
|
return null;
|
|
472
474
|
const message = value.final_message;
|
|
473
|
-
if (!
|
|
475
|
+
if (!isPlainRecord(message) || !sameKeySet(Object.keys(message), [
|
|
474
476
|
'text', 'original_chars', 'truncated', 'sha256',
|
|
475
477
|
]))
|
|
476
478
|
return null;
|
|
@@ -561,12 +563,6 @@ function defineJsonProperty(target, key, value) {
|
|
|
561
563
|
writable: true,
|
|
562
564
|
});
|
|
563
565
|
}
|
|
564
|
-
function isPlainObject(value) {
|
|
565
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
566
|
-
return false;
|
|
567
|
-
const prototype = Object.getPrototypeOf(value);
|
|
568
|
-
return prototype === Object.prototype || prototype === null;
|
|
569
|
-
}
|
|
570
566
|
function deepFreeze(value) {
|
|
571
567
|
if (typeof value !== 'object' || value === null || Object.isFrozen(value))
|
|
572
568
|
return value;
|
|
@@ -6,6 +6,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
6
6
|
import { basename, dirname, join } from 'node:path';
|
|
7
7
|
import { hostCodexHomeValue, refreshEphemeralCodexHomeIdentity } from './process-owner.js';
|
|
8
8
|
import { CodexCredentialError, createCodexEnvironment, snapshotEnvironmentInput } from './spawn-env.js';
|
|
9
|
+
import { isErrno, isPlainRecord } from '../../core/guards.js';
|
|
9
10
|
export { CodexCredentialError, environmentValue } from './spawn-env.js';
|
|
10
11
|
const credentialSnapshotBrand = Symbol('CredentialSnapshot');
|
|
11
12
|
const snapshotValues = new WeakMap();
|
|
@@ -183,13 +184,4 @@ function requireString(value) {
|
|
|
183
184
|
function ownerMatches(uid) {
|
|
184
185
|
return typeof process.getuid !== 'function' || uid === process.getuid();
|
|
185
186
|
}
|
|
186
|
-
function isPlainRecord(value) {
|
|
187
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
188
|
-
return false;
|
|
189
|
-
const prototype = Object.getPrototypeOf(value);
|
|
190
|
-
return prototype === Object.prototype || prototype === null;
|
|
191
|
-
}
|
|
192
|
-
function isErrno(error, code) {
|
|
193
|
-
return typeof error === 'object' && error !== null && Reflect.get(error, 'code') === code;
|
|
194
|
-
}
|
|
195
187
|
//# sourceMappingURL=credential-snapshot.js.map
|