@operad-io/engine 0.1.0 → 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/config.schema.json +2 -1
- package/package.json +1 -1
- package/src/config/config.ts +74 -45
- package/src/flow/types.ts +4 -0
- package/src/flow/validate.ts +5 -0
- package/src/http/index.ts +2 -0
- package/src/http/plugins.ts +66 -0
- package/src/http/server.ts +342 -48
- package/src/kernel/decide.ts +115 -30
- package/src/kernel/state.ts +9 -0
- package/src/kernel/types.ts +25 -40
- package/src/log/open-log.ts +2 -5
- package/src/log/sqlite.ts +127 -85
- package/src/log/types.ts +35 -9
- package/src/loop/code-watch.ts +108 -2
- package/src/loop/older-code.ts +3 -4
- package/src/loop/serve.ts +122 -95
- package/src/notify/notify.ts +2 -6
- package/src/platform/atomic-write.ts +163 -0
- package/src/platform/file-lock.ts +43 -21
- package/src/platform/index.ts +2 -0
- package/src/platform/kept-workers.ts +290 -0
- package/src/platform/process-group.ts +11 -3
- package/src/platform/sqlite-open.ts +20 -6
- package/src/platform/sqlite-schema.ts +30 -0
- package/src/platform/step-reap.ts +33 -18
- package/src/platform/watch.ts +1 -11
- package/src/plugin/action-schema.ts +59 -1
- package/src/plugin/choice-info.ts +133 -0
- package/src/plugin/context.ts +279 -0
- package/src/plugin/declared-flows.ts +3 -10
- package/src/plugin/errors.ts +9 -0
- package/src/plugin/freeze.ts +12 -0
- package/src/plugin/harness.ts +28 -0
- package/src/plugin/index.ts +8 -7
- package/src/plugin/install.ts +265 -17
- package/src/plugin/keys.ts +2 -12
- package/src/plugin/load.ts +47 -23
- package/src/plugin/logger.ts +14 -0
- package/src/plugin/open-store.ts +0 -6
- package/src/plugin/question-form.ts +323 -0
- package/src/plugin/registry.ts +512 -76
- package/src/plugin/secrets.ts +14 -24
- package/src/plugin/semver.ts +52 -0
- package/src/plugin/settings.ts +1 -9
- package/src/plugin/sqlite-store.ts +94 -64
- package/src/plugin/store.ts +5 -0
- package/src/plugin/types.ts +566 -21
- package/src/plugin/validate.ts +396 -26
- package/src/runner/answer.ts +26 -68
- package/src/runner/ask.ts +227 -28
- package/src/runner/cancel.ts +10 -7
- package/src/runner/grants.ts +2 -2
- package/src/runner/index.ts +1 -3
- package/src/runner/limits.ts +2 -2
- package/src/runner/runner.ts +15 -14
- package/src/runner/service.ts +52 -19
- package/src/runner/step-worker.ts +9 -0
- package/src/testing/answer.ts +69 -0
- package/src/testing/clock-manual.ts +152 -0
- package/src/testing/config.ts +16 -0
- package/src/testing/fs.ts +172 -0
- package/src/testing/home.ts +43 -0
- package/src/testing/index.ts +19 -0
- package/src/testing/types.ts +2 -0
- package/src/testing/world.ts +9 -2
- package/src/trigger/kernel.ts +13 -46
- package/src/trigger/rules.ts +22 -12
- package/src/trigger/types.ts +2 -6
- package/src/util.ts +99 -0
- package/src/views/event-line.ts +22 -0
- package/src/views/history.ts +36 -19
- package/src/views/live-logs.ts +313 -0
- package/src/views/pending.ts +23 -5
- package/src/views/presentation.ts +629 -81
- package/src/views/running.ts +5 -5
- package/src/views/settings.ts +205 -66
- package/src/views/types.ts +3 -2
- package/src/views/uploads.ts +15 -7
- package/triggers.schema.json +4 -0
package/src/plugin/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ClientApi } from "../views/presentation.ts";
|
|
2
|
+
import type { ActionInfo } from "./registry.ts";
|
|
2
3
|
import type { FlowDefinition } from "../flow/types.ts";
|
|
3
4
|
import type { KernelState } from "../kernel/types.ts";
|
|
4
5
|
import type { Secret } from "../log/secret.ts";
|
|
@@ -10,6 +11,7 @@ import type {
|
|
|
10
11
|
TriggerRule,
|
|
11
12
|
TriggerView,
|
|
12
13
|
} from "../trigger/types.ts";
|
|
14
|
+
import { isRecord } from "../util.ts";
|
|
13
15
|
|
|
14
16
|
/** The plugin API version a module declares with `operadPlugin`. */
|
|
15
17
|
export const OPERAD_PLUGIN_VERSION = 1 as const;
|
|
@@ -110,6 +112,12 @@ export interface ObjectRow {
|
|
|
110
112
|
* does. The row is drawn waiting, like one with a run waiting.
|
|
111
113
|
*/
|
|
112
114
|
readonly waiting?: boolean | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Structured data the plugin defines for its clients, passed through
|
|
117
|
+
* unchanged. The kernel reads no field of it; a client that does not know
|
|
118
|
+
* a plugin's shape ignores it.
|
|
119
|
+
*/
|
|
120
|
+
readonly data?: Readonly<Record<string, JsonValue>> | undefined;
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
/** One section a detail page offers. `live` means its content still grows. */
|
|
@@ -128,6 +136,25 @@ export interface SectionReadOptions {
|
|
|
128
136
|
* does not implement it answers with the whole section and leaves `delta` out.
|
|
129
137
|
*/
|
|
130
138
|
readonly after?: string | undefined;
|
|
139
|
+
/** The read asked to skip the size cap, so the plugin may leave its data whole. */
|
|
140
|
+
readonly full?: boolean | undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** What a live section says it is doing, and since when. */
|
|
144
|
+
export interface SectionStatus {
|
|
145
|
+
readonly text: string;
|
|
146
|
+
/** When the state named by `text` began, in milliseconds since the epoch. */
|
|
147
|
+
readonly since: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** A model request a harness waits to try again, with when the next attempt starts. */
|
|
151
|
+
export interface SectionRetry {
|
|
152
|
+
readonly attempt: number;
|
|
153
|
+
readonly maxAttempts: number;
|
|
154
|
+
/** When the next attempt starts, in milliseconds since the epoch. */
|
|
155
|
+
readonly until: number;
|
|
156
|
+
/** The provider's message that caused the retry. */
|
|
157
|
+
readonly reason: string;
|
|
131
158
|
}
|
|
132
159
|
|
|
133
160
|
/** The Markdown of one section, and where to continue when it is paged. */
|
|
@@ -146,6 +173,34 @@ export interface SectionContent {
|
|
|
146
173
|
* text, not only what changed since the last read.
|
|
147
174
|
*/
|
|
148
175
|
readonly tail?: string | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* What the live section is doing now; the kernel passes it through and
|
|
178
|
+
* never reads it. A client that does not know it ignores it.
|
|
179
|
+
*/
|
|
180
|
+
readonly status?: SectionStatus | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* A model request the harness is waiting to try again. The kernel passes it
|
|
183
|
+
* through on every read; a client that does not know it ignores it.
|
|
184
|
+
*/
|
|
185
|
+
readonly retry?: SectionRetry | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Numbers a client shows beside the section, such as how full an agent's
|
|
188
|
+
* context is. The kernel passes it through on every read; a client that
|
|
189
|
+
* does not know it ignores it.
|
|
190
|
+
*/
|
|
191
|
+
readonly context?:
|
|
192
|
+
| {
|
|
193
|
+
readonly used: number;
|
|
194
|
+
readonly window?: number | undefined;
|
|
195
|
+
readonly model?: string | undefined;
|
|
196
|
+
}
|
|
197
|
+
| undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Structured data the plugin defines for its clients, passed through
|
|
200
|
+
* unchanged on every read. A client that does not know a plugin's shape
|
|
201
|
+
* ignores it.
|
|
202
|
+
*/
|
|
203
|
+
readonly data?: Readonly<Record<string, JsonValue>> | undefined;
|
|
149
204
|
/**
|
|
150
205
|
* `markdown` holds only what follows the requested `after`. Omit, or set
|
|
151
206
|
* false, when the answer is a whole page; the kernel then tells the client
|
|
@@ -191,6 +246,12 @@ export interface ViewContext extends PluginBaseContext {
|
|
|
191
246
|
readonly settingsInForce?:
|
|
192
247
|
| ((plugin: string) => Readonly<Record<string, JsonValue>>)
|
|
193
248
|
| undefined;
|
|
249
|
+
/**
|
|
250
|
+
* The most bytes a section read may return when the client did not ask for
|
|
251
|
+
* `full`: Markdown, the tail and the plugin's data together. A plugin that
|
|
252
|
+
* carries data cuts its own parts before the kernel shortens Markdown.
|
|
253
|
+
*/
|
|
254
|
+
readonly sectionCapBytes: number;
|
|
194
255
|
/**
|
|
195
256
|
* An object after its type's `prepare` has run with the settings in force
|
|
196
257
|
* now, so a view can see a change without a restart. Undefined when the
|
|
@@ -213,6 +274,8 @@ export interface SecretStore {
|
|
|
213
274
|
set(name: string, value: string | Secret<string>): Promise<void>;
|
|
214
275
|
delete(name: string): Promise<void>;
|
|
215
276
|
names(): Promise<readonly string[]>;
|
|
277
|
+
/** Every value, from one read of the store, so masking costs one file read. */
|
|
278
|
+
values(): Promise<readonly string[]>;
|
|
216
279
|
}
|
|
217
280
|
|
|
218
281
|
/** How one object type appears to every client. */
|
|
@@ -226,6 +289,70 @@ export interface ObjectViews {
|
|
|
226
289
|
* one namespace exists. Read once per list.
|
|
227
290
|
*/
|
|
228
291
|
readonly showScope?: ((ctx: ViewContext) => MaybePromise<boolean>) | undefined;
|
|
292
|
+
/**
|
|
293
|
+
* Numbers a detail page shows beside its row, such as how full an agent's
|
|
294
|
+
* context is. It may read facts and may be slow; the kernel passes it
|
|
295
|
+
* through and reads no meaning into it. Absent when the type has none.
|
|
296
|
+
*/
|
|
297
|
+
readonly context?:
|
|
298
|
+
| ((
|
|
299
|
+
ctx: ViewContext,
|
|
300
|
+
object: StoredObject,
|
|
301
|
+
) => MaybePromise<
|
|
302
|
+
| {
|
|
303
|
+
readonly used: number;
|
|
304
|
+
readonly window?: number | undefined;
|
|
305
|
+
readonly model?: string | undefined;
|
|
306
|
+
}
|
|
307
|
+
| undefined
|
|
308
|
+
>)
|
|
309
|
+
| undefined;
|
|
310
|
+
/**
|
|
311
|
+
* The skills an object offers as `/name` commands, such as a chat's. The
|
|
312
|
+
* kernel passes it through and reads no meaning into it. Absent when the
|
|
313
|
+
* type has none.
|
|
314
|
+
*/
|
|
315
|
+
readonly skills?:
|
|
316
|
+
| ((
|
|
317
|
+
ctx: ViewContext,
|
|
318
|
+
object: StoredObject,
|
|
319
|
+
) => MaybePromise<readonly ViewSkill[] | undefined>)
|
|
320
|
+
| undefined;
|
|
321
|
+
/**
|
|
322
|
+
* Whether a file below the object's attachment directory may be served: a
|
|
323
|
+
* path the object's own records name, never one a client chose. The kernel
|
|
324
|
+
* passes the path segments after the type and id, already decoded. A type
|
|
325
|
+
* that declares it serves only what it allows; a type without it keeps the
|
|
326
|
+
* kernel's attachment-directory bounds, as before.
|
|
327
|
+
*/
|
|
328
|
+
readonly file?:
|
|
329
|
+
| ((
|
|
330
|
+
ctx: ViewContext,
|
|
331
|
+
object: StoredObject,
|
|
332
|
+
path: readonly string[],
|
|
333
|
+
) => MaybePromise<boolean>)
|
|
334
|
+
| undefined;
|
|
335
|
+
/**
|
|
336
|
+
* The changing part of a live section, pushed on the event stream as it
|
|
337
|
+
* grows. The kernel passes `section`, `tail`, `status` and `data` through
|
|
338
|
+
* without reading them, in the same shapes a section read uses. Absent: the
|
|
339
|
+
* type pushes no live part and an event carries only the object id.
|
|
340
|
+
*/
|
|
341
|
+
readonly tail?:
|
|
342
|
+
| ((
|
|
343
|
+
ctx: ViewContext,
|
|
344
|
+
object: StoredObject,
|
|
345
|
+
) => MaybePromise<
|
|
346
|
+
| {
|
|
347
|
+
readonly section: string;
|
|
348
|
+
readonly tail?: string | undefined;
|
|
349
|
+
readonly status?: SectionStatus | undefined;
|
|
350
|
+
readonly retry?: SectionRetry | undefined;
|
|
351
|
+
readonly data?: Readonly<Record<string, JsonValue>> | undefined;
|
|
352
|
+
}
|
|
353
|
+
| undefined
|
|
354
|
+
>)
|
|
355
|
+
| undefined;
|
|
229
356
|
/** Called when a person opens a section; it may be slow and paged. */
|
|
230
357
|
readonly load: (
|
|
231
358
|
ctx: ViewContext,
|
|
@@ -235,6 +362,13 @@ export interface ObjectViews {
|
|
|
235
362
|
) => MaybePromise<SectionContent>;
|
|
236
363
|
}
|
|
237
364
|
|
|
365
|
+
/** A skill an object offers as a `/name` command: its name and what it does. */
|
|
366
|
+
export interface ViewSkill {
|
|
367
|
+
readonly name: string;
|
|
368
|
+
/** The description from its `SKILL.md`, cut to what a menu shows. */
|
|
369
|
+
readonly description?: string | undefined;
|
|
370
|
+
}
|
|
371
|
+
|
|
238
372
|
/** A key binding a plugin brings as its default. */
|
|
239
373
|
export type KeyBindings = Readonly<Record<string, string>>;
|
|
240
374
|
|
|
@@ -336,6 +470,12 @@ export interface ObjectStore {
|
|
|
336
470
|
/** One page of one object's facts in sequence order. */
|
|
337
471
|
facts(object: ObjectRef, options?: FactsOptions): FactsPage;
|
|
338
472
|
|
|
473
|
+
/**
|
|
474
|
+
* The sequence of the object's latest fact, or 0 when it has none. A cheap
|
|
475
|
+
* revision for a reader that need not read the facts themselves.
|
|
476
|
+
*/
|
|
477
|
+
latestFactSequence?(object: ObjectRef): number;
|
|
478
|
+
|
|
339
479
|
/** The distinct object types that have facts under this object id, sorted. */
|
|
340
480
|
objectTypesOf(id: string): readonly string[];
|
|
341
481
|
|
|
@@ -417,6 +557,8 @@ export interface PluginBaseContext {
|
|
|
417
557
|
readonly secrets: SecretStore;
|
|
418
558
|
/** Set when the kernel can cancel a run for this plugin. */
|
|
419
559
|
readonly runs?: RunControl | undefined;
|
|
560
|
+
/** The setup guides; set on commands and actions. */
|
|
561
|
+
readonly setup?: SetupReader | undefined;
|
|
420
562
|
}
|
|
421
563
|
|
|
422
564
|
/** The answer a plugin action gives to the person wait it is answering. */
|
|
@@ -424,25 +566,159 @@ export type Answer = (choice: string, note?: string) => MaybePromise<void>;
|
|
|
424
566
|
|
|
425
567
|
/** What a plugin may ask the kernel to do with a run it owns. */
|
|
426
568
|
export interface RunControl {
|
|
427
|
-
/**
|
|
428
|
-
|
|
569
|
+
/**
|
|
570
|
+
* Cancels a run through the kernel; an ended run is left alone. True when
|
|
571
|
+
* this cancelled an active run, so a plugin can tell it from a run that had
|
|
572
|
+
* already ended; a host that does not report says nothing.
|
|
573
|
+
*/
|
|
574
|
+
cancel(runId: string, flow?: FlowDefinition): MaybePromise<boolean | void>;
|
|
575
|
+
/**
|
|
576
|
+
* Whether the run still exists and has not ended. Undefined when the host
|
|
577
|
+
* cannot tell. A status view uses it to stop calling a crashed run writing.
|
|
578
|
+
*/
|
|
579
|
+
active(runId: string): MaybePromise<boolean | void>;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/** One thing a plugin's check found not set up (ADR 0010 D7). */
|
|
583
|
+
export interface MissingItem {
|
|
584
|
+
/** A short word, unique within the plugin. */
|
|
585
|
+
readonly name: string;
|
|
586
|
+
/** One sentence saying what is not set up. */
|
|
587
|
+
readonly description: string;
|
|
429
588
|
}
|
|
430
589
|
|
|
590
|
+
/** What a plugin's `check` may return: a note, nothing, or the missing items. */
|
|
591
|
+
export type PluginCheckReturn =
|
|
592
|
+
| string
|
|
593
|
+
| void
|
|
594
|
+
| { readonly note?: string | undefined; readonly missing: readonly MissingItem[] };
|
|
595
|
+
|
|
431
596
|
/** The result of one plugin's optional `check`. */
|
|
432
597
|
export interface PluginCheck {
|
|
433
598
|
readonly plugin: string;
|
|
434
599
|
readonly ok: boolean;
|
|
435
600
|
readonly message: string;
|
|
601
|
+
/** What the check found not set up; present only when the check returned the object form. */
|
|
602
|
+
readonly missing?: readonly MissingItem[] | undefined;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** A plugin's setup guide with what its check finds missing now (ADR 0010 D7). */
|
|
606
|
+
export interface SetupGuide {
|
|
607
|
+
readonly plugin: string;
|
|
608
|
+
/** Whether the plugin is loaded; an off plugin reports the one item `enable`. */
|
|
609
|
+
readonly enabled: boolean;
|
|
610
|
+
/** The guide's text without its front matter. */
|
|
611
|
+
readonly text: string;
|
|
612
|
+
readonly missing: readonly MissingItem[];
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** Reads the setup guides of plugins, loaded or off. */
|
|
616
|
+
export interface SetupReader {
|
|
617
|
+
/** The names and state of the plugins that have a guide. */
|
|
618
|
+
list(): Promise<readonly { readonly plugin: string; readonly enabled: boolean }[]>;
|
|
619
|
+
/** One plugin's guide; undefined when it has none or is unknown. */
|
|
620
|
+
get(plugin: string): Promise<SetupGuide | undefined>;
|
|
436
621
|
}
|
|
437
622
|
|
|
438
623
|
/** The longest grace, in seconds, a timer can hold (2^31-1 ms, rounded down). */
|
|
439
624
|
export const MAX_ASK_GRACE_SECS = 2_147_483;
|
|
440
625
|
|
|
626
|
+
/** What one choice of a question says about itself. */
|
|
627
|
+
export interface ChoiceInfo {
|
|
628
|
+
/** What a client shows instead of the raw choice. */
|
|
629
|
+
readonly label?: string | undefined;
|
|
630
|
+
/** One sentence saying what choosing this does. */
|
|
631
|
+
readonly hint?: string | undefined;
|
|
632
|
+
/** The asker recommends `primary`; `destructive` cannot be undone. */
|
|
633
|
+
readonly role?: "primary" | "destructive" | undefined;
|
|
634
|
+
/** Whether the answer may or must carry a note. */
|
|
635
|
+
readonly note?: "optional" | "required" | undefined;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** One answer a form's question offers. */
|
|
639
|
+
export interface AskQuestionChoice {
|
|
640
|
+
/** What a client shows and what an answer names. */
|
|
641
|
+
readonly label: string;
|
|
642
|
+
/** One sentence saying what choosing this means. */
|
|
643
|
+
readonly description?: string | undefined;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* One question of a form a step asks a person: the agent's own question, with
|
|
648
|
+
* its choices, carried through the kernel unchanged.
|
|
649
|
+
*/
|
|
650
|
+
export interface AskQuestion {
|
|
651
|
+
/** What an answer names this question by; unique within the form. */
|
|
652
|
+
readonly id: string;
|
|
653
|
+
/** The question in full, as the agent asked it; for a plan review, its title. */
|
|
654
|
+
readonly text: string;
|
|
655
|
+
/**
|
|
656
|
+
* Long Markdown the question asks about, when its text alone cannot hold it:
|
|
657
|
+
* a plan review carries the plan here. Clients show it as written.
|
|
658
|
+
*/
|
|
659
|
+
readonly body?: string | undefined;
|
|
660
|
+
/** A short label a client shows beside the question. */
|
|
661
|
+
readonly header?: string | undefined;
|
|
662
|
+
/** The answers offered; absent or empty means free text only. */
|
|
663
|
+
readonly choices?: readonly AskQuestionChoice[] | undefined;
|
|
664
|
+
/** True when the person may pick more than one choice. */
|
|
665
|
+
readonly multiple?: boolean | undefined;
|
|
666
|
+
/** True when the person may answer in their own words. */
|
|
667
|
+
readonly freeText?: boolean | undefined;
|
|
668
|
+
/**
|
|
669
|
+
* An absolute `http:` or `https:` address a client shows and may open, such
|
|
670
|
+
* as a login page. The plugin checks the host and path before it puts one
|
|
671
|
+
* here; the kernel checks only the scheme and the length (ADR 0008 D8).
|
|
672
|
+
*/
|
|
673
|
+
readonly url?: string | undefined;
|
|
674
|
+
/** A short bounded text a client shows for the person to copy, such as a device code. */
|
|
675
|
+
readonly code?: string | undefined;
|
|
676
|
+
/**
|
|
677
|
+
* True when the person's own text is a secret: a client masks the input, and
|
|
678
|
+
* the kernel keeps the answer out of every fact and record. Needs `freeText`.
|
|
679
|
+
*/
|
|
680
|
+
readonly secret?: true | undefined;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/** The person's answer to one question of a form. */
|
|
684
|
+
export interface AskQuestionAnswer {
|
|
685
|
+
/** The question this answers; one of the form's ids. */
|
|
686
|
+
readonly id: string;
|
|
687
|
+
/** The labels picked, in the form's order. */
|
|
688
|
+
readonly choices?: readonly string[] | undefined;
|
|
689
|
+
/** What the person typed, instead of or beside a choice. */
|
|
690
|
+
readonly text?: string | undefined;
|
|
691
|
+
/** True when the person gave no answer to this question. */
|
|
692
|
+
readonly skipped?: true | undefined;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** What a question says when it is checked again while it waits. */
|
|
696
|
+
export interface AskRecheck {
|
|
697
|
+
/** False when this question no longer needs a person. */
|
|
698
|
+
readonly ask: boolean;
|
|
699
|
+
/** Why it was let through, shown in history; the level's own title for a level change. */
|
|
700
|
+
readonly note?: string | undefined;
|
|
701
|
+
/** Who changed what lifted the question, when one person did. */
|
|
702
|
+
readonly actor?: Actor | undefined;
|
|
703
|
+
}
|
|
704
|
+
|
|
441
705
|
/** What a step asks a person with `ctx.ask`. */
|
|
442
706
|
export interface AskRequest {
|
|
443
707
|
readonly prompt: string;
|
|
444
708
|
/** The answers offered; none means a free note only. */
|
|
445
709
|
readonly choices?: readonly string[] | undefined;
|
|
710
|
+
/**
|
|
711
|
+
* What each choice is, keyed by the choice string an answer sends. The keys
|
|
712
|
+
* must be choices; at most one is `primary`. The kernel checks it and carries
|
|
713
|
+
* it to every read of the question.
|
|
714
|
+
*/
|
|
715
|
+
readonly choiceInfo?: Readonly<Record<string, ChoiceInfo>> | undefined;
|
|
716
|
+
/**
|
|
717
|
+
* The form the person fills in, when the agent asked questions rather than
|
|
718
|
+
* for one answer. A form has no `choices` of its own: the kernel shows one
|
|
719
|
+
* question's labels to a client that cannot draw a form.
|
|
720
|
+
*/
|
|
721
|
+
readonly questions?: readonly AskQuestion[] | undefined;
|
|
446
722
|
/**
|
|
447
723
|
* How long to wait for the answer, in seconds, while the step goes on
|
|
448
724
|
* waiting. The narrowest of this, the step's `askGraceSecs` param and the
|
|
@@ -457,6 +733,13 @@ export interface AskRequest {
|
|
|
457
733
|
readonly onTimeout?: "waiting" | "reject_once" | undefined;
|
|
458
734
|
/** What the step needs to carry on later; handed back in the `waiting` data. */
|
|
459
735
|
readonly resume?: JsonValue | undefined;
|
|
736
|
+
/**
|
|
737
|
+
* Whether the question still needs a person. The host checks it while the
|
|
738
|
+
* question waits; when it says no, the question is answered `allow_once` with
|
|
739
|
+
* its note and actor. A level change uses this so a question it made
|
|
740
|
+
* unnecessary does not stay open.
|
|
741
|
+
*/
|
|
742
|
+
readonly recheck?: (() => MaybePromise<AskRecheck>) | undefined;
|
|
460
743
|
}
|
|
461
744
|
|
|
462
745
|
/** The answer `ctx.ask` returns. */
|
|
@@ -467,14 +750,11 @@ export interface AskAnswer {
|
|
|
467
750
|
readonly actor?: Actor | undefined;
|
|
468
751
|
/** True when the grace passed and `onTimeout` was `"reject_once"`. */
|
|
469
752
|
readonly rejected?: boolean | undefined;
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
readonly
|
|
475
|
-
readonly prompt: string;
|
|
476
|
-
readonly choices: readonly string[];
|
|
477
|
-
readonly resume: JsonValue;
|
|
753
|
+
/**
|
|
754
|
+
* The person's answer to each question of a form, in the form's order, with
|
|
755
|
+
* `skipped` for one they left alone. Absent for a question that is not a form.
|
|
756
|
+
*/
|
|
757
|
+
readonly answers?: readonly AskQuestionAnswer[] | undefined;
|
|
478
758
|
}
|
|
479
759
|
|
|
480
760
|
/** What the host reports back for one question a step asked. */
|
|
@@ -485,6 +765,11 @@ export type AskOutcome =
|
|
|
485
765
|
readonly waitId: string;
|
|
486
766
|
readonly prompt: string;
|
|
487
767
|
readonly choices: readonly string[];
|
|
768
|
+
readonly choiceInfo?: Readonly<Record<string, ChoiceInfo>> | undefined;
|
|
769
|
+
/** The form the step asked, when it asked one. */
|
|
770
|
+
readonly questions?: readonly AskQuestion[] | undefined;
|
|
771
|
+
/** What the step needs to carry on later, when the asker shaped it; the request's own resume otherwise. */
|
|
772
|
+
readonly resume?: JsonValue | undefined;
|
|
488
773
|
};
|
|
489
774
|
|
|
490
775
|
/**
|
|
@@ -505,9 +790,13 @@ export interface StepAsker {
|
|
|
505
790
|
/** The context a step run receives. */
|
|
506
791
|
export interface StepContext extends PluginBaseContext {
|
|
507
792
|
readonly runId: string;
|
|
793
|
+
/** The names of the loaded plugins of kind `harness`. */
|
|
794
|
+
readonly harnesses: readonly string[];
|
|
508
795
|
readonly object: RunObject | undefined;
|
|
509
796
|
/** Fixed JSON the flow was started with; null when it was given none. */
|
|
510
797
|
readonly params: JsonValue;
|
|
798
|
+
/** The flow definition the run executes; absent in a direct step call with no flow. */
|
|
799
|
+
readonly flow?: FlowDefinition | undefined;
|
|
511
800
|
/** The run's access profile, opaque to the kernel; null when it has none. */
|
|
512
801
|
readonly access: JsonValue;
|
|
513
802
|
/** The event that started the run, with paths to its text. */
|
|
@@ -543,8 +832,15 @@ export interface StepContext extends PluginBaseContext {
|
|
|
543
832
|
readonly stepLoaded?: ((use: string) => boolean) | undefined;
|
|
544
833
|
/** The models a loaded harness plugin declares; undefined when it is not loaded or declares none. */
|
|
545
834
|
readonly harnessModels?: ((harness: string) => HarnessModels | undefined) | undefined;
|
|
835
|
+
/**
|
|
836
|
+
* The models a loaded harness plugin declares, waiting for one refresh when
|
|
837
|
+
* the plugin has no kept list yet. Undefined when it is not loaded or declares none.
|
|
838
|
+
*/
|
|
839
|
+
readonly harnessModelsReady?: ((harness: string) => Promise<HarnessModels | undefined>) | undefined;
|
|
546
840
|
/** The efforts a loaded harness plugin declares; undefined when it is not loaded or declares none. */
|
|
547
841
|
readonly harnessEfforts?: ((harness: string) => HarnessEfforts | undefined) | undefined;
|
|
842
|
+
/** What a loaded harness plugin declares it can do; undefined when it is not loaded. */
|
|
843
|
+
readonly harnessCapabilities?: ((harness: string) => HarnessCapabilities | undefined) | undefined;
|
|
548
844
|
/**
|
|
549
845
|
* Runs another loaded step in this run. The kernel offers it when a plugin
|
|
550
846
|
* step delegates to a harness or another plugin; a direct call to a step's
|
|
@@ -623,6 +919,8 @@ export interface StepRunOptions {
|
|
|
623
919
|
readonly cwd?: string | undefined;
|
|
624
920
|
readonly signal?: AbortSignal | undefined;
|
|
625
921
|
readonly params?: JsonValue | undefined;
|
|
922
|
+
/** The flow definition the run executes, for a step that binds data to it. */
|
|
923
|
+
readonly flow?: FlowDefinition | undefined;
|
|
626
924
|
/** The run's access profile; the kernel only checks who enforces it. */
|
|
627
925
|
readonly access?: JsonValue | undefined;
|
|
628
926
|
readonly trigger?: TriggerView | undefined;
|
|
@@ -636,6 +934,24 @@ export interface StepRunOptions {
|
|
|
636
934
|
| undefined;
|
|
637
935
|
}
|
|
638
936
|
|
|
937
|
+
/** Where a plugin write goes outside operad: one call's target and its full content. */
|
|
938
|
+
export interface OutwardWrite {
|
|
939
|
+
/** A message, mail or post; a repository push; a call to an outside service; or a shell command. */
|
|
940
|
+
readonly kind: "channel" | "mail" | "post" | "repository" | "service" | "command";
|
|
941
|
+
/** The target as a person reads it: a channel and conversation, an address, a remote and branch, a service, or a command. */
|
|
942
|
+
readonly target: string;
|
|
943
|
+
/** The full content the write carries, when the plugin can name it. */
|
|
944
|
+
readonly content?: string | undefined;
|
|
945
|
+
/** True when the target is one of the owner's own channels, which never ask. */
|
|
946
|
+
readonly owner?: boolean | undefined;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/** The outward writes of one call, or none. */
|
|
950
|
+
export type OutwardWrites = OutwardWrite | readonly OutwardWrite[] | undefined;
|
|
951
|
+
|
|
952
|
+
/** Names the target of one call a step or action writes outward. */
|
|
953
|
+
export type OutwardTargets = (input: unknown) => OutwardWrites;
|
|
954
|
+
|
|
639
955
|
/** A step type a plugin declares. The use name is `<plugin>/<name>`. */
|
|
640
956
|
export interface StepTypeDefinition {
|
|
641
957
|
readonly name: string;
|
|
@@ -665,6 +981,14 @@ export interface StepTypeDefinition {
|
|
|
665
981
|
readonly callsNamedByData?: boolean | undefined;
|
|
666
982
|
/** Access profile fields this step applies, such as `denyPaths`. */
|
|
667
983
|
readonly enforces?: readonly string[] | undefined;
|
|
984
|
+
/**
|
|
985
|
+
* True when this step can write outside operad: send a message, mail or a
|
|
986
|
+
* post, push, or call an outside service. `outward` names the target of one
|
|
987
|
+
* call; an undeclared step that marks itself so counts as outward, with the
|
|
988
|
+
* whole call as the target.
|
|
989
|
+
*/
|
|
990
|
+
readonly reachesOutside?: boolean | undefined;
|
|
991
|
+
readonly outward?: OutwardTargets | undefined;
|
|
668
992
|
/**
|
|
669
993
|
* How long one run of this step may take, in seconds. Default: the runner's
|
|
670
994
|
* step timeout (5 minutes). A step that runs an agent or a test suite sets
|
|
@@ -755,9 +1079,11 @@ export type ActionArgType =
|
|
|
755
1079
|
* One property of an action's arguments. It is the JSON Schema subset the
|
|
756
1080
|
* kernel validates: `type`, `enum`, `minimum`, `maximum`, `minLength`,
|
|
757
1081
|
* `maxLength`, `items`, `properties`, `required`, `additionalProperties` (`false` or a schema for the other fields),
|
|
758
|
-
* `description` and `role`.
|
|
1082
|
+
* `title`, `description` and `role`.
|
|
759
1083
|
*/
|
|
760
1084
|
export interface ActionArgSchema {
|
|
1085
|
+
/** A short name a client shows for this field. */
|
|
1086
|
+
readonly title?: string | undefined;
|
|
761
1087
|
readonly type?: ActionArgType | undefined;
|
|
762
1088
|
readonly enum?: readonly (string | number | boolean)[] | undefined;
|
|
763
1089
|
readonly minimum?: number | undefined;
|
|
@@ -792,6 +1118,12 @@ export interface ActionArgSchema {
|
|
|
792
1118
|
readonly additionalProperties?: false | ActionArgSchema | undefined;
|
|
793
1119
|
/** A value the kernel fills when the field is absent. */
|
|
794
1120
|
readonly default?: unknown;
|
|
1121
|
+
/**
|
|
1122
|
+
* The value the field has now, for an action that changes an existing value.
|
|
1123
|
+
* A client shows it as the choice in effect; it is neither a default nor
|
|
1124
|
+
* read by the kernel.
|
|
1125
|
+
*/
|
|
1126
|
+
readonly current?: unknown;
|
|
795
1127
|
readonly description?: string | undefined;
|
|
796
1128
|
/** A note is prompted for in a terminal and accepted as `--note`. */
|
|
797
1129
|
readonly role?: "note" | undefined;
|
|
@@ -800,6 +1132,11 @@ export interface ActionArgSchema {
|
|
|
800
1132
|
* upload's reference and the action runs with the stored path.
|
|
801
1133
|
*/
|
|
802
1134
|
readonly format?: "file" | undefined;
|
|
1135
|
+
/**
|
|
1136
|
+
* In an action whose value is a model id: what each choice is, by id. The
|
|
1137
|
+
* kernel passes it through and does not read it.
|
|
1138
|
+
*/
|
|
1139
|
+
readonly info?: Readonly<Record<string, HarnessModelInfo>> | undefined;
|
|
803
1140
|
/** In a settings schema: a client may change this setting. */
|
|
804
1141
|
readonly editable?: boolean | undefined;
|
|
805
1142
|
/** In a settings schema: changing it needs the person's confirmation. */
|
|
@@ -814,18 +1151,76 @@ export interface ActionArgsSchema extends ActionArgSchema {
|
|
|
814
1151
|
/** What an action's checks may read: the object store, never write. */
|
|
815
1152
|
export interface ActionEnv {
|
|
816
1153
|
readonly store: ObjectStore;
|
|
1154
|
+
/**
|
|
1155
|
+
* The object the action works on now, as its type and id, so a `when` can
|
|
1156
|
+
* read its facts with the store; absent for an action that targets no object.
|
|
1157
|
+
*/
|
|
1158
|
+
readonly object?: ObjectRef | undefined;
|
|
1159
|
+
/** The operad home; an action's choices may be in its settings. */
|
|
1160
|
+
readonly home?: string | undefined;
|
|
817
1161
|
/** The harness plugins loaded now; the kernel always sets it. */
|
|
818
1162
|
readonly harnesses?: readonly string[] | undefined;
|
|
819
1163
|
/** The models each loaded harness plugin declares, by plugin name. */
|
|
820
1164
|
readonly models?: Readonly<Record<string, HarnessModels>> | undefined;
|
|
821
1165
|
/** The efforts each loaded harness plugin declares, by plugin name. */
|
|
822
1166
|
readonly efforts?: Readonly<Record<string, HarnessEfforts>> | undefined;
|
|
1167
|
+
/** Whether a plugin that declares this step is loaded now. */
|
|
1168
|
+
readonly stepLoaded?: ((use: string) => boolean) | undefined;
|
|
1169
|
+
/**
|
|
1170
|
+
* Whether a run still exists and has not ended, so an offer can tell a live
|
|
1171
|
+
* run from one the host says has ended; absent when the host cannot tell.
|
|
1172
|
+
*/
|
|
1173
|
+
readonly runs?: RunControl | undefined;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/** What a harness knows a model can do; only the ones it truly knows are listed. */
|
|
1177
|
+
export type HarnessModelCapability = "vision" | "reasoning" | "tools" | "web";
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* What a harness can say about one model. `id` is the string a chat stores;
|
|
1181
|
+
* a field the harness does not know is left out rather than guessed.
|
|
1182
|
+
*/
|
|
1183
|
+
export interface HarnessModelInfo {
|
|
1184
|
+
readonly id: string;
|
|
1185
|
+
/** A display name, when the harness has one. */
|
|
1186
|
+
readonly name?: string | undefined;
|
|
1187
|
+
/** The provider, such as `anthropic`, `openai` or `opencode-go`. */
|
|
1188
|
+
readonly provider?: string | undefined;
|
|
1189
|
+
/** The context window in tokens, when the harness knows it. */
|
|
1190
|
+
readonly window?: number | undefined;
|
|
1191
|
+
/** What the model can do, as far as the harness truly knows. */
|
|
1192
|
+
readonly capabilities?: readonly HarnessModelCapability[] | undefined;
|
|
823
1193
|
}
|
|
824
1194
|
|
|
825
1195
|
/** The models a harness plugin declares: those a chat may pick, and the one used when none is set. */
|
|
826
1196
|
export interface HarnessModels {
|
|
827
|
-
|
|
1197
|
+
/**
|
|
1198
|
+
* The model ids, or a description of each. A bare string works for a harness
|
|
1199
|
+
* that knows nothing more, so a client that reads only ids keeps working.
|
|
1200
|
+
*/
|
|
1201
|
+
readonly list: readonly (string | HarnessModelInfo)[];
|
|
828
1202
|
readonly default: string | null;
|
|
1203
|
+
/**
|
|
1204
|
+
* The context window of each listed model the harness knows, in tokens.
|
|
1205
|
+
* A model with no entry has an unknown window; it is never guessed.
|
|
1206
|
+
*/
|
|
1207
|
+
readonly windows?: Readonly<Record<string, number>> | undefined;
|
|
1208
|
+
/** What each listed model is, by id; a model with no entry is only an id. */
|
|
1209
|
+
readonly info?: Readonly<Record<string, HarnessModelInfo>> | undefined;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/** The model ids a declaration lists, in its order. */
|
|
1213
|
+
export function modelIds(models: HarnessModels | undefined): readonly string[] {
|
|
1214
|
+
if (models === undefined) return [];
|
|
1215
|
+
return models.list.map((model) => (typeof model === "string" ? model : model.id));
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/** What a harness's model hook may read besides its settings. */
|
|
1219
|
+
export interface HarnessModelContext {
|
|
1220
|
+
/** The operad home: where a harness keeps the list it read. */
|
|
1221
|
+
readonly home: string;
|
|
1222
|
+
/** Where a background refresh reports a failure. */
|
|
1223
|
+
readonly log: (message: string) => void;
|
|
829
1224
|
}
|
|
830
1225
|
|
|
831
1226
|
/**
|
|
@@ -838,10 +1233,50 @@ export interface HarnessEfforts {
|
|
|
838
1233
|
readonly flag?: string | undefined;
|
|
839
1234
|
}
|
|
840
1235
|
|
|
841
|
-
/**
|
|
1236
|
+
/**
|
|
1237
|
+
* The efforts a harness declares, or a function that reads them from the
|
|
1238
|
+
* plugin's settings each time they are asked for. A harness whose default
|
|
1239
|
+
* follows a setting of its own uses the function form.
|
|
1240
|
+
*/
|
|
1241
|
+
export type HarnessEffortsSource =
|
|
1242
|
+
| HarnessEfforts
|
|
1243
|
+
| ((settings: Readonly<Record<string, JsonValue>>) => HarnessEfforts);
|
|
1244
|
+
|
|
1245
|
+
/** What a harness plugin's agent does itself, from ADR 0022's capability list. */
|
|
1246
|
+
export interface HarnessCapabilities {
|
|
1247
|
+
/**
|
|
1248
|
+
* The model this harness prefers for background work such as a memory tidy.
|
|
1249
|
+
* Left out: a bot uses its own model, else the harness's default model.
|
|
1250
|
+
*/
|
|
1251
|
+
readonly backgroundModel?: string | undefined;
|
|
1252
|
+
/**
|
|
1253
|
+
* True when the agent loads the skill directories the step gives it, so the
|
|
1254
|
+
* prompt needs no list of them. False or absent: the harness does not load
|
|
1255
|
+
* skills by itself.
|
|
1256
|
+
*/
|
|
1257
|
+
readonly loadsSkills?: boolean | undefined;
|
|
1258
|
+
/**
|
|
1259
|
+
* True when the agent takes a message while its run is going, after the tool
|
|
1260
|
+
* calls already running. False or absent: the run cannot take one, so a
|
|
1261
|
+
* message waits for the next run.
|
|
1262
|
+
*/
|
|
1263
|
+
readonly takesMessagesMidRun?: boolean | undefined;
|
|
1264
|
+
/**
|
|
1265
|
+
* The access levels the agent can carry, as their ids (`plan`, `ask`,
|
|
1266
|
+
* `edits`, `full`). Absent or empty: the agent carries none, so a chat at a
|
|
1267
|
+
* level refuses the reply instead of ignoring the level.
|
|
1268
|
+
*/
|
|
1269
|
+
readonly accessLevels?: readonly string[] | undefined;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/** An action a plugin offers on an object type, or without one. */
|
|
842
1273
|
export interface ActionTypeDefinition {
|
|
843
1274
|
readonly name: string;
|
|
844
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* The object type the action works on. Absent when the action targets no
|
|
1277
|
+
* object: it runs from its arguments alone, as a client's POST /v1/act does.
|
|
1278
|
+
*/
|
|
1279
|
+
readonly on?: string | undefined;
|
|
845
1280
|
/** The person's input, as a JSON Schema object. */
|
|
846
1281
|
readonly args?: ActionArgsSchema | undefined;
|
|
847
1282
|
/**
|
|
@@ -852,6 +1287,20 @@ export interface ActionTypeDefinition {
|
|
|
852
1287
|
readonly argsFor?: ((object: RunObject, env: ActionEnv) => ActionArgsSchema) | undefined;
|
|
853
1288
|
/** The action asks for confirmation before it runs. */
|
|
854
1289
|
readonly confirm?: boolean | undefined;
|
|
1290
|
+
/**
|
|
1291
|
+
* True when this action can write outside operad; `outward` names the target
|
|
1292
|
+
* of one call. A background run asks before it runs when no target function
|
|
1293
|
+
* is declared.
|
|
1294
|
+
*/
|
|
1295
|
+
readonly reachesOutside?: boolean | undefined;
|
|
1296
|
+
readonly outward?: OutwardTargets | undefined;
|
|
1297
|
+
/**
|
|
1298
|
+
* A one-line description when a chat may run this action as a `/<name>`
|
|
1299
|
+
* command; its presence is what makes the action a chat command. `true` takes
|
|
1300
|
+
* the description from the args schema's own `description`, else the action
|
|
1301
|
+
* name. Absent when the action cannot be typed after a slash.
|
|
1302
|
+
*/
|
|
1303
|
+
readonly command?: boolean | string | undefined;
|
|
855
1304
|
/**
|
|
856
1305
|
* The action ends the object (a cancel). A client's main key or button never
|
|
857
1306
|
* picks it, even when it is the only action offered.
|
|
@@ -910,7 +1359,7 @@ export interface ActionOutcome {
|
|
|
910
1359
|
|
|
911
1360
|
/** Whether an action's return value is an `ActionOutcome`. */
|
|
912
1361
|
export function isActionOutcome(value: unknown): value is ActionOutcome {
|
|
913
|
-
if (
|
|
1362
|
+
if (!isRecord(value)) return false;
|
|
914
1363
|
const keys = Object.keys(value);
|
|
915
1364
|
const record = value as { readonly text?: unknown; readonly opens?: unknown };
|
|
916
1365
|
return (
|
|
@@ -937,12 +1386,34 @@ export interface ActionEvent {
|
|
|
937
1386
|
export interface ActionContext extends PluginBaseContext {
|
|
938
1387
|
/** The names of the loaded plugins of kind `harness`. */
|
|
939
1388
|
readonly harnesses: readonly string[];
|
|
1389
|
+
/** The kernel's runs, when the host supplies them; a plugin can avoid starting a second one. */
|
|
1390
|
+
readonly runLookup?: RunLookup | undefined;
|
|
1391
|
+
/** Whether a plugin that declares this step is loaded now. */
|
|
1392
|
+
readonly stepLoaded?: ((use: string) => boolean) | undefined;
|
|
940
1393
|
/** The models each loaded harness plugin declares, by plugin name. */
|
|
941
1394
|
readonly models: Readonly<Record<string, HarnessModels>>;
|
|
942
1395
|
/** The efforts each loaded harness plugin declares, by plugin name. */
|
|
943
1396
|
readonly efforts: Readonly<Record<string, HarnessEfforts>>;
|
|
944
1397
|
/** Sends an event through the kernel's rules; set when the host can route events. */
|
|
945
1398
|
readonly emit?: ((event: ActionEvent) => Promise<void>) | undefined;
|
|
1399
|
+
/**
|
|
1400
|
+
* The actions declared on this object's type, for an action that forwards a
|
|
1401
|
+
* person's text to one of them (a chat command). Optional: a host that cannot
|
|
1402
|
+
* run actions leaves it out.
|
|
1403
|
+
*/
|
|
1404
|
+
readonly actions?: readonly ActionInfo[] | undefined;
|
|
1405
|
+
/**
|
|
1406
|
+
* Runs another action on the same object with the checks a client's `act`
|
|
1407
|
+
* makes (`when`, the arguments, `confirm`); `yes` answers the confirmation.
|
|
1408
|
+
* Optional: set when the host can run actions.
|
|
1409
|
+
*/
|
|
1410
|
+
readonly act?:
|
|
1411
|
+
| ((
|
|
1412
|
+
name: string,
|
|
1413
|
+
args: unknown,
|
|
1414
|
+
options?: { readonly yes?: boolean | undefined } | undefined,
|
|
1415
|
+
) => Promise<ActionRun>)
|
|
1416
|
+
| undefined;
|
|
946
1417
|
readonly runId: string | undefined;
|
|
947
1418
|
readonly object: RunObject;
|
|
948
1419
|
/** Who asked for the action: a person through a client. */
|
|
@@ -953,7 +1424,8 @@ export interface ActionContext extends PluginBaseContext {
|
|
|
953
1424
|
|
|
954
1425
|
/** Options for running an action through the registry. */
|
|
955
1426
|
export interface ActionRunOptions {
|
|
956
|
-
|
|
1427
|
+
/** The object the action is on; absent when the action targets no object. */
|
|
1428
|
+
readonly object?: RunObject | StoredObject | undefined;
|
|
957
1429
|
readonly runId?: string | undefined;
|
|
958
1430
|
readonly cwd?: string | undefined;
|
|
959
1431
|
readonly signal?: AbortSignal | undefined;
|
|
@@ -976,6 +1448,8 @@ export interface CommandDefinition {
|
|
|
976
1448
|
export interface CommandContext extends PluginBaseContext {
|
|
977
1449
|
/** The text the command reads from stdin, when its caller supplied one. */
|
|
978
1450
|
readonly input?: string | undefined;
|
|
1451
|
+
/** Every loaded flow name, so a command can refuse one that cannot start. */
|
|
1452
|
+
readonly flows: readonly string[];
|
|
979
1453
|
}
|
|
980
1454
|
|
|
981
1455
|
/** Options for running a command through the registry. */
|
|
@@ -1093,6 +1567,19 @@ export interface StandingItem {
|
|
|
1093
1567
|
export interface StandingContext extends PluginBaseContext {
|
|
1094
1568
|
/** The names of the plugins this process loaded. */
|
|
1095
1569
|
readonly loaded: readonly string[];
|
|
1570
|
+
/** The names of the loaded plugins of kind `harness`. */
|
|
1571
|
+
readonly harnesses?: readonly string[] | undefined;
|
|
1572
|
+
/** The kernel's runs, when the host supplies them; a standing item can tell a live run. */
|
|
1573
|
+
readonly runLookup?: RunLookup | undefined;
|
|
1574
|
+
/**
|
|
1575
|
+
* Whether a loaded harness reports its agent signed in (ADR 0022);
|
|
1576
|
+
* undefined when it cannot tell or is not loaded.
|
|
1577
|
+
*/
|
|
1578
|
+
readonly signedIn?:
|
|
1579
|
+
| ((harness: string) => MaybePromise<boolean | undefined>)
|
|
1580
|
+
| undefined;
|
|
1581
|
+
/** Whether a plugin that declares this step is loaded now. */
|
|
1582
|
+
readonly stepLoaded?: ((use: string) => boolean) | undefined;
|
|
1096
1583
|
}
|
|
1097
1584
|
|
|
1098
1585
|
/** A plugin's declared dependencies: plugins and the plugin API version. */
|
|
@@ -1111,6 +1598,12 @@ export interface SourceContext extends PluginBaseContext {
|
|
|
1111
1598
|
/** The routing rules, already checked. */
|
|
1112
1599
|
readonly rules: readonly TriggerRule[];
|
|
1113
1600
|
readonly clock: () => number;
|
|
1601
|
+
/** The loaded harness plugin names, in load order. */
|
|
1602
|
+
readonly harnesses?: readonly string[] | undefined;
|
|
1603
|
+
/** What a loaded harness plugin declares it can do; undefined when it is not loaded. */
|
|
1604
|
+
readonly harnessCapabilities?:
|
|
1605
|
+
| ((harness: string) => HarnessCapabilities | undefined)
|
|
1606
|
+
| undefined;
|
|
1114
1607
|
/** Sends one event through the kernel's rules. */
|
|
1115
1608
|
emit(event: SourceEvent): Promise<void>;
|
|
1116
1609
|
/**
|
|
@@ -1167,18 +1660,44 @@ export interface PluginShape {
|
|
|
1167
1660
|
*/
|
|
1168
1661
|
readonly models?:
|
|
1169
1662
|
| HarnessModels
|
|
1170
|
-
| ((
|
|
1663
|
+
| ((
|
|
1664
|
+
settings: Readonly<Record<string, JsonValue>>,
|
|
1665
|
+
context: HarnessModelContext,
|
|
1666
|
+
) => HarnessModels)
|
|
1667
|
+
| undefined;
|
|
1668
|
+
/**
|
|
1669
|
+
* A harness plugin: the models a chat may pick, waiting for one refresh when
|
|
1670
|
+
* no list is kept yet. The reply asks this before it refuses a stored model.
|
|
1671
|
+
*/
|
|
1672
|
+
readonly modelsReady?:
|
|
1673
|
+
| ((
|
|
1674
|
+
settings: Readonly<Record<string, JsonValue>>,
|
|
1675
|
+
context: HarnessModelContext,
|
|
1676
|
+
) => MaybePromise<HarnessModels>)
|
|
1677
|
+
| undefined;
|
|
1678
|
+
/** A harness plugin: the efforts a chat may pick (empty list: none can be chosen), or a function of its settings. */
|
|
1679
|
+
readonly efforts?: HarnessEffortsSource | undefined;
|
|
1680
|
+
/** A harness plugin: what its agent does itself. */
|
|
1681
|
+
readonly capabilities?: HarnessCapabilities | undefined;
|
|
1682
|
+
/**
|
|
1683
|
+
* A harness plugin: whether its agent is signed in now. `true` or `false`
|
|
1684
|
+
* when it can tell, `undefined` when it cannot; only that answer is exposed,
|
|
1685
|
+
* never a credential. A function is called with the plugin's settings each
|
|
1686
|
+
* time the answer is read.
|
|
1687
|
+
*/
|
|
1688
|
+
readonly signedIn?:
|
|
1689
|
+
| ((settings: Readonly<Record<string, JsonValue>>) => MaybePromise<boolean | undefined>)
|
|
1171
1690
|
| undefined;
|
|
1172
|
-
/** A harness plugin: the efforts a chat may pick (empty list: none can be chosen). */
|
|
1173
|
-
readonly efforts?: HarnessEfforts | undefined;
|
|
1174
1691
|
/** Access profile fields this plugin's steps apply. */
|
|
1175
1692
|
readonly enforces?: readonly string[] | undefined;
|
|
1176
1693
|
/** What this plugin needs loaded before it can be used. */
|
|
1177
1694
|
readonly requires?: PluginRequires | undefined;
|
|
1178
1695
|
/** Starts a source; `operad serve` stops it on exit. */
|
|
1179
1696
|
readonly start?: ((ctx: SourceContext) => MaybePromise<SourceHandle> | SourceHandle) | undefined;
|
|
1180
|
-
/** Runs when `operad init` checks the plugin; a string is the check's note. */
|
|
1181
|
-
readonly check?: ((ctx: PluginBaseContext) => MaybePromise<
|
|
1697
|
+
/** Runs when `operad init` checks the plugin; a string is the check's note, an object lists what is missing. */
|
|
1698
|
+
readonly check?: ((ctx: PluginBaseContext) => MaybePromise<PluginCheckReturn>) | undefined;
|
|
1699
|
+
/** The absolute path of the plugin's setup guide, a `SKILL.md` (ADR 0010 D7). */
|
|
1700
|
+
readonly guide?: string | undefined;
|
|
1182
1701
|
}
|
|
1183
1702
|
|
|
1184
1703
|
/** One settings file under a repository's `.operad/`, with its schema. */
|
|
@@ -1191,6 +1710,30 @@ export interface ProjectSettingsFile {
|
|
|
1191
1710
|
/** Where the file is, relative to the repository's `.operad/`. */
|
|
1192
1711
|
readonly path: string;
|
|
1193
1712
|
readonly schema: ActionArgsSchema;
|
|
1713
|
+
/**
|
|
1714
|
+
* The plugin's own check of the whole file as it would be written, run after
|
|
1715
|
+
* the schema and before the write. A string is the reason to refuse; nothing
|
|
1716
|
+
* is written and the client is told that reason as it is.
|
|
1717
|
+
*/
|
|
1718
|
+
readonly check?:
|
|
1719
|
+
| ((ctx: ProjectSettingsContext) => MaybePromise<string | undefined>)
|
|
1720
|
+
| undefined;
|
|
1721
|
+
/**
|
|
1722
|
+
* Read-only values the plugin works out when settings are listed, by
|
|
1723
|
+
* property name. A property that has no stored value takes the value here.
|
|
1724
|
+
*/
|
|
1725
|
+
readonly derived?:
|
|
1726
|
+
| ((ctx: ProjectSettingsContext) => MaybePromise<Readonly<Record<string, JsonValue>>>)
|
|
1727
|
+
| undefined;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/** What a project settings file's `check` and `derived` are given. */
|
|
1731
|
+
export interface ProjectSettingsContext {
|
|
1732
|
+
readonly repository: SettingsRepository;
|
|
1733
|
+
/** The setting being changed, such as `dev.flows.mine`; empty when listing. */
|
|
1734
|
+
readonly name: string;
|
|
1735
|
+
/** The file's JSON object: as it would be written for `check`, as it is for `derived`. */
|
|
1736
|
+
readonly value: Readonly<Record<string, unknown>>;
|
|
1194
1737
|
}
|
|
1195
1738
|
|
|
1196
1739
|
/** A repository a plugin has registered. */
|
|
@@ -1219,6 +1762,7 @@ export interface WaitingRun {
|
|
|
1219
1762
|
readonly object: ObjectRef;
|
|
1220
1763
|
readonly prompt?: string | undefined;
|
|
1221
1764
|
readonly choices?: readonly string[] | undefined;
|
|
1765
|
+
readonly choiceInfo?: Readonly<Record<string, ChoiceInfo>> | undefined;
|
|
1222
1766
|
/**
|
|
1223
1767
|
* When the run last recorded anything. A run whose object is not in the store
|
|
1224
1768
|
* takes this as the time of its placeholder object, so an age shown for it
|
|
@@ -1238,6 +1782,7 @@ export interface PendingEntry {
|
|
|
1238
1782
|
readonly runId: string;
|
|
1239
1783
|
readonly prompt: string | undefined;
|
|
1240
1784
|
readonly choices: readonly string[] | undefined;
|
|
1785
|
+
readonly choiceInfo?: Readonly<Record<string, ChoiceInfo>> | undefined;
|
|
1241
1786
|
readonly object: StoredObject;
|
|
1242
1787
|
readonly actions: readonly PendingActionView[];
|
|
1243
1788
|
}
|