@myagentroam/agent 0.10.59 → 0.10.60
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.
- package/dist/agent-core/runtime/compaction/history.d.ts +1 -1
- package/dist/agent-core/runtime/compaction/retained-context.d.ts +1 -1
- package/dist/agent-core/runtime/compaction/retained-context.js +1 -1
- package/dist/agent-core/runtime/compaction/smart.d.ts +1 -1
- package/dist/agent-core/runtime/compaction/smart.js +1 -1
- package/dist/agent-core/runtime/context/gc-runtime.d.ts +1 -1
- package/dist/agent-core/runtime/context/gc-runtime.js +20 -14
- package/dist/agent-core/runtime/context/gc.d.ts +1 -1
- package/dist/agent-core/runtime/context/gc.js +4 -10
- package/dist/agent-core/runtime/context/projection.d.ts +1 -1
- package/dist/agent-core/runtime/context/projection.js +3 -5
- package/dist/agent-core/runtime/context/restore.d.ts +4 -4
- package/dist/agent-core/runtime/context/restore.js +1 -1
- package/dist/agent-core/runtime/context/usage.d.ts +2 -2
- package/dist/agent-core/runtime/context/usage.js +1 -1
- package/dist/agent-core/runtime/context/world-state.d.ts +2 -2
- package/dist/agent-core/runtime/context/world-state.js +1 -1
- package/dist/agent-core/sdk/agent.js +1 -1
- package/dist/agent-core/sdk/native-steer.d.ts +1 -1
- package/dist/agent-core/sdk/session.d.ts +1 -1
- package/dist/agent-core/sdk/session.js +1 -1
- package/dist/agent-core/sdk/subagent-backend.d.ts +1 -1
- package/dist/agent-core/session/catalog.js +1 -1
- package/dist/agent-core/session/context-gc-checkpoint.d.ts +4 -8
- package/dist/agent-core/session/context-gc-checkpoint.js +82 -137
- package/dist/agent-core/session/context-gc-observations.d.ts +1 -1
- package/dist/agent-core/session/context-gc-replacements.d.ts +4 -7
- package/dist/agent-core/session/context-gc-replacements.js +25 -59
- package/dist/agent-core/session/context-gc-subagent.d.ts +0 -3
- package/dist/agent-core/session/context-gc-subagent.js +2 -16
- package/dist/agent-core/session/deferred-input.d.ts +1 -1
- package/dist/agent-core/session/store/current-state.d.ts +17 -0
- package/dist/agent-core/session/store/current-state.js +53 -0
- package/dist/agent-core/session/store/directory-index.d.ts +18 -0
- package/dist/agent-core/session/store/directory-index.js +163 -0
- package/dist/agent-core/session/store/execution-state.d.ts +17 -0
- package/dist/agent-core/session/store/execution-state.js +178 -0
- package/dist/agent-core/session/store/history.d.ts +25 -0
- package/dist/agent-core/session/store/history.js +157 -0
- package/dist/agent-core/session/store/images.d.ts +21 -0
- package/dist/agent-core/session/store/images.js +248 -0
- package/dist/agent-core/session/store/index.d.ts +4 -0
- package/dist/agent-core/session/store/index.js +2 -0
- package/dist/agent-core/session/{jsonl-store.d.ts → store/jsonl-store.d.ts} +12 -92
- package/dist/agent-core/session/{jsonl-store.js → store/jsonl-store.js} +108 -1053
- package/dist/agent-core/session/store/records.d.ts +23 -0
- package/dist/agent-core/session/store/records.js +249 -0
- package/dist/agent-core/session/store/types.d.ts +83 -0
- package/dist/agent-core/session/store/types.js +1 -0
- package/dist/agent-core/session/tool-result-resources.d.ts +1 -1
- package/dist/agent-core/subagent/session-controller.d.ts +1 -1
- package/dist/agent-core/tools/code-mode/state.d.ts +1 -1
- package/dist/agent-core/tools/code-mode/state.js +2 -2
- 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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
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
|
-
|
|
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
|
|
183
|
-
|
|
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:
|
|
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/
|
|
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,
|
|
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
|
|
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,
|
|
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/
|
|
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/
|
|
4
|
-
import {
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
10
|
-
export declare function reasoningEffortBaseline(records: readonly import('../../session/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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'))
|
|
@@ -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/
|
|
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,7 +10,7 @@ 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/
|
|
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';
|
|
@@ -45,7 +45,7 @@ import { AGENT_EXECUTION_POLICY } from '../runtime/execution-policy.js';
|
|
|
45
45
|
import { loadAgentInstructions, renderAgentInstructions } from '../runtime/context/instructions.js';
|
|
46
46
|
import { normalizeMessagesForModel } from '../runtime/context/normalize.js';
|
|
47
47
|
import { latestSmartContextTokens, projectSmartCompactionMessage, requestSmartCompaction } from '../runtime/compaction/smart.js';
|
|
48
|
-
import { compactSummaryFromCheckpoint, inputMetadataFromRecord } from '../session/
|
|
48
|
+
import { compactSummaryFromCheckpoint, inputMetadataFromRecord } from '../session/store/index.js';
|
|
49
49
|
import { SubagentSessionController } from '../subagent/session-controller.js';
|
|
50
50
|
import { agentStartToolDefinitionWithModels } from '../tools/agent/agent-start.js';
|
|
51
51
|
import { allowsDirectTool, allowsToolCaller, toolCallers } from '../tools/callers.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { JsonlSessionStore } from '../session/
|
|
1
|
+
import type { JsonlSessionStore } from '../session/store/index.js';
|
|
2
2
|
import type { SubagentSessionControllerBackend } from '../subagent/session-controller.js';
|
|
3
3
|
export declare function createSubagentBackend(store: JsonlSessionStore, workspace: string): SubagentSessionControllerBackend;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarAgentError } from '../error.js';
|
|
2
2
|
import { publicHostedToolEvents } from '../runtime/event-projection.js';
|
|
3
|
-
import { JsonlSessionStore } from './
|
|
3
|
+
import { JsonlSessionStore } from './store/index.js';
|
|
4
4
|
const MAX_INPUT_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
5
5
|
const INPUT_IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
6
6
|
export async function openMarAgentSessionCatalog(input) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ContextGcWebToolName } from './context-gc-replacements.js';
|
|
2
2
|
import { type ContextGcSubagentToolName } from './context-gc-subagent.js';
|
|
3
|
-
import type { SessionRecord } from './
|
|
3
|
+
import type { SessionRecord } from './store/index.js';
|
|
4
4
|
export declare const CONTEXT_GC_CHECKPOINT_VERSION: 1;
|
|
5
5
|
export declare const CONTEXT_GC_MAX_TARGETS = 4096;
|
|
6
6
|
export type ContextGcPlatform = 'linux' | 'darwin' | 'win32';
|
|
@@ -35,7 +35,6 @@ export interface ContextGcTarget {
|
|
|
35
35
|
readonly role: 'tool_call' | 'tool' | 'provider';
|
|
36
36
|
readonly callId?: string;
|
|
37
37
|
readonly toolName?: string;
|
|
38
|
-
readonly sourceHash: string;
|
|
39
38
|
}
|
|
40
39
|
export interface ContextGcReadItemReplacement {
|
|
41
40
|
readonly supersededByCallId?: string;
|
|
@@ -125,7 +124,6 @@ export interface ContextGcCheckpointDraft {
|
|
|
125
124
|
readonly version: 1;
|
|
126
125
|
readonly base: ContextGcBase;
|
|
127
126
|
readonly boundarySequence: number;
|
|
128
|
-
sourceProjectionHash: string;
|
|
129
127
|
readonly replacements: readonly ContextGcReplacement[];
|
|
130
128
|
readonly trigger: {
|
|
131
129
|
readonly usageSequence: number;
|
|
@@ -145,20 +143,18 @@ export interface ContextGcCheckpointPayload extends ContextGcCheckpointDraft {
|
|
|
145
143
|
/** Disposable memoization for one evaluation's immutable record snapshot. */
|
|
146
144
|
export declare class ContextGcCheckpointCache {
|
|
147
145
|
#private;
|
|
148
|
-
read(records: readonly SessionRecord[], boundarySequence?: number, workspace?: string
|
|
146
|
+
read(records: readonly SessionRecord[], boundarySequence?: number, workspace?: string): ReturnType<typeof latestValidContextGcCheckpoint>;
|
|
149
147
|
}
|
|
150
148
|
export declare function contextGcMinimumUsageGrowth(contextWindowTokens: number): number;
|
|
151
|
-
export declare function contextGcRecordSourceHash(record: Pick<SessionRecord, 'payload'>): string;
|
|
152
149
|
export declare function contextGcLogicalPathKey(path: string, workspace: string, platform?: ContextGcPlatform): string | undefined;
|
|
153
150
|
export declare function contextGcTargetKey(target: ContextGcTarget): string;
|
|
154
151
|
export declare function contextGcReplacementKey(replacement: ContextGcReplacement): string;
|
|
155
152
|
export declare function contextGcBaseFromRecords(records: readonly SessionRecord[], boundarySequence?: number): ContextGcBase | undefined;
|
|
156
153
|
export declare function contextGcBaseSequence(base: ContextGcBase): number;
|
|
157
|
-
export declare function contextGcSourceProjectionHash(records: readonly SessionRecord[], boundarySequence: number, base?: ContextGcBase | undefined): string | undefined;
|
|
158
154
|
export declare function normalizeContextGcReplacements(replacements: readonly ContextGcReplacement[]): ContextGcReplacement[] | undefined;
|
|
159
155
|
export declare function parseContextGcCheckpoint(record: SessionRecord | undefined): ContextGcCheckpointPayload | undefined;
|
|
160
|
-
export declare function validateContextGcCheckpoint(records: readonly SessionRecord[], record: SessionRecord, workspace?: string | undefined): ContextGcCheckpointPayload | undefined;
|
|
161
|
-
export declare function latestValidContextGcCheckpoint(records: readonly SessionRecord[], boundarySequence?: number,
|
|
156
|
+
export declare function validateContextGcCheckpoint(records: readonly SessionRecord[], record: SessionRecord, workspace?: string | undefined, committedReplacements?: readonly ContextGcReplacement[]): ContextGcCheckpointPayload | undefined;
|
|
157
|
+
export declare function latestValidContextGcCheckpoint(records: readonly SessionRecord[], boundarySequence?: number, _workspace?: string): {
|
|
162
158
|
readonly record: SessionRecord;
|
|
163
159
|
readonly payload: ContextGcCheckpointPayload;
|
|
164
160
|
} | undefined;
|