@qlairoslabs/acp-client 0.13.1-alpha.1 → 0.13.2-alpha.1

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 (105) hide show
  1. package/CONSUMER_GUIDE.md +60 -26
  2. package/package.json +5 -1
  3. package/src/agent/config.ts +2 -0
  4. package/src/agent/native-operations.ts +1 -0
  5. package/src/agent-session.ts +11 -2
  6. package/src/agent.ts +4 -1
  7. package/src/index.ts +2 -0
  8. package/src/native/capabilities.ts +2 -2
  9. package/src/native/connection.ts +1 -1
  10. package/src/native/controller.ts +2 -1
  11. package/src/native/host-config.ts +2 -0
  12. package/src/native/host.ts +10 -0
  13. package/src/native/mcp.ts +47 -0
  14. package/src/native/recovery.ts +8 -7
  15. package/src/native/reminders/routine-guard.ts +4 -3
  16. package/src/native/reminders/routine-wire.ts +1 -1
  17. package/src/native-harness/README.md +58 -1
  18. package/src/native-harness/package.json +4 -0
  19. package/src/native-harness/src/capabilities/attachments/admission.ts +42 -0
  20. package/src/native-harness/src/capabilities/attachments/image-validation.ts +98 -0
  21. package/src/native-harness/src/capabilities/attachments/input.ts +1 -0
  22. package/src/native-harness/src/capabilities/attachments/read.ts +76 -0
  23. package/src/native-harness/src/capabilities/attachments/recovery.ts +26 -0
  24. package/src/native-harness/src/capabilities/attachments/selection.ts +37 -0
  25. package/src/native-harness/src/capabilities/attachments/service.ts +75 -0
  26. package/src/native-harness/src/capabilities/attachments/upload.ts +164 -0
  27. package/src/native-harness/src/capabilities/attachments/vision.ts +45 -0
  28. package/src/native-harness/src/capabilities/context/build.ts +5 -0
  29. package/src/native-harness/src/capabilities/model/openrouter-stream.ts +80 -17
  30. package/src/native-harness/src/capabilities/model/runner.ts +6 -3
  31. package/src/native-harness/src/capabilities/tools/mcp/client.ts +97 -0
  32. package/src/native-harness/src/capabilities/tools/mcp/http.ts +183 -0
  33. package/src/native-harness/src/capabilities/tools/mcp/registry.ts +62 -0
  34. package/src/native-harness/src/capabilities/tools/mcp/result.ts +33 -0
  35. package/src/native-harness/src/capabilities/tools/mcp/schema.ts +77 -0
  36. package/src/native-harness/src/capabilities/tools/mcp/secrets.ts +28 -0
  37. package/src/native-harness/src/capabilities/tools/mcp/stdio.ts +105 -0
  38. package/src/native-harness/src/capabilities/tools/runtime/invocations.ts +4 -1
  39. package/src/native-harness/src/capabilities/tools/web/config.ts +1 -0
  40. package/src/native-harness/src/capabilities/tools/web/definitions.ts +18 -0
  41. package/src/native-harness/src/capabilities/tools/web/direct-address.ts +56 -0
  42. package/src/native-harness/src/capabilities/tools/web/direct-transport.ts +235 -0
  43. package/src/native-harness/src/capabilities/tools/web/direct.ts +149 -0
  44. package/src/native-harness/src/capabilities/tools/web/exa-transport.ts +41 -0
  45. package/src/native-harness/src/capabilities/tools/web/exa.ts +71 -0
  46. package/src/native-harness/src/capabilities/tools/web/preview.ts +44 -0
  47. package/src/native-harness/src/capabilities/tools/web/registry.ts +47 -0
  48. package/src/native-harness/src/capabilities/tools/web/usage.ts +1 -0
  49. package/src/native-harness/src/contracts/agent.ts +3 -1
  50. package/src/native-harness/src/contracts/attachments.ts +62 -0
  51. package/src/native-harness/src/contracts/config-permissions.ts +13 -4
  52. package/src/native-harness/src/contracts/context.ts +1 -1
  53. package/src/native-harness/src/contracts/events.ts +2 -2
  54. package/src/native-harness/src/contracts/loop.ts +3 -3
  55. package/src/native-harness/src/contracts/mcp.ts +22 -0
  56. package/src/native-harness/src/contracts/model-execution.ts +2 -1
  57. package/src/native-harness/src/contracts/operator-controls.ts +8 -1
  58. package/src/native-harness/src/contracts/protocol.ts +20 -4
  59. package/src/native-harness/src/contracts/session-file.ts +2 -1
  60. package/src/native-harness/src/contracts/session.ts +6 -1
  61. package/src/native-harness/src/contracts/storage.ts +23 -5
  62. package/src/native-harness/src/contracts/tools.ts +2 -0
  63. package/src/native-harness/src/contracts/web.ts +16 -0
  64. package/src/native-harness/src/governance/permissions/gate.ts +9 -2
  65. package/src/native-harness/src/governance/policy/resolve.ts +6 -1
  66. package/src/native-harness/src/index.ts +43 -11
  67. package/src/native-harness/src/interfaces/cli/development.ts +108 -53
  68. package/src/native-harness/src/interfaces/cli/serve.ts +2 -2
  69. package/src/native-harness/src/interfaces/cli/start.ts +22 -13
  70. package/src/native-harness/src/interfaces/client.ts +8 -2
  71. package/src/native-harness/src/interfaces/inspector/index.html +7 -1
  72. package/src/native-harness/src/interfaces/inspector/state.ts +6 -2
  73. package/src/native-harness/src/interfaces/protocol/load.ts +3 -1
  74. package/src/native-harness/src/interfaces/protocol/local.ts +13 -4
  75. package/src/native-harness/src/interfaces/protocol/operator.ts +8 -2
  76. package/src/native-harness/src/interfaces/protocol/server.ts +93 -29
  77. package/src/native-harness/src/interfaces/protocol/stdio-client.ts +1 -0
  78. package/src/native-harness/src/interfaces/web-chat/index.html +65 -12
  79. package/src/native-harness/src/interfaces/web-chat/server.ts +30 -3
  80. package/src/native-harness/src/kernel/channels.ts +19 -11
  81. package/src/native-harness/src/kernel/loop.ts +1 -1
  82. package/src/native-harness/src/runtime/config/inference-key.ts +7 -0
  83. package/src/native-harness/src/runtime/config/managed.ts +1 -1
  84. package/src/native-harness/src/runtime/config/paths.ts +3 -2
  85. package/src/native-harness/src/runtime/execution/mcp-stdio.ts +31 -0
  86. package/src/native-harness/src/state/storage/archive.ts +95 -12
  87. package/src/native-harness/src/state/storage/attachment-files.ts +58 -0
  88. package/src/native-harness/src/state/storage/attachment-import.ts +106 -0
  89. package/src/native-harness/src/state/storage/attachment-tables.ts +123 -0
  90. package/src/native-harness/src/state/storage/engine.ts +194 -34
  91. package/src/native-harness/src/state/storage/inference.ts +30 -2
  92. package/src/native-harness/src/state/storage/memory-attachments.ts +56 -0
  93. package/src/native-harness/src/state/storage/memory.ts +18 -3
  94. package/src/native-harness/src/state/storage/reminder-archive.ts +2 -2
  95. package/src/native-harness/src/state/storage/session-file.ts +22 -9
  96. package/src/native-harness/src/state/storage/sqlite.ts +51 -10
  97. package/src/native-harness/src/state/storage/web-tables.ts +47 -0
  98. package/src/native-harness/src/testing.ts +150 -55
  99. package/src/native-harness/src/util/attachment-input.ts +42 -0
  100. package/src/native-harness/src/util/config.ts +59 -12
  101. package/src/native-harness/src/util/mcp-config.ts +102 -0
  102. package/src/native-harness/src/util/web-config.ts +34 -0
  103. package/src/native-harness/src/util/web-usage.ts +33 -0
  104. package/src/steering/combine.ts +1 -0
  105. package/src/steering/contracts.ts +3 -0
@@ -0,0 +1,71 @@
1
+ import { ExaResponseLimit } from "./exa-transport.ts";
2
+ import { directUrl } from "./direct-address.ts";
3
+ import { fetchPreview, searchPreview, type WebHit } from "./preview.ts";
4
+
5
+ import type { WebToolError as WebError, WebResultUsage as WebUsage, WebToolResponse as WebResponse } from "../../../contracts/web.ts";
6
+ export type { WebToolError as WebError, WebResultUsage as WebUsage, WebToolResponse as WebResponse } from "../../../contracts/web.ts";
7
+ /** Transport must reject redirects, enforce raw/decoded 2 MiB caps and abort. */
8
+ export type ExaTransport = (request: { path: "/search" | "/contents"; key: string; body: object; signal: AbortSignal }) => Promise<{ status: number; body: unknown }>;
9
+ const failed = (code: WebError, usage: WebUsage = {}): WebResponse => ({ ok: false, code, message: ({ blocked_destination: "Web destination is blocked", unsupported_content: "Unsupported page content", invalid_arguments: "Invalid web tool arguments", rate_limited: "Web provider rate limit reached", provider_error: "Web provider request failed", tool_timeout: "Web request timed out", page_unavailable: "Page content is unavailable", result_too_large: "Page metadata exceeds the result limit", tool_interrupted: "Web request was interrupted", response_too_large: "Web provider response exceeds the limit" })[code], usage });
10
+ const record = (v: unknown): Record<string, unknown> | undefined => v && typeof v === "object" && !Array.isArray(v) ? v as Record<string, unknown> : undefined;
11
+ const usageOf = (value: Record<string, unknown> | undefined): WebUsage => {
12
+ const usage: WebUsage = {}, id = value?.requestId, cost = record(value?.costDollars)?.total;
13
+ if (typeof id === "string" && Buffer.byteLength(id) <= 256 && id.trim() && !/[\u0000-\u001f\u007f]/u.test(id)) usage.requestId = id;
14
+ if (typeof cost === "number" && Number.isFinite(cost) && cost >= 0) usage.usd = cost;
15
+ return usage;
16
+ };
17
+ /** Share strict public URL syntax and literal checks with the direct adapter;
18
+ * actual DNS binding remains the direct transport's responsibility. */
19
+ export function normalizedWebUrl(value: unknown): string | undefined {
20
+ if (typeof value !== "string") return;
21
+ try { const result = directUrl(value).href; return Buffer.byteLength(result) <= 2048 ? result : undefined; } catch { return; }
22
+ }
23
+ export function webArgumentsProblem(name: "web_search" | "web_fetch", value: unknown): string | undefined {
24
+ const input = record(value), field = name === "web_search" ? "query" : "url";
25
+ if (!input || Object.keys(input).length !== 1 || !(field in input)) return "Expected exactly one argument";
26
+ if (field === "query") return typeof input.query === "string" && !!input.query.trim() && Buffer.byteLength(input.query) <= 1024 ? undefined : "Invalid query";
27
+ return normalizedWebUrl(input.url) ? undefined : "Invalid URL";
28
+ }
29
+ export async function runExa(input: { operation: "web_search" | "web_fetch"; args: { query: string } | { url: string }; key: string; transport: ExaTransport; maxResults?: number; excerptBytes?: number; deadlineMs?: number; signal?: AbortSignal }): Promise<WebResponse> {
30
+ if (input.signal?.aborted) return failed("tool_interrupted");
31
+ const args = input.args, search = input.operation === "web_search";
32
+ if (webArgumentsProblem(input.operation, args)) return failed("invalid_arguments");
33
+ const url = !search && "url" in args ? normalizedWebUrl(args.url)! : undefined;
34
+ const body = search && "query" in args ? { query: args.query, type: "auto", numResults: input.maxResults ?? 5, contents: { highlights: { maxCharacters: 512 } } }
35
+ : { urls: [url], text: { maxCharacters: 16000 }, maxAgeHours: 24, livecrawlTimeout: 10000, subpages: 0 };
36
+ const controller = new AbortController(); let cause: "tool_timeout" | "tool_interrupted" | undefined;
37
+ const abort = () => { cause ??= "tool_interrupted"; controller.abort(); };
38
+ input.signal?.addEventListener("abort", abort, { once: true });
39
+ if (input.signal?.aborted) abort();
40
+ const timeout = setTimeout(() => { cause ??= "tool_timeout"; controller.abort(); }, input.deadlineMs ?? 15000);
41
+ try {
42
+ if (cause) return failed(cause);
43
+ const response = await input.transport({ path: search ? "/search" : "/contents", key: input.key, body, signal: controller.signal });
44
+ if (cause) return failed(cause);
45
+ const json = record(response.body), usage = usageOf(json);
46
+ // Provider output is untrusted and may echo request headers. Do not allow
47
+ // the resolved credential to escape via content or request metadata.
48
+ if (input.key && usage.requestId?.includes(input.key)) delete usage.requestId;
49
+ const redact = (value: string) => input.key ? value.replaceAll(input.key, "[redacted]") : value;
50
+ if (response.status === 429) return failed("rate_limited", usage);
51
+ if (response.status < 200 || response.status >= 300 || !json) return failed("provider_error", usage);
52
+ if (search) {
53
+ if (!Array.isArray(json.results)) return failed("provider_error", usage);
54
+ const hits: WebHit[] = [];
55
+ for (const value of json.results) {
56
+ const item = record(value), hitUrl = normalizedWebUrl(item?.url); if (!hitUrl || (input.key && hitUrl.includes(input.key))) continue;
57
+ const highlights = item?.highlights;
58
+ hits.push({ title: typeof item?.title === "string" ? redact(item.title) : null, url: hitUrl,
59
+ excerpt: Array.isArray(highlights) ? highlights.filter((part): part is string => typeof part === "string").map(redact).join(" ") || null : null });
60
+ }
61
+ return { ok: true, content: searchPreview(hits, input.maxResults ?? 5, input.excerptBytes ?? 512), usage };
62
+ }
63
+ const statuses = Array.isArray(json.statuses) ? json.statuses.map(record).filter(entry => entry?.id === url) : [];
64
+ const results = Array.isArray(json.results) ? json.results.map(record).filter(entry => normalizedWebUrl(entry?.url) === url) : [];
65
+ if (statuses.length !== 1 || statuses[0]?.status !== "success" || results.length !== 1 || typeof results[0]?.text !== "string" || !results[0].text.trim()) return failed("page_unavailable", usage);
66
+ if (input.key && url!.includes(input.key)) return failed("page_unavailable", usage);
67
+ const content = fetchPreview({ url: url!, title: typeof results[0].title === "string" ? redact(results[0].title) : null, text: redact(results[0].text), truncated: false, coverage: "unknown" });
68
+ return content === undefined ? failed("result_too_large", usage) : { ok: true, content, usage };
69
+ } catch (error) { return failed(cause ?? (error instanceof ExaResponseLimit ? "response_too_large" : "provider_error")); }
70
+ finally { clearTimeout(timeout); input.signal?.removeEventListener("abort", abort); }
71
+ }
@@ -0,0 +1,44 @@
1
+ /** Provider-neutral model-facing data. All limits include serialized JSON. */
2
+ export interface WebHit { title: string | null; url: string; excerpt: string | null }
3
+ export interface WebPage { url: string; title: string | null; text: string; truncated: boolean; coverage: "full" | "partial" | "unknown" }
4
+ export const WEB_PREVIEW_BYTES = 2048;
5
+ const size = (value: unknown) => Buffer.byteLength(JSON.stringify(value), "utf8");
6
+
7
+ /** Longest scalar-aligned prefix which makes the complete object fit. */
8
+ function fitText(value: string, fits: (prefix: string) => boolean): string | undefined {
9
+ const scalars = Array.from(value); let low = 0, high = scalars.length;
10
+ if (!fits("")) return undefined;
11
+ while (low < high) { const mid = Math.ceil((low + high) / 2); if (fits(scalars.slice(0, mid).join(""))) low = mid; else high = mid - 1; }
12
+ return scalars.slice(0, low).join("");
13
+ }
14
+ export function truncateUtf8(value: string, max: number): string {
15
+ return fitText(value, prefix => Buffer.byteLength(prefix) <= max) ?? "";
16
+ }
17
+ export function searchPreview(hits: readonly WebHit[], maxHits = 5, excerptBytes = 512): string {
18
+ const results: WebHit[] = [];
19
+ for (const original of hits.slice(0, maxHits)) {
20
+ const hit = { ...original, excerpt: original.excerpt === null ? null : truncateUtf8(original.excerpt, excerptBytes) };
21
+ const candidate = () => ({ results: [...results, hit] });
22
+ if (size(candidate()) > WEB_PREVIEW_BYTES && hit.excerpt !== null)
23
+ hit.excerpt = fitText(hit.excerpt, prefix => size({ results: [...results, { ...hit, excerpt: prefix }] }) <= WEB_PREVIEW_BYTES) ?? null;
24
+ if (size(candidate()) > WEB_PREVIEW_BYTES && hit.title !== null)
25
+ hit.title = fitText(hit.title, prefix => size({ results: [...results, { ...hit, title: prefix }] }) <= WEB_PREVIEW_BYTES) ?? null;
26
+ if (size(candidate()) > WEB_PREVIEW_BYTES) break;
27
+ results.push(hit);
28
+ }
29
+ return JSON.stringify({ results });
30
+ }
31
+ export function fetchPreview(input: WebPage): string | undefined {
32
+ const page = { ...input }; const fits = () => size(page) <= WEB_PREVIEW_BYTES;
33
+ if (fits()) return JSON.stringify(page);
34
+ page.truncated = true;
35
+ if (page.title !== null) {
36
+ const original = page.title;
37
+ page.title = fitText(original, prefix => size({ ...page, title: prefix, text: "" }) <= WEB_PREVIEW_BYTES) ?? null;
38
+ }
39
+ const original = page.text;
40
+ const text = fitText(original, prefix => size({ ...page, text: prefix }) <= WEB_PREVIEW_BYTES);
41
+ if (text === undefined) return undefined;
42
+ page.text = text;
43
+ return JSON.stringify(page);
44
+ }
@@ -0,0 +1,47 @@
1
+ import { fetchDirect } from "./direct.ts";
2
+ import { DirectHttpError } from "./direct-address.ts";
3
+ import type { CheckedWebRegistration } from "../../../contracts/web.ts";
4
+ export type { CheckedWebRegistration } from "../../../contracts/web.ts";
5
+ import { resolveWebCredentials, type Validated, type WebConfig } from "./config.ts";
6
+ import { WEB_FETCH, WEB_SEARCH, webDefinitions, webProblem } from "./definitions.ts";
7
+ import { runExa, type ExaTransport, type WebResponse } from "./exa.ts";
8
+
9
+ /** Adapter implementations are supplied by the trusted assembly, never config. */
10
+ export type DirectFetch = (url: string, signal: AbortSignal, deadlineMs: number) => Promise<WebResponse>;
11
+ /** Build once per executable open; credentials remain inside executor closures. */
12
+ export function createWebRegistry(config: WebConfig, env: Readonly<Record<string, string | undefined>>,
13
+ providers: { exa: ExaTransport; http?: DirectFetch }): Validated<readonly CheckedWebRegistration[]> {
14
+ const credentials = resolveWebCredentials(config, env);
15
+ if (!credentials.ok) return credentials;
16
+ if (config.webFetch?.backend === "http" && !providers.http) return { ok: false, error: { code: "invalid_config", message: "HTTP fetch adapter is unavailable" } };
17
+ const registrations: CheckedWebRegistration[] = [];
18
+ if (config.webSearch) {
19
+ const options = structuredClone(config.webSearch), key = credentials.value.searchKey!;
20
+ registrations.push({ definition: webDefinitions.find(value => value.name === WEB_SEARCH)!, validate: args => webProblem(WEB_SEARCH, args),
21
+ dispatch: { backend: "exa", operation: "web_search", paid: true },
22
+ execute: (args, signal) => runExa({ operation: "web_search", args: args as { query: string }, key, transport: providers.exa,
23
+ maxResults: options.maxResults, excerptBytes: options.excerptBytes, deadlineMs: options.deadlineMs, signal }) });
24
+ }
25
+ if (config.webFetch) {
26
+ const options = structuredClone(config.webFetch);
27
+ registrations.push({ definition: webDefinitions.find(value => value.name === WEB_FETCH)!, validate: args => webProblem(WEB_FETCH, args),
28
+ dispatch: options.backend === "exa" ? { backend: "exa", operation: "web_fetch", paid: true } : { backend: "http", operation: "web_fetch", paid: false },
29
+ execute: (args, signal) => {
30
+ const problem = webProblem(WEB_FETCH, args);
31
+ if (problem) return Promise.resolve({ ok: false, code: "invalid_arguments", message: "Invalid web tool arguments", usage: {} });
32
+ return options.backend === "exa"
33
+ ? runExa({ operation: "web_fetch", args: args as { url: string }, key: credentials.value.fetchKey!, transport: providers.exa, deadlineMs: options.deadlineMs, signal })
34
+ : providers.http!((args as { url: string }).url, signal, options.deadlineMs ?? 15000).then(result => ({ ...result, usage: {} }));
35
+ } });
36
+ }
37
+ return { ok: true, value: registrations };
38
+ }
39
+
40
+ /** Production adapter; fixture transports remain assembly-only. */
41
+ export const directWebFetch: DirectFetch = async (url, signal, deadlineMs) => {
42
+ try { return { ok: true, content: await fetchDirect(url, deadlineMs, signal), usage: {} }; }
43
+ catch (error) {
44
+ const known = error instanceof DirectHttpError;
45
+ return { ok: false, code: known ? error.code : "page_unavailable", message: known ? error.message : "Web destination could not be read.", usage: {} };
46
+ }
47
+ };
@@ -0,0 +1 @@
1
+ export * from "../../../util/web-usage.ts";
@@ -4,6 +4,8 @@ export interface ChannelInput {
4
4
  channelId: string;
5
5
  participantId: string;
6
6
  text: string;
7
+ /** Ordered mixed parts; callers supply a matching newline-joined text projection. */
8
+ parts?: readonly import("./attachments.ts").InputPart[];
7
9
  itemId?: string;
8
10
  policy?: string | null;
9
11
  }
@@ -52,7 +54,7 @@ export type SendResult =
52
54
  * an already accepted input never gets this; it returns its recorded outcome. */
53
55
  | "channel_suspended"
54
56
  /** Decision 0014: the channel ID was deleted and is reserved. */
55
- | "channel_retired" };
57
+ | "channel_retired" | "unsupported_image" | "transfer_limit" };
56
58
 
57
59
  /** Shared entity with one delivery behavior for messages and notices: accept
58
60
  * durably, then the channel takes the item as soon as it can. An active turn
@@ -0,0 +1,62 @@
1
+ /** An immutable harness-owned attachment reference, never a filesystem path. */
2
+ export type InputPart =
3
+ | { readonly type: "text"; readonly text: string }
4
+ | { readonly type: "attachment"; readonly id: string };
5
+
6
+ /** Metadata describes committed bytes. It does not grant access to them. */
7
+ export interface AttachmentMetadata {
8
+ readonly id: string;
9
+ readonly channel: string;
10
+ readonly filename: string;
11
+ readonly mediaType: string;
12
+ readonly bytes: number;
13
+ readonly sha256: string;
14
+ }
15
+
16
+ /** Metadata-only presentation of a submitted part. */
17
+ export type AttachmentViewPart = { type: "text"; text: string } |
18
+ { type: "attachment"; id: string; text?: never; metadata?: AttachmentMetadata; unavailable?: true };
19
+
20
+ /** A provider boundary refused an image request without sending a partial one. */
21
+ export interface AttachmentFailure {
22
+ code: "unsupported_image" | "attachment_unavailable" | "transfer_limit";
23
+ attachmentIds: string[];
24
+ }
25
+
26
+ /** Limits apply to decoded bytes, not base64 or transport frames. */
27
+ export const ATTACHMENT_LIMITS = {
28
+ fileBytes: 20 * 1024 * 1024,
29
+ imageBytesPerTurn: 40 * 1024 * 1024,
30
+ parts: 32,
31
+ references: 8,
32
+ inputBytes: 8 * 1024,
33
+ chunkBytes: 512 * 1024,
34
+ openUploads: 4,
35
+ uploadIdleMs: 60_000,
36
+ imageSide: 8192,
37
+ imagePixels: 20_000_000,
38
+ } as const;
39
+
40
+ /** Project only metadata allowed by the current owner or shared timeline. */
41
+ export function attachmentView(parts: readonly InputPart[], read: ((id: string) => { ok: true; value: { metadata: AttachmentMetadata; timelineVisible: boolean } | undefined } | { ok: false }) | undefined,
42
+ scope: { ownerChannel?: string; timeline?: boolean }): AttachmentViewPart[] {
43
+ return parts.map(part => {
44
+ if (part.type === "text") return { ...part };
45
+ const result = read?.(part.id), found = result?.ok ? result.value : undefined;
46
+ const visible = found && (scope.timeline ? found.timelineVisible : found.metadata.channel === scope.ownerChannel);
47
+ return visible ? { ...part, metadata: found!.metadata } : { ...part, unavailable: true };
48
+ });
49
+ }
50
+
51
+ /** Durable reason representation allows typed recovery after process restart. */
52
+ export function attachmentFailureReason(failure: AttachmentFailure): string {
53
+ return JSON.stringify({ attachmentFailure: failure });
54
+ }
55
+ export function parseAttachmentFailure(reason: string): AttachmentFailure | undefined {
56
+ try {
57
+ const value = JSON.parse(reason)?.attachmentFailure;
58
+ if (!value || !["unsupported_image", "attachment_unavailable", "transfer_limit"].includes(value.code)
59
+ || !Array.isArray(value.attachmentIds) || !value.attachmentIds.every((id: unknown) => typeof id === "string")) return undefined;
60
+ return { code: value.code, attachmentIds: [...value.attachmentIds] };
61
+ } catch { return undefined; }
62
+ }
@@ -1,17 +1,26 @@
1
+ import type { McpServer } from "./mcp.ts";
2
+
1
3
  /** Decisions 0016 and 0017: a validated portable session configuration.
2
4
  * Script files and credential environment variables are destination resources. */
3
5
  export type ToolDecision = "allow" | "ask" | "deny";
4
- export interface ToolPolicy { fallback: ToolDecision; tools: Record<string, ToolDecision> }
5
- export type ManagedModel = { protocol: "scripted"; script: string }
6
- | { protocol: "openrouter"; model: string; apiKeyEnv: string }
6
+ export interface ToolPolicy { fallback: ToolDecision; mcp?: "allow" | "deny"; tools: Record<string, ToolDecision> }
7
+ export type ManagedModel = { protocol: "scripted"; script: string; imageInput?: boolean }
8
+ | { protocol: "openrouter"; model: string; apiKeyEnv: string; imageInput?: boolean }
7
9
  | { protocol: "openai-compatible"; providerId: string; model: string; baseUrl: string; apiKeyEnv?: string };
10
+ /** Decision 0035: independent portable web backends, with credential names only. */
11
+ export interface ExaSearchConfig { backend: "exa"; apiKeyEnv?: string; maxResults?: number; excerptBytes?: number; deadlineMs?: number }
12
+ export type WebFetchConfig = { backend: "exa"; apiKeyEnv?: string; deadlineMs?: number } | { backend: "http"; deadlineMs?: number };
13
+ export interface WebConfig { webSearch?: ExaSearchConfig; webFetch?: WebFetchConfig }
8
14
  export interface ManagedConfig {
9
15
  version: 1;
10
- limits?: { unattendedTurns: number };
16
+ limits?: { unattendedTurns?: number; mcpCallTimeoutMs?: number };
17
+ mcpServers?: Record<string, McpServer>;
11
18
  system: string;
12
19
  model: ManagedModel;
13
20
  defaultPolicy: string;
14
21
  timelineTools?: boolean;
22
+ webSearch?: ExaSearchConfig;
23
+ webFetch?: WebFetchConfig;
15
24
  policies: Record<string, ToolPolicy>;
16
25
  }
17
26
 
@@ -99,7 +99,7 @@ export interface TurnContext {
99
99
  * barrier resolves before the last cancellation check. */
100
100
  dispatchTool(call: ToolCall, execute: ExecuteTurnTool): Promise<{ content: string; dispatched: boolean;
101
101
  /** Decision 0021: recorded with the paired result of a dispatched call. */
102
- outcome?: import("./tools.ts").ToolOutcome }>;
102
+ outcome?: import("./tools.ts").ToolOutcome; usage?: import("./web.ts").WebResultUsage }>;
103
103
  /** Take pending inbox items (messages and notices) into this turn. */
104
104
  drainNotices?(): void;
105
105
  finish?(): boolean;
@@ -30,7 +30,7 @@ export interface ChannelEvent {
30
30
  revision?: number;
31
31
  event: (LoopEvent & { turnId: string; messageId?: string })
32
32
  | import("./model-execution.ts").ModelTextEvent
33
- | { type: "turn_started" | "turn_took"; turnId: string; items: string[]; messages?: { itemId: string; messageId: string; position: import("./operator-controls.ts").MessagePosition }[] }
33
+ | { type: "turn_started" | "turn_took"; turnId: string; items: string[]; messages?: { itemId: string; messageId: string; position: import("./operator-controls.ts").MessagePosition; parts?: import("./attachments.ts").AttachmentViewPart[] }[] }
34
34
  | { type: "items_receipt"; turnId: string; items: string[]; milestone: "delivered" | "seen" }
35
35
  | { type: "turn_suspended" | "turn_resumed"; turnId: string }
36
36
  | { type: "channel_state"; lifecycle: "open" | "suspending" | "suspended" | "retired"; displayName?: string; policy?: string }
@@ -38,7 +38,7 @@ export interface ChannelEvent {
38
38
  | (import("./reminders.ts").ReminderChannelEvent & { turnId?: never })
39
39
  | import("./operator-controls.ts").ApprovalClosedEvent
40
40
  | ({ type: "approval_requested" } & import("./config-permissions.ts").ApprovalRequest)
41
- | { type: "turn_ended"; turnId: string; outcome: "completed" | "failed" | "interrupted"; error?: string; uncertainCalls?: string[] };
41
+ | { type: "turn_ended"; turnId: string; outcome: "completed" | "failed" | "interrupted"; error?: string; uncertainCalls?: string[]; attachmentFailure?: import("./attachments.ts").AttachmentFailure };
42
42
  }
43
43
  export type EventSink = (event: ChannelEvent) => void;
44
44
 
@@ -7,9 +7,9 @@ export interface ToolCall {
7
7
 
8
8
  /** Neutral history. Provider state is opaque to the loop. */
9
9
  export type Message =
10
- | { role: "system" | "user"; content: string }
10
+ | { role: "system" | "user"; content: string; parts?: readonly import("./attachments.ts").InputPart[] }
11
11
  | { role: "assistant"; content: string | null; calls: ToolCall[]; providerState?: unknown }
12
- | { role: "tool"; content: string; callId: string; /** Decision 0021; absent means a legacy success. */ outcome?: import("./tools.ts").ToolOutcome };
12
+ | { role: "tool"; content: string; callId: string; /** Decision 0021; absent means a legacy success. */ outcome?: import("./tools.ts").ToolOutcome; usage?: import("./web.ts").WebResultUsage; webNoDispatch?: true };
13
13
 
14
14
  /** JSON schema describing the arguments accepted by a configured tool. */
15
15
  export interface ToolDefinition {
@@ -26,6 +26,6 @@ export type Model = (
26
26
 
27
27
  /** Executes only permitted tools; returns serialized successes or errors. Stop
28
28
  * aborts `signal`; a call already in flight may still have had its effect. */
29
- export interface ToolExecutionResult { content: string; outcome: import("./tools.ts").ToolOutcome }
29
+ export interface ToolExecutionResult { content: string; outcome: import("./tools.ts").ToolOutcome; usage?: import("./web.ts").WebResultUsage }
30
30
  export type ExecuteTool<Result = string> = (call: ToolCall, signal?: AbortSignal) => Promise<Result>;
31
31
  export type ExecuteTurnTool = ExecuteTool<string | ToolExecutionResult>;
@@ -0,0 +1,22 @@
1
+ /** Portable header declaration. Resolved material belongs to an executable open. */
2
+ export type McpHeader = { literal: string } | { env: string } | { runtime: true };
3
+ /** Trusted session configuration, validated without spawning or connecting. */
4
+ export type McpServer = { enabled?: boolean } & (
5
+ { transport: "stdio"; command: string; args: string[]; cwd?: string; env?: Record<string, { env: string }> }
6
+ | { transport: "http"; endpoint: string; headers?: Record<string, McpHeader> }
7
+ );
8
+ export type McpRuntimeHeaders = Record<string, Record<string, string>>;
9
+
10
+ export interface McpTool {
11
+ readonly definition: import("./loop.ts").ToolDefinition;
12
+ available(): boolean;
13
+ accepts(args: unknown): boolean;
14
+ call(args: Record<string, unknown>, signal: AbortSignal): Promise<{ content: string; code?: string }>;
15
+ }
16
+
17
+ /** Runtime-only observation. No transport diagnostics or credential values. */
18
+ export interface McpServerStatus {
19
+ transport: "stdio" | "http";
20
+ state: "ready" | "disabled" | "unavailable";
21
+ reason?: "config" | "spawn" | "connect" | "discovery" | "limit" | "closed";
22
+ }
@@ -29,7 +29,8 @@ export type ModelAttemptEvent =
29
29
  | { type: "text_delta"; text: string }
30
30
  | { type: "usage"; usage: ModelUsage }
31
31
  | { type: "response"; response: ModelResponse; providerRequestId?: string }
32
- | { type: "failure"; kind: "transient" | "invalid_request" | "invalid_config" | "provider"; message: string; providerRequestId?: string };
32
+ | { type: "failure"; kind: "transient" | "invalid_request" | "invalid_config" | "provider"; message: string; providerRequestId?: string;
33
+ code?: "unsupported_image" | "attachment_unavailable" | "transfer_limit"; attachmentIds?: readonly string[] };
33
34
  /** One attempt emits exactly one terminal response or failure unless aborted;
34
35
  * EOF without a terminal is incomplete. A consumer ignores events after the
35
36
  * first terminal, timeout or abort. The adapter assembles and validates tools. */
@@ -2,6 +2,7 @@ import type { ApprovalCloseReason, ApprovalRequest } from "./config-permissions.
2
2
  import type { ChannelChangeResult, ChannelStatusResult, ItemStatus, StoredMessage, PendingChannelChange, ProtocolConfig, TurnStatus } from "./protocol.ts";
3
3
 
4
4
  export interface OpenResult {
5
+ mcpServers?: Record<string, import("./mcp.ts").McpServerStatus>;
5
6
  sessionId: string;
6
7
  lifecycle: import("./storage.ts").SessionLifecycle;
7
8
  revision: number;
@@ -12,6 +13,8 @@ export interface OpenResult {
12
13
  nextDueAt?: string | null;
13
14
  reminderRevision?: number;
14
15
  unattendedTurnGuard?: { maxConsecutiveTurns: number } | null;
16
+ imageInput?: true;
17
+ imageLimits?: { formats: string[]; fileBytes: number; turnBytes: number; maxImages: number; maxSide: number; maxPixels: number };
15
18
  }
16
19
 
17
20
  export interface ChannelObservation {
@@ -23,7 +26,8 @@ export interface ChannelObservation {
23
26
 
24
27
  /** Ordered storage position scoped to a session and channel, distinct from message identity. */
25
28
  export type MessagePosition = string;
26
- export type ConversationMessage = (StoredMessage | {
29
+ type ParticipantMessage = { messageId: string; channel: string; turnId: string; parts: import("./attachments.ts").AttachmentViewPart[] };
30
+ export type ConversationMessage = (ParticipantMessage | {
27
31
  messageId: string; channel: string; turnId: string; omitted: true;
28
32
  }) & { position: MessagePosition; actor: { kind: "participant"; id: string }; itemId: string } |
29
33
  ((StoredMessage | { messageId: string; channel: string; turnId: string; omitted: true }) &
@@ -66,6 +70,8 @@ export interface OperatorMethods {
66
70
  }
67
71
 
68
72
  export interface LoadResultOpenParams {
73
+ /** Executable owning launcher material, never saved. */
74
+ mcpRuntimeHeaders?: import("./mcp.ts").McpRuntimeHeaders;
69
75
  sessionId: string;
70
76
  config?: ProtocolConfig;
71
77
  channelChanges?: PendingChannelChange[];
@@ -77,6 +83,7 @@ export interface LoadResultOpenParams {
77
83
  * Store adapters use the numeric bounds internally. Wire cursors are decoded
78
84
  * and checked by the protocol before invoking this port. */
79
85
  export interface OperatorStorageReads {
86
+ readManagedAttachment?(id: string): import("./storage.ts").StorageResult<{ metadata: import("./attachments.ts").AttachmentMetadata; timelineVisible: boolean } | undefined>;
80
87
  readChannel(channel: string): import("./storage.ts").StorageResult<{
81
88
  channel: Omit<import("./storage.ts").StoredChannel, "participantIds">;
82
89
  pendingCount: number;
@@ -18,13 +18,18 @@ export interface InitializeParams {
18
18
  }
19
19
  export interface ProtocolConfig {
20
20
  version: 1;
21
- limits?: { unattendedTurns: number };
21
+ limits?: import("./config-permissions.ts").ManagedConfig["limits"];
22
+ mcpServers?: Record<string, import("./mcp.ts").McpServer>;
22
23
  system: string;
23
24
  model: import("./config-permissions.ts").ManagedModel;
25
+ webSearch?: import("./config-permissions.ts").ExaSearchConfig;
26
+ webFetch?: import("./config-permissions.ts").WebFetchConfig;
24
27
  defaultPolicy?: string;
25
28
  policies?: Record<string, import("./config-permissions.ts").ToolPolicy>;
26
29
  }
27
30
  export interface CreateParams {
31
+ /** Executable owning launcher material, never saved. */
32
+ mcpRuntimeHeaders?: import("./mcp.ts").McpRuntimeHeaders;
28
33
  sessionId: string;
29
34
  config?: ProtocolConfig;
30
35
  reminderChanges?: import("./reminders.ts").ReminderChange[];
@@ -42,7 +47,7 @@ export interface NotifyParams {
42
47
  }
43
48
  export interface PushParams {
44
49
  channel: string;
45
- item: { id: string; kind: "user_message"; sender: string; content: { type: "text"; text: string }[]; policy?: string | null; delivery?: "queue"; wake?: true };
50
+ item: { id: string; kind: "user_message"; sender: string; content: import("./attachments.ts").InputPart[]; policy?: string | null; delivery?: "queue"; wake?: true };
46
51
  }
47
52
  export interface InitializeResult {
48
53
  protocolVersion: 1;
@@ -52,6 +57,7 @@ export interface InitializeResult {
52
57
 
53
58
  export interface Description {
54
59
  reminderLimits?: import("./reminders.ts").ReminderLimits;
60
+ attachmentLimits?: { fileBytes: number; chunkBytes: number; openUploads: number; uploadIdleMs: number };
55
61
  configOptions: unknown[]; commands: unknown[]; policies: string[];
56
62
  /** Advertise only implemented guarantees: `durable`/`true` are reported by a
57
63
  * server only once its acceptance commits to storage before acknowledging. */
@@ -61,7 +67,8 @@ export interface Description {
61
67
  * reject the field. */
62
68
  startupChannelChanges?: true;
63
69
  /** Decision 0021: tool catalogs, `functions/call` callbacks and invocation records. */
64
- functions?: true; reminders?: true; routines?: true; unattendedTurnGuard?: true };
70
+ mcpServers?: { stdio: boolean; http: boolean; sse: false };
71
+ functions?: true; reminders?: true; routines?: true; unattendedTurnGuard?: true; managedAttachments?: true; orderedParts?: true };
65
72
  }
66
73
 
67
74
  // ---- Channel changes applied at open, decision 0020.
@@ -116,17 +123,20 @@ export interface ItemStatus {
116
123
  milestone: ItemMilestone; turnId?: string;
117
124
  policy?: import("./config-permissions.ts").ItemPolicy;
118
125
  externalSource?: string;
126
+ parts?: import("./attachments.ts").AttachmentViewPart[];
119
127
  }
120
128
  export interface TurnStatus {
121
129
  turnId: string; channel: string; items: string[];
122
130
  state: "running" | "suspended" | "completed" | "failed" | "interrupted";
123
131
  reason?: string;
132
+ attachmentFailure?: import("./attachments.ts").AttachmentFailure;
124
133
  /** Recorded calls with no recorded result; never replayed by the harness. */
125
134
  uncertainCalls?: string[];
126
135
  }
127
136
  /** `idle`, `suspended` and unresolved interrupted work are distinguishable:
128
137
  * see SessionStatus in the session contract for the exact derivation. */
129
138
  export interface StatusResult {
139
+ mcpServers?: Record<string, import("./mcp.ts").McpServerStatus>;
130
140
  sessionId: string; revision: number;
131
141
  lifecycle: "running" | "suspending" | "suspended";
132
142
  execution: "idle" | "working" | "suspending" | "suspended" | "stopped" | "incompatible";
@@ -171,6 +181,12 @@ export interface TransferLimits { chunkBytes: 524288; maxBytes: 268435456; idleM
171
181
  export type ArchiveLocation = { type: "path"; path: string } | { type: "transfer" };
172
182
 
173
183
  export interface DurableMethods extends ModelExecutionMethods, ReminderMethods, Omit<OperatorMethods, "session/create"> {
184
+ "attachment/begin": { params: { channel: string; filename: string; mediaType: string; bytes: number; sha256: string }; result: { uploadId: string; attachmentId: string; offset: number } };
185
+ "attachment/status": { params: { channel: string; uploadId: string }; result: { offset: number } };
186
+ "attachment/write": { params: { channel: string; uploadId: string; offset: number; data: string }; result: { offset: number } };
187
+ "attachment/finalize": { params: { channel: string; uploadId: string }; result: import("./attachments.ts").AttachmentMetadata };
188
+ "attachment/abort": { params: { channel: string; uploadId: string }; result: Record<string, never> };
189
+ "attachment/read": { params: { channel: string; id: string; offset: number }; result: { metadata: import("./attachments.ts").AttachmentMetadata; data: string; nextOffset?: number } };
174
190
  /** Open an existing session with runtime configuration. Returns the load
175
191
  * view; a second load on the same endpoint returns a fresh view only.
176
192
  * `channelChanges` (decision 0020) is validated as a whole, then applied
@@ -269,7 +285,7 @@ export interface Methods {
269
285
  }
270
286
  export interface RpcRequest { jsonrpc: "2.0"; id: number; method: string; params: unknown }
271
287
  export type RpcResponse = { jsonrpc: "2.0"; id: number; result: unknown } |
272
- { jsonrpc: "2.0"; id: number | null; error: { code: number; message: string; data: { code: string } } };
288
+ { jsonrpc: "2.0"; id: number | null; error: { code: number; message: string; data: { code: string; expectedOffset?: number } } };
273
289
  export interface RpcNotification { jsonrpc: "2.0"; method: "channel/event"; params: ChannelEvent }
274
290
  // ---- Requests from the harness to the host, decision 0021. IDs are numeric,
275
291
  // per connection, and separate from the IDs of host requests: direction tells
@@ -3,7 +3,8 @@
3
3
  * embedded or required to exist during import. */
4
4
  export interface PortableSessionConfig {
5
5
  version: 1;
6
- limits?: { unattendedTurns: number };
6
+ limits?: import("./config-permissions.ts").ManagedConfig["limits"];
7
+ mcpServers?: Record<string, import("./mcp.ts").McpServer>;
7
8
  system: string;
8
9
  model: import("./config-permissions.ts").ManagedModel;
9
10
  /** Present on session files produced after decision 0016. */
@@ -89,6 +89,11 @@ export interface PersistentSessionOptions {
89
89
  reminderClock?: import("./reminders.ts").ReminderClock;
90
90
  /** Local opt-in when there is no managed configuration. */
91
91
  timelineTools?: boolean;
92
+ /** Trusted assembly has verified the opted-in model and image validator. */
93
+ imageInput?: boolean;
94
+ /** Local web implementations created by trusted session assembly. */
95
+ mcpTools?: ReadonlyMap<string, import("./mcp.ts").McpTool>;
96
+ webTools?: readonly import("./web.ts").CheckedWebRegistration[];
92
97
  systemPrompt: string;
93
98
  /** Optional assertion of the storage owner's validated config. Omission uses
94
99
  * the owner snapshot; legacy allow applies only when that snapshot is absent. */
@@ -123,7 +128,7 @@ export interface PersistentSession {
123
128
  };
124
129
  /** Read an oldest-first page of complete model-call summaries. */
125
130
  readModelCalls: SessionStorage["readCalls"];
126
- operatorReads?: Pick<SessionStorage, "readSession" | "readExecution" | "readChannel" | "readTracked" | "readTimeline">;
131
+ operatorReads?: Pick<SessionStorage, "readSession" | "readExecution" | "readChannel" | "readTracked" | "readTimeline"> & Partial<Pick<SessionStorage, "readManagedAttachment">>;
127
132
  turnPhase?(turnId: number): import("./tools.ts").TurnPhase | undefined;
128
133
  /** Approval requests belong to this connection; disconnect closes them. */
129
134
  approvals: {
@@ -30,7 +30,7 @@ export type StorageErrorCode =
30
30
  /** Export refused: active or pending work exists and the session is not suspended. */
31
31
  | "busy"
32
32
  | "invalid_archive"
33
- | "serialization_error" | "storage_failure" | "transfer_limit" | "invalid_cursor";
33
+ | "serialization_error" | "storage_failure" | "transfer_limit" | "invalid_cursor" | "unsupported_image" | "attachment_unavailable";
34
34
 
35
35
  /** A failed mutation leaves no partial domain changes. Do not retry blindly. */
36
36
  export interface StorageError { code: StorageErrorCode; message: string }
@@ -79,7 +79,7 @@ export interface StoredSession {
79
79
  sessionId: string;
80
80
  /** Storage contract/data format revision, distinct from RPC and archive versions.
81
81
  * Revision 5 stores model calls and script reservations. Formats 2–4 upgrade on open. */
82
- formatVersion: 6 | 7 | 8;
82
+ formatVersion: 6 | 7 | 8 | 9 | 10;
83
83
  createdAt: string;
84
84
  lifecycle: SessionLifecycle;
85
85
  /** The key supplied at create. Immutable; open never rewrites it. */
@@ -133,6 +133,8 @@ export interface AcceptItem {
133
133
  inheritedPolicyNames?: readonly string[];
134
134
  /** Original payload, kept unrendered for the life of the item. */
135
135
  text: string;
136
+ /** Ordered mixed input; absent for legacy text-only identity. */
137
+ parts?: readonly import("./attachments.ts").InputPart[];
136
138
  }
137
139
 
138
140
  /** An accepted input. While `milestone` is `received` it is pending: in the
@@ -222,6 +224,7 @@ export interface StorageSnapshot {
222
224
  /** Decision 0021: names of revocable tools whose grant is revoked, sorted.
223
225
  * Absent when none ever was. Carried by export and import. */
224
226
  revokedTools?: string[];
227
+ webDispatches?: import("./web.ts").StoredWebDispatch[];
225
228
  }
226
229
 
227
230
  /** Logical, adapter-independent session copy. JSON-serializable. Versioned
@@ -229,7 +232,10 @@ export interface StorageSnapshot {
229
232
  * Version 5 adds external notices. */
230
233
  export interface SessionArchive {
231
234
  format: "harness-session";
232
- archiveVersion: 5 | 6 | 7;
235
+ archiveVersion: 5 | 6 | 7 | 8 | 9;
236
+ /** Complete retained managed bytes, only in logical archive 8. */
237
+ webState?: { baseFormat: 6 | 7 | 8 | 9 };
238
+ attachmentState?: { baseFormat: 6 | 7 | 8; files: Array<{ metadata: import("./attachments.ts").AttachmentMetadata; readyAt: string; bytes: Uint8Array }> };
233
239
  reminderState?: import("./reminders.ts").ReminderArchiveState;
234
240
  exportedAt: string;
235
241
  snapshot: StorageSnapshot;
@@ -302,6 +308,16 @@ export interface ReminderStorage {
302
308
  }
303
309
 
304
310
  export interface SessionStorage extends ModelCallStore, ReminderStorage, TimelineRetrievalReads, OperatorStorageReads, InferenceStorageReads, InspectionStorageReads {
311
+ /** Owner-only publication fence. The managed-byte owner calls this only
312
+ * after it has verified and durably published the immutable bytes. */
313
+ registerReadyAttachment(metadata: import("./attachments.ts").AttachmentMetadata): StorageResult<void>;
314
+ /** Owner-scoped metadata and timeline visibility; bytes are read separately. */
315
+ readManagedAttachment(id: string): StorageResult<{ metadata: import("./attachments.ts").AttachmentMetadata; timelineVisible: boolean } | undefined>;
316
+ /** IDs with committed ready metadata, for owner-only crash recovery. */
317
+ managedAttachmentIds(): StorageResult<string[]>;
318
+ /** Owner-only cleanup fence; accepted references prevent reclamation. */
319
+ unreferencedAttachments(readyBefore: string): StorageResult<import("./attachments.ts").AttachmentMetadata[]>;
320
+ reclaimAttachment(id: string, readyBefore: string): StorageResult<boolean>;
305
321
  readSession(): StorageResult<StoredSession>;
306
322
  readExecution(): StorageResult<Pick<StorageSnapshot, "revision" | "session" | "channels" | "turns" | "items">>;
307
323
  readReadyChannels(intake?: IntakeLimit): StorageResult<{ lifecycle: SessionLifecycle; channels: string[] }>;
@@ -315,10 +331,12 @@ export interface SessionStorage extends ModelCallStore, ReminderStorage, Timelin
315
331
  * dispatched. Invalid or duplicate marks write nothing; failure cannot invoke
316
332
  * the tool or emit started. After success its effect is uncertain until its
317
333
  * result commits. This evidence is never an approval grant. */
318
- markToolDispatched(turnId: number, callId: string): StorageResult<void>;
334
+ markToolDispatched(turnId: number, callId: string, evidence?: import("./web.ts").WebDispatchEvidence): StorageResult<void>;
319
335
  /** False when stored policy references cannot be resolved by this owner. */
320
336
  unattendedGuard(): StorageResult<number | undefined>;
321
337
  executionCompatible(): StorageResult<boolean>;
338
+ /** Bind the current open catalog before any checkpoint can run. */
339
+ bindMcpCatalog?(fingerprint: string): void;
322
340
  /** Imported configuration, or undefined for sessions not imported from a file. */
323
341
  importedConfig(): StorageResult<import("./session-file.ts").PortableSessionConfig | undefined>;
324
342
  /** Persist the validated configuration used by this owner. */
@@ -340,7 +358,7 @@ export interface SessionStorage extends ModelCallStore, ReminderStorage, Timelin
340
358
  * Nothing is added to the timeline and no turn is created or changed. */
341
359
  /** External notice retries compare durable identity before admission or
342
360
  * policy validation for new work, through a path that writes nothing. */
343
- acceptItem(input: AcceptItem, maxInputBytes?: number): StorageResult<{ item: StoredItem; duplicate: boolean }>;
361
+ acceptItem(input: AcceptItem, maxInputBytes?: number, options?: { imageInput?: boolean }): StorageResult<{ item: StoredItem; duplicate: boolean }>;
344
362
 
345
363
  /** Start the channel's next turn by taking ALL its pending items, in
346
364
  * acceptance order, in one transaction: create the running turn, move each
@@ -82,6 +82,8 @@ export interface ToolInvocation {
82
82
  * repeats such a call. `none`: it never dispatched. */
83
83
  effect?: "none" | "unknown";
84
84
  reference?: ResultReference;
85
+ /** Durable per-invocation provider usage, absent for legacy calls. */
86
+ webUsage?: import("./web.ts").WebUsageView;
85
87
  }
86
88
 
87
89
  /** What the turn is doing now, with the ID of the model call, approval request