@qlairoslabs/acp-client 0.13.0-alpha.1 → 0.13.2-alpha.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/CONSUMER_GUIDE.md +181 -8
- package/MIGRATION-0.12-to-0.13.md +20 -7
- package/package.json +13 -2
- package/src/agent/config.ts +2 -0
- package/src/agent/conversation-manager.ts +1 -0
- package/src/agent/native-operations.ts +40 -0
- package/src/agent-session-config.ts +2 -0
- package/src/agent-session.ts +12 -2
- package/src/agent.ts +100 -2
- package/src/client.ts +5 -3
- package/src/controller-connection.ts +1 -0
- package/src/controller.ts +2 -0
- package/src/index.ts +3 -0
- package/src/launcher.ts +2 -0
- package/src/native/approvals.ts +20 -3
- package/src/native/capabilities.ts +2 -2
- package/src/native/connection.ts +1 -1
- package/src/native/controller.ts +5 -3
- package/src/native/host-config.ts +2 -0
- package/src/native/host.ts +83 -4
- package/src/native/mcp.ts +47 -0
- package/src/native/recovery.ts +8 -7
- package/src/native/reminders/routine-guard.ts +4 -3
- package/src/native/reminders/routine-wire.ts +1 -1
- package/src/native-harness/README.md +58 -1
- package/src/native-harness/package.json +4 -0
- package/src/native-harness/scripts/build-routine-zones.py +47 -0
- package/src/native-harness/src/capabilities/attachments/admission.ts +42 -0
- package/src/native-harness/src/capabilities/attachments/image-validation.ts +98 -0
- package/src/native-harness/src/capabilities/attachments/input.ts +1 -0
- package/src/native-harness/src/capabilities/attachments/read.ts +76 -0
- package/src/native-harness/src/capabilities/attachments/recovery.ts +26 -0
- package/src/native-harness/src/capabilities/attachments/selection.ts +37 -0
- package/src/native-harness/src/capabilities/attachments/service.ts +75 -0
- package/src/native-harness/src/capabilities/attachments/upload.ts +164 -0
- package/src/native-harness/src/capabilities/attachments/vision.ts +45 -0
- package/src/native-harness/src/capabilities/context/build.ts +5 -0
- package/src/native-harness/src/capabilities/context/session.ts +2 -1
- package/src/native-harness/src/capabilities/model/openrouter-stream.ts +80 -17
- package/src/native-harness/src/capabilities/model/runner.ts +6 -3
- package/src/native-harness/src/capabilities/reminders/cron-calendar.ts +50 -0
- package/src/native-harness/src/capabilities/reminders/cron-fields.ts +46 -0
- package/src/native-harness/src/capabilities/reminders/cron-proof.ts +32 -0
- package/src/native-harness/src/capabilities/reminders/cron-zone.ts +53 -0
- package/src/native-harness/src/capabilities/reminders/iana-zones.json.gz +0 -0
- package/src/native-harness/src/capabilities/reminders/iana-zones.ts +34 -0
- package/src/native-harness/src/capabilities/reminders/interval.ts +30 -0
- package/src/native-harness/src/capabilities/reminders/routine-advance.ts +47 -0
- package/src/native-harness/src/capabilities/reminders/routine-backlog.ts +47 -0
- package/src/native-harness/src/capabilities/reminders/routine-expiry.ts +15 -0
- package/src/native-harness/src/capabilities/reminders/routine-occurrence.ts +65 -0
- package/src/native-harness/src/capabilities/reminders/routine-schedule.ts +70 -0
- package/src/native-harness/src/capabilities/reminders/unattended.ts +8 -0
- package/src/native-harness/src/capabilities/tools/mcp/client.ts +97 -0
- package/src/native-harness/src/capabilities/tools/mcp/http.ts +183 -0
- package/src/native-harness/src/capabilities/tools/mcp/registry.ts +62 -0
- package/src/native-harness/src/capabilities/tools/mcp/result.ts +33 -0
- package/src/native-harness/src/capabilities/tools/mcp/schema.ts +77 -0
- package/src/native-harness/src/capabilities/tools/mcp/secrets.ts +28 -0
- package/src/native-harness/src/capabilities/tools/mcp/stdio.ts +105 -0
- package/src/native-harness/src/capabilities/tools/reminders/index.ts +27 -5
- package/src/native-harness/src/capabilities/tools/runtime/invocations.ts +4 -1
- package/src/native-harness/src/capabilities/tools/web/config.ts +1 -0
- package/src/native-harness/src/capabilities/tools/web/definitions.ts +18 -0
- package/src/native-harness/src/capabilities/tools/web/direct-address.ts +56 -0
- package/src/native-harness/src/capabilities/tools/web/direct-transport.ts +235 -0
- package/src/native-harness/src/capabilities/tools/web/direct.ts +149 -0
- package/src/native-harness/src/capabilities/tools/web/exa-transport.ts +41 -0
- package/src/native-harness/src/capabilities/tools/web/exa.ts +71 -0
- package/src/native-harness/src/capabilities/tools/web/preview.ts +44 -0
- package/src/native-harness/src/capabilities/tools/web/registry.ts +47 -0
- package/src/native-harness/src/capabilities/tools/web/usage.ts +1 -0
- package/src/native-harness/src/contracts/agent.ts +3 -1
- package/src/native-harness/src/contracts/attachments.ts +62 -0
- package/src/native-harness/src/contracts/config-permissions.ts +14 -3
- package/src/native-harness/src/contracts/context.ts +1 -1
- package/src/native-harness/src/contracts/events.ts +2 -2
- package/src/native-harness/src/contracts/loop.ts +3 -3
- package/src/native-harness/src/contracts/mcp.ts +22 -0
- package/src/native-harness/src/contracts/model-execution.ts +2 -1
- package/src/native-harness/src/contracts/operator-controls.ts +8 -1
- package/src/native-harness/src/contracts/protocol.ts +21 -5
- package/src/native-harness/src/contracts/reminders.ts +4 -2
- package/src/native-harness/src/contracts/routines.ts +20 -0
- package/src/native-harness/src/contracts/session-file.ts +2 -0
- package/src/native-harness/src/contracts/session.ts +8 -3
- package/src/native-harness/src/contracts/storage.ts +32 -13
- package/src/native-harness/src/contracts/tools.ts +2 -0
- package/src/native-harness/src/contracts/web.ts +16 -0
- package/src/native-harness/src/governance/permissions/gate.ts +9 -2
- package/src/native-harness/src/governance/policy/resolve.ts +6 -1
- package/src/native-harness/src/index.ts +48 -12
- package/src/native-harness/src/interfaces/cli/development.ts +108 -53
- package/src/native-harness/src/interfaces/cli/serve.ts +2 -2
- package/src/native-harness/src/interfaces/cli/start.ts +22 -13
- package/src/native-harness/src/interfaces/client.ts +8 -2
- package/src/native-harness/src/interfaces/inspector/index.html +7 -1
- package/src/native-harness/src/interfaces/inspector/state.ts +6 -2
- package/src/native-harness/src/interfaces/protocol/load.ts +3 -1
- package/src/native-harness/src/interfaces/protocol/local.ts +13 -4
- package/src/native-harness/src/interfaces/protocol/operator.ts +8 -2
- package/src/native-harness/src/interfaces/protocol/server.ts +102 -36
- package/src/native-harness/src/interfaces/protocol/stdio-client.ts +8 -0
- package/src/native-harness/src/interfaces/web-chat/index.html +65 -12
- package/src/native-harness/src/interfaces/web-chat/server.ts +30 -3
- package/src/native-harness/src/kernel/channels.ts +27 -15
- package/src/native-harness/src/kernel/loop.ts +1 -1
- package/src/native-harness/src/runtime/config/inference-key.ts +7 -0
- package/src/native-harness/src/runtime/config/managed.ts +1 -1
- package/src/native-harness/src/runtime/config/paths.ts +8 -1
- package/src/native-harness/src/runtime/execution/mcp-stdio.ts +31 -0
- package/src/native-harness/src/runtime/reminder-validation.ts +31 -10
- package/src/native-harness/src/runtime/reminders.ts +2 -2
- package/src/native-harness/src/state/storage/archive.ts +113 -12
- package/src/native-harness/src/state/storage/attachment-files.ts +58 -0
- package/src/native-harness/src/state/storage/attachment-import.ts +106 -0
- package/src/native-harness/src/state/storage/attachment-tables.ts +123 -0
- package/src/native-harness/src/state/storage/engine.ts +396 -45
- package/src/native-harness/src/state/storage/inference.ts +30 -2
- package/src/native-harness/src/state/storage/memory-attachments.ts +56 -0
- package/src/native-harness/src/state/storage/memory-reminders.ts +31 -6
- package/src/native-harness/src/state/storage/memory.ts +32 -4
- package/src/native-harness/src/state/storage/reminder-archive.ts +53 -12
- package/src/native-harness/src/state/storage/reminder-change.ts +60 -14
- package/src/native-harness/src/state/storage/reminder-tables.ts +11 -3
- package/src/native-harness/src/state/storage/routine-row.ts +25 -0
- package/src/native-harness/src/state/storage/session-file.ts +22 -9
- package/src/native-harness/src/state/storage/sqlite-reminders.ts +48 -8
- package/src/native-harness/src/state/storage/sqlite.ts +59 -11
- package/src/native-harness/src/state/storage/web-tables.ts +47 -0
- package/src/native-harness/src/testing.ts +151 -56
- package/src/native-harness/src/util/attachment-input.ts +42 -0
- package/src/native-harness/src/util/config.ts +64 -9
- package/src/native-harness/src/util/intake.ts +7 -0
- package/src/native-harness/src/util/mcp-config.ts +102 -0
- package/src/native-harness/src/util/web-config.ts +34 -0
- package/src/native-harness/src/util/web-usage.ts +33 -0
- package/src/orchestrator/permissions.ts +6 -3
- package/src/permissions/conversation.ts +13 -5
- package/src/permissions/matcher.ts +2 -0
- package/src/permissions/outcome.ts +12 -1
- package/src/permissions/policy.ts +13 -8
- package/src/steering/combine.ts +1 -0
- package/src/steering/contracts.ts +3 -0
- package/src/terminals.ts +9 -6
- package/src/native/reminders/reminders.test.ts +0 -553
- package/src/native/reminders/routine-config.typecheck.ts +0 -13
- package/src/native/reminders/wire.typecheck.ts +0 -13
- package/src/native-harness/.res/README.md +0 -1
- package/src/native-harness/.res/architecture/README.md +0 -21
- package/src/native-harness/.res/architecture/context-and-data.md +0 -31
- package/src/native-harness/.res/architecture/execution.md +0 -42
- package/src/native-harness/.res/architecture/overview.md +0 -44
- package/src/native-harness/.res/architecture/persistence.md +0 -56
- package/src/native-harness/.res/architecture/suspend-and-resume.md +0 -45
- package/src/native-harness/.res/architecture/technical-architecture.md +0 -50
- package/src/native-harness/.res/decisions/0001-basic-loop.md +0 -11
- package/src/native-harness/.res/decisions/0002-channel-input.md +0 -17
- package/src/native-harness/.res/decisions/0003-inference-inspection.md +0 -14
- package/src/native-harness/.res/decisions/0004-shared-context.md +0 -21
- package/src/native-harness/.res/decisions/0005-notice-inbox.md +0 -20
- package/src/native-harness/.res/decisions/0006-explicit-notices.md +0 -12
- package/src/native-harness/.res/decisions/0007-channel-output.md +0 -12
- package/src/native-harness/.res/decisions/0008-browser-client.md +0 -16
- package/src/native-harness/.res/decisions/0009-scripted-model.md +0 -18
- package/src/native-harness/.res/decisions/0010-inprocess-protocol.md +0 -19
- package/src/native-harness/.res/decisions/0011-stdio-transport.md +0 -21
- package/src/native-harness/.res/decisions/0012-session-storage-contract.md +0 -37
- package/src/native-harness/.res/decisions/0013-durable-delivery-contract.md +0 -64
- package/src/native-harness/.res/decisions/0014-channel-controls-contract.md +0 -73
- package/src/native-harness/.res/decisions/0015-session-file-contract.md +0 -72
- package/src/native-harness/.res/decisions/0016-configuration-permissions.md +0 -159
- package/src/native-harness/.res/decisions/0017-openrouter-managed-config.md +0 -69
- package/src/native-harness/.res/decisions/0018-tool-dispatch-evidence.md +0 -78
- package/src/native-harness/.res/decisions/0019-model-execution.md +0 -188
- package/src/native-harness/.res/decisions/0020-startup-channel-changes.md +0 -71
- package/src/native-harness/.res/decisions/0021-tools-and-host-callbacks.md +0 -100
- package/src/native-harness/.res/decisions/0022-operator-controls.md +0 -115
- package/src/native-harness/.res/decisions/0023-long-running-mock.md +0 -82
- package/src/native-harness/.res/decisions/0024-callback-policy-names.md +0 -46
- package/src/native-harness/.res/decisions/0025-external-notices.md +0 -364
- package/src/native-harness/.res/decisions/0026-bounded-context.md +0 -81
- package/src/native-harness/.res/decisions/0027-development-instructions.md +0 -22
- package/src/native-harness/.res/decisions/0028-debug-tools.md +0 -16
- package/src/native-harness/.res/decisions/0029-bounded-model-call-pages.md +0 -37
- package/src/native-harness/.res/decisions/0030-timeline-retrieval.md +0 -145
- package/src/native-harness/.res/decisions/0031-one-off-reminders.md +0 -173
- package/src/native-harness/.res/docs/11-15.md +0 -148
- package/src/native-harness/.res/docs/BUSINESS_RULES.md +0 -111
- package/src/native-harness/.res/docs/WORK.md +0 -65
- package/src/native-harness/.res/docs/_/11-16-persistence/LOG.md +0 -312
- package/src/native-harness/.res/docs/_/11-16-persistence/PLAN.md +0 -77
- package/src/native-harness/.res/docs/_/11-16-persistence/SPEC.md +0 -313
- package/src/native-harness/.res/docs/_/11-19-channel-controls/LOG.md +0 -160
- package/src/native-harness/.res/docs/_/11-19-channel-controls/PLAN.md +0 -89
- package/src/native-harness/.res/docs/_/11-19-channel-controls/SPEC.md +0 -135
- package/src/native-harness/.res/docs/_/11-19-config-permissions/LOG.md +0 -143
- package/src/native-harness/.res/docs/_/11-19-config-permissions/PLAN.md +0 -93
- package/src/native-harness/.res/docs/_/11-19-config-permissions/SPEC.md +0 -181
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/11-20-LOG.md +0 -433
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PLAN.md +0 -60
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PROTOCOL.md +0 -141
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/SPEC.md +0 -168
- package/src/native-harness/.res/docs/attachments/0001-DESIGN/SPEC.md +0 -111
- package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/PLAN.md +0 -129
- package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/SPEC.md +0 -135
- package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/LOG.md +0 -437
- package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/PLAN.md +0 -127
- package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/SPEC.md +0 -203
- package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/LOG.md +0 -292
- package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/PLAN.md +0 -91
- package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/SPEC.md +0 -187
- package/src/native-harness/.res/docs/model-execution/0001-DESIGN/LOG.md +0 -148
- package/src/native-harness/.res/docs/model-execution/0001-DESIGN/PLAN.md +0 -95
- package/src/native-harness/.res/docs/model-execution/0001-DESIGN/SPEC.md +0 -200
- package/src/native-harness/.res/docs/model-execution/0002-AMENDMENT-accounting/SPEC.md +0 -80
- package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/LOG.md +0 -206
- package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/PLAN.md +0 -106
- package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/SPEC.md +0 -297
- package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/LOG.md +0 -41
- package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/PLAN.md +0 -36
- package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/SPEC.md +0 -84
- package/src/native-harness/.res/docs/shell-execution/0001-DESIGN/SPEC.md +0 -147
- package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/LOG.md +0 -15
- package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/PLAN.md +0 -107
- package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/SPEC.md +0 -114
- package/src/native-harness/.res/docs/todos/11-19-TODO-auto_review-approve.md +0 -24
- package/src/native-harness/.res/docs/todos/11-20-TODO-user-entered-tool-code.md +0 -23
- package/src/native-harness/.res/docs/todos/11-21-TODO-node-resource-coordination.md +0 -103
- package/src/native-harness/.res/docs/todos/11-22-TODO-harness-m1-sequence.md +0 -50
- package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/LOG.md +0 -337
- package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/PLAN.md +0 -76
- package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/SPEC.md +0 -204
- package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/LOG.md +0 -73
- package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md +0 -64
- package/src/native-harness/.res/docs/tools-and-callbacks/0003-DESIGN-attachment-tools/SPEC.md +0 -58
- package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/LOG.md +0 -45
- package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/PLAN.md +0 -108
- package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/SPEC.md +0 -169
- package/src/native-harness/.res/docs/web-tools/0001-DESIGN/SPEC.md +0 -128
- package/src/native-harness/.res/marketing-draft.md +0 -22
- package/src/native-harness/.res/sandbox/1-simple-harness/README.md +0 -285
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-1.md +0 -19
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-10.md +0 -138
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-11.md +0 -148
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-12.md +0 -172
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-13.md +0 -194
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-14.md +0 -233
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-15.md +0 -249
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-16.md +0 -265
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-17.md +0 -279
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-18.md +0 -293
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-19.md +0 -307
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-2.md +0 -29
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-20.md +0 -317
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-21.md +0 -327
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-3.md +0 -40
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-4.md +0 -59
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-5.md +0 -69
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-6.md +0 -79
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-7.md +0 -89
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-8.md +0 -102
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-9.md +0 -116
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation.jsonl +0 -49
- package/src/native-harness/.res/sandbox/1-simple-harness/doc.md +0 -87
- package/src/native-harness/.res/sandbox/1-simple-harness/harness.py +0 -289
- package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 2.py +0 -221
- package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 3.py +0 -287
- package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy.py +0 -165
- package/src/native-harness/.res/sandbox/1-simple-harness/state.json +0 -22
- package/src/native-harness/.res/sandbox/1-simple-harness/system-prompt.md +0 -2
- package/src/native-harness/AGENTS.md +0 -70
- package/src/native-harness/ARCHITECTURE.md +0 -249
- package/src/native-harness/bun.lock +0 -26
- package/src/native-harness/test/agent.test.ts +0 -130
- package/src/native-harness/test/approval-gate.test.ts +0 -255
- package/src/native-harness/test/approval-protocol.test.ts +0 -94
- package/src/native-harness/test/boundaries.test.ts +0 -18
- package/src/native-harness/test/channel-controls.test.ts +0 -322
- package/src/native-harness/test/client-abort.test.ts +0 -136
- package/src/native-harness/test/config-policy.test.ts +0 -301
- package/src/native-harness/test/conformance/storage.ts +0 -1141
- package/src/native-harness/test/context.test.ts +0 -177
- package/src/native-harness/test/crash.test.ts +0 -187
- package/src/native-harness/test/debug-tools.test.ts +0 -67
- package/src/native-harness/test/development-cli.test.ts +0 -67
- package/src/native-harness/test/development.test.ts +0 -171
- package/src/native-harness/test/dispatch-evidence.test.ts +0 -58
- package/src/native-harness/test/e2e.test.ts +0 -186
- package/src/native-harness/test/external-notices.test.ts +0 -101
- package/src/native-harness/test/fixtures/approval-e2e.jsonl +0 -4
- package/src/native-harness/test/fixtures/crash-scenario.jsonl +0 -5
- package/src/native-harness/test/fixtures/development-lifecycle.jsonl +0 -10
- package/src/native-harness/test/fixtures/echo-scenario.jsonl +0 -3
- package/src/native-harness/test/fixtures/format2-schema.ts +0 -27
- package/src/native-harness/test/fixtures/format3-schema.ts +0 -16
- package/src/native-harness/test/fixtures/hold-scenario.jsonl +0 -4
- package/src/native-harness/test/fixtures/model-e2e.jsonl +0 -3
- package/src/native-harness/test/fixtures/storage-owner.ts +0 -20
- package/src/native-harness/test/format-reply.test.ts +0 -10
- package/src/native-harness/test/helpers/operator-view.ts +0 -41
- package/src/native-harness/test/helpers/scenario.ts +0 -9
- package/src/native-harness/test/helpers/session.ts +0 -38
- package/src/native-harness/test/helpers/stdio.ts +0 -46
- package/src/native-harness/test/inspector.test.ts +0 -77
- package/src/native-harness/test/listeners.test.ts +0 -49
- package/src/native-harness/test/loop.test.ts +0 -88
- package/src/native-harness/test/model-channel-double.test.ts +0 -87
- package/src/native-harness/test/model-crash.test.ts +0 -62
- package/src/native-harness/test/model-delivery-regressions.test.ts +0 -55
- package/src/native-harness/test/model-e2e.test.ts +0 -71
- package/src/native-harness/test/model-final-filter.test.ts +0 -30
- package/src/native-harness/test/model-large-reply.test.ts +0 -28
- package/src/native-harness/test/model-live-queue.test.ts +0 -33
- package/src/native-harness/test/model-runner.test.ts +0 -117
- package/src/native-harness/test/model-storage.test.ts +0 -99
- package/src/native-harness/test/model-stream-adapter.test.ts +0 -26
- package/src/native-harness/test/model-stream-public.test.ts +0 -77
- package/src/native-harness/test/notices.test.ts +0 -64
- package/src/native-harness/test/openrouter-config.test.ts +0 -218
- package/src/native-harness/test/operator-controls.test.ts +0 -132
- package/src/native-harness/test/output.test.ts +0 -44
- package/src/native-harness/test/owner-config.test.ts +0 -64
- package/src/native-harness/test/permissions-e2e.test.ts +0 -68
- package/src/native-harness/test/persistence.test.ts +0 -236
- package/src/native-harness/test/portability.test.ts +0 -337
- package/src/native-harness/test/protocol.test.ts +0 -160
- package/src/native-harness/test/reminder-clock.test.ts +0 -61
- package/src/native-harness/test/reminder-stdio.test.ts +0 -140
- package/src/native-harness/test/reminder-storage.test.ts +0 -124
- package/src/native-harness/test/scenario-jsonl.test.ts +0 -112
- package/src/native-harness/test/scripted.test.ts +0 -92
- package/src/native-harness/test/session-file.test.ts +0 -51
- package/src/native-harness/test/startup-channel-changes.test.ts +0 -256
- package/src/native-harness/test/stdio.test.ts +0 -132
- package/src/native-harness/test/storage-memory.test.ts +0 -4
- package/src/native-harness/test/storage-sqlite.test.ts +0 -420
- package/src/native-harness/test/suspension.test.ts +0 -430
- package/src/native-harness/test/timeline-retrieval.test.ts +0 -211
- package/src/native-harness/test/tools-catalog.test.ts +0 -468
- package/src/native-harness/test/tools-protocol.test.ts +0 -418
- package/src/native-harness/test/transfers.test.ts +0 -94
- package/src/native-harness/test/web-chat.test.ts +0 -35
package/src/controller.ts
CHANGED
|
@@ -68,6 +68,8 @@ export interface AgentControllerConfig extends PermissionPolicyConfig {
|
|
|
68
68
|
execPrefix?: string[];
|
|
69
69
|
/** @deprecated Use launcher and its exact spawnEnv. */
|
|
70
70
|
env?: Record<string, string>;
|
|
71
|
+
/** Exact environment for built-in ACP terminals. */
|
|
72
|
+
terminalEnv?: Record<string, string>;
|
|
71
73
|
cwd?: string;
|
|
72
74
|
additionalDirectories?: string[];
|
|
73
75
|
/** Session id to load on start(). */
|
package/src/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ export type { ConversationTimelineItem } from "./persistence/timeline-reconcile.
|
|
|
41
41
|
export * from "./audit/index.ts";
|
|
42
42
|
|
|
43
43
|
export { Agent } from "./agent.ts";
|
|
44
|
+
export { channelSettingsLive, type NativeChannelSettings, type NativeChannelSettingsResult, type NativeRestartOptions, type NativeRestartPreview, type NativeRestartResult, type NativeToolSetting } from "./agent/native-operations.ts";
|
|
44
45
|
export type {
|
|
45
46
|
AgentConfig,
|
|
46
47
|
AgentConversationManager,
|
|
@@ -804,3 +805,5 @@ export { ReminderError } from "./native/reminders/schedule.ts";
|
|
|
804
805
|
export type { ReminderErrorCode, ReminderSchedule, ReminderScheduleInput } from "./native/reminders/schedule.ts";
|
|
805
806
|
export type { Reminder } from "./persistence/reminders.ts";
|
|
806
807
|
export type { ReminderCreate, ReminderEdit, ReminderView, ReminderEvent } from "./native/reminders/service.ts";
|
|
808
|
+
|
|
809
|
+
export type { McpRuntimeHeaders, McpRuntimeHeadersProvider, NativeInputPolicy, NativeMcpStatus } from "./native/mcp.ts";
|
package/src/launcher.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface PreparedLaunch {
|
|
|
13
13
|
spawnCwd?: string;
|
|
14
14
|
/** Complete environment for the directly spawned process. */
|
|
15
15
|
spawnEnv: Record<string, string>;
|
|
16
|
+
/** Exact environment for built-in host terminals. Independent of spawnEnv. */
|
|
17
|
+
terminalEnv?: Record<string, string>;
|
|
16
18
|
/** Release resources created while preparing this launch. Called exactly once. */
|
|
17
19
|
dispose?: () => void | Promise<void>;
|
|
18
20
|
}
|
package/src/native/approvals.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { permissionArrival } from "../permissions/arrival.ts";
|
|
|
2
2
|
import type { ChannelEvent } from "../native-harness/src/client.ts";
|
|
3
3
|
import type { Logger } from "../logger.ts";
|
|
4
4
|
import { cancelledPermission, nativeConversationStopping, nativePermissionRequests, refuseNativeOnClose, type NativePermission, type PermissionResolution } from "../permissions/conversation.ts";
|
|
5
|
+
import { unansweredCancellation } from "../permissions/outcome.ts";
|
|
5
6
|
import { recordingPermissionHandlers } from "../permissions/policy.ts";
|
|
6
7
|
import type { PermissionRequest, PromptHandlers } from "../types.ts";
|
|
7
8
|
import type { NativeApprovalRequest, NativeApprovalResponder } from "./host.ts";
|
|
@@ -20,11 +21,15 @@ class Approval implements NativePermission {
|
|
|
20
21
|
private inFlight = false;
|
|
21
22
|
private observedAnswer?: PermissionResolution;
|
|
22
23
|
private started = false;
|
|
24
|
+
private cancelTurn?: () => void;
|
|
25
|
+
|
|
26
|
+
onCancelTurn(listener: () => void): void { this.cancelTurn = listener; }
|
|
23
27
|
|
|
24
28
|
constructor(
|
|
25
29
|
readonly request: NativeApprovalRequest,
|
|
26
30
|
readonly hostHandled: boolean,
|
|
27
31
|
private readonly send: SendApproval,
|
|
32
|
+
private readonly interrupt?: () => Promise<boolean>,
|
|
28
33
|
) {
|
|
29
34
|
this.resolution = new Promise(resolve => { this.resolve = resolve; });
|
|
30
35
|
}
|
|
@@ -46,6 +51,17 @@ class Approval implements NativePermission {
|
|
|
46
51
|
async answer(resolution: PermissionResolution): Promise<boolean> {
|
|
47
52
|
if (this.inFlight || this.abort.signal.aborted) return false;
|
|
48
53
|
this.inFlight = true;
|
|
54
|
+
if (resolution.outcome === unansweredCancellation && this.interrupt) {
|
|
55
|
+
this.observedAnswer = resolution;
|
|
56
|
+
try {
|
|
57
|
+
this.cancelTurn?.();
|
|
58
|
+
const accepted = await this.interrupt();
|
|
59
|
+
this.finish(accepted ? resolution : cancelledPermission);
|
|
60
|
+
return accepted;
|
|
61
|
+
} finally {
|
|
62
|
+
this.finish(cancelledPermission);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
49
65
|
const decision = resolution.outcome.outcome === "selected" && resolution.outcome.optionId === "allow_once" ? allow : deny;
|
|
50
66
|
try {
|
|
51
67
|
const accepted = await this.send(decision.optionId);
|
|
@@ -64,7 +80,7 @@ class Approval implements NativePermission {
|
|
|
64
80
|
if (!this.inFlight) this.finish(this.observedAnswer);
|
|
65
81
|
} else if (reason === "approval_timeout") {
|
|
66
82
|
this.finish({ outcome: deny, by: "timeout" });
|
|
67
|
-
} else {
|
|
83
|
+
} else if (this.observedAnswer?.outcome !== unansweredCancellation) {
|
|
68
84
|
this.finish(cancelledPermission);
|
|
69
85
|
}
|
|
70
86
|
}
|
|
@@ -76,6 +92,7 @@ class Approval implements NativePermission {
|
|
|
76
92
|
finish(result: PermissionResolution): void {
|
|
77
93
|
if (this.abort.signal.aborted) return;
|
|
78
94
|
this.abort.abort();
|
|
95
|
+
this.cancelTurn = undefined;
|
|
79
96
|
this.resolve(result);
|
|
80
97
|
}
|
|
81
98
|
}
|
|
@@ -88,11 +105,11 @@ export class NativeApprovals {
|
|
|
88
105
|
|
|
89
106
|
constructor(private readonly responder: NativeApprovalResponder | undefined, private readonly log: Logger) {}
|
|
90
107
|
|
|
91
|
-
observe(channel: string, event: ApprovalEvent, send: SendApproval): void {
|
|
108
|
+
observe(channel: string, event: ApprovalEvent, send: SendApproval, interrupt?: () => Promise<boolean>): void {
|
|
92
109
|
let ticket = this.events.get(event) ?? this.active.get(event.requestId);
|
|
93
110
|
if (!ticket) {
|
|
94
111
|
const { type: _type, ...request } = event;
|
|
95
|
-
ticket = new Approval({ ...request, channel }, this.responder !== undefined, send);
|
|
112
|
+
ticket = new Approval({ ...request, channel }, this.responder !== undefined, send, interrupt);
|
|
96
113
|
this.active.set(event.requestId, ticket);
|
|
97
114
|
}
|
|
98
115
|
this.events.set(event, ticket);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConversationCapabilities } from "../conversation-controller/capabilities.ts";
|
|
2
2
|
|
|
3
|
-
export function nativeConversationCapabilities(reminders = true, routines = false): ConversationCapabilities {
|
|
3
|
+
export function nativeConversationCapabilities(reminders = true, routines = false, mcp?: import("./mcp.ts").NativeMcpStatus["capabilities"]): ConversationCapabilities {
|
|
4
4
|
return {
|
|
5
5
|
nativeSteering: true,
|
|
6
6
|
reminders,
|
|
@@ -11,7 +11,7 @@ export function nativeConversationCapabilities(reminders = true, routines = fals
|
|
|
11
11
|
backend: {
|
|
12
12
|
loadSession: false, forkSession: false, listSessions: false,
|
|
13
13
|
media: { image: false, audio: false, file: false },
|
|
14
|
-
mcpServers: { stdio: false, http: false, sse: false },
|
|
14
|
+
mcpServers: mcp ?? { stdio: false, http: false, sse: false },
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
}
|
package/src/native/connection.ts
CHANGED
|
@@ -30,7 +30,7 @@ export async function launchNativeConnection(config: NativeHarnessHostConfig, lo
|
|
|
30
30
|
void (async () => {
|
|
31
31
|
// Diagnostics only: the protocol is on stdout.
|
|
32
32
|
const text = await new Response(child.stderr).text().catch(() => "");
|
|
33
|
-
if (text.trim()) log.warn("native_harness_stderr", { text: text.slice(-4000) });
|
|
33
|
+
if (text.trim()) log.warn("native_harness_stderr", config.mcpRuntimeHeaders ? { redacted: true } : { text: text.slice(-4000) });
|
|
34
34
|
})();
|
|
35
35
|
let notify: (event: ReminderNotification) => void = () => {};
|
|
36
36
|
const transport = createStdioTransport({
|
package/src/native/controller.ts
CHANGED
|
@@ -214,7 +214,7 @@ export class NativeController implements ConversationController, ChannelPort {
|
|
|
214
214
|
}
|
|
215
215
|
subscribeUsageUpdate(_listener: UsageListener): () => void { return () => undefined; }
|
|
216
216
|
get currentSessionId(): string | null { return this.#host.sessionId; }
|
|
217
|
-
get conversationCapabilities(): ConversationCapabilities { return nativeConversationCapabilities(this.#host.reminderSync?.supported, this.#host.reminderSync?.routineAdmission.available); }
|
|
217
|
+
get conversationCapabilities(): ConversationCapabilities { return nativeConversationCapabilities(this.#host.reminderSync?.supported, this.#host.reminderSync?.routineAdmission.available, this.#host.capabilities?.mcpServers); }
|
|
218
218
|
|
|
219
219
|
receiptOf(messageId: string): "delivered" | "seen" | undefined { return this.#receipts.get(messageId); }
|
|
220
220
|
|
|
@@ -250,6 +250,7 @@ export class NativeController implements ConversationController, ChannelPort {
|
|
|
250
250
|
channel: this.#channel,
|
|
251
251
|
sender: message.participantId ?? this.#config.defaultSender ?? "user",
|
|
252
252
|
text: message.text,
|
|
253
|
+
...(message.nativePolicy === undefined ? {} : { policy: message.nativePolicy }),
|
|
253
254
|
});
|
|
254
255
|
}
|
|
255
256
|
}
|
|
@@ -485,7 +486,7 @@ export class NativeController implements ConversationController, ChannelPort {
|
|
|
485
486
|
// that end must not wait behind the question.
|
|
486
487
|
if (turn.approvals.has(event.requestId)) return;
|
|
487
488
|
turn.approvals.add(event.requestId);
|
|
488
|
-
const approval = this.#approve(event, handlers,
|
|
489
|
+
const approval = this.#approve(turn, event, handlers,
|
|
489
490
|
AbortSignal.any([approvals.signal, attachment]), signal);
|
|
490
491
|
if (recordingPermissionHandlers.has(handlers.onPermissionRequest!)) {
|
|
491
492
|
approvalWork.add(approval);
|
|
@@ -524,9 +525,10 @@ export class NativeController implements ConversationController, ChannelPort {
|
|
|
524
525
|
});
|
|
525
526
|
}
|
|
526
527
|
|
|
527
|
-
async #approve(event: Extract<TurnScoped, { type: "approval_requested" }>, handlers: PromptHandlers, cancelled: AbortSignal, signal: (output: ProviderOutput) => void): Promise<void> {
|
|
528
|
+
async #approve(turn: Turn, event: Extract<TurnScoped, { type: "approval_requested" }>, handlers: PromptHandlers, cancelled: AbortSignal, signal: (output: ProviderOutput) => void): Promise<void> {
|
|
528
529
|
const ticket = this.#host.approvalFor(event);
|
|
529
530
|
if (!ticket) return;
|
|
531
|
+
ticket.onCancelTurn?.(() => { turn.cancelRequested = true; });
|
|
530
532
|
const sessionId = this.#host.sessionId;
|
|
531
533
|
signal({ kind: "permission_started", sessionId });
|
|
532
534
|
try { await runNativeApproval(ticket, event, handlers, cancelled, this.#log); }
|
|
@@ -29,6 +29,8 @@ export interface NativeHarnessHostConfig {
|
|
|
29
29
|
readonly sessionId: string;
|
|
30
30
|
/** Sent on every open. Session configuration is fixed while the session is open. */
|
|
31
31
|
readonly config: RoutineConfigInput;
|
|
32
|
+
/** Fresh secret material for each executable native harness open. */
|
|
33
|
+
readonly mcpRuntimeHeaders?: import("./mcp.ts").McpRuntimeHeadersProvider;
|
|
32
34
|
/** The harness home, a path in the harness's environment. Must survive process restarts. */
|
|
33
35
|
readonly home: string;
|
|
34
36
|
/** How to start the harness server; defaults to this package's harness in `serve --stdio` mode. */
|
package/src/native/host.ts
CHANGED
|
@@ -85,7 +85,8 @@ const REQUIRED_METHODS = ["session/open", "channel/observe", "channel/reconcile"
|
|
|
85
85
|
export class NativeHarnessHost {
|
|
86
86
|
readonly sessionId: string;
|
|
87
87
|
readonly records: NativeHostRecords;
|
|
88
|
-
|
|
88
|
+
#config: NativeHarnessHostConfig;
|
|
89
|
+
#restartTransition?: Promise<void>;
|
|
89
90
|
readonly #log: Logger;
|
|
90
91
|
reminderSync?: ReminderSync;
|
|
91
92
|
reminderWake?: ReminderWakeSupervisor;
|
|
@@ -121,7 +122,7 @@ export class NativeHarnessHost {
|
|
|
121
122
|
|| this.#changes.busy || [...this.#ports.values()].some(port => port.busy());
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
#idleStop(window: number, stillIdle: () => boolean): Promise<ConditionalStopResult> {
|
|
125
|
+
#idleStop(window: number, stillIdle: () => boolean, onStopped?: () => void): Promise<ConditionalStopResult> {
|
|
125
126
|
if (this.#idling) return this.#idling;
|
|
126
127
|
const connection = this.#connection;
|
|
127
128
|
if (this.#stoppingExplicitly || !connection || !stillIdle() || this.#localBusy()) return Promise.resolve({ stopped: false, reason: "busy" });
|
|
@@ -130,6 +131,7 @@ export class NativeHarnessHost {
|
|
|
130
131
|
await this.reminderSync?.settled();
|
|
131
132
|
if (result.stopped && this.#connection === connection) {
|
|
132
133
|
this.#connection = null;
|
|
134
|
+
onStopped?.();
|
|
133
135
|
this.#approvals.stop();
|
|
134
136
|
for (const port of this.#ports.values()) port.disconnected();
|
|
135
137
|
try { await connection.kill(); } finally { this.#setState("stopped"); }
|
|
@@ -240,8 +242,9 @@ export class NativeHarnessHost {
|
|
|
240
242
|
|
|
241
243
|
#observeApproval(connection: NativeConnection, { channel, event }: ChannelEvent): void {
|
|
242
244
|
if (event.type === "approval_requested") {
|
|
243
|
-
this.#approvals.observe(channel, event,
|
|
244
|
-
this.#connection === connection && this.#answerApproval(event.requestId, decision)
|
|
245
|
+
this.#approvals.observe(channel, event,
|
|
246
|
+
async decision => this.#connection === connection && this.#answerApproval(event.requestId, decision),
|
|
247
|
+
async () => this.#connection === connection && this.interrupt(channel, event.turnId, "unanswered permission"));
|
|
245
248
|
} else if (event.type === "approval_closed") {
|
|
246
249
|
this.#approvals.closed(event);
|
|
247
250
|
}
|
|
@@ -301,8 +304,72 @@ export class NativeHarnessHost {
|
|
|
301
304
|
}
|
|
302
305
|
}
|
|
303
306
|
|
|
307
|
+
async waitForIdle(signal?: AbortSignal): Promise<void> {
|
|
308
|
+
for (;;) {
|
|
309
|
+
signal?.throwIfAborted();
|
|
310
|
+
if (!this.#localBusy() && !this.#starting && !this.#stoppingExplicitly) {
|
|
311
|
+
const connection = this.#connection;
|
|
312
|
+
if (!connection) return;
|
|
313
|
+
const status = await connection.client.status();
|
|
314
|
+
signal?.throwIfAborted();
|
|
315
|
+
if (connection === this.#connection && !this.#localBusy() &&
|
|
316
|
+
(status.execution === "idle" || status.execution === "suspended") && status.channels.every(
|
|
317
|
+
channel => !channel.activeTurn && !channel.waitingForResume && channel.pending.length === 0,
|
|
318
|
+
)) return;
|
|
319
|
+
}
|
|
320
|
+
await new Promise<void>(resolve => setTimeout(resolve, 25));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async restartForAgent(options: import("../agent/native-operations.ts").NativeRestartOptions,
|
|
325
|
+
interrupted: { channel: string; turnId: string }[]): Promise<void> {
|
|
326
|
+
const { signal, when = "idle" } = options;
|
|
327
|
+
signal?.throwIfAborted();
|
|
328
|
+
let configured = false;
|
|
329
|
+
const configure = () => {
|
|
330
|
+
if (configured) return;
|
|
331
|
+
configured = true;
|
|
332
|
+
if (options.functions !== undefined) {
|
|
333
|
+
this.#functions?.dispose();
|
|
334
|
+
this.#functions = null;
|
|
335
|
+
}
|
|
336
|
+
this.#config = { ...this.#config, ...(options.config ? { config: options.config } : {}),
|
|
337
|
+
...(options.functions !== undefined ? { functions: options.functions ?? undefined } : {}) };
|
|
338
|
+
};
|
|
339
|
+
if (when === "idle") {
|
|
340
|
+
for (;;) {
|
|
341
|
+
await this.waitForIdle(signal);
|
|
342
|
+
if (!this.#connection) break;
|
|
343
|
+
if ((await this.#idleStop(0, () => !signal?.aborted, configure)).stopped) break;
|
|
344
|
+
await new Promise<void>(resolve => setTimeout(resolve, 25));
|
|
345
|
+
}
|
|
346
|
+
configure();
|
|
347
|
+
} else {
|
|
348
|
+
const transition = async () => {
|
|
349
|
+
await this.#starting;
|
|
350
|
+
const connection = this.#connection;
|
|
351
|
+
if (connection) {
|
|
352
|
+
const { channels } = await connection.client.status();
|
|
353
|
+
await Promise.all(channels.map(async ({ channel, activeTurn }) => {
|
|
354
|
+
if (activeTurn?.state === "running" && await this.interrupt(channel, activeTurn.turnId, "agent_restart")) {
|
|
355
|
+
interrupted.push({ channel, turnId: activeTurn.turnId });
|
|
356
|
+
}
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
await this.stop();
|
|
360
|
+
configure();
|
|
361
|
+
};
|
|
362
|
+
const pending = this.#restartTransition = transition();
|
|
363
|
+
try { await pending; }
|
|
364
|
+
finally { if (this.#restartTransition === pending) this.#restartTransition = undefined; }
|
|
365
|
+
}
|
|
366
|
+
signal?.throwIfAborted();
|
|
367
|
+
await this.restart();
|
|
368
|
+
}
|
|
369
|
+
|
|
304
370
|
/** Starts the harness if it is not running. Concurrent callers share one start. */
|
|
305
371
|
ensureStarted(): Promise<void> {
|
|
372
|
+
if (this.#restartTransition) return this.#restartTransition.then(() => this.ensureStarted());
|
|
306
373
|
if (this.#idling) return this.#idling.catch(() => {}).then(() => this.ensureStarted());
|
|
307
374
|
if (this.#wakeFailure) { this.#wakeFailure = null; this.#restarts.length = 0; }
|
|
308
375
|
this.reminderIdle?.activity();
|
|
@@ -455,6 +522,7 @@ export class NativeHarnessHost {
|
|
|
455
522
|
signal.throwIfAborted();
|
|
456
523
|
|
|
457
524
|
const status = await client.status();
|
|
525
|
+
if (status.mcpServers === undefined && opened.mcpServers !== undefined) status.mcpServers = opened.mcpServers;
|
|
458
526
|
signal.throwIfAborted();
|
|
459
527
|
const view: LoadResult = { status, items: [], turns: [], messages: [] };
|
|
460
528
|
const submissions = this.records.submissions();
|
|
@@ -678,6 +746,7 @@ export class NativeHarnessHost {
|
|
|
678
746
|
* definite refusal (suspended or retired channel, unknown policy, a conflicting id) rejects it.
|
|
679
747
|
*/
|
|
680
748
|
async push(input: Omit<Submission, "state">): Promise<ItemStatus> {
|
|
749
|
+
if (this.#restartTransition) await this.#restartTransition;
|
|
681
750
|
this.records.saveSubmission({ ...input, state: "saved" });
|
|
682
751
|
const waiter = this.#waiters.get(input.id) ?? deferred<ItemStatus>();
|
|
683
752
|
this.#waiters.set(input.id, waiter);
|
|
@@ -760,6 +829,7 @@ export class NativeHarnessHost {
|
|
|
760
829
|
* the harness.
|
|
761
830
|
*/
|
|
762
831
|
async changeChannel(channel: string, desire: ChannelDesire): Promise<ChannelChangeOutcome> {
|
|
832
|
+
if (this.#restartTransition) await this.#restartTransition;
|
|
763
833
|
if (this.#idling) await this.ensureStarted();
|
|
764
834
|
this.reminderIdle?.activity();
|
|
765
835
|
const result = await this.#changes.change(channel, desire, this.#state === "running");
|
|
@@ -790,6 +860,15 @@ export class NativeHarnessHost {
|
|
|
790
860
|
return live;
|
|
791
861
|
}
|
|
792
862
|
|
|
863
|
+
async mcpStatus(): Promise<import("./mcp.ts").NativeMcpStatus> {
|
|
864
|
+
const { session, stale } = await this.operatorStatus();
|
|
865
|
+
return this.mcpSnapshot(stale, session);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
mcpSnapshot(stale = this.#state !== "running", session = this.#lastStatus): import("./mcp.ts").NativeMcpStatus {
|
|
869
|
+
return { capabilities: this.#capabilities?.mcpServers, servers: session?.mcpServers, stale };
|
|
870
|
+
}
|
|
871
|
+
|
|
793
872
|
async operatorStatus() {
|
|
794
873
|
const connection = this.#connection;
|
|
795
874
|
let confirmed = false;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { HarnessClientError, type CreateParams, type InitializeResult, type PushParams, type StatusResult } from "../native-harness/src/client.ts";
|
|
2
|
+
import { codeOf } from "./errors.ts";
|
|
3
|
+
|
|
4
|
+
export type NativeInputPolicy = NonNullable<PushParams["item"]["policy"]>;
|
|
5
|
+
export type McpRuntimeHeaders = NonNullable<CreateParams["mcpRuntimeHeaders"]>;
|
|
6
|
+
export type McpRuntimeHeadersProvider = () => McpRuntimeHeaders | Promise<McpRuntimeHeaders>;
|
|
7
|
+
export type NativeMcpStatus = {
|
|
8
|
+
readonly capabilities?: InitializeResult["description"]["capabilities"]["mcpServers"];
|
|
9
|
+
readonly servers?: StatusResult["mcpServers"];
|
|
10
|
+
readonly stale: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const runtimeHeaderLimits = { totalBytes: 8 * 1024, valueBytes: 2 * 1024 };
|
|
14
|
+
|
|
15
|
+
function validateRuntimeHeaderSize(material: McpRuntimeHeaders): void {
|
|
16
|
+
const tooLarge = () => new HarnessClientError("mcp_runtime_headers_too_large",
|
|
17
|
+
"Native MCP runtime headers exceed the 8 KiB total or 2 KiB per-value limit");
|
|
18
|
+
for (const headers of Object.values(material)) {
|
|
19
|
+
for (const value of Object.values(headers)) {
|
|
20
|
+
if (Buffer.byteLength(value) > runtimeHeaderLimits.valueBytes) throw tooLarge();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Count JSON framing, names and escape expansion as well as the values.
|
|
24
|
+
if (Buffer.byteLength(JSON.stringify(material)) > runtimeHeaderLimits.totalBytes) throw tooLarge();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function executableMcpOpen<T>(provider: McpRuntimeHeadersProvider | undefined, signal: AbortSignal,
|
|
28
|
+
send: (material?: McpRuntimeHeaders) => Promise<T>): Promise<T> {
|
|
29
|
+
if (!provider) return send();
|
|
30
|
+
let material: McpRuntimeHeaders;
|
|
31
|
+
try { material = await provider(); }
|
|
32
|
+
catch { throw new HarnessClientError("mcp_runtime_headers_failed", "Could not obtain native MCP runtime headers"); }
|
|
33
|
+
signal.throwIfAborted();
|
|
34
|
+
try { validateRuntimeHeaderSize(material); }
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (codeOf(error) === "mcp_runtime_headers_too_large") throw error;
|
|
37
|
+
throw new HarnessClientError("mcp_runtime_headers_failed", "Could not encode native MCP runtime headers");
|
|
38
|
+
}
|
|
39
|
+
try { return await send(material); }
|
|
40
|
+
catch (error) {
|
|
41
|
+
const code = codeOf(error);
|
|
42
|
+
const allowed = ["not_found", "timeout", "transport_closed", "closed", "storage_failure", "invalid_config",
|
|
43
|
+
"invalid_params", "incompatible", "busy", "already_exists"];
|
|
44
|
+
throw new HarnessClientError(code && allowed.includes(code) ? code : "mcp_open_failed",
|
|
45
|
+
"Native harness executable open failed");
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/native/recovery.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { executableMcpOpen, type McpRuntimeHeadersProvider } from "./mcp.ts";
|
|
1
2
|
import { activatesRoutine, RoutineAdmission } from "./reminders/routine-guard.ts";
|
|
2
3
|
import type { ReminderChange } from "../persistence/reminders.ts";
|
|
3
4
|
import type { ReminderSync } from "./reminders/sync.ts";
|
|
@@ -51,7 +52,7 @@ export async function readCompleteMessage(client: HarnessClient, messageId: stri
|
|
|
51
52
|
|
|
52
53
|
/** The catalog and startup edits are installed before recovered work can start. */
|
|
53
54
|
export async function openOrCreate(
|
|
54
|
-
client: HarnessClient, config: { sessionId: string; config?: RoutineConfigInput },
|
|
55
|
+
client: HarnessClient, config: { sessionId: string; config?: RoutineConfigInput; mcpRuntimeHeaders?: McpRuntimeHeadersProvider },
|
|
55
56
|
batch: PendingChannelChange[], tools: Parameters<HarnessClient["openSession"]>[0]["tools"], signal: AbortSignal, reminders?: ReminderSync,
|
|
56
57
|
) {
|
|
57
58
|
const admission = reminders?.routineAdmission ?? new RoutineAdmission();
|
|
@@ -71,10 +72,12 @@ export async function openOrCreate(
|
|
|
71
72
|
sessionId: config.sessionId, config: admission.configForOpen(config.config), ...changes,
|
|
72
73
|
...(staged.length ? { reminderChanges: staged } : {}),
|
|
73
74
|
};
|
|
75
|
+
const send = (request: typeof params) => executableMcpOpen(config.mcpRuntimeHeaders, signal, material => {
|
|
76
|
+
const executable = { ...request, ...(material === undefined ? {} : { mcpRuntimeHeaders: material }) };
|
|
77
|
+
return create ? client.createSession({ ...executable, participants: [], channels: {} }) : client.openSession(executable);
|
|
78
|
+
});
|
|
74
79
|
try {
|
|
75
|
-
return
|
|
76
|
-
? await client.createSession({ ...params, participants: [], channels: {} })
|
|
77
|
-
: await client.openSession(params);
|
|
80
|
+
return await send(params);
|
|
78
81
|
} catch (error) {
|
|
79
82
|
const code = codeOf(error);
|
|
80
83
|
if (staged.length && code === "storage_failure") {
|
|
@@ -103,9 +106,7 @@ export async function openOrCreate(
|
|
|
103
106
|
const { reminderChanges: _rejected, ...unbatched } = params;
|
|
104
107
|
let result: ReminderWireOpen;
|
|
105
108
|
try {
|
|
106
|
-
result =
|
|
107
|
-
? await client.createSession({ ...unbatched, participants: [], channels: {} })
|
|
108
|
-
: await client.openSession(unbatched);
|
|
109
|
+
result = await send(unbatched);
|
|
109
110
|
} catch (retryError) {
|
|
110
111
|
await reminders!.restoreStaged(originals);
|
|
111
112
|
throw retryError;
|
|
@@ -48,14 +48,15 @@ export class RoutineAdmission {
|
|
|
48
48
|
configForOpen(config: RoutineConfigInput | undefined): RoutineConfig | undefined {
|
|
49
49
|
if (!config) return;
|
|
50
50
|
const { limits, ...rest } = config;
|
|
51
|
-
const configured = limits
|
|
52
|
-
|
|
51
|
+
const { unattendedTurns: configured, ...otherLimits } = limits ?? {};
|
|
52
|
+
const retained = Object.keys(otherLimits).length ? { ...rest, limits: otherLimits } : rest;
|
|
53
|
+
if (configured === undefined) return retained;
|
|
53
54
|
const value = configured === "unlimited" ? Number.MAX_SAFE_INTEGER : configured;
|
|
54
55
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
55
56
|
throw new ReminderError("invalid_config", 'unattendedTurns must be a positive safe integer or "unlimited"');
|
|
56
57
|
}
|
|
57
58
|
if (!this.supported) throw new HarnessIncompatibleError("The native harness must support routines and unattendedTurnGuard to configure unattendedTurns");
|
|
58
|
-
return this.bound === value ?
|
|
59
|
+
return this.bound === value ? retained : { ...rest, limits: { ...otherLimits, unattendedTurns: value } };
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
opened(opened: ReminderWireOpen): void {
|
|
@@ -17,5 +17,5 @@ export interface ReminderNegotiation {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export type RoutineConfigInput = Omit<ProtocolConfig, "limits"> & {
|
|
20
|
-
limits?: { unattendedTurns
|
|
20
|
+
limits?: Omit<NonNullable<ProtocolConfig["limits"]>, "unattendedTurns"> & { unattendedTurns?: number | "unlimited" };
|
|
21
21
|
};
|
|
@@ -24,7 +24,15 @@ work. Experiments live in [.res/sandbox/](.res/sandbox/).
|
|
|
24
24
|
This directory is an independent TypeScript and Bun project (Bun >= 1.3.5), with
|
|
25
25
|
its own package manifest, lockfile and TypeScript configuration. It does not
|
|
26
26
|
depend on the parent acp-client package. Development dependencies are TypeScript
|
|
27
|
-
and Bun types
|
|
27
|
+
and Bun types. Managed image input additionally requires the optional local
|
|
28
|
+
`ffmpeg`, `ffprobe`, and Linux `prlimit` executables on `PATH`; general-file attachments do not.
|
|
29
|
+
Image input is offered only when the model configuration explicitly opts in
|
|
30
|
+
and all three executables are available. Both image processes run under a 1 GiB
|
|
31
|
+
address-space limit, a CPU limit, and a file-descriptor limit, with bounded
|
|
32
|
+
output and a cancellable timeout. Input is passed via an anonymous Linux temporary inode on stdin, with no named
|
|
33
|
+
copy left on disk; an O_TMPFILE-capable temporary filesystem is required.
|
|
34
|
+
They accept only pipe input; missing tools,
|
|
35
|
+
unsupported platforms, resource exhaustion, and invalid images fail closed.
|
|
28
36
|
|
|
29
37
|
From this directory:
|
|
30
38
|
|
|
@@ -605,6 +613,28 @@ Run `bun test test/protocol.test.ts test/stdio.test.ts` for transport parity and
|
|
|
605
613
|
framing/process lifecycle checks. Child stdin in Bun uses IPC and may require
|
|
606
614
|
local IPC permissions in sandboxed environments. All scenarios are offline.
|
|
607
615
|
|
|
616
|
+
### Managed attachments
|
|
617
|
+
|
|
618
|
+
Managed stdio sessions store files in `<home>/<sessionId>/media`; development
|
|
619
|
+
with an explicit `--db PATH` uses `PATH.media`. The paired web chat can upload
|
|
620
|
+
and download files, and memory-backed development uses a temporary media root.
|
|
621
|
+
The host can use `beginAttachment`, `writeAttachment`, `finalizeAttachment`,
|
|
622
|
+
`attachmentStatus`, `abortAttachment` and `readAttachment` on `HarnessClient`.
|
|
623
|
+
Chunks are at most 512 KiB decoded; each file is at most 20 MiB. Finalization
|
|
624
|
+
checks length and SHA-256 before committing ready metadata. A push may contain
|
|
625
|
+
ordered text and attachment references, including an attachment-only input.
|
|
626
|
+
Text-only pushes retain their existing retry identity.
|
|
627
|
+
|
|
628
|
+
Set `model.imageInput: true` explicitly to enable PNG, JPEG and WebP input
|
|
629
|
+
when the local validator is available. Initialize reports attachment protocol
|
|
630
|
+
support; create/open reports the effective image capability and limits. A
|
|
631
|
+
text-only model rejects an image push before acceptance. Ready files belong to
|
|
632
|
+
their uploading channel until a referenced message enters the shared timeline;
|
|
633
|
+
then timeline readers may download them. History and diagnostics contain
|
|
634
|
+
references and metadata, not image bytes. Complete session exports include
|
|
635
|
+
retained attachment bytes and fail if those bytes are missing or the bounded
|
|
636
|
+
archive cannot contain them.
|
|
637
|
+
|
|
608
638
|
## Consumer tools and host callbacks
|
|
609
639
|
|
|
610
640
|
A host can register functions for the model to call
|
|
@@ -724,3 +754,30 @@ A stopped harness needs a host to reopen it before any due work can run.
|
|
|
724
754
|
|
|
725
755
|
Run `bun test test/reminder-stdio.test.ts` from this package to verify cold
|
|
726
756
|
open, replay, process death and the idle-stop fence with a scripted model.
|
|
757
|
+
|
|
758
|
+
Managed web tools are disabled until configured. `webSearch` accepts an Exa
|
|
759
|
+
backend; `webFetch` independently accepts Exa or direct HTTP. Exa resolves the
|
|
760
|
+
configured `apiKeyEnv` (default `EXA_API_KEY`) from the launching process at
|
|
761
|
+
executable open; configuration and exports store the variable name, never its
|
|
762
|
+
value. Direct HTTP needs no Exa credential. Both tools use the session's normal
|
|
763
|
+
tool policy and produce bounded JSON previews; inspect per-invocation provider
|
|
764
|
+
estimates separately from model token usage. See
|
|
765
|
+
[decision 0035](.res/decisions/0035-web-search-fetch.md) for transport limits,
|
|
766
|
+
address checks, cost recovery and defaults.
|
|
767
|
+
|
|
768
|
+
### Managed MCP tools
|
|
769
|
+
|
|
770
|
+
Decision 0036 adds the optional `@modelcontextprotocol/sdk` 1.31.0 dependency
|
|
771
|
+
for executable sessions with configured MCP servers. Install the harness
|
|
772
|
+
package dependencies before running the feature. Set `mcpServers` in managed
|
|
773
|
+
configuration, with a direct executable, arguments and any explicit environment
|
|
774
|
+
references. Grant `mcp: "allow"` under the trusted owner policy. MCP defaults
|
|
775
|
+
to deny, including when any taken input contributes a policy without a grant.
|
|
776
|
+
An executable reopen discovers the configured server's tools again.
|
|
777
|
+
|
|
778
|
+
Streamable HTTPS uses an optional private Undici 7.29.0 dispatcher, with
|
|
779
|
+
endpoint binding and certificate validation. Use environment references or
|
|
780
|
+
runtime declarations for secret headers. The owning protocol caller supplies
|
|
781
|
+
runtime values on each executable create or reopen. Upstream launcher
|
|
782
|
+
acceptance is tracked separately. The offline fixtures do not establish the
|
|
783
|
+
approval behavior of agents-tools or the door.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build the public-domain IANA offset catalog from a matching zoneinfo tree."""
|
|
3
|
+
import calendar
|
|
4
|
+
import gzip
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from zoneinfo import ZoneInfo
|
|
12
|
+
|
|
13
|
+
root = Path(sys.argv[1] if len(sys.argv) > 1 else "/usr/share/zoneinfo").resolve()
|
|
14
|
+
source = (root / "tzdata.zi").read_text().splitlines()
|
|
15
|
+
version = source[0].split()[2]
|
|
16
|
+
epoch = calendar.timegm((2100, 1, 1, 0, 0, 0))
|
|
17
|
+
cycle = 146097 * 86400
|
|
18
|
+
zones = {}
|
|
19
|
+
aliases = {}
|
|
20
|
+
for line in source:
|
|
21
|
+
fields = line.split()
|
|
22
|
+
if fields and fields[0] == "L":
|
|
23
|
+
aliases[fields[2]] = fields[1]
|
|
24
|
+
if not fields or fields[0] != "Z":
|
|
25
|
+
continue
|
|
26
|
+
name = fields[1]
|
|
27
|
+
with (root / name).open("rb") as file:
|
|
28
|
+
zone = ZoneInfo.from_file(file)
|
|
29
|
+
initial = int(datetime(1800, 1, 1, tzinfo=timezone.utc).astimezone(zone).utcoffset().total_seconds())
|
|
30
|
+
changes = []
|
|
31
|
+
last = initial
|
|
32
|
+
listing = subprocess.check_output(["zdump", "-v", "-c", "1800,2900", str(root / name)], text=True)
|
|
33
|
+
for match in re.finditer(r" (\w{3} \w{3} +\d+ \d\d:\d\d:\d\d \d+) UT = .* gmtoff=(-?\d+)$", listing, re.M):
|
|
34
|
+
offset = int(match[2])
|
|
35
|
+
if offset != last:
|
|
36
|
+
instant = calendar.timegm(datetime.strptime(match[1], "%a %b %d %H:%M:%S %Y").timetuple())
|
|
37
|
+
changes.append((instant, offset))
|
|
38
|
+
last = offset
|
|
39
|
+
first = [(at - epoch, offset) for at, offset in changes if epoch <= at < epoch + cycle]
|
|
40
|
+
second = [(at - epoch - cycle, offset) for at, offset in changes if epoch + cycle <= at]
|
|
41
|
+
if first != second:
|
|
42
|
+
raise RuntimeError(f"Unproved 400-year tail for {name}")
|
|
43
|
+
zones[name] = [initial, [row for row in changes if row[0] < epoch + cycle]]
|
|
44
|
+
|
|
45
|
+
output = Path(__file__).resolve().parents[1] / "src/capabilities/reminders/iana-zones.json.gz"
|
|
46
|
+
output.write_bytes(gzip.compress(json.dumps([version, epoch, cycle, zones, aliases], separators=(",", ":"), sort_keys=True).encode(), mtime=0))
|
|
47
|
+
print(version, len(zones), len(aliases), output.stat().st_size)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AttachmentMetadata, InputPart } from "../../contracts/attachments.ts";
|
|
2
|
+
import { ATTACHMENT_LIMITS } from "../../contracts/attachments.ts";
|
|
3
|
+
import { mixedPartsSignature, validateMixedParts } from "./input.ts";
|
|
4
|
+
|
|
5
|
+
export class AttachmentAdmissionError extends Error {
|
|
6
|
+
constructor(readonly code: "item_conflict" | "not_found" | "unsupported_image" | "transfer_limit", message: string) { super(message); }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Called within the session owner's single transaction. `accept` must apply
|
|
10
|
+
* normal channel/lifecycle/policy checks and insert the item; `associate` must
|
|
11
|
+
* persist the ordered parts and links in that transaction. Existing identities
|
|
12
|
+
* are compared before checking lifecycle, file state or model capability. */
|
|
13
|
+
export function admitAttachmentInput<T>(input: { channel: string; identity: string; content: unknown; imageInput: boolean;
|
|
14
|
+
known: () => { identity: string; value: T } | undefined;
|
|
15
|
+
lookup: (id: string) => AttachmentMetadata | undefined;
|
|
16
|
+
accept: (identity: string, parts: readonly InputPart[]) => T;
|
|
17
|
+
associate: (value: T, parts: readonly InputPart[]) => void;
|
|
18
|
+
}): { value: T; duplicate: boolean } {
|
|
19
|
+
const parts = validateMixedParts(input.content);
|
|
20
|
+
// The caller's identity covers channel, sender and policy, while this suffix
|
|
21
|
+
// makes the exact ordered part boundaries part of that identity.
|
|
22
|
+
const identity = JSON.stringify([input.identity, mixedPartsSignature(parts)]);
|
|
23
|
+
const known = input.known();
|
|
24
|
+
if (known) {
|
|
25
|
+
if (known.identity !== identity) throw new AttachmentAdmissionError("item_conflict", "Item ID already identifies different input");
|
|
26
|
+
return { value: known.value, duplicate: true };
|
|
27
|
+
}
|
|
28
|
+
let images = 0, bytes = 0;
|
|
29
|
+
for (const part of parts) if (part.type === "attachment") {
|
|
30
|
+
const metadata = input.lookup(part.id);
|
|
31
|
+
if (!metadata || metadata.channel !== input.channel) throw new AttachmentAdmissionError("not_found", "Unknown attachment");
|
|
32
|
+
if (metadata.mediaType.startsWith("image/")) {
|
|
33
|
+
if (!input.imageInput) throw new AttachmentAdmissionError("unsupported_image", "Image input is unsupported");
|
|
34
|
+
images++; bytes += metadata.bytes;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (images > ATTACHMENT_LIMITS.references || bytes > ATTACHMENT_LIMITS.imageBytesPerTurn)
|
|
38
|
+
throw new AttachmentAdmissionError("transfer_limit", "Input image budget exceeded");
|
|
39
|
+
const value = input.accept(identity, parts);
|
|
40
|
+
input.associate(value, parts);
|
|
41
|
+
return { value, duplicate: false };
|
|
42
|
+
}
|