@lace-cloud/chat-core 0.20.0 → 0.21.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/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { RenderInput } from '@lace-cloud/proto';
2
1
  import { EditorPort, SourcePort, CommandsPort, CommandFailure, CanvasSource } from '@lace-cloud/canvas/engine';
3
2
 
4
3
  type ToolSchema = {
@@ -25,231 +24,29 @@ interface ToolRegistry {
25
24
  }
26
25
  declare function createToolRegistry(): ToolRegistry;
27
26
 
28
- type DecisionKind = 'operation' | 'instance' | 'input' | 'module' | 'connection' | 'steps';
29
- declare const DECISION_KINDS: readonly DecisionKind[];
30
- declare const NONE_CANDIDATE_ID = "(none)";
31
- type Candidate = {
32
- readonly id: string;
33
- readonly kind: DecisionKind;
34
- readonly text: string;
35
- };
36
-
37
- type InstanceRole = 'instance' | 'source' | 'target';
38
- type InputState = 'not set' | 'set' | 'wired';
39
- type PinFacts = {
40
- readonly name: string;
41
- readonly description?: string;
42
- };
43
- type CandidateFacts = {
44
- readonly id: string;
45
- readonly kind: 'operation';
46
- } | {
47
- readonly id: string;
48
- readonly kind: 'steps';
49
- } | {
50
- readonly id: string;
51
- readonly kind: 'instance';
52
- readonly role: InstanceRole;
53
- readonly module: string;
54
- readonly inputs: readonly PinFacts[];
55
- readonly outputs: readonly PinFacts[];
56
- } | {
57
- readonly id: string;
58
- readonly kind: 'input';
59
- readonly instance: string;
60
- readonly module: string;
61
- readonly type: string;
62
- readonly required: boolean;
63
- readonly state: InputState;
64
- readonly description?: string;
65
- } | {
66
- readonly id: string;
67
- readonly kind: 'module';
68
- readonly displayName: string;
69
- readonly description: string;
70
- readonly system: string;
71
- readonly categories: readonly string[];
72
- } | {
73
- readonly id: string;
74
- readonly kind: 'connection';
75
- readonly source: string;
76
- readonly output: string;
77
- readonly target: string;
78
- readonly input: string;
79
- readonly score?: number;
80
- };
81
- declare function renderCandidate(facts: CandidateFacts): Candidate;
82
-
83
- declare const VALUE_PLACEHOLDER = "<value>";
84
- declare function renderRequest(request: string, values: readonly unknown[], statement?: string): string;
85
-
86
- type ChangeOutcome = 'reverted' | 'changed_again' | 'saved' | 'generated' | 'hand_edited';
87
- type OutcomeReport = {
88
- readonly event: ChangeOutcome;
89
- readonly question?: number;
90
- readonly candidate?: string;
91
- };
92
-
93
- type Took = 'named' | 'chat' | 'clm';
94
- type Question = {
95
- readonly kind: DecisionKind;
96
- readonly capture_id: string | null;
97
- readonly chat: string | null;
98
- readonly clm: {
99
- readonly id: string;
100
- readonly rightness: number;
101
- } | null;
102
- readonly took: Took;
103
- readonly taken: string | null;
104
- };
105
- type DecisionReport = {
106
- readonly id: string;
107
- readonly surface: 'canvas';
108
- readonly questions: readonly Question[];
109
- readonly applied: string | null;
110
- readonly asked: boolean;
111
- };
112
-
113
- type Transport = (path: `/api/v1/candidates/${string}`, init: {
114
- readonly method: 'POST';
115
- readonly body: unknown;
116
- readonly signal: AbortSignal;
117
- }) => Promise<Answered | {
118
- readonly carried: false;
119
- }>;
120
- type Answered = {
121
- readonly status: number;
122
- readonly body: unknown;
123
- };
124
- type RankRequest = {
125
- readonly request: string;
126
- readonly statement: string;
127
- readonly candidates: readonly Candidate[];
128
- };
129
- type Score = {
130
- readonly id: string;
131
- readonly score: number;
132
- readonly rightness: number;
133
- };
134
- type Threshold = {
135
- readonly from: number;
136
- };
137
- type Thresholds = Readonly<Partial<Record<DecisionKind, Threshold>>>;
138
- type Ranked = {
139
- readonly capture_id: string;
140
- readonly head: string;
141
- readonly scores: readonly Score[];
142
- readonly thresholds: Thresholds;
143
- };
144
-
145
- type Part = 'train' | 'calibration' | 'held_out';
146
- type Origin = 'real' | 'synthetic';
147
- type TrainingRow = {
148
- readonly request: string;
149
- readonly statement: string;
150
- readonly candidates: readonly Candidate[];
151
- readonly label: string;
152
- readonly part: Part;
153
- readonly origin: Origin;
154
- readonly turn: string;
155
- readonly chat: string | null;
156
- };
157
- type LabelledQuestion = {
158
- readonly kind: DecisionKind;
159
- readonly candidates: readonly Candidate[];
160
- readonly label: string;
161
- readonly chat: string | null;
162
- };
163
- type LabelledTurn = {
164
- readonly id: string;
165
- readonly request: string;
166
- readonly statement: string;
167
- readonly origin: Origin;
168
- readonly questions: readonly LabelledQuestion[];
169
- };
170
- declare function partOf(key: string): Part;
171
- declare function trainingRows(turn: LabelledTurn, part: Part): TrainingRow[];
172
-
173
- declare function sure(ranked: Ranked, kind: DecisionKind): boolean;
174
- type Readings = {
175
- readonly kind: DecisionKind;
176
- readonly chat: string | null;
177
- readonly ranked: Ranked | null;
178
- };
179
- type Composed = {
180
- readonly took: 'chat' | 'clm';
181
- readonly taken: string | null;
182
- readonly clm: {
183
- readonly id: string;
184
- readonly rightness: number;
185
- } | null;
186
- readonly differed: boolean;
187
- };
188
- declare function compose({ kind, chat, ranked }: Readings): Composed;
189
-
190
- type CanvasInput = RenderInput & {
191
- readonly sensitive: boolean;
192
- };
193
-
194
27
  type CanvasEditor = Pick<EditorPort, 'apply' | 'save' | 'generate' | 'wiringCandidates'>;
195
28
  type CanvasToolPorts = {
196
29
  readonly source: SourcePort;
197
30
  readonly editor: CanvasEditor;
198
31
  readonly commands: CommandsPort;
199
- readonly transport?: Transport;
200
32
  };
201
33
  type ModuleToolPorts = {
202
34
  readonly commands: CommandsPort;
203
35
  };
204
36
 
205
- type ChangeTarget = {
206
- readonly scope: string;
207
- readonly instance: string;
208
- readonly input?: string;
209
- };
210
- type InputBinding = {
211
- readonly mode: CanvasInput['mode'];
212
- readonly value?: unknown;
213
- readonly variable?: string;
214
- readonly expression?: string;
215
- readonly wiredSource?: string;
216
- };
217
- type InstancePresence = {
218
- readonly instance: string;
219
- readonly module: string;
220
- };
221
- type ChangeState = InputBinding | InstancePresence | null;
222
- type RecordQuestion = {
223
- readonly kind: DecisionKind;
224
- readonly candidates: readonly string[];
225
- };
226
- type ChangeRecord = {
227
- readonly id: string;
228
- readonly target: ChangeTarget;
229
- readonly before: ChangeState;
230
- readonly after: ChangeState;
231
- readonly revision?: number;
232
- readonly questions: readonly RecordQuestion[];
233
- readonly reported: boolean;
234
- };
235
-
236
37
  declare const canvasToolSchemas: readonly [ToolSchema, ToolSchema, ToolSchema, ToolSchema];
237
- type ChangeResult = ToolResult & {
238
- readonly applied: readonly ChangeRecord[];
239
- };
240
38
  type CanvasTools = readonly [
241
- ToolRegistration<ChangeResult>,
39
+ ToolRegistration,
242
40
  ToolRegistration,
243
41
  ToolRegistration,
244
42
  ToolRegistration
245
- ] & {
246
- readonly dispose: () => void;
247
- };
43
+ ];
248
44
  declare function canvasTools(ports: CanvasToolPorts): CanvasTools;
249
45
 
250
46
  declare const moduleToolSchemas: readonly [ToolSchema, ToolSchema, ToolSchema];
251
- type ModuleToolResult = ToolResult & {
252
- readonly failure?: CommandFailure;
47
+ type ModuleToolResult = ToolResult & Partial<ModuleToolData>;
48
+ type ModuleToolData = {
49
+ readonly failure: CommandFailure;
253
50
  };
254
51
  type ModuleTools = readonly [
255
52
  ToolRegistration<ModuleToolResult>,
@@ -258,11 +55,6 @@ type ModuleTools = readonly [
258
55
  ];
259
56
  declare function moduleTools({ commands }: ModuleToolPorts): ModuleTools;
260
57
 
261
- declare function changeOutcomes(record: ChangeRecord, frames: readonly CanvasSource[], own?: ReadonlySet<number>): {
262
- readonly record: ChangeRecord;
263
- readonly outcomes: OutcomeReport[];
264
- };
265
-
266
58
  declare function renderCanvas(source: CanvasSource): string;
267
59
 
268
- export { type Answered, type Candidate, type CandidateFacts, type CanvasEditor, type CanvasToolPorts, type CanvasTools, type ChangeOutcome, type ChangeRecord, type ChangeResult, type ChangeState, type ChangeTarget, type Composed, DECISION_KINDS, type DecisionKind, type DecisionReport, type InputBinding, type InstancePresence, type LabelledQuestion, type LabelledTurn, type ModuleToolPorts, type ModuleToolResult, type ModuleTools, NONE_CANDIDATE_ID, type Origin, type OutcomeReport, type Part, type Question, type RankRequest, type Ranked, type Readings, type Score, type Threshold, type Thresholds, type Took, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolSchema, type TrainingRow, type Transport, VALUE_PLACEHOLDER, canvasToolSchemas, canvasTools, changeOutcomes, compose, createToolRegistry, moduleToolSchemas, moduleTools, partOf, renderCandidate, renderCanvas, renderRequest, sure, trainingRows };
60
+ export { type CanvasEditor, type CanvasToolPorts, type CanvasTools, type ModuleToolPorts, type ModuleToolResult, type ModuleTools, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolSchema, canvasToolSchemas, canvasTools, createToolRegistry, moduleToolSchemas, moduleTools, renderCanvas };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { RenderInput } from '@lace-cloud/proto';
2
1
  import { EditorPort, SourcePort, CommandsPort, CommandFailure, CanvasSource } from '@lace-cloud/canvas/engine';
3
2
 
4
3
  type ToolSchema = {
@@ -25,231 +24,29 @@ interface ToolRegistry {
25
24
  }
26
25
  declare function createToolRegistry(): ToolRegistry;
27
26
 
28
- type DecisionKind = 'operation' | 'instance' | 'input' | 'module' | 'connection' | 'steps';
29
- declare const DECISION_KINDS: readonly DecisionKind[];
30
- declare const NONE_CANDIDATE_ID = "(none)";
31
- type Candidate = {
32
- readonly id: string;
33
- readonly kind: DecisionKind;
34
- readonly text: string;
35
- };
36
-
37
- type InstanceRole = 'instance' | 'source' | 'target';
38
- type InputState = 'not set' | 'set' | 'wired';
39
- type PinFacts = {
40
- readonly name: string;
41
- readonly description?: string;
42
- };
43
- type CandidateFacts = {
44
- readonly id: string;
45
- readonly kind: 'operation';
46
- } | {
47
- readonly id: string;
48
- readonly kind: 'steps';
49
- } | {
50
- readonly id: string;
51
- readonly kind: 'instance';
52
- readonly role: InstanceRole;
53
- readonly module: string;
54
- readonly inputs: readonly PinFacts[];
55
- readonly outputs: readonly PinFacts[];
56
- } | {
57
- readonly id: string;
58
- readonly kind: 'input';
59
- readonly instance: string;
60
- readonly module: string;
61
- readonly type: string;
62
- readonly required: boolean;
63
- readonly state: InputState;
64
- readonly description?: string;
65
- } | {
66
- readonly id: string;
67
- readonly kind: 'module';
68
- readonly displayName: string;
69
- readonly description: string;
70
- readonly system: string;
71
- readonly categories: readonly string[];
72
- } | {
73
- readonly id: string;
74
- readonly kind: 'connection';
75
- readonly source: string;
76
- readonly output: string;
77
- readonly target: string;
78
- readonly input: string;
79
- readonly score?: number;
80
- };
81
- declare function renderCandidate(facts: CandidateFacts): Candidate;
82
-
83
- declare const VALUE_PLACEHOLDER = "<value>";
84
- declare function renderRequest(request: string, values: readonly unknown[], statement?: string): string;
85
-
86
- type ChangeOutcome = 'reverted' | 'changed_again' | 'saved' | 'generated' | 'hand_edited';
87
- type OutcomeReport = {
88
- readonly event: ChangeOutcome;
89
- readonly question?: number;
90
- readonly candidate?: string;
91
- };
92
-
93
- type Took = 'named' | 'chat' | 'clm';
94
- type Question = {
95
- readonly kind: DecisionKind;
96
- readonly capture_id: string | null;
97
- readonly chat: string | null;
98
- readonly clm: {
99
- readonly id: string;
100
- readonly rightness: number;
101
- } | null;
102
- readonly took: Took;
103
- readonly taken: string | null;
104
- };
105
- type DecisionReport = {
106
- readonly id: string;
107
- readonly surface: 'canvas';
108
- readonly questions: readonly Question[];
109
- readonly applied: string | null;
110
- readonly asked: boolean;
111
- };
112
-
113
- type Transport = (path: `/api/v1/candidates/${string}`, init: {
114
- readonly method: 'POST';
115
- readonly body: unknown;
116
- readonly signal: AbortSignal;
117
- }) => Promise<Answered | {
118
- readonly carried: false;
119
- }>;
120
- type Answered = {
121
- readonly status: number;
122
- readonly body: unknown;
123
- };
124
- type RankRequest = {
125
- readonly request: string;
126
- readonly statement: string;
127
- readonly candidates: readonly Candidate[];
128
- };
129
- type Score = {
130
- readonly id: string;
131
- readonly score: number;
132
- readonly rightness: number;
133
- };
134
- type Threshold = {
135
- readonly from: number;
136
- };
137
- type Thresholds = Readonly<Partial<Record<DecisionKind, Threshold>>>;
138
- type Ranked = {
139
- readonly capture_id: string;
140
- readonly head: string;
141
- readonly scores: readonly Score[];
142
- readonly thresholds: Thresholds;
143
- };
144
-
145
- type Part = 'train' | 'calibration' | 'held_out';
146
- type Origin = 'real' | 'synthetic';
147
- type TrainingRow = {
148
- readonly request: string;
149
- readonly statement: string;
150
- readonly candidates: readonly Candidate[];
151
- readonly label: string;
152
- readonly part: Part;
153
- readonly origin: Origin;
154
- readonly turn: string;
155
- readonly chat: string | null;
156
- };
157
- type LabelledQuestion = {
158
- readonly kind: DecisionKind;
159
- readonly candidates: readonly Candidate[];
160
- readonly label: string;
161
- readonly chat: string | null;
162
- };
163
- type LabelledTurn = {
164
- readonly id: string;
165
- readonly request: string;
166
- readonly statement: string;
167
- readonly origin: Origin;
168
- readonly questions: readonly LabelledQuestion[];
169
- };
170
- declare function partOf(key: string): Part;
171
- declare function trainingRows(turn: LabelledTurn, part: Part): TrainingRow[];
172
-
173
- declare function sure(ranked: Ranked, kind: DecisionKind): boolean;
174
- type Readings = {
175
- readonly kind: DecisionKind;
176
- readonly chat: string | null;
177
- readonly ranked: Ranked | null;
178
- };
179
- type Composed = {
180
- readonly took: 'chat' | 'clm';
181
- readonly taken: string | null;
182
- readonly clm: {
183
- readonly id: string;
184
- readonly rightness: number;
185
- } | null;
186
- readonly differed: boolean;
187
- };
188
- declare function compose({ kind, chat, ranked }: Readings): Composed;
189
-
190
- type CanvasInput = RenderInput & {
191
- readonly sensitive: boolean;
192
- };
193
-
194
27
  type CanvasEditor = Pick<EditorPort, 'apply' | 'save' | 'generate' | 'wiringCandidates'>;
195
28
  type CanvasToolPorts = {
196
29
  readonly source: SourcePort;
197
30
  readonly editor: CanvasEditor;
198
31
  readonly commands: CommandsPort;
199
- readonly transport?: Transport;
200
32
  };
201
33
  type ModuleToolPorts = {
202
34
  readonly commands: CommandsPort;
203
35
  };
204
36
 
205
- type ChangeTarget = {
206
- readonly scope: string;
207
- readonly instance: string;
208
- readonly input?: string;
209
- };
210
- type InputBinding = {
211
- readonly mode: CanvasInput['mode'];
212
- readonly value?: unknown;
213
- readonly variable?: string;
214
- readonly expression?: string;
215
- readonly wiredSource?: string;
216
- };
217
- type InstancePresence = {
218
- readonly instance: string;
219
- readonly module: string;
220
- };
221
- type ChangeState = InputBinding | InstancePresence | null;
222
- type RecordQuestion = {
223
- readonly kind: DecisionKind;
224
- readonly candidates: readonly string[];
225
- };
226
- type ChangeRecord = {
227
- readonly id: string;
228
- readonly target: ChangeTarget;
229
- readonly before: ChangeState;
230
- readonly after: ChangeState;
231
- readonly revision?: number;
232
- readonly questions: readonly RecordQuestion[];
233
- readonly reported: boolean;
234
- };
235
-
236
37
  declare const canvasToolSchemas: readonly [ToolSchema, ToolSchema, ToolSchema, ToolSchema];
237
- type ChangeResult = ToolResult & {
238
- readonly applied: readonly ChangeRecord[];
239
- };
240
38
  type CanvasTools = readonly [
241
- ToolRegistration<ChangeResult>,
39
+ ToolRegistration,
242
40
  ToolRegistration,
243
41
  ToolRegistration,
244
42
  ToolRegistration
245
- ] & {
246
- readonly dispose: () => void;
247
- };
43
+ ];
248
44
  declare function canvasTools(ports: CanvasToolPorts): CanvasTools;
249
45
 
250
46
  declare const moduleToolSchemas: readonly [ToolSchema, ToolSchema, ToolSchema];
251
- type ModuleToolResult = ToolResult & {
252
- readonly failure?: CommandFailure;
47
+ type ModuleToolResult = ToolResult & Partial<ModuleToolData>;
48
+ type ModuleToolData = {
49
+ readonly failure: CommandFailure;
253
50
  };
254
51
  type ModuleTools = readonly [
255
52
  ToolRegistration<ModuleToolResult>,
@@ -258,11 +55,6 @@ type ModuleTools = readonly [
258
55
  ];
259
56
  declare function moduleTools({ commands }: ModuleToolPorts): ModuleTools;
260
57
 
261
- declare function changeOutcomes(record: ChangeRecord, frames: readonly CanvasSource[], own?: ReadonlySet<number>): {
262
- readonly record: ChangeRecord;
263
- readonly outcomes: OutcomeReport[];
264
- };
265
-
266
58
  declare function renderCanvas(source: CanvasSource): string;
267
59
 
268
- export { type Answered, type Candidate, type CandidateFacts, type CanvasEditor, type CanvasToolPorts, type CanvasTools, type ChangeOutcome, type ChangeRecord, type ChangeResult, type ChangeState, type ChangeTarget, type Composed, DECISION_KINDS, type DecisionKind, type DecisionReport, type InputBinding, type InstancePresence, type LabelledQuestion, type LabelledTurn, type ModuleToolPorts, type ModuleToolResult, type ModuleTools, NONE_CANDIDATE_ID, type Origin, type OutcomeReport, type Part, type Question, type RankRequest, type Ranked, type Readings, type Score, type Threshold, type Thresholds, type Took, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolSchema, type TrainingRow, type Transport, VALUE_PLACEHOLDER, canvasToolSchemas, canvasTools, changeOutcomes, compose, createToolRegistry, moduleToolSchemas, moduleTools, partOf, renderCandidate, renderCanvas, renderRequest, sure, trainingRows };
60
+ export { type CanvasEditor, type CanvasToolPorts, type CanvasTools, type ModuleToolPorts, type ModuleToolResult, type ModuleTools, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolSchema, canvasToolSchemas, canvasTools, createToolRegistry, moduleToolSchemas, moduleTools, renderCanvas };