maka-agent 0.2.0-dev.48.20260923 → 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 (78) 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-onboarding.js +5 -3
  7. package/dist/runtime-host-session-channel.js +9 -3
  8. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  9. package/node_modules/@maka/core/dist/events.js +13 -0
  10. package/node_modules/@maka/core/dist/llm-connections.js +2 -5
  11. package/node_modules/@maka/core/dist/model-facts.js +2 -4
  12. package/node_modules/@maka/core/dist/model-metadata.generated.js +345 -248
  13. package/node_modules/@maka/core/dist/model-thinking.js +17 -17
  14. package/node_modules/@maka/core/dist/model-web-search.js +7 -9
  15. package/node_modules/@maka/core/dist/models-dev-projection.js +1 -1
  16. package/node_modules/@maka/core/dist/onboarding.js +1 -4
  17. package/node_modules/@maka/core/dist/provider-registry.js +60 -86
  18. package/node_modules/@maka/core/dist/runtime-event.js +2 -2
  19. package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +28 -16
  20. package/node_modules/@maka/core/dist/runtime-policy.js +1 -1
  21. package/node_modules/@maka/core/dist/session.js +23 -9
  22. package/node_modules/@maka/core/dist/transcript-search.js +1 -0
  23. package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
  24. package/node_modules/@maka/eval/dist/harbor-maka-subject.js +3 -0
  25. package/node_modules/@maka/eval/dist/maka-subject.js +8 -1
  26. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +1 -11
  27. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +2 -12
  28. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +3 -71
  29. package/node_modules/@maka/runtime/dist/conversation-copy.js +2 -2
  30. package/node_modules/@maka/runtime/dist/local-web-fetch.js +23 -11
  31. package/node_modules/@maka/runtime/dist/model-adapter.js +10 -5
  32. package/node_modules/@maka/runtime/dist/model-factory.js +33 -30
  33. package/node_modules/@maka/runtime/dist/model-fetcher.js +4 -1
  34. package/node_modules/@maka/runtime/dist/model-runtime.js +3 -9
  35. package/node_modules/@maka/runtime/dist/read-page.js +11 -8
  36. package/node_modules/@maka/runtime/dist/recovery-resolver.js +47 -20
  37. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +1 -0
  38. package/node_modules/@maka/runtime/dist/scheduled-task-tools.js +39 -8
  39. package/node_modules/@maka/runtime/dist/session-manager.js +12 -2
  40. package/node_modules/@maka/runtime/dist/telemetry/model-pricing.generated.js +141 -134
  41. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +3 -3
  42. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +7 -6
  43. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +28 -62
  44. package/node_modules/@maka/runtime-host/dist/client/hosted-execution-target.js +7 -1
  45. package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +3 -0
  46. package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +6 -3
  47. package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
  48. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -1
  49. package/node_modules/@maka/runtime-host/dist/protocol/prompt-suggestions.js +61 -0
  50. package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +4 -1
  51. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +2 -1
  52. package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +3 -0
  53. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +54 -6
  54. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +38 -2
  55. package/node_modules/@maka/runtime-host/dist/server/generated-text.js +39 -0
  56. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +8 -0
  57. package/node_modules/@maka/runtime-host/dist/server/prompt-suggestion.js +179 -0
  58. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +2 -2
  59. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +48 -16
  60. package/node_modules/@maka/runtime-host/dist/server/session-title.js +3 -16
  61. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +38 -3
  62. package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +3 -0
  63. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +6 -13
  64. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +35 -11
  65. package/node_modules/@maka/storage/dist/config-transfer.js +14 -8
  66. package/node_modules/@maka/storage/dist/execution-stores.js +4 -3
  67. package/node_modules/@maka/storage/dist/interaction-store.js +13 -0
  68. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +28 -17
  69. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +9 -3
  70. package/node_modules/@maka/storage/dist/runtime-policy/legacy-custom-connection.js +65 -0
  71. package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +10 -5
  72. package/node_modules/@maka/storage/dist/session-bundle-policy.js +11 -0
  73. package/node_modules/@maka/storage/dist/session-store.js +29 -6
  74. package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +3 -0
  75. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +125 -7
  76. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +5 -3
  77. package/node_modules/@maka/storage/dist/usage-screen.js +138 -108
  78. package/package.json +1 -1
@@ -142,10 +142,7 @@ export class AcpSessionEventMapper {
142
142
  }
143
143
  }
144
144
  function deltaText(event, current = '') {
145
- return foldRuntimeHostAssistantDelta(current, {
146
- startOffset: event.startOffset ?? current.length,
147
- text: event.text,
148
- }).text;
145
+ return foldRuntimeHostAssistantDelta(current, event).text;
149
146
  }
150
147
  function streamKey(kind, messageId) {
151
148
  return `${kind}:${messageId}`;
@@ -16,9 +16,9 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
- import { CATALOG_PROVIDER_TYPES, PROVIDER_REGISTRY, providerAuthSupportsApiKey, } from '@maka/core/llm-connections';
19
+ import { CATALOG_PROVIDER_TYPES, MODEL_API_PROTOCOL_LABELS, MODEL_API_PROTOCOLS, PROVIDER_REGISTRY, providerAuthSupportsApiKey, } from '@maka/core/llm-connections';
20
20
  export function listApiKeyOnboardableProviders() {
21
- // Custom relays have no built-in base URL and stay listed: `requiresBaseUrl`
21
+ // Custom connections have no built-in base URL and stay listed: `requiresBaseUrl`
22
22
  // tells the wizard to collect an endpoint before the API key. The original
23
23
  // phase-1 wizard filtered every empty-baseUrl provider out because it had no
24
24
  // base-URL step to offer (#1254); that step exists now (#3405). Providers
@@ -30,13 +30,29 @@ export function listApiKeyOnboardableProviders() {
30
30
  return false;
31
31
  const definition = PROVIDER_REGISTRY[providerType];
32
32
  return Boolean(definition.baseUrl) || definition.category === 'custom';
33
- }).map((providerType) => {
33
+ }).flatMap((providerType) => {
34
34
  const definition = PROVIDER_REGISTRY[providerType];
35
- return {
35
+ const entry = {
36
36
  providerType,
37
37
  label: definition.label,
38
38
  requiresBaseUrl: !definition.baseUrl,
39
39
  setupMethod: 'api_key',
40
40
  };
41
+ if (providerType !== 'custom')
42
+ return [entry];
43
+ return MODEL_API_PROTOCOLS.map((defaultApiProtocol) => ({
44
+ ...entry,
45
+ defaultApiProtocol,
46
+ label: `${definition.label} (${MODEL_API_PROTOCOL_LABELS[defaultApiProtocol]})`,
47
+ }));
41
48
  });
42
49
  }
50
+ export function onboardingCreateTarget(provider) {
51
+ return {
52
+ kind: 'create',
53
+ providerType: provider.providerType,
54
+ ...(provider.defaultApiProtocol === undefined
55
+ ? {}
56
+ : { defaultApiProtocol: provider.defaultApiProtocol }),
57
+ };
58
+ }
@@ -941,14 +941,6 @@ function systemNoteText(message) {
941
941
  return 'Context compacted to keep this task within the model window.';
942
942
  case 'context_compaction_failed_open':
943
943
  return 'Context summary failed; the session continued without a new summary.';
944
- case 'context_provider_dropping': {
945
- const data = message.data;
946
- const used = typeof data?.inputTokens === 'number' ? data.inputTokens : undefined;
947
- const prior = typeof data?.priorInputTokens === 'number' ? data.priorInputTokens : undefined;
948
- if (used === undefined || prior === undefined)
949
- return "After content was appended, the provider-reported input token count did not grow; context may have been truncated or rewritten. If this persists, check that the model's actual context capacity and the connection settings agree.";
950
- return `After content was appended, the provider-reported input token count did not grow; context may have been truncated or rewritten (${used} tokens versus ${prior} before). If this persists, check that the model's actual context capacity and the connection settings agree.`;
951
- }
952
944
  case 'context_overflow_after_compaction':
953
945
  return 'History was compacted and the provider still called this request too large. What remains also carries the system prompt, the tool schemas, the summary and the recent tail; shortening this message is the part you control.';
954
946
  case 'context_reported_window_exceeded': {
@@ -822,7 +822,7 @@ export function onboardingProviderPickerItems(providers, locale) {
822
822
  function onboardingProviderKey(provider) {
823
823
  return provider.target.kind === 'existing'
824
824
  ? provider.target.connectionId
825
- : `create:${provider.target.providerType}`;
825
+ : `create:${provider.target.providerType}:${provider.target.defaultApiProtocol ?? ''}`;
826
826
  }
827
827
  export function thinkingLevelPickerItems(levels, current, locale) {
828
828
  const copy = getTuiPickerCopy(locale);
@@ -26,7 +26,7 @@ import { projectRevisionLinkedSessionTree } from '@maka/core/session-revisions';
26
26
  import { slashCommandsForSurface, } from '@maka/core/slash-command-catalog';
27
27
  import { latestAssistantModelId, } from '@maka/core/session';
28
28
  import { defineUiMessageCatalog, formatUiMessage, resolveUiMessageCatalog, } from '@maka/core/ui-locale';
29
- import { listApiKeyOnboardableProviders } from './onboarding-catalog.js';
29
+ import { listApiKeyOnboardableProviders, onboardingCreateTarget } from './onboarding-catalog.js';
30
30
  import { AUTO_RECAP_DISPLAY_LIMIT_BYTES, shouldAutoRecap } from './session-recap.js';
31
31
  import { MakaSkillHighlightEditor } from './skill-highlight-editor.js';
32
32
  import { parseGraphCommand } from '@maka/core/graph-command';
@@ -2256,7 +2256,7 @@ export async function runMakaPiTui(input) {
2256
2256
  // wizard can report unavailability in-frame at submit instead of throwing.
2257
2257
  providers = listApiKeyOnboardableProviders().map((provider) => ({
2258
2258
  ...provider,
2259
- target: { kind: 'create', providerType: provider.providerType },
2259
+ target: onboardingCreateTarget(provider),
2260
2260
  label: provider.label,
2261
2261
  suggestedSlug: deriveConnectionSlug(provider.providerType),
2262
2262
  enabledModelIds: [],
@@ -2288,8 +2288,10 @@ export async function runMakaPiTui(input) {
2288
2288
  onSubmitIdentity: (identity) => {
2289
2289
  if (wizardTarget?.kind === 'create') {
2290
2290
  wizardTarget = {
2291
- kind: 'create',
2292
- providerType: wizardTarget.providerType,
2291
+ ...onboardingCreateTarget({
2292
+ providerType: wizardTarget.providerType,
2293
+ defaultApiProtocol: wizardTarget.defaultApiProtocol,
2294
+ }),
2293
2295
  ...(identity.slug === null ? {} : { slug: identity.slug }),
2294
2296
  ...(identity.name === null ? {} : { name: identity.name }),
2295
2297
  };
@@ -19,7 +19,7 @@
19
19
  import { randomUUID } from 'node:crypto';
20
20
  import { deriveConnectionSlug, deriveInteractiveOAuthConnectionSlug, offerableCatalogEntries, providerFallbackModelIds, PROVIDER_REGISTRY, } from '@maka/core/llm-connections';
21
21
  import { createOAuthPresentationClientProvider, readRuntimeHostConnectionCatalog, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, } from '@maka/runtime-host/client';
22
- import { listApiKeyOnboardableProviders } from './onboarding-catalog.js';
22
+ import { listApiKeyOnboardableProviders, onboardingCreateTarget } from './onboarding-catalog.js';
23
23
  /** Adapt the TUI onboarding workflow to Host-owned verification and persistence. */
24
24
  export function createRuntimeHostOnboardingSurface(connection, options = {}) {
25
25
  const shutdown = new AbortController();
@@ -432,8 +432,10 @@ export function projectProviders(catalog, codexOAuthEnabled = false) {
432
432
  const existingSlugs = catalog.connections.map((connection) => connection.slug);
433
433
  for (const provider of listApiKeyOnboardableProviders()) {
434
434
  for (const connection of catalog.connections) {
435
- if (connection.providerType !== provider.providerType)
435
+ if (connection.providerType !== provider.providerType ||
436
+ connection.defaultApiProtocol !== provider.defaultApiProtocol) {
436
437
  continue;
438
+ }
437
439
  entries.push({
438
440
  ...provider,
439
441
  target: { kind: 'existing', connectionId: connection.connectionId },
@@ -444,7 +446,7 @@ export function projectProviders(catalog, codexOAuthEnabled = false) {
444
446
  }
445
447
  entries.push({
446
448
  ...provider,
447
- target: { kind: 'create', providerType: provider.providerType },
449
+ target: onboardingCreateTarget(provider),
448
450
  label: provider.label,
449
451
  suggestedSlug: deriveConnectionSlug(provider.providerType, existingSlugs),
450
452
  enabledModelIds: [],
@@ -19,7 +19,7 @@
19
19
  import { decodeStoredMessage as decodePersistedStoredMessage, } from '@maka/core/session';
20
20
  import { markPersisted } from '@maka/core/persisted-value';
21
21
  import { createRuntimeHostSessionProjectionSeed, RuntimeHostSessionProjector, isRuntimeHostTerminalTurn as isTerminalTurn, sameRuntimeHostTerminalTurn, } from '@maka/runtime-host/adapter';
22
- import { isRuntimeHostReconnectingConnection, RuntimeHostRequestInterruptedError, RuntimeHostSubscriptionError, } from '@maka/runtime-host/client';
22
+ import { isRuntimeHostReconnectingConnection, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, RuntimeHostSubscriptionError, } from '@maka/runtime-host/client';
23
23
  import { SESSION_TRANSCRIPT_BOOTSTRAP_MAX_BYTES, SESSION_TRANSCRIPT_PAGE_MAX_BYTES, } from '@maka/runtime-host/protocol';
24
24
  const decodeStoredMessage = (value) => decodePersistedStoredMessage(markPersisted(value));
25
25
  const PROMPT_TRANSCRIPT_RANGE_MAX_BYTES = 16 * 1024 * 1024;
@@ -652,6 +652,11 @@ export class RuntimeHostSessionChannel {
652
652
  #canRecover(error) {
653
653
  if (!isRuntimeHostReconnectingConnection(this.#connection))
654
654
  return false;
655
+ // The Host can retire a transcript subscription before its close frame is
656
+ // consumed. Recover the invalidated read through the same bounded policy.
657
+ if (error instanceof RuntimeHostOperationError) {
658
+ return error.operation === 'session.transcript.page' && error.code === 'not_found';
659
+ }
655
660
  if (error instanceof RuntimeHostRequestInterruptedError) {
656
661
  return error.reason === 'connection_lost';
657
662
  }
@@ -659,6 +664,7 @@ export class RuntimeHostSessionChannel {
659
664
  (error.reason === 'connection_closed' ||
660
665
  error.reason === 'sequence_gap' ||
661
666
  error.reason === 'projection_revision_invalid' ||
667
+ error.reason === 'transcript_changed' ||
662
668
  error.reason === 'slow_consumer'));
663
669
  }
664
670
  #accept(frame) {
@@ -678,8 +684,8 @@ export class RuntimeHostSessionChannel {
678
684
  return;
679
685
  }
680
686
  if (frame.kind === 'subscription.closed') {
681
- if (frame.reason === 'slow_consumer') {
682
- throw new RuntimeHostSubscriptionError('slow_consumer', 'Runtime Host Session subscription consumer fell behind');
687
+ if (frame.reason === 'slow_consumer' || frame.reason === 'transcript_changed') {
688
+ throw new RuntimeHostSubscriptionError(frame.reason, 'Runtime Host Session transcript requires a fresh subscription');
683
689
  }
684
690
  this.#fail(new Error(`Runtime Host Session subscription closed: ${frame.reason}`));
685
691
  return;
@@ -415,6 +415,19 @@ function attachmentRefsEqual(left, right) {
415
415
  return right.ref.kind === 'external_file' && left.ref.absolutePath === right.ref.absolutePath;
416
416
  }
417
417
  }
418
+ /**
419
+ * Apply a text/thinking delta to a stream that has consumed `currentEnd`
420
+ * source characters. Overlap with consumed text is dropped, so replayed and
421
+ * reseeded deltas are idempotent. A delta that starts past `currentEnd` is a
422
+ * gap and returns `undefined`; one without `startOffset` appends.
423
+ */
424
+ export function foldAssistantDelta(currentEnd, delta) {
425
+ const startOffset = delta.startOffset ?? currentEnd;
426
+ if (startOffset > currentEnd)
427
+ return undefined;
428
+ const tail = delta.text.slice(currentEnd - startOffset);
429
+ return { tail, endOffset: currentEnd + tail.length };
430
+ }
418
431
  const TOOL_STEP_PROGRESS_PATTERN = /^steps:(\d+)\/(\d+)$/;
419
432
  export function encodeToolStepProgress(progress) {
420
433
  return isValidToolStepProgress(progress)
@@ -17,12 +17,9 @@
17
17
  * under the License.
18
18
  */
19
19
  import { CODEX_SUBSCRIPTION_UNSUPPORTED_CHATGPT_MODELS } from './codex-model-compatibility.js';
20
- import { CATALOG_PROVIDER_TYPES, PROVIDER_REGISTRY, RECOMMENDED_PROVIDER_TYPES, providerDefaultsOf, providerFallbackModelIds, providerMenuLabel, } from './provider-registry.js';
20
+ import { CATALOG_PROVIDER_TYPES, isModelApiProtocol, MODEL_API_PROTOCOL_LABELS, MODEL_API_PROTOCOLS, PROVIDER_REGISTRY, RECOMMENDED_PROVIDER_TYPES, providerDefaultsOf, providerFallbackModelIds, providerMenuLabel, } from './provider-registry.js';
21
21
  export { CODEX_SUBSCRIPTION_UNSUPPORTED_CHATGPT_MODELS };
22
- export { CATALOG_PROVIDER_TYPES, PROVIDER_REGISTRY, RECOMMENDED_PROVIDER_TYPES, providerDefaultsOf, providerFallbackModelIds, providerMenuLabel, };
23
- export function isRelayProviderType(providerType) {
24
- return providerType === 'openai-compatible' || providerType === 'openai-responses-compatible';
25
- }
22
+ export { CATALOG_PROVIDER_TYPES, isModelApiProtocol, MODEL_API_PROTOCOL_LABELS, MODEL_API_PROTOCOLS, PROVIDER_REGISTRY, RECOMMENDED_PROVIDER_TYPES, providerDefaultsOf, providerFallbackModelIds, providerMenuLabel, };
26
23
  const MODEL_MODALITIES = ['text', 'image', 'audio', 'pdf', 'video'];
27
24
  export function isModelModality(value) {
28
25
  return MODEL_MODALITIES.includes(value);
@@ -16,7 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
- import { providerDefaultsOf } from './provider-registry.js';
19
+ import { isModelApiProtocol, providerDefaultsOf } from './provider-registry.js';
20
20
  import { isModelModality } from './llm-connections.js';
21
21
  export const MODEL_FACTS_SCHEMA_VERSION = 1;
22
22
  export const MODEL_FACT_KEY_MAX_LENGTH = 512;
@@ -118,9 +118,7 @@ export function normalizeModelFactOverride(value) {
118
118
  }
119
119
  }
120
120
  if ('apiProtocol' in value) {
121
- if (value.apiProtocol !== 'openai-chat' &&
122
- value.apiProtocol !== 'openai-responses' &&
123
- value.apiProtocol !== 'anthropic-messages')
121
+ if (!isModelApiProtocol(value.apiProtocol))
124
122
  throw new Error('Invalid apiProtocol');
125
123
  result.apiProtocol = value.apiProtocol;
126
124
  }