@myagentroam/agent 0.10.28 → 0.10.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/agent-core/extensions/session-input.d.ts +2 -0
  2. package/dist/agent-core/extensions/session-input.js +21 -3
  3. package/dist/agent-core/model/openai-responses.js +1 -1
  4. package/dist/agent-core/runtime/compaction/coordinator.d.ts +15 -0
  5. package/dist/agent-core/runtime/compaction/coordinator.js +88 -0
  6. package/dist/agent-core/runtime/compaction/requests.d.ts +16 -0
  7. package/dist/agent-core/runtime/compaction/requests.js +114 -0
  8. package/dist/agent-core/runtime/compaction/retained-context.d.ts +6 -0
  9. package/dist/agent-core/runtime/compaction/retained-context.js +52 -0
  10. package/dist/agent-core/runtime/context/restore.d.ts +1 -0
  11. package/dist/agent-core/runtime/context/restore.js +14 -4
  12. package/dist/agent-core/runtime/context/usage.js +3 -1
  13. package/dist/agent-core/runtime/event-projection.js +1 -1
  14. package/dist/agent-core/runtime/events.d.ts +21 -0
  15. package/dist/agent-core/runtime/execution-policy.d.ts +1 -0
  16. package/dist/agent-core/runtime/execution-policy.js +1 -0
  17. package/dist/agent-core/runtime/execution.d.ts +1 -0
  18. package/dist/agent-core/runtime/execution.js +1 -0
  19. package/dist/agent-core/sdk/extension-session.js +4 -2
  20. package/dist/agent-core/sdk/session.d.ts +2 -0
  21. package/dist/agent-core/sdk/session.js +307 -191
  22. package/dist/agent-core/sdk/types.d.ts +4 -1
  23. package/dist/agent-core/session/catalog.js +2 -2
  24. package/dist/agent-core/session/jsonl-store.d.ts +2 -0
  25. package/dist/agent-core/session/jsonl-store.js +6 -0
  26. package/dist/agent-core/tools/local/exec.js +9 -1
  27. package/dist/index.d.ts +1 -1
  28. 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?: Partial<RunInput>): ExecutionHandle;
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 }),
@@ -182,8 +182,11 @@ export class ExecTool {
182
182
  throw new MarAgentError('MAR_AGENT_PROCESS_NOT_FOUND', 'Managed process was not found.');
183
183
  if (input.action === 'poll' && input.yieldMs)
184
184
  await waitForProcessChange(process, Math.min(Math.max(input.yieldMs, 0), TOOL_EXECUTION_LIMITS.execMaxPollYieldMs), signal);
185
- if (input.action === 'write')
185
+ if (input.action === 'write') {
186
+ if (process.status !== 'running')
187
+ throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Completed process cannot accept input.');
186
188
  process.child.stdin.write(input.data);
189
+ }
187
190
  if (input.action === 'cancel')
188
191
  await this.#terminate(process, true);
189
192
  const result = this.#result(input.processId, process);
@@ -267,6 +270,7 @@ export class ExecTool {
267
270
  ...(child.exitCode === null ? {} : { exitCode: child.exitCode }),
268
271
  ...(child.signalCode == null ? {} : { exitSignal: child.signalCode }),
269
272
  finalized: false,
273
+ terminalResultReturned: false,
270
274
  waiters: new Set()
271
275
  };
272
276
  this.#processes.set(id, managed);
@@ -493,6 +497,7 @@ export class ExecTool {
493
497
  if (process.native ||
494
498
  process.status === 'running' ||
495
499
  !process.finalized ||
500
+ !process.terminalResultReturned ||
496
501
  this.#processes.get(id) !== process)
497
502
  return;
498
503
  this.#processes.delete(id);
@@ -562,6 +567,9 @@ export class ExecTool {
562
567
  return managed.terminate;
563
568
  }
564
569
  #result(id, process) {
570
+ // Uncollected terminal output is a live resource, not an expiring replay.
571
+ if (process.status !== 'running')
572
+ process.terminalResultReturned = true;
565
573
  const stdout = consumeOutput(process.stdout);
566
574
  const stderr = consumeOutput(process.stderr);
567
575
  return {
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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.10.28",
3
+ "version": "0.10.30",
4
4
  "description": "Embeddable MAR coding agent SDK and CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",