@oharness/engine 0.1.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 (256) hide show
  1. package/dist/agent/agent.d.ts +196 -0
  2. package/dist/agent/agent.js +758 -0
  3. package/dist/agent/agent.js.map +1 -0
  4. package/dist/agent/compaction.d.ts +68 -0
  5. package/dist/agent/compaction.js +179 -0
  6. package/dist/agent/compaction.js.map +1 -0
  7. package/dist/agent/hooks.d.ts +77 -0
  8. package/dist/agent/hooks.js +152 -0
  9. package/dist/agent/hooks.js.map +1 -0
  10. package/dist/agent/memory.d.ts +45 -0
  11. package/dist/agent/memory.js +147 -0
  12. package/dist/agent/memory.js.map +1 -0
  13. package/dist/agent/overflow.d.ts +35 -0
  14. package/dist/agent/overflow.js +69 -0
  15. package/dist/agent/overflow.js.map +1 -0
  16. package/dist/agent/permissions.d.ts +181 -0
  17. package/dist/agent/permissions.js +289 -0
  18. package/dist/agent/permissions.js.map +1 -0
  19. package/dist/agent/prompt.d.ts +25 -0
  20. package/dist/agent/prompt.js +63 -0
  21. package/dist/agent/prompt.js.map +1 -0
  22. package/dist/agent/session.d.ts +108 -0
  23. package/dist/agent/session.js +231 -0
  24. package/dist/agent/session.js.map +1 -0
  25. package/dist/agent/settings.d.ts +37 -0
  26. package/dist/agent/settings.js +113 -0
  27. package/dist/agent/settings.js.map +1 -0
  28. package/dist/agent/skills.d.ts +58 -0
  29. package/dist/agent/skills.js +225 -0
  30. package/dist/agent/skills.js.map +1 -0
  31. package/dist/agent/store.d.ts +308 -0
  32. package/dist/agent/store.js +596 -0
  33. package/dist/agent/store.js.map +1 -0
  34. package/dist/agent/subagent.d.ts +44 -0
  35. package/dist/agent/subagent.js +138 -0
  36. package/dist/agent/subagent.js.map +1 -0
  37. package/dist/agent/titles.d.ts +8 -0
  38. package/dist/agent/titles.js +23 -0
  39. package/dist/agent/titles.js.map +1 -0
  40. package/dist/agent/workspace.d.ts +60 -0
  41. package/dist/agent/workspace.js +156 -0
  42. package/dist/agent/workspace.js.map +1 -0
  43. package/dist/artifacts/publish.d.ts +94 -0
  44. package/dist/artifacts/publish.js +104 -0
  45. package/dist/artifacts/publish.js.map +1 -0
  46. package/dist/artifacts/store.d.ts +324 -0
  47. package/dist/artifacts/store.js +500 -0
  48. package/dist/artifacts/store.js.map +1 -0
  49. package/dist/auth/index.d.ts +13 -0
  50. package/dist/auth/index.js +10 -0
  51. package/dist/auth/index.js.map +1 -0
  52. package/dist/auth/manager.d.ts +83 -0
  53. package/dist/auth/manager.js +266 -0
  54. package/dist/auth/manager.js.map +1 -0
  55. package/dist/auth/oauth.d.ts +83 -0
  56. package/dist/auth/oauth.js +327 -0
  57. package/dist/auth/oauth.js.map +1 -0
  58. package/dist/auth/providers/account.d.ts +59 -0
  59. package/dist/auth/providers/account.js +282 -0
  60. package/dist/auth/providers/account.js.map +1 -0
  61. package/dist/auth/providers/anthropic.d.ts +24 -0
  62. package/dist/auth/providers/anthropic.js +209 -0
  63. package/dist/auth/providers/anthropic.js.map +1 -0
  64. package/dist/auth/providers/generic.d.ts +57 -0
  65. package/dist/auth/providers/generic.js +155 -0
  66. package/dist/auth/providers/generic.js.map +1 -0
  67. package/dist/auth/providers/official.d.ts +3 -0
  68. package/dist/auth/providers/official.js +90 -0
  69. package/dist/auth/providers/official.js.map +1 -0
  70. package/dist/auth/providers/ottoport.d.ts +3 -0
  71. package/dist/auth/providers/ottoport.js +60 -0
  72. package/dist/auth/providers/ottoport.js.map +1 -0
  73. package/dist/auth/store.d.ts +22 -0
  74. package/dist/auth/store.js +138 -0
  75. package/dist/auth/store.js.map +1 -0
  76. package/dist/auth/types.d.ts +167 -0
  77. package/dist/auth/types.js +16 -0
  78. package/dist/auth/types.js.map +1 -0
  79. package/dist/config.d.ts +197 -0
  80. package/dist/config.js +195 -0
  81. package/dist/config.js.map +1 -0
  82. package/dist/core/errors.d.ts +46 -0
  83. package/dist/core/errors.js +83 -0
  84. package/dist/core/errors.js.map +1 -0
  85. package/dist/core/tokens.d.ts +12 -0
  86. package/dist/core/tokens.js +56 -0
  87. package/dist/core/tokens.js.map +1 -0
  88. package/dist/core/types.d.ts +91 -0
  89. package/dist/core/types.js +49 -0
  90. package/dist/core/types.js.map +1 -0
  91. package/dist/harness.d.ts +302 -0
  92. package/dist/harness.js +695 -0
  93. package/dist/harness.js.map +1 -0
  94. package/dist/index.d.ts +32 -0
  95. package/dist/index.js +21 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/mcp/client.d.ts +55 -0
  98. package/dist/mcp/client.js +199 -0
  99. package/dist/mcp/client.js.map +1 -0
  100. package/dist/mcp/index.d.ts +13 -0
  101. package/dist/mcp/index.js +8 -0
  102. package/dist/mcp/index.js.map +1 -0
  103. package/dist/mcp/manager.d.ts +77 -0
  104. package/dist/mcp/manager.js +325 -0
  105. package/dist/mcp/manager.js.map +1 -0
  106. package/dist/mcp/oauth.d.ts +63 -0
  107. package/dist/mcp/oauth.js +302 -0
  108. package/dist/mcp/oauth.js.map +1 -0
  109. package/dist/mcp/protocol.d.ts +130 -0
  110. package/dist/mcp/protocol.js +14 -0
  111. package/dist/mcp/protocol.js.map +1 -0
  112. package/dist/mcp/registry.d.ts +52 -0
  113. package/dist/mcp/registry.js +100 -0
  114. package/dist/mcp/registry.js.map +1 -0
  115. package/dist/mcp/registry.json +293 -0
  116. package/dist/mcp/secrets.d.ts +20 -0
  117. package/dist/mcp/secrets.js +75 -0
  118. package/dist/mcp/secrets.js.map +1 -0
  119. package/dist/mcp/transport.d.ts +51 -0
  120. package/dist/mcp/transport.js +158 -0
  121. package/dist/mcp/transport.js.map +1 -0
  122. package/dist/paths.d.ts +37 -0
  123. package/dist/paths.js +63 -0
  124. package/dist/paths.js.map +1 -0
  125. package/dist/plugins.d.ts +55 -0
  126. package/dist/plugins.js +201 -0
  127. package/dist/plugins.js.map +1 -0
  128. package/dist/providers/builtin.d.ts +23 -0
  129. package/dist/providers/builtin.js +141 -0
  130. package/dist/providers/builtin.js.map +1 -0
  131. package/dist/providers/catalog.d.ts +129 -0
  132. package/dist/providers/catalog.js +254 -0
  133. package/dist/providers/catalog.js.map +1 -0
  134. package/dist/providers/catalog.json +472 -0
  135. package/dist/providers/discovery.d.ts +16 -0
  136. package/dist/providers/discovery.js +161 -0
  137. package/dist/providers/discovery.js.map +1 -0
  138. package/dist/providers/http.d.ts +24 -0
  139. package/dist/providers/http.js +139 -0
  140. package/dist/providers/http.js.map +1 -0
  141. package/dist/providers/index.d.ts +10 -0
  142. package/dist/providers/index.js +8 -0
  143. package/dist/providers/index.js.map +1 -0
  144. package/dist/providers/piai.d.ts +124 -0
  145. package/dist/providers/piai.js +551 -0
  146. package/dist/providers/piai.js.map +1 -0
  147. package/dist/providers/registry.d.ts +65 -0
  148. package/dist/providers/registry.js +195 -0
  149. package/dist/providers/registry.js.map +1 -0
  150. package/dist/providers/resilient.d.ts +46 -0
  151. package/dist/providers/resilient.js +117 -0
  152. package/dist/providers/resilient.js.map +1 -0
  153. package/dist/providers/types.d.ts +182 -0
  154. package/dist/providers/types.js +50 -0
  155. package/dist/providers/types.js.map +1 -0
  156. package/dist/schedule/cron.d.ts +35 -0
  157. package/dist/schedule/cron.js +125 -0
  158. package/dist/schedule/cron.js.map +1 -0
  159. package/dist/schedule/scheduler.d.ts +87 -0
  160. package/dist/schedule/scheduler.js +237 -0
  161. package/dist/schedule/scheduler.js.map +1 -0
  162. package/dist/storage/kv.d.ts +56 -0
  163. package/dist/storage/kv.js +173 -0
  164. package/dist/storage/kv.js.map +1 -0
  165. package/dist/storage/migrate.d.ts +11 -0
  166. package/dist/storage/migrate.js +93 -0
  167. package/dist/storage/migrate.js.map +1 -0
  168. package/dist/storage/project.d.ts +9 -0
  169. package/dist/storage/project.js +57 -0
  170. package/dist/storage/project.js.map +1 -0
  171. package/dist/storage/records.d.ts +32 -0
  172. package/dist/storage/records.js +48 -0
  173. package/dist/storage/records.js.map +1 -0
  174. package/dist/sync/client.d.ts +79 -0
  175. package/dist/sync/client.js +118 -0
  176. package/dist/sync/client.js.map +1 -0
  177. package/dist/sync/mirror.d.ts +85 -0
  178. package/dist/sync/mirror.js +389 -0
  179. package/dist/sync/mirror.js.map +1 -0
  180. package/dist/sync/protocol.d.ts +67 -0
  181. package/dist/sync/protocol.js +16 -0
  182. package/dist/sync/protocol.js.map +1 -0
  183. package/dist/sync/settings.d.ts +56 -0
  184. package/dist/sync/settings.js +60 -0
  185. package/dist/sync/settings.js.map +1 -0
  186. package/dist/tools/builtin/artifact.d.ts +16 -0
  187. package/dist/tools/builtin/artifact.js +134 -0
  188. package/dist/tools/builtin/artifact.js.map +1 -0
  189. package/dist/tools/builtin/bash.d.ts +3 -0
  190. package/dist/tools/builtin/bash.js +142 -0
  191. package/dist/tools/builtin/bash.js.map +1 -0
  192. package/dist/tools/builtin/fs.d.ts +19 -0
  193. package/dist/tools/builtin/fs.js +280 -0
  194. package/dist/tools/builtin/fs.js.map +1 -0
  195. package/dist/tools/builtin/index.d.ts +22 -0
  196. package/dist/tools/builtin/index.js +42 -0
  197. package/dist/tools/builtin/index.js.map +1 -0
  198. package/dist/tools/builtin/mcp-resource.d.ts +3 -0
  199. package/dist/tools/builtin/mcp-resource.js +220 -0
  200. package/dist/tools/builtin/mcp-resource.js.map +1 -0
  201. package/dist/tools/builtin/memory.d.ts +10 -0
  202. package/dist/tools/builtin/memory.js +76 -0
  203. package/dist/tools/builtin/memory.js.map +1 -0
  204. package/dist/tools/builtin/recall.d.ts +13 -0
  205. package/dist/tools/builtin/recall.js +163 -0
  206. package/dist/tools/builtin/recall.js.map +1 -0
  207. package/dist/tools/builtin/search.d.ts +3 -0
  208. package/dist/tools/builtin/search.js +240 -0
  209. package/dist/tools/builtin/search.js.map +1 -0
  210. package/dist/tools/builtin/skill.d.ts +10 -0
  211. package/dist/tools/builtin/skill.js +46 -0
  212. package/dist/tools/builtin/skill.js.map +1 -0
  213. package/dist/tools/builtin/task.d.ts +9 -0
  214. package/dist/tools/builtin/task.js +68 -0
  215. package/dist/tools/builtin/task.js.map +1 -0
  216. package/dist/tools/builtin/todo.d.ts +20 -0
  217. package/dist/tools/builtin/todo.js +63 -0
  218. package/dist/tools/builtin/todo.js.map +1 -0
  219. package/dist/tools/define.d.ts +19 -0
  220. package/dist/tools/define.js +39 -0
  221. package/dist/tools/define.js.map +1 -0
  222. package/dist/tools/index.d.ts +7 -0
  223. package/dist/tools/index.js +5 -0
  224. package/dist/tools/index.js.map +1 -0
  225. package/dist/tools/registry.d.ts +39 -0
  226. package/dist/tools/registry.js +101 -0
  227. package/dist/tools/registry.js.map +1 -0
  228. package/dist/tools/types.d.ts +112 -0
  229. package/dist/tools/types.js +22 -0
  230. package/dist/tools/types.js.map +1 -0
  231. package/dist/util/id.d.ts +9 -0
  232. package/dist/util/id.js +19 -0
  233. package/dist/util/id.js.map +1 -0
  234. package/dist/util/json.d.ts +25 -0
  235. package/dist/util/json.js +100 -0
  236. package/dist/util/json.js.map +1 -0
  237. package/dist/util/jwt.d.ts +74 -0
  238. package/dist/util/jwt.js +177 -0
  239. package/dist/util/jwt.js.map +1 -0
  240. package/dist/util/logger.d.ts +13 -0
  241. package/dist/util/logger.js +59 -0
  242. package/dist/util/logger.js.map +1 -0
  243. package/dist/util/queue.d.ts +26 -0
  244. package/dist/util/queue.js +106 -0
  245. package/dist/util/queue.js.map +1 -0
  246. package/dist/util/schema.d.ts +17 -0
  247. package/dist/util/schema.js +98 -0
  248. package/dist/util/schema.js.map +1 -0
  249. package/dist/util/shell.d.ts +20 -0
  250. package/dist/util/shell.js +24 -0
  251. package/dist/util/shell.js.map +1 -0
  252. package/official.json +4 -0
  253. package/package.json +38 -0
  254. package/skills/artifact-authoring/SKILL.md +81 -0
  255. package/skills/canvas/SKILL.md +85 -0
  256. package/skills/skill-authoring/SKILL.md +85 -0
@@ -0,0 +1,324 @@
1
+ import type { Message } from "../core/types.ts";
2
+ /**
3
+ * Artifacts: the things a turn produces, as opposed to the things it says.
4
+ *
5
+ * A file written to the working tree is already a deliverable and the review
6
+ * pane already shows it as a diff. This is for the other case — a chart, a
7
+ * rendered page, a document the model is iterating on — where the deliverable
8
+ * has no natural home on disk and where the interesting question is "what does
9
+ * it look like now", not "what changed since last time".
10
+ *
11
+ * The two properties that make this more than `write` to a temp file:
12
+ *
13
+ * - Identity. An artifact has an id chosen by the model, so a second call
14
+ * with the same id is a revision rather than a new object. That is the
15
+ * whole mechanism: without it every edit would litter the panel with a
16
+ * near-duplicate and the frontend would have no way to know which one is
17
+ * current.
18
+ * - Versions. Every revision is kept, so a frontend can offer "back to the
19
+ * one before you broke it" without the model having to re-derive it.
20
+ *
21
+ * Content lives here and never travels in the event stream. Artifacts are
22
+ * routinely tens of kilobytes and are rewritten in full on every revision;
23
+ * putting that in an event would push it through the SSE relay and into every
24
+ * frontend's memory on every keystroke of a rewrite. Frontends get a
25
+ * descriptor and fetch the body if and when they are going to show it.
26
+ */
27
+ /**
28
+ * How much a frontend has to be able to do to show an artifact honestly.
29
+ *
30
+ * This list is the contract between the engine and every frontend, and it is
31
+ * deliberately short. It is not "which mime types exist" — it is "how many
32
+ * fundamentally different rendering capabilities do we ask a frontend for",
33
+ * and every entry costs each frontend an implementation or an honest refusal.
34
+ * Adding one is a decision, which is why the list is closed and why
35
+ * test/artifacts.test.ts fails when a frontend has no declared answer for a
36
+ * member of it.
37
+ *
38
+ * text Plain prose or data. Any frontend can show this.
39
+ * markdown Structured prose. A frontend without a renderer shows the source,
40
+ * which is still readable — that is why it is separate from `code`.
41
+ * code Source, with a language hint. Degrades to text.
42
+ * image Raster bytes. A terminal generally cannot; see the TUI's answer.
43
+ * vector SVG. Renderable as a document, but also readable as source.
44
+ * page Self-contained HTML that must execute to mean anything. This is
45
+ * the only kind that requires a sandbox, and the only one with no
46
+ * honest textual degradation.
47
+ */
48
+ export declare const ARTIFACT_KINDS: readonly ["text", "markdown", "code", "image", "vector", "page"];
49
+ export type ArtifactKind = (typeof ARTIFACT_KINDS)[number];
50
+ /**
51
+ * The mime that means "this is a canvas".
52
+ *
53
+ * Deliberately a mime and not a seventh entry in ARTIFACT_KINDS. That list is
54
+ * the set of *rendering capabilities* we ask every frontend for, and a canvas
55
+ * asks for nothing new: it is HTML that has to execute, which is exactly what
56
+ * `page` already means. What differs is who wrote the surrounding document —
57
+ * for a `page` the model did, for a canvas the harness does, wrapping the
58
+ * model's artboards in an editor. A frontend that knows nothing about canvases
59
+ * still shows one correctly, because what it receives from /artifact/view is a
60
+ * complete page. Adding a kind would instead have forced every frontend, the
61
+ * website and a database enum to declare an answer to a question none of them
62
+ * actually needed to be asked.
63
+ */
64
+ export declare const CANVAS_MIME = "text/canvas+html";
65
+ /** Whether a mime names a canvas, tolerant of charset parameters and case. */
66
+ export declare function isCanvas(mime: string): boolean;
67
+ /**
68
+ * The capability a mime type implies, falling back by family.
69
+ *
70
+ * Unknown types resolve to `text` rather than throwing: a model that invents
71
+ * `text/x-rst` should get a usable artifact showing its source, not a tool
72
+ * error that costs a turn. The fallback is deliberately the least capable
73
+ * kind — guessing upward would mean handing an unvetted string to a renderer.
74
+ */
75
+ export declare function kindForMime(mime: string): ArtifactKind;
76
+ /** True for kinds whose body is only meaningful when executed by a browser. */
77
+ export declare function needsSandbox(kind: ArtifactKind): boolean;
78
+ /**
79
+ * Where an artifact was published, once it has been.
80
+ *
81
+ * Held here rather than only in the browser tab that clicked Publish, so a
82
+ * reload does not offer to publish something that already has a link.
83
+ * Memory, like the rest of the store: a restarted process forgets the link
84
+ * but the row on the site is still there, and republishing finds it again by
85
+ * `source_id` and returns the same URL.
86
+ */
87
+ export interface ArtifactPublication {
88
+ url: string;
89
+ visibility: "unlisted" | "team";
90
+ teamId?: string;
91
+ /**
92
+ * The revision that was sent.
93
+ *
94
+ * A published link does NOT follow later revisions — the site holds a copy,
95
+ * and only another publish overwrites it. Keeping the number here is what
96
+ * lets a frontend say "the link is showing v2, you are on v4" instead of
97
+ * quietly serving stale content to whoever was sent it.
98
+ */
99
+ version: number;
100
+ }
101
+ /** One revision. Bodies are immutable once stored; a change makes a new one. */
102
+ export interface ArtifactVersion {
103
+ version: number;
104
+ content: string;
105
+ /** Milliseconds since the epoch, for ordering and for "3 revisions ago". */
106
+ createdAt: number;
107
+ bytes: number;
108
+ /**
109
+ * Who wrote this revision.
110
+ *
111
+ * Absent means the model, which is every revision that arrives through
112
+ * `artifact_write`. `"user"` means a person edited it in a frontend — today
113
+ * only the canvas editor can do that. Worth recording because the two have
114
+ * different consequences: the model overwriting its own last revision is
115
+ * ordinary iteration, and the model overwriting a person's edit is a
116
+ * surprise that it should be told about (see the artifact_write receipt).
117
+ */
118
+ author?: "user";
119
+ }
120
+ export interface Artifact {
121
+ id: string;
122
+ title: string;
123
+ mime: string;
124
+ kind: ArtifactKind;
125
+ /** Language hint for `code`, e.g. "python". Advisory: only affects display. */
126
+ language?: string;
127
+ versions: ArtifactVersion[];
128
+ /** Set once the artifact has been copied to the site. */
129
+ publication?: ArtifactPublication;
130
+ }
131
+ /**
132
+ * What a frontend is told when an artifact changes.
133
+ *
134
+ * Everything needed to draw a row in a list and decide whether this frontend
135
+ * can render the body — and nothing else. Notably not the content.
136
+ */
137
+ export interface ArtifactDescriptor {
138
+ id: string;
139
+ title: string;
140
+ mime: string;
141
+ kind: ArtifactKind;
142
+ language?: string;
143
+ version: number;
144
+ bytes: number;
145
+ /** Set when the revision on screen was authored by a person, not the model. */
146
+ author?: "user";
147
+ /** Total revisions kept, so a frontend can offer history without a fetch. */
148
+ versionCount: number;
149
+ /** Present once published. Compare `version` with this one to spot a stale link. */
150
+ publication?: ArtifactPublication;
151
+ }
152
+ /**
153
+ * One artifact revision, as it is written to disk and as it crosses the sync
154
+ * feed.
155
+ *
156
+ * Everything needed to rebuild the artifact without the transcript. Flat
157
+ * rather than nested under an artifact object because the file is a log: each
158
+ * line stands alone, and an artifact is what you get by folding its lines
159
+ * together in order.
160
+ */
161
+ export interface StoredArtifactRevision {
162
+ /**
163
+ * Stable across devices, so the server dedupes and a retried push is free.
164
+ *
165
+ * These three — id, seq, device — are the same fields `mergeRecords` names
166
+ * as the ones that must survive the trip, and for the same reason: without
167
+ * them a merge cannot tell a record it already holds from a new one.
168
+ *
169
+ * Optional because a line written before revisions travelled has none, and
170
+ * those still have to load.
171
+ */
172
+ id?: string;
173
+ /** Lamport counter, shared with the session's messages so one watermark covers both. */
174
+ seq?: number;
175
+ device?: string;
176
+ artifact: string;
177
+ title: string;
178
+ mime: string;
179
+ language?: string;
180
+ version: number;
181
+ content: string;
182
+ at: number;
183
+ /** Absent for the model, "user" for a revision a person made by hand. */
184
+ author?: "user";
185
+ }
186
+ /** Reject a log line this build cannot make sense of, rather than half-read it. */
187
+ export declare function asArtifactRevision(value: unknown): StoredArtifactRevision | undefined;
188
+ export declare function isValidArtifactId(id: string): boolean;
189
+ /** Refused rather than truncated: half a document renders as a broken one. */
190
+ export declare const MAX_ARTIFACT_BYTES: number;
191
+ export declare class ArtifactStore {
192
+ private readonly items;
193
+ /**
194
+ * Told about every revision this store accepts.
195
+ *
196
+ * A callback rather than a store reference, so this file keeps knowing
197
+ * nothing about disks, projects or sync — it holds artifacts, and whoever
198
+ * owns it decides what durability means. It is also what keeps the two
199
+ * writers symmetrical: a model's `put` and a person's `edit` are the same
200
+ * kind of event to anything downstream, which is the property that was
201
+ * missing when only one of them left a trace.
202
+ */
203
+ onRevision?: (revision: StoredArtifactRevision) => void;
204
+ private announce;
205
+ /**
206
+ * Record a revision, creating the artifact if this id is new.
207
+ *
208
+ * Returns the descriptor rather than the artifact so callers cannot hold a
209
+ * reference into the store and mutate a stored version in place.
210
+ */
211
+ put(input: {
212
+ id: string;
213
+ title: string;
214
+ mime: string;
215
+ content: string;
216
+ language?: string;
217
+ }): ArtifactDescriptor;
218
+ /**
219
+ * Record a revision a *person* wrote, in a frontend, to an artifact that
220
+ * already exists.
221
+ *
222
+ * Separate from `put` rather than a flag on it, because the two have
223
+ * different preconditions and different failure modes. `put` may create, and
224
+ * takes a title and a mime because the model is declaring what the thing is.
225
+ * An edit may only revise: there is no such thing as a person creating an
226
+ * artifact out of nothing here, and letting an edit invent one would give a
227
+ * frontend a way to conjure artifacts the transcript has no record of. It
228
+ * also leaves title and mime alone — the canvas editor changes content, and
229
+ * silently relabelling the artifact because a save round-tripped a field is
230
+ * not something anybody asked for.
231
+ *
232
+ * Returns undefined for an unknown id so the caller can answer 404 rather
233
+ * than distinguishing exception types; the size ceiling still throws,
234
+ * because that one is a rejected write and not a missing thing.
235
+ */
236
+ edit(id: string, content: string): ArtifactDescriptor | undefined;
237
+ /**
238
+ * Put back a revision that was read from disk or arrived over sync.
239
+ *
240
+ * Separate from `put` and `edit` because it is not a new event: the version
241
+ * number and the author were decided when it first happened, and inventing
242
+ * fresh ones here would renumber a history that other things already refer
243
+ * to. It also stays silent — announcing would write the log back to the log.
244
+ */
245
+ restore(revision: StoredArtifactRevision): void;
246
+ /** The latest revision, or a specific one. Undefined if either is unknown. */
247
+ get(id: string, version?: number): {
248
+ artifact: Artifact;
249
+ revision: ArtifactVersion;
250
+ } | undefined;
251
+ /** Every artifact at its latest revision, oldest first. */
252
+ list(): ArtifactDescriptor[];
253
+ /**
254
+ * Every revision this store holds, oldest first, in the shape it is written
255
+ * down in.
256
+ *
257
+ * Exists for the one-time seeding of a session whose artifacts were rebuilt
258
+ * by replaying its transcript: without it that session's log would start at
259
+ * whatever happened next, and the versions that came before would vanish the
260
+ * moment the log took precedence over the replay.
261
+ */
262
+ export(): StoredArtifactRevision[];
263
+ /** Record that this artifact now has a URL on the site. */
264
+ markPublished(id: string, publication: ArtifactPublication): ArtifactDescriptor | undefined;
265
+ /** Forget a publication after it has been withdrawn from the site. */
266
+ clearPublication(id: string): ArtifactDescriptor | undefined;
267
+ delete(id: string): boolean;
268
+ get size(): number;
269
+ }
270
+ /**
271
+ * Where the store hangs off the session.
272
+ *
273
+ * In `session.state` rather than a field on Session, for the same reason the
274
+ * todo list is: that map is already the session-scoped scratch space tools
275
+ * reach through `ctx.host.state`, and it is already copied into and out of
276
+ * subagents. A field would need both of those paths taught about it.
277
+ *
278
+ * Consequence worth stating plainly: this is memory, so artifacts live as long
279
+ * as the process. That matches the todo list and is the right default for a
280
+ * scratch surface — but it means a frontend must not treat an artifact as a
281
+ * durable deliverable. Anything that needs to outlive the session gets written
282
+ * to the working tree with `write`.
283
+ */
284
+ export declare const ARTIFACTS_KEY = "artifacts:store";
285
+ /**
286
+ * Rebuild a session's artifacts from its transcript.
287
+ *
288
+ * The store is memory, so resuming a conversation used to bring back every
289
+ * message and none of the things those messages made: the panel was empty, the
290
+ * cards were gone, and an artifact the user had been looking at ten minutes
291
+ * earlier had no way back. The content was never actually lost — an artifact's
292
+ * body is the argument of the `artifact_write` call that made it, and that is
293
+ * in the transcript like any other tool call. This replays those calls.
294
+ *
295
+ * Replaying in order is what restores the version history for free: the second
296
+ * call for an id becomes v2 exactly as it did the first time round.
297
+ *
298
+ * Calls whose result came back an error are skipped — they never made an
299
+ * artifact, and re-running them here would invent one that never existed.
300
+ *
301
+ * What this cannot bring back is a revision written by a person — a canvas
302
+ * edit is not a tool call and so leaves no trace in the transcript. A resumed
303
+ * session therefore shows the model's last version as the latest, and the
304
+ * edits made on top of it are gone. Stated here rather than fixed, because
305
+ * fixing it means deciding where a human-authored revision is durably stored,
306
+ * and every cheap answer (a synthetic tool call, a user message carrying the
307
+ * body) either lies about who acted or pays the artifact's full size in
308
+ * transcript tokens on every save.
309
+ */
310
+ export declare function rehydrateArtifacts(store: ArtifactStore, messages: readonly Message[]): number;
311
+ /**
312
+ * Rebuild a session's artifacts from what was written down, in order.
313
+ *
314
+ * Preferred over `rehydrateArtifacts` wherever a log exists, and the two must
315
+ * not both run: replay derives version numbers by counting writes, the log
316
+ * carries the numbers that actually happened, and applying one on top of the
317
+ * other would renumber the history and duplicate every revision.
318
+ *
319
+ * The transcript replay stays as the fallback, and has to: every session
320
+ * recorded before artifacts were written down has no log, and refusing to
321
+ * rebuild those would take away something that works today.
322
+ */
323
+ export declare function restoreArtifacts(store: ArtifactStore, revisions: readonly StoredArtifactRevision[]): number;
324
+ export declare function getArtifactStore(state: Map<string, unknown>): ArtifactStore;