@myagentroam/agent 0.11.13 → 0.11.15
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/host/contracts.d.ts +2 -2
- package/dist/agent-core/host/contracts.js +1 -2
- package/dist/agent-core/host/local-agent-host.js +1 -2
- package/dist/agent-core/runtime/compaction/requests.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 +2 -2
- package/dist/agent-core/runtime/context/gc-runtime.js +9 -6
- package/dist/agent-core/runtime/context/gc.js +43 -29
- package/dist/agent-core/runtime/context/projection.d.ts +1 -1
- package/dist/agent-core/runtime/context/projection.js +4 -4
- package/dist/agent-core/runtime/context/restore.d.ts +3 -2
- package/dist/agent-core/runtime/context/restore.js +2 -3
- package/dist/agent-core/runtime/context/usage.js +1 -1
- package/dist/agent-core/runtime/context/world-state.d.ts +1 -1
- package/dist/agent-core/runtime/context/world-state.js +1 -1
- package/dist/agent-core/runtime/execution-handle.d.ts +12 -0
- package/dist/agent-core/runtime/execution-handle.js +1 -0
- package/dist/agent-core/sdk/agent.js +140 -63
- package/dist/agent-core/sdk/session.d.ts +3 -3
- package/dist/agent-core/sdk/session.js +3 -1
- package/dist/agent-core/sdk/subagent-backend.d.ts +2 -2
- package/dist/agent-core/sdk/types.d.ts +6 -13
- package/dist/agent-core/session/catalog.d.ts +8 -2
- package/dist/agent-core/session/catalog.js +48 -10
- package/dist/agent-core/session/context-gc-checkpoint.d.ts +4 -2
- package/dist/agent-core/session/context-gc-checkpoint.js +15 -7
- package/dist/agent-core/session/store/contracts.d.ts +148 -0
- package/dist/agent-core/session/store/contracts.js +1 -0
- package/dist/agent-core/session/store/execution-state.js +0 -12
- package/dist/agent-core/session/store/jsonl-store.d.ts +7 -30
- package/dist/agent-core/session/store/jsonl-store.js +133 -47
- package/dist/agent-core/session/store/types.d.ts +0 -3
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import type { CoreEnvironmentBackend } from '../extensions/environment.js';
|
|
|
7
7
|
import type { CoreOperationContext } from '../extensions/operation.js';
|
|
8
8
|
import type { CoreToolRef } from '../extensions/tools.js';
|
|
9
9
|
export declare const MAR_AGENT_HOST_API_VERSION = "1.0";
|
|
10
|
-
export type MarAgentHostCapability = 'workspace.read' | 'workspace.patch' | 'process.manage' | 'code.execute' | 'user-input.request' | 'event.publish'
|
|
10
|
+
export type MarAgentHostCapability = 'workspace.read' | 'workspace.patch' | 'process.manage' | 'code.execute' | 'user-input.request' | 'event.publish';
|
|
11
11
|
export interface HostDescription {
|
|
12
12
|
apiVersion: string;
|
|
13
13
|
mode: 'normal' | 'node';
|
|
@@ -51,7 +51,7 @@ export interface HostSessionResourceSnapshot {
|
|
|
51
51
|
cwd: string;
|
|
52
52
|
}[];
|
|
53
53
|
}
|
|
54
|
-
/** The Host owns workspace/tool effects;
|
|
54
|
+
/** The Host owns workspace/tool effects; SessionStore is injected or defaults to SDK-owned JSONL. */
|
|
55
55
|
export interface MarAgentHost {
|
|
56
56
|
/** Independent model consumption facts, including child and auxiliary calls. */
|
|
57
57
|
modelUsage?: import('../model/usage-observer.js').ModelUsageObserver | undefined;
|
|
@@ -5,8 +5,7 @@ const requiredCapabilities = [
|
|
|
5
5
|
'workspace.patch',
|
|
6
6
|
'process.manage',
|
|
7
7
|
'user-input.request',
|
|
8
|
-
'event.publish'
|
|
9
|
-
'session.store'
|
|
8
|
+
'event.publish'
|
|
10
9
|
];
|
|
11
10
|
export function negotiateHost(description) {
|
|
12
11
|
const match = /^(\d+)\.(\d+)$/.exec(description.apiVersion);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompactInput, ExecutionHandle } from '
|
|
1
|
+
import type { CompactInput, ExecutionHandle } from '../execution-handle.js';
|
|
2
2
|
import type { MarAgentEvent } from '../events.js';
|
|
3
3
|
import type { CompactFlight } from './coordinator.js';
|
|
4
4
|
/** External handles represent an operation inside its owning main Execution, not another loop. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseModelInputMetadata } from '../../session/store/
|
|
1
|
+
import { parseModelInputMetadata } from '../../session/store/execution-state.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 {
|
|
2
|
+
import type { SessionRecord } from '../../session/store/contracts.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/store/
|
|
2
|
+
import { compactSummaryFromCheckpoint } from '../../session/store/execution-state.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,9 +1,9 @@
|
|
|
1
1
|
import type { ClientToolDefinition, ModelUsage } from '../../model/contracts.js';
|
|
2
2
|
import { type ContextGcPlatform } from '../../session/context-gc-checkpoint.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { SessionStore, SessionRecord } from '../../session/store/contracts.js';
|
|
4
4
|
import { type ContextProjection } from './projection.js';
|
|
5
5
|
export interface ContextGcRuntimeInput {
|
|
6
|
-
readonly store:
|
|
6
|
+
readonly store: SessionStore;
|
|
7
7
|
readonly sessionId: string;
|
|
8
8
|
readonly records?: readonly SessionRecord[];
|
|
9
9
|
readonly system: string;
|
|
@@ -100,13 +100,16 @@ async function attemptContextGc(input) {
|
|
|
100
100
|
records =
|
|
101
101
|
input.records ?? (await input.store.readExecutionState(input.sessionId)).contextRecords;
|
|
102
102
|
const checkpointCache = new ContextGcCheckpointCache();
|
|
103
|
-
const previous = checkpointCache.read(records
|
|
103
|
+
const previous = checkpointCache.read(records);
|
|
104
104
|
if (previous) {
|
|
105
105
|
deferred = {
|
|
106
106
|
...deferred,
|
|
107
107
|
checkpointTrigger: previous.payload.trigger,
|
|
108
108
|
protectedCandidatesPending: previous.payload.metrics.protectedCandidateTokens > 0
|
|
109
109
|
};
|
|
110
|
+
}
|
|
111
|
+
if (previous?.payload.trigger.modelId === input.modelId &&
|
|
112
|
+
previous.payload.trigger.contextWindowTokens === input.contextWindowTokens) {
|
|
110
113
|
const rolloutGrowth = records.filter((record) => record.sequence > previous.record.sequence &&
|
|
111
114
|
record.type === 'model.attempt' &&
|
|
112
115
|
isRecord(record.payload) &&
|
|
@@ -120,7 +123,7 @@ async function attemptContextGc(input) {
|
|
|
120
123
|
contextGcMinimumUsageGrowth(input.contextWindowTokens))
|
|
121
124
|
return deferred;
|
|
122
125
|
}
|
|
123
|
-
const projection = buildContextProjection(records,
|
|
126
|
+
const projection = buildContextProjection(records, checkpointCache);
|
|
124
127
|
const inspection = inspectContextGc({
|
|
125
128
|
records,
|
|
126
129
|
checkpointCache,
|
|
@@ -159,14 +162,14 @@ async function attemptContextGc(input) {
|
|
|
159
162
|
const committed = await input.store.commitContextGc(input.sessionId, draft, records);
|
|
160
163
|
return {
|
|
161
164
|
...deferred,
|
|
162
|
-
result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft,
|
|
165
|
+
result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, records, committed)
|
|
163
166
|
};
|
|
164
167
|
}
|
|
165
168
|
catch (commitError) {
|
|
166
169
|
try {
|
|
167
170
|
return {
|
|
168
171
|
...deferred,
|
|
169
|
-
result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft,
|
|
172
|
+
result: await matchingCheckpointWasPersisted(input.store, input.sessionId, draft, records)
|
|
170
173
|
};
|
|
171
174
|
}
|
|
172
175
|
catch {
|
|
@@ -176,7 +179,7 @@ async function attemptContextGc(input) {
|
|
|
176
179
|
return deferred;
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
|
-
async function matchingCheckpointWasPersisted(store, sessionId, draft,
|
|
182
|
+
async function matchingCheckpointWasPersisted(store, sessionId, draft, records, committed) {
|
|
180
183
|
const record = committed ??
|
|
181
184
|
(await store.readPage(sessionId, {
|
|
182
185
|
limit: 1,
|
|
@@ -185,7 +188,7 @@ async function matchingCheckpointWasPersisted(store, sessionId, draft, workspace
|
|
|
185
188
|
if (record?.sequence !== draft.boundarySequence + 1 || record.type !== 'context.gc.completed')
|
|
186
189
|
return false;
|
|
187
190
|
const updatedRecords = [...records, record];
|
|
188
|
-
const projection = buildContextProjection(updatedRecords
|
|
191
|
+
const projection = buildContextProjection(updatedRecords);
|
|
189
192
|
if (committed)
|
|
190
193
|
return { records: updatedRecords, projection };
|
|
191
194
|
const payload = projection.checkpoint;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { codeCallEvidence, codePartialPatchCallEvidence, codeObservationEvidence, retainedCodeInputs } from '../../session/context-gc-observations.js';
|
|
2
|
-
import { ContextGcCheckpointCache, contextGcBaseFromRecords, contextGcLogicalPathKey, contextGcMinimumUsageGrowth, contextGcTargetKey, normalizeContextGcReplacements } from '../../session/context-gc-checkpoint.js';
|
|
2
|
+
import { ContextGcCheckpointCache, contextGcBaseFromRecords, contextGcCheckpointIntervalEligible, 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';
|
|
@@ -131,15 +131,25 @@ export function inspectContextGc(input) {
|
|
|
131
131
|
if (!usageRecord)
|
|
132
132
|
return {};
|
|
133
133
|
const normalRolloutOrdinal = countSuccessfulNormalRollouts(input.records, input.modelId, input.contextWindowTokens);
|
|
134
|
-
const previous = input.checkpointCache.read(input.records
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
const previous = input.checkpointCache.read(input.records);
|
|
135
|
+
const checkpointEligible = contextGcCheckpointIntervalEligible({
|
|
136
|
+
usageSequence: usageRecord.sequence,
|
|
137
|
+
contextInputTokens: contextUsageTokens,
|
|
138
|
+
contextWindowTokens: input.contextWindowTokens,
|
|
139
|
+
normalRolloutOrdinal,
|
|
140
|
+
modelId: input.modelId,
|
|
141
|
+
platform: input.platform
|
|
142
|
+
}, previous?.payload.trigger);
|
|
143
|
+
// Discovery and economic evaluation have their own low-growth opportunities;
|
|
144
|
+
// neither a protected candidate nor periodic discovery makes a draft eligible.
|
|
145
|
+
if (previous?.payload.trigger.modelId === input.modelId &&
|
|
146
|
+
previous.payload.trigger.contextWindowTokens === input.contextWindowTokens) {
|
|
138
147
|
const rolloutGrowth = normalRolloutOrdinal - previous.payload.trigger.normalRolloutOrdinal;
|
|
139
148
|
if (rolloutGrowth < 2 ||
|
|
140
|
-
(
|
|
149
|
+
(previous.payload.metrics.protectedCandidateTokens === 0 &&
|
|
141
150
|
rolloutGrowth < CONTEXT_GC_POLICY.largeExecProtectionRollouts &&
|
|
142
|
-
contextUsageTokens - previous.payload.trigger.contextInputTokens <
|
|
151
|
+
contextUsageTokens - previous.payload.trigger.contextInputTokens <
|
|
152
|
+
contextGcMinimumUsageGrowth(input.contextWindowTokens)))
|
|
143
153
|
return {};
|
|
144
154
|
}
|
|
145
155
|
if (input.messages.length !== input.messageSources.length)
|
|
@@ -188,41 +198,45 @@ export function inspectContextGc(input) {
|
|
|
188
198
|
normalRolloutOrdinal,
|
|
189
199
|
protectedCandidateTokens
|
|
190
200
|
});
|
|
191
|
-
const plan =
|
|
201
|
+
const plan = checkpointEligible
|
|
202
|
+
? finalizePlan(input, marginal ?? stageAPlanWithProtectedCandidates)
|
|
203
|
+
: undefined;
|
|
192
204
|
const retryAfterRollouts = Math.min(exec.retryAfterRollouts, codeMode.retryAfterRollouts, web.retryAfterRollouts);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
205
|
+
if (!plan && checkpointEligible)
|
|
206
|
+
return {};
|
|
207
|
+
return {
|
|
208
|
+
...(plan ? { plan } : {}),
|
|
209
|
+
...(protectedCandidateTokens > 0 && Number.isFinite(retryAfterRollouts)
|
|
210
|
+
? { retryAfterRollouts }
|
|
211
|
+
: {})
|
|
212
|
+
};
|
|
201
213
|
}
|
|
202
214
|
const exec = collectExecCandidates(input, groups, existingTargets, candidateSavings);
|
|
203
215
|
const codeMode = collectCodeModeCandidates(input, groups, existingTargets, candidateSavings);
|
|
204
216
|
const web = collectWebCandidates(input, groups, existingTargets, candidateSavings);
|
|
217
|
+
const protectedCandidateTokens = deterministicProtectedTokens +
|
|
218
|
+
exec.protectedTokens +
|
|
219
|
+
codeMode.protectedTokens +
|
|
220
|
+
web.protectedTokens;
|
|
205
221
|
const combined = evaluateCandidateSet(input, existing, [...deterministicCandidates, ...exec.eligible, ...codeMode.eligible, ...web.eligible], {
|
|
206
222
|
stage: 'STAGE_A_AND_EXEC',
|
|
207
223
|
contextUsageTokens,
|
|
208
224
|
usageRatio,
|
|
209
225
|
usageRecord,
|
|
210
226
|
normalRolloutOrdinal,
|
|
211
|
-
protectedCandidateTokens
|
|
212
|
-
exec.protectedTokens +
|
|
213
|
-
codeMode.protectedTokens +
|
|
214
|
-
web.protectedTokens
|
|
227
|
+
protectedCandidateTokens
|
|
215
228
|
});
|
|
216
|
-
if (combined?.economics.passes) {
|
|
229
|
+
if (combined?.economics.passes && checkpointEligible) {
|
|
217
230
|
const plan = finalizePlan(input, combined);
|
|
218
231
|
return plan ? { plan } : {};
|
|
219
232
|
}
|
|
220
233
|
const retryAfterRollouts = Math.min(stageA.retryAfterRollouts, subagent.retryAfterRollouts, exec.retryAfterRollouts, codeMode.retryAfterRollouts, web.retryAfterRollouts);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
234
|
+
// A worthwhile mixed set retains every positive protected candidate's retry
|
|
235
|
+
// hint even when the checkpoint interval prevents a durable draft.
|
|
236
|
+
return protectedCandidateTokens > 0 &&
|
|
237
|
+
(combined?.economics.passes ||
|
|
238
|
+
protectedCandidateTokens >=
|
|
239
|
+
contextGcMinimumReclaimedTokens(contextUsageTokens, input.contextWindowTokens)) &&
|
|
226
240
|
Number.isFinite(retryAfterRollouts)
|
|
227
241
|
? { retryAfterRollouts }
|
|
228
242
|
: {};
|
|
@@ -459,7 +473,7 @@ function evaluateCandidateSet(input, existing, candidates, state) {
|
|
|
459
473
|
if (reclaimedTokens === 0)
|
|
460
474
|
return undefined;
|
|
461
475
|
const cache = contextGcCacheImpact(input, input.messages, projected.messages, input.usage.cacheReadTokens ?? 0, reclaimedTokens);
|
|
462
|
-
const growthSamples = collectContextGrowthSamples(input.records, input.modelId, input.contextWindowTokens, input.
|
|
476
|
+
const growthSamples = collectContextGrowthSamples(input.records, input.modelId, input.contextWindowTokens, input.checkpointCache);
|
|
463
477
|
const contextGrowthP75Tokens = percentile75(growthSamples);
|
|
464
478
|
const compactThresholdTokens = Math.floor(input.contextWindowTokens * COMPACT_THRESHOLD_RATIO);
|
|
465
479
|
// Usage describes the request before its generated output and tool results.
|
|
@@ -1098,8 +1112,8 @@ function latestUsageRecord(records, selectedModelId) {
|
|
|
1098
1112
|
}
|
|
1099
1113
|
return latest;
|
|
1100
1114
|
}
|
|
1101
|
-
function collectContextGrowthSamples(records, modelId, contextWindowTokens,
|
|
1102
|
-
const previous = checkpointCache.read(records
|
|
1115
|
+
function collectContextGrowthSamples(records, modelId, contextWindowTokens, checkpointCache) {
|
|
1116
|
+
const previous = checkpointCache.read(records);
|
|
1103
1117
|
const base = contextGcBaseFromRecords(records);
|
|
1104
1118
|
const startSequence = previous?.record.sequence ?? (base?.type === 'COMPACT' ? base.sequence : base?.firstSequence);
|
|
1105
1119
|
let activeModelId = modelId;
|
|
@@ -9,7 +9,7 @@ export interface ContextProjection {
|
|
|
9
9
|
readonly entries: readonly ContextProjectionEntry[];
|
|
10
10
|
readonly checkpoint?: ContextGcCheckpointPayload;
|
|
11
11
|
}
|
|
12
|
-
export declare function buildContextProjection(records: readonly SessionRecord[],
|
|
12
|
+
export declare function buildContextProjection(records: readonly SessionRecord[], checkpointCache?: ContextGcCheckpointCache): ContextProjection;
|
|
13
13
|
export declare function applyContextGcReplacementsToMessages(messages: readonly ModelMessage[], messageSources: readonly SessionRecord[], replacements: readonly ContextGcReplacement[]): {
|
|
14
14
|
readonly messages: ModelMessage[];
|
|
15
15
|
readonly messageSources: SessionRecord[];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { restoreNativeModelContext } from '../../model/native-context.js';
|
|
2
2
|
import { appliedInputRecord } from '../../session/deferred-input.js';
|
|
3
|
-
import { inputMetadataFromRecord } from '../../session/store/
|
|
3
|
+
import { inputMetadataFromRecord } from '../../session/store/execution-state.js';
|
|
4
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';
|
|
8
8
|
const MAX_MODEL_CONTEXT_BYTES = 1024 * 1024;
|
|
9
|
-
export function buildContextProjection(records,
|
|
9
|
+
export function buildContextProjection(records, checkpointCache) {
|
|
10
10
|
let activeModelId;
|
|
11
11
|
const rawEntries = [];
|
|
12
12
|
for (const record of records) {
|
|
@@ -33,8 +33,8 @@ export function buildContextProjection(records, workspace, checkpointCache) {
|
|
|
33
33
|
rawEntries.push({ record, message });
|
|
34
34
|
}
|
|
35
35
|
const valid = checkpointCache
|
|
36
|
-
? checkpointCache.read(records
|
|
37
|
-
: latestValidContextGcCheckpoint(records
|
|
36
|
+
? checkpointCache.read(records)
|
|
37
|
+
: latestValidContextGcCheckpoint(records);
|
|
38
38
|
const messages = rawEntries.flatMap((entry) => (entry.message ? [entry.message] : []));
|
|
39
39
|
const sources = rawEntries.flatMap((entry) => (entry.message ? [entry.record] : []));
|
|
40
40
|
const applied = applyContextGcReplacementsToMessages(messages, sources, valid?.payload.replacements ?? []);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { SessionStore } from '../../session/store/contracts.js';
|
|
1
2
|
import type { ModelMessage } from '../../model/contracts.js';
|
|
2
|
-
import {
|
|
3
|
+
import type { CompactUserInput } from '../../session/store/contracts.js';
|
|
3
4
|
import type { EnvironmentContextState } from './contracts.js';
|
|
4
5
|
import { type ContextProjection } from './projection.js';
|
|
5
|
-
export declare function restoreMessages(store:
|
|
6
|
+
export declare function restoreMessages(store: SessionStore, sessionId: string, records: readonly import('../../session/store/index.js').SessionRecord[], options: {
|
|
6
7
|
includeImages: boolean;
|
|
7
8
|
strictImages?: boolean;
|
|
8
9
|
currentTurnId?: string;
|
|
@@ -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/store/
|
|
3
|
+
import { compactSummaryFromCheckpoint, replacementHistoryFromCheckpoint, inputMetadataFromRecord } from '../../session/store/execution-state.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';
|
|
@@ -9,8 +9,7 @@ export async function restoreMessages(store, sessionId, records, options) {
|
|
|
9
9
|
const messages = [];
|
|
10
10
|
const outcomes = new Map();
|
|
11
11
|
const toolOutcomes = new WeakMap();
|
|
12
|
-
const modelProjection = new Map((options.projection ??
|
|
13
|
-
buildContextProjection(records, (await store.getSession(sessionId)).workspace)).entries.map((entry) => [entry.record.recordId, entry.message]));
|
|
12
|
+
const modelProjection = new Map((options.projection ?? buildContextProjection(records)).entries.map((entry) => [entry.record.recordId, entry.message]));
|
|
14
13
|
let userMessages = [];
|
|
15
14
|
let ignoredImages = 0;
|
|
16
15
|
let currentTurnUserIndex;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from 'node:util';
|
|
2
2
|
import { marAgentReasoningEffortSchema } from '../../model/configuration.js';
|
|
3
|
-
import { compactSummaryFromCheckpoint } from '../../session/store/
|
|
3
|
+
import { compactSummaryFromCheckpoint } from '../../session/store/execution-state.js';
|
|
4
4
|
import { estimatedRequestTokens } from './request-budget.js';
|
|
5
5
|
export function latestModelUsage(records, selectedModelId) {
|
|
6
6
|
let usage;
|
|
@@ -19,7 +19,7 @@ export declare function insertContextualWorldState(messages: readonly ModelMessa
|
|
|
19
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/store/
|
|
22
|
+
export declare function persistContextualWorldState(store: import('../../session/store/contracts.js').SessionStore, 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/store/
|
|
4
|
+
import { compactSummaryFromCheckpoint } from '../../session/store/execution-state.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,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExecutionResult, RunInput } from './contracts.js';
|
|
2
|
+
import type { MarAgentEvent } from './events.js';
|
|
3
|
+
/** A live execution exposes streamed events separately from its terminal result. */
|
|
4
|
+
export interface ExecutionHandle extends AsyncIterable<MarAgentEvent> {
|
|
5
|
+
readonly executionId: string;
|
|
6
|
+
result(): Promise<ExecutionResult>;
|
|
7
|
+
/** Signals abort; await result() to observe the terminal status and cleanup. */
|
|
8
|
+
cancel(): void;
|
|
9
|
+
}
|
|
10
|
+
export type CompactInput = Partial<RunInput> & {
|
|
11
|
+
readonly async?: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|