@qvac/core 0.2.1 → 0.3.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 (278) hide show
  1. package/.claude/skills/compaction/SKILL.md +15 -6
  2. package/.claude/skills/js-house-style/SKILL.md +1 -0
  3. package/.claude/skills/pr-create/SKILL.md +66 -3
  4. package/.claude/skills/pr-review/SKILL.md +252 -40
  5. package/.claude/skills/release/SKILL.md +122 -0
  6. package/CLAUDE.md +8 -5
  7. package/README.md +3 -1
  8. package/dist-lib/client.js +1 -1
  9. package/dist-lib/index.js +8 -8
  10. package/dist-lib/lib/api/agents.d.ts +1 -1
  11. package/dist-lib/lib/api/agents.js +10 -10
  12. package/dist-lib/lib/api/app-config.js +1 -1
  13. package/dist-lib/lib/api/approval-rules.js +9 -5
  14. package/dist-lib/lib/api/attachments.js +25 -3
  15. package/dist-lib/lib/api/chat-groups.d.ts +1 -1
  16. package/dist-lib/lib/api/chat-groups.js +5 -4
  17. package/dist-lib/lib/api/chat.js +10 -10
  18. package/dist-lib/lib/api/chunks.d.ts +1 -1
  19. package/dist-lib/lib/api/chunks.js +11 -21
  20. package/dist-lib/lib/api/config.js +1 -1
  21. package/dist-lib/lib/api/current-mesh.d.ts +16 -1
  22. package/dist-lib/lib/api/current-mesh.js +18 -0
  23. package/dist-lib/lib/api/custom-models.js +2 -2
  24. package/dist-lib/lib/api/devices.d.ts +1 -1
  25. package/dist-lib/lib/api/devices.js +12 -9
  26. package/dist-lib/lib/api/diagnostics.js +1 -1
  27. package/dist-lib/lib/api/effective-ctx-size.js +1 -1
  28. package/dist-lib/lib/api/execution.js +4 -4
  29. package/dist-lib/lib/api/files.js +2 -2
  30. package/dist-lib/lib/api/index.d.ts +1 -0
  31. package/dist-lib/lib/api/index.js +34 -34
  32. package/dist-lib/lib/api/instrument.js +1 -1
  33. package/dist-lib/lib/api/knowledge.js +13 -9
  34. package/dist-lib/lib/api/logs.js +1 -1
  35. package/dist-lib/lib/api/members.d.ts +4 -1
  36. package/dist-lib/lib/api/members.js +87 -18
  37. package/dist-lib/lib/api/mesh.d.ts +13 -3
  38. package/dist-lib/lib/api/mesh.js +25 -2
  39. package/dist-lib/lib/api/model-download.js +1 -1
  40. package/dist-lib/lib/api/network.js +1 -1
  41. package/dist-lib/lib/api/notifications.js +3 -3
  42. package/dist-lib/lib/api/rag.js +7 -7
  43. package/dist-lib/lib/api/sync.d.ts +1 -1
  44. package/dist-lib/lib/api/sync.js +3 -2
  45. package/dist-lib/lib/api/tool-activity.js +5 -5
  46. package/dist-lib/lib/api/tool-configs.js +5 -5
  47. package/dist-lib/lib/api/watchable.d.ts +6 -1
  48. package/dist-lib/lib/api/watchable.js +14 -3
  49. package/dist-lib/lib/assistant/fetch-body.d.ts +5 -0
  50. package/dist-lib/lib/assistant/fetch-body.js +36 -0
  51. package/dist-lib/lib/assistant/harness.d.ts +225 -0
  52. package/dist-lib/lib/assistant/harness.js +154 -0
  53. package/dist-lib/lib/assistant/history.d.ts +31 -0
  54. package/dist-lib/lib/assistant/history.js +226 -0
  55. package/dist-lib/lib/assistant/message.d.ts +45 -0
  56. package/dist-lib/lib/assistant/message.js +47 -0
  57. package/dist-lib/lib/assistant/skill-encode.d.ts +21 -0
  58. package/dist-lib/lib/assistant/skill-encode.js +71 -0
  59. package/dist-lib/lib/assistant-client.js +2 -2
  60. package/dist-lib/lib/assistant-tree.js +10 -4
  61. package/dist-lib/lib/assistant.d.ts +28 -292
  62. package/dist-lib/lib/assistant.js +284 -716
  63. package/dist-lib/lib/audio-format.js +2 -2
  64. package/dist-lib/lib/client.js +2 -2
  65. package/dist-lib/lib/collabora/convert.js +1 -1
  66. package/dist-lib/lib/collabora/entry.js +1 -1
  67. package/dist-lib/lib/collabora/worker.js +1 -1
  68. package/dist-lib/lib/compaction.d.ts +1 -2
  69. package/dist-lib/lib/compaction.js +8 -6
  70. package/dist-lib/lib/constants.js +1 -1
  71. package/dist-lib/lib/core/account-recovery.d.ts +19 -0
  72. package/dist-lib/lib/core/account-recovery.js +50 -0
  73. package/dist-lib/lib/core/agent.js +8 -4
  74. package/dist-lib/lib/core/app-build.d.ts +1 -1
  75. package/dist-lib/lib/core/approval-rules.d.ts +1 -0
  76. package/dist-lib/lib/core/approval-rules.js +3 -1
  77. package/dist-lib/lib/core/archived-mesh.d.ts +25 -0
  78. package/dist-lib/lib/core/archived-mesh.js +162 -0
  79. package/dist-lib/lib/core/chat-activity.js +1 -1
  80. package/dist-lib/lib/core/chat-group.d.ts +1 -0
  81. package/dist-lib/lib/core/chat-group.js +24 -4
  82. package/dist-lib/lib/core/chat-search.js +2 -2
  83. package/dist-lib/lib/core/chat.js +5 -5
  84. package/dist-lib/lib/core/chunk.d.ts +2 -1
  85. package/dist-lib/lib/core/chunk.js +31 -4
  86. package/dist-lib/lib/core/contract/agents.js +1 -1
  87. package/dist-lib/lib/core/contract/approval-rules.js +6 -4
  88. package/dist-lib/lib/core/contract/attestations.js +1 -1
  89. package/dist-lib/lib/core/contract/chat-group.js +1 -1
  90. package/dist-lib/lib/core/contract/chat.js +1 -1
  91. package/dist-lib/lib/core/contract/chunks.js +2 -2
  92. package/dist-lib/lib/core/contract/compute.d.ts +11 -0
  93. package/dist-lib/lib/core/contract/compute.js +45 -0
  94. package/dist-lib/lib/core/contract/devices.js +19 -5
  95. package/dist-lib/lib/core/contract/index.d.ts +3 -1
  96. package/dist-lib/lib/core/contract/index.js +19 -16
  97. package/dist-lib/lib/core/contract/indexing.js +2 -2
  98. package/dist-lib/lib/core/contract/joined-meshes.js +1 -1
  99. package/dist-lib/lib/core/contract/knowledge.js +2 -2
  100. package/dist-lib/lib/core/contract/members.js +2 -2
  101. package/dist-lib/lib/core/contract/seal.d.ts +2 -0
  102. package/dist-lib/lib/core/contract/seal.js +8 -0
  103. package/dist-lib/lib/core/contract/seed-defaults.js +1 -1
  104. package/dist-lib/lib/core/contract/tool-activity.js +1 -1
  105. package/dist-lib/lib/core/contract/tool-configs.js +3 -3
  106. package/dist-lib/lib/core/contract/writers.js +66 -42
  107. package/dist-lib/lib/core/departures.js +1 -1
  108. package/dist-lib/lib/core/device-invites.js +1 -1
  109. package/dist-lib/lib/core/document-attachment.js +2 -2
  110. package/dist-lib/lib/core/files/attachments.js +3 -3
  111. package/dist-lib/lib/core/files/index.d.ts +2 -2
  112. package/dist-lib/lib/core/files/index.js +19 -19
  113. package/dist-lib/lib/core/files/knowledge.js +3 -3
  114. package/dist-lib/lib/core/files/preview/image.js +1 -1
  115. package/dist-lib/lib/core/files/preview/index.js +6 -6
  116. package/dist-lib/lib/core/files/processing/claims.js +1 -1
  117. package/dist-lib/lib/core/files/processing/document.js +5 -5
  118. package/dist-lib/lib/core/files/processing/index.js +8 -8
  119. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  120. package/dist-lib/lib/core/files/processing/protocol.js +3 -3
  121. package/dist-lib/lib/core/files/processing/source.js +1 -1
  122. package/dist-lib/lib/core/files/rag/artifact/codec.js +1 -1
  123. package/dist-lib/lib/core/files/rag/artifact/id.js +1 -1
  124. package/dist-lib/lib/core/files/rag/artifact/types.d.ts +4 -4
  125. package/dist-lib/lib/core/files/rag/build.js +2 -2
  126. package/dist-lib/lib/core/files/rag/chunk/chunking.js +2 -2
  127. package/dist-lib/lib/core/files/rag/document-types.d.ts +3 -3
  128. package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +9 -9
  129. package/dist-lib/lib/core/files/rag/extract/extract.js +7 -7
  130. package/dist-lib/lib/core/files/rag/extract/html-text.js +1 -1
  131. package/dist-lib/lib/core/files/rag/extract/office-collabora.js +2 -2
  132. package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +1 -1
  133. package/dist-lib/lib/core/files/rag/extract/pdf-text.js +1 -1
  134. package/dist-lib/lib/core/files/rag/extract/text-decoding.js +1 -1
  135. package/dist-lib/lib/core/files/rag/extract/types.d.ts +2 -2
  136. package/dist-lib/lib/core/files/rag/index.js +22 -22
  137. package/dist-lib/lib/core/files/rag/load.js +5 -5
  138. package/dist-lib/lib/core/files/rag/policy.js +2 -2
  139. package/dist-lib/lib/core/files/rag/produce.js +5 -5
  140. package/dist-lib/lib/core/files/rag/retrieval/coverage.js +2 -2
  141. package/dist-lib/lib/core/files/rag/retrieval/diversity.js +1 -1
  142. package/dist-lib/lib/core/files/rag/retrieval/floor.js +2 -2
  143. package/dist-lib/lib/core/files/rag/retrieval/format.js +1 -1
  144. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +18 -11
  145. package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +5 -5
  146. package/dist-lib/lib/core/files/rag/retrieval/scoring.js +2 -2
  147. package/dist-lib/lib/core/files/rag/retrieval/search.js +4 -4
  148. package/dist-lib/lib/core/files/rag/retrieval/selection.js +2 -2
  149. package/dist-lib/lib/core/files/rag/retrieval/sources.js +2 -2
  150. package/dist-lib/lib/core/files/rag/retrieval/terms.js +1 -1
  151. package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +1 -1
  152. package/dist-lib/lib/core/files/records/chunks.js +1 -1
  153. package/dist-lib/lib/core/files/records/index.js +8 -8
  154. package/dist-lib/lib/core/files/records/knowledge.js +2 -2
  155. package/dist-lib/lib/core/files/records/output.js +1 -1
  156. package/dist-lib/lib/core/files/records/reclaim.js +5 -5
  157. package/dist-lib/lib/core/files/records/routing.js +7 -7
  158. package/dist-lib/lib/core/files/store/blob.js +2 -2
  159. package/dist-lib/lib/core/files/store/index.js +7 -7
  160. package/dist-lib/lib/core/files/store/reference.js +2 -2
  161. package/dist-lib/lib/core/files/store/server.js +1 -1
  162. package/dist-lib/lib/core/files/store/sweep.js +1 -1
  163. package/dist-lib/lib/core/files/upload-input.js +2 -2
  164. package/dist-lib/lib/core/files/upload.d.ts +1 -1
  165. package/dist-lib/lib/core/files/upload.js +6 -6
  166. package/dist-lib/lib/core/harness-loan.d.ts +29 -0
  167. package/dist-lib/lib/core/harness-loan.js +187 -0
  168. package/dist-lib/lib/core/helpers/index.d.ts +2 -1
  169. package/dist-lib/lib/core/helpers/index.js +4 -4
  170. package/dist-lib/lib/core/hosted-agents.js +2 -2
  171. package/dist-lib/lib/core/identity.d.ts +2 -0
  172. package/dist-lib/lib/core/identity.js +4 -2
  173. package/dist-lib/lib/core/invite.d.ts +1 -0
  174. package/dist-lib/lib/core/invite.js +4 -2
  175. package/dist-lib/lib/core/local/index.d.ts +12 -3
  176. package/dist-lib/lib/core/local/index.js +81 -16
  177. package/dist-lib/lib/core/membership.d.ts +3 -0
  178. package/dist-lib/lib/core/membership.js +15 -1
  179. package/dist-lib/lib/core/mesh-seed-handoff.js +1 -1
  180. package/dist-lib/lib/core/mesh.d.ts +9 -3
  181. package/dist-lib/lib/core/mesh.js +41 -26
  182. package/dist-lib/lib/core/migrations/agent-catalog.js +1 -1
  183. package/dist-lib/lib/core/migrations/index.js +5 -3
  184. package/dist-lib/lib/core/migrations/membership.js +2 -2
  185. package/dist-lib/lib/core/migrations/seal.d.ts +3 -0
  186. package/dist-lib/lib/core/migrations/seal.js +30 -0
  187. package/dist-lib/lib/core/next-frame.js +1 -1
  188. package/dist-lib/lib/core/notification.js +1 -1
  189. package/dist-lib/lib/core/ota-config.js +1 -1
  190. package/dist-lib/lib/core/secret-handoff.js +1 -1
  191. package/dist-lib/lib/core/send.js +3 -3
  192. package/dist-lib/lib/core/skill-overlay-handoff.js +1 -1
  193. package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
  194. package/dist-lib/lib/core/skill-secrets.js +3 -3
  195. package/dist-lib/lib/core/sync/devices.js +1 -1
  196. package/dist-lib/lib/core/sync/index.js +8 -5
  197. package/dist-lib/lib/core/sync-status.js +1 -1
  198. package/dist-lib/lib/core/system-info.js +1 -1
  199. package/dist-lib/lib/core/tool-activity.js +2 -2
  200. package/dist-lib/lib/core/tool-configs.js +2 -2
  201. package/dist-lib/lib/core.d.ts +42 -3
  202. package/dist-lib/lib/core.js +543 -100
  203. package/dist-lib/lib/credential-pusher.js +4 -4
  204. package/dist-lib/lib/deadline.js +1 -1
  205. package/dist-lib/lib/fs-drive-bridge.js +5 -3
  206. package/dist-lib/lib/integrations/index.js +3 -3
  207. package/dist-lib/lib/integrations/oauth-providers.js +1 -1
  208. package/dist-lib/lib/integrations/setup-routes.d.ts +5 -5
  209. package/dist-lib/lib/integrations/setup-routes.js +3 -3
  210. package/dist-lib/lib/knowledge-search.js +1 -1
  211. package/dist-lib/lib/log.js +3 -3
  212. package/dist-lib/lib/mesh-scoped-engine.d.ts +3 -0
  213. package/dist-lib/lib/mesh-scoped-engine.js +101 -0
  214. package/dist-lib/lib/model-context.d.ts +2 -2
  215. package/dist-lib/lib/model-context.js +1 -1
  216. package/dist-lib/lib/model-download.d.ts +2 -0
  217. package/dist-lib/lib/model-download.js +26 -11
  218. package/dist-lib/lib/oauth/asana.js +3 -3
  219. package/dist-lib/lib/oauth/browser-connect.js +1 -1
  220. package/dist-lib/lib/oauth/client.js +2 -2
  221. package/dist-lib/lib/oauth/common.d.ts +1 -1
  222. package/dist-lib/lib/oauth/common.js +1 -1
  223. package/dist-lib/lib/oauth/flow-core.js +3 -3
  224. package/dist-lib/lib/oauth/flow.js +2 -2
  225. package/dist-lib/lib/oauth/google.js +4 -4
  226. package/dist-lib/lib/oauth/host.js +3 -3
  227. package/dist-lib/lib/oauth/keys.js +1 -0
  228. package/dist-lib/lib/oauth/loopback.js +1 -1
  229. package/dist-lib/lib/oauth/notion.js +3 -3
  230. package/dist-lib/lib/oauth/providers.js +1 -1
  231. package/dist-lib/lib/oauth/resolve.js +1 -1
  232. package/dist-lib/lib/oauth/spotify.js +4 -3
  233. package/dist-lib/lib/oauth/token-exchange.js +1 -1
  234. package/dist-lib/lib/oauth/verify.d.ts +8 -0
  235. package/dist-lib/lib/oauth/verify.js +58 -0
  236. package/dist-lib/lib/oauth.client.js +2 -2
  237. package/dist-lib/lib/oauth.d.ts +1 -0
  238. package/dist-lib/lib/oauth.js +13 -12
  239. package/dist-lib/lib/run-notices.d.ts +7 -7
  240. package/dist-lib/lib/run-transcript.js +1 -1
  241. package/dist-lib/schema/build.js +12 -6
  242. package/dist-lib/schema/content.d.ts +11 -11
  243. package/dist-lib/schema/engine.js +193 -30
  244. package/dist-lib/schema/field-order.js +2 -2
  245. package/dist-lib/schema/local.js +18 -4
  246. package/dist-lib/schema/qvac.d.ts +3 -0
  247. package/dist-lib/schema/qvac.js +22 -6
  248. package/dist-lib/spec/bind.js +41 -0
  249. package/dist-lib/spec/calls.js +12 -0
  250. package/dist-lib/spec/capabilities.d.ts +36 -12
  251. package/dist-lib/spec/hrpc/hrpc.json +161 -5
  252. package/dist-lib/spec/hrpc/index.js +154 -9
  253. package/dist-lib/spec/hrpc/messages.js +549 -129
  254. package/dist-lib/spec/hyperschema/index.js +549 -129
  255. package/dist-lib/spec/hyperschema/schema.json +370 -40
  256. package/dist-lib/spec/hyperschema/types.d.ts +85 -1
  257. package/dist-lib/spec/local/hyperdb/db.json +15 -0
  258. package/dist-lib/spec/local/hyperdb/index.js +70 -1
  259. package/dist-lib/spec/local/hyperdb/messages.js +300 -117
  260. package/dist-lib/spec/local/hyperschema/index.js +97 -4
  261. package/dist-lib/spec/local/hyperschema/schema.json +58 -1
  262. package/dist-lib/spec/local/hyperschema/types.d.ts +14 -0
  263. package/dist-lib/spec/mesh/hyperdb/messages.js +393 -288
  264. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +6 -0
  265. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  266. package/dist-lib/spec/mesh/hyperdispatch/messages.js +176 -85
  267. package/dist-lib/spec/mesh/hyperschema/index.js +176 -85
  268. package/dist-lib/spec/mesh/hyperschema/schema.json +71 -21
  269. package/dist-lib/spec/mesh/hyperschema/types.d.ts +14 -1
  270. package/package.json +14 -8
  271. package/tui/README.md +7 -0
  272. package/tui/app.mjs +633 -55
  273. package/tui/lib/busy-words.mjs +57 -5
  274. package/tui/lib/export.mjs +1 -0
  275. package/tui/lib/render.mjs +25 -2
  276. package/tui/lib/selection.mjs +16 -0
  277. package/tui/lib/usage.mjs +54 -0
  278. package/tui/main.mjs +5 -2
@@ -0,0 +1,225 @@
1
+ import type { AbortSignal } from 'bare-abort-controller';
2
+ import type { ApprovalCall, MemoryBudget } from '@qvac/harness';
3
+ import type { ManagedSkill, SkillFileContent } from '@qvac/harness/lib/tools/skills/overlay-crud.ts';
4
+ import type { SkillManagementHooks } from '../core.ts';
5
+ import type { DriveOpFn, GrantedDrive } from '@qvac/harness/lib/tools/fs/remote.ts';
6
+ import type { AssistantAgent, AssistantCapabilityProfile, AssistantChunkContentAttachment, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantModelInfoList, AssistantSkillCatalogResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantToolReportEntry, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../../spec/hyperschema/types.d.ts';
7
+ import type { HarnessDiagnostics } from '../diagnostics.ts';
8
+ import type { DownloadArgs, DownloadEventStream, ImageDownloadObservation } from '../model-download.ts';
9
+ import type { AttachInput, AttachmentMeta, ChatMessage, FetchedAttachment } from './message.ts';
10
+ import type { Skill } from './skill-encode.ts';
11
+ export interface HarnessEvent {
12
+ type: string;
13
+ text?: string;
14
+ message?: string;
15
+ [key: string]: unknown;
16
+ }
17
+ export interface ModelState {
18
+ status: string;
19
+ model?: string;
20
+ percentage?: number;
21
+ downloaded?: number;
22
+ total?: number;
23
+ catalogChanged?: boolean;
24
+ }
25
+ export interface HarnessInfo {
26
+ toolNames: string[];
27
+ skills: string[];
28
+ supportsImages: boolean;
29
+ }
30
+ export type ModelType = string;
31
+ export interface ModelInfo {
32
+ name: string;
33
+ type: ModelType;
34
+ registryPath: string;
35
+ registrySource: string;
36
+ isCached: boolean;
37
+ isLoaded: boolean;
38
+ supportsImages?: boolean;
39
+ expectedSize: number;
40
+ actualSize?: number;
41
+ }
42
+ export interface ListModelsOptions {
43
+ type?: ModelType;
44
+ cachedOnly?: boolean;
45
+ fullRegistry?: boolean;
46
+ }
47
+ export interface DeleteModelSummary {
48
+ name: string;
49
+ removed: number;
50
+ freedBytes: number;
51
+ }
52
+ export interface ToolCatalogEntry {
53
+ name: string;
54
+ description: string;
55
+ skillGated: boolean;
56
+ scopeRequired: boolean;
57
+ toolset?: string | null;
58
+ rootsRequired?: boolean;
59
+ writeRootsRequired?: boolean;
60
+ promptChars?: number;
61
+ }
62
+ export interface Harness {
63
+ completion(context: {
64
+ model: string;
65
+ agent: AssistantAgent;
66
+ messages: ChatMessage[];
67
+ cacheKey?: string;
68
+ thinkingDefault?: string;
69
+ toolConfigs?: Record<string, Record<string, unknown>>;
70
+ grantedDirs?: string[];
71
+ grantedDrives?: GrantedDrive[];
72
+ driveOp?: DriveOpFn;
73
+ grantedWriteDirs?: string[];
74
+ generationParams?: {
75
+ temp?: number;
76
+ top_p?: number;
77
+ top_k?: number;
78
+ presence_penalty?: number;
79
+ repeat_penalty?: number;
80
+ frequency_penalty?: number;
81
+ reasoning_budget: 0 | -1;
82
+ };
83
+ responseFormat?: {
84
+ type: 'text';
85
+ } | {
86
+ type: 'json_object';
87
+ } | {
88
+ type: 'json_schema';
89
+ json_schema: {
90
+ name: string;
91
+ description?: string;
92
+ schema: Record<string, unknown>;
93
+ strict?: boolean;
94
+ };
95
+ };
96
+ approve?: (call: ApprovalCall) => Promise<boolean>;
97
+ attach?: (input: AttachInput) => Promise<AssistantChunkContentAttachment>;
98
+ fetchAttachment?: (query: {
99
+ attachmentId?: string;
100
+ signal?: AbortSignal;
101
+ meta?: boolean;
102
+ }) => Promise<FetchedAttachment | AttachmentMeta | null>;
103
+ ragSearch?: (input: {
104
+ query: string;
105
+ limit?: number;
106
+ }) => Promise<{
107
+ enabled: boolean;
108
+ indexEmpty: boolean;
109
+ hasKnowledge: boolean;
110
+ pendingReferenced?: boolean;
111
+ errorMessage?: string | null;
112
+ hits: ReadonlyArray<{
113
+ content: string;
114
+ metadataJson?: string | null;
115
+ score: number;
116
+ }>;
117
+ }>;
118
+ progress?: (update: {
119
+ percentage: number;
120
+ } | null) => void;
121
+ signal?: AbortSignal;
122
+ }): AsyncIterable<HarnessEvent>;
123
+ describe?(): Promise<HarnessInfo | null> | HarnessInfo;
124
+ embed?(context: {
125
+ model: string;
126
+ texts: string[];
127
+ signal?: AbortSignal;
128
+ }): Promise<number[][]>;
129
+ list?(options?: ListModelsOptions): Promise<ReadonlyArray<ModelInfo>>;
130
+ warmModel?(context: {
131
+ model: string;
132
+ agent?: AssistantAgent;
133
+ signal?: AbortSignal;
134
+ }): Promise<void>;
135
+ deleteModel?(name: string): Promise<DeleteModelSummary>;
136
+ clearKvCache?(): Promise<AssistantKvCacheDeletionResponse>;
137
+ deleteKvCache?(kvCacheKey: string): Promise<AssistantKvCacheDeletionResponse>;
138
+ infraModels?(profile: string): Promise<ReadonlyArray<{
139
+ name: string;
140
+ addon: string;
141
+ }>>;
142
+ capability?(): Promise<{
143
+ capabilityProfile: AssistantCapabilityProfile;
144
+ recommendedModelName: string;
145
+ memoryBudget?: MemoryBudget;
146
+ }>;
147
+ download?(args: DownloadArgs): DownloadEventStream;
148
+ transcribe?(context: {
149
+ model: string;
150
+ audio: Buffer;
151
+ signal?: AbortSignal;
152
+ }): Promise<string>;
153
+ speak?(context: {
154
+ model: string;
155
+ text: string;
156
+ signal?: AbortSignal;
157
+ }): Promise<{
158
+ audio: Buffer;
159
+ sampleRate: number;
160
+ }>;
161
+ speakStream?(context: {
162
+ model: string;
163
+ text: AsyncIterable<string>;
164
+ signal?: AbortSignal;
165
+ }): AsyncIterable<{
166
+ audio: Buffer;
167
+ sampleRate: number;
168
+ }>;
169
+ setCredentials?(entries: ReadonlyArray<{
170
+ key: string;
171
+ token?: string | null;
172
+ expiresAt?: number | null;
173
+ agentId?: string | null;
174
+ }>): void | Promise<void>;
175
+ setCustomModels?(entries: ReadonlyArray<{
176
+ name: string;
177
+ src: string;
178
+ projectionSrc?: string;
179
+ }>): void | Promise<void>;
180
+ on?(event: 'model' | 'status', listener: (...args: never[]) => void): unknown;
181
+ off?(event: 'model' | 'status', listener: (...args: never[]) => void): unknown;
182
+ presuspend?(): Promise<void> | void;
183
+ suspend?(): Promise<void> | void;
184
+ wakeup?(): Promise<void> | void;
185
+ resume?(): Promise<void> | void;
186
+ skills?(agentId?: string | null, modelName?: string | null, options?: {
187
+ readonly refresh?: boolean;
188
+ readonly skipCredentialProbe?: boolean;
189
+ }): Promise<ReadonlyArray<Skill>>;
190
+ tools?(): Promise<ReadonlyArray<ToolCatalogEntry>>;
191
+ listManagedSkills?(): Promise<ReadonlyArray<ManagedSkill>>;
192
+ readSkillFile?(name: string): Promise<SkillFileContent | null>;
193
+ writeSkillFile?(name: string, content: string): Promise<{
194
+ ok: boolean;
195
+ }>;
196
+ copyBaseForEdit?(name: string): Promise<{
197
+ copied: boolean;
198
+ }>;
199
+ deleteOverlaySkill?(name: string): Promise<{
200
+ removed: boolean;
201
+ }>;
202
+ diagnostics?(): HarnessDiagnostics;
203
+ fetchDiagnostics?(): Promise<HarnessDiagnostics | null>;
204
+ toolNames?: string[];
205
+ skillNames?: string[];
206
+ supportsImages?: boolean;
207
+ supportsImagesFor?(model: string): boolean;
208
+ }
209
+ export declare function harnessListModels(harness: Pick<Harness, 'list'>): (options: AssistantListModelsRequest) => Promise<AssistantModelInfoList>;
210
+ export declare function harnessDeleteModel(harness: Pick<Harness, 'deleteModel'>): (options: AssistantDeleteModelRequest) => Promise<AssistantDeleteModelResponse>;
211
+ export declare function harnessClearKvCache(harness: Pick<Harness, 'clearKvCache'>): () => Promise<AssistantKvCacheDeletionResponse>;
212
+ export declare function harnessTranscribe(harness: Pick<Harness, 'transcribe'>): (request: AssistantTranscribeRequest) => Promise<AssistantTranscribeResponse>;
213
+ export declare function harnessSpeak(harness: Pick<Harness, 'speak'>): (request: AssistantSpeakRequest) => Promise<AssistantSpeakResponse>;
214
+ export declare function harnessSkillCatalog(harness: Pick<Harness, 'skills'>, syncCredentials?: () => Promise<void> | undefined): (agentId?: string | null, modelName?: string | null, options?: {
215
+ readonly refresh?: boolean;
216
+ readonly skipCredentialProbe?: boolean;
217
+ }) => Promise<AssistantSkillCatalogResponse>;
218
+ export declare function harnessSkillManagement(harness: Pick<Harness, 'listManagedSkills' | 'readSkillFile' | 'writeSkillFile' | 'copyBaseForEdit' | 'deleteOverlaySkill'>): SkillManagementHooks;
219
+ export declare function harnessTools(harness: Pick<Harness, 'tools'>): () => Promise<AssistantToolCatalogResponse>;
220
+ export declare function toolReportEntry(tool: ToolCatalogEntry): AssistantToolReportEntry;
221
+ export declare function harnessSpeakStream(harness: Pick<Harness, 'speakStream'>): (text: AsyncIterable<string>) => AsyncIterable<AssistantSpeakResponse>;
222
+ export declare function harnessDeathReason(status: unknown): string;
223
+ export declare function harnessDied(status: unknown): boolean;
224
+ export declare function modelCatalogChanged(state: unknown): boolean;
225
+ export declare function imageDownloadProgress(state: unknown): ImageDownloadObservation | null;
@@ -0,0 +1,154 @@
1
+ import { diffusionDownloadName } from '@qvac/harness/lib/models/model-catalog.ts';
2
+ import { RUN_FAILURE_REASONS } from '../run-notices.js';
3
+ import { toEngineSkill } from './skill-encode.js';
4
+ export function harnessListModels(harness) {
5
+ return async ({ type, cachedOnly, fullRegistry } = {}) => ({
6
+ models: [
7
+ ...((await harness.list?.({
8
+ type: type ?? undefined,
9
+ cachedOnly: cachedOnly ?? undefined,
10
+ fullRegistry: fullRegistry ?? undefined
11
+ })) ?? [])
12
+ ]
13
+ });
14
+ }
15
+ export function harnessDeleteModel(harness) {
16
+ return async ({ name }) => (await harness.deleteModel?.(name)) ?? { name, removed: 0, freedBytes: 0 };
17
+ }
18
+ export function harnessClearKvCache(harness) {
19
+ return async () => (await harness.clearKvCache?.()) ?? {
20
+ status: 'unsupported',
21
+ error: 'Harness does not support KV cache deletion'
22
+ };
23
+ }
24
+ export function harnessTranscribe(harness) {
25
+ return async ({ audio, model }) => {
26
+ if (!harness.transcribe)
27
+ throw new Error('harness does not support transcribe');
28
+ return { text: await harness.transcribe({ audio, model: model ?? '' }) };
29
+ };
30
+ }
31
+ export function harnessSpeak(harness) {
32
+ return async ({ text, model }) => {
33
+ if (!harness.speak)
34
+ throw new Error('harness does not support speak');
35
+ const { audio, sampleRate } = await harness.speak({ text, model: model ?? '' });
36
+ return { audio, sampleRate };
37
+ };
38
+ }
39
+ export function harnessSkillCatalog(harness, syncCredentials) {
40
+ return async (agentId, modelName, options) => {
41
+ if (options?.refresh)
42
+ await syncCredentials?.();
43
+ return {
44
+ skills: ((await harness.skills?.(agentId, modelName, options)) ?? []).map(toEngineSkill)
45
+ };
46
+ };
47
+ }
48
+ export function harnessSkillManagement(harness) {
49
+ return {
50
+ async listManagedSkills() {
51
+ return {
52
+ skills: ((await harness.listManagedSkills?.()) ?? []).map((skill) => ({
53
+ name: skill.name,
54
+ origin: skill.origin,
55
+ overridesBase: skill.overridesBase
56
+ }))
57
+ };
58
+ },
59
+ async readSkillFile(name) {
60
+ const file = await harness.readSkillFile?.(name);
61
+ return file ? { found: true, content: file.content, origin: file.origin } : { found: false };
62
+ },
63
+ async writeSkillFile(name, content) {
64
+ if (!harness.writeSkillFile)
65
+ return { ok: false };
66
+ return harness.writeSkillFile(name, content);
67
+ },
68
+ async copySkillForEdit(name) {
69
+ return { copied: (await harness.copyBaseForEdit?.(name))?.copied ?? false };
70
+ },
71
+ async deleteOverlaySkill(name) {
72
+ return { removed: (await harness.deleteOverlaySkill?.(name))?.removed ?? false };
73
+ }
74
+ };
75
+ }
76
+ export function harnessTools(harness) {
77
+ return async () => ({
78
+ tools: ((await harness.tools?.()) ?? []).map((tool) => ({
79
+ ...toolReportEntry(tool),
80
+ description: tool.description
81
+ }))
82
+ });
83
+ }
84
+ export function toolReportEntry(tool) {
85
+ return {
86
+ name: tool.name,
87
+ promptChars: tool.promptChars ?? 0,
88
+ toolset: tool.toolset ?? null,
89
+ skillGated: tool.skillGated === true,
90
+ scopeRequired: tool.scopeRequired === true,
91
+ rootsRequired: tool.rootsRequired === true,
92
+ writeRootsRequired: tool.writeRootsRequired === true
93
+ };
94
+ }
95
+ export function harnessSpeakStream(harness) {
96
+ return async function* (text) {
97
+ if (!harness.speakStream)
98
+ throw new Error('harness does not support speakStream');
99
+ for await (const { audio, sampleRate } of harness.speakStream({ model: '', text })) {
100
+ yield { audio, sampleRate };
101
+ }
102
+ };
103
+ }
104
+ export function harnessDeathReason(status) {
105
+ const HARNESS_DIED = RUN_FAILURE_REASONS.harnessDied;
106
+ if (typeof status !== 'object' || status === null)
107
+ return HARNESS_DIED;
108
+ const record = status;
109
+ const detail = typeof record.error === 'string' && record.error ? record.error : null;
110
+ const code = typeof record.code === 'string' && record.code ? record.code : null;
111
+ if (!detail)
112
+ return code ? `${HARNESS_DIED} (${code})` : HARNESS_DIED;
113
+ return code ? `${HARNESS_DIED}: ${detail} (${code})` : `${HARNESS_DIED}: ${detail}`;
114
+ }
115
+ export function harnessDied(status) {
116
+ if (typeof status !== 'object' || status === null || !('state' in status))
117
+ return false;
118
+ return status.state === 'died';
119
+ }
120
+ export function modelCatalogChanged(state) {
121
+ return (typeof state === 'object' &&
122
+ state !== null &&
123
+ 'catalogChanged' in state &&
124
+ state.catalogChanged === true);
125
+ }
126
+ export function imageDownloadProgress(state) {
127
+ if (typeof state !== 'object' ||
128
+ state === null ||
129
+ !('status' in state) ||
130
+ (state.status !== 'downloading' && state.status !== 'downloaded') ||
131
+ !('model' in state) ||
132
+ typeof state.model !== 'string' ||
133
+ !('percentage' in state) ||
134
+ typeof state.percentage !== 'number' ||
135
+ !Number.isFinite(state.percentage) ||
136
+ !('downloaded' in state) ||
137
+ typeof state.downloaded !== 'number' ||
138
+ !Number.isFinite(state.downloaded) ||
139
+ !('total' in state) ||
140
+ typeof state.total !== 'number' ||
141
+ !Number.isFinite(state.total)) {
142
+ return null;
143
+ }
144
+ const model = diffusionDownloadName(state.model);
145
+ if (!model)
146
+ return null;
147
+ return {
148
+ model,
149
+ phase: state.status === 'downloading' ? 'downloading' : 'complete',
150
+ percentage: state.percentage,
151
+ downloaded: state.downloaded,
152
+ total: state.total
153
+ };
154
+ }
@@ -0,0 +1,31 @@
1
+ import type { AbortSignal } from 'bare-abort-controller';
2
+ import type { AssistantChunk } from '../../spec/hyperschema/types.d.ts';
3
+ import type { Capabilities } from '../api/index.ts';
4
+ import type { ChatMessage } from './message.ts';
5
+ export declare const TERMINAL_STATES: Set<string>;
6
+ export declare const HISTORY_TYPES: AssistantChunk['type'][];
7
+ export declare const SKILL_TOOL = "skill";
8
+ export interface StaleToolRuns {
9
+ runIds: Set<string>;
10
+ questionChunkIds: Set<string>;
11
+ }
12
+ export declare function listHistoryChunks(engine: Pick<Capabilities, 'listChunks'>, chatId: string): Promise<AssistantChunk[]>;
13
+ export declare function latestAttemptStarts(chunks: ReadonlyArray<AssistantChunk>): Map<string, number>;
14
+ export declare function beforeLatestAttempt(chunk: AssistantChunk, starts: Map<string, number>): boolean;
15
+ export interface CompactOptions {
16
+ readonly signal?: AbortSignal;
17
+ readonly onFold?: () => Promise<void> | void;
18
+ readonly meshId?: string;
19
+ }
20
+ export type CompactionTrigger = 'before-run' | 'overflow';
21
+ export interface CompactResult {
22
+ readonly compacted: boolean;
23
+ readonly foldedTurns?: number;
24
+ readonly reason?: string;
25
+ }
26
+ export declare function historyFromChunks(chunks: ReadonlyArray<AssistantChunk>, stale?: Partial<StaleToolRuns>): ChatMessage[];
27
+ export declare function inputAvailableToRun(chunk: AssistantChunk, requestSeq: number): boolean;
28
+ export declare function normalizeQuestion(text: string): string;
29
+ export declare const GENERIC_ACKNOWLEDGEMENTS: Set<string>;
30
+ export declare function isGenericAcknowledgement(question: string): boolean;
31
+ export declare function staleToolRunIds(historyChunks: ReadonlyArray<AssistantChunk>, approvalChunks: ReadonlyArray<AssistantChunk>, currentRunId: string): StaleToolRuns;
@@ -0,0 +1,226 @@
1
+ import { attachmentTurn, skillLoadedTurn } from '@qvac/harness/lib/capabilities/tool-turns.ts';
2
+ import { HISTORY_CHUNK_TYPES } from '../core/chunk.js';
3
+ import { isAudioAttachment } from '../core/audio-attachment.js';
4
+ import { isDocumentAttachment } from '../core/document-attachment.js';
5
+ import { groupAttachmentsByMessage } from '../core/files/index.js';
6
+ import { IMAGE_MIMES } from '../core/image/normalize.js';
7
+ import { compactionTurn, foldCompactedChunks } from '../compaction.js';
8
+ export const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
9
+ export const HISTORY_TYPES = HISTORY_CHUNK_TYPES;
10
+ export const SKILL_TOOL = 'skill';
11
+ export async function listHistoryChunks(engine, chatId) {
12
+ const [history, toolResults, runStatuses] = await Promise.all([
13
+ engine.listChunks({ chatId, types: HISTORY_TYPES }),
14
+ engine.listChunks({ chatId, type: 'tool-result' }),
15
+ engine.listChunks({ chatId, type: 'run-status' })
16
+ ]);
17
+ return [
18
+ ...(history.chunks ?? []),
19
+ ...(toolResults.chunks ?? []),
20
+ ...(runStatuses.chunks ?? [])
21
+ ].sort((a, b) => a.seq - b.seq);
22
+ }
23
+ export function latestAttemptStarts(chunks) {
24
+ const starts = new Map();
25
+ for (const chunk of chunks) {
26
+ if (chunk.type !== 'run-status' || !chunk.runId)
27
+ continue;
28
+ if (TERMINAL_STATES.has(chunk.runStatus?.state ?? ''))
29
+ continue;
30
+ if (chunk.runStatus?.progress?.phase === 'compacting')
31
+ continue;
32
+ starts.set(chunk.runId, chunk.seq);
33
+ }
34
+ return starts;
35
+ }
36
+ export function beforeLatestAttempt(chunk, starts) {
37
+ if (!chunk.runId)
38
+ return false;
39
+ const start = starts.get(chunk.runId);
40
+ return start !== undefined && chunk.seq < start;
41
+ }
42
+ export function historyFromChunks(chunks, stale = {}) {
43
+ const attemptStarts = latestAttemptStarts(chunks);
44
+ const staleRunIds = stale.runIds ?? new Set();
45
+ const staleQuestionChunkIds = stale.questionChunkIds ?? new Set();
46
+ const folded = foldCompactedChunks(chunks);
47
+ const source = folded.chunks;
48
+ const attachments = [];
49
+ const userMessages = [];
50
+ for (const chunk of source) {
51
+ if (chunk.type === 'attachment')
52
+ attachments.push(chunk);
53
+ else if (chunk.userMessage)
54
+ userMessages.push(chunk);
55
+ }
56
+ const byMessage = groupAttachmentsByMessage(attachments, userMessages);
57
+ const history = [];
58
+ const replayedSkills = new Set();
59
+ if (folded.summary)
60
+ history.push({ role: 'user', content: compactionTurn(folded.summary) });
61
+ const byRun = new Map();
62
+ const anchor = (runId) => {
63
+ let turn = byRun.get(runId);
64
+ if (!turn) {
65
+ turn = { role: 'assistant', content: '' };
66
+ byRun.set(runId, turn);
67
+ history.push(turn);
68
+ }
69
+ return turn;
70
+ };
71
+ for (const chunk of source) {
72
+ if (chunk.userMessage) {
73
+ if (staleQuestionChunkIds.has(chunk.id))
74
+ continue;
75
+ const turn = { role: 'user', content: chunk.userMessage.text };
76
+ const refs = (byMessage.get(chunk.id) ?? [])
77
+ .map((attachmentChunk) => attachmentChunk.attachment)
78
+ .filter((ref) => !ref.deletedAt);
79
+ const images = refs.filter((ref) => IMAGE_MIMES.has(ref.mimeType.toLowerCase()));
80
+ const audio = refs.filter((ref) => isAudioAttachment(ref.fileName, ref.mimeType));
81
+ const documents = refs.filter((ref) => isDocumentAttachment(ref));
82
+ if (images.length)
83
+ turn.images = images;
84
+ if (audio.length)
85
+ turn.audioAttachments = audio;
86
+ if (documents.length)
87
+ turn.documents = documents;
88
+ history.push(turn);
89
+ continue;
90
+ }
91
+ if (chunk.attachment)
92
+ continue;
93
+ if (chunk.type === 'run-request' && chunk.runId) {
94
+ anchor(chunk.runId);
95
+ continue;
96
+ }
97
+ if (chunk.toolResult?.name === SKILL_TOOL) {
98
+ if (chunk.runId && staleRunIds.has(chunk.runId))
99
+ continue;
100
+ if (beforeLatestAttempt(chunk, attemptStarts))
101
+ continue;
102
+ const loaded = chunk.toolResult.result?.name;
103
+ if (typeof loaded === 'string' && !replayedSkills.has(loaded)) {
104
+ replayedSkills.add(loaded);
105
+ const at = history.indexOf(anchor(chunk.runId)) + 1;
106
+ history.splice(at, 0, { role: 'tool', content: skillLoadedTurn(loaded) });
107
+ }
108
+ continue;
109
+ }
110
+ if (chunk.toolResult) {
111
+ if (chunk.runId && staleRunIds.has(chunk.runId))
112
+ continue;
113
+ if (beforeLatestAttempt(chunk, attemptStarts))
114
+ continue;
115
+ const produced = attachmentTurn(chunk.toolResult.name, chunk.toolResult.result);
116
+ if (produced)
117
+ history.push({ role: 'tool', content: produced });
118
+ continue;
119
+ }
120
+ if (!chunk.content)
121
+ continue;
122
+ if (chunk.runId && staleRunIds.has(chunk.runId))
123
+ continue;
124
+ if (beforeLatestAttempt(chunk, attemptStarts))
125
+ continue;
126
+ anchor(chunk.runId).content += chunk.content.text;
127
+ }
128
+ return history.filter((turn) => turn.role === 'user' || turn.content.length > 0);
129
+ }
130
+ export function inputAvailableToRun(chunk, requestSeq) {
131
+ const userInput = Boolean(chunk.userMessage || (chunk.attachment && !chunk.runId));
132
+ return !userInput || chunk.seq < requestSeq;
133
+ }
134
+ export function normalizeQuestion(text) {
135
+ return text.trim().toLowerCase().replace(/\s+/g, ' ');
136
+ }
137
+ export const GENERIC_ACKNOWLEDGEMENTS = new Set([
138
+ 'yes',
139
+ 'y',
140
+ 'yeah',
141
+ 'yep',
142
+ 'yup',
143
+ 'ok',
144
+ 'okay',
145
+ 'k',
146
+ 'sure',
147
+ 'fine',
148
+ 'no',
149
+ 'n',
150
+ 'nope',
151
+ 'nah',
152
+ 'again',
153
+ 'continue',
154
+ 'go on',
155
+ 'go ahead',
156
+ 'keep going',
157
+ 'proceed',
158
+ 'do it',
159
+ 'more',
160
+ 'please',
161
+ 'thanks',
162
+ 'thank you',
163
+ 'retry',
164
+ 'redo'
165
+ ]);
166
+ export function isGenericAcknowledgement(question) {
167
+ return GENERIC_ACKNOWLEDGEMENTS.has(question.replace(/[?.!]+$/, '').trim());
168
+ }
169
+ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
170
+ const empty = { runIds: new Set(), questionChunkIds: new Set() };
171
+ const toolRuns = new Set();
172
+ for (const chunk of approvalChunks) {
173
+ if (chunk.runId)
174
+ toolRuns.add(chunk.runId);
175
+ }
176
+ if (!toolRuns.size)
177
+ return empty;
178
+ const turnOrder = [];
179
+ const turnText = new Map();
180
+ const turnRuns = new Map();
181
+ const runChunk = new Map();
182
+ let lastUser = null;
183
+ for (const chunk of historyChunks) {
184
+ if (chunk.userMessage) {
185
+ lastUser = { text: chunk.userMessage.text, chunkId: chunk.id };
186
+ continue;
187
+ }
188
+ if (chunk.type === 'run-request' && chunk.runId && lastUser !== null) {
189
+ const chunkId = lastUser.chunkId;
190
+ if (!turnText.has(chunkId)) {
191
+ turnOrder.push(chunkId);
192
+ turnText.set(chunkId, lastUser.text);
193
+ }
194
+ turnRuns.set(chunkId, [...(turnRuns.get(chunkId) ?? []), chunk.runId]);
195
+ runChunk.set(chunk.runId, chunkId);
196
+ }
197
+ }
198
+ const currentChunkId = runChunk.get(currentRunId) ?? lastUser?.chunkId;
199
+ if (currentChunkId === undefined)
200
+ return empty;
201
+ const currentText = turnText.get(currentChunkId) ?? lastUser?.text;
202
+ if (currentText === undefined)
203
+ return empty;
204
+ const target = normalizeQuestion(currentText);
205
+ if (isGenericAcknowledgement(target))
206
+ return empty;
207
+ const currentIndex = turnOrder.indexOf(currentChunkId);
208
+ const start = currentIndex === -1 ? turnOrder.length - 1 : currentIndex - 1;
209
+ const runIds = new Set();
210
+ const questionChunkIds = new Set();
211
+ let blockHadApproval = false;
212
+ for (let i = start; i >= 0; i--) {
213
+ const chunkId = turnOrder[i];
214
+ if (normalizeQuestion(turnText.get(chunkId)) !== target)
215
+ break;
216
+ questionChunkIds.add(chunkId);
217
+ for (const rid of turnRuns.get(chunkId) ?? []) {
218
+ runIds.add(rid);
219
+ if (toolRuns.has(rid))
220
+ blockHadApproval = true;
221
+ }
222
+ }
223
+ if (!blockHadApproval)
224
+ return empty;
225
+ return { runIds, questionChunkIds };
226
+ }
@@ -0,0 +1,45 @@
1
+ import type { DocumentAttachment } from '../core/document-attachment.ts';
2
+ export interface ChatMessage {
3
+ role: 'user' | 'assistant' | 'tool';
4
+ content: string;
5
+ attachments?: {
6
+ path: string;
7
+ }[];
8
+ images?: AttachmentRef[];
9
+ audioAttachments?: AttachmentRef[];
10
+ documents?: DocumentAttachment[];
11
+ }
12
+ export declare const IMAGE_ONLY_USER_PROMPT = "The user sent one or more images without any accompanying text. Describe what the images show and respond to anything notable in them.";
13
+ export declare const DOCUMENT_ONLY_USER_PROMPT = "The user sent one or more documents without any accompanying text. Summarize the attached documents.";
14
+ export declare const IMAGE_AND_DOCUMENT_USER_PROMPT = "The user sent one or more images together with one or more documents, and no accompanying text. Describe what the images show and summarize the attached documents.";
15
+ export declare function backfillDocumentOnlyTurn(messages: ChatMessage[]): void;
16
+ export declare function backfillImageOnlyTurns(messages: ChatMessage[]): void;
17
+ export declare function unreadableImagesNotice(fileNames: readonly string[]): string;
18
+ export declare function annotateUnreadableImages(unreadable: ReadonlyMap<ChatMessage, string[]>): void;
19
+ export declare function unheardAudioNotice(label: string, reason: string, opts?: {
20
+ retryable?: boolean;
21
+ }): string;
22
+ export declare function silentAudioNotice(fileName: string): string;
23
+ export declare function audioTranscriptBlock(fileName: string, transcript: string): string;
24
+ export interface AttachmentRef {
25
+ id: string;
26
+ fileName: string;
27
+ mimeType: string;
28
+ blobId: string;
29
+ url?: string | null;
30
+ }
31
+ export interface AttachInput {
32
+ fileName: string;
33
+ mimeType: string;
34
+ bytes: Uint8Array;
35
+ raw?: boolean;
36
+ }
37
+ export interface AttachmentMeta {
38
+ id: string;
39
+ fileName: string;
40
+ mimeType: string;
41
+ byteLength: number;
42
+ }
43
+ export interface FetchedAttachment extends AttachmentMeta {
44
+ bytes: Uint8Array;
45
+ }