@leuduan/lagent 0.0.0-stage → 44.0.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/LICENSE +16 -0
- package/README.md +157 -2
- package/dist/chunks/2GCIWSOA.js +5 -0
- package/dist/chunks/2P47AHNK.js +7 -0
- package/dist/chunks/34KW6VNQ.js +1 -0
- package/dist/chunks/3UMZMPWW.js +1 -0
- package/dist/chunks/5IRF47YB.js +1 -0
- package/dist/chunks/6DRCKZ2C.js +1 -0
- package/dist/chunks/6FRNHMCV.js +1 -0
- package/dist/chunks/7LI64H5X.js +17 -0
- package/dist/chunks/7VAPNE3L.js +1 -0
- package/dist/chunks/ASSQZH3F.js +1 -0
- package/dist/chunks/B4FXK5ER.js +77 -0
- package/dist/chunks/BBCW2FZK.js +1 -0
- package/dist/chunks/BPRCULZH.js +1 -0
- package/dist/chunks/CANPZYTH.js +24 -0
- package/dist/chunks/CQEVREBT.js +1 -0
- package/dist/chunks/CUK7CGC7.js +1 -0
- package/dist/chunks/D4PQP5MA.js +3 -0
- package/dist/chunks/DDANMY45.js +3 -0
- package/dist/chunks/DDZ7YF26.js +1 -0
- package/dist/chunks/EMRB4KCN.js +6 -0
- package/dist/chunks/EPYQ5M3B.js +3 -0
- package/dist/chunks/FJLU4UH3.js +1 -0
- package/dist/chunks/G44LG6VL.js +1 -0
- package/dist/chunks/GGSVIIWJ.js +2 -0
- package/dist/chunks/HK6ZSONF.js +1 -0
- package/dist/chunks/IAAEP6VL.js +30 -0
- package/dist/chunks/JCTBX33H.js +36 -0
- package/dist/chunks/JFX2MXBA.js +4 -0
- package/dist/chunks/JFZZXVWD.js +15 -0
- package/dist/chunks/KUZCL2SH.js +1 -0
- package/dist/chunks/MHC6VPB4.js +7 -0
- package/dist/chunks/MMNNZCBO.js +5 -0
- package/dist/chunks/MNJ4SRF7.js +1 -0
- package/dist/chunks/N6IXG2VL.js +1 -0
- package/dist/chunks/OCBPT7KE.js +1 -0
- package/dist/chunks/OL5A6ITQ.js +1 -0
- package/dist/chunks/PUSUPTAT.js +1 -0
- package/dist/chunks/Q75FUN7D.js +2 -0
- package/dist/chunks/Q7S5LFGN.js +1 -0
- package/dist/chunks/RCIHV3KG.js +1 -0
- package/dist/chunks/S34ZA2R6.js +1 -0
- package/dist/chunks/SS3B5W34.js +12 -0
- package/dist/chunks/VYMT4TXD.js +1 -0
- package/dist/chunks/W57RW55W.js +1 -0
- package/dist/compositions/base.d.ts +11 -0
- package/dist/compositions/codex.d.ts +66 -0
- package/dist/compositions/codexPrompts.d.ts +56 -0
- package/dist/context.d.ts +109 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +1 -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/llm/client.d.ts +135 -0
- package/dist/llm/content.d.ts +52 -0
- package/dist/llm/failure.d.ts +82 -0
- package/dist/llm/index.d.ts +22 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/primitives.d.ts +286 -0
- package/dist/llm/prompt.d.ts +21 -0
- package/dist/llm/provider.d.ts +74 -0
- package/dist/llm/readLedger.d.ts +24 -0
- package/dist/llm/request.d.ts +58 -0
- package/dist/loop/agent.d.ts +18 -0
- package/dist/loop/authorization.d.ts +41 -0
- package/dist/loop/auxiliary.d.ts +58 -0
- package/dist/loop/chunks.d.ts +27 -0
- package/dist/loop/completion.d.ts +17 -0
- package/dist/loop/errors.d.ts +139 -0
- package/dist/loop/hooks.d.ts +274 -0
- package/dist/loop/index.d.ts +16 -0
- package/dist/loop/runner.d.ts +134 -0
- package/dist/loop/runtime.d.ts +76 -0
- package/dist/loop/strategy.d.ts +80 -0
- package/dist/loop/surfacePrepare.d.ts +30 -0
- package/dist/loop/tool.d.ts +106 -0
- package/dist/loop/toolCalls.d.ts +35 -0
- package/dist/plugin.d.ts +50 -0
- package/dist/plugin.js +1 -0
- package/dist/plugins/agentsMd.d.ts +80 -0
- package/dist/plugins/agentsMd.js +1 -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/ask/tools.d.ts +9 -0
- package/dist/plugins/commands/index.d.ts +43 -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 +558 -0
- package/dist/plugins/commands/service.d.ts +321 -0
- package/dist/plugins/commands/shell.d.ts +25 -0
- package/dist/plugins/commands/tools.d.ts +10 -0
- package/dist/plugins/compaction/checkpoint.d.ts +94 -0
- package/dist/plugins/compaction/config.d.ts +133 -0
- package/dist/plugins/compaction/estimate.d.ts +37 -0
- package/dist/plugins/compaction/index.d.ts +87 -0
- package/dist/plugins/compaction/index.js +7 -0
- package/dist/plugins/compaction/planner.d.ts +207 -0
- package/dist/plugins/compaction/prune.d.ts +9 -0
- package/dist/plugins/compaction/record.d.ts +227 -0
- package/dist/plugins/compaction/segments.d.ts +23 -0
- package/dist/plugins/compaction/state.d.ts +68 -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 +633 -0
- package/dist/plugins/delegations/request.d.ts +384 -0
- package/dist/plugins/delegations/role.d.ts +30 -0
- package/dist/plugins/delegations/service.d.ts +563 -0
- package/dist/plugins/delegations/standing.d.ts +19 -0
- package/dist/plugins/delegations/stopCheck.d.ts +21 -0
- package/dist/plugins/delegations/tools.d.ts +71 -0
- package/dist/plugins/delegations/waitContracts.d.ts +118 -0
- package/dist/plugins/delegations/waitResolver.d.ts +116 -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/fileTools/config.d.ts +10 -0
- package/dist/plugins/fileTools/editFiles.d.ts +117 -0
- package/dist/plugins/fileTools/fsRead.d.ts +17 -0
- package/dist/plugins/fileTools/gitDiscovery.d.ts +9 -0
- package/dist/plugins/fileTools/index.d.ts +18 -0
- package/dist/plugins/fileTools/index.js +1 -0
- package/dist/plugins/fileTools/ripgrep.d.ts +20 -0
- package/dist/plugins/fileTools/textEdit.d.ts +67 -0
- package/dist/plugins/fileTools/tools.d.ts +6 -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/tools.d.ts +41 -0
- package/dist/plugins/mcp/version.d.ts +2 -0
- package/dist/plugins/routeNotice.d.ts +22 -0
- package/dist/plugins/routeNotice.js +1 -0
- package/dist/plugins/sandbox/absent.d.ts +33 -0
- package/dist/plugins/sandbox/client.d.ts +39 -0
- package/dist/plugins/sandbox/files.d.ts +28 -0
- package/dist/plugins/sandbox/index.d.ts +52 -0
- package/dist/plugins/sandbox/index.js +4 -0
- package/dist/plugins/sandbox/mode.d.ts +57 -0
- package/dist/plugins/sandbox/policy.d.ts +163 -0
- package/dist/plugins/sandbox/protocol.d.ts +107 -0
- package/dist/plugins/sandbox/service.d.ts +153 -0
- package/dist/plugins/sandbox/worker.d.ts +12 -0
- package/dist/plugins/sandbox/worker.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 +83 -0
- package/dist/plugins/skills/index.d.ts +31 -0
- package/dist/plugins/skills/index.js +1 -0
- package/dist/plugins/skills/tools.d.ts +11 -0
- package/dist/plugins/subAgents/availableRoutes.d.ts +53 -0
- package/dist/plugins/subAgents/index.d.ts +67 -0
- package/dist/plugins/subAgents/index.js +1 -0
- package/dist/plugins/subAgents/tools.d.ts +67 -0
- package/dist/plugins/threadDirs.d.ts +36 -0
- package/dist/plugins/threadDirs.js +1 -0
- package/dist/plugins/toolPolicy/index.d.ts +61 -0
- package/dist/plugins/toolPolicy/index.js +1 -0
- package/dist/plugins/truncateToolOutput.d.ts +30 -0
- package/dist/plugins/truncateToolOutput.js +6 -0
- package/dist/plugins/usage/index.d.ts +26 -0
- package/dist/plugins/usage/index.js +1 -0
- package/dist/plugins/usage/tracker.d.ts +34 -0
- package/dist/plugins/verify/index.d.ts +27 -0
- package/dist/plugins/verify/index.js +6 -0
- package/dist/plugins/verify/judgement.d.ts +16 -0
- package/dist/plugins/verify/record.d.ts +382 -0
- package/dist/plugins/verify/service.d.ts +93 -0
- package/dist/plugins/verify/state.d.ts +58 -0
- package/dist/plugins/webTools/html.d.ts +23 -0
- package/dist/plugins/webTools/index.d.ts +34 -0
- package/dist/plugins/webTools/index.js +1 -0
- package/dist/plugins/webTools/network.d.ts +23 -0
- package/dist/plugins/webTools/web.d.ts +32 -0
- package/dist/plugins/workflows/assignment.d.ts +20 -0
- package/dist/plugins/workflows/cleanup.d.ts +38 -0
- package/dist/plugins/workflows/definition.d.ts +184 -0
- package/dist/plugins/workflows/entryPlan.d.ts +95 -0
- package/dist/plugins/workflows/hostBindings.d.ts +146 -0
- package/dist/plugins/workflows/index.d.ts +28 -0
- package/dist/plugins/workflows/index.js +11 -0
- package/dist/plugins/workflows/observations.d.ts +81 -0
- package/dist/plugins/workflows/participantModels.d.ts +28 -0
- package/dist/plugins/workflows/participants.d.ts +143 -0
- package/dist/plugins/workflows/policy.d.ts +112 -0
- package/dist/plugins/workflows/record.d.ts +2849 -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/state.d.ts +373 -0
- package/dist/plugins/workflows/stopCheck.d.ts +13 -0
- package/dist/plugins/workflows/tools.d.ts +13 -0
- package/dist/plugins/workflows/view.d.ts +103 -0
- package/dist/plugins/workflows/workStatus.d.ts +21 -0
- package/dist/plugins/workspaceNotice.d.ts +36 -0
- package/dist/plugins/workspaceNotice.js +1 -0
- package/dist/providers/anthropic.d.ts +178 -0
- package/dist/providers/anthropicMessages.d.ts +66 -0
- package/dist/providers/codex.d.ts +71 -0
- package/dist/providers/codexAuth.d.ts +116 -0
- package/dist/providers/deepseek.d.ts +59 -0
- package/dist/providers/failure.d.ts +23 -0
- package/dist/providers/gateway.d.ts +24 -0
- package/dist/providers/index.d.ts +18 -0
- package/dist/providers/index.js +6 -0
- package/dist/providers/openaiChat.d.ts +73 -0
- package/dist/providers/openaiResponses.d.ts +109 -0
- package/dist/providers/opencodeCopilot.d.ts +23 -0
- package/dist/providers/opencodeGo.d.ts +109 -0
- package/dist/providers/shared.d.ts +112 -0
- package/dist/providers/stream.d.ts +156 -0
- package/dist/records/index.d.ts +13 -0
- package/dist/records/index.js +1 -0
- package/dist/records/journal.d.ts +2968 -0
- package/dist/records/toolResult.d.ts +65 -0
- package/dist/services/agents.d.ts +62 -0
- package/dist/services/catalogContributions.d.ts +73 -0
- package/dist/services/confinement/files.d.ts +118 -0
- package/dist/services/confinement/service.d.ts +219 -0
- package/dist/services/core.d.ts +28 -0
- package/dist/services/extensionEvents.d.ts +181 -0
- package/dist/services/journal.d.ts +26 -0
- package/dist/services/llm.d.ts +82 -0
- package/dist/services/modes.d.ts +65 -0
- package/dist/services/plugins.d.ts +34 -0
- package/dist/services/presets/definition.d.ts +154 -0
- package/dist/services/presets/installations.d.ts +139 -0
- package/dist/services/prompts.d.ts +85 -0
- package/dist/services/threads/activation.d.ts +100 -0
- package/dist/services/threads/admission.d.ts +174 -0
- package/dist/services/threads/birth.d.ts +219 -0
- package/dist/services/threads/index.d.ts +14 -0
- package/dist/services/threads/runEvents.d.ts +79 -0
- package/dist/services/threads/runOwner.d.ts +368 -0
- package/dist/services/threads/service.d.ts +450 -0
- package/dist/services/threads/thread.d.ts +268 -0
- package/dist/services/threads/view.d.ts +93 -0
- package/dist/services/tools.d.ts +118 -0
- package/dist/state/birth.d.ts +62 -0
- package/dist/state/chain.d.ts +46 -0
- package/dist/state/confirmations.d.ts +64 -0
- package/dist/state/continuation.d.ts +167 -0
- package/dist/state/decide.d.ts +72 -0
- package/dist/state/dispatches.d.ts +54 -0
- package/dist/state/errors.d.ts +26 -0
- package/dist/state/forks.d.ts +61 -0
- package/dist/state/holds.d.ts +104 -0
- package/dist/state/inbox.d.ts +188 -0
- package/dist/state/index.d.ts +31 -0
- package/dist/state/inputs.d.ts +58 -0
- package/dist/state/installations.d.ts +28 -0
- package/dist/state/limits.d.ts +14 -0
- package/dist/state/prompt.d.ts +13 -0
- package/dist/state/recovery.d.ts +7 -0
- package/dist/state/replace.d.ts +33 -0
- package/dist/state/requests.d.ts +129 -0
- package/dist/state/route.d.ts +61 -0
- package/dist/state/summary.d.ts +16 -0
- package/dist/state/surface.d.ts +153 -0
- package/dist/state/surfaceRead.d.ts +20 -0
- package/dist/state/thread.d.ts +73 -0
- package/dist/state/turns.d.ts +87 -0
- package/dist/state/waits.d.ts +38 -0
- package/dist/state/wake.d.ts +32 -0
- package/dist/stores/durableObject.d.ts +23 -0
- package/dist/stores/durableObject.js +1 -0
- package/dist/stores/durableObjectConnection.d.ts +27 -0
- package/dist/stores/memory.d.ts +29 -0
- package/dist/stores/sql.d.ts +59 -0
- package/dist/stores/sqlite.d.ts +31 -0
- package/dist/stores/sqlite.js +1 -0
- package/dist/sys/environment.d.ts +42 -0
- package/dist/sys/git.d.ts +47 -0
- package/dist/sys/paths.d.ts +9 -0
- package/dist/sys/spawn.d.ts +186 -0
- package/dist/testing/clock.d.ts +17 -0
- package/dist/testing/fakeLlm.d.ts +76 -0
- package/dist/testing/fedLlm.d.ts +34 -0
- package/dist/testing/helpers.d.ts +362 -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/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/jsonSchema.d.ts +7 -0
- package/dist/util/log.d.ts +6 -0
- package/dist/util/retries.d.ts +25 -0
- package/dist/util/text.d.ts +21 -0
- package/dist/util/timers.d.ts +43 -0
- package/package.json +183 -3
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { type AnswerCheck } from '../../state/index.js';
|
|
2
|
+
import type { JournalEvent, Seq } from '../../records/journal.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,13 @@
|
|
|
1
|
+
import type { Context } from '@leuduan/cordis';
|
|
2
|
+
import { type Governance } from './policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The workflow's stop check (§7 of the design): while a thread's assignment is active, an answer
|
|
5
|
+
* that is not its submission (a reply, another tool's conclusion) is sent back once per epoch with
|
|
6
|
+
* how to submit. Once that reminder is spent, the outcome depends on who answered: on the root it
|
|
7
|
+
* abstains, so the answer may be accepted as chat, but prose never advances the workflow, the
|
|
8
|
+
* assignment stays active and a person resumes it; on an isolated participant's child it rejects,
|
|
9
|
+
* which fails its task and opens the attempt's recovery. The submission itself, and every thread
|
|
10
|
+
* that is not working an assignment, it leaves to the other checks, whose rejection wins. A pure
|
|
11
|
+
* read of the journal, so judging again repeats nothing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function remindToSubmit(ctx: Context, governance: Governance): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context } from '@leuduan/cordis';
|
|
2
|
+
import { type Governance } from './policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The protocol tool, one static envelope for every assignment, since a tool's spec is fixed when it
|
|
5
|
+
* is defined: the output is validated by the assignment's own schema, rebuilt from the registered
|
|
6
|
+
* definition. A valid submission is the turn's answer (`concludes_turn`), the assignment's
|
|
7
|
+
* candidate until core accepts or refuses that answer. Refused as an error, recording no candidate:
|
|
8
|
+
* a caller that is not the thread working the assignment it names from this call's model step on
|
|
9
|
+
* (the vote's standing: the root's own assignment, or the one whose task an isolated participant's
|
|
10
|
+
* child serves), work it started that is still open at any depth (quiescence), and an output its
|
|
11
|
+
* schema refuses. Validating is all it does, so a rerun after an interruption repeats nothing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function submitTool(ctx: Context, governance: Governance): import("../../plugin.js").Tool;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ThinkingEffort } from '../../llm/primitives.js';
|
|
2
|
+
import type { ReadonlyJsonValue } from '../../util/json.js';
|
|
3
|
+
import type { WorkflowDefinition } from './definition.js';
|
|
4
|
+
import { type AssignmentState, type InstanceState, type PendingDecision, type ResultDecision } from './state.js';
|
|
5
|
+
import type { StartState } from './participants.js';
|
|
6
|
+
import { type Citation } from './record.js';
|
|
7
|
+
import { type Barrier } from './routing.js';
|
|
8
|
+
import type { ReadonlyState } from '../../util/foldState.js';
|
|
9
|
+
/** An instance as a host reads it (§9 of the design): derived at each read, never recorded. */
|
|
10
|
+
export type InstanceView = {
|
|
11
|
+
/** The id of the definition it runs by, recorded at opening. */
|
|
12
|
+
readonly definition: string;
|
|
13
|
+
/** The instance's input, recorded at opening: what a host compares a repeated start with. */
|
|
14
|
+
readonly input: ReadonlyJsonValue;
|
|
15
|
+
/**
|
|
16
|
+
* Each isolated participant's model as its opening pinned it, the definition's or the starter's
|
|
17
|
+
* choice: what a host compares a repeated start's models with.
|
|
18
|
+
*/
|
|
19
|
+
readonly models: Readonly<Record<string, {
|
|
20
|
+
readonly provider: string;
|
|
21
|
+
readonly model: string;
|
|
22
|
+
readonly thinkingEffort: ThinkingEffort | null;
|
|
23
|
+
}>>;
|
|
24
|
+
readonly status: 'running' | 'waiting' | 'blocked' | 'completed' | 'cancelled';
|
|
25
|
+
/** The step being worked or decided; `null` once the instance ended. */
|
|
26
|
+
readonly step: string | null;
|
|
27
|
+
readonly attempt: {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly ordinal: number;
|
|
30
|
+
} | null;
|
|
31
|
+
readonly assignments: readonly {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly participant: string;
|
|
34
|
+
readonly state: AssignmentState;
|
|
35
|
+
/** The thread it runs in: the root, or the isolated participant's child. */
|
|
36
|
+
readonly thread: string;
|
|
37
|
+
/** The delegation task an isolated participant works it as; `null` for the root's own. */
|
|
38
|
+
readonly task: string | null;
|
|
39
|
+
/** The participant generation an isolated assignment was pinned to; `null` for the root's own. */
|
|
40
|
+
readonly generation: number | null;
|
|
41
|
+
}[];
|
|
42
|
+
readonly results: readonly {
|
|
43
|
+
readonly revision: string;
|
|
44
|
+
readonly step: string;
|
|
45
|
+
readonly outputs: Readonly<Record<string, ReadonlyJsonValue>>;
|
|
46
|
+
readonly decision: ResultDecision | null;
|
|
47
|
+
/** Neither retired by its step's re-entry nor stale through what it was bound to. */
|
|
48
|
+
readonly current: boolean;
|
|
49
|
+
/** The inputs its attempt bound at entry. */
|
|
50
|
+
readonly inputs: Readonly<Record<string, Citation | null>>;
|
|
51
|
+
}[];
|
|
52
|
+
readonly pending: PendingDecision | null;
|
|
53
|
+
readonly blocked: null | {
|
|
54
|
+
readonly reason: 'missing-binding' | 'entry-refused' | 'cleanup';
|
|
55
|
+
readonly detail: string;
|
|
56
|
+
};
|
|
57
|
+
readonly waitingOn: null | 'decision' | 'dispatch' | 'participant' | 'cleanup' | 'person-input';
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* What the view reads besides the root's rows: the evidence barrier an admitted cancellation, or a
|
|
61
|
+
* pending recovery, waits on, as the commands and delegations plugins answer it now; whether the
|
|
62
|
+
* root is settled (idle or held), so an open assignment of its own waits on a person; where its
|
|
63
|
+
* isolated assignments' starts stand; and what the providers it pinned say now.
|
|
64
|
+
*/
|
|
65
|
+
export type RootFacts = {
|
|
66
|
+
readonly barrier: Barrier;
|
|
67
|
+
readonly settled: boolean;
|
|
68
|
+
/** Where each open isolated assignment's start stands, by assignment (`Participants.states`). */
|
|
69
|
+
readonly starts: ReadonlyMap<string, StartState>;
|
|
70
|
+
/**
|
|
71
|
+
* Why a provider cannot serve the instance's pin now (see `Providers.problem`), or `null`: a check
|
|
72
|
+
* provider by the participant whose assignments list it, an evidence provider by its name.
|
|
73
|
+
*/
|
|
74
|
+
readonly provider: (binding: {
|
|
75
|
+
readonly check: string;
|
|
76
|
+
readonly participant: string;
|
|
77
|
+
} | {
|
|
78
|
+
readonly evidence: string;
|
|
79
|
+
}) => string | null;
|
|
80
|
+
/** The latest refusal of an automatic transition's entry over evidence acquired for it, if any. */
|
|
81
|
+
readonly entryRefusal: {
|
|
82
|
+
readonly transition: string;
|
|
83
|
+
readonly reason: string;
|
|
84
|
+
} | null;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The instance as a host reads it, derived from recorded facts and what is registered now
|
|
88
|
+
* (`registered`, looked up by the recorded id). Without a definition it can continue on
|
|
89
|
+
* ({@link heldBy}), execution is blocked (`missing-binding`, with why): the recorded copy still
|
|
90
|
+
* renders results and pending subjects, but no decision is offered; a terminal instance stays
|
|
91
|
+
* terminal. An admitted cancellation waits on its
|
|
92
|
+
* cleanup (`cleanup`), whatever is registered, and is `blocked` on it once a command's stop failed
|
|
93
|
+
* or its termination is unknown; a pending recovery likewise, offering no verdict until its cleanup
|
|
94
|
+
* is established. `waitingOn` is `person-input` while the root's own assignment is open and the
|
|
95
|
+
* root is settled: idle, held by a Stop, or failed, whether a candidate's check is still owed, a
|
|
96
|
+
* rejection or a spent reminder left it active, or its activation input is gone; otherwise
|
|
97
|
+
* `dispatch` while an open isolated assignment's task is not started yet (its start in flight, or
|
|
98
|
+
* waiting for a slot or its conversation's previous task), and `participant` while isolated
|
|
99
|
+
* participants work their started tasks. A start held (a binding it runs on unavailable, a pinned
|
|
100
|
+
* configuration its child conflicts with) blocks the instance (`missing-binding`), as a missing
|
|
101
|
+
* provider does.
|
|
102
|
+
*/
|
|
103
|
+
export declare function instanceView(state: ReadonlyState<InstanceState>, registered: WorkflowDefinition | undefined, root: RootFacts): InstanceView;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Context } from '@leuduan/cordis';
|
|
2
|
+
import { type CommandWork } from '../commands/index.js';
|
|
3
|
+
import type { Origins } from '../../journal/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* What stands between the threads `scope` names, under `threadId` and including it, and their end,
|
|
6
|
+
* each item saying why, as the plugins that own that work answer it from durable evidence whether or
|
|
7
|
+
* not they are mounted: `draining`, work that is ending or will end on its own (a command running or
|
|
8
|
+
* stopping, a sub-agent's task open, draining a late turn or being cleaned up, a stop obligation not
|
|
9
|
+
* yet acknowledged); `unresolved`, work whose end nothing establishes (a command whose end is not
|
|
10
|
+
* known, a task or command record that cannot be read). Both empty: everything there is known to
|
|
11
|
+
* have ended. A stop obligation on `threadId` outside `scope` counts while it targets a thread in it.
|
|
12
|
+
* What submission's quiescence, cancellation's cleanup and a recovery's barrier read before
|
|
13
|
+
* certifying quiet.
|
|
14
|
+
*/
|
|
15
|
+
export declare function workUnder(ctx: Context, threadId: string, scope: ReadonlySet<string>): CommandWork;
|
|
16
|
+
/**
|
|
17
|
+
* `threadId` and every thread its work started, at any depth: under the instance's `root`, neither
|
|
18
|
+
* the root's isolated participants nor anything under them, which are the workflow's work, not the
|
|
19
|
+
* root's.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ownWork(origins: Origins, threadId: string, root: string): Set<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const WorkspaceSchema: z.ZodObject<{
|
|
4
|
+
cwd: z.ZodString;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
/** Where a thread works: its `cwd`. */
|
|
7
|
+
export type Workspace = z.output<typeof WorkspaceSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* Briefs an agent on where it works: its thread's `cwd` and the operating system.
|
|
10
|
+
*
|
|
11
|
+
* Only the operating system goes into the prompt, which is recorded once and must not depend on
|
|
12
|
+
* which thread it is (see `PromptRenderInput`). The working directory is told as
|
|
13
|
+
* a conversation message at the next model step that is already due, whenever it differs from the
|
|
14
|
+
* latest notice the model can still see: on its first step, again if they change, and again after a
|
|
15
|
+
* replacement took that notice off the surface. The cached part of the request ahead of the history
|
|
16
|
+
* is never rewritten, and threads in one workspace are told the same notice.
|
|
17
|
+
*
|
|
18
|
+
* Every notice is the whole workspace, with a working directory that moved since the notice the
|
|
19
|
+
* model can still see noted as previously, so the latest visible notice establishes all of it. A
|
|
20
|
+
* fork inherits what its source was told, so it is told again only when its workspace differs.
|
|
21
|
+
*
|
|
22
|
+
* It deliberately says nothing that changes while the thread lives — no directory listing, no git
|
|
23
|
+
* status, no date. An agent that needs the layout lists it with its tools.
|
|
24
|
+
*
|
|
25
|
+
* Mounted on the root it briefs every thread; mounted through `thread.ctx` it briefs that thread
|
|
26
|
+
* only. The notice is per thread, so it reaches a role child too; the prompt section is for every
|
|
27
|
+
* global agent, so it does not.
|
|
28
|
+
*/
|
|
29
|
+
export declare const workspaceNotice: Plugin.Object<undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* What a thread is told: its whole workspace, every time, with a working directory that differs
|
|
32
|
+
* from `told`, the notice the model can still see, noted as previously.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderWorkspaceNotice(workspace: Workspace, told: Workspace | null): string;
|
|
35
|
+
export declare function renderEnvironmentInfo(): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"../chunks/Q7S5LFGN.js";import"../chunks/EPYQ5M3B.js";import"../chunks/6FRNHMCV.js";import"../chunks/CUK7CGC7.js";import"../chunks/BPRCULZH.js";import"../chunks/DDANMY45.js";import"../chunks/BBCW2FZK.js";import"../chunks/MMNNZCBO.js";import"../chunks/G44LG6VL.js";import"../chunks/D4PQP5MA.js";export{c as renderEnvironmentInfo,b as renderWorkspaceNotice,a as workspaceNotice};
|