@senselab-ai/sensei 0.0.0-stage → 0.2.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 +285 -2
- package/dist/client.d.ts +260 -0
- package/dist/client.js +623 -0
- package/dist/evals.d.ts +233 -0
- package/dist/evals.js +140 -0
- package/dist/files.d.ts +29 -0
- package/dist/files.js +132 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +20 -0
- package/dist/run.d.ts +138 -0
- package/dist/run.js +272 -0
- package/dist/types.d.ts +699 -0
- package/dist/types.js +7 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +6 -0
- package/package.json +42 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the API sends and takes. Fields are named as the API names them
|
|
3
|
+
* (snake_case): a value read from the service is not renamed on the way in.
|
|
4
|
+
* Options you pass (`askFirst`, `baseRef`, ...) are camelCase, and are
|
|
5
|
+
* renamed once, in client.ts.
|
|
6
|
+
*/
|
|
7
|
+
export type RunStatus = "queued" | "running" | "waiting" | "verified" | "done" | "unverified" | "failed" | "cancelled" | (string & {});
|
|
8
|
+
/** The fields of an agent's input or output, as written: `{ticket: "number"}`. */
|
|
9
|
+
export type Shape = Record<string, unknown>;
|
|
10
|
+
export interface Limit {
|
|
11
|
+
usd?: number;
|
|
12
|
+
minutes?: number;
|
|
13
|
+
steps?: number;
|
|
14
|
+
}
|
|
15
|
+
/** What a run may spend. */
|
|
16
|
+
export type Budget = Limit;
|
|
17
|
+
export interface Step {
|
|
18
|
+
id: string;
|
|
19
|
+
/** A saved agent's name, or a definition. */
|
|
20
|
+
agent: string | Definition;
|
|
21
|
+
input?: Record<string, unknown>;
|
|
22
|
+
when?: string | boolean;
|
|
23
|
+
for_each?: string;
|
|
24
|
+
parallel?: number;
|
|
25
|
+
}
|
|
26
|
+
/** An agent, written down once: what a definition file holds. */
|
|
27
|
+
export interface Definition {
|
|
28
|
+
agent?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
instructions?: string;
|
|
31
|
+
input?: Shape;
|
|
32
|
+
output?: Shape;
|
|
33
|
+
computer?: "plain" | "browser";
|
|
34
|
+
repo?: string;
|
|
35
|
+
ref?: string;
|
|
36
|
+
image?: string;
|
|
37
|
+
tools?: string[];
|
|
38
|
+
ask_first?: string[];
|
|
39
|
+
check?: string;
|
|
40
|
+
limit?: Limit;
|
|
41
|
+
steps?: Step[];
|
|
42
|
+
/** What the repository's tests need beside the run: a database, a cache. Usually said in the repository's own `sensei.yaml`. */
|
|
43
|
+
services?: Record<string, Record<string, unknown>>;
|
|
44
|
+
/** Commands that prepare the computer before the work starts. */
|
|
45
|
+
setup?: string[];
|
|
46
|
+
/** Plain values in the environment of everything the run does. */
|
|
47
|
+
env?: Record<string, string>;
|
|
48
|
+
/** Names of the project's secrets the setup commands are given, and nothing else is. */
|
|
49
|
+
secrets?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* A batch: one entry for each change to `repo`, each a run of its own. Or the input field that holds
|
|
52
|
+
* the list, such as `"$input.changes"` with `input: { changes: "list" }`: the list is then given when
|
|
53
|
+
* the batch is started, which is how a step hands a batch the tasks an earlier step listed.
|
|
54
|
+
*/
|
|
55
|
+
tasks?: string[] | string;
|
|
56
|
+
/** A batch: how many tasks work at once, 1 to 10. */
|
|
57
|
+
parallel?: number;
|
|
58
|
+
/** A batch: test the verified changes together before any pull request. On unless false. */
|
|
59
|
+
together?: boolean;
|
|
60
|
+
/** A batch: a pull request for each verified change, saying how it fits with the rest, or one holding the changes that fit. */
|
|
61
|
+
deliver?: BatchDeliver;
|
|
62
|
+
/** A batch: what all of it may use. `limit` is what each task may. */
|
|
63
|
+
total?: {
|
|
64
|
+
usd?: number;
|
|
65
|
+
minutes?: number;
|
|
66
|
+
};
|
|
67
|
+
/** The order the fields were written in. The service works it out. */
|
|
68
|
+
order?: {
|
|
69
|
+
input?: string[];
|
|
70
|
+
output?: string[];
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** What a waiting run is asking: the action, its arguments, and why. */
|
|
74
|
+
export interface Ask {
|
|
75
|
+
action: string;
|
|
76
|
+
tool?: string;
|
|
77
|
+
arguments?: Record<string, unknown>;
|
|
78
|
+
why?: string;
|
|
79
|
+
/** On a run with steps: the step that is asking. */
|
|
80
|
+
step?: string | null;
|
|
81
|
+
/** On a change waiting to be pushed: the size of the change. */
|
|
82
|
+
diff_stat?: unknown;
|
|
83
|
+
}
|
|
84
|
+
export interface StartedWith {
|
|
85
|
+
learnings?: number | null;
|
|
86
|
+
/** What the team corrected before, carried into this run. */
|
|
87
|
+
kept?: Array<{
|
|
88
|
+
text?: string;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
/** One step of a run with steps, as its result lists it. */
|
|
92
|
+
export interface StepSummary {
|
|
93
|
+
id: string;
|
|
94
|
+
status?: RunStatus;
|
|
95
|
+
runs?: string[];
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
export type BatchDeliver = "each" | "one";
|
|
99
|
+
/** One task of a batch: how it did alone, and how it fits with the others. */
|
|
100
|
+
export interface BatchTask {
|
|
101
|
+
/** From 1, in the order the tasks were given. */
|
|
102
|
+
index: number;
|
|
103
|
+
task: string;
|
|
104
|
+
/** Its own run, once it has started. */
|
|
105
|
+
run: string | null;
|
|
106
|
+
/** Alone: its run's status, or `pending` / `not_started` before it has one. */
|
|
107
|
+
status: RunStatus | "pending" | "not_started";
|
|
108
|
+
summary?: string;
|
|
109
|
+
error?: string;
|
|
110
|
+
branch?: string | null;
|
|
111
|
+
pr_url?: string | null;
|
|
112
|
+
usd?: number;
|
|
113
|
+
seconds?: number;
|
|
114
|
+
/** Together with the other verified changes. Absent until they were tested together. */
|
|
115
|
+
together?: "fits" | "conflict" | "breaks" | "merged" | "untested" | (string & {});
|
|
116
|
+
/** Why it was left out, in a sentence. */
|
|
117
|
+
note?: string;
|
|
118
|
+
}
|
|
119
|
+
/** What testing a batch's verified changes together found. */
|
|
120
|
+
export interface BatchTogether {
|
|
121
|
+
status: "passed" | "failed" | "not_finished" | "no_tests" | "alone" | "merged" | "nothing" | "off" | "not_run" | (string & {});
|
|
122
|
+
/** The tasks whose changes merge, by index. */
|
|
123
|
+
merged?: number[];
|
|
124
|
+
left_out?: Array<{
|
|
125
|
+
index: number;
|
|
126
|
+
why: string;
|
|
127
|
+
with?: number[];
|
|
128
|
+
files?: string[];
|
|
129
|
+
failing?: string[];
|
|
130
|
+
}>;
|
|
131
|
+
base_sha?: string | null;
|
|
132
|
+
base_ref?: string | null;
|
|
133
|
+
/** The run that tested them. */
|
|
134
|
+
run?: string;
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
}
|
|
137
|
+
/** A batch: `result.batch` of a run started with `tasks`. */
|
|
138
|
+
export interface BatchData {
|
|
139
|
+
tasks: BatchTask[];
|
|
140
|
+
counts: {
|
|
141
|
+
total: number;
|
|
142
|
+
verified: number;
|
|
143
|
+
/** How many fit together; null until they were tested together. */
|
|
144
|
+
fit: number | null;
|
|
145
|
+
working: number;
|
|
146
|
+
failed: number;
|
|
147
|
+
pending: number;
|
|
148
|
+
pull_requests: number;
|
|
149
|
+
};
|
|
150
|
+
parallel: number;
|
|
151
|
+
deliver: BatchDeliver;
|
|
152
|
+
limit: Limit;
|
|
153
|
+
total: {
|
|
154
|
+
usd?: number;
|
|
155
|
+
minutes?: number;
|
|
156
|
+
};
|
|
157
|
+
base_sha: string | null;
|
|
158
|
+
base_ref: string | null;
|
|
159
|
+
phase: "tasks" | "together" | "deliver" | "done" | (string & {});
|
|
160
|
+
/** 1, and one more each time it was checked again. */
|
|
161
|
+
round: number;
|
|
162
|
+
together?: BatchTogether;
|
|
163
|
+
/** Why no further task started: the ceiling that was reached. */
|
|
164
|
+
stopped?: string;
|
|
165
|
+
/** With `deliver: "one"`: the pull request that holds them all. */
|
|
166
|
+
pr_url?: string;
|
|
167
|
+
/** With more than one pull request: all of them, on the repository's host. */
|
|
168
|
+
pull_requests_url?: string;
|
|
169
|
+
}
|
|
170
|
+
/** A run's `result`. What is in it depends on the kind of run. */
|
|
171
|
+
export interface RunResultData {
|
|
172
|
+
kind?: "agent" | "steps" | "batch" | (string & {});
|
|
173
|
+
/** On a batch. */
|
|
174
|
+
batch?: BatchData;
|
|
175
|
+
/** On a run that ended `missing_setting`: the names its tests need and were not given. */
|
|
176
|
+
missing?: string[];
|
|
177
|
+
output?: unknown;
|
|
178
|
+
summary?: string;
|
|
179
|
+
evidence?: string[];
|
|
180
|
+
not_sure?: string[];
|
|
181
|
+
started_with?: StartedWith;
|
|
182
|
+
ask?: Ask;
|
|
183
|
+
/** A list on a run with steps; a count on a run of one agent. */
|
|
184
|
+
steps?: StepSummary[] | number;
|
|
185
|
+
diff_stat?: unknown;
|
|
186
|
+
patch?: string;
|
|
187
|
+
[key: string]: unknown;
|
|
188
|
+
}
|
|
189
|
+
export interface Usage {
|
|
190
|
+
/** Everything the run cost: its model calls, its computer and the services beside it. */
|
|
191
|
+
usd?: number;
|
|
192
|
+
seconds?: number;
|
|
193
|
+
/** Of `usd`: the model calls, and the computer for the seconds it was up. */
|
|
194
|
+
tokens_usd?: number;
|
|
195
|
+
computer_usd?: number;
|
|
196
|
+
computer_seconds?: number;
|
|
197
|
+
/** Of `usd`: the services beside the run (a database its tests need), summed over them. Only on a run that had any. */
|
|
198
|
+
services_usd?: number;
|
|
199
|
+
services_seconds?: number;
|
|
200
|
+
[key: string]: unknown;
|
|
201
|
+
}
|
|
202
|
+
/** A run, as the API returns it. */
|
|
203
|
+
export interface Run {
|
|
204
|
+
id: string;
|
|
205
|
+
object: "run";
|
|
206
|
+
project_id: string | null;
|
|
207
|
+
agent: string | null;
|
|
208
|
+
agent_version: number | null;
|
|
209
|
+
input: Record<string, unknown> | null;
|
|
210
|
+
output: unknown;
|
|
211
|
+
ask: Ask | null;
|
|
212
|
+
parent_run_id: string | null;
|
|
213
|
+
step: string | null;
|
|
214
|
+
step_item: number | null;
|
|
215
|
+
outcome: "success" | "failure" | null;
|
|
216
|
+
outcome_note: string | null;
|
|
217
|
+
outcome_at: string | null;
|
|
218
|
+
repo_url: string;
|
|
219
|
+
base_ref: string | null;
|
|
220
|
+
base_sha: string | null;
|
|
221
|
+
task: string;
|
|
222
|
+
model: string;
|
|
223
|
+
budget: Budget;
|
|
224
|
+
attempts: number;
|
|
225
|
+
policy: Record<string, unknown>;
|
|
226
|
+
status: RunStatus;
|
|
227
|
+
waiting_for: "ask" | "approval" | "step" | (string & {}) | null;
|
|
228
|
+
result: RunResultData | null;
|
|
229
|
+
usage: Usage;
|
|
230
|
+
error: string | null;
|
|
231
|
+
created_at: string;
|
|
232
|
+
started_at: string | null;
|
|
233
|
+
finished_at: string | null;
|
|
234
|
+
url: string | null;
|
|
235
|
+
/** The schedule that started it, when one did. */
|
|
236
|
+
schedule_id?: string | null;
|
|
237
|
+
/** On a queued run: no computer is free yet (`computer`), or one is starting (`computer_starting`). */
|
|
238
|
+
waiting_on?: "computer" | "computer_starting" | (string & {});
|
|
239
|
+
/** On a run with steps (`GET /v1/runs/{id}`): each step, as a run. */
|
|
240
|
+
steps?: Run[];
|
|
241
|
+
/** After `answer`: whether a correction was kept for later runs. */
|
|
242
|
+
kept?: boolean;
|
|
243
|
+
/** After `answer` on a run with steps: the run whose step was answered. */
|
|
244
|
+
answered_step_of?: string;
|
|
245
|
+
/** After `outcome`: how many sessions it was learned from. */
|
|
246
|
+
learned_from?: number;
|
|
247
|
+
}
|
|
248
|
+
export interface RunEvent {
|
|
249
|
+
seq: number;
|
|
250
|
+
kind: string;
|
|
251
|
+
attempt: number | null;
|
|
252
|
+
data: Record<string, unknown>;
|
|
253
|
+
at: string | null;
|
|
254
|
+
}
|
|
255
|
+
/** The numbers a team watches for one agent. */
|
|
256
|
+
export interface AgentNumbers {
|
|
257
|
+
days: number;
|
|
258
|
+
runs: number;
|
|
259
|
+
verdicts: number;
|
|
260
|
+
correct: number;
|
|
261
|
+
correct_rate: number | null;
|
|
262
|
+
unchecked: number;
|
|
263
|
+
asked_runs: number;
|
|
264
|
+
asked_rate: number | null;
|
|
265
|
+
avg_steps: number | null;
|
|
266
|
+
usd: number;
|
|
267
|
+
cost_per_correct: number | null;
|
|
268
|
+
waiting: number;
|
|
269
|
+
last_run_at: string | null;
|
|
270
|
+
}
|
|
271
|
+
/** A correction the team made, kept for the agent's later runs. */
|
|
272
|
+
export interface Note {
|
|
273
|
+
id: string;
|
|
274
|
+
text: string;
|
|
275
|
+
run_id: string | null;
|
|
276
|
+
said_through: string | null;
|
|
277
|
+
created_at: string;
|
|
278
|
+
}
|
|
279
|
+
export interface AgentVersion {
|
|
280
|
+
version: number;
|
|
281
|
+
source: string;
|
|
282
|
+
created_at: string;
|
|
283
|
+
}
|
|
284
|
+
/** A definition saved under a name. */
|
|
285
|
+
export interface Agent {
|
|
286
|
+
object: "agent";
|
|
287
|
+
name: string;
|
|
288
|
+
version: number;
|
|
289
|
+
description: string | null;
|
|
290
|
+
kind: "agent" | "steps";
|
|
291
|
+
source: string;
|
|
292
|
+
updated_at: string;
|
|
293
|
+
/** Not in `agents.list()`. */
|
|
294
|
+
definition?: Definition;
|
|
295
|
+
/** In `agents.list()` and `agents.get()`. */
|
|
296
|
+
numbers?: AgentNumbers;
|
|
297
|
+
/** In `agents.get()`. */
|
|
298
|
+
versions?: AgentVersion[];
|
|
299
|
+
/** In `agents.get()`: what the team corrected. */
|
|
300
|
+
kept?: Note[];
|
|
301
|
+
/** After `agents.save()`: false when the same definition was saved before. */
|
|
302
|
+
created?: boolean;
|
|
303
|
+
/** After `agents.save()`: tools it names that are not connected. */
|
|
304
|
+
missing_tools?: string[];
|
|
305
|
+
}
|
|
306
|
+
/** Whether a definition would run, and what it needs. */
|
|
307
|
+
export interface AgentCheck {
|
|
308
|
+
ok: boolean;
|
|
309
|
+
error?: string;
|
|
310
|
+
missing_tools?: string[];
|
|
311
|
+
/** Secrets it names that the project does not have. */
|
|
312
|
+
missing_secrets?: string[];
|
|
313
|
+
needs?: {
|
|
314
|
+
kind: "agent" | "steps" | "repo" | "batch";
|
|
315
|
+
/** On a batch: how many tasks, or null when they are given when it is started. */
|
|
316
|
+
tasks?: number | null;
|
|
317
|
+
/** On a batch whose tasks are given when it is started: the input field that holds them. */
|
|
318
|
+
tasks_from?: string;
|
|
319
|
+
parallel?: number;
|
|
320
|
+
together?: boolean;
|
|
321
|
+
deliver?: BatchDeliver;
|
|
322
|
+
services?: string[];
|
|
323
|
+
secrets?: string[];
|
|
324
|
+
steps: string[];
|
|
325
|
+
computer: string | null;
|
|
326
|
+
tools: string[];
|
|
327
|
+
asks_first: string[];
|
|
328
|
+
check: boolean;
|
|
329
|
+
input: Shape;
|
|
330
|
+
output: Shape;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** One of the team's own systems, connected on the project. */
|
|
334
|
+
export interface Tool {
|
|
335
|
+
id: string;
|
|
336
|
+
object: "tool";
|
|
337
|
+
name: string;
|
|
338
|
+
url: string;
|
|
339
|
+
header_name: string;
|
|
340
|
+
/** The last characters of the secret, never the secret. */
|
|
341
|
+
secret: string | null;
|
|
342
|
+
scope: "project" | "account";
|
|
343
|
+
created_at: string;
|
|
344
|
+
/** After `tools.connect()`: what the tool offers. */
|
|
345
|
+
actions?: string[];
|
|
346
|
+
}
|
|
347
|
+
export interface Repo {
|
|
348
|
+
id: string;
|
|
349
|
+
object: "repo";
|
|
350
|
+
url: string;
|
|
351
|
+
host: string;
|
|
352
|
+
default_branch: string | null;
|
|
353
|
+
/** The last characters of the token, never the token. */
|
|
354
|
+
token: string | null;
|
|
355
|
+
created_at: string;
|
|
356
|
+
}
|
|
357
|
+
/** An agent run on a timetable. */
|
|
358
|
+
export interface Schedule {
|
|
359
|
+
id: string;
|
|
360
|
+
object: "schedule";
|
|
361
|
+
agent: string;
|
|
362
|
+
input: Record<string, unknown> | null;
|
|
363
|
+
/** As it was written: "every weekday at 09:00". */
|
|
364
|
+
when: string;
|
|
365
|
+
cron: string;
|
|
366
|
+
timezone: string;
|
|
367
|
+
enabled: boolean;
|
|
368
|
+
next_run_at: string | null;
|
|
369
|
+
last_run_at: string | null;
|
|
370
|
+
last_run_id: string | null;
|
|
371
|
+
last_status: RunStatus | null;
|
|
372
|
+
paused_reason: string | null;
|
|
373
|
+
created_at: string;
|
|
374
|
+
}
|
|
375
|
+
export type Decision = "approve" | "correct" | "reject";
|
|
376
|
+
export type Outcome = "right" | "wrong";
|
|
377
|
+
/**
|
|
378
|
+
* What a run is started with. One of: `agent` (a saved agent, by name),
|
|
379
|
+
* `definition` (what a definition file holds), or `task` in words (with
|
|
380
|
+
* `repo` it is a change to that repository).
|
|
381
|
+
*/
|
|
382
|
+
export interface RunCreateParams {
|
|
383
|
+
agent?: string;
|
|
384
|
+
definition?: Definition;
|
|
385
|
+
task?: string;
|
|
386
|
+
repo?: string;
|
|
387
|
+
/** The agent's input. */
|
|
388
|
+
input?: Record<string, unknown>;
|
|
389
|
+
/** With a named `definition`: false runs it without saving it. */
|
|
390
|
+
save?: boolean;
|
|
391
|
+
tools?: string[];
|
|
392
|
+
askFirst?: string[];
|
|
393
|
+
computer?: "plain" | "browser";
|
|
394
|
+
output?: Shape;
|
|
395
|
+
check?: string;
|
|
396
|
+
baseRef?: string;
|
|
397
|
+
attempts?: number;
|
|
398
|
+
budget?: Budget;
|
|
399
|
+
openPr?: boolean;
|
|
400
|
+
approveBeforePush?: boolean;
|
|
401
|
+
dryRun?: boolean;
|
|
402
|
+
branch?: string;
|
|
403
|
+
callbackUrl?: string;
|
|
404
|
+
testCommand?: string;
|
|
405
|
+
image?: string;
|
|
406
|
+
/** A change to a repository that fixes this pull request. */
|
|
407
|
+
pr?: number;
|
|
408
|
+
}
|
|
409
|
+
/** A batch: many changes to one repository. */
|
|
410
|
+
export interface BatchParams {
|
|
411
|
+
/** The repository every task changes: its URL, or `org/name`. */
|
|
412
|
+
repo: string;
|
|
413
|
+
/** One entry for each change. Each is worked alone, from the same commit. */
|
|
414
|
+
tasks: string[];
|
|
415
|
+
/** The branch or commit to start from. Default: the default branch. */
|
|
416
|
+
ref?: string;
|
|
417
|
+
/** Said once, for every task. */
|
|
418
|
+
instructions?: string;
|
|
419
|
+
/** How many tasks work at once, 1 to 10. Default 4. */
|
|
420
|
+
parallel?: number;
|
|
421
|
+
/** Test the verified changes together before any pull request. Default true. */
|
|
422
|
+
together?: boolean;
|
|
423
|
+
deliver?: BatchDeliver;
|
|
424
|
+
/** What one task may use. */
|
|
425
|
+
limit?: Limit;
|
|
426
|
+
/** What the batch may use. When it is reached the tasks still working are stopped, none is started, and what verified is kept. */
|
|
427
|
+
total?: {
|
|
428
|
+
usd?: number;
|
|
429
|
+
minutes?: number;
|
|
430
|
+
};
|
|
431
|
+
check?: string;
|
|
432
|
+
/** Names of the project's secrets the setup commands are given. */
|
|
433
|
+
secrets?: string[];
|
|
434
|
+
}
|
|
435
|
+
/** A plain value or a secret a project's runs are given by name. */
|
|
436
|
+
export interface Setting {
|
|
437
|
+
id: string;
|
|
438
|
+
object: "setting";
|
|
439
|
+
name: string;
|
|
440
|
+
kind: "setting" | "secret";
|
|
441
|
+
/** A setting's value. A secret's is never returned. */
|
|
442
|
+
value: string | null;
|
|
443
|
+
scope: "project" | "account";
|
|
444
|
+
last_used_at: string | null;
|
|
445
|
+
created_at: string;
|
|
446
|
+
updated_at: string;
|
|
447
|
+
}
|
|
448
|
+
export interface SettingsList {
|
|
449
|
+
data: Setting[];
|
|
450
|
+
/** Names recent runs needed and were not given. */
|
|
451
|
+
needed: Array<{
|
|
452
|
+
name: string;
|
|
453
|
+
runs: number;
|
|
454
|
+
[key: string]: unknown;
|
|
455
|
+
}>;
|
|
456
|
+
}
|
|
457
|
+
export interface RunListParams {
|
|
458
|
+
status?: RunStatus;
|
|
459
|
+
limit?: number;
|
|
460
|
+
agent?: string;
|
|
461
|
+
/** The steps of this run. */
|
|
462
|
+
parent?: string;
|
|
463
|
+
}
|
|
464
|
+
export interface WaitOptions {
|
|
465
|
+
/** Return the run as it is when this much time is up. */
|
|
466
|
+
timeoutMs?: number;
|
|
467
|
+
pollMs?: number;
|
|
468
|
+
}
|
|
469
|
+
export interface OutcomeOptions {
|
|
470
|
+
note?: string;
|
|
471
|
+
/** On a run with steps: the step that was wrong. */
|
|
472
|
+
step?: string;
|
|
473
|
+
}
|
|
474
|
+
export interface ScheduleCreateParams {
|
|
475
|
+
agent: string;
|
|
476
|
+
/** Words such as "every weekday at 09:00", or a 5-field cron expression. */
|
|
477
|
+
when: string;
|
|
478
|
+
input?: Record<string, unknown>;
|
|
479
|
+
timezone?: string;
|
|
480
|
+
}
|
|
481
|
+
export interface ScheduleUpdateParams {
|
|
482
|
+
when?: string;
|
|
483
|
+
input?: Record<string, unknown>;
|
|
484
|
+
timezone?: string;
|
|
485
|
+
enabled?: boolean;
|
|
486
|
+
}
|
|
487
|
+
/** Where a project's model is, in one word. */
|
|
488
|
+
export type ModelState = "collecting" | "queued" | "training" | "checking" | "waiting" | "on_trial" | "live" | "no_room" | "taken_off" | "on_hold" | (string & {});
|
|
489
|
+
export type ModelVersionState = "live" | "previous" | "waiting" | "on_trial" | "rejected" | "discarded" | "rolled_back" | "failed" | "queued" | "training" | "checking" | (string & {});
|
|
490
|
+
/** How a new version goes live: by itself, or after a decision. */
|
|
491
|
+
export type Promotion = "auto" | "review";
|
|
492
|
+
/** The share of sessions a version is tried on, in percent. 0 stops the trial. */
|
|
493
|
+
export type TrialShare = 0 | 5 | 10 | 25 | 50;
|
|
494
|
+
export interface ModelProject {
|
|
495
|
+
id: string | null;
|
|
496
|
+
name: string | null;
|
|
497
|
+
slug: string | null;
|
|
498
|
+
}
|
|
499
|
+
/** What a version's check on held-out steps found. Rates are 0 to 1. */
|
|
500
|
+
export interface ModelCheck {
|
|
501
|
+
passed: boolean | null;
|
|
502
|
+
steps: number | null;
|
|
503
|
+
rate: number | null;
|
|
504
|
+
compared_rate: number | null;
|
|
505
|
+
/** `base`, or a version such as `v2`. */
|
|
506
|
+
compared_with: string | null;
|
|
507
|
+
}
|
|
508
|
+
export interface ModelVersion {
|
|
509
|
+
id: string;
|
|
510
|
+
/** Set once the version is live or waiting. */
|
|
511
|
+
number: number | null;
|
|
512
|
+
state: ModelVersionState;
|
|
513
|
+
reason: string | null;
|
|
514
|
+
/** Turns it learned from. */
|
|
515
|
+
trained_on: number;
|
|
516
|
+
held_out: number;
|
|
517
|
+
check: ModelCheck | null;
|
|
518
|
+
/** How its sessions turned out since it was served: counts and rates. */
|
|
519
|
+
record: Record<string, unknown> | null;
|
|
520
|
+
serving: {
|
|
521
|
+
state?: string;
|
|
522
|
+
since?: string | null;
|
|
523
|
+
reason?: string | null;
|
|
524
|
+
} | null;
|
|
525
|
+
/** Before it has finished: waiting for a machine, or what its machine last reported. Null once it has. */
|
|
526
|
+
progress: ModelProgress | null;
|
|
527
|
+
/** A run of several passes: how each did on the held-out steps and which went forward. */
|
|
528
|
+
passes: ModelPasses | null;
|
|
529
|
+
/** "withdrawn" for a version made because turns were withdrawn: it is not tried first. */
|
|
530
|
+
cause: string | null;
|
|
531
|
+
created_at: string | null;
|
|
532
|
+
trained_at: string | null;
|
|
533
|
+
decided_at: string | null;
|
|
534
|
+
}
|
|
535
|
+
/** Where a run that has not finished stands. At most about three minutes old. */
|
|
536
|
+
export interface ModelProgress {
|
|
537
|
+
state: "queued" | "starting" | "preparing" | "training" | "exporting";
|
|
538
|
+
queued_at: string | null;
|
|
539
|
+
launched_at: string | null;
|
|
540
|
+
/** Which machine this is for the run: 1 to 3. */
|
|
541
|
+
attempt: number;
|
|
542
|
+
/** Why the machine before this one was replaced, when it was. */
|
|
543
|
+
again: "interrupted" | "lost" | null;
|
|
544
|
+
/** Why it is still waiting, in a sentence. */
|
|
545
|
+
waiting_for: string | null;
|
|
546
|
+
at?: string | null;
|
|
547
|
+
started_at?: string | null;
|
|
548
|
+
step?: number | null;
|
|
549
|
+
total_steps?: number | null;
|
|
550
|
+
pass?: number | null;
|
|
551
|
+
passes?: number | null;
|
|
552
|
+
steps_per_pass?: number | null;
|
|
553
|
+
/** Points of `[step, loss]`, as they arrive. */
|
|
554
|
+
loss?: {
|
|
555
|
+
train: [number, number][];
|
|
556
|
+
val: [number, number][];
|
|
557
|
+
} | null;
|
|
558
|
+
}
|
|
559
|
+
export interface ModelPasses {
|
|
560
|
+
/** The pass that went forward. Null while they are still being compared. */
|
|
561
|
+
chosen: number | null;
|
|
562
|
+
/** False when nothing could compare them and the last pass went forward. */
|
|
563
|
+
compared: boolean | null;
|
|
564
|
+
passes: {
|
|
565
|
+
pass: number;
|
|
566
|
+
step: number | null;
|
|
567
|
+
/** How often it chose the step that worked, 0 to 1. */
|
|
568
|
+
agreement: number | null;
|
|
569
|
+
n: number | null;
|
|
570
|
+
chosen: boolean;
|
|
571
|
+
skipped: string | null;
|
|
572
|
+
}[];
|
|
573
|
+
}
|
|
574
|
+
/** One side of a comparison on the project's own sessions: counts and rates. */
|
|
575
|
+
export type ModelSide = Record<string, unknown>;
|
|
576
|
+
/** A live version beside the base model, or that the last one was taken off. */
|
|
577
|
+
export interface ModelWatch {
|
|
578
|
+
taken_off: boolean;
|
|
579
|
+
at: string | null;
|
|
580
|
+
since?: string | null;
|
|
581
|
+
reason?: string | null;
|
|
582
|
+
version?: ModelSide | null;
|
|
583
|
+
base?: ModelSide | null;
|
|
584
|
+
verdict?: {
|
|
585
|
+
state?: string;
|
|
586
|
+
reason?: string;
|
|
587
|
+
} | null;
|
|
588
|
+
/** After a version was taken off: a new one is trained from what the project keeps now. */
|
|
589
|
+
retrain_requested?: boolean;
|
|
590
|
+
}
|
|
591
|
+
export interface ModelTrial {
|
|
592
|
+
share: number;
|
|
593
|
+
started_at: string | null;
|
|
594
|
+
/** Whether Sensei stops the trial by itself when the version is clearly behind. */
|
|
595
|
+
guard: boolean;
|
|
596
|
+
verdict: {
|
|
597
|
+
state?: string;
|
|
598
|
+
reason?: string;
|
|
599
|
+
} | null;
|
|
600
|
+
candidate: Record<string, unknown> | null;
|
|
601
|
+
live: Record<string, unknown> | null;
|
|
602
|
+
}
|
|
603
|
+
export interface ModelCandidate extends ModelVersion {
|
|
604
|
+
since: string | null;
|
|
605
|
+
/** When it is set aside if nobody decides. Null while a trial runs. */
|
|
606
|
+
expires_at: string | null;
|
|
607
|
+
/** Who decides it: Sensei by itself, or a person. */
|
|
608
|
+
decided_by: "sensei" | "person";
|
|
609
|
+
/** The day Sensei decides a trial it started, at the latest. */
|
|
610
|
+
decides_by: string | null;
|
|
611
|
+
/** The end-to-end check, where the project requires one before a version goes live. */
|
|
612
|
+
e2e: {
|
|
613
|
+
state: "clear" | "waiting" | "behind";
|
|
614
|
+
reason: string | null;
|
|
615
|
+
} | null;
|
|
616
|
+
trial: ModelTrial;
|
|
617
|
+
}
|
|
618
|
+
export interface ModelSettings {
|
|
619
|
+
promotion: Promotion;
|
|
620
|
+
/** The share of sessions a version is tried on by itself before it goes live. Null where it cannot be set. */
|
|
621
|
+
trial_share: number | null;
|
|
622
|
+
emails: boolean;
|
|
623
|
+
}
|
|
624
|
+
/** Where the project's model is: what `client.model.get()` answers. */
|
|
625
|
+
export interface ProjectModel {
|
|
626
|
+
object: "model";
|
|
627
|
+
project: ModelProject;
|
|
628
|
+
state: ModelState;
|
|
629
|
+
/** The state in a sentence. */
|
|
630
|
+
summary: string;
|
|
631
|
+
reason: string | null;
|
|
632
|
+
held_until: string | null;
|
|
633
|
+
/** What the project's keys are answered by right now. */
|
|
634
|
+
served: {
|
|
635
|
+
by: "version" | "base";
|
|
636
|
+
version: number | null;
|
|
637
|
+
};
|
|
638
|
+
live: ModelVersion | null;
|
|
639
|
+
candidate: ModelCandidate | null;
|
|
640
|
+
/** The run in flight: queued, training or being checked. */
|
|
641
|
+
training: ModelVersion | null;
|
|
642
|
+
/** The live version beside the base model on the project's own results. Null where nothing is compared. */
|
|
643
|
+
watch: ModelWatch | null;
|
|
644
|
+
settings: ModelSettings;
|
|
645
|
+
trial_shares: number[];
|
|
646
|
+
/** Whether a version of a project that goes live by itself is tried on `settings.trial_share` of sessions first. */
|
|
647
|
+
trial_by_default: boolean;
|
|
648
|
+
/** Whether this key may promote, discard, roll back and change settings. */
|
|
649
|
+
can_manage: boolean | null;
|
|
650
|
+
at: string;
|
|
651
|
+
/** With `get({ page: true })`: everything the dashboard's model page shows. */
|
|
652
|
+
page?: Record<string, unknown>;
|
|
653
|
+
}
|
|
654
|
+
export type ModelEventType = "training.queued" | "training.started" | "training.requeued" | "training.finished" | "training.failed" | "training.on_hold" | "version.waiting" | "version.on_trial" | "version.trial_changed" | "version.trial_stopped" | "version.live" | "version.discarded" | "version.expiring" | "version.expired" | "version.rolled_back" | "version.taken_off" | "version.not_served" | "settings.promotion" | (string & {});
|
|
655
|
+
export interface ModelEvent {
|
|
656
|
+
id: number;
|
|
657
|
+
type: ModelEventType;
|
|
658
|
+
created_at: string | null;
|
|
659
|
+
project: ModelProject;
|
|
660
|
+
data: {
|
|
661
|
+
version: number | null;
|
|
662
|
+
run_id: string | null;
|
|
663
|
+
/** Sensei by itself, a person on the dashboard, or a key (its first characters). */
|
|
664
|
+
by: {
|
|
665
|
+
type: "sensei" | "person" | "key";
|
|
666
|
+
id?: string | null;
|
|
667
|
+
prefix?: string | null;
|
|
668
|
+
};
|
|
669
|
+
[field: string]: unknown;
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
export interface ModelEventsPage {
|
|
673
|
+
data: ModelEvent[];
|
|
674
|
+
/** Pass as `since` to read only what came after. */
|
|
675
|
+
cursor: number;
|
|
676
|
+
has_more: boolean;
|
|
677
|
+
}
|
|
678
|
+
export interface ModelEventsParams {
|
|
679
|
+
/** An event id (a `cursor`) or an ISO time. */
|
|
680
|
+
since?: number | string;
|
|
681
|
+
limit?: number;
|
|
682
|
+
}
|
|
683
|
+
export interface ModelWaitOptions {
|
|
684
|
+
/** Stop when the state is one of these. Default: a state that stays until someone acts. */
|
|
685
|
+
until?: readonly ModelState[];
|
|
686
|
+
/** Return the model as it is when this much time is up. */
|
|
687
|
+
timeoutMs?: number;
|
|
688
|
+
pollMs?: number;
|
|
689
|
+
}
|
|
690
|
+
export interface ModelSettingsParams {
|
|
691
|
+
promotion?: Promotion;
|
|
692
|
+
trialShare?: number;
|
|
693
|
+
emails?: boolean;
|
|
694
|
+
}
|
|
695
|
+
/** What a decision answers with: what it did, and the model as it is after. */
|
|
696
|
+
export interface ModelDecision<T = Record<string, unknown>> {
|
|
697
|
+
result: T;
|
|
698
|
+
model: ProjectModel;
|
|
699
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the API sends and takes. Fields are named as the API names them
|
|
3
|
+
* (snake_case): a value read from the service is not renamed on the way in.
|
|
4
|
+
* Options you pass (`askFirst`, `baseRef`, ...) are camelCase, and are
|
|
5
|
+
* renamed once, in client.ts.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|