@leuduan/lagent 0.0.0-stage → 0.1.2
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/LICENSE +16 -0
- package/README.md +144 -2
- package/dist/chunks/2O7ZGEIT.js +1 -0
- package/dist/chunks/2OSESBIL.js +1 -0
- package/dist/chunks/34KW6VNQ.js +1 -0
- package/dist/chunks/37YOGDGY.js +1 -0
- package/dist/chunks/3LQHQRIU.js +6 -0
- package/dist/chunks/3QCW4WDJ.js +1 -0
- package/dist/chunks/4XVRUSCQ.js +1 -0
- package/dist/chunks/6ECI2GGV.js +1 -0
- package/dist/chunks/74HKUGRR.js +1 -0
- package/dist/chunks/ADHERZLW.js +2 -0
- package/dist/chunks/AP6Q4EPT.js +36 -0
- package/dist/chunks/BM3S37EZ.js +1 -0
- package/dist/chunks/C5LYCXJG.js +1 -0
- package/dist/chunks/CDQG7RKA.js +1 -0
- package/dist/chunks/D7E6EWIE.js +3 -0
- package/dist/chunks/DDANMY45.js +3 -0
- package/dist/chunks/DRYAN665.js +1 -0
- package/dist/chunks/DXFXAYDN.js +17 -0
- package/dist/chunks/EGZI4XQX.js +24 -0
- package/dist/chunks/ENWFSU27.js +41 -0
- package/dist/chunks/G6RXC3AL.js +1 -0
- package/dist/chunks/G74AGRAJ.js +15 -0
- package/dist/chunks/GQGNVSKB.js +1 -0
- package/dist/chunks/IJ2WNMD5.js +7 -0
- package/dist/chunks/J5S4URAW.js +1 -0
- package/dist/chunks/JPZFKSWT.js +1 -0
- package/dist/chunks/KESCTXGO.js +5 -0
- package/dist/chunks/L3N4FIEN.js +1 -0
- package/dist/chunks/NAOUTU7A.js +4 -0
- package/dist/chunks/NDIM7MEW.js +1 -0
- package/dist/chunks/O4PPOM5Z.js +2 -0
- package/dist/chunks/OVZFGILJ.js +1 -0
- package/dist/chunks/P5ZHHOOM.js +6 -0
- package/dist/chunks/PUSUPTAT.js +1 -0
- package/dist/chunks/QMMLQJBS.js +1 -0
- package/dist/chunks/RK3VP2Q4.js +3 -0
- package/dist/chunks/SGGMBSBA.js +1 -0
- package/dist/chunks/SL2YLB2F.js +1 -0
- package/dist/chunks/TOOIB6J2.js +1 -0
- package/dist/chunks/TYTQRLTX.js +1 -0
- package/dist/chunks/UC3FVVJ2.js +5 -0
- package/dist/chunks/UCTEU62F.js +1 -0
- package/dist/chunks/UD3VJER6.js +1 -0
- package/dist/chunks/UKXMCHHT.js +1 -0
- package/dist/chunks/WUUKTSRT.js +7 -0
- package/dist/chunks/X65X4KP5.js +7 -0
- package/dist/chunks/YIR5MYGU.js +1 -0
- package/dist/chunks/YLNJXQ3Z.js +1 -0
- package/dist/context.d.ts +101 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +77 -0
- package/dist/journal/catalog.d.ts +112 -0
- package/dist/journal/forkChain.d.ts +16 -0
- package/dist/journal/index.d.ts +15 -0
- package/dist/journal/journal.d.ts +475 -0
- package/dist/journal/projection.d.ts +87 -0
- package/dist/journal/store.d.ts +181 -0
- package/dist/kit/claim.d.ts +13 -0
- package/dist/kit/drain.d.ts +10 -0
- package/dist/kit/extension.d.ts +180 -0
- package/dist/kit/grants.d.ts +9 -0
- package/dist/kit/modes.d.ts +65 -0
- package/dist/kit/retries.d.ts +25 -0
- package/dist/kit/scope.d.ts +32 -0
- package/dist/kit/service.d.ts +7 -0
- package/dist/kit/strategy.d.ts +10 -0
- package/dist/kit/timers.d.ts +43 -0
- package/dist/kit/tool.d.ts +72 -0
- package/dist/llm/client.d.ts +135 -0
- package/dist/llm/content.d.ts +52 -0
- package/dist/llm/door.d.ts +21 -0
- package/dist/llm/door.js +1 -0
- package/dist/llm/failure.d.ts +82 -0
- package/dist/llm/index.d.ts +16 -0
- package/dist/llm/primitives.d.ts +286 -0
- package/dist/llm/prompt.d.ts +21 -0
- package/dist/llm/provider.d.ts +63 -0
- package/dist/llm/readLedger.d.ts +24 -0
- package/dist/llm/request.d.ts +58 -0
- package/dist/loop/agent.d.ts +134 -0
- package/dist/loop/auxiliary.d.ts +54 -0
- package/dist/loop/chain.d.ts +46 -0
- package/dist/loop/chunks.d.ts +27 -0
- package/dist/loop/continuation.d.ts +166 -0
- package/dist/loop/decide.d.ts +64 -0
- package/dist/loop/errors.d.ts +162 -0
- package/dist/loop/forks.d.ts +61 -0
- package/dist/loop/holds.d.ts +104 -0
- package/dist/loop/hooks.d.ts +241 -0
- package/dist/loop/inbox.d.ts +188 -0
- package/dist/loop/index.d.ts +37 -0
- package/dist/loop/limits.d.ts +14 -0
- package/dist/loop/opening.d.ts +42 -0
- package/dist/loop/prepare.d.ts +30 -0
- package/dist/loop/projections.d.ts +307 -0
- package/dist/loop/replace.d.ts +33 -0
- package/dist/loop/requests.d.ts +129 -0
- package/dist/loop/route.d.ts +53 -0
- package/dist/loop/runtime.d.ts +85 -0
- package/dist/loop/state.d.ts +70 -0
- package/dist/loop/strategy.d.ts +71 -0
- package/dist/loop/summary.d.ts +3 -0
- package/dist/loop/surface.d.ts +153 -0
- package/dist/loop/threadState.d.ts +72 -0
- package/dist/loop/tool.d.ts +101 -0
- package/dist/loop/toolCalls.d.ts +42 -0
- package/dist/loop/wake.d.ts +32 -0
- package/dist/models/config/agent.d.ts +18 -0
- package/dist/models/config/prompt.d.ts +18 -0
- package/dist/models/door.d.ts +12 -0
- package/dist/models/door.js +1 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/jsonSchema.d.ts +7 -0
- package/dist/models/wire/journal.d.ts +2772 -0
- package/dist/models/wire/primitives.d.ts +65 -0
- package/dist/plugin.d.ts +53 -0
- package/dist/plugin.js +1 -0
- package/dist/plugins/agentsMd.d.ts +76 -0
- package/dist/plugins/agentsMd.js +1 -0
- package/dist/plugins/ask/askQuestion.d.ts +9 -0
- package/dist/plugins/ask/index.d.ts +26 -0
- package/dist/plugins/ask/index.js +1 -0
- package/dist/plugins/ask/service.d.ts +125 -0
- package/dist/plugins/commands/background.d.ts +8 -0
- package/dist/plugins/commands/foreground.d.ts +4 -0
- package/dist/plugins/commands/index.d.ts +40 -0
- package/dist/plugins/commands/index.js +1 -0
- package/dist/plugins/commands/output.d.ts +115 -0
- package/dist/plugins/commands/record.d.ts +549 -0
- package/dist/plugins/commands/service.d.ts +314 -0
- package/dist/plugins/commands/shell.d.ts +25 -0
- package/dist/plugins/compaction/checkpoint.d.ts +91 -0
- package/dist/plugins/compaction/config.d.ts +133 -0
- package/dist/plugins/compaction/estimate.d.ts +29 -0
- package/dist/plugins/compaction/index.d.ts +2 -0
- package/dist/plugins/compaction/index.js +7 -0
- package/dist/plugins/compaction/log.d.ts +61 -0
- package/dist/plugins/compaction/planner.d.ts +207 -0
- package/dist/plugins/compaction/preset.d.ts +86 -0
- package/dist/plugins/compaction/prune.d.ts +9 -0
- package/dist/plugins/compaction/records.d.ts +227 -0
- package/dist/plugins/compaction/segments.d.ts +23 -0
- package/dist/plugins/compaction/shared.d.ts +14 -0
- package/dist/plugins/compaction/summarize.d.ts +13 -0
- package/dist/plugins/dateAndBranch.d.ts +47 -0
- package/dist/plugins/dateAndBranch.js +1 -0
- package/dist/plugins/delegations/answers.d.ts +39 -0
- package/dist/plugins/delegations/assignmentKey.d.ts +22 -0
- package/dist/plugins/delegations/cleanup.d.ts +161 -0
- package/dist/plugins/delegations/constraint.d.ts +76 -0
- package/dist/plugins/delegations/index.d.ts +39 -0
- package/dist/plugins/delegations/index.js +1 -0
- package/dist/plugins/delegations/notices.d.ts +261 -0
- package/dist/plugins/delegations/obligations.d.ts +210 -0
- package/dist/plugins/delegations/record.d.ts +632 -0
- package/dist/plugins/delegations/request.d.ts +381 -0
- package/dist/plugins/delegations/role.d.ts +30 -0
- package/dist/plugins/delegations/service.d.ts +562 -0
- package/dist/plugins/delegations/standing.d.ts +19 -0
- package/dist/plugins/delegations/stopCheck.d.ts +21 -0
- package/dist/plugins/delegations/testing.d.ts +16 -0
- package/dist/plugins/delegations/tools.d.ts +71 -0
- package/dist/plugins/delegations/waitBook.d.ts +116 -0
- package/dist/plugins/delegations/waits.d.ts +118 -0
- package/dist/plugins/diagnostics/digest.d.ts +14 -0
- package/dist/plugins/diagnostics/index.d.ts +68 -0
- package/dist/plugins/diagnostics/index.js +1 -0
- package/dist/plugins/historyRecall/history.d.ts +9 -0
- package/dist/plugins/historyRecall/index.d.ts +31 -0
- package/dist/plugins/historyRecall/index.js +1 -0
- package/dist/plugins/historyRecall/render.d.ts +34 -0
- package/dist/plugins/historyRecall/tools.d.ts +4 -0
- package/dist/plugins/mcp/catalog.d.ts +36 -0
- package/dist/plugins/mcp/config.d.ts +63 -0
- package/dist/plugins/mcp/connection.d.ts +53 -0
- package/dist/plugins/mcp/errors.d.ts +32 -0
- package/dist/plugins/mcp/index.d.ts +33 -0
- package/dist/plugins/mcp/index.js +5 -0
- package/dist/plugins/mcp/mount.d.ts +98 -0
- package/dist/plugins/mcp/names.d.ts +25 -0
- package/dist/plugins/mcp/render.d.ts +29 -0
- package/dist/plugins/mcp/slots.d.ts +15 -0
- package/dist/plugins/mcp/stdio.d.ts +49 -0
- package/dist/plugins/mcp/tool.d.ts +41 -0
- package/dist/plugins/providers/anthropic.d.ts +175 -0
- package/dist/plugins/providers/anthropicMessages.d.ts +65 -0
- package/dist/plugins/providers/codex.d.ts +60 -0
- package/dist/plugins/providers/codexAuth.d.ts +116 -0
- package/dist/plugins/providers/deepseek.d.ts +55 -0
- package/dist/plugins/providers/door.d.ts +61 -0
- package/dist/plugins/providers/door.js +1 -0
- package/dist/plugins/providers/failure.d.ts +23 -0
- package/dist/plugins/providers/gateway.d.ts +23 -0
- package/dist/plugins/providers/index.d.ts +6 -0
- package/dist/plugins/providers/openaiChat.d.ts +62 -0
- package/dist/plugins/providers/openaiResponses.d.ts +100 -0
- package/dist/plugins/providers/opencodeCopilot.d.ts +23 -0
- package/dist/plugins/providers/opencodeGo.d.ts +98 -0
- package/dist/plugins/providers/shared.d.ts +104 -0
- package/dist/plugins/providers/stream.d.ts +154 -0
- package/dist/plugins/routeContext.d.ts +22 -0
- package/dist/plugins/routeContext.js +1 -0
- package/dist/plugins/schedules/index.d.ts +21 -0
- package/dist/plugins/schedules/index.js +5 -0
- package/dist/plugins/schedules/record.d.ts +396 -0
- package/dist/plugins/schedules/service.d.ts +120 -0
- package/dist/plugins/schedules/time.d.ts +26 -0
- package/dist/plugins/schedules/tools.d.ts +6 -0
- package/dist/plugins/skills/discovery.d.ts +54 -0
- package/dist/plugins/skills/index.d.ts +31 -0
- package/dist/plugins/skills/index.js +1 -0
- package/dist/plugins/skills/tool.d.ts +11 -0
- package/dist/plugins/store/durableObject.d.ts +23 -0
- package/dist/plugins/store/durableObject.js +1 -0
- package/dist/plugins/store/durableObjectConnection.d.ts +27 -0
- package/dist/plugins/store/memory.d.ts +29 -0
- package/dist/plugins/store/sql.d.ts +59 -0
- package/dist/plugins/store/sqlite.d.ts +31 -0
- package/dist/plugins/store/sqlite.js +1 -0
- package/dist/plugins/subAgents/availableRoutes.d.ts +53 -0
- package/dist/plugins/subAgents/fork.d.ts +32 -0
- package/dist/plugins/subAgents/index.d.ts +67 -0
- package/dist/plugins/subAgents/index.js +1 -0
- package/dist/plugins/subAgents/tool.d.ts +38 -0
- package/dist/plugins/toolPolicy/index.d.ts +61 -0
- package/dist/plugins/toolPolicy/index.js +1 -0
- package/dist/plugins/tools/editFiles.d.ts +128 -0
- package/dist/plugins/tools/fsRead.d.ts +17 -0
- package/dist/plugins/tools/html.d.ts +23 -0
- package/dist/plugins/tools/index.d.ts +59 -0
- package/dist/plugins/tools/index.js +1 -0
- package/dist/plugins/tools/network.d.ts +23 -0
- package/dist/plugins/tools/ripgrep.d.ts +20 -0
- package/dist/plugins/tools/textEdit.d.ts +67 -0
- package/dist/plugins/tools/web.d.ts +32 -0
- package/dist/plugins/truncateToolOutput.d.ts +26 -0
- package/dist/plugins/truncateToolOutput.js +1 -0
- package/dist/plugins/usage/index.d.ts +24 -0
- package/dist/plugins/usage/index.js +1 -0
- package/dist/plugins/usage/tracker.d.ts +34 -0
- package/dist/plugins/verify/facts.d.ts +356 -0
- package/dist/plugins/verify/index.d.ts +75 -0
- package/dist/plugins/verify/index.js +1 -0
- package/dist/plugins/verify/service.d.ts +90 -0
- package/dist/plugins/workflows/assignment.d.ts +16 -0
- package/dist/plugins/workflows/bindings.d.ts +95 -0
- package/dist/plugins/workflows/cleanup.d.ts +38 -0
- package/dist/plugins/workflows/definition.d.ts +184 -0
- package/dist/plugins/workflows/fold.d.ts +373 -0
- package/dist/plugins/workflows/index.d.ts +28 -0
- package/dist/plugins/workflows/index.js +6 -0
- package/dist/plugins/workflows/observations.d.ts +81 -0
- package/dist/plugins/workflows/participants.d.ts +143 -0
- package/dist/plugins/workflows/policy.d.ts +112 -0
- package/dist/plugins/workflows/providers.d.ts +146 -0
- package/dist/plugins/workflows/record.d.ts +2863 -0
- package/dist/plugins/workflows/routing.d.ts +116 -0
- package/dist/plugins/workflows/schema.d.ts +26 -0
- package/dist/plugins/workflows/service.d.ts +477 -0
- package/dist/plugins/workflows/submit.d.ts +8 -0
- package/dist/plugins/workflows/view.d.ts +103 -0
- package/dist/plugins/workflows/work.d.ts +21 -0
- package/dist/plugins/workspaceContext.d.ts +38 -0
- package/dist/plugins/workspaceContext.js +1 -0
- package/dist/presets/agents.d.ts +7 -0
- package/dist/presets/base.d.ts +10 -0
- package/dist/presets/codex.d.ts +60 -0
- package/dist/presets/index.d.ts +4 -0
- package/dist/presets/prompts.d.ts +56 -0
- package/dist/sandbox/absent.d.ts +32 -0
- package/dist/sandbox/client.d.ts +39 -0
- package/dist/sandbox/files.d.ts +28 -0
- package/dist/sandbox/index.d.ts +49 -0
- package/dist/sandbox/index.js +4 -0
- package/dist/sandbox/mode.d.ts +57 -0
- package/dist/sandbox/policy.d.ts +86 -0
- package/dist/sandbox/protocol.d.ts +107 -0
- package/dist/sandbox/service.d.ts +143 -0
- package/dist/sandbox/worker.d.ts +12 -0
- package/dist/sandbox/worker.js +1 -0
- package/dist/services/admission.d.ts +174 -0
- package/dist/services/agents.d.ts +37 -0
- package/dist/services/birth.d.ts +220 -0
- package/dist/services/contributions.d.ts +73 -0
- package/dist/services/core.d.ts +34 -0
- package/dist/services/journal.d.ts +26 -0
- package/dist/services/launches.d.ts +104 -0
- package/dist/services/llm.d.ts +80 -0
- package/dist/services/owner.d.ts +367 -0
- package/dist/services/preset.d.ts +154 -0
- package/dist/services/presets.d.ts +139 -0
- package/dist/services/prompts.d.ts +67 -0
- package/dist/services/runEvents.d.ts +79 -0
- package/dist/services/thread.d.ts +267 -0
- package/dist/services/threadActivation.d.ts +100 -0
- package/dist/services/threadDirs.d.ts +38 -0
- package/dist/services/threadView.d.ts +92 -0
- package/dist/services/threads.d.ts +449 -0
- package/dist/services/tools.d.ts +41 -0
- package/dist/sys/environment.d.ts +47 -0
- package/dist/sys/git.d.ts +60 -0
- package/dist/sys/paths.d.ts +56 -0
- package/dist/sys/spawn.d.ts +176 -0
- package/dist/testing/clock.d.ts +17 -0
- package/dist/testing/fakeLlm.d.ts +74 -0
- package/dist/testing/fedLlm.d.ts +32 -0
- package/dist/testing/helpers.d.ts +344 -0
- package/dist/testing/index.d.ts +13 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/processes.d.ts +13 -0
- package/dist/testing/sandbox.d.ts +71 -0
- package/dist/testing/settlement.d.ts +6 -0
- package/dist/testing/tmpDirs.d.ts +17 -0
- package/dist/util/async.d.ts +8 -0
- package/dist/util/diff.d.ts +25 -0
- package/dist/util/dispatch.d.ts +8 -0
- package/dist/util/errors.d.ts +28 -0
- package/dist/util/foldState.d.ts +17 -0
- package/dist/util/freeze.d.ts +2 -0
- package/dist/util/ids.d.ts +2 -0
- package/dist/util/json.d.ts +37 -0
- package/dist/util/log.d.ts +6 -0
- package/dist/util/text.d.ts +21 -0
- package/dist/util/version.d.ts +2 -0
- package/package.json +175 -3
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { type AnswerCheck } from '../../loop/index.js';
|
|
2
|
+
import type { JournalEvent, Seq } from '../../models/index.js';
|
|
3
|
+
import type { ReadonlyState } from '../../util/foldState.js';
|
|
4
|
+
import type { JsonValue, ReadonlyJsonValue } from '../../util/json.js';
|
|
5
|
+
import type { WorkflowDefinition } from './definition.js';
|
|
6
|
+
import { type Citation, type Decided, type Entered, type InstanceRow, type Observation, type Opened } from './record.js';
|
|
7
|
+
/**
|
|
8
|
+
* Where an assignment stands: `scheduled` until its activation input is claimed, `active` from that
|
|
9
|
+
* claim, `candidate` while a submission of it is the answer under check, `accepted` once core
|
|
10
|
+
* accepts that answer, and `superseded` once its authority closed without acceptance.
|
|
11
|
+
*/
|
|
12
|
+
export type AssignmentState = 'scheduled' | 'active' | 'candidate' | 'accepted' | 'superseded';
|
|
13
|
+
/**
|
|
14
|
+
* A submitted output, the `tool/result` row that recorded it, and the `tool/call` row of the call
|
|
15
|
+
* that made it (`null` when the result cites none).
|
|
16
|
+
*/
|
|
17
|
+
export type Submitted = {
|
|
18
|
+
readonly output: JsonValue;
|
|
19
|
+
readonly seq: Seq;
|
|
20
|
+
readonly call: Seq | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The search for a replacement activation input, once the recorded one was removed before its claim
|
|
24
|
+
* (a Stop's clear, a withdrawal): the unsourced inputs queued on the root since that removal and still
|
|
25
|
+
* queued, in queue order, each with whether a person's wake brought it.
|
|
26
|
+
*/
|
|
27
|
+
export type Replacement = {
|
|
28
|
+
readonly queued: {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
person: boolean;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
export type AssignmentRecord = {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly participant: string;
|
|
36
|
+
/** Whether the conversation participant works it on the root, or an isolated one on its child. */
|
|
37
|
+
readonly context: 'conversation' | 'isolated';
|
|
38
|
+
/** The thread it runs in: the root, or the participant's child. */
|
|
39
|
+
readonly thread: string;
|
|
40
|
+
/** Its delegation task on the child; `null` on the root. */
|
|
41
|
+
readonly task: string | null;
|
|
42
|
+
/** The participant generation it was pinned to; `null` on the root. */
|
|
43
|
+
readonly generation: number | null;
|
|
44
|
+
/** Whether an isolated one's child is the participant's own conversation or its attempt's; `null` on the root. */
|
|
45
|
+
readonly lifetime: 'instance' | 'attempt' | null;
|
|
46
|
+
/** The check providers judging an isolated one's answer, as its entry recorded them; none on the root. */
|
|
47
|
+
readonly checks: readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
* The input recorded as its activation: on the root, the host's first input or its transition's
|
|
50
|
+
* scheduling input; on a child, its task's input.
|
|
51
|
+
*/
|
|
52
|
+
readonly activation: string;
|
|
53
|
+
state: AssignmentState;
|
|
54
|
+
/** Set once its root activation input was removed unclaimed; see {@link activationInput}. */
|
|
55
|
+
replacement: Replacement | null;
|
|
56
|
+
/** The root's `input/message` row that claimed its activation input; a child's claim is the child's. */
|
|
57
|
+
claimSeq: Seq | null;
|
|
58
|
+
/** The submission under check on the root, while it is the root's answer. */
|
|
59
|
+
candidate: Submitted | null;
|
|
60
|
+
/**
|
|
61
|
+
* Its latest submission, kept whatever became of it: diagnostic history apart from the answer
|
|
62
|
+
* under check, which a recovery shows its producer and the coordinator, labeled unaccepted.
|
|
63
|
+
*/
|
|
64
|
+
submitted: Submitted | null;
|
|
65
|
+
/**
|
|
66
|
+
* The submission accepted: latched, so later input never takes it back. For an isolated
|
|
67
|
+
* participant, its output as the root's observation of the child carried it, at that row.
|
|
68
|
+
*/
|
|
69
|
+
accepted: Submitted | null;
|
|
70
|
+
/** The epoch of the latest submission reminder it was sent ({@link submissionReminder}). */
|
|
71
|
+
reminded: Seq | null;
|
|
72
|
+
/**
|
|
73
|
+
* The root row at which its authority closed: the turn ending that accepted it, the observation
|
|
74
|
+
* that carried its child's acceptance, or the row that superseded it. `null` while it is open.
|
|
75
|
+
*/
|
|
76
|
+
closed: Seq | null;
|
|
77
|
+
};
|
|
78
|
+
export type AttemptRecord = {
|
|
79
|
+
readonly entered: Entered;
|
|
80
|
+
readonly seq: Seq;
|
|
81
|
+
readonly assignments: readonly AssignmentRecord[];
|
|
82
|
+
/** Its result, once every assignment is accepted; at entry for a pure gate. Never once it recovers. */
|
|
83
|
+
result: string | null;
|
|
84
|
+
/** Its recovery, once an isolated participant's task ended without acceptance. */
|
|
85
|
+
recovery: RecoveryRecord | null;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* An attempt that will produce no result, and the one decision a person owes on it: its assignment
|
|
89
|
+
* authority closed at its boundary, and what it shows is frozen there, so later events change none
|
|
90
|
+
* of it. An accepted sibling keeps its history, but never makes a partial result.
|
|
91
|
+
*/
|
|
92
|
+
export type RecoveryRecord = {
|
|
93
|
+
/** A participant's task ended without acceptance (`failure`), or a person stopped the attempt (`stop`). */
|
|
94
|
+
readonly cause: 'failure' | 'stop';
|
|
95
|
+
readonly detail: string;
|
|
96
|
+
/** The row that opened it: its boundary. */
|
|
97
|
+
readonly seq: Seq;
|
|
98
|
+
/** By participant, unaccepted: each one's latest submission, and its partial report. */
|
|
99
|
+
readonly candidates: Readonly<Record<string, JsonValue>>;
|
|
100
|
+
readonly reports: Readonly<Record<string, string>>;
|
|
101
|
+
/** The decision on it, once one is recorded. */
|
|
102
|
+
decision: string | null;
|
|
103
|
+
};
|
|
104
|
+
/** An accepted result: the outputs of one attempt, by participant, and what happened to it. */
|
|
105
|
+
export type ResultRecord = {
|
|
106
|
+
readonly revision: string;
|
|
107
|
+
readonly attempt: string;
|
|
108
|
+
readonly step: string;
|
|
109
|
+
readonly outputs: Readonly<Record<string, JsonValue>>;
|
|
110
|
+
/** The row that completed it: the last acceptance, or a pure gate's entry. */
|
|
111
|
+
readonly seq: Seq;
|
|
112
|
+
/** The host decision on it, once one is recorded. */
|
|
113
|
+
decision: string | null;
|
|
114
|
+
/** The transition it, or its decision, made. */
|
|
115
|
+
routed: string | null;
|
|
116
|
+
/** Retired by its own step's re-entry. Its dependents go stale with it ({@link staleResults}). */
|
|
117
|
+
retired: boolean;
|
|
118
|
+
};
|
|
119
|
+
export type DecisionRecord = Decided & {
|
|
120
|
+
readonly seq: Seq;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The fold's records as a reader holds them from `journal.state`: read-only views of what the
|
|
124
|
+
* reducer mutates. A function that only reads takes the view, so the reducer and a reader share it.
|
|
125
|
+
*/
|
|
126
|
+
export type AssignmentView = ReadonlyState<AssignmentRecord>;
|
|
127
|
+
export type AttemptView = ReadonlyState<AttemptRecord>;
|
|
128
|
+
export type RecoveryView = ReadonlyState<RecoveryRecord>;
|
|
129
|
+
export type ResultView = ReadonlyState<ResultRecord>;
|
|
130
|
+
/** A cancellation admitted, or a decision recorded, under its operation id: what a replay compares. */
|
|
131
|
+
export type Operation = Extract<InstanceRow, {
|
|
132
|
+
op: 'decided' | 'cancel-requested';
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* One workflow instance as its root's rows leave it, recorded facts only: nothing here depends on
|
|
136
|
+
* which definitions are registered. What is pending, where it goes next and what may run are
|
|
137
|
+
* derived from it, with the definition, by `routing.ts` and `view.ts`.
|
|
138
|
+
*/
|
|
139
|
+
export type InstanceState = {
|
|
140
|
+
/** The instance's id: its root thread's, which every identity it derives starts with. */
|
|
141
|
+
instance: string | null;
|
|
142
|
+
opened: Opened | null;
|
|
143
|
+
/** Every attempt by id, in entry order. */
|
|
144
|
+
readonly attempts: Map<string, AttemptRecord>;
|
|
145
|
+
/** The latest attempt. */
|
|
146
|
+
current: AttemptRecord | null;
|
|
147
|
+
/** Every result by revision, in the order they were accepted. */
|
|
148
|
+
readonly results: Map<string, ResultRecord>;
|
|
149
|
+
readonly decisions: Map<string, DecisionRecord>;
|
|
150
|
+
readonly operations: Map<string, Operation>;
|
|
151
|
+
/** Each step's entries over the instance's life. */
|
|
152
|
+
readonly ordinals: Map<string, number>;
|
|
153
|
+
/** Each step's entries since the latest host decision: what its `maxAttempts` bounds. */
|
|
154
|
+
readonly counts: Map<string, number>;
|
|
155
|
+
/** Each restarted participant's conversation generation; see {@link generationOf}. */
|
|
156
|
+
readonly generations: Map<string, number>;
|
|
157
|
+
/** Every acceptance or ending observed of a child, by its task: one per task, the first; later ones are kept nowhere. */
|
|
158
|
+
readonly observed: Map<string, Observation & {
|
|
159
|
+
readonly seq: Seq;
|
|
160
|
+
}>;
|
|
161
|
+
/**
|
|
162
|
+
* The latest person's Stop of the instance (its `stopped` row and why): the boundary a transition
|
|
163
|
+
* owed by a result ready before it is judged against ({@link stopOwed}).
|
|
164
|
+
*/
|
|
165
|
+
stop: {
|
|
166
|
+
readonly seq: Seq;
|
|
167
|
+
readonly reason: string;
|
|
168
|
+
} | null;
|
|
169
|
+
cancellation: Extract<InstanceRow, {
|
|
170
|
+
op: 'cancel-requested';
|
|
171
|
+
}> | null;
|
|
172
|
+
terminal: null | {
|
|
173
|
+
readonly kind: 'completed';
|
|
174
|
+
readonly transition: string;
|
|
175
|
+
} | {
|
|
176
|
+
readonly kind: 'cancelled';
|
|
177
|
+
};
|
|
178
|
+
/** The thread's answer under check, as core's stop checks fold it. */
|
|
179
|
+
answer: AnswerCheck;
|
|
180
|
+
/** The root's latest response and its calls, which the response fence orders a call by. */
|
|
181
|
+
readonly calls: Map<Seq, number>;
|
|
182
|
+
response: ResponseCalls['response'];
|
|
183
|
+
/** The root's latest unsourced input: a person's. */
|
|
184
|
+
personAt: Seq | null;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* A thread's latest response that asked for calls, and its `tool/call` rows by seq, each with the
|
|
188
|
+
* call's position in that response: what the response fence orders a call by, on the root and on a
|
|
189
|
+
* participant's child alike.
|
|
190
|
+
*/
|
|
191
|
+
export type ResponseCalls = {
|
|
192
|
+
readonly calls: Map<Seq, number>;
|
|
193
|
+
/** The latest `assistant/message` that asked for calls, and their ids in order. */
|
|
194
|
+
response: {
|
|
195
|
+
readonly seq: Seq;
|
|
196
|
+
readonly ids: readonly string[];
|
|
197
|
+
} | null;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Whether the call recorded at `callSeq` comes after the submission whose call is `submittedCall` in
|
|
201
|
+
* the response that asked for both: core does not stop the rest of a batch after a concluding
|
|
202
|
+
* result, and records every call of it before any runs, so the calls after a submission under check
|
|
203
|
+
* are fenced by their position in that response, never by row order. The submission's own call is
|
|
204
|
+
* not after itself, so its replay stands.
|
|
205
|
+
*/
|
|
206
|
+
export declare function fencedCall(thread: ReadonlyState<ResponseCalls>, submittedCall: Seq | null, callSeq: Seq | undefined): boolean;
|
|
207
|
+
/** What {@link live} reads of an instance's state. */
|
|
208
|
+
type Liveness = {
|
|
209
|
+
readonly opened: unknown;
|
|
210
|
+
readonly terminal: unknown;
|
|
211
|
+
readonly cancellation: unknown;
|
|
212
|
+
};
|
|
213
|
+
/** Whether the instance can still take work: opened, not ending and not ended. */
|
|
214
|
+
export declare const live: (state: Liveness) => boolean;
|
|
215
|
+
/**
|
|
216
|
+
* The instance a root thread holds, folded from this plugin's rows and core's. The root's own
|
|
217
|
+
* assignment activates when a step claims its activation input (`input/message.input_id`), or the
|
|
218
|
+
* person's input replacing it once it was removed unclaimed ({@link activationInput}); its
|
|
219
|
+
* submission is a candidate while it is the answer under check; and it is accepted, latched, when
|
|
220
|
+
* core accepts that exact answer: the turn ending `completed` with the submission's result as the
|
|
221
|
+
* pending answer, read with core's own `answerCheck`. So nothing is written to accept, and core's
|
|
222
|
+
* answer check resetting on later input takes nothing back. An isolated participant's assignment
|
|
223
|
+
* is accepted, or its attempt recovers, by the root's observation of its child (`observed`), which
|
|
224
|
+
* carries the child's facts across, since this fold cannot read them; a person's Stop (`stopped`)
|
|
225
|
+
* recovers an attempt whose isolated work is still open. Submissions, claims, endings and
|
|
226
|
+
* observations outside the current attempt's open assignments are evidence only and advance
|
|
227
|
+
* nothing.
|
|
228
|
+
*
|
|
229
|
+
* Resets at a fork's spawn row: a fork inherits no workflow state.
|
|
230
|
+
*/
|
|
231
|
+
export declare const instanceFold: import("../../journal/projection.js").PluginProjection<InstanceState>;
|
|
232
|
+
/**
|
|
233
|
+
* The input whose claim activates a scheduled assignment now: its recorded activation input while
|
|
234
|
+
* that was not removed; after a removal, the first input queued on the root since then that is
|
|
235
|
+
* still queued and that a person's wake brought; `null` while there is none. Each later removal
|
|
236
|
+
* reselects, since a removed input leaves the queue. Sourced input never qualifies, nor unsourced
|
|
237
|
+
* input without a person's wake: the host's own notices are not a person's.
|
|
238
|
+
*/
|
|
239
|
+
export declare function activationInput(assignment: AssignmentView): string | null;
|
|
240
|
+
/** A response that asks for calls: the one later `tool/call` rows are placed in. A cut-off reply asks for none. */
|
|
241
|
+
export declare function respond(state: ResponseCalls, event: JournalEvent<'assistant/message'>): void;
|
|
242
|
+
/** A call of the latest response recorded: its position in that response, by its row. */
|
|
243
|
+
export declare function call(state: ResponseCalls, event: JournalEvent<'tool/call'>): void;
|
|
244
|
+
/**
|
|
245
|
+
* The epoch of `assignment`'s submission reminder: the later of its activation's claim and the
|
|
246
|
+
* person's latest input. `null` while it is not active.
|
|
247
|
+
*/
|
|
248
|
+
export declare function reminderEpoch(state: ReadonlyState<InstanceState>, assignment: AssignmentView): Seq | null;
|
|
249
|
+
/**
|
|
250
|
+
* What an instance's continuation refers to in its definition, from recorded facts alone, so a
|
|
251
|
+
* root's catalog entry can carry it and the check needs nothing loaded: the definition's id; while it
|
|
252
|
+
* is live, the step it stands on; and each participant whose assignment of the current attempt is
|
|
253
|
+
* still open (`open`), or that has a conversation of its own in the instance, which later steps
|
|
254
|
+
* continue (`persistent`), with the context it was recorded in.
|
|
255
|
+
*/
|
|
256
|
+
export type DefinitionReferences = {
|
|
257
|
+
readonly id: string;
|
|
258
|
+
readonly step: string | null;
|
|
259
|
+
readonly participants: Readonly<Record<string, {
|
|
260
|
+
readonly context: 'conversation' | 'isolated';
|
|
261
|
+
readonly open: boolean;
|
|
262
|
+
}>>;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* The participants with a conversation of their own in the instance, as their entries recorded
|
|
266
|
+
* them (an isolated assignment of `instance` lifetime), each with its current generation's child:
|
|
267
|
+
* the one later entries continue. A generation a restart superseded is history, not listed.
|
|
268
|
+
*/
|
|
269
|
+
export declare function persistentConversations(state: ReadonlyState<InstanceState>): Map<string, string>;
|
|
270
|
+
/** What `state`'s continuation refers to in its definition ({@link DefinitionReferences}). */
|
|
271
|
+
export declare function definitionReferences(state: ReadonlyState<InstanceState>): DefinitionReferences;
|
|
272
|
+
/**
|
|
273
|
+
* Why an instance cannot continue on `registered`, the definition registered under its id now, or
|
|
274
|
+
* `null` when it can (the recovery compatibility check): the one rule every reader of execution
|
|
275
|
+
* applies. Execution always takes the definition registered now, so an edit applies to a running
|
|
276
|
+
* instance from its next action, and accepted results stay as recorded. It is held only where it
|
|
277
|
+
* literally cannot go on: no definition is registered under its id; the step it stands on is gone;
|
|
278
|
+
* a participant with an open assignment is gone, changed context (conversation or isolated) or is no
|
|
279
|
+
* longer assigned by that step; or a participant with a conversation of its own in the instance is
|
|
280
|
+
* gone or no longer isolated. What an entered attempt recorded at entry (each assignment's
|
|
281
|
+
* participant, child, lifetime, generation and checks) is its contract while its assignments are
|
|
282
|
+
* open, so an edit to those applies from the next entry; prompts and schemas apply from the next
|
|
283
|
+
* presentation or submission. Edge targets, options and restart choices are derived from the
|
|
284
|
+
* definition at each read, and registration checks they resolve, so none can dangle; an isolated
|
|
285
|
+
* participant or provider the opening never pinned refuses the entry that needs it.
|
|
286
|
+
*/
|
|
287
|
+
export declare function heldBy(references: DefinitionReferences, registered: WorkflowDefinition | undefined): string | null;
|
|
288
|
+
/**
|
|
289
|
+
* The definition an instance executes by: the one registered under its id now, unless the instance
|
|
290
|
+
* cannot continue on it ({@link heldBy}). `undefined` then: execution is blocked
|
|
291
|
+
* (`missing-binding`), while reads, cancellation and a terminal outcome stay, and registering a
|
|
292
|
+
* definition that fits resumes it. An availability condition derived at each read, never part of
|
|
293
|
+
* the fold.
|
|
294
|
+
*/
|
|
295
|
+
export declare function executable(state: ReadonlyState<InstanceState>, registered: WorkflowDefinition | undefined): WorkflowDefinition | undefined;
|
|
296
|
+
/** What a decision decides: the step's accepted outputs, and every input its attempt bound at entry. */
|
|
297
|
+
export type Subject = {
|
|
298
|
+
readonly outputs: Readonly<Record<string, ReadonlyJsonValue>>;
|
|
299
|
+
readonly inputs: Readonly<Record<string, {
|
|
300
|
+
readonly value: ReadonlyJsonValue;
|
|
301
|
+
readonly citation: Citation | null;
|
|
302
|
+
}>>;
|
|
303
|
+
};
|
|
304
|
+
/** The decision reasons. */
|
|
305
|
+
export type DecisionReason = 'gate' | 'exhaustion' | 'recovery';
|
|
306
|
+
/** The persistent participants one revise choice may name in `restart`, and those it must name. */
|
|
307
|
+
export type RestartChoice = {
|
|
308
|
+
readonly required: readonly string[];
|
|
309
|
+
readonly allowed: readonly string[];
|
|
310
|
+
};
|
|
311
|
+
/** A decision a person owes, derived from the facts that make it pending; `decide` addresses its `id`. */
|
|
312
|
+
export type PendingDecision = {
|
|
313
|
+
readonly id: string;
|
|
314
|
+
readonly attempt: string;
|
|
315
|
+
readonly reason: DecisionReason;
|
|
316
|
+
/** The cited result revision; `null` for recovery. */
|
|
317
|
+
readonly result: string | null;
|
|
318
|
+
/** Exactly what is decided, from recorded facts: a card renders it and never re-resolves bindings. */
|
|
319
|
+
readonly subject: Subject;
|
|
320
|
+
/** What `decide` would take now. Empty verdicts while execution is blocked or cleanup is pending. */
|
|
321
|
+
readonly actions: {
|
|
322
|
+
/**
|
|
323
|
+
* Whether a recovery's cleanup is not established yet: its attempt's work still ending, or of
|
|
324
|
+
* unknown end. No verdict is offered meanwhile, and `decide` refuses without consuming it.
|
|
325
|
+
*/
|
|
326
|
+
readonly cleanupPending: boolean;
|
|
327
|
+
readonly verdicts: readonly ('approve' | 'revise')[];
|
|
328
|
+
readonly options: readonly string[];
|
|
329
|
+
/**
|
|
330
|
+
* By revise choice: a plain retry, and each option offered. Empty but on a recovery, the only
|
|
331
|
+
* decision that restarts anyone; its required restarts are the allowed participants whose
|
|
332
|
+
* conversation delegations would not continue now.
|
|
333
|
+
*/
|
|
334
|
+
readonly restart: {
|
|
335
|
+
readonly retry: RestartChoice;
|
|
336
|
+
readonly options: Readonly<Record<string, RestartChoice>>;
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
readonly detail: {
|
|
340
|
+
/** The transition exhaustion held back. */
|
|
341
|
+
readonly blocked?: {
|
|
342
|
+
readonly from: string;
|
|
343
|
+
readonly to: string;
|
|
344
|
+
};
|
|
345
|
+
readonly recovery?: {
|
|
346
|
+
readonly cause: 'failure' | 'stop';
|
|
347
|
+
readonly detail: string;
|
|
348
|
+
readonly candidates: Readonly<Record<string, ReadonlyJsonValue>>;
|
|
349
|
+
readonly reports: Readonly<Record<string, string>>;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
/** The routing envelope's decision: what a person decided on a result. */
|
|
354
|
+
export type ResultDecision = {
|
|
355
|
+
readonly reason: DecisionReason;
|
|
356
|
+
readonly verdict: 'approve' | 'revise';
|
|
357
|
+
readonly option: string | null;
|
|
358
|
+
readonly feedback: string | null;
|
|
359
|
+
};
|
|
360
|
+
/** The host decision that opened an attempt, by identity; presented with it, so feedback needs no binding. */
|
|
361
|
+
export type AttemptCause = {
|
|
362
|
+
readonly decision: string;
|
|
363
|
+
/** The attempt the decision was made on. */
|
|
364
|
+
readonly attempt: string;
|
|
365
|
+
readonly verdict: 'approve' | 'revise';
|
|
366
|
+
readonly option: string | null;
|
|
367
|
+
readonly feedback: string | null;
|
|
368
|
+
};
|
|
369
|
+
/** What opened `attempt`, when a host decision did; `null` for the opening and automatic routing. */
|
|
370
|
+
export declare function attemptCause(state: ReadonlyState<InstanceState>, attempt: AttemptView): AttemptCause | null;
|
|
371
|
+
/** The subject of a decision on `attempt`: its result's outputs, and its inputs as bound. */
|
|
372
|
+
export declare function subjectOf(state: ReadonlyState<InstanceState>, attempt: AttemptView): Subject;
|
|
373
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { type WorkflowsConfig } from './service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Structured workflows: definitions made with `defineWorkflow` and registered here by the host, with
|
|
5
|
+
* the restriction policies and prerequisite checks they name, and the instances that run them,
|
|
6
|
+
* through the `ctx.workflows` service: `opening` for a root's creation, `read`, `decide`, `cancel`,
|
|
7
|
+
* and `stop` for a person's Stop of a root, which recovers isolated work it stops. Each
|
|
8
|
+
* instance's root and isolated participant is told its assignments at its model steps, granted
|
|
9
|
+
* `submit_workflow_output`, whose accepted answer alone advances it, and reminded once per epoch to
|
|
10
|
+
* submit; each, and every thread it starts, is restricted through the exact assignment serving it
|
|
11
|
+
* until the instance ends. An opening pins what the instance runs on (participants' configuration,
|
|
12
|
+
* the host's check and evidence providers), and entries acquire their evidence outside the journal
|
|
13
|
+
* write. Isolated participants' tasks are started by the plugin itself, as delegations' owner of
|
|
14
|
+
* them, independently of the root's turns; a definition with isolated participants needs
|
|
15
|
+
* delegations mounted first. All configuration is required. Root-only, mounted once by the
|
|
16
|
+
* application. See `docs/workflows.md`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const workflows: Plugin.Object<WorkflowsConfig>;
|
|
19
|
+
export { defineWorkflow, WorkflowDefinitionError } from './definition.js';
|
|
20
|
+
export type { Assignment, Binding, CanonicalDefinition, Condition, Definition, Edge, JsonScalar, JsonSchema, Participant, ParticipantModel, Step, StepOption, WorkflowDefinition, } from './definition.js';
|
|
21
|
+
export { WorkflowRefusedError } from './service.js';
|
|
22
|
+
export { SUBMIT_TOOL, WORKFLOWS_OWNER } from './record.js';
|
|
23
|
+
export type { CancelRequest, CatalogEntry, DecideRequest, OpeningRequest, Prerequisite, StopCancel, RoleBinding, WorkflowsConfig, WorkflowsService, } from './service.js';
|
|
24
|
+
export type { Acquired, CheckProvider, CheckRequest, Configured, EvidenceProvider, EvidenceRequest, PinOutcome, ProviderBinding, ProviderNotice, } from './providers.js';
|
|
25
|
+
export type { DecisionReason, PendingDecision, ResultDecision, Subject } from './fold.js';
|
|
26
|
+
export type { Citation } from './record.js';
|
|
27
|
+
export type { InstanceView } from './view.js';
|
|
28
|
+
export type { Restriction } from './policy.js';
|