driverkit 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTROLS.md +578 -0
- package/REACT.md +477 -0
- package/README.md +104 -2
- package/dist/agent/backend.d.ts +69 -0
- package/dist/agent/backend.d.ts.map +1 -0
- package/dist/agent/backend.js +130 -0
- package/dist/agent/backend.js.map +1 -0
- package/dist/agent/control.d.ts +148 -0
- package/dist/agent/control.d.ts.map +1 -0
- package/dist/agent/control.js +342 -0
- package/dist/agent/control.js.map +1 -0
- package/dist/agent/index.d.ts +9 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +6 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/loop.d.ts +136 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +824 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/render.d.ts +173 -0
- package/dist/agent/render.d.ts.map +1 -0
- package/dist/agent/render.js +425 -0
- package/dist/agent/render.js.map +1 -0
- package/dist/agent/tools.d.ts +138 -0
- package/dist/agent/tools.d.ts.map +1 -0
- package/dist/agent/tools.js +622 -0
- package/dist/agent/tools.js.map +1 -0
- package/dist/agent/types.d.ts +566 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +32 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/browser/budget.d.ts +92 -0
- package/dist/browser/budget.d.ts.map +1 -0
- package/dist/browser/budget.js +151 -0
- package/dist/browser/budget.js.map +1 -0
- package/dist/browser/connect.d.ts +368 -0
- package/dist/browser/connect.d.ts.map +1 -0
- package/dist/browser/connect.js +1038 -0
- package/dist/browser/connect.js.map +1 -0
- package/dist/browser/elsewhere.d.ts +89 -0
- package/dist/browser/elsewhere.d.ts.map +1 -0
- package/dist/browser/elsewhere.js +91 -0
- package/dist/browser/elsewhere.js.map +1 -0
- package/dist/browser/frames.d.ts +85 -0
- package/dist/browser/frames.d.ts.map +1 -0
- package/dist/browser/frames.js +11 -0
- package/dist/browser/frames.js.map +1 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/check/check.d.ts +171 -0
- package/dist/check/check.d.ts.map +1 -0
- package/dist/check/check.js +666 -0
- package/dist/check/check.js.map +1 -0
- package/dist/check/index.d.ts +3 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +2 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/types.d.ts +149 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +29 -0
- package/dist/check/types.js.map +1 -0
- package/dist/controls/controls.d.ts +198 -0
- package/dist/controls/controls.d.ts.map +1 -0
- package/dist/controls/controls.js +742 -0
- package/dist/controls/controls.js.map +1 -0
- package/dist/controls/dom.d.ts +108 -0
- package/dist/controls/dom.d.ts.map +1 -0
- package/dist/controls/dom.js +56 -0
- package/dist/controls/dom.js.map +1 -0
- package/dist/controls/index.d.ts +26 -0
- package/dist/controls/index.d.ts.map +1 -0
- package/dist/controls/index.js +23 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/controls/rows.d.ts +66 -0
- package/dist/controls/rows.d.ts.map +1 -0
- package/dist/controls/rows.js +127 -0
- package/dist/controls/rows.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +15 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +192 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +2799 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/types.d.ts +2468 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +19 -0
- package/dist/core/types.js.map +1 -0
- package/dist/otel/index.d.ts +122 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/index.js +157 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/react/index.d.ts +191 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +547 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/runtime.d.ts +95 -0
- package/dist/react/runtime.d.ts.map +1 -0
- package/dist/react/runtime.js +54 -0
- package/dist/react/runtime.js.map +1 -0
- package/dist/react/store.d.ts +333 -0
- package/dist/react/store.d.ts.map +1 -0
- package/dist/react/store.js +695 -0
- package/dist/react/store.js.map +1 -0
- package/dist/relay/auth.d.ts +244 -0
- package/dist/relay/auth.d.ts.map +1 -0
- package/dist/relay/auth.js +391 -0
- package/dist/relay/auth.js.map +1 -0
- package/dist/relay/frames.d.ts +141 -0
- package/dist/relay/frames.d.ts.map +1 -0
- package/dist/relay/frames.js +20 -0
- package/dist/relay/frames.js.map +1 -0
- package/dist/relay/index.d.ts +8 -0
- package/dist/relay/index.d.ts.map +1 -0
- package/dist/relay/index.js +4 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/relay/relay.d.ts +277 -0
- package/dist/relay/relay.d.ts.map +1 -0
- package/dist/relay/relay.js +1026 -0
- package/dist/relay/relay.js.map +1 -0
- package/dist/relay/serve.d.ts +33 -0
- package/dist/relay/serve.d.ts.map +1 -0
- package/dist/relay/serve.js +86 -0
- package/dist/relay/serve.js.map +1 -0
- package/dist/widget/chat.d.ts +290 -0
- package/dist/widget/chat.d.ts.map +1 -0
- package/dist/widget/chat.js +486 -0
- package/dist/widget/chat.js.map +1 -0
- package/dist/widget/css.d.ts +49 -0
- package/dist/widget/css.d.ts.map +1 -0
- package/dist/widget/css.js +532 -0
- package/dist/widget/css.js.map +1 -0
- package/dist/widget/dom.d.ts +143 -0
- package/dist/widget/dom.d.ts.map +1 -0
- package/dist/widget/dom.js +27 -0
- package/dist/widget/dom.js.map +1 -0
- package/dist/widget/highlight.d.ts +64 -0
- package/dist/widget/highlight.d.ts.map +1 -0
- package/dist/widget/highlight.js +136 -0
- package/dist/widget/highlight.js.map +1 -0
- package/dist/widget/index.d.ts +9 -0
- package/dist/widget/index.d.ts.map +1 -0
- package/dist/widget/index.js +20 -0
- package/dist/widget/index.js.map +1 -0
- package/dist/widget/position.d.ts +166 -0
- package/dist/widget/position.d.ts.map +1 -0
- package/dist/widget/position.js +497 -0
- package/dist/widget/position.js.map +1 -0
- package/dist/widget/settings.d.ts +116 -0
- package/dist/widget/settings.d.ts.map +1 -0
- package/dist/widget/settings.js +117 -0
- package/dist/widget/settings.js.map +1 -0
- package/dist/widget/widget.d.ts +442 -0
- package/dist/widget/widget.d.ts.map +1 -0
- package/dist/widget/widget.js +2005 -0
- package/dist/widget/widget.js.map +1 -0
- package/package.json +144 -4
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surviving a page reload: restore everything, resume nothing.
|
|
3
|
+
*
|
|
4
|
+
* Today a reload destroys the drive loop, the transcript, and everything the
|
|
5
|
+
* agent knows. Settings and the panel's position are remembered — see
|
|
6
|
+
* `settings.ts` and `position.ts` — and the conversation, which is the only
|
|
7
|
+
* thing in the panel anybody would miss, was not.
|
|
8
|
+
*
|
|
9
|
+
* **THE RULE, AND WHY IT IS NOT "RESUME WHERE WE LEFT OFF".** A page can die
|
|
10
|
+
* mid-commit. Five steps in, `accept-selected` in flight on 3,412 rows, the tab
|
|
11
|
+
* reloads. Storage can record that the call was STARTED. It cannot record
|
|
12
|
+
* whether it LANDED — that answer is on the server, and the page that was
|
|
13
|
+
* waiting for it is gone. A run that auto-resumed would either repeat a commit
|
|
14
|
+
* that already happened or skip one that did not, and those two are precisely
|
|
15
|
+
* what the plan token was built to prevent. So on return the transcript is
|
|
16
|
+
* there, and the panel says plainly that a call was in flight and may or may
|
|
17
|
+
* not have landed, naming the verb, before anything else happens.
|
|
18
|
+
*
|
|
19
|
+
* **WHAT IS PERSISTED: THE MODEL TURNS, AND THE RENDERED LINES ARE REBUILT FROM
|
|
20
|
+
* THEM.** Those were the two candidates and only one of them is a conversation.
|
|
21
|
+
* Persisting the rendered lines is cheaper and gives the person their history
|
|
22
|
+
* back — and leaves the model with amnesia, so the panel reads "I accepted
|
|
23
|
+
* 1,000 contacts" above an input box where "undo that" is unanswerable. That is
|
|
24
|
+
* a worse lie than an empty panel, because it looks like it worked. Persisting
|
|
25
|
+
* the turns gives both: the conversation continues coherently AND a readable
|
|
26
|
+
* transcript can be drawn from it, out of one source of truth. Two stored
|
|
27
|
+
* copies of one conversation is two things that come to disagree, which is the
|
|
28
|
+
* same argument the core makes for building an `AuditEvent` off the `Result`
|
|
29
|
+
* rather than from a second look at the app.
|
|
30
|
+
*
|
|
31
|
+
* Note what "resume nothing" does and does not mean. The run does not restart:
|
|
32
|
+
* no step is retried, no verb is called, nothing happens until the person types
|
|
33
|
+
* something. The CONVERSATION is continuous, which is the point of keeping it.
|
|
34
|
+
*
|
|
35
|
+
* **WHERE IT GOES: `sessionStorage`, NOT `localStorage`, AND THE SCOPE IS THE
|
|
36
|
+
* PRIVACY ANSWER AS WELL AS THE CORRECTNESS ONE.** A transcript holds the
|
|
37
|
+
* person's instructions and the model's prose about their records. That is a
|
|
38
|
+
* different privacy class from a remembered pane position, on a machine that
|
|
39
|
+
* may be shared, and `localStorage` would keep it until somebody cleared site
|
|
40
|
+
* data. `sessionStorage` is per TAB, survives a reload, and is discarded when
|
|
41
|
+
* the tab closes — so the conversation lives exactly as long as the sitting it
|
|
42
|
+
* was had in. It also settles scoping for free, which `localStorage` could not:
|
|
43
|
+
* two tabs of one app are two conversations and must not stomp each other, and
|
|
44
|
+
* a per-tab key in `localStorage` would need a tab id and would leave a key
|
|
45
|
+
* behind for every tab ever opened, which nothing can sweep up because
|
|
46
|
+
* `StorageLike` cannot enumerate. Per tab, dying with the tab, no garbage. The
|
|
47
|
+
* budget goes the other way for the opposite reason; see `budget.ts`.
|
|
48
|
+
*
|
|
49
|
+
* **AND IT IS OPT-IN.** `WidgetOptions.rememberChat` defaults off. A library
|
|
50
|
+
* must not start writing its users' business prose to disk because somebody
|
|
51
|
+
* upgraded, and "an app that opts into nothing behaves identically" is a rule
|
|
52
|
+
* this is not worth breaking. Once an app has opted in, the VIEWER's switch —
|
|
53
|
+
* `Settings.rememberChat`, beside the others — defaults on and turning it off
|
|
54
|
+
* forgets what is already stored. The app's `false` wins: an app handling
|
|
55
|
+
* records that must not be written down can say so, and no viewer can undo it.
|
|
56
|
+
*/
|
|
57
|
+
import type { Manifest } from "../core/index.ts";
|
|
58
|
+
import type { Turn } from "../agent/types.ts";
|
|
59
|
+
import type { StorageLike } from "./dom.ts";
|
|
60
|
+
/**
|
|
61
|
+
* The schema version, written into every record and checked on the way back.
|
|
62
|
+
*
|
|
63
|
+
* A stored conversation from an older widget is the normal case and not the
|
|
64
|
+
* exceptional one — somebody has a tab open from before the deploy — and
|
|
65
|
+
* `settings.ts` folds field by field for exactly that reason. A transcript
|
|
66
|
+
* cannot be folded that way: a half-understood `Turn[]` handed to a model is a
|
|
67
|
+
* 400 from the provider, not a default pace. So the version is a gate, and a
|
|
68
|
+
* record that is not this version is dropped whole.
|
|
69
|
+
*/
|
|
70
|
+
export declare const CHAT_VERSION = 1;
|
|
71
|
+
/**
|
|
72
|
+
* What the panel was doing when the page went away.
|
|
73
|
+
*
|
|
74
|
+
* `asked` and `sent` are the two states the restored panel must never confuse,
|
|
75
|
+
* and they are different KINDS of fact, not degrees of one:
|
|
76
|
+
*
|
|
77
|
+
* `asked` — a question was on screen and nobody had answered it. The core
|
|
78
|
+
* asks before it runs, so this one is KNOWABLE: the verb did not
|
|
79
|
+
* run and nothing moved. The panel can say so flatly.
|
|
80
|
+
* `sent` — the call was past every gate and in flight. This one is NOT
|
|
81
|
+
* knowable from here, ever, and no amount of care in this file
|
|
82
|
+
* changes that. The answer was on the server.
|
|
83
|
+
*
|
|
84
|
+
* `verb` is the verb's name. Not its arguments: a name is a word out of the
|
|
85
|
+
* app's own manifest and an argument is the person's data, and this record is
|
|
86
|
+
* being written to disk for a sentence in a notice.
|
|
87
|
+
*/
|
|
88
|
+
export interface ChatInFlight {
|
|
89
|
+
verb: string;
|
|
90
|
+
phase: "asked" | "sent";
|
|
91
|
+
}
|
|
92
|
+
/** One stored conversation. */
|
|
93
|
+
export interface SavedChat {
|
|
94
|
+
v: number;
|
|
95
|
+
/** `MountOptions.app`, so a record found under a key this build no longer
|
|
96
|
+
* writes cannot be shown in the wrong app's panel. */
|
|
97
|
+
app: string;
|
|
98
|
+
/** `Date.now()` at the write, for the notice and for anybody debugging. */
|
|
99
|
+
at: number;
|
|
100
|
+
/** The conversation, scrubbed and trimmed. See `scrubTurns`. */
|
|
101
|
+
messages: Turn[];
|
|
102
|
+
/** Whether anything had been asked. Drives the launcher's dot, which is a
|
|
103
|
+
* different question from "is there a transcript". */
|
|
104
|
+
conversed: boolean;
|
|
105
|
+
/** What was in flight, when something was. See `ChatInFlight`. */
|
|
106
|
+
inFlight?: ChatInFlight;
|
|
107
|
+
/** How many leading turns `trimTurns` dropped for size. Present only when it
|
|
108
|
+
* dropped some, because the notice has to say so: a transcript that is
|
|
109
|
+
* quietly missing its beginning is one the person will read as complete. */
|
|
110
|
+
trimmed?: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* How much stored conversation is enough.
|
|
114
|
+
*
|
|
115
|
+
* `sessionStorage` is about 5MB per origin and `setItem` THROWS on quota — and
|
|
116
|
+
* the quota is shared with the app this panel is embedded in, which is the part
|
|
117
|
+
* that makes a generous limit irresponsible rather than merely wasteful. A long
|
|
118
|
+
* run must not break the app it is a guest in.
|
|
119
|
+
*
|
|
120
|
+
* 128KB is roughly a hundred steps of a pruned conversation, because
|
|
121
|
+
* `pruneScreens` has already removed every screen but the newest: what is left
|
|
122
|
+
* is an outcome line per call and the person's own words. It is a fortieth of
|
|
123
|
+
* the origin's quota, so the panel cannot be the reason an app's own storage
|
|
124
|
+
* write fails.
|
|
125
|
+
*/
|
|
126
|
+
export declare const CHAT_LIMIT_CHARS: number;
|
|
127
|
+
export declare function chatKey(app: string): string;
|
|
128
|
+
/** `sessionStorage`, if reaching for it does not throw — which it does when
|
|
129
|
+
* site data is blocked, before any read has been attempted. The twin of
|
|
130
|
+
* `defaultStorage()` in `position.ts`, pointing at the per-tab one. */
|
|
131
|
+
export declare function defaultSession(): StorageLike | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Replace the value of every argument the app declared `sensitive`.
|
|
134
|
+
*
|
|
135
|
+
* **This is the leak `ArgSpec.sensitive` was built to stop, in the one new
|
|
136
|
+
* place it could reappear.** That field exists so a value never crosses the
|
|
137
|
+
* `onAudit` boundary — "the boundary a record is most likely to leave the box
|
|
138
|
+
* across" — and the core replaces it before the hook rather than asking the
|
|
139
|
+
* host to. Persisting the raw model turns would write the same value to disk,
|
|
140
|
+
* where it outlives the call, the run and the page, and it would do it under a
|
|
141
|
+
* feature nobody would think to check. An app that declared an argument too
|
|
142
|
+
* secret for its own logger did not thereby agree to have it in storage.
|
|
143
|
+
*
|
|
144
|
+
* Done HERE, at the one boundary, and not at the call sites that build turns —
|
|
145
|
+
* which is the repo's standing rule about scrubbing and the reason this takes a
|
|
146
|
+
* whole conversation rather than one argument. Every byte that reaches storage
|
|
147
|
+
* goes through this function; there is nowhere else to forget it.
|
|
148
|
+
*
|
|
149
|
+
* `REDACTED` is the core's own marker, reused rather than reinvented, so a
|
|
150
|
+
* restored turn says the same word an audit record says and neither can be
|
|
151
|
+
* mistaken for a string the agent actually sent.
|
|
152
|
+
*
|
|
153
|
+
* **The consequence, stated rather than hidden:** a restored conversation hands
|
|
154
|
+
* the model `[redacted]` where its own earlier argument was. That is correct —
|
|
155
|
+
* the alternative is the leak — and it is honest, because the turn then says
|
|
156
|
+
* out loud that the value is not being shown. A model that needs the value
|
|
157
|
+
* again asks for it again, which is what should happen to a secret after a
|
|
158
|
+
* reload.
|
|
159
|
+
*/
|
|
160
|
+
export declare function scrubTurns(turns: Turn[], manifest: Manifest): Turn[];
|
|
161
|
+
/**
|
|
162
|
+
* Drop leading turns until the rest fits, cutting only at a safe seam.
|
|
163
|
+
*
|
|
164
|
+
* **The seam is the whole of this function and the reason it is not a `slice`.**
|
|
165
|
+
* Every tool-use API rejects a conversation in which a `tool_use` block has no
|
|
166
|
+
* matching result — `abandoned` in `loop.ts` exists for that one fact, and says
|
|
167
|
+
* what it costs: "one missing tool turn is a dead panel", forever, with nothing
|
|
168
|
+
* on screen to explain it. So trimming must never leave a tool turn whose
|
|
169
|
+
* assistant turn is gone, nor an assistant turn whose results are gone.
|
|
170
|
+
*
|
|
171
|
+
* A `user` turn is the only index where that is provable without reasoning
|
|
172
|
+
* about pairs: the loop answers every call of an assistant turn before it asks
|
|
173
|
+
* the model again, and a person speaks between runs. So the remainder is cut to
|
|
174
|
+
* begin at a user turn, and if no user boundary is small enough, NOTHING is
|
|
175
|
+
* stored and the caller says so. Storing a conversation that cannot be used is
|
|
176
|
+
* worse than storing none: the first breaks the panel permanently and the
|
|
177
|
+
* second loses a transcript.
|
|
178
|
+
*
|
|
179
|
+
* Returns the number dropped so the notice can admit it. A transcript quietly
|
|
180
|
+
* missing its beginning is one somebody will read as complete.
|
|
181
|
+
*/
|
|
182
|
+
export declare function trimTurns(turns: Turn[], limitChars?: number): {
|
|
183
|
+
messages: Turn[];
|
|
184
|
+
trimmed: number;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Answer every tool call left dangling, so the restored history is usable.
|
|
188
|
+
*
|
|
189
|
+
* **This is the correctness bug a reload creates and the single most
|
|
190
|
+
* load-bearing function in the file.** A page that dies mid-call leaves an
|
|
191
|
+
* assistant turn whose `tool_use` has no result. Handed back as `history` that
|
|
192
|
+
* is a 400 from the provider on the person's very next message, and on every
|
|
193
|
+
* message after it, with an apparently fine transcript on screen. The panel
|
|
194
|
+
* would come back looking restored and be permanently broken.
|
|
195
|
+
*
|
|
196
|
+
* So each dangling call gets an answer, and the answer is written for the model
|
|
197
|
+
* rather than for the protocol — the same judgement `abandoned` makes. What it
|
|
198
|
+
* must never say is anything that reads as a step to retry, and what it must
|
|
199
|
+
* never do is guess:
|
|
200
|
+
*
|
|
201
|
+
* `sent` — the outcome is UNKNOWN. This is the sentence the whole feature
|
|
202
|
+
* turns on, and it is deliberately the wording `render.py` uses for
|
|
203
|
+
* a relay `timeout`, because it is the same fact: the call was
|
|
204
|
+
* accepted, nobody heard back, and a commit may already have run.
|
|
205
|
+
* The natural reflex — treat a non-answer as a failure and retry
|
|
206
|
+
* it — is the one move that turns one bulk accept into two.
|
|
207
|
+
* `asked` — KNOWN not to have run, because the core asks before it runs.
|
|
208
|
+
* Said flatly, because an agent told "unknown" about a commit that
|
|
209
|
+
* provably did not happen will go and check for nothing, and may
|
|
210
|
+
* decide not to do the thing the person asked for.
|
|
211
|
+
*
|
|
212
|
+
* Only the call the record named gets the `asked` wording. Any other dangling
|
|
213
|
+
* call is unknown, which is the safe direction and also the true one.
|
|
214
|
+
*/
|
|
215
|
+
export declare function closeDangling(turns: Turn[], inFlight?: ChatInFlight): Turn[];
|
|
216
|
+
/**
|
|
217
|
+
* What the panel says, in order, when a conversation comes back.
|
|
218
|
+
*
|
|
219
|
+
* Returned as lines rather than printed, so the words are testable without a
|
|
220
|
+
* DOM and so there is one place they are written. The first line is always
|
|
221
|
+
* about what may have happened to the data, because that is the thing a person
|
|
222
|
+
* has to act on and everything else can wait behind it.
|
|
223
|
+
*
|
|
224
|
+
* The verb is NAMED. "A call was in flight" sends somebody to look at the whole
|
|
225
|
+
* app; "`accept-selected` was in flight" sends them to one screen.
|
|
226
|
+
*/
|
|
227
|
+
export declare function restoredLines(record: SavedChat): string[];
|
|
228
|
+
/**
|
|
229
|
+
* One readable line per stored turn, for redrawing the transcript.
|
|
230
|
+
*
|
|
231
|
+
* Deliberately not a reconstruction of what the panel looked like. A tool turn
|
|
232
|
+
* was a row in the step list with a state marker and a `title`; what comes back
|
|
233
|
+
* is a plain line of text, because the step list is a live thing — it glows, it
|
|
234
|
+
* marks a call as pending, it is about a run that is happening — and redrawing
|
|
235
|
+
* it for a run that ended at a reload would be a panel claiming to be mid-step.
|
|
236
|
+
* A restored transcript should read as a record, which is what it is.
|
|
237
|
+
*
|
|
238
|
+
* The screen blocks are dropped from what is DISPLAYED. They are still in the
|
|
239
|
+
* stored turns, where the model needs the newest one; a wall of table on reload
|
|
240
|
+
* is not what the person wants to see first.
|
|
241
|
+
*/
|
|
242
|
+
export declare function replayLines(record: SavedChat): Array<{
|
|
243
|
+
className: string;
|
|
244
|
+
text: string;
|
|
245
|
+
}>;
|
|
246
|
+
/**
|
|
247
|
+
* Read a stored conversation back, or null for every way that can fail.
|
|
248
|
+
*
|
|
249
|
+
* Validated field by field, and a failure is a `null` rather than a repair.
|
|
250
|
+
* `settings.ts` folds a partial record over the defaults because a missing pace
|
|
251
|
+
* is a readable record with a gap in it; a `Turn[]` with a gap in it is a
|
|
252
|
+
* provider error on the person's next message. The two kinds of persisted state
|
|
253
|
+
* want opposite treatment and this is the strict one.
|
|
254
|
+
*
|
|
255
|
+
* Every read is inside one try, like `loadJson`: a private window and blocked
|
|
256
|
+
* site data throw on the way IN, before any value has been looked at.
|
|
257
|
+
*/
|
|
258
|
+
export declare function loadChat(session: StorageLike | undefined, app: string): SavedChat | null;
|
|
259
|
+
/**
|
|
260
|
+
* Write a conversation, and swallow every reason it can fail.
|
|
261
|
+
*
|
|
262
|
+
* Swallowed, unlike `budget.ts`, and the asymmetry is the point. A budget that
|
|
263
|
+
* cannot be written is an uncapped agent, so that one fails closed and stops
|
|
264
|
+
* the agent. A transcript that cannot be written is a conversation somebody
|
|
265
|
+
* will have to retype, which is not worth a thrown error — and a throw here
|
|
266
|
+
* would be thrown INSIDE a drive run, out of an `onResult` handler, where it
|
|
267
|
+
* would take down the run that is moving the person's screen. A storage write
|
|
268
|
+
* must never break a drive run. See `saveJson`, which makes the same promise
|
|
269
|
+
* for the panel's position and for the same reason.
|
|
270
|
+
*
|
|
271
|
+
* `trimmed: 0` is not written, so an ordinary record carries no field for it
|
|
272
|
+
* and `loadChat` reading its absence as "nothing was dropped" is the same
|
|
273
|
+
* sentence either way.
|
|
274
|
+
*/
|
|
275
|
+
export declare function saveChat(session: StorageLike | undefined, app: string, record: Omit<SavedChat, "v" | "app">): void;
|
|
276
|
+
/**
|
|
277
|
+
* Forget the stored conversation.
|
|
278
|
+
*
|
|
279
|
+
* Written empty rather than removed, because `StorageLike` is two methods and
|
|
280
|
+
* `removeItem` is not one of them — and `loadChat` reads an empty string as an
|
|
281
|
+
* empty slot, which is what a removal would leave anyway.
|
|
282
|
+
*
|
|
283
|
+
* Called by "Clear conversation", and that call is load-bearing rather than
|
|
284
|
+
* tidy. `era` in `widget.ts` exists so a dying run's writes cannot land in a
|
|
285
|
+
* fresh transcript after a clear; a stored record is the same hazard with a
|
|
286
|
+
* longer fuse — clear the panel, reload, and a cleared conversation comes back
|
|
287
|
+
* from disk. The destructive option has to be destructive all the way down.
|
|
288
|
+
*/
|
|
289
|
+
export declare function forgetChat(session: StorageLike | undefined, app: string): void;
|
|
290
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/widget/chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAY,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;AAED,+BAA+B;AAC/B,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV;2DACuD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