maka-agent 0.2.0-dev.47.20260922 → 0.2.0-dev.49.20260924
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/dist/acp/session-event-mapper.js +1 -4
- package/dist/onboarding-catalog.js +20 -4
- package/dist/pi-transcript.js +0 -8
- package/dist/pi-tui-pickers.js +1 -1
- package/dist/pi-tui-runner.js +6 -4
- package/dist/runtime-host-capability-provider-command.js +25 -6
- package/dist/runtime-host-onboarding.js +5 -3
- package/dist/runtime-host-session-channel.js +9 -3
- package/dist/tui-mcp-control.js +37 -24
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-errors.js +26 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-filesystem.js +103 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-process.js +119 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-projection.js +146 -0
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +653 -0
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +24446 -0
- package/node_modules/@maka/acp-executor-plugin/package.json +15 -0
- package/node_modules/@maka/antigravity-acp-plugin/dist/index.js +88 -0
- package/node_modules/@maka/antigravity-acp-plugin/dist/model-presentation.js +53 -0
- package/node_modules/@maka/antigravity-acp-plugin/dist/plugin.mjs +115 -0
- package/node_modules/@maka/antigravity-acp-plugin/package.json +15 -0
- package/node_modules/@maka/core/dist/events.js +13 -0
- package/node_modules/@maka/core/dist/executor-catalog.js +106 -0
- package/node_modules/@maka/core/dist/llm-connections.js +2 -5
- package/node_modules/@maka/core/dist/mcp.js +4 -1
- package/node_modules/@maka/core/dist/model-facts.js +2 -4
- package/node_modules/@maka/core/dist/model-metadata.generated.js +345 -248
- package/node_modules/@maka/core/dist/model-metadata.js +28 -1
- package/node_modules/@maka/core/dist/model-thinking.js +17 -17
- package/node_modules/@maka/core/dist/model-web-search.js +7 -9
- package/node_modules/@maka/core/dist/models-dev-projection.js +1 -1
- package/node_modules/@maka/core/dist/onboarding.js +1 -4
- package/node_modules/@maka/core/dist/provider-registry.js +60 -86
- package/node_modules/@maka/core/dist/runtime-event-store.js +25 -0
- package/node_modules/@maka/core/dist/runtime-event.js +2 -2
- package/node_modules/@maka/core/dist/runtime-invocation.js +5 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +28 -16
- package/node_modules/@maka/core/dist/runtime-policy/credential-vault-codec.js +6 -0
- package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +21 -0
- package/node_modules/@maka/core/dist/runtime-policy.js +1 -1
- package/node_modules/@maka/core/dist/session.js +25 -9
- package/node_modules/@maka/core/dist/settings.js +1 -0
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +365 -104
- package/node_modules/@maka/core/dist/transcript-search.js +1 -0
- package/node_modules/@maka/core/dist/turn-origin.js +14 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +2 -0
- package/node_modules/@maka/eval/dist/harbor-maka-subject.js +3 -0
- package/node_modules/@maka/eval/dist/maka-subject.js +8 -1
- package/node_modules/@maka/mcp/dist/credential-coordinator.js +6 -1
- package/node_modules/@maka/mcp/dist/index.js +31 -5
- package/node_modules/@maka/mcp/dist/oauth.js +54 -6
- package/node_modules/@maka/runtime/dist/agent-run-inspect.js +1 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +1 -11
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +2 -12
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +3 -71
- package/node_modules/@maka/runtime/dist/conversation-copy.js +58 -3
- package/node_modules/@maka/runtime/dist/local-web-fetch.js +23 -11
- package/node_modules/@maka/runtime/dist/mcp-tools.js +9 -2
- package/node_modules/@maka/runtime/dist/model-adapter.js +10 -5
- package/node_modules/@maka/runtime/dist/model-factory.js +33 -30
- package/node_modules/@maka/runtime/dist/model-fetcher.js +4 -1
- package/node_modules/@maka/runtime/dist/model-runtime.js +3 -9
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +116 -3
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +212 -16
- package/node_modules/@maka/runtime/dist/read-page.js +11 -8
- package/node_modules/@maka/runtime/dist/recovery-resolver.js +47 -20
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +1 -0
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +2 -2
- package/node_modules/@maka/runtime/dist/scheduled-task-tools.js +39 -8
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +182 -127
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +3 -0
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +29 -4
- package/node_modules/@maka/runtime/dist/telemetry/model-pricing.generated.js +141 -134
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +3 -3
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +7 -6
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +28 -62
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +8 -5
- package/node_modules/@maka/runtime-host/dist/client/hosted-execution-target.js +7 -1
- package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
- package/node_modules/@maka/runtime-host/dist/client/reconnect-lifecycle.js +8 -1
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +6 -1
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +3 -0
- package/node_modules/@maka/runtime-host/dist/composition-identity.js +19 -0
- package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +6 -3
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -2
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +34 -0
- package/node_modules/@maka/runtime-host/dist/protocol/prompt-suggestions.js +61 -0
- package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +4 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +40 -2
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/builtin-external-agent-plugins.js +188 -0
- package/node_modules/@maka/runtime-host/dist/server/candidate.js +12 -7
- package/node_modules/@maka/runtime-host/dist/server/client-capability-recovery.js +44 -46
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/context-coordinator.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition-factory.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +212 -24
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +41 -2
- package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/generated-text.js +39 -0
- package/node_modules/@maka/runtime-host/dist/server/host-composition-source.js +47 -0
- package/node_modules/@maka/runtime-host/dist/server/host-composition.js +1 -29
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +2 -9
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +75 -9
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +12 -0
- package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +45 -0
- package/node_modules/@maka/runtime-host/dist/server/jev-routing-model.js +157 -0
- package/node_modules/@maka/runtime-host/dist/server/listener-set.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +11 -1
- package/node_modules/@maka/runtime-host/dist/server/process-lifecycle.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/process-termination-error.js +27 -0
- package/node_modules/@maka/runtime-host/dist/server/prompt-suggestion.js +179 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +93 -14
- package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +99 -12
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +48 -16
- package/node_modules/@maka/runtime-host/dist/server/session-effect-coordinator.js +12 -6
- package/node_modules/@maka/runtime-host/dist/server/session-title.js +3 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +71 -3
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +6 -13
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +39 -11
- package/node_modules/@maka/runtime-host/dist/server/workhub-result-coordinator.js +173 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-result-runtime.js +293 -0
- package/node_modules/@maka/runtime-host/package.json +2 -0
- package/node_modules/@maka/storage/dist/agent-run-store-contract.js +8 -0
- package/node_modules/@maka/storage/dist/config-transfer.js +14 -8
- package/node_modules/@maka/storage/dist/execution-stores.js +19 -6
- package/node_modules/@maka/storage/dist/interaction-store.js +13 -0
- package/node_modules/@maka/storage/dist/mcp-config-store.js +91 -2
- package/node_modules/@maka/storage/dist/operational-state-store.js +15 -1
- package/node_modules/@maka/storage/dist/plan-authority.js +2 -0
- package/node_modules/@maka/storage/dist/plan-store.js +30 -0
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +28 -17
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +9 -3
- package/node_modules/@maka/storage/dist/runtime-policy/credential-vault-document.js +4 -1
- package/node_modules/@maka/storage/dist/runtime-policy/legacy-custom-connection.js +65 -0
- package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +10 -5
- package/node_modules/@maka/storage/dist/runtime-policy/policy-document.js +2 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +11 -0
- package/node_modules/@maka/storage/dist/session-store-values.js +16 -4
- package/node_modules/@maka/storage/dist/session-store.js +29 -6
- package/node_modules/@maka/storage/dist/shell-run-authority.js +1 -0
- package/node_modules/@maka/storage/dist/shell-run-store.js +15 -0
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +3 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +74 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +849 -91
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +21 -3
- package/node_modules/@maka/storage/dist/usage-screen.js +138 -108
- package/package.json +1 -1
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { createWorkHubResultRuntime } from './workhub-result-runtime.js';
|
|
20
|
+
import { createJevRoutingModel } from './jev-routing-model.js';
|
|
19
21
|
import { copyWorkHubAttachmentsToTarget } from './workhub-message-attachments.js';
|
|
20
22
|
import { createHash, randomUUID } from 'node:crypto';
|
|
21
23
|
import { attachmentKindFromMimeType, MAX_READ_IMAGE_BYTES } from '@maka/core/attachments';
|
|
@@ -94,12 +96,13 @@ import { recoverClientCapabilityOutcomes } from './client-capability-recovery.js
|
|
|
94
96
|
import { HostConnectionEffectCoordinator } from './connection-effect-coordinator.js';
|
|
95
97
|
import { HostChangeFeed } from './host-change-feed.js';
|
|
96
98
|
import { HostConfigurationCoordinator } from './configuration-coordinator.js';
|
|
99
|
+
import { HostPromptSuggestionCoordinator, supportsPromptSuggestion } from './prompt-suggestion.js';
|
|
97
100
|
import { HostContextCoordinator } from './context-coordinator.js';
|
|
98
101
|
import { HostClientCapabilityCoordinator } from './client-capability-coordinator.js';
|
|
99
102
|
import { HostDailyReviewCoordinator } from './daily-review-coordinator.js';
|
|
100
103
|
import { prepareHostAiSdkBackend } from './execution-model-composition.js';
|
|
101
104
|
import { createInteractiveRunComposer, createInteractiveRunComposerFactory, routeInteractiveRunToolSurface, } from './interactive-run-composer.js';
|
|
102
|
-
import { createHostGoalEvaluator, createHostDailyReviewModel, createHostMemoryExtractionModel, createHostPluginModel, createHostSessionEffectModel, } from './execution-model-authority.js';
|
|
105
|
+
import { readDuringBackendCreation, createHostGoalEvaluator, createHostDailyReviewModel, createHostMemoryExtractionModel, createHostPluginModel, createHostSessionEffectModel, createHostPromptSuggestionModel, } from './execution-model-authority.js';
|
|
103
106
|
import { HostExecutionInspectCoordinator } from './execution-inspect-coordinator.js';
|
|
104
107
|
import { HostExternalSessionCoordinator } from './external-session-coordinator.js';
|
|
105
108
|
import { boundedFailureDiagnostic } from './failure-diagnostic.js';
|
|
@@ -133,6 +136,7 @@ import { HostPlanCoordinator } from './plan-coordinator.js';
|
|
|
133
136
|
import { HostProjectDirectoryAuthority, } from './project-directory-authority.js';
|
|
134
137
|
import { HostProjectCatalogCoordinator } from './project-catalog-coordinator.js';
|
|
135
138
|
import { HostProjectMembershipGate } from './project-membership-gate.js';
|
|
139
|
+
import { HostBuiltinExternalAgentPluginCoordinator, withBuiltinExternalAgentCatalog, } from './builtin-external-agent-plugins.js';
|
|
136
140
|
import { HostPluginPlatformCoordinator } from './plugin-platform-coordinator.js';
|
|
137
141
|
import { HostPluginPlatform } from './plugin-platform.js';
|
|
138
142
|
import { RootAdmissionOwner } from './root-admission-owner.js';
|
|
@@ -150,7 +154,7 @@ import { HostStorageMaintenance } from './storage-maintenance.js';
|
|
|
150
154
|
import { HostSessionRevisionCoordinator } from './session-revision-coordinator.js';
|
|
151
155
|
import { HostSessionEffectCoordinator } from './session-effect-coordinator.js';
|
|
152
156
|
import { SessionContinuityCoordinator } from './session-continuity-coordinator.js';
|
|
153
|
-
import { createSessionTranscriptReader, } from './session-transcript-reader.js';
|
|
157
|
+
import { createSessionTranscriptReader, createTurnResultReader, } from './session-transcript-reader.js';
|
|
154
158
|
import { HostSkillCatalogCoordinator, SkillCatalogInvocableContextError, } from './skill-catalog-coordinator.js';
|
|
155
159
|
import { SkillCatalogRepository } from './skill-catalog-repository.js';
|
|
156
160
|
import { HostSessionTodoCoordinator } from './session-todo-coordinator.js';
|
|
@@ -201,6 +205,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
201
205
|
let graphControlStore;
|
|
202
206
|
let graphClient;
|
|
203
207
|
let sessionEffects;
|
|
208
|
+
let promptSuggestions;
|
|
204
209
|
let memoryExtraction;
|
|
205
210
|
let unsubscribeTranscriptChanges;
|
|
206
211
|
let unsubscribeRuntimeEventCommits;
|
|
@@ -253,9 +258,28 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
253
258
|
executors: pluginExecutors,
|
|
254
259
|
clientBridge: pluginClientBridge,
|
|
255
260
|
});
|
|
256
|
-
const pluginPlatformCoordinator = new HostPluginPlatformCoordinator(pluginPlatform)
|
|
261
|
+
const pluginPlatformCoordinator = new HostPluginPlatformCoordinator(pluginPlatform, async (input) => {
|
|
262
|
+
if (input.kind === 'conversation') {
|
|
263
|
+
const header = await stores.sessionStore.readHeaderSnapshot(input.sessionId);
|
|
264
|
+
if (!header.executorId)
|
|
265
|
+
return [];
|
|
266
|
+
return pluginExecutors.catalog({
|
|
267
|
+
sessionId: input.sessionId,
|
|
268
|
+
executorId: header.executorId,
|
|
269
|
+
cwd: header.cwd,
|
|
270
|
+
...(header.executorConfig ? { configuration: header.executorConfig } : {}),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
const catalog = await pluginExecutors.catalog({ cwd: input.cwd });
|
|
274
|
+
return withBuiltinExternalAgentCatalog(catalog);
|
|
275
|
+
});
|
|
257
276
|
const openedProjectCatalog = storage.projectCatalog;
|
|
258
277
|
const runtimePolicyStores = storage.runtimePolicy;
|
|
278
|
+
const builtinExternalAgentPlugins = new HostBuiltinExternalAgentPluginCoordinator({
|
|
279
|
+
platform: pluginPlatform,
|
|
280
|
+
controlDirectory: context.owner.controlDirectory,
|
|
281
|
+
readPolicy: () => runtimePolicyStores.runtimePolicy.getSnapshot(),
|
|
282
|
+
});
|
|
259
283
|
const oauthCredentials = new HostOAuthExecutionAuthority(runtimePolicyStores);
|
|
260
284
|
const openedScheduledTaskStore = storage.scheduledTasks;
|
|
261
285
|
const openedPlanStore = storage.plan;
|
|
@@ -623,6 +647,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
623
647
|
}, projectMembership, context.requestDrain, new HostProjectDirectoryAuthority(options.projectDirectoryRoots));
|
|
624
648
|
let rootCoordinator;
|
|
625
649
|
let workHubCoordination;
|
|
650
|
+
let workHubResults;
|
|
626
651
|
let canonicalProjection;
|
|
627
652
|
let memory;
|
|
628
653
|
let clientCapabilities;
|
|
@@ -634,7 +659,32 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
634
659
|
let dailyReview;
|
|
635
660
|
const rootPort = {
|
|
636
661
|
readLatestRootTurnLineage: (identity) => requireRootCoordinator(rootCoordinator).readLatestRootTurnLineage(identity),
|
|
637
|
-
readSessionHeader: (sessionId) =>
|
|
662
|
+
readSessionHeader: async (sessionId) => {
|
|
663
|
+
const projected = await requireRootCoordinator(rootCoordinator).readSessionHeader(sessionId);
|
|
664
|
+
if (!projected || projected.unavailableReason)
|
|
665
|
+
return projected;
|
|
666
|
+
const header = await stores.sessionStore.readHeaderSnapshot(sessionId);
|
|
667
|
+
if (!header.executorId)
|
|
668
|
+
return projected;
|
|
669
|
+
const [entry] = await pluginExecutors.catalog({
|
|
670
|
+
sessionId,
|
|
671
|
+
executorId: header.executorId,
|
|
672
|
+
cwd: header.cwd,
|
|
673
|
+
...(header.executorConfig ? { configuration: header.executorConfig } : {}),
|
|
674
|
+
});
|
|
675
|
+
return {
|
|
676
|
+
...projected,
|
|
677
|
+
idleOnly: true,
|
|
678
|
+
supportsAttachments: entry?.supportsAttachments ?? false,
|
|
679
|
+
...(entry?.readiness === 'ready'
|
|
680
|
+
? {}
|
|
681
|
+
: {
|
|
682
|
+
unavailableReason: entry?.readiness === 'history_only'
|
|
683
|
+
? 'External conversation is history-only. Start a new task.'
|
|
684
|
+
: 'Executor is unavailable. Check External Agents settings.',
|
|
685
|
+
}),
|
|
686
|
+
};
|
|
687
|
+
},
|
|
638
688
|
readRootState: (sessionId) => requireRootCoordinator(rootCoordinator).readRootState(sessionId),
|
|
639
689
|
claimStopFence: (input, commitQueueFence, admission) => requireRootCoordinator(rootCoordinator).claimStopFence(input, commitQueueFence, admission),
|
|
640
690
|
startFromMessage: (input, admission, commitAdmission) => requireRootCoordinator(rootCoordinator).startFromMessage(input, admission, commitAdmission),
|
|
@@ -676,8 +726,15 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
676
726
|
continuity = new SessionContinuityCoordinator(context.hostEpoch, (sessionId) => canonicalProjectionReader.read(sessionId), sessionAdmission, context.requestDrain, transcriptReader, (sessionId) => hostChanges.publishSessionCatalog(sessionId), context.sessionAccessAuthority);
|
|
677
727
|
const continuityCoordinator = continuity;
|
|
678
728
|
const planStore = observeInteractivePlanStoreWriter(openedPlanStore, (sessionId) => continuityCoordinator.enqueueSessionDomainChanged(sessionId, 'plan'), context.requestDrain);
|
|
679
|
-
unsubscribeTranscriptChanges = stores.sessionStore.subscribeTranscriptChanges((sessionId) =>
|
|
680
|
-
|
|
729
|
+
unsubscribeTranscriptChanges = stores.sessionStore.subscribeTranscriptChanges((sessionId) => {
|
|
730
|
+
continuityCoordinator.enqueueCanonicalRefresh(sessionId);
|
|
731
|
+
sessionAdmission.detach(() => workHubResults?.notify(sessionId));
|
|
732
|
+
});
|
|
733
|
+
unsubscribeRuntimeEventCommits = stores.runtimeEventStore.subscribeRuntimeEventCommits((sessionId) => {
|
|
734
|
+
continuityCoordinator.enqueueTranscriptAdvanced(sessionId);
|
|
735
|
+
sessionAdmission.detach(() => workHubResults?.notify(sessionId));
|
|
736
|
+
sessionAdmission.detach(() => promptSuggestions?.reconcile(sessionId));
|
|
737
|
+
});
|
|
681
738
|
unsubscribeUsageChanges = openedUsageStores.subscribeSessionUsageChanges((sessionId) => continuityCoordinator.enqueueSessionDomainChanged(sessionId, 'usage'));
|
|
682
739
|
dailyReview = new HostDailyReviewCoordinator({
|
|
683
740
|
store: openedDailyReviewStore,
|
|
@@ -717,7 +774,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
717
774
|
preflightSessionSnapshot: (sessionId, interactionProjection) => canonicalProjectionReader.fitsCandidate(sessionId, {
|
|
718
775
|
interactions: interactionProjection,
|
|
719
776
|
}),
|
|
720
|
-
refreshCanonicalContinuity: (sessionId, admission) =>
|
|
777
|
+
refreshCanonicalContinuity: async (sessionId, admission) => {
|
|
778
|
+
await continuityCoordinator.refreshCanonical(sessionId, admission);
|
|
779
|
+
sessionAdmission.detach(() => workHubResults?.notify(sessionId));
|
|
780
|
+
},
|
|
721
781
|
onPoison: (error) => {
|
|
722
782
|
if (poisonFailure)
|
|
723
783
|
return;
|
|
@@ -784,7 +844,9 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
784
844
|
goalTools: requireGoal(goal).tools,
|
|
785
845
|
builtinTools,
|
|
786
846
|
hostTools,
|
|
787
|
-
resolveRootTools: (sessionId) =>
|
|
847
|
+
resolveRootTools: (sessionId) => sessionId === WORKHUB_COORDINATION_SESSION_ID && workHubResults
|
|
848
|
+
? Promise.resolve([workHubResults.tool])
|
|
849
|
+
: requireGraphCoordinator(graphCoordinator).toolsForSession(sessionId),
|
|
788
850
|
resolvePluginTools: (sessionId, coreTools) => pluginTools.resolveContributions(sessionId, coreTools),
|
|
789
851
|
resolvePluginSystemPrompt: async (sessionId, promptContext, baseText) => {
|
|
790
852
|
const assembly = await pluginSystemPrompt.assemble({
|
|
@@ -842,6 +904,9 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
842
904
|
...(factoryContext.header.thinkingLevel
|
|
843
905
|
? { thinkingLevel: factoryContext.header.thinkingLevel }
|
|
844
906
|
: {}),
|
|
907
|
+
...(factoryContext.header.executorConfig
|
|
908
|
+
? { configuration: factoryContext.header.executorConfig }
|
|
909
|
+
: {}),
|
|
845
910
|
...(factoryContext.systemPrompt ? { instructions: factoryContext.systemPrompt } : {}),
|
|
846
911
|
binding,
|
|
847
912
|
}),
|
|
@@ -918,7 +983,9 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
918
983
|
const capabilitySnapshot = requireClientCapabilities(clientCapabilities).snapshotForSession(sessionId);
|
|
919
984
|
try {
|
|
920
985
|
const [graphTools, planState] = await Promise.all([
|
|
921
|
-
|
|
986
|
+
sessionId === WORKHUB_COORDINATION_SESSION_ID && workHubResults
|
|
987
|
+
? Promise.resolve([workHubResults.tool])
|
|
988
|
+
: requireGraphCoordinator(graphCoordinator).toolsForSession(sessionId),
|
|
922
989
|
planStore.readState(sessionId),
|
|
923
990
|
]);
|
|
924
991
|
const { runtimePolicy, surface } = await resolveInteractiveToolSurface({
|
|
@@ -1035,6 +1102,46 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1035
1102
|
requestDrain: context.requestDrain,
|
|
1036
1103
|
});
|
|
1037
1104
|
sessionEffects = sessionEffectCoordinator;
|
|
1105
|
+
const promptSuggestionCoordinator = new HostPromptSuggestionCoordinator({
|
|
1106
|
+
generate: createHostPromptSuggestionModel({
|
|
1107
|
+
runtimePolicy: runtimePolicyStores,
|
|
1108
|
+
oauthCredentials,
|
|
1109
|
+
usage: openedUsageStores,
|
|
1110
|
+
requestDrain: context.requestDrain,
|
|
1111
|
+
}),
|
|
1112
|
+
readSource: (sessionId) => sessionAdmission.run(sessionId, async () => {
|
|
1113
|
+
if ((await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.privacy.incognitoActive)
|
|
1114
|
+
return undefined;
|
|
1115
|
+
const canonical = await canonicalProjectionReader.read(sessionId);
|
|
1116
|
+
const turn = canonical?.rootTurn;
|
|
1117
|
+
if (!canonical ||
|
|
1118
|
+
!turn ||
|
|
1119
|
+
turn.status !== 'completed' ||
|
|
1120
|
+
turn.contextCompactionOutcome ||
|
|
1121
|
+
canonical.session.isArchived ||
|
|
1122
|
+
canonical.interactions.pending.length ||
|
|
1123
|
+
canonical.queue.followup.length ||
|
|
1124
|
+
canonical.queue.steering.length ||
|
|
1125
|
+
canonical.goal?.status === 'active' ||
|
|
1126
|
+
requireSessionManager(manager).runningTurnIds(sessionId).length)
|
|
1127
|
+
return undefined;
|
|
1128
|
+
const header = await stores.sessionStore.readHeaderSnapshot(sessionId);
|
|
1129
|
+
if (!supportsPromptSuggestion(sessionId, header))
|
|
1130
|
+
return undefined;
|
|
1131
|
+
await requireSessionManager(manager).ensureTranscriptLedgerForRead(sessionId);
|
|
1132
|
+
const view = await recapReadModel.getSessionView(sessionId);
|
|
1133
|
+
if (view.messages.some((message) => message.type === 'user' && message.turnId === turn.turnId && message.origin))
|
|
1134
|
+
return undefined;
|
|
1135
|
+
return {
|
|
1136
|
+
sessionId,
|
|
1137
|
+
turnId: turn.turnId,
|
|
1138
|
+
terminalEventId: turn.terminalEventId,
|
|
1139
|
+
header,
|
|
1140
|
+
messages: view.messages,
|
|
1141
|
+
};
|
|
1142
|
+
}),
|
|
1143
|
+
});
|
|
1144
|
+
promptSuggestions = promptSuggestionCoordinator;
|
|
1038
1145
|
const resolveChildTools = async (sessionId) => {
|
|
1039
1146
|
const header = await stores.sessionStore.readHeader(sessionId);
|
|
1040
1147
|
const shell = resolveTurnShellPlan((await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.shell);
|
|
@@ -1246,9 +1353,32 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1246
1353
|
}, {
|
|
1247
1354
|
currentGraphId: (rootSessionId) => requireGraphCoordinator(graphCoordinator).currentGraphId(rootSessionId),
|
|
1248
1355
|
beginNextGraphEpoch: async (rootSessionId) => (await requireGraphCoordinator(graphCoordinator).beginNextGraphEpoch(rootSessionId, (operation) => requireGraphSupervisorWake(graphSupervisorWake).runWithSessionWakesSuppressed(rootSessionId, operation, 'agent_graph_epoch_advanced'))).graphId,
|
|
1249
|
-
}, (input) => sessionEffectCoordinator.nameSessionFromRootMessage(input), context.owner.capability.rootId,
|
|
1250
|
-
|
|
1251
|
-
|
|
1356
|
+
}, (input) => sessionEffectCoordinator.nameSessionFromRootMessage(input), context.owner.capability.rootId, async (input) => {
|
|
1357
|
+
// Explicit injection remains an experiment seam. Injected models own
|
|
1358
|
+
// policy/egress checks and cancellation; this bypasses the production
|
|
1359
|
+
// Jev preparation deadline (including its transcript-read protection).
|
|
1360
|
+
if (dependencies.workHubRoutingModel)
|
|
1361
|
+
return workHubCoordination.prepareRoutingDecision(input);
|
|
1362
|
+
// One admission budget covers policy/transcript reads, both Jev asks,
|
|
1363
|
+
// candidate resolution and transport cleanup; it is not per request.
|
|
1364
|
+
const signal = AbortSignal.any([
|
|
1365
|
+
...(input.inputClosedSignal ? [input.inputClosedSignal] : []),
|
|
1366
|
+
AbortSignal.timeout(8_000),
|
|
1367
|
+
]);
|
|
1368
|
+
try {
|
|
1369
|
+
const { policy } = await readDuringBackendCreation(() => runtimePolicyStores.runtimePolicy.getSnapshot(), signal);
|
|
1370
|
+
if (!policy.jev?.enabled || policy.privacy.incognitoActive)
|
|
1371
|
+
return undefined;
|
|
1372
|
+
return await readDuringBackendCreation(() => workHubCoordination.prepareRoutingDecision({ ...input, inputClosedSignal: signal }), signal);
|
|
1373
|
+
}
|
|
1374
|
+
catch {
|
|
1375
|
+
if (!input.inputClosedSignal?.aborted) {
|
|
1376
|
+
const failure = signal.aborted ? 'timeout' : 'preparation_unavailable';
|
|
1377
|
+
console.warn(`[runtime-host] Jev routing fallback: ${failure}`);
|
|
1378
|
+
}
|
|
1379
|
+
return undefined;
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1252
1382
|
const coordinator = rootCoordinator;
|
|
1253
1383
|
const pluginModel = createHostPluginModel({
|
|
1254
1384
|
runtimePolicy: runtimePolicyStores,
|
|
@@ -1601,6 +1731,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1601
1731
|
});
|
|
1602
1732
|
async function applyRuntimePolicyMutationEffects() {
|
|
1603
1733
|
try {
|
|
1734
|
+
await builtinExternalAgentPlugins.reconcile();
|
|
1604
1735
|
await requireMemory(memory).refreshAfterPolicyMutation();
|
|
1605
1736
|
}
|
|
1606
1737
|
catch (error) {
|
|
@@ -1624,8 +1755,33 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1624
1755
|
continuity: continuityCoordinator,
|
|
1625
1756
|
workspaceResolver,
|
|
1626
1757
|
requestDrain: context.requestDrain,
|
|
1627
|
-
|
|
1758
|
+
configureExecutor: async (header, configuration) => {
|
|
1759
|
+
if (!header.executorId)
|
|
1760
|
+
throw new Error('Session has no executor');
|
|
1761
|
+
await pluginExecutors.configureConversation(header.id, header.executorId, {
|
|
1762
|
+
conversationKey: header.id,
|
|
1763
|
+
cwd: header.cwd,
|
|
1764
|
+
configuration,
|
|
1765
|
+
});
|
|
1766
|
+
},
|
|
1767
|
+
retireExecutor: (sessionId) => pluginExecutors.retireConversation(sessionId),
|
|
1768
|
+
assertExecutorAvailable: async (sessionId, executorId, configuration, cwd) => {
|
|
1628
1769
|
pluginExecutors.identity(sessionId, executorId);
|
|
1770
|
+
const [entry] = await pluginExecutors.catalog({
|
|
1771
|
+
cwd,
|
|
1772
|
+
executorId,
|
|
1773
|
+
discoverySessionId: sessionId,
|
|
1774
|
+
});
|
|
1775
|
+
if (!entry || entry.readiness !== 'ready')
|
|
1776
|
+
throw new Error('Executor is not ready');
|
|
1777
|
+
// Catalog-managed executors pin their confirmed configuration on every create path.
|
|
1778
|
+
// Providers without model discovery retain main's executor-specific model contract.
|
|
1779
|
+
if (entry.supportsModelChange || entry.models.length > 0) {
|
|
1780
|
+
if (configuration?.model &&
|
|
1781
|
+
!entry.models.some((model) => model.id === configuration.model))
|
|
1782
|
+
throw new Error('Executor model is unavailable');
|
|
1783
|
+
return configuration ?? {};
|
|
1784
|
+
}
|
|
1629
1785
|
},
|
|
1630
1786
|
...(context.sessionAccessAuthority
|
|
1631
1787
|
? { sessionAccessAuthority: context.sessionAccessAuthority }
|
|
@@ -1651,7 +1807,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1651
1807
|
},
|
|
1652
1808
|
});
|
|
1653
1809
|
workHubCoordination = new HostWorkHubCoordinationCoordinator({
|
|
1654
|
-
routingModel: dependencies.workHubRoutingModel,
|
|
1810
|
+
routingModel: dependencies.workHubRoutingModel ?? createJevRoutingModel({ stores: runtimePolicyStores }),
|
|
1655
1811
|
requestForm: (input) => interactions.requestForm(input),
|
|
1656
1812
|
targetExecution: workHubTargetExecution,
|
|
1657
1813
|
configureModel: (input) => sessionCatalog.configureWorkHubModel(input),
|
|
@@ -1734,7 +1890,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1734
1890
|
? 'operation_unavailable'
|
|
1735
1891
|
: 'operation_conflict', plan.result.reason === 'resume_feature_disabled'
|
|
1736
1892
|
? 'Safe-boundary resume is disabled for this Runtime Host'
|
|
1737
|
-
:
|
|
1893
|
+
: `WorkHub delegated execution is not resumable (${plan.result.reason})`);
|
|
1738
1894
|
}
|
|
1739
1895
|
// Root planning authenticates handoff membership. Its source may be
|
|
1740
1896
|
// a physical successor of this same logical Turn, never another Turn.
|
|
@@ -1755,7 +1911,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1755
1911
|
? 'operation_unavailable'
|
|
1756
1912
|
: 'operation_conflict', started.result.plan.reason === 'resume_feature_disabled'
|
|
1757
1913
|
? 'Safe-boundary resume is disabled for this Runtime Host'
|
|
1758
|
-
:
|
|
1914
|
+
: `WorkHub delegated execution is not resumable (${started.result.plan.reason})`);
|
|
1759
1915
|
}
|
|
1760
1916
|
return {
|
|
1761
1917
|
outcome: 'resume_started',
|
|
@@ -1881,6 +2037,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1881
2037
|
? WORKHUB_COORDINATION_REPLACEMENT_SCHEMA_VERSION
|
|
1882
2038
|
: 1,
|
|
1883
2039
|
kind: 'delegation_assigned',
|
|
2040
|
+
returnResults: true,
|
|
1884
2041
|
actionId: input.actionId,
|
|
1885
2042
|
actionFingerprint: input.actionFingerprint,
|
|
1886
2043
|
coordinationTurnId: input.coordinationTurnId ?? input.actionId,
|
|
@@ -1947,6 +2104,20 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1947
2104
|
},
|
|
1948
2105
|
requestDrain: context.requestDrain,
|
|
1949
2106
|
});
|
|
2107
|
+
workHubResults = createWorkHubResultRuntime({
|
|
2108
|
+
stores,
|
|
2109
|
+
executions: coordinator,
|
|
2110
|
+
messages,
|
|
2111
|
+
interactions,
|
|
2112
|
+
admission: sessionAdmission,
|
|
2113
|
+
readTurnResult: createTurnResultReader({
|
|
2114
|
+
stores,
|
|
2115
|
+
canonicalPermissionOutcomes,
|
|
2116
|
+
ensureTranscriptLedger: (sessionId) => requireSessionManager(manager).ensureTranscriptLedgerForRead(sessionId),
|
|
2117
|
+
}),
|
|
2118
|
+
acquireResidency: () => context.acquireResidency('hosted-execution'),
|
|
2119
|
+
onError: (error) => console.error(`[runtime-host] WorkHub result reconciliation failed: ${boundedFailureDiagnostic(error)}`),
|
|
2120
|
+
});
|
|
1950
2121
|
scheduledTasks = new HostScheduledTaskCoordinator({
|
|
1951
2122
|
store: openedScheduledTaskStore,
|
|
1952
2123
|
sessions: stores.sessionStore,
|
|
@@ -1969,9 +2140,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1969
2140
|
const sessionBundles = new HostSessionBundleCoordinator({
|
|
1970
2141
|
lease: context.owner.lease,
|
|
1971
2142
|
fenceSubtree: (sessionId, operation) => requireSessionManager(manager).runSessionSubtreeQuiescentMutation(sessionId, operation),
|
|
1972
|
-
recoverInterruptedSessions: (sessionIds) =>
|
|
1973
|
-
.recoverInterruptedSessionsForSessions(sessionIds)
|
|
1974
|
-
.
|
|
2143
|
+
recoverInterruptedSessions: async (sessionIds) => {
|
|
2144
|
+
await requireSessionManager(manager).recoverInterruptedSessionsForSessions(sessionIds);
|
|
2145
|
+
await stores.runtimeEventStore.rebuildTerminalToolProjectionsForSessions(sessionIds);
|
|
2146
|
+
},
|
|
1975
2147
|
onImported: (sessionId) => hostChanges.publishSessionCatalog(sessionId),
|
|
1976
2148
|
});
|
|
1977
2149
|
const externalSessions = new HostExternalSessionCoordinator({
|
|
@@ -2029,7 +2201,13 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2029
2201
|
sessionEffects: sessionEffectCoordinator,
|
|
2030
2202
|
graph: requireGraphCoordinator(graphCoordinator),
|
|
2031
2203
|
graphWake: requireGraphSupervisorWake(graphSupervisorWake),
|
|
2032
|
-
manager
|
|
2204
|
+
manager: {
|
|
2205
|
+
finalizeChildWorkspacePatches: (sessionId) => requireSessionManager(manager).finalizeChildWorkspacePatches(sessionId),
|
|
2206
|
+
disposeSessionBackend: async (sessionId) => {
|
|
2207
|
+
await requireSessionManager(manager).disposeSessionBackend(sessionId);
|
|
2208
|
+
await pluginExecutors.retireConversation(sessionId);
|
|
2209
|
+
},
|
|
2210
|
+
},
|
|
2033
2211
|
capabilities: clientCapabilities,
|
|
2034
2212
|
continuity: continuityCoordinator,
|
|
2035
2213
|
artifacts: openedArtifactStore,
|
|
@@ -2103,6 +2281,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2103
2281
|
(connectionId) => pluginPlatformCoordinator.releaseConnection(connectionId),
|
|
2104
2282
|
],
|
|
2105
2283
|
}),
|
|
2284
|
+
createRuntimeHostDomainModule({
|
|
2285
|
+
id: 'builtin-external-agent-plugins',
|
|
2286
|
+
recovery: { state: () => builtinExternalAgentPlugins.recover() },
|
|
2287
|
+
}),
|
|
2106
2288
|
createRuntimeHostDomainModule({
|
|
2107
2289
|
id: 'memory',
|
|
2108
2290
|
handlers: [requireMemory(memory).handlers],
|
|
@@ -2137,9 +2319,6 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2137
2319
|
recoverySessions = await stores.sessionStore.listForRecovery();
|
|
2138
2320
|
await worktreeChildExecutor.recover(recoverySessions.flatMap((session) => session.subagentWorkspace ? [session.subagentWorkspace] : []));
|
|
2139
2321
|
await sessionRevisions.recover();
|
|
2140
|
-
for (const session of recoverySessions) {
|
|
2141
|
-
await stores.runtimeEventStore.repairImmutableSteeringMessageProofsForRecovery(session.id);
|
|
2142
|
-
}
|
|
2143
2322
|
},
|
|
2144
2323
|
},
|
|
2145
2324
|
}),
|
|
@@ -2265,6 +2444,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2265
2444
|
messages.handlers,
|
|
2266
2445
|
interactions.handlers,
|
|
2267
2446
|
sessionEffectCoordinator.handlers,
|
|
2447
|
+
promptSuggestionCoordinator.handlers,
|
|
2268
2448
|
continuityCoordinator.handlers,
|
|
2269
2449
|
runtimeResources.handlers,
|
|
2270
2450
|
contextOperations.handlers,
|
|
@@ -2285,6 +2465,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2285
2465
|
},
|
|
2286
2466
|
},
|
|
2287
2467
|
drain: [
|
|
2468
|
+
() => workHubResults?.coordinator.beginDrain(),
|
|
2288
2469
|
() => turnAccessRequests?.beginDrain(),
|
|
2289
2470
|
() => rootCoordinator?.beginDrain(),
|
|
2290
2471
|
() => workspaceExecution?.beginDrain(),
|
|
@@ -2292,6 +2473,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2292
2473
|
() => messages.beginDrain(),
|
|
2293
2474
|
() => interactions.beginDrain(),
|
|
2294
2475
|
() => sessionEffects?.beginDrain(),
|
|
2476
|
+
() => promptSuggestions?.beginDrain(),
|
|
2295
2477
|
],
|
|
2296
2478
|
close: [
|
|
2297
2479
|
async () => {
|
|
@@ -2301,9 +2483,11 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2301
2483
|
rootCloseTask ??= coordinator.close();
|
|
2302
2484
|
await rootCloseTask;
|
|
2303
2485
|
},
|
|
2486
|
+
() => workHubResults?.coordinator.close(),
|
|
2304
2487
|
() => runtimeResources?.close(),
|
|
2305
2488
|
() => workspaceExecution?.close(),
|
|
2306
2489
|
() => sessionEffects?.close(),
|
|
2490
|
+
() => promptSuggestions?.close(),
|
|
2307
2491
|
() => messages.close(),
|
|
2308
2492
|
() => interactions.close(),
|
|
2309
2493
|
() => turnAccessRequests?.close(),
|
|
@@ -2357,7 +2541,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2357
2541
|
beginDrain();
|
|
2358
2542
|
const handlers = composeRuntimeHostDomainHandlers(domainModules);
|
|
2359
2543
|
const recover = () => {
|
|
2360
|
-
recoveryTask ??= recoverRuntimeHostDomainModules(domainModules)
|
|
2544
|
+
recoveryTask ??= recoverRuntimeHostDomainModules(domainModules).then(() => {
|
|
2545
|
+
if (!draining)
|
|
2546
|
+
workHubResults?.coordinator.start();
|
|
2547
|
+
});
|
|
2361
2548
|
return recoveryTask;
|
|
2362
2549
|
};
|
|
2363
2550
|
const close = () => {
|
|
@@ -2495,6 +2682,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2495
2682
|
}
|
|
2496
2683
|
try {
|
|
2497
2684
|
await sessionEffects?.close();
|
|
2685
|
+
await promptSuggestions?.close();
|
|
2498
2686
|
}
|
|
2499
2687
|
catch (closeError) {
|
|
2500
2688
|
errors.push(closeError);
|
|
@@ -16,9 +16,12 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { buildPromptSuggestionPrompt } from './prompt-suggestion.js';
|
|
19
20
|
import { randomUUID } from 'node:crypto';
|
|
20
21
|
import { authorizeConnectionModel, effectiveBaseUrl, PROVIDER_REGISTRY, } from '@maka/core/llm-connections';
|
|
22
|
+
import { thinkingVariantsForConnection } from '@maka/core/model-thinking';
|
|
21
23
|
import { isModelExplicitlyUnsupportedForChat } from '@maka/core/model-catalog';
|
|
24
|
+
import { declaredModelApiProtocol } from '@maka/core/model-thinking';
|
|
22
25
|
import { parseRequestHeaders } from '@maka/core/runtime-policy';
|
|
23
26
|
import { applyWorkHubRoutingPolicy, bindWorkHubRoutingDecision, decodeWorkHubIntent, decodeWorkHubRecall, projectWorkHubIntentModelInput, projectWorkHubRecallModelInput, WORKHUB_INTENT_SYSTEM_PROMPT, WORKHUB_RECALL_SYSTEM_PROMPT, workHubIntentRequiresRecall, } from '@maka/core/workhub-routing';
|
|
24
27
|
import { buildPricingLookup, llmCallUsageFields, recordLlmCallStrict, } from '@maka/runtime/telemetry';
|
|
@@ -185,6 +188,31 @@ export function createHostDailyReviewModel(input) {
|
|
|
185
188
|
},
|
|
186
189
|
});
|
|
187
190
|
}
|
|
191
|
+
export function createHostPromptSuggestionModel(input) {
|
|
192
|
+
const authority = createAuxiliaryModelCallAuthority(input);
|
|
193
|
+
return async (source, abortSignal) => {
|
|
194
|
+
const result = await runHostAuxiliaryModelCall(authority, {
|
|
195
|
+
transportContextId: source.sessionId,
|
|
196
|
+
telemetrySessionId: source.sessionId,
|
|
197
|
+
header: { ...source.header, thinkingLevel: 'off' },
|
|
198
|
+
callKind: 'prompt_suggestion',
|
|
199
|
+
callId: `prompt_suggestion_${source.terminalEventId}_${authority.newId()}`,
|
|
200
|
+
abortSignal,
|
|
201
|
+
buildRequest: (target) => {
|
|
202
|
+
const variants = thinkingVariantsForConnection(target.connection, target.model);
|
|
203
|
+
if (variants.length && !variants.includes('off')) {
|
|
204
|
+
throw new AuxiliaryModelCallConfigurationError('Prompt suggestions require a model that can disable reasoning');
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
prompt: buildPromptSuggestionPrompt(source.messages, source.header.role === 'workhub_coordination'),
|
|
208
|
+
maxOutputTokens: 128,
|
|
209
|
+
maxRetries: 0,
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
return result.finishReason === 'length' ? undefined : result.text;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
188
216
|
/** Creates tool-free Session title and recap calls on canonical Host model authority. */
|
|
189
217
|
export function createHostSessionEffectModel(input) {
|
|
190
218
|
const authority = createAuxiliaryModelCallAuthority(input);
|
|
@@ -305,6 +333,9 @@ function createAuxiliaryModelCallAuthority(input) {
|
|
|
305
333
|
};
|
|
306
334
|
}
|
|
307
335
|
async function runHostAuxiliaryModelCall(authority, input) {
|
|
336
|
+
if (input.header.backend === 'plugin-executor') {
|
|
337
|
+
throw new AuxiliaryModelCallConfigurationError('Plugin executor Sessions do not provide a native auxiliary model');
|
|
338
|
+
}
|
|
308
339
|
const target = await readAuxiliaryPreflight(authority, input.abortSignal, () => readDuringBackendCreation(() => resolveExecutionTarget(input.header, authority.runtimePolicy, authority.oauthCredentials, authority.createFetchTransport), input.abortSignal));
|
|
309
340
|
const pricingSnapshot = await readAuxiliaryPreflight(authority, input.abortSignal, () => readDuringBackendCreation(() => authority.usage.pricing.snapshot(), input.abortSignal));
|
|
310
341
|
const request = input.buildRequest(target);
|
|
@@ -539,8 +570,12 @@ function executionConnectionRef(header) {
|
|
|
539
570
|
connectionSlug: header.llmConnectionSlug,
|
|
540
571
|
};
|
|
541
572
|
}
|
|
542
|
-
function providerStateIdentityForResolvedExecution(resolved) {
|
|
573
|
+
function providerStateIdentityForResolvedExecution(resolved, model) {
|
|
543
574
|
const credentialBasis = (material) => material ? { credentialId: material.credentialId, revision: material.revision } : null;
|
|
575
|
+
// Provider state from one wire cannot replay on another, so a model whose
|
|
576
|
+
// declared wire changes starts a new identity. Undeclared stays absent to
|
|
577
|
+
// keep every other identity unchanged.
|
|
578
|
+
const apiProtocol = declaredModelApiProtocol(resolved.connection, model);
|
|
544
579
|
return stableHash({
|
|
545
580
|
protocol: 'provider_state_identity_v1',
|
|
546
581
|
connectionId: resolved.connection.connectionId,
|
|
@@ -548,6 +583,7 @@ function providerStateIdentityForResolvedExecution(resolved) {
|
|
|
548
583
|
endpoint: new URL(effectiveBaseUrl(resolved.connection)).toString(),
|
|
549
584
|
credential: credentialBasis(resolved.secretMaterial.connection),
|
|
550
585
|
requestHeaders: credentialBasis(resolved.secretMaterial.requestHeaders),
|
|
586
|
+
...(apiProtocol === undefined ? {} : { apiProtocol }),
|
|
551
587
|
});
|
|
552
588
|
}
|
|
553
589
|
async function resolveDailyReviewHeader(runtimePolicy, modelKey) {
|
|
@@ -615,6 +651,9 @@ export async function resolveExecutionTarget(header, runtimePolicy, oauthCredent
|
|
|
615
651
|
slug: resolved.connection.slug,
|
|
616
652
|
providerType: resolved.connection.providerType,
|
|
617
653
|
...(resolved.connection.baseUrl ? { baseUrl: resolved.connection.baseUrl } : {}),
|
|
654
|
+
...(resolved.connection.defaultApiProtocol === undefined
|
|
655
|
+
? {}
|
|
656
|
+
: { defaultApiProtocol: resolved.connection.defaultApiProtocol }),
|
|
618
657
|
defaultModel: model,
|
|
619
658
|
models: discovered
|
|
620
659
|
? [...resolved.connection.models]
|
|
@@ -629,7 +668,7 @@ export async function resolveExecutionTarget(header, runtimePolicy, oauthCredent
|
|
|
629
668
|
const requestHeaders = resolved.secretMaterial.requestHeaders
|
|
630
669
|
? parseRequestHeaders(resolved.secretMaterial.requestHeaders.secret)
|
|
631
670
|
: {};
|
|
632
|
-
const providerStateIdentity = providerStateIdentityForResolvedExecution(resolved);
|
|
671
|
+
const providerStateIdentity = providerStateIdentityForResolvedExecution(resolved, model);
|
|
633
672
|
if (provider.authKind === 'oauth_token') {
|
|
634
673
|
const material = resolved.secretMaterial.connection;
|
|
635
674
|
if (!material) {
|
|
@@ -233,6 +233,10 @@ export function extensionPackageContentDigest(files) {
|
|
|
233
233
|
}
|
|
234
234
|
return `sha256-${hash.digest('hex')}`;
|
|
235
235
|
}
|
|
236
|
+
/** Computes the canonical digest used by PluginPackageStore without installing the package. */
|
|
237
|
+
export async function extensionPackageDirectoryContentDigest(root) {
|
|
238
|
+
return extensionPackageContentDigest(await readDirectory(root));
|
|
239
|
+
}
|
|
236
240
|
function safePath(value) {
|
|
237
241
|
if (!value ||
|
|
238
242
|
value.length > 512 ||
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
export function firstGeneratedLine(text) {
|
|
20
|
+
return text
|
|
21
|
+
.replace(/<think>[\s\S]*?(?:<\/think>|$)/gi, '')
|
|
22
|
+
.split(/\r?\n/)
|
|
23
|
+
.map((line) => line.trim())
|
|
24
|
+
.find(Boolean);
|
|
25
|
+
}
|
|
26
|
+
export function unquoteGeneratedText(text) {
|
|
27
|
+
const pairs = [
|
|
28
|
+
['"', '"'],
|
|
29
|
+
["'", "'"],
|
|
30
|
+
['`', '`'],
|
|
31
|
+
['“', '”'],
|
|
32
|
+
['「', '」'],
|
|
33
|
+
['『', '』'],
|
|
34
|
+
];
|
|
35
|
+
const unquoted = pairs.find(([left, right]) => text.startsWith(left) && text.endsWith(right))
|
|
36
|
+
? text.slice(1, -1).trim()
|
|
37
|
+
: text;
|
|
38
|
+
return unquoted;
|
|
39
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID } from '../composition-identity.js';
|
|
20
|
+
const COMPOSITION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
|
21
|
+
export function defineRuntimeHostComposition(descriptor, create) {
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
descriptor: normalizeHostCompositionDescriptor(descriptor),
|
|
24
|
+
create,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function defineInteractiveRuntimeHostComposition(create) {
|
|
28
|
+
return defineRuntimeHostComposition(INTERACTIVE_HOST_COMPOSITION_DESCRIPTOR, create);
|
|
29
|
+
}
|
|
30
|
+
export function normalizeHostCompositionDescriptor(descriptor) {
|
|
31
|
+
if (!COMPOSITION_ID_PATTERN.test(descriptor.id) || descriptor.id.length > 128) {
|
|
32
|
+
throw new TypeError('Runtime Host composition id is invalid');
|
|
33
|
+
}
|
|
34
|
+
if (descriptor.revision.length === 0 ||
|
|
35
|
+
descriptor.revision.length > 128 ||
|
|
36
|
+
/[\u0000-\u001f\u007f]/u.test(descriptor.revision)) {
|
|
37
|
+
throw new TypeError('Runtime Host composition revision is invalid');
|
|
38
|
+
}
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
id: descriptor.id,
|
|
41
|
+
revision: descriptor.revision,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export const INTERACTIVE_HOST_COMPOSITION_DESCRIPTOR = normalizeHostCompositionDescriptor({
|
|
45
|
+
id: INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID,
|
|
46
|
+
revision: '3',
|
|
47
|
+
});
|