@leuduan/lagent 0.1.2 → 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/README.md +28 -15
- package/dist/chunks/{UC3FVVJ2.js → 2GCIWSOA.js} +2 -2
- package/dist/chunks/2P47AHNK.js +7 -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/{SL2YLB2F.js → 7VAPNE3L.js} +1 -1
- package/dist/chunks/{BM3S37EZ.js → ASSQZH3F.js} +1 -1
- package/dist/chunks/B4FXK5ER.js +77 -0
- package/dist/chunks/{37YOGDGY.js → BBCW2FZK.js} +1 -1
- 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/{CDQG7RKA.js → DDZ7YF26.js} +1 -1
- package/dist/chunks/EMRB4KCN.js +6 -0
- package/dist/chunks/EPYQ5M3B.js +3 -0
- package/dist/chunks/G44LG6VL.js +1 -0
- package/dist/chunks/GGSVIIWJ.js +2 -0
- package/dist/chunks/IAAEP6VL.js +30 -0
- package/dist/chunks/{AP6Q4EPT.js → JCTBX33H.js} +1 -1
- 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/{C5LYCXJG.js → MNJ4SRF7.js} +1 -1
- package/dist/chunks/N6IXG2VL.js +1 -0
- package/dist/chunks/OCBPT7KE.js +1 -0
- package/dist/chunks/OL5A6ITQ.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/{presets → compositions}/codex.d.ts +12 -6
- package/dist/{presets/prompts.d.ts → compositions/codexPrompts.d.ts} +1 -1
- package/dist/context.d.ts +18 -10
- package/dist/index.d.ts +31 -23
- package/dist/index.js +1 -77
- package/dist/journal/catalog.d.ts +1 -1
- package/dist/journal/journal.d.ts +3 -3
- package/dist/journal/projection.d.ts +1 -1
- package/dist/journal/store.d.ts +3 -3
- package/dist/llm/index.d.ts +19 -13
- package/dist/llm/index.js +1 -0
- package/dist/llm/provider.d.ts +11 -0
- package/dist/loop/agent.d.ts +16 -132
- package/dist/loop/authorization.d.ts +41 -0
- package/dist/loop/auxiliary.d.ts +7 -3
- package/dist/loop/chunks.d.ts +3 -3
- package/dist/loop/completion.d.ts +17 -0
- package/dist/loop/errors.d.ts +6 -29
- package/dist/loop/hooks.d.ts +39 -6
- package/dist/loop/index.d.ts +7 -28
- package/dist/loop/runner.d.ts +134 -0
- package/dist/loop/runtime.d.ts +7 -16
- package/dist/loop/strategy.d.ts +12 -3
- package/dist/loop/{prepare.d.ts → surfacePrepare.d.ts} +2 -2
- package/dist/loop/tool.d.ts +11 -6
- package/dist/loop/toolCalls.d.ts +3 -10
- package/dist/plugin.d.ts +31 -34
- package/dist/plugin.js +1 -1
- package/dist/plugins/agentsMd.d.ts +24 -20
- package/dist/plugins/agentsMd.js +1 -1
- package/dist/plugins/ask/index.d.ts +2 -2
- package/dist/plugins/ask/index.js +1 -1
- package/dist/plugins/ask/service.d.ts +2 -2
- package/dist/plugins/commands/index.d.ts +5 -2
- package/dist/plugins/commands/index.js +1 -1
- package/dist/plugins/commands/output.d.ts +1 -1
- package/dist/plugins/commands/record.d.ts +31 -22
- package/dist/plugins/commands/service.d.ts +18 -11
- package/dist/plugins/commands/{background.d.ts → tools.d.ts} +2 -0
- package/dist/plugins/compaction/checkpoint.d.ts +4 -1
- package/dist/plugins/compaction/config.d.ts +3 -3
- package/dist/plugins/compaction/estimate.d.ts +9 -1
- package/dist/plugins/compaction/index.d.ts +87 -2
- package/dist/plugins/compaction/index.js +5 -5
- package/dist/plugins/compaction/{records.d.ts → record.d.ts} +36 -36
- package/dist/plugins/compaction/{log.d.ts → state.d.ts} +8 -1
- package/dist/plugins/dateAndBranch.js +1 -1
- package/dist/plugins/delegations/answers.d.ts +1 -1
- package/dist/plugins/delegations/assignmentKey.d.ts +1 -1
- package/dist/plugins/delegations/cleanup.d.ts +1 -1
- package/dist/plugins/delegations/index.js +1 -1
- package/dist/plugins/delegations/notices.d.ts +8 -8
- package/dist/plugins/delegations/obligations.d.ts +13 -13
- package/dist/plugins/delegations/record.d.ts +11 -10
- package/dist/plugins/delegations/request.d.ts +8 -5
- package/dist/plugins/delegations/role.d.ts +1 -1
- package/dist/plugins/delegations/service.d.ts +9 -8
- package/dist/plugins/delegations/{waitBook.d.ts → waitResolver.d.ts} +9 -9
- package/dist/plugins/diagnostics/digest.d.ts +1 -1
- package/dist/plugins/diagnostics/index.d.ts +1 -1
- package/dist/plugins/diagnostics/index.js +1 -1
- package/dist/plugins/fileTools/config.d.ts +10 -0
- package/dist/plugins/{tools → fileTools}/editFiles.d.ts +16 -27
- 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/tools.d.ts +6 -0
- package/dist/plugins/historyRecall/history.d.ts +1 -1
- package/dist/plugins/historyRecall/index.js +1 -1
- package/dist/plugins/historyRecall/render.d.ts +1 -1
- package/dist/plugins/mcp/catalog.d.ts +1 -1
- package/dist/plugins/mcp/index.d.ts +2 -2
- package/dist/plugins/mcp/index.js +1 -1
- package/dist/plugins/mcp/mount.d.ts +2 -2
- package/dist/plugins/mcp/render.d.ts +1 -1
- package/dist/plugins/mcp/{tool.d.ts → tools.d.ts} +1 -1
- package/dist/plugins/{routeContext.d.ts → routeNotice.d.ts} +2 -2
- package/dist/plugins/routeNotice.js +1 -0
- package/dist/{sandbox → plugins/sandbox}/absent.d.ts +11 -10
- package/dist/{sandbox → plugins/sandbox}/index.d.ts +5 -2
- package/dist/plugins/sandbox/index.js +4 -0
- package/dist/{sandbox → plugins/sandbox}/mode.d.ts +5 -5
- package/dist/plugins/sandbox/policy.d.ts +163 -0
- package/dist/{sandbox → plugins/sandbox}/service.d.ts +23 -13
- package/dist/plugins/schedules/index.js +3 -3
- package/dist/plugins/schedules/record.d.ts +18 -18
- package/dist/plugins/schedules/service.d.ts +2 -2
- package/dist/plugins/skills/discovery.d.ts +38 -9
- package/dist/plugins/skills/index.d.ts +1 -1
- package/dist/plugins/skills/index.js +1 -1
- package/dist/plugins/subAgents/index.js +1 -1
- package/dist/plugins/subAgents/{fork.d.ts → tools.d.ts} +36 -1
- package/dist/plugins/threadDirs.d.ts +36 -0
- package/dist/plugins/threadDirs.js +1 -0
- package/dist/plugins/toolPolicy/index.d.ts +2 -2
- package/dist/plugins/toolPolicy/index.js +1 -1
- package/dist/plugins/truncateToolOutput.d.ts +14 -10
- package/dist/plugins/truncateToolOutput.js +6 -1
- package/dist/plugins/usage/index.d.ts +4 -2
- package/dist/plugins/usage/index.js +1 -1
- package/dist/plugins/usage/tracker.d.ts +1 -1
- package/dist/plugins/verify/index.d.ts +7 -55
- package/dist/plugins/verify/index.js +6 -1
- 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 +7 -4
- package/dist/plugins/verify/state.d.ts +58 -0
- package/dist/plugins/webTools/index.d.ts +34 -0
- package/dist/plugins/webTools/index.js +1 -0
- package/dist/plugins/workflows/assignment.d.ts +6 -2
- package/dist/plugins/workflows/cleanup.d.ts +1 -1
- package/dist/plugins/workflows/definition.d.ts +2 -2
- package/dist/plugins/workflows/{bindings.d.ts → entryPlan.d.ts} +2 -2
- package/dist/plugins/workflows/{providers.d.ts → hostBindings.d.ts} +2 -2
- package/dist/plugins/workflows/index.d.ts +4 -4
- package/dist/plugins/workflows/index.js +10 -5
- package/dist/plugins/workflows/observations.d.ts +3 -3
- package/dist/plugins/workflows/participantModels.d.ts +28 -0
- package/dist/plugins/workflows/participants.d.ts +2 -2
- package/dist/plugins/workflows/policy.d.ts +2 -2
- package/dist/plugins/workflows/record.d.ts +51 -65
- package/dist/plugins/workflows/routing.d.ts +2 -2
- package/dist/plugins/workflows/service.d.ts +24 -24
- package/dist/plugins/workflows/{fold.d.ts → state.d.ts} +2 -2
- 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 +2 -2
- package/dist/plugins/{workspaceContext.d.ts → workspaceNotice.d.ts} +5 -7
- package/dist/plugins/workspaceNotice.js +1 -0
- package/dist/{plugins/providers → providers}/anthropic.d.ts +6 -3
- package/dist/{plugins/providers → providers}/anthropicMessages.d.ts +2 -1
- package/dist/{plugins/providers → providers}/codex.d.ts +14 -3
- package/dist/{plugins/providers → providers}/deepseek.d.ts +6 -2
- package/dist/{plugins/providers → providers}/failure.d.ts +1 -1
- package/dist/{plugins/providers → providers}/gateway.d.ts +2 -1
- package/dist/providers/index.d.ts +18 -0
- package/dist/providers/index.js +6 -0
- package/dist/{plugins/providers → providers}/openaiChat.d.ts +13 -2
- package/dist/{plugins/providers → providers}/openaiResponses.d.ts +12 -3
- package/dist/{plugins/providers → providers}/opencodeCopilot.d.ts +2 -2
- package/dist/{plugins/providers → providers}/opencodeGo.d.ts +18 -7
- package/dist/{plugins/providers → providers}/shared.d.ts +9 -1
- package/dist/{plugins/providers → providers}/stream.d.ts +4 -2
- package/dist/{models/door.d.ts → records/index.d.ts} +8 -7
- package/dist/records/index.js +1 -0
- package/dist/{models/wire → records}/journal.d.ts +210 -14
- package/dist/{models/wire/primitives.d.ts → records/toolResult.d.ts} +1 -1
- package/dist/services/agents.d.ts +26 -1
- package/dist/services/confinement/files.d.ts +118 -0
- package/dist/services/confinement/service.d.ts +219 -0
- package/dist/services/core.d.ts +2 -8
- package/dist/{kit/extension.d.ts → services/extensionEvents.d.ts} +5 -4
- package/dist/services/journal.d.ts +1 -1
- package/dist/services/llm.d.ts +4 -2
- package/dist/{kit → services}/modes.d.ts +1 -1
- package/dist/services/plugins.d.ts +34 -0
- package/dist/services/{preset.d.ts → presets/definition.d.ts} +4 -4
- package/dist/services/{presets.d.ts → presets/installations.d.ts} +3 -3
- package/dist/services/prompts.d.ts +23 -5
- package/dist/services/{threadActivation.d.ts → threads/activation.d.ts} +3 -3
- package/dist/services/{admission.d.ts → threads/admission.d.ts} +3 -3
- package/dist/services/{birth.d.ts → threads/birth.d.ts} +9 -10
- package/dist/services/threads/index.d.ts +14 -0
- package/dist/services/{runEvents.d.ts → threads/runEvents.d.ts} +2 -2
- package/dist/services/{owner.d.ts → threads/runOwner.d.ts} +5 -4
- package/dist/services/{threads.d.ts → threads/service.d.ts} +9 -8
- package/dist/services/{thread.d.ts → threads/thread.d.ts} +8 -7
- package/dist/services/{threadView.d.ts → threads/view.d.ts} +7 -6
- package/dist/services/tools.d.ts +79 -2
- package/dist/{loop/opening.d.ts → state/birth.d.ts} +22 -2
- package/dist/{loop → state}/chain.d.ts +3 -3
- package/dist/state/confirmations.d.ts +64 -0
- package/dist/{loop → state}/continuation.d.ts +3 -2
- package/dist/{loop → state}/decide.d.ts +10 -2
- package/dist/state/dispatches.d.ts +54 -0
- package/dist/state/errors.d.ts +26 -0
- package/dist/{loop → state}/forks.d.ts +1 -1
- package/dist/{loop → state}/holds.d.ts +1 -1
- package/dist/{loop → state}/inbox.d.ts +2 -2
- 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/prompt.d.ts +13 -0
- package/dist/state/recovery.d.ts +7 -0
- package/dist/{loop → state}/replace.d.ts +2 -2
- package/dist/{loop → state}/requests.d.ts +3 -3
- package/dist/{loop → state}/route.d.ts +10 -2
- package/dist/state/summary.d.ts +16 -0
- package/dist/{loop → state}/surface.d.ts +3 -3
- package/dist/state/surfaceRead.d.ts +20 -0
- package/dist/{loop/threadState.d.ts → state/thread.d.ts} +12 -11
- package/dist/state/turns.d.ts +87 -0
- package/dist/state/waits.d.ts +38 -0
- package/dist/{loop → state}/wake.d.ts +1 -1
- package/dist/stores/durableObject.js +1 -0
- package/dist/{plugins/store → stores}/memory.d.ts +2 -2
- package/dist/{plugins/store → stores}/sql.d.ts +2 -2
- package/dist/stores/sqlite.js +1 -0
- package/dist/sys/environment.d.ts +0 -5
- package/dist/sys/git.d.ts +0 -13
- package/dist/sys/paths.d.ts +0 -47
- package/dist/sys/spawn.d.ts +16 -6
- package/dist/testing/clock.d.ts +1 -1
- package/dist/testing/fakeLlm.d.ts +4 -2
- package/dist/testing/fedLlm.d.ts +3 -1
- package/dist/testing/helpers.d.ts +31 -13
- package/dist/testing/index.js +1 -1
- package/dist/testing/settlement.d.ts +1 -1
- package/package.json +36 -28
- package/dist/chunks/2O7ZGEIT.js +0 -1
- package/dist/chunks/2OSESBIL.js +0 -1
- package/dist/chunks/3LQHQRIU.js +0 -6
- package/dist/chunks/3QCW4WDJ.js +0 -1
- package/dist/chunks/4XVRUSCQ.js +0 -1
- package/dist/chunks/6ECI2GGV.js +0 -1
- package/dist/chunks/74HKUGRR.js +0 -1
- package/dist/chunks/ADHERZLW.js +0 -2
- package/dist/chunks/D7E6EWIE.js +0 -3
- package/dist/chunks/DRYAN665.js +0 -1
- package/dist/chunks/DXFXAYDN.js +0 -17
- package/dist/chunks/EGZI4XQX.js +0 -24
- package/dist/chunks/ENWFSU27.js +0 -41
- package/dist/chunks/G6RXC3AL.js +0 -1
- package/dist/chunks/G74AGRAJ.js +0 -15
- package/dist/chunks/GQGNVSKB.js +0 -1
- package/dist/chunks/IJ2WNMD5.js +0 -7
- package/dist/chunks/JPZFKSWT.js +0 -1
- package/dist/chunks/KESCTXGO.js +0 -5
- package/dist/chunks/L3N4FIEN.js +0 -1
- package/dist/chunks/NAOUTU7A.js +0 -4
- package/dist/chunks/NDIM7MEW.js +0 -1
- package/dist/chunks/O4PPOM5Z.js +0 -2
- package/dist/chunks/OVZFGILJ.js +0 -1
- package/dist/chunks/P5ZHHOOM.js +0 -6
- package/dist/chunks/QMMLQJBS.js +0 -1
- package/dist/chunks/RK3VP2Q4.js +0 -3
- package/dist/chunks/SGGMBSBA.js +0 -1
- package/dist/chunks/TOOIB6J2.js +0 -1
- package/dist/chunks/TYTQRLTX.js +0 -1
- package/dist/chunks/UCTEU62F.js +0 -1
- package/dist/chunks/UD3VJER6.js +0 -1
- package/dist/chunks/WUUKTSRT.js +0 -7
- package/dist/chunks/X65X4KP5.js +0 -7
- package/dist/chunks/YIR5MYGU.js +0 -1
- package/dist/chunks/YLNJXQ3Z.js +0 -1
- package/dist/kit/claim.d.ts +0 -13
- package/dist/kit/drain.d.ts +0 -10
- package/dist/kit/grants.d.ts +0 -9
- package/dist/kit/scope.d.ts +0 -32
- package/dist/kit/service.d.ts +0 -7
- package/dist/kit/strategy.d.ts +0 -10
- package/dist/kit/tool.d.ts +0 -72
- package/dist/llm/door.d.ts +0 -21
- package/dist/llm/door.js +0 -1
- package/dist/loop/projections.d.ts +0 -307
- package/dist/loop/state.d.ts +0 -70
- package/dist/loop/summary.d.ts +0 -3
- package/dist/models/config/agent.d.ts +0 -18
- package/dist/models/config/prompt.d.ts +0 -18
- package/dist/models/door.js +0 -1
- package/dist/models/index.d.ts +0 -7
- package/dist/plugins/commands/foreground.d.ts +0 -4
- package/dist/plugins/compaction/preset.d.ts +0 -86
- package/dist/plugins/compaction/shared.d.ts +0 -14
- package/dist/plugins/delegations/testing.d.ts +0 -16
- package/dist/plugins/providers/door.d.ts +0 -61
- package/dist/plugins/providers/door.js +0 -1
- package/dist/plugins/providers/index.d.ts +0 -6
- package/dist/plugins/routeContext.js +0 -1
- package/dist/plugins/store/durableObject.js +0 -1
- package/dist/plugins/store/sqlite.js +0 -1
- package/dist/plugins/subAgents/tool.d.ts +0 -38
- package/dist/plugins/tools/index.d.ts +0 -59
- package/dist/plugins/tools/index.js +0 -1
- package/dist/plugins/verify/facts.d.ts +0 -356
- package/dist/plugins/workflows/submit.d.ts +0 -8
- package/dist/plugins/workspaceContext.js +0 -1
- package/dist/presets/agents.d.ts +0 -7
- package/dist/presets/base.d.ts +0 -10
- package/dist/presets/index.d.ts +0 -4
- package/dist/sandbox/index.js +0 -4
- package/dist/sandbox/policy.d.ts +0 -86
- package/dist/services/launches.d.ts +0 -104
- package/dist/services/threadDirs.d.ts +0 -38
- package/dist/testing/sandbox.d.ts +0 -71
- /package/dist/chunks/{UKXMCHHT.js → FJLU4UH3.js} +0 -0
- /package/dist/chunks/{J5S4URAW.js → HK6ZSONF.js} +0 -0
- /package/dist/plugins/ask/{askQuestion.d.ts → tools.d.ts} +0 -0
- /package/dist/plugins/delegations/{waits.d.ts → waitContracts.d.ts} +0 -0
- /package/dist/plugins/{tools → fileTools}/fsRead.d.ts +0 -0
- /package/dist/plugins/{tools → fileTools}/ripgrep.d.ts +0 -0
- /package/dist/plugins/{tools → fileTools}/textEdit.d.ts +0 -0
- /package/dist/{util → plugins/mcp}/version.d.ts +0 -0
- /package/dist/{sandbox → plugins/sandbox}/client.d.ts +0 -0
- /package/dist/{sandbox → plugins/sandbox}/files.d.ts +0 -0
- /package/dist/{sandbox → plugins/sandbox}/protocol.d.ts +0 -0
- /package/dist/{sandbox → plugins/sandbox}/worker.d.ts +0 -0
- /package/dist/{sandbox → plugins/sandbox}/worker.js +0 -0
- /package/dist/plugins/skills/{tool.d.ts → tools.d.ts} +0 -0
- /package/dist/plugins/{tools → webTools}/html.d.ts +0 -0
- /package/dist/plugins/{tools → webTools}/network.d.ts +0 -0
- /package/dist/plugins/{tools → webTools}/web.d.ts +0 -0
- /package/dist/plugins/workflows/{work.d.ts → workStatus.d.ts} +0 -0
- /package/dist/{plugins/providers → providers}/codexAuth.d.ts +0 -0
- /package/dist/services/{contributions.d.ts → catalogContributions.d.ts} +0 -0
- /package/dist/{loop → state}/limits.d.ts +0 -0
- /package/dist/{plugins/store → stores}/durableObject.d.ts +0 -0
- /package/dist/{plugins/store → stores}/durableObjectConnection.d.ts +0 -0
- /package/dist/{plugins/store → stores}/sqlite.d.ts +0 -0
- /package/dist/{models → util}/jsonSchema.d.ts +0 -0
- /package/dist/{kit → util}/retries.d.ts +0 -0
- /package/dist/{kit → util}/timers.d.ts +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FileScope } from '../../services/confinement/files.js';
|
|
1
2
|
export type SkillDocument = {
|
|
2
3
|
name: string;
|
|
3
4
|
directoryName: string;
|
|
@@ -25,30 +26,58 @@ export declare function resolveSkillRoots(cwd: string, roots: {
|
|
|
25
26
|
readonly workspace: readonly string[];
|
|
26
27
|
readonly host: readonly string[];
|
|
27
28
|
}): string[];
|
|
29
|
+
/**
|
|
30
|
+
* A skill document that cannot be used as it is: not a regular file, too large, or its frontmatter does
|
|
31
|
+
* not parse. Never a refusal, a missing file or a stop: those are the facade's own errors.
|
|
32
|
+
*/
|
|
33
|
+
export declare class SkillDocumentError extends Error {
|
|
34
|
+
constructor(message: string, options?: ErrorOptions);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reads the skill document at `path` through `files`, the verified handle and the policy of the
|
|
38
|
+
* operation it belongs to, which is the one way any skill file is read.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readSkillDocument(files: FileScope, path: string, directoryName: string): Promise<SkillDocument>;
|
|
28
41
|
/** A file or directory discovery skipped, and why. */
|
|
29
42
|
export type SkippedSkill = {
|
|
30
43
|
readonly path: string;
|
|
31
44
|
readonly reason: string;
|
|
32
45
|
};
|
|
33
46
|
/**
|
|
34
|
-
* Walks the roots for `SKILL.md` files
|
|
35
|
-
* that cannot be read or parsed,
|
|
36
|
-
* `skipped`, so one broken skill never hides the others.
|
|
47
|
+
* Walks the roots for `SKILL.md` files, through `files`; the first skill claiming a name or alias
|
|
48
|
+
* wins. A document that cannot be read or parsed, a directory that cannot be listed and a root the
|
|
49
|
+
* policy refuses are skipped and passed to `skipped`, so one broken skill never hides the others. A
|
|
50
|
+
* root that does not exist is not a problem. Nothing here touches the file system but through `files`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function discoverSkills(files: FileScope, roots: readonly string[], skipped?: (skip: SkippedSkill) => void, signal?: AbortSignal): Promise<SkillDocument[]>;
|
|
53
|
+
/**
|
|
54
|
+
* What one thread's activation found: the roots it searched from its `cwd`, and the skills in them,
|
|
55
|
+
* read under one policy (`identity`) at one state of the confinement (`epoch`). Content read under
|
|
56
|
+
* another is not delivered: see the `skill` tool and the listing.
|
|
37
57
|
*/
|
|
38
|
-
export declare function discoverSkills(roots: readonly string[], skipped?: (skip: SkippedSkill) => void): SkillDocument[];
|
|
39
|
-
/** What one thread's activation found: the roots it searched from its `cwd`, and the skills in them. */
|
|
40
58
|
export type SkillCatalog = {
|
|
41
59
|
readonly workspaceRoot: string;
|
|
42
60
|
readonly roots: readonly string[];
|
|
43
61
|
readonly skills: readonly SkillDocument[];
|
|
62
|
+
/** How the facade it was read through judged reads (`FileScope.identity`). */
|
|
63
|
+
readonly identity: string;
|
|
64
|
+
/** `ConfinementService.epoch` before it was read. */
|
|
65
|
+
readonly epoch: number;
|
|
66
|
+
/** Why there is no catalog, when the operation it needed was refused; else `null`. */
|
|
67
|
+
readonly unavailable: string | null;
|
|
44
68
|
};
|
|
45
69
|
/**
|
|
46
|
-
* Searches the roots for a thread working in `cwd`, once
|
|
47
|
-
* discovery skipped goes to `skipped`.
|
|
70
|
+
* Searches the roots for a thread working in `cwd`, once, through `files`: everything after reads
|
|
71
|
+
* the result. What discovery skipped goes to `skipped`.
|
|
48
72
|
*/
|
|
49
|
-
export declare function prepareSkillCatalog(cwd: string, roots: {
|
|
73
|
+
export declare function prepareSkillCatalog(files: FileScope, cwd: string, roots: {
|
|
50
74
|
readonly workspace: readonly string[];
|
|
51
75
|
readonly host: readonly string[];
|
|
52
|
-
},
|
|
76
|
+
}, noted: {
|
|
77
|
+
readonly identity: string;
|
|
78
|
+
readonly epoch: number;
|
|
79
|
+
}, skipped?: (skip: SkippedSkill) => void, signal?: AbortSignal): Promise<SkillCatalog>;
|
|
80
|
+
/** The catalog of a thread whose operation was refused: no skills, and why. */
|
|
81
|
+
export declare const unavailableCatalog: (cwd: string, epoch: number, reason: string) => SkillCatalog;
|
|
53
82
|
/** The catalog as the model reads it: one line per skill, paths relative to the workspace where inside it. */
|
|
54
83
|
export declare function formatSkillListing({ skills, workspaceRoot, roots }: SkillCatalog): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Plugin } from '@leuduan/cordis';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export { DEFAULT_WORKSPACE_SKILL_ROOTS, userSkillRoots } from './discovery.js';
|
|
4
|
-
export { SKILL_TOOL } from './
|
|
4
|
+
export { SKILL_TOOL } from './tools.js';
|
|
5
5
|
declare const SkillsConfigSchema: z.ZodObject<{
|
|
6
6
|
roots: z.ZodArray<z.ZodString>;
|
|
7
7
|
workspaceRoots: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"../../chunks/
|
|
1
|
+
import{a,b,c,d}from"../../chunks/2P47AHNK.js";import"../../chunks/VYMT4TXD.js";import"../../chunks/3UMZMPWW.js";import"../../chunks/34KW6VNQ.js";import"../../chunks/JFX2MXBA.js";import"../../chunks/S34ZA2R6.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 DEFAULT_WORKSPACE_SKILL_ROOTS,c as SKILL_TOOL,d as skills,b as userSkillRoots};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunks/
|
|
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};
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { Tool } from '../../loop/index.js';
|
|
3
|
-
import type
|
|
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;
|
|
4
39
|
/** Validates a fork endpoint's call, and is the source of the schema advertised to the model. */
|
|
5
40
|
export declare const ForkParameters: z.ZodObject<{
|
|
6
41
|
task: z.ZodString;
|
|
@@ -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};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '@leuduan/cordis';
|
|
2
|
-
import { type Modes } from '../../
|
|
3
|
-
import { type AgentSelector } from '../../
|
|
2
|
+
import { type Modes } from '../../services/modes.js';
|
|
3
|
+
import { type AgentSelector } from '../../services/agents.js';
|
|
4
4
|
/** What one mode lets through: `allow` lists the tools it lets be called, every other one denied. */
|
|
5
5
|
export type ModeRules = {
|
|
6
6
|
/** The only tools a call may name in this mode; without it, every tool. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../../chunks/
|
|
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};
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import type { Plugin } from '@leuduan/cordis';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import type { ToolResult } from '../
|
|
3
|
+
import type { ToolResult } from '../records/toolResult.js';
|
|
4
4
|
/** Where full outputs go inside a thread's directory. */
|
|
5
5
|
export declare const TOOL_OUTPUTS_DIR = "tool-outputs";
|
|
6
6
|
/** The least limit that holds the longest gap marker and a character each of head and tail. */
|
|
7
7
|
export declare const MIN_TOOL_OUTPUT_LENGTH: number;
|
|
8
8
|
export declare const TruncateToolOutputConfigSchema: z.ZodObject<{
|
|
9
9
|
maxToolOutputLength: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
spill: z.ZodBoolean;
|
|
10
11
|
}, z.core.$strip>;
|
|
11
12
|
export type TruncateToolOutputConfig = z.input<typeof TruncateToolOutputConfigSchema>;
|
|
12
13
|
/**
|
|
13
14
|
* Caps tool output at a character limit, keeping its head and its tail around a marker that says how
|
|
14
|
-
* much of the middle was cut
|
|
15
|
-
* (`<thread dir>/tool-outputs/`), where file tools can read it back when available
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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.
|
|
20
23
|
*/
|
|
21
|
-
export declare const truncateToolOutput: Plugin.Object<TruncateToolOutputConfig
|
|
24
|
+
export declare const truncateToolOutput: Plugin.Object<TruncateToolOutputConfig>;
|
|
22
25
|
/**
|
|
23
26
|
* Truncates `result` to `limit` characters, head and tail with the gap marker between them, writing the
|
|
24
|
-
* full output into `directory` when it was cut
|
|
27
|
+
* full output into `directory` when it was cut, unless that is `null`. `limit` is at least
|
|
28
|
+
* {@link MIN_TOOL_OUTPUT_LENGTH}.
|
|
25
29
|
*/
|
|
26
|
-
export declare function applyTruncation(result: ToolResult, limit: number, directory: string): Promise<ToolResult>;
|
|
30
|
+
export declare function applyTruncation(result: ToolResult, limit: number, directory: string | null): Promise<ToolResult>;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import{
|
|
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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, Service } from '@leuduan/cordis';
|
|
1
|
+
import { Context, Service, type Plugin } from '@leuduan/cordis';
|
|
2
2
|
import { UsageSnapshot } from './tracker.js';
|
|
3
3
|
export { UsageSnapshot } from './tracker.js';
|
|
4
4
|
export type { UsageSnapshotInit } from './tracker.js';
|
|
@@ -14,7 +14,7 @@ declare module '@leuduan/cordis' {
|
|
|
14
14
|
* is a function of its own rows, and a sum over several threads is the host's, over the threads it
|
|
15
15
|
* shows, as a caller-chain rollup is, by joining threads on `origin`.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
declare class UsageService extends Service {
|
|
18
18
|
static inject: string[];
|
|
19
19
|
constructor(ctx: Context);
|
|
20
20
|
/** Everything one thread has spent so far. */
|
|
@@ -22,3 +22,5 @@ export declare class UsageService extends Service {
|
|
|
22
22
|
/** What one thread's most recent completed turn spent. */
|
|
23
23
|
lastTurn(threadId: string): UsageSnapshot;
|
|
24
24
|
}
|
|
25
|
+
export declare const usage: Plugin.Constructor<undefined>;
|
|
26
|
+
export type { UsageService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as _}from"../../chunks/
|
|
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};
|
|
@@ -6,61 +6,13 @@ export declare const VerifyConfigSchema: z.ZodObject<{
|
|
|
6
6
|
}, z.core.$strict>;
|
|
7
7
|
export type VerifyConfig = z.input<typeof VerifyConfigSchema>;
|
|
8
8
|
/**
|
|
9
|
-
* A
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* A verification counts only if its allowed attempt — the `tool/authorization` row written just
|
|
16
|
-
* before it starts — comes after the result row of the last other change, and its result says it
|
|
17
|
-
* ran to completion with exit code 0. Commands and edits are exclusive, so within one response a
|
|
18
|
-
* verification starts after the changes before it settled; the attempt still decides, as results
|
|
19
|
-
* land in model order and a change from elsewhere — a background command, a tool by another plugin
|
|
20
|
-
* under the same name — need not be. Until its outcome is known it is a possible change itself, since a
|
|
21
|
-
* formatter in the check rewrites files: one that passes proves its own changes and everything
|
|
22
|
-
* settled before it started; one that fails, is cancelled, times out, is interrupted or leaves
|
|
23
|
-
* processes behind leaves verification outstanding. A background command that ends after it
|
|
24
|
-
* started makes it stale; one still running at the stop is not held against the gate. A call that
|
|
25
|
-
* was never allowed to run, denied or rejected, changed nothing and is not counted.
|
|
26
|
-
*
|
|
27
|
-
* With an unverified change it sends the model back to run the command, at most
|
|
28
|
-
* {@link VERIFY_REMINDERS} times since the last change other than a verification run, or since the
|
|
29
|
-
* person last wrote, and then rejects the answer, so the turn ends `rejected`. When policy denied
|
|
30
|
-
* the latest verification attempt since the person last wrote, a read-only conversation say, it
|
|
31
|
-
* rejects at once, wherever that attempt's result landed among the changes' results.
|
|
32
|
-
*
|
|
33
|
-
* The {@link verify} service is the judge: the preset puts its verification in force on the thread
|
|
34
|
-
* it serves for as long as it is mounted (`ctx.verify.gate`), and tells the model of it. A
|
|
35
|
-
* requirement recorded for the assignment the thread serves on the same verification is judged
|
|
36
|
-
* with the gate, once: a barrier at its arming, with or without a change, counting its reminders
|
|
37
|
-
* and denials from it.
|
|
38
|
-
*
|
|
39
|
-
* So that the model need not learn the command from an objection, the thread is also told it up
|
|
40
|
-
* front, as a notice at the next model step whenever no notice it can still see says the same: on
|
|
41
|
-
* its first step, and again after a replacement took it away. The notice is neither a change nor a
|
|
42
|
-
* reminder.
|
|
43
|
-
*
|
|
44
|
-
* A pure fold over each thread's rows, not the current turn's, so a crash or an approval pause
|
|
45
|
-
* cannot hide an earlier turn's unverified work, and judging an answer again after a crash repeats
|
|
46
|
-
* nothing. The fold records what happened whatever the verification is, so it is one for every
|
|
47
|
-
* gate, and each verification is judged from it at the stop.
|
|
48
|
-
*
|
|
49
|
-
* The thread's delegated work is its own: a change made by any thread its calls started, at any
|
|
50
|
-
* depth, counts as the thread's, at its row, so a verification must have started after it. Every
|
|
51
|
-
* command a child ran counts, a passing run of the same verification included: a check may rewrite
|
|
52
|
-
* files, and a child's proof is not its caller's. Rows are numbered in one journal order across threads, so the two
|
|
53
|
-
* compare directly; a child's change also starts the count of reminders over. A child that is not
|
|
54
|
-
* loaded is read from the catalog, so this holds across a restart, and a child whose changes cannot
|
|
55
|
-
* be read rejects the answer at once rather than pass it. A thread an owner assigned, such as a
|
|
56
|
-
* workflow's isolated participant, is that owner's work, not its caller's. The preset is not handed
|
|
57
|
-
* down: a child is not gated itself.
|
|
58
|
-
*
|
|
59
|
-
* Installed per thread, with `cwd` resolved against the thread's cwd by the host; or mounted
|
|
60
|
-
* (`mountPreset`) from the setup of a preset placed on a thread, which gates that thread. Refuses
|
|
61
|
-
* to mount without the {@link verify} service.
|
|
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.
|
|
62
14
|
*/
|
|
63
|
-
export declare const verifyPreset: import("../../services/
|
|
15
|
+
export declare const verifyPreset: import("../../services/presets/definition.js").Preset<z.ZodObject<{
|
|
64
16
|
command: z.ZodString;
|
|
65
17
|
cwd: z.ZodString;
|
|
66
18
|
}, z.core.$strict>>;
|
|
@@ -71,5 +23,5 @@ export declare const verifyPreset: import("../../services/preset.js").Preset<z.Z
|
|
|
71
23
|
* application, before anything mounts the preset.
|
|
72
24
|
*/
|
|
73
25
|
export declare const verify: Plugin.Object<undefined>;
|
|
74
|
-
export { VERIFY_PRESET,
|
|
26
|
+
export { VERIFY_PRESET, VERIFY_REPAIRS } from './record.js';
|
|
75
27
|
export { VERIFY_OWNER, type OwedVerification, type VerifyService } from './service.js';
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import{
|
|
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;
|