@skillcdn/console 0.6.2 → 0.6.3
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 +13 -6
- package/SKILLCDN.md +3 -2
- package/dist/agent-page.d.ts +2 -0
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +40 -3
- package/dist/agent-page.js.map +1 -1
- package/dist/agent-state.d.ts +9 -0
- package/dist/agent-state.d.ts.map +1 -0
- package/dist/agent-state.js +28 -0
- package/dist/agent-state.js.map +1 -0
- package/dist/api.d.ts +4 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4 -3
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +304 -130
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +13 -4
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +43 -9
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +82 -9
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +780 -318
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/pack.d.ts +2 -2
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +6 -4
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/runner-files.d.ts +16 -0
- package/dist/cli/runner-files.d.ts.map +1 -0
- package/dist/cli/runner-files.js +110 -0
- package/dist/cli/runner-files.js.map +1 -0
- package/dist/cli/runner-host.d.ts +7 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +40 -2
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/client.d.ts +16 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +28 -3
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +48 -3
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +3 -2
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +9 -3
- package/dist/components/agents.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +1 -1
- package/dist/console.js.map +1 -1
- package/dist/feed-words.d.ts.map +1 -1
- package/dist/feed-words.js +12 -1
- package/dist/feed-words.js.map +1 -1
- package/dist/i18n/en.d.ts +45 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +36 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +28 -0
- package/dist/i18n/ko.js.map +1 -1
- package/dist/limits.d.ts +10 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +10 -0
- package/dist/limits.js.map +1 -1
- package/dist/plugin/context.d.ts +39 -7
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +9 -3
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +5 -1
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +14 -2
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +18 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +77 -1
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts +7 -0
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +9 -0
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +16 -22
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +72 -120
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/runner.d.ts +25 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +404 -19
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack-status.d.ts +19 -0
- package/dist/runner/slack-status.d.ts.map +1 -0
- package/dist/runner/slack-status.js +332 -0
- package/dist/runner/slack-status.js.map +1 -0
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +245 -57
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +109 -15
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/runner/usage.d.ts +6 -1
- package/dist/runner/usage.d.ts.map +1 -1
- package/dist/runner/usage.js +9 -2
- package/dist/runner/usage.js.map +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +160 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +82 -5
- package/dist/schemas.js.map +1 -1
- package/dist/vocabulary.d.ts +7 -0
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +6 -0
- package/dist/vocabulary.js.map +1 -1
- package/dist/wake-text.d.ts +43 -0
- package/dist/wake-text.d.ts.map +1 -0
- package/dist/wake-text.js +115 -0
- package/dist/wake-text.js.map +1 -0
- package/docs/specs/cli.md +19 -11
- package/docs/specs/plugins.md +5 -5
- package/docs/specs/rest.md +10 -3
- package/docs/specs/runner.md +96 -20
- package/docs/start.md +26 -5
- package/package.json +3 -3
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/skills/deploying-a-console/SKILL.md +3 -3
- package/skills/deploying-a-console/references/access.md +15 -1
- package/skills/deploying-a-console/references/resources.md +2 -2
- package/skills/deploying-a-console/scripts/github-app.mjs +593 -0
- package/skills/running-an-agent/SKILL.md +13 -10
- package/skills/running-an-agent/references/preparing-the-machine.md +1 -1
- package/skills/running-an-agent/references/slack-app.md +25 -8
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +1 -1
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +1 -1
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +1 -1
- package/skills/running-an-agent/references/your-first-task.md +7 -2
- package/skills/trying-a-console/SKILL.md +136 -0
- package/skills/trying-a-console/references/when-it-does-not-go.md +30 -0
- package/skills/working-the-board/SKILL.md +3 -3
- package/skills/working-the-board/references/the-pack.md +3 -3
- package/skills/working-the-board/references/what-they-were-told.md +1 -1
- package/src/agent-page.tsx +92 -1
- package/src/agent-state.ts +33 -0
- package/src/api.ts +16 -0
- package/src/cli/cli.ts +359 -137
- package/src/cli/format.ts +49 -9
- package/src/cli/help.ts +904 -359
- package/src/cli/pack.ts +6 -4
- package/src/cli/runner-files.ts +120 -0
- package/src/cli/runner-host.ts +48 -2
- package/src/client.ts +53 -0
- package/src/components/agent-page.tsx +150 -3
- package/src/components/agents.tsx +20 -5
- package/src/console.tsx +1 -0
- package/src/feed-words.ts +14 -1
- package/src/i18n/en.ts +39 -1
- package/src/i18n/ko.ts +32 -0
- package/src/limits.ts +10 -0
- package/src/plugin/context.ts +40 -7
- package/src/runner/acp.ts +9 -3
- package/src/runner/claude.ts +5 -1
- package/src/runner/codex.ts +14 -2
- package/src/runner/config.ts +114 -1
- package/src/runner/desk.ts +10 -0
- package/src/runner/message.ts +88 -126
- package/src/runner/runner.ts +487 -22
- package/src/runner/slack-status.ts +423 -0
- package/src/runner/slack.ts +293 -61
- package/src/runner/types.ts +108 -13
- package/src/runner/usage.ts +16 -3
- package/src/runner.ts +4 -0
- package/src/schemas.ts +97 -3
- package/src/vocabulary.ts +9 -0
- package/src/wake-text.ts +133 -0
package/src/runner/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentStateReason, TranscriptKind } from "../vocabulary.js";
|
|
2
|
+
import type { WakePart } from "../wake-text.js";
|
|
2
3
|
|
|
3
4
|
// What the runner's modules are to one another (ADR-0085, docs/specs/runner.md): a driver speaks
|
|
4
5
|
// to one product, a wake source raises wakes from outside the console, a service keeps the
|
|
@@ -39,8 +40,13 @@ export type DriverEvent =
|
|
|
39
40
|
readonly effort: string | null;
|
|
40
41
|
readonly version: string | null;
|
|
41
42
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The id the product resumes the conversation from next time. With `anew`, the product was
|
|
45
|
+
* asked to go on with a conversation and began this one in its place, since it kept the other
|
|
46
|
+
* no more or goes on with none (ADR-0166): the runner then takes the agent's conversation to
|
|
47
|
+
* have begun with the session, which holds nothing it was handed before.
|
|
48
|
+
*/
|
|
49
|
+
| { readonly type: "conversation"; readonly id: string; readonly anew?: boolean | undefined }
|
|
44
50
|
/**
|
|
45
51
|
* The product took a message: the oldest it was sent and had not said so of. Said once for
|
|
46
52
|
* every message sent, when the product reads it, so that a message handed over in a turn is
|
|
@@ -49,6 +55,12 @@ export type DriverEvent =
|
|
|
49
55
|
| { readonly type: "taken" }
|
|
50
56
|
/** A turn completed: the agent is done with what it was sent, and waits for more. */
|
|
51
57
|
| { readonly type: "turn_completed" }
|
|
58
|
+
/**
|
|
59
|
+
* The product put the conversation so far in fewer words of its own, as one does whose
|
|
60
|
+
* conversation grew long (ADR-0166): what the agent was handed before, it holds as a summary
|
|
61
|
+
* at best. Said by a driver whose product says so, and never by another.
|
|
62
|
+
*/
|
|
63
|
+
| { readonly type: "compacted" }
|
|
52
64
|
/**
|
|
53
65
|
* How many sub-agents are at work in the background of the session, as the product lists
|
|
54
66
|
* them (ADR-0162): said as that changes, from the first that is. A driver whose product lists
|
|
@@ -235,6 +247,15 @@ export interface Driver {
|
|
|
235
247
|
readonly resume: boolean;
|
|
236
248
|
/** Whether the model and the effort are taken in a running session. */
|
|
237
249
|
readonly set: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Whether a message the driver said was taken stands in the product's conversation from
|
|
252
|
+
* then on, whatever became of the turn: the driver says `taken` when the product says the
|
|
253
|
+
* message back out of its conversation, or began a turn with it. Where it does, what the
|
|
254
|
+
* product took as a usage limit was reached is named to the agent in the same session and
|
|
255
|
+
* not said a second time (ADR-0166). Left out, or false, for a driver that says `taken` when
|
|
256
|
+
* it handed the message over: the runner then says such a message whole again.
|
|
257
|
+
*/
|
|
258
|
+
readonly holdsTaken?: boolean | undefined;
|
|
238
259
|
};
|
|
239
260
|
/**
|
|
240
261
|
* The product's permission modes, in its own words: what runs without asking. `unattended` is
|
|
@@ -287,13 +308,9 @@ export interface WakeSocket {
|
|
|
287
308
|
close(): void;
|
|
288
309
|
}
|
|
289
310
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
* of their own, so that nothing a message holds reads as a line of the source's. A line holds
|
|
294
|
-
* what the source says itself, an id and a moment among it, and never a word someone else wrote.
|
|
295
|
-
*/
|
|
296
|
-
export type WakePart = { readonly says: string } | { readonly words: string };
|
|
311
|
+
// A part of a wake a source raises (ADR-0163): declared with how the parts are written as a
|
|
312
|
+
// signal's text, which the console writes too.
|
|
313
|
+
export type { WakePart } from "../wake-text.js";
|
|
297
314
|
|
|
298
315
|
/**
|
|
299
316
|
* A wake as a wake source raises one: `parts` where the source says something itself, who wrote
|
|
@@ -356,11 +373,20 @@ export interface WakeHost {
|
|
|
356
373
|
*/
|
|
357
374
|
raise(wake: RaisedWake): Promise<boolean>;
|
|
358
375
|
/**
|
|
359
|
-
* What the source keeps from one run of its own to the next, under names of its own,
|
|
360
|
-
*
|
|
361
|
-
* never a word of a message.
|
|
376
|
+
* What the source keeps from one run of its own to the next, under names of its own, and from
|
|
377
|
+
* one runner to the one started after it where the machine keeps it (ADR-0166): the ids and
|
|
378
|
+
* the moments of what it brought the agent. Never a secret, and never a word of a message.
|
|
362
379
|
*/
|
|
363
380
|
readonly kept: Map<string, string>;
|
|
381
|
+
/**
|
|
382
|
+
* When the conversation the agent goes on with began, in milliseconds since the epoch
|
|
383
|
+
* (ADR-0166): at a reset, with a new day where the desk says so, in a session whose product
|
|
384
|
+
* goes on with none, and when the product put it in fewer words. What the agent was handed
|
|
385
|
+
* before that moment its conversation holds no more, so a source counts nothing from before
|
|
386
|
+
* it as brought. 0 where nothing says when; left out by a host that says nothing of it, which
|
|
387
|
+
* a source reads as 0.
|
|
388
|
+
*/
|
|
389
|
+
began?(): number;
|
|
364
390
|
/** A line for whoever reads the runner's own output: never what a message says. */
|
|
365
391
|
log(line: string): void;
|
|
366
392
|
/**
|
|
@@ -368,14 +394,25 @@ export interface WakeHost {
|
|
|
368
394
|
* yet, with why in a few words of the source's own. Never what a message says.
|
|
369
395
|
*/
|
|
370
396
|
stands(state: "connected" | "waiting", why?: string): void;
|
|
397
|
+
/**
|
|
398
|
+
* Asks an address of the source's messenger. `body` is what a call that writes sends, as its
|
|
399
|
+
* text. Of the answer, what it says as JSON, and beside it the status of the answer and its
|
|
400
|
+
* headers where the host has them: a messenger that asks to be left alone for a while says so
|
|
401
|
+
* there.
|
|
402
|
+
*/
|
|
371
403
|
fetch(
|
|
372
404
|
url: string,
|
|
373
405
|
init: {
|
|
374
406
|
readonly method: string;
|
|
375
407
|
readonly headers: Readonly<Record<string, string>>;
|
|
408
|
+
readonly body?: string | undefined;
|
|
376
409
|
readonly signal: AbortSignal;
|
|
377
410
|
},
|
|
378
|
-
): Promise<{
|
|
411
|
+
): Promise<{
|
|
412
|
+
json(): Promise<unknown>;
|
|
413
|
+
readonly status?: number | undefined;
|
|
414
|
+
readonly headers?: { get(name: string): string | null } | undefined;
|
|
415
|
+
}>;
|
|
379
416
|
socket(url: string): WakeSocket;
|
|
380
417
|
/** Waits so long, or less where the signal ends the wait. */
|
|
381
418
|
wait(ms: number, signal: AbortSignal): Promise<void>;
|
|
@@ -389,6 +426,40 @@ export interface WakeHost {
|
|
|
389
426
|
writers?(accounts: readonly WakeAccount[], signal: AbortSignal): Promise<readonly WakeWriter[]>;
|
|
390
427
|
}
|
|
391
428
|
|
|
429
|
+
/**
|
|
430
|
+
* How an agent stands to whoever waits for it where a wake source listens (ADR-0170), as the
|
|
431
|
+
* runner says it and the source shows it where it can:
|
|
432
|
+
*
|
|
433
|
+
* - `idle`: nothing to show. With `last`, the runner ends and says nothing after it: what the
|
|
434
|
+
* source showed is taken back now or not at all;
|
|
435
|
+
* - `thinking`: what that source raised reached the runner, and the turn it began is under way;
|
|
436
|
+
* - `working`: the agent has been at work for longer than `runner.json` gives a turn before it
|
|
437
|
+
* is said, whatever woke it, sub-agents in its background among it;
|
|
438
|
+
* - `limited`: the usage limit of its product stopped it, until the moment `until` where the
|
|
439
|
+
* product said one, in milliseconds since the epoch.
|
|
440
|
+
*/
|
|
441
|
+
export type AgentStatus =
|
|
442
|
+
| { readonly state: "idle"; readonly last?: boolean | undefined }
|
|
443
|
+
| { readonly state: "thinking" }
|
|
444
|
+
| { readonly state: "working" }
|
|
445
|
+
| { readonly state: "limited"; readonly until?: number | undefined };
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* What `runner.json` says of how each of them is shown, under `status`: an emoji by its name
|
|
449
|
+
* and a line of words, each the source's own where the desk says none. `back` is what the
|
|
450
|
+
* words of `limited` go on with where the moment is known, `{time}` in it standing for the
|
|
451
|
+
* moment.
|
|
452
|
+
*/
|
|
453
|
+
export interface StatusWords {
|
|
454
|
+
readonly thinking?: StatusLook | undefined;
|
|
455
|
+
readonly working?: StatusLook | undefined;
|
|
456
|
+
readonly limited?: (StatusLook & { readonly back?: string | undefined }) | undefined;
|
|
457
|
+
}
|
|
458
|
+
export interface StatusLook {
|
|
459
|
+
readonly emoji?: string | undefined;
|
|
460
|
+
readonly text?: string | undefined;
|
|
461
|
+
}
|
|
462
|
+
|
|
392
463
|
/** A module that raises wakes from outside the console. `console`, the console's own stream of signals, is the runner's own. */
|
|
393
464
|
export interface WakeSource {
|
|
394
465
|
readonly name: string;
|
|
@@ -415,6 +486,30 @@ export interface WakeSource {
|
|
|
415
486
|
readonly signal: AbortSignal;
|
|
416
487
|
},
|
|
417
488
|
): Promise<WakeRead>;
|
|
489
|
+
/**
|
|
490
|
+
* Shows how the agent stands, where the source's messenger has a place for it (ADR-0170): the
|
|
491
|
+
* runner decides which, and the source how. Said when it changes, and again every half
|
|
492
|
+
* minute while it stands, so that a source keeps what it shows from lapsing and tries again
|
|
493
|
+
* what failed; with the host the source runs with, the same one every time. It never rejects
|
|
494
|
+
* for what the messenger answered, and what it cannot show costs the agent nothing: said
|
|
495
|
+
* once, in the runner's lines. Left out by a source that shows nothing.
|
|
496
|
+
*/
|
|
497
|
+
show?(
|
|
498
|
+
host: Pick<WakeHost, "secret" | "fetch" | "wait" | "log" | "kept">,
|
|
499
|
+
status: AgentStatus,
|
|
500
|
+
options: {
|
|
501
|
+
/** What `runner.json` says of the emoji and the words. */
|
|
502
|
+
readonly words: StatusWords;
|
|
503
|
+
/** The language of the workspace, where the runner knows it: the source's own words are in it where it has them. */
|
|
504
|
+
readonly language?: string | undefined;
|
|
505
|
+
/** The moment, in milliseconds since the epoch. */
|
|
506
|
+
now(): number;
|
|
507
|
+
/** A moment as people read one, in the workspace's zone: the hour and the minute, with the day where it is not within the day to come. */
|
|
508
|
+
time(at: number): string;
|
|
509
|
+
/** Ends when the runner does, and with the last thing said a few seconds after it. */
|
|
510
|
+
readonly signal: AbortSignal;
|
|
511
|
+
},
|
|
512
|
+
): Promise<void>;
|
|
418
513
|
}
|
|
419
514
|
|
|
420
515
|
/** What a service is told of the runner it keeps running. */
|
package/src/runner/usage.ts
CHANGED
|
@@ -210,8 +210,13 @@ export function limitWords(
|
|
|
210
210
|
options: {
|
|
211
211
|
readonly now: number;
|
|
212
212
|
readonly moment: (iso: string) => string;
|
|
213
|
-
/** How many signals follow in the message. */
|
|
213
|
+
/** How many signals follow in the message, said whole. */
|
|
214
214
|
readonly follow: number;
|
|
215
|
+
/**
|
|
216
|
+
* How many more the message only names (ADR-0166): what the product took in this
|
|
217
|
+
* conversation as the limit was reached and the agent never answered, which stands above.
|
|
218
|
+
*/
|
|
219
|
+
readonly above?: number | undefined;
|
|
215
220
|
/** Whether this is a supervisor's signal tried before the runner's own try, with what else is kept left for then. */
|
|
216
221
|
readonly early?: boolean | undefined;
|
|
217
222
|
},
|
|
@@ -224,11 +229,19 @@ export function limitWords(
|
|
|
224
229
|
: limited.until === undefined
|
|
225
230
|
? `The product did not say when the limit resets, so the runner tries now, ${at(options.now)}, by itself.`
|
|
226
231
|
: `The limit reset ${at(limited.until)}, and the runner brings you back by itself.`;
|
|
232
|
+
const above = options.above ?? 0;
|
|
233
|
+
// What the conversation holds is not said twice: it is named, and the agent reads it above.
|
|
234
|
+
const unanswered =
|
|
235
|
+
above === 0
|
|
236
|
+
? ""
|
|
237
|
+
: `What you were handed as the limit was reached and had not answered stands above in this conversation: it is named below by its ${above === 1 ? "number" : "numbers"}, and not said again. `;
|
|
227
238
|
const meanwhile = early
|
|
228
239
|
? "The message follows; what else reached you meanwhile is kept, and handed to you then."
|
|
229
240
|
: options.follow === 0
|
|
230
|
-
?
|
|
231
|
-
:
|
|
241
|
+
? `${unanswered}Nothing ${above === 0 ? "" : "else "}reached you meanwhile.`
|
|
242
|
+
: above === 0
|
|
243
|
+
? "What reached you meanwhile follows, in the order it came, what you were handed as the limit was reached and had not read among it."
|
|
244
|
+
: `${unanswered}What reached you since follows, in the order it came.`;
|
|
232
245
|
return `${stopped} ${now} Go on with what you were doing: look at what each sub-agent left before you start it again. ${meanwhile}`;
|
|
233
246
|
}
|
|
234
247
|
|
package/src/runner.ts
CHANGED
|
@@ -63,6 +63,7 @@ export {
|
|
|
63
63
|
createRunner,
|
|
64
64
|
HEARTBEAT_MS,
|
|
65
65
|
HOLD_MS,
|
|
66
|
+
type KeptBySource,
|
|
66
67
|
MAX_COOL_DOWN_MS,
|
|
67
68
|
MAX_HOLD_MS,
|
|
68
69
|
REPORT_MS,
|
|
@@ -91,6 +92,7 @@ export {
|
|
|
91
92
|
taskScript,
|
|
92
93
|
} from "./runner/task-scheduler.js";
|
|
93
94
|
export type {
|
|
95
|
+
AgentStatus,
|
|
94
96
|
Boundary,
|
|
95
97
|
Child,
|
|
96
98
|
Cut,
|
|
@@ -108,6 +110,8 @@ export type {
|
|
|
108
110
|
ServicePlan,
|
|
109
111
|
Spawn,
|
|
110
112
|
StartOptions,
|
|
113
|
+
StatusLook,
|
|
114
|
+
StatusWords,
|
|
111
115
|
WakeAccount,
|
|
112
116
|
WakeHost,
|
|
113
117
|
WakePart,
|
package/src/schemas.ts
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
MAX_RUNNER_USAGE_WINDOWS,
|
|
53
53
|
MAX_SEAL_REASON_LENGTH,
|
|
54
54
|
MAX_SECRET_LENGTH,
|
|
55
|
+
MAX_SECRET_OFFER_NOTE_LENGTH,
|
|
55
56
|
MAX_SERVICE_PARAMETERS,
|
|
56
57
|
MAX_SERVICE_VALUE_LENGTH,
|
|
57
58
|
MAX_SIGNAL_KEY_LENGTH,
|
|
@@ -105,6 +106,7 @@ import {
|
|
|
105
106
|
RUN_ENDINGS,
|
|
106
107
|
RUN_STATUSES,
|
|
107
108
|
SECRET_ACCESSES,
|
|
109
|
+
SECRET_OFFER_STATES,
|
|
108
110
|
SERVICE_ROLES,
|
|
109
111
|
SESSION_ENDS,
|
|
110
112
|
SESSION_KINDS,
|
|
@@ -138,8 +140,22 @@ const paragraphs = (maxLength: number) =>
|
|
|
138
140
|
/** A body in Markdown. */
|
|
139
141
|
const body = paragraphs(MAX_BODY_LENGTH);
|
|
140
142
|
|
|
143
|
+
/**
|
|
144
|
+
* An address of the web someone sent, of the schemes named: trimmed, bounded, and with nothing
|
|
145
|
+
* in it that hides. A control character is run by the terminal a link is printed in, and an
|
|
146
|
+
* invisible one makes an address read as another, so neither is taken, a tab and a line break
|
|
147
|
+
* among them, which an address has no use for.
|
|
148
|
+
*/
|
|
149
|
+
const link = (protocol: RegExp) =>
|
|
150
|
+
z.string().check(
|
|
151
|
+
z.trim(),
|
|
152
|
+
z.maxLength(MAX_URL_LENGTH),
|
|
153
|
+
z.refine((value) => !hasForbiddenCodePoint(value), "must not contain control characters"),
|
|
154
|
+
z.url({ protocol }),
|
|
155
|
+
);
|
|
156
|
+
|
|
141
157
|
/** A link a person adds to a task: the web, over https, and nothing that runs. */
|
|
142
|
-
const url =
|
|
158
|
+
const url = link(/^https$/);
|
|
143
159
|
|
|
144
160
|
const uuid = z.uuid();
|
|
145
161
|
/** An ISO 8601 instant, as the server writes it. */
|
|
@@ -889,6 +905,13 @@ export const restRunnerHeartbeatInputSchema = z.object({
|
|
|
889
905
|
* out by a runner of before, and empty where the product has said nothing.
|
|
890
906
|
*/
|
|
891
907
|
usage: z.optional(z.array(runnerUsageWindow).check(z.maxLength(MAX_RUNNER_USAGE_WINDOWS))),
|
|
908
|
+
/**
|
|
909
|
+
* When the runner said the reason, by its machine's clock: a reason changes under a state
|
|
910
|
+
* that stays, a turn completes or a new conversation begins while the agent runs on, and is
|
|
911
|
+
* said again the same, so the console cannot tell a turn that just completed from one that
|
|
912
|
+
* did an hour ago. Left out by a runner of before.
|
|
913
|
+
*/
|
|
914
|
+
reasonAt: z.optional(instant),
|
|
892
915
|
});
|
|
893
916
|
export type RestRunnerHeartbeatInput = z.infer<typeof restRunnerHeartbeatInputSchema>;
|
|
894
917
|
|
|
@@ -1004,7 +1027,14 @@ export type RestRunnerHeartbeat = z.infer<typeof restRunnerHeartbeatSchema>;
|
|
|
1004
1027
|
export const restAgentStateSchema = z.object({
|
|
1005
1028
|
state: z.enum(AGENT_STATES),
|
|
1006
1029
|
reason: z.nullable(z.string()),
|
|
1030
|
+
/** Since when the state stands: not when the reason was said, which changes under a state that stays. */
|
|
1007
1031
|
since: instant,
|
|
1032
|
+
/**
|
|
1033
|
+
* When the reason was said: the same moment as `since` where the two came together, a later
|
|
1034
|
+
* one where the reason changed under the state. Left out by a console of before, and `null`
|
|
1035
|
+
* where the console keeps no moment for it: the reason is then shown with none.
|
|
1036
|
+
*/
|
|
1037
|
+
reasonAt: z.optional(z.nullable(instant)),
|
|
1008
1038
|
heardAt: z.nullable(instant),
|
|
1009
1039
|
/**
|
|
1010
1040
|
* Until when it stands so, where its runner said (ADR-0150): when a usage limit resets.
|
|
@@ -1424,6 +1454,65 @@ export const restAgentSecretAccessesSchema = z.object({
|
|
|
1424
1454
|
});
|
|
1425
1455
|
export type RestAgentSecretAccesses = z.infer<typeof restAgentSecretAccessesSchema>;
|
|
1426
1456
|
|
|
1457
|
+
/**
|
|
1458
|
+
* What `POST /api/v1/agents/<handle>/secret-offers` is sent (ADR-0169): the name the offerer
|
|
1459
|
+
* proposes, the value, up to `MAX_AGENT_SECRET_BYTES` of UTF-8, what it is for in a line, and
|
|
1460
|
+
* optionally the day the value ends on.
|
|
1461
|
+
*/
|
|
1462
|
+
export const restAgentSecretOfferInputSchema = z.object({
|
|
1463
|
+
name: z.string().check(z.refine(isSecretName)),
|
|
1464
|
+
value: z.string().check(z.minLength(1), z.maxLength(MAX_AGENT_SECRET_BYTES)),
|
|
1465
|
+
note: z.optional(z.nullable(line(MAX_SECRET_OFFER_NOTE_LENGTH))),
|
|
1466
|
+
expiresOn: z.optional(z.nullable(day)),
|
|
1467
|
+
});
|
|
1468
|
+
export type RestAgentSecretOfferInput = z.infer<typeof restAgentSecretOfferInputSchema>;
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* A secret offered to an agent account (ADR-0169), as its listing says it: never its value. The
|
|
1472
|
+
* name the offerer proposed, what they said it is for, who offered it and through which agent,
|
|
1473
|
+
* how it stands, until when it waits, and, once the account took it, the name it keeps it under.
|
|
1474
|
+
*/
|
|
1475
|
+
export const restAgentSecretOfferSchema = z.object({
|
|
1476
|
+
id: uuid,
|
|
1477
|
+
name: z.string(),
|
|
1478
|
+
note: z.nullable(z.string()),
|
|
1479
|
+
/** Who offered it; `null` for someone who is no longer there. */
|
|
1480
|
+
by: z.nullable(restPersonSchema),
|
|
1481
|
+
/** The agent they offered it through, when they acted with a token; `null` when they did it themselves. */
|
|
1482
|
+
agent: z.nullable(z.string()),
|
|
1483
|
+
expiresOn: z.nullable(day),
|
|
1484
|
+
state: z.enum(SECRET_OFFER_STATES),
|
|
1485
|
+
at: instant,
|
|
1486
|
+
/** Until when it waits: past it, the offer is gone as one left is. */
|
|
1487
|
+
endsAt: instant,
|
|
1488
|
+
/** When the account took or left it, or its days ran out; `null` while it waits. */
|
|
1489
|
+
decidedAt: z.nullable(instant),
|
|
1490
|
+
/** The name the account keeps it under, once taken; `null` otherwise. */
|
|
1491
|
+
takenAs: z.nullable(z.string()),
|
|
1492
|
+
});
|
|
1493
|
+
export type RestAgentSecretOffer = z.infer<typeof restAgentSecretOfferSchema>;
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* `GET /api/v1/agents/me/secret-offers`, the offers that wait for the account itself, and
|
|
1497
|
+
* `GET /api/v1/agents/<handle>/secret-offers`, the account's record of them for a supervisor,
|
|
1498
|
+
* the newest first.
|
|
1499
|
+
*/
|
|
1500
|
+
export const restAgentSecretOffersSchema = z.object({
|
|
1501
|
+
items: z.array(restAgentSecretOfferSchema),
|
|
1502
|
+
});
|
|
1503
|
+
export type RestAgentSecretOffers = z.infer<typeof restAgentSecretOffersSchema>;
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* What `POST /api/v1/agents/me/secret-offers/<id>/take` is sent: the name to keep the value
|
|
1507
|
+
* under, where another than the one offered, and whether it takes the place of a secret the
|
|
1508
|
+
* account keeps under that name already.
|
|
1509
|
+
*/
|
|
1510
|
+
export const restAgentSecretOfferTakeInputSchema = z.object({
|
|
1511
|
+
as: z.optional(z.string().check(z.refine(isSecretName))),
|
|
1512
|
+
replace: z.optional(z.boolean()),
|
|
1513
|
+
});
|
|
1514
|
+
export type RestAgentSecretOfferTakeInput = z.infer<typeof restAgentSecretOfferTakeInputSchema>;
|
|
1515
|
+
|
|
1427
1516
|
/**
|
|
1428
1517
|
* `GET /api/v1/me/manager`: whom whoever asks reports to, a person or an agent account, `null`
|
|
1429
1518
|
* for nobody; and the administrators of the workspace, who stand in where there is nobody, or
|
|
@@ -3166,9 +3255,14 @@ export const restCommentInputSchema = z.object({
|
|
|
3166
3255
|
});
|
|
3167
3256
|
export type RestCommentInput = z.infer<typeof restCommentInputSchema>;
|
|
3168
3257
|
|
|
3169
|
-
/**
|
|
3258
|
+
/**
|
|
3259
|
+
* What `POST .../runs/<id>/artifacts` is sent: a link to what was made. Over https; over plain
|
|
3260
|
+
* http the console takes an address of its own alone, which a console on one machine is served
|
|
3261
|
+
* at (`http://127.0.0.1:11199`), and refuses any other, so the schema lets both schemes through
|
|
3262
|
+
* and the console says which.
|
|
3263
|
+
*/
|
|
3170
3264
|
export const restArtifactInputSchema = z.object({
|
|
3171
|
-
url,
|
|
3265
|
+
url: link(/^https?$/),
|
|
3172
3266
|
label: z.optional(line(MAX_LINK_LABEL_LENGTH)),
|
|
3173
3267
|
});
|
|
3174
3268
|
export type RestArtifactInput = z.infer<typeof restArtifactInputSchema>;
|
package/src/vocabulary.ts
CHANGED
|
@@ -231,6 +231,15 @@ export const SECRET_ACCESSES = ["set", "read", "removed"] as const;
|
|
|
231
231
|
|
|
232
232
|
export type SecretAccess = (typeof SECRET_ACCESSES)[number];
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* How a secret offered to an agent account stands (ADR-0169): it waits for the account; the
|
|
236
|
+
* account took it into its store; the account left it; or its days ran out. Only one that waits
|
|
237
|
+
* holds a value.
|
|
238
|
+
*/
|
|
239
|
+
export const SECRET_OFFER_STATES = ["waiting", "taken", "left", "lapsed"] as const;
|
|
240
|
+
|
|
241
|
+
export type SecretOfferState = (typeof SECRET_OFFER_STATES)[number];
|
|
242
|
+
|
|
234
243
|
/**
|
|
235
244
|
* How an agent account stands, in one word (ADR-0085): `running`, its runner heard from and the
|
|
236
245
|
* agent at work or ready for it; `stopped`, by a supervisor, until one starts it again; `refused`,
|
package/src/wake-text.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MAX_SIGNAL_LENGTH } from "./limits.js";
|
|
2
|
+
|
|
3
|
+
// A wake as the one text a signal carries (ADR-0163, ADR-0166): the lines of whoever raised it,
|
|
4
|
+
// a wake source or the console itself, apart from what someone else wrote, so that no word of a
|
|
5
|
+
// message or of a comment ever reads as a line of the console's. Written here once, for the
|
|
6
|
+
// runner, which writes what its wake sources raise and reads every such text back, and for the
|
|
7
|
+
// console, which writes a wake of the board's that carries a member's words. Pure: no I/O.
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A part of a wake (ADR-0163): a line of the source's own, or what someone else wrote. The
|
|
11
|
+
* runner hands the agent each line under the session's mark and the words in a block of their
|
|
12
|
+
* own, so that nothing a message holds reads as a line of the source's. A line holds what the
|
|
13
|
+
* source says itself, an id and a moment among it, and never a word someone else wrote.
|
|
14
|
+
*/
|
|
15
|
+
export type WakePart = { readonly says: string } | { readonly words: string };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The first version whose runner reads a wake of the board's, and one of the console's own
|
|
19
|
+
* (ADR-0169), in parts (ADR-0166): the console's
|
|
20
|
+
* lines under the session's mark, and what a member wrote, a comment say, in a block. A runner
|
|
21
|
+
* of before prints such a text whole under its header, as the console's own words, so the
|
|
22
|
+
* console writes one in parts only for an account whose runner last said this version or a
|
|
23
|
+
* later one.
|
|
24
|
+
*/
|
|
25
|
+
export const BOARD_PARTS_FROM = "0.6.3";
|
|
26
|
+
|
|
27
|
+
/** A word of a header on one line, with nothing in it that ends the header early. */
|
|
28
|
+
export const inHeader = (text: string): string => text.replaceAll(/[[\]\r\n]+/g, " ").trim();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* What a line of a wake's text begins with, as the console keeps the text (ADR-0163): a line of
|
|
32
|
+
* the wake source's own, and a line of someone else's words. Every line of someone's words is
|
|
33
|
+
* begun so where the text is written, so that no word of theirs is ever a line of the source's.
|
|
34
|
+
*/
|
|
35
|
+
const SAYS = "#";
|
|
36
|
+
const WORDS = ">";
|
|
37
|
+
/** What a wake's text ends on where its parts came to more than a signal carries. */
|
|
38
|
+
const WAKE_CUT = "The wake came to more than a signal carries, and was cut here";
|
|
39
|
+
|
|
40
|
+
/** The first `most` characters of a text, never half of a character that takes two. */
|
|
41
|
+
function firstOf(text: string, most: number): string {
|
|
42
|
+
const last = text.charCodeAt(most - 1);
|
|
43
|
+
return text.slice(0, last >= 0xd800 && last <= 0xdbff ? most - 1 : most);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* What someone wrote, a line each behind `>`. A line break of any spelling ends a line, so that
|
|
48
|
+
* none is left in one to end it for a reader.
|
|
49
|
+
*/
|
|
50
|
+
export function quotedLines(words: string): string[] {
|
|
51
|
+
return words.split(/\r\n?|\n/).map((line) => (line === "" ? WORDS : `${WORDS} ${line}`));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The parts of a wake as the one text a signal carries: a line of the source's own behind `#`,
|
|
56
|
+
* and each line of someone else's words behind `>`, in the order given. The runner writes it so
|
|
57
|
+
* for every wake a source raises, whatever the source handed it, and reads it back so when the
|
|
58
|
+
* signal returns (`wakePartsOf`). Two runs of words with no line between them are parted by a
|
|
59
|
+
* line that says nothing. Within `most` characters, the most a signal carries: what comes to
|
|
60
|
+
* more is cut at the end of a line, or within a line of words, and the text's last line says so.
|
|
61
|
+
*/
|
|
62
|
+
export function wakeTextOf(parts: readonly WakePart[], most = MAX_SIGNAL_LENGTH): string {
|
|
63
|
+
const lines: string[] = [];
|
|
64
|
+
let afterWords = false;
|
|
65
|
+
for (const part of parts) {
|
|
66
|
+
if ("says" in part) {
|
|
67
|
+
const says = inHeader(part.says);
|
|
68
|
+
if (says !== "") {
|
|
69
|
+
lines.push(`${SAYS} ${says}`);
|
|
70
|
+
afterWords = false;
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (part.words === "") {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (afterWords) {
|
|
78
|
+
lines.push(SAYS);
|
|
79
|
+
}
|
|
80
|
+
lines.push(...quotedLines(part.words));
|
|
81
|
+
afterWords = true;
|
|
82
|
+
}
|
|
83
|
+
const whole = lines.join("\n");
|
|
84
|
+
if (whole.length <= most) {
|
|
85
|
+
return whole;
|
|
86
|
+
}
|
|
87
|
+
const cut = `${SAYS} ${WAKE_CUT}`;
|
|
88
|
+
const kept: string[] = [];
|
|
89
|
+
let room = most - cut.length;
|
|
90
|
+
for (const line of lines) {
|
|
91
|
+
if (line.length + 1 > room) {
|
|
92
|
+
// A line of words is carried as far as it goes; one of the source's own, whole or not at all.
|
|
93
|
+
if (line.startsWith(`${WORDS} `) && room > WORDS.length + 2) {
|
|
94
|
+
kept.push(firstOf(line, room - 1));
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
kept.push(line);
|
|
99
|
+
room -= line.length + 1;
|
|
100
|
+
}
|
|
101
|
+
return [...kept, cut].join("\n");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The parts of a wake read back from its text, or nothing where the text is not written as
|
|
106
|
+
* `wakeTextOf` writes one: a wake raised by a runner of before, which is then carried whole as
|
|
107
|
+
* someone else's words, as it was.
|
|
108
|
+
*/
|
|
109
|
+
export function wakePartsOf(text: string): readonly WakePart[] | undefined {
|
|
110
|
+
const parts: WakePart[] = [];
|
|
111
|
+
let words: string[] | undefined;
|
|
112
|
+
const close = (): void => {
|
|
113
|
+
if (words !== undefined) {
|
|
114
|
+
parts.push({ words: words.join("\n") });
|
|
115
|
+
words = undefined;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
for (const line of text.split("\n")) {
|
|
119
|
+
if (line === WORDS || line.startsWith(`${WORDS} `)) {
|
|
120
|
+
words ??= [];
|
|
121
|
+
words.push(line.slice(WORDS.length + 1));
|
|
122
|
+
} else if (line === SAYS || line.startsWith(`${SAYS} `)) {
|
|
123
|
+
close();
|
|
124
|
+
if (line.length > SAYS.length + 1) {
|
|
125
|
+
parts.push({ says: line.slice(SAYS.length + 1) });
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
close();
|
|
132
|
+
return parts;
|
|
133
|
+
}
|