@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 CHANGED
@@ -1,3 +1,286 @@
1
- # Temporary Holding Version
1
+ # @senselab-ai/sensei
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run Sensei agents from JavaScript and TypeScript. Needs Node 18 or later.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @senselab-ai/sensei
9
+ export SENSEI_API_KEY=... # create a key on the Access management page
10
+ ```
11
+
12
+ If you have run `sensei login` with the `sensei` command, that key is used. `SENSEI_RUNS_URL` changes the address.
13
+
14
+ ## Update
15
+
16
+ ```sh
17
+ npm install @senselab-ai/sensei@latest
18
+ ```
19
+
20
+ `VERSION` is the version that is installed:
21
+
22
+ ```ts
23
+ import { VERSION } from "@senselab-ai/sensei";
24
+ ```
25
+
26
+ ## Run something
27
+
28
+ ```ts
29
+ import { Sensei, Client, SenseiError } from "@senselab-ai/sensei";
30
+
31
+ const sensei = new Sensei(); // key and base URL from env, or new Sensei({ apiKey, baseUrl, fetch })
32
+ const r = await sensei.run("refund-requests", { input: { ticket: 48213 } }); // a saved agent by name
33
+ const r2 = await sensei.run("./refunds.yaml", { input: { ticket: 48213 } }); // a definition file
34
+ const r3 = await sensei.run({ agent: "x", instructions: "..." }, { input: {} }); // a definition object
35
+ const r4 = await sensei.run("Summarise the open tickets", { tools: ["helpdesk"] }); // a task in words
36
+ if (r.waiting) { console.log(r.ask); await r.answer("approve"); } // or r.answer("correct", "give store credit instead"), r.answer("reject")
37
+ console.log(r.status, r.ok, r.output, r.evidence, r.notSure, r.startedWith, r.cost, r.url);
38
+ await r.outcome("right", { note: "customer confirmed" });
39
+ const many = await sensei.map("refund-requests", [{ ticket: 1 }, { ticket: 2 }], { parallel: 4 });
40
+ const started = await sensei.start("refund-requests", { input: { ticket: 1 } }); // does not wait
41
+ ```
42
+
43
+ `run` waits until the run has finished or has a question for a person. `start` returns at once.
44
+
45
+ The first argument is read like this:
46
+
47
+ - An object is a definition.
48
+ - A string that ends in `.yaml`, `.yml` or `.json`, or that is a file on disk, is a definition file.
49
+ - Any other string with no space in it is a saved agent's name.
50
+ - Anything else is a task in words.
51
+
52
+ For a task of one word, pass `task`: `sensei.run(null, { task: "Summarise" })`.
53
+
54
+ ## What comes back
55
+
56
+ - `status`: `queued`, `running`, `waiting`, `done`, `verified`, `unverified`, `failed` or `cancelled`.
57
+ - `ok`: true when the status is `done` or `verified`.
58
+ - `output`: in the shape the definition names.
59
+ - `summary`: what it did, in a sentence.
60
+ - `evidence`: what Sensei checked.
61
+ - `notSure`: what it could not confirm.
62
+ - `startedWith`: `{ learnings, corrections }`. The number of Learnings the run started with, and what your team corrected before.
63
+ - `cost`: in US dollars.
64
+ - `url`: the run's page.
65
+ - `error`: why it failed, when it did.
66
+ - `run`: the run as the API returned it.
67
+
68
+ ## Options
69
+
70
+ `input` is the agent's input. The rest are options of the run:
71
+
72
+ `repo`, `tools`, `askFirst`, `computer`, `output`, `check`, `baseRef`, `attempts`, `budget`, `openPr`, `approveBeforePush`, `dryRun`, `branch`, `callbackUrl`, `testCommand`, `image`, `save`, `pr`.
73
+
74
+ ```ts
75
+ // A change to a repository.
76
+ await sensei.run("Fix the failing test", { repo: "https://github.com/acme/shop", openPr: true });
77
+
78
+ // Fix an open pull request, by its number.
79
+ await sensei.run("Do what the review asks", { repo: "https://github.com/acme/shop", pr: 212 });
80
+
81
+ // Spend at most one dollar. Stop waiting after a minute.
82
+ await sensei.run("refund-requests", { input: { ticket: 48213 }, budget: { usd: 1 }, timeoutMs: 60_000 });
83
+ ```
84
+
85
+ ## Answer a waiting run
86
+
87
+ A run waits when it reaches an action your team marked `ask_first`. `r.ask` says what it wants to do, and why.
88
+
89
+ ```ts
90
+ if (r.waiting) {
91
+ console.log(r.ask); // { tool: "stripe", action: "refund", arguments: { order: 9917, amount: 32 }, why: "..." }
92
+ await r.answer("approve");
93
+ // or: await r.answer("correct", "give store credit instead");
94
+ // or: await r.answer("reject");
95
+ }
96
+ ```
97
+
98
+ `correct` takes what to do instead. It is kept for the agent's later runs. `answer` waits for what comes next. Pass `{ wait: false }` to return at once.
99
+
100
+ ## Say how it turned out
101
+
102
+ Later, when you know, say whether the run was right. Sensei learns from it, and the agent's numbers count it.
103
+
104
+ ```ts
105
+ await r.outcome("right", { note: "customer confirmed" });
106
+ await r.outcome("wrong", { note: "The ticket was reopened" });
107
+ ```
108
+
109
+ On a run with steps, `{ step: "refund" }` names the step that was wrong.
110
+
111
+ ## Many at once
112
+
113
+ ```ts
114
+ const many = await sensei.map("refund-requests", [{ ticket: 1 }, { ticket: 2 }, { ticket: 3 }], { parallel: 4 });
115
+ for (const r of many) console.log(r.status, r.output);
116
+ ```
117
+
118
+ One run per input, in the order given. A run that asks a person comes back `waiting`. The others are not held up by it. When the account already has too many runs going, `map` waits for one of its own to finish and carries on.
119
+
120
+ ## Several changes to one repository
121
+
122
+ ```ts
123
+ const b = await sensei.batch({
124
+ repo: "acme/api",
125
+ tasks: ["Move billing to the new logger", "Move checkout to the new logger"],
126
+ total: { usd: 24 }, // all of them; limit: { usd: 3 } is each task
127
+ });
128
+ await b.wait();
129
+ for (const t of b.tasks) console.log(t.index, t.status, t.together, t.pr_url);
130
+ console.log(b.pullRequests);
131
+ await b.checkAgain(); // after merging some: the rest, together, on the branch as it is now
132
+ ```
133
+
134
+ Each task is a run of its own, from the same commit, `parallel` at a time (4 unless you say, 10 at most). The changes that verify are merged and tested together, and each gets a pull request that says how it fits with the rest. With `deliver: "one"` there is one pull request, holding the changes that fit. A task's `together` says whether it fits, conflicts with another or breaks the tests once merged.
135
+
136
+ ## Settings and secrets
137
+
138
+ What a repository's tests need and a run is not handed, given to the project once, by name.
139
+
140
+ ```ts
141
+ await sensei.settings.set("REPORTS_BUCKET", "reports-test"); // a plain value: every command of a run reads it
142
+ await sensei.settings.set("NPM_TOKEN", token, { secret: true }); // a secret: setup commands only, never returned
143
+ const { data, needed } = await sensei.settings.list(); // needed: names recent runs asked for and did not get
144
+ await sensei.settings.remove("NPM_TOKEN");
145
+ ```
146
+
147
+ A secret reaches a run only when the repository's `sensei.yaml` or the definition names it under `secrets:`.
148
+
149
+ ## Schedules
150
+
151
+ Run a saved agent on a timetable.
152
+
153
+ ```ts
154
+ const s = await sensei.schedules.create({
155
+ agent: "daily-report",
156
+ when: "every weekday at 09:00",
157
+ input: { team: "support" },
158
+ timezone: "Europe/Lisbon",
159
+ });
160
+
161
+ await sensei.schedules.update(s.id, { enabled: false }); // pause
162
+ await sensei.schedules.update(s.id, { when: "every hour", enabled: true });
163
+ console.log(await sensei.schedules.list());
164
+ await sensei.schedules.remove(s.id);
165
+ ```
166
+
167
+ `when` is words: `every weekday at 09:00`, `every hour`, `every monday at 09:00`, `every 15 minutes`. A cron expression of five fields works too.
168
+
169
+ ## The API, one call at a time
170
+
171
+ `Client` is the same API with nothing added. Every method returns the API's JSON.
172
+
173
+ ```ts
174
+ const client = new Client(); // also sensei.client
175
+
176
+ const run = await client.runs.create({ agent: "refund-requests", input: { ticket: 48213 } });
177
+ for await (const event of client.runs.events(run.id)) console.log(event.kind, event.data);
178
+ const settled = await client.runs.wait(run.id, { timeoutMs: 60_000 });
179
+
180
+ await client.runs.list({ status: "waiting", limit: 20 });
181
+ await client.runs.answer(run.id, "approve");
182
+ await client.runs.outcome(run.id, "right", { note: "customer confirmed" });
183
+ await client.runs.cancel(run.id);
184
+ ```
185
+
186
+ - `client.runs`: `create`, `batch`, `checkAgain`, `get`, `list`, `wait`, `events`, `answer`, `outcome`, `cancel`, `approve`, `resume`.
187
+ - `client.settings`: `list`, `set`, `remove`.
188
+ - `client.agents`: `list`, `get`, `save`, `check`, `remove`, `forget`.
189
+ - `client.tools`: `list`, `connect`, `disconnect`.
190
+ - `client.repos`: `list`, `connect`, `disconnect`.
191
+ - `client.schedules`: `list`, `create`, `update`, `remove`.
192
+ - `client.model`: `get`, `versions`, `events`, `wait`, `promote`, `discard`, `rollback`, `setTrial`, `settings`.
193
+
194
+ `events` ends when the run is done or waiting. If the connection closes before that, it connects again from the last event it saw.
195
+
196
+ ## Your project's own model
197
+
198
+ On Team and Enterprise, Sensei trains a version of the model on your project's verified work, checks it on steps it has never seen, and then either makes it live or waits for you. `sensei.model` (also `client.model`) follows that and decides. The project is the one your key belongs to.
199
+
200
+ ```ts
201
+ const model = await sensei.model.get();
202
+ console.log(model.state, model.summary); // "waiting", "Version 2 passed its check and is waiting for a decision."
203
+
204
+ const settled = await sensei.model.wait({ until: ["waiting", "live"], timeoutMs: 3_600_000 });
205
+ if (settled.state === "waiting") await sensei.model.setTrial(10); // or sensei.model.promote()
206
+
207
+ for (const v of await sensei.model.versions()) console.log(v.number, v.state, v.check);
208
+
209
+ let page = await sensei.model.events(); // oldest first
210
+ page = await sensei.model.events({ since: page.cursor }); // only what came after
211
+
212
+ await sensei.model.discard("regressed on billing");
213
+ await sensei.model.rollback();
214
+ await sensei.model.settings({ promotion: "review", emails: true });
215
+ ```
216
+
217
+ `state` is one of `collecting`, `queued`, `training`, `checking`, `waiting`, `on_trial`, `live`, `no_room`, `taken_off` and `on_hold`. `wait` asks again every 15 seconds (`pollMs`) and returns the model as it is when `timeoutMs` is up, so check `state` on what comes back.
218
+
219
+ Beside the state, `training.progress` says where a run that has not finished stands (`queued`, `starting`, `preparing`, `training` or `exporting`; which attempt it is; the pass, step and loss so far, at most about three minutes old), `passes` on a version says how each pass of its run did on the held-out steps and which went forward, `candidate.decided_by` is `sensei` when the version goes live or is set aside by itself after its trial (`decides_by` is the day, at the latest), `candidate.e2e` is the end-to-end check where the project requires one, and `watch` is the live version beside the base model on the project's own confirmed results.
220
+
221
+ Any key of the project can read. `promote`, `discard`, `rollback`, `setTrial` and a change of `settings` need a key that an account admin has allowed to **Manage model versions** on the Keys page. The permission is off on every key until then, so an agent's own key cannot promote the model it is served by. Without it they throw `SenseiError` with status 403 and code `manage_model_versions_required`.
222
+
223
+ Events are `{ id, type, created_at, project, data }`: `training.queued`, `training.started`, `training.finished`, `training.failed`, `version.waiting`, `version.on_trial`, `version.trial_changed`, `version.trial_stopped`, `version.live`, `version.discarded`, `version.rolled_back`, `version.taken_off`. `data` holds the version number, who did it and numbers. It never holds your sessions. On `training.queued` and `training.finished`, `data.billing` says how the run is paid for (`included`, `paid` or `no_charge`) and `data.charge_cents` is what a paid run drew from your credits when it was queued. If the run fails, `data.returned_cents` on `training.failed` or `training.on_hold` is what was put back.
224
+
225
+ A project can have the same events sent to an `https` address (`PUT /v1/model/webhook` with `{ "url": "https://..." }`; the answer holds the signing secret once). To check a delivery is from Sensei:
226
+
227
+ ```ts
228
+ import { createHmac, timingSafeEqual } from "node:crypto";
229
+
230
+ function isFromSensei(secret: string, headers: Headers, body: string): boolean {
231
+ const want = "v1=" + createHmac("sha256", secret).update(`${headers.get("x-sensei-timestamp")}.${body}`).digest("hex");
232
+ const got = headers.get("x-sensei-signature") ?? "";
233
+ return got.length === want.length && timingSafeEqual(Buffer.from(got), Buffer.from(want));
234
+ }
235
+ ```
236
+
237
+ `body` is the request body exactly as received. Answer with a 2xx within five seconds; anything else is tried again, six times over about nine hours. A delivery can arrive twice: `x-sensei-delivery` is the event's id.
238
+
239
+ ## End-to-end check
240
+
241
+ Rerun tasks you saved, in a sandbox, on two versions of your model, each attempt graded by your own test command. Nothing happens until you save a task and start a check.
242
+
243
+ Only work with a repository and a test command can be checked this way. Sessions from your own agent through the endpoint record no repository state, so those projects keep the step check and the trial.
244
+
245
+ ```ts
246
+ const task = await sensei.evals.tasks.add({ runId: "1f0c2a9e-..." }); // a verified run, or:
247
+ await sensei.evals.tasks.add({ repo: "acme/app", baseCommit: "<full commit id>", ask: "Fix the empty read", testCommand: "pytest -q" });
248
+ await sensei.evals.tasks.list(); // accepted, checking, or refused with the reason
249
+ await sensei.evals.tasks.remove(task.id);
250
+
251
+ const { usd } = await sensei.evals.estimate({ sides: ["live", "version"] });
252
+ let check = await sensei.evals.create({ sides: ["live", "version"], attempts: 1, limitUsd: 25 });
253
+ check = await sensei.evals.wait(check.id); // finished or stopped
254
+ console.log(check.reading?.sentence);
255
+ const results = await sensei.evals.results(check.id); // every task, side and attempt, with its run
256
+ await sensei.evals.resume(check.id, { limitUsd: 40 }); // the attempts that errored, and only those
257
+ ```
258
+
259
+ A side is `base`, `live`, `version` (the version waiting) or a version's id. A task's test command must fail at its base commit and give the same result twice, or the task is refused with the reason. Each attempt is a run and is charged as one, at the rate of the side that answered; `limitUsd` is required, and the check stops starting attempts when it is reached. With fewer than 20 tasks the reading is a count, not a verdict.
260
+
261
+ Any key of the project reads. Changing tasks and starting, resuming or stopping a check need a key with "Manage model versions" (`manage_model_versions_required` otherwise).
262
+
263
+ ## Errors
264
+
265
+ An answer that is not a success throws `SenseiError`, with the `status`, `code` and `message` the service sent.
266
+
267
+ ```ts
268
+ try {
269
+ await sensei.run("refund-requests", { input: { ticket: 48213 } });
270
+ } catch (e) {
271
+ if (e instanceof SenseiError && e.code === "too_many_runs") console.log("Try again in a moment.");
272
+ else throw e;
273
+ }
274
+ ```
275
+
276
+ A definition file that cannot be read throws `FileError`, which says what is wrong with the file.
277
+
278
+ ## Develop
279
+
280
+ ```sh
281
+ npm install
282
+ npm run build
283
+ npm test
284
+ ```
285
+
286
+ The tests use a fake `fetch`. Nothing reaches a network.
@@ -0,0 +1,260 @@
1
+ /**
2
+ * The client for Sensei runs: a thin wrapper over `/v1/runs`, `/v1/agents`,
3
+ * `/v1/tools`, `/v1/repos` and `/v1/schedules`, and over `/v1/model` for the
4
+ * project's own trained model. Every method returns the API's JSON as it
5
+ * is; `runs.events` yields events as they happen. `Sensei` (run.ts) is the
6
+ * short way to run something and read the result.
7
+ */
8
+ import { Evals } from "./evals.js";
9
+ import type { Agent, AgentCheck, BatchParams, Decision, Definition, ModelDecision, ModelEventsPage, ModelEventsParams, ModelSettings, ModelSettingsParams, ModelState, ModelVersion, ModelWaitOptions, Outcome, OutcomeOptions, ProjectModel, Repo, Run, RunCreateParams, RunEvent, RunListParams, Schedule, ScheduleCreateParams, ScheduleUpdateParams, Setting, SettingsList, Tool, WaitOptions } from "./types.js";
10
+ export declare const DEFAULT_URL = "https://runs.sense-lab.ai";
11
+ /** A run in one of these has stopped moving until someone acts (or for good). */
12
+ export declare const SETTLED: readonly string[];
13
+ /**
14
+ * A project's model in one of these stays there until someone acts or new
15
+ * work arrives: what `model.wait` waits for unless told otherwise.
16
+ */
17
+ export declare const MODEL_SETTLED: readonly ModelState[];
18
+ export declare class SenseiError extends Error {
19
+ /** The HTTP status, or 0 when the call was never made. */
20
+ readonly status: number;
21
+ readonly code: string | undefined;
22
+ constructor(status: number, message: string, code?: string);
23
+ }
24
+ /** Where `sensei login` (the command) keeps the key. */
25
+ export declare function configPath(): string;
26
+ /**
27
+ * Explicit argument, then environment, then `~/.config/sensei/config.json`
28
+ * (written by `sensei login`). The file is read only when it is needed.
29
+ */
30
+ export declare function resolveConfig(baseUrl?: string, apiKey?: string): {
31
+ baseUrl: string;
32
+ apiKey: string;
33
+ };
34
+ /** What the client needs of `fetch`. The built-in one fits; so does a fake. */
35
+ export type FetchLike = (url: string, init: FetchInit) => Promise<FetchResponse>;
36
+ export interface FetchInit {
37
+ method: string;
38
+ headers: Record<string, string>;
39
+ body?: string;
40
+ }
41
+ export interface FetchResponse {
42
+ readonly status: number;
43
+ text(): Promise<string>;
44
+ readonly body: {
45
+ getReader(): FetchBodyReader;
46
+ } | null;
47
+ }
48
+ export interface FetchBodyReader {
49
+ read(): Promise<{
50
+ done: boolean;
51
+ value?: Uint8Array;
52
+ }>;
53
+ cancel(): Promise<void>;
54
+ }
55
+ export interface ClientOptions {
56
+ /** Default: `SENSEI_API_KEY`. */
57
+ apiKey?: string;
58
+ /** Default: `SENSEI_RUNS_URL`, then https://runs.sense-lab.ai. */
59
+ baseUrl?: string;
60
+ /** Default: the built-in `fetch`. */
61
+ fetch?: FetchLike;
62
+ /** Sent as `x-sensei-through`. */
63
+ through?: string;
64
+ }
65
+ type Params = Record<string, string | number | null | undefined>;
66
+ export declare class Client {
67
+ #private;
68
+ readonly baseUrl: string;
69
+ readonly runs: Runs;
70
+ readonly agents: Agents;
71
+ readonly tools: Tools;
72
+ /** What the project's runs are given by name: plain settings, and secrets for setup. */
73
+ readonly settings: Settings;
74
+ readonly repos: Repos;
75
+ readonly schedules: Schedules;
76
+ readonly model: Model;
77
+ /** The end-to-end check: saved tasks on two versions of the model (evals.ts). */
78
+ readonly evals: Evals;
79
+ constructor(options?: ClientOptions);
80
+ /** One call to the API: its JSON, or a `SenseiError` when it says no. */
81
+ request<T = unknown>(method: string, path: string, call?: {
82
+ body?: object;
83
+ params?: Params;
84
+ }): Promise<T>;
85
+ }
86
+ /** The body of `POST /v1/runs`. */
87
+ export declare function runBody(params: RunCreateParams): Record<string, unknown>;
88
+ export declare class Runs {
89
+ #private;
90
+ constructor(client: Client);
91
+ /**
92
+ * Start a run. One of: `agent` (a saved agent, by name), `definition`
93
+ * (what a definition file holds), or `task` in words (with `repo` it is a
94
+ * change to that repository).
95
+ */
96
+ create(params: RunCreateParams): Promise<Run>;
97
+ /**
98
+ * Start many changes to one repository as one batch. Each task is a run
99
+ * of its own, worked alone from the same commit. The changes that verify
100
+ * are tested together, and pull requests are opened for the ones that
101
+ * fit. It answers at once: `get` or `wait` follow it, and `result.batch`
102
+ * says how each task did alone and together.
103
+ */
104
+ batch(params: BatchParams): Promise<Run>;
105
+ /**
106
+ * Test a finished batch's changes together once more, against the branch
107
+ * as it is now: after some were merged, or the branch moved. Changes
108
+ * already merged are left out.
109
+ */
110
+ checkAgain(runId: string): Promise<Run>;
111
+ get(runId: string): Promise<Run>;
112
+ list(params?: RunListParams): Promise<Run[]>;
113
+ /**
114
+ * The run once it has finished or has a question for a person.
115
+ * `timeoutMs` returns it as it is when the time is up.
116
+ */
117
+ wait(runId: string, options?: WaitOptions): Promise<Run>;
118
+ /**
119
+ * Answer a waiting run: `approve`, `correct` (with `text`: what to do
120
+ * instead, kept for the agent's later runs) or `reject`.
121
+ */
122
+ answer(runId: string, decision: Decision, text?: string): Promise<Run>;
123
+ /**
124
+ * Say how a finished run turned out: `right` or `wrong`. It is what
125
+ * Sensei learns from, and what the agent's numbers count.
126
+ */
127
+ outcome(runId: string, outcome: Outcome, options?: OutcomeOptions): Promise<Run>;
128
+ /**
129
+ * Events as they happen, until the run is done or waiting. Reconnects
130
+ * from the last event seen if the connection closes before that.
131
+ */
132
+ events(runId: string, options?: {
133
+ after?: number;
134
+ }): AsyncGenerator<RunEvent, void, undefined>;
135
+ /** Push the change a run is waiting to push (and open its pull request). */
136
+ approve(runId: string): Promise<Run>;
137
+ /** A new attempt, with what a person said. */
138
+ resume(runId: string, options?: {
139
+ guidance?: string;
140
+ }): Promise<Run>;
141
+ cancel(runId: string): Promise<Run>;
142
+ }
143
+ export declare class Repos {
144
+ #private;
145
+ constructor(client: Client);
146
+ list(): Promise<Repo[]>;
147
+ connect(url: string, options?: {
148
+ token?: string;
149
+ defaultBranch?: string;
150
+ }): Promise<Repo>;
151
+ disconnect(repoId: string): Promise<void>;
152
+ }
153
+ /** Definitions saved under a name, so anyone on the project runs them by name. */
154
+ export declare class Agents {
155
+ #private;
156
+ constructor(client: Client);
157
+ list(): Promise<Agent[]>;
158
+ get(name: string, options?: {
159
+ version?: number;
160
+ }): Promise<Agent>;
161
+ save(definition: Definition): Promise<Agent>;
162
+ check(definition: Definition): Promise<AgentCheck>;
163
+ remove(name: string): Promise<void>;
164
+ /** Take back a correction the team made. */
165
+ forget(name: string, noteId: string): Promise<void>;
166
+ }
167
+ /** The team's own systems, connected once on the project (MCP servers). */
168
+ export declare class Tools {
169
+ #private;
170
+ constructor(client: Client);
171
+ list(): Promise<Tool[]>;
172
+ connect(name: string, url: string, options?: {
173
+ secret?: string;
174
+ headerName?: string;
175
+ }): Promise<Tool>;
176
+ disconnect(name: string): Promise<void>;
177
+ }
178
+ /**
179
+ * What a project's runs are given by name. A setting is a plain value in
180
+ * the environment of everything a run does, and is shown. A secret is given
181
+ * to the setup commands of a run that names it (`secrets:`) and to nothing
182
+ * else, and is never returned.
183
+ */
184
+ export declare class Settings {
185
+ #private;
186
+ constructor(client: Client);
187
+ /** The settings and secrets, and the names recent runs needed and did not get. */
188
+ list(): Promise<SettingsList>;
189
+ set(name: string, value: string, options?: {
190
+ secret?: boolean;
191
+ }): Promise<Setting>;
192
+ remove(name: string): Promise<void>;
193
+ }
194
+ /** A saved agent, run on a timetable. */
195
+ export declare class Schedules {
196
+ #private;
197
+ constructor(client: Client);
198
+ list(): Promise<Schedule[]>;
199
+ /** `when` is words such as "every weekday at 09:00", or a 5-field cron expression. */
200
+ create(params: ScheduleCreateParams): Promise<Schedule>;
201
+ update(scheduleId: string, params: ScheduleUpdateParams): Promise<Schedule>;
202
+ remove(scheduleId: string): Promise<void>;
203
+ }
204
+ /**
205
+ * The project's own model: the version of Sensei trained on its verified
206
+ * work. The project is the one the key belongs to.
207
+ *
208
+ * Any key reads. `promote`, `discard`, `rollback`, `setTrial` and `settings`
209
+ * change what the project's keys are served, so they need a key an account
210
+ * admin has allowed to "Manage model versions" on the Keys page; any other
211
+ * key gets a `SenseiError` with status 403 and code
212
+ * `manage_model_versions_required`.
213
+ */
214
+ export declare class Model {
215
+ #private;
216
+ constructor(client: Client);
217
+ /**
218
+ * Where the model is. `state` is one word; `summary` says it in a
219
+ * sentence. `page: true` adds everything the dashboard's model page
220
+ * shows, under `page`.
221
+ */
222
+ get(options?: {
223
+ page?: boolean;
224
+ }): Promise<ProjectModel>;
225
+ /** Every version, newest first, with its state and what its check found. */
226
+ versions(): Promise<ModelVersion[]>;
227
+ /**
228
+ * What happened, oldest first. `since` is an event id (the `cursor` of
229
+ * the last answer) or an ISO time; pass the cursor back to read only what
230
+ * came after.
231
+ */
232
+ events(params?: ModelEventsParams): Promise<ModelEventsPage>;
233
+ /**
234
+ * The model once its state is one of `until`. Asks again every `pollMs`;
235
+ * `timeoutMs` returns it as it is when the time is up, so check `state`
236
+ * on what comes back.
237
+ */
238
+ wait(options?: ModelWaitOptions): Promise<ProjectModel>;
239
+ /** The version waiting becomes what every key of the project is served. */
240
+ promote(): Promise<ModelDecision>;
241
+ /** Set the version waiting aside. Nothing changes for the project's keys. */
242
+ discard(reason?: string): Promise<ModelDecision>;
243
+ /** One step back: the version before the live one, or the base model. */
244
+ rollback(): Promise<ModelDecision>;
245
+ /**
246
+ * Serve the version waiting to `share` percent of the project's
247
+ * sessions: 5, 10, 25 or 50. 0 stops the trial and keeps the version.
248
+ */
249
+ setTrial(share: number): Promise<ModelDecision>;
250
+ /**
251
+ * Change the project's settings; with nothing passed, read them.
252
+ * `promotion`: `auto` (a version that passes its check goes live by
253
+ * itself) or `review` (it waits for a decision). `trialShare`: the share
254
+ * of sessions (5, 10, 25 or 50) a version is tried on by itself, where
255
+ * Sensei tries a version before making it live. `emails`: whether the
256
+ * account's admins are emailed about this project's versions.
257
+ */
258
+ settings(params?: ModelSettingsParams): Promise<ModelSettings>;
259
+ }
260
+ export {};