@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,368 @@
|
|
|
1
|
+
import type { Seq, ThreadSummary } from '../../records/journal.js';
|
|
2
|
+
import type { JsonValue } from '../../util/json.js';
|
|
3
|
+
import type { ReadonlyJsonValue } from '../../util/json.js';
|
|
4
|
+
import { type Continuation, type ConstraintAnswer, type DecisionTurn, type Hold, type HoldBasis, type TurnLimits, type WaitDeclaration } from '../../state/index.js';
|
|
5
|
+
import type { Journal, OriginBreak } from '../../journal/index.js';
|
|
6
|
+
import type { Admission, AdmittedOperation, OperationKind } from './admission.js';
|
|
7
|
+
import { type RunEvent, type RunState } from './runEvents.js';
|
|
8
|
+
/**
|
|
9
|
+
* Which run requests pending at boot `start` runs, judged by the age of each request's newest
|
|
10
|
+
* cause: every one, none, or those newer than `newerThanMs`. The rest are held (`startup`) until a
|
|
11
|
+
* releasing cause.
|
|
12
|
+
*/
|
|
13
|
+
export type StartupPolicy = 'all' | 'none' | {
|
|
14
|
+
readonly newerThanMs: number;
|
|
15
|
+
};
|
|
16
|
+
export type StartOptions = {
|
|
17
|
+
readonly resume: StartupPolicy;
|
|
18
|
+
/** How many runs execute at once; the rest wait in memory, in order, for one to end. */
|
|
19
|
+
readonly startLimit: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A feature's registration as an owner: its say over when the threads it applies to run, and its
|
|
23
|
+
* part in startup. `owner` is the
|
|
24
|
+
* name a thread's `requires` lists; such a thread, and every thread created under it by origin, is
|
|
25
|
+
* held `missing` while no registration under it is ready. What a thread records in `requires` stays
|
|
26
|
+
* its own: a constraint's `applies` reads it, and only readiness passes down. `repair` runs at
|
|
27
|
+
* `start`, awaited before the startup policy classifies what is pending, so the causes it writes are
|
|
28
|
+
* judged with the rest; registered once started, it runs at once, and its causes are admitted like
|
|
29
|
+
* any later one. The owner's threads stay `missing` until it resolves, held with its error if it
|
|
30
|
+
* rejects; a rejection is reported and never fails `start`.
|
|
31
|
+
* `constraint`'s `applies` and `evaluate` are synchronous; a throw is a hold on that thread with the
|
|
32
|
+
* error as its reason. A registration with no `constraint` constrains no thread: one carrying only a
|
|
33
|
+
* `repair` is a startup participant, such as a feature firing the work that fell due while the
|
|
34
|
+
* process was down, or the owner of waits, whose repair resolves what was satisfied while the
|
|
35
|
+
* process was down.
|
|
36
|
+
*
|
|
37
|
+
* The registration is also what a call's wait names (`waitFor`'s `owner`): a call may declare one
|
|
38
|
+
* only while a registration under that owner is live, and only its handle resolves it.
|
|
39
|
+
*/
|
|
40
|
+
export type OwnerRegistration = {
|
|
41
|
+
readonly owner: string;
|
|
42
|
+
/** Which threads the registration governs, and what it says of each; none when omitted. */
|
|
43
|
+
readonly constraint?: {
|
|
44
|
+
applies(summary: ThreadSummary): boolean;
|
|
45
|
+
/** What it says about a thread it applies to. */
|
|
46
|
+
evaluate(threadId: string): ConstraintAnswer;
|
|
47
|
+
};
|
|
48
|
+
repair?(): Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* What `build` resolves a wait with: its `value`, a JSON object the owner versions and the waiting
|
|
52
|
+
* tool reads; the `chain` of the turn it asks for, `person` for a person's answer and `reactive`
|
|
53
|
+
* otherwise; and the rows the resolution cites as `evidence` beside the declaration.
|
|
54
|
+
*/
|
|
55
|
+
export type WaitValue = {
|
|
56
|
+
readonly value: {
|
|
57
|
+
readonly [key: string]: JsonValue;
|
|
58
|
+
};
|
|
59
|
+
readonly chain?: 'person';
|
|
60
|
+
readonly evidence?: readonly Seq[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* What `resolveWait` did: `resolved`; `declined` when `build` returned `null`; `resolved-before`
|
|
64
|
+
* with the value recorded first, which an answer-once check reports; `closed` when the call was
|
|
65
|
+
* answered without a value (cancelled, denied, aborted); `unknown` when no wait is declared for the
|
|
66
|
+
* call (yet), or one is, under another owner.
|
|
67
|
+
*/
|
|
68
|
+
export type WaitResolution = {
|
|
69
|
+
readonly status: 'resolved';
|
|
70
|
+
} | {
|
|
71
|
+
readonly status: 'declined';
|
|
72
|
+
} | {
|
|
73
|
+
readonly status: 'resolved-before';
|
|
74
|
+
readonly value: {
|
|
75
|
+
readonly [key: string]: ReadonlyJsonValue;
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
78
|
+
readonly status: 'closed';
|
|
79
|
+
} | {
|
|
80
|
+
readonly status: 'unknown';
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* An owner registration's handle: `changed` asks for the thread to be evaluated again; `dispose` withdraws
|
|
84
|
+
* it. `resolveWait` resolves a wait a call of `threadId` declared under this registration's owner,
|
|
85
|
+
* in one write on that thread: `build`, run inside it with the declaration, gives the value, and the
|
|
86
|
+
* write records it with an inputless cause that releases nothing, so the call is dispatched again
|
|
87
|
+
* once nothing else holds the thread. Racing resolutions serialize: the first wins. A disposed
|
|
88
|
+
* handle refuses it.
|
|
89
|
+
*/
|
|
90
|
+
export type OwnerHandle = {
|
|
91
|
+
changed(threadId: string): void;
|
|
92
|
+
resolveWait(wait: {
|
|
93
|
+
readonly threadId: string;
|
|
94
|
+
readonly callSeq: Seq;
|
|
95
|
+
}, build: (declaration: WaitDeclaration) => WaitValue | null): Promise<WaitResolution>;
|
|
96
|
+
dispose(): void;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* A constraint owner a thread's run needs that is not ready: `absent` when no registration serves
|
|
100
|
+
* it, `repairing` until its repair finishes, `failed` with why when that repair failed.
|
|
101
|
+
* `introducedBy` is the threads that require it: the thread itself, or callers above it.
|
|
102
|
+
*/
|
|
103
|
+
export type OwnerReadiness = {
|
|
104
|
+
readonly owner: string;
|
|
105
|
+
readonly state: 'absent' | 'repairing' | {
|
|
106
|
+
readonly failed: string;
|
|
107
|
+
};
|
|
108
|
+
readonly introducedBy: readonly string[];
|
|
109
|
+
};
|
|
110
|
+
/** What stands behind a `missing` hold: the owners not ready, and whether the callers above it could be read. */
|
|
111
|
+
export type MissingDetail = {
|
|
112
|
+
readonly owners: readonly OwnerReadiness[];
|
|
113
|
+
readonly chain: 'complete' | OriginBreak;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Where a thread stands, from `threads.inspect`: `idle` with no run pending; `requested` while its
|
|
117
|
+
* pending run waits to be admitted, a failed attempt to prepare it included, which backs off before
|
|
118
|
+
* the next; `running` while an execution serves it; `held` with `hold`. `operation` names an
|
|
119
|
+
* exclusive operation other than a run holding the thread now. `missing` says what is behind a
|
|
120
|
+
* `missing` hold and is `null` for any other. `approvalBlocked` is a screening read from the
|
|
121
|
+
* catalog whatever the state: the thread's last turn ended blocked and a confirmation waits on it
|
|
122
|
+
* or on a thread created under it. The run's actual hold (`approval`) is decided from the thread's
|
|
123
|
+
* folds, which can pass an answer the screening still counts. `basis` is the look it was computed on.
|
|
124
|
+
*/
|
|
125
|
+
export type ThreadInspection = {
|
|
126
|
+
readonly state: 'idle' | 'requested' | 'running' | 'held';
|
|
127
|
+
readonly operation: Exclude<OperationKind, 'run'> | null;
|
|
128
|
+
readonly hold: Hold | null;
|
|
129
|
+
readonly missing: MissingDetail | null;
|
|
130
|
+
readonly approvalBlocked: boolean;
|
|
131
|
+
readonly basis: HoldBasis;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* One execution of a run request, the owner's record of it from admission to the publication of
|
|
135
|
+
* where the run stands: what its finalization settles the run by, and the decision it asks as it
|
|
136
|
+
* goes. `execute` records on it as it decides; the finalization and the publication read it.
|
|
137
|
+
*/
|
|
138
|
+
export type RunExecution = {
|
|
139
|
+
readonly runId: string;
|
|
140
|
+
/**
|
|
141
|
+
* The journal's head as the execution was admitted; a recovered ending's execution's, when the run
|
|
142
|
+
* settles from that ending.
|
|
143
|
+
*/
|
|
144
|
+
attemptCutoff: Seq;
|
|
145
|
+
/** The last continuation decision: what the finalization settles by, unless a cancel captured it. */
|
|
146
|
+
final: Continuation | null;
|
|
147
|
+
/** Why the run failed in setup, for its settlement. */
|
|
148
|
+
errorText: string | null;
|
|
149
|
+
/**
|
|
150
|
+
* The continuation decision for the run, for the cancel that captured the operation serving it:
|
|
151
|
+
* asked at the execution's entry, after every turn and when an abort ends it.
|
|
152
|
+
*/
|
|
153
|
+
readonly decide: (turn: DecisionTurn) => Continuation;
|
|
154
|
+
};
|
|
155
|
+
/** What the owner needs of the threads service. */
|
|
156
|
+
export type OwnerHost = {
|
|
157
|
+
readonly journal: Journal;
|
|
158
|
+
readonly admission: Admission;
|
|
159
|
+
/** Aborts once lagent is closing. */
|
|
160
|
+
readonly signal: AbortSignal;
|
|
161
|
+
/**
|
|
162
|
+
* The execution of `run` under its admitted `operation`: the entry decision, the turns it opens
|
|
163
|
+
* and the decision after the last, recorded on `run`. A failure before it opens a turn is its
|
|
164
|
+
* setup's, which settles the run failed and resolves; only a failure past its setup rejects.
|
|
165
|
+
*/
|
|
166
|
+
execute(run: RunExecution, operation: AdmittedOperation): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* The operation's cleanup, still under its admission: releases the activation a failed or stale
|
|
169
|
+
* setup left, which could not be released while the operation held the thread.
|
|
170
|
+
*/
|
|
171
|
+
cleanup(operation: AdmittedOperation): Promise<void> | undefined;
|
|
172
|
+
/** Loads what an execution of the thread reads and keeps it held, under the application's retention policy. */
|
|
173
|
+
retain(threadId: string): Promise<{
|
|
174
|
+
release(): void;
|
|
175
|
+
}>;
|
|
176
|
+
report(error: unknown): void;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* The one owner of when threads run: it admits a thread's pending run request once nothing holds
|
|
180
|
+
* it, runs the request's envelope (the execution through the threads service, its finalization
|
|
181
|
+
* under the same admission) and publishes each run's state. It makes every continuation decision,
|
|
182
|
+
* from the folds and the registered constraints. Nothing is admitted before `start`. A committed
|
|
183
|
+
* write, an operation settling or a constraint's `changed` re-evaluates the threads it touches,
|
|
184
|
+
* coalesced on a microtask, reading the catalog first and loading a thread only when it may be
|
|
185
|
+
* eligible; the decision is made again, authoritatively and with nothing awaited before admission,
|
|
186
|
+
* once the thread is loaded. A thread that failed to load backs off before the next try.
|
|
187
|
+
*/
|
|
188
|
+
export declare class RunOwner {
|
|
189
|
+
private started;
|
|
190
|
+
private starting;
|
|
191
|
+
private limit;
|
|
192
|
+
/** Runs executing that count against the limit. */
|
|
193
|
+
private counted;
|
|
194
|
+
/** Threads the startup policy declined, until a releasing cause lands on them. */
|
|
195
|
+
private readonly startupDeclined;
|
|
196
|
+
private readonly owners;
|
|
197
|
+
/** The serial the next registration gets. */
|
|
198
|
+
private nextSerial;
|
|
199
|
+
private readonly dirty;
|
|
200
|
+
private scheduled;
|
|
201
|
+
/** Threads being loaded for admission. */
|
|
202
|
+
private readonly admitting;
|
|
203
|
+
/** Every admission from its entry to the end of its cleanup, which shutdown waits for. */
|
|
204
|
+
private readonly preparations;
|
|
205
|
+
/** The execution serving each executing thread's run. */
|
|
206
|
+
private readonly executing;
|
|
207
|
+
/** Threads waiting for a slot under the limit, in order. */
|
|
208
|
+
private readonly waiting;
|
|
209
|
+
/** The hold last decided for each thread's pending run, which its state reads and its events say. */
|
|
210
|
+
private readonly holds;
|
|
211
|
+
private readonly listeners;
|
|
212
|
+
/** The threads whose pending run failed to be prepared for admission, and their backoff. */
|
|
213
|
+
private readonly preparation;
|
|
214
|
+
private readonly host;
|
|
215
|
+
private readonly limits;
|
|
216
|
+
constructor(host: OwnerHost, limits: TurnLimits);
|
|
217
|
+
/** Starts admitting; see `Threads.start`. */
|
|
218
|
+
start(options: StartOptions): Promise<void>;
|
|
219
|
+
registerOwner(registration: OwnerRegistration): OwnerHandle;
|
|
220
|
+
private repair;
|
|
221
|
+
/**
|
|
222
|
+
* Decides again every thread requiring `owner`, itself or through a thread above it by origin, or
|
|
223
|
+
* with a call waiting on it, resolved or not, whose registration or repair changed: a resolved call
|
|
224
|
+
* waiting to be dispatched again is not stranded. A change worth a new look does not wait out a
|
|
225
|
+
* preparation's backoff.
|
|
226
|
+
*/
|
|
227
|
+
private scheduleRequiring;
|
|
228
|
+
/** Whether a registration under `owner` is live now. */
|
|
229
|
+
isRegistered(owner: string): boolean;
|
|
230
|
+
/** `OwnerHandle.resolveWait` for a live registration under `owner`. */
|
|
231
|
+
private resolveWait;
|
|
232
|
+
/**
|
|
233
|
+
* Re-evaluates the thread a row landed on, and the threads above it, whose holds can read it. A
|
|
234
|
+
* releasing cause re-authorizes the subtree the startup policy declined under the thread: each
|
|
235
|
+
* thread in it is decided again, which never overrides a person's stop of a child, a cancellation
|
|
236
|
+
* hold or a stopped task, neither of which is the startup decline. A releasing cause on the
|
|
237
|
+
* thread, and the release of a descendant's decline, forget a preparation's backoff: a person
|
|
238
|
+
* asked, or what held the thread is gone. Any other row waits it out.
|
|
239
|
+
*/
|
|
240
|
+
onRow(threadId: string, row: {
|
|
241
|
+
readonly type: string;
|
|
242
|
+
readonly data: unknown;
|
|
243
|
+
}): void;
|
|
244
|
+
/**
|
|
245
|
+
* An operation on the thread settled, published as it released the thread: a run an execution
|
|
246
|
+
* served is held or settled to its waiters from this moment; and the thread is looked at again.
|
|
247
|
+
*/
|
|
248
|
+
onSettled(threadId: string, kind: OperationKind): void;
|
|
249
|
+
/** Resolves once every admission begun has finished, its cleanup included; none begins once closing. */
|
|
250
|
+
whenIdle(): Promise<void>;
|
|
251
|
+
/** Tells every waiter on a pending run that lagent is closing. */
|
|
252
|
+
close(): void;
|
|
253
|
+
onRunEvent(listener: (event: RunEvent) => void): () => void;
|
|
254
|
+
runState(threadId: string, runId: string): RunState | null;
|
|
255
|
+
/**
|
|
256
|
+
* Where the thread stands, `null` for a thread the catalog does not hold. Admits nothing, changes
|
|
257
|
+
* no backoff and publishes nothing. On the `loaded` basis the thread and the callers above it must
|
|
258
|
+
* be loaded, and the hold is decided from their folds; otherwise it throws.
|
|
259
|
+
*/
|
|
260
|
+
inspect(threadId: string, basis: HoldBasis): ThreadInspection | null;
|
|
261
|
+
/** The `loaded` basis needs what a run reads: the thread and every caller above it, in memory. */
|
|
262
|
+
private requireLoaded;
|
|
263
|
+
/**
|
|
264
|
+
* The hold admission would record for the thread's pending run now: the entry continuation
|
|
265
|
+
* decision, from the folds, that `admit` asks. A decision that advances, repairs or settles the
|
|
266
|
+
* run is no hold; none either while the run is being admitted.
|
|
267
|
+
*/
|
|
268
|
+
private loadedHold;
|
|
269
|
+
/**
|
|
270
|
+
* Whether the thread's last turn ended blocked and a confirmation waits on it or under it: the
|
|
271
|
+
* one rule of the approval screening, from the catalog, which `inspect` reports and the owner's
|
|
272
|
+
* look at a pending run applies. It scans the thread's subtree only for a blocked ending.
|
|
273
|
+
*/
|
|
274
|
+
private approvalBlocked;
|
|
275
|
+
/**
|
|
276
|
+
* Where the idle pending run `runId` stands, the one rule `runState` and `inspect` read: the hold
|
|
277
|
+
* decided for it; none while it is being loaded to be admitted, or is about to be decided whatever
|
|
278
|
+
* the catalog holds (obsolete, or captured by a cancel a crash left unsettled); otherwise the hold
|
|
279
|
+
* the catalog shows, then the constraint's, as `consider` would record them; or none, requested.
|
|
280
|
+
*/
|
|
281
|
+
private idleHold;
|
|
282
|
+
/** Whether the startup policy declined the thread's pending run, and nothing released it since. */
|
|
283
|
+
private declined;
|
|
284
|
+
/**
|
|
285
|
+
* The constraint owners the thread's run needs that are not registered and repaired, with why: what
|
|
286
|
+
* its own `requires` names and what every thread above it by origin requires, read from the
|
|
287
|
+
* catalog. Only readiness is inherited, never a caller's holds or what its constraints say. A
|
|
288
|
+
* caller chain that stops short of its root, at a caller the catalog does not hold or a cycle,
|
|
289
|
+
* cannot say what is required, and holds the thread.
|
|
290
|
+
*/
|
|
291
|
+
private missing;
|
|
292
|
+
/** The owners `missing` counts, not ready, with the threads that require each, and the chain read. */
|
|
293
|
+
private missingDetail;
|
|
294
|
+
/**
|
|
295
|
+
* The registrations the thread's run needs, as one token: every owner its own `requires` names
|
|
296
|
+
* or a thread above it by origin requires, each with the registration serving it. Equal tokens
|
|
297
|
+
* mean the same registrations, all ready; `null` while one is missing. What a judged turn ending
|
|
298
|
+
* is fenced on (`LoopServices.requiredRegistrations`): a registration that left or was replaced
|
|
299
|
+
* during the judgment may be a checker that did not judge the answer.
|
|
300
|
+
*/
|
|
301
|
+
requiredRegistrations(threadId: string): string | null;
|
|
302
|
+
/**
|
|
303
|
+
* What the registered constraints that apply to the thread say, combined, a hold stamped with the
|
|
304
|
+
* owner that gave it; `allow` with none.
|
|
305
|
+
*/
|
|
306
|
+
private verdict;
|
|
307
|
+
/**
|
|
308
|
+
* The continuation decision for the thread's pending run, from its folds and catalog as they
|
|
309
|
+
* stand: how the last turn ended (`ending`, opened at `start`), the holds derived on it, what the
|
|
310
|
+
* registered constraints say, and the cancel that captured the execution (`cancel`), or that a
|
|
311
|
+
* crash left recorded against the run. The one place a run's next step is decided: before
|
|
312
|
+
* admitting it, at an execution's entry, after each turn and as it lets go.
|
|
313
|
+
*/
|
|
314
|
+
private decide;
|
|
315
|
+
/** The decision for the thread's pending run as no execution serves it, from where its last turn stands. */
|
|
316
|
+
private entryDecision;
|
|
317
|
+
/** The holds on the thread's pending request, derived from its folds as `deriveHolds` orders them. */
|
|
318
|
+
private derivedHolds;
|
|
319
|
+
private schedule;
|
|
320
|
+
/** From the catalog: leaves the thread, holds it, queues it for a slot, or loads it to admit it. */
|
|
321
|
+
private consider;
|
|
322
|
+
/**
|
|
323
|
+
* The first hold the catalog alone shows, by the order the folds' decision reads them
|
|
324
|
+
* (`deriveHolds`), or `null` when the thread may be eligible.
|
|
325
|
+
*/
|
|
326
|
+
private catalogHold;
|
|
327
|
+
/**
|
|
328
|
+
* Loads what the thread's run reads, decides again from the folds, and admits the pending run
|
|
329
|
+
* with nothing awaited between that decision and the admission; then serves it, finalizes it
|
|
330
|
+
* under its admission and, once the execution has let the thread go, publishes where the run
|
|
331
|
+
* stands and looks at the thread again. The reads stay held until all of that is done.
|
|
332
|
+
*/
|
|
333
|
+
private admit;
|
|
334
|
+
/**
|
|
335
|
+
* An execution's finalization, under its admission: settles the run as its last decision said,
|
|
336
|
+
* in one write with the successor request its residual causes open. The settlement is built
|
|
337
|
+
* inside the write, which is the irrevocable boundary: a cancel that captured the execution before
|
|
338
|
+
* then settles it by the cancel's intent, whatever was decided, a hold included; after, what was
|
|
339
|
+
* built stands, and a cancel that captures it later has admission finalize it again, which settles
|
|
340
|
+
* a run the build left pending. A run settled meanwhile, or left pending (a hold, a shutdown),
|
|
341
|
+
* writes nothing.
|
|
342
|
+
*/
|
|
343
|
+
private finalize;
|
|
344
|
+
/**
|
|
345
|
+
* Records a failed preparation of the thread's pending run and looks at the thread again once its
|
|
346
|
+
* backoff is due, from half a second to a minute, so a store that fails to read is neither given
|
|
347
|
+
* up on nor hammered. Until then `consider` admits nothing: no row retries it, but the causes
|
|
348
|
+
* listed at `forgetPreparation`'s callers.
|
|
349
|
+
*/
|
|
350
|
+
private retryLater;
|
|
351
|
+
/** Forgets the thread's preparation failures and its pending retry: the next look may admit it at once. */
|
|
352
|
+
private forgetPreparation;
|
|
353
|
+
/** Publishes where a run stands once its execution let the thread go. */
|
|
354
|
+
private afterExecution;
|
|
355
|
+
/**
|
|
356
|
+
* Records a hold, and publishes it unless it is the one already published (`always` publishes it
|
|
357
|
+
* again). Published as read from the folds (`loaded`) when it stands as decided or `basis` says
|
|
358
|
+
* so, from the catalog otherwise.
|
|
359
|
+
*/
|
|
360
|
+
private hold;
|
|
361
|
+
/** Forgets a decided hold of `reason` on the thread, so the next look decides again. */
|
|
362
|
+
private forgetDecided;
|
|
363
|
+
/** Starts what waits for a slot, in order, while slots are free. */
|
|
364
|
+
private drain;
|
|
365
|
+
private durable;
|
|
366
|
+
private publishState;
|
|
367
|
+
private publish;
|
|
368
|
+
}
|