zigmini 1.0.0-beta.3 → 1.1.0-beta.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 (138) hide show
  1. package/README.ko.md +27 -2
  2. package/README.md +27 -2
  3. package/assets/agent/gateway-request-rules.md +1 -1
  4. package/assets/agent/gateway-rules.md +6 -1
  5. package/assets/android/zigmini.apk +0 -0
  6. package/assets/android/zigmini.apk.json +3 -3
  7. package/assets/build.json +1 -1
  8. package/assets/document-reader/document-reader +0 -0
  9. package/assets/document-reader/host-selector +0 -0
  10. package/assets/document-reader/manifest.json +27 -0
  11. package/docs/manual.ko.md +114 -10
  12. package/docs/manual.md +117 -11
  13. package/host/document-reader/DocumentRead.swift +370 -0
  14. package/host/document-reader/HostSelector.swift +192 -0
  15. package/host/document-reader/Protocol.swift +647 -0
  16. package/host/document-reader/main.swift +22 -0
  17. package/host/omo-bridge/agent-aside-tool.ts +119 -0
  18. package/host/omo-bridge/agent-aside.ts +522 -0
  19. package/host/omo-bridge/agent-collaboration-files.ts +282 -0
  20. package/host/omo-bridge/agent-collaboration.ts +385 -0
  21. package/host/omo-bridge/agent-control.ts +400 -28
  22. package/host/omo-bridge/agent-execution.sb +42 -0
  23. package/host/omo-bridge/agent-execution.ts +158 -0
  24. package/host/omo-bridge/agent-tool-adapters.ts +388 -0
  25. package/host/omo-bridge/agent-tool-permissions.ts +96 -0
  26. package/host/omo-bridge/aside-tabs.ts +41 -0
  27. package/host/omo-bridge/attachment-read.ts +100 -0
  28. package/host/omo-bridge/bridge.ts +10 -0
  29. package/host/omo-bridge/managed-call.ts +46 -0
  30. package/host/omo-bridge/task-control.ts +39 -5
  31. package/host/omo-check/patches/attachments-293/README.md +138 -0
  32. package/host/omo-check/patches/attachments-293/document-content.js +234 -0
  33. package/host/omo-check/patches/attachments-293/document-content.types.txt +91 -0
  34. package/host/omo-check/patches/attachments-293/omo-5.1.51-documents.patch +831 -0
  35. package/host/omo-check/patches/attachments-293/omo-5.1.51-gateway-port.manifest.json +471 -0
  36. package/host/omo-check/patches/omo-5.1.51-agent-tool-authority.patch +471 -0
  37. package/host/omo-check/patches/omo-5.1.51-gateway-port.manifest.json +28 -6
  38. package/host/omo-check/patches/omo-5.1.51-memory-receipts.patch +5 -0
  39. package/package.json +5 -3
  40. package/src/agent/api.ts +345 -20
  41. package/src/agent/artifacts.ts +196 -0
  42. package/src/agent/aside-target-routes.ts +369 -0
  43. package/src/agent/aside-targets.ts +215 -0
  44. package/src/agent/collaboration-admission.ts +47 -0
  45. package/src/agent/collaboration-read.ts +117 -0
  46. package/src/agent/collaboration-session.ts +196 -0
  47. package/src/agent/collaboration-types.ts +258 -0
  48. package/src/agent/collaboration.ts +399 -0
  49. package/src/agent/definition.ts +65 -3
  50. package/src/agent/fields.ts +9 -3
  51. package/src/agent/file-core.ts +325 -0
  52. package/src/agent/files.ts +87 -8
  53. package/src/agent/list.ts +3 -3
  54. package/src/agent/managed-call.ts +144 -0
  55. package/src/agent/tool-catalog.ts +184 -0
  56. package/src/agent/tool-delivery.ts +359 -0
  57. package/src/agent/tool-permission-types.ts +81 -0
  58. package/src/agent/tool-permissions.ts +1366 -0
  59. package/src/attachments/api.ts +161 -0
  60. package/src/attachments/document-reader.ts +325 -0
  61. package/src/attachments/host-selector.ts +410 -0
  62. package/src/attachments/managed-binding.ts +83 -0
  63. package/src/attachments/prepare.ts +214 -0
  64. package/src/attachments/selector-port.ts +28 -0
  65. package/src/attachments/service.ts +729 -0
  66. package/src/attachments/store.ts +698 -0
  67. package/src/attachments/types.ts +123 -0
  68. package/src/cli/doctor.ts +30 -10
  69. package/src/decisions.ts +109 -10
  70. package/src/engine/apply-patch.ts +21 -0
  71. package/src/engine/compat.json +2 -1
  72. package/src/engine/install.ts +45 -4
  73. package/src/engine/sandbox-cell.ts +2 -0
  74. package/src/gc.ts +33 -225
  75. package/src/housekeeping/api.ts +163 -0
  76. package/src/housekeeping/audit.ts +61 -0
  77. package/src/housekeeping/collectors/agent-collaboration.ts +33 -0
  78. package/src/housekeeping/collectors/agent-drafts.ts +43 -0
  79. package/src/housekeeping/collectors/agent-file-trash.ts +36 -0
  80. package/src/housekeeping/collectors/agent-trash.ts +28 -0
  81. package/src/housekeeping/collectors/attachment-cleanup.ts +35 -0
  82. package/src/housekeeping/collectors/db-backup.ts +25 -0
  83. package/src/housekeeping/collectors/docker-build-cache.ts +29 -0
  84. package/src/housekeeping/collectors/docker-image.ts +135 -0
  85. package/src/housekeeping/collectors/omo-version.ts +32 -0
  86. package/src/housekeeping/collectors/orphan-test-process.ts +205 -0
  87. package/src/housekeeping/collectors/reconcile-work.ts +55 -0
  88. package/src/housekeeping/collectors/rpc-daemon.ts +39 -0
  89. package/src/housekeeping/collectors/shared.ts +149 -0
  90. package/src/housekeeping/collectors/temp-dir.ts +28 -0
  91. package/src/housekeeping/collectors/update-file.ts +25 -0
  92. package/src/housekeeping/collectors/worktree.ts +193 -0
  93. package/src/housekeeping/engine.ts +125 -0
  94. package/src/housekeeping/reconcile/work.ts +130 -0
  95. package/src/housekeeping/registry.ts +63 -0
  96. package/src/housekeeping/trash.ts +59 -0
  97. package/src/housekeeping/types.ts +31 -0
  98. package/src/hub.ts +1095 -41
  99. package/src/main.ts +228 -30
  100. package/src/message-references.ts +14 -5
  101. package/src/profile-prompt.ts +13 -1
  102. package/src/protocol.ts +41 -6
  103. package/src/security-allow.ts +79 -2
  104. package/src/security-check.ts +1 -1
  105. package/src/store.ts +1946 -23
  106. package/src/test-crash.ts +20 -0
  107. package/src/work-watch.ts +55 -7
  108. package/src/work.ts +192 -3
  109. package/web/DESIGN.md +33 -0
  110. package/web/agents.d.ts +189 -12
  111. package/web/agents.js +898 -39
  112. package/web/app.js +2634 -210
  113. package/web/attachments.d.ts +91 -0
  114. package/web/attachments.js +422 -0
  115. package/web/collaboration.d.ts +87 -0
  116. package/web/collaboration.js +290 -0
  117. package/web/decisions.d.ts +39 -2
  118. package/web/decisions.js +354 -2
  119. package/web/gc.d.ts +26 -5
  120. package/web/gc.js +113 -13
  121. package/web/i18n/agents.d.ts +4 -0
  122. package/web/i18n/agents.js +200 -8
  123. package/web/i18n/attachments.js +78 -0
  124. package/web/i18n/decisions.d.ts +4 -0
  125. package/web/i18n/decisions.js +68 -0
  126. package/web/i18n/gc.d.ts +4 -0
  127. package/web/i18n/gc.js +184 -2
  128. package/web/i18n/main.js +80 -8
  129. package/web/i18n/tour.d.ts +4 -0
  130. package/web/i18n/tour.js +37 -0
  131. package/web/index.html +20 -3
  132. package/web/profile.d.ts +2 -2
  133. package/web/profile.js +11 -6
  134. package/web/style.css +342 -21
  135. package/web/tooltip.d.ts +2 -0
  136. package/web/tooltip.js +12 -0
  137. package/web/tour.d.ts +57 -0
  138. package/web/tour.js +450 -0
@@ -0,0 +1,234 @@
1
+ // UNRELEASED T5 source appended to pi-ai/dist/types.js by the frozen source patch.
2
+ // Gateway authorization is a required caller-owned boundary, not implemented here.
3
+ import { createHash } from "node:crypto";
4
+ import { z } from "zod";
5
+
6
+ export class DocumentInputError extends Error {
7
+ constructor(code) {
8
+ super(code);
9
+ this.name = "DocumentInputError";
10
+ this.code = code;
11
+ }
12
+ }
13
+ const documentSha = z.string().regex(/^[a-f0-9]{64}$/);
14
+ const documentSourceSchema = z.object({
15
+ attachmentId: z.string().uuid(), grantId: z.string().uuid(), originalSha256: documentSha,
16
+ }).strict();
17
+ const documentFields = {
18
+ type: z.literal("document"), mimeType: z.literal("application/pdf"), name: z.string().min(1).max(1024),
19
+ };
20
+ export const documentReferenceSchema = z.object({
21
+ ...documentFields, source: documentSourceSchema.extend({ kind: z.literal("attachment") }).strict(),
22
+ }).strict();
23
+ export const documentContentSchema = z.object({
24
+ ...documentFields, data: z.string().min(4).max(13981016)
25
+ .regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/),
26
+ provenance: documentSourceSchema,
27
+ }).strict();
28
+ export const documentAttachmentSchema = z.object({
29
+ id: z.string().uuid(), grantId: z.string().uuid(), name: z.string().min(1).max(1024),
30
+ format: z.enum(["html", "md", "txt", "pdf"]), bytes: z.number().int().min(1).max(10485760),
31
+ sha256: documentSha, readMode: z.enum(["text", "native-document", "pages", "ocr"]),
32
+ pageCount: z.number().int().min(1).max(300).optional(),
33
+ }).strict();
34
+ export function checkedDocument(value) {
35
+ const parsed = documentContentSchema.safeParse(value);
36
+ if (!parsed.success) throw new DocumentInputError("attachment_document_invalid");
37
+ const document = parsed.data;
38
+ const bytes = Buffer.from(document.data, "base64");
39
+ if (bytes.length > 10485760 || bytes.toString("base64") !== document.data ||
40
+ bytes.subarray(0, 5).toString("ascii") !== "%PDF-" ||
41
+ createHash("sha256").update(bytes).digest("hex") !== document.provenance.originalSha256)
42
+ throw new DocumentInputError("attachment_document_integrity");
43
+ return document;
44
+ }
45
+ /** Ingress bytes are checked, then dropped. Durable records contain only sealed grant references. */
46
+ export function normalizeDocumentInput(input, references = false) {
47
+ if (input.documents === undefined && input.attachments === undefined) return {};
48
+ if (!input.clientInputId || !Array.isArray(input.documents) ||
49
+ input.documents.length < 1 || input.documents.length > 4 ||
50
+ !Array.isArray(input.attachments) || input.attachments.length !== input.documents.length)
51
+ throw new DocumentInputError("attachment_document_identity");
52
+ const attachments = input.attachments.map(value => {
53
+ const result = documentAttachmentSchema.safeParse(value);
54
+ if (!result.success) throw new DocumentInputError("attachment_metadata_invalid");
55
+ return result.data;
56
+ });
57
+ const seen = new Set();
58
+ const documents = input.documents.map((value, index) => {
59
+ const document = references ? documentReferenceSchema.parse(value) : checkedDocument(value);
60
+ const source = references ? document.source : document.provenance;
61
+ const metadata = attachments[index];
62
+ if (seen.has(source.attachmentId) || metadata.id !== source.attachmentId ||
63
+ metadata.grantId !== source.grantId || metadata.sha256 !== source.originalSha256 ||
64
+ metadata.name !== document.name || metadata.format !== "pdf" ||
65
+ (!references && metadata.bytes !== Buffer.from(document.data, "base64").length))
66
+ throw new DocumentInputError("attachment_document_identity");
67
+ seen.add(source.attachmentId);
68
+ return { type: "document", mimeType: "application/pdf", name: document.name,
69
+ source: { kind: "attachment", attachmentId: source.attachmentId,
70
+ grantId: source.grantId, originalSha256: source.originalSha256 } };
71
+ });
72
+ return { documents, attachments, origin: "owner-attachment" };
73
+ }
74
+ export function documentInputMetadata(input) {
75
+ return input?.documents?.length
76
+ ? { origin: "owner-attachment", attachments: input.attachments }
77
+ : {};
78
+ }
79
+ /** Provider identity and API are both required; a lookalike model name grants no native-file route. */
80
+ export function documentReadMode(model) {
81
+ if (!model?.input?.includes("image")) return "ocr";
82
+ if ((model.provider === "openai" && model.api === "openai-responses") ||
83
+ (model.provider === "anthropic" && model.api === "anthropic-messages")) return "native-document";
84
+ return "pages";
85
+ }
86
+ export function hasDocuments(messages) {
87
+ return messages.some(message => Array.isArray(message.content) &&
88
+ message.content.some(block => block.type === "document" || block.documentSource !== undefined));
89
+ }
90
+ export function documentRequestLimit(model) {
91
+ // OpenAI documents a 50 MB aggregate file limit. This local wire ceiling is stricter after base64.
92
+ // Claude first-party documents 128 MB. Subscription transport keeps a conservative 24 MiB ceiling.
93
+ if (model.provider === "openai" && model.api === "openai-responses") return 50_000_000;
94
+ if (model.provider === "anthropic" && model.api === "anthropic-messages") return 128_000_000;
95
+ return 24 * 1024 * 1024;
96
+ }
97
+ export function assertDocumentRequestBudget(payload, model, messages) {
98
+ if (!hasDocuments(messages)) return;
99
+ const bytes = Buffer.byteLength(JSON.stringify(payload));
100
+ if (bytes > documentRequestLimit(model))
101
+ throw new DocumentInputError("attachment_request_limit");
102
+ }
103
+ const representationBlock = z.discriminatedUnion("type", [
104
+ z.object({ type: z.literal("text"), text: z.string().max(49152) }).strict(),
105
+ z.object({ type: z.literal("image"), mimeType: z.enum(["image/png", "image/jpeg"]),
106
+ data: z.string().max(5592408) }).strict(),
107
+ documentContentSchema,
108
+ ]);
109
+ const representationSchema = z.object({
110
+ status: z.literal("ready"), originalSha256: documentSha, representationSha256: documentSha,
111
+ payloadSha256: documentSha,
112
+ grantRevision: z.number().int().positive(), estimatedTokens: z.number().int().nonnegative(),
113
+ content: z.array(representationBlock).min(1).max(2000),
114
+ coverage: z.object({
115
+ totalPages: z.number().int().min(1).max(300),
116
+ pages: z.array(z.object({ page: z.number().int().min(1).max(300),
117
+ representation: z.enum(["native-text", "rendered-image", "ocr-text", "verified-blank"]) }).strict()).max(300),
118
+ }).strict(),
119
+ nextCursor: z.string().min(1).optional(),
120
+ }).strict();
121
+ /** Resolve on every request, including replay and provider changes. There is no host-path reader or cache. */
122
+ export async function resolveDocumentMessages(messages, model, boundary) {
123
+ const result = [];
124
+ let wireBytes = Buffer.byteLength(JSON.stringify(messages));
125
+ let inputTokens = Math.ceil(wireBytes / 3);
126
+ let nativePages = 0;
127
+ for (const message of messages) {
128
+ if (!Array.isArray(message.content) || !message.content.some(block => block.type === "document")) {
129
+ result.push(message);
130
+ continue;
131
+ }
132
+ if (message.role !== "user" || message.origin !== "owner-attachment" || !message.clientInputId)
133
+ throw new DocumentInputError("attachment_document_origin");
134
+ const content = [];
135
+ for (const block of message.content) {
136
+ if (block.type !== "document") { content.push(block); continue; }
137
+ const reference = documentReferenceSchema.parse(block);
138
+ const metadata = message.attachments?.find(item => item.id === reference.source.attachmentId);
139
+ if (!metadata || metadata.grantId !== reference.source.grantId ||
140
+ metadata.sha256 !== reference.source.originalSha256)
141
+ throw new DocumentInputError("attachment_document_identity");
142
+ let mode = documentReadMode(model);
143
+ const nativeLimit = model.provider === "anthropic" && model.contextWindow < 1_000_000 ? 100 : 300;
144
+ if (mode === "native-document" && (nativePages + (metadata.pageCount ?? 300) > nativeLimit ||
145
+ wireBytes + Math.ceil(metadata.bytes / 3) * 4 + 65536 > documentRequestLimit(model)))
146
+ mode = "pages";
147
+ const readRepresentation = async () => {
148
+ const response = boundary.resolve === undefined ? { status: "attachment_unavailable" } :
149
+ await boundary.resolve({ reference, mode, sessionId: boundary.sessionId,
150
+ inputId: boundary.inputId, originInputId: message.clientInputId,
151
+ model, signal: boundary.signal });
152
+ if (["attachment_revoked", "attachment_unavailable", "attachment_text_held"].includes(response.status))
153
+ return response;
154
+ const parsed = representationSchema.safeParse(response);
155
+ if (!parsed.success) throw new DocumentInputError("attachment_representation_invalid");
156
+ const representation = parsed.data;
157
+ if (representation.originalSha256 !== reference.source.originalSha256)
158
+ throw new DocumentInputError("attachment_document_integrity");
159
+ const representationDigest = createHash("sha256")
160
+ .update(JSON.stringify({ content: representation.content, coverage: representation.coverage,
161
+ ...(representation.nextCursor === undefined ? {} : { nextCursor: representation.nextCursor }) })).digest("hex");
162
+ if (representationDigest !== representation.payloadSha256)
163
+ throw new DocumentInputError("attachment_representation_integrity");
164
+ return representation;
165
+ };
166
+ let representation = await readRepresentation();
167
+ if (representation.status === "ready" && mode === "native-document" &&
168
+ (wireBytes + Buffer.byteLength(JSON.stringify(representation.content)) + 65536 > documentRequestLimit(model) ||
169
+ (model.contextWindow > 0 && inputTokens + representation.estimatedTokens + model.maxTokens > model.contextWindow))) {
170
+ // This is another local representation selection, before any provider dispatch, not a model retry.
171
+ mode = "pages";
172
+ representation = await readRepresentation();
173
+ }
174
+ if (representation.status === "attachment_revoked" || representation.status === "attachment_unavailable") {
175
+ content.push({ type: "text", text: JSON.stringify({ type: representation.status,
176
+ attachmentId: reference.source.attachmentId, grantId: reference.source.grantId }),
177
+ documentSource: reference.source });
178
+ continue;
179
+ }
180
+ if (representation.status === "attachment_text_held") throw new DocumentInputError(representation.status);
181
+ const pages = representation.coverage.pages;
182
+ if (pages.length === 0 || new Set(pages.map(page => page.page)).size !== pages.length ||
183
+ (metadata.pageCount !== undefined && metadata.pageCount !== representation.coverage.totalPages) ||
184
+ pages.some(page => page.page > representation.coverage.totalPages) ||
185
+ (pages.length < representation.coverage.totalPages && !representation.nextCursor))
186
+ throw new DocumentInputError("attachment_coverage_incomplete");
187
+ // Ready means the complete representation was prepared; coverage is only this bounded delivery.
188
+ if (mode === "ocr" && pages.some(page => !["ocr-text", "verified-blank"].includes(page.representation)))
189
+ throw new DocumentInputError("attachment_ocr_incomplete");
190
+ let images = 0;
191
+ let documents = 0;
192
+ let textBytes = 0;
193
+ const blocks = representation.content.map(part => {
194
+ if (part.type === "text") textBytes += Buffer.byteLength(part.text);
195
+ if (part.type === "document") {
196
+ documents++;
197
+ const document = checkedDocument(part);
198
+ if (mode !== "native-document" || document.provenance.grantId !== reference.source.grantId ||
199
+ document.provenance.attachmentId !== reference.source.attachmentId ||
200
+ document.provenance.originalSha256 !== reference.source.originalSha256)
201
+ throw new DocumentInputError("attachment_document_route");
202
+ }
203
+ if (part.type === "image") {
204
+ images++;
205
+ const bytes = Buffer.from(part.data, "base64");
206
+ if (mode === "ocr" || bytes.length > 4194304 || bytes.toString("base64") !== part.data ||
207
+ (!bytes.subarray(0, 8).equals(Buffer.from([137,80,78,71,13,10,26,10])) &&
208
+ !(bytes[0] === 255 && bytes[1] === 216)))
209
+ throw new DocumentInputError("attachment_image_invalid");
210
+ }
211
+ return { ...part, documentSource: reference.source };
212
+ });
213
+ if (images > 2 || (mode === "native-document" ? documents !== 1 : documents !== 0))
214
+ throw new DocumentInputError("attachment_document_route");
215
+ if (textBytes > 49152) throw new DocumentInputError("attachment_text_limit");
216
+ if (mode !== "native-document" &&
217
+ (images !== pages.filter(page => page.representation === "rendered-image").length ||
218
+ (!representation.content.some(part => part.type === "text" && part.text.trim() !== "") && pages.some(page => ["native-text", "ocr-text"].includes(page.representation)))))
219
+ throw new DocumentInputError("attachment_coverage_incomplete");
220
+ nativePages += mode === "native-document" ? representation.coverage.totalPages : 0;
221
+ const coverage = { type: "attachment_coverage", source: reference.source,
222
+ representationSha256: representation.representationSha256, grantRevision: representation.grantRevision,
223
+ coverage: representation.coverage, nextCursor: representation.nextCursor };
224
+ content.push({ type: "text", text: JSON.stringify(coverage), documentSource: reference.source }, ...blocks);
225
+ wireBytes += Buffer.byteLength(JSON.stringify(blocks));
226
+ inputTokens += representation.estimatedTokens;
227
+ if (wireBytes + 65536 > documentRequestLimit(model) ||
228
+ (model.contextWindow > 0 && inputTokens + model.maxTokens > model.contextWindow))
229
+ throw new DocumentInputError("attachment_request_limit");
230
+ }
231
+ result.push({ ...message, content });
232
+ }
233
+ return result;
234
+ }
@@ -0,0 +1,91 @@
1
+ /** UNRELEASED declarations appended to pi-ai/dist/types.d.ts, in its type scope. */
2
+ export interface DocumentProvenance {
3
+ readonly attachmentId: string;
4
+ readonly grantId: string;
5
+ readonly originalSha256: string;
6
+ }
7
+ export interface DocumentContent {
8
+ readonly type: "document";
9
+ readonly mimeType: "application/pdf";
10
+ readonly name: string;
11
+ readonly data: string;
12
+ readonly provenance: DocumentProvenance;
13
+ }
14
+ export interface DocumentReference {
15
+ readonly type: "document";
16
+ readonly mimeType: "application/pdf";
17
+ readonly name: string;
18
+ readonly source: DocumentProvenance & { readonly kind: "attachment" };
19
+ }
20
+ export interface DocumentAttachment {
21
+ readonly id: string;
22
+ readonly grantId: string;
23
+ readonly name: string;
24
+ readonly format: "html" | "md" | "txt" | "pdf";
25
+ readonly bytes: number;
26
+ readonly sha256: string;
27
+ readonly readMode: "text" | "native-document" | "pages" | "ocr";
28
+ readonly pageCount?: number;
29
+ }
30
+ export interface DocumentCoverage {
31
+ readonly totalPages: number;
32
+ readonly pages: readonly {
33
+ readonly page: number;
34
+ readonly representation: "native-text" | "rendered-image" | "ocr-text" | "verified-blank";
35
+ }[];
36
+ }
37
+ export interface DocumentRepresentation {
38
+ readonly status: "ready";
39
+ readonly originalSha256: string;
40
+ readonly representationSha256: string;
41
+ /** Delivery content/coverage/cursor digest; separate from the reader's full representation digest. */
42
+ readonly payloadSha256: string;
43
+ readonly grantRevision: number;
44
+ readonly estimatedTokens: number;
45
+ readonly content: readonly (TextContent | ImageContent | DocumentContent)[];
46
+ readonly coverage: DocumentCoverage;
47
+ readonly nextCursor?: string;
48
+ }
49
+ /** The caller MUST authorize against the current managed binding and grant before releasing bytes. */
50
+ export type DocumentResolver = (request: {
51
+ readonly reference: DocumentReference;
52
+ readonly mode: "native-document" | "pages" | "ocr";
53
+ readonly sessionId: string;
54
+ readonly inputId: string | undefined;
55
+ readonly originInputId: string;
56
+ readonly model: Model<Api>;
57
+ readonly signal: AbortSignal | undefined;
58
+ }) => Promise<DocumentRepresentation | {
59
+ readonly status: "attachment_revoked" | "attachment_unavailable" | "attachment_text_held";
60
+ }>;
61
+ export declare class DocumentInputError extends Error {
62
+ readonly code: string;
63
+ constructor(code: string);
64
+ }
65
+ export declare const documentReferenceSchema: import("zod").ZodType<DocumentReference>;
66
+ export declare const documentContentSchema: import("zod").ZodType<DocumentContent>;
67
+ export declare const documentAttachmentSchema: import("zod").ZodType<DocumentAttachment>;
68
+ export declare function checkedDocument(value: unknown): DocumentContent;
69
+ export declare function normalizeDocumentInput(input: {
70
+ readonly clientInputId?: string;
71
+ readonly documents?: readonly unknown[];
72
+ readonly attachments?: readonly unknown[];
73
+ }, references?: boolean): {
74
+ readonly documents?: DocumentReference[];
75
+ readonly attachments?: DocumentAttachment[];
76
+ readonly origin?: "owner-attachment";
77
+ };
78
+ export declare function documentInputMetadata(input?: {
79
+ readonly documents?: readonly unknown[];
80
+ readonly attachments?: readonly DocumentAttachment[];
81
+ }): { readonly origin?: "owner-attachment"; readonly attachments?: readonly DocumentAttachment[] };
82
+ export declare function documentReadMode(model: Model<Api>): "native-document" | "pages" | "ocr";
83
+ export declare function hasDocuments(messages: readonly Message[]): boolean;
84
+ export declare function documentRequestLimit(model: Model<Api>): number;
85
+ export declare function assertDocumentRequestBudget(payload: unknown, model: Model<Api>, messages: readonly Message[]): void;
86
+ export declare function resolveDocumentMessages(messages: readonly Message[], model: Model<Api>, boundary: {
87
+ readonly resolve?: DocumentResolver;
88
+ readonly sessionId: string;
89
+ readonly inputId?: string;
90
+ readonly signal?: AbortSignal;
91
+ }): Promise<Message[]>;