maka-agent 0.2.0-dev.50.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
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ /** Shared by request previews, connection probes and SDK base URL resolution. */
20
+ export function openAiChatBaseUrl(baseUrl) {
21
+ return openAiBaseUrl(baseUrl);
22
+ }
23
+ export function openAiChatUrl(baseUrl) {
24
+ return openAiRequestUrl(baseUrl, '/chat/completions');
25
+ }
26
+ export function openAiResponsesBaseUrl(baseUrl) {
27
+ return openAiBaseUrl(baseUrl);
28
+ }
29
+ export function openResponsesUrl(baseUrl) {
30
+ return openAiRequestUrl(baseUrl, '/responses');
31
+ }
32
+ export function openAiBaseUrl(baseUrl) {
33
+ const url = new URL(baseUrl);
34
+ let path = url.pathname.replace(/\/+$/, '');
35
+ // Accept both a base and a full endpoint, including previously duplicated
36
+ // suffixes. Models on one connection may use either OpenAI protocol.
37
+ // Preserve the gateway's prefix; never assume or insert /v1.
38
+ // A terminal OpenAI endpoint is always treated as an endpoint: a gateway
39
+ // mounted at that exact path cannot be distinguished from a full request URL.
40
+ const endpoint = /\/(?:chat\/completions|responses)$/i;
41
+ while (endpoint.test(path)) {
42
+ path = path.replace(endpoint, '').replace(/\/+$/, '');
43
+ }
44
+ url.pathname = path;
45
+ return url.toString();
46
+ }
47
+ function openAiRequestUrl(baseUrl, endpoint) {
48
+ const url = new URL(openAiBaseUrl(baseUrl));
49
+ url.pathname = `${url.pathname.replace(/\/+$/, '')}${endpoint}`;
50
+ return url.toString();
51
+ }
@@ -47,14 +47,6 @@ const JUST_NOW = {
47
47
  'zh-TW': '剛剛',
48
48
  en: 'just now',
49
49
  };
50
- // The sidebar column is sized to the scan tokens ("59min"); the spelled-out
51
- // "just now" is wider than any of them, so the slot gets its own compact en
52
- // label.
53
- const SIDEBAR_JUST_NOW = {
54
- 'zh-CN': '刚刚',
55
- 'zh-TW': '剛剛',
56
- en: 'now',
57
- };
58
50
  /** Future timestamps are treated as age zero and therefore display as just now. */
59
51
  function relativeAgeMs(ts, now) {
60
52
  return Math.max(0, now - ts);
@@ -162,7 +154,7 @@ export function formatCompactTimestamp(ts, now, locale) {
162
154
  export function formatSidebarTimestamp(ts, now, locale) {
163
155
  const diffMs = relativeAgeMs(ts, now);
164
156
  if (diffMs < JUST_NOW_MS)
165
- return SIDEBAR_JUST_NOW[locale];
157
+ return JUST_NOW[locale];
166
158
  const bucket = sidebarTimeBucket(diffMs);
167
159
  return `${bucket.value}${bucket.suffix}`;
168
160
  }
@@ -94,6 +94,7 @@
94
94
  "./incognito": "./dist/incognito.js",
95
95
  "./backend-types": "./dist/backend-types.js",
96
96
  "./codex-model-compatibility": "./dist/codex-model-compatibility.js",
97
+ "./openai-urls": "./dist/openai-urls.js",
97
98
  "./llm-connections": "./dist/llm-connections.js",
98
99
  "./provider-registry": "./dist/provider-registry.js",
99
100
  "./model-catalog": "./dist/model-catalog.js",
@@ -401,11 +401,13 @@ export class AiSdkTurn {
401
401
  runId;
402
402
  orchestration;
403
403
  toolRuntime;
404
+ startedAt;
404
405
  constructor(deps, request) {
405
406
  this.deps = deps;
406
407
  this.request = request;
407
408
  this.turnId = request.turnId;
408
409
  this.runId = request.runId;
410
+ this.startedAt = deps.now();
409
411
  this.orchestration =
410
412
  request.orchestration ??
411
413
  resolveEffectiveOrchestration(deps.backend.header.orchestrationMode, undefined);
@@ -1127,19 +1129,16 @@ export class AiSdkTurn {
1127
1129
  };
1128
1130
  };
1129
1131
  const dynamicContextMessages = (resolvedSystemPrompt.contexts ?? []).map(({ text }) => ({ role: 'user', content: text }));
1130
- const contextualRequestMessages = dynamicContextMessages.length === 0
1131
- ? requestMessages
1132
- : [...requestMessages, ...dynamicContextMessages];
1133
1132
  const shaped = requestProjection
1134
1133
  ? await requestProjection({
1135
1134
  completedSteps: completedProviderSteps,
1136
1135
  stepNumber: runtimeSteps,
1137
1136
  model,
1138
- messages: contextualRequestMessages,
1137
+ messages: requestMessages,
1139
1138
  resolveDispatch,
1140
1139
  })
1141
1140
  : undefined;
1142
- const projectedMessages = shaped?.messages ?? contextualRequestMessages;
1141
+ const projectedMessages = shaped?.messages ?? requestMessages;
1143
1142
  const activeToolsForRequest = resolveDispatch(shaped?.activeTools).activeTools;
1144
1143
  const requestSystemPrompt = joinPromptFragments([
1145
1144
  requestSystemPromptBase,
@@ -1184,9 +1183,11 @@ export class AiSdkTurn {
1184
1183
  let attemptSawReplayBarrier = false;
1185
1184
  const attemptHasNoObservableOutput = () => !attemptSawVisibleContent && !attemptSawToolActivity && !attemptSawReplayBarrier;
1186
1185
  const attemptCanReplay = () => !attemptSawToolActivity && !attemptSawReplayBarrier;
1187
- this.memorySourceMessages = [...attemptMessages];
1186
+ // Request-only facts must survive history replacement and overflow recovery.
1187
+ const dispatchMessages = [...attemptMessages, ...dynamicContextMessages];
1188
+ this.memorySourceMessages = dispatchMessages;
1188
1189
  this.memorySourceEventMessagePositions =
1189
- this.deps.messageProjection.memoryEventMessagePositions(attemptMessages);
1190
+ this.deps.messageProjection.memoryEventMessagePositions(dispatchMessages);
1190
1191
  this.memorySourceSystemPrompt = requestSystemPrompt;
1191
1192
  this.memorySourceTools = modelTools;
1192
1193
  this.memorySourceActiveTools = [...activeToolsForRequest];
@@ -1208,7 +1209,7 @@ export class AiSdkTurn {
1208
1209
  const historyCompactBoundary = requestHistoryCompactBoundary();
1209
1210
  result = await this.deps.modelAdapter.startStream({
1210
1211
  model,
1211
- messages: attemptMessages,
1212
+ messages: dispatchMessages,
1212
1213
  tools: modelTools,
1213
1214
  activeTools: activeToolsForRequest,
1214
1215
  onStreamActivity: () => requestWatchdog?.markActivity(),
@@ -2349,6 +2350,7 @@ export class AiSdkTurn {
2349
2350
  sessionId: this.deps.backend.sessionId,
2350
2351
  turnId,
2351
2352
  cwd: this.deps.backend.header.cwd,
2353
+ turnStartedAt: this.startedAt,
2352
2354
  emitSkillCatalogTrace: (message, data) => this.runTrace?.emit('skill', 'skill_catalog_built', message, data),
2353
2355
  });
2354
2356
  return typeof resolved === 'string' || resolved === undefined
@@ -382,7 +382,7 @@ export function buildBuiltinTools(options = {}) {
382
382
  {
383
383
  name: 'Glob',
384
384
  activityKind: 'search',
385
- description: 'Find file and directory paths matching a glob pattern. Case sensitivity follows platform defaults. Hidden entries require an explicit dot-prefixed pattern component. Returns at most 200 matches in traversal order, without sorting.',
385
+ description: 'Find file and directory paths matching a glob pattern. Case sensitivity follows platform defaults. Hidden entries require an explicit dot-prefixed pattern component. Returns at most 200 matches in traversal order, without sorting. `truncated` is true when more matches exist or an error prevents confirming whether more matches exist after the limit.',
386
386
  parameters: z.object({
387
387
  pattern: z
388
388
  .string()
@@ -400,7 +400,7 @@ export function buildBuiltinTools(options = {}) {
400
400
  });
401
401
  if (result.kind !== 'glob')
402
402
  throw internalFilesystemReadFailure('Glob', 'no file list came back', 'no files match the pattern');
403
- return { files: result.files };
403
+ return { files: result.files, truncated: result.truncated };
404
404
  },
405
405
  },
406
406
  {
@@ -524,12 +524,13 @@ function createWorkspaceFilesystemExecutor(workspace) {
524
524
  label: 'Glob cwd',
525
525
  scope,
526
526
  });
527
- const { files } = await workspace.globFiles({
527
+ const { files, truncated } = await workspace.globFiles({
528
528
  cwd: base,
529
529
  pattern: operation.pattern,
530
530
  ...(operation.limit !== undefined ? { limit: operation.limit } : {}),
531
+ ...(abortSignal ? { abortSignal } : {}),
531
532
  });
532
- return { kind: 'glob', files };
533
+ return { kind: 'glob', files, truncated };
533
534
  }
534
535
  case 'grep': {
535
536
  const { path } = await workspace.resolveExistingPath({
@@ -20,9 +20,10 @@ import { z } from 'zod';
20
20
  import { readContinuationSchema, readPageSchema } from '../read-page.js';
21
21
  import { validateSandboxBoundaryExpansion } from '@maka/core/sandbox-boundary';
22
22
  import { GREP_MAX_LINES, GREP_MAX_LINES_PER_FILE, GREP_MAX_MATCH_BYTES } from '../grep-search.js';
23
- // v10 adds bounded Read pages to v9's exact Grep counts. Older workers cannot
24
- // satisfy the combined result contract and must be rejected at the handshake.
25
- export const FILESYSTEM_WORKER_PROTOCOL_VERSION = 10;
23
+ // v10 adds bounded Read pages to v9's exact Grep counts; v11 adds Glob's
24
+ // truncation flag to v10's result contract. Older workers cannot satisfy the
25
+ // combined result contract and must be rejected at the handshake.
26
+ export const FILESYSTEM_WORKER_PROTOCOL_VERSION = 11;
26
27
  /** The single authority on which operation kinds are writes. Shared by the
27
28
  * client (permission/identity decisions) and the worker (operation guards) so
28
29
  * the set cannot drift. */
@@ -206,7 +207,9 @@ export const FilesystemWorkerResultSchema = z.discriminatedUnion('kind', [
206
207
  diff: z.string().optional(),
207
208
  })
208
209
  .strict(),
209
- z.object({ kind: z.literal('glob'), files: z.array(z.string()) }).strict(),
210
+ z
211
+ .object({ kind: z.literal('glob'), files: z.array(z.string()), truncated: z.boolean() })
212
+ .strict(),
210
213
  z
211
214
  .object({
212
215
  kind: z.literal('grep'),
@@ -22,16 +22,24 @@ import { globIterate } from 'glob';
22
22
  export async function globFiles(input) {
23
23
  let failure;
24
24
  const directories = new Set([resolve(input.cwd)]);
25
+ const files = [];
26
+ const limit = input.limit ?? 200;
27
+ let probingOverflow = false;
28
+ let probeIncomplete = false;
25
29
  function record(error, path) {
26
30
  // Speculative literal components may miss. A directory already admitted by
27
31
  // cwd, stat, or enumeration disappearing instead makes this walk incomplete.
28
32
  if (directories.has(resolve(path)) || (error.code !== 'ENOENT' && error.code !== 'ENOTDIR')) {
29
- failure ??= error;
33
+ if (probingOverflow)
34
+ probeIncomplete = true;
35
+ else
36
+ failure ??= error;
30
37
  }
31
38
  }
32
- const files = [];
39
+ let truncated = false;
33
40
  for await (const file of globIterate(input.pattern, {
34
41
  cwd: input.cwd,
42
+ signal: input.abortSignal,
35
43
  ignore: { childrenIgnored: (entry) => entry.isSymbolicLink() },
36
44
  fs: {
37
45
  readdir(path, options, callback) {
@@ -62,13 +70,18 @@ export async function globFiles(input) {
62
70
  },
63
71
  },
64
72
  })) {
73
+ if (files.length >= limit) {
74
+ // One match past the cap is the only proof the pattern had more to give.
75
+ truncated = true;
76
+ break;
77
+ }
65
78
  if (failure)
66
79
  throw failure;
67
80
  files.push(file);
68
- if (files.length >= (input.limit ?? 200))
69
- break;
81
+ if (files.length >= limit)
82
+ probingOverflow = true;
70
83
  }
71
84
  if (failure)
72
85
  throw failure;
73
- return { files };
86
+ return { files, truncated: truncated || probeIncomplete };
74
87
  }
@@ -27,7 +27,7 @@ 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 { modelOverride, resolveThinkingLevel, supportsCustomFastServiceTier, thinkingOptionsForModel, thinkingVariantsForConnection, } from '@maka/core/model-thinking';
30
+ import { modelOverride, resolveThinkingLevel, THINKING_LEVELS, 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';
@@ -349,6 +349,32 @@ function claudeThinkingMode(providerType, modelId, thinkingOptions) {
349
349
  ? 'adaptive'
350
350
  : 'legacy';
351
351
  }
352
+ /**
353
+ * The level that asks this model for the least reasoning it accepts, for
354
+ * callers that want none but cannot rely on `'off'` surviving
355
+ * `resolveThinkingLevel`.
356
+ *
357
+ * `'off'` is used when the model declares it. It is also used when the model
358
+ * declares no levels, or is a Claude model on Anthropic Messages, because on
359
+ * those paths an omitted parameter already means no extended thinking, while
360
+ * the lowest effort would switch adaptive thinking on. That holds for Claude,
361
+ * not for every Anthropic Messages route: Kimi's K3 and kimi-for-coding think
362
+ * by default when no level is sent.
363
+ *
364
+ * Everywhere else a dropped `'off'` omits the effort parameter, and the
365
+ * provider then runs its default reasoning (medium on GPT-5, GPT-6 and o3,
366
+ * dynamic on Gemini 3). So this returns the model's lowest declared level
367
+ * instead, which the wire builders send explicitly.
368
+ */
369
+ export function leastReasoningThinkingLevel(connection, modelId, runtime = resolveModelRuntime(connection, modelId)) {
370
+ const variants = thinkingVariantsForConnection(connection, modelId);
371
+ if (variants.length === 0 || variants.includes('off'))
372
+ return 'off';
373
+ if (runtime.wire === 'anthropic-messages' && claudeFamilyId(modelId).startsWith('claude-')) {
374
+ return 'off';
375
+ }
376
+ return THINKING_LEVELS.find((level) => variants.includes(level)) ?? 'off';
377
+ }
352
378
  export function buildProviderOptions(connection, modelId, thinkingLevel, runtime = resolveModelRuntime(connection, modelId)) {
353
379
  return withParallelToolCallOptions(connection, modelId, buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtime), runtime);
354
380
  }
@@ -16,6 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { openAiBaseUrl } from '@maka/core/openai-urls';
19
20
  import { PROVIDER_REGISTRY, providerFallbackModelIds, effectiveBaseUrl, isModelModality, providerAuthSupportsApiKey, } from '@maka/core/llm-connections';
20
21
  import { CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, CONNECTION_MODEL_ID_MAX_LENGTH, decodeConnectionModels, } from '@maka/core/runtime-policy';
21
22
  import { anthropicV1Url, googleApiUrl } from './provider-urls.js';
@@ -107,7 +108,7 @@ async function fetchProviderModelsStrict(connection, apiKey, fetchFn) {
107
108
  }
108
109
  case 'openai':
109
110
  case 'openai-compatible': {
110
- const r = await fetchForConnectionEffect(fetchFn, modelListUrl(baseUrl, discovery.path, discovery.query), {
111
+ const r = await fetchForConnectionEffect(fetchFn, modelListUrl(openAiBaseUrl(baseUrl), discovery.path, discovery.query), {
111
112
  headers: {
112
113
  'content-type': 'application/json',
113
114
  ...(apiKey &&
@@ -20,7 +20,7 @@ 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
22
  import { declaredModelApiProtocol, modelOverride, } from '@maka/core/model-thinking';
23
- import { anthropicV1BaseUrl, googleV1BetaBaseUrl, openAiResponsesBaseUrl, } from './provider-urls.js';
23
+ import { anthropicV1BaseUrl, googleV1BetaBaseUrl, openAiResponsesBaseUrl, openAiChatBaseUrl, } from './provider-urls.js';
24
24
  import { resolveApplyPatchProfile } from './apply-patch-profile.js';
25
25
  export function resolveModelRuntime(connection, modelId) {
26
26
  // Model metadata cannot reactivate a retired provider.
@@ -57,10 +57,12 @@ export function resolveModelRuntime(connection, modelId) {
57
57
  : adapter.kind === 'google' && adapter.normalizeBaseUrl !== false
58
58
  ? googleV1BetaBaseUrl(resolvedBaseUrl)
59
59
  : adapter.kind === 'openai-compatible' && adapter.normalizeBaseUrl
60
- ? anthropicV1BaseUrl(resolvedBaseUrl)
60
+ ? anthropicV1BaseUrl(openAiChatBaseUrl(resolvedBaseUrl))
61
61
  : wire === 'openai-responses' && resolvedBaseUrl
62
62
  ? openAiResponsesBaseUrl(resolvedBaseUrl)
63
- : resolvedBaseUrl;
63
+ : wire === 'openai-chat' && resolvedBaseUrl
64
+ ? openAiChatBaseUrl(resolvedBaseUrl)
65
+ : resolvedBaseUrl;
64
66
  const parallelToolCalls = resolveParallelToolCalls(connection, modelId, baseAdapter);
65
67
  return {
66
68
  ...call,
@@ -49,24 +49,7 @@ export function googleApiUrl(baseUrl, path, apiKey) {
49
49
  const cleanPath = path.startsWith('/') ? path : `/${path}`;
50
50
  return `${googleV1BetaBaseUrl(baseUrl)}${cleanPath}?key=${encodeURIComponent(apiKey)}`;
51
51
  }
52
- /** Normalize an Open Responses endpoint without assuming a `/v1` prefix. */
53
- export function openResponsesUrl(baseUrl) {
54
- const url = new URL(baseUrl);
55
- const basePath = url.pathname.replace(/\/+$/, '').replace(/\/responses$/i, '');
56
- url.pathname = `${basePath}/responses`;
57
- return url.toString();
58
- }
59
- /**
60
- * Inverse of {@link openResponsesUrl} for the native OpenAI adapter: it
61
- * appends `/responses` internally, so an endpoint-form override
62
- * (`…/v1/responses`, which the probe accepts) must be reduced back to its
63
- * base or the model request lands on `/responses/responses` (#2972).
64
- */
65
- export function openAiResponsesBaseUrl(baseUrl) {
66
- const url = new URL(baseUrl);
67
- url.pathname = url.pathname.replace(/\/+$/, '').replace(/\/responses$/i, '');
68
- return url.toString();
69
- }
52
+ export { openAiChatBaseUrl, openAiChatUrl, openAiResponsesBaseUrl, openResponsesUrl, } from '@maka/core/openai-urls';
70
53
  function stripTrailing(u) {
71
54
  return u.replace(/\/+$/, '');
72
55
  }
@@ -21,6 +21,7 @@
21
21
  *
22
22
  * Agent-facing access to the Runtime Host-owned ScheduledTask catalog.
23
23
  */
24
+ import { resolve } from 'node:path';
24
25
  import { z } from 'zod';
25
26
  import { SCHEDULED_TASK_CRON_MAX_CHARS, SCHEDULED_TASK_INTENT_MAX_CHARS, SCHEDULED_TASK_MAX_INTERVAL_SECONDS, SCHEDULED_TASK_TITLE_MAX_CHARS, } from '@maka/core/scheduled-task';
26
27
  export const SCHEDULED_TASK_TOOL_NAME = 'ScheduledTask';
@@ -108,6 +109,7 @@ export function buildScheduledTaskTool(deps) {
108
109
  if (tasks.length === 0)
109
110
  return `No scheduled tasks.\n${clockLine()}`;
110
111
  return [
112
+ `Scheduled task catalog (${tasks.length}):`,
111
113
  ...tasks.map((task) => `- ${task.id} | ${task.title} | ${task.status} | next=${fireLine(task.nextFireAt)} | effect=${task.effect.kind}`),
112
114
  clockLine(),
113
115
  ].join('\n');
@@ -116,17 +118,40 @@ export function buildScheduledTaskTool(deps) {
116
118
  if (!input.title || !input.intentBody || !input.schedule) {
117
119
  return `create requires title, intentBody, and schedule\n${clockLine()}`;
118
120
  }
121
+ const effect = input.effect ?? 'session_resume';
122
+ const resolvedCwd = ctx.cwd?.trim() ? resolve(ctx.cwd) : '';
123
+ if (effect !== 'notify_local' && !resolvedCwd) {
124
+ return `create ${effect} requires a project working directory\n${clockLine()}`;
125
+ }
119
126
  const result = await deps.authority.create({
120
127
  title: input.title,
121
128
  intentBody: input.intentBody,
122
129
  schedule: input.schedule,
123
- effect: input.effect ?? 'session_resume',
130
+ effect,
124
131
  sessionId,
125
132
  ...(input.maxFires !== undefined ? { maxFires: input.maxFires } : {}),
126
133
  });
127
134
  if ('error' in result)
128
135
  return `${result.error}\n${clockLine()}`;
129
- return `Scheduled task created: ${result.title} (${result.id})\nnextFireAt=${fireLine(result.nextFireAt)}\neffect=${result.effect.kind}\n${clockLine()}`;
136
+ let catalog;
137
+ try {
138
+ catalog = await deps.authority.list();
139
+ }
140
+ catch {
141
+ return `Scheduled task may have been created, but catalog verification was unavailable for ${result.id}; query mode=list before retrying to avoid duplicates\n${clockLine()}`;
142
+ }
143
+ const persisted = catalog.find((task) => task.id === result.id);
144
+ if (!persisted) {
145
+ return `Scheduled task may have been created, but catalog verification could not find ${result.id}; query mode=list before retrying to avoid duplicates\n${clockLine()}`;
146
+ }
147
+ const taskCwd = persisted.effect.kind === 'agent_run' ? persisted.effect.execution.cwd : resolvedCwd;
148
+ return [
149
+ `Scheduled task created and verified in Maka catalog: ${persisted.title} (${persisted.id})`,
150
+ `nextFireAt=${fireLine(persisted.nextFireAt)}`,
151
+ `effect=${persisted.effect.kind}`,
152
+ `cwd=${taskCwd}`,
153
+ clockLine(),
154
+ ].join('\n');
130
155
  }
131
156
  if (!input.id)
132
157
  return `${input.mode} requires id`;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import { randomUUID } from 'node:crypto';
20
20
  import { PROVIDER_REGISTRY, effectiveBaseUrl, providerDefaultsOf, providerFallbackModelIds, connectionModelsEnumerateAccount, connectionEnabledModelIds, } from '@maka/core/llm-connections';
21
- import { openResponsesUrl } from './provider-urls.js';
21
+ import { openAiChatUrl, openResponsesUrl } from './provider-urls.js';
22
22
  import { resolveModelRuntime } from './model-runtime.js';
23
23
  import { fetchGitHubCopilotModels } from './model-fetcher.js';
24
24
  import { CONNECTION_EFFECT_ERROR_BODY_MAX_BYTES, ConnectionEffectFetchError, fetchForConnectionEffect, } from './connection-effect-fetch.js';
@@ -237,7 +237,7 @@ async function probeOpenAI(connection, baseUrl, apiKey, model, t0, fetchFn, time
237
237
  // chat with the provider error class.
238
238
  return { ok: true, latencyMs: Date.now() - t0, modelTested: model };
239
239
  }
240
- const r = await fetchForConnectionEffect(fetchFn, `${stripTrailing(baseUrl)}/chat/completions`, {
240
+ const r = await fetchForConnectionEffect(fetchFn, openAiChatUrl(baseUrl), {
241
241
  method: 'POST',
242
242
  headers: {
243
243
  ...requestHeaders,
@@ -3138,14 +3138,20 @@ Ze.glob = Ze;
3138
3138
  async function globFiles(input2) {
3139
3139
  let failure2;
3140
3140
  const directories = /* @__PURE__ */ new Set([resolve(input2.cwd)]);
3141
+ const files = [];
3142
+ const limit = input2.limit ?? 200;
3143
+ let probingOverflow = false;
3144
+ let probeIncomplete = false;
3141
3145
  function record2(error62, path2) {
3142
3146
  if (directories.has(resolve(path2)) || error62.code !== "ENOENT" && error62.code !== "ENOTDIR") {
3143
- failure2 ??= error62;
3147
+ if (probingOverflow) probeIncomplete = true;
3148
+ else failure2 ??= error62;
3144
3149
  }
3145
3150
  }
3146
- const files = [];
3151
+ let truncated = false;
3147
3152
  for await (const file2 of es(input2.pattern, {
3148
3153
  cwd: input2.cwd,
3154
+ signal: input2.abortSignal,
3149
3155
  ignore: { childrenIgnored: (entry) => entry.isSymbolicLink() },
3150
3156
  fs: {
3151
3157
  readdir(path2, options, callback) {
@@ -3172,12 +3178,16 @@ async function globFiles(input2) {
3172
3178
  }
3173
3179
  }
3174
3180
  })) {
3181
+ if (files.length >= limit) {
3182
+ truncated = true;
3183
+ break;
3184
+ }
3175
3185
  if (failure2) throw failure2;
3176
3186
  files.push(file2);
3177
- if (files.length >= (input2.limit ?? 200)) break;
3187
+ if (files.length >= limit) probingOverflow = true;
3178
3188
  }
3179
3189
  if (failure2) throw failure2;
3180
- return { files };
3190
+ return { files, truncated: truncated || probeIncomplete };
3181
3191
  }
3182
3192
 
3183
3193
  // src/filesystem-worker/operations.ts
@@ -24726,7 +24736,7 @@ function sniffImageMime(bytes) {
24726
24736
  }
24727
24737
 
24728
24738
  // src/filesystem-worker/protocol.ts
24729
- var FILESYSTEM_WORKER_PROTOCOL_VERSION = 10;
24739
+ var FILESYSTEM_WORKER_PROTOCOL_VERSION = 11;
24730
24740
  function operationAccess(kind) {
24731
24741
  return kind === "write" || kind === "apply_patch" || kind === "edit" || kind === "format_json" ? "write" : "read";
24732
24742
  }
@@ -24864,7 +24874,7 @@ var FilesystemWorkerResultSchema = external_exports.discriminatedUnion("kind", [
24864
24874
  changed: external_exports.boolean(),
24865
24875
  diff: external_exports.string().optional()
24866
24876
  }).strict(),
24867
- external_exports.object({ kind: external_exports.literal("glob"), files: external_exports.array(external_exports.string()) }).strict(),
24877
+ external_exports.object({ kind: external_exports.literal("glob"), files: external_exports.array(external_exports.string()), truncated: external_exports.boolean() }).strict(),
24868
24878
  external_exports.object({
24869
24879
  kind: external_exports.literal("grep"),
24870
24880
  matchedLines: external_exports.number().int().nonnegative(),
@@ -64,7 +64,9 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1;
64
64
  export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
65
65
  // Increment when the same protocol version no longer guarantees safe Client-Host
66
66
  // interoperability. Mismatches are rejected before domain commands are admitted.
67
- export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 189;
67
+ export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 191;
68
+ // 191: Session catalog change frames can carry attention events.
69
+ // 190: ScheduledTask execution templates preserve toolMode; older peers reject it.
68
70
  // 189: Remove form_interaction transcript messages and the transcript_changed close reason.
69
71
  // 188: Session capability replacement can require an atomic idle root check;
70
72
  // complete MCP configuration identities fence conflicting providers across ACP clients.
@@ -22,6 +22,7 @@ import { isOrchestrationMode } from '@maka/core/orchestration';
22
22
  import { isPermissionMode } from '@maka/core/permission';
23
23
  import { isScheduledTaskStatus, SCHEDULED_TASK_CHAT_ID_MAX_CHARS, SCHEDULED_TASK_CRON_MAX_CHARS, SCHEDULED_TASK_INTENT_MAX_CHARS, SCHEDULED_TASK_MAX_DELAY_MS, SCHEDULED_TASK_MAX_INTERVAL_SECONDS, SCHEDULED_TASK_MIN_INTERVAL_SECONDS, SCHEDULED_TASK_RUN_HISTORY_LIMIT, SCHEDULED_TASK_RUN_MESSAGE_MAX_CHARS, SCHEDULED_TASK_SESSION_ID_MAX_CHARS, SCHEDULED_TASK_TITLE_MAX_CHARS, } from '@maka/core/scheduled-task';
24
24
  import { isThinkingLevel } from '@maka/core/model-thinking';
25
+ import { isToolMode } from '@maka/core/tool-mode';
25
26
  import { requireCount, requireEncodedByteLimit, requireEntityId, requireExactRecord, requireRecord, requireShapedRecord, } from './codec.js';
26
27
  import { invalidProtocolFrame } from './errors.js';
27
28
  import { defineHostPathOperation, defineOperation } from './operation-spec.js';
@@ -393,7 +394,7 @@ function decodeExecution(value, requireConnectionId = false) {
393
394
  'permissionMode',
394
395
  'collaborationMode',
395
396
  'orchestrationMode',
396
- ], ['projectId', 'thinkingLevel', 'backend', 'llmConnectionId']);
397
+ ], ['projectId', 'thinkingLevel', 'backend', 'llmConnectionId', 'toolMode']);
397
398
  if (requireConnectionId && !Object.hasOwn(execution, 'llmConnectionId')) {
398
399
  throw invalidProtocolFrame('ScheduledTask execution requires Connection id');
399
400
  }
@@ -409,6 +410,9 @@ function decodeExecution(value, requireConnectionId = false) {
409
410
  if (Object.hasOwn(execution, 'thinkingLevel') && !isThinkingLevel(execution.thinkingLevel)) {
410
411
  throw invalidProtocolFrame('Invalid ScheduledTask thinking level');
411
412
  }
413
+ if (Object.hasOwn(execution, 'toolMode') && !isToolMode(execution.toolMode)) {
414
+ throw invalidProtocolFrame('Invalid ScheduledTask tool mode');
415
+ }
412
416
  if (Object.hasOwn(execution, 'projectId') &&
413
417
  execution.projectId !== null &&
414
418
  typeof execution.projectId !== 'string') {
@@ -416,6 +420,9 @@ function decodeExecution(value, requireConnectionId = false) {
416
420
  }
417
421
  return {
418
422
  cwd: boundedText(execution.cwd, 'ScheduledTask cwd', 4_096, true),
423
+ ...(Object.hasOwn(execution, 'toolMode')
424
+ ? { toolMode: execution.toolMode }
425
+ : {}),
419
426
  ...(Object.hasOwn(execution, 'projectId')
420
427
  ? { projectId: execution.projectId }
421
428
  : {}),
@@ -16,16 +16,34 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
- import { requireCount, requireExactRecord, requireId } from './codec.js';
19
+ import { requireCount, requireId, requireShapedRecord, requireUtf8String } from './codec.js';
20
+ import { invalidProtocolFrame } from './errors.js';
21
+ export const SESSION_ATTENTION_BODY_MAX_BYTES = 2_048;
22
+ function decodeSessionAttention(value) {
23
+ const attention = requireShapedRecord(value, 'Session attention', ['kind', 'eventId'], ['body']);
24
+ if (attention.kind !== 'completed' &&
25
+ attention.kind !== 'errored' &&
26
+ attention.kind !== 'waiting') {
27
+ throw invalidProtocolFrame('Invalid Session attention kind');
28
+ }
29
+ return {
30
+ kind: attention.kind,
31
+ eventId: requireId(attention.eventId, 'Session attention eventId'),
32
+ ...(attention.body === undefined
33
+ ? {}
34
+ : {
35
+ body: requireUtf8String(attention.body, 'Session attention body', SESSION_ATTENTION_BODY_MAX_BYTES),
36
+ }),
37
+ };
38
+ }
20
39
  export function decodeSessionCatalogChangedFrame(value) {
21
- const frame = requireExactRecord(value, 'Session catalog changed frame', [
22
- 'kind',
23
- 'revision',
24
- 'sessionId',
25
- ]);
40
+ const frame = requireShapedRecord(value, 'Session catalog changed frame', ['kind', 'revision', 'sessionId'], ['attention']);
26
41
  return {
27
42
  kind: 'session.catalog.changed',
28
43
  revision: requireCount(frame.revision, 'Session catalog change revision'),
29
44
  sessionId: requireId(frame.sessionId, 'sessionId'),
45
+ ...(frame.attention === undefined
46
+ ? {}
47
+ : { attention: decodeSessionAttention(frame.attention) }),
30
48
  };
31
49
  }
@@ -723,7 +723,20 @@ export async function createExecutionRuntimeHostComposition(context, options = {
723
723
  canonicalPermissionOutcomes,
724
724
  ensureTranscriptLedger: (sessionId) => requireSessionManager(manager).ensureTranscriptLedgerForRead(sessionId),
725
725
  });
726
- continuity = new SessionContinuityCoordinator(context.hostEpoch, (sessionId) => canonicalProjectionReader.read(sessionId), sessionAdmission, context.requestDrain, transcriptReader, (sessionId) => hostChanges.publishSessionCatalog(sessionId), context.sessionAccessAuthority);
726
+ continuity = new SessionContinuityCoordinator(context.hostEpoch, (sessionId) => canonicalProjectionReader.read(sessionId), sessionAdmission, context.requestDrain, transcriptReader, async (sessionId, attention) => {
727
+ if (attention) {
728
+ try {
729
+ if ((await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.privacy.incognitoActive) {
730
+ attention = undefined;
731
+ }
732
+ }
733
+ catch (error) {
734
+ attention = undefined;
735
+ console.warn('[runtime-host] Could not read notification privacy policy', error);
736
+ }
737
+ }
738
+ hostChanges.publishSessionCatalog(sessionId, attention);
739
+ }, context.sessionAccessAuthority);
727
740
  const continuityCoordinator = continuity;
728
741
  const planStore = observeInteractivePlanStoreWriter(openedPlanStore, (sessionId) => continuityCoordinator.enqueueSessionDomainChanged(sessionId, 'plan'), context.requestDrain);
729
742
  unsubscribeTranscriptChanges = stores.sessionStore.subscribeTranscriptChanges((sessionId) => {
@@ -774,8 +787,8 @@ export async function createExecutionRuntimeHostComposition(context, options = {
774
787
  preflightSessionSnapshot: (sessionId, interactionProjection) => canonicalProjectionReader.fitsCandidate(sessionId, {
775
788
  interactions: interactionProjection,
776
789
  }),
777
- refreshCanonicalContinuity: async (sessionId, admission) => {
778
- await continuityCoordinator.refreshCanonical(sessionId, admission);
790
+ refreshCanonicalContinuity: async (sessionId, admission, attention) => {
791
+ await continuityCoordinator.refreshCanonical(sessionId, admission, attention);
779
792
  sessionAdmission.detach(() => workHubResults?.notify(sessionId));
780
793
  },
781
794
  onPoison: (error) => {