maka-agent 0.2.0-dev.11.20260831 → 0.2.0-dev.12.20260901
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/dist/cli-core.js +25 -1
- 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-cli.js +150 -4
- 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 +5 -1
- 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 +13 -5
- package/dist/runtime-host-update-discovery.js +1 -0
- package/dist/tui-clipboard.js +86 -0
- package/dist/tui-copy-catalog.js +246 -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 +80 -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-readiness.js +3 -31
- package/node_modules/@maka/core/dist/deep-research.js +1 -20
- package/node_modules/@maka/core/dist/events.js +22 -1
- 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/model-catalog.js +221 -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 +4 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +34 -18
- package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +75 -0
- package/node_modules/@maka/core/dist/runtime-policy.js +2 -1
- 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 +119 -5
- 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/workhub-creation-intent.js +896 -0
- package/node_modules/@maka/core/package.json +6 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +7 -0
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +3 -2
- 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 +18 -1
- 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/quiescent-session-snapshot.js +78 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +3 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +1 -0
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +8 -4
- 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-runtime.js +50 -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 -0
- package/node_modules/@maka/runtime-host/dist/client/catalog-reader.js +19 -5
- package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +3 -2
- package/node_modules/@maka/runtime-host/dist/client/connection.js +22 -0
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/index.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/oauth-presentation.js +1 -1
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +4 -0
- package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +8 -0
- 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/owner.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/client-capability.js +22 -1
- 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/index.js +33 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +3 -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 +25 -61
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +4 -1
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +92 -4
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +15 -13
- 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/bootstrap-runtime-policy.js +10 -4
- 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/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 +117 -4
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +2 -2
- 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/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/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/operation-dispatcher.js +43 -118
- 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 +29 -4
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +2 -1
- 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 +16 -36
- package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +2 -2
- package/node_modules/@maka/storage/dist/runtime-policy-stores.js +1 -1
- 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/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/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';
|
|
@@ -295,15 +296,32 @@ function projectCatalogItems(snapshot) {
|
|
|
295
296
|
// table: a header item is atomic to the paginator, so a long declaration
|
|
296
297
|
// list would make the whole connection unreadable.
|
|
297
298
|
const { enabledModelIds, models, relayModelProfiles,
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
|
|
299
|
+
// When the Host last ran discovery, and the marker that invalidates a
|
|
300
|
+
// test when model facts change: both are the Host's own bookkeeping,
|
|
301
|
+
// not part of the client-visible catalog protocol.
|
|
302
|
+
modelsFetchedAt: _modelsFetchedAt, lastTestModelFactsFingerprint: _lastTestModelFactsFingerprint, ...header } = connection;
|
|
303
|
+
// The Host resolves the catalog because it owns the model metadata the
|
|
304
|
+
// resolution merges in. A client that merged its own bundled copy would
|
|
305
|
+
// describe a model by the version it happens to ship, so two clients on
|
|
306
|
+
// one Host could disagree about the same model.
|
|
307
|
+
const catalogEntries = resolveConnectionModelCatalog({
|
|
308
|
+
slug: connection.slug,
|
|
309
|
+
providerType: connection.providerType,
|
|
310
|
+
defaultModel: snapshot.defaultTarget?.connectionId === connection.connectionId
|
|
311
|
+
? snapshot.defaultTarget.modelId
|
|
312
|
+
: '',
|
|
313
|
+
enabledModelIds: [...enabledModelIds],
|
|
314
|
+
models: [...models],
|
|
315
|
+
...(connection.modelSource === undefined ? {} : { modelSource: connection.modelSource }),
|
|
316
|
+
...(relayModelProfiles === undefined ? {} : { relayModelProfiles }),
|
|
317
|
+
});
|
|
301
318
|
items.push({
|
|
302
319
|
kind: 'connection',
|
|
303
320
|
connectionIndex,
|
|
304
321
|
...header,
|
|
305
322
|
enabledModelIdCount: enabledModelIds.length,
|
|
306
323
|
modelCount: models.length,
|
|
324
|
+
catalogEntryCount: catalogEntries.length,
|
|
307
325
|
});
|
|
308
326
|
for (const [itemIndex, modelId] of enabledModelIds.entries()) {
|
|
309
327
|
const relayProfile = relayModelProfiles?.[modelId];
|
|
@@ -316,7 +334,14 @@ function projectCatalogItems(snapshot) {
|
|
|
316
334
|
});
|
|
317
335
|
}
|
|
318
336
|
for (const [itemIndex, model] of models.entries()) {
|
|
319
|
-
|
|
337
|
+
// The override's effect travels; which fields it touched does not. That
|
|
338
|
+
// provenance answers one Host-side question — whether a context window
|
|
339
|
+
// was set by hand — and this page is not where it gets asked.
|
|
340
|
+
const { factOverriddenFields: _factOverriddenFields, ...projected } = model;
|
|
341
|
+
items.push({ kind: 'model', connectionIndex, itemIndex, model: projected });
|
|
342
|
+
}
|
|
343
|
+
for (const [itemIndex, entry] of catalogEntries.entries()) {
|
|
344
|
+
items.push({ kind: 'catalog_entry', connectionIndex, itemIndex, entry });
|
|
320
345
|
}
|
|
321
346
|
}
|
|
322
347
|
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 }),
|
|
@@ -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
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { createHash } from 'node:crypto';
|
|
20
20
|
import { WORKHUB_COORDINATION_SESSION_ID, isWorkHubCoordinationSessionTarget, } from '@maka/core/session';
|
|
21
|
+
import { readWorkHubRequestIntent, workHubCorrectionTargetsSession, workHubCreationAuthorizesTitle, } from '@maka/core/workhub-creation-intent';
|
|
21
22
|
import { WORKHUB_COORDINATION_CANDIDATE_MAX_ITEMS } from '../protocol/index.js';
|
|
22
23
|
const SIDE_CONVERSATION_LABEL = 'mode:side_conversation';
|
|
23
24
|
const ACTION_REPLAY_MAX_ITEMS = 256;
|
|
@@ -85,11 +86,23 @@ export class WorkHubCoordinationActionGate {
|
|
|
85
86
|
}
|
|
86
87
|
async #act(input, fingerprint, context) {
|
|
87
88
|
const proposal = input.proposal;
|
|
89
|
+
const requestIntent = readWorkHubRequestIntent(input.userText);
|
|
90
|
+
if (requestIntent.execution === 'ambiguous' &&
|
|
91
|
+
proposal.disposition !== 'answer_here' &&
|
|
92
|
+
proposal.disposition !== 'clarify') {
|
|
93
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub cannot write from an ambiguous instruction');
|
|
94
|
+
}
|
|
88
95
|
const durable = await this.#effects.readAssignment(input.actionId);
|
|
89
96
|
if (durable) {
|
|
90
|
-
|
|
97
|
+
const replayFingerprint = durable.replacesActionId
|
|
98
|
+
? replacementActionFingerprint(input, durable.targetSessionId)
|
|
99
|
+
: fingerprint;
|
|
100
|
+
if (durable.actionFingerprint !== replayFingerprint) {
|
|
91
101
|
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub action identity belongs to a different proposal');
|
|
92
102
|
}
|
|
103
|
+
if (durable.replacesActionId) {
|
|
104
|
+
await this.#assertReplacementReplayTarget(input, durable.targetSessionId);
|
|
105
|
+
}
|
|
93
106
|
return this.#assign(assignmentInputFromRecord(durable), context);
|
|
94
107
|
}
|
|
95
108
|
if (proposal.disposition === 'answer_here') {
|
|
@@ -107,12 +120,40 @@ export class WorkHubCoordinationActionGate {
|
|
|
107
120
|
return { disposition: 'clarify', coordinationTurnId: turnId };
|
|
108
121
|
}
|
|
109
122
|
if (proposal.disposition === 'create_new') {
|
|
110
|
-
if (!input.create) {
|
|
111
|
-
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub creation
|
|
123
|
+
if (!input.create || !workHubCreationAuthorizesTitle(requestIntent, proposal.title)) {
|
|
124
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub creation requires an unambiguous instruction and creation context');
|
|
112
125
|
}
|
|
113
126
|
const sessionId = workHubCreatedSessionId(input.actionId);
|
|
114
127
|
return this.#assign(delegationAssignment(input, fingerprint, sessionId, proposal.title), context);
|
|
115
128
|
}
|
|
129
|
+
if (proposal.disposition === 'replace') {
|
|
130
|
+
if (input.confirmation?.kind !== 'user_correction' || !requestIntent.correction.cue) {
|
|
131
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement requires explicit correction in trusted user text');
|
|
132
|
+
}
|
|
133
|
+
const replaced = await this.#effects.readAssignment(proposal.replacesActionId);
|
|
134
|
+
if (!replaced) {
|
|
135
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub can replace only a durable delegation it owns');
|
|
136
|
+
}
|
|
137
|
+
if (await this.#effects.readSupersession(replaced.delegationId)) {
|
|
138
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub delegation has already been superseded');
|
|
139
|
+
}
|
|
140
|
+
const prepared = await this.#effects.readReplacement(replaced.delegationId);
|
|
141
|
+
if (prepared) {
|
|
142
|
+
if (!isExplicitWorkHubCorrectionText(input.userText, prepared.disposition, prepared.targetSessionName)) {
|
|
143
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement target is not affirmed in trusted user text');
|
|
144
|
+
}
|
|
145
|
+
if (prepared.actionId !== input.actionId ||
|
|
146
|
+
prepared.actionFingerprint !==
|
|
147
|
+
replacementActionFingerprint(input, prepared.targetSessionId)) {
|
|
148
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub delegation already has a different replacement intent');
|
|
149
|
+
}
|
|
150
|
+
await this.#assertReplacementReplayTarget(input, prepared.targetSessionId);
|
|
151
|
+
return this.#replace(prepared, context);
|
|
152
|
+
}
|
|
153
|
+
const replacement = await this.#replacementAssignment(input, replaced);
|
|
154
|
+
const intent = await this.#effects.prepareReplacement(replacement);
|
|
155
|
+
return this.#replace(intent, context);
|
|
156
|
+
}
|
|
116
157
|
const candidates = await this.candidates();
|
|
117
158
|
if (candidates.candidateSetId !== input.candidateSetId) {
|
|
118
159
|
throw new WorkHubActionGateFailure('candidate_set_stale', 'WorkHub Session candidates changed; refresh before delegating');
|
|
@@ -124,8 +165,175 @@ export class WorkHubCoordinationActionGate {
|
|
|
124
165
|
this.#assertTarget(target);
|
|
125
166
|
return this.#assign(delegationAssignment(input, fingerprint, target.sessionId, target.sessionName), context);
|
|
126
167
|
}
|
|
168
|
+
async #replacementAssignment(input, replaced) {
|
|
169
|
+
if (input.proposal.disposition !== 'replace') {
|
|
170
|
+
throw new WorkHubActionGateFailure('action_conflict', 'Invalid WorkHub replacement');
|
|
171
|
+
}
|
|
172
|
+
const target = input.proposal.target;
|
|
173
|
+
if (target.disposition === 'create_new') {
|
|
174
|
+
if (!isExplicitWorkHubCorrectionText(input.userText, 'create_new', target.title)) {
|
|
175
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement creation requires explicit non-negated user intent');
|
|
176
|
+
}
|
|
177
|
+
if (!input.create) {
|
|
178
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement creation context is unavailable');
|
|
179
|
+
}
|
|
180
|
+
const targetSessionId = workHubCreatedSessionId(input.actionId);
|
|
181
|
+
return {
|
|
182
|
+
actionId: input.actionId,
|
|
183
|
+
actionFingerprint: replacementActionFingerprint(input, targetSessionId),
|
|
184
|
+
targetSessionId,
|
|
185
|
+
targetSessionName: target.title,
|
|
186
|
+
disposition: 'create_new',
|
|
187
|
+
userText: input.userText,
|
|
188
|
+
create: { title: target.title, workspace: input.create.workspace },
|
|
189
|
+
replacesActionId: replaced.actionId,
|
|
190
|
+
replacesDelegationId: replaced.delegationId,
|
|
191
|
+
replacedTargetSessionId: replaced.targetSessionId,
|
|
192
|
+
replacedTargetMessageId: replaced.targetMessageId,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const candidates = await this.candidates();
|
|
196
|
+
if (candidates.candidateSetId !== input.candidateSetId) {
|
|
197
|
+
throw new WorkHubActionGateFailure('candidate_set_stale', 'WorkHub Session candidates changed; refresh before replacing');
|
|
198
|
+
}
|
|
199
|
+
const destination = candidates.candidates.find((candidate) => candidate.candidateRef === target.candidateRef);
|
|
200
|
+
if (!destination) {
|
|
201
|
+
throw new WorkHubActionGateFailure('candidate_unavailable', 'WorkHub replacement target is not in the admitted candidate set');
|
|
202
|
+
}
|
|
203
|
+
this.#assertTarget(destination);
|
|
204
|
+
if (!isExplicitWorkHubCorrectionText(input.userText, 'delegate_existing', destination.sessionName)) {
|
|
205
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement target is not affirmed in trusted user text');
|
|
206
|
+
}
|
|
207
|
+
if (destination.sessionId === replaced.targetSessionId) {
|
|
208
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement must choose a different Session');
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
actionId: input.actionId,
|
|
212
|
+
actionFingerprint: replacementActionFingerprint(input, destination.sessionId),
|
|
213
|
+
targetSessionId: destination.sessionId,
|
|
214
|
+
targetSessionName: destination.sessionName,
|
|
215
|
+
disposition: 'delegate_existing',
|
|
216
|
+
userText: input.userText,
|
|
217
|
+
replacesActionId: replaced.actionId,
|
|
218
|
+
replacesDelegationId: replaced.delegationId,
|
|
219
|
+
replacedTargetSessionId: replaced.targetSessionId,
|
|
220
|
+
replacedTargetMessageId: replaced.targetMessageId,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async #replace(replacement, context) {
|
|
224
|
+
const aborted = await this.#effects.readReplacementAbort(replacement.replacesDelegationId);
|
|
225
|
+
if (aborted) {
|
|
226
|
+
if (aborted.actionId !== replacement.actionId ||
|
|
227
|
+
aborted.actionFingerprint !== replacement.actionFingerprint) {
|
|
228
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub delegation replacement has a different terminal outcome');
|
|
229
|
+
}
|
|
230
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement was aborted after its source delegation retired');
|
|
231
|
+
}
|
|
232
|
+
const superseded = await this.#effects.readSupersession(replacement.replacesDelegationId);
|
|
233
|
+
if (superseded) {
|
|
234
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub delegation has already been superseded');
|
|
235
|
+
}
|
|
236
|
+
const source = await this.#effects.readAssignment(replacement.replacesActionId);
|
|
237
|
+
if (!source ||
|
|
238
|
+
source.delegationId !== replacement.replacesDelegationId ||
|
|
239
|
+
source.targetSessionId !== replacement.replacedTargetSessionId ||
|
|
240
|
+
source.targetMessageId !== replacement.replacedTargetMessageId) {
|
|
241
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement source identity changed');
|
|
242
|
+
}
|
|
243
|
+
let assignment = assignmentInputFromReplacement(replacement);
|
|
244
|
+
const retirement = await this.#effects.readDelegationRetirement(source);
|
|
245
|
+
if (retirement === 'recovering') {
|
|
246
|
+
throw new WorkHubActionEffectFailure('operation_unavailable', 'WorkHub is still resolving the delegated Message owner');
|
|
247
|
+
}
|
|
248
|
+
if (retirement === 'not_retired' && replacement.disposition === 'delegate_existing') {
|
|
249
|
+
await this.#replacementTarget(replacement);
|
|
250
|
+
}
|
|
251
|
+
if (retirement === 'not_retired')
|
|
252
|
+
await this.#effects.retireDelegation(source);
|
|
253
|
+
try {
|
|
254
|
+
if (replacement.disposition === 'delegate_existing') {
|
|
255
|
+
// Retirement can await cancellation or Stop long enough for display
|
|
256
|
+
// metadata or lifecycle state to change. Re-read after that destructive
|
|
257
|
+
// boundary and carry the current name into SQLite's identity guard.
|
|
258
|
+
const target = await this.#replacementTarget(replacement);
|
|
259
|
+
assignment = { ...assignment, targetSessionName: target.name };
|
|
260
|
+
}
|
|
261
|
+
return await this.#assign(assignment, context);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
// An assignment may have committed before its caller observed a transport
|
|
265
|
+
// or projection failure. Never append an abort beside a real supersession.
|
|
266
|
+
const [durable, supersession] = await Promise.all([
|
|
267
|
+
this.#effects.readAssignment(replacement.actionId),
|
|
268
|
+
this.#effects.readSupersession(replacement.replacesDelegationId),
|
|
269
|
+
]);
|
|
270
|
+
if (durable && supersession?.replacementDelegationId === durable.delegationId) {
|
|
271
|
+
return this.#assign(assignmentInputFromRecord(durable), context);
|
|
272
|
+
}
|
|
273
|
+
const reason = replacement.disposition === 'delegate_existing'
|
|
274
|
+
? await this.#replacementAbortReason(replacement)
|
|
275
|
+
: 'target_unavailable';
|
|
276
|
+
if (reason)
|
|
277
|
+
await this.#effects.abortReplacement({ replacement, reason });
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async #assertReplacementReplayTarget(input, targetSessionId) {
|
|
282
|
+
if (input.proposal.disposition !== 'replace' ||
|
|
283
|
+
input.proposal.target.disposition !== 'delegate_existing' ||
|
|
284
|
+
input.candidateSetId === undefined) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const candidateRef = input.proposal.target.candidateRef;
|
|
288
|
+
const candidates = await this.candidates();
|
|
289
|
+
if (candidates.candidateSetId !== input.candidateSetId)
|
|
290
|
+
return;
|
|
291
|
+
const proposed = candidates.candidates.find((candidate) => candidate.candidateRef === candidateRef);
|
|
292
|
+
if (proposed && proposed.sessionId !== targetSessionId) {
|
|
293
|
+
throw new WorkHubActionGateFailure('action_conflict', 'WorkHub replacement replay cannot change its durable target Session');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async #replacementTarget(replacement) {
|
|
297
|
+
const target = (await this.#effects.listSessions()).find((session) => session.id === replacement.targetSessionId);
|
|
298
|
+
if (!target || !isCandidateSession(target)) {
|
|
299
|
+
throw new WorkHubActionGateFailure('candidate_unavailable', 'WorkHub replacement target is unavailable');
|
|
300
|
+
}
|
|
301
|
+
this.#assertTarget({
|
|
302
|
+
candidateRef: 'prepared',
|
|
303
|
+
sessionId: target.id,
|
|
304
|
+
sessionName: target.name,
|
|
305
|
+
workspace: workspaceProjection(target),
|
|
306
|
+
state: candidateState(target.status),
|
|
307
|
+
updatedAt: updatedAt(target),
|
|
308
|
+
});
|
|
309
|
+
return target;
|
|
310
|
+
}
|
|
311
|
+
async #replacementAbortReason(replacement) {
|
|
312
|
+
try {
|
|
313
|
+
await this.#replacementTarget(replacement);
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
if (!(error instanceof WorkHubActionGateFailure))
|
|
318
|
+
return undefined;
|
|
319
|
+
if (error.code === 'candidate_unavailable')
|
|
320
|
+
return 'target_unavailable';
|
|
321
|
+
if (error.code === 'target_waiting_for_user')
|
|
322
|
+
return 'target_waiting_for_user';
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
127
326
|
async #assign(assignment, context) {
|
|
128
327
|
const admitted = await this.#effects.assign(assignment, context);
|
|
328
|
+
if (assignment.replacesDelegationId) {
|
|
329
|
+
return {
|
|
330
|
+
disposition: 'replace',
|
|
331
|
+
replacementDisposition: assignment.disposition,
|
|
332
|
+
targetSessionId: assignment.targetSessionId,
|
|
333
|
+
targetTurnId: admitted.turnId,
|
|
334
|
+
...(admitted.steered ? { steered: true } : {}),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
129
337
|
return {
|
|
130
338
|
disposition: assignment.disposition,
|
|
131
339
|
targetSessionId: assignment.targetSessionId,
|
|
@@ -238,6 +446,9 @@ function actionFingerprint(input) {
|
|
|
238
446
|
return digest({
|
|
239
447
|
userText: input.userText,
|
|
240
448
|
disposition: input.proposal.disposition,
|
|
449
|
+
...(input.proposal.disposition === 'delegate_existing'
|
|
450
|
+
? { candidateRef: input.proposal.candidateRef }
|
|
451
|
+
: {}),
|
|
241
452
|
...(input.proposal.disposition === 'create_new'
|
|
242
453
|
? {
|
|
243
454
|
title: input.proposal.title,
|
|
@@ -247,6 +458,32 @@ function actionFingerprint(input) {
|
|
|
247
458
|
...(input.proposal.disposition === 'clarify'
|
|
248
459
|
? { assistantText: input.proposal.assistantText }
|
|
249
460
|
: {}),
|
|
461
|
+
...(input.proposal.disposition === 'replace'
|
|
462
|
+
? {
|
|
463
|
+
replacesActionId: input.proposal.replacesActionId,
|
|
464
|
+
target: input.proposal.target,
|
|
465
|
+
...(input.proposal.target.disposition === 'create_new'
|
|
466
|
+
? { workspace: input.create?.workspace }
|
|
467
|
+
: {}),
|
|
468
|
+
}
|
|
469
|
+
: {}),
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function replacementActionFingerprint(input, targetSessionId) {
|
|
473
|
+
if (input.proposal.disposition !== 'replace') {
|
|
474
|
+
throw new WorkHubActionGateFailure('action_conflict', 'Invalid WorkHub replacement replay');
|
|
475
|
+
}
|
|
476
|
+
return digest({
|
|
477
|
+
userText: input.userText,
|
|
478
|
+
disposition: input.proposal.disposition,
|
|
479
|
+
replacesActionId: input.proposal.replacesActionId,
|
|
480
|
+
target: {
|
|
481
|
+
disposition: input.proposal.target.disposition,
|
|
482
|
+
targetSessionId,
|
|
483
|
+
...(input.proposal.target.disposition === 'create_new'
|
|
484
|
+
? { title: input.proposal.target.title, workspace: input.create?.workspace }
|
|
485
|
+
: {}),
|
|
486
|
+
},
|
|
250
487
|
});
|
|
251
488
|
}
|
|
252
489
|
function assignmentInputFromRecord(assignment) {
|
|
@@ -258,8 +495,44 @@ function assignmentInputFromRecord(assignment) {
|
|
|
258
495
|
disposition: assignment.disposition,
|
|
259
496
|
userText: assignment.userText,
|
|
260
497
|
...(assignment.create ? { create: assignment.create } : {}),
|
|
498
|
+
...(assignment.replacesActionId && assignment.replacesDelegationId
|
|
499
|
+
? {
|
|
500
|
+
replacesActionId: assignment.replacesActionId,
|
|
501
|
+
replacesDelegationId: assignment.replacesDelegationId,
|
|
502
|
+
}
|
|
503
|
+
: {}),
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function assignmentInputFromReplacement(replacement) {
|
|
507
|
+
return {
|
|
508
|
+
actionId: replacement.actionId,
|
|
509
|
+
actionFingerprint: replacement.actionFingerprint,
|
|
510
|
+
targetSessionId: replacement.targetSessionId,
|
|
511
|
+
targetSessionName: replacement.targetSessionName,
|
|
512
|
+
disposition: replacement.disposition,
|
|
513
|
+
userText: replacement.userText,
|
|
514
|
+
...(replacement.create ? { create: replacement.create } : {}),
|
|
515
|
+
replacesActionId: replacement.replacesActionId,
|
|
516
|
+
replacesDelegationId: replacement.replacesDelegationId,
|
|
261
517
|
};
|
|
262
518
|
}
|
|
263
519
|
function hash(value) {
|
|
264
520
|
return createHash('sha256').update(value, 'utf8').digest('hex');
|
|
265
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* Destructive replacement needs evidence in the user-originated text itself;
|
|
524
|
+
* a strategy-provided replacement proposal and confirmation marker are not
|
|
525
|
+
* sufficient authority. Keep this deliberately narrower than route inference.
|
|
526
|
+
*/
|
|
527
|
+
export function isExplicitWorkHubCorrectionText(value, targetDisposition, targetSessionName) {
|
|
528
|
+
const intent = readWorkHubRequestIntent(value);
|
|
529
|
+
if (targetDisposition === 'create_new') {
|
|
530
|
+
return Boolean(intent.correction.cue &&
|
|
531
|
+
intent.creation.explicit &&
|
|
532
|
+
targetSessionName &&
|
|
533
|
+
workHubCreationAuthorizesTitle(intent, targetSessionName));
|
|
534
|
+
}
|
|
535
|
+
return Boolean(targetSessionName &&
|
|
536
|
+
intent.correction.cue &&
|
|
537
|
+
workHubCorrectionTargetsSession(intent, targetSessionName));
|
|
538
|
+
}
|