maka-agent 0.2.0-dev.14.20260902 → 0.2.0-dev.16.20260903

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.
Files changed (160) hide show
  1. package/dist/cli-core.js +0 -1
  2. package/dist/pi-transcript.js +48 -0
  3. package/dist/pi-tui-form-interaction.js +497 -0
  4. package/dist/pi-tui-pickers.js +256 -55
  5. package/dist/pi-tui-runner.js +215 -12
  6. package/dist/runtime-host-cli.js +17 -42
  7. package/dist/runtime-host-lifecycle-transaction.js +31 -13
  8. package/dist/runtime-host-managed-lifecycle-manager.js +1 -1
  9. package/dist/runtime-host-onboarding.js +3 -1
  10. package/dist/runtime-host-openrc-service.js +469 -0
  11. package/dist/runtime-host-run-command.js +6 -2
  12. package/dist/runtime-host-service-command.js +3 -3
  13. package/dist/runtime-host-service-management-command.js +43 -15
  14. package/dist/runtime-host-session-channel.js +3 -0
  15. package/dist/runtime-host-session-driver.js +21 -6
  16. package/dist/runtime-host-setup-command.js +30 -31
  17. package/dist/tui-context-refresh.js +103 -0
  18. package/dist/tui-copy-catalog.js +73 -0
  19. package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
  20. package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
  21. package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
  22. package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
  23. package/node_modules/@maka/core/dist/chat-model-choice.js +4 -0
  24. package/node_modules/@maka/core/dist/computer-use.js +27 -92
  25. package/node_modules/@maka/core/dist/interaction.js +577 -3
  26. package/node_modules/@maka/core/dist/llm-connections.js +4 -0
  27. package/node_modules/@maka/core/dist/local-memory.js +2 -2
  28. package/node_modules/@maka/core/dist/model-call-usage-projection.js +3 -0
  29. package/node_modules/@maka/core/dist/model-metadata.js +26 -7
  30. package/node_modules/@maka/core/dist/model-thinking.js +17 -0
  31. package/node_modules/@maka/core/dist/provider-registry.js +1 -0
  32. package/node_modules/@maka/core/dist/runtime-event.js +23 -1
  33. package/node_modules/@maka/core/dist/scheduled-task.js +4 -0
  34. package/node_modules/@maka/core/dist/session.js +95 -2
  35. package/node_modules/@maka/core/dist/text-sanitize.js +19 -0
  36. package/node_modules/@maka/core/dist/usage-ledger-merge.js +3 -0
  37. package/node_modules/@maka/core/dist/usage-record-schema.js +11 -5
  38. package/node_modules/@maka/core/dist/workhub-creation-intent.js +75 -9
  39. package/node_modules/@maka/core/dist/workhub-session-resolver.js +50 -0
  40. package/node_modules/@maka/core/package.json +2 -0
  41. package/node_modules/@maka/eval/dist/harbor-external-subject.js +2 -1
  42. package/node_modules/@maka/eval/dist/harness-executor.js +3 -2
  43. package/node_modules/@maka/eval/dist/install-preflight.js +39 -10
  44. package/node_modules/@maka/eval/dist/process-termination.js +83 -0
  45. package/node_modules/@maka/mcp/dist/sep-2243.js +3 -3
  46. package/node_modules/@maka/runtime/dist/agent-run.js +6 -3
  47. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +332 -118
  48. package/node_modules/@maka/runtime/dist/ai-sdk-compaction-contract.js +6 -1
  49. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +171 -341
  50. package/node_modules/@maka/runtime/dist/bots/telegram-bridge.js +3 -26
  51. package/node_modules/@maka/runtime/dist/bundled-skill-catalog.generated.js +1 -1
  52. package/node_modules/@maka/runtime/dist/computer-use-codec.js +1 -141
  53. package/node_modules/@maka/runtime/dist/computer-use-tools.js +23 -105
  54. package/node_modules/@maka/runtime/dist/context-budget-policy.js +20 -26
  55. package/node_modules/@maka/runtime/dist/context-budget.js +18 -20
  56. package/node_modules/@maka/runtime/dist/conversation-copy.js +23 -19
  57. package/node_modules/@maka/runtime/dist/cua-frame-state.js +1 -69
  58. package/node_modules/@maka/runtime/dist/github-copilot-oauth-enrollment.js +267 -0
  59. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +6 -9
  60. package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +67 -23
  61. package/node_modules/@maka/runtime/dist/history-compact-summary-validation.js +11 -18
  62. package/node_modules/@maka/runtime/dist/history-compaction.js +66 -73
  63. package/node_modules/@maka/runtime/dist/interaction-authority.js +69 -0
  64. package/node_modules/@maka/runtime/dist/mcp-tools.js +13 -1
  65. package/node_modules/@maka/runtime/dist/memory-extraction.js +11 -11
  66. package/node_modules/@maka/runtime/dist/model-adapter.js +24 -6
  67. package/node_modules/@maka/runtime/dist/model-factory.js +14 -5
  68. package/node_modules/@maka/runtime/dist/oauth-provider-contracts.js +28 -1
  69. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +7 -6
  70. package/node_modules/@maka/runtime/dist/opencode-session-header.js +29 -0
  71. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +11 -1
  72. package/node_modules/@maka/runtime/dist/runtime-kernel.js +12 -11
  73. package/node_modules/@maka/runtime/dist/runtime-read-model.js +51 -13
  74. package/node_modules/@maka/runtime/dist/scheduled-task-tools.js +3 -0
  75. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +26 -0
  76. package/node_modules/@maka/runtime/dist/session-manager.js +1 -0
  77. package/node_modules/@maka/runtime/dist/session-projection-helpers.js +16 -1
  78. package/node_modules/@maka/runtime/dist/stream-graph-projection.js +6 -0
  79. package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +5 -0
  80. package/node_modules/@maka/runtime/dist/stream-usage-fallback-fetch.js +74 -0
  81. package/node_modules/@maka/runtime/dist/subscription-credentials.js +51 -4
  82. package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +47 -3
  83. package/node_modules/@maka/runtime/dist/system-prompt/main-session-prompt.js +20 -1
  84. package/node_modules/@maka/runtime/dist/test-connection.js +18 -11
  85. package/node_modules/@maka/runtime/dist/tool-runtime.js +183 -0
  86. package/node_modules/@maka/runtime/package.json +1 -0
  87. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +14 -0
  88. package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +84 -1
  89. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +68 -51
  90. package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
  91. package/node_modules/@maka/runtime-host/dist/client/owner-connection-code.js +8 -5
  92. package/node_modules/@maka/runtime-host/dist/client/peer-client.js +342 -36
  93. package/node_modules/@maka/runtime-host/dist/client/reconnect-lifecycle.js +60 -4
  94. package/node_modules/@maka/runtime-host/dist/peer-mesh/index.js +3 -3
  95. package/node_modules/@maka/runtime-host/dist/peer-mesh/limits.js +1 -1
  96. package/node_modules/@maka/runtime-host/dist/peer-mesh/model.js +48 -60
  97. package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +847 -431
  98. package/node_modules/@maka/runtime-host/dist/peer-mesh/owner.js +33 -74
  99. package/node_modules/@maka/runtime-host/dist/peer-mesh/store.js +82 -69
  100. package/node_modules/@maka/runtime-host/dist/peer-reachability/index.js +21 -0
  101. package/node_modules/@maka/runtime-host/dist/peer-reachability/model.js +202 -0
  102. package/node_modules/@maka/runtime-host/dist/peer-reachability/owner.js +119 -0
  103. package/node_modules/@maka/runtime-host/dist/peer-reachability/publisher.js +245 -0
  104. package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +4 -1
  105. package/node_modules/@maka/runtime-host/dist/protocol/client-capability.js +68 -0
  106. package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +15 -8
  107. package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +7 -23
  108. package/node_modules/@maka/runtime-host/dist/protocol/index.js +47 -1
  109. package/node_modules/@maka/runtime-host/dist/protocol/oauth.js +25 -1
  110. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
  111. package/node_modules/@maka/runtime-host/dist/protocol/peer-mesh.js +14 -31
  112. package/node_modules/@maka/runtime-host/dist/protocol/scheduled-task.js +19 -6
  113. package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +36 -1
  114. package/node_modules/@maka/runtime-host/dist/protocol/session-revision.js +11 -2
  115. package/node_modules/@maka/runtime-host/dist/protocol/usage-pricing.js +16 -2
  116. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +51 -2
  117. package/node_modules/@maka/runtime-host/dist/server/access-authority.js +35 -2
  118. package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +1 -0
  119. package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +12 -10
  120. package/node_modules/@maka/runtime-host/dist/server/client-capability-invocation-broker.js +163 -30
  121. package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +38 -14
  122. package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +45 -22
  123. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +78 -20
  124. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +4 -2
  125. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +2 -1
  126. package/node_modules/@maka/runtime-host/dist/server/execution-service.js +49 -28
  127. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +3 -6
  128. package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +130 -27
  129. package/node_modules/@maka/runtime-host/dist/server/interaction-projection.js +30 -1
  130. package/node_modules/@maka/runtime-host/dist/server/listener-set.js +2 -4
  131. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +16 -3
  132. package/node_modules/@maka/runtime-host/dist/server/oauth-coordinator.js +66 -3
  133. package/node_modules/@maka/runtime-host/dist/server/oauth-execution-authority.js +20 -3
  134. package/node_modules/@maka/runtime-host/dist/server/peer-listener.js +8 -21
  135. package/node_modules/@maka/runtime-host/dist/server/peer-mesh-authority.js +1 -1
  136. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +6 -3
  137. package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +72 -12
  138. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +48 -18
  139. package/node_modules/@maka/runtime-host/dist/server/session-turn-access-request-coordinator.js +43 -26
  140. package/node_modules/@maka/runtime-host/dist/server/usage-pricing-coordinator.js +15 -1
  141. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +229 -4
  142. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +146 -8
  143. package/node_modules/@maka/runtime-host/dist/transport/peer-native.js +32 -6
  144. package/node_modules/@maka/runtime-host/package.json +1 -0
  145. package/node_modules/@maka/storage/dist/agent-run-store.js +18 -5
  146. package/node_modules/@maka/storage/dist/codex-session-adapter.js +14 -0
  147. package/node_modules/@maka/storage/dist/execution-stores.js +5 -0
  148. package/node_modules/@maka/storage/dist/interaction-store.js +13 -1
  149. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +9 -3
  150. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +49 -19
  151. package/node_modules/@maka/storage/dist/runtime-policy/oauth-login-receipt-document.js +3 -1
  152. package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +13 -5
  153. package/node_modules/@maka/storage/dist/session-copy-cleanup.js +4 -2
  154. package/node_modules/@maka/storage/dist/session-store.js +39 -6
  155. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +16 -9
  156. package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +30 -3
  157. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +117 -0
  158. package/node_modules/@maka/storage/dist/sqlite-usage-store.js +29 -6
  159. package/node_modules/@maka/storage/dist/usage-stores.js +3 -1
  160. package/package.json +1 -1
@@ -117,15 +117,7 @@ export async function runRuntimeHostSetupCli(options, overrides = {}) {
117
117
  }
118
118
  }
119
119
  async function resolveRuntimeHostSetupRootId(options) {
120
- let legacyRootPath;
121
- try {
122
- legacyRootPath = (await readRuntimeHostManagedServiceConfig(resolveRuntimeHostManagedServiceConfigPath(options.clientDataRoot))).rootPath;
123
- }
124
- catch (error) {
125
- if (!(error instanceof RuntimeHostServiceManagerError) || error.code !== 'not_installed') {
126
- throw error;
127
- }
128
- }
120
+ const legacyRootPath = (await readOptionalLegacyServiceConfig(options.clientDataRoot))?.rootPath;
129
121
  const path = resolve(options.rootPath ??
130
122
  legacyRootPath ??
131
123
  options.expectedTarget?.rootPath ??
@@ -135,6 +127,17 @@ async function resolveRuntimeHostSetupRootId(options) {
135
127
  }
136
128
  return (await resolveStorageRoot({ path, kind: 'interactive' })).rootId;
137
129
  }
130
+ async function readOptionalLegacyServiceConfig(clientDataRoot) {
131
+ try {
132
+ return await readRuntimeHostManagedServiceConfig(resolveRuntimeHostManagedServiceConfigPath(clientDataRoot));
133
+ }
134
+ catch (error) {
135
+ if (error instanceof RuntimeHostServiceManagerError && error.code === 'not_installed') {
136
+ return null;
137
+ }
138
+ throw error;
139
+ }
140
+ }
138
141
  async function runRuntimeHostSetupLocked(options, deps, emit) {
139
142
  if (options.lifecycle === 'on_demand') {
140
143
  await runRuntimeHostOnDemandSetupLocked(options, deps, emit);
@@ -146,7 +149,10 @@ async function runRuntimeHostSetupLocked(options, deps, emit) {
146
149
  async function runRuntimeHostSupervisedSetupLocked(options, deps, emit) {
147
150
  emit({ kind: 'progress', phase: 'checking_environment' });
148
151
  const legacyServiceId = resolveRuntimeHostManagedServiceId(options.clientDataRoot);
149
- const legacyBackend = deps.createBackend(legacyServiceId, options.clientDataRoot);
152
+ const legacyConfig = await readOptionalLegacyServiceConfig(options.clientDataRoot);
153
+ const legacyBackend = legacyConfig
154
+ ? deps.createBackend(legacyServiceId, options.clientDataRoot)
155
+ : undefined;
150
156
  const legacyCommon = {
151
157
  clientDataRoot: options.clientDataRoot,
152
158
  defaultRootPath: options.defaultRootPath,
@@ -156,8 +162,9 @@ async function runRuntimeHostSupervisedSetupLocked(options, deps, emit) {
156
162
  ? { expectedTarget: legacyManagedTarget(options.expectedTarget, legacyServiceId) }
157
163
  : {}),
158
164
  };
159
- const legacyStatus = await deps.manageService({ ...legacyCommon, action: 'status' }, legacyBackend);
160
- const legacyConfig = legacyStatus.service.config;
165
+ const legacyStatus = legacyBackend
166
+ ? await deps.manageService({ ...legacyCommon, action: 'status' }, legacyBackend)
167
+ : undefined;
161
168
  const capability = await resolveStorageRoot({
162
169
  path: resolve(options.rootPath ??
163
170
  legacyConfig?.rootPath ??
@@ -170,13 +177,13 @@ async function runRuntimeHostSupervisedSetupLocked(options, deps, emit) {
170
177
  convergeOperator: (currentConfig, desiredConfig) => deps.convergeOperator(currentConfig, desiredConfig),
171
178
  verifyOperator: deps.verifyOperator,
172
179
  resolveProvider: (provider) => deps.resolveLifecycleProvider(capability.rootId, provider),
173
- ...(legacyConfig
180
+ ...(legacyConfig && legacyBackend
174
181
  ? legacyMigrationDeps(legacyConfig, legacyBackend, legacyServiceId, options.clientDataRoot)
175
182
  : {}),
176
183
  };
177
184
  const recovered = await resolveRecoverableRuntimeHostManagedDeployment(capability.rootId, lifecycleDeps, {
178
- ...(legacyConfig ? { retirementSupervisor: legacyBackend } : {}),
179
- ...(legacyConfig
185
+ ...(legacyBackend ? { retirementSupervisor: legacyBackend } : {}),
186
+ ...(legacyBackend
180
187
  ? {
181
188
  activatePrevious: () => deps
182
189
  .manageService({ ...legacyCommon, action: 'start' }, legacyBackend)
@@ -188,10 +195,11 @@ async function runRuntimeHostSupervisedSetupLocked(options, deps, emit) {
188
195
  const current = recovered.kind === 'active' ? recovered.config : undefined;
189
196
  assertExpectedDeploymentGeneration(options.expectedTarget, current);
190
197
  const legacyToMigrate = current ? null : legacyConfig;
191
- if (current && legacyConfig)
198
+ if (current && legacyBackend)
192
199
  await assertLegacyArtifactsAbsent(legacyBackend);
193
- if (legacyToMigrate)
200
+ if (legacyToMigrate && legacyStatus) {
194
201
  await assertCompatibleExistingVersion(legacyStatus, options.version);
202
+ }
195
203
  if (current && current.launch.package.version !== options.version && !options.updateExisting) {
196
204
  throw new RuntimeHostSetupError('version_change_requires_update', `Runtime Host ${current.launch.package.version} is already installed; changing to ${options.version} requires the update workflow`);
197
205
  }
@@ -227,7 +235,7 @@ async function runRuntimeHostSupervisedSetupLocked(options, deps, emit) {
227
235
  throw new RuntimeHostSetupError('configuration_changed', 'Change an existing supervised Runtime Host through its explicit configure or update workflow');
228
236
  }
229
237
  emit({ kind: 'progress', phase: 'installing_service' });
230
- if (legacyToMigrate) {
238
+ if (legacyToMigrate && legacyBackend) {
231
239
  await legacyBackend.verifyDeployment(legacyToMigrate, {
232
240
  acceptLegacyConfigLaunch: true,
233
241
  });
@@ -244,8 +252,8 @@ async function runRuntimeHostSupervisedSetupLocked(options, deps, emit) {
244
252
  : 'install',
245
253
  ...(current ? { current } : {}),
246
254
  desired,
247
- ...(legacyToMigrate ? { retirementSupervisor: legacyBackend } : {}),
248
- ...(legacyToMigrate
255
+ ...(legacyToMigrate && legacyBackend ? { retirementSupervisor: legacyBackend } : {}),
256
+ ...(legacyToMigrate && legacyBackend
249
257
  ? {
250
258
  activatePrevious: () => deps
251
259
  .manageService({ ...legacyCommon, action: 'start' }, legacyBackend)
@@ -397,16 +405,7 @@ async function runRuntimeHostOnDemandSetupLocked(options, deps, emit) {
397
405
  }
398
406
  emit({ kind: 'progress', phase: 'checking_environment' });
399
407
  const legacyServiceId = resolveRuntimeHostManagedServiceId(options.clientDataRoot);
400
- const legacyConfigPath = resolveRuntimeHostManagedServiceConfigPath(options.clientDataRoot);
401
- let legacyConfig = null;
402
- try {
403
- legacyConfig = await readRuntimeHostManagedServiceConfig(legacyConfigPath);
404
- }
405
- catch (error) {
406
- if (!(error instanceof RuntimeHostServiceManagerError) || error.code !== 'not_installed') {
407
- throw error;
408
- }
409
- }
408
+ const legacyConfig = await readOptionalLegacyServiceConfig(options.clientDataRoot);
410
409
  const legacyBackend = legacyConfig
411
410
  ? deps.createBackend(legacyServiceId, options.clientDataRoot)
412
411
  : undefined;
@@ -589,7 +588,7 @@ async function runRuntimeHostOnDemandSetupLocked(options, deps, emit) {
589
588
  throw new RuntimeHostSetupError('deployment_failed', 'Setup did not install an operator');
590
589
  activation = await deps.activateManaged({ rootId: capability.rootId });
591
590
  if (legacyConfig) {
592
- await removeRuntimeHostServiceFile(legacyConfigPath, 'legacy service config');
591
+ await removeRuntimeHostServiceFile(resolveRuntimeHostManagedServiceConfigPath(options.clientDataRoot), 'legacy service config');
593
592
  if (legacyConfig.managedDeploymentRoot &&
594
593
  resolve(legacyConfig.managedDeploymentRoot) !== resolve(config.deploymentRoot)) {
595
594
  await removeRuntimeHostManagedDeployment(legacyConfig.managedDeploymentRoot, legacyServiceId);
@@ -0,0 +1,103 @@
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
+ /**
20
+ * How full the context is right now, re-asked mid-turn (#4545).
21
+ *
22
+ * The statusline ctx segment historically moved once per turn, when the
23
+ * end-of-turn `token_usage` event landed — a long agentic turn burned context
24
+ * for minutes with the indicator frozen at the previous turn's value. The Host
25
+ * already commits a latest-context snapshot at every settled provider request
26
+ * (the desktop inspector's data source), so the TUI pulls it on the same
27
+ * signal desktop uses instead of growing a parallel push event.
28
+ */
29
+ /**
30
+ * When a live session's context snapshot is worth re-reading. Mirrors the
31
+ * desktop inspector's TRACE_RELEVANT_EVENT_TYPES
32
+ * (apps/desktop/src/renderer/session-trace-refresh.ts): the snapshot is
33
+ * committed at each settled provider request, so the events that follow one —
34
+ * tool boundaries above all — are the moments the answer can have changed.
35
+ * That is deliberately not "every event": a streaming turn emits text deltas
36
+ * continuously, and none of them moves the snapshot.
37
+ */
38
+ const CTX_REFRESH_EVENT_TYPES = new Set([
39
+ 'tool_start',
40
+ 'tool_result',
41
+ 'token_usage',
42
+ 'provider_retry',
43
+ 'error',
44
+ 'complete',
45
+ 'abort',
46
+ ]);
47
+ export function isCtxRefreshRelevantEvent(event) {
48
+ return CTX_REFRESH_EVENT_TYPES.has(event.type);
49
+ }
50
+ /**
51
+ * Long enough to absorb a step boundary's event burst, short enough to feel
52
+ * live. Same value and rationale as the desktop inspector's
53
+ * TRACE_REFRESH_DEBOUNCE_MS.
54
+ */
55
+ export const CTX_REFRESH_DEBOUNCE_MS = 400;
56
+ /**
57
+ * Coalesces a burst of refresh-worthy events into one query, and lets only
58
+ * the latest issued query apply. A query that resolves after a newer one was
59
+ * issued — or after `cancel` retired it — is dropped: the answer a slow read
60
+ * brings back describes an older snapshot than the one already shown, and a
61
+ * torn-down session is not owed an update at all. A failed query leaves the
62
+ * last value standing: it is still the newest answer anyone has.
63
+ *
64
+ * The scheduler is injected so the policy is testable without a wall clock,
65
+ * and follows the CLI's ticker convention: schedule returns the cancel.
66
+ */
67
+ export function createCtxRefresher(input) {
68
+ let cancelScheduled;
69
+ let revision = 0;
70
+ const dropScheduled = () => {
71
+ cancelScheduled?.();
72
+ cancelScheduled = undefined;
73
+ };
74
+ const run = () => {
75
+ cancelScheduled = undefined;
76
+ const requestRevision = ++revision;
77
+ void input.query().then((result) => {
78
+ if (requestRevision !== revision)
79
+ return;
80
+ input.apply(result);
81
+ }, () => { });
82
+ };
83
+ return {
84
+ observe(event) {
85
+ if (!isCtxRefreshRelevantEvent(event))
86
+ return;
87
+ // Restart rather than stack: the last event of a burst is the one whose
88
+ // snapshot the reader wants, and an earlier timer would read before it.
89
+ dropScheduled();
90
+ cancelScheduled = input.schedule(run, input.delayMs);
91
+ },
92
+ cancel() {
93
+ dropScheduled();
94
+ revision += 1;
95
+ },
96
+ };
97
+ }
98
+ /** Default one-shot timer; unref'd so a pending refresh never holds the CLI open. */
99
+ export function scheduleCtxRefreshTimeout(callback, delayMs) {
100
+ const handle = setTimeout(callback, delayMs);
101
+ handle.unref();
102
+ return () => clearTimeout(handle);
103
+ }
@@ -237,6 +237,60 @@ export const TUI_COPY_RESOURCES = {
237
237
  },
238
238
  },
239
239
  },
240
+ 'form-interaction': {
241
+ en: {
242
+ requestedBy: 'Requested by {detail}',
243
+ sensitiveWarning: 'Do not enter passwords, API keys, access tokens, or payment details.',
244
+ required: 'required',
245
+ optional: 'optional',
246
+ omitted: 'omitted',
247
+ empty: 'empty',
248
+ invalid: "Value does not meet this field's constraints",
249
+ minimumLength: 'At least {minimum} characters',
250
+ maximumLength: 'At most {maximum} characters',
251
+ lengthRange: '{minimum}–{maximum} characters',
252
+ minimumValue: 'Minimum {minimum}',
253
+ maximumValue: 'Maximum {maximum}',
254
+ valueRange: 'Range {minimum}–{maximum}',
255
+ minimumItems: 'Select at least {minimum}',
256
+ maximumItems: 'Select at most {maximum}',
257
+ itemRange: 'Select {minimum}–{maximum}',
258
+ format: 'Format: {format}',
259
+ reviewHint: '↑↓ field · Enter edit · Space include/omit · s submit · d decline · Esc cancel',
260
+ textHint: 'Type a value · Enter review · Esc review',
261
+ choiceHint: '↑↓ select · Enter review · Esc review',
262
+ multiHint: '↑↓ move · Space toggle · Enter review · Esc review',
263
+ trueValue: 'true',
264
+ falseValue: 'false',
265
+ selectedCount: '{count} selected',
266
+ },
267
+ zh: {
268
+ requestedBy: '由 {detail} 请求',
269
+ sensitiveWarning: '请勿输入密码、API 密钥、访问令牌或支付信息。',
270
+ required: '必填',
271
+ optional: '选填',
272
+ omitted: '未提供',
273
+ empty: '空',
274
+ invalid: '该值不符合字段约束',
275
+ minimumLength: '至少 {minimum} 个字符',
276
+ maximumLength: '最多 {maximum} 个字符',
277
+ lengthRange: '长度 {minimum}–{maximum} 个字符',
278
+ minimumValue: '最小值 {minimum}',
279
+ maximumValue: '最大值 {maximum}',
280
+ valueRange: '范围 {minimum}–{maximum}',
281
+ minimumItems: '至少选择 {minimum} 项',
282
+ maximumItems: '最多选择 {maximum} 项',
283
+ itemRange: '选择 {minimum}–{maximum} 项',
284
+ format: '格式:{format}',
285
+ reviewHint: '↑↓ 选择字段 · Enter 编辑 · Space 提供/省略 · s 提交 · d 拒绝 · Esc 取消',
286
+ textHint: '输入值 · Enter 返回检查 · Esc 返回检查',
287
+ choiceHint: '↑↓ 选择 · Enter 返回检查 · Esc 返回检查',
288
+ multiHint: '↑↓ 移动 · Space 切换 · Enter 返回检查 · Esc 返回检查',
289
+ trueValue: '是',
290
+ falseValue: '否',
291
+ selectedCount: '已选择 {count} 项',
292
+ },
293
+ },
240
294
  pickers: {
241
295
  en: {
242
296
  modelPickerTitle: 'Select Model',
@@ -263,6 +317,11 @@ export const TUI_COPY_RESOURCES = {
263
317
  setupTitle: 'Set Up Provider',
264
318
  baseUrlLabel: 'Base URL',
265
319
  apiKeyLabel: 'API key',
320
+ connectionNameLabel: 'Name',
321
+ connectionSlugLabel: 'Slug',
322
+ identityHint: 'Name this connection, or keep the defaults to auto-assign · Enter continues · Esc returns',
323
+ identitySlugInvalid: 'Slug must be 2–64 characters: lowercase letters, digits, and hyphens',
324
+ identityNameTooLong: 'Name must be 256 characters or fewer',
266
325
  onboardingUnavailable: 'Onboarding is unavailable: this environment does not provide a setup surface.',
267
326
  onboardingRequestFailed: 'Could not reach the Runtime Host. Try again.',
268
327
  onboardingRejections: {
@@ -272,6 +331,7 @@ export const TUI_COPY_RESOURCES = {
272
331
  base_url_not_configured: 'A Base URL is required for this provider.',
273
332
  catalog_full: 'The connection catalog is full.',
274
333
  model_unavailable: 'A selected model is no longer available. Verify and select again.',
334
+ slug_taken: 'That slug is already taken. Pick another, or clear it to auto-assign.',
275
335
  superseded: 'This connection changed. Reopen /setup and try again.',
276
336
  },
277
337
  onboardingFailures: {
@@ -301,10 +361,14 @@ export const TUI_COPY_RESOURCES = {
301
361
  reuse: {
302
362
  baseUrl: 'Leave blank to reuse the saved key, or enter a new key to rotate it · Esc returns to Base URL',
303
363
  provider: 'Leave blank to reuse the saved key, or enter a new key to rotate it · Esc returns to provider selection',
364
+ // The identity step only exists for create targets, so a `reuse`
365
+ // hint never lands here; the provider text keeps the record total.
366
+ identity: 'Leave blank to reuse the saved key, or enter a new key to rotate it · Esc returns to provider selection',
304
367
  },
305
368
  enter: {
306
369
  baseUrl: 'Enter an API key · stored only on this machine · Esc returns to Base URL',
307
370
  provider: 'Enter an API key · stored only on this machine · Esc returns to provider selection',
371
+ identity: 'Enter an API key · stored only on this machine · Esc returns to connection naming',
308
372
  },
309
373
  },
310
374
  submitAction: 'Enter to submit',
@@ -343,6 +407,11 @@ export const TUI_COPY_RESOURCES = {
343
407
  setupTitle: '配置模型提供商',
344
408
  baseUrlLabel: 'Base URL',
345
409
  apiKeyLabel: 'API key',
410
+ connectionNameLabel: '名称',
411
+ connectionSlugLabel: '标识(slug)',
412
+ identityHint: '为该连接起名,或保留默认值自动分配 · Enter 继续 · Esc 返回',
413
+ identitySlugInvalid: '标识需为 2–64 位小写字母、数字或连字符',
414
+ identityNameTooLong: '名称不能超过 256 个字符',
346
415
  onboardingUnavailable: 'Onboarding 不可用:当前运行环境未提供配置入口。',
347
416
  onboardingRequestFailed: '无法连接 Runtime Host,请重试。',
348
417
  onboardingRejections: {
@@ -352,6 +421,7 @@ export const TUI_COPY_RESOURCES = {
352
421
  base_url_not_configured: '该服务商需要填写 Base URL。',
353
422
  catalog_full: '连接目录已满。',
354
423
  model_unavailable: '所选模型已不可用,请重新验证并选择。',
424
+ slug_taken: '该标识已被占用。请更换,或清空后自动分配。',
355
425
  superseded: '该连接已发生变化,请重新打开 /setup 后重试。',
356
426
  },
357
427
  onboardingFailures: {
@@ -381,10 +451,13 @@ export const TUI_COPY_RESOURCES = {
381
451
  reuse: {
382
452
  baseUrl: '留空复用已保存的 key,或输入新 key 轮换 · Esc 返回 Base URL',
383
453
  provider: '留空复用已保存的 key,或输入新 key 轮换 · Esc 返回选择服务商',
454
+ // identity 步骤只存在于新建流程,reuse 不会落到这里;沿用 provider 文案保持记录完整。
455
+ identity: '留空复用已保存的 key,或输入新 key 轮换 · Esc 返回选择服务商',
384
456
  },
385
457
  enter: {
386
458
  baseUrl: '输入 API key · 仅本机存储 · Esc 返回 Base URL',
387
459
  provider: '输入 API key · 仅本机存储 · Esc 返回选择服务商',
460
+ identity: '输入 API key · 仅本机存储 · Esc 返回命名连接',
388
461
  },
389
462
  },
390
463
  submitAction: 'Enter 提交',
@@ -16,6 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { declaredContextWindow } from './model-thinking.js';
19
20
  import { offerableCatalogEntries, providerDefaultsOf, providerMenuLabel, } from './llm-connections.js';
20
21
  export function buildChatModelChoices(connections) {
21
22
  const choices = [];
@@ -24,6 +25,7 @@ export function buildChatModelChoices(connections) {
24
25
  if (!provider)
25
26
  continue;
26
27
  for (const entry of offerableCatalogEntries(connection)) {
28
+ const declaredWindow = declaredContextWindow(connection, entry.id);
27
29
  choices.push({
28
30
  connectionId: connection.connectionId,
29
31
  connectionSlug: connection.slug,
@@ -37,6 +39,8 @@ export function buildChatModelChoices(connections) {
37
39
  isDefault: entry.isDefault,
38
40
  thinkingLevels: entry.thinkingLevels,
39
41
  supportsVision: entry.supportsVision,
42
+ ...(entry.contextWindow !== undefined ? { contextWindow: entry.contextWindow } : {}),
43
+ ...(declaredWindow !== undefined ? { declaredContextWindow: declaredWindow } : {}),
40
44
  });
41
45
  }
42
46
  }
@@ -80,26 +80,7 @@ export const COMPUTER_USE_ERROR_CODES = [
80
80
  export function isComputerUseErrorCode(value) {
81
81
  return (typeof value === 'string' && COMPUTER_USE_ERROR_CODES.includes(value));
82
82
  }
83
- export const CU_SCROLL_DIRECTIONS = ['up', 'down', 'left', 'right'];
84
- export const CU_ACTION_TYPES = [
85
- 'screenshot',
86
- 'cursor_position',
87
- 'mouse_move',
88
- 'left_click',
89
- 'right_click',
90
- 'middle_click',
91
- 'double_click',
92
- 'triple_click',
93
- 'left_mouse_down',
94
- 'left_mouse_up',
95
- 'left_click_drag',
96
- 'type',
97
- 'key',
98
- 'hold_key',
99
- 'scroll',
100
- 'wait',
101
- 'zoom',
102
- ];
83
+ export const CU_ACTION_TYPES = ['screenshot', 'type', 'key', 'wait'];
103
84
  export const COMPUTER_USE_ACTION_TYPES = CU_ACTION_TYPES;
104
85
  /**
105
86
  * The semantic actions, which name an element rather than a pixel. They are not
@@ -120,9 +101,7 @@ export const CU_SEMANTIC_ACTION_TYPES = [
120
101
  'press_key',
121
102
  ];
122
103
  /**
123
- * Every action name the tool schema spells out itself, as it spells them —
124
- * that is, every name that is not one of the `CU_ACTION_TYPES` coordinate
125
- * actions folded into `CU_TOOL_ACTION_TYPES` below.
104
+ * Every semantic action name the tool schema spells out itself.
126
105
  *
127
106
  * This list used to be hand-written beside a schema that already listed the
128
107
  * same names, and it drifted: `window_action` was added to the strict union and
@@ -151,13 +130,8 @@ export const COMPUTER_USE_SEMANTIC_ACTIONS = [
151
130
  ...CU_SEMANTIC_ACTION_TYPES,
152
131
  ];
153
132
  /**
154
- * Every action name the `maka_computer` tool accepts, in wire order.
155
- *
156
- * One list, so that adding an action cannot leave a consumer silently matching
157
- * nothing. This has already cost us once: an offline analyser restated the
158
- * vocabulary as two regexes, neither of which matched a single coordinate
159
- * action after the surface moved, and it reported clean runs for trajectories
160
- * made entirely of blind clicks.
133
+ * Every action name the `maka_computer` tool accepts from a model, in wire
134
+ * order.
161
135
  */
162
136
  export const CU_TOOL_ACTION_TYPES = [...COMPUTER_USE_SEMANTIC_ACTIONS, ...CU_ACTION_TYPES];
163
137
  /**
@@ -166,13 +140,7 @@ export const CU_TOOL_ACTION_TYPES = [...COMPUTER_USE_SEMANTIC_ACTIONS, ...CU_ACT
166
140
  * mutating — including any action added later, which fails loud in an analyser
167
141
  * rather than silently dropping out of the counts.
168
142
  */
169
- export const CU_OBSERVING_ACTION_TYPES = [
170
- 'list_apps',
171
- 'observe',
172
- 'screenshot',
173
- 'cursor_position',
174
- 'wait',
175
- ];
143
+ export const CU_OBSERVING_ACTION_TYPES = ['list_apps', 'observe', 'screenshot', 'wait'];
176
144
  const OBSERVING_ACTION_SET = new Set(CU_OBSERVING_ACTION_TYPES);
177
145
  const TOOL_ACTION_SET = new Set(CU_TOOL_ACTION_TYPES);
178
146
  export const CU_MUTATING_ACTION_TYPES = CU_TOOL_ACTION_TYPES.filter((action) => !OBSERVING_ACTION_SET.has(action));
@@ -199,7 +167,6 @@ export const COMPUTER_USE_EFFECTS = ['confirmed', 'unverifiable', 'suspected_noo
199
167
  export const COMPUTER_USE_APPROVAL_CLASSES = [
200
168
  'metadata_read',
201
169
  'screenshot_read',
202
- 'pointer_mutation',
203
170
  'keyboard_mutation',
204
171
  'semantic_mutation',
205
172
  ];
@@ -235,14 +202,14 @@ const MODEL_CALL_NAMED_ARGS = new Set([
235
202
  * Arguments whose value is the model's own choice from a fixed set, a number,
236
203
  * or a word it wrote itself — nothing here comes off the screen.
237
204
  *
238
- * Keyed by action, not by argument name, because `text` is six arguments
239
- * wearing one name. It carries the key for `press_key`, `key` and `hold_key`,
205
+ * Keyed by action, not by argument name, because `text` is five arguments
206
+ * wearing one name. It carries the key for `press_key` and `key`,
240
207
  * the element action name for `secondary_action`, the substring to select for
241
208
  * `select_text`, and whatever a person asked to be typed for `type`. Two of
242
- * those come off the screen or out of a person's head; four are a name the
209
+ * those come off the screen or out of a person's head; three are a name the
243
210
  * model picked from a set the executor publishes.
244
211
  *
245
- * Keying on the name meant excluding all six, which is right for `type` and
212
+ * Keying on the name meant excluding all five, which is right for `type` and
246
213
  * wrong for the rest — and the wrong half is the one that motivated this
247
214
  * projection: the model read back `press_key ... text: <text>` and could not
248
215
  * see which key it had pressed.
@@ -268,11 +235,9 @@ const MODEL_CALL_PLAIN_VALUES = new Map([
268
235
  // `query` and `menu` name what to look at, not what was found there.
269
236
  ['observe', new Set(['include_screenshot', 'query', 'menu'])],
270
237
  ['screenshot', new Set(['include_screenshot'])],
271
- ['scroll', new Set(['scroll_direction', 'scroll_amount'])],
272
- // The semantic twin of `scroll`, added after this map was written.
273
238
  ['scroll_element', new Set(['scroll_direction', 'scroll_amount'])],
274
239
  // The verb, from the enum the schema publishes. `position` and `size` are
275
- // geometry and are handled by MODEL_CALL_GEOMETRY_ARGS below.
240
+ // semantic window geometry and are handled below.
276
241
  ['window_action', new Set(['window_action'])],
277
242
  // The text a wait is waiting for is a prediction about the screen, written
278
243
  // before the screen shows it.
@@ -280,7 +245,6 @@ const MODEL_CALL_PLAIN_VALUES = new Map([
280
245
  // The key name, from the set of key names the executor accepts.
281
246
  ['press_key', new Set(['text'])],
282
247
  ['key', new Set(['text'])],
283
- ['hold_key', new Set(['text', 'duration'])],
284
248
  // The element action name, from the closed set the observation lists.
285
249
  ['secondary_action', new Set(['text'])],
286
250
  ]);
@@ -294,26 +258,15 @@ const MODEL_CALL_PLAIN_VALUES = new Map([
294
258
  */
295
259
  const MODEL_CALL_PLAIN_STEP_MEMBERS = new Set(['do', 'role']);
296
260
  /**
297
- * Geometry the model itself chose, projected verbatim.
298
- *
299
- * Independent of action, because these names mean the same thing wherever they
300
- * appear and none of them ever holds screen content: a coordinate, the drag
301
- * origin, the zoom rectangle, and the place and size a window was asked to take
302
- * are numbers the model wrote into the call. A model that clicked a point and
303
- * missed has to be able to see which point, or its next call is the same call.
261
+ * Semantic window geometry the model itself chose, projected verbatim.
304
262
  *
305
- * `position` and `size` joined late, with `window_action`. Reduced to
306
- * `"<point>"` they were a string where the schema wants a tuple, so a replayed
307
- * window move was rejected off the wire.
263
+ * `position` and `size` belong to `window_action`; they place or resize the
264
+ * observed window and never address a control by pixel. Reduced to `"<point>"`
265
+ * they become strings where the schema requires tuples, so replaying the
266
+ * model's own call would be rejected before execution.
308
267
  */
309
- const MODEL_CALL_GEOMETRY_ARGS = new Set([
310
- 'coordinate',
311
- 'start_coordinate',
312
- 'region',
313
- 'position',
314
- 'size',
315
- ]);
316
- /** Integers only, so a mistyped `coordinate` still degrades to a shape. */
268
+ const MODEL_CALL_GEOMETRY_ARGS = new Set(['position', 'size']);
269
+ /** Integers only, so malformed window geometry still degrades to a shape. */
317
270
  function integerTuple(value) {
318
271
  if (!Array.isArray(value) || value.length === 0 || value.length > 4)
319
272
  return undefined;
@@ -460,28 +413,14 @@ export function computerUseModelCallArgs(args) {
460
413
  ...rest,
461
414
  };
462
415
  }
463
- const POINTER_ACTIONS = new Set([
464
- 'mouse_move',
465
- 'left_click',
466
- 'right_click',
467
- 'middle_click',
468
- 'double_click',
469
- 'triple_click',
470
- 'left_mouse_down',
471
- 'left_mouse_up',
472
- 'left_click_drag',
473
- 'scroll',
474
- 'zoom',
475
- ]);
476
- const KEYBOARD_ACTIONS = new Set(['type', 'key', 'hold_key', 'press_key']);
416
+ const KEYBOARD_ACTIONS = new Set(['type', 'key', 'press_key']);
477
417
  const SEMANTIC_ACTIONS = new Set([
478
418
  'click_element',
479
419
  'set_value',
480
420
  'select_text',
481
421
  'secondary_action',
482
- // Scrolling an element moves what is on screen without changing any value.
483
- // It is still a mutation of the target's state, and it is the semantic twin
484
- // of the coordinate `scroll` that already sits in POINTER_ACTIONS.
422
+ // Scrolling an element moves what is on screen without changing any value,
423
+ // but it still mutates the target's UI state.
485
424
  'scroll_element',
486
425
  // A sequence of element actions is still element actions: same class, same
487
426
  // approval, one call.
@@ -504,7 +443,7 @@ export function computerUseApprovalSummary(args) {
504
443
  // screenshot-by-default contract: an omitted flag is metadata_read, and only
505
444
  // an explicit true requires Screen Recording approval.
506
445
  const includeScreenshot = ownDataProperty(record, 'include_screenshot') === true;
507
- const approvalClass = action === 'list_apps' || action === 'cursor_position' || action === 'wait'
446
+ const approvalClass = action === 'list_apps' || action === 'wait'
508
447
  ? 'metadata_read'
509
448
  : action === 'observe'
510
449
  ? includeScreenshot
@@ -512,13 +451,11 @@ export function computerUseApprovalSummary(args) {
512
451
  : 'metadata_read'
513
452
  : action === 'screenshot'
514
453
  ? 'screenshot_read'
515
- : POINTER_ACTIONS.has(action)
516
- ? 'pointer_mutation'
517
- : KEYBOARD_ACTIONS.has(action)
518
- ? 'keyboard_mutation'
519
- : SEMANTIC_ACTIONS.has(action)
520
- ? 'semantic_mutation'
521
- : 'semantic_mutation';
454
+ : KEYBOARD_ACTIONS.has(action)
455
+ ? 'keyboard_mutation'
456
+ : SEMANTIC_ACTIONS.has(action)
457
+ ? 'semantic_mutation'
458
+ : 'semantic_mutation';
522
459
  const rawApp = ownDataProperty(record, 'app');
523
460
  const rawWindowId = ownDataProperty(record, 'window_id');
524
461
  const rawObservationId = ownDataProperty(record, 'observation_id');
@@ -532,9 +469,7 @@ export function computerUseApprovalSummary(args) {
532
469
  const explicitTarget = exactApp !== undefined || windowId !== undefined;
533
470
  const targetBound = action === 'list_apps' ||
534
471
  ((action === 'observe' || action === 'screenshot') && explicitTarget) ||
535
- ((POINTER_ACTIONS.has(action) ||
536
- KEYBOARD_ACTIONS.has(action) ||
537
- SEMANTIC_ACTIONS.has(action)) &&
472
+ ((KEYBOARD_ACTIONS.has(action) || SEMANTIC_ACTIONS.has(action)) &&
538
473
  exactObservationId !== undefined &&
539
474
  explicitTarget);
540
475
  const rememberForTurnAllowed = knownAction && targetBound;