@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,53 @@
|
|
|
1
|
+
import type { Context } from '@leuduan/cordis';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { LlmService } from '../../services/llm.js';
|
|
4
|
+
declare const RouteCatalogSchema: z.ZodObject<{
|
|
5
|
+
providers: z.ZodArray<z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
default_model: z.ZodString;
|
|
8
|
+
default_thinking_effort: z.ZodNullable<z.ZodEnum<{
|
|
9
|
+
low: "low";
|
|
10
|
+
high: "high";
|
|
11
|
+
none: "none";
|
|
12
|
+
medium: "medium";
|
|
13
|
+
max: "max";
|
|
14
|
+
}>>;
|
|
15
|
+
models: z.ZodArray<z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
description: z.ZodNullable<z.ZodString>;
|
|
18
|
+
thinking_efforts: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
19
|
+
low: "low";
|
|
20
|
+
high: "high";
|
|
21
|
+
none: "none";
|
|
22
|
+
medium: "medium";
|
|
23
|
+
max: "max";
|
|
24
|
+
}>>>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
/** The routes a sub-agent call can name, as its caller is told them. */
|
|
29
|
+
export type RouteCatalog = z.output<typeof RouteCatalogSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Every registered provider, in name order, each with its declared models and its default model
|
|
32
|
+
* first when the list does not name it. Registering a provider is what offers it, so nothing is
|
|
33
|
+
* filtered. Deterministic, so two catalogs compare equal exactly when a caller would be told the
|
|
34
|
+
* same thing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function routeCatalog(llm: LlmService): RouteCatalog;
|
|
37
|
+
/** The whole list, which replaces any list the model can still see (`replaces`). */
|
|
38
|
+
export declare function renderAvailableRoutes(catalog: RouteCatalog, options: {
|
|
39
|
+
replaces: boolean;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* Tells the agents `isCaller` selects the routes a sub-agent call can name, at the next model step
|
|
43
|
+
* already due whenever the catalog differs from the latest notice the model can still see: on its
|
|
44
|
+
* first step, when a provider comes or goes, and after a replacement took the notice off the
|
|
45
|
+
* surface. The whole list is told again, never a diff, so the latest visible notice is the catalog.
|
|
46
|
+
*
|
|
47
|
+
* Installed by `subAgents` in the scope it grants in, selecting the agents those grants reach, so it
|
|
48
|
+
* reaches exactly the threads they do. It describes; nothing the tool accepts depends on it. A
|
|
49
|
+
* thread that two mounts both tell gets the notice once, since identical contributions to one step
|
|
50
|
+
* are recorded once (`ModelStep.contribute`).
|
|
51
|
+
*/
|
|
52
|
+
export declare function tellAvailableRoutes(ctx: Context, isCaller: (agentName: string) => boolean): void;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* One way callers delegate: a tool under `toolName`, granted to `callers` and described to them
|
|
5
|
+
* here, whose calls start children on the target. The endpoint is how callers see the target; the
|
|
6
|
+
* target is what a child runs on, so renaming or rewording the tool never redefines a child.
|
|
7
|
+
*/
|
|
8
|
+
declare const EndpointSchema: z.ZodObject<{
|
|
9
|
+
toolName: z.ZodString;
|
|
10
|
+
callers: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodLiteral<"global">, z.ZodLiteral<"all">]>;
|
|
11
|
+
description: z.ZodString;
|
|
12
|
+
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
|
+
kind: z.ZodLiteral<"agent">;
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
basePrompt: z.ZodString;
|
|
18
|
+
tools: z.ZodArray<z.ZodString>;
|
|
19
|
+
kind: z.ZodLiteral<"role">;
|
|
20
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
21
|
+
kind: z.ZodLiteral<"fork">;
|
|
22
|
+
}, z.core.$strict>], "kind">;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export type EndpointInput = z.input<typeof EndpointSchema>;
|
|
25
|
+
declare const SubAgentsConfigSchema: z.ZodObject<{
|
|
26
|
+
endpoints: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
27
|
+
toolName: z.ZodString;
|
|
28
|
+
callers: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodLiteral<"global">, z.ZodLiteral<"all">]>;
|
|
29
|
+
description: z.ZodString;
|
|
30
|
+
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
31
|
+
kind: z.ZodLiteral<"agent">;
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
basePrompt: z.ZodString;
|
|
36
|
+
tools: z.ZodArray<z.ZodString>;
|
|
37
|
+
kind: z.ZodLiteral<"role">;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"fork">;
|
|
40
|
+
}, z.core.$strict>], "kind">;
|
|
41
|
+
}, z.core.$strict>>>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
export type SubAgentsConfig = z.input<typeof SubAgentsConfigSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* Lets agents start sub-agents and forks, as tools: one endpoint per tool, whose target is a
|
|
46
|
+
* registered global agent, a role, or a fork of the caller. Mount it once per layer with that
|
|
47
|
+
* layer's endpoints: a second mount in one layer naming the same tool collides rather than
|
|
48
|
+
* merging. Mounts in different layers are independent, such as one on the root and the one the
|
|
49
|
+
* `codex` preset makes per thread for its explorer and its fork.
|
|
50
|
+
*
|
|
51
|
+
* The target kind decides what a call takes and what its child is. An agent target must be
|
|
52
|
+
* registered when this mounts, and must be global wherever this mounts: a child is a sibling of its
|
|
53
|
+
* caller's scope, so an agent registered in the caller's scope is invisible to the child, which
|
|
54
|
+
* could never run on it. A role target creates its child with the role recorded as the child's
|
|
55
|
+
* defining installation of the `role` preset, which `delegations` registers and which defines the
|
|
56
|
+
* child's agent in the child's own layer. Both take a task, a route and `background`. A fork target
|
|
57
|
+
* takes a task and `background` only; see {@link forkTool}.
|
|
58
|
+
*
|
|
59
|
+
* Every tool only starts: its result names the child's `thread_id`, which `message_agent` (the
|
|
60
|
+
* `delegations` plugin) continues. Every call delegates through `ctx.delegations`, so the
|
|
61
|
+
* `delegations` plugin must be mounted first, and this one refuses to mount without it. Every
|
|
62
|
+
* caller is also told the routes a call can name (see `tellAvailableRoutes`), in the same scope as
|
|
63
|
+
* its grants, so this configuration is the one list of who can start a sub-agent. Guidance about
|
|
64
|
+
* coordinating forks belongs to the consumer preset or host.
|
|
65
|
+
*/
|
|
66
|
+
export declare const subAgents: Plugin.Object<SubAgentsConfig | undefined>;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../../chunks/MHC6VPB4.js";import"../../chunks/CANPZYTH.js";import"../../chunks/VYMT4TXD.js";import"../../chunks/MNJ4SRF7.js";import"../../chunks/JFZZXVWD.js";import"../../chunks/N6IXG2VL.js";import"../../chunks/6DRCKZ2C.js";import"../../chunks/7LI64H5X.js";import"../../chunks/3UMZMPWW.js";import"../../chunks/34KW6VNQ.js";import"../../chunks/KUZCL2SH.js";import"../../chunks/CQEVREBT.js";import"../../chunks/HK6ZSONF.js";import"../../chunks/7VAPNE3L.js";import"../../chunks/EPYQ5M3B.js";import"../../chunks/5IRF47YB.js";import"../../chunks/OL5A6ITQ.js";import"../../chunks/JFX2MXBA.js";import"../../chunks/S34ZA2R6.js";import"../../chunks/6FRNHMCV.js";import"../../chunks/CUK7CGC7.js";import"../../chunks/BPRCULZH.js";import"../../chunks/FJLU4UH3.js";import"../../chunks/DDANMY45.js";import"../../chunks/BBCW2FZK.js";import"../../chunks/MMNNZCBO.js";import"../../chunks/G44LG6VL.js";import"../../chunks/D4PQP5MA.js";export{a as subAgents};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Tool } from '../../loop/index.js';
|
|
3
|
+
import { type DelegationTarget } from '../delegations/index.js';
|
|
4
|
+
/** Parameters an agent accepts when another agent invokes it as a tool. */
|
|
5
|
+
export declare const SubAgentRequestParameters: z.ZodPreprocess<z.ZodObject<{
|
|
6
|
+
task: z.ZodString;
|
|
7
|
+
background: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
provider: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
model: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
thinking_effort: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
11
|
+
low: "low";
|
|
12
|
+
high: "high";
|
|
13
|
+
none: "none";
|
|
14
|
+
medium: "medium";
|
|
15
|
+
max: "max";
|
|
16
|
+
}>>>;
|
|
17
|
+
}, z.core.$strip>, unknown>;
|
|
18
|
+
/** How an endpoint describes its target to callers. */
|
|
19
|
+
export type EndpointDescription = {
|
|
20
|
+
readonly toolName: string;
|
|
21
|
+
readonly description: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Delegation, as a tool.
|
|
25
|
+
*
|
|
26
|
+
* One of these is registered per target, a global agent or a role endpoint, so a target is
|
|
27
|
+
* advertised to the model exactly like any other tool and reaching it is an ordinary grant. The
|
|
28
|
+
* child is a normal thread: created with this call as its `origin` and its task in the same
|
|
29
|
+
* write, and driven by `ctx.delegations` until the task settles. The tool only starts: its result
|
|
30
|
+
* names the child's `thread_id`, whether the child answered or failed, and `message_agent` is how a
|
|
31
|
+
* later call continues it.
|
|
32
|
+
*
|
|
33
|
+
* The child is born on the caller's route with the fields the call names folded over it, and keeps
|
|
34
|
+
* that route, so a child started on a cheap model stays on it when continued without naming one.
|
|
35
|
+
*/
|
|
36
|
+
export declare const subAgentTool: ({ toolName, description }: EndpointDescription, target: Exclude<DelegationTarget, {
|
|
37
|
+
kind: "fork";
|
|
38
|
+
}>) => Tool;
|
|
39
|
+
/** Validates a fork endpoint's call, and is the source of the schema advertised to the model. */
|
|
40
|
+
export declare const ForkParameters: z.ZodObject<{
|
|
41
|
+
task: z.ZodString;
|
|
42
|
+
background: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
export declare const formatForkResult: (output: string, isError: boolean) => string;
|
|
45
|
+
/**
|
|
46
|
+
* What the forked thread is asked to do: the fork framing, naming the tool that forked it so it is
|
|
47
|
+
* told not to call that again, plus the task itself.
|
|
48
|
+
*/
|
|
49
|
+
export declare const forkTaskPrompt: (task: string, toolName: string) => string;
|
|
50
|
+
/**
|
|
51
|
+
* A fork endpoint's tool: a child thread that continues this conversation, driven by
|
|
52
|
+
* `ctx.delegations` like any other delegation.
|
|
53
|
+
*
|
|
54
|
+
* The child is cut at the request that produced the call, so it sees exactly what the model saw
|
|
55
|
+
* when it asked — not the call, and not sibling results committed after it. Several calls on one
|
|
56
|
+
* reply run concurrently through the tool-call pool, and every sibling shares that request's cached
|
|
57
|
+
* prefix, the route and the mode included. Its task is queued in the same append that creates it,
|
|
58
|
+
* framed as a fork task, and its answer comes back as a `fork_result`, or with `background` a receipt
|
|
59
|
+
* comes back at once. The call takes no route: a fork runs on its source's route, so its siblings
|
|
60
|
+
* share the prefix.
|
|
61
|
+
*
|
|
62
|
+
* The child's id and its task's are derived from the call, so a call re-dispatched after a crash
|
|
63
|
+
* waits for the task it opened instead of duplicating it, and one whose task already settled
|
|
64
|
+
* returns its recorded output without running twice. Like every start tool, the result names the child's `thread_id`; `message_agent`
|
|
65
|
+
* continues it, with the message as plain input.
|
|
66
|
+
*/
|
|
67
|
+
export declare const forkTool: ({ toolName, description }: EndpointDescription) => Tool;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Service, type Context, type Plugin } from '@leuduan/cordis';
|
|
2
|
+
declare module '@leuduan/cordis' {
|
|
3
|
+
interface Context {
|
|
4
|
+
/** Each thread's own directory under the application data directory (optional plugin). */
|
|
5
|
+
threadDirs: ThreadDirsService;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export type ThreadDirsConfig = {
|
|
9
|
+
/** Absolute application data directory; thread directories live under `<dataDir>/threads`. Required. */
|
|
10
|
+
dataDir: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Where each thread keeps files of its own: `<dataDir>/threads/<thread-id>/`, a scratch space.
|
|
14
|
+
* Harness-written files go in named subdirectories such as `tool-outputs/` and `commands/`. Mount
|
|
15
|
+
* it on the root with `root.plugin(threadDirs, { dataDir })`; a plugin that keeps files here
|
|
16
|
+
* injects `threadDirs`, so it waits, unmounted, until a host that has a file system mounts this.
|
|
17
|
+
*
|
|
18
|
+
* The path is derived from the data directory and thread id, but absolute paths are also recorded
|
|
19
|
+
* in prompts and tool results. Keep the data directory at the same location when reopening a
|
|
20
|
+
* durable journal. Plugins can use the id supplied by their activation hook to find the directory.
|
|
21
|
+
*
|
|
22
|
+
* Nothing here limits who may read or write the directories: what the model's tools and commands
|
|
23
|
+
* may reach is the confinement policy's. A host whose data directory holds what commands must not
|
|
24
|
+
* change, such as its journal, lists it in the sandbox's `filesystem.denyWrite`.
|
|
25
|
+
*/
|
|
26
|
+
declare class ThreadDirsService extends Service<ThreadDirsConfig> {
|
|
27
|
+
readonly dataDir: string;
|
|
28
|
+
readonly root: string;
|
|
29
|
+
constructor(ctx: Context, config: ThreadDirsConfig);
|
|
30
|
+
/** The directory of `threadId`, without touching the filesystem. */
|
|
31
|
+
dirFor(threadId: string): string;
|
|
32
|
+
/** The directory of `threadId`, created if missing. */
|
|
33
|
+
ensure(threadId: string): string;
|
|
34
|
+
}
|
|
35
|
+
export declare const threadDirs: Plugin.Constructor<ThreadDirsConfig>;
|
|
36
|
+
export type { ThreadDirsService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunks/W57RW55W.js";import"../chunks/VYMT4TXD.js";export{a as threadDirs};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { type Modes } from '../../services/modes.js';
|
|
3
|
+
import { type AgentSelector } from '../../services/agents.js';
|
|
4
|
+
/** What one mode lets through: `allow` lists the tools it lets be called, every other one denied. */
|
|
5
|
+
export type ModeRules = {
|
|
6
|
+
/** The only tools a call may name in this mode; without it, every tool. */
|
|
7
|
+
readonly allow?: readonly string[];
|
|
8
|
+
/** Why a call `allow` leaves out is denied, told to the model. */
|
|
9
|
+
readonly denial?: string;
|
|
10
|
+
/** `'all'` approves every call this mode lets through, satisfying a confirmation. */
|
|
11
|
+
readonly approve?: 'all';
|
|
12
|
+
};
|
|
13
|
+
/** What a mode notice is rendered against: what the model can still see, and what it was told last. */
|
|
14
|
+
export type ModeTold<Mode extends string> = {
|
|
15
|
+
readonly seen: Mode | null;
|
|
16
|
+
readonly last: Mode | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* What `toolPolicy` does with a set of durable modes: the rules each mode enforces and what the model
|
|
20
|
+
* is told on entering one. The state itself, and the host's way to set it, stay with the set.
|
|
21
|
+
*/
|
|
22
|
+
export type ModePolicy<Mode extends string = string> = {
|
|
23
|
+
/** Durable modes, from {@link defineModes}, whose rules apply in the mode a thread is in. */
|
|
24
|
+
readonly modes: Modes<Mode>;
|
|
25
|
+
/** What each of the set's modes lets through; a mode without rules is refused at mount. */
|
|
26
|
+
readonly rules: Readonly<Record<Mode, ModeRules>>;
|
|
27
|
+
/**
|
|
28
|
+
* What the model is told on entering `mode`, as a conversation message at the next model step; `null`
|
|
29
|
+
* to tell nothing. Asked only when the latest notice the model can still see says another mode.
|
|
30
|
+
*/
|
|
31
|
+
notice(mode: Mode, told: ModeTold<Mode>): string | null;
|
|
32
|
+
};
|
|
33
|
+
export type ToolPolicyConfig = {
|
|
34
|
+
/** Whose calls these rules govern, and which threads a mode notice tells; every agent without it. */
|
|
35
|
+
readonly agents?: AgentSelector;
|
|
36
|
+
/** Tools held for the user; a predicate for a source whose tools come and go, as MCP's do. */
|
|
37
|
+
readonly confirm?: readonly string[] | ((tool: string) => boolean);
|
|
38
|
+
/** Tools approved without asking, satisfying a confirmation; `'all'` approves every call. */
|
|
39
|
+
readonly approve?: readonly string[] | 'all';
|
|
40
|
+
/** Tools refused outright. */
|
|
41
|
+
readonly deny?: readonly string[];
|
|
42
|
+
} & (ModePolicy | {
|
|
43
|
+
readonly [Key in keyof ModePolicy]?: undefined;
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* What needs asking before a tool runs: the one policy plugin. Each rule votes on
|
|
47
|
+
* `lagent/tool/authorize` on its own, so the engine's table decides between them: a denial wins, an
|
|
48
|
+
* approval satisfies a confirmation and is recorded `confirmed_by: 'policy'`. Grants say who may
|
|
49
|
+
* call a tool at all; this says what a call that may be made needs.
|
|
50
|
+
*
|
|
51
|
+
* Mount it as many times as a host has rules. On the untagged application context it governs every
|
|
52
|
+
* thread, delegated ones included; in a thread's scope, that thread only.
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* await root.plugin(toolPolicy, { confirm: ['run_command', 'edit_files'] })
|
|
56
|
+
* await root.plugin(toolPolicy, { approve: 'all' }) // auto-accept
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const toolPolicy: Plugin.Object<ToolPolicyConfig>;
|
|
60
|
+
/** The tools the shipped presets hold for confirmation: everything that writes or executes. */
|
|
61
|
+
export declare const SAFE_WRITES_TOOLS: readonly ["run_command", "start_command", "edit_files"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"../../chunks/ASSQZH3F.js";import"../../chunks/DDZ7YF26.js";import"../../chunks/6FRNHMCV.js";import"../../chunks/CUK7CGC7.js";import"../../chunks/BPRCULZH.js";import"../../chunks/DDANMY45.js";import"../../chunks/BBCW2FZK.js";import"../../chunks/MMNNZCBO.js";import"../../chunks/G44LG6VL.js";import"../../chunks/D4PQP5MA.js";export{b as SAFE_WRITES_TOOLS,a as toolPolicy};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { ToolResult } from '../records/toolResult.js';
|
|
4
|
+
/** Where full outputs go inside a thread's directory. */
|
|
5
|
+
export declare const TOOL_OUTPUTS_DIR = "tool-outputs";
|
|
6
|
+
/** The least limit that holds the longest gap marker and a character each of head and tail. */
|
|
7
|
+
export declare const MIN_TOOL_OUTPUT_LENGTH: number;
|
|
8
|
+
export declare const TruncateToolOutputConfigSchema: z.ZodObject<{
|
|
9
|
+
maxToolOutputLength: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
spill: z.ZodBoolean;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type TruncateToolOutputConfig = z.input<typeof TruncateToolOutputConfigSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* Caps tool output at a character limit, keeping its head and its tail around a marker that says how
|
|
15
|
+
* much of the middle was cut. With `spill: true` it also writes the full text to the thread's own
|
|
16
|
+
* directory (`<thread dir>/tool-outputs/`), where file tools can read it back when available, and
|
|
17
|
+
* names the path; it then injects `threadDirs` and stays pending until `threadDirs` is
|
|
18
|
+
* mounted. With `spill: false` the cut text is gone and no directory is needed, as on a host with
|
|
19
|
+
* no file system. Characters are UTF-16 code units, as `string.length` counts them, and no cut
|
|
20
|
+
* splits a surrogate pair. A tool may opt out by setting `no_truncation: true` in its result
|
|
21
|
+
* metadata. Because this wraps `lagent/tool/execute`, the journal records exactly what the model
|
|
22
|
+
* saw. A call that waits has no output to cap.
|
|
23
|
+
*/
|
|
24
|
+
export declare const truncateToolOutput: Plugin.Object<TruncateToolOutputConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Truncates `result` to `limit` characters, head and tail with the gap marker between them, writing the
|
|
27
|
+
* full output into `directory` when it was cut, unless that is `null`. `limit` is at least
|
|
28
|
+
* {@link MIN_TOOL_OUTPUT_LENGTH}.
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyTruncation(result: ToolResult, limit: number, directory: string | null): Promise<ToolResult>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{W as d}from"../chunks/BPRCULZH.js";import"../chunks/DDANMY45.js";import"../chunks/BBCW2FZK.js";import{c}from"../chunks/MMNNZCBO.js";import"../chunks/G44LG6VL.js";import"../chunks/D4PQP5MA.js";import{randomBytes as T}from"node:crypto";import{mkdir as O,writeFile as $}from"node:fs/promises";import{join as _}from"node:path";import{z as s}from"zod";var x=/[^A-Za-z0-9_.-]+/g,w="tool-outputs",A=String(Number.MAX_SAFE_INTEGER).length,h=t=>`
|
|
2
|
+
[\u2026 ${t} characters omitted \u2026]
|
|
3
|
+
`,m=h("9".repeat(A)).length+2,E=s.object({maxToolOutputLength:s.number().int().min(m,{message:`maxToolOutputLength must hold the gap marker and some head and tail: at least ${m}`}).default(1e4),spill:s.boolean()}),b={name:"lagent:truncate-tool-output",apply(t,a){let{maxToolOutputLength:o,spill:n}=E.parse(a);if(!n){p(t,o,()=>null);return}t.inject(["threadDirs"],e=>p(e,o,l=>_(e.threadDirs.dirFor(l),w)))}};function p(t,a,o){t.on("lagent/tool/execute",async(n,e)=>{let l=await e();return d(l)?l:await M(l,a,o(n.threadId))})}async function M(t,a,o){let n=await S(t,a,o),e=[...t.notes??[]];return n.note!==null&&e.push(n.note),{...t,output:n.output,notes:e.length>0?e:null,metadata:{...t.metadata,truncation:n.metadata}}}async function S(t,a,o){let n=t.output;if(t.metadata.no_truncation===!0)return{output:n,note:null,metadata:{was_truncated:!1,limit:a,original_length:n.length,returned_length:n.length,no_truncation:!0}};if(n.length<=a)return{output:n,note:null,metadata:{was_truncated:!1,limit:a,original_length:n.length,returned_length:n.length}};let e=o===null?null:await F(n,t,o),l=n.split(`
|
|
4
|
+
`).length,{head:u,tail:r}=I(n,a),i=n.length-u.length-r.length,g=`${u}${h(String(i))}${r}`;return{output:g,note:`Output truncated to its first ${u.length} and last ${r.length} of ${n.length} characters (${l} lines).`+(e===null?"":` The full output is written to ${e}.`),metadata:{was_truncated:!0,limit:a,original_length:n.length,returned_length:g.length,omitted_length:i,...e===null?{}:{full_output_path:e}}}}function I(t,a){let o=a-h(String(t.length)).length,n=Math.ceil(o/2),e=o-n,l=n,u=t.lastIndexOf(`
|
|
5
|
+
`,l-1);u>=Math.floor(n/2)?l=u+1:l=c(t,l,"end");let r=t.length-e,i=t.indexOf(`
|
|
6
|
+
`,r);return i!==-1&&i+1<=r+Math.floor(e/2)?r=i+1:r=c(t,r,"start"),{head:t.slice(0,l),tail:t.slice(r)}}async function F(t,a,o){let n=`${f(a.name||"tool")}-${f(a.call_id||"call")}-`,e=_(o,`${n}${T(6).toString("hex")}.txt`);return await O(o,{recursive:!0,mode:448}),await $(e,t,{encoding:"utf8",flag:"wx",mode:384}),e}var f=t=>t.replace(x,"-").slice(0,L).replace(/^[.-]+|[.-]+$/g,"")||"value",L=40;export{m as MIN_TOOL_OUTPUT_LENGTH,w as TOOL_OUTPUTS_DIR,E as TruncateToolOutputConfigSchema,M as applyTruncation,b as truncateToolOutput};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Context, Service, type Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { UsageSnapshot } from './tracker.js';
|
|
3
|
+
export { UsageSnapshot } from './tracker.js';
|
|
4
|
+
export type { UsageSnapshotInit } from './tracker.js';
|
|
5
|
+
declare module '@leuduan/cordis' {
|
|
6
|
+
interface Context {
|
|
7
|
+
/** Model usage totals per thread (optional plugin). */
|
|
8
|
+
usage: UsageService;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Model usage as a fold over each thread's journal. The engine itself counts nothing — without
|
|
13
|
+
* this service mounted, nobody is keeping score. There is no journal-wide total: a thread's spend
|
|
14
|
+
* is a function of its own rows, and a sum over several threads is the host's, over the threads it
|
|
15
|
+
* shows, as a caller-chain rollup is, by joining threads on `origin`.
|
|
16
|
+
*/
|
|
17
|
+
declare class UsageService extends Service {
|
|
18
|
+
static inject: string[];
|
|
19
|
+
constructor(ctx: Context);
|
|
20
|
+
/** Everything one thread has spent so far. */
|
|
21
|
+
thread(threadId: string): UsageSnapshot;
|
|
22
|
+
/** What one thread's most recent completed turn spent. */
|
|
23
|
+
lastTurn(threadId: string): UsageSnapshot;
|
|
24
|
+
}
|
|
25
|
+
export declare const usage: Plugin.Constructor<undefined>;
|
|
26
|
+
export type { UsageService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as _}from"../../chunks/BBCW2FZK.js";import"../../chunks/MMNNZCBO.js";import"../../chunks/G44LG6VL.js";import"../../chunks/D4PQP5MA.js";import{Service as a}from"@leuduan/cordis";var n=class e{request_count;input_tokens;output_tokens;cache_read_input_tokens;cache_write_input_tokens;reasoning_output_tokens;constructor(t={}){this.request_count=t.request_count??0,this.input_tokens=t.input_tokens??0,this.output_tokens=t.output_tokens??0,this.cache_read_input_tokens=t.cache_read_input_tokens??0,this.cache_write_input_tokens=t.cache_write_input_tokens??0,this.reasoning_output_tokens=t.reasoning_output_tokens??0,Object.freeze(this)}get totalTokens(){return this.input_tokens+this.output_tokens}get cacheMissInputTokens(){return this.input_tokens-this.cache_read_input_tokens}delta(t){return new e({request_count:this.request_count-t.request_count,input_tokens:this.input_tokens-t.input_tokens,output_tokens:this.output_tokens-t.output_tokens,cache_read_input_tokens:this.cache_read_input_tokens-t.cache_read_input_tokens,cache_write_input_tokens:this.cache_write_input_tokens-t.cache_write_input_tokens,reasoning_output_tokens:this.reasoning_output_tokens-t.reasoning_output_tokens})}plus(t){return new e({request_count:this.request_count+t.request_count,input_tokens:this.input_tokens+t.input_tokens,output_tokens:this.output_tokens+t.output_tokens,cache_read_input_tokens:this.cache_read_input_tokens+t.cache_read_input_tokens,cache_write_input_tokens:this.cache_write_input_tokens+t.cache_write_input_tokens,reasoning_output_tokens:this.reasoning_output_tokens+t.reasoning_output_tokens})}toJSON(){return{request_count:this.request_count,input_tokens:this.input_tokens,output_tokens:this.output_tokens,cache_read_input_tokens:this.cache_read_input_tokens,cache_write_input_tokens:this.cache_write_input_tokens,reasoning_output_tokens:this.reasoning_output_tokens}}},s=()=>({request_count:0,input_tokens:0,output_tokens:0,cache_read_input_tokens:0,cache_write_input_tokens:0,reasoning_output_tokens:0}),r=(e,t)=>{t&&(e.input_tokens+=t.input_tokens,e.output_tokens+=t.output_tokens,e.cache_read_input_tokens+=t.cache_read_input_tokens,e.cache_write_input_tokens+=t.cache_write_input_tokens,e.reasoning_output_tokens+=t.reasoning_output_tokens)};function i(e,t){switch(t.type){case"llm/request":case"auxiliary/request":e.request_count+=1;return;case"assistant/message":r(e,t.data.response.message.usage);return;case"auxiliary/result":r(e,t.data.usage);return;default:return}}var c=()=>({totals:s(),baseline:s(),lastTurn:s()}),o=_({key:"lagent:usage:thread",onFork:"reset",init:c,apply(e,t){return i(e.totals,t),t.type==="turn/start"?e.baseline={...e.totals}:t.type==="turn/end"&&(e.lastTurn=new n(e.totals).delta(new n(e.baseline)).toJSON()),e}}),u=class extends a{static inject=["journal"];constructor(t){super(t,"usage"),t.effect(()=>t.journal.register(o))}thread(t){return new n(this.ctx.journal.state(o,t).totals)}lastTurn(t){return new n(this.ctx.journal.state(o,t).lastTurn)}},g=u;export{n as UsageSnapshot,g as usage};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { JournalEvent } from '../../records/journal.js';
|
|
2
|
+
export type UsageSnapshotInit = Partial<{
|
|
3
|
+
request_count: number;
|
|
4
|
+
input_tokens: number;
|
|
5
|
+
output_tokens: number;
|
|
6
|
+
cache_read_input_tokens: number;
|
|
7
|
+
cache_write_input_tokens: number;
|
|
8
|
+
reasoning_output_tokens: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class UsageSnapshot {
|
|
11
|
+
readonly request_count: number;
|
|
12
|
+
readonly input_tokens: number;
|
|
13
|
+
readonly output_tokens: number;
|
|
14
|
+
readonly cache_read_input_tokens: number;
|
|
15
|
+
readonly cache_write_input_tokens: number;
|
|
16
|
+
readonly reasoning_output_tokens: number;
|
|
17
|
+
constructor(init?: UsageSnapshotInit);
|
|
18
|
+
get totalTokens(): number;
|
|
19
|
+
get cacheMissInputTokens(): number;
|
|
20
|
+
delta(previous: UsageSnapshot): UsageSnapshot;
|
|
21
|
+
/** This and `other` together: how a host sums the threads it shows, since nothing rolls up for it. */
|
|
22
|
+
plus(other: UsageSnapshot): UsageSnapshot;
|
|
23
|
+
toJSON(): Required<UsageSnapshotInit>;
|
|
24
|
+
}
|
|
25
|
+
/** A thread's usage counters as plain data: what the usage fold keeps, and what a snapshot is built from. */
|
|
26
|
+
export type UsageCounters = Required<UsageSnapshotInit>;
|
|
27
|
+
export declare const emptyCounters: () => UsageCounters;
|
|
28
|
+
/**
|
|
29
|
+
* Counts model requests and aggregates token usage from `llm/request` and `assistant/message`, and
|
|
30
|
+
* from the auxiliary calls plugins make beside the conversation, `auxiliary/request` and
|
|
31
|
+
* `auxiliary/result`: a summary that was discarded was still paid for, so every result counts,
|
|
32
|
+
* whatever became of its text. Mutates `counters`; a fold reducer's state is its own to change.
|
|
33
|
+
*/
|
|
34
|
+
export declare function countEvent(counters: UsageCounters, event: JournalEvent): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const VerifyConfigSchema: z.ZodObject<{
|
|
4
|
+
command: z.ZodString;
|
|
5
|
+
cwd: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type VerifyConfig = z.input<typeof VerifyConfigSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* A thread's configured automatic completion check. Runtime execution is the only proof;
|
|
10
|
+
* ordinary model commands remain diagnostics. Requirements and gates share the verify service,
|
|
11
|
+
* which plans execution at the pure stop boundary and core dispatches before final judgment.
|
|
12
|
+
* Relevant command and delegated work must settle first. Commands obey current grants,
|
|
13
|
+
* confirmation and sandbox policy, and must establish their intended postcondition on success.
|
|
14
|
+
*/
|
|
15
|
+
export declare const verifyPreset: import("../../services/presets/definition.js").Preset<z.ZodObject<{
|
|
16
|
+
command: z.ZodString;
|
|
17
|
+
cwd: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
/**
|
|
20
|
+
* The `ctx.verify` service ({@link VerifyService}), the one judge of verification on every thread:
|
|
21
|
+
* the gates {@link verifyPreset} mounts, and the requirements an owner records for an assignment
|
|
22
|
+
* with `owed(...)`, whose threads require {@link VERIFY_OWNER}. Root-only, mounted once by the
|
|
23
|
+
* application, before anything mounts the preset.
|
|
24
|
+
*/
|
|
25
|
+
export declare const verify: Plugin.Object<undefined>;
|
|
26
|
+
export { VERIFY_PRESET, VERIFY_REPAIRS } from './record.js';
|
|
27
|
+
export { VERIFY_OWNER, type OwedVerification, type VerifyService } from './service.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{t as K,w as W,x as U}from"../../chunks/CANPZYTH.js";import"../../chunks/VYMT4TXD.js";import"../../chunks/MNJ4SRF7.js";import{a as C,d as J}from"../../chunks/JFZZXVWD.js";import"../../chunks/N6IXG2VL.js";import"../../chunks/6DRCKZ2C.js";import"../../chunks/7LI64H5X.js";import"../../chunks/3UMZMPWW.js";import"../../chunks/34KW6VNQ.js";import"../../chunks/KUZCL2SH.js";import"../../chunks/CQEVREBT.js";import"../../chunks/HK6ZSONF.js";import{a as N}from"../../chunks/7VAPNE3L.js";import"../../chunks/EPYQ5M3B.js";import"../../chunks/5IRF47YB.js";import{a as M}from"../../chunks/OL5A6ITQ.js";import"../../chunks/JFX2MXBA.js";import{c as P,d as T}from"../../chunks/S34ZA2R6.js";import{b as g,e as Y}from"../../chunks/6FRNHMCV.js";import"../../chunks/CUK7CGC7.js";import{s as v}from"../../chunks/BPRCULZH.js";import"../../chunks/FJLU4UH3.js";import"../../chunks/DDANMY45.js";import{h as F}from"../../chunks/BBCW2FZK.js";import{a as V}from"../../chunks/MMNNZCBO.js";import"../../chunks/G44LG6VL.js";import"../../chunks/D4PQP5MA.js";import{isAbsolute as pe,resolve as ge}from"node:path";import{z as O}from"zod";import{isAbsolute as ae,resolve as oe}from"node:path";import{z as u}from"zod";var w="verify",k=2,j=u.strictObject({command:u.string(),cwd:u.string()}),B=g({plugin:"lagent:verify",kind:"notice",version:2,schema:j}),$=g({plugin:"lagent:verify",kind:"repair",version:1,schema:j}),D=g({plugin:"lagent:verify",kind:"rejected",version:2,schema:u.strictObject({...j.shape,cause:u.enum(["denied","unverified","execution"])})}),se=u.strictObject({owner:u.string().min(1),assignment:u.string().min(1),generation:u.number().int().nonnegative(),input:u.string().min(1),command:u.string().trim().min(1),cwd:u.string().refine(ae,"An absolute path")}),q=g({plugin:"lagent:verify",kind:"requirement",version:1,schema:se});function I(n){let e=q.parse(n);return{...e,cwd:oe(e.cwd)}}import{resolve as S}from"node:path";import{Service as ue}from"@leuduan/cordis";import{z as me}from"zod";import{resolve as ce}from"node:path";import{z as G}from"zod";var m=(n,e)=>JSON.stringify([n,e]),f=(n,e)=>n===null?e:e===null?n:Math.max(n,e),y=F({key:"lagent:verify:facts",init:()=>({calls:new Map,changedAt:null,personAt:null,repairs:new Map,attempts:new Map}),apply(n,e){switch(e.type){case"assistant/message":for(let t of e.data.response.message.tool_calls)t.arguments!==null&&(t.name==="edit_files"||t.name==="run_command")&&n.calls.set(t.call_id,null);break;case"tool/authorization":n.calls.has(e.data.call_id)&&e.data.decision==="allow"&&(n.calls.set(e.data.call_id,e.seq),n.changedAt=e.seq);break;case"tool/result":{n.calls.get(e.data.result.call_id)!=null&&(n.changedAt=e.seq),n.calls.delete(e.data.result.call_id);break}case"execution/requested":{let{owner:t,operation:r,candidate_seq:i,key:a}=e.data;if(t!=="lagent:verify"&&(r.name==="run_command"||r.name==="edit_files")&&n.calls.set(`runtime_${e.seq}`,null),t!=="lagent:verify"||r.name!=="run_command")break;let{command:o,workdir:c}=r.arguments;if(typeof o!="string"||typeof c!="string")break;n.attempts.set(e.seq,{seq:e.seq,candidate:i,key:a,verification:{command:o,cwd:ce(c)},authorizedAt:null,resultAt:null,result:null});break}case"execution/authorization":{let t=`runtime_${e.data.request_seq}`;n.calls.has(t)&&e.data.decision==="allow"&&(n.calls.set(t,e.seq),n.changedAt=e.seq);let r=n.attempts.get(e.data.request_seq);r!==void 0&&e.data.decision==="allow"&&(r.authorizedAt=e.seq);break}case"execution/result":{let t=`runtime_${e.data.request_seq}`;n.calls.get(t)!=null&&(n.changedAt=e.seq),n.calls.delete(t);let r=n.attempts.get(e.data.request_seq);r!==void 0&&(r.resultAt=e.seq,r.result=e.data.result);break}case"ext":C.read(e)!==void 0&&(n.changedAt=e.seq);break;case"input/message":if(e.data.source===null)n.personAt=e.seq,n.repairs.clear();else{let t=$.readContribution(e);if(t!==void 0){let r=m(t.command,t.cwd);n.repairs.set(r,[...n.repairs.get(r)??[],e.seq])}}break}return n}});function de(n){let e=n.changedAt;for(let t of n.attempts.values())t.authorizedAt!==null&&(e=f(e,f(t.authorizedAt,t.resultAt)));return e}var A=N({key:"verify",version:2,schema:G.strictObject({changed_at:G.number().int().positive().nullable()}),applies:()=>!0,compute:(n,e)=>({changed_at:de(n.state(y,e))})});function R(n,e){let t=new Set([e]);for(let r of n.origins.subtree(e,{self:!0})){let{origin:i,thread_id:a}=r;i===null||i.cause.kind==="assignment"||!t.has(i.caller_thread_id)||t.add(a)}return t}function H(n,e){let t=null;for(let r of R(n,e)){if(r===e)continue;let i=A.read(n,r);if(i.status!=="available")return{unreadable:`agent ${r}: ${i.status==="unavailable"?i.reason:"its changes are not recorded"}`};t=f(t,i.value.changed_at)}return{at:t}}var L=n=>JSON.stringify([n.owner,n.assignment,n.generation]),Q=q.projection({key:"requirements",init:()=>new Map,onFork:"reset",apply(n,e,t){let r=L(e);return n.has(r)||n.set(r,{value:e,seq:t.seq}),n}});function X(n,e,t,r){let i=t?void 0:n.state(Q,e).get(L(r));return i===void 0?[q.entry(r,{threadId:e})]:JSON.stringify(i.value)===JSON.stringify(r)?[]:{refuse:{message:`Verification for assignment ${r.assignment} is already owed on ${e}, differently`}}}function E(n,e){let t=n.state(Q,e);if(t.size===0)return null;let{inputs:r}=n.state(v,e),i=K(n,e),a=null;for(let{value:o,seq:c}of t.values()){let d=r.get(o.input)?.claimedAt??null;if(d===null)continue;let l=Math.max(c,d);i!==null&&i>l||(a===null||a.at<l)&&(a={verification:{command:o.command,cwd:o.cwd},at:l})}return a}import{resolve as Z}from"node:path";var le=(n,e)=>JSON.stringify([n.command,n.cwd,e]);function ee(n,e){let{metadata:t}=n;return!n.is_error&&t.exit_code===0&&t.timed_out===!1&&t.aborted===!1&&t.stop_failed===!1&&typeof t.cwd=="string"&&Z(t.cwd)===e}function x(n,e,t,r){let i=m(e.command,e.cwd),a=f(n.changedAt,r),o=null;for(let d of n.attempts.values())d.authorizedAt!==null&&(m(d.verification.command,d.verification.cwd)===i&&d.result!==null&&ee(d.result,e.cwd)?o=f(o,d.authorizedAt):a=f(a,f(d.authorizedAt,d.resultAt)));let c=f(a,t);return{mutatedAt:a,provenAt:o,fresh:c===null||o!==null&&o>c,repairs:(n.repairs.get(i)??[]).filter(d=>t===null||d>t).length}}function te(n,e,t,r,i){let a=`\`${e.command}\` (in ${e.cwd})`,o=(h,ie="unverified")=>D.rejection(h,{...e,cause:ie});if("unreadable"in r)return o(`Delegated changes cannot be read (${r.unreadable}), so ${a} cannot be verified.`);let c=x(n,e,t,r.at);if(c.fresh)return;let d=le(e,t),l=[...n.attempts.values()].find(h=>h.candidate===i&&h.key===d);if(l===void 0||l.result===null&&l.authorizedAt===null)return{decision:"prepare",request:{owner:"lagent:verify",key:d,operation:{name:"run_command",arguments:{command:e.command,workdir:e.cwd}}}};let s=l.result;if(s===null)return o(`Runtime verification ${a} may have started but its result is unknown. Reconcile its command and cleanup before an explicit retry.`,"execution");if(s.metadata.not_dispatched===!0)return o(`Runtime verification ${a} was not dispatched; no process was started. It was not replayed automatically. Submit a new candidate to verify again.
|
|
2
|
+
${s.output}`,"execution");if(s.metadata.runtime_denied===!0)return o(`Runtime verification ${a} was denied: ${s.output}`,"denied");if(typeof s.metadata.cwd=="string"&&Z(s.metadata.cwd)!==e.cwd)return o(`Runtime verification ran in ${s.metadata.cwd}, rather than the pinned directory ${e.cwd}.`,"execution");if(s.metadata.aborted===!0&&s.metadata.stop_failed===!1){let h=s.metadata.not_started===!0?"was cancelled before execution; no process was started.":"was interrupted; process cleanup completed, but file changes were not rolled back.";return o(`Runtime verification ${a} ${h} It was not replayed automatically. Submit a new candidate to verify again.
|
|
3
|
+
${s.output}`,"execution")}if(s.metadata.stop_failed!==!1||s.metadata.aborted===!0||typeof s.metadata.exit_code!="number"&&s.metadata.timed_out!==!0)return o(`Runtime verification ${a} has no usable completed result or cleanup evidence: ${s.output}`,"execution");let p=ee(s,e.cwd),re=p?`Its proof became stale after recorded activity at row ${c.mutatedAt??t}.`:`It failed (exit ${s.metadata.exit_code}${s.metadata.timed_out===!0?", timed out":""}).`,z=`Runtime verification ${a}: ${re}
|
|
4
|
+
${s.output}`;return c.repairs>=k?o(`${z}
|
|
5
|
+
The ${k} repair continuations are spent; this candidate is rejected.`):{decision:"continue",message:$.contribution({content:`${z}
|
|
6
|
+
${p?"Wait for the invalidating work to settle, inspect any changes, and submit again; the command itself succeeded.":"Fix the reported problem and submit again."} Verification runs automatically; ordinary command calls do not satisfy it.`},e)}}function fe(n){if(n.kind==="send")return null;if(n.kind==="create"){let{origin:i,spec:a}=n.opening;return{origin:i,requires:a.requires,installations:a.installations}}let{origin:e,requires:t,inherits:r}=n.opening;return{origin:e,requires:t,installations:r.installations}}var b="lagent:verify",ne=g({plugin:b,kind:"eligibility",version:1,schema:me.strictObject({})}),_=class extends ue{static inject=["threads","journal","commands"];gates=new Map;constructor(e){super(e,"verify"),e.effect(()=>e.threads.registerOwner({owner:b}).dispose),e.effect(()=>e.journal.register(y)),A.register(e),e.on("lagent/turn/stop",t=>this.judge(t))}gate(e,t){let r=m(t.command,S(t.cwd)),i=E(this.ctx.journal,e);if(i!==null&&m(i.verification.command,i.verification.cwd)!==r)throw new Error(`Thread ${e} owes a different pinned assignment verification`);if([...this.gates.get(e)?.values()??[]].some(c=>m(c.command,c.cwd)!==r))throw new Error(`Thread ${e} already has a different verification gate`);let a=Symbol("verify gate"),o=this.gates.get(e);return o===void 0&&this.gates.set(e,o=new Map),o.set(a,{command:t.command,cwd:S(t.cwd)}),()=>{o.delete(a),o.size===0&&this.gates.get(e)===o&&this.gates.delete(e)}}owed(e){let{inputId:t,...r}=e,i=I({...r,input:t}),a=m(i.command,i.cwd);return o=>{let{threadId:c}=o,d=fe(o);if(!this.required(c,d))return{refuse:{message:`Thread ${c} owes verification, so it must require ${b}`}};let l=this.inPlace(c,d).find(s=>m(s.command,s.cwd)!==a);return l!==void 0?{refuse:{message:`Thread ${c} verifies with \`${l.command}\` (in ${l.cwd}), not the \`${i.command}\` (in ${i.cwd}) this assignment pins`}}:X(this.ctx.journal,c,d!==null,i)}}judge({threadId:e,observe:t,answer:r}){t(()=>this.observed(e,r.seq));let{judged:i,delegated:a}=this.reading(e);if(i.size===0)return;let o=this.ctx.journal.state(y,e),c=[...i.values()].map(({verification:s,armedAt:p})=>te(o,s,p,a,r.seq)),d=c.find(s=>s?.decision==="reject");if(d!==void 0)return d;if([...i.values()].some(({verification:s,armedAt:p})=>"unreadable"in a?!0:p!==null||x(o,s,p,a.at).mutatedAt!==null)){let s=this.work(e);if(s.unresolved.length>0)return ne.rejection(`Verification cannot proceed while work is unresolved: ${s.unresolved.join("; ")}`,{});if(s.draining.length>0)return{decision:"continue",message:ne.contribution({content:`Before automatic verification, wait for relevant commands and agents to settle, or stop them: ${s.draining.join("; ")}`},{})}}return c.find(s=>s!==void 0)}observed(e,t){let{judged:r,delegated:i}=this.reading(e),a=this.ctx.journal.state(y,e);return JSON.stringify([[...r].map(([o,{verification:c,armedAt:d}])=>[o,d,"unreadable"in i?null:x(a,c,d,i.at)]),i,r.size===0?null:this.work(e),[...a.attempts.values()].filter(o=>o.candidate===t&&o.resultAt!==null).map(o=>[o.key,o.resultAt])])}work(e){let t=R(this.ctx.journal,e),r=[],i=[];for(let a of t){let o=J(this.ctx,a,{descendants:!1});r.push(...o.draining),i.push(...o.unresolved);for(let c of W(this.ctx.journal,a))r.push(`thread ${a}: ${c.targets.length} agent stops are pending`)}for(let a of U(this.ctx.journal,e))t.has(a.childId)&&(a.state==="unavailable"?i.push(`agent ${a.childId}: ${a.error}`):(a.state==="open"||a.draining||a.cleanupPending)&&r.push(`agent ${a.childId} has not settled`));return{draining:r,unresolved:i}}reading(e){let t=new Map,r=E(this.ctx.journal,e);for(let i of this.gates.get(e)?.values()??[])t.set(m(i.command,i.cwd),{verification:i,armedAt:null});return r!==null&&t.set(m(r.verification.command,r.verification.cwd),{verification:r.verification,armedAt:r.at}),{judged:t,delegated:t.size===0?{at:null}:H(this.ctx.journal,e)}}inPlace(e,t){return[...(t===null?[...this.ctx.journal.state(v,e).installations.current.values()].map(({presetId:a,config:o})=>({presetId:a,config:o})):t.installations.map(({preset_id:a,config:o})=>({presetId:a,config:o}))).flatMap(({presetId:a,config:o})=>{if(a!==w)return[];let{command:c,cwd:d}=o;return[{command:c,cwd:S(d)}]}),...this.gates.get(e)?.values()??[]]}required(e,t){let{owners:r}=this.ctx.journal.origins.requiredOwners(t??e);return r.some(({owner:i})=>i===b)}};var he=O.strictObject({command:O.string().trim().min(1),cwd:O.string().refine(pe,"An absolute path: resolve it against the thread's cwd before installing")}),et=M({id:w,placement:"thread",schema:he,inject:["journal","verify"],setup(n,e,t){let r=P(n,"verify","verifyPreset"),i={command:e.command,cwd:ge(e.cwd)},a=`\`${i.command}\` (in ${i.cwd})`;Y(n,{event:B,rank:1,current:()=>i,render:()=>V("verification",`Verification runs automatically with ${a} when you submit or finish after changes. Test as useful while working, settle your commands and agents, then submit. Address runtime failure feedback; ordinary command calls do not satisfy verification.`)}),n.effect(()=>r.gate(t.thread.id,i))}}),tt={name:"lagent:verify",inject:["threads","journal","commands"],async apply(n){T(n,"verify"),await n.plugin(_)}};export{b as VERIFY_OWNER,w as VERIFY_PRESET,k as VERIFY_REPAIRS,he as VerifyConfigSchema,tt as verify,et as verifyPreset};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StopVerdict } from '../../loop/index.js';
|
|
2
|
+
import type { Seq } from '../../records/journal.js';
|
|
3
|
+
import type { ToolResult } from '../../records/toolResult.js';
|
|
4
|
+
import type { ReadonlyState } from '../../util/foldState.js';
|
|
5
|
+
import { type Verification } from './record.js';
|
|
6
|
+
import { type VerifyFacts, type DelegatedChange } from './state.js';
|
|
7
|
+
export declare const attemptKey: (verification: Verification, armedAt: Seq | null) => string;
|
|
8
|
+
export declare function passed(result: ReadonlyState<ToolResult>, cwd: string): boolean;
|
|
9
|
+
export declare function judgment(facts: ReadonlyState<VerifyFacts>, verification: Verification, armedAt: Seq | null, delegatedAt: Seq | null): {
|
|
10
|
+
mutatedAt: number | null;
|
|
11
|
+
provenAt: number | null;
|
|
12
|
+
fresh: boolean;
|
|
13
|
+
repairs: number;
|
|
14
|
+
};
|
|
15
|
+
/** A pure completion plan, or bounded feedback from this candidate's one durable attempt. */
|
|
16
|
+
export declare function verdict(facts: ReadonlyState<VerifyFacts>, verification: Verification, armedAt: Seq | null, delegated: DelegatedChange, candidateSeq: Seq): StopVerdict | undefined;
|