maka-agent 0.2.0-dev.6.20260830 → 0.2.0-dev.9.20260831

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 (86) hide show
  1. package/dist/cli-core.js +11 -0
  2. package/dist/runtime-host-cli.js +44 -0
  3. package/dist/runtime-host-installed-update-activator.js +70 -33
  4. package/dist/runtime-host-installed-update-coordinator.js +11 -96
  5. package/dist/runtime-host-lifecycle-transaction.js +2 -0
  6. package/dist/runtime-host-local-handoff.js +169 -38
  7. package/dist/runtime-host-local-source-retirement.js +103 -0
  8. package/dist/runtime-host-local-target-activation.js +141 -0
  9. package/dist/runtime-host-peer-management-command.js +10 -4
  10. package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
  11. package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
  12. package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
  13. package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
  14. package/node_modules/@maka/core/dist/agent-run.js +0 -2
  15. package/node_modules/@maka/core/dist/artifacts.js +23 -15
  16. package/node_modules/@maka/core/dist/durable-tool-result-projection.js +124 -0
  17. package/node_modules/@maka/core/dist/foreign-session.js +1 -1
  18. package/node_modules/@maka/core/dist/llm-connections.js +20 -0
  19. package/node_modules/@maka/core/dist/runtime-event.js +28 -3
  20. package/node_modules/@maka/core/dist/session-name.js +0 -1
  21. package/node_modules/@maka/core/dist/task-ledger.js +6 -134
  22. package/node_modules/@maka/core/dist/usage-record-schema.js +1 -0
  23. package/node_modules/@maka/core/package.json +1 -0
  24. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +97 -133
  25. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +4 -18
  26. package/node_modules/@maka/runtime/dist/context-budget.js +0 -1
  27. package/node_modules/@maka/runtime/dist/conversation-copy.js +67 -0
  28. package/node_modules/@maka/runtime/dist/durable-tool-result-projection.js +390 -0
  29. package/node_modules/@maka/runtime/dist/model-history.js +12 -39
  30. package/node_modules/@maka/runtime/dist/plan-mode.js +0 -65
  31. package/node_modules/@maka/runtime/dist/recovery-resolver.js +18 -14
  32. package/node_modules/@maka/runtime/dist/run-trace.js +0 -10
  33. package/node_modules/@maka/runtime/dist/runtime-kernel.js +0 -1
  34. package/node_modules/@maka/runtime/dist/sandbox/index.js +0 -1
  35. package/node_modules/@maka/runtime/dist/sandbox/linux-sandbox.js +0 -12
  36. package/node_modules/@maka/runtime/dist/sandbox/macos-seatbelt.js +0 -12
  37. package/node_modules/@maka/runtime/dist/sandbox/sandbox-manager.js +0 -35
  38. package/node_modules/@maka/runtime/dist/sandbox/windows-sandbox.js +0 -12
  39. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +20 -11
  40. package/node_modules/@maka/runtime/dist/session-manager.js +0 -170
  41. package/node_modules/@maka/runtime/dist/shell-detect.js +3 -7
  42. package/node_modules/@maka/runtime/dist/shell-run-contract.js +0 -1
  43. package/node_modules/@maka/runtime/dist/shell-run-manager.js +1 -39
  44. package/node_modules/@maka/runtime/dist/shell-tools.js +1 -1
  45. package/node_modules/@maka/runtime/dist/task-ledger-tools.js +2 -2
  46. package/node_modules/@maka/runtime/dist/tool-runtime.js +118 -71
  47. package/node_modules/@maka/runtime/package.json +1 -1
  48. package/node_modules/@maka/runtime-host/dist/candidate-entry.js +6 -1
  49. package/node_modules/@maka/runtime-host/dist/candidate-launch-owner-guard.js +13 -0
  50. package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +4 -1
  51. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +27 -1
  52. package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
  53. package/node_modules/@maka/runtime-host/dist/client/launcher.js +8 -2
  54. package/node_modules/@maka/runtime-host/dist/client/peer-client.js +11 -1
  55. package/node_modules/@maka/runtime-host/dist/peer-mesh/index.js +1 -1
  56. package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +394 -113
  57. package/node_modules/@maka/runtime-host/dist/peer-mesh/store.js +90 -21
  58. package/node_modules/@maka/runtime-host/dist/protocol/index.js +8 -1
  59. package/node_modules/@maka/runtime-host/dist/protocol/oauth.js +60 -7
  60. package/node_modules/@maka/runtime-host/dist/protocol/usage-pricing.js +4 -0
  61. package/node_modules/@maka/runtime-host/dist/server/artifact-coordinator.js +2 -4
  62. package/node_modules/@maka/runtime-host/dist/server/candidate.js +3 -0
  63. package/node_modules/@maka/runtime-host/dist/server/client-capability-recovery.js +10 -7
  64. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +6 -9
  65. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +9 -7
  66. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +10 -0
  67. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +2 -58
  68. package/node_modules/@maka/runtime-host/dist/server/oauth-coordinator.js +91 -42
  69. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +10 -1
  70. package/node_modules/@maka/runtime-host/dist/server/usage-pricing-coordinator.js +45 -5
  71. package/node_modules/@maka/storage/dist/artifact-attachments.js +62 -11
  72. package/node_modules/@maka/storage/dist/artifact-store.js +11 -0
  73. package/node_modules/@maka/storage/dist/artifact-stores.js +4 -1
  74. package/node_modules/@maka/storage/dist/quiescent-session-snapshot.js +1154 -0
  75. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +36 -0
  76. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +213 -46
  77. package/node_modules/@maka/storage/dist/runtime-policy/document-io.js +1 -1
  78. package/node_modules/@maka/storage/dist/runtime-policy/oauth-login-receipt-document.js +186 -0
  79. package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +120 -1
  80. package/node_modules/@maka/storage/dist/runtime-policy-stores.js +2 -1
  81. package/node_modules/@maka/storage/dist/session-bundle-ustar.js +12 -0
  82. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +5 -0
  83. package/package.json +1 -1
  84. package/node_modules/@maka/runtime/dist/sandbox/diagnostics.js +0 -285
  85. package/node_modules/@maka/runtime/dist/system-prompt/sandbox-context-prompt.js +0 -77
  86. package/node_modules/@maka/runtime/dist/system-prompt/session-environment-prompt.js +0 -47
@@ -128,41 +128,6 @@ export class SandboxManager {
128
128
  return false;
129
129
  return backend.canEnforceProfile?.(input.profile) ?? true;
130
130
  }
131
- probe(request) {
132
- const selected = this.selectInitial({
133
- profile: request.command.profile,
134
- preference: request.preference,
135
- platform: request.platform,
136
- });
137
- if (!selected.ok)
138
- return selected;
139
- if (selected.sandboxType === 'none') {
140
- return {
141
- ok: true,
142
- executable: request.command.program,
143
- sandboxType: 'none',
144
- requiresSandbox: false,
145
- preference: selected.preference,
146
- };
147
- }
148
- const backend = this.backends.get(selected.sandboxType);
149
- if (!backend) {
150
- return {
151
- ok: false,
152
- reason: 'backend_not_available',
153
- sandboxType: selected.sandboxType,
154
- requiresSandbox: selected.requiresSandbox,
155
- platform: selected.platform,
156
- preference: selected.preference,
157
- message: `Sandbox backend ${selected.sandboxType} is not registered.`,
158
- };
159
- }
160
- return backend.probe({
161
- ...request,
162
- preference: selected.preference,
163
- platform: selected.platform,
164
- });
165
- }
166
131
  transform(request) {
167
132
  const selected = this.selectInitial({
168
133
  profile: request.command.profile,
@@ -70,18 +70,6 @@ export class WindowsBrokerSandboxBackend {
70
70
  profile.fileSystem.kind === 'restricted' &&
71
71
  profile.network.kind === 'restricted');
72
72
  }
73
- probe(request) {
74
- const plan = this.plan(request);
75
- if (!plan.ok)
76
- return plan;
77
- return {
78
- ok: true,
79
- executable: this.options.clientPath,
80
- sandboxType: 'windows',
81
- requiresSandbox: true,
82
- preference: plan.preference,
83
- };
84
- }
85
73
  transform(request) {
86
74
  const plan = this.plan(request);
87
75
  if (!plan.ok)
@@ -24,6 +24,7 @@
24
24
  * ledger.
25
25
  */
26
26
  import { failureClassFromCompleteStopReason, normalizeMessageContent, } from '@maka/core/events';
27
+ import { compatibilityToolResultProjection } from './durable-tool-result-projection.js';
27
28
  /**
28
29
  * Map a `CompleteEvent.stopReason` onto a terminal `RuntimeEventStatus`.
29
30
  *
@@ -267,6 +268,23 @@ function mapBackendSessionEvent(event, ctx, memory) {
267
268
  };
268
269
  case 'tool_result': {
269
270
  const name = memory.toolNameByUseId.get(event.toolUseId) ?? '';
271
+ const content = {
272
+ kind: 'function_response',
273
+ id: event.toolUseId,
274
+ name,
275
+ result: event.content,
276
+ ...(event.isError ? { isError: true } : {}),
277
+ ...(event.providerExecuted !== undefined
278
+ ? { providerExecuted: event.providerExecuted }
279
+ : {}),
280
+ ...(event.providerExecuted && event.providerOutput !== undefined
281
+ ? { providerOutput: structuredClone(event.providerOutput) }
282
+ : {}),
283
+ };
284
+ const modelProjection = event.modelProjection ??
285
+ (event.operationId === undefined
286
+ ? compatibilityToolResultProjection(content, ctx.sessionId)
287
+ : undefined);
270
288
  const ev = {
271
289
  ...base,
272
290
  role: 'tool',
@@ -274,17 +292,8 @@ function mapBackendSessionEvent(event, ctx, memory) {
274
292
  ...(event.origin !== undefined ? { origin: event.origin } : {}),
275
293
  ...(event.modelVisibility !== undefined ? { modelVisibility: event.modelVisibility } : {}),
276
294
  content: {
277
- kind: 'function_response',
278
- id: event.toolUseId,
279
- name,
280
- result: event.content,
281
- ...(event.isError ? { isError: true } : {}),
282
- ...(event.providerExecuted !== undefined
283
- ? { providerExecuted: event.providerExecuted }
284
- : {}),
285
- ...(event.providerExecuted && event.providerOutput !== undefined
286
- ? { providerOutput: structuredClone(event.providerOutput) }
287
- : {}),
295
+ ...content,
296
+ ...(modelProjection ? { modelProjection } : {}),
288
297
  },
289
298
  refs: {
290
299
  toolCallId: event.toolUseId,
@@ -35,7 +35,6 @@ import { DEFAULT_TOOL_MODE } from '@maka/core/tool-mode';
35
35
  import { PLAN_USER_ABANDON_REASON, PLAN_USER_CANCEL_REASON, PlanConflictError, } from '@maka/core/plan';
36
36
  import { DEFAULT_SESSION_NAME } from '@maka/core/session-name';
37
37
  import { DEEP_RESEARCH_SESSION_LABEL, isDeepResearchSession } from '@maka/core/deep-research';
38
- import { SIDE_CONVERSATION_SESSION_LABEL } from '@maka/core/side-conversation';
39
38
  import { SUBAGENT_SESSION_RUNTIME_SCHEMA_VERSION, SUBAGENT_SESSION_SPAWN_SCHEMA_VERSION, childSessionsForParent, deriveTurnRecords, subagentSessionRuntimeSummary, } from '@maka/core/session';
40
39
  import { decodeAgentGraphIntentClaim } from '@maka/core/agent-graph-control';
41
40
  import { executionBoundaryContains } from '@maka/core/sandbox-boundary';
@@ -46,7 +45,6 @@ import { isTerminalRuntimeEvent } from '@maka/core/runtime-event';
46
45
  import { AGENT_GRAPH_OPERATOR_PROVISION_SCHEMA_VERSION } from '@maka/core/agent-graph-topology';
47
46
  import { RuntimeReadModel, RuntimeReadModelError, } from './runtime-read-model.js';
48
47
  import { inspectAgentRunReadModel } from './agent-run-inspect.js';
49
- import { cloneConversationRuntimeLedger as cloneConversationLedger, createConversationCopySlice, prepareConversationRuntimeLedgerCopy, } from './conversation-copy.js';
50
48
  import { firstRuntimeRepairRunId, RuntimeLedgerRepair } from './runtime-ledger-repair.js';
51
49
  import { buildRecoveredTerminalRuntimeEvent, classifyTerminalRuntimeLedger, commitTerminalRunWithRuntimeFact, effectiveRunHeaderFromTerminalFact, terminalRunStatusFromRuntimeEvent, } from './terminal-run-commit.js';
52
50
  import { readLatestContextDiagnostics } from './context-diagnostics.js';
@@ -2578,13 +2576,6 @@ export class SessionManager {
2578
2576
  content: normalizeMessageContent(user),
2579
2577
  };
2580
2578
  }
2581
- async branchFromTurn(sessionId, input) {
2582
- const sourceView = await this.getSessionView(sessionId);
2583
- const slice = createConversationCopySlice(sourceView.messages, input.sourceTurnId, 'through');
2584
- if (!slice)
2585
- throw new Error(`Cannot branch from unknown turn ${input.sourceTurnId}`);
2586
- return this.createBranchSession(sessionId, sourceView, [...slice.messages], input);
2587
- }
2588
2579
  /** Canonical, repaired source view for a Host-owned cross-Session copy. */
2589
2580
  async readConversationCopySnapshot(sessionId) {
2590
2581
  const readMessagesSnapshot = this.deps.store.readMessagesSnapshot;
@@ -2604,130 +2595,6 @@ export class SessionManager {
2604
2595
  turns: deriveTurnRecords(messages),
2605
2596
  };
2606
2597
  }
2607
- async branchBeforeTurn(sessionId, input) {
2608
- const sourceView = await this.getSessionView(sessionId);
2609
- const slice = createConversationCopySlice(sourceView.messages, input.sourceTurnId, 'before');
2610
- if (!slice)
2611
- throw new Error(`Cannot branch before unknown turn ${input.sourceTurnId}`);
2612
- return this.createBranchSession(sessionId, sourceView, [...slice.messages], input);
2613
- }
2614
- /**
2615
- * Create a non-destructive edit-and-resend version. Unlike branchBeforeTurn,
2616
- * this is not a new sidebar conversation: revision lineage lets hosts fold
2617
- * every version into one conversation slot while keeping old transcripts.
2618
- */
2619
- async reviseBeforeTurn(sessionId, input) {
2620
- const sourceView = await this.getSessionView(sessionId);
2621
- const slice = createConversationCopySlice(sourceView.messages, input.sourceTurnId, 'before');
2622
- if (!slice)
2623
- throw new Error(`Cannot revise before unknown turn ${input.sourceTurnId}`);
2624
- return this.createRevisionSession(sessionId, sourceView, [...slice.messages], input);
2625
- }
2626
- async createRevisionSession(sessionId, sourceView, copied, input) {
2627
- const plan = await this.prepareConversationRuntimeLedgerClone(sessionId, sourceView, copied);
2628
- const [header, boundary] = await Promise.all([
2629
- this.deps.store.readHeader(sessionId),
2630
- this.deps.store.readExecutionBoundary(sessionId),
2631
- ]);
2632
- const revisionRootSessionId = header.revisionRootSessionId ?? sessionId;
2633
- const family = (await this.deps.store.list()).filter((candidate) => candidate.id === revisionRootSessionId ||
2634
- candidate.revisionRootSessionId === revisionRootSessionId);
2635
- const revisionIndex = Math.max(1, ...family.map((candidate) => candidate.revisionIndex ?? 1)) + 1;
2636
- const next = await this.deps.store.create({
2637
- cwd: header.cwd,
2638
- ...(header.projectId !== undefined ? { projectId: header.projectId } : {}),
2639
- ...(header.llmConnectionId === undefined
2640
- ? {}
2641
- : { llmConnectionId: header.llmConnectionId }),
2642
- llmConnectionSlug: header.llmConnectionSlug,
2643
- model: header.model,
2644
- thinkingLevel: header.thinkingLevel,
2645
- permissionMode: header.permissionMode,
2646
- collaborationMode: header.collaborationMode,
2647
- orchestrationMode: header.orchestrationMode ?? 'default',
2648
- name: header.name,
2649
- labels: header.labels,
2650
- // A revision of a real branch remains in that branch's conversation
2651
- // slot; revision lineage itself must not create a branch banner.
2652
- parentSessionId: header.parentSessionId,
2653
- branchOfTurnId: header.branchOfTurnId,
2654
- revisionRootSessionId,
2655
- revisionParentSessionId: sessionId,
2656
- revisionOfTurnId: input.sourceTurnId,
2657
- revisionIndex,
2658
- revisionState: 'preparing',
2659
- status: 'active',
2660
- }, boundary);
2661
- try {
2662
- const rewritten = await this.cloneConversationRuntimeLedger(next.id, copied, plan);
2663
- if (rewritten.length > 0)
2664
- await this.deps.store.appendMessages(next.id, [...rewritten]);
2665
- await this.deps.store.appendMessage(next.id, {
2666
- type: 'system_note',
2667
- id: this.deps.newId(),
2668
- ts: this.deps.now(),
2669
- kind: 'session_start',
2670
- data: {
2671
- revisionRootSessionId,
2672
- revisionParentSessionId: sessionId,
2673
- revisionOfTurnId: input.sourceTurnId,
2674
- revisionIndex,
2675
- revisionState: 'preparing',
2676
- },
2677
- });
2678
- await this.deps.store.updateHeader(next.id, {
2679
- isFlagged: header.isFlagged,
2680
- titleIsManual: header.titleIsManual,
2681
- });
2682
- return headerToSummary(await this.deps.store.readHeader(next.id));
2683
- }
2684
- catch (error) {
2685
- return this.rollbackLegacyConversationCopy(next.id, error);
2686
- }
2687
- }
2688
- async createBranchSession(sessionId, sourceView, copied, input) {
2689
- const plan = await this.prepareConversationRuntimeLedgerClone(sessionId, sourceView, copied);
2690
- const [header, boundary] = await Promise.all([
2691
- this.deps.store.readHeader(sessionId),
2692
- this.deps.store.readExecutionBoundary(sessionId),
2693
- ]);
2694
- const next = await this.deps.store.create({
2695
- cwd: header.cwd,
2696
- ...(header.projectId !== undefined ? { projectId: header.projectId } : {}),
2697
- ...(header.llmConnectionId === undefined
2698
- ? {}
2699
- : { llmConnectionId: header.llmConnectionId }),
2700
- llmConnectionSlug: header.llmConnectionSlug,
2701
- model: header.model,
2702
- thinkingLevel: header.thinkingLevel,
2703
- permissionMode: header.permissionMode,
2704
- collaborationMode: header.collaborationMode,
2705
- orchestrationMode: header.orchestrationMode ?? 'default',
2706
- name: input.name ?? `${header.name} · 分支`,
2707
- labels: input.sideConversation
2708
- ? [...new Set([...header.labels, SIDE_CONVERSATION_SESSION_LABEL])]
2709
- : header.labels,
2710
- parentSessionId: sessionId,
2711
- branchOfTurnId: input.sourceTurnId,
2712
- status: 'active',
2713
- }, boundary);
2714
- try {
2715
- const rewritten = await this.cloneConversationRuntimeLedger(next.id, copied, plan);
2716
- if (rewritten.length > 0)
2717
- await this.deps.store.appendMessages(next.id, [...rewritten]);
2718
- await this.deps.store.appendMessage(next.id, {
2719
- type: 'system_note',
2720
- id: this.deps.newId(),
2721
- ts: this.deps.now(),
2722
- kind: 'session_start',
2723
- data: { parentSessionId: sessionId, branchOfTurnId: input.sourceTurnId },
2724
- });
2725
- return headerToSummary(await this.deps.store.readHeader(next.id));
2726
- }
2727
- catch (error) {
2728
- return this.rollbackLegacyConversationCopy(next.id, error);
2729
- }
2730
- }
2731
2598
  async respondToSandboxBoundary(sessionId, response) {
2732
2599
  if (this.deps.interactionAuthority) {
2733
2600
  throw new RuntimeInteractionInvariantError('Hosted permission answers must use the captured continuation');
@@ -3049,43 +2916,6 @@ export class SessionManager {
3049
2916
  }
3050
2917
  this.preparedTranscriptLedgers.add(sessionId);
3051
2918
  }
3052
- async prepareConversationRuntimeLedgerClone(sourceSessionId, sourceView, copiedMessages) {
3053
- if (!this.deps.runStore || !this.deps.runtimeEventStore)
3054
- return undefined;
3055
- return prepareConversationRuntimeLedgerCopy({
3056
- sourceSessionId,
3057
- sourceEvents: sourceView.events,
3058
- copiedMessages,
3059
- runStore: this.deps.runStore,
3060
- runtimeEventStore: this.deps.runtimeEventStore,
3061
- });
3062
- }
3063
- async cloneConversationRuntimeLedger(childSessionId, copiedMessages, plan) {
3064
- if (!plan || !this.deps.runStore || !this.deps.runtimeEventStore)
3065
- return copiedMessages;
3066
- const copied = await cloneConversationLedger({
3067
- plan,
3068
- copiedMessages,
3069
- referenceMap: {
3070
- mode: 'preserve_external',
3071
- sourceSessionId: plan.sourceSessionId,
3072
- targetSessionId: childSessionId,
3073
- },
3074
- runStore: this.deps.runStore,
3075
- runtimeEventStore: this.deps.runtimeEventStore,
3076
- newId: this.deps.newId,
3077
- });
3078
- return copied.copiedMessages;
3079
- }
3080
- async rollbackLegacyConversationCopy(sessionId, error) {
3081
- try {
3082
- await this.deps.store.remove(sessionId);
3083
- }
3084
- catch (cleanupError) {
3085
- throw new AggregateError([error, cleanupError], `Conversation copy ${sessionId} failed and could not be removed`);
3086
- }
3087
- throw error;
3088
- }
3089
2919
  /**
3090
2920
  * Closes only the two provably pre-provider crash windows owned by B2:
3091
2921
  * claim-only and target-Run-created-without-start. A repaired claim never
@@ -26,9 +26,9 @@
26
26
  // the model is trapped writing `dir /s /b` style commands. This module detects
27
27
  // a better shell (pwsh > powershell > cmd) and carries the result to the two
28
28
  // places that need it: the spawn call (shell-exec / shell-run-manager) and the
29
- // prompt surfaces that must DECLARE the dialect to the model (tool description,
30
- // session environment fragment). Selection without declaration — or the other
31
- // way round — makes the model guess the dialect, which is the original bug.
29
+ // Bash tool description that declares the dialect to the model. Selection
30
+ // without declaration — or the other way round — makes the model guess the
31
+ // dialect, which is the original bug.
32
32
  import { execFile } from 'node:child_process';
33
33
  import { existsSync } from 'node:fs';
34
34
  import { win32 } from 'node:path';
@@ -87,10 +87,6 @@ export function throwIfShellSetupFailed(shell) {
87
87
  if (shell.setupError)
88
88
  throw shell.setupError;
89
89
  }
90
- /** Model-facing shell name; a broken preference is declared, not silently hidden. */
91
- export function turnShellDisplayName(shell) {
92
- return shell.setupError ? `Unavailable (${shell.setupError.message})` : shell.plan.displayName;
93
- }
94
90
  /** Rejects a persisted override unless the Host can execute it as GNU Bash. */
95
91
  export async function validateShellPreference(settings, input = {}) {
96
92
  const plan = resolveShellPlan(settings, input);
@@ -32,7 +32,6 @@ export const DEFAULT_MAX_LIVE_PTY_RUNS = 8;
32
32
  export const DEFAULT_SHELL_RUN_FLUSH_INTERVAL_MS = 1_000;
33
33
  export const DEFAULT_SHELL_RUN_FLUSH_BYTES = 64 * 1024;
34
34
  export const DEFAULT_PIPE_OUTPUT_DRAIN_MS = 2_000;
35
- export const SHELL_RUN_CONTEXT_SUMMARY_LIMIT = 8;
36
35
  export const SHELL_RUN_RESOURCE_PREFIX = 'maka://runtime/background-tasks';
37
36
  export const MAX_SHELL_RUN_RESOURCE_REF_CHARS = SHELL_RUN_RESOURCE_PREFIX.length + 1 + SHELL_RUN_ID_MAX_CHARS;
38
37
  export { isWellFormedTerminalInput };
@@ -30,7 +30,7 @@ import { PipeTailCollector } from './pipe-tail-collector.js';
30
30
  import { PtyProcessDriver } from './pty-process-driver.js';
31
31
  import { PTY_INITIAL_COLS, PTY_INITIAL_ROWS, PtyScreenCollector, } from './pty-screen-collector.js';
32
32
  import { loadPtyStack } from './pty-stack.js';
33
- import { DEFAULT_BASH_TIMEOUT_MS, DEFAULT_MAX_LIVE_PTY_RUNS, DEFAULT_MAX_LIVE_SHELL_RUNS, DEFAULT_PIPE_OUTPUT_DRAIN_MS, DEFAULT_SHELL_RUN_FLUSH_BYTES, DEFAULT_SHELL_RUN_FLUSH_INTERVAL_MS, MAX_FOREGROUND_BASH_TIMEOUT_MS, MAX_SHELL_RUN_TIMEOUT_MS, SHELL_RUN_CONTEXT_SUMMARY_LIMIT, ShellRunPtyControlClosedError, parseShellRunResourceRef, shellRunResourceRef, validateWriteStdinInput, } from './shell-run-contract.js';
33
+ import { DEFAULT_BASH_TIMEOUT_MS, DEFAULT_MAX_LIVE_PTY_RUNS, DEFAULT_MAX_LIVE_SHELL_RUNS, DEFAULT_PIPE_OUTPUT_DRAIN_MS, DEFAULT_SHELL_RUN_FLUSH_BYTES, DEFAULT_SHELL_RUN_FLUSH_INTERVAL_MS, MAX_FOREGROUND_BASH_TIMEOUT_MS, MAX_SHELL_RUN_TIMEOUT_MS, ShellRunPtyControlClosedError, parseShellRunResourceRef, shellRunResourceRef, validateWriteStdinInput, } from './shell-run-contract.js';
34
34
  import { compactShellRunContent, ptyControlOperation, shellRunContent, shellRunUpdate, terminalContent, } from './shell-run-tool-result.js';
35
35
  import { CompletionLatch } from './completion-latch.js';
36
36
  import { closeChildFdSources } from './child-fd-input.js';
@@ -404,30 +404,6 @@ export class ShellRunProcessManager {
404
404
  const record = await this.markObserved(await live.finished.join());
405
405
  return shellRunContent(record, { kind: 'stop', applied });
406
406
  }
407
- async buildContextSummary(sessionId) {
408
- const records = (await this.actionableRecords(sessionId)).filter((record) => record.visibility !== 'user');
409
- if (records.length === 0)
410
- return undefined;
411
- const visible = records.slice(0, SHELL_RUN_CONTEXT_SUMMARY_LIMIT);
412
- const lines = [
413
- 'Background tasks for this session:',
414
- ...visible.map((record) => {
415
- const completed = record.completedAt !== undefined ? ` completedAt=${record.completedAt}` : '';
416
- return `- ref=${shellRunResourceRef(record.shellRunId)} mode=${record.output.mode} status=${record.status} cwd=${record.cwd} updatedAt=${record.updatedAt}${completed} command=${JSON.stringify(record.command)}`;
417
- }),
418
- ];
419
- const overflow = records.length - visible.length;
420
- if (overflow > 0)
421
- lines.push(`- ${overflow} more background task(s) not shown in this turn tail.`);
422
- const hasControllablePty = records.some((record) => {
423
- const live = this.liveResource(sessionId, record.shellRunId);
424
- return live?.mode === 'pty' && isPtyControlOpen(live);
425
- });
426
- lines.push(hasControllablePty
427
- ? 'Use Read on a ref for its bounded output snapshot; use WriteStdin to control a running PTY task.'
428
- : 'Use Read on a ref for its bounded output snapshot.');
429
- return lines.join('\n');
430
- }
431
407
  async listSessionUpdates(sessionId) {
432
408
  const records = await this.input.store.listSessionShellRuns(sessionId);
433
409
  return records.map(shellRunUpdate);
@@ -1483,13 +1459,6 @@ export class ShellRunProcessManager {
1483
1459
  return this.input.store.updateShellRun(current.sessionId, current.shellRunId, buildPatch());
1484
1460
  }
1485
1461
  }
1486
- async actionableRecords(sessionId) {
1487
- const records = await this.input.store.listSessionShellRuns(sessionId);
1488
- return records
1489
- .filter((record) => isActiveShellRunStatus(record.status) ||
1490
- (record.observedAt === undefined && isTerminalShellRunStatus(record.status)))
1491
- .sort(compareActionableShellRuns);
1492
- }
1493
1462
  notifyShellRunUpdate(record) {
1494
1463
  try {
1495
1464
  this.input.onShellRunUpdate?.(shellRunUpdate(record));
@@ -1679,13 +1648,6 @@ function startupCleanupError(startupError, cleanupFailure) {
1679
1648
  const cleanupError = asError(cleanupFailure, 'Shell process startup cleanup failed');
1680
1649
  return new Error(`Shell process startup failed: ${safeFailureMessage(startupError)}; startup cleanup failed: ${safeFailureMessage(cleanupError)}`, { cause: new AggregateError([startupError, cleanupError]) });
1681
1650
  }
1682
- function compareActionableShellRuns(a, b) {
1683
- const rank = (record) => (isActiveShellRunStatus(record.status) ? 1 : 0);
1684
- return (rank(a) - rank(b) ||
1685
- b.updatedAt - a.updatedAt ||
1686
- b.startedAt - a.startedAt ||
1687
- a.shellRunId.localeCompare(b.shellRunId));
1688
- }
1689
1651
  async function racePromiseWithAbort(promise, signal) {
1690
1652
  if (!signal)
1691
1653
  return promise;
@@ -211,7 +211,7 @@ export function buildStopBackgroundTaskTool(backgroundTasks) {
211
211
  return {
212
212
  name: 'StopBackgroundTask',
213
213
  activityKind: 'command',
214
- description: 'Stop a background task by runtime ref. Currently supports background shell run refs returned by Bash and shown in the turn tail.',
214
+ description: 'Stop a background task by runtime ref. Currently supports background shell run refs returned by Bash.',
215
215
  parameters: z.object({
216
216
  ref: z
217
217
  .string()
@@ -34,8 +34,8 @@ function buildTaskCreateTool(store, name, updateToolName) {
34
34
  return {
35
35
  name,
36
36
  displayName: 'Task Create',
37
- description: 'Add one or more tasks to the session task ledger. The full updated ledger is re-shown each turn, ' +
38
- `so use this to record work you plan to do; update status with ${updateToolName} as you progress.`,
37
+ description: 'Add one or more tasks to the session task ledger. ' +
38
+ `Use task_list or task_get to read it later, and update status with ${updateToolName} as you progress.`,
39
39
  parameters: z.object({
40
40
  tasks: z
41
41
  .array(z.object({