@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.
- package/dist/agent/agent.d.ts +196 -0
- package/dist/agent/agent.js +758 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/compaction.d.ts +68 -0
- package/dist/agent/compaction.js +179 -0
- package/dist/agent/compaction.js.map +1 -0
- package/dist/agent/hooks.d.ts +77 -0
- package/dist/agent/hooks.js +152 -0
- package/dist/agent/hooks.js.map +1 -0
- package/dist/agent/memory.d.ts +45 -0
- package/dist/agent/memory.js +147 -0
- package/dist/agent/memory.js.map +1 -0
- package/dist/agent/overflow.d.ts +35 -0
- package/dist/agent/overflow.js +69 -0
- package/dist/agent/overflow.js.map +1 -0
- package/dist/agent/permissions.d.ts +181 -0
- package/dist/agent/permissions.js +289 -0
- package/dist/agent/permissions.js.map +1 -0
- package/dist/agent/prompt.d.ts +25 -0
- package/dist/agent/prompt.js +63 -0
- package/dist/agent/prompt.js.map +1 -0
- package/dist/agent/session.d.ts +108 -0
- package/dist/agent/session.js +231 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/settings.d.ts +37 -0
- package/dist/agent/settings.js +113 -0
- package/dist/agent/settings.js.map +1 -0
- package/dist/agent/skills.d.ts +58 -0
- package/dist/agent/skills.js +225 -0
- package/dist/agent/skills.js.map +1 -0
- package/dist/agent/store.d.ts +308 -0
- package/dist/agent/store.js +596 -0
- package/dist/agent/store.js.map +1 -0
- package/dist/agent/subagent.d.ts +44 -0
- package/dist/agent/subagent.js +138 -0
- package/dist/agent/subagent.js.map +1 -0
- package/dist/agent/titles.d.ts +8 -0
- package/dist/agent/titles.js +23 -0
- package/dist/agent/titles.js.map +1 -0
- package/dist/agent/workspace.d.ts +60 -0
- package/dist/agent/workspace.js +156 -0
- package/dist/agent/workspace.js.map +1 -0
- package/dist/artifacts/publish.d.ts +94 -0
- package/dist/artifacts/publish.js +104 -0
- package/dist/artifacts/publish.js.map +1 -0
- package/dist/artifacts/store.d.ts +324 -0
- package/dist/artifacts/store.js +500 -0
- package/dist/artifacts/store.js.map +1 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/manager.d.ts +83 -0
- package/dist/auth/manager.js +266 -0
- package/dist/auth/manager.js.map +1 -0
- package/dist/auth/oauth.d.ts +83 -0
- package/dist/auth/oauth.js +327 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/providers/account.d.ts +59 -0
- package/dist/auth/providers/account.js +282 -0
- package/dist/auth/providers/account.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +24 -0
- package/dist/auth/providers/anthropic.js +209 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/generic.d.ts +57 -0
- package/dist/auth/providers/generic.js +155 -0
- package/dist/auth/providers/generic.js.map +1 -0
- package/dist/auth/providers/official.d.ts +3 -0
- package/dist/auth/providers/official.js +90 -0
- package/dist/auth/providers/official.js.map +1 -0
- package/dist/auth/providers/ottoport.d.ts +3 -0
- package/dist/auth/providers/ottoport.js +60 -0
- package/dist/auth/providers/ottoport.js.map +1 -0
- package/dist/auth/store.d.ts +22 -0
- package/dist/auth/store.js +138 -0
- package/dist/auth/store.js.map +1 -0
- package/dist/auth/types.d.ts +167 -0
- package/dist/auth/types.js +16 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/config.d.ts +197 -0
- package/dist/config.js +195 -0
- package/dist/config.js.map +1 -0
- package/dist/core/errors.d.ts +46 -0
- package/dist/core/errors.js +83 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/tokens.d.ts +12 -0
- package/dist/core/tokens.js +56 -0
- package/dist/core/tokens.js.map +1 -0
- package/dist/core/types.d.ts +91 -0
- package/dist/core/types.js +49 -0
- package/dist/core/types.js.map +1 -0
- package/dist/harness.d.ts +302 -0
- package/dist/harness.js +695 -0
- package/dist/harness.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/client.d.ts +55 -0
- package/dist/mcp/client.js +199 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +77 -0
- package/dist/mcp/manager.js +325 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/oauth.d.ts +63 -0
- package/dist/mcp/oauth.js +302 -0
- package/dist/mcp/oauth.js.map +1 -0
- package/dist/mcp/protocol.d.ts +130 -0
- package/dist/mcp/protocol.js +14 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/registry.d.ts +52 -0
- package/dist/mcp/registry.js +100 -0
- package/dist/mcp/registry.js.map +1 -0
- package/dist/mcp/registry.json +293 -0
- package/dist/mcp/secrets.d.ts +20 -0
- package/dist/mcp/secrets.js +75 -0
- package/dist/mcp/secrets.js.map +1 -0
- package/dist/mcp/transport.d.ts +51 -0
- package/dist/mcp/transport.js +158 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/paths.d.ts +37 -0
- package/dist/paths.js +63 -0
- package/dist/paths.js.map +1 -0
- package/dist/plugins.d.ts +55 -0
- package/dist/plugins.js +201 -0
- package/dist/plugins.js.map +1 -0
- package/dist/providers/builtin.d.ts +23 -0
- package/dist/providers/builtin.js +141 -0
- package/dist/providers/builtin.js.map +1 -0
- package/dist/providers/catalog.d.ts +129 -0
- package/dist/providers/catalog.js +254 -0
- package/dist/providers/catalog.js.map +1 -0
- package/dist/providers/catalog.json +472 -0
- package/dist/providers/discovery.d.ts +16 -0
- package/dist/providers/discovery.js +161 -0
- package/dist/providers/discovery.js.map +1 -0
- package/dist/providers/http.d.ts +24 -0
- package/dist/providers/http.js +139 -0
- package/dist/providers/http.js.map +1 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/index.js +8 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/piai.d.ts +124 -0
- package/dist/providers/piai.js +551 -0
- package/dist/providers/piai.js.map +1 -0
- package/dist/providers/registry.d.ts +65 -0
- package/dist/providers/registry.js +195 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/resilient.d.ts +46 -0
- package/dist/providers/resilient.js +117 -0
- package/dist/providers/resilient.js.map +1 -0
- package/dist/providers/types.d.ts +182 -0
- package/dist/providers/types.js +50 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/schedule/cron.d.ts +35 -0
- package/dist/schedule/cron.js +125 -0
- package/dist/schedule/cron.js.map +1 -0
- package/dist/schedule/scheduler.d.ts +87 -0
- package/dist/schedule/scheduler.js +237 -0
- package/dist/schedule/scheduler.js.map +1 -0
- package/dist/storage/kv.d.ts +56 -0
- package/dist/storage/kv.js +173 -0
- package/dist/storage/kv.js.map +1 -0
- package/dist/storage/migrate.d.ts +11 -0
- package/dist/storage/migrate.js +93 -0
- package/dist/storage/migrate.js.map +1 -0
- package/dist/storage/project.d.ts +9 -0
- package/dist/storage/project.js +57 -0
- package/dist/storage/project.js.map +1 -0
- package/dist/storage/records.d.ts +32 -0
- package/dist/storage/records.js +48 -0
- package/dist/storage/records.js.map +1 -0
- package/dist/sync/client.d.ts +79 -0
- package/dist/sync/client.js +118 -0
- package/dist/sync/client.js.map +1 -0
- package/dist/sync/mirror.d.ts +85 -0
- package/dist/sync/mirror.js +389 -0
- package/dist/sync/mirror.js.map +1 -0
- package/dist/sync/protocol.d.ts +67 -0
- package/dist/sync/protocol.js +16 -0
- package/dist/sync/protocol.js.map +1 -0
- package/dist/sync/settings.d.ts +56 -0
- package/dist/sync/settings.js +60 -0
- package/dist/sync/settings.js.map +1 -0
- package/dist/tools/builtin/artifact.d.ts +16 -0
- package/dist/tools/builtin/artifact.js +134 -0
- package/dist/tools/builtin/artifact.js.map +1 -0
- package/dist/tools/builtin/bash.d.ts +3 -0
- package/dist/tools/builtin/bash.js +142 -0
- package/dist/tools/builtin/bash.js.map +1 -0
- package/dist/tools/builtin/fs.d.ts +19 -0
- package/dist/tools/builtin/fs.js +280 -0
- package/dist/tools/builtin/fs.js.map +1 -0
- package/dist/tools/builtin/index.d.ts +22 -0
- package/dist/tools/builtin/index.js +42 -0
- package/dist/tools/builtin/index.js.map +1 -0
- package/dist/tools/builtin/mcp-resource.d.ts +3 -0
- package/dist/tools/builtin/mcp-resource.js +220 -0
- package/dist/tools/builtin/mcp-resource.js.map +1 -0
- package/dist/tools/builtin/memory.d.ts +10 -0
- package/dist/tools/builtin/memory.js +76 -0
- package/dist/tools/builtin/memory.js.map +1 -0
- package/dist/tools/builtin/recall.d.ts +13 -0
- package/dist/tools/builtin/recall.js +163 -0
- package/dist/tools/builtin/recall.js.map +1 -0
- package/dist/tools/builtin/search.d.ts +3 -0
- package/dist/tools/builtin/search.js +240 -0
- package/dist/tools/builtin/search.js.map +1 -0
- package/dist/tools/builtin/skill.d.ts +10 -0
- package/dist/tools/builtin/skill.js +46 -0
- package/dist/tools/builtin/skill.js.map +1 -0
- package/dist/tools/builtin/task.d.ts +9 -0
- package/dist/tools/builtin/task.js +68 -0
- package/dist/tools/builtin/task.js.map +1 -0
- package/dist/tools/builtin/todo.d.ts +20 -0
- package/dist/tools/builtin/todo.js +63 -0
- package/dist/tools/builtin/todo.js.map +1 -0
- package/dist/tools/define.d.ts +19 -0
- package/dist/tools/define.js +39 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +39 -0
- package/dist/tools/registry.js +101 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/types.d.ts +112 -0
- package/dist/tools/types.js +22 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/util/id.d.ts +9 -0
- package/dist/util/id.js +19 -0
- package/dist/util/id.js.map +1 -0
- package/dist/util/json.d.ts +25 -0
- package/dist/util/json.js +100 -0
- package/dist/util/json.js.map +1 -0
- package/dist/util/jwt.d.ts +74 -0
- package/dist/util/jwt.js +177 -0
- package/dist/util/jwt.js.map +1 -0
- package/dist/util/logger.d.ts +13 -0
- package/dist/util/logger.js +59 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/queue.d.ts +26 -0
- package/dist/util/queue.js +106 -0
- package/dist/util/queue.js.map +1 -0
- package/dist/util/schema.d.ts +17 -0
- package/dist/util/schema.js +98 -0
- package/dist/util/schema.js.map +1 -0
- package/dist/util/shell.d.ts +20 -0
- package/dist/util/shell.js +24 -0
- package/dist/util/shell.js.map +1 -0
- package/official.json +4 -0
- package/package.json +38 -0
- package/skills/artifact-authoring/SKILL.md +81 -0
- package/skills/canvas/SKILL.md +85 -0
- 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;
|