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
|
@@ -25,33 +25,6 @@ export function buildStatusPatch(status, ts, blockedReason) {
|
|
|
25
25
|
statusUpdatedAt: ts,
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
export function buildTurnStateMessage(input) {
|
|
29
|
-
const lineage = input.lineage ?? {};
|
|
30
|
-
return {
|
|
31
|
-
type: 'turn_state',
|
|
32
|
-
id: input.id,
|
|
33
|
-
turnId: input.turnId,
|
|
34
|
-
ts: input.ts,
|
|
35
|
-
status: input.status,
|
|
36
|
-
...(lineage.parentTurnId ? { parentTurnId: lineage.parentTurnId } : {}),
|
|
37
|
-
...(lineage.retriedFromTurnId ? { retriedFromTurnId: lineage.retriedFromTurnId } : {}),
|
|
38
|
-
...(lineage.regeneratedFromTurnId
|
|
39
|
-
? { regeneratedFromTurnId: lineage.regeneratedFromTurnId }
|
|
40
|
-
: {}),
|
|
41
|
-
...(lineage.branchOfTurnId ? { branchOfTurnId: lineage.branchOfTurnId } : {}),
|
|
42
|
-
...(lineage.parentSessionId ? { parentSessionId: lineage.parentSessionId } : {}),
|
|
43
|
-
...(input.status === 'aborted' ? { abortedAt: input.ts } : {}),
|
|
44
|
-
...(input.status === 'aborted' && input.abortSource ? { abortSource: input.abortSource } : {}),
|
|
45
|
-
...(input.status === 'failed' ? { errorClass: input.errorClass ?? 'unknown' } : {}),
|
|
46
|
-
partialOutputRetained: input.partialOutputRetained,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function turnHasRetainedOutput(messages, turnId) {
|
|
50
|
-
return messages.some((message) => (message.type === 'assistant' &&
|
|
51
|
-
message.turnId === turnId &&
|
|
52
|
-
message.text.trim().length > 0) ||
|
|
53
|
-
(message.type === 'tool_result' && message.turnId === turnId));
|
|
54
|
-
}
|
|
55
28
|
export function normalizeStopSessionSource(source, workHubActionId) {
|
|
56
29
|
if (source !== 'workhub_direct_stop' && workHubActionId !== undefined) {
|
|
57
30
|
throw new Error('WorkHub direct-stop identity requires its dedicated Stop source');
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { dedupeModelCallAttempts, groupModelCallAttempts, } from '@maka/core/model-call-attempt';
|
|
20
20
|
import { TERMINAL_RUNTIME_EVENT_STATUSES } from '@maka/core/runtime-event';
|
|
21
|
-
import { SESSION_TRACE_SCHEMA_VERSION, traceTurnIdentityKey, } from '@maka/core/session-trace';
|
|
21
|
+
import { SESSION_TRACE_SCHEMA_VERSION, MODEL_ATTEMPT_SHAPE, traceTurnIdentityKey, } from '@maka/core/session-trace';
|
|
22
|
+
import { pickShape } from '@maka/core/record-schema';
|
|
22
23
|
export function projectSessionTrace(input) {
|
|
23
24
|
const events = input.runtimeEvents.filter((event) => !event.partial);
|
|
24
25
|
// An aborted attempt and its later settlement are appended under one
|
|
@@ -189,35 +190,7 @@ function projectModelCallSteps(attempts) {
|
|
|
189
190
|
return steps;
|
|
190
191
|
}
|
|
191
192
|
function toTraceAttempt(attempt) {
|
|
192
|
-
return
|
|
193
|
-
attemptId: attempt.attemptId,
|
|
194
|
-
attempt: attempt.attempt,
|
|
195
|
-
status: attempt.status,
|
|
196
|
-
startedAt: attempt.startedAt,
|
|
197
|
-
completedAt: attempt.completedAt,
|
|
198
|
-
latencyMs: attempt.latencyMs,
|
|
199
|
-
...(attempt.timeToFirstTokenMs !== undefined
|
|
200
|
-
? { timeToFirstTokenMs: attempt.timeToFirstTokenMs }
|
|
201
|
-
: {}),
|
|
202
|
-
...(attempt.finishReason !== undefined ? { finishReason: attempt.finishReason } : {}),
|
|
203
|
-
...(attempt.errorClass !== undefined ? { errorClass: attempt.errorClass } : {}),
|
|
204
|
-
...(attempt.httpStatus !== undefined ? { httpStatus: attempt.httpStatus } : {}),
|
|
205
|
-
...(attempt.providerCode !== undefined ? { providerCode: attempt.providerCode } : {}),
|
|
206
|
-
...(attempt.providerRequestId !== undefined
|
|
207
|
-
? { providerRequestId: attempt.providerRequestId }
|
|
208
|
-
: {}),
|
|
209
|
-
...(attempt.retryable !== undefined ? { retryable: attempt.retryable } : {}),
|
|
210
|
-
...(attempt.inputTokens !== undefined ? { inputTokens: attempt.inputTokens } : {}),
|
|
211
|
-
...(attempt.outputTokens !== undefined ? { outputTokens: attempt.outputTokens } : {}),
|
|
212
|
-
...(attempt.cacheReadInputTokens !== undefined
|
|
213
|
-
? { cacheReadInputTokens: attempt.cacheReadInputTokens }
|
|
214
|
-
: {}),
|
|
215
|
-
...(attempt.reasoningTokens !== undefined ? { reasoningTokens: attempt.reasoningTokens } : {}),
|
|
216
|
-
...(attempt.contextWindow !== undefined ? { contextWindow: attempt.contextWindow } : {}),
|
|
217
|
-
...(attempt.costUsd !== undefined ? { costUsd: attempt.costUsd } : {}),
|
|
218
|
-
costBasis: attempt.costBasis,
|
|
219
|
-
usageBasis: attempt.usageBasis,
|
|
220
|
-
};
|
|
193
|
+
return pickShape(attempt, MODEL_ATTEMPT_SHAPE);
|
|
221
194
|
}
|
|
222
195
|
/** Prefix the runtime gives a written history-compaction boundary. */
|
|
223
196
|
const HISTORY_COMPACT_EVENT_PREFIX = 'history-compact:';
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { redactSecrets } from '@maka/core/redaction';
|
|
20
19
|
import { GITHUB_COPILOT_API_VERSION, GITHUB_COPILOT_COMPAT_HEADERS, } from './subscription-credentials.js';
|
|
21
20
|
import { openAiCodexHeaders } from './subscription-auth.js';
|
|
22
21
|
export function buildSubscriptionModelFetch(input) {
|
|
@@ -327,7 +326,7 @@ function codexInstructionsFromBody(body) {
|
|
|
327
326
|
return 'You are Maka, a helpful AI assistant.';
|
|
328
327
|
}
|
|
329
328
|
function formatOpenAiCodexHttpError(statusCode, detail) {
|
|
330
|
-
const compact =
|
|
329
|
+
const compact = detail.replace(/\s+/g, ' ').trim().slice(0, 240);
|
|
331
330
|
return compact
|
|
332
331
|
? `Codex OAuth request failed: HTTP ${statusCode} ${compact}`
|
|
333
332
|
: `Codex OAuth request failed: HTTP ${statusCode}`;
|
|
@@ -337,7 +336,7 @@ function openAiCodexHttpError(response, detail, exhaustedEdgeRejection = false)
|
|
|
337
336
|
? 'openai_codex_edge_rejection'
|
|
338
337
|
: openAiCodexProviderCode(detail);
|
|
339
338
|
const rawRequestId = response.headers.get('x-request-id')?.trim();
|
|
340
|
-
const requestId = rawRequestId ?
|
|
339
|
+
const requestId = rawRequestId ? rawRequestId.slice(0, 256) : undefined;
|
|
341
340
|
return Object.assign(new Error(formatOpenAiCodexHttpError(response.status, detail)), {
|
|
342
341
|
name: exhaustedEdgeRejection ? 'OpenAiCodexEdgeRejectionError' : 'OpenAiCodexHttpError',
|
|
343
342
|
...(exhaustedEdgeRejection ? { code: 'openai_codex_edge_rejection' } : {}),
|
|
@@ -358,7 +357,7 @@ function openAiCodexProviderCode(detail) {
|
|
|
358
357
|
const value = error.code ?? error.type;
|
|
359
358
|
if (typeof value !== 'string' && typeof value !== 'number')
|
|
360
359
|
return undefined;
|
|
361
|
-
const normalized =
|
|
360
|
+
const normalized = String(value).trim().slice(0, 256);
|
|
362
361
|
return normalized || undefined;
|
|
363
362
|
}
|
|
364
363
|
catch {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
|
-
import { PROVIDER_REGISTRY, providerDefaultsOf, providerFallbackModelIds, connectionModelsEnumerateAccount, connectionEnabledModelIds, } from '@maka/core/llm-connections';
|
|
21
|
-
import {
|
|
20
|
+
import { PROVIDER_REGISTRY, effectiveBaseUrl, providerDefaultsOf, providerFallbackModelIds, connectionModelsEnumerateAccount, connectionEnabledModelIds, } from '@maka/core/llm-connections';
|
|
21
|
+
import { openResponsesUrl } from './provider-urls.js';
|
|
22
22
|
import { resolveModelRuntime } from './model-runtime.js';
|
|
23
23
|
import { fetchGitHubCopilotModels } from './model-fetcher.js';
|
|
24
24
|
import { CONNECTION_EFFECT_ERROR_BODY_MAX_BYTES, ConnectionEffectFetchError, fetchForConnectionEffect, } from './connection-effect-fetch.js';
|
|
@@ -105,7 +105,9 @@ async function testConnectionStrict(connection, apiKey, model, fetchFn, t0, time
|
|
|
105
105
|
if (!defaults) {
|
|
106
106
|
return { ok: false, errorMessage: `Unknown provider type "${connection.providerType}"` };
|
|
107
107
|
}
|
|
108
|
-
const sessionId = connection.providerType === 'opencode-go'
|
|
108
|
+
const sessionId = connection.providerType === 'opencode-go' || connection.providerType === 'opencode-free'
|
|
109
|
+
? randomUUID()
|
|
110
|
+
: undefined;
|
|
109
111
|
const auth = defaults.authKind;
|
|
110
112
|
const secret = auth === 'none' ? '' : apiKey;
|
|
111
113
|
const testModel = resolveConnectionTestModel(connection, model, providerFallbackModelIds(defaults));
|
|
@@ -147,15 +149,14 @@ async function testConnectionModel(connection, secret, testModel, fetchFn, t0, t
|
|
|
147
149
|
if (providerDefaultsOf(connection.providerType)?.runtimeAdapter.kind === 'unavailable') {
|
|
148
150
|
return retiredProviderTestResult(connection.providerType);
|
|
149
151
|
}
|
|
152
|
+
if (connection.providerType === 'github-copilot') {
|
|
153
|
+
return probeGitHubCopilot(effectiveBaseUrl(connection), secret, testModel, t0, fetchFn);
|
|
154
|
+
}
|
|
150
155
|
const { adapter, baseUrl, wire } = resolveModelRuntime(connection, testModel);
|
|
151
156
|
const requestHeaders = withOpenCodeSessionHeader(connection.providerType, sessionId);
|
|
152
157
|
switch (adapter.kind) {
|
|
153
158
|
case 'anthropic':
|
|
154
|
-
return await probeAnthropic(
|
|
155
|
-
case 'unavailable':
|
|
156
|
-
// Unreachable: the guard above returns first. The arm keeps the switch
|
|
157
|
-
// exhaustive so a newly retired provider cannot slip past it.
|
|
158
|
-
return retiredProviderTestResult(connection.providerType);
|
|
159
|
+
return await probeAnthropic(adapter, baseUrl, secret, testModel, t0, fetchFn, requestHeaders);
|
|
159
160
|
case 'openai':
|
|
160
161
|
return wire === 'openai-responses'
|
|
161
162
|
? await probeOpenAIResponses(baseUrl, secret, testModel, t0, fetchFn, requestHeaders)
|
|
@@ -166,8 +167,6 @@ async function testConnectionModel(connection, secret, testModel, fetchFn, t0, t
|
|
|
166
167
|
return wire === 'openai-responses'
|
|
167
168
|
? await probeOpenAIResponses(baseUrl, secret, testModel, t0, fetchFn, requestHeaders)
|
|
168
169
|
: await probeOpenAI(connection, baseUrl, secret, testModel, t0, fetchFn, timeoutMs, requestHeaders);
|
|
169
|
-
case 'github-copilot':
|
|
170
|
-
return await probeGitHubCopilot(baseUrl, secret, testModel, t0, fetchFn);
|
|
171
170
|
case 'google':
|
|
172
171
|
return await probeGoogle(baseUrl, secret, testModel, t0, adapter.normalizeBaseUrl !== false, fetchFn);
|
|
173
172
|
case 'cohere':
|
|
@@ -227,14 +226,17 @@ async function probeCohere(baseUrl, apiKey, model, t0, fetchFn) {
|
|
|
227
226
|
function retiredProviderTestResult(providerType) {
|
|
228
227
|
return { ok: false, errorMessage: `"${providerType}" is retired and can no longer be used.` };
|
|
229
228
|
}
|
|
230
|
-
async function probeAnthropic(
|
|
229
|
+
async function probeAnthropic(adapter, baseUrl, secret, model, t0, fetchFn, requestHeaders) {
|
|
231
230
|
const headers = {
|
|
232
231
|
...requestHeaders,
|
|
233
|
-
'
|
|
232
|
+
...(adapter.auth === 'bearer'
|
|
233
|
+
? { authorization: `Bearer ${secret}` }
|
|
234
|
+
: { 'x-api-key': secret }),
|
|
234
235
|
'anthropic-version': '2023-06-01',
|
|
235
236
|
'content-type': 'application/json',
|
|
236
237
|
};
|
|
237
|
-
const
|
|
238
|
+
const url = `${stripTrailing(baseUrl)}/messages`;
|
|
239
|
+
const r = await fetchForConnectionEffect(fetchFn, url, {
|
|
238
240
|
method: 'POST',
|
|
239
241
|
headers,
|
|
240
242
|
body: JSON.stringify({
|
|
@@ -311,9 +313,7 @@ function isOpenAIChatCompletion(value) {
|
|
|
311
313
|
}));
|
|
312
314
|
}
|
|
313
315
|
async function probeGoogle(baseUrl, apiKey, model, t0, normalizeBaseUrl, fetchFn) {
|
|
314
|
-
const url = normalizeBaseUrl
|
|
315
|
-
? googleApiUrl(baseUrl, `/models/${encodeURIComponent(model)}:generateContent`, apiKey)
|
|
316
|
-
: `${stripTrailing(baseUrl)}/models/${encodeURIComponent(model)}:generateContent`;
|
|
316
|
+
const url = `${stripTrailing(baseUrl)}/models/${encodeURIComponent(model)}:generateContent${normalizeBaseUrl ? `?key=${encodeURIComponent(apiKey)}` : ''}`;
|
|
317
317
|
const r = await fetchForConnectionEffect(fetchFn, url, {
|
|
318
318
|
method: 'POST',
|
|
319
319
|
headers: {
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
/** Frozen bytes for archive rewriteVersion 1. Do not inherit future UI/provider formatting changes. */
|
|
20
|
+
export function serializeToolResultProjectionV1(projection) {
|
|
21
|
+
switch (projection.kind) {
|
|
22
|
+
case 'text':
|
|
23
|
+
return JSON.stringify(projection.text);
|
|
24
|
+
case 'json':
|
|
25
|
+
return JSON.stringify(projection.value);
|
|
26
|
+
case 'execution_denied':
|
|
27
|
+
return JSON.stringify({ kind: 'text', text: projection.reason ?? '' });
|
|
28
|
+
case 'failure':
|
|
29
|
+
return JSON.stringify(projection.message);
|
|
30
|
+
case 'content':
|
|
31
|
+
return JSON.stringify(projection.parts.map((part) => part.kind === 'text'
|
|
32
|
+
? { type: 'text', text: part.text }
|
|
33
|
+
: {
|
|
34
|
+
type: 'text',
|
|
35
|
+
text: `[Artifact ${JSON.stringify(part.ref.kind === 'session_context' ? part.ref.refId : part.ref.relativePath)} (${part.mediaType}) is stored in this Session.]`,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -142,6 +142,7 @@ export class ToolRuntime {
|
|
|
142
142
|
this.turnId = input.turnId;
|
|
143
143
|
this.hostedInteraction = hosted;
|
|
144
144
|
this.readExecutionBoundary = input.readExecutionBoundary;
|
|
145
|
+
this.sandboxBoundaryDenied = input.inheritedSandboxBoundaryDenied === true;
|
|
145
146
|
}
|
|
146
147
|
async endTurn(reason = 'completed') {
|
|
147
148
|
const turnId = this.turnId;
|
|
@@ -165,6 +166,7 @@ export class ToolRuntime {
|
|
|
165
166
|
sessionId: this.input.sessionId,
|
|
166
167
|
requestId,
|
|
167
168
|
decision: 'deny',
|
|
169
|
+
closureReason: reason === 'aborted' ? 'turn_stopped' : 'turn_terminal',
|
|
168
170
|
});
|
|
169
171
|
}));
|
|
170
172
|
for (const result of results) {
|
|
@@ -490,17 +492,6 @@ export class ToolRuntime {
|
|
|
490
492
|
isError: true,
|
|
491
493
|
}, this.input.sessionId) ?? DURABLE_TOOL_RESULT_PROJECTION_FAILURE;
|
|
492
494
|
const durableOutcome = await durableAttempt?.commitOutcome(content, true, modelProjection);
|
|
493
|
-
const msg = {
|
|
494
|
-
type: 'tool_result',
|
|
495
|
-
id: this.input.newId(),
|
|
496
|
-
turnId,
|
|
497
|
-
ts: this.input.now(),
|
|
498
|
-
toolUseId,
|
|
499
|
-
isError: true,
|
|
500
|
-
content,
|
|
501
|
-
...activityIdentity,
|
|
502
|
-
};
|
|
503
|
-
await this.input.appendMessage(msg);
|
|
504
495
|
queue.push({
|
|
505
496
|
type: 'tool_result',
|
|
506
497
|
id: durableOutcome?.id ?? this.input.newId(),
|
|
@@ -667,30 +658,6 @@ export class ToolRuntime {
|
|
|
667
658
|
queue.push(event);
|
|
668
659
|
callEventPublished = true;
|
|
669
660
|
};
|
|
670
|
-
const callMsg = {
|
|
671
|
-
type: 'tool_call',
|
|
672
|
-
id: toolUseId,
|
|
673
|
-
turnId,
|
|
674
|
-
ts: now,
|
|
675
|
-
toolName: tool.name,
|
|
676
|
-
...activityIdentity,
|
|
677
|
-
...(tool.activityKind ? { activityKind: tool.activityKind } : {}),
|
|
678
|
-
...(tool.displayName ? { displayName: tool.displayName } : {}),
|
|
679
|
-
args: structuredClone(persistedArgs),
|
|
680
|
-
...(ctx.providerOptions !== undefined
|
|
681
|
-
? { providerOptions: structuredClone(ctx.providerOptions) }
|
|
682
|
-
: {}),
|
|
683
|
-
// Persist the same step id the tool_start event carries so the UI
|
|
684
|
-
// timeline and post-restart backfill can pair this call with its step.
|
|
685
|
-
...(stepId !== undefined ? { stepId } : {}),
|
|
686
|
-
};
|
|
687
|
-
let callMessageAppended = false;
|
|
688
|
-
const appendCallMessage = async () => {
|
|
689
|
-
if (callMessageAppended)
|
|
690
|
-
return;
|
|
691
|
-
await this.input.appendMessage(callMsg);
|
|
692
|
-
callMessageAppended = true;
|
|
693
|
-
};
|
|
694
661
|
const emitToolStartedTrace = () => {
|
|
695
662
|
trace?.emit('tool', 'tool_started', 'Tool execution started', {
|
|
696
663
|
toolUseId,
|
|
@@ -704,7 +671,6 @@ export class ToolRuntime {
|
|
|
704
671
|
* through here so the pair can never be split across lanes again.
|
|
705
672
|
*/
|
|
706
673
|
const refuseBeforeDispatch = async (text, sandboxFailure) => {
|
|
707
|
-
await appendCallMessage();
|
|
708
674
|
publishCallEvent(buildCallEvent('preflight'));
|
|
709
675
|
emitToolStartedTrace();
|
|
710
676
|
await this.writeSyntheticToolResult(toolUseId, turnId, tool.name, text, queue, undefined, sandboxFailure, undefined, activityIdentity);
|
|
@@ -976,7 +942,6 @@ export class ToolRuntime {
|
|
|
976
942
|
await disposeManagedMutationAdmission(managedMutationAdmission);
|
|
977
943
|
throw error;
|
|
978
944
|
}
|
|
979
|
-
await appendCallMessage();
|
|
980
945
|
publishCallEvent(buildCallEvent('dispatch'));
|
|
981
946
|
emitToolStartedTrace();
|
|
982
947
|
if (durableAttempt) {
|
|
@@ -1225,18 +1190,6 @@ export class ToolRuntime {
|
|
|
1225
1190
|
commandHash: denialKey,
|
|
1226
1191
|
});
|
|
1227
1192
|
}
|
|
1228
|
-
const resultMsg = {
|
|
1229
|
-
type: 'tool_result',
|
|
1230
|
-
id: this.input.newId(),
|
|
1231
|
-
turnId,
|
|
1232
|
-
ts: this.input.now(),
|
|
1233
|
-
toolUseId,
|
|
1234
|
-
isError: toolResultStatus !== 'success',
|
|
1235
|
-
content,
|
|
1236
|
-
durationMs,
|
|
1237
|
-
...activityIdentity,
|
|
1238
|
-
};
|
|
1239
|
-
await this.input.appendMessage(resultMsg);
|
|
1240
1193
|
queue.push({
|
|
1241
1194
|
type: 'tool_result',
|
|
1242
1195
|
id: durableOutcome?.id ?? this.input.newId(),
|
|
@@ -1345,18 +1298,6 @@ export class ToolRuntime {
|
|
|
1345
1298
|
const projected = this.projectToolResult(tool, turnId, toolUseId, executionArgs, terminalResult);
|
|
1346
1299
|
const modelProjection = isPromiseLike(projected) ? await projected : projected;
|
|
1347
1300
|
const durableOutcome = await durableAttempt?.commitOutcome(terminalFailure.content, true, modelProjection, durationMs);
|
|
1348
|
-
const resultMsg = {
|
|
1349
|
-
type: 'tool_result',
|
|
1350
|
-
id: this.input.newId(),
|
|
1351
|
-
turnId,
|
|
1352
|
-
ts: this.input.now(),
|
|
1353
|
-
toolUseId,
|
|
1354
|
-
isError: true,
|
|
1355
|
-
content: terminalFailure.content,
|
|
1356
|
-
durationMs,
|
|
1357
|
-
...activityIdentity,
|
|
1358
|
-
};
|
|
1359
|
-
await this.input.appendMessage(resultMsg);
|
|
1360
1301
|
queue.push({
|
|
1361
1302
|
type: 'tool_result',
|
|
1362
1303
|
id: durableOutcome?.id ?? this.input.newId(),
|
|
@@ -2134,6 +2075,7 @@ export class ToolRuntime {
|
|
|
2134
2075
|
sessionId: this.input.sessionId,
|
|
2135
2076
|
requestId,
|
|
2136
2077
|
decision: 'deny',
|
|
2078
|
+
closureReason: 'turn_stopped',
|
|
2137
2079
|
}).then(() => undefined));
|
|
2138
2080
|
}
|
|
2139
2081
|
};
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"./tool-availability": "./dist/tool-availability.js",
|
|
107
107
|
"./tool-free-model-call": "./dist/tool-free-model-call.js",
|
|
108
108
|
"./tool-result-archive": "./dist/tool-result-archive.js",
|
|
109
|
+
"./ledger-tool-result-archive-reader": "./dist/ledger-tool-result-archive-reader.js",
|
|
109
110
|
"./tool-result-archive-capability": "./dist/tool-result-archive-capability.js",
|
|
110
111
|
"./tool-result-archive-resource": "./dist/tool-result-archive-resource.js",
|
|
111
112
|
"./tool-runtime": "./dist/tool-runtime.js",
|
|
@@ -102,6 +102,11 @@ export class RuntimeHostSessionProjector {
|
|
|
102
102
|
}
|
|
103
103
|
if (isRuntimeHostTerminalTurn(root))
|
|
104
104
|
return events;
|
|
105
|
+
// Re-derive the running compaction row on reconnect / restart: the Host keeps
|
|
106
|
+
// the compaction Turn alive, so a reconnecting client learns of it here.
|
|
107
|
+
if (root.rootExecutionKind === 'context_compact') {
|
|
108
|
+
events.push(contextCompactionStartedEvent(root, this.#now()));
|
|
109
|
+
}
|
|
105
110
|
let seededAssistantText = false;
|
|
106
111
|
if (includeAssistantText) {
|
|
107
112
|
for (const accumulator of this.#accumulators.values()) {
|
|
@@ -362,6 +367,18 @@ export class RuntimeHostSessionProjector {
|
|
|
362
367
|
}
|
|
363
368
|
if (startedTurn)
|
|
364
369
|
this.#accumulators.clear();
|
|
370
|
+
// Emit the presentation-only compaction-started event when the root Turn
|
|
371
|
+
// FIRST becomes a `context_compact` run, not only when the runId changes.
|
|
372
|
+
// The real lifecycle is `admitted (no rootExecutionKind) → running/
|
|
373
|
+
// context_compact` at the SAME runId, so gating on startedTurn would miss
|
|
374
|
+
// the live transition and only surface the row on reconnect via seedActive.
|
|
375
|
+
const rootIsCompaction = !!root && !isRuntimeHostTerminalTurn(root) && root.rootExecutionKind === 'context_compact';
|
|
376
|
+
const previousWasCompaction = !!previousRoot &&
|
|
377
|
+
!isRuntimeHostTerminalTurn(previousRoot) &&
|
|
378
|
+
previousRoot.rootExecutionKind === 'context_compact';
|
|
379
|
+
if (root && rootIsCompaction && !previousWasCompaction) {
|
|
380
|
+
events.push(contextCompactionStartedEvent(root, this.#now()));
|
|
381
|
+
}
|
|
365
382
|
const retry = liveProviderRetryEvent(previousRoot, root, this.#now());
|
|
366
383
|
if (retry)
|
|
367
384
|
events.push(retry);
|
|
@@ -399,6 +416,10 @@ export class RuntimeHostSessionProjector {
|
|
|
399
416
|
turnId: root.turnId,
|
|
400
417
|
ts: this.#now(),
|
|
401
418
|
stopReason: 'end_turn',
|
|
419
|
+
// Forward the typed compaction outcome already carried by the canonical
|
|
420
|
+
// Turn snapshot so the renderer can settle the running toast and show the
|
|
421
|
+
// terminal state. This projects an existing snapshot field (no turn-state
|
|
422
|
+
// persistence), so checkpointId stays a string.
|
|
402
423
|
...(root.contextCompactionOutcome
|
|
403
424
|
? { contextCompactionOutcome: root.contextCompactionOutcome }
|
|
404
425
|
: {}),
|
|
@@ -456,6 +477,20 @@ function projectMessageRetractionEvents(previous, next, ts) {
|
|
|
456
477
|
outcome: 'retracted',
|
|
457
478
|
}));
|
|
458
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Presentation-only event that drives the renderer's live "compacting" row.
|
|
482
|
+
* Emitted on both the live transition (`accept`) and reconnect (`seedActive`)
|
|
483
|
+
* with a deterministic id keyed on the run, so a reconnect re-emits it
|
|
484
|
+
* idempotently.
|
|
485
|
+
*/
|
|
486
|
+
function contextCompactionStartedEvent(turn, now) {
|
|
487
|
+
return {
|
|
488
|
+
type: 'context_compaction_started',
|
|
489
|
+
id: `host-compaction-started:${turn.runId}`,
|
|
490
|
+
turnId: turn.turnId,
|
|
491
|
+
ts: now,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
459
494
|
export function projectRuntimeHostInteractionRequest(interaction, now) {
|
|
460
495
|
const base = {
|
|
461
496
|
id: `host-interaction:${interaction.interactionId}:${interaction.revision}`,
|
|
@@ -74,7 +74,10 @@ export async function runExecutionCandidateEntry(argv, entrypointUrl, hooks = {}
|
|
|
74
74
|
await launchOwnerGuard?.dispose();
|
|
75
75
|
process.exit(2);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
// A launcher that disappears without releasing this Host (Desktop quit,
|
|
78
|
+
// launcher crash) is an intentional retirement of an owned ephemeral Host,
|
|
79
|
+
// not a crash — closing with the retirement reason keeps the exit truthful.
|
|
80
|
+
launchOwnerGuard?.bind(() => result.host.close({ reason: 'retirement' }));
|
|
78
81
|
const stopWatch = hooks.onWon?.(result.host);
|
|
79
82
|
try {
|
|
80
83
|
await runRuntimeHostProcessLifecycle(result.host);
|
|
@@ -248,7 +248,15 @@ export async function connectOrSpawnRuntimeHostWithDependencies(input, dependenc
|
|
|
248
248
|
}
|
|
249
249
|
const managedLaunchRejection = runtimeHostManagedLaunchRejection(managedDeployment, managedLaunchClaim, 'on_demand');
|
|
250
250
|
if (managedLaunchRejection !== undefined) {
|
|
251
|
-
|
|
251
|
+
// A managed endpoint that accepted a connection but did not answer
|
|
252
|
+
// is temporarily unavailable, not evidence that the client needs a
|
|
253
|
+
// new operator. Keep reconnecting without ever launching a replacement.
|
|
254
|
+
return {
|
|
255
|
+
kind: 'failed',
|
|
256
|
+
reason: managedLaunchRejection === 'managed_root_requires_operator' && sawUnresponsiveEndpoint
|
|
257
|
+
? 'host_unresponsive'
|
|
258
|
+
: managedLaunchRejection,
|
|
259
|
+
};
|
|
252
260
|
}
|
|
253
261
|
try {
|
|
254
262
|
const remaining = deadline - performance.now();
|
|
@@ -79,6 +79,7 @@ export class RuntimeHostRequestInterruptedError extends Error {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
class RuntimeHostConnectionImpl {
|
|
82
|
+
cooperativeHandoff;
|
|
82
83
|
rootId;
|
|
83
84
|
hostEpoch;
|
|
84
85
|
connectionId;
|
|
@@ -122,6 +123,7 @@ class RuntimeHostConnectionImpl {
|
|
|
122
123
|
this.hostEpoch = accepted.hostEpoch;
|
|
123
124
|
this.connectionId = accepted.connectionId;
|
|
124
125
|
this.selectedProtocol = accepted.selectedProtocol;
|
|
126
|
+
this.cooperativeHandoff = accepted.cooperativeHandoff;
|
|
125
127
|
this.compositionId = accepted.compositionId;
|
|
126
128
|
this.compositionRevision = accepted.compositionRevision;
|
|
127
129
|
this.#getPeerPath = options?.getPeerPath ?? (() => options?.peerPath);
|
|
@@ -944,6 +946,7 @@ async function exchangeRuntimeHostHandshake(input) {
|
|
|
944
946
|
const helloProtocol = input.helloProtocol ?? input.protocol;
|
|
945
947
|
const hello = {
|
|
946
948
|
kind: 'hello',
|
|
949
|
+
activitySnapshotVersion: 2,
|
|
947
950
|
clientInstanceId: input.clientInstanceId,
|
|
948
951
|
surface: 'desktop',
|
|
949
952
|
protocolMin: helloProtocol.min,
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
/** Shared consequence-oriented copy, not a second lifecycle policy. */
|
|
20
|
+
export function formatHostHandoff(view, locale) {
|
|
21
|
+
const zh = locale !== 'en';
|
|
22
|
+
const tw = locale === 'zh-TW';
|
|
23
|
+
const titles = tw
|
|
24
|
+
? {
|
|
25
|
+
busy: '背景服務仍在使用中',
|
|
26
|
+
activity_unknown: '需要確認是否停止背景服務',
|
|
27
|
+
operator_required: '需要在服務所在位置處理',
|
|
28
|
+
repair_required: '背景服務需要修復',
|
|
29
|
+
retry_required: '暫時無法完成交接',
|
|
30
|
+
}
|
|
31
|
+
: zh
|
|
32
|
+
? {
|
|
33
|
+
busy: '后台服务仍在使用中',
|
|
34
|
+
activity_unknown: '需要确认是否停止后台服务',
|
|
35
|
+
operator_required: '需要在服务所在位置处理',
|
|
36
|
+
repair_required: '后台服务需要修复',
|
|
37
|
+
retry_required: '暂时无法完成交接',
|
|
38
|
+
}
|
|
39
|
+
: {
|
|
40
|
+
busy: 'Your background service is still in use',
|
|
41
|
+
activity_unknown: 'Confirm before stopping the service',
|
|
42
|
+
operator_required: 'Action is needed where the service runs',
|
|
43
|
+
repair_required: 'Your background service needs repair',
|
|
44
|
+
retry_required: 'The handoff could not finish yet',
|
|
45
|
+
};
|
|
46
|
+
const descriptions = tw
|
|
47
|
+
? {
|
|
48
|
+
busy: '其他連線或正在執行的工作阻止了自動交接。停止並繼續可能中斷這些工作。',
|
|
49
|
+
activity_unknown: '這個版本無法提供足夠的活動資訊。停止服務可能中斷其他視窗或裝置上的工作。',
|
|
50
|
+
operator_required: `目前的用戶端沒有替換此服務的權限。請在 ${view.target.name} 上,由管理該服務的使用者更新或停止服務。`,
|
|
51
|
+
repair_required: '上次啟動或交接未能完成。可以安全重試;若仍失敗,請複製診斷資訊。',
|
|
52
|
+
retry_required: '服務狀態發生了變化,或交接尚未完成。可以安全重試,不會預設中斷工作。',
|
|
53
|
+
}
|
|
54
|
+
: zh
|
|
55
|
+
? {
|
|
56
|
+
busy: '其它连接或正在执行的工作阻止了自动交接。停止并继续可能中断这些工作。',
|
|
57
|
+
activity_unknown: '这个版本无法提供足够的活动信息。停止服务可能中断其它窗口或设备上的工作。',
|
|
58
|
+
operator_required: `当前客户端没有替换此服务的权限。请在 ${view.target.name} 上,由管理该服务的用户更新或停止服务。`,
|
|
59
|
+
repair_required: '上次启动或交接未能完成。可以安全重试;若仍失败,请复制诊断信息。',
|
|
60
|
+
retry_required: '服务状态发生了变化,或交接尚未完成。可以安全重试,不会默认中断工作。',
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
busy: 'Other connections or work in progress prevent an automatic handoff. Stopping the service may interrupt that work.',
|
|
64
|
+
activity_unknown: 'This version cannot provide enough activity information. Stopping it may interrupt work in other windows or on other devices.',
|
|
65
|
+
operator_required: `This client cannot replace the service. Ask its operator to update or stop it on ${view.target.name}.`,
|
|
66
|
+
repair_required: 'The last startup or handoff did not finish. Retry safely, or copy diagnostics if it still fails.',
|
|
67
|
+
retry_required: 'The service changed or the handoff has not finished. A safe retry will not interrupt work by default.',
|
|
68
|
+
};
|
|
69
|
+
const activity = view.activity;
|
|
70
|
+
const facts = activity
|
|
71
|
+
? tw
|
|
72
|
+
? `${activity.connections} 個連線 · ${activity.activeOperations} 個進行中的操作`
|
|
73
|
+
: zh
|
|
74
|
+
? `${activity.connections} 个连接 · ${activity.activeOperations} 个进行中的操作`
|
|
75
|
+
: `${activity.connections} connections · ${activity.activeOperations} operations in progress`
|
|
76
|
+
: '';
|
|
77
|
+
const waiting = view.mayExitNaturally
|
|
78
|
+
? tw
|
|
79
|
+
? 'Maka 會持續檢查,並在可以安全繼續時自動繼續。'
|
|
80
|
+
: zh
|
|
81
|
+
? 'Maka 会持续检查,并在可以安全继续时自动继续。'
|
|
82
|
+
: 'Maka keeps checking and continues automatically when it is safe.'
|
|
83
|
+
: tw
|
|
84
|
+
? 'Maka 會持續檢查。常駐服務不會僅因等待而結束,可能需要你採取操作。'
|
|
85
|
+
: zh
|
|
86
|
+
? 'Maka 会持续检查。常驻服务不会仅因等待而退出,可能需要你采取操作。'
|
|
87
|
+
: 'Maka keeps checking. A persistent service will not exit just because you wait; action may be needed.';
|
|
88
|
+
const repairNotice = view.operation === 'repair'
|
|
89
|
+
? tw
|
|
90
|
+
? '修復將使用目前應用程式配套的版本,可能替換現有服務版本。'
|
|
91
|
+
: zh
|
|
92
|
+
? '修复将使用当前应用配套的版本,可能替换现有服务版本。'
|
|
93
|
+
: 'Repair uses the version supplied with this app and may replace the installed service version.'
|
|
94
|
+
: '';
|
|
95
|
+
const labels = tw
|
|
96
|
+
? {
|
|
97
|
+
cancel: '取消',
|
|
98
|
+
retry: '安全重試',
|
|
99
|
+
interrupt: view.operation === 'repair' ? '中斷並修復' : '停止並繼續',
|
|
100
|
+
}
|
|
101
|
+
: zh
|
|
102
|
+
? {
|
|
103
|
+
cancel: '取消',
|
|
104
|
+
retry: '安全重试',
|
|
105
|
+
interrupt: view.operation === 'repair' ? '中断并修复' : '停止并继续',
|
|
106
|
+
}
|
|
107
|
+
: {
|
|
108
|
+
cancel: 'Cancel',
|
|
109
|
+
retry: 'Retry safely',
|
|
110
|
+
interrupt: view.operation === 'repair' ? 'Interrupt and repair' : 'Stop and continue',
|
|
111
|
+
};
|
|
112
|
+
const phases = tw
|
|
113
|
+
? {
|
|
114
|
+
checking: '正在檢查服務',
|
|
115
|
+
staging: '正在準備更新',
|
|
116
|
+
pausing: '正在等待安全暫停點',
|
|
117
|
+
retiring: '正在停止舊服務',
|
|
118
|
+
replacing: '正在替換服務',
|
|
119
|
+
verifying: '正在確認工作區已就緒',
|
|
120
|
+
}
|
|
121
|
+
: zh
|
|
122
|
+
? {
|
|
123
|
+
checking: '正在检查服务',
|
|
124
|
+
staging: '正在准备更新',
|
|
125
|
+
pausing: '正在等待安全暂停点',
|
|
126
|
+
retiring: '正在停止旧服务',
|
|
127
|
+
replacing: '正在替换服务',
|
|
128
|
+
verifying: '正在确认工作区已就绪',
|
|
129
|
+
}
|
|
130
|
+
: {
|
|
131
|
+
checking: 'Checking the service',
|
|
132
|
+
staging: 'Preparing the update',
|
|
133
|
+
pausing: 'Waiting for a safe pause point',
|
|
134
|
+
retiring: 'Stopping the previous service',
|
|
135
|
+
replacing: 'Replacing the service',
|
|
136
|
+
verifying: 'Verifying your workspace is ready',
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
title: view.state === 'progress'
|
|
140
|
+
? tw
|
|
141
|
+
? '正在繼續開啟工作區'
|
|
142
|
+
: zh
|
|
143
|
+
? '正在继续打开工作区'
|
|
144
|
+
: 'Continuing to your workspace'
|
|
145
|
+
: titles[view.reason],
|
|
146
|
+
description: view.state === 'progress' ? phases[view.phase ?? 'checking'] : descriptions[view.reason],
|
|
147
|
+
detail: view.state === 'progress'
|
|
148
|
+
? tw
|
|
149
|
+
? '正在完成交接或安全收尾,請稍候。'
|
|
150
|
+
: zh
|
|
151
|
+
? '正在完成交接或安全收尾,请稍候。'
|
|
152
|
+
: 'Finishing the handoff or its safe recovery. Please wait.'
|
|
153
|
+
: [facts, waiting, repairNotice, view.operatorStep].filter(Boolean).join('\n'),
|
|
154
|
+
actions: view.actions.map((action) => ({ action, label: labels[action] })),
|
|
155
|
+
};
|
|
156
|
+
}
|