@arnilo/prism 0.6.0 → 0.7.0

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 (129) hide show
  1. package/CHANGELOG.md +44 -5
  2. package/README.md +10 -10
  3. package/dist/agent-definitions.js +1 -0
  4. package/dist/agent-run-lifecycle.js +11 -0
  5. package/dist/agent-run-state.d.ts +6 -0
  6. package/dist/agent-run-state.js +29 -9
  7. package/dist/agent-session/session/assemble.js +33 -2
  8. package/dist/agent-session/session/persist.js +6 -2
  9. package/dist/agent-session/session/tool-round.js +1 -0
  10. package/dist/agent-session/session/types.d.ts +10 -0
  11. package/dist/agent-session/session.d.ts +14 -0
  12. package/dist/agent-session/session.js +40 -3
  13. package/dist/artifacts.d.ts +39 -1
  14. package/dist/artifacts.js +73 -0
  15. package/dist/attention-compiler.d.ts +121 -0
  16. package/dist/attention-compiler.js +479 -0
  17. package/dist/cli-init.js +20 -6
  18. package/dist/context-budget.d.ts +20 -1
  19. package/dist/context-budget.js +10 -1
  20. package/dist/contracts-core/agent.d.ts +7 -0
  21. package/dist/contracts-core/attention.d.ts +66 -0
  22. package/dist/contracts-core/attention.js +2 -0
  23. package/dist/contracts-core/compaction.d.ts +59 -0
  24. package/dist/contracts-core/compaction.js +77 -1
  25. package/dist/contracts-core/provider.d.ts +4 -0
  26. package/dist/contracts-core.d.ts +1 -0
  27. package/dist/contracts-core.js +1 -0
  28. package/dist/contracts-protocol.d.ts +29 -0
  29. package/dist/contracts-run-state.d.ts +6 -0
  30. package/dist/host-composition.d.ts +78 -0
  31. package/dist/host-composition.js +248 -0
  32. package/dist/index.d.ts +9 -6
  33. package/dist/index.js +5 -4
  34. package/dist/input.d.ts +13 -1
  35. package/dist/input.js +40 -1
  36. package/dist/secure-agent.d.ts +2 -0
  37. package/dist/secure-agent.js +6 -1
  38. package/dist/tool-result-fold.d.ts +12 -0
  39. package/dist/tool-result-fold.js +13 -6
  40. package/dist/tools.d.ts +10 -0
  41. package/dist/tools.js +41 -0
  42. package/docs/acp-agent.md +42 -11
  43. package/docs/acp.md +2 -1
  44. package/docs/ag-ui.md +5 -3
  45. package/docs/agent-definitions.md +9 -1
  46. package/docs/agent-events.md +4 -1
  47. package/docs/agent-session-runtime.md +6 -6
  48. package/docs/attention-compiler.md +272 -0
  49. package/docs/cli-rpc.md +4 -2
  50. package/docs/coding-agent-tools.md +1 -1
  51. package/docs/coding-security.md +5 -3
  52. package/docs/coding-tools.md +1 -1
  53. package/docs/coding-workspaces.md +22 -0
  54. package/docs/compaction-and-retry.md +36 -4
  55. package/docs/compaction-observational-memory.md +62 -9
  56. package/docs/context-and-skills.md +4 -2
  57. package/docs/conversations.md +1 -1
  58. package/docs/dev-inspector.md +4 -0
  59. package/docs/device-adapters.md +1 -0
  60. package/docs/document-reader.md +11 -3
  61. package/docs/documents.md +10 -2
  62. package/docs/enterprise-postgres-state.md +2 -2
  63. package/docs/evaluations.md +168 -4
  64. package/docs/execution-timeline.md +180 -0
  65. package/docs/history/0.7.0-primitive-review.md +254 -0
  66. package/docs/history/migration-0.0.md +2 -2
  67. package/docs/history/release-handoffs.md +37 -1
  68. package/docs/host-compositions.md +147 -0
  69. package/docs/hosted-sandboxes.md +94 -0
  70. package/docs/index.md +58 -39
  71. package/docs/input-and-prompt-assembly.md +1 -0
  72. package/docs/knowledge-sync.md +84 -0
  73. package/docs/language-intelligence.md +1 -1
  74. package/docs/live-testing.md +4 -1
  75. package/docs/mcp-tools.md +2 -1
  76. package/docs/memory-fabric.md +416 -0
  77. package/docs/migrate-to-0.5.md +1 -1
  78. package/docs/migrate-to-0.6.md +1 -0
  79. package/docs/migrate-to-0.7.md +345 -0
  80. package/docs/migration.md +13 -1
  81. package/docs/model-routing.md +79 -4
  82. package/docs/multi-agent-patterns.md +20 -6
  83. package/docs/observability.md +52 -1
  84. package/docs/operations.md +13 -1
  85. package/docs/options-index.md +13 -1
  86. package/docs/peer-dependencies.md +6 -4
  87. package/docs/process-sessions.md +3 -1
  88. package/docs/prompt-registry.md +1 -1
  89. package/docs/provider-caching.md +4 -2
  90. package/docs/provider-conformance.md +1 -1
  91. package/docs/provider-packages.md +22 -22
  92. package/docs/providers/bedrock.md +71 -7
  93. package/docs/providers/openai.md +1 -1
  94. package/docs/rag.md +24 -8
  95. package/docs/realtime-voice.md +87 -0
  96. package/docs/release-and-install.md +36 -34
  97. package/docs/runs-and-usage.md +3 -2
  98. package/docs/server.md +5 -3
  99. package/docs/speech.md +2 -0
  100. package/docs/supervisors.md +33 -5
  101. package/docs/testing.md +1 -1
  102. package/docs/thinking-and-reasoning.md +3 -1
  103. package/docs/tools.md +6 -5
  104. package/docs/web-tools.md +2 -1
  105. package/docs/work-artifacts-and-review.md +14 -4
  106. package/docs/work-connectors.md +3 -1
  107. package/docs/work-tools.md +14 -4
  108. package/docs/workflows.md +69 -1
  109. package/docs/working-and-semantic-memory.md +25 -14
  110. package/package.json +1 -1
  111. package/templates/README.md +2 -0
  112. package/templates/business-worker/README.md.tmpl +19 -0
  113. package/templates/business-worker/env.example.tmpl +1 -0
  114. package/templates/business-worker/gitignore.tmpl +11 -0
  115. package/templates/business-worker/manifest.json +11 -0
  116. package/templates/business-worker/package.json.tmpl +23 -0
  117. package/templates/business-worker/src/agent.ts.tmpl +92 -0
  118. package/templates/business-worker/src/index.ts.tmpl +13 -0
  119. package/templates/business-worker/src/tests/agent.test.ts.tmpl +77 -0
  120. package/templates/business-worker/tsconfig.json.tmpl +15 -0
  121. package/templates/personal-assistant/README.md.tmpl +18 -0
  122. package/templates/personal-assistant/env.example.tmpl +1 -0
  123. package/templates/personal-assistant/gitignore.tmpl +11 -0
  124. package/templates/personal-assistant/manifest.json +11 -0
  125. package/templates/personal-assistant/package.json.tmpl +23 -0
  126. package/templates/personal-assistant/src/agent.ts.tmpl +65 -0
  127. package/templates/personal-assistant/src/index.ts.tmpl +13 -0
  128. package/templates/personal-assistant/src/tests/agent.test.ts.tmpl +28 -0
  129. package/templates/personal-assistant/tsconfig.json.tmpl +15 -0
@@ -71,7 +71,7 @@ export function applyContextBudget(options) {
71
71
  const historyCursor = { index: 0 };
72
72
  // Measure once, then subtract each dropped item's own estimate (dropNext computes it
73
73
  // with the same estimators) — avoids an O(n²) re-scan of the full keep-set per drop.
74
- const kept = measureAll(groups, context, skills, tools, skillContext, demotedBodies, estimateTokens);
74
+ const kept = measureInputCost({ groups, context, skills, tools, skillContext, demotedBodies, estimateTokens });
75
75
  while (overBudget(kept, budget)) {
76
76
  const drop = dropNext(groups, context, skills, layout, skillContext, demotedBodies, historyCursor, estimateTokens);
77
77
  if (!drop) {
@@ -171,6 +171,15 @@ function omission(kind, id, message, estimateTokens) {
171
171
  byteLength: estimateMessageBytes(message),
172
172
  };
173
173
  }
174
+ /**
175
+ * One O(n) cost measurement of the whole request (groups, context, skills, tool declarations).
176
+ * Shared with the attention-compiler gate, which measures once per turn and then subtracts a
177
+ * per-mutation delta instead of re-measuring — the same trick `applyContextBudget` uses.
178
+ */
179
+ export function measureInputCost(options) {
180
+ return measureAll(options.groups, options.context ?? [], options.skills ?? [], options.tools, options.skillContext ?? {}, options.demotedBodies ?? EMPTY_DEMOTED_BODIES, options.estimateTokens ?? estimateTextTokens);
181
+ }
182
+ const EMPTY_DEMOTED_BODIES = new Set();
174
183
  /**
175
184
  * Resolves the budget's estimator, validating each return value: a host estimator that
176
185
  * yields NaN/negative/non-finite tokens would make every eviction decision unsound, so it
@@ -33,6 +33,8 @@ export interface AgentDefinition {
33
33
  readonly metadata?: Readonly<Record<string, unknown>>;
34
34
  /** Optional escape hatch. When present, overrides declarative resolution. */
35
35
  create?(config?: AgentConfig): Promise<Agent> | Agent;
36
+ /** Opt-in attention compiler for the agent this definition resolves to (plan 074 C1). */
37
+ readonly attentionCompiler?: import("./attention.js").AttentionCompilerSetting;
36
38
  }
37
39
  /** Input to {@link resolveAgentDefinition}. All fields are optional; the host
38
40
  * controls scope by which registries it passes. */
@@ -64,6 +66,9 @@ export interface AgentConfig {
64
66
  readonly toolsSearch?: import("../tool-search.js").ToolsSearchOptions;
65
67
  /** Opt-in projection-only fold for aged large tool results in provider view; store untouched. */
66
68
  readonly toolResultFold?: import("../tool-result-fold.js").ToolResultFoldOptions;
69
+ /** Opt-in attention compiler (plan 074): `true` for defaults, an object to tune ratios/depth.
70
+ * Omitted keeps today's request bytes; per-run options may only relax this setting. */
71
+ readonly attentionCompiler?: import("./attention.js").AttentionCompilerSetting;
67
72
  readonly inputBuilder?: InputBuilder;
68
73
  readonly promptBuilder?: PromptBuilder;
69
74
  readonly middleware?: MiddlewareRegistry;
@@ -116,6 +121,8 @@ export interface SecureAgentOptions extends Omit<AgentConfig, "tools" | "validat
116
121
  readonly limits: RunLimits;
117
122
  readonly definitionRevision: string;
118
123
  readonly runState: Omit<AgentRunStateOptions, "definitionRevision" | "interruptBeforeTool">;
124
+ /** Optional host composition readiness assertions evaluated on creation. */
125
+ readonly composition?: import("../host-composition.js").HostCompositionOptions;
119
126
  }
120
127
  export interface Agent {
121
128
  readonly config: AgentConfig;
@@ -0,0 +1,66 @@
1
+ /** Attention Compiler contracts (plan 074 Tasks 2–5). Opt-in per-turn gate that measures the
2
+ * assembled input and mutates a history clone only after a host ratio of the model input
3
+ * cap. `resolveRunAttentionCompiler` turns the agent setting plus an optional run overlay
4
+ * into the frozen handle the session hands to assembly; nothing declared here runs on its
5
+ * own, and omitting the option keeps today's request bytes. */
6
+ import type { CompactionTrigger } from "./compaction.js";
7
+ import type { ModelConfig } from "./content.js";
8
+ /** Input-cap resolution inputs shared by the compiler and `input_ratio` compaction triggers. */
9
+ export interface AttentionInputCapOptions {
10
+ /** Host cap; when set it wins over `model.limits.contextWindow` (C2). */
11
+ readonly maxInputTokens?: number;
12
+ /** Output + next-turn headroom subtracted from the window (default 1024). */
13
+ readonly reserveTokens?: number;
14
+ }
15
+ export interface AttentionCompilerOptions extends AttentionInputCapOptions {
16
+ /** Fraction of `inputCap` that triggers mutation; in `(0, 1)` (default 0.75). */
17
+ readonly triggerRatio?: number;
18
+ /** Where compaction should fire relative to `triggerRatio`; must exceed it (default 0.9). */
19
+ readonly compactRatio?: number;
20
+ /** Newest thinking-bearing assistant turns kept intact (default 1). */
21
+ readonly thinkingKeepTurns?: number;
22
+ /** Newest tool results kept full (default 3). */
23
+ readonly keepLast?: number;
24
+ /** Tool names whose results are never stubbed, whatever the ratio. */
25
+ readonly excludeTools?: readonly string[];
26
+ }
27
+ /** Where the compiler is switched on: `true` uses the defaults, an object tunes them, `false`
28
+ * (or omitted) leaves requests byte-for-byte as they are without the compiler. On
29
+ * `RunOptions` the same shape is an overlay: `false` disables, `true` is a no-op, and an
30
+ * object may only *relax* the agent setting (see `resolveRunAttentionCompiler`). */
31
+ export type AttentionCompilerSetting = boolean | AttentionCompilerOptions;
32
+ export interface AttentionCompilerContext {
33
+ /** Model limits used to resolve the input cap; ignored when `maxInputTokens` is set. */
34
+ readonly model?: Pick<ModelConfig, "limits">;
35
+ /** Validated at create so an unknown trigger type fails at config time, not on turn one. */
36
+ readonly compactionTrigger?: CompactionTrigger;
37
+ }
38
+ /** Validated, frozen configuration returned by `createAttentionCompiler`. */
39
+ export interface AttentionCompiler {
40
+ readonly inputCap: number;
41
+ readonly reserveTokens: number;
42
+ readonly triggerRatio: number;
43
+ readonly compactRatio: number;
44
+ readonly thinkingKeepTurns: number;
45
+ readonly keepLast: number;
46
+ readonly excludeTools: readonly string[];
47
+ }
48
+ /** One mutated turn. Under-ratio turns emit nothing and produce no report (C14). */
49
+ export interface AttentionReport {
50
+ /** Estimated tokens measured before this turn's mutation — the value compared to the ratio. */
51
+ readonly used: number;
52
+ /** Estimated tokens of the same request after this turn's mutation: the cost curve is `used` → `usedAfter`. */
53
+ readonly usedAfter: number;
54
+ readonly inputCap: number;
55
+ readonly triggerRatio: number;
56
+ /** Thinking turns absent from this request; rows re-applied from the sticky frontier count again. */
57
+ readonly droppedThinkingTurns: number;
58
+ /** Tool results stubbed in this request; rows re-applied from the sticky frontier count again. */
59
+ readonly stubbedToolResults: number;
60
+ /** Payload bytes the stubs took out of this request (never the stub text itself). */
61
+ readonly stubbedBytes: number;
62
+ /** True when the gate stopped with eligible rows left: the sticky frontier is partial. */
63
+ readonly truncated: boolean;
64
+ readonly runId?: string;
65
+ readonly sessionId?: string;
66
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=attention.js.map
@@ -21,15 +21,74 @@ export interface CompactionResult {
21
21
  readonly entries?: readonly SessionEntry[];
22
22
  readonly metadata?: Readonly<Record<string, unknown>>;
23
23
  }
24
+ /** Inputs a compaction trigger decides on. Estimates and ids only — never raw payloads. */
25
+ export interface CompactionTriggerContext {
26
+ readonly sessionId: string;
27
+ readonly entryCount: number;
28
+ readonly estimatedInputTokens: number;
29
+ readonly inputCapTokens: number;
30
+ readonly metadata?: Readonly<Record<string, unknown>>;
31
+ readonly signal?: AbortSignal;
32
+ }
33
+ /** Host-programmable compact-when gate (plan 074 C11). Omitted → `thresholdEntries` only. */
34
+ export type CompactionTrigger = {
35
+ readonly type: "threshold_entries";
36
+ readonly entries: number;
37
+ } | {
38
+ readonly type: "input_ratio";
39
+ readonly ratio: number;
40
+ } | {
41
+ readonly type: "custom";
42
+ readonly shouldCompact: (context: CompactionTriggerContext) => boolean | Promise<boolean>;
43
+ };
44
+ /** Validate a host trigger at config time, so an unknown `type` fails at create (C11). */
45
+ export declare function assertCompactionTrigger(trigger: CompactionTrigger): CompactionTrigger;
24
46
  export interface CompactionOptions {
25
47
  readonly strategy?: CompactionStrategy;
26
48
  readonly thresholdEntries?: number;
49
+ /** Replaces the `thresholdEntries` gate when set; omitted keeps today's entry-count gate. */
50
+ readonly trigger?: CompactionTrigger;
27
51
  readonly keepRecentEntries?: number;
28
52
  readonly maxSummaryChars?: number;
29
53
  readonly secrets?: readonly (string | undefined)[];
30
54
  readonly metadata?: Readonly<Record<string, unknown>>;
31
55
  readonly signal?: AbortSignal;
32
56
  }
57
+ /** Legacy gates a compaction decision can fall back to when no `trigger` is configured. */
58
+ export interface ResolveShouldCompactOptions {
59
+ /** Host trigger; when set it replaces the legacy gates below. */
60
+ readonly trigger?: CompactionTrigger;
61
+ /** Session gate: compact when the branch holds more than this many entries. */
62
+ readonly thresholdEntries?: number;
63
+ /** Attach-loop gate: compact when the estimated input is at or above this many tokens. */
64
+ readonly compactAfterTokens?: number;
65
+ }
66
+ /** Everything a compaction decision reads. Estimates only — never raw payloads. */
67
+ export interface ResolveShouldCompactInput {
68
+ readonly sessionId: string;
69
+ readonly entryCount: number;
70
+ /** Estimated tokens of the would-be input; called at most once, and only when a ratio or custom trigger reads it. */
71
+ readonly estimateInputTokens: () => number;
72
+ /** Resolved input cap (the attention compiler's `resolveInputCap`); called at most once, and only when a ratio or custom trigger reads it. */
73
+ readonly resolveInputCapTokens: () => number;
74
+ readonly metadata?: Readonly<Record<string, unknown>>;
75
+ readonly signal?: AbortSignal;
76
+ /** Receives the failure behind a fail-closed `false`. */
77
+ readonly onError?: (error: unknown) => void;
78
+ }
79
+ /**
80
+ * The single compact-when decision used by `autoCompact` and by host attach loops that gate their
81
+ * own post-run compaction (plan 074 C11).
82
+ *
83
+ * Precedence: an explicit `trigger` replaces the legacy gates. Only the token gates below a `trigger`
84
+ * replace are lazy — a `threshold_entries` trigger, or a `custom` callback that only reads counts,
85
+ * never pays for the token estimate or the input cap.
86
+ *
87
+ * Failure policy: a malformed trigger throws (`assertCompactionTrigger`, config error), while a
88
+ * throwing `custom.shouldCompact` — including a callback that reads an unresolvable cap — decides
89
+ * `false` and reports through `onError`, so a host bug can never compact on a guess.
90
+ */
91
+ export declare function resolveShouldCompact(options: ResolveShouldCompactOptions, input: ResolveShouldCompactInput): Promise<boolean>;
33
92
  export interface CompactionMiddlewarePayload {
34
93
  readonly context: CompactionContext;
35
94
  readonly result: CompactionResult;
@@ -1,2 +1,78 @@
1
- export {};
1
+ /** Validate a host trigger at config time, so an unknown `type` fails at create (C11). */
2
+ export function assertCompactionTrigger(trigger) {
3
+ if (typeof trigger !== "object" || trigger === null) {
4
+ throw new TypeError("compaction trigger must be an object");
5
+ }
6
+ switch (trigger.type) {
7
+ case "threshold_entries":
8
+ if (!Number.isSafeInteger(trigger.entries) || trigger.entries < 1) {
9
+ throw new TypeError("compaction trigger threshold_entries.entries must be a positive safe integer");
10
+ }
11
+ return trigger;
12
+ case "input_ratio":
13
+ if (!Number.isFinite(trigger.ratio) || trigger.ratio <= 0 || trigger.ratio >= 1) {
14
+ throw new TypeError("compaction trigger input_ratio.ratio must be a number in (0, 1)");
15
+ }
16
+ return trigger;
17
+ case "custom":
18
+ if (typeof trigger.shouldCompact !== "function") {
19
+ throw new TypeError("compaction trigger custom.shouldCompact must be a function");
20
+ }
21
+ return trigger;
22
+ default:
23
+ throw new TypeError(`unknown compaction trigger type: ${String(trigger.type)}`);
24
+ }
25
+ }
26
+ /**
27
+ * The single compact-when decision used by `autoCompact` and by host attach loops that gate their
28
+ * own post-run compaction (plan 074 C11).
29
+ *
30
+ * Precedence: an explicit `trigger` replaces the legacy gates. Only the token gates below a `trigger`
31
+ * replace are lazy — a `threshold_entries` trigger, or a `custom` callback that only reads counts,
32
+ * never pays for the token estimate or the input cap.
33
+ *
34
+ * Failure policy: a malformed trigger throws (`assertCompactionTrigger`, config error), while a
35
+ * throwing `custom.shouldCompact` — including a callback that reads an unresolvable cap — decides
36
+ * `false` and reports through `onError`, so a host bug can never compact on a guess.
37
+ */
38
+ export async function resolveShouldCompact(options, input) {
39
+ let estimated;
40
+ let cap;
41
+ const estimateOnce = () => (estimated ??= input.estimateInputTokens());
42
+ const capOnce = () => (cap ??= input.resolveInputCapTokens());
43
+ const trigger = options.trigger;
44
+ if (trigger === undefined) {
45
+ if (options.thresholdEntries !== undefined)
46
+ return input.entryCount > options.thresholdEntries;
47
+ if (options.compactAfterTokens !== undefined)
48
+ return estimateOnce() >= options.compactAfterTokens;
49
+ return false;
50
+ }
51
+ assertCompactionTrigger(trigger);
52
+ if (trigger.type === "threshold_entries")
53
+ return input.entryCount > trigger.entries;
54
+ if (trigger.type === "input_ratio")
55
+ return estimateOnce() >= trigger.ratio * capOnce();
56
+ // Getter-backed so a callback that only reads counts never forces cap resolution, which throws
57
+ // when the active model declares no context window.
58
+ const context = {
59
+ sessionId: input.sessionId,
60
+ entryCount: input.entryCount,
61
+ get estimatedInputTokens() {
62
+ return estimateOnce();
63
+ },
64
+ get inputCapTokens() {
65
+ return capOnce();
66
+ },
67
+ ...(input.metadata === undefined ? {} : { metadata: input.metadata }),
68
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
69
+ };
70
+ try {
71
+ return (await trigger.shouldCompact(context)) === true;
72
+ }
73
+ catch (error) {
74
+ input.onError?.(error);
75
+ return false;
76
+ }
77
+ }
2
78
  //# sourceMappingURL=compaction.js.map
@@ -83,6 +83,10 @@ export interface RealtimeSession {
83
83
  close(reason?: string, options?: {
84
84
  readonly signal?: AbortSignal;
85
85
  }): Promise<void>;
86
+ /** Return a host-dispatched tool result. Omitted on transports that cannot complete tools. */
87
+ completeTool?(callId: string, output: string, options?: {
88
+ readonly signal?: AbortSignal;
89
+ }): Promise<void>;
86
90
  }
87
91
  /** Factory a provider exposes for realtime sessions; not part of `AIProvider`. */
88
92
  export type RealtimeSessionFactory = (options: RealtimeSessionOptions) => RealtimeSession;
@@ -3,6 +3,7 @@
3
3
  * of `./contracts-core.js` is unchanged (0.1.4 barrel precedent). */
4
4
  export type { AudioContent, DocumentContent, FileContent } from "./content.js";
5
5
  export * from "./contracts-core/agent.js";
6
+ export * from "./contracts-core/attention.js";
6
7
  export * from "./contracts-core/batch.js";
7
8
  export * from "./contracts-core/compaction.js";
8
9
  export * from "./contracts-core/content.js";
@@ -1,4 +1,5 @@
1
1
  export * from "./contracts-core/agent.js";
2
+ export * from "./contracts-core/attention.js";
2
3
  export * from "./contracts-core/batch.js";
3
4
  export * from "./contracts-core/compaction.js";
4
5
  export * from "./contracts-core/content.js";
@@ -45,6 +45,9 @@ export type RealtimeEvent = {
45
45
  } | {
46
46
  readonly type: "tool_call";
47
47
  readonly call: ToolCallContent;
48
+ } | {
49
+ readonly type: "usage";
50
+ readonly usage: Usage;
48
51
  } | {
49
52
  readonly type: "interrupted";
50
53
  } | {
@@ -97,11 +100,22 @@ export interface RunOptions {
97
100
  readonly activateAllSkills?: true;
98
101
  /** Progressive: catalog (name+description) unless loaded; eager: full instructions every turn. Default progressive. */
99
102
  readonly skillsDisclosure?: import("./skill-disclosure.js").SkillsDisclosure;
103
+ /**
104
+ * Optional per-run allow-list of registered tool names. Omitted → every registered tool (legacy).
105
+ * Empty → no tools this run. Unknown names fail closed. Cannot widen the agent registry or a
106
+ * checkpointed grant; resume intersects this list with current authority.
107
+ */
108
+ readonly toolNames?: readonly string[];
100
109
  /** Tools disclosure: "all" (default) sends every active tool schema; "search" sends top-k + the generated `search_tools` tool. */
101
110
  readonly toolsDisclosure?: import("./tool-search.js").ToolsDisclosure;
102
111
  readonly toolsSearch?: import("./tool-search.js").ToolsSearchOptions;
103
112
  /** Opt-in projection-only fold for aged large tool results in provider view; store untouched. */
104
113
  readonly toolResultFold?: import("./tool-result-fold.js").ToolResultFoldOptions;
114
+ /** Per-run overlay for `AgentConfig.attentionCompiler` (plan 074 C12): `false` disables the
115
+ * compiler for this run, `true` is a no-op, an object may only relax the agent setting
116
+ * (gate ratios up, `keepLast`/`thinkingKeepTurns` down, `excludeTools` extended). Enabling
117
+ * the compiler where the agent config left it off throws before the first provider turn. */
118
+ readonly attentionCompiler?: import("./contracts-core/attention.js").AttentionCompilerSetting;
105
119
  readonly instructionInjectors?: readonly InstructionInjector[];
106
120
  readonly inputLayout?: InputAssemblyLayout;
107
121
  readonly loop?: AgentLoopStrategy | AgentLoopOptions;
@@ -299,6 +313,21 @@ export type AgentEvent = {
299
313
  readonly sessionId: string;
300
314
  readonly runId?: string;
301
315
  readonly summary: string;
316
+ } | {
317
+ /** One attention-compiler mutation (plan 074 R15/T6): measured counts only, never message text. */
318
+ readonly type: "attention_compiled";
319
+ readonly sessionId: string;
320
+ readonly runId?: string;
321
+ readonly used: number;
322
+ /** Estimated tokens of the same request after this turn's mutation. */
323
+ readonly usedAfter: number;
324
+ readonly inputCap: number;
325
+ readonly triggerRatio: number;
326
+ readonly droppedThinkingTurns: number;
327
+ readonly stubbedToolResults: number;
328
+ /** Payload bytes the tool stubs took out of this request. */
329
+ readonly stubbedBytes: number;
330
+ readonly truncated: boolean;
302
331
  } | {
303
332
  readonly type: "retry_scheduled";
304
333
  readonly sessionId: string;
@@ -196,6 +196,12 @@ export interface AgentRunResumeOptions {
196
196
  readonly fencingToken?: number;
197
197
  /** Routes root decisions for nested-run approvals back to the child (e.g. supervisor). */
198
198
  readonly resumeNestedRun?: ResumeNestedRun;
199
+ /**
200
+ * Opt-in (plan 078 Task 7): receives the reconstructed session before the resumed run
201
+ * starts, so an observer (e.g. the supervisor's child-event pump) can subscribe while the
202
+ * run is still live. The session is valid only for the duration of this resume.
203
+ */
204
+ readonly onSession?: (session: AgentSession) => void;
199
205
  /** Opt-in (plan 015 Task 4): restore persisted loaded-skill names into the resumed session catalog. */
200
206
  readonly persistSessionState?: boolean;
201
207
  /** Opt-in (plan 018 Task 6): restore persisted loaded-skill bodies (requires `persistSessionState` too). */
@@ -0,0 +1,78 @@
1
+ import type { Agent, AgentConfig, CheckpointStore, SecureAgentOptions, SessionStore } from "./contracts.js";
2
+ import type { SecretRedactor } from "./redaction.js";
3
+ export type HostCompositionProfile = "personal" | "local-personal" | "business" | "business-worker" | "multi-tenant-worker";
4
+ export declare class HostCompositionError extends Error {
5
+ readonly code: string;
6
+ constructor(message: string, code?: string);
7
+ }
8
+ export interface HostCompositionGovernance {
9
+ readonly modelRouter?: unknown;
10
+ readonly budgetPolicy?: unknown;
11
+ readonly rateLimitPolicy?: unknown;
12
+ readonly supported?: boolean;
13
+ readonly [key: string]: unknown;
14
+ }
15
+ export interface HostCompositionOptions {
16
+ readonly profile?: HostCompositionProfile;
17
+ readonly agent?: Agent | AgentConfig | SecureAgentOptions | Partial<AgentConfig>;
18
+ readonly store?: SessionStore | CheckpointStore | {
19
+ readonly kind?: string;
20
+ readonly durable?: boolean;
21
+ [key: string]: unknown;
22
+ };
23
+ readonly checkpoints?: CheckpointStore;
24
+ readonly workspaceRoot?: string;
25
+ readonly sandboxRoots?: readonly string[];
26
+ readonly credentialRefs?: readonly string[];
27
+ readonly governance?: HostCompositionGovernance;
28
+ readonly redactor?: SecretRedactor;
29
+ /** Explicit opt-in for live network checks; inert by default. */
30
+ readonly liveChecks?: boolean;
31
+ }
32
+ export interface HostCompositionToolReport {
33
+ readonly name: string;
34
+ readonly description?: string;
35
+ readonly hasParameters: boolean;
36
+ }
37
+ export interface HostCompositionReport {
38
+ readonly profile: "personal" | "business";
39
+ readonly effectiveTools: readonly HostCompositionToolReport[];
40
+ readonly credentialReferences: readonly string[];
41
+ readonly ownership: {
42
+ readonly tenantId?: string;
43
+ readonly accountId?: string;
44
+ readonly userId?: string;
45
+ };
46
+ readonly storage: {
47
+ readonly kind: string;
48
+ readonly durable: boolean;
49
+ };
50
+ readonly sandbox: {
51
+ readonly workspaceRoot?: string;
52
+ readonly roots: readonly string[];
53
+ readonly isolated: boolean;
54
+ };
55
+ readonly governance: {
56
+ readonly permission: boolean;
57
+ readonly trust: boolean;
58
+ readonly redactor: boolean;
59
+ readonly validator: boolean;
60
+ readonly modelRouting: boolean;
61
+ readonly secure: boolean;
62
+ };
63
+ readonly readiness: {
64
+ readonly ok: boolean;
65
+ readonly errors: readonly string[];
66
+ readonly warnings: readonly string[];
67
+ };
68
+ }
69
+ /**
70
+ * Inspects a host composition in an inert, bounded, and secret-redacting manner.
71
+ * Performs zero network calls by default.
72
+ */
73
+ export declare function inspectHostComposition(options: HostCompositionOptions): HostCompositionReport;
74
+ /**
75
+ * Asserts that a host composition meets all readiness requirements for its profile.
76
+ * Throws HostCompositionError on failure.
77
+ */
78
+ export declare function assertHostCompositionReadiness(options: HostCompositionOptions): HostCompositionReport;