@myagentroam/agent 0.10.59 → 0.10.61

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 (58) hide show
  1. package/dist/agent-core/runtime/compaction/history.d.ts +1 -1
  2. package/dist/agent-core/runtime/compaction/retained-context.d.ts +1 -1
  3. package/dist/agent-core/runtime/compaction/retained-context.js +1 -1
  4. package/dist/agent-core/runtime/compaction/smart.d.ts +1 -1
  5. package/dist/agent-core/runtime/compaction/smart.js +1 -1
  6. package/dist/agent-core/runtime/context/gc-runtime.d.ts +1 -1
  7. package/dist/agent-core/runtime/context/gc-runtime.js +20 -14
  8. package/dist/agent-core/runtime/context/gc.d.ts +1 -1
  9. package/dist/agent-core/runtime/context/gc.js +4 -10
  10. package/dist/agent-core/runtime/context/projection.d.ts +1 -1
  11. package/dist/agent-core/runtime/context/projection.js +3 -5
  12. package/dist/agent-core/runtime/context/restore.d.ts +4 -4
  13. package/dist/agent-core/runtime/context/restore.js +1 -1
  14. package/dist/agent-core/runtime/context/usage.d.ts +2 -2
  15. package/dist/agent-core/runtime/context/usage.js +1 -1
  16. package/dist/agent-core/runtime/context/world-state.d.ts +2 -2
  17. package/dist/agent-core/runtime/context/world-state.js +1 -1
  18. package/dist/agent-core/sdk/agent.js +2 -2
  19. package/dist/agent-core/sdk/extension-agents.js +5 -1
  20. package/dist/agent-core/sdk/native-steer.d.ts +1 -1
  21. package/dist/agent-core/sdk/session.d.ts +19 -13
  22. package/dist/agent-core/sdk/session.js +35 -40
  23. package/dist/agent-core/sdk/subagent-backend.d.ts +1 -1
  24. package/dist/agent-core/sdk/subagent-backend.js +20 -17
  25. package/dist/agent-core/session/catalog.js +1 -1
  26. package/dist/agent-core/session/context-gc-checkpoint.d.ts +4 -8
  27. package/dist/agent-core/session/context-gc-checkpoint.js +82 -137
  28. package/dist/agent-core/session/context-gc-observations.d.ts +1 -1
  29. package/dist/agent-core/session/context-gc-replacements.d.ts +4 -7
  30. package/dist/agent-core/session/context-gc-replacements.js +25 -59
  31. package/dist/agent-core/session/context-gc-subagent.d.ts +0 -3
  32. package/dist/agent-core/session/context-gc-subagent.js +2 -16
  33. package/dist/agent-core/session/deferred-input.d.ts +1 -1
  34. package/dist/agent-core/session/store/current-state.d.ts +17 -0
  35. package/dist/agent-core/session/store/current-state.js +53 -0
  36. package/dist/agent-core/session/store/directory-index.d.ts +18 -0
  37. package/dist/agent-core/session/store/directory-index.js +169 -0
  38. package/dist/agent-core/session/store/execution-state.d.ts +18 -0
  39. package/dist/agent-core/session/store/execution-state.js +187 -0
  40. package/dist/agent-core/session/store/history.d.ts +25 -0
  41. package/dist/agent-core/session/store/history.js +157 -0
  42. package/dist/agent-core/session/store/images.d.ts +21 -0
  43. package/dist/agent-core/session/store/images.js +248 -0
  44. package/dist/agent-core/session/store/index.d.ts +4 -0
  45. package/dist/agent-core/session/store/index.js +2 -0
  46. package/dist/agent-core/session/{jsonl-store.d.ts → store/jsonl-store.d.ts} +14 -94
  47. package/dist/agent-core/session/{jsonl-store.js → store/jsonl-store.js} +323 -1269
  48. package/dist/agent-core/session/store/records.d.ts +23 -0
  49. package/dist/agent-core/session/store/records.js +249 -0
  50. package/dist/agent-core/session/store/types.d.ts +84 -0
  51. package/dist/agent-core/session/store/types.js +1 -0
  52. package/dist/agent-core/session/tool-result-resources.d.ts +1 -1
  53. package/dist/agent-core/subagent/scheduler.js +1 -1
  54. package/dist/agent-core/subagent/session-controller.d.ts +5 -2
  55. package/dist/agent-core/subagent/session-controller.js +99 -15
  56. package/dist/agent-core/tools/code-mode/state.d.ts +1 -1
  57. package/dist/agent-core/tools/code-mode/state.js +2 -2
  58. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { ModelMessage } from '../../model/contracts.js';
2
- import type { CompactHistoryMessage, CompactUserInput } from '../../session/jsonl-store.js';
2
+ import type { CompactHistoryMessage, CompactUserInput } from '../../session/store/index.js';
3
3
  export declare const DEFAULT_COMPACTION_FOCUS = "Create a durable continuation state for the next model invocation.";
4
4
  export declare function buildNativeCompactionMessages(messages: readonly ModelMessage[], input?: {
5
5
  focus?: string;
@@ -1,6 +1,6 @@
1
1
  import type { ModelMessage } from '../../model/contracts.js';
2
2
  import type { CompactSnapshotAnchor } from '../events.js';
3
3
  /** Use a public native identity, never private context text, as the visible boundary. */
4
- export declare function compactSnapshotAnchor(messages: readonly ModelMessage[], sources: WeakMap<ModelMessage, import('../../session/jsonl-store.js').SessionRecord>): CompactSnapshotAnchor | undefined;
4
+ export declare function compactSnapshotAnchor(messages: readonly ModelMessage[], sources: WeakMap<ModelMessage, import('../../session/store/index.js').SessionRecord>): CompactSnapshotAnchor | undefined;
5
5
  /** Decode the SDK-owned checkpoint suffix without promoting contextual text to real input. */
6
6
  export declare function restoreCompactTail(value: unknown): ModelMessage | undefined;
@@ -1,4 +1,4 @@
1
- import { parseModelInputMetadata } from '../../session/jsonl-store.js';
1
+ import { parseModelInputMetadata } from '../../session/store/index.js';
2
2
  import { restoreModelContext } from '../context/projection.js';
3
3
  /** Use a public native identity, never private context text, as the visible boundary. */
4
4
  export function compactSnapshotAnchor(messages, sources) {
@@ -1,5 +1,5 @@
1
1
  import type { ModelMessage } from '../../model/contracts.js';
2
- import { type SessionRecord } from '../../session/jsonl-store.js';
2
+ import { type SessionRecord } from '../../session/store/index.js';
3
3
  export declare const SMART_COMPACTION_MARKER = "<mar_runtime>\n <smart_compaction>For this message only, smart_compact may be considered at a clear transition into sustained new work, when the previous phase is largely complete and its details have low continuation value.</smart_compaction>\n</mar_runtime>";
4
4
  export interface SmartCompactionInput {
5
5
  readonly recordId: string;
@@ -1,5 +1,5 @@
1
1
  import { MarAgentError } from '../../error.js';
2
- import { compactSummaryFromCheckpoint } from '../../session/jsonl-store.js';
2
+ import { compactSummaryFromCheckpoint } from '../../session/store/index.js';
3
3
  export const SMART_COMPACTION_MARKER = '<mar_runtime>\n <smart_compaction>For this message only, smart_compact may be considered at a clear transition into sustained new work, when the previous phase is largely complete and its details have low continuation value.</smart_compaction>\n</mar_runtime>';
4
4
  /** A measured watermark, not the stricter native-request budget calibration. */
5
5
  export function latestSmartContextTokens(records, modelId, contextWindowTokens) {
@@ -1,6 +1,6 @@
1
1
  import type { ClientToolDefinition, ModelUsage } from '../../model/contracts.js';
2
2
  import { type ContextGcPlatform } from '../../session/context-gc-checkpoint.js';
3
- import { JsonlSessionStore, type SessionRecord } from '../../session/jsonl-store.js';
3
+ import { JsonlSessionStore, type SessionRecord } from '../../session/store/index.js';
4
4
  import { type ContextProjection } from './projection.js';
5
5
  export interface ContextGcRuntimeInput {
6
6
  readonly store: JsonlSessionStore;
@@ -1,5 +1,5 @@
1
1
  import { isDeepStrictEqual } from 'node:util';
2
- import { ContextGcCheckpointCache, contextGcMinimumUsageGrowth, contextGcReplacementKey, contextGcSourceProjectionHash } from '../../session/context-gc-checkpoint.js';
2
+ import { ContextGcCheckpointCache, contextGcMinimumUsageGrowth, contextGcReplacementKey } from '../../session/context-gc-checkpoint.js';
3
3
  import { CONTEXT_GC_POLICY, contextGcEligibleUsage, inspectContextGc } from './gc.js';
4
4
  import { buildContextProjection } from './projection.js';
5
5
  /** Only scheduling metadata survives a call; records and validation caches do not. */
@@ -95,8 +95,10 @@ async function attemptContextGc(input) {
95
95
  return { result: false };
96
96
  let deferred = { result: false };
97
97
  let draft;
98
+ let records;
98
99
  try {
99
- const records = input.records ?? (await input.store.readExecutionState(input.sessionId)).contextRecords;
100
+ records =
101
+ input.records ?? (await input.store.readExecutionState(input.sessionId)).contextRecords;
100
102
  const checkpointCache = new ContextGcCheckpointCache();
101
103
  const previous = checkpointCache.read(records, undefined, input.workspace);
102
104
  if (previous) {
@@ -148,27 +150,23 @@ async function attemptContextGc(input) {
148
150
  const plan = inspection.plan;
149
151
  if (!plan)
150
152
  return deferred;
151
- const hash = contextGcSourceProjectionHash(records, plan.draft.boundarySequence, plan.draft.base);
152
- if (!hash)
153
- return deferred;
154
- plan.draft.sourceProjectionHash = hash;
155
153
  draft = plan.draft;
156
154
  }
157
155
  catch {
158
156
  return deferred;
159
157
  }
160
158
  try {
161
- await input.store.commitContextGc(input.sessionId, draft);
159
+ const committed = await input.store.commitContextGc(input.sessionId, draft, records);
162
160
  return {
163
161
  ...deferred,
164
- result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, input.workspace)
162
+ result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, input.workspace, records, committed)
165
163
  };
166
164
  }
167
165
  catch (commitError) {
168
166
  try {
169
167
  return {
170
168
  ...deferred,
171
- result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, input.workspace)
169
+ result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, input.workspace, records)
172
170
  };
173
171
  }
174
172
  catch {
@@ -178,13 +176,21 @@ async function attemptContextGc(input) {
178
176
  return deferred;
179
177
  }
180
178
  }
181
- async function matchingCheckpointWasPersisted(store, sessionId, draft, workspace) {
182
- const state = await store.readExecutionState(sessionId);
183
- const projection = buildContextProjection(state.contextRecords, workspace);
179
+ async function matchingCheckpointWasPersisted(store, sessionId, draft, workspace, records, committed) {
180
+ const record = committed ??
181
+ (await store.readPage(sessionId, {
182
+ limit: 1,
183
+ beforeSequence: draft.boundarySequence + 2
184
+ })).records[0];
185
+ if (record?.sequence !== draft.boundarySequence + 1 || record.type !== 'context.gc.completed')
186
+ return false;
187
+ const updatedRecords = [...records, record];
188
+ const projection = buildContextProjection(updatedRecords, workspace);
189
+ if (committed)
190
+ return { records: updatedRecords, projection };
184
191
  const payload = projection.checkpoint;
185
192
  const latest = payload ? { payload } : undefined;
186
193
  if (latest?.payload.boundarySequence !== draft.boundarySequence ||
187
- latest.payload.sourceProjectionHash !== draft.sourceProjectionHash ||
188
194
  !isDeepStrictEqual(latest.payload.base, draft.base) ||
189
195
  !isDeepStrictEqual(latest.payload.trigger, draft.trigger) ||
190
196
  !isDeepStrictEqual(latest.payload.economics, draft.economics) ||
@@ -198,7 +204,7 @@ async function matchingCheckpointWasPersisted(store, sessionId, draft, workspace
198
204
  const value = persisted.get(contextGcReplacementKey(replacement));
199
205
  return value !== undefined && isDeepStrictEqual(value, replacement);
200
206
  });
201
- return matches ? { records: state.contextRecords, projection } : false;
207
+ return matches ? { records: updatedRecords, projection } : false;
202
208
  }
203
209
  function isRecord(value) {
204
210
  return value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -1,6 +1,6 @@
1
1
  import type { ClientToolDefinition, ModelMessage, ModelUsage } from '../../model/contracts.js';
2
2
  import { ContextGcCheckpointCache, type ContextGcCheckpointDraft, type ContextGcEconomicsPolicy, type ContextGcMetrics, type ContextGcPlatform, type ContextGcReplacement } from '../../session/context-gc-checkpoint.js';
3
- import type { SessionRecord } from '../../session/jsonl-store.js';
3
+ import type { SessionRecord } from '../../session/store/index.js';
4
4
  export declare const CONTEXT_GC_POLICY: ContextGcEconomicsPolicy;
5
5
  interface ContextGcEconomicsInput {
6
6
  readonly contextUsageTokens: number;
@@ -1,5 +1,5 @@
1
1
  import { codeCallEvidence, codePartialPatchCallEvidence, codeObservationEvidence, retainedCodeInputs } from '../../session/context-gc-observations.js';
2
- import { ContextGcCheckpointCache, contextGcBaseFromRecords, contextGcLogicalPathKey, contextGcMinimumUsageGrowth, contextGcRecordSourceHash, contextGcTargetKey, normalizeContextGcReplacements } from '../../session/context-gc-checkpoint.js';
2
+ import { ContextGcCheckpointCache, contextGcBaseFromRecords, contextGcLogicalPathKey, contextGcMinimumUsageGrowth, contextGcTargetKey, normalizeContextGcReplacements } from '../../session/context-gc-checkpoint.js';
3
3
  import { codeCellCompletionSequence, contextGcApplyPatchInputReplacement, contextGcCodeModeInputReplacement, contextGcCodeModeOutputReplacement, contextGcExecInputReplacement, contextGcExecOutputReplacement, contextGcPatchResultFromCompletedPayload, contextGcPatchResultFromFailedPayload, contextGcStaleReadReplacement, contextGcWebOutputReplacement, normalizeContextGcCodeModeInput, normalizeContextGcExecResult } from '../../session/context-gc-replacements.js';
4
4
  import { contextGcSubagentNeedsRetainedPriorFinal, contextGcSubagentOutputReplacement, contextGcSubagentPriorFinalIsRetained, contextGcSubagentSnapshotIsPreciselyCovered, contextGcSubagentSnapshotIsSuperseded, contextGcSubagentSnapshotTurnId, normalizeContextGcSubagentSnapshot } from '../../session/context-gc-subagent.js';
5
5
  import { parseReadContextOutput } from '../../tools/local/read-context.js';
@@ -425,7 +425,6 @@ function finalizePlan(input, evaluated) {
425
425
  version: 1,
426
426
  base,
427
427
  boundarySequence: evaluated.boundarySequence,
428
- sourceProjectionHash: '',
429
428
  replacements,
430
429
  trigger: {
431
430
  usageSequence: evaluated.usageRecord.sequence,
@@ -558,7 +557,7 @@ function collectStageACandidates(input, groups, existingReplacements, existingTa
558
557
  toolName: 'apply_patch',
559
558
  callId: patch.callId,
560
559
  target: patchTarget,
561
- replacementArguments: contextGcApplyPatchInputReplacement(patchCall.message.arguments, result, evidenceSequence),
560
+ replacementArguments: contextGcApplyPatchInputReplacement(patchCall.message.arguments, result),
562
561
  providerAliasTargets: patch.aliases
563
562
  .map(({ record, message }) => targetFor(record, message))
564
563
  .filter((target) => target !== undefined),
@@ -589,8 +588,6 @@ function collectStageACandidates(input, groups, existingReplacements, existingTa
589
588
  replacement: contextGcStaleReadReplacement({
590
589
  path: item.path,
591
590
  content: item.content,
592
- evidenceSequence,
593
- supersededByCallId: patch.callId,
594
591
  operation: matched.operation
595
592
  }),
596
593
  evidenceSequence,
@@ -693,9 +690,7 @@ function collectSubagentCandidates(input, groups, existingTargets, candidateSavi
693
690
  replacementContent: contextGcSubagentOutputReplacement({
694
691
  sourceContent,
695
692
  source: source.snapshot,
696
- terminal: terminal.snapshot,
697
- terminalCallId: terminal.group.callId,
698
- evidenceSequence
693
+ terminal: terminal.snapshot
699
694
  }),
700
695
  terminalToolName: terminal.group.toolName,
701
696
  terminalCallId: terminal.group.callId,
@@ -819,7 +814,7 @@ function collectExecCandidates(input, groups, existingTargets, candidateSavings)
819
814
  toolName: invocation.group.toolName,
820
815
  callId: invocation.group.callId,
821
816
  target: callTarget,
822
- replacementArguments: contextGcExecInputReplacement(invocation.input, 3, invocation.group.toolName),
817
+ replacementArguments: contextGcExecInputReplacement(invocation.input, invocation.group.toolName),
823
818
  providerAliasTargets: invocation.group.aliases
824
819
  .map(({ record, message }) => targetFor(record, message))
825
820
  .filter((target) => target !== undefined),
@@ -1274,7 +1269,6 @@ function targetFor(record, message) {
1274
1269
  role: message.role,
1275
1270
  ...(callId === undefined ? {} : { callId }),
1276
1271
  ...(toolName === undefined ? {} : { toolName }),
1277
- sourceHash: contextGcRecordSourceHash(record),
1278
1272
  ...(message.observationId ? { observationId: message.observationId } : {})
1279
1273
  };
1280
1274
  }
@@ -1,6 +1,6 @@
1
1
  import type { ModelMessage } from '../../model/contracts.js';
2
2
  import { type ContextGcCheckpointCache, type ContextGcCheckpointPayload, type ContextGcReplacement } from '../../session/context-gc-checkpoint.js';
3
- import type { SessionRecord } from '../../session/jsonl-store.js';
3
+ import type { SessionRecord } from '../../session/store/index.js';
4
4
  export interface ContextProjectionEntry {
5
5
  readonly record: SessionRecord;
6
6
  readonly message: ModelMessage;
@@ -1,7 +1,7 @@
1
1
  import { anthropicThinkingBlock } from '../../model/anthropic-thinking.js';
2
2
  import { appliedInputRecord } from '../../session/deferred-input.js';
3
- import { inputMetadataFromRecord } from '../../session/jsonl-store.js';
4
- import { contextGcRecordSourceHash, contextGcTargetKey, latestValidContextGcCheckpoint } from '../../session/context-gc-checkpoint.js';
3
+ import { inputMetadataFromRecord } from '../../session/store/index.js';
4
+ import { contextGcTargetKey, latestValidContextGcCheckpoint } from '../../session/context-gc-checkpoint.js';
5
5
  import { TOOL_EXECUTION_LIMITS } from '../../tools/execution-limits.js';
6
6
  import { replaceReadContextItems } from '../../tools/local/read-context.js';
7
7
  import { parseCodeCalls, parseObservations, renderObservationResult } from '../../tools/code-mode/observations.js';
@@ -285,13 +285,11 @@ function targetFromMessage(record, message) {
285
285
  recordId: record.recordId,
286
286
  role: message.role,
287
287
  ...(callId === undefined ? {} : { callId }),
288
- ...(toolName === undefined ? {} : { toolName }),
289
- sourceHash: contextGcRecordSourceHash(record)
288
+ ...(toolName === undefined ? {} : { toolName })
290
289
  };
291
290
  }
292
291
  function targetMatchesReplacement(left, right) {
293
292
  return (contextGcTargetKey(left) === contextGcTargetKey(right) &&
294
- left.sourceHash === right.sourceHash &&
295
293
  (right.toolName === undefined || right.toolName === left.toolName));
296
294
  }
297
295
  function cloneMessage(message) {
@@ -1,19 +1,19 @@
1
1
  import type { ModelMessage } from '../../model/contracts.js';
2
- import { type CompactUserInput, type JsonlSessionStore } from '../../session/jsonl-store.js';
2
+ import { type CompactUserInput, type JsonlSessionStore } from '../../session/store/index.js';
3
3
  import type { EnvironmentContextState } from './contracts.js';
4
4
  import { type ContextProjection } from './projection.js';
5
- export declare function restoreMessages(store: JsonlSessionStore, sessionId: string, records: readonly import('../../session/jsonl-store.js').SessionRecord[], options: {
5
+ export declare function restoreMessages(store: JsonlSessionStore, sessionId: string, records: readonly import('../../session/store/index.js').SessionRecord[], options: {
6
6
  includeImages: boolean;
7
7
  strictImages?: boolean;
8
8
  currentTurnId?: string;
9
9
  projection?: ContextProjection;
10
- messageSources?: WeakMap<ModelMessage, import('../../session/jsonl-store.js').SessionRecord>;
10
+ messageSources?: WeakMap<ModelMessage, import('../../session/store/index.js').SessionRecord>;
11
11
  }): Promise<{
12
12
  toolOutcomes: WeakMap<ModelMessage, {
13
13
  isError: boolean;
14
14
  result?: unknown;
15
15
  }>;
16
- pendingInputs: Map<string, import("../../session/jsonl-store.js").SessionRecord>;
16
+ pendingInputs: Map<string, import("../../session/store/types.js").SessionRecord>;
17
17
  environmentState: EnvironmentContextState | undefined;
18
18
  userMessages: CompactUserInput[];
19
19
  messages: ModelMessage[];
@@ -1,6 +1,6 @@
1
1
  import { MarAgentError } from '../../error.js';
2
2
  import { appliedInputRecord, pendingDeferredInputs } from '../../session/deferred-input.js';
3
- import { compactSummaryFromCheckpoint, replacementHistoryFromCheckpoint, inputMetadataFromRecord } from '../../session/jsonl-store.js';
3
+ import { compactSummaryFromCheckpoint, replacementHistoryFromCheckpoint, inputMetadataFromRecord } from '../../session/store/index.js';
4
4
  import { compactedHistoryMessages, continuationMessage } from '../compaction/history.js';
5
5
  import { restoreCompactTail } from '../compaction/retained-context.js';
6
6
  import { environmentContextUpdate, restoreEnvironmentState } from './environment.js';
@@ -6,8 +6,8 @@ export interface AuthoritativeModelUsage {
6
6
  readonly historyMessages?: readonly ModelMessage[];
7
7
  readonly appendedMessages?: readonly ModelMessage[];
8
8
  }
9
- export declare function latestModelUsage(records: readonly import('../../session/jsonl-store.js').SessionRecord[], selectedModelId: string): AuthoritativeModelUsage | undefined;
10
- export declare function reasoningEffortBaseline(records: readonly import('../../session/jsonl-store.js').SessionRecord[], modelId: string): MarAgentReasoningEffort | undefined;
9
+ export declare function latestModelUsage(records: readonly import('../../session/store/index.js').SessionRecord[], selectedModelId: string): AuthoritativeModelUsage | undefined;
10
+ export declare function reasoningEffortBaseline(records: readonly import('../../session/store/index.js').SessionRecord[], modelId: string): MarAgentReasoningEffort | undefined;
11
11
  export declare function lastConfigurationEffort(messages: readonly ModelMessage[], modelId: string): MarAgentReasoningEffort | undefined;
12
12
  export declare function shouldUseNativeCompaction(input: {
13
13
  readonly estimatedRequestTokens: number;
@@ -1,6 +1,6 @@
1
1
  import { isDeepStrictEqual } from 'node:util';
2
2
  import { marAgentReasoningEffortSchema } from '../../model/configuration.js';
3
- import { compactSummaryFromCheckpoint } from '../../session/jsonl-store.js';
3
+ import { compactSummaryFromCheckpoint } from '../../session/store/index.js';
4
4
  import { estimatedRequestTokens } from './request-budget.js';
5
5
  export function latestModelUsage(records, selectedModelId) {
6
6
  let usage;
@@ -16,10 +16,10 @@ export interface ContextualWorldState {
16
16
  }>;
17
17
  }
18
18
  export declare function insertContextualWorldState(messages: readonly ModelMessage[], entries: Readonly<ContextualWorldState['entries']>): ModelMessage[];
19
- export declare function latestContextualWorldStateGeneration(records: readonly import('../../session/jsonl-store.js').SessionRecord[]): string | undefined;
19
+ export declare function latestContextualWorldStateGeneration(records: readonly import('../../session/store/index.js').SessionRecord[]): string | undefined;
20
20
  export declare function updatePromptWorldState(state: ContextualWorldState, index: number, parts: readonly ContextualPart[]): ContextualWorldState;
21
21
  export declare function parsePersistedContextualWorldState(payload: unknown): ContextualWorldState | undefined;
22
- export declare function persistContextualWorldState(store: import('../../session/jsonl-store.js').JsonlSessionStore, sessionId: string, state: ContextualWorldState): Promise<void>;
22
+ export declare function persistContextualWorldState(store: import('../../session/store/index.js').JsonlSessionStore, sessionId: string, state: ContextualWorldState): Promise<void>;
23
23
  export declare function updateContextualWorldState(state: ContextualWorldState, index: number, current: {
24
24
  instructionSnapshot: string | undefined;
25
25
  instructionContent: string | undefined;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { MarAgentError } from '../../error.js';
3
3
  import { contextualBlock, contextualChanges } from './contextual-blocks.js';
4
- import { compactSummaryFromCheckpoint } from '../../session/jsonl-store.js';
4
+ import { compactSummaryFromCheckpoint } from '../../session/store/index.js';
5
5
  export function insertContextualWorldState(messages, entries) {
6
6
  const result = [...messages];
7
7
  // Entries can be restored before the latest user after Compact. Sort anchors,
@@ -7,7 +7,7 @@ import { negotiateHost } from '../host/contracts.js';
7
7
  import { toolCallers } from '../tools/callers.js';
8
8
  import { AnthropicMessagesAdapter } from '../model/anthropic-messages.js';
9
9
  import { OpenAiResponsesAdapter } from '../model/openai-responses.js';
10
- import { JsonlSessionStore } from '../session/jsonl-store.js';
10
+ import { JsonlSessionStore } from '../session/store/index.js';
11
11
  /** Validate models before Host negotiation and expose only built-in protocol adapters. */
12
12
  export async function createMarAgent(options) {
13
13
  if (Object.hasOwn(options, 'adapterFactory'))
@@ -100,7 +100,7 @@ export async function createMarAgentWithAdapter(options) {
100
100
  return schedule(definition, run);
101
101
  },
102
102
  baseTools: (id, context) => {
103
- const execution = sessionRuntimes.get(id)?.toolSources;
103
+ const execution = sessionRuntimes.get(id)?.execution?.toolSources;
104
104
  if (context?.executionId && execution?.executionId === context.executionId)
105
105
  return execution.bindings;
106
106
  return (options.host.extensionPorts?.tools?.catalog(id, context?.executionId) ?? []).map((source) => ({
@@ -28,7 +28,11 @@ export function createExtensionAgentsBackend(input) {
28
28
  throw new MarAgentError(created.errorCode ?? 'MAR_AGENT_SUBAGENT_FAILED', created.errorMessage ?? 'Agent could not start.');
29
29
  }
30
30
  })),
31
- list: (call) => withController(call, async (controller) => controller.inspectAll()),
31
+ list: (call) => withController(call, async (controller) => {
32
+ await controller.prepareAll(call.signal);
33
+ call.signal.throwIfAborted();
34
+ return controller.inspectAll();
35
+ }),
32
36
  inspect: (target, call) => withController(call, (controller) => controller.inspect(target.agentId)),
33
37
  wait: (target, call) => withController(call, (controller) => {
34
38
  const selection = parseAgentWaitTargets(target);
@@ -1,7 +1,7 @@
1
1
  import type { CoreOperationContext } from '../extensions/operation.js';
2
2
  import { type CorePromptInput, type CorePromptResult } from '../extensions/prompt-input.js';
3
3
  import type { SessionInputCoordinator } from '../extensions/session-input.js';
4
- import type { SessionRecord } from '../session/jsonl-store.js';
4
+ import type { SessionRecord } from '../session/store/index.js';
5
5
  import type { SteerInput, SteerResult } from './types.js';
6
6
  /** Admission reserves the existing FIFO before any asynchronous Hook or writer work. */
7
7
  export declare function createNativeSteer(input: {
@@ -10,13 +10,29 @@ import type { HostDescription, MarAgentHost } from '../host/contracts.js';
10
10
  import { type MarAgentReasoningEffort } from '../model/configuration.js';
11
11
  import type { ModelAdapter, ModelMessage } from '../model/contracts.js';
12
12
  import { CompactRequests } from '../runtime/compaction/requests.js';
13
- import { JsonlSessionStore } from '../session/jsonl-store.js';
13
+ import { JsonlSessionStore } from '../session/store/index.js';
14
14
  import { SubagentSessionController, type SubagentMailboxMessage, type SubagentMessageDelivery, type SubagentTurnHandle } from '../subagent/session-controller.js';
15
15
  import { createSessionToolScheduler } from '../tools/scheduler.js';
16
16
  import { TodoStore } from '../tools/agent/todo.js';
17
- import type { CreateMarAgentOptions, ExecutionResult, MarAgentSession } from './types.js';
18
- export interface SessionRuntime {
17
+ import type { CreateMarAgentOptions, ExecutionMode, ExecutionResult, MarAgentSession } from './types.js';
18
+ interface SessionExecutionContext {
19
+ readonly executionId: string;
20
+ readonly modelId: string;
21
+ readonly mode: ExecutionMode;
22
+ readonly models: ReadonlyMap<string, ResolvedModelConfiguration>;
23
+ readonly instruction: string | undefined;
19
24
  steer?: (input: import('./types.js').SteerInput) => Promise<import('./types.js').SteerResult>;
25
+ compactRequests?: CompactRequests;
26
+ requestMessages?: {
27
+ read(): readonly ModelMessage[];
28
+ };
29
+ appendedMessages?: {
30
+ append(recordId: string, message: ModelMessage): void;
31
+ };
32
+ toolSources?: ExecutionToolSources;
33
+ }
34
+ export interface SessionRuntime {
35
+ execution?: SessionExecutionContext;
20
36
  todo?: TodoStore;
21
37
  readonly scheduleTool: ReturnType<typeof createSessionToolScheduler>;
22
38
  readonly sourceType: 'user' | 'subagent';
@@ -26,22 +42,12 @@ export interface SessionRuntime {
26
42
  subagents?: SubagentSessionController;
27
43
  subagentsOpening?: Promise<SubagentSessionController>;
28
44
  inputs?: SessionInputCoordinator;
29
- compactRequests?: CompactRequests;
30
45
  requestSnapshots?: ExtensionRequestSnapshots;
31
- requestMessages?: {
32
- readonly executionId: string;
33
- read(): readonly ModelMessage[];
34
- };
35
46
  recordProjection?: Promise<unknown>;
36
- appendedMessages?: {
37
- readonly executionId: string;
38
- append(recordId: string, message: ModelMessage): void;
39
- };
40
47
  sessionBackend?: CoreSessionBackend & {
41
48
  kick(): void;
42
49
  };
43
50
  agentsBackend?: CoreAgentsBackend;
44
- toolSources?: ExecutionToolSources;
45
51
  }
46
52
  interface InternalMarAgentSession extends MarAgentSession {
47
53
  startSubagentTurn(input: {