@myagentroam/agent 0.10.29 → 0.10.31
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/extensions/session-input.d.ts +2 -0
- package/dist/agent-core/extensions/session-input.js +21 -3
- package/dist/agent-core/model/contracts.d.ts +1 -0
- package/dist/agent-core/model/openai-responses.js +6 -2
- package/dist/agent-core/runtime/compaction/coordinator.d.ts +15 -0
- package/dist/agent-core/runtime/compaction/coordinator.js +88 -0
- package/dist/agent-core/runtime/compaction/requests.d.ts +16 -0
- package/dist/agent-core/runtime/compaction/requests.js +114 -0
- package/dist/agent-core/runtime/compaction/retained-context.d.ts +6 -0
- package/dist/agent-core/runtime/compaction/retained-context.js +52 -0
- package/dist/agent-core/runtime/compaction/smart.d.ts +14 -0
- package/dist/agent-core/runtime/compaction/smart.js +59 -0
- package/dist/agent-core/runtime/context/restore.d.ts +1 -0
- package/dist/agent-core/runtime/context/restore.js +14 -4
- package/dist/agent-core/runtime/context/usage.js +3 -1
- package/dist/agent-core/runtime/event-projection.js +1 -1
- package/dist/agent-core/runtime/events.d.ts +21 -0
- package/dist/agent-core/runtime/execution-policy.d.ts +2 -0
- package/dist/agent-core/runtime/execution-policy.js +2 -0
- package/dist/agent-core/runtime/execution.d.ts +1 -0
- package/dist/agent-core/runtime/execution.js +1 -0
- package/dist/agent-core/sdk/extension-session.js +4 -2
- package/dist/agent-core/sdk/session.d.ts +2 -0
- package/dist/agent-core/sdk/session.js +350 -192
- package/dist/agent-core/sdk/types.d.ts +4 -1
- package/dist/agent-core/session/catalog.js +2 -2
- package/dist/agent-core/session/jsonl-store.d.ts +2 -0
- package/dist/agent-core/session/jsonl-store.js +9 -1
- package/dist/agent-core/tools/agent/smart-compact.d.ts +9 -0
- package/dist/agent-core/tools/agent/smart-compact.js +20 -0
- package/dist/agent-core/tools/registry.js +4 -1
- package/dist/agent-core/tools/runtime-context.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -21,12 +21,15 @@ export interface ExecutionHandle extends AsyncIterable<MarAgentEvent> {
|
|
|
21
21
|
/** Signals abort; await result() to observe the terminal status and cleanup. */
|
|
22
22
|
cancel(): void;
|
|
23
23
|
}
|
|
24
|
+
export type CompactInput = Partial<RunInput> & {
|
|
25
|
+
readonly async?: boolean;
|
|
26
|
+
};
|
|
24
27
|
/** A persisted Session permits one active main execution at a time. */
|
|
25
28
|
export interface MarAgentSession {
|
|
26
29
|
readonly id: string;
|
|
27
30
|
run(input: RunInput): ExecutionHandle;
|
|
28
31
|
plan(input: RunInput): ExecutionHandle;
|
|
29
|
-
compact(input?:
|
|
32
|
+
compact(input?: CompactInput): ExecutionHandle;
|
|
30
33
|
cancel(executionId: string): Promise<void>;
|
|
31
34
|
}
|
|
32
35
|
export interface MarAgent {
|
|
@@ -86,8 +86,8 @@ export async function openMarAgentSessionCatalog(input) {
|
|
|
86
86
|
if (!isMarAgentEvent(record.payload))
|
|
87
87
|
continue;
|
|
88
88
|
if (record.payload.type === 'context.compacted')
|
|
89
|
-
return { inputTokens: 0 };
|
|
90
|
-
if (record.payload.type === 'usage.updated') {
|
|
89
|
+
return record.payload.retainedContext === true ? undefined : { inputTokens: 0 };
|
|
90
|
+
if (record.payload.type === 'usage.updated' && record.payload.purpose !== 'compact') {
|
|
91
91
|
const inputTokens = record.payload.contextInputTokens ?? record.payload.inputTokens;
|
|
92
92
|
if (typeof inputTokens === 'number' &&
|
|
93
93
|
Number.isSafeInteger(inputTokens) &&
|
|
@@ -193,6 +193,8 @@ export declare class JsonlSessionStore {
|
|
|
193
193
|
summary: string;
|
|
194
194
|
replacementHistory?: readonly CompactHistoryMessage[];
|
|
195
195
|
retainedModelContext?: readonly ModelMessage[];
|
|
196
|
+
snapshotRecordId?: string;
|
|
197
|
+
snapshotMessageCount?: number;
|
|
196
198
|
environment?: EnvironmentContextState;
|
|
197
199
|
automatic?: boolean;
|
|
198
200
|
modelId?: string;
|
|
@@ -1306,6 +1306,12 @@ export class JsonlSessionStore {
|
|
|
1306
1306
|
type: 'compact.completed',
|
|
1307
1307
|
payload: {
|
|
1308
1308
|
summary: input.summary,
|
|
1309
|
+
...(input.snapshotRecordId === undefined
|
|
1310
|
+
? {}
|
|
1311
|
+
: { snapshotRecordId: input.snapshotRecordId }),
|
|
1312
|
+
...(input.snapshotMessageCount === undefined
|
|
1313
|
+
? {}
|
|
1314
|
+
: { snapshotMessageCount: input.snapshotMessageCount }),
|
|
1309
1315
|
...(input.replacementHistory === undefined
|
|
1310
1316
|
? {}
|
|
1311
1317
|
: { replacementHistory: input.replacementHistory }),
|
|
@@ -2521,7 +2527,8 @@ export function parseModelInputMetadata(value) {
|
|
|
2521
2527
|
...(typeof metadata.extensionId === 'string' && metadata.extensionId.length <= 128
|
|
2522
2528
|
? { extensionId: metadata.extensionId }
|
|
2523
2529
|
: {}),
|
|
2524
|
-
...(metadata.truncated === true ? { truncated: true } : {})
|
|
2530
|
+
...(metadata.truncated === true ? { truncated: true } : {}),
|
|
2531
|
+
...(metadata.smartCompaction === true ? { smartCompaction: true } : {})
|
|
2525
2532
|
};
|
|
2526
2533
|
}
|
|
2527
2534
|
export function inputMetadataFromRecord(record) {
|
|
@@ -2534,6 +2541,7 @@ export function inputMetadataFromRecord(record) {
|
|
|
2534
2541
|
? 'parent_agent'
|
|
2535
2542
|
: 'user',
|
|
2536
2543
|
recordId: record.recordId,
|
|
2544
|
+
...(payload.smartCompaction === true ? { smartCompaction: true } : {}),
|
|
2537
2545
|
...(typeof source?.extensionId === 'string' && source.extensionId.length <= 128
|
|
2538
2546
|
? { extensionId: source.extensionId }
|
|
2539
2547
|
: {})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClientToolDefinition } from '../../model/contracts.js';
|
|
2
|
+
import type { ToolRuntimeContext } from '../runtime-context.js';
|
|
3
|
+
export declare const smartCompactToolDefinition: ClientToolDefinition;
|
|
4
|
+
export declare function executeSmartCompact(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
5
|
+
content: string;
|
|
6
|
+
data: {
|
|
7
|
+
status: string;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MarAgentError } from '../../error.js';
|
|
2
|
+
export const smartCompactToolDefinition = {
|
|
3
|
+
name: 'smart_compact',
|
|
4
|
+
allowedCallers: ['direct', 'programmatic'],
|
|
5
|
+
parallelSafety: 'safe',
|
|
6
|
+
description: 'Request background context compaction only when the current real user message ends with <mar_runtime><smart_compaction scope="this_message">eligible</smart_compaction></mar_runtime> (on separate lines). The scope applies only to the containing user message; a historical marker does not authorize the current input. Call only when prior work is substantially complete, the request begins a sustained new work phase, and prior detailed context has low continuation value while key state can be retained in a summary. Do not call merely because the conversation is long, for a one-off question, or while prior evidence is still needed. Prefer calling alongside the first batch of necessary read/search/exec tools rather than creating a separate rollout. Acceptance does not wait for generation or installation.',
|
|
7
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false }
|
|
8
|
+
};
|
|
9
|
+
export function executeSmartCompact(arguments_, context) {
|
|
10
|
+
if (!arguments_ ||
|
|
11
|
+
typeof arguments_ !== 'object' ||
|
|
12
|
+
Array.isArray(arguments_) ||
|
|
13
|
+
Object.keys(arguments_).length)
|
|
14
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Smart Compaction input must be an empty object.');
|
|
15
|
+
if (!context.requestSmartCompact)
|
|
16
|
+
throw new MarAgentError('MAR_AGENT_SMART_COMPACT_DENIED', 'The current user input is not eligible for Smart Compaction.');
|
|
17
|
+
context.requestSmartCompact();
|
|
18
|
+
const data = { status: 'accepted' };
|
|
19
|
+
return Promise.resolve({ content: JSON.stringify(data), data });
|
|
20
|
+
}
|
|
@@ -12,6 +12,7 @@ import { executeTodoRead, todoReadToolDefinition } from './agent/todo-read.js';
|
|
|
12
12
|
import { executeTodoWrite, todoWriteToolDefinition } from './agent/todo-write.js';
|
|
13
13
|
import { executeToolSearch, toolSearchToolDefinition } from './mcp/tool-search.js';
|
|
14
14
|
import { viewImageToolDefinition } from './local/view-image.js';
|
|
15
|
+
import { smartCompactToolDefinition, executeSmartCompact } from './agent/smart-compact.js';
|
|
15
16
|
export const BUILTIN_TOOL_DEFINITIONS = [
|
|
16
17
|
skillToolDefinition,
|
|
17
18
|
toolSearchToolDefinition,
|
|
@@ -28,10 +29,12 @@ export const BUILTIN_TOOL_DEFINITIONS = [
|
|
|
28
29
|
agentStartToolDefinition,
|
|
29
30
|
agentWaitToolDefinition,
|
|
30
31
|
agentMessageToolDefinition,
|
|
31
|
-
agentCancelToolDefinition
|
|
32
|
+
agentCancelToolDefinition,
|
|
33
|
+
smartCompactToolDefinition
|
|
32
34
|
];
|
|
33
35
|
export const AGENT_TOOL_HANDLERS = new Map([
|
|
34
36
|
['skill', executeSkill],
|
|
37
|
+
['smart_compact', executeSmartCompact],
|
|
35
38
|
['tool_search', executeToolSearch],
|
|
36
39
|
['question', executeQuestion],
|
|
37
40
|
['todo_read', (_arguments, context) => executeTodoRead(context)],
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export type { CoreModelsApi, CoreModelDescription, CoreModelTextBlock, CoreGener
|
|
|
38
38
|
export type { CoreDataApi, CoreJsonValue, CoreCheckpoint, CoreCheckpointApi, CoreStateApi, CoreStateChange, CoreStoreApi, CoreStoreCommit } from './agent-core/extensions/data.js';
|
|
39
39
|
export { generateSessionTitle, type GenerateSessionTitleInput } from './shared/auto-title.js';
|
|
40
40
|
export type { CoreProcessesApi, CoreProcessesBackend, CoreProcessInput, CoreProcessRunInput, CoreProcessHandle, CoreProcessExit, CoreProcessResult, CoreProcessCompletion } from './agent-core/extensions/processes.js';
|
|
41
|
-
export type { CreateMarAgentOptions, CreateSessionInput, ExecutionHandle, MarAgent, MarAgentSession, SessionTitleUpdateInput } from './agent-core/sdk/types.js';
|
|
41
|
+
export type { CreateMarAgentOptions, CreateSessionInput, ExecutionHandle, CompactInput, MarAgent, MarAgentSession, SessionTitleUpdateInput } from './agent-core/sdk/types.js';
|
|
42
42
|
export { openMarAgentSessionCatalog, type MarAgentContextUsage, type MarAgentHistoryEntry, type MarAgentHistoryPage, type MarAgentSessionCatalog, type MarAgentSessionDeleteResult, type MarAgentSessionImage, type MarAgentSessionPage, type MarAgentSessionSummary } from './agent-core/session/catalog.js';
|
|
43
43
|
export type { SessionListInput, SessionSource } from './agent-core/session/types.js';
|
|
44
44
|
export type { ApplyPatchFileResult, ApplyPatchResult, ApplyPatchPartialResult, ClientToolDefinition, MarAgentToolArtifact, MarAgentToolImageArtifact, McpCatalogTool, McpToolCallContext, McpToolCatalog, McpToolCatalogContext, ToolCall, ToolCaller, ToolExecutionContext, ToolExecutionResult } from './agent-core/tools/contracts.js';
|