maka-agent 0.2.0-dev.51.20260925 → 0.2.0-dev.52.20260926

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 (35) hide show
  1. package/dist/acp/goal-plan-operations.js +142 -0
  2. package/dist/acp/goal-plan-routes.js +33 -0
  3. package/dist/acp/maka-acp-agent.js +41 -1
  4. package/dist/acp/session-domain-observation.js +185 -0
  5. package/dist/acp/session-event-mapper.js +1 -1
  6. package/dist/acp/session-registry.js +417 -9
  7. package/dist/acp/tool-event-mapper.js +36 -3
  8. package/dist/runtime-host-session-channel.js +4 -0
  9. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  10. package/node_modules/@maka/core/dist/openai-urls.js +51 -0
  11. package/node_modules/@maka/core/dist/relative-time.js +1 -9
  12. package/node_modules/@maka/core/package.json +1 -0
  13. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +10 -8
  14. package/node_modules/@maka/runtime/dist/builtin-tools.js +2 -2
  15. package/node_modules/@maka/runtime/dist/filesystem-executor.js +3 -2
  16. package/node_modules/@maka/runtime/dist/filesystem-worker/protocol.js +7 -4
  17. package/node_modules/@maka/runtime/dist/glob-search.js +18 -5
  18. package/node_modules/@maka/runtime/dist/model-factory.js +27 -1
  19. package/node_modules/@maka/runtime/dist/model-fetcher.js +2 -1
  20. package/node_modules/@maka/runtime/dist/model-runtime.js +5 -3
  21. package/node_modules/@maka/runtime/dist/provider-urls.js +1 -18
  22. package/node_modules/@maka/runtime/dist/scheduled-task-tools.js +27 -2
  23. package/node_modules/@maka/runtime/dist/test-connection.js +2 -2
  24. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +16 -6
  25. package/node_modules/@maka/runtime-host/dist/protocol/index.js +3 -1
  26. package/node_modules/@maka/runtime-host/dist/protocol/scheduled-task.js +8 -1
  27. package/node_modules/@maka/runtime-host/dist/protocol/session-catalog-change.js +24 -6
  28. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +16 -3
  29. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +20 -16
  30. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +18 -1
  31. package/node_modules/@maka/runtime-host/dist/server/host-change-feed.js +15 -22
  32. package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +30 -3
  33. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +1 -1
  34. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +16 -3
  35. package/package.json +1 -1
@@ -19,13 +19,12 @@
19
19
  import { buildPromptSuggestionPrompt } from './prompt-suggestion.js';
20
20
  import { randomUUID } from 'node:crypto';
21
21
  import { authorizeConnectionModel, effectiveBaseUrl, PROVIDER_REGISTRY, } from '@maka/core/llm-connections';
22
- import { thinkingVariantsForConnection } from '@maka/core/model-thinking';
23
22
  import { isModelExplicitlyUnsupportedForChat } from '@maka/core/model-catalog';
24
23
  import { declaredModelApiProtocol } from '@maka/core/model-thinking';
25
24
  import { parseRequestHeaders } from '@maka/core/runtime-policy';
26
25
  import { applyWorkHubRoutingPolicy, bindWorkHubRoutingDecision, decodeWorkHubIntent, decodeWorkHubRecall, projectWorkHubIntentModelInput, projectWorkHubRecallModelInput, WORKHUB_INTENT_SYSTEM_PROMPT, WORKHUB_RECALL_SYSTEM_PROMPT, workHubIntentRequiresRecall, } from '@maka/core/workhub-routing';
27
26
  import { buildPricingLookup, llmCallUsageFields, recordLlmCallStrict, } from '@maka/runtime/telemetry';
28
- import { buildProviderOptions, getAIModel } from '@maka/runtime/model-factory';
27
+ import { buildProviderOptions, getAIModel, leastReasoningThinkingLevel, } from '@maka/runtime/model-factory';
29
28
  import { stableHash } from '@maka/runtime/request-shape';
30
29
  import { buildSessionRecapMessages } from '@maka/runtime/session-recap';
31
30
  import { buildSessionTitlePrompt, cleanGeneratedSessionTitle, SESSION_TITLE_GENERATION_TIMEOUT_MS, } from './session-title.js';
@@ -171,6 +170,7 @@ export function createHostDailyReviewModel(input) {
171
170
  callKind: 'daily_review',
172
171
  callId: `daily_review_${callId}`,
173
172
  abortSignal: effectiveAbortSignal,
173
+ reasoning: 'least',
174
174
  buildRequest: () => ({ prompt, maxOutputTokens: 2_048 }),
175
175
  });
176
176
  return {
@@ -188,27 +188,28 @@ export function createHostDailyReviewModel(input) {
188
188
  },
189
189
  });
190
190
  }
191
+ const PROMPT_SUGGESTION_MAX_OUTPUT_TOKENS = 128;
192
+ const PROMPT_SUGGESTION_REASONING_MAX_OUTPUT_TOKENS = 1_024;
191
193
  export function createHostPromptSuggestionModel(input) {
192
194
  const authority = createAuxiliaryModelCallAuthority(input);
193
195
  return async (source, abortSignal) => {
194
196
  const result = await runHostAuxiliaryModelCall(authority, {
195
197
  transportContextId: source.sessionId,
196
198
  telemetrySessionId: source.sessionId,
197
- header: { ...source.header, thinkingLevel: 'off' },
199
+ header: source.header,
198
200
  callKind: 'prompt_suggestion',
199
201
  callId: `prompt_suggestion_${source.terminalEventId}_${authority.newId()}`,
200
202
  abortSignal,
201
- buildRequest: (target) => {
202
- const variants = thinkingVariantsForConnection(target.connection, target.model);
203
- if (variants.length && !variants.includes('off')) {
204
- throw new AuxiliaryModelCallConfigurationError('Prompt suggestions require a model that can disable reasoning');
205
- }
206
- return {
207
- prompt: buildPromptSuggestionPrompt(source.messages, source.header.role === 'workhub_coordination'),
208
- maxOutputTokens: 128,
209
- maxRetries: 0,
210
- };
211
- },
203
+ reasoning: 'least',
204
+ buildRequest: (_target, thinkingLevel) => ({
205
+ prompt: buildPromptSuggestionPrompt(source.messages, source.header.role === 'workhub_coordination'),
206
+ // Reasoning tokens count against the output budget. A model that cannot
207
+ // turn reasoning off spends some at its lowest effort before the line.
208
+ maxOutputTokens: thinkingLevel === 'off'
209
+ ? PROMPT_SUGGESTION_MAX_OUTPUT_TOKENS
210
+ : PROMPT_SUGGESTION_REASONING_MAX_OUTPUT_TOKENS,
211
+ maxRetries: 0,
212
+ }),
212
213
  });
213
214
  return result.finishReason === 'length' ? undefined : result.text;
214
215
  };
@@ -338,7 +339,10 @@ async function runHostAuxiliaryModelCall(authority, input) {
338
339
  }
339
340
  const target = await readAuxiliaryPreflight(authority, input.abortSignal, () => readDuringBackendCreation(() => resolveExecutionTarget(input.header, authority.runtimePolicy, authority.oauthCredentials, authority.createFetchTransport), input.abortSignal));
340
341
  const pricingSnapshot = await readAuxiliaryPreflight(authority, input.abortSignal, () => readDuringBackendCreation(() => authority.usage.pricing.snapshot(), input.abortSignal));
341
- const request = input.buildRequest(target);
342
+ const thinkingLevel = input.reasoning === 'least'
343
+ ? leastReasoningThinkingLevel(target.connection, target.model)
344
+ : input.header.thinkingLevel;
345
+ const request = input.buildRequest(target, thinkingLevel);
342
346
  const pricing = buildPricingLookup(pricingSnapshot.overrides);
343
347
  const transport = authority.createFetchTransport(toRuntimePolicyProxy(target.networkProxy, target.proxySecret));
344
348
  let apiKey = target.apiKey;
@@ -373,7 +377,7 @@ async function runHostAuxiliaryModelCall(authority, input) {
373
377
  try {
374
378
  result = await readDuringBackendCreation(() => {
375
379
  const runtime = resolveModelRuntime(target.connection, target.model);
376
- const providerOptions = buildProviderOptions(target.connection, target.model, input.header.thinkingLevel, runtime);
380
+ const providerOptions = buildProviderOptions(target.connection, target.model, thinkingLevel, runtime);
377
381
  const model = getAIModel({
378
382
  sessionId: input.transportContextId,
379
383
  connection: target.connection,
@@ -330,7 +330,24 @@ async function buildHostAiSdkBackend(input, target) {
330
330
  ? { emitSkillCatalogTrace: context.emitSkillCatalogTrace }
331
331
  : {}),
332
332
  });
333
- return { text: resolved.text, sourceRevisions: resolved.sourceRevisions };
333
+ return {
334
+ ...resolved,
335
+ contexts: [
336
+ ...(resolved.contexts ?? []),
337
+ {
338
+ name: 'runtime.environment',
339
+ text: [
340
+ 'Runtime Host environment for this turn:',
341
+ JSON.stringify({
342
+ cwd: context.cwd,
343
+ platform: process.platform,
344
+ sampledAt: new Date(context.turnStartedAt ?? Date.now()).toISOString(),
345
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
346
+ }),
347
+ ].join('\n'),
348
+ },
349
+ ],
350
+ };
334
351
  },
335
352
  lookupPricing: pricing,
336
353
  recordModelCallAttempt,
@@ -55,36 +55,21 @@ export class HostChangeFeed {
55
55
  revision: this.#projectCatalogRevision,
56
56
  });
57
57
  }
58
- publishSessionCatalog(sessionId) {
59
- this.#publishSessionCatalog(sessionId);
58
+ publishSessionCatalog(sessionId, attention) {
59
+ this.#publishSessionCatalog(sessionId, undefined, attention);
60
60
  }
61
61
  /** Publish the final scoped invalidation, then stop that resource-scoped feed. */
62
62
  publishSessionCatalogAndCloseScope(sessionId, principalId) {
63
63
  this.#publishSessionCatalog(sessionId, principalId);
64
64
  }
65
- #publishSessionCatalog(sessionId, closeScopeFor) {
65
+ #publishSessionCatalog(sessionId, closeScopeFor, attention) {
66
66
  this.#sessionCatalogRevision += 1;
67
- const frame = {
67
+ this.#publish({
68
68
  kind: 'session.catalog.changed',
69
69
  revision: this.#sessionCatalogRevision,
70
70
  sessionId,
71
- };
72
- for (const [connectionId, subscription] of this.#subscriptions) {
73
- if (!isSubscribed(subscription.mask, frame))
74
- continue;
75
- void subscription.sink.send(frame).catch(() => {
76
- if (this.#subscriptions.get(connectionId) === subscription) {
77
- this.#subscriptions.delete(connectionId);
78
- }
79
- });
80
- if (closeScopeFor !== undefined &&
81
- subscription.mask.sessionCatalog !== true &&
82
- subscription.mask.sessionCatalog?.sessionId === sessionId &&
83
- subscription.mask.sessionCatalog.principalId === closeScopeFor &&
84
- this.#subscriptions.get(connectionId) === subscription) {
85
- this.#subscriptions.delete(connectionId);
86
- }
87
- }
71
+ ...(attention ? { attention } : {}),
72
+ }, closeScopeFor);
88
73
  }
89
74
  publishScheduledTask(revision, reason, taskId) {
90
75
  this.#publish({
@@ -94,7 +79,7 @@ export class HostChangeFeed {
94
79
  taskId,
95
80
  });
96
81
  }
97
- #publish(frame) {
82
+ #publish(frame, closeScopeFor) {
98
83
  for (const [connectionId, subscription] of this.#subscriptions) {
99
84
  if (!isSubscribed(subscription.mask, frame))
100
85
  continue;
@@ -103,6 +88,14 @@ export class HostChangeFeed {
103
88
  this.#subscriptions.delete(connectionId);
104
89
  }
105
90
  });
91
+ if (closeScopeFor !== undefined &&
92
+ frame.kind === 'session.catalog.changed' &&
93
+ subscription.mask.sessionCatalog !== true &&
94
+ subscription.mask.sessionCatalog?.sessionId === frame.sessionId &&
95
+ subscription.mask.sessionCatalog.principalId === closeScopeFor &&
96
+ this.#subscriptions.get(connectionId) === subscription) {
97
+ this.#subscriptions.delete(connectionId);
98
+ }
106
99
  }
107
100
  }
108
101
  }
@@ -18,11 +18,12 @@
18
18
  */
19
19
  import { randomUUID } from 'node:crypto';
20
20
  import { isDeepStrictEqual } from 'node:util';
21
+ import { truncateUtf8 } from '@maka/core/diagnostic-log';
21
22
  import { isInteractionAnswerValidForRequest, projectInteractionClientCapabilityRequest, projectInteractionSandboxBoundaryRequest, projectInteractionFormRequest, projectInteractionQuestionRequest, } from '@maka/core/interaction';
22
23
  import { WORKHUB_COORDINATION_SESSION_ID } from '@maka/core/session';
23
24
  import { RuntimeInteractionAdmissionRejectedError, RuntimeInteractionFailStopError, RuntimeInteractionInvariantError, } from '@maka/runtime/interaction-authority';
24
25
  import { authenticateInteractionStoreWriter, } from '@maka/storage/interaction-store';
25
- import { INTERACTION_MAX_PENDING_PER_SESSION, } from '../protocol/index.js';
26
+ import { INTERACTION_MAX_PENDING_PER_SESSION, SESSION_ATTENTION_BODY_MAX_BYTES, } from '../protocol/index.js';
26
27
  import { answerOutcome, clientCapabilityCanonicalOutcome, compareStoredInteractionRequests, projectInteractionRecord, projectSandboxBoundaryInteraction, projectSessionInteractions, formCanonicalOutcome, questionCanonicalOutcome, runtimeQuestionOutcome, runtimeFormOutcome, } from './interaction-projection.js';
27
28
  export class ClientCapabilityApprovalClosedError extends Error {
28
29
  reason;
@@ -448,7 +449,11 @@ export class HostInteractionCoordinator {
448
449
  throw new RuntimeInteractionAdmissionRejectedError(entry.request.requestId, 'request_settled');
449
450
  }
450
451
  entry.phase = 'live';
451
- await this.#refreshCanonicalContinuity(entry.request.sessionId, admission);
452
+ await this.#refreshCanonicalContinuity(entry.request.sessionId, admission, {
453
+ kind: 'waiting',
454
+ eventId: entry.request.requestId,
455
+ ...waitingAttentionBody(entry.request),
456
+ });
452
457
  this.#throwIfPoisoned();
453
458
  return;
454
459
  }
@@ -521,7 +526,11 @@ export class HostInteractionCoordinator {
521
526
  phase: 'live',
522
527
  };
523
528
  this.#live.set(boundaryRequest.requestId, entry);
524
- await this.#refreshCanonicalContinuity(run.sessionId, admission);
529
+ await this.#refreshCanonicalContinuity(run.sessionId, admission, {
530
+ kind: 'waiting',
531
+ eventId: boundaryRequest.requestId,
532
+ body: truncateUtf8(boundaryRequest.justification, SESSION_ATTENTION_BODY_MAX_BYTES, '…'),
533
+ });
525
534
  this.#throwIfPoisoned();
526
535
  }
527
536
  #query(sessionId, interactionId) {
@@ -1329,6 +1338,24 @@ function isExpectedRuntimeError(error) {
1329
1338
  return (error instanceof RuntimeInteractionAdmissionRejectedError ||
1330
1339
  error instanceof RuntimeInteractionFailStopError);
1331
1340
  }
1341
+ function waitingAttentionBody(request) {
1342
+ let body;
1343
+ switch (request.request.kind) {
1344
+ case 'question':
1345
+ body = request.request.questions[0]?.question;
1346
+ break;
1347
+ case 'form':
1348
+ body = request.request.message;
1349
+ break;
1350
+ case 'sandbox_boundary':
1351
+ body = request.request.justification;
1352
+ break;
1353
+ case 'permission':
1354
+ case 'client_capability':
1355
+ break;
1356
+ }
1357
+ return body ? { body: truncateUtf8(body, SESSION_ATTENTION_BODY_MAX_BYTES, '…') } : {};
1358
+ }
1332
1359
  function rejected(error) {
1333
1360
  return observed(Promise.reject(error));
1334
1361
  }
@@ -2291,7 +2291,7 @@ export class RootTurnCoordinator {
2291
2291
  };
2292
2292
  await this.interactions.assertTerminalFence({ ...identity, runId: active.continuation?.runId ?? active.runId }, lease);
2293
2293
  const batch = this.messages.beginTerminalTransition(identity);
2294
- await this.continuity.publishTerminalProjection(sessionId, active.turnId, active.runId, lease);
2294
+ await this.continuity.publishTerminalProjection(sessionId, active.turnId, active.runId, lease, active.descriptor.kind !== 'context_compact');
2295
2295
  if (batch.sources.length === 0) {
2296
2296
  this.messages.completeIdle(batch);
2297
2297
  active.messageTransitionCommitted = true;
@@ -132,8 +132,7 @@ export class SessionContinuityCoordinator {
132
132
  },
133
133
  };
134
134
  }
135
- async refreshCanonical(sessionId, admission) {
136
- this.onCatalogChanged(sessionId);
135
+ async refreshCanonical(sessionId, admission, attention) {
137
136
  await this.#runInSessionLane(sessionId, async () => {
138
137
  if (this.#closed)
139
138
  return;
@@ -148,6 +147,7 @@ export class SessionContinuityCoordinator {
148
147
  if (committed.changed)
149
148
  this.#broadcastProjection(committed.state, committed.value);
150
149
  }, admission);
150
+ await this.onCatalogChanged(sessionId, attention);
151
151
  }
152
152
  /** Safe for synchronous commit hooks: this only schedules and coalesces lane work. */
153
153
  enqueueCanonicalRefresh(sessionId) {
@@ -409,7 +409,7 @@ export class SessionContinuityCoordinator {
409
409
  this.#broadcastProjection(committed.state, committed.value);
410
410
  }, admission);
411
411
  }
412
- async publishTerminalProjection(sessionId, turnId, runId, admission) {
412
+ async publishTerminalProjection(sessionId, turnId, runId, admission, publishCompletionAttention = true) {
413
413
  await this.#runInSessionLane(sessionId, async () => {
414
414
  if (this.#closed)
415
415
  throw new Error('Session continuity coordinator is closed');
@@ -456,6 +456,19 @@ export class SessionContinuityCoordinator {
456
456
  state.assistantStreams.clear();
457
457
  state.toolResultPreviews.clear();
458
458
  this.#broadcastProjection(state, snapshot);
459
+ if (publishCompletionAttention && rootTurn.status === 'completed') {
460
+ await this.onCatalogChanged(sessionId, {
461
+ kind: 'completed',
462
+ eventId: rootTurn.terminalEventId,
463
+ });
464
+ }
465
+ else if (rootTurn.status === 'failed') {
466
+ await this.onCatalogChanged(sessionId, {
467
+ kind: 'errored',
468
+ eventId: rootTurn.terminalEventId,
469
+ ...(rootTurn.failureMessage ? { body: rootTurn.failureMessage } : {}),
470
+ });
471
+ }
459
472
  for (const subscriber of state.subscribers.values()) {
460
473
  this.#payAssistantBacklog(subscriber, state);
461
474
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maka-agent",
3
- "version": "0.2.0-dev.51.20260925",
3
+ "version": "0.2.0-dev.52.20260926",
4
4
  "description": "Apache Maka (Incubating) developer snapshot; not an Apache release.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",