maka-agent 0.2.0-dev.47.20260922 → 0.2.0-dev.49.20260924

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/acp/session-event-mapper.js +1 -4
  2. package/dist/onboarding-catalog.js +20 -4
  3. package/dist/pi-transcript.js +0 -8
  4. package/dist/pi-tui-pickers.js +1 -1
  5. package/dist/pi-tui-runner.js +6 -4
  6. package/dist/runtime-host-capability-provider-command.js +25 -6
  7. package/dist/runtime-host-onboarding.js +5 -3
  8. package/dist/runtime-host-session-channel.js +9 -3
  9. package/dist/tui-mcp-control.js +37 -24
  10. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  11. package/node_modules/@maka/acp-executor-plugin/dist/acp-errors.js +26 -0
  12. package/node_modules/@maka/acp-executor-plugin/dist/acp-filesystem.js +103 -0
  13. package/node_modules/@maka/acp-executor-plugin/dist/acp-process.js +119 -0
  14. package/node_modules/@maka/acp-executor-plugin/dist/acp-projection.js +146 -0
  15. package/node_modules/@maka/acp-executor-plugin/dist/index.js +653 -0
  16. package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +24446 -0
  17. package/node_modules/@maka/acp-executor-plugin/package.json +15 -0
  18. package/node_modules/@maka/antigravity-acp-plugin/dist/index.js +88 -0
  19. package/node_modules/@maka/antigravity-acp-plugin/dist/model-presentation.js +53 -0
  20. package/node_modules/@maka/antigravity-acp-plugin/dist/plugin.mjs +115 -0
  21. package/node_modules/@maka/antigravity-acp-plugin/package.json +15 -0
  22. package/node_modules/@maka/core/dist/events.js +13 -0
  23. package/node_modules/@maka/core/dist/executor-catalog.js +106 -0
  24. package/node_modules/@maka/core/dist/llm-connections.js +2 -5
  25. package/node_modules/@maka/core/dist/mcp.js +4 -1
  26. package/node_modules/@maka/core/dist/model-facts.js +2 -4
  27. package/node_modules/@maka/core/dist/model-metadata.generated.js +345 -248
  28. package/node_modules/@maka/core/dist/model-metadata.js +28 -1
  29. package/node_modules/@maka/core/dist/model-thinking.js +17 -17
  30. package/node_modules/@maka/core/dist/model-web-search.js +7 -9
  31. package/node_modules/@maka/core/dist/models-dev-projection.js +1 -1
  32. package/node_modules/@maka/core/dist/onboarding.js +1 -4
  33. package/node_modules/@maka/core/dist/provider-registry.js +60 -86
  34. package/node_modules/@maka/core/dist/runtime-event-store.js +25 -0
  35. package/node_modules/@maka/core/dist/runtime-event.js +2 -2
  36. package/node_modules/@maka/core/dist/runtime-invocation.js +5 -0
  37. package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +28 -16
  38. package/node_modules/@maka/core/dist/runtime-policy/credential-vault-codec.js +6 -0
  39. package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +21 -0
  40. package/node_modules/@maka/core/dist/runtime-policy.js +1 -1
  41. package/node_modules/@maka/core/dist/session.js +25 -9
  42. package/node_modules/@maka/core/dist/settings.js +1 -0
  43. package/node_modules/@maka/core/dist/tool-ledger-scanner.js +365 -104
  44. package/node_modules/@maka/core/dist/transcript-search.js +1 -0
  45. package/node_modules/@maka/core/dist/turn-origin.js +14 -0
  46. package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
  47. package/node_modules/@maka/core/package.json +2 -0
  48. package/node_modules/@maka/eval/dist/harbor-maka-subject.js +3 -0
  49. package/node_modules/@maka/eval/dist/maka-subject.js +8 -1
  50. package/node_modules/@maka/mcp/dist/credential-coordinator.js +6 -1
  51. package/node_modules/@maka/mcp/dist/index.js +31 -5
  52. package/node_modules/@maka/mcp/dist/oauth.js +54 -6
  53. package/node_modules/@maka/runtime/dist/agent-run-inspect.js +1 -1
  54. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +1 -11
  55. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +2 -12
  56. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +3 -71
  57. package/node_modules/@maka/runtime/dist/conversation-copy.js +58 -3
  58. package/node_modules/@maka/runtime/dist/local-web-fetch.js +23 -11
  59. package/node_modules/@maka/runtime/dist/mcp-tools.js +9 -2
  60. package/node_modules/@maka/runtime/dist/model-adapter.js +10 -5
  61. package/node_modules/@maka/runtime/dist/model-factory.js +33 -30
  62. package/node_modules/@maka/runtime/dist/model-fetcher.js +4 -1
  63. package/node_modules/@maka/runtime/dist/model-runtime.js +3 -9
  64. package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +116 -3
  65. package/node_modules/@maka/runtime/dist/plugin-executor-service.js +212 -16
  66. package/node_modules/@maka/runtime/dist/read-page.js +11 -8
  67. package/node_modules/@maka/runtime/dist/recovery-resolver.js +47 -20
  68. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +1 -0
  69. package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +2 -2
  70. package/node_modules/@maka/runtime/dist/scheduled-task-tools.js +39 -8
  71. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -0
  72. package/node_modules/@maka/runtime/dist/session-manager.js +182 -127
  73. package/node_modules/@maka/runtime/dist/shell-run-manager.js +3 -0
  74. package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +29 -4
  75. package/node_modules/@maka/runtime/dist/telemetry/model-pricing.generated.js +141 -134
  76. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +3 -3
  77. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +7 -6
  78. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +28 -62
  79. package/node_modules/@maka/runtime-host/dist/candidate-entry.js +8 -5
  80. package/node_modules/@maka/runtime-host/dist/client/hosted-execution-target.js +7 -1
  81. package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
  82. package/node_modules/@maka/runtime-host/dist/client/reconnect-lifecycle.js +8 -1
  83. package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +6 -1
  84. package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +3 -0
  85. package/node_modules/@maka/runtime-host/dist/composition-identity.js +19 -0
  86. package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +6 -3
  87. package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -2
  88. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -1
  89. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +34 -0
  90. package/node_modules/@maka/runtime-host/dist/protocol/prompt-suggestions.js +61 -0
  91. package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +4 -1
  92. package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +40 -2
  93. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +2 -1
  94. package/node_modules/@maka/runtime-host/dist/server/builtin-external-agent-plugins.js +188 -0
  95. package/node_modules/@maka/runtime-host/dist/server/candidate.js +12 -7
  96. package/node_modules/@maka/runtime-host/dist/server/client-capability-recovery.js +44 -46
  97. package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +3 -0
  98. package/node_modules/@maka/runtime-host/dist/server/context-coordinator.js +2 -0
  99. package/node_modules/@maka/runtime-host/dist/server/execution-composition-factory.js +1 -1
  100. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +212 -24
  101. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +41 -2
  102. package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +4 -0
  103. package/node_modules/@maka/runtime-host/dist/server/generated-text.js +39 -0
  104. package/node_modules/@maka/runtime-host/dist/server/host-composition-source.js +47 -0
  105. package/node_modules/@maka/runtime-host/dist/server/host-composition.js +1 -29
  106. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +2 -9
  107. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +75 -9
  108. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +12 -0
  109. package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +45 -0
  110. package/node_modules/@maka/runtime-host/dist/server/jev-routing-model.js +157 -0
  111. package/node_modules/@maka/runtime-host/dist/server/listener-set.js +2 -2
  112. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +4 -0
  113. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +11 -1
  114. package/node_modules/@maka/runtime-host/dist/server/process-lifecycle.js +1 -1
  115. package/node_modules/@maka/runtime-host/dist/server/process-termination-error.js +27 -0
  116. package/node_modules/@maka/runtime-host/dist/server/prompt-suggestion.js +179 -0
  117. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +93 -14
  118. package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +2 -0
  119. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +99 -12
  120. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +48 -16
  121. package/node_modules/@maka/runtime-host/dist/server/session-effect-coordinator.js +12 -6
  122. package/node_modules/@maka/runtime-host/dist/server/session-title.js +3 -16
  123. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +71 -3
  124. package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +3 -0
  125. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +6 -13
  126. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +39 -11
  127. package/node_modules/@maka/runtime-host/dist/server/workhub-result-coordinator.js +173 -0
  128. package/node_modules/@maka/runtime-host/dist/server/workhub-result-runtime.js +293 -0
  129. package/node_modules/@maka/runtime-host/package.json +2 -0
  130. package/node_modules/@maka/storage/dist/agent-run-store-contract.js +8 -0
  131. package/node_modules/@maka/storage/dist/config-transfer.js +14 -8
  132. package/node_modules/@maka/storage/dist/execution-stores.js +19 -6
  133. package/node_modules/@maka/storage/dist/interaction-store.js +13 -0
  134. package/node_modules/@maka/storage/dist/mcp-config-store.js +91 -2
  135. package/node_modules/@maka/storage/dist/operational-state-store.js +15 -1
  136. package/node_modules/@maka/storage/dist/plan-authority.js +2 -0
  137. package/node_modules/@maka/storage/dist/plan-store.js +30 -0
  138. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  139. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +28 -17
  140. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +9 -3
  141. package/node_modules/@maka/storage/dist/runtime-policy/credential-vault-document.js +4 -1
  142. package/node_modules/@maka/storage/dist/runtime-policy/legacy-custom-connection.js +65 -0
  143. package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +10 -5
  144. package/node_modules/@maka/storage/dist/runtime-policy/policy-document.js +2 -0
  145. package/node_modules/@maka/storage/dist/session-bundle-policy.js +11 -0
  146. package/node_modules/@maka/storage/dist/session-store-values.js +16 -4
  147. package/node_modules/@maka/storage/dist/session-store.js +29 -6
  148. package/node_modules/@maka/storage/dist/shell-run-authority.js +1 -0
  149. package/node_modules/@maka/storage/dist/shell-run-store.js +15 -0
  150. package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +3 -0
  151. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +74 -1
  152. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +849 -91
  153. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +21 -3
  154. package/node_modules/@maka/storage/dist/usage-screen.js +138 -108
  155. package/package.json +1 -1
@@ -144,24 +144,36 @@ function htmlToMarkdown(html, pageUrl) {
144
144
  assertSafeHtmlNesting(html);
145
145
  const { document } = parseHTML(html);
146
146
  const baseHref = document.querySelector('base[href]')?.getAttribute('href');
147
- let linkBaseUrl = pageUrl;
147
+ let baseUrl = pageUrl;
148
148
  if (baseHref) {
149
149
  try {
150
- linkBaseUrl = new URL(baseHref, pageUrl).toString();
150
+ baseUrl = new URL(baseHref, pageUrl).toString();
151
151
  }
152
152
  catch {
153
153
  // Fall back to the response URL for a malformed page-authored base URL.
154
154
  }
155
155
  }
156
- for (const element of document.querySelectorAll('[href]')) {
157
- const href = element.getAttribute('href');
158
- if (!href)
159
- continue;
160
- try {
161
- element.setAttribute('href', new URL(href, linkBaseUrl).toString());
162
- }
163
- catch {
164
- // Keep malformed page-authored links as-is.
156
+ const documentBase = document.querySelector('base') ?? document.createElement('base');
157
+ documentBase.setAttribute('href', baseUrl);
158
+ if (!documentBase.parentNode)
159
+ document.head?.prepend(documentBase);
160
+ // Turndown renders both `<a href>` and `<img src>` as Markdown links, so each
161
+ // has to carry an absolute URL: a relative path stops meaning anything once
162
+ // the model reads the Markdown apart from the page it was extracted from.
163
+ for (const [selector, attribute] of [
164
+ ['[href]', 'href'],
165
+ ['img[src]', 'src'],
166
+ ]) {
167
+ for (const element of document.querySelectorAll(selector)) {
168
+ const value = element.getAttribute(attribute);
169
+ if (!value)
170
+ continue;
171
+ try {
172
+ element.setAttribute(attribute, new URL(value, baseUrl).toString());
173
+ }
174
+ catch {
175
+ // Keep malformed page-authored values as-is.
176
+ }
165
177
  }
166
178
  }
167
179
  const article = new Readability(document).parse();
@@ -136,13 +136,20 @@ function mcpToolDescription(descriptor) {
136
136
  }
137
137
  export function mcpProxyToolName(serverId, toolName) {
138
138
  const raw = `mcp__${sanitizeNamePart(serverId)}__${sanitizeNamePart(toolName)}`;
139
- if (raw.length <= MAX_PROVIDER_TOOL_NAME)
139
+ // Preserve existing simple names; hash identities whose spelling or separators are ambiguous.
140
+ if (raw.length <= MAX_PROVIDER_TOOL_NAME &&
141
+ sanitizeNamePart(serverId) === serverId &&
142
+ sanitizeNamePart(toolName) === toolName &&
143
+ !serverId.includes('__') &&
144
+ !toolName.includes('__'))
140
145
  return raw;
141
146
  const hash = createHash('sha256')
142
147
  .update(`${serverId}\0${toolName}`)
143
148
  .digest('hex')
144
149
  .slice(0, HASH_CHARS);
145
- return `${raw.slice(0, MAX_PROVIDER_TOOL_NAME - HASH_CHARS - 2)}__${hash}`;
150
+ // A truncated name must not become another identity's unmodified name.
151
+ const hashed = `mcp_h__${sanitizeNamePart(serverId)}__${sanitizeNamePart(toolName)}`;
152
+ return `${hashed.slice(0, MAX_PROVIDER_TOOL_NAME - HASH_CHARS - 2)}__${hash}`;
146
153
  }
147
154
  function sanitizeNamePart(value) {
148
155
  const sanitized = value
@@ -152,7 +152,12 @@ export class ModelAdapter {
152
152
  const providerToolName = (name) => usesOpenAiResponsesAdapter && name === TOOL_SEARCH_NAME ? TOOL_SEARCH_PROVIDER_NAME : name;
153
153
  const runtimeToolName = (name) => usesOpenAiResponsesAdapter && name === TOOL_SEARCH_PROVIDER_NAME ? TOOL_SEARCH_NAME : name;
154
154
  const sdkTools = lowerModelTools(input.tools);
155
- if (usesOpenAiResponsesAdapter && sdkTools[TOOL_SEARCH_NAME] !== undefined) {
155
+ // Prose names the alias only when the provider can call it. In Code Mode
156
+ // tool_search is nested inside exec under its runtime name, so the
157
+ // catalog prompt must keep that name.
158
+ const providerExposesToolSearch = usesOpenAiResponsesAdapter && sdkTools[TOOL_SEARCH_NAME] !== undefined;
159
+ const providerTextToolName = (name) => providerExposesToolSearch ? providerToolName(name) : name;
160
+ if (providerExposesToolSearch) {
156
161
  sdkTools[TOOL_SEARCH_PROVIDER_NAME] = sdkTools[TOOL_SEARCH_NAME];
157
162
  delete sdkTools[TOOL_SEARCH_NAME];
158
163
  }
@@ -163,9 +168,9 @@ export class ModelAdapter {
163
168
  const continuation = responsesLane
164
169
  ? planOpenAiResponsesContinuation(fullMessages, this.openAiResponsesTransportState.semanticBaseline(responsesLane))
165
170
  : { messages: fullMessages };
166
- const providerMessages = remapModelMessageToolNames(continuation.messages, providerToolName);
171
+ const providerMessages = remapModelMessageToolNames(continuation.messages, providerToolName, providerTextToolName);
167
172
  const providerSystem = input.system
168
- ? remapProviderToolNamesInText(input.system, providerToolName)
173
+ ? remapProviderToolNamesInText(input.system, providerTextToolName)
169
174
  : undefined;
170
175
  const providerOptions = usesNativeOpenAiResponses(this.input.connection, this.runtime)
171
176
  ? mergeOpenAiResponsesProviderOptions(this.input.providerOptions, this.input.sessionId ?? this.input.connection.slug, continuation.previousResponseId)
@@ -914,7 +919,7 @@ function lowerChatToolImages(messages) {
914
919
  * OpenAI Responses reserves the provider name `tool_search`. Keep Maka's
915
920
  * persisted/history name intact and translate only the provider-bound copy.
916
921
  */
917
- function remapModelMessageToolNames(messages, providerToolName) {
922
+ function remapModelMessageToolNames(messages, providerToolName, providerTextToolName) {
918
923
  const remapContent = (content) => content.map((part) => {
919
924
  if ((part.type === 'tool-call' || part.type === 'tool-result') &&
920
925
  'toolName' in part &&
@@ -925,7 +930,7 @@ function remapModelMessageToolNames(messages, providerToolName) {
925
930
  typeof remapped.output.value === 'string') {
926
931
  remapped.output = {
927
932
  ...remapped.output,
928
- value: remapProviderToolNamesInText(remapped.output.value, providerToolName),
933
+ value: remapProviderToolNamesInText(remapped.output.value, providerTextToolName),
929
934
  };
930
935
  }
931
936
  }
@@ -27,11 +27,11 @@ import { createOpenAI } from '@ai-sdk/openai';
27
27
  import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
28
28
  import { isJSONArray, } from '@ai-sdk/provider';
29
29
  import { lookupModelMetadata } from '@maka/core/model-metadata';
30
- import { resolveThinkingLevel, supportsRelayFastServiceTier, thinkingOptionsForModel, thinkingVariantsForConnection, } from '@maka/core/model-thinking';
30
+ import { modelOverride, resolveThinkingLevel, supportsCustomFastServiceTier, thinkingOptionsForModel, thinkingVariantsForConnection, } from '@maka/core/model-thinking';
31
31
  import { createOpenAiChatReasoningTransport, createOpenAiChatReasoningTransportState, } from './openai-chat-reasoning-transport.js';
32
32
  import { openResponsesUrl } from './provider-urls.js';
33
33
  import { createOpenResponsesCompatibilityFinalizer } from './open-responses-compatibility.js';
34
- import { resolveModelRuntime, runtimeProviderName, } from './model-runtime.js';
34
+ import { resolveModelRuntime } from './model-runtime.js';
35
35
  import { openAiCodexHeaders } from './subscription-auth.js';
36
36
  import { createRequestCustomizationFetch } from './request-customization-fetch.js';
37
37
  import { createStreamUsageFallbackFetch } from './stream-usage-fallback-fetch.js';
@@ -65,7 +65,7 @@ export function getAIModel(input) {
65
65
  })
66
66
  : requestFetch;
67
67
  return createOpenResponses({
68
- name: runtimeProviderName(adapter, connection),
68
+ name: connection.providerType,
69
69
  apiKey,
70
70
  url: openResponsesUrl(baseURL),
71
71
  fetch: responsesFetch,
@@ -134,7 +134,7 @@ export function getAIModel(input) {
134
134
  ? composeRequestTransforms(reasoningTransport.transformRequestBody, replayAssistantReasoning('reasoning', true))
135
135
  : reasoningTransport.transformRequestBody;
136
136
  const model = createOpenAICompatible({
137
- name: runtimeProviderName(adapter, connection),
137
+ name: connection.providerType,
138
138
  apiKey,
139
139
  baseURL,
140
140
  // Ask every Chat Completions server for stream usage unless the
@@ -356,6 +356,21 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtim
356
356
  const thinkingOptions = thinkingOptionsForModel(connection.providerType, modelId);
357
357
  const level = resolveThinkingLevel(connection, modelId, thinkingLevel);
358
358
  switch (connection.providerType) {
359
+ case 'custom':
360
+ // Messages needs a thinking mode beside the effort. A declared level is
361
+ // the user's statement the gateway thinks, so it always gets adaptive.
362
+ // Messages has no `minimal` effort; `low` is its lowest.
363
+ if (runtime.wire === 'anthropic-messages') {
364
+ return level
365
+ ? {
366
+ anthropic: {
367
+ thinking: { type: 'adaptive', display: 'summarized' },
368
+ effort: level === 'minimal' ? 'low' : level,
369
+ },
370
+ }
371
+ : {};
372
+ }
373
+ return buildFamilyWire(connection, modelId, level, thinkingOptions, thinkingLevel, runtime);
359
374
  case 'kimi-coding-plan': {
360
375
  // Kimi's coding route has no off wire. Check the raw argument, not the
361
376
  // normalized level: the entry gate above drops unsupported levels to
@@ -541,7 +556,7 @@ function withParallelToolCallOptions(connection, modelId, options, runtime) {
541
556
  optionKey = 'parallelToolCalls';
542
557
  }
543
558
  else if (runtime.adapter.kind === 'openai-compatible') {
544
- providerKey = openAiCompatibleProviderOptionsKey(runtime.adapter, connection);
559
+ providerKey = openAiCompatibleProviderOptionsKey(connection);
545
560
  optionKey = 'parallel_tool_calls';
546
561
  }
547
562
  else {
@@ -559,18 +574,12 @@ function withParallelToolCallOptions(connection, modelId, options, runtime) {
559
574
  function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedLevel, runtime) {
560
575
  const { adapter, wire, reasoningReplay } = runtime;
561
576
  const explicitReasoningEffort = level ? (level === 'off' ? 'none' : level) : undefined;
562
- const serviceTier = wire === 'openai-responses' &&
563
- reasoningReplay.kind === 'responses' &&
564
- reasoningReplay.contract.adapter === 'openai' &&
565
- supportsRelayFastServiceTier(connection.providerType, modelId)
566
- ? connection.modelOverrides?.[modelId]?.serviceTier
567
- : undefined;
568
577
  // Provider selection and reasoning continuation are independent. The OpenAI
569
578
  // provider reads its provider-options namespace; the Open Responses provider
570
579
  // consumes a provider-native reasoningEffort through the same namespace,
571
580
  // keyed by the provider name getAIModel passes to createOpenResponses.
572
581
  if (wire === 'openai-responses') {
573
- // Connection-aware: a relay model's declared variants count too.
582
+ // Connection-aware: a custom model's declared variants count too.
574
583
  const reasons = thinkingVariantsForConnection(connection, modelId).length > 0;
575
584
  if (reasoningReplay.contract.adapter === 'open-responses') {
576
585
  // @ai-sdk/open-responses@2.0.34 passes a provider-native reasoningEffort
@@ -579,15 +588,13 @@ function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedL
579
588
  // sends `xhigh` to high, not max). The SDK resolves providerOptions
580
589
  // under the raw provider `name` — no camelCase alias, unlike
581
590
  // openai-compatible — so key by the same name getAIModel passes.
582
- return explicitReasoningEffort || serviceTier
583
- ? {
584
- [runtimeProviderName(adapter, connection)]: {
585
- ...(explicitReasoningEffort ? { reasoningEffort: explicitReasoningEffort } : {}),
586
- ...(serviceTier ? { serviceTier } : {}),
587
- },
588
- }
591
+ return explicitReasoningEffort
592
+ ? { [connection.providerType]: { reasoningEffort: explicitReasoningEffort } }
589
593
  : {};
590
594
  }
595
+ const serviceTier = supportsCustomFastServiceTier(connection, modelId)
596
+ ? modelOverride(connection, modelId)?.serviceTier
597
+ : undefined;
591
598
  const reasoningEffort = explicitReasoningEffort ??
592
599
  (requestedLevel === undefined ? defaultOpenAiReasoningEffort(modelId) : undefined);
593
600
  return {
@@ -612,25 +619,21 @@ function buildFamilyWire(connection, modelId, level, thinkingOptions, requestedL
612
619
  (requestedLevel === undefined ? defaultOpenAiReasoningEffort(modelId) : undefined);
613
620
  if (reasoningEffort) {
614
621
  return {
615
- [openAiCompatibleProviderOptionsKey(adapter, connection)]: { reasoningEffort },
622
+ [openAiCompatibleProviderOptionsKey(connection)]: { reasoningEffort },
616
623
  };
617
624
  }
618
625
  }
619
- if (!explicitReasoningEffort && !serviceTier)
626
+ if (!explicitReasoningEffort)
620
627
  return {};
621
628
  switch (adapter.kind) {
622
629
  case 'openai-compatible':
623
630
  return {
624
- [openAiCompatibleProviderOptionsKey(adapter, connection)]: {
625
- ...(explicitReasoningEffort ? { reasoningEffort: explicitReasoningEffort } : {}),
631
+ [openAiCompatibleProviderOptionsKey(connection)]: {
632
+ reasoningEffort: explicitReasoningEffort,
626
633
  },
627
634
  };
628
635
  case 'openai':
629
- return {
630
- openai: {
631
- ...(explicitReasoningEffort ? { reasoningEffort: explicitReasoningEffort } : {}),
632
- },
633
- };
636
+ return { openai: { reasoningEffort: explicitReasoningEffort } };
634
637
  case 'anthropic':
635
638
  // Anthropic-protocol models declare no `none` effort, so an off
636
639
  // choice only exists where an explicit case wires it.
@@ -667,6 +670,6 @@ function toCamelCase(name) {
667
670
  * A metadata reader keyed by the raw `connection.providerType` would
668
671
  * silently read nothing for dashed providers.
669
672
  */
670
- function openAiCompatibleProviderOptionsKey(adapter, connection) {
671
- return toCamelCase(runtimeProviderName(adapter, connection));
673
+ function openAiCompatibleProviderOptionsKey(connection) {
674
+ return toCamelCase(connection.providerType);
672
675
  }
@@ -86,7 +86,10 @@ async function fetchProviderModelsStrict(connection, apiKey, fetchFn) {
86
86
  // The wire is the Runtime adapter's, not a second field beside it. Only four
87
87
  // adapter kinds reach here: every other one returned above on its own
88
88
  // discovery branch, and both OpenAI-shaped kinds speak the same /models wire.
89
- switch (definition.runtimeAdapter.kind) {
89
+ const listAdapter = (connection.defaultApiProtocol &&
90
+ definition.protocolAdapters?.[connection.defaultApiProtocol]) ||
91
+ definition.runtimeAdapter;
92
+ switch (listAdapter.kind) {
90
93
  case 'anthropic': {
91
94
  const r = await fetchForConnectionEffect(fetchFn, anthropicV1Url(baseUrl, '/models'), {
92
95
  headers: anthropicModelHeaders(apiKey),
@@ -19,7 +19,7 @@
19
19
  import { PROVIDER_REGISTRY, effectiveBaseUrl, } from '@maka/core/llm-connections';
20
20
  import { lookupModelMetadata, lookupModelRuntimeOverride, openAiAdapterApiProtocol, } from '@maka/core/model-metadata';
21
21
  import { isRetiredProvider } from '@maka/core/provider-registry';
22
- import { modelOverride } from '@maka/core/model-thinking';
22
+ import { declaredModelApiProtocol, modelOverride, } from '@maka/core/model-thinking';
23
23
  import { anthropicV1BaseUrl, googleV1BetaBaseUrl, openAiResponsesBaseUrl, } from './provider-urls.js';
24
24
  import { resolveApplyPatchProfile } from './apply-patch-profile.js';
25
25
  export function resolveModelRuntime(connection, modelId) {
@@ -32,7 +32,7 @@ export function resolveModelRuntime(connection, modelId) {
32
32
  if (!override && !defaults) {
33
33
  throw new Error(`Unknown provider type "${connection.providerType}"; cannot resolve model runtime.`);
34
34
  }
35
- const apiProtocol = connection.models?.find((model) => model.id === modelId)?.apiProtocol;
35
+ const apiProtocol = declaredModelApiProtocol(connection, modelId);
36
36
  const baseAdapter = override?.adapter ?? defaults.runtimeAdapter;
37
37
  const calls = adapterCalls(baseAdapter);
38
38
  const preferred = openAiAdapterApiProtocol(modelId, connection.providerType);
@@ -70,7 +70,7 @@ export function resolveModelRuntime(connection, modelId) {
70
70
  replay.contract.adapter === 'open-responses' &&
71
71
  replay.contract.reasoningReplay === 'plaintext-summary'
72
72
  ? {
73
- responsesProviderOptionsKey: runtimeProviderName(adapter, connection),
73
+ responsesProviderOptionsKey: connection.providerType,
74
74
  responsesReplayProfile: connection.slug ?? connection.providerType,
75
75
  }
76
76
  : {}),
@@ -99,12 +99,6 @@ function resolveParallelToolCalls(connection, modelId, adapter) {
99
99
  // they require an explicit model declaration instead of inheriting this.
100
100
  return adapter.kind === 'openai' || adapter.kind === 'openai-codex' ? true : undefined;
101
101
  }
102
- /** Provider identity used to name SDK instances and key their provider options. */
103
- export function runtimeProviderName(adapter, connection) {
104
- return adapter.kind === 'openai-compatible' && adapter.name === 'connection'
105
- ? (connection.slug ?? connection.providerType)
106
- : connection.providerType;
107
- }
108
102
  /** Native OpenAI lanes keep mutable continuation state inside ModelAdapter. */
109
103
  export function modelUsesNativeOpenAiResponses(connection, modelId) {
110
104
  return (connection.providerType === 'openai' &&
@@ -17,12 +17,14 @@
17
17
  * under the License.
18
18
  */
19
19
  import { randomUUID } from 'node:crypto';
20
+ import { redactSecrets } from '@maka/core/redaction';
20
21
  import { AsyncEventQueue } from './async-queue.js';
21
22
  /** Converts a small plugin executor contract into Maka's existing Run event stream. */
22
23
  export class PluginExecutorBackend {
23
24
  kind = 'plugin-executor';
24
25
  sessionId;
25
26
  #cwd;
27
+ #configuration;
26
28
  #instructions;
27
29
  #model;
28
30
  #thinkingLevel;
@@ -34,6 +36,7 @@ export class PluginExecutorBackend {
34
36
  constructor(input) {
35
37
  this.sessionId = input.sessionId;
36
38
  this.#cwd = input.cwd;
39
+ this.#configuration = input.configuration;
37
40
  this.#instructions = input.instructions;
38
41
  this.#model = input.model;
39
42
  this.#thinkingLevel = input.thinkingLevel;
@@ -86,6 +89,7 @@ export class PluginExecutorBackend {
86
89
  const turnId = input.turnId;
87
90
  let thinkingText = '';
88
91
  const toolUseIds = new Map();
92
+ const toolOutputSequences = new Map();
89
93
  let result;
90
94
  let failure;
91
95
  let failed = false;
@@ -99,6 +103,7 @@ export class PluginExecutorBackend {
99
103
  cwd: this.#cwd,
100
104
  ...(this.#model ? { model: this.#model } : {}),
101
105
  reasoningEffort: this.#thinkingLevel ?? null,
106
+ ...(this.#configuration ? { configuration: this.#configuration } : {}),
102
107
  ...(this.#instructions ? { instructions: this.#instructions } : {}),
103
108
  ...(input.attachments ? { attachments: input.attachments } : {}),
104
109
  ...(input.directoryReferences ? { directoryReferences: input.directoryReferences } : {}),
@@ -108,8 +113,9 @@ export class PluginExecutorBackend {
108
113
  onEvent: (event) => {
109
114
  if (event.type === 'thinking_delta')
110
115
  thinkingText += event.text;
111
- this.#publishOutputEvent(turnId, messageId, event, toolUseIds, queue);
116
+ this.#publishOutputEvent(turnId, messageId, event, toolUseIds, toolOutputSequences, queue);
112
117
  },
118
+ onPermissionRequest: (request) => this.#requestPermission(input, request, signal, toolUseIds, queue),
113
119
  });
114
120
  }
115
121
  catch (error) {
@@ -130,6 +136,81 @@ export class PluginExecutorBackend {
130
136
  }
131
137
  this.#publishResult(turnId, messageId, result, queue);
132
138
  }
139
+ async #requestPermission(input, request, signal, toolUseIds, queue) {
140
+ const hosted = input.hostedInteraction;
141
+ if (!hosted || signal.aborted)
142
+ return { outcome: 'cancelled' };
143
+ const requestId = this.#newId();
144
+ const event = {
145
+ type: 'form_request',
146
+ id: this.#newId(),
147
+ turnId: input.turnId,
148
+ ts: this.#now(),
149
+ requestId,
150
+ toolUseId: toolUseIds.get(request.toolCallId) ?? request.toolCallId,
151
+ message: request.title,
152
+ requester: {
153
+ name: this.#binding.identity.displayName,
154
+ source: this.#binding.identity.extensionId,
155
+ },
156
+ fields: [
157
+ {
158
+ kind: 'single_select',
159
+ name: 'optionId',
160
+ label: request.kind === 'question' ? 'Question' : 'Permission',
161
+ required: true,
162
+ options: request.options.map((option) => ({
163
+ value: option.optionId,
164
+ label: option.name,
165
+ })),
166
+ },
167
+ ],
168
+ };
169
+ let settle;
170
+ const answer = new Promise((resolve) => {
171
+ settle = resolve;
172
+ });
173
+ let settled = false;
174
+ const finish = (result) => {
175
+ if (settled)
176
+ return;
177
+ settled = true;
178
+ settle(result);
179
+ };
180
+ const settlement = {
181
+ applyAnswer: async (result) => {
182
+ if (result.action !== 'accept')
183
+ return finish({ outcome: 'cancelled' });
184
+ const selected = result.values.optionId;
185
+ if (typeof selected !== 'string' ||
186
+ !request.options.some((option) => option.optionId === selected)) {
187
+ return finish({ outcome: 'cancelled' });
188
+ }
189
+ finish({ outcome: 'selected', optionId: selected });
190
+ },
191
+ applyClosure: async () => finish({ outcome: 'cancelled' }),
192
+ };
193
+ let admission;
194
+ const onAbort = () => {
195
+ finish({ outcome: 'cancelled' });
196
+ void Promise.resolve().then(async () => {
197
+ await admission?.catch(() => undefined);
198
+ await hosted.withdrawFormRequest(requestId).catch(() => undefined);
199
+ });
200
+ };
201
+ signal.addEventListener('abort', onAbort, { once: true });
202
+ try {
203
+ admission = hosted.admitFormRequest({ request: event, settlement });
204
+ await admission;
205
+ if (signal.aborted)
206
+ return { outcome: 'cancelled' };
207
+ queue.push(event);
208
+ return await answer;
209
+ }
210
+ finally {
211
+ signal.removeEventListener('abort', onAbort);
212
+ }
213
+ }
133
214
  #closeOptionalOutput(turnId, messageId, thinkingText, toolUseIds, queue) {
134
215
  if (thinkingText) {
135
216
  queue.push({
@@ -194,9 +275,10 @@ export class PluginExecutorBackend {
194
275
  turnId,
195
276
  ts: this.#now(),
196
277
  stopReason: 'user_stop',
278
+ ...(result.providerStopReason ? { providerStopReason: result.providerStopReason } : {}),
197
279
  });
198
280
  }
199
- #publishOutputEvent(turnId, messageId, event, toolUseIds, queue) {
281
+ #publishOutputEvent(turnId, messageId, event, toolUseIds, toolOutputSequences, queue) {
200
282
  if (event.type === 'output_delta') {
201
283
  if (!event.text)
202
284
  return;
@@ -239,6 +321,7 @@ export class PluginExecutorBackend {
239
321
  }
240
322
  const toolUseId = this.#newId();
241
323
  toolUseIds.set(event.toolCallId, toolUseId);
324
+ toolOutputSequences.set(event.toolCallId, 0);
242
325
  queue.push({
243
326
  type: 'tool_start',
244
327
  id: this.#newId(),
@@ -257,6 +340,31 @@ export class PluginExecutorBackend {
257
340
  const toolUseId = toolUseIds.get(event.toolCallId);
258
341
  if (!toolUseId)
259
342
  return;
343
+ if (event.type === 'tool_output_delta') {
344
+ if (!event.text)
345
+ return;
346
+ const chunk = redactSecrets(event.text);
347
+ if (!chunk)
348
+ return;
349
+ const now = this.#now();
350
+ const seq = (toolOutputSequences.get(event.toolCallId) ?? 0) + 1;
351
+ toolOutputSequences.set(event.toolCallId, seq);
352
+ queue.push({
353
+ type: 'tool_output_delta',
354
+ id: this.#newId(),
355
+ sessionId: this.sessionId,
356
+ turnId,
357
+ ts: now,
358
+ toolCallId: toolUseId,
359
+ toolUseId,
360
+ seq,
361
+ stream: event.stream ?? 'stdout',
362
+ chunk,
363
+ redacted: chunk !== event.text,
364
+ createdAt: now,
365
+ });
366
+ return;
367
+ }
260
368
  if (event.type === 'tool_progress') {
261
369
  if (!event.text)
262
370
  return;
@@ -271,6 +379,7 @@ export class PluginExecutorBackend {
271
379
  return;
272
380
  }
273
381
  toolUseIds.delete(event.toolCallId);
382
+ toolOutputSequences.delete(event.toolCallId);
274
383
  queue.push({
275
384
  type: 'tool_result',
276
385
  id: this.#newId(),
@@ -279,7 +388,9 @@ export class PluginExecutorBackend {
279
388
  toolUseId,
280
389
  providerExecuted: true,
281
390
  isError: event.isError ?? false,
282
- content: { kind: 'text', text: event.text },
391
+ content: event.content.kind === 'text'
392
+ ? event.content
393
+ : { kind: 'file_diff', paths: [...event.content.paths], diff: event.content.diff },
283
394
  });
284
395
  }
285
396
  #publishFailure(turnId, message, code, recoverable, queue) {
@@ -311,6 +422,8 @@ function cancellationEventReason(result) {
311
422
  return 'redirect';
312
423
  if (result.reason === 'timeout')
313
424
  return 'timeout';
425
+ if (result.reason === 'crash')
426
+ return 'crash';
314
427
  if (result.source === 'executor_retired')
315
428
  return 'crash';
316
429
  return 'user_stop';