@lace-cloud/chat-core 0.17.0 → 0.19.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/README.md +354 -59
- package/dist/index.cjs +1948 -574
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +227 -248
- package/dist/index.d.ts +227 -248
- package/dist/index.mjs +1939 -564
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# @lace-cloud/chat-core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
What a host's chat calls Lace through: Lace's ranking of the closed
|
|
4
|
+
questions a canvas change asks, beside the reading of the developer's own
|
|
5
|
+
model in the host's chat. Lace publishes no chat of its own: the host has
|
|
6
|
+
a chat that can call tools (VS Code's native chat, a portal's own loop),
|
|
7
|
+
and this package gives it the contract a tool is written against, the
|
|
8
|
+
tool sets for a module's canvas, the composition of the two readings, and
|
|
9
|
+
the client that reports each decision to Lace. No model port, no loop and
|
|
10
|
+
no UI live here; a host adapts the tools to whatever its chat is and
|
|
11
|
+
supplies the ports.
|
|
6
12
|
|
|
7
|
-
**Zero `vscode` imports.**
|
|
8
|
-
|
|
9
|
-
`AgentController`.
|
|
13
|
+
**Zero `vscode` imports.** The adapter from this contract to an editor's
|
|
14
|
+
tool API lives with that editor.
|
|
10
15
|
|
|
11
16
|
## Install
|
|
12
17
|
|
|
@@ -14,68 +19,358 @@ implement the `ChatHostAdapter` interface and pass an instance into
|
|
|
14
19
|
npm install @lace-cloud/chat-core
|
|
15
20
|
```
|
|
16
21
|
|
|
17
|
-
##
|
|
22
|
+
## The contract
|
|
23
|
+
|
|
24
|
+
A tool is a schema and a handler. `ToolSchema` is
|
|
25
|
+
`{name, title, description, inputSchema}`: the name the model calls the
|
|
26
|
+
tool by, the short label a host shows a person, the description that
|
|
27
|
+
carries the tool's guidance to any host, and the JSON schema of its
|
|
28
|
+
input. `ToolHandler` is `(input) → Promise<ToolResult>`, with
|
|
29
|
+
`ToolResult` `{content, isError?}`; a tool whose result carries data for
|
|
30
|
+
its host beside the text states that result as the handler's type
|
|
31
|
+
parameter (`ToolHandler<R>`, `ToolRegistration<R>`). A `ToolRegistry`
|
|
32
|
+
holds the pairs; every host constructs its own with
|
|
33
|
+
`createToolRegistry()` and registers the tools its environment provides.
|
|
18
34
|
|
|
19
35
|
```ts
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
createToolRegistry,
|
|
23
|
-
ProactivityWatcher,
|
|
24
|
-
type ChatHostAdapter,
|
|
25
|
-
type WebviewTransport,
|
|
26
|
-
} from '@lace-cloud/chat-core';
|
|
27
|
-
|
|
28
|
-
// 1. Implement ChatHostAdapter for your IDE.
|
|
29
|
-
const adapter: ChatHostAdapter = {
|
|
30
|
-
selectModel: async (selector) => /* IDE's LM API */,
|
|
31
|
-
sendRequest: async (model, messages, tools, signal) => /* … */,
|
|
32
|
-
saveHistory: async (messages) => /* … */,
|
|
33
|
-
loadHistory: async () => /* … */,
|
|
34
|
-
getConfig: () => /* … */,
|
|
35
|
-
getWorkspaceName: () => /* … */,
|
|
36
|
-
log: (level, msg) => /* … */,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// 2. Implement WebviewTransport (postMessage shape).
|
|
40
|
-
const transport: WebviewTransport = {
|
|
41
|
-
postMessage: (msg) => webview.postMessage(msg),
|
|
42
|
-
onMessage: (handler) => webview.onDidReceiveMessage(handler),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// 3. Wire up the agentic loop.
|
|
36
|
+
import { createToolRegistry, type ToolSchema } from '@lace-cloud/chat-core';
|
|
37
|
+
|
|
46
38
|
const registry = createToolRegistry();
|
|
47
|
-
registry.register(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
transport,
|
|
52
|
-
toolRegistry: registry,
|
|
53
|
-
buildSystemPrompt: /* … */,
|
|
54
|
-
getCanvasFacts: () => ({ nodeCount, diagnosticCount }),
|
|
55
|
-
historyKey: 'lace.chatHistory',
|
|
56
|
-
});
|
|
57
|
-
await agent.init();
|
|
39
|
+
registry.register(schema, handler);
|
|
40
|
+
|
|
41
|
+
registry.listSchemas(); // what the host hands its model
|
|
42
|
+
registry.getHandler(name); // what the host runs when the model calls one
|
|
58
43
|
```
|
|
59
44
|
|
|
60
|
-
##
|
|
45
|
+
## The ports a host fills
|
|
61
46
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
Capability is a port's presence. The surface's ports are the canvas's own
|
|
48
|
+
(`@lace-cloud/canvas/engine`); `openEngineSession` and
|
|
49
|
+
`openEngineCommands` there hand them out. The one port of this package's
|
|
50
|
+
own is `Transport`: one POST to Lace's API under `/api/v1/candidates/*`,
|
|
51
|
+
with the developer's credential attached by the host per request. The
|
|
52
|
+
package never sees a credential. A host with none supplies no `Transport`,
|
|
53
|
+
and the tools then compose the model's reading alone and report nothing.
|
|
66
54
|
|
|
67
55
|
```ts
|
|
68
|
-
import {
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
import { canvasTools, createToolRegistry, moduleTools } from '@lace-cloud/chat-core';
|
|
57
|
+
|
|
58
|
+
const registry = createToolRegistry();
|
|
59
|
+
const canvas = canvasTools({ source, editor, commands, transport }); // one authoring session
|
|
60
|
+
for (const tool of [...canvas, ...moduleTools({ commands })]) {
|
|
61
|
+
registry.register(tool.schema, tool.handler);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// When the host drops the tools or the session closes:
|
|
65
|
+
canvas.dispose();
|
|
77
66
|
```
|
|
78
67
|
|
|
68
|
+
That is the whole of a host's composition. `canvasTools` returns its four
|
|
69
|
+
registrations, in the order below, carrying `dispose`. With a `transport`
|
|
70
|
+
the set reads the session's frames itself, for what happened next to each
|
|
71
|
+
change it reported, from its construction until `dispose`.
|
|
72
|
+
|
|
73
|
+
| Tool set | Ports | Schemas | Tools |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| `canvasTools` | `source`, `editor`, `commands`, `transport?` | `canvasToolSchemas` | `lace_change_module_canvas`, `lace_describe_module_canvas`, `lace_save_module_canvas`, `lace_generate_module_terraform` |
|
|
76
|
+
| `moduleTools` | `commands` | `moduleToolSchemas` | `lace_validate_module_terraform`, `lace_search_module_registry`, `lace_describe_registry_module` |
|
|
77
|
+
|
|
78
|
+
Each set's schemas are data beside its constructor (`canvasToolSchemas`,
|
|
79
|
+
`moduleToolSchemas`: each tool's name, title, description and input
|
|
80
|
+
schema, in the order the constructor returns its registrations), and the
|
|
81
|
+
constructor registers exactly those, so a host that generates a manifest
|
|
82
|
+
of the tools reads them with no ports at all.
|
|
83
|
+
|
|
84
|
+
- `source` is the session's frames; `editor` is the session mapping's
|
|
85
|
+
`EditorPort` without `resolveConflict`: its `apply`, `save`,
|
|
86
|
+
`generate` and `wiringCandidates` (the engine matcher's scored
|
|
87
|
+
output → input pairs); `commands` runs a CLI command; `transport` is
|
|
88
|
+
the port to Lace's API.
|
|
89
|
+
- **The change tool is intent-first.** It takes
|
|
90
|
+
`{changes: [{request, value?, modelReading, alternativeReading?}]}`:
|
|
91
|
+
`request` is one change in the developer's own words and never a
|
|
92
|
+
literal, `value` the literal the developer gave for it (the tool selects
|
|
93
|
+
and never writes a value of its own), one change and one value per
|
|
94
|
+
entry, `modelReading` the model's own reading of the change, required
|
|
95
|
+
on every call (its operation, and the names the developer gave as the
|
|
96
|
+
canvas lists them, never a value), and `alternativeReading` its other
|
|
97
|
+
reading of the words, where the words bear one. For each change the
|
|
98
|
+
tool enumerates what the canvas offers for every decision the change
|
|
99
|
+
needs (which operation, which instance, which input, which registry
|
|
100
|
+
module, which output → input pair) and resolves each in order: the one
|
|
101
|
+
candidate the request names exactly, the one it names when case is
|
|
102
|
+
ignored, otherwise the two systems. Each change is one `apply` of one
|
|
103
|
+
generated `Action`, whose instance-addressed sub-message carries
|
|
104
|
+
`scope`, the key of the module that owns the instance
|
|
105
|
+
(`resolveInstance` in `@lace-cloud/proto`), and on a `connect`
|
|
106
|
+
`source_scope` for the source end; the changes apply in the order
|
|
107
|
+
given, each resolved against the state the one before it left.
|
|
108
|
+
- **The operations** a change can be: `place` (a registry module, from
|
|
109
|
+
`registry list --axis module --limit 500`, narrowed by `--query` when
|
|
110
|
+
the request refers to a module as `author/name`; a truncated listing
|
|
111
|
+
is said in the result), `connect` (the pair picked among every output
|
|
112
|
+
of the source into every input of the target no wire feeds, each
|
|
113
|
+
candidate carrying the engine matcher's score for it where the matcher
|
|
114
|
+
scores it), `disconnect`, `set` (a literal), `bind` (an
|
|
115
|
+
input takes its value from a variable, `var.<name>`), `clear` (an
|
|
116
|
+
input is unset), `rename`, `delete` and `ungroup`. Each is one row of
|
|
117
|
+
`OPERATIONS`.
|
|
118
|
+
- **The longest span names.** A single word names a candidate only
|
|
119
|
+
where no other candidate's id, prose or references cover a longer run
|
|
120
|
+
of the request's words around it: in "store the orders database admin
|
|
121
|
+
password", `admin` is a word of the database's admin password (its
|
|
122
|
+
input's description), not the instance `admin`, so the instance goes
|
|
123
|
+
to the two systems. Function words ("the", "to", "in", …) name nothing: a run
|
|
124
|
+
holds them whoever covers them and a span does not count them, so in
|
|
125
|
+
"upgrade the cluster to Kubernetes" `cluster` names the instance
|
|
126
|
+
`cluster`, though a node group's description covers "the cluster to".
|
|
127
|
+
An instance's prose holds its inputs and outputs with what the module
|
|
128
|
+
says each is. A dotted or slashed reference is never outspanned.
|
|
129
|
+
- **An entry is one change.** A decision fills one slot of a change, so
|
|
130
|
+
words that name more of its candidates than that, each by a name of its
|
|
131
|
+
own ("delete net and delete db_replica"), say the entry holds
|
|
132
|
+
several: the candidate the model's reading names among them, else the
|
|
133
|
+
first named, is applied, and the result says the entry held more and
|
|
134
|
+
names what nothing was applied for, with no rank call. Where the names
|
|
135
|
+
cannot tell (a name two candidates share, or one named candidate inside
|
|
136
|
+
another) and the two systems read any decision of the entry, Lace's
|
|
137
|
+
ranking also reads whether the entry is one change or several
|
|
138
|
+
(`steps`), under the model's reading alone; the model's answer is `one`
|
|
139
|
+
by construction, since the tool asks one entry per change. An entry read
|
|
140
|
+
as several has the change read applied, and the result says the entry
|
|
141
|
+
held more. Either way it asks for the rest, one entry per change.
|
|
142
|
+
`steps` decides only what the result says; it never stops the change,
|
|
143
|
+
and it is never ranked under the alternative reading, so it never asks.
|
|
144
|
+
A `value` sent with an operation that
|
|
145
|
+
takes none (`place`, `connect`, `disconnect`, `clear`, `delete`,
|
|
146
|
+
`ungroup`) is said in the result to be unused.
|
|
147
|
+
- **The composition.** Per question the names leave open, two readings:
|
|
148
|
+
the model's answer is the candidate its stated slot names (none when it
|
|
149
|
+
states no slot of the question), and Lace's is its ranking's pick with
|
|
150
|
+
a rightness, the measured probability of being right. The answer is
|
|
151
|
+
Lace's where the ranking is sure (`sure`: the pick's rightness reaches
|
|
152
|
+
the threshold the reply carries for the kind, a reply with no threshold
|
|
153
|
+
for the kind being sure of nothing, and `(none)` ranked first never
|
|
154
|
+
sure), the model's own otherwise. The operation is Lace's only when the
|
|
155
|
+
ranking was sure of it, of every question asked under it, and the
|
|
156
|
+
change resolves under it. Where the model stated another operation, this
|
|
157
|
+
move rule is part of planning: a question under Lace's operation that
|
|
158
|
+
falls to the model (answered or not), or a change that does not resolve
|
|
159
|
+
under it (the canvas offers nothing for a question, the listing fails,
|
|
160
|
+
the value it needs is missing), means the operation is the model's, and
|
|
161
|
+
the change is resolved again under it; only that outcome is the
|
|
162
|
+
change's, and the result says why Lace's operation did not stand.
|
|
163
|
+
Where the ranking is sure and the reading named another candidate,
|
|
164
|
+
Lace's answer stands and the result says both, with a line for the
|
|
165
|
+
model to pass on: the decision is graded by what the developer does
|
|
166
|
+
next, not withheld. A change neither system resolves
|
|
167
|
+
is not applied, and the result names the part and its candidates,
|
|
168
|
+
asking for the reading to name one. Where the model gave an alternative
|
|
169
|
+
reading and the ranking is sure of a different answer under it,
|
|
170
|
+
nothing is applied and both decisions come back for the model to ask
|
|
171
|
+
the developer. Until a kind's threshold ships, the ranking is sure of
|
|
172
|
+
nothing of that kind and every question is the model's: a change then
|
|
173
|
+
applies exactly when the reading names a candidate, as it does with no
|
|
174
|
+
`Transport` or a ranking service that is down. The composition is
|
|
175
|
+
`compose(readings)`, a pure function.
|
|
176
|
+
- **Every canvas tool's result ends with the current canvas**, written
|
|
177
|
+
by `renderCanvas`, a pure function of one frame: the instances with
|
|
178
|
+
their modules, inputs and outputs, the wires, the required inputs not
|
|
179
|
+
set, the groups, the diagnostics, and the standing (unsaved,
|
|
180
|
+
ungenerated, conflict, refused). An input the module marks sensitive
|
|
181
|
+
shows that it is set and never its value.
|
|
182
|
+
- **One rendered request per change, and no value the call carries in
|
|
183
|
+
what is sent.** `renderRequest(request, values, statement)` replaces
|
|
184
|
+
each text in `values` with `VALUE_PLACEHOLDER`: where it stands as a
|
|
185
|
+
token of its own, and everywhere when it holds a character a name
|
|
186
|
+
cannot; the request is cut at a word so that it and the statement
|
|
187
|
+
together fit the request bound. The change tool gives it every form of
|
|
188
|
+
the change's own value (`forms`: each literal, and a `var.` value with
|
|
189
|
+
and without its prefix), always the placeholder, a form the canvas names
|
|
190
|
+
included, since the request's names are read from the rendered words and
|
|
191
|
+
the value must never name a candidate; and every other value of the
|
|
192
|
+
call that the canvas does not name when the change is ranked (`unnamed`
|
|
193
|
+
against `canvasNames`): a name the canvas holds is a canvas fact Lace's
|
|
194
|
+
ranking sees among the candidates, and is kept. A statement is a reading
|
|
195
|
+
as words, built from the stated slots that name a fact alone (an
|
|
196
|
+
operation, a name the canvas holds, a registry module as `author/name`)
|
|
197
|
+
and withheld the same way: the model's reading, and its alternative
|
|
198
|
+
reading where it gave one. The request is cut to the room the longer
|
|
199
|
+
statement leaves. Each rank call for the change carries that one request
|
|
200
|
+
and one of those statements: the model's reading for every question the
|
|
201
|
+
two systems read, and, where an alternative was given, the alternative
|
|
202
|
+
reading's for each of those but `steps`; the API captures each call as
|
|
203
|
+
sent. A change whose
|
|
204
|
+
request or either statement, with every canvas name withheld, still
|
|
205
|
+
holds any withheld text of the call inside a word (`holdsValue`) is not
|
|
206
|
+
ranked: no rank call is made for it, the names and the model's reading
|
|
207
|
+
decide it, and the result says Lace did not rank it. Its decision is still
|
|
208
|
+
reported once the call settles, with no capture on any question and every
|
|
209
|
+
value replaced.
|
|
210
|
+
- **The change tool's result is a `ChangeResult`**: the text the model
|
|
211
|
+
reads, and `applied`, one `ChangeRecord` per applied change:
|
|
212
|
+
`{id, target, before, after, revision?, questions, reported}`. `target`
|
|
213
|
+
is the instance, or the input of it, the change addressed; `before` and
|
|
214
|
+
`after` are that input's binding or that instance's presence;
|
|
215
|
+
`revision` is the frame its apply produced; `questions` are the
|
|
216
|
+
decision's questions in the order reported, each its kind and its
|
|
217
|
+
candidates' ids; `reported` says the decision was reported to Lace, so
|
|
218
|
+
its outcomes are. `id` is the decision's.
|
|
219
|
+
- **What happened next to a change.** `changeOutcomes(record, frames, own?)`
|
|
220
|
+
is a pure function from a `ChangeRecord`, the session's frames after
|
|
221
|
+
the change and the revisions the package's own applies produced to the
|
|
222
|
+
outcomes reached (`OutcomeReport`), each kind once in the order first
|
|
223
|
+
reached, and the record carried to the last frame. One predicate, what
|
|
224
|
+
the change decided (the answers of its closed questions as the canvas
|
|
225
|
+
holds them: an input's mode, which names the operation that writes it,
|
|
226
|
+
and the wire's source, which names the pair; an instance's module; the
|
|
227
|
+
target's presence), serves the edit outcomes: `reverted` when what the
|
|
228
|
+
change addressed is back to its state before it (an undo, a Reload);
|
|
229
|
+
`hand_edited` when a frame the package did not produce changes what the
|
|
230
|
+
change decided to another answer than its own (a canvas edit, an edit of
|
|
231
|
+
the text), the strongest label; `changed_again` when a later change
|
|
232
|
+
through the package does; `saved` and `generated` when a save or a
|
|
233
|
+
Generate moved the session while the change still stood as applied. A
|
|
234
|
+
new value of an input in the same mode (another literal, another
|
|
235
|
+
variable) changes no question: it reaches no outcome, and the change no
|
|
236
|
+
longer stands as applied, so no save or Generate after it is read. A
|
|
237
|
+
hand edit or a change again names, where the fold can tell, the
|
|
238
|
+
decision's question the edit answers and the candidate it names (a
|
|
239
|
+
binding in another mode names the operation that writes that mode; a
|
|
240
|
+
wire from another source names the connection). A rename, a group or an
|
|
241
|
+
ungroup moves an instance without changing it, so the record follows
|
|
242
|
+
its instance.
|
|
243
|
+
- **The canvas tool set reads the outcomes itself.** With a `transport`
|
|
244
|
+
it composes the outcome observer with the session's `source` at
|
|
245
|
+
construction: the observer follows the records of each change-tool
|
|
246
|
+
result whose decision was reported, reads the session frame by frame
|
|
247
|
+
and reports each outcome once. It is the one owner of which frames are
|
|
248
|
+
the package's own: the change tool runs every apply through it, the
|
|
249
|
+
frames that arrive while an apply is in flight are held until it
|
|
250
|
+
resolves, and a held frame at the revision the apply returned is the
|
|
251
|
+
package's own (every apply's, reported or not, a change the names
|
|
252
|
+
alone settled included); any other is read as usual. `dispose` ends
|
|
253
|
+
the reading. With no `transport` the set reads no frames and `dispose`
|
|
254
|
+
does nothing.
|
|
255
|
+
- Save and Generate run only when their own tool is called, through the
|
|
256
|
+
operations the canvas's own buttons run. No tool asks for a
|
|
257
|
+
confirmation, and none reaches an operation the canvas confirms. The
|
|
258
|
+
editor's `save` resolves, and its `generate` yields its success, once
|
|
259
|
+
the source has delivered the frame that carries the call, so the
|
|
260
|
+
canvas their result ends with shows the save or the generate; when the
|
|
261
|
+
session's stream ends first, the result says what the engine did and
|
|
262
|
+
that the canvas below is from before it.
|
|
263
|
+
- **One spelling of a reason.** A refused Save, Generate or apply names
|
|
264
|
+
the reason it carries as a failure document spells it (`reasonWire`:
|
|
265
|
+
`unsaved`, `source_refused`, …), or the API's own code when the API
|
|
266
|
+
decided it, so a model reads one vocabulary from every tool.
|
|
267
|
+
- The module tools each run one command (`module validate`,
|
|
268
|
+
`registry list`, `registry describe`) and return its document trimmed
|
|
269
|
+
to what a model needs.
|
|
270
|
+
- **A module tool's result is a `ModuleToolResult`**: the text the model
|
|
271
|
+
reads, and `failure`, the failure document of a command that failed
|
|
272
|
+
and wrote one (`CommandFailure`, from `CommandExitError.failure`). The
|
|
273
|
+
text then names the document's `reason`, its `message` and its `url`
|
|
274
|
+
when it has one; a host branches on `failure.reason`, never on the
|
|
275
|
+
text. A command that printed its result and exited non-zero, or wrote
|
|
276
|
+
no document, has no `failure`: the text gives its exit and what it
|
|
277
|
+
wrote to stderr. The change tool's place reads `registry list` the
|
|
278
|
+
same way and says the same text when that command fails.
|
|
279
|
+
|
|
280
|
+
## Lace's ranking: the service and what it collects
|
|
281
|
+
|
|
282
|
+
The package is the client of Lace's ranking service, through the API,
|
|
283
|
+
over the host's `Transport`.
|
|
284
|
+
|
|
285
|
+
- **A rank call** is `POST /api/v1/candidates/rank` with
|
|
286
|
+
`{request, statement, candidates}` (`RankRequest`): the request as
|
|
287
|
+
rendered, the statement as rendered, and the question's candidates as
|
|
288
|
+
`{id, kind, text}`, one kind per set, `(none)` last in every kind but
|
|
289
|
+
`steps` (`NONE_CANDIDATE_ID`: none of the others, in the words of its
|
|
290
|
+
kind, ranked like any candidate and never applied). The reply
|
|
291
|
+
(`Ranked`) is `{capture_id, head, scores, thresholds}`: the id the API
|
|
292
|
+
minted for the question as asked, the head's content hash, the scores
|
|
293
|
+
in rank order each with its `rightness`, and the head's thresholds, one
|
|
294
|
+
`{from}` per kind a threshold shipped for. A question is read against
|
|
295
|
+
the thresholds of the reply it came from, never against a value held
|
|
296
|
+
from elsewhere. A 503 (`ranking_unavailable`), a transport that throws
|
|
297
|
+
or a body that is not a reply is one failed call: the question is
|
|
298
|
+
the model's alone and is reported with no capture.
|
|
299
|
+
- **Collection is the service's side effect of being asked.** At the rank
|
|
300
|
+
call the API stores the question as asked (the request and statement as
|
|
301
|
+
rendered, the candidates as sent, both arms' scores, the head) under
|
|
302
|
+
the `capture_id`, keyed to the developer's account. Nothing in it is a
|
|
303
|
+
value the tools were given: the package renders before it sends, every
|
|
304
|
+
value of the call withheld as above, and a change whose words or
|
|
305
|
+
readings still hold one inside a word is not sent. A literal the model
|
|
306
|
+
left in `request` instead of passing it in `value` is no value the tools
|
|
307
|
+
were given, and is sent as written.
|
|
308
|
+
- **The decision is reported once**, when the call settles, for every
|
|
309
|
+
change a question of which went to the two systems:
|
|
310
|
+
`POST /api/v1/candidates/decisions` with a `DecisionReport`
|
|
311
|
+
`{id, surface: 'canvas', questions, applied, asked}`. Per question
|
|
312
|
+
(`Question`): its kind, the `capture_id` (null where the words settled
|
|
313
|
+
it by name, the rank failed, or the set was ranked in parts), the
|
|
314
|
+
model's candidate `chat` (null where its statement named none), the
|
|
315
|
+
ranking's pick `clm` with its rightness (null where not ranked, or
|
|
316
|
+
ranked in parts), whose answer was taken (`took`:
|
|
317
|
+
`named`, `chat` or `clm`) and the candidate the decision holds
|
|
318
|
+
(`taken`, null where neither resolved). `applied` is what the change
|
|
319
|
+
did in words, every value of the call the canvas did not name when the
|
|
320
|
+
change was ranked withheld; null when nothing applied. A change the
|
|
321
|
+
names alone settled is reported to nothing: nothing was captured.
|
|
322
|
+
- **Each outcome is reported once**, by the canvas tool set's observer, to
|
|
323
|
+
`POST /api/v1/candidates/decisions/:id/outcomes` as an `OutcomeReport`
|
|
324
|
+
`{event, question?, candidate?}`.
|
|
325
|
+
- The API derives each question's label from the outcomes alone; nobody
|
|
326
|
+
reviews by default. A report the API refuses or the transport drops is
|
|
327
|
+
one failed call: nothing retries it and nothing in the UI says so.
|
|
328
|
+
|
|
329
|
+
No rank call carries more than `RANK_CANDIDATES_MAX` (256) candidates, a
|
|
330
|
+
request and statement together over `RANK_REQUEST_MAX_CHARS` (4,000
|
|
331
|
+
characters) or a candidate's prose over `RANK_CANDIDATE_TEXT_MAX_CHARS`
|
|
332
|
+
(2,000), each at most the ranking route's own bound. `renderCandidate`
|
|
333
|
+
fits a candidate's prose to its bound, the same facts always alike: names
|
|
334
|
+
come first, so what the module or the registry says a thing is is
|
|
335
|
+
shortened at a word before any name is dropped, and a name is dropped
|
|
336
|
+
whole, from the end of its list, with how many more there are. A decision
|
|
337
|
+
over a larger set (a registry of more modules, say) is ranked part by
|
|
338
|
+
part, at most 255 real candidates and `(none)` a call, and the parts'
|
|
339
|
+
picks are ranked together, so no candidate is left out; a pick made across
|
|
340
|
+
parts was never scored against the whole set, so the ranking is never sure
|
|
341
|
+
of it, and no one capture holds every candidate of the question, so its
|
|
342
|
+
question is reported with no capture and no pick: every candidate a
|
|
343
|
+
reported question names is one of the capture it names.
|
|
344
|
+
|
|
345
|
+
## The rows a head trains on
|
|
346
|
+
|
|
347
|
+
The row format has one definition, `trainingRows`:
|
|
348
|
+
`trainingRows(turn, part)` is one row per question of a turn,
|
|
349
|
+
`{request, statement, candidates, label, part, origin, turn, chat}`:
|
|
350
|
+
exactly what the question's rank call carried, the id of the right
|
|
351
|
+
candidate, the part its caller gives, where the turn came from (`real`, a
|
|
352
|
+
developer's call; `synthetic`, the generator), the turn's id shared by every
|
|
353
|
+
row of the turn, and the model's candidate for the question (null when it
|
|
354
|
+
stated none), which the threshold fit's bar reads. The caller owns the
|
|
355
|
+
part, and each row is written once, in it: a real turn's part is
|
|
356
|
+
`partOf(turn)`, a pure function of the turn id (`hashFraction`, its FNV-1a
|
|
357
|
+
hash): 60% train, 20% calibration, 20% held out, the same part in every
|
|
358
|
+
corpus. A synthetic turn's part is the one its generator gives it. No
|
|
359
|
+
row holds a value the tools were given: the request and the statement are
|
|
360
|
+
the strings the rank call carried, every value the placeholder.
|
|
361
|
+
|
|
362
|
+
How rows are generated, reviewed and exported, and how the ranking is
|
|
363
|
+
measured, is offline tooling this package does not ship; it is documented
|
|
364
|
+
with its source.
|
|
365
|
+
|
|
366
|
+
## The boundary
|
|
367
|
+
|
|
368
|
+
Chat reads the session's IR through the canvas package's React-free
|
|
369
|
+
entry (`@lace-cloud/canvas/engine`: the port types and the engine
|
|
370
|
+
mapping) and `@lace-cloud/proto` (the projection) alone. It never imports
|
|
371
|
+
the canvas's React barrel (`@lace-cloud/canvas`), `vscode`,
|
|
372
|
+
`node:child_process`, the CLI or `@grpc/grpc-js`.
|
|
373
|
+
|
|
79
374
|
## License
|
|
80
375
|
|
|
81
|
-
BUSL-1.1 — see the `LICENSE` file packed in this package.
|
|
376
|
+
BUSL-1.1 — see the `LICENSE` file packed in this package.
|