@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,167 @@
|
|
|
1
|
+
import type { CancelIntent, InterruptionCause, RunOutcomeKind, RunSettledReason, Seq, TurnEndReason } from '../records/journal.js';
|
|
2
|
+
import type { JsonValue } from '../util/json.js';
|
|
3
|
+
import { type DeepReadonly } from '../util/json.js';
|
|
4
|
+
import type { DerivedHold, Hold } from './holds.js';
|
|
5
|
+
import type { PendingRun } from './requests.js';
|
|
6
|
+
import type { ThreadState } from './thread.js';
|
|
7
|
+
/**
|
|
8
|
+
* What a registered constraint says of a thread's pending request: `allow`; `hold` with why (`reason`,
|
|
9
|
+
* in words) and, optionally, a machine-readable `code` and `data`, until the feature calls `changed`;
|
|
10
|
+
* or `obsolete`, the request's authority gone for good: it settles `superseded` once nothing of it is
|
|
11
|
+
* left to drain.
|
|
12
|
+
*/
|
|
13
|
+
export type ConstraintAnswer = {
|
|
14
|
+
readonly kind: 'allow';
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'hold';
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
readonly code?: string;
|
|
19
|
+
readonly data?: JsonValue;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'obsolete';
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
};
|
|
24
|
+
/** An answer as the decision reads it: core stamps the registration's `owner` onto a hold. */
|
|
25
|
+
export type OwnedAnswer = Exclude<ConstraintAnswer, {
|
|
26
|
+
readonly kind: 'hold';
|
|
27
|
+
}> | (Extract<ConstraintAnswer, {
|
|
28
|
+
readonly kind: 'hold';
|
|
29
|
+
}> & {
|
|
30
|
+
readonly owner: string;
|
|
31
|
+
});
|
|
32
|
+
/** What the work on a thread looks like to the decision: the folds' answers, read as it decides. */
|
|
33
|
+
export type WorkSnapshot = {
|
|
34
|
+
/** Whether a run would find something to do (`hasThreadWork`). */
|
|
35
|
+
readonly hasWork: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether input waits for the next step: steering that arrived during the turn just ended, or a
|
|
38
|
+
* report its sender queued for the next step, which a turn that ran out answering calls left.
|
|
39
|
+
*/
|
|
40
|
+
readonly nextStepQueued: boolean;
|
|
41
|
+
/** Whether any input waits, for a step or a turn. */
|
|
42
|
+
readonly anyQueued: boolean;
|
|
43
|
+
/** Whether the conversation holds calls with no answer. */
|
|
44
|
+
readonly unanswered: boolean;
|
|
45
|
+
};
|
|
46
|
+
/** How a turn ended, as a continuation decision reads it: its kind, and for an interruption its cause. */
|
|
47
|
+
export type Ending = {
|
|
48
|
+
readonly kind: Exclude<TurnEndReason['kind'], 'interrupted'>;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'interrupted';
|
|
51
|
+
readonly cause: InterruptionCause;
|
|
52
|
+
};
|
|
53
|
+
/** Everything one continuation decision reads. No clock, I/O or callback. */
|
|
54
|
+
export type ContinuationInput = {
|
|
55
|
+
readonly pending: PendingRun;
|
|
56
|
+
/** How the execution's last turn ended; `null` at the execution's entry, or for an idle thread. */
|
|
57
|
+
readonly ending: Ending | null;
|
|
58
|
+
/**
|
|
59
|
+
* The repairs the request may still spend on interrupted turns, read from its durable count
|
|
60
|
+
* (`repairsLeft`), so a crash, a hold or a new execution neither grants nor loses one.
|
|
61
|
+
*/
|
|
62
|
+
readonly repairsLeft: number;
|
|
63
|
+
readonly work: WorkSnapshot;
|
|
64
|
+
/**
|
|
65
|
+
* Whether a confirmation on the thread or under it was answered since its last turn began: what
|
|
66
|
+
* the next turn carries to the call that parked on it.
|
|
67
|
+
*/
|
|
68
|
+
readonly answeredUnder: boolean;
|
|
69
|
+
/** The derived holds on the request, as `deriveHolds` orders them. */
|
|
70
|
+
readonly holds: readonly DerivedHold[];
|
|
71
|
+
/** What the constraints the thread is under say, combined; `allow` with none. */
|
|
72
|
+
readonly constraint: OwnedAnswer;
|
|
73
|
+
/** The intent of the cancel that captured this execution, if one did. */
|
|
74
|
+
readonly cancel: CancelIntent | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* What a thread does next with its pending request: run another turn (`advance`); end the
|
|
78
|
+
* execution with the request still pending (`hold`, `shutdown` when an abort that no cancel
|
|
79
|
+
* captured ended it); settle the request with an outcome; or rerun the interrupted turn (`repair`),
|
|
80
|
+
* when plugins, or what its judgment was fenced on, changed under it.
|
|
81
|
+
*/
|
|
82
|
+
export type Continuation = {
|
|
83
|
+
readonly kind: 'advance';
|
|
84
|
+
} | {
|
|
85
|
+
readonly kind: 'hold';
|
|
86
|
+
readonly hold: Hold;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: 'settle';
|
|
89
|
+
readonly outcome: RunOutcomeKind;
|
|
90
|
+
readonly reason: RunSettledReason;
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: 'repair';
|
|
93
|
+
};
|
|
94
|
+
/** How a cancel settles the run it reaches: a person's `cancelled`, a feature's cleanup `superseded`. */
|
|
95
|
+
export declare const cancelOutcome: (intent: CancelIntent) => RunOutcomeKind;
|
|
96
|
+
/** The repairs left to a request whose rows fold to `requests`: one, less one per interrupted turn since a releasing cause, after the first. */
|
|
97
|
+
export declare const repairsLeft: (requests: {
|
|
98
|
+
readonly interruptions: number;
|
|
99
|
+
}) => number;
|
|
100
|
+
/** A constraint's hold as the hold on the request: its answer, the owner that gave it stamped. */
|
|
101
|
+
export declare function constraintHold(answer: Extract<OwnedAnswer, {
|
|
102
|
+
readonly kind: 'hold';
|
|
103
|
+
}>): Hold;
|
|
104
|
+
/**
|
|
105
|
+
* The one continuation decision, at an idle thread and at every turn boundary of an execution. It
|
|
106
|
+
* replaces the loop's own branch after a turn, and every host's rule for running a thread again;
|
|
107
|
+
* the turn and step decider underneath (`nextAction`) is unchanged. In order:
|
|
108
|
+
*
|
|
109
|
+
* 1. A cancel that captured the execution settles it by its intent; a constraint that calls the
|
|
110
|
+
* request obsolete settles it `superseded`.
|
|
111
|
+
* 2. How the last turn ended: an abort no cancel captured is a shutdown, leaving the request
|
|
112
|
+
* pending; an interrupted turn holds for any current hold (a repair would run the turn again
|
|
113
|
+
* under it), and otherwise is repaired while the execution has a repair left. Once none is, a
|
|
114
|
+
* turn whose activation changed fails the request, and one whose judgment was invalidated (a
|
|
115
|
+
* transient race with the facts it judged) leaves it held until the next releasing cause, the
|
|
116
|
+
* answer still owed its checks; a turn recovery closed goes on as at an entry. An error fails the
|
|
117
|
+
* request, as a failure before any turn does (`setup`); out of steps or a rejected answer goes
|
|
118
|
+
* on only for input waiting for the next step (`nextStep`), and fails otherwise; a blocked
|
|
119
|
+
* turn holds on an approval still waiting unless an answer under the thread landed since it
|
|
120
|
+
* began, and otherwise decides as below; a completed turn goes on while input waits, and settles
|
|
121
|
+
* `completed` otherwise.
|
|
122
|
+
* 3. Going on, or at the entry: the derived holds (past an approval hold when an answer landed
|
|
123
|
+
* since the last turn began; a wait holds whatever landed), then the constraint's own hold, then
|
|
124
|
+
* whether a run would find work at all. One that would not still holds on an approval waiting,
|
|
125
|
+
* and otherwise settles as its last turn ended, or `completed` with nothing done. A blocked turn
|
|
126
|
+
* whose calls nothing holds and none can be dispatched breaks the rules the holds keep: the
|
|
127
|
+
* decision throws.
|
|
128
|
+
*/
|
|
129
|
+
export declare function continuation(input: ContinuationInput): Continuation;
|
|
130
|
+
/**
|
|
131
|
+
* The run a cancel's own write settles, by its intent: the request pending when the write lands,
|
|
132
|
+
* unless it is the run of the execution the cancel captured, whose finalization settles it. That is
|
|
133
|
+
* the pending run of an idle thread, or a successor the captured execution's finalization already
|
|
134
|
+
* opened from residual causes.
|
|
135
|
+
*/
|
|
136
|
+
export declare function cancelWriteSettles(pending: PendingRun | null, capturedRunId: string | null): string | null;
|
|
137
|
+
/** A turn a run served: how it ended, its `turn/start`, and the attempt cutoff of the execution that opened it. */
|
|
138
|
+
export type ServedTurn = {
|
|
139
|
+
readonly ending: DeepReadonly<TurnEndReason>;
|
|
140
|
+
readonly start: Seq;
|
|
141
|
+
readonly attemptCutoff: Seq;
|
|
142
|
+
};
|
|
143
|
+
/** The thread's last turn when it served `runId` and has ended. */
|
|
144
|
+
export declare function lastTurn(state: ThreadState, runId: string): ServedTurn | null;
|
|
145
|
+
/**
|
|
146
|
+
* The thread's last turn when it served `runId` and ended, as a resumed run re-enters from it: a
|
|
147
|
+
* crash between a failed turn and its settlement fails the run, carrying the causes that release
|
|
148
|
+
* the failure to a successor, rather than retry it under the failed run. A turn that a shutdown
|
|
149
|
+
* aborted, or that recovery abandoned, is no ending to decide from: the run goes on. Nor is a turn that did not fail when a releasing cause came after it: a person who asked
|
|
150
|
+
* since would have opened a request of their own, had the run settled first. That includes an
|
|
151
|
+
* interrupted turn, its activation changed or its judgment invalidated: until a releasing cause
|
|
152
|
+
* lands, it is the ending the run is repaired from, held on or failed by, as its spent repairs say.
|
|
153
|
+
*/
|
|
154
|
+
export declare function resumedTurn(state: ThreadState, runId: string): ServedTurn | null;
|
|
155
|
+
/** Where a continuation decision reads the last turn from: how it ended (`null` before any) and where it began. */
|
|
156
|
+
export type DecisionTurn = {
|
|
157
|
+
readonly ending: Ending | null;
|
|
158
|
+
readonly start: Seq | null;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* The turn the decision at an execution's entry, or one made before admitting a run, reads: the
|
|
162
|
+
* ending of a turn that served the pending run when a crash or a hold left it there (`resumed`),
|
|
163
|
+
* and otherwise where the thread's last turn began, so an answer since counts.
|
|
164
|
+
*/
|
|
165
|
+
export declare function entryTurn(state: ThreadState): DecisionTurn & {
|
|
166
|
+
readonly resumed: ServedTurn | null;
|
|
167
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type QueuedInput, type Seq, type TurnEndReason, type InboxTarget } from '../records/journal.js';
|
|
2
|
+
import type { ToolCall } from '../llm/primitives.js';
|
|
3
|
+
import type { TurnLimits } from './limits.js';
|
|
4
|
+
import type { Journal } from '../journal/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* What one thread looks like at a decision point. Not the public `ThreadView` read.
|
|
7
|
+
*
|
|
8
|
+
* Every field is a fold of the journal but one input: which queue the boundary reads and whether a
|
|
9
|
+
* stop check sent back the answer of a turn that opened by answering calls (`decisionView`'s
|
|
10
|
+
* `target` and `sentBack`), which the loop remembers for the turn. A crash closes the turn, and a new
|
|
11
|
+
* turn starts both afresh, so a journal that stops anywhere still decides the same way.
|
|
12
|
+
*/
|
|
13
|
+
export type DecisionView = {
|
|
14
|
+
/** Input waiting at this boundary. */
|
|
15
|
+
readonly queued: readonly QueuedInput[];
|
|
16
|
+
/** Calls the conversation has no answer for. */
|
|
17
|
+
readonly unanswered: readonly ToolCall[];
|
|
18
|
+
/** Of those, the ones that cannot be dispatched now: waiting on a confirmation, or on a wait not resolved. */
|
|
19
|
+
readonly parked: readonly ToolCall[];
|
|
20
|
+
/** Whether the conversation ends on something the model has not replied to. */
|
|
21
|
+
readonly owed: boolean;
|
|
22
|
+
/** Whether a tool result asked for this turn to stop. */
|
|
23
|
+
readonly concluded: boolean;
|
|
24
|
+
/** The answer the conversation ends on, while no stop check has accepted or rejected it. */
|
|
25
|
+
readonly provisional: Seq | null;
|
|
26
|
+
/** Steps already taken in this turn. */
|
|
27
|
+
readonly step: number;
|
|
28
|
+
};
|
|
29
|
+
export type Action =
|
|
30
|
+
/** Run these, then decide again. */
|
|
31
|
+
{
|
|
32
|
+
kind: 'answer-calls';
|
|
33
|
+
calls: readonly ToolCall[];
|
|
34
|
+
}
|
|
35
|
+
/** Record this input, ask the model, then decide again. */
|
|
36
|
+
| {
|
|
37
|
+
kind: 'ask-model';
|
|
38
|
+
claim: readonly QueuedInput[];
|
|
39
|
+
}
|
|
40
|
+
/** Ask the stop checks to judge the provisional answer. */
|
|
41
|
+
| {
|
|
42
|
+
kind: 'check';
|
|
43
|
+
}
|
|
44
|
+
/** Stop, for this reason. */
|
|
45
|
+
| {
|
|
46
|
+
kind: 'end';
|
|
47
|
+
reason: TurnEndReason;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* What a thread does next.
|
|
51
|
+
*
|
|
52
|
+
* A pure function of the view, so the whole of the loop's control flow is a truth table rather than
|
|
53
|
+
* something you need a model, a store and a clock to exercise. The loop is then: decide, do it,
|
|
54
|
+
* append what happened, decide again — which is why resuming needs no separate path. A journal that
|
|
55
|
+
* stops mid-turn produces a view like any other, and the same decision picks it up.
|
|
56
|
+
*
|
|
57
|
+
* Deliberately absent: what to do when a model call *fails*. A transient failure before any output
|
|
58
|
+
* is retried beneath the loop, by `ctx.llm`'s client under the provider's policy; one that still
|
|
59
|
+
* fails ends the turn, reported with its kind, and whether to run it again is the host's. Request
|
|
60
|
+
* middleware cannot retry: it may call `next()` once. A decider that could see a failure and ask
|
|
61
|
+
* again would spin on a provider outage, since the conversation it reads is unchanged by one.
|
|
62
|
+
*/
|
|
63
|
+
export declare function nextAction(view: DecisionView, limits: TurnLimits): Action;
|
|
64
|
+
/** Whether there is anything to do at all — the same decision, asked as a question. */
|
|
65
|
+
export declare const hasWork: (view: DecisionView, limits: TurnLimits) => boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A journal view, usable without constructing an execution runtime or activating plugins.
|
|
68
|
+
* `sentBack` says a stop check sent back the answer of a turn that opened by answering calls, so
|
|
69
|
+
* input waiting for a turn joins it batch by batch (`Inbox.peek`).
|
|
70
|
+
*/
|
|
71
|
+
export declare function decisionView(journal: Journal, threadId: string, target: InboxTarget, step: number, turn: number, sentBack?: boolean): DecisionView;
|
|
72
|
+
export declare function hasThreadWork(journal: Journal, threadId: string, limits: TurnLimits): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { InterruptionPolicy, JournalEvent, Seq } from '../records/journal.js';
|
|
2
|
+
import type { DeepReadonly } from '../util/json.js';
|
|
3
|
+
import type { ConversationMessage, ToolCall } from '../llm/primitives.js';
|
|
4
|
+
import type { Reducer } from './thread.js';
|
|
5
|
+
import { type WaitEntry } from './waits.js';
|
|
6
|
+
/**
|
|
7
|
+
* Calls dispatched and not yet answered, and the row that recorded the dispatch.
|
|
8
|
+
*
|
|
9
|
+
* Bookkeeping, not truth: what a turn still owes answers for is {@link unansweredToolCalls}, read
|
|
10
|
+
* off the conversation. This exists so a re-dispatched call can cite its original `tool/call` rather
|
|
11
|
+
* than recording a second one.
|
|
12
|
+
*/
|
|
13
|
+
export declare const dispatchedCalls: Reducer<Map<string, Seq>>;
|
|
14
|
+
/** One dispatch attempt of a call: its `tool/authorization` row, and what became of it. */
|
|
15
|
+
export type DispatchAttempt = {
|
|
16
|
+
/** The `tool/authorization` row: the attempt itself. */
|
|
17
|
+
seq: Seq;
|
|
18
|
+
/** The `tool/call` row the attempt dispatched. */
|
|
19
|
+
call_seq: Seq;
|
|
20
|
+
turn: number;
|
|
21
|
+
decision: JournalEvent<'tool/authorization'>['data']['decision'];
|
|
22
|
+
/** What the tool declared, at this attempt, a re-dispatch may do if the attempt is interrupted. */
|
|
23
|
+
policy: InterruptionPolicy;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The latest dispatch attempt of every call that has no result yet, by call id.
|
|
27
|
+
*
|
|
28
|
+
* An attempt is written immediately before the tool is invoked, so an allowed attempt with no
|
|
29
|
+
* result, from a turn that has since closed, of a call that did not suspend, is a call the process
|
|
30
|
+
* was cut off in: the tool may have begun. {@link abandonedAttempt} reads that; the policy recorded with the attempt
|
|
31
|
+
* decides what a re-dispatch may do. A new `tool/call` under a reused provider id starts a new call
|
|
32
|
+
* with no attempt; a result clears the call's attempt.
|
|
33
|
+
*/
|
|
34
|
+
export declare const dispatchAttempts: Reducer<Map<string, DispatchAttempt>>;
|
|
35
|
+
/**
|
|
36
|
+
* The attempt of `callId` that was abandoned, if any: allowed, so the tool may have begun;
|
|
37
|
+
* unanswered; of the `tool/call` row being dispatched now, not of an earlier call that reused the
|
|
38
|
+
* provider's id; of a call that is not suspended (`waits`), since a waiting call returned on purpose
|
|
39
|
+
* and one whose wait resolved is dispatched again from its recorded value, however often a crash
|
|
40
|
+
* cuts that dispatch off; and from a turn before `currentTurn`, so the process that made it is gone —
|
|
41
|
+
* every earlier turn is closed before a new one opens. Read before a new attempt is recorded, so the
|
|
42
|
+
* judgment is about the attempt that was cut off.
|
|
43
|
+
*/
|
|
44
|
+
export declare function abandonedAttempt(state: ReadonlyMap<string, DispatchAttempt>, waits: ReadonlyMap<Seq, WaitEntry>, callId: string, callSeq: Seq, currentTurn: number): DispatchAttempt | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Tool calls on the last assistant message that have no result yet.
|
|
47
|
+
*
|
|
48
|
+
* Derived from the conversation, not from `tool/call` rows, because the conversation is what a
|
|
49
|
+
* provider validates: a message holding calls must be followed by a result for each one. Calls are
|
|
50
|
+
* recorded one row at a time, so a hard kill part-way through that burst leaves a thread with fewer
|
|
51
|
+
* `tool/call` rows than the model asked for — nothing "pending", and a conversation nothing could
|
|
52
|
+
* answer. Reading the assistant message instead makes the two agree by construction.
|
|
53
|
+
*/
|
|
54
|
+
export declare function unansweredToolCalls(messages: readonly DeepReadonly<ConversationMessage>[]): DeepReadonly<ToolCall>[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReplacementRule } from './surface.js';
|
|
2
|
+
/** No thread has this id. */
|
|
3
|
+
export declare class UnknownThreadError extends ReferenceError {
|
|
4
|
+
readonly threadId: string;
|
|
5
|
+
constructor(threadId: string);
|
|
6
|
+
}
|
|
7
|
+
/** A fork was asked for at a row it cannot be cut at; nothing was appended. */
|
|
8
|
+
export declare class ForkCutError extends Error {
|
|
9
|
+
readonly threadId: string;
|
|
10
|
+
readonly seq: number;
|
|
11
|
+
constructor(threadId: string, seq: number, reason: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A replacement `replaceSurface` refused: it breaks a rule of the surface it would land on (see
|
|
15
|
+
* `judgeReplacement`). Nothing of its group was recorded. Distinct from any other failure, so a
|
|
16
|
+
* strategy can tell a plan the surface refused from a journal that could not write.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ReplacementRefusedError extends Error {
|
|
19
|
+
readonly index: number;
|
|
20
|
+
readonly rule: ReplacementRule;
|
|
21
|
+
constructor(message: string,
|
|
22
|
+
/** The refused replacement's position in the group it was offered with. */
|
|
23
|
+
index: number,
|
|
24
|
+
/** The surface rule it breaks. */
|
|
25
|
+
rule: ReplacementRule);
|
|
26
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Journal } from '../journal/index.js';
|
|
2
|
+
import type { Seq, TurnEndReason } from '../records/journal.js';
|
|
3
|
+
import type { RowRef } from './surface.js';
|
|
4
|
+
/**
|
|
5
|
+
* Where forks may be cut, and the lookups that find such a row from a turn or a reply. Journal
|
|
6
|
+
* reads only: forking never activates, leases or waits on the thread it forks.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Where "fork from here" cuts, along a thread's lineage: a turn's ending, or a replacement recorded
|
|
10
|
+
* between turns, such as a `compact()`, which a `turn/end` alone would miss. A replacement point
|
|
11
|
+
* carries the turn it followed, `null` when no turn had ended before it.
|
|
12
|
+
*/
|
|
13
|
+
export type ForkPoint = (RowRef & {
|
|
14
|
+
readonly kind: 'turn/end';
|
|
15
|
+
readonly turn: number;
|
|
16
|
+
readonly reason: TurnEndReason;
|
|
17
|
+
}) | (RowRef & {
|
|
18
|
+
readonly kind: 'surface/replaced';
|
|
19
|
+
readonly afterTurn: number | null;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Resolves `at` on `sourceId` to the row a fork is cut at, and the thread that owns it.
|
|
23
|
+
*
|
|
24
|
+
* The row must be of a cut kind and belong to the source's lineage; a row the source inherited is
|
|
25
|
+
* redirected to the thread that owns it, so the fork becomes that thread's. A pair must name the
|
|
26
|
+
* owner. The cut must also be settled (see {@link unsettled}).
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveCut(journal: Journal, sourceId: string, at: Seq | RowRef): RowRef;
|
|
29
|
+
/**
|
|
30
|
+
* The cut for forking at the turn that contains `anchor`: that turn's `turn/end`, or with `before`
|
|
31
|
+
* its `turn/start` — after what the turn started with was recorded, such as the prompt of a first
|
|
32
|
+
* turn, a mode switch and the turn's route, and before any of its input.
|
|
33
|
+
*
|
|
34
|
+
* An anchor inside a turn that has not ended is rejected rather than clipped back to the turn
|
|
35
|
+
* before; `before` has no such problem, since it cuts ahead of the turn's input.
|
|
36
|
+
*/
|
|
37
|
+
export declare function turnCut(journal: Journal, threadId: string, anchor: Seq | RowRef, before: boolean): RowRef;
|
|
38
|
+
/**
|
|
39
|
+
* Every `turn/end` along a thread's lineage that a fork can be cut at, and every replacement recorded
|
|
40
|
+
* between turns, oldest first, with the thread that owns each. A turn that ended with a call
|
|
41
|
+
* unanswered, or with an answer still owed its stop checks, is left out. A replacement recorded
|
|
42
|
+
* inside a turn is not listed: its turn's ending follows it. One pass: the two folds are replayed
|
|
43
|
+
* along the lineage as they go.
|
|
44
|
+
*/
|
|
45
|
+
export declare function forkPoints(journal: Journal, threadId: string): ForkPoint[];
|
|
46
|
+
/**
|
|
47
|
+
* The `llm/request` that produced the reply recorded at `row`: the request with the same
|
|
48
|
+
* `llm_call_id`, searched on the thread that owns the reply. `null` for a row that is not a reply.
|
|
49
|
+
*/
|
|
50
|
+
export declare function requestBehind(journal: Journal, row: RowRef): RowRef | null;
|
|
51
|
+
/**
|
|
52
|
+
* The request behind the conversation's latest reply — the one whose tool calls a step is
|
|
53
|
+
* answering, and so the row a tool that forks this thread cuts at. `null` before any reply. A
|
|
54
|
+
* stand-in in the assistant role is not a reply: no request is behind it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function latestReplyRequest(journal: Journal, threadId: string): RowRef | null;
|
|
57
|
+
/**
|
|
58
|
+
* The row of the conversation's latest reply: the `assistant/message` whose tool calls a step is
|
|
59
|
+
* answering, on a fork's source when the fork inherited it. `null` before any reply.
|
|
60
|
+
*/
|
|
61
|
+
export declare function latestReply(journal: Journal, threadId: string): RowRef | null;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Seq } from '../records/journal.js';
|
|
2
|
+
import type { ReadonlyState } from '../util/foldState.js';
|
|
3
|
+
import { type ReadonlyJsonValue } from '../util/json.js';
|
|
4
|
+
import type { RequestsState } from './requests.js';
|
|
5
|
+
/**
|
|
6
|
+
* Why a pending request does not run now. Every one is derived from recorded facts and live
|
|
7
|
+
* registrations, never stored:
|
|
8
|
+
*
|
|
9
|
+
* - `approval`: the thread's last turn ended blocked and a confirmation waits on it or under it;
|
|
10
|
+
* the answer releases it.
|
|
11
|
+
* - `failure`: the latest settlement failed and no releasing cause is pending.
|
|
12
|
+
* - `cancellation`: a person cancelled the thread, and no releasing cause came after.
|
|
13
|
+
* - `startup`: the startup policy declined the request at boot; a releasing cause releases it.
|
|
14
|
+
* - `missing`: a constraint owner the thread or a thread above it by origin requires is not
|
|
15
|
+
* registered, or its repair has not finished; or the callers above it cannot be read.
|
|
16
|
+
* - `wait`: a call of the thread waits on a dependency whose owner has not resolved it; only its
|
|
17
|
+
* resolution, or a cancel that answers the call, ends it. `deadline` is the owner's to act on.
|
|
18
|
+
* - `constraint`: a registered owner's constraint says not now, with the `code` and `data` it
|
|
19
|
+
* answered with; core stamps the `owner`.
|
|
20
|
+
* - `rejudge`: the judgment of the answer's stop checks was invalidated until the repair budget ran
|
|
21
|
+
* out; the answer stays owed its checks, and a releasing cause releases it.
|
|
22
|
+
* - `shutdown`: lagent is closing; the request stays pending for the next start.
|
|
23
|
+
*/
|
|
24
|
+
export type Hold = {
|
|
25
|
+
readonly reason: 'missing';
|
|
26
|
+
} | {
|
|
27
|
+
readonly reason: 'wait';
|
|
28
|
+
readonly callSeq: Seq;
|
|
29
|
+
readonly owner: string;
|
|
30
|
+
readonly ownerRegistered: boolean;
|
|
31
|
+
readonly deadline: number | null;
|
|
32
|
+
readonly text: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly reason: 'constraint';
|
|
35
|
+
readonly owner: string;
|
|
36
|
+
readonly code?: string;
|
|
37
|
+
readonly data?: ReadonlyJsonValue;
|
|
38
|
+
readonly text: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly reason: 'rejudge';
|
|
41
|
+
readonly text: string;
|
|
42
|
+
} | {
|
|
43
|
+
readonly reason: 'approval' | 'failure' | 'cancellation' | 'startup' | 'shutdown';
|
|
44
|
+
};
|
|
45
|
+
/** The reasons a hold can be read for while lagent runs: every one but `shutdown`. */
|
|
46
|
+
export type HoldReason = Exclude<Hold['reason'], 'shutdown'>;
|
|
47
|
+
/** The holds the folds and the catalog derive: those that neither a constraint nor a closing lagent made. */
|
|
48
|
+
export type DerivedHold = Exclude<Hold, {
|
|
49
|
+
readonly reason: 'constraint' | 'shutdown';
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Which look a hold was read from: `catalog`, the screening the catalog shows without loading the
|
|
53
|
+
* thread, or `loaded`, decided from the thread's folds.
|
|
54
|
+
*/
|
|
55
|
+
export type HoldBasis = 'catalog' | 'loaded';
|
|
56
|
+
/** Whether two holds say the same thing. */
|
|
57
|
+
export declare const sameHold: (a: Hold, b: Hold) => boolean;
|
|
58
|
+
/** What a hold says in words, for a reader that prints one: its text, or `null` when its reason says it all. */
|
|
59
|
+
export declare const holdText: (hold: Hold) => string | null;
|
|
60
|
+
/**
|
|
61
|
+
* What holds are derived from, read from the thread's folds or from its catalog entry, which record
|
|
62
|
+
* the same facts, and from the owner's registrations.
|
|
63
|
+
*/
|
|
64
|
+
export type HoldFacts = {
|
|
65
|
+
/** Whether the thread's last turn ended blocked and a confirmation waits on it or on a thread created under it. */
|
|
66
|
+
readonly approval: boolean;
|
|
67
|
+
/** Whether the latest settlement failed and no releasing cause is pending (`failureHeld`). */
|
|
68
|
+
readonly failed: boolean;
|
|
69
|
+
/** Whether a person's cancel holds the thread (`cancelHeld`). */
|
|
70
|
+
readonly cancelled: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the startup policy declined this request and no releasing cause landed since boot: the
|
|
73
|
+
* owner's to say, since a releasing cause recorded before the restart is one the policy judged.
|
|
74
|
+
*/
|
|
75
|
+
readonly startupDeclined: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The constraint owners the thread or a thread above it by origin requires that are not registered,
|
|
78
|
+
* or not repaired yet, with why; or that the callers above it cannot be read.
|
|
79
|
+
*/
|
|
80
|
+
readonly missing: readonly string[];
|
|
81
|
+
/**
|
|
82
|
+
* The thread's first wait that has not resolved, if any: its call, why it waits, its owner and
|
|
83
|
+
* deadline, and whether that owner is registered now.
|
|
84
|
+
*/
|
|
85
|
+
readonly unresolvedWait: {
|
|
86
|
+
readonly callSeq: Seq;
|
|
87
|
+
readonly reason: string;
|
|
88
|
+
readonly owner: string;
|
|
89
|
+
readonly deadlineAt: number | null;
|
|
90
|
+
readonly registered: boolean;
|
|
91
|
+
} | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The holds on a thread's pending request, in the order a decision reads them: the one rule both
|
|
95
|
+
* the folds' decision and the owner's catalog reading apply. A request that holds a releasing cause
|
|
96
|
+
* is past the failure, cancellation and startup holds; the approval hold yields only to the answer
|
|
97
|
+
* itself, and the wait hold to the resolution. A constraint's own `hold` is not derived here: the
|
|
98
|
+
* decision reads its verdict.
|
|
99
|
+
*/
|
|
100
|
+
export declare function deriveHolds(facts: HoldFacts): DerivedHold[];
|
|
101
|
+
/** Whether a failure holds the thread: its latest settlement failed and no releasing cause is pending. */
|
|
102
|
+
export declare function failureHeld(requests: ReadonlyState<RequestsState>): boolean;
|
|
103
|
+
/** Whether a person's cancel holds the thread: its latest `user` cancel has no releasing cause after it. */
|
|
104
|
+
export declare function cancelHeld(requests: ReadonlyState<RequestsState>): boolean;
|