@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,261 @@
|
|
|
1
|
+
import type { Context } from '@leuduan/cordis';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type PluginJournal } from '../../journal/index.js';
|
|
4
|
+
import type { ExtensionRecord, Seq } from '../../records/journal.js';
|
|
5
|
+
import { type TaskRef, type TaskState } from './record.js';
|
|
6
|
+
import type { DeepReadonly } from '../../util/json.js';
|
|
7
|
+
/** The most a notice quotes of what a blocking call would have returned; its closing hint comes on top. */
|
|
8
|
+
export declare const NOTICE_TEXT_CHARS = 8000;
|
|
9
|
+
declare const NoticeDataSchema: z.ZodObject<{
|
|
10
|
+
task_id: z.ZodString;
|
|
11
|
+
thread_id: z.ZodString;
|
|
12
|
+
status: z.ZodEnum<{
|
|
13
|
+
completed: "completed";
|
|
14
|
+
failed: "failed";
|
|
15
|
+
}>;
|
|
16
|
+
summary: z.ZodString;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
/** What a notice's source carries. */
|
|
19
|
+
export type NoticeData = z.output<typeof NoticeDataSchema>;
|
|
20
|
+
/**
|
|
21
|
+
* The source of a completion notice: the input the delegations service queues on a caller when one
|
|
22
|
+
* of its background tasks completes or fails. Its `summary` is one bounded line, such as
|
|
23
|
+
* `explore t1/42/0 completed`, for a host to show collapsed and for compaction to read.
|
|
24
|
+
*/
|
|
25
|
+
export declare const noticeEvent: {
|
|
26
|
+
record: (value: {
|
|
27
|
+
task_id: string;
|
|
28
|
+
thread_id: string;
|
|
29
|
+
status: "completed" | "failed";
|
|
30
|
+
summary: string;
|
|
31
|
+
}) => ExtensionRecord;
|
|
32
|
+
parse: (value: {
|
|
33
|
+
task_id: string;
|
|
34
|
+
thread_id: string;
|
|
35
|
+
status: "completed" | "failed";
|
|
36
|
+
summary: string;
|
|
37
|
+
}) => {
|
|
38
|
+
task_id: string;
|
|
39
|
+
thread_id: string;
|
|
40
|
+
status: "completed" | "failed";
|
|
41
|
+
summary: string;
|
|
42
|
+
};
|
|
43
|
+
entry: (value: {
|
|
44
|
+
task_id: string;
|
|
45
|
+
thread_id: string;
|
|
46
|
+
status: "completed" | "failed";
|
|
47
|
+
summary: string;
|
|
48
|
+
}, options: import("../../journal/journal.js").AppendOptions) => {
|
|
49
|
+
type: "ext";
|
|
50
|
+
data: {
|
|
51
|
+
plugin: string;
|
|
52
|
+
instance_id: string;
|
|
53
|
+
kind: string;
|
|
54
|
+
version: number;
|
|
55
|
+
data: z.core.util.JSONType;
|
|
56
|
+
};
|
|
57
|
+
options: import("../../journal/journal.js").AppendOptions;
|
|
58
|
+
};
|
|
59
|
+
append(journal: PluginJournal, value: {
|
|
60
|
+
task_id: string;
|
|
61
|
+
thread_id: string;
|
|
62
|
+
status: "completed" | "failed";
|
|
63
|
+
summary: string;
|
|
64
|
+
}, options: import("../../journal/journal.js").AppendOptions): Promise<import("../../records/journal.js").JournalEvent<"ext">>;
|
|
65
|
+
read(event: import("../../records/journal.js").JournalEvent): {
|
|
66
|
+
task_id: string;
|
|
67
|
+
thread_id: string;
|
|
68
|
+
status: "completed" | "failed";
|
|
69
|
+
summary: string;
|
|
70
|
+
} | undefined;
|
|
71
|
+
contribution(message: {
|
|
72
|
+
role?: import("../../records/journal.js").InputRole;
|
|
73
|
+
content: string | readonly import("../../llm/content.js").ContentPartInput[];
|
|
74
|
+
}, value: {
|
|
75
|
+
task_id: string;
|
|
76
|
+
thread_id: string;
|
|
77
|
+
status: "completed" | "failed";
|
|
78
|
+
summary: string;
|
|
79
|
+
}, options?: {
|
|
80
|
+
sourceSeqs?: readonly Seq[];
|
|
81
|
+
}): import("../../records/journal.js").StepContribution;
|
|
82
|
+
matchesSource(record: DeepReadonly<ExtensionRecord>): boolean;
|
|
83
|
+
rejection(reason: string, value: {
|
|
84
|
+
task_id: string;
|
|
85
|
+
thread_id: string;
|
|
86
|
+
status: "completed" | "failed";
|
|
87
|
+
summary: string;
|
|
88
|
+
}): {
|
|
89
|
+
decision: "reject";
|
|
90
|
+
reason: string;
|
|
91
|
+
source: ExtensionRecord;
|
|
92
|
+
};
|
|
93
|
+
readContribution: (event: import("../../records/journal.js").JournalEvent) => {
|
|
94
|
+
task_id: string;
|
|
95
|
+
thread_id: string;
|
|
96
|
+
status: "completed" | "failed";
|
|
97
|
+
summary: string;
|
|
98
|
+
} | undefined;
|
|
99
|
+
readSource: (source: DeepReadonly<ExtensionRecord> | null) => {
|
|
100
|
+
task_id: string;
|
|
101
|
+
thread_id: string;
|
|
102
|
+
status: "completed" | "failed";
|
|
103
|
+
summary: string;
|
|
104
|
+
} | undefined;
|
|
105
|
+
told: import("../../journal/projection.js").PluginProjection<import("../../services/extensionEvents.js").ToldNotices<{
|
|
106
|
+
task_id: string;
|
|
107
|
+
thread_id: string;
|
|
108
|
+
status: "completed" | "failed";
|
|
109
|
+
summary: string;
|
|
110
|
+
}>>;
|
|
111
|
+
projection<State>(fold: {
|
|
112
|
+
key: string;
|
|
113
|
+
init(): State;
|
|
114
|
+
apply(state: State, value: {
|
|
115
|
+
task_id: string;
|
|
116
|
+
thread_id: string;
|
|
117
|
+
status: "completed" | "failed";
|
|
118
|
+
summary: string;
|
|
119
|
+
}, event: import("../../records/journal.js").JournalEvent<"ext">): State;
|
|
120
|
+
onFork?: "inherit" | "reset";
|
|
121
|
+
}): import("../../journal/projection.js").PluginProjection<State>;
|
|
122
|
+
};
|
|
123
|
+
/** What a notice's source carries, when `source` is one; `undefined` for any other. For a host drawing the notice. */
|
|
124
|
+
export declare const readNotice: (source: DeepReadonly<ExtensionRecord> | null) => NoticeData | undefined;
|
|
125
|
+
/** The notice's input id on the caller, derived from the task, so a redelivery queues nothing. */
|
|
126
|
+
export declare const noticeInputId: (taskId: string) => string;
|
|
127
|
+
/** A notice, ready to send: whom it goes to, for which task, its text and its source's data. */
|
|
128
|
+
export type Notice = {
|
|
129
|
+
readonly callerId: string;
|
|
130
|
+
readonly callSeq: Seq;
|
|
131
|
+
readonly taskId: string;
|
|
132
|
+
readonly text: string;
|
|
133
|
+
readonly source: NoticeData;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* The notice for a background task that settled: what a blocking call would have returned, bounded,
|
|
137
|
+
* framed as an `agent_notification` naming the child, the task, its agent and its status, with a
|
|
138
|
+
* closing hint naming `message_agent` and the thread when the child can be continued.
|
|
139
|
+
*/
|
|
140
|
+
export declare function composeNotice(task: {
|
|
141
|
+
readonly callerId: string;
|
|
142
|
+
readonly callSeq: Seq;
|
|
143
|
+
readonly childId: string;
|
|
144
|
+
readonly taskId: string;
|
|
145
|
+
readonly agent: string;
|
|
146
|
+
readonly status: 'completed' | 'failed';
|
|
147
|
+
readonly output: string;
|
|
148
|
+
readonly continuable: boolean;
|
|
149
|
+
}): Notice;
|
|
150
|
+
/**
|
|
151
|
+
* Where a background task's notice stands on its caller, by the one notice-debt predicate that
|
|
152
|
+
* sending, the successor rule, `resume` and the stop check all read. A notice is debt
|
|
153
|
+
* while it is **owed**, **unspent** and **unclaimed** (`unsent` or `queued`):
|
|
154
|
+
*
|
|
155
|
+
* - owed: the task's receipt is durable on the caller, and the caller's task its opening call
|
|
156
|
+
* addressed, the latest whose `started` row precedes that call (the receiver), is open; a root
|
|
157
|
+
* caller has none and is always owed, and a thread made by hand under another, which has none
|
|
158
|
+
* either, is never owed: delegations wakes no thread it does not manage but a root.
|
|
159
|
+
* `pending-receipt` while the call has no result yet; `unowed` once its result is not the
|
|
160
|
+
* receipt, or the receiver has ended, for good;
|
|
161
|
+
* - unclaimed and unspent, by its input's fate on the caller (`inputFate`): its id is not known
|
|
162
|
+
* there (`unsent`), or it is still queued (`queued`); once a step took it, `claimed`; a notice
|
|
163
|
+
* discarded unread, withdrawn or cleared by a cancel, keeps its id known and is `spent`.
|
|
164
|
+
*
|
|
165
|
+
* Reads the caller's rows and folds, so the caller must be loaded: inside its own write, its turn,
|
|
166
|
+
* or a read of it.
|
|
167
|
+
*/
|
|
168
|
+
export type NoticeStanding = 'pending-receipt' | 'unowed' | 'unsent' | 'queued' | 'claimed' | 'spent';
|
|
169
|
+
export declare function noticeStanding(journal: PluginJournal, task: {
|
|
170
|
+
readonly callerId: string;
|
|
171
|
+
readonly callSeq: Seq;
|
|
172
|
+
readonly taskId: string;
|
|
173
|
+
}): NoticeStanding;
|
|
174
|
+
/**
|
|
175
|
+
* Where the notice of task `taskId` stands on `callerId`, or `null` when that thread did not open
|
|
176
|
+
* the task by a call of its own: the id names another caller, or no call. The one way a caller asks
|
|
177
|
+
* about a task it knows by id; the caller must be loaded, as for {@link noticeStanding}.
|
|
178
|
+
*/
|
|
179
|
+
export declare function ownNoticeStanding(journal: PluginJournal, callerId: string, taskId: string): NoticeStanding | null;
|
|
180
|
+
/** Whether a notice that stands so is still debt: owed, unspent and unclaimed. */
|
|
181
|
+
export declare const isNoticeDebt: (standing: NoticeStanding) => boolean;
|
|
182
|
+
/** Whether a notice that stands so can never be debt again. */
|
|
183
|
+
export declare const noticeSettled: (standing: NoticeStanding) => boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Notice delivery, for the delegations service: the one path a background task's notice takes to
|
|
186
|
+
* its caller, and the withdrawal of notices no longer owed. Settling a task, its receipt landing,
|
|
187
|
+
* the successor rule, a wait and `resume` all deliver through `deliver`.
|
|
188
|
+
*
|
|
189
|
+
* The ordering it keeps: `afterEnding` runs in the listener of the write that ended a turn or
|
|
190
|
+
* settled a run, and enqueues there, before a run that goes round again can claim one, the
|
|
191
|
+
* withdrawal of the notices that write left unowed; and `deliver` enqueues its send synchronously when the child is loaded, as
|
|
192
|
+
* it is in that listener, with nothing awaited at its entrance, so the notice is ordered ahead of
|
|
193
|
+
* every write enqueued after the settle.
|
|
194
|
+
*/
|
|
195
|
+
export declare class NoticeDelivery {
|
|
196
|
+
/**
|
|
197
|
+
* Background tasks whose notice this process found queued, claimed, discarded or no longer owed:
|
|
198
|
+
* nothing is left to send for them, so `resume` does not read them again.
|
|
199
|
+
*/
|
|
200
|
+
private readonly noticed;
|
|
201
|
+
private readonly ctx;
|
|
202
|
+
constructor(ctx: Context);
|
|
203
|
+
/**
|
|
204
|
+
* A turn ended or a run settled on `threadId`, either of which may have settled its latest task. A background task that
|
|
205
|
+
* completed or failed has its notice sent to its caller, enqueued here, in the listener of the
|
|
206
|
+
* write that settled it; and a delegated thread whose own task settled withdraws the notices still
|
|
207
|
+
* queued on it, which their receiver no longer owes anyone.
|
|
208
|
+
*/
|
|
209
|
+
afterEnding(threadId: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* The one delivery path of a notice: composed from the child, then one `send` on the caller under
|
|
212
|
+
* the notice's id and source, whose write-time check is the notice-debt predicate, so a notice not
|
|
213
|
+
* owed is refused inside the write and a redelivery queues nothing. Enqueued synchronously when the
|
|
214
|
+
* child is loaded, as it is in the listener of the write that settled its task; otherwise once the
|
|
215
|
+
* child is read.
|
|
216
|
+
*/
|
|
217
|
+
deliver(childId: string, taskId: string): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* The successor rule's half: sends the notice of `childId`'s latest task, and returns where it
|
|
220
|
+
* stands on the caller then, or `null` when the task gets no notice.
|
|
221
|
+
*/
|
|
222
|
+
deliverLatest(childId: string): Promise<NoticeStanding | null>;
|
|
223
|
+
/**
|
|
224
|
+
* Withdraws the notices queued on `threadId` that are no longer owed: what the live settle does,
|
|
225
|
+
* for a crash that came between a receiver's settling and that withdrawal. `resume` and a
|
|
226
|
+
* continuation, before it opens a new task on the thread, both ask for it.
|
|
227
|
+
*/
|
|
228
|
+
withdrawExpired(threadId: string): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Makes the notices of settled tasks a read returns on durable, through the one delivery path,
|
|
231
|
+
* which is idempotent and gated on the receipt: it sends the notice a crash left
|
|
232
|
+
* unsent, and for a live settle, whose send the settling write's listener already enqueued, its
|
|
233
|
+
* own send queues behind that one and finds it known. A failure is reported, and the read still
|
|
234
|
+
* returns.
|
|
235
|
+
*/
|
|
236
|
+
durable(ended: readonly {
|
|
237
|
+
readonly task: TaskRef;
|
|
238
|
+
readonly state: TaskState | 'unavailable' | 'superseded';
|
|
239
|
+
}[]): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* `resume`'s notice work under `under`: withdraws the notices no longer owed that a crash between
|
|
242
|
+
* a settle and its withdrawal left queued, and sends those a crash between a settle and its notice
|
|
243
|
+
* left unsent, reading a child whose task state the catalog cannot give from its rows. Returns each
|
|
244
|
+
* write, failures reported.
|
|
245
|
+
*/
|
|
246
|
+
resume(under: string): Promise<unknown>[];
|
|
247
|
+
/**
|
|
248
|
+
* The input queued on the loaded `threadId` that no one is owed any more: notices whose task of
|
|
249
|
+
* `threadId` they were owed to has settled, by the notice-debt predicate; and its own latest
|
|
250
|
+
* task's input, when that task failed before a step took it, in its setup say.
|
|
251
|
+
*/
|
|
252
|
+
private expired;
|
|
253
|
+
/**
|
|
254
|
+
* The notice of task `taskId` on the loaded `childId`, or `null` when it gets none: its `started`
|
|
255
|
+
* row owes none (a blocking call's task, an owner's assignment), or it has not completed or failed. Its text is what a blocking call would have
|
|
256
|
+
* returned; the hint to continue the child is given unless it stopped mid-work.
|
|
257
|
+
*/
|
|
258
|
+
private noticeOf;
|
|
259
|
+
private send;
|
|
260
|
+
}
|
|
261
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type AppendEntry, type PluginJournal } from '../../journal/index.js';
|
|
3
|
+
import type { Seq } from '../../records/journal.js';
|
|
4
|
+
import type { TaskRef } from './record.js';
|
|
5
|
+
export declare const stopObligationRow: {
|
|
6
|
+
record: (value: {
|
|
7
|
+
op: "stop_requested";
|
|
8
|
+
obligation_id: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
targets: {
|
|
11
|
+
task_id: string;
|
|
12
|
+
child_id: string;
|
|
13
|
+
}[];
|
|
14
|
+
} | {
|
|
15
|
+
op: "stop_completed";
|
|
16
|
+
obligation_id: string;
|
|
17
|
+
}) => import("../../records/journal.js").ExtensionRecord;
|
|
18
|
+
parse: (value: {
|
|
19
|
+
op: "stop_requested";
|
|
20
|
+
obligation_id: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
targets: {
|
|
23
|
+
task_id: string;
|
|
24
|
+
child_id: string;
|
|
25
|
+
}[];
|
|
26
|
+
} | {
|
|
27
|
+
op: "stop_completed";
|
|
28
|
+
obligation_id: string;
|
|
29
|
+
}) => {
|
|
30
|
+
op: "stop_requested";
|
|
31
|
+
obligation_id: string;
|
|
32
|
+
reason: string;
|
|
33
|
+
targets: {
|
|
34
|
+
task_id: string;
|
|
35
|
+
child_id: string;
|
|
36
|
+
}[];
|
|
37
|
+
} | {
|
|
38
|
+
op: "stop_completed";
|
|
39
|
+
obligation_id: string;
|
|
40
|
+
};
|
|
41
|
+
entry: (value: {
|
|
42
|
+
op: "stop_requested";
|
|
43
|
+
obligation_id: string;
|
|
44
|
+
reason: string;
|
|
45
|
+
targets: {
|
|
46
|
+
task_id: string;
|
|
47
|
+
child_id: string;
|
|
48
|
+
}[];
|
|
49
|
+
} | {
|
|
50
|
+
op: "stop_completed";
|
|
51
|
+
obligation_id: string;
|
|
52
|
+
}, options: import("../../journal/journal.js").AppendOptions) => {
|
|
53
|
+
type: "ext";
|
|
54
|
+
data: {
|
|
55
|
+
plugin: string;
|
|
56
|
+
instance_id: string;
|
|
57
|
+
kind: string;
|
|
58
|
+
version: number;
|
|
59
|
+
data: z.core.util.JSONType;
|
|
60
|
+
};
|
|
61
|
+
options: import("../../journal/journal.js").AppendOptions;
|
|
62
|
+
};
|
|
63
|
+
append(journal: PluginJournal, value: {
|
|
64
|
+
op: "stop_requested";
|
|
65
|
+
obligation_id: string;
|
|
66
|
+
reason: string;
|
|
67
|
+
targets: {
|
|
68
|
+
task_id: string;
|
|
69
|
+
child_id: string;
|
|
70
|
+
}[];
|
|
71
|
+
} | {
|
|
72
|
+
op: "stop_completed";
|
|
73
|
+
obligation_id: string;
|
|
74
|
+
}, options: import("../../journal/journal.js").AppendOptions): Promise<import("../../records/journal.js").JournalEvent<"ext">>;
|
|
75
|
+
read(event: import("../../records/journal.js").JournalEvent): {
|
|
76
|
+
op: "stop_requested";
|
|
77
|
+
obligation_id: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
targets: {
|
|
80
|
+
task_id: string;
|
|
81
|
+
child_id: string;
|
|
82
|
+
}[];
|
|
83
|
+
} | {
|
|
84
|
+
op: "stop_completed";
|
|
85
|
+
obligation_id: string;
|
|
86
|
+
} | undefined;
|
|
87
|
+
contribution(message: {
|
|
88
|
+
role?: import("../../records/journal.js").InputRole;
|
|
89
|
+
content: string | readonly import("../../llm/content.js").ContentPartInput[];
|
|
90
|
+
}, value: {
|
|
91
|
+
op: "stop_requested";
|
|
92
|
+
obligation_id: string;
|
|
93
|
+
reason: string;
|
|
94
|
+
targets: {
|
|
95
|
+
task_id: string;
|
|
96
|
+
child_id: string;
|
|
97
|
+
}[];
|
|
98
|
+
} | {
|
|
99
|
+
op: "stop_completed";
|
|
100
|
+
obligation_id: string;
|
|
101
|
+
}, options?: {
|
|
102
|
+
sourceSeqs?: readonly Seq[];
|
|
103
|
+
}): import("../../records/journal.js").StepContribution;
|
|
104
|
+
matchesSource(record: import("../../util/json.js").DeepReadonly<import("../../records/journal.js").ExtensionRecord>): boolean;
|
|
105
|
+
rejection(reason: string, value: {
|
|
106
|
+
op: "stop_requested";
|
|
107
|
+
obligation_id: string;
|
|
108
|
+
reason: string;
|
|
109
|
+
targets: {
|
|
110
|
+
task_id: string;
|
|
111
|
+
child_id: string;
|
|
112
|
+
}[];
|
|
113
|
+
} | {
|
|
114
|
+
op: "stop_completed";
|
|
115
|
+
obligation_id: string;
|
|
116
|
+
}): {
|
|
117
|
+
decision: "reject";
|
|
118
|
+
reason: string;
|
|
119
|
+
source: import("../../records/journal.js").ExtensionRecord;
|
|
120
|
+
};
|
|
121
|
+
readContribution: (event: import("../../records/journal.js").JournalEvent) => {
|
|
122
|
+
op: "stop_requested";
|
|
123
|
+
obligation_id: string;
|
|
124
|
+
reason: string;
|
|
125
|
+
targets: {
|
|
126
|
+
task_id: string;
|
|
127
|
+
child_id: string;
|
|
128
|
+
}[];
|
|
129
|
+
} | {
|
|
130
|
+
op: "stop_completed";
|
|
131
|
+
obligation_id: string;
|
|
132
|
+
} | undefined;
|
|
133
|
+
readSource: (source: import("../../util/json.js").DeepReadonly<import("../../records/journal.js").ExtensionRecord> | null) => {
|
|
134
|
+
op: "stop_requested";
|
|
135
|
+
obligation_id: string;
|
|
136
|
+
reason: string;
|
|
137
|
+
targets: {
|
|
138
|
+
task_id: string;
|
|
139
|
+
child_id: string;
|
|
140
|
+
}[];
|
|
141
|
+
} | {
|
|
142
|
+
op: "stop_completed";
|
|
143
|
+
obligation_id: string;
|
|
144
|
+
} | undefined;
|
|
145
|
+
told: import("../../journal/projection.js").PluginProjection<import("../../services/extensionEvents.js").ToldNotices<{
|
|
146
|
+
op: "stop_requested";
|
|
147
|
+
obligation_id: string;
|
|
148
|
+
reason: string;
|
|
149
|
+
targets: {
|
|
150
|
+
task_id: string;
|
|
151
|
+
child_id: string;
|
|
152
|
+
}[];
|
|
153
|
+
} | {
|
|
154
|
+
op: "stop_completed";
|
|
155
|
+
obligation_id: string;
|
|
156
|
+
}>>;
|
|
157
|
+
projection<State>(fold: {
|
|
158
|
+
key: string;
|
|
159
|
+
init(): State;
|
|
160
|
+
apply(state: State, value: {
|
|
161
|
+
op: "stop_requested";
|
|
162
|
+
obligation_id: string;
|
|
163
|
+
reason: string;
|
|
164
|
+
targets: {
|
|
165
|
+
task_id: string;
|
|
166
|
+
child_id: string;
|
|
167
|
+
}[];
|
|
168
|
+
} | {
|
|
169
|
+
op: "stop_completed";
|
|
170
|
+
obligation_id: string;
|
|
171
|
+
}, event: import("../../records/journal.js").JournalEvent<"ext">): State;
|
|
172
|
+
onFork?: "inherit" | "reset";
|
|
173
|
+
}): import("../../journal/projection.js").PluginProjection<State>;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The `stop_requested` row of a stop obligation over `targets`, for a write on `threadId`, the thread
|
|
177
|
+
* whose work they are: the one way an obligation is asked for, by delegations' own stop of everything
|
|
178
|
+
* under a cancelled thread (`stopObligationRows`) or by an owner stopping exactly its tasks.
|
|
179
|
+
* Delegations carries it out from the write's listener, and the next startup's repair does once more
|
|
180
|
+
* while it is outstanding, mounted or not when the row was written.
|
|
181
|
+
*/
|
|
182
|
+
export declare function stopObligation(threadId: string, reason: string, targets: readonly TaskRef[]): AppendEntry<'ext'>;
|
|
183
|
+
/** One outstanding obligation: the row that asked for it, why, and the tasks it stops. */
|
|
184
|
+
export type StopObligation = {
|
|
185
|
+
readonly id: string;
|
|
186
|
+
readonly seq: Seq;
|
|
187
|
+
readonly reason: string;
|
|
188
|
+
readonly targets: readonly TaskRef[];
|
|
189
|
+
};
|
|
190
|
+
/** A thread's outstanding stop obligations, by id. Resets at a fork's spawn row: a fork owes none. */
|
|
191
|
+
export declare const stopObligations: import("../../journal/projection.js").PluginProjection<Map<string, StopObligation>>;
|
|
192
|
+
/**
|
|
193
|
+
* A thread's outstanding obligations for its catalog entry, an empty list when it owes none: every
|
|
194
|
+
* entry carries the value, so one rebuilt without it, after a crash between rows and catalog, is
|
|
195
|
+
* one the registration's refresh recomputes.
|
|
196
|
+
*/
|
|
197
|
+
export declare const outstandingStops: import("../../services/catalogContributions.js").ContributionDefinition<{
|
|
198
|
+
obligation_id: string;
|
|
199
|
+
seq: number;
|
|
200
|
+
reason: string;
|
|
201
|
+
targets: {
|
|
202
|
+
task_id: string;
|
|
203
|
+
child_id: string;
|
|
204
|
+
}[];
|
|
205
|
+
}[]>;
|
|
206
|
+
/**
|
|
207
|
+
* What `threadId` owes: its outstanding obligations, none for a thread whose entry cannot be read
|
|
208
|
+
* (a refresh that failed leaves it so until its next write) and none for one the journal does not hold.
|
|
209
|
+
*/
|
|
210
|
+
export declare function readObligations(journal: PluginJournal, threadId: string): readonly StopObligation[];
|