@skillcdn/console 0.5.0 → 0.5.1
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 +68 -11
- package/SKILLCDN.md +3 -3
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +3 -2
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +7 -6
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -5
- package/dist/api.js.map +1 -1
- package/dist/charts.d.ts +103 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +182 -0
- package/dist/charts.js.map +1 -0
- package/dist/cli/cli.d.ts +26 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1304 -383
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command-words.d.ts +20 -0
- package/dist/cli/command-words.d.ts.map +1 -0
- package/dist/cli/command-words.js +51 -0
- package/dist/cli/command-words.js.map +1 -0
- package/dist/cli/credentials.d.ts +54 -5
- package/dist/cli/credentials.d.ts.map +1 -1
- package/dist/cli/credentials.js +126 -20
- package/dist/cli/credentials.js.map +1 -1
- package/dist/cli/directory.d.ts +19 -4
- package/dist/cli/directory.d.ts.map +1 -1
- package/dist/cli/directory.js +16 -8
- package/dist/cli/directory.js.map +1 -1
- package/dist/cli/format.d.ts +65 -8
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +242 -37
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +13 -4
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +92 -54
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +76 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/pack.d.ts +69 -60
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +241 -270
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-check.d.ts +42 -0
- package/dist/cli/plugin-check.d.ts.map +1 -1
- package/dist/cli/plugin-check.js +221 -36
- package/dist/cli/plugin-check.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts +6 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +21 -4
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/plugin-main.js +1 -0
- package/dist/cli/plugin-main.js.map +1 -1
- package/dist/cli/serve.d.ts +33 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +252 -3
- package/dist/cli/serve.js.map +1 -1
- package/dist/client.d.ts +48 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +72 -80
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +64 -1
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +244 -96
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/charts.d.ts +157 -0
- package/dist/components/charts.d.ts.map +1 -0
- package/dist/components/charts.js +182 -0
- package/dist/components/charts.js.map +1 -0
- package/dist/components/desk-records.d.ts +102 -0
- package/dist/components/desk-records.d.ts.map +1 -0
- package/dist/components/desk-records.js +221 -0
- package/dist/components/desk-records.js.map +1 -0
- package/dist/components/desk.d.ts +85 -0
- package/dist/components/desk.d.ts.map +1 -0
- package/dist/components/desk.js +135 -0
- package/dist/components/desk.js.map +1 -0
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +4 -1
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +4 -2
- package/dist/components/home.js.map +1 -1
- package/dist/components/plugin-settings.d.ts.map +1 -1
- package/dist/components/plugin-settings.js +54 -3
- package/dist/components/plugin-settings.js.map +1 -1
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +27 -7
- package/dist/components/projects.js.map +1 -1
- package/dist/components/rules.d.ts +8 -10
- package/dist/components/rules.d.ts.map +1 -1
- package/dist/components/rules.js +35 -13
- package/dist/components/rules.js.map +1 -1
- package/dist/components/setup.d.ts +9 -3
- package/dist/components/setup.d.ts.map +1 -1
- package/dist/components/setup.js +10 -4
- package/dist/components/setup.js.map +1 -1
- package/dist/console.css +677 -7
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +14 -8
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +32 -33
- package/dist/data.js.map +1 -1
- package/dist/desk-page.d.ts +38 -0
- package/dist/desk-page.d.ts.map +1 -0
- package/dist/desk-page.js +184 -0
- package/dist/desk-page.js.map +1 -0
- package/dist/desk-records-page.d.ts +18 -0
- package/dist/desk-records-page.d.ts.map +1 -0
- package/dist/desk-records-page.js +130 -0
- package/dist/desk-records-page.js.map +1 -0
- package/dist/desk-records.d.ts +247 -0
- package/dist/desk-records.d.ts.map +1 -0
- package/dist/desk-records.js +543 -0
- package/dist/desk-records.js.map +1 -0
- package/dist/desk.d.ts +122 -0
- package/dist/desk.d.ts.map +1 -0
- package/dist/desk.js +211 -0
- package/dist/desk.js.map +1 -0
- package/dist/feed-stream.d.ts +39 -0
- package/dist/feed-stream.d.ts.map +1 -0
- package/dist/feed-stream.js +117 -0
- package/dist/feed-stream.js.map +1 -0
- package/dist/home-tiles.d.ts +10 -3
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +54 -31
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +180 -5
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +184 -7
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +169 -6
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +11 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +11 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +3 -3
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/context.d.ts +42 -11
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +2 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +2 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/manifest.d.ts +13 -0
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +30 -3
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +55 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +37 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/plugin/sandbox.d.ts.map +1 -1
- package/dist/plugin/sandbox.js +4 -1
- package/dist/plugin/sandbox.js.map +1 -1
- package/dist/plugin/testing.d.ts +6 -2
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +52 -10
- package/dist/plugin/testing.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/records.d.ts +283 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +543 -0
- package/dist/records.js.map +1 -0
- package/dist/routes.d.ts +3 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +3 -1
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +30 -11
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +98 -45
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +31 -20
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +85 -15
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +19 -16
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/desk.d.ts +43 -2
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +166 -10
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/process.d.ts.map +1 -1
- package/dist/runner/process.js +11 -4
- package/dist/runner/process.js.map +1 -1
- package/dist/runner/redact.d.ts +39 -4
- package/dist/runner/redact.d.ts.map +1 -1
- package/dist/runner/redact.js +81 -5
- package/dist/runner/redact.js.map +1 -1
- package/dist/runner/runner.d.ts +15 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +231 -33
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/task-scheduler.d.ts +20 -0
- package/dist/runner/task-scheduler.d.ts.map +1 -1
- package/dist/runner/task-scheduler.js +34 -4
- package/dist/runner/task-scheduler.js.map +1 -1
- package/dist/runner/types.d.ts +36 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +17 -0
- package/dist/runner/types.js.map +1 -1
- package/dist/runner.d.ts +6 -6
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +5 -5
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +509 -5
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +76 -16
- package/dist/schemas.js.map +1 -1
- package/dist/services.d.ts +22 -5
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +35 -15
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +3 -1
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +7 -4
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +14 -3
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +13 -3
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +64 -38
- package/docs/specs/plugins.md +27 -20
- package/docs/specs/records.md +113 -0
- package/docs/specs/rest.md +20 -13
- package/docs/specs/runner.md +23 -17
- package/package.json +7 -2
- package/skills/building-a-console/SKILL.md +4 -4
- package/skills/building-a-plugin/SKILL.md +6 -6
- package/skills/deploying-a-console/SKILL.md +4 -4
- package/skills/deploying-a-console/references/resources.md +41 -4
- package/skills/deploying-a-console/references/running-it-again.md +3 -2
- package/skills/keeping-a-desk/SKILL.md +133 -0
- package/skills/keeping-a-desk/collections.md +96 -0
- package/skills/planning-the-board/SKILL.md +14 -18
- package/skills/planning-the-board/references/a-task.md +2 -2
- package/skills/planning-the-board/references/project-rules.md +13 -14
- package/skills/planning-the-board/references/setting-up.md +15 -13
- package/skills/running-an-agent/SKILL.md +10 -9
- package/skills/working-the-board/SKILL.md +62 -44
- package/skills/working-the-board/references/terms.md +9 -5
- package/skills/working-the-board/references/the-pack.md +12 -10
- package/skills/working-the-board/references/the-sentence.md +2 -2
- package/src/agent-page.tsx +3 -1
- package/src/api.ts +77 -2
- package/src/charts.ts +250 -0
- package/src/cli/cli.ts +1698 -476
- package/src/cli/command-words.ts +56 -0
- package/src/cli/credentials.ts +181 -20
- package/src/cli/directory.ts +28 -10
- package/src/cli/format.ts +301 -46
- package/src/cli/help.ts +102 -54
- package/src/cli/main.ts +72 -2
- package/src/cli/pack.ts +333 -372
- package/src/cli/plugin-check.ts +275 -34
- package/src/cli/plugin-cli.ts +28 -4
- package/src/cli/plugin-main.ts +1 -0
- package/src/cli/serve.ts +295 -2
- package/src/client.ts +192 -177
- package/src/components/agent-page.tsx +489 -243
- package/src/components/charts.tsx +680 -0
- package/src/components/desk-records.tsx +724 -0
- package/src/components/desk.tsx +471 -0
- package/src/components/event-feed.tsx +5 -1
- package/src/components/home.tsx +12 -0
- package/src/components/plugin-settings.tsx +171 -12
- package/src/components/projects.tsx +29 -12
- package/src/components/rules.tsx +94 -34
- package/src/components/setup.tsx +18 -3
- package/src/console.tsx +17 -9
- package/src/data.ts +37 -34
- package/src/desk-page.tsx +332 -0
- package/src/desk-records-page.tsx +256 -0
- package/src/desk-records.ts +808 -0
- package/src/desk.ts +329 -0
- package/src/feed-stream.ts +144 -0
- package/src/home-tiles.ts +55 -35
- package/src/i18n/en.ts +196 -9
- package/src/i18n/ko.ts +178 -8
- package/src/index.ts +118 -0
- package/src/limits.ts +11 -0
- package/src/onboarding.ts +12 -4
- package/src/plugin/context.ts +55 -12
- package/src/plugin/limits.ts +2 -0
- package/src/plugin/manifest.ts +38 -2
- package/src/plugin/rest-schemas.ts +41 -0
- package/src/plugin/sandbox.ts +4 -1
- package/src/plugin/testing.ts +63 -12
- package/src/plugin.ts +2 -0
- package/src/records.ts +702 -0
- package/src/routes.ts +3 -1
- package/src/rules.ts +108 -47
- package/src/runner/acp.ts +47 -29
- package/src/runner/claude.ts +113 -23
- package/src/runner/codex.ts +35 -25
- package/src/runner/desk.ts +198 -12
- package/src/runner/process.ts +11 -4
- package/src/runner/redact.ts +92 -6
- package/src/runner/runner.ts +275 -34
- package/src/runner/task-scheduler.ts +36 -4
- package/src/runner/types.ts +47 -1
- package/src/runner.ts +27 -2
- package/src/schemas.ts +83 -15
- package/src/services.ts +49 -14
- package/src/setup-guide.ts +6 -2
- package/src/styles/README.md +11 -1
- package/src/styles/console.css +9 -0
- package/src/styles/pages/desk.css +126 -0
- package/src/styles/pages/documents.css +5 -0
- package/src/styles/parts/bars.css +80 -0
- package/src/styles/parts/chart.css +173 -0
- package/src/styles/parts/figures.css +65 -0
- package/src/styles/parts/legend.css +48 -0
- package/src/styles/parts/series.css +32 -0
- package/src/styles/parts/share.css +25 -0
- package/src/styles/parts/spark.css +23 -0
- package/src/styles/parts/stat.css +69 -0
- package/src/styles/tokens.css +13 -7
- package/src/vocabulary.ts +16 -3
- package/template/desk-web/README.md +8 -0
- package/template/desk-web/index.html +13 -0
- package/template/desk-web/package.json +25 -0
- package/template/desk-web/src/main.tsx +24 -0
- package/template/desk-web/src/page.tsx +51 -0
- package/template/desk-web/tsconfig.json +16 -0
- package/template/desk-web/vite.config.ts +15 -0
package/dist/runner/runner.js
CHANGED
|
@@ -3,7 +3,7 @@ import { MAX_RUNNER_LINE_LENGTH, MAX_RUNNER_OFFERS, MAX_TRANSCRIPT_ATTACHMENTS,
|
|
|
3
3
|
import { RUNNER_CHOICE } from "../schemas.js";
|
|
4
4
|
import { hasForbiddenCodePoint } from "../text.js";
|
|
5
5
|
import { composeSignals, deskName, GROUP_WINDOW_MS, introOf, makeMark, } from "./message.js";
|
|
6
|
-
import { redactorOf } from "./redact.js";
|
|
6
|
+
import { cutShown, cutShownEnd, redactorOf } from "./redact.js";
|
|
7
7
|
// The runner (ADR-0085, docs/specs/runner.md): one process per agent account on its machine. It
|
|
8
8
|
// keeps one session of the agent's product at a time, feeds it what the console sends, reports
|
|
9
9
|
// what the product does, and says every thirty seconds that it is there. It restarts nothing by
|
|
@@ -26,6 +26,13 @@ export const MAX_COOL_DOWN_MS = 4 * 60 * 60_000;
|
|
|
26
26
|
export const RECONNECT_MS = 5000;
|
|
27
27
|
/** What an autosave's commit says: the runner's, and never the agent's own words. */
|
|
28
28
|
export const AUTOSAVE_MESSAGE = "Autosave at the end of a session";
|
|
29
|
+
/**
|
|
30
|
+
* How long the runner holds back what the console refused as more than an hour takes
|
|
31
|
+
* (ADR-0132), the events of a session and the wakes of its wake sources: a minute at first,
|
|
32
|
+
* twice as long after each refusal that follows, a quarter of an hour at most.
|
|
33
|
+
*/
|
|
34
|
+
export const HOLD_MS = 60_000;
|
|
35
|
+
export const MAX_HOLD_MS = 15 * 60_000;
|
|
29
36
|
/** The longest the runner waits before it starts a wake source again that keeps ending at once. */
|
|
30
37
|
export const MAX_SOURCE_PAUSE_MS = 5 * 60_000;
|
|
31
38
|
/** How long a wake source holds before the runner takes it to have worked. */
|
|
@@ -126,8 +133,12 @@ export function createRunner(options) {
|
|
|
126
133
|
coolDownMs: COOL_DOWN_MS,
|
|
127
134
|
maxCoolDownMs: MAX_COOL_DOWN_MS,
|
|
128
135
|
reconnectMs: RECONNECT_MS,
|
|
136
|
+
holdMs: HOLD_MS,
|
|
137
|
+
maxHoldMs: MAX_HOLD_MS,
|
|
129
138
|
...options.timing,
|
|
130
139
|
};
|
|
140
|
+
/** How long what an hour's bound refused is held back: the first time, and twice as long each time after. */
|
|
141
|
+
const heldFor = (before) => before === undefined ? timing.holdMs : Math.min(before.pause * 2, timing.maxHoldMs);
|
|
131
142
|
const bounds = { outboxBytes: MAX_OUTBOX_BYTES, ...options.bounds };
|
|
132
143
|
// What keeps failing is said once, and again when what is said of it changes, so that an hour
|
|
133
144
|
// without the console is a line and not thousands; that it is over is said once too.
|
|
@@ -173,7 +184,12 @@ export function createRunner(options) {
|
|
|
173
184
|
timers.add(timer);
|
|
174
185
|
};
|
|
175
186
|
// What the runner holds.
|
|
187
|
+
/** The number of the last signal delivered, every one before it too: what is kept and said to the console. */
|
|
176
188
|
let delivered = 0;
|
|
189
|
+
/** The signals handed to the product that it has not taken yet, by number: not delivered, and not sent twice. */
|
|
190
|
+
const owed = new Set();
|
|
191
|
+
/** The highest number of a signal the product took, or the record says was never read or let go. */
|
|
192
|
+
let settled = 0;
|
|
177
193
|
/** The number of the last signal the stream gave, and of the last one acted on: the second is behind the first while one waits in the queue. */
|
|
178
194
|
let received = 0;
|
|
179
195
|
let handled = 0;
|
|
@@ -204,8 +220,10 @@ export function createRunner(options) {
|
|
|
204
220
|
/** The values of the account's store, by what the store said of them last. */
|
|
205
221
|
let secretsStamp;
|
|
206
222
|
let secretValues = new Map();
|
|
207
|
-
let redact = (
|
|
223
|
+
let redact = redactorOf([]);
|
|
208
224
|
let tooOldSaid = false;
|
|
225
|
+
/** The console took as many wakes of this runner's as an hour takes: until when none is raised, and how long that was. */
|
|
226
|
+
let wakesHeld;
|
|
209
227
|
/**
|
|
210
228
|
* The package the runner runs from, where it is another version than the runner's: the one
|
|
211
229
|
* last seen, and the one seen twice running, which the runner ends for.
|
|
@@ -328,11 +346,18 @@ export function createRunner(options) {
|
|
|
328
346
|
}
|
|
329
347
|
};
|
|
330
348
|
const codeOf = (error) => error instanceof ApiError ? error.code : error instanceof Error ? error.name : "error";
|
|
331
|
-
/**
|
|
332
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Sends what the product did, a batch at a time, the pictures first. What the console has
|
|
351
|
+
* already is left there. Nothing is sent while the console holds the session to its hour
|
|
352
|
+
* (ADR-0132), but at the session's end, which is `last`.
|
|
353
|
+
*/
|
|
354
|
+
const flush = async (target, last = false) => {
|
|
333
355
|
if (flushing) {
|
|
334
356
|
return;
|
|
335
357
|
}
|
|
358
|
+
if (!last && target.hold !== undefined && options.now() < target.hold.until) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
336
361
|
flushing = true;
|
|
337
362
|
const about = `transcript ${target.id}`;
|
|
338
363
|
try {
|
|
@@ -383,6 +408,8 @@ export function createRunner(options) {
|
|
|
383
408
|
for (const event of target.outbox.splice(0, batch.length)) {
|
|
384
409
|
target.waiting -= event.held;
|
|
385
410
|
}
|
|
411
|
+
target.hold = undefined;
|
|
412
|
+
target.unsent = undefined;
|
|
386
413
|
sayOver(about, `the transcript of session ${target.id} is sent again`);
|
|
387
414
|
sayOver(`outbox ${target.id}`);
|
|
388
415
|
}
|
|
@@ -431,6 +458,19 @@ export function createRunner(options) {
|
|
|
431
458
|
target.waiting += only.held - before;
|
|
432
459
|
continue;
|
|
433
460
|
}
|
|
461
|
+
if (code === "transcript.too_many") {
|
|
462
|
+
// As many events as the console takes of a session within an hour: what waits is
|
|
463
|
+
// kept, within what the runner keeps, and sent again after a while, longer each
|
|
464
|
+
// time, so that the console is not asked every second for what it will refuse.
|
|
465
|
+
const pause = heldFor(target.hold);
|
|
466
|
+
target.hold = { until: options.now() + pause, pause };
|
|
467
|
+
target.unsent = code;
|
|
468
|
+
// Nothing is kept past the session's end: what is let go then is said there.
|
|
469
|
+
if (!last) {
|
|
470
|
+
sayOnce(about, `the console takes no more events of session ${target.id} within the hour (${code}); they are kept and sent again later`);
|
|
471
|
+
}
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
434
474
|
if (code === "transcript.session_over" ||
|
|
435
475
|
code === "transcript.session_not_found" ||
|
|
436
476
|
code === "transcript.away") {
|
|
@@ -445,8 +485,10 @@ export function createRunner(options) {
|
|
|
445
485
|
}
|
|
446
486
|
}
|
|
447
487
|
catch (error) {
|
|
448
|
-
// Kept, and sent with the next batch. Said once for as long as it lasts, and when it is
|
|
449
|
-
|
|
488
|
+
// Kept, and sent with the next batch. Said once for as long as it lasts, and when it is
|
|
489
|
+
// over; at the session's end there is no next batch, and what is let go is said there.
|
|
490
|
+
target.unsent = codeOf(error);
|
|
491
|
+
if (!stopped && !last) {
|
|
450
492
|
sayOnce(about, `the transcript of session ${target.id} waits to be sent (${codeOf(error)})`);
|
|
451
493
|
}
|
|
452
494
|
}
|
|
@@ -519,7 +561,10 @@ export function createRunner(options) {
|
|
|
519
561
|
});
|
|
520
562
|
}
|
|
521
563
|
catch (error) {
|
|
522
|
-
|
|
564
|
+
const code = codeOf(error);
|
|
565
|
+
log(code === "transcript.too_many_sessions"
|
|
566
|
+
? `the console begins no more sessions of this account within the hour (${code}); tried again after the cool-down`
|
|
567
|
+
: `a session could not be begun at the console (${code})`);
|
|
523
568
|
for (const path of handed.written) {
|
|
524
569
|
await options.files.remove(path).catch(() => undefined);
|
|
525
570
|
}
|
|
@@ -535,12 +580,17 @@ export function createRunner(options) {
|
|
|
535
580
|
effort: settings.effort,
|
|
536
581
|
resume,
|
|
537
582
|
permissions: config.permissions,
|
|
583
|
+
// Whatever the driver shows a part of is cut once the secrets, as the store has them
|
|
584
|
+
// now, are out of it: no part of one stands where a text was cut.
|
|
585
|
+
cut: (text, most, more) => cutShown(redact, text, most, more),
|
|
586
|
+
cutEnd: (text, most, more) => cutShownEnd(redact, text, most, more),
|
|
538
587
|
}),
|
|
539
588
|
startedAt: options.now(),
|
|
540
589
|
first: true,
|
|
541
590
|
turn: false,
|
|
542
591
|
sent: [],
|
|
543
592
|
handed: [],
|
|
593
|
+
took: false,
|
|
544
594
|
n: 0,
|
|
545
595
|
outbox: [],
|
|
546
596
|
waiting: 0,
|
|
@@ -567,10 +617,24 @@ export function createRunner(options) {
|
|
|
567
617
|
await target.driver.stop().catch(() => undefined);
|
|
568
618
|
}
|
|
569
619
|
await target.pumped;
|
|
570
|
-
|
|
571
|
-
|
|
620
|
+
await hearLast(target);
|
|
621
|
+
// What the product was handed and never took is sent again, by the console where the
|
|
622
|
+
// runner itself ends and by the runner where the product had not started; else it is on
|
|
623
|
+
// the record as never read.
|
|
624
|
+
await leave(target, stopped ? "after" : already || target.took ? undefined : "next");
|
|
572
625
|
record(target, "status", `The session ended: ${how}.`, { ended: how });
|
|
573
|
-
await flush(target);
|
|
626
|
+
await flush(target, true);
|
|
627
|
+
// What the console did not take by now goes with the session: nothing of it is sent
|
|
628
|
+
// later, and the runner's line says how many, where an earlier one said they were kept.
|
|
629
|
+
const unsent = target.outbox.length;
|
|
630
|
+
if (unsent > 0) {
|
|
631
|
+
const one = unsent === 1;
|
|
632
|
+
log(`${unsent} ${one ? "event" : "events"} of session ${target.id} ${one ? "was" : "were"} let go unsent when it ended: ${target.unsent === "transcript.too_many"
|
|
633
|
+
? `the console takes no more of it within the hour (${target.unsent})`
|
|
634
|
+
: `the console did not take ${one ? "it" : "them"} (${target.unsent ?? "error"})`}`);
|
|
635
|
+
}
|
|
636
|
+
saidOf.delete(`transcript ${target.id}`);
|
|
637
|
+
saidOf.delete(`outbox ${target.id}`);
|
|
574
638
|
try {
|
|
575
639
|
await client.endAgentSession(target.id, { how });
|
|
576
640
|
}
|
|
@@ -763,25 +827,124 @@ export function createRunner(options) {
|
|
|
763
827
|
if (waited) {
|
|
764
828
|
write();
|
|
765
829
|
}
|
|
766
|
-
target.handed.push({ written: waited, write });
|
|
830
|
+
target.handed.push({ written: waited, write, signals: batch });
|
|
767
831
|
target.turn = true;
|
|
768
832
|
// Everything handed over since the agent was last done: what a product that took nothing is sent again.
|
|
769
833
|
target.sent = [...target.sent, ...batch];
|
|
770
|
-
|
|
771
|
-
|
|
834
|
+
// Handed over, and not delivered until the product says it took it: a product that did
|
|
835
|
+
// not start took nothing, and a runner that ends then is sent it again when it is back.
|
|
836
|
+
for (const signal of batch) {
|
|
837
|
+
owed.add(signal.number);
|
|
838
|
+
}
|
|
839
|
+
await account();
|
|
840
|
+
};
|
|
841
|
+
/** Counts signals as delivered: the product took them, or the record says what became of them. */
|
|
842
|
+
const count = async (signals) => {
|
|
843
|
+
for (const signal of signals) {
|
|
844
|
+
owed.delete(signal.number);
|
|
845
|
+
settled = Math.max(settled, signal.number);
|
|
846
|
+
}
|
|
772
847
|
await account();
|
|
773
848
|
};
|
|
774
849
|
/**
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
|
|
850
|
+
* The product took the oldest message it was handed: on the record now, where it was not
|
|
851
|
+
* written at once, and delivered.
|
|
852
|
+
*/
|
|
853
|
+
const take = async (target) => {
|
|
854
|
+
target.took = true;
|
|
855
|
+
const message = target.handed.shift();
|
|
856
|
+
if (message !== undefined) {
|
|
857
|
+
if (!message.written) {
|
|
858
|
+
message.write();
|
|
859
|
+
}
|
|
860
|
+
await count(message.signals);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
/**
|
|
864
|
+
* The agent is done with what it was sent: what the product was handed and did not say it
|
|
865
|
+
* took is taken, on the record where the record does not hold it yet, and delivered.
|
|
778
866
|
*/
|
|
779
|
-
const settle = (target
|
|
867
|
+
const settle = async (target) => {
|
|
868
|
+
target.took = true;
|
|
869
|
+
const counted = [];
|
|
780
870
|
for (const message of target.handed.splice(0)) {
|
|
781
871
|
if (!message.written) {
|
|
782
|
-
message.write(
|
|
872
|
+
message.write();
|
|
873
|
+
}
|
|
874
|
+
counted.push(...message.signals);
|
|
875
|
+
}
|
|
876
|
+
await count(counted);
|
|
877
|
+
};
|
|
878
|
+
/**
|
|
879
|
+
* Hears what the product said as its session was ended. Its words wait in the queue behind
|
|
880
|
+
* whatever ended the session, and are let go there once the session is no longer the open
|
|
881
|
+
* one: a message it said it took then is taken, and not sent again, and the conversation it
|
|
882
|
+
* named is the one to go on with, where that message is.
|
|
883
|
+
*/
|
|
884
|
+
const hearLast = async (target) => {
|
|
885
|
+
let named = false;
|
|
886
|
+
for (const message of queue) {
|
|
887
|
+
if (message.t !== "driver" || message.session !== target) {
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
const { event } = message;
|
|
891
|
+
if (event.type === "conversation") {
|
|
892
|
+
conversation = event.id;
|
|
893
|
+
named = true;
|
|
894
|
+
}
|
|
895
|
+
else if (event.type === "taken") {
|
|
896
|
+
await take(target);
|
|
897
|
+
}
|
|
898
|
+
else if (event.type === "turn_completed") {
|
|
899
|
+
await settle(target);
|
|
900
|
+
record(target, "status", "The turn completed.", { turn: "completed" });
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
if (named) {
|
|
904
|
+
await persist();
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
/**
|
|
908
|
+
* What becomes of what the product was handed and never took, as its session ends
|
|
909
|
+
* (ADR-0131). Sent again, it is not delivered, and the record holds nothing more of it than
|
|
910
|
+
* a line that says so: by the console to the runner started `after` this one, where the
|
|
911
|
+
* runner itself ends; by this runner in the `next` session, where the product had taken
|
|
912
|
+
* nothing of this one, and so had not started. Else it is let go: on the record as never
|
|
913
|
+
* read, which delivers it; what the record holds since it was handed over, to a product that
|
|
914
|
+
* waited for a message, is said in a line not to have been taken.
|
|
915
|
+
*/
|
|
916
|
+
const leave = async (target, again) => {
|
|
917
|
+
const messages = target.handed.splice(0);
|
|
918
|
+
const signals = messages.flatMap((message) => message.signals);
|
|
919
|
+
if (signals.length === 0) {
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
const numbersOf = (some) => some.map((signal) => `#${signal.number}`).join(", ");
|
|
923
|
+
if (again !== undefined) {
|
|
924
|
+
const numbers = numbersOf(signals);
|
|
925
|
+
record(target, "status", `The session ended before the product took what it was sent: ${numbers}. It is sent again.`);
|
|
926
|
+
log(`${numbers} not taken when session ${target.id} ended: sent again`);
|
|
927
|
+
if (again === "next") {
|
|
928
|
+
for (const signal of signals) {
|
|
929
|
+
// Waits to be handed over again: owed no word of the product's, and not delivered.
|
|
930
|
+
owed.delete(signal.number);
|
|
931
|
+
sentBefore.add(signal.number);
|
|
932
|
+
}
|
|
933
|
+
pending = [...signals, ...pending];
|
|
934
|
+
}
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
const written = messages.filter((message) => message.written).flatMap((one) => one.signals);
|
|
938
|
+
if (written.length > 0) {
|
|
939
|
+
record(target, "status", `The session ended before the product took what it was sent: ${numbersOf(written)}. Whoever sent it says it again where it still matters.`);
|
|
940
|
+
}
|
|
941
|
+
for (const message of messages) {
|
|
942
|
+
if (!message.written) {
|
|
943
|
+
message.write(true);
|
|
783
944
|
}
|
|
784
945
|
}
|
|
946
|
+
// On the record as never read: delivered.
|
|
947
|
+
await count(signals);
|
|
785
948
|
};
|
|
786
949
|
/**
|
|
787
950
|
* What the transcript says of a signal beside its words: its number and kind, where it came
|
|
@@ -803,13 +966,24 @@ export function createRunner(options) {
|
|
|
803
966
|
return { tries, until: options.now() + length };
|
|
804
967
|
};
|
|
805
968
|
/**
|
|
806
|
-
*
|
|
807
|
-
*
|
|
969
|
+
* Counts what is delivered: signals in order, up to the last one the product took, the record
|
|
970
|
+
* says was never read or let go, or the runner acted on itself, a stop or a choice of model
|
|
971
|
+
* say, and never past one that still waits to be handed to the product or that the product
|
|
972
|
+
* has not said it took.
|
|
808
973
|
*/
|
|
809
974
|
const account = async (signal) => {
|
|
810
975
|
acted = Math.max(acted, signal?.number ?? 0);
|
|
811
|
-
|
|
812
|
-
|
|
976
|
+
const most = Math.max(settled, acted);
|
|
977
|
+
let least = Number.POSITIVE_INFINITY;
|
|
978
|
+
for (const kept of pending) {
|
|
979
|
+
least = Math.min(least, kept.number);
|
|
980
|
+
}
|
|
981
|
+
for (const number of owed) {
|
|
982
|
+
least = Math.min(least, number);
|
|
983
|
+
}
|
|
984
|
+
const next = Math.min(most, least - 1);
|
|
985
|
+
if (next > delivered) {
|
|
986
|
+
delivered = next;
|
|
813
987
|
await persist();
|
|
814
988
|
}
|
|
815
989
|
};
|
|
@@ -821,7 +995,9 @@ export function createRunner(options) {
|
|
|
821
995
|
};
|
|
822
996
|
const onSignal = async (signal) => {
|
|
823
997
|
handled = Math.max(handled, signal.number);
|
|
824
|
-
if (signal.number <= delivered ||
|
|
998
|
+
if (signal.number <= delivered ||
|
|
999
|
+
owed.has(signal.number) ||
|
|
1000
|
+
pending.some((kept) => kept.number === signal.number)) {
|
|
825
1001
|
return;
|
|
826
1002
|
}
|
|
827
1003
|
const by = signal.by?.name ?? signal.by?.login ?? "a supervisor";
|
|
@@ -829,8 +1005,9 @@ export function createRunner(options) {
|
|
|
829
1005
|
case "stop": {
|
|
830
1006
|
held = true;
|
|
831
1007
|
if (session !== undefined) {
|
|
832
|
-
// What the product had not taken is on the record before the stop that leaves it
|
|
833
|
-
|
|
1008
|
+
// What the product had not taken is on the record before the stop that leaves it
|
|
1009
|
+
// unread; what a product that had not started was handed waits for the restart.
|
|
1010
|
+
await leave(session, session.took ? undefined : "next");
|
|
834
1011
|
record(session, "person", signal.text, signalData(signal));
|
|
835
1012
|
}
|
|
836
1013
|
await end("stopped");
|
|
@@ -956,16 +1133,12 @@ export function createRunner(options) {
|
|
|
956
1133
|
return;
|
|
957
1134
|
}
|
|
958
1135
|
case "taken": {
|
|
959
|
-
|
|
960
|
-
const message = target.handed.shift();
|
|
961
|
-
if (message !== undefined && !message.written) {
|
|
962
|
-
message.write();
|
|
963
|
-
}
|
|
1136
|
+
await take(target);
|
|
964
1137
|
return;
|
|
965
1138
|
}
|
|
966
1139
|
case "turn_completed": {
|
|
967
1140
|
// The agent is done with everything it was sent: what a product did not say it took is taken.
|
|
968
|
-
settle(target);
|
|
1141
|
+
await settle(target);
|
|
969
1142
|
// The record says where a turn ends, so that whoever reads it live knows the agent is done.
|
|
970
1143
|
record(target, "status", "The turn completed.", { turn: "completed" });
|
|
971
1144
|
target.turn = false;
|
|
@@ -1011,10 +1184,14 @@ export function createRunner(options) {
|
|
|
1011
1184
|
}
|
|
1012
1185
|
for (const signal of again) {
|
|
1013
1186
|
sentBefore.add(signal.number);
|
|
1187
|
+
// Waits to be handed over again: owed no word of the product's, and not delivered.
|
|
1188
|
+
owed.delete(signal.number);
|
|
1014
1189
|
}
|
|
1015
1190
|
pending = [...again, ...pending];
|
|
1016
1191
|
// Sent again, and on the record when it is taken then.
|
|
1017
1192
|
target.handed = [];
|
|
1193
|
+
// What was let go is on the record as that, and is delivered: it is sent no more.
|
|
1194
|
+
await count(gone);
|
|
1018
1195
|
}
|
|
1019
1196
|
target.sent = [];
|
|
1020
1197
|
waits = cooled(waits);
|
|
@@ -1111,7 +1288,7 @@ export function createRunner(options) {
|
|
|
1111
1288
|
// the product says it took then is this message, which the record holds nothing
|
|
1112
1289
|
// of, and not the message of a signal that waits behind it.
|
|
1113
1290
|
target.turn = true;
|
|
1114
|
-
target.handed.push({ written: true, write: () => undefined });
|
|
1291
|
+
target.handed.push({ written: true, write: () => undefined, signals: [] });
|
|
1115
1292
|
}
|
|
1116
1293
|
catch {
|
|
1117
1294
|
// Not told: the runner's own line above says it to whoever reads its output.
|
|
@@ -1176,7 +1353,28 @@ export function createRunner(options) {
|
|
|
1176
1353
|
const host = {
|
|
1177
1354
|
secret: async (name) => secretValues.get(name),
|
|
1178
1355
|
raise: async (raised) => {
|
|
1179
|
-
|
|
1356
|
+
// The console takes so many wakes a runner raises itself within an hour (ADR-0132):
|
|
1357
|
+
// past that, what the sources raise is let go for a while, longer each time, and said
|
|
1358
|
+
// once, so that a source that repeats itself costs the console nothing more.
|
|
1359
|
+
if (wakesHeld !== undefined && options.now() < wakesHeld.until) {
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
try {
|
|
1363
|
+
await client.raiseWake({ source: "messenger", key: raised.key, text: raised.text });
|
|
1364
|
+
}
|
|
1365
|
+
catch (error) {
|
|
1366
|
+
if (codeOf(error) !== "signal.too_many") {
|
|
1367
|
+
throw error;
|
|
1368
|
+
}
|
|
1369
|
+
const pause = heldFor(wakesHeld);
|
|
1370
|
+
wakesHeld = { until: options.now() + pause, pause };
|
|
1371
|
+
sayOnce("wakes", "the console takes no more wakes of this runner's within the hour (signal.too_many); what its wake sources raise is let go for a while");
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
if (wakesHeld !== undefined) {
|
|
1375
|
+
wakesHeld = undefined;
|
|
1376
|
+
sayOver("wakes", "the console takes the wakes of this runner's wake sources again");
|
|
1377
|
+
}
|
|
1180
1378
|
},
|
|
1181
1379
|
log,
|
|
1182
1380
|
fetch: wakes.fetch,
|