maka-agent 0.2.0-dev.11.20260831 → 0.2.0-dev.14.20260902
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 +2 -2
- package/RUNTIME_HOST_PEER_DEPENDENCIES.rust.tsv +70 -0
- package/RUNTIME_HOST_PEER_THIRD_PARTY_NOTICES.txt +1839 -140
- package/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/acp/maka-acp-agent.js +6 -3
- package/dist/acp/session-registry.js +307 -0
- package/dist/acp/stdio-server.js +20 -1
- package/dist/cli-core.js +40 -3
- package/dist/mcp-capability-provider.js +1 -1
- package/dist/onboarding-catalog.js +3 -5
- package/dist/pi-transcript.js +21 -17
- package/dist/pi-tui-layout.js +4 -2
- package/dist/pi-tui-mcp-status.js +44 -130
- package/dist/pi-tui-pickers.js +11 -5
- package/dist/pi-tui-runner.js +133 -102
- package/dist/runtime-host-access-command.js +37 -4
- package/dist/runtime-host-capability-provider-command.js +16 -2
- package/dist/runtime-host-cli-context.js +73 -3
- package/dist/runtime-host-cli.js +187 -10
- package/dist/runtime-host-lifecycle-transaction.js +5 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-onboarding.js +12 -16
- package/dist/runtime-host-peer-management-command.js +16 -4
- package/dist/runtime-host-plugin-command.js +101 -0
- package/dist/runtime-host-run-command.js +8 -2
- package/dist/runtime-host-service-management-command.js +2 -1
- package/dist/runtime-host-setup-command.js +1 -0
- package/dist/runtime-host-task-readiness.js +2 -3
- package/dist/runtime-host-tui-command.js +1 -1
- package/dist/runtime-host-tui-context.js +18 -5
- package/dist/runtime-host-update-command.js +71 -35
- package/dist/runtime-host-update-discovery.js +1 -0
- package/dist/tui-clipboard.js +86 -0
- package/dist/tui-copy-catalog.js +248 -0
- package/dist/tui-copy-command.js +103 -0
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/node_modules/@maka/core/dist/attachments.js +92 -1
- package/node_modules/@maka/core/dist/bounded-response.js +71 -0
- package/node_modules/@maka/core/dist/chat-model-choice.js +8 -33
- package/node_modules/@maka/core/dist/client-capability-grant.js +149 -0
- package/node_modules/@maka/core/dist/connection-error-copy.js +17 -34
- package/node_modules/@maka/core/dist/connection-readiness.js +3 -31
- package/node_modules/@maka/core/dist/deep-research.js +1 -20
- package/node_modules/@maka/core/dist/events.js +22 -14
- package/node_modules/@maka/core/dist/foreign-session.js +2 -2
- package/node_modules/@maka/core/dist/interaction.js +49 -2
- package/node_modules/@maka/core/dist/llm-connections.js +74 -82
- package/node_modules/@maka/core/dist/maka-wordmark.js +23 -0
- package/node_modules/@maka/core/dist/model-catalog.js +242 -315
- package/node_modules/@maka/core/dist/model-facts.js +13 -19
- package/node_modules/@maka/core/dist/model-metadata.generated.js +1907 -1872
- package/node_modules/@maka/core/dist/model-metadata.js +184 -199
- package/node_modules/@maka/core/dist/model-thinking.js +1 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +302 -0
- package/node_modules/@maka/core/dist/models-dev-refresh.js +55 -0
- package/node_modules/@maka/core/dist/onboarding.js +2 -1
- package/node_modules/@maka/core/dist/provider-auth.js +47 -291
- package/node_modules/@maka/core/dist/provider-registry.js +68 -357
- package/node_modules/@maka/core/dist/runtime-event.js +5 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +83 -18
- package/node_modules/@maka/core/dist/runtime-policy/credential-vault-codec.js +9 -1
- package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +84 -0
- package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +75 -0
- package/node_modules/@maka/core/dist/runtime-policy.js +5 -2
- package/node_modules/@maka/core/dist/session-send-projection.js +2 -1
- package/node_modules/@maka/core/dist/session-start-mode.js +42 -0
- package/node_modules/@maka/core/dist/session.js +120 -5
- package/node_modules/@maka/core/dist/settings.js +10 -2
- package/node_modules/@maka/core/dist/slash-command-catalog.js +1 -0
- package/node_modules/@maka/core/dist/task-submission-readiness.js +2 -1
- package/node_modules/@maka/core/dist/usage-record-schema.js +11 -1
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +896 -0
- package/node_modules/@maka/core/package.json +8 -2
- package/node_modules/@maka/mcp/dist/index.js +1 -0
- package/node_modules/@maka/runtime/dist/agent-run.js +7 -0
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +55 -82
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +178 -140
- package/node_modules/@maka/runtime/dist/archive-read-tool.js +26 -5
- package/node_modules/@maka/runtime/dist/builtin-tools.js +27 -2
- package/node_modules/@maka/runtime/dist/context-budget-policy.js +0 -12
- package/node_modules/@maka/runtime/dist/conversation-copy.js +66 -43
- package/node_modules/@maka/runtime/dist/durable-tool-result-projection.js +31 -0
- package/node_modules/@maka/runtime/dist/history-compact-error.js +10 -2
- package/node_modules/@maka/runtime/dist/history-compact-input-fit.js +7 -1
- package/node_modules/@maka/runtime/dist/history-compaction.js +13 -22
- package/node_modules/@maka/runtime/dist/image-file.js +5 -20
- package/node_modules/@maka/runtime/dist/local-web-fetch.js +2 -43
- package/node_modules/@maka/runtime/dist/mcp-tools.js +28 -0
- package/node_modules/@maka/runtime/dist/model-fetcher.js +15 -8
- package/node_modules/@maka/runtime/dist/model-history.js +59 -17
- package/node_modules/@maka/runtime/dist/model-runtime.js +2 -2
- package/node_modules/@maka/runtime/dist/plugin-composition-loader.js +173 -20
- package/node_modules/@maka/runtime/dist/plugin-runtime.js +219 -0
- package/node_modules/@maka/runtime/dist/provider-image-overflow-recovery.js +12 -31
- package/node_modules/@maka/runtime/dist/quiescent-session-snapshot.js +78 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +6 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +14 -2
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +11 -10
- package/node_modules/@maka/runtime/dist/shell-tools.js +77 -1
- package/node_modules/@maka/runtime/dist/telemetry/model-pricing.generated.js +93 -83
- package/node_modules/@maka/runtime/dist/test-connection.js +6 -6
- package/node_modules/@maka/runtime/dist/tool-availability.js +74 -5
- package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +333 -52
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +34 -3
- package/node_modules/@maka/runtime/dist/tool-runtime.js +62 -6
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +39 -16
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +10 -3
- package/node_modules/@maka/runtime-host/dist/client/catalog-reader.js +59 -18
- package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +3 -2
- package/node_modules/@maka/runtime-host/dist/client/connection.js +72 -31
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +49 -4
- package/node_modules/@maka/runtime-host/dist/client/index.js +3 -2
- package/node_modules/@maka/runtime-host/dist/client/oauth-presentation.js +1 -1
- package/node_modules/@maka/runtime-host/dist/client/owner-connection-code.js +32 -1
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +26 -4
- package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +8 -0
- package/node_modules/@maka/runtime-host/dist/operator/access-management-frame.js +10 -1
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +2 -0
- package/node_modules/@maka/runtime-host/dist/operator/peer-management-frame.js +2 -0
- package/node_modules/@maka/runtime-host/dist/operator/service-management-frame.js +2 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +56 -12
- package/node_modules/@maka/runtime-host/dist/peer-mesh/owner.js +4 -0
- package/node_modules/@maka/runtime-host/dist/protocol/client-capability.js +22 -1
- package/node_modules/@maka/runtime-host/dist/protocol/configuration.js +55 -9
- package/node_modules/@maka/{storage/dist/task-ledger-store-internal.js → runtime-host/dist/protocol/connection-catalog-change.js} +7 -13
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +37 -0
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +49 -1
- package/node_modules/@maka/runtime-host/dist/protocol/network-proxy.js +1 -7
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +512 -0
- package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +72 -61
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +4 -2
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +5 -12
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +92 -4
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +17 -14
- package/node_modules/@maka/runtime-host/dist/server/access-credential-metadata.js +4 -2
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +119 -47
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-execution-coordinator.js +1 -2
- package/node_modules/@maka/runtime-host/dist/server/bootstrap-runtime-policy.js +10 -4
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +0 -9
- package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +192 -18
- package/node_modules/@maka/runtime-host/dist/server/client-capability-invocation-broker.js +122 -48
- package/node_modules/@maka/runtime-host/dist/server/client-capability-provider-id.js +31 -0
- package/node_modules/@maka/runtime-host/dist/server/configuration-coordinator.js +20 -1
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +163 -28
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/execution-service.js +4 -1
- package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +249 -0
- package/node_modules/@maka/runtime-host/dist/server/extension-package-manifest.js +262 -0
- package/node_modules/@maka/runtime-host/dist/server/host-change-feed.js +11 -0
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +15 -0
- package/node_modules/@maka/runtime-host/dist/server/index.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +181 -13
- package/node_modules/@maka/runtime-host/dist/server/interaction-projection.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/listener-set.js +8 -4
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +88 -22
- package/node_modules/@maka/runtime-host/dist/server/model-metadata-refresh.js +96 -0
- package/node_modules/@maka/runtime-host/dist/server/network-proxy-coordinator.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/operation-dispatcher.js +43 -118
- package/node_modules/@maka/runtime-host/dist/server/peer-listener.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-composition-patch.js +58 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-composition-store.js +141 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-package-loader.js +130 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-package-store.js +528 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +249 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +1130 -0
- package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +24 -5
- package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +57 -5
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +3 -3
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +35 -3
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +16 -0
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +10 -2
- package/node_modules/@maka/runtime-host/dist/server/web-fetch-tool.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +276 -3
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +101 -1
- package/node_modules/@maka/runtime-host/dist/transport/peer-native.js +1 -0
- package/node_modules/@maka/runtime-host/dist/webrtc-stun-policy.js +114 -0
- package/node_modules/@maka/runtime-host/package.json +2 -0
- package/node_modules/@maka/storage/dist/agent-run-store.js +4 -0
- package/node_modules/@maka/storage/dist/artifact-store.js +7 -23
- package/node_modules/@maka/storage/dist/conversation-operational-state.js +3 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +3 -0
- package/node_modules/@maka/storage/dist/interaction-store-public.js +1 -1
- package/node_modules/@maka/storage/dist/interaction-store.js +173 -0
- package/node_modules/@maka/storage/dist/production-session-snapshot.js +761 -0
- package/node_modules/@maka/storage/dist/quiescent-session-snapshot.js +1 -1
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +19 -22
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +205 -42
- package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +2 -2
- package/node_modules/@maka/storage/dist/runtime-policy-stores.js +5 -2
- package/node_modules/@maka/storage/dist/session-message-projection.js +1 -1
- package/node_modules/@maka/storage/dist/session-store.js +32 -6
- package/node_modules/@maka/storage/dist/session-todo-store.js +6 -68
- package/node_modules/@maka/storage/dist/settings-store.js +16 -25
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +19 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +10 -1
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +73 -3
- package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +2 -10
- package/node_modules/@maka/storage/package.json +2 -0
- package/node_modules/fast-uri/index.js +215 -47
- package/node_modules/fast-uri/lib/schemes.js +9 -4
- package/node_modules/fast-uri/lib/utils.js +396 -92
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
- package/node_modules/qs/CHANGELOG.md +15 -0
- package/node_modules/qs/README.md +19 -1
- package/node_modules/qs/dist/qs.js +21 -21
- package/node_modules/qs/eslint.config.mjs +1 -1
- package/node_modules/qs/lib/parse.js +3 -4
- package/node_modules/qs/lib/stringify.js +23 -8
- package/node_modules/qs/lib/utils.js +10 -3
- package/node_modules/qs/package.json +4 -4
- package/package.json +1 -1
- package/node_modules/@maka/core/dist/task-ledger.js +0 -669
- package/node_modules/@maka/storage/dist/task-ledger-authority.js +0 -121
- package/node_modules/@maka/storage/dist/task-ledger-store.js +0 -663
|
@@ -140,6 +140,10 @@ function snapshotMessageContent(content) {
|
|
|
140
140
|
}
|
|
141
141
|
if (snapshot.attachments)
|
|
142
142
|
Object.freeze(snapshot.attachments);
|
|
143
|
+
for (const reference of snapshot.directoryReferences ?? [])
|
|
144
|
+
Object.freeze(reference);
|
|
145
|
+
if (snapshot.directoryReferences)
|
|
146
|
+
Object.freeze(snapshot.directoryReferences);
|
|
143
147
|
for (const quote of snapshot.quotes ?? [])
|
|
144
148
|
Object.freeze(quote);
|
|
145
149
|
if (snapshot.quotes)
|
|
@@ -51,6 +51,7 @@ export class RootTurnCoordinator {
|
|
|
51
51
|
assertScheduledTaskRecoveryAdmission;
|
|
52
52
|
agentGraphEpochs;
|
|
53
53
|
nameSessionFromRootMessage;
|
|
54
|
+
directoryHostId;
|
|
54
55
|
handlers = {
|
|
55
56
|
'turn.resume.query': (input, context) => this.queryTurnResume(input, context),
|
|
56
57
|
'turn.resume.start': (input, context) => this.startTurnResume(input, context),
|
|
@@ -62,7 +63,7 @@ export class RootTurnCoordinator {
|
|
|
62
63
|
executionProjection;
|
|
63
64
|
attachmentValidator;
|
|
64
65
|
prepareSkillInvocation;
|
|
65
|
-
constructor(manager, stores, sessionAdmission, rootAdmissionOwner, interactions, messages, continuity, acquireRecoveryResidency, requestHostDrain, clientCapabilities, resolveExecutionObserver, assertScheduledTaskRecoveryAdmission, attachmentValidator, prepareSkillInvocation, agentGraphEpochs, nameSessionFromRootMessage) {
|
|
66
|
+
constructor(manager, stores, sessionAdmission, rootAdmissionOwner, interactions, messages, continuity, acquireRecoveryResidency, requestHostDrain, clientCapabilities, resolveExecutionObserver, assertScheduledTaskRecoveryAdmission, attachmentValidator, prepareSkillInvocation, agentGraphEpochs, nameSessionFromRootMessage, directoryHostId) {
|
|
66
67
|
this.manager = manager;
|
|
67
68
|
this.sessionAdmission = sessionAdmission;
|
|
68
69
|
this.rootAdmissionOwner = rootAdmissionOwner;
|
|
@@ -76,6 +77,7 @@ export class RootTurnCoordinator {
|
|
|
76
77
|
this.assertScheduledTaskRecoveryAdmission = assertScheduledTaskRecoveryAdmission;
|
|
77
78
|
this.agentGraphEpochs = agentGraphEpochs;
|
|
78
79
|
this.nameSessionFromRootMessage = nameSessionFromRootMessage;
|
|
80
|
+
this.directoryHostId = directoryHostId;
|
|
79
81
|
this.stores = authenticateExecutionStoresWriter(stores, 'interactive');
|
|
80
82
|
this.executionProjection = new HostedExecutionProjectionReader(this.stores);
|
|
81
83
|
this.#admissions = new HostedExecutionAdmissionRegistry((sessionId) => this.#executions.has(sessionId));
|
|
@@ -642,7 +644,7 @@ export class RootTurnCoordinator {
|
|
|
642
644
|
failed: [],
|
|
643
645
|
receipts: [],
|
|
644
646
|
};
|
|
645
|
-
const canonicalContent = preflightRootMessageContent(prepared.content);
|
|
647
|
+
const canonicalContent = preflightRootMessageContent(this.validateDirectoryReferences(input.sessionId, prepared.content));
|
|
646
648
|
if (!canonicalContent.ok)
|
|
647
649
|
return { error: 'Prepared message content exceeds durable limits' };
|
|
648
650
|
const binding = prepared.commitCapabilityBinding
|
|
@@ -763,17 +765,34 @@ export class RootTurnCoordinator {
|
|
|
763
765
|
if (parseSkillInvocationTokens(content.text).length === 0) {
|
|
764
766
|
return {
|
|
765
767
|
kind: 'ready',
|
|
766
|
-
content,
|
|
768
|
+
content: this.validateDirectoryReferences(input.sessionId, content),
|
|
767
769
|
skillInvocation: { loaded: [], failed: [], receipts: [] },
|
|
768
770
|
};
|
|
769
771
|
}
|
|
770
|
-
const prepare = () =>
|
|
772
|
+
const prepare = async () => {
|
|
773
|
+
const prepared = await this.prepareSkillInvocationContent(input.sessionId, input.turnId, content, []);
|
|
774
|
+
return prepared.kind === 'ready'
|
|
775
|
+
? {
|
|
776
|
+
...prepared,
|
|
777
|
+
content: this.validateDirectoryReferences(input.sessionId, prepared.content),
|
|
778
|
+
}
|
|
779
|
+
: prepared;
|
|
780
|
+
};
|
|
771
781
|
if (input.placement === 'current_turn')
|
|
772
782
|
return prepare();
|
|
773
783
|
const preview = await this.previewCapabilityBinding(input.sessionId, '', prepare);
|
|
774
784
|
return preview.ok ? preview.value : { kind: 'rejected', error: preview.message };
|
|
775
785
|
});
|
|
776
786
|
}
|
|
787
|
+
validateDirectoryReferences(sessionId, content) {
|
|
788
|
+
if (!content.directoryReferences?.length)
|
|
789
|
+
return content;
|
|
790
|
+
if (!this.directoryHostId ||
|
|
791
|
+
content.directoryReferences.some((reference) => reference.hostId !== this.directoryHostId)) {
|
|
792
|
+
throw new RuntimeHostedRootUnavailableError(sessionId, 'Directory references belong to a different Runtime Host');
|
|
793
|
+
}
|
|
794
|
+
return content;
|
|
795
|
+
}
|
|
777
796
|
claimStop(input, commitQueueFence, admission) {
|
|
778
797
|
return this.runCommand(async () => {
|
|
779
798
|
const disposition = await this.prepareStopDisposition(input, commitQueueFence, admission);
|
|
@@ -957,7 +976,7 @@ export class RootTurnCoordinator {
|
|
|
957
976
|
const prepared = await this.prepareRootMessageContent(request, lease);
|
|
958
977
|
if (prepared.kind === 'rejected')
|
|
959
978
|
return completedStart(prepared.outcome);
|
|
960
|
-
const canonicalContent = preflightRootMessageContent(prepared.content);
|
|
979
|
+
const canonicalContent = preflightRootMessageContent(this.validateDirectoryReferences(request.sessionId, prepared.content));
|
|
961
980
|
if (!canonicalContent.ok)
|
|
962
981
|
return completedStart(canonicalContent.outcome);
|
|
963
982
|
const attachments = canonicalContent.content.attachments ?? [];
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { resolveConnectionModelCatalog } from '@maka/core/model-catalog';
|
|
19
20
|
import { authenticateRuntimePolicyStoresWriter, RuntimePolicyStoreError, } from '@maka/storage/runtime-policy-stores';
|
|
20
21
|
import { CONNECTION_CATALOG_PAGE_MAX_BYTES, CONNECTION_CATALOG_PAGE_MAX_ITEMS, } from '../protocol/index.js';
|
|
21
22
|
import { buildHostAgentSettingsTools } from './agent-settings-tools.js';
|
|
@@ -28,6 +29,7 @@ export class HostRuntimePolicyCoordinator {
|
|
|
28
29
|
handlers = {
|
|
29
30
|
'runtime.policy.query': () => this.#queryPolicy(),
|
|
30
31
|
'runtime.policy.mutate': (input) => this.#mutatePolicy(input),
|
|
32
|
+
'runtime.policy.network-proxy.update': (input) => this.#updateNetworkProxy(input),
|
|
31
33
|
'connection.catalog.query': (input) => this.#queryCatalog(input),
|
|
32
34
|
'connection.catalog.create': (input) => this.#createConnection(input),
|
|
33
35
|
'connection.catalog.update': (input) => this.#updateConnection(input),
|
|
@@ -64,6 +66,27 @@ export class HostRuntimePolicyCoordinator {
|
|
|
64
66
|
return projectPolicyMutation(await this.#stores.runtimePolicy.mutate(input));
|
|
65
67
|
});
|
|
66
68
|
}
|
|
69
|
+
async #updateNetworkProxy(input) {
|
|
70
|
+
return this.#storeMutation(async () => {
|
|
71
|
+
try {
|
|
72
|
+
await this.validateMutation({
|
|
73
|
+
expectedRevision: input.expectedPolicyRevision,
|
|
74
|
+
operation: { kind: 'set_network_proxy', value: input.networkProxy },
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new RuntimePolicyStoreError('invalid_policy_input', 'Network proxy update failed Host validation', { cause: error });
|
|
79
|
+
}
|
|
80
|
+
const result = await this.#stores.operations.updateNetworkProxy(input);
|
|
81
|
+
return result.kind === 'committed'
|
|
82
|
+
? {
|
|
83
|
+
kind: 'committed',
|
|
84
|
+
revision: result.snapshot.revision,
|
|
85
|
+
credentialStatus: result.credentialStatus,
|
|
86
|
+
}
|
|
87
|
+
: result;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
67
90
|
async #queryCatalog(input) {
|
|
68
91
|
const stored = await this.#storeQuery(() => this.#stores.connectionCatalog.getSnapshot());
|
|
69
92
|
if (!stored.ok)
|
|
@@ -142,7 +165,9 @@ export class HostRuntimePolicyCoordinator {
|
|
|
142
165
|
async #setCredential(input) {
|
|
143
166
|
return this.#storeMutation(async () => {
|
|
144
167
|
const result = await this.#stores.credentialVault.set(input);
|
|
145
|
-
if (result.kind === 'connection_not_found' ||
|
|
168
|
+
if (result.kind === 'connection_not_found' ||
|
|
169
|
+
result.kind === 'connection_stale' ||
|
|
170
|
+
result.kind === 'credential_stale') {
|
|
146
171
|
return result;
|
|
147
172
|
}
|
|
148
173
|
const status = result.snapshot.entries.find((entry) => sameLocator(entry.locator, input.locator));
|
|
@@ -155,6 +180,9 @@ export class HostRuntimePolicyCoordinator {
|
|
|
155
180
|
async #deleteCredential(input) {
|
|
156
181
|
return this.#storeMutation(async () => {
|
|
157
182
|
const result = await this.#stores.credentialVault.delete(input);
|
|
183
|
+
if (result.kind === 'connection_stale') {
|
|
184
|
+
throw invariantFailure('Credential deletion returned an impossible connection conflict');
|
|
185
|
+
}
|
|
158
186
|
if (result.kind === 'connection_not_found' || result.kind === 'credential_stale') {
|
|
159
187
|
return result;
|
|
160
188
|
}
|
|
@@ -295,15 +323,32 @@ function projectCatalogItems(snapshot) {
|
|
|
295
323
|
// table: a header item is atomic to the paginator, so a long declaration
|
|
296
324
|
// list would make the whole connection unreadable.
|
|
297
325
|
const { enabledModelIds, models, relayModelProfiles,
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
|
|
326
|
+
// When the Host last ran discovery, and the marker that invalidates a
|
|
327
|
+
// test when model facts change: both are the Host's own bookkeeping,
|
|
328
|
+
// not part of the client-visible catalog protocol.
|
|
329
|
+
modelsFetchedAt: _modelsFetchedAt, lastTestModelFactsFingerprint: _lastTestModelFactsFingerprint, ...header } = connection;
|
|
330
|
+
// The Host resolves the catalog because it owns the model metadata the
|
|
331
|
+
// resolution merges in. A client that merged its own bundled copy would
|
|
332
|
+
// describe a model by the version it happens to ship, so two clients on
|
|
333
|
+
// one Host could disagree about the same model.
|
|
334
|
+
const catalogEntries = resolveConnectionModelCatalog({
|
|
335
|
+
slug: connection.slug,
|
|
336
|
+
providerType: connection.providerType,
|
|
337
|
+
defaultModel: snapshot.defaultTarget?.connectionId === connection.connectionId
|
|
338
|
+
? snapshot.defaultTarget.modelId
|
|
339
|
+
: '',
|
|
340
|
+
enabledModelIds: [...enabledModelIds],
|
|
341
|
+
models: [...models],
|
|
342
|
+
...(connection.modelSource === undefined ? {} : { modelSource: connection.modelSource }),
|
|
343
|
+
...(relayModelProfiles === undefined ? {} : { relayModelProfiles }),
|
|
344
|
+
});
|
|
301
345
|
items.push({
|
|
302
346
|
kind: 'connection',
|
|
303
347
|
connectionIndex,
|
|
304
348
|
...header,
|
|
305
349
|
enabledModelIdCount: enabledModelIds.length,
|
|
306
350
|
modelCount: models.length,
|
|
351
|
+
catalogEntryCount: catalogEntries.length,
|
|
307
352
|
});
|
|
308
353
|
for (const [itemIndex, modelId] of enabledModelIds.entries()) {
|
|
309
354
|
const relayProfile = relayModelProfiles?.[modelId];
|
|
@@ -316,7 +361,14 @@ function projectCatalogItems(snapshot) {
|
|
|
316
361
|
});
|
|
317
362
|
}
|
|
318
363
|
for (const [itemIndex, model] of models.entries()) {
|
|
319
|
-
|
|
364
|
+
// The override's effect travels; which fields it touched does not. That
|
|
365
|
+
// provenance answers one Host-side question — whether a context window
|
|
366
|
+
// was set by hand — and this page is not where it gets asked.
|
|
367
|
+
const { factOverriddenFields: _factOverriddenFields, ...projected } = model;
|
|
368
|
+
items.push({ kind: 'model', connectionIndex, itemIndex, model: projected });
|
|
369
|
+
}
|
|
370
|
+
for (const [itemIndex, entry] of catalogEntries.entries()) {
|
|
371
|
+
items.push({ kind: 'catalog_entry', connectionIndex, itemIndex, entry });
|
|
320
372
|
}
|
|
321
373
|
}
|
|
322
374
|
return items;
|
|
@@ -23,7 +23,7 @@ import { isModelExplicitlyUnsupportedForChat } from '@maka/core/model-catalog';
|
|
|
23
23
|
import { thinkingVariantsForConnection } from '@maka/core/model-thinking';
|
|
24
24
|
import { executionBoundaryDisplayMode, } from '@maka/core/sandbox-boundary';
|
|
25
25
|
import { DEFAULT_SESSION_NAME, normalizeUserSessionName } from '@maka/core/session-name';
|
|
26
|
-
import { isSessionStartModeLabel as isExecutionSemanticLabel, sessionStartModeSpec, } from '@maka/core/
|
|
26
|
+
import { isSessionStartModeLabel as isExecutionSemanticLabel, sessionStartModeSpec, } from '@maka/core/session-start-mode';
|
|
27
27
|
import { isWorkHubCoordinationSessionId, isWorkHubCoordinationSessionTarget, } from '@maka/core/session';
|
|
28
28
|
import { isSessionNotFoundError, SessionMetadataConflictError, SessionMetadataVersionConflictError, SessionReadMarkerMessageNotFoundError, } from '@maka/storage/execution-stores';
|
|
29
29
|
import { SessionConfigurationRevisionConflictError, SessionConfigurationTransitionError, } from '@maka/runtime/session-manager';
|
|
@@ -108,6 +108,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
108
108
|
...(workspace.projectId === null ? {} : { projectId: workspace.projectId }),
|
|
109
109
|
name: prepared.name,
|
|
110
110
|
labels: [...prepared.labels],
|
|
111
|
+
llmConnectionId: model.connectionId,
|
|
111
112
|
llmConnectionSlug: model.connectionSlug,
|
|
112
113
|
model: model.model,
|
|
113
114
|
...(input.thinkingLevel === undefined ? {} : { thinkingLevel: input.thinkingLevel }),
|
|
@@ -68,7 +68,7 @@ export class HostSessionRetirementCoordinator {
|
|
|
68
68
|
#continuity;
|
|
69
69
|
#artifacts;
|
|
70
70
|
#sessionTodo;
|
|
71
|
-
#
|
|
71
|
+
#contextOffload;
|
|
72
72
|
#purgeOperationalState;
|
|
73
73
|
#purgeAgentGraphState;
|
|
74
74
|
#worktrees;
|
|
@@ -95,7 +95,7 @@ export class HostSessionRetirementCoordinator {
|
|
|
95
95
|
this.#continuity = options.continuity;
|
|
96
96
|
this.#artifacts = options.artifacts;
|
|
97
97
|
this.#sessionTodo = options.sessionTodo;
|
|
98
|
-
this.#
|
|
98
|
+
this.#contextOffload = options.contextOffload;
|
|
99
99
|
this.#purgeOperationalState = options.purgeOperationalState;
|
|
100
100
|
this.#purgeAgentGraphState = options.purgeAgentGraphState;
|
|
101
101
|
this.#worktrees = options.worktrees;
|
|
@@ -201,7 +201,6 @@ export class HostSessionRetirementCoordinator {
|
|
|
201
201
|
if (plan.archive.sessionIds.length > 0) {
|
|
202
202
|
archiveHandles = await this.#prepareRetirement(plan.archive, 'archive');
|
|
203
203
|
}
|
|
204
|
-
await this.#assertNoContextOffloadReferences?.(plan.remove.sessionIds);
|
|
205
204
|
const allSessionIds = [...plan.remove.sessionIds, ...plan.archive.sessionIds];
|
|
206
205
|
await this.#finalizeWorkspacePatches(allSessionIds);
|
|
207
206
|
await this.#disposeBackends(allSessionIds);
|
|
@@ -494,6 +493,7 @@ export class HostSessionRetirementCoordinator {
|
|
|
494
493
|
purgeSessionSidecars({
|
|
495
494
|
artifacts: this.#artifacts,
|
|
496
495
|
sessionTodo: this.#sessionTodo,
|
|
496
|
+
...(this.#contextOffload ? { contextOffload: this.#contextOffload } : {}),
|
|
497
497
|
purgeOperationalState: this.#purgeOperationalState,
|
|
498
498
|
}, sessionId),
|
|
499
499
|
this.#purgeAgentGraphState(sessionId),
|
|
@@ -20,7 +20,7 @@ import { createHash, randomUUID } from 'node:crypto';
|
|
|
20
20
|
import { isDeepResearchSession } from '@maka/core/deep-research';
|
|
21
21
|
import { SIDE_CONVERSATION_SESSION_LABEL } from '@maka/core/side-conversation';
|
|
22
22
|
import { isWorkHubCoordinationSessionId, isWorkHubCoordinationSessionTarget, sessionRevisionFamilyId, } from '@maka/core/session';
|
|
23
|
-
import { archivedToolResultContainsLinkedChildReferences, archivedToolResultContainsConversationOwnedReferences, cloneConversationRuntimeLedger, collectConversationCopyLinkedChildReferences, collectConversationCopySessionFileRefs, createConversationCopySlice, prepareConversationRuntimeLedgerCopy, } from '@maka/runtime/conversation-copy';
|
|
23
|
+
import { archivedToolResultContainsLinkedChildReferences, archivedToolResultContainsConversationOwnedReferences, cloneConversationRuntimeLedger, collectConversationCopyLinkedChildReferences, collectConversationCopySessionContextRefIds, collectConversationCopySessionFileRefs, createConversationCopySlice, prepareConversationRuntimeLedgerCopy, } from '@maka/runtime/conversation-copy';
|
|
24
24
|
import { isArchivedToolResultPlaceholder } from '@maka/runtime/context-budget';
|
|
25
25
|
import { decodeModelProjectionTransition, MODEL_PROJECTION_TRANSITION_EVENT_TYPE, } from '@maka/core/model-projection-transition';
|
|
26
26
|
import { authenticateInteractiveArtifactStoreWriter, } from '@maka/storage/artifact-stores';
|
|
@@ -52,7 +52,7 @@ export class HostSessionRevisionCoordinator {
|
|
|
52
52
|
const copies = (await this.#stores.sessionStore.listHeaders()).filter((header) => header.conversationCopy !== undefined);
|
|
53
53
|
for (const header of copies) {
|
|
54
54
|
if (header.conversationCopy.state === 'preparing')
|
|
55
|
-
await this.#
|
|
55
|
+
await this.#discardDuringRecovery(header);
|
|
56
56
|
}
|
|
57
57
|
const committed = copies.filter((header) => header.conversationCopy.state === 'committed');
|
|
58
58
|
const retained = new Set(committed
|
|
@@ -85,10 +85,18 @@ export class HostSessionRevisionCoordinator {
|
|
|
85
85
|
await this.options.manager.commitRevisionVersion(header.id);
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
await this.#
|
|
88
|
+
await this.#discardDuringRecovery(header);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
async #discardDuringRecovery(header) {
|
|
93
|
+
try {
|
|
94
|
+
await this.#discard(header);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error(`[runtime-host] conversation copy cleanup deferred during recovery (${header.id}): ${conversationCopyCommitFailureDiagnostic(error)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
92
100
|
async #copy(kind, input) {
|
|
93
101
|
if (isWorkHubCoordinationSessionId(input.targetSessionId)) {
|
|
94
102
|
return copyFailure('operation_conflict', 'Target Session identity is reserved for WorkHub coordination');
|
|
@@ -315,6 +323,28 @@ export class HostSessionRevisionCoordinator {
|
|
|
315
323
|
.filter(({ serializedResult }) => archivedToolResultContainsLinkedChildReferences(serializedResult) ||
|
|
316
324
|
archivedToolResultContainsConversationOwnedReferences(serializedResult, input.sourceSessionId, linkedReferences.references))
|
|
317
325
|
.map(({ descriptor, serializedResult }) => [descriptor.artifactId, serializedResult]));
|
|
326
|
+
const sourceContextRefIds = collectConversationCopySessionContextRefIds({
|
|
327
|
+
sourceSessionId: input.sourceSessionId,
|
|
328
|
+
messages: slice.messages,
|
|
329
|
+
runtimeEvents: plan.runs.flatMap(({ runtimeEvents }) => runtimeEvents),
|
|
330
|
+
archivedResults: archivePreflight.serializedResults,
|
|
331
|
+
});
|
|
332
|
+
if (sourceContextRefIds.length > 0 && !this.options.contextOffload) {
|
|
333
|
+
throw new Error('Session context copy authority is unavailable');
|
|
334
|
+
}
|
|
335
|
+
const contextCopy = sourceContextRefIds.length === 0
|
|
336
|
+
? { ok: true, copied: [] }
|
|
337
|
+
: await this.options.contextOffload.copyReferences({
|
|
338
|
+
sourceSessionId: input.sourceSessionId,
|
|
339
|
+
targetSessionId: input.targetSessionId,
|
|
340
|
+
references: sourceContextRefIds.map((sourceRefId) => ({
|
|
341
|
+
sourceRefId,
|
|
342
|
+
targetOwner: { kind: 'read_image_snapshot', ownerId: sourceRefId },
|
|
343
|
+
})),
|
|
344
|
+
});
|
|
345
|
+
if (!contextCopy.ok) {
|
|
346
|
+
throw new Error(`Session context references could not be copied: ${contextCopy.reason}`);
|
|
347
|
+
}
|
|
318
348
|
const artifactCopy = await this.#artifacts.copyConversationArtifacts({
|
|
319
349
|
sourceSessionId: input.sourceSessionId,
|
|
320
350
|
targetSessionId: input.targetSessionId,
|
|
@@ -340,6 +370,7 @@ export class HostSessionRevisionCoordinator {
|
|
|
340
370
|
targetSessionId: input.targetSessionId,
|
|
341
371
|
artifactIds: artifactCopy.artifactIds,
|
|
342
372
|
relativePaths: artifactCopy.relativePaths,
|
|
373
|
+
contextRefs: new Map(contextCopy.copied.map(({ sourceRefId, targetRefId }) => [sourceRefId, targetRefId])),
|
|
343
374
|
linkedChildren: kind === 'side_conversation'
|
|
344
375
|
? {
|
|
345
376
|
mode: 'snapshot',
|
|
@@ -544,6 +575,7 @@ export class HostSessionRevisionCoordinator {
|
|
|
544
575
|
await purgeSessionSidecars({
|
|
545
576
|
artifacts: this.#artifacts,
|
|
546
577
|
sessionTodo: this.#sessionTodo,
|
|
578
|
+
...(this.options.contextOffload ? { contextOffload: this.options.contextOffload } : {}),
|
|
547
579
|
purgeOperationalState: (sessionId) => this.#stores.purgeConversationOperationalState(sessionId),
|
|
548
580
|
}, header.id);
|
|
549
581
|
await this.#stores.sessionStore.discardStableConversationCopy(header.id, copy.requestFingerprint);
|
|
@@ -16,10 +16,26 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
const CONTEXT_GARBAGE_BATCH_BLOBS = 64;
|
|
20
|
+
async function retireContextSession(contextOffload, sessionId) {
|
|
21
|
+
await contextOffload.retireSession(sessionId);
|
|
22
|
+
for (;;) {
|
|
23
|
+
const collected = await contextOffload.collectGarbage({
|
|
24
|
+
olderThan: Number.MAX_SAFE_INTEGER,
|
|
25
|
+
maxBlobs: CONTEXT_GARBAGE_BATCH_BLOBS,
|
|
26
|
+
maxBytes: Number.MAX_SAFE_INTEGER,
|
|
27
|
+
});
|
|
28
|
+
if (!collected.hasMore)
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
19
32
|
export async function purgeSessionSidecars(authority, sessionId) {
|
|
20
33
|
const outcomes = await Promise.allSettled([
|
|
21
34
|
authority.artifacts.purgeSessionArtifacts(sessionId),
|
|
22
35
|
authority.sessionTodo.purgeSessionState(sessionId),
|
|
36
|
+
...(authority.contextOffload
|
|
37
|
+
? [retireContextSession(authority.contextOffload, sessionId)]
|
|
38
|
+
: []),
|
|
23
39
|
authority.purgeOperationalState(sessionId),
|
|
24
40
|
]);
|
|
25
41
|
const failures = outcomes.flatMap((outcome) => outcome.status === 'rejected' ? [outcome.reason] : []);
|
|
@@ -209,7 +209,11 @@ async function readRangeEdges(input) {
|
|
|
209
209
|
if (targetRecords.length > SESSION_TRANSCRIPT_RANGE_MAX_MESSAGES ||
|
|
210
210
|
targetBytes > SESSION_TRANSCRIPT_RANGE_MAX_BYTES) {
|
|
211
211
|
if (targetStart === 0) {
|
|
212
|
-
|
|
212
|
+
return {
|
|
213
|
+
selected: input.selected,
|
|
214
|
+
rangeBoundarySequence: null,
|
|
215
|
+
protectedTurnSequence: null,
|
|
216
|
+
};
|
|
213
217
|
}
|
|
214
218
|
reachedFarEdge = true;
|
|
215
219
|
break;
|
|
@@ -246,7 +250,11 @@ async function readRangeEdges(input) {
|
|
|
246
250
|
groupBytes > SESSION_TRANSCRIPT_RANGE_MAX_BYTES) {
|
|
247
251
|
if (groupStart > 0)
|
|
248
252
|
break;
|
|
249
|
-
|
|
253
|
+
return {
|
|
254
|
+
selected: input.selected,
|
|
255
|
+
rangeBoundarySequence: null,
|
|
256
|
+
protectedTurnSequence: null,
|
|
257
|
+
};
|
|
250
258
|
}
|
|
251
259
|
if (retainedMessages + group.length > SESSION_TRANSCRIPT_RANGE_MAX_MESSAGES ||
|
|
252
260
|
retainedBytes + groupBytes > SESSION_TRANSCRIPT_RANGE_MAX_BYTES) {
|
|
@@ -24,7 +24,7 @@ export function createHostWebFetchService(input) {
|
|
|
24
24
|
const createFetchTransport = input.createFetchTransport ?? createProxiedFetchTransport;
|
|
25
25
|
return {
|
|
26
26
|
fetch: async ({ url, sessionId, abortSignal }) => {
|
|
27
|
-
const resolved = await input.policy.
|
|
27
|
+
const resolved = await input.policy.resolveHostOutboundExecution();
|
|
28
28
|
if (resolved.kind === 'privacy_mode') {
|
|
29
29
|
throw new Error('WebFetch is disabled while privacy mode is active.');
|
|
30
30
|
}
|