@myagentroam/agent 0.9.62 → 0.9.64
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/dist/cli/codex-auth-file.js +268 -3
- package/dist/cli/main.js +427 -2
- package/dist/error.js +66 -2
- package/dist/host/contracts.js +20 -2
- package/dist/host/local-agent-host.js +146 -2
- package/dist/host/local-process-executor.js +39 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -2
- package/dist/model/anthropic-messages.js +474 -2
- package/dist/model/anthropic-thinking.js +33 -2
- package/dist/model/catalog-file.js +88 -2
- package/dist/model/configuration.js +137 -2
- package/dist/model/contracts.d.ts +2 -0
- package/dist/model/contracts.js +1 -2
- package/dist/model/http.js +529 -2
- package/dist/model/openai-responses.d.ts +2 -0
- package/dist/model/openai-responses.js +1602 -2
- package/dist/model/runtime-credential.js +35 -2
- package/dist/model/sse.js +199 -2
- package/dist/prompts/compact.js +25 -2
- package/dist/prompts/core.js +37 -2
- package/dist/prompts/execution-budget.js +10 -2
- package/dist/prompts/index.d.ts +3 -2
- package/dist/prompts/index.js +47 -2
- package/dist/prompts/modes.js +25 -2
- package/dist/prompts/output.js +1 -2
- package/dist/prompts/resources.d.ts +1 -1
- package/dist/prompts/resources.js +31 -2
- package/dist/prompts/subagent.d.ts +6 -0
- package/dist/prompts/subagent.js +29 -2
- package/dist/prompts/title.js +9 -2
- package/dist/prompts/workflow.js +32 -2
- package/dist/runtime/async-queue.js +62 -2
- package/dist/runtime/builtin-skills.js +19 -2
- package/dist/runtime/byted-ark-imagegen-skill.js +18 -2
- package/dist/runtime/codex-imagegen-skill.js +35 -2
- package/dist/runtime/compact.js +225 -2
- package/dist/runtime/context-gc-runtime.d.ts +35 -0
- package/dist/runtime/context-gc-runtime.js +163 -0
- package/dist/runtime/context-gc-tokens.d.ts +24 -0
- package/dist/runtime/context-gc-tokens.js +83 -0
- package/dist/runtime/context-gc.d.ts +66 -0
- package/dist/runtime/context-gc.js +909 -0
- package/dist/runtime/context-projection.d.ts +23 -0
- package/dist/runtime/context-projection.js +203 -0
- package/dist/runtime/environment-context.js +41 -2
- package/dist/runtime/execution-policy.js +13 -2
- package/dist/runtime/instructions.js +298 -2
- package/dist/runtime/normalize.js +40 -2
- package/dist/runtime/plan-output.js +95 -2
- package/dist/runtime/rollout-budget.d.ts +2 -0
- package/dist/runtime/rollout-budget.js +92 -2
- package/dist/runtime/token-budget.d.ts +2 -0
- package/dist/runtime/token-budget.js +44 -2
- package/dist/sdk/agent.js +1804 -2
- package/dist/sdk/types.d.ts +15 -5
- package/dist/sdk/types.js +1 -2
- package/dist/session/catalog.d.ts +5 -4
- package/dist/session/catalog.js +133 -2
- package/dist/session/context-gc-checkpoint.d.ts +148 -0
- package/dist/session/context-gc-checkpoint.js +665 -0
- package/dist/session/context-gc-replacements.d.ts +52 -0
- package/dist/session/context-gc-replacements.js +226 -0
- package/dist/session/context-gc-subagent.d.ts +43 -0
- package/dist/session/context-gc-subagent.js +267 -0
- package/dist/session/jsonl-store.d.ts +42 -4
- package/dist/session/jsonl-store.js +1657 -2
- package/dist/subagent/scheduler.d.ts +35 -2
- package/dist/subagent/scheduler.js +249 -2
- package/dist/subagent/session-controller.d.ts +94 -0
- package/dist/subagent/session-controller.js +675 -0
- package/dist/tools/agent-cancel.js +28 -2
- package/dist/tools/{task.d.ts → agent-message.d.ts} +2 -2
- package/dist/tools/agent-message.js +51 -0
- package/dist/tools/agent-start.js +84 -2
- package/dist/tools/agent-wait.js +53 -2
- package/dist/tools/apply-patch.js +478 -2
- package/dist/tools/code-mode.js +370 -2
- package/dist/tools/codex-image-gen.js +312 -2
- package/dist/tools/exec.js +455 -2
- package/dist/tools/execution-limits.d.ts +1 -0
- package/dist/tools/execution-limits.js +44 -2
- package/dist/tools/local-registry.js +233 -2
- package/dist/tools/local-workspace-tools.js +28 -2
- package/dist/tools/question.js +124 -2
- package/dist/tools/read-context.d.ts +16 -0
- package/dist/tools/read-context.js +85 -0
- package/dist/tools/read.d.ts +13 -0
- package/dist/tools/read.js +294 -2
- package/dist/tools/registry.js +76 -2
- package/dist/tools/runtime-context.d.ts +9 -2
- package/dist/tools/runtime-context.js +1 -2
- package/dist/tools/runtime.js +21 -2
- package/dist/tools/scheduler.js +41 -2
- package/dist/tools/shared/path-resolver.js +133 -2
- package/dist/tools/skill.js +37 -2
- package/dist/tools/todo-read.js +10 -2
- package/dist/tools/todo-write.js +65 -2
- package/dist/tools/todo.js +67 -2
- package/dist/tools/view-image.js +81 -2
- package/dist/tools/web-fetch.js +11 -2
- package/dist/tools/web-search.js +14 -2
- package/package.json +9 -7
- package/README.md +0 -3
- package/dist/runtime/prompt.d.ts +0 -9
- package/dist/runtime/prompt.js +0 -2
- package/dist/tools/shared/secret-redaction.d.ts +0 -4
- package/dist/tools/shared/secret-redaction.js +0 -2
- package/dist/tools/task-cancel.d.ts +0 -7
- package/dist/tools/task-cancel.js +0 -2
- package/dist/tools/task-output.d.ts +0 -7
- package/dist/tools/task-output.js +0 -2
- package/dist/tools/task-tools.d.ts +0 -36
- package/dist/tools/task-tools.js +0 -2
- package/dist/tools/task.js +0 -2
- package/dist/tools/todo-tools.d.ts +0 -25
- package/dist/tools/todo-tools.js +0 -2
package/dist/sdk/types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { HostDescription } from '../host/contracts.js';
|
|
2
2
|
import type { MarAgentModelConfiguration, MarAgentReasoningEffort } from '../model/configuration.js';
|
|
3
3
|
import type { ModelAdapter } from '../model/contracts.js';
|
|
4
|
+
import type { MarAgentSessionPage, MarAgentSessionSummary } from '../session/catalog.js';
|
|
5
|
+
import type { SessionListInput, SessionSource } from '../session/jsonl-store.js';
|
|
4
6
|
export type AccessMode = 'on-request' | 'full-access';
|
|
5
7
|
export type ExecutionMode = 'run' | 'plan' | 'compact';
|
|
6
8
|
export interface ToolCall {
|
|
@@ -83,6 +85,8 @@ export type MarAgentEvent = MarAgentEventBase & ({
|
|
|
83
85
|
itemId: string;
|
|
84
86
|
phase: 'commentary' | 'final_answer';
|
|
85
87
|
text: string;
|
|
88
|
+
modelId: string;
|
|
89
|
+
modelName: string;
|
|
86
90
|
} | {
|
|
87
91
|
type: 'plan.completed';
|
|
88
92
|
itemId: string;
|
|
@@ -117,7 +121,7 @@ export type MarAgentEvent = MarAgentEventBase & ({
|
|
|
117
121
|
summary: string;
|
|
118
122
|
truncated?: boolean;
|
|
119
123
|
artifacts?: readonly MarAgentToolArtifact[];
|
|
120
|
-
data?: import('../tools/exec.js').ExecResult | Omit<import('../tools/exec.js').ExecResult, 'stdout' | 'stderr'> | import('../tools/apply-patch.js').ApplyPatchResult | import('../tools/view-image.js').ViewImageResult | import('../subagent/scheduler.js').SubagentTaskSnapshot;
|
|
124
|
+
data?: import('../tools/exec.js').ExecResult | Omit<import('../tools/exec.js').ExecResult, 'stdout' | 'stderr'> | import('../tools/apply-patch.js').ApplyPatchResult | import('../tools/read.js').ReadEventData | import('../tools/view-image.js').ViewImageResult | import('../subagent/scheduler.js').SubagentTaskSnapshot;
|
|
121
125
|
} | {
|
|
122
126
|
type: 'tool.failed';
|
|
123
127
|
toolName: string;
|
|
@@ -146,11 +150,18 @@ export type MarAgentEvent = MarAgentEventBase & ({
|
|
|
146
150
|
type: 'subagent.started';
|
|
147
151
|
agentId: string;
|
|
148
152
|
description: string;
|
|
153
|
+
modelId?: string;
|
|
154
|
+
modelName?: string;
|
|
155
|
+
reasoningEffort?: MarAgentReasoningEffort;
|
|
149
156
|
} | {
|
|
150
157
|
type: 'subagent.completed';
|
|
151
158
|
agentId: string;
|
|
152
159
|
description?: string;
|
|
153
160
|
status: string;
|
|
161
|
+
modelId?: string;
|
|
162
|
+
modelName?: string;
|
|
163
|
+
reasoningEffort?: MarAgentReasoningEffort;
|
|
164
|
+
latestMessage?: import('../subagent/scheduler.js').SubagentLatestMessage;
|
|
154
165
|
errorCode?: string;
|
|
155
166
|
errorMessage?: string;
|
|
156
167
|
} | {
|
|
@@ -212,10 +223,8 @@ export interface MarAgentSession {
|
|
|
212
223
|
export interface MarAgent {
|
|
213
224
|
createSession(input: CreateSessionInput): Promise<MarAgentSession>;
|
|
214
225
|
openSession(sessionId: string): Promise<MarAgentSession>;
|
|
215
|
-
listSessions(input?:
|
|
216
|
-
|
|
217
|
-
cursor?: string;
|
|
218
|
-
}): Promise<unknown>;
|
|
226
|
+
listSessions(input?: SessionListInput): Promise<MarAgentSessionPage>;
|
|
227
|
+
clearSession(sessionId: string): Promise<void>;
|
|
219
228
|
reconfigureModels(input: {
|
|
220
229
|
readonly models: readonly MarAgentModelConfiguration[];
|
|
221
230
|
readonly defaultModelId?: string;
|
|
@@ -244,3 +253,4 @@ export interface CreateMarAgentOptions {
|
|
|
244
253
|
rolloutBudget?: false | RolloutBudgetOptions;
|
|
245
254
|
adapterFactory?: (configuration: MarAgentModelConfiguration) => ModelAdapter;
|
|
246
255
|
}
|
|
256
|
+
export type { MarAgentSessionSummary, SessionListInput, SessionSource };
|
package/dist/sdk/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export{};
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SessionListInput, type SessionSource } from './jsonl-store.js';
|
|
1
2
|
import type { MarAgentEvent, MarAgentImageMetadata } from '../sdk/types.js';
|
|
2
3
|
export interface MarAgentSessionSummary {
|
|
3
4
|
id: string;
|
|
@@ -5,6 +6,7 @@ export interface MarAgentSessionSummary {
|
|
|
5
6
|
workspace: string;
|
|
6
7
|
createdAt: string;
|
|
7
8
|
lastActivityAt: string;
|
|
9
|
+
source: SessionSource;
|
|
8
10
|
}
|
|
9
11
|
export interface MarAgentSessionPage {
|
|
10
12
|
sessions: MarAgentSessionSummary[];
|
|
@@ -22,6 +24,7 @@ export type MarAgentHistoryEntry = {
|
|
|
22
24
|
turnId: string;
|
|
23
25
|
text: string;
|
|
24
26
|
clientMessageId?: string;
|
|
27
|
+
inputSource?: 'user' | 'parent_agent';
|
|
25
28
|
images?: readonly MarAgentHistoryImageMetadata[];
|
|
26
29
|
} | {
|
|
27
30
|
kind: 'event';
|
|
@@ -46,10 +49,7 @@ export interface MarAgentSessionImage {
|
|
|
46
49
|
}
|
|
47
50
|
/** Public session catalog facade. Storage details remain SDK-private. */
|
|
48
51
|
export interface MarAgentSessionCatalog {
|
|
49
|
-
list(input?:
|
|
50
|
-
limit?: number;
|
|
51
|
-
cursor?: string;
|
|
52
|
-
}): Promise<MarAgentSessionPage>;
|
|
52
|
+
list(input?: SessionListInput): Promise<MarAgentSessionPage>;
|
|
53
53
|
history(sessionId: string, input?: {
|
|
54
54
|
limit?: number;
|
|
55
55
|
cursor?: string;
|
|
@@ -66,6 +66,7 @@ export interface MarAgentSessionCatalog {
|
|
|
66
66
|
rollback(sessionId: string, input: {
|
|
67
67
|
readonly boundaryTurnId: string | null;
|
|
68
68
|
}): Promise<MarAgentSessionSummary>;
|
|
69
|
+
clear(sessionId: string): Promise<MarAgentSessionSummary>;
|
|
69
70
|
delete(sessionId: string): Promise<MarAgentSessionDeleteResult>;
|
|
70
71
|
close(): Promise<void>;
|
|
71
72
|
}
|
package/dist/session/catalog.js
CHANGED
|
@@ -1,2 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import { JsonlSessionStore } from './jsonl-store.js';
|
|
2
|
+
const MAX_INPUT_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
3
|
+
const INPUT_IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
4
|
+
export async function openMarAgentSessionCatalog(input) {
|
|
5
|
+
const store = await JsonlSessionStore.open(input.homeDirectory);
|
|
6
|
+
return {
|
|
7
|
+
list: (options) => store.list(options),
|
|
8
|
+
history: async (sessionId, options = {}) => {
|
|
9
|
+
const beforeSequence = parseCursor(options.cursor);
|
|
10
|
+
const page = await store.readPage(sessionId, {
|
|
11
|
+
...(options.limit === undefined ? {} : { limit: options.limit }),
|
|
12
|
+
...(beforeSequence === undefined ? {} : { beforeSequence })
|
|
13
|
+
});
|
|
14
|
+
const entries = page.records.flatMap((record) => {
|
|
15
|
+
if (record.type === 'turn.user' &&
|
|
16
|
+
record.executionId !== undefined &&
|
|
17
|
+
record.turnId !== undefined &&
|
|
18
|
+
isRecord(record.payload) &&
|
|
19
|
+
typeof record.payload.prompt === 'string') {
|
|
20
|
+
const images = imageMetadata(record.payload.images);
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
kind: 'user',
|
|
24
|
+
sequence: record.sequence,
|
|
25
|
+
timestamp: record.timestamp,
|
|
26
|
+
sessionId: record.sessionId,
|
|
27
|
+
executionId: record.executionId,
|
|
28
|
+
turnId: record.turnId,
|
|
29
|
+
text: record.payload.prompt,
|
|
30
|
+
...(typeof record.payload.clientMessageId === 'string'
|
|
31
|
+
? { clientMessageId: record.payload.clientMessageId }
|
|
32
|
+
: {}),
|
|
33
|
+
...(record.payload.inputSource === 'parent_agent'
|
|
34
|
+
? { inputSource: 'parent_agent' }
|
|
35
|
+
: {}),
|
|
36
|
+
...(images.length > 0 ? { images } : {})
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
if (isMarAgentEvent(record.payload))
|
|
41
|
+
return [{ kind: 'event', sequence: record.sequence, event: record.payload }];
|
|
42
|
+
return [];
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
entries,
|
|
46
|
+
...(page.previousBeforeSequence === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { nextCursor: String(page.previousBeforeSequence) })
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
readImage: async (sessionId, input) => {
|
|
52
|
+
const image = await store.readInputImage(sessionId, input);
|
|
53
|
+
return image === undefined
|
|
54
|
+
? undefined
|
|
55
|
+
: {
|
|
56
|
+
name: image.name,
|
|
57
|
+
mimeType: image.mimeType,
|
|
58
|
+
byteSize: image.byteSize,
|
|
59
|
+
dataBase64: image.dataBase64
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
contextUsage: async (sessionId) => {
|
|
63
|
+
const page = await store.readPage(sessionId, { limit: 1000 });
|
|
64
|
+
for (const record of page.records.toReversed()) {
|
|
65
|
+
if (!isMarAgentEvent(record.payload))
|
|
66
|
+
continue;
|
|
67
|
+
if (record.payload.type === 'context.compacted')
|
|
68
|
+
return { inputTokens: 0 };
|
|
69
|
+
if (record.payload.type === 'usage.updated') {
|
|
70
|
+
const inputTokens = record.payload.contextInputTokens ?? record.payload.inputTokens;
|
|
71
|
+
if (typeof inputTokens === 'number' &&
|
|
72
|
+
Number.isSafeInteger(inputTokens) &&
|
|
73
|
+
inputTokens >= 0)
|
|
74
|
+
return { inputTokens };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
},
|
|
79
|
+
fork: async (sessionId, options) => {
|
|
80
|
+
const session = await store.forkSession(sessionId, options);
|
|
81
|
+
return { ...session, source: session.source ?? { type: 'user' } };
|
|
82
|
+
},
|
|
83
|
+
rollback: (sessionId, options) => store.rollbackSession(sessionId, options),
|
|
84
|
+
clear: (sessionId) => store.clearSession(sessionId),
|
|
85
|
+
delete: (sessionId) => store.delete(sessionId),
|
|
86
|
+
close: () => store.close()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function parseCursor(cursor) {
|
|
90
|
+
if (cursor === undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
const value = Number(cursor);
|
|
93
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
94
|
+
return undefined;
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
function isRecord(value) {
|
|
98
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
99
|
+
}
|
|
100
|
+
function imageMetadata(value) {
|
|
101
|
+
if (!Array.isArray(value))
|
|
102
|
+
return [];
|
|
103
|
+
return value.flatMap((image) => isRecord(image) &&
|
|
104
|
+
typeof image.name === 'string' &&
|
|
105
|
+
typeof image.mimeType === 'string' &&
|
|
106
|
+
typeof image.byteSize === 'number' &&
|
|
107
|
+
Number.isSafeInteger(image.byteSize) &&
|
|
108
|
+
image.byteSize >= 0
|
|
109
|
+
? [
|
|
110
|
+
{
|
|
111
|
+
name: image.name,
|
|
112
|
+
mimeType: image.mimeType,
|
|
113
|
+
byteSize: image.byteSize,
|
|
114
|
+
readable: INPUT_IMAGE_MIME_TYPES.has(image.mimeType) &&
|
|
115
|
+
image.byteSize > 0 &&
|
|
116
|
+
image.byteSize <= MAX_INPUT_IMAGE_BYTES &&
|
|
117
|
+
typeof image.fileName === 'string' &&
|
|
118
|
+
/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}\.bin$/u.test(image.fileName) &&
|
|
119
|
+
typeof image.sha256 === 'string' &&
|
|
120
|
+
/^[a-f0-9]{64}$/u.test(image.sha256)
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
: []);
|
|
124
|
+
}
|
|
125
|
+
function isMarAgentEvent(value) {
|
|
126
|
+
return (isRecord(value) &&
|
|
127
|
+
typeof value.type === 'string' &&
|
|
128
|
+
typeof value.eventId === 'string' &&
|
|
129
|
+
typeof value.sequence === 'number' &&
|
|
130
|
+
typeof value.timestamp === 'string' &&
|
|
131
|
+
typeof value.sessionId === 'string' &&
|
|
132
|
+
typeof value.executionId === 'string');
|
|
133
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { type ContextGcSubagentToolName } from './context-gc-subagent.js';
|
|
2
|
+
import type { SessionRecord } from './jsonl-store.js';
|
|
3
|
+
export declare const CONTEXT_GC_CHECKPOINT_VERSION: 1;
|
|
4
|
+
export declare const CONTEXT_GC_MAX_TARGETS = 4096;
|
|
5
|
+
export type ContextGcPlatform = 'linux' | 'darwin' | 'win32';
|
|
6
|
+
export interface ContextGcEconomicsPolicy {
|
|
7
|
+
readonly version: 1;
|
|
8
|
+
readonly immediatePaybackRollouts: number;
|
|
9
|
+
readonly maximumPaybackRollouts: number;
|
|
10
|
+
readonly contextGrowthSampleWindow: number;
|
|
11
|
+
readonly minimumContextGrowthSamples: number;
|
|
12
|
+
readonly minimumObservationRollouts: number;
|
|
13
|
+
readonly stageAProtectionRollouts: number;
|
|
14
|
+
readonly largeExecProtectionRollouts: number;
|
|
15
|
+
readonly normalInputCostRate: number;
|
|
16
|
+
readonly cacheReadCostRate: number;
|
|
17
|
+
readonly cacheWriteCostRate: number;
|
|
18
|
+
readonly outputCostRate: number;
|
|
19
|
+
readonly minimumGrossReductionRate: number;
|
|
20
|
+
readonly minimumCacheInvestmentRoi: number;
|
|
21
|
+
}
|
|
22
|
+
export type ContextGcBase = {
|
|
23
|
+
readonly type: 'SESSION_START';
|
|
24
|
+
readonly firstSequence: number;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: 'COMPACT';
|
|
27
|
+
readonly sequence: number;
|
|
28
|
+
readonly recordId: string;
|
|
29
|
+
};
|
|
30
|
+
export interface ContextGcTarget {
|
|
31
|
+
readonly sequence: number;
|
|
32
|
+
readonly recordId: string;
|
|
33
|
+
readonly role: 'tool_call' | 'tool' | 'provider';
|
|
34
|
+
readonly callId?: string;
|
|
35
|
+
readonly toolName?: string;
|
|
36
|
+
readonly sourceHash: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ContextGcReadItemReplacement {
|
|
39
|
+
readonly index: number;
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly replacement: string;
|
|
42
|
+
readonly evidenceSequence: number;
|
|
43
|
+
}
|
|
44
|
+
export type ContextGcReplacement = {
|
|
45
|
+
readonly kind: 'READ_OUTPUT_ITEMS';
|
|
46
|
+
readonly callId: string;
|
|
47
|
+
readonly target: ContextGcTarget;
|
|
48
|
+
readonly items: readonly ContextGcReadItemReplacement[];
|
|
49
|
+
readonly evidenceSequences: readonly number[];
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: 'TOOL_CALL_INPUT';
|
|
52
|
+
readonly toolName: 'apply_patch' | 'exec';
|
|
53
|
+
readonly callId: string;
|
|
54
|
+
readonly target: ContextGcTarget;
|
|
55
|
+
readonly replacementArguments: unknown;
|
|
56
|
+
readonly providerAliasTargets: readonly ContextGcTarget[];
|
|
57
|
+
readonly evidenceSequence: number;
|
|
58
|
+
} | {
|
|
59
|
+
readonly kind: 'EXEC_OUTPUT';
|
|
60
|
+
readonly callId: string;
|
|
61
|
+
readonly target: ContextGcTarget;
|
|
62
|
+
readonly replacementContent: string;
|
|
63
|
+
readonly evidenceSequence: number;
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: 'SUBAGENT_OUTPUT';
|
|
66
|
+
readonly toolName: 'agent_wait' | 'agent_message';
|
|
67
|
+
readonly callId: string;
|
|
68
|
+
readonly target: ContextGcTarget;
|
|
69
|
+
readonly replacementContent: string;
|
|
70
|
+
readonly terminalToolName: ContextGcSubagentToolName;
|
|
71
|
+
readonly terminalCallId: string;
|
|
72
|
+
readonly evidenceSequence: number;
|
|
73
|
+
readonly retainedPriorFinal?: {
|
|
74
|
+
readonly toolName: ContextGcSubagentToolName;
|
|
75
|
+
readonly callId: string;
|
|
76
|
+
readonly evidenceSequence: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export interface ContextGcMetrics {
|
|
80
|
+
readonly stage: 'STAGE_A' | 'STAGE_A_AND_EXEC';
|
|
81
|
+
readonly tokenEstimator?: 'UTF8_BYTES_V1';
|
|
82
|
+
readonly beforeTokens: number;
|
|
83
|
+
readonly afterTokens: number;
|
|
84
|
+
readonly reclaimedTokens: number;
|
|
85
|
+
readonly grossReductionRate: number;
|
|
86
|
+
readonly effectiveMinimumGrossReductionRate?: number;
|
|
87
|
+
readonly minimumRequiredReclaimedTokens?: number;
|
|
88
|
+
readonly cacheRebuildPenaltyCostUnits: number;
|
|
89
|
+
readonly compactDeferralCreditCostUnits: number;
|
|
90
|
+
readonly imminentCompactAvoidanceCreditCostUnits?: number;
|
|
91
|
+
readonly appliedCompactCreditCostUnits?: number;
|
|
92
|
+
readonly requiredPositiveNetRollouts: number;
|
|
93
|
+
readonly requiredTargetRoiRollouts: number;
|
|
94
|
+
readonly projectedRolloutsUntilCompactAfterGc: number;
|
|
95
|
+
readonly projectedTokensBeforeGc?: number;
|
|
96
|
+
readonly projectedTokensAfterGc?: number;
|
|
97
|
+
readonly contextGrowthSampleCount: number;
|
|
98
|
+
readonly contextGrowthP75Tokens: number;
|
|
99
|
+
readonly expectedNetSavedCostUnits: number;
|
|
100
|
+
readonly cacheInvestmentRoi: number;
|
|
101
|
+
readonly minimumObservedRollouts: number;
|
|
102
|
+
readonly protectedCandidateTokens: number;
|
|
103
|
+
readonly eligibleCandidateCount: number;
|
|
104
|
+
readonly eligibleTargetCount: number;
|
|
105
|
+
readonly cachePenaltyKnown?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface ContextGcCheckpointDraft {
|
|
108
|
+
readonly version: 1;
|
|
109
|
+
readonly base: ContextGcBase;
|
|
110
|
+
readonly boundarySequence: number;
|
|
111
|
+
sourceProjectionHash: string;
|
|
112
|
+
readonly replacements: readonly ContextGcReplacement[];
|
|
113
|
+
readonly trigger: {
|
|
114
|
+
readonly usageSequence: number;
|
|
115
|
+
readonly contextInputTokens: number;
|
|
116
|
+
readonly contextWindowTokens: number;
|
|
117
|
+
readonly normalRolloutOrdinal: number;
|
|
118
|
+
readonly modelId: string;
|
|
119
|
+
readonly platform: ContextGcPlatform;
|
|
120
|
+
};
|
|
121
|
+
readonly economics: ContextGcEconomicsPolicy;
|
|
122
|
+
readonly metrics: ContextGcMetrics;
|
|
123
|
+
}
|
|
124
|
+
export interface ContextGcCheckpointPayload extends ContextGcCheckpointDraft {
|
|
125
|
+
readonly checkpointId: string;
|
|
126
|
+
readonly generation: number;
|
|
127
|
+
}
|
|
128
|
+
/** Disposable memoization for one evaluation's immutable record snapshot. */
|
|
129
|
+
export declare class ContextGcCheckpointCache {
|
|
130
|
+
#private;
|
|
131
|
+
read(records: readonly SessionRecord[], boundarySequence?: number, workspace?: string | undefined): ReturnType<typeof latestValidContextGcCheckpoint>;
|
|
132
|
+
}
|
|
133
|
+
export declare function contextGcMinimumUsageGrowth(contextWindowTokens: number): number;
|
|
134
|
+
export declare function contextGcRecordSourceHash(record: Pick<SessionRecord, 'payload'>): string;
|
|
135
|
+
export declare function contextGcLogicalPathKey(path: string, workspace: string, platform?: ContextGcPlatform): string | undefined;
|
|
136
|
+
export declare function contextGcTargetKey(target: ContextGcTarget): string;
|
|
137
|
+
export declare function contextGcReplacementKey(replacement: ContextGcReplacement): string;
|
|
138
|
+
export declare function contextGcBaseFromRecords(records: readonly SessionRecord[], boundarySequence?: number): ContextGcBase | undefined;
|
|
139
|
+
export declare function contextGcBaseSequence(base: ContextGcBase): number;
|
|
140
|
+
export declare function contextGcSourceProjectionHash(records: readonly SessionRecord[], boundarySequence: number, base?: ContextGcBase | undefined): string | undefined;
|
|
141
|
+
export declare function normalizeContextGcReplacements(replacements: readonly ContextGcReplacement[]): ContextGcReplacement[] | undefined;
|
|
142
|
+
export declare function parseContextGcCheckpoint(record: SessionRecord | undefined): ContextGcCheckpointPayload | undefined;
|
|
143
|
+
export declare function validateContextGcCheckpoint(records: readonly SessionRecord[], record: SessionRecord, workspace?: string | undefined): ContextGcCheckpointPayload | undefined;
|
|
144
|
+
export declare function latestValidContextGcCheckpoint(records: readonly SessionRecord[], boundarySequence?: number, workspace?: string | undefined): {
|
|
145
|
+
readonly record: SessionRecord;
|
|
146
|
+
readonly payload: ContextGcCheckpointPayload;
|
|
147
|
+
} | undefined;
|
|
148
|
+
export declare function sameContextGcBase(left: ContextGcBase | undefined, right: ContextGcBase | undefined): boolean;
|