maka-agent 0.2.0-dev.22.20260905 → 0.2.0-dev.24.20260907
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/maka-acp-agent.js +2 -1
- package/dist/acp/session-configuration.js +143 -0
- package/dist/acp/session-registry.js +90 -4
- package/dist/cli-core.js +2 -0
- package/dist/pi-transcript.js +5 -12
- package/dist/pi-tui-runner.js +74 -4
- package/dist/runtime-host-cli-context.js +167 -78
- package/dist/runtime-host-cli-installation.js +8 -2
- package/dist/runtime-host-cli.js +31 -1
- package/dist/runtime-host-handoff-surface.js +81 -0
- package/dist/runtime-host-installed-update-bootstrap.js +13 -0
- package/dist/runtime-host-installed-update-coordinator.js +33 -0
- package/dist/runtime-host-lifecycle-transaction.js +9 -1
- package/dist/runtime-host-local-handoff.js +37 -4
- package/dist/runtime-host-local-managed-activation.js +84 -0
- package/dist/runtime-host-local-source-retirement.js +18 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-operator-retirement.js +50 -0
- package/dist/runtime-host-service-manager.js +3 -0
- package/dist/runtime-host-session-driver.js +4 -25
- package/dist/runtime-host-session-update.js +62 -0
- package/dist/runtime-host-tui-command.js +38 -73
- package/dist/runtime-host-tui-context.js +1 -0
- package/dist/runtime-host-tui-owner.js +226 -0
- package/dist/tui-copy-catalog.js +140 -3
- package/dist/tui-host-owner-copy.js +24 -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/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/bot-events.js +18 -63
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- package/node_modules/@maka/core/dist/model-call-attempt.js +0 -82
- package/node_modules/@maka/core/dist/model-call-usage-projection.js +0 -186
- package/node_modules/@maka/core/dist/model-failure.js +40 -0
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
- package/node_modules/@maka/core/dist/model-metadata.js +3 -3
- package/node_modules/@maka/core/dist/model-web-search.js +5 -4
- package/node_modules/@maka/core/dist/provider-registry.js +45 -4
- package/node_modules/@maka/core/dist/record-schema.js +22 -2
- package/node_modules/@maka/core/dist/redaction.js +41 -58
- package/node_modules/@maka/core/dist/runtime-boundary.js +31 -11
- package/node_modules/@maka/core/dist/runtime-event.js +37 -6
- package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
- package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
- package/node_modules/@maka/core/dist/session-trace.js +5 -1
- package/node_modules/@maka/core/dist/session.js +54 -52
- package/node_modules/@maka/core/dist/slash-command-catalog.js +2 -0
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
- package/node_modules/@maka/core/dist/usage-ledger-merge.js +7 -9
- package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +34 -20
- package/node_modules/@maka/core/package.json +4 -0
- package/node_modules/@maka/eval/harbor/egress-proxy/entrypoint.sh +2 -1
- package/node_modules/@maka/mcp/dist/index.js +131 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +272 -105
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +13 -5
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +155 -134
- package/node_modules/@maka/runtime/dist/bots/base-adapter.js +17 -0
- package/node_modules/@maka/runtime/dist/bots/bot-test.js +38 -22
- package/node_modules/@maka/runtime/dist/bots/dingtalk-bridge.js +7 -5
- package/node_modules/@maka/runtime/dist/bots/discord-bridge.js +4 -4
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +4 -5
- package/node_modules/@maka/runtime/dist/bots/qq-bridge.js +6 -4
- package/node_modules/@maka/runtime/dist/bots/slack-bridge.js +3 -4
- package/node_modules/@maka/runtime/dist/bots/telegram-bridge.js +4 -5
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +17 -19
- package/node_modules/@maka/runtime/dist/bots/wecom-bridge.js +5 -6
- package/node_modules/@maka/runtime/dist/bots/ws-bridge-base.js +2 -3
- package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
- package/node_modules/@maka/runtime/dist/conversation-copy.js +5 -4
- package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
- package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
- package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +106 -0
- package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
- package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
- package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
- package/node_modules/@maka/runtime/dist/model-fetcher.js +7 -0
- package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
- package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +68 -108
- package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +82 -54
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +117 -159
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +150 -112
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
- package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
- package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
- package/node_modules/@maka/runtime/dist/session-trace-projection.js +3 -30
- package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
- package/node_modules/@maka/runtime/dist/test-connection.js +16 -16
- package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
- package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +4 -1
- package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
- package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +156 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +273 -0
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
- package/node_modules/@maka/runtime-host/dist/client/index.js +3 -1
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +13 -0
- package/node_modules/@maka/runtime-host/dist/client/registered-host-termination.js +0 -59
- package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +27 -5
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +28 -16
- package/node_modules/@maka/runtime-host/dist/protocol/external-session.js +4 -0
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +29 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +37 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +2 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +28 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +40 -20
- package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
- package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +33 -0
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +26 -1
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +6 -1
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/canonical-usage-reader.js +24 -11
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +7 -4
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +168 -28
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +6 -3
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +108 -23
- package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +85 -8
- package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +7 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +344 -71
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +201 -12
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +8 -55
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -0
- package/node_modules/@maka/runtime-host/dist/server/usage-pricing-coordinator.js +4 -11
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -15
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +6 -2
- package/node_modules/@maka/storage/dist/agent-run-store.js +44 -0
- package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
- package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
- package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +0 -2
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
- package/node_modules/@maka/storage/dist/conversation-operational-state.js +4 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +11 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
- package/node_modules/@maka/storage/dist/model-call-ledger.js +199 -32
- package/node_modules/@maka/storage/dist/model-call-usage-sql.js +136 -0
- package/node_modules/@maka/storage/dist/opencode-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
- package/node_modules/@maka/storage/dist/operational-state-store-public.js +1 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +5 -3
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +24 -4
- package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
- package/node_modules/@maka/storage/dist/session-repository.js +767 -0
- package/node_modules/@maka/storage/dist/session-store.js +25 -99
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +17 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +129 -25
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
- package/node_modules/@maka/storage/dist/sqlite-usage-schema.js +200 -20
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +111 -0
- package/node_modules/@maka/storage/dist/usage-stores.js +6 -2
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -26,5 +26,6 @@ export function createMakaAcpAgent(options) {
|
|
|
26
26
|
agentInfo: { name: 'maka', title: 'Maka', version: options.version },
|
|
27
27
|
}))
|
|
28
28
|
.onRequest(methods.agent.session.new, ({ params }) => options.sessionRegistry.create(params))
|
|
29
|
-
.onRequest(methods.agent.session.list, ({ params }) => options.sessionRegistry.list(params))
|
|
29
|
+
.onRequest(methods.agent.session.list, ({ params }) => options.sessionRegistry.list(params))
|
|
30
|
+
.onRequest(methods.agent.session.setConfigOption, ({ params }) => options.sessionRegistry.setConfigOption(params));
|
|
30
31
|
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 { COLLABORATION_MODES } from '@maka/core/collaboration';
|
|
20
|
+
import { THINKING_LEVELS } from '@maka/core/model-thinking';
|
|
21
|
+
import { ORCHESTRATION_MODES } from '@maka/core/orchestration';
|
|
22
|
+
import { CHAT_DEFAULT_PERMISSION_MODES } from '@maka/core/settings';
|
|
23
|
+
const PERMISSION_NAMES = {
|
|
24
|
+
explore: 'Explore',
|
|
25
|
+
ask: 'Ask',
|
|
26
|
+
bypass: 'Bypass',
|
|
27
|
+
};
|
|
28
|
+
const THINKING_NAMES = {
|
|
29
|
+
default: 'Default',
|
|
30
|
+
off: 'Off',
|
|
31
|
+
minimal: 'Minimal',
|
|
32
|
+
low: 'Low',
|
|
33
|
+
medium: 'Medium',
|
|
34
|
+
high: 'High',
|
|
35
|
+
xhigh: 'Extra high',
|
|
36
|
+
max: 'Max',
|
|
37
|
+
};
|
|
38
|
+
const COLLABORATION_NAMES = {
|
|
39
|
+
agent: 'Agent',
|
|
40
|
+
plan: 'Plan',
|
|
41
|
+
};
|
|
42
|
+
const ORCHESTRATION_NAMES = {
|
|
43
|
+
default: 'Default',
|
|
44
|
+
swarm: 'Swarm',
|
|
45
|
+
graph: 'Graph',
|
|
46
|
+
};
|
|
47
|
+
const PERMISSION_SPEC = {
|
|
48
|
+
id: 'permission_mode',
|
|
49
|
+
name: 'Permission mode',
|
|
50
|
+
category: '_maka/permission_mode',
|
|
51
|
+
options: namedOptions(CHAT_DEFAULT_PERMISSION_MODES, PERMISSION_NAMES),
|
|
52
|
+
};
|
|
53
|
+
const THINKING_SPEC = {
|
|
54
|
+
id: 'thinking_level',
|
|
55
|
+
name: 'Thinking level',
|
|
56
|
+
category: 'thought_level',
|
|
57
|
+
options: namedOptions(['default', ...THINKING_LEVELS], THINKING_NAMES),
|
|
58
|
+
};
|
|
59
|
+
const COLLABORATION_SPEC = {
|
|
60
|
+
id: 'collaboration_mode',
|
|
61
|
+
name: 'Collaboration mode',
|
|
62
|
+
category: 'mode',
|
|
63
|
+
options: namedOptions(COLLABORATION_MODES, COLLABORATION_NAMES),
|
|
64
|
+
};
|
|
65
|
+
const ORCHESTRATION_SPEC = {
|
|
66
|
+
id: 'orchestration_mode',
|
|
67
|
+
name: 'Orchestration mode',
|
|
68
|
+
category: '_maka/orchestration_mode',
|
|
69
|
+
options: namedOptions(ORCHESTRATION_MODES, ORCHESTRATION_NAMES),
|
|
70
|
+
};
|
|
71
|
+
const CONFIG_SPECS = [
|
|
72
|
+
PERMISSION_SPEC,
|
|
73
|
+
THINKING_SPEC,
|
|
74
|
+
COLLABORATION_SPEC,
|
|
75
|
+
ORCHESTRATION_SPEC,
|
|
76
|
+
];
|
|
77
|
+
export function projectAcpSessionConfigOptions(session, thinkingLevels) {
|
|
78
|
+
return [
|
|
79
|
+
configOption(PERMISSION_SPEC, session.permissionMode),
|
|
80
|
+
...(thinkingLevels.length === 0
|
|
81
|
+
? []
|
|
82
|
+
: [
|
|
83
|
+
configOption({
|
|
84
|
+
...THINKING_SPEC,
|
|
85
|
+
options: namedOptions(['default', ...thinkingLevels], THINKING_NAMES),
|
|
86
|
+
}, session.thinkingLevel ?? 'default'),
|
|
87
|
+
]),
|
|
88
|
+
configOption(COLLABORATION_SPEC, session.collaborationMode),
|
|
89
|
+
configOption(ORCHESTRATION_SPEC, session.orchestrationMode),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
function namedOptions(values, names) {
|
|
93
|
+
return values.map((value) => [value, names[value]]);
|
|
94
|
+
}
|
|
95
|
+
function configOption(spec, currentValue) {
|
|
96
|
+
return {
|
|
97
|
+
type: 'select',
|
|
98
|
+
id: spec.id,
|
|
99
|
+
name: spec.name,
|
|
100
|
+
category: spec.category,
|
|
101
|
+
currentValue,
|
|
102
|
+
options: spec.options.map(([value, name]) => ({ value, name })),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export class AcpSessionConfigInputError extends Error {
|
|
106
|
+
field;
|
|
107
|
+
reason;
|
|
108
|
+
name = 'AcpSessionConfigInputError';
|
|
109
|
+
constructor(field, reason) {
|
|
110
|
+
super(`Invalid ACP Session configuration ${field}`);
|
|
111
|
+
this.field = field;
|
|
112
|
+
this.reason = reason;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export function validateAcpSessionConfigOptionRequest(request) {
|
|
116
|
+
const spec = CONFIG_SPECS.find(({ id }) => id === request.configId);
|
|
117
|
+
if (!spec)
|
|
118
|
+
throw new AcpSessionConfigInputError('configId', 'unsupported');
|
|
119
|
+
if (typeof request.value !== 'string')
|
|
120
|
+
throw new AcpSessionConfigInputError('value', 'invalid_type');
|
|
121
|
+
if (!spec.options.some(([value]) => value === request.value)) {
|
|
122
|
+
throw new AcpSessionConfigInputError('value', 'unsupported');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export function createAcpSessionConfigPatch(request) {
|
|
126
|
+
validateAcpSessionConfigOptionRequest(request);
|
|
127
|
+
switch (request.configId) {
|
|
128
|
+
case 'permission_mode':
|
|
129
|
+
return { permissionMode: request.value };
|
|
130
|
+
case 'thinking_level':
|
|
131
|
+
return {
|
|
132
|
+
thinkingLevel: request.value === 'default'
|
|
133
|
+
? null
|
|
134
|
+
: request.value,
|
|
135
|
+
};
|
|
136
|
+
case 'collaboration_mode':
|
|
137
|
+
return { collaborationMode: request.value };
|
|
138
|
+
case 'orchestration_mode':
|
|
139
|
+
return { orchestrationMode: request.value };
|
|
140
|
+
default:
|
|
141
|
+
throw new AcpSessionConfigInputError('configId', 'unsupported');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -20,14 +20,17 @@ import { randomUUID } from 'node:crypto';
|
|
|
20
20
|
import { realpath } from 'node:fs/promises';
|
|
21
21
|
import { isAbsolute, normalize } from 'node:path';
|
|
22
22
|
import { RequestError, } from '@agentclientprotocol/sdk';
|
|
23
|
-
import { readRuntimeHostSessionCatalogPage, RuntimeHostCatalogReadError, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, RuntimeHostSessionCatalogRevisionChangedError, } from '@maka/runtime-host/client';
|
|
23
|
+
import { readRuntimeHostConnectionCatalog, readRuntimeHostSessionCatalogPage, RuntimeHostCatalogReadError, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, RuntimeHostSessionCatalogRevisionChangedError, } from '@maka/runtime-host/client';
|
|
24
24
|
import { SESSION_CATALOG_CURSOR_MAX_BYTES, SESSION_CATALOG_CWD_MAX_BYTES, } from '@maka/runtime-host/protocol';
|
|
25
|
+
import { RuntimeHostSessionUpdateError, requireRuntimeHostSessionProjection, updateRuntimeHostSession, } from '../runtime-host-session-update.js';
|
|
26
|
+
import { AcpSessionConfigInputError, createAcpSessionConfigPatch, projectAcpSessionConfigOptions, validateAcpSessionConfigOptionRequest, } from './session-configuration.js';
|
|
25
27
|
const ACP_SESSION_CURSOR_MAX_BYTES = 8 * 1024;
|
|
26
28
|
/** Owns all Runtime Host resources associated with one ACP connection. */
|
|
27
29
|
export class AcpSessionRegistry {
|
|
28
30
|
#connect;
|
|
29
31
|
#newSessionId;
|
|
30
32
|
#inFlightOperations = new Set();
|
|
33
|
+
#ownedSessionIds = new Set();
|
|
31
34
|
#connection;
|
|
32
35
|
#connectTask;
|
|
33
36
|
#connectAbortController;
|
|
@@ -47,6 +50,19 @@ export class AcpSessionRegistry {
|
|
|
47
50
|
this.#assertOpen('session.catalog.query');
|
|
48
51
|
return this.#track(this.#list(params));
|
|
49
52
|
}
|
|
53
|
+
async setConfigOption(params) {
|
|
54
|
+
this.#assertOpen('session.configuration.update');
|
|
55
|
+
if (!this.#ownedSessionIds.has(params.sessionId)) {
|
|
56
|
+
throw RequestError.invalidParams({ reason: 'unknown_session' }, 'Session is not owned by this ACP connection');
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
validateAcpSessionConfigOptionRequest(params);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw requestErrorFromConfigInput(error);
|
|
63
|
+
}
|
|
64
|
+
return this.#track(this.#setConfigOption(params));
|
|
65
|
+
}
|
|
50
66
|
dispose() {
|
|
51
67
|
this.#closing = true;
|
|
52
68
|
this.#connectAbortController?.abort();
|
|
@@ -56,8 +72,9 @@ export class AcpSessionRegistry {
|
|
|
56
72
|
async #create(params) {
|
|
57
73
|
const connection = await this.#getConnection('session.create');
|
|
58
74
|
const sessionId = this.#newSessionId();
|
|
75
|
+
let result;
|
|
59
76
|
try {
|
|
60
|
-
await connection.request('session.create', {
|
|
77
|
+
result = await connection.request('session.create', {
|
|
61
78
|
sessionId,
|
|
62
79
|
workspace: { kind: 'host_path', path: params.cwd },
|
|
63
80
|
modelTarget: { kind: 'default' },
|
|
@@ -66,7 +83,46 @@ export class AcpSessionRegistry {
|
|
|
66
83
|
catch (error) {
|
|
67
84
|
throw requestErrorFromRuntimeHost(error, 'session.create', { sessionId });
|
|
68
85
|
}
|
|
69
|
-
|
|
86
|
+
let created;
|
|
87
|
+
try {
|
|
88
|
+
created = requireRuntimeHostSessionProjection(result, 'session.create');
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
throw requestErrorFromSessionUpdate(error, 'session.create', { sessionId });
|
|
92
|
+
}
|
|
93
|
+
const configOptions = await this.#projectConfigOptions(connection, created);
|
|
94
|
+
this.#ownedSessionIds.add(sessionId);
|
|
95
|
+
return { sessionId, configOptions };
|
|
96
|
+
}
|
|
97
|
+
async #setConfigOption(params) {
|
|
98
|
+
const connection = await this.#getConnection('session.configuration.update');
|
|
99
|
+
let committed;
|
|
100
|
+
try {
|
|
101
|
+
committed = await updateRuntimeHostSession(connection, params.sessionId, (current) => connection.request('session.configuration.update', {
|
|
102
|
+
sessionId: params.sessionId,
|
|
103
|
+
expectedRevision: current.revision,
|
|
104
|
+
patch: createAcpSessionConfigPatch(params),
|
|
105
|
+
}), {
|
|
106
|
+
operation: 'session.configuration.update',
|
|
107
|
+
assertRequestAllowed: () => this.#assertOpen('session.configuration.update'),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
throw requestErrorFromSessionUpdate(error, 'session.configuration.update');
|
|
112
|
+
}
|
|
113
|
+
return { configOptions: await this.#projectConfigOptions(connection, committed) };
|
|
114
|
+
}
|
|
115
|
+
async #projectConfigOptions(connection, session) {
|
|
116
|
+
let catalog;
|
|
117
|
+
try {
|
|
118
|
+
catalog = await readRuntimeHostConnectionCatalog(connection);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
throw requestErrorFromRuntimeHost(error, 'connection.catalog.query');
|
|
122
|
+
}
|
|
123
|
+
const selectedConnection = catalog.connections.find(({ connectionId }) => connectionId === session.llmConnectionId);
|
|
124
|
+
const selectedModel = selectedConnection?.catalogEntries.find(({ id }) => id === session.model);
|
|
125
|
+
return projectAcpSessionConfigOptions(session, selectedModel?.thinkingLevels ?? []);
|
|
70
126
|
}
|
|
71
127
|
async #list(params) {
|
|
72
128
|
const cursor = params.cursor == null ? undefined : decodeAcpSessionCursor(params.cursor);
|
|
@@ -110,6 +166,7 @@ export class AcpSessionRegistry {
|
|
|
110
166
|
const connectionClose = this.#closeOwnedConnection();
|
|
111
167
|
await Promise.allSettled([connectionClose]);
|
|
112
168
|
await Promise.allSettled([...this.#inFlightOperations]);
|
|
169
|
+
this.#ownedSessionIds.clear();
|
|
113
170
|
}
|
|
114
171
|
#closeOwnedConnection() {
|
|
115
172
|
const connection = this.#connection;
|
|
@@ -192,9 +249,38 @@ function validateNewSessionParams(params) {
|
|
|
192
249
|
throw RequestError.invalidParams({ field: 'additionalDirectories', reason: 'unsupported' }, 'Additional directories are not supported by this ACP adapter yet');
|
|
193
250
|
}
|
|
194
251
|
}
|
|
252
|
+
function requestErrorFromConfigInput(error) {
|
|
253
|
+
if (error instanceof AcpSessionConfigInputError) {
|
|
254
|
+
return RequestError.invalidParams({ field: error.field, reason: error.reason }, 'Invalid Session configuration option');
|
|
255
|
+
}
|
|
256
|
+
return RequestError.internalError({
|
|
257
|
+
source: 'adapter',
|
|
258
|
+
operation: 'session.configuration.update',
|
|
259
|
+
code: 'validation_failed',
|
|
260
|
+
}, 'Session configuration validation failed');
|
|
261
|
+
}
|
|
262
|
+
function requestErrorFromSessionUpdate(error, operation, extra = {}) {
|
|
263
|
+
if (error instanceof RequestError)
|
|
264
|
+
return error;
|
|
265
|
+
if (!(error instanceof RuntimeHostSessionUpdateError)) {
|
|
266
|
+
return requestErrorFromRuntimeHost(error, operation, extra);
|
|
267
|
+
}
|
|
268
|
+
const common = { source: 'runtime_host', operation: error.operation, ...extra };
|
|
269
|
+
switch (error.reason) {
|
|
270
|
+
case 'not_found':
|
|
271
|
+
return RequestError.invalidParams({ ...common, code: 'not_found' }, 'Runtime Host Session was not found');
|
|
272
|
+
case 'invalid_projection':
|
|
273
|
+
return RequestError.internalError({ ...common, code: 'catalog_read_failure', reason: 'invalid_projection' }, 'Runtime Host returned an invalid Session lookup');
|
|
274
|
+
case 'unsupported_session_projection':
|
|
275
|
+
return RequestError.internalError({ ...common, code: 'unsupported_session_projection' }, 'Runtime Host Session cannot be represented in ACP');
|
|
276
|
+
case 'revision_conflict':
|
|
277
|
+
return RequestError.internalError({ ...common, code: 'revision_conflict', attempts: error.attempts }, 'Session configuration kept changing');
|
|
278
|
+
}
|
|
279
|
+
}
|
|
195
280
|
function requestErrorFromRuntimeHost(error, operation, extra = {}) {
|
|
196
281
|
const data = { ...runtimeHostErrorData(error, operation), ...extra };
|
|
197
|
-
if (error instanceof RuntimeHostOperationError &&
|
|
282
|
+
if (error instanceof RuntimeHostOperationError &&
|
|
283
|
+
(error.code === 'invalid_request' || error.code === 'not_found')) {
|
|
198
284
|
return RequestError.invalidParams(data, 'Runtime Host rejected the request');
|
|
199
285
|
}
|
|
200
286
|
return RequestError.internalError(data, 'Runtime Host request failed');
|
package/dist/cli-core.js
CHANGED
|
@@ -338,6 +338,7 @@ export async function runMakaCli(argv = process.argv.slice(2), options = RELEASE
|
|
|
338
338
|
: { compatibility: command.targetCompatibility }),
|
|
339
339
|
},
|
|
340
340
|
allowInterruptActiveTasks: command.allowInterruptActiveTasks,
|
|
341
|
+
...(command.expectedSource ? { expectedSource: command.expectedSource } : {}),
|
|
341
342
|
});
|
|
342
343
|
}
|
|
343
344
|
case 'runtime-host-local-update-activate': {
|
|
@@ -422,6 +423,7 @@ export async function runMakaCli(argv = process.argv.slice(2), options = RELEASE
|
|
|
422
423
|
...(command.expectedConfigFingerprint
|
|
423
424
|
? { expectedConfigFingerprint: command.expectedConfigFingerprint }
|
|
424
425
|
: {}),
|
|
426
|
+
...(command.expectedHost ? { expectedHost: command.expectedHost } : {}),
|
|
425
427
|
...(command.retainManagedDeployment ? { retainManagedDeployment: true } : {}),
|
|
426
428
|
...(command.allowInterruptActiveTasks ? { allowInterruptActiveTasks: true } : {}),
|
|
427
429
|
});
|
package/dist/pi-transcript.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { Markdown, visibleWidth } from '@earendil-works/pi-tui';
|
|
20
|
-
import { deriveTurnRecords, STEP_LIMIT_NOTICE_TEXT, } from '@maka/core/session';
|
|
20
|
+
import { deriveTurnRecords, isRuntimeSystemNoteKind, STEP_LIMIT_NOTICE_TEXT, } from '@maka/core/session';
|
|
21
21
|
import { providerRetryDisplaySeconds } from '@maka/core/provider-retry-countdown';
|
|
22
22
|
import { defineUiMessageCatalog, resolveUiMessageCatalog, } from '@maka/core/ui-locale';
|
|
23
23
|
import { TUI_COPY_RESOURCES } from './tui-copy-catalog.js';
|
|
@@ -931,14 +931,11 @@ function tokenDelta(before, after) {
|
|
|
931
931
|
return Math.max(0, before - after);
|
|
932
932
|
}
|
|
933
933
|
function systemNoteText(message) {
|
|
934
|
+
// Retired kinds are still decoded off legacy transcript rows, and none of
|
|
935
|
+
// them ever had a line here worth reading.
|
|
936
|
+
if (!isRuntimeSystemNoteKind(message.kind))
|
|
937
|
+
return undefined;
|
|
934
938
|
switch (message.kind) {
|
|
935
|
-
case 'session_start':
|
|
936
|
-
case 'session_resume':
|
|
937
|
-
return undefined;
|
|
938
|
-
case 'mode_change':
|
|
939
|
-
return 'Permission mode changed.';
|
|
940
|
-
case 'model_change':
|
|
941
|
-
return 'Model changed.';
|
|
942
939
|
case 'context_compacted':
|
|
943
940
|
return 'Context compacted to keep this task within the model window.';
|
|
944
941
|
case 'context_compaction_failed_open':
|
|
@@ -984,10 +981,6 @@ function systemNoteText(message) {
|
|
|
984
981
|
}
|
|
985
982
|
case 'step_limit':
|
|
986
983
|
return STEP_LIMIT_NOTICE_TEXT;
|
|
987
|
-
case 'error':
|
|
988
|
-
return 'Session recorded an error.';
|
|
989
|
-
case 'abort':
|
|
990
|
-
return 'Session was stopped.';
|
|
991
984
|
}
|
|
992
985
|
}
|
|
993
986
|
export function renderMakaPiTranscript(state, metadata, width) {
|
package/dist/pi-tui-runner.js
CHANGED
|
@@ -41,6 +41,7 @@ import { MakaAutocompleteAboveEditorComponent } from './tui-autocomplete-layout.
|
|
|
41
41
|
import { TranscriptViewerOverlay } from './pi-tui-transcript-viewer.js';
|
|
42
42
|
import { copyToClipboard } from './tui-clipboard.js';
|
|
43
43
|
import { getTuiCopyCopy, lastAssistantText, serializeTranscriptText } from './tui-copy-command.js';
|
|
44
|
+
import { getTuiHostOwnerCopy } from './tui-host-owner-copy.js';
|
|
44
45
|
import { McpManagementOverlay } from './pi-tui-mcp-status.js';
|
|
45
46
|
import { createShellRunElapsedTicker } from './shell-run-elapsed-ticker.js';
|
|
46
47
|
import { createShellRunHydrationController } from './shell-run-hydration.js';
|
|
@@ -632,10 +633,8 @@ export async function runMakaPiTui(input) {
|
|
|
632
633
|
rejectClosed(error);
|
|
633
634
|
else
|
|
634
635
|
resolveClosed();
|
|
635
|
-
//
|
|
636
|
-
//
|
|
637
|
-
if (!interruptRequested)
|
|
638
|
-
void input.driver.stop().catch(() => { });
|
|
636
|
+
// Closing a viewport is not a Turn or Host stop. Explicit interrupt keys
|
|
637
|
+
// retain their own stop path; an attached Host continues independently.
|
|
639
638
|
};
|
|
640
639
|
const handleProcessExit = (exitCode, error) => {
|
|
641
640
|
process.exitCode = exitCode;
|
|
@@ -2943,7 +2942,78 @@ export async function runMakaPiTui(input) {
|
|
|
2943
2942
|
notice('Goal cleared.');
|
|
2944
2943
|
}
|
|
2945
2944
|
};
|
|
2945
|
+
const runHostCommand = async (parts) => {
|
|
2946
|
+
const copy = getTuiHostOwnerCopy(locale);
|
|
2947
|
+
if (!input.hostControl)
|
|
2948
|
+
throw new Error(copy.unavailable);
|
|
2949
|
+
const action = parts[1] ?? 'status';
|
|
2950
|
+
if (action === 'status' && parts.length <= 2) {
|
|
2951
|
+
const text = await input.hostControl.status();
|
|
2952
|
+
if (!closed) {
|
|
2953
|
+
state.entries.push({ kind: 'notice', level: 'info', text });
|
|
2954
|
+
requestRender();
|
|
2955
|
+
}
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
if (action !== 'stop' && action !== 'restart' && action !== 'update') {
|
|
2959
|
+
throw new Error(copy.usage);
|
|
2960
|
+
}
|
|
2961
|
+
const targets = parts.slice(2);
|
|
2962
|
+
if (targets.length > (action === 'update' ? 1 : 0)) {
|
|
2963
|
+
throw new Error(copy.usage);
|
|
2964
|
+
}
|
|
2965
|
+
const accepted = await input.hostControl.prepare({
|
|
2966
|
+
action,
|
|
2967
|
+
...(targets[0] ? { target: targets[0] } : {}),
|
|
2968
|
+
}, (detail) => new Promise((resolve) => {
|
|
2969
|
+
if (closed)
|
|
2970
|
+
return resolve('cancel');
|
|
2971
|
+
showSelectPicker(copy.pickerTitle, 'cancel', [
|
|
2972
|
+
{
|
|
2973
|
+
value: 'cancel',
|
|
2974
|
+
label: copy.cancel,
|
|
2975
|
+
description: copy.cancelDescription,
|
|
2976
|
+
},
|
|
2977
|
+
{
|
|
2978
|
+
value: 'safe',
|
|
2979
|
+
label: copy.safe,
|
|
2980
|
+
description: copy.safeDescription,
|
|
2981
|
+
},
|
|
2982
|
+
...(action === 'update'
|
|
2983
|
+
? []
|
|
2984
|
+
: [
|
|
2985
|
+
{
|
|
2986
|
+
value: 'interrupt',
|
|
2987
|
+
label: copy.interrupt,
|
|
2988
|
+
description: copy.interruptDescription,
|
|
2989
|
+
},
|
|
2990
|
+
]),
|
|
2991
|
+
], (item) => resolve(item.value), {
|
|
2992
|
+
minPrimaryColumnWidth: 16,
|
|
2993
|
+
maxPrimaryColumnWidth: 26,
|
|
2994
|
+
selectedIndex: 0,
|
|
2995
|
+
notice: detail,
|
|
2996
|
+
onCancel: () => resolve('cancel'),
|
|
2997
|
+
});
|
|
2998
|
+
}));
|
|
2999
|
+
if (accepted)
|
|
3000
|
+
beginGracefulClose();
|
|
3001
|
+
};
|
|
2946
3002
|
const slashCommandHandlers = {
|
|
3003
|
+
host: {
|
|
3004
|
+
description: primaryGuidance.commands.host,
|
|
3005
|
+
midTurn: 'local',
|
|
3006
|
+
run: (parts) => {
|
|
3007
|
+
void runHostCommand(parts).catch(reportError);
|
|
3008
|
+
},
|
|
3009
|
+
},
|
|
3010
|
+
update: {
|
|
3011
|
+
description: primaryGuidance.commands.update,
|
|
3012
|
+
midTurn: 'local',
|
|
3013
|
+
run: (parts) => {
|
|
3014
|
+
void runHostCommand(['/host', 'update', ...parts.slice(1)]).catch(reportError);
|
|
3015
|
+
},
|
|
3016
|
+
},
|
|
2947
3017
|
context: {
|
|
2948
3018
|
description: primaryGuidance.commands.context,
|
|
2949
3019
|
// Read-only diagnostics, but runControl-gated: mid-turn it would
|