@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ModelRoute } from '../llm/provider.js';
|
|
2
|
+
import type { Seq, ThreadEnvironment } from '../records/journal.js';
|
|
3
|
+
import type { CompletionRequest } from './hooks.js';
|
|
4
|
+
import type { LoopRuntime } from './runtime.js';
|
|
5
|
+
/** Dispatches a pure completion plan once, under its candidate's durable identity and current policy. */
|
|
6
|
+
export declare function prepareCompletion(options: {
|
|
7
|
+
runtime: LoopRuntime;
|
|
8
|
+
threadId: string;
|
|
9
|
+
agentName: string;
|
|
10
|
+
environment: ThreadEnvironment;
|
|
11
|
+
route: ModelRoute;
|
|
12
|
+
turn: number;
|
|
13
|
+
candidateSeq: Seq;
|
|
14
|
+
request: CompletionRequest;
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
validate(): void;
|
|
17
|
+
}): Promise<'settled' | 'blocked'>;
|
package/dist/loop/errors.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ReadonlyJsonValue } from '../util/json.js';
|
|
2
|
-
import type { Refusal } from '
|
|
3
|
-
import type { ReplacementRule, RowRef } from './surface.js';
|
|
2
|
+
import type { Refusal, RowRef } from '../state/index.js';
|
|
4
3
|
/** What holds a thread while an operation on it is refused busy. */
|
|
5
4
|
export type ThreadHolding = 'run' | 'compact' | 'rebuild' | 'configure' | 'release' | 'cancel';
|
|
6
5
|
/** A human's answer to an approval request. */
|
|
@@ -13,12 +12,10 @@ export declare class UnknownAgentError extends ReferenceError {
|
|
|
13
12
|
readonly agentName: string;
|
|
14
13
|
constructor(agentName: string);
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
/** A turn is already running on this thread; one driver at a time. */
|
|
15
|
+
/**
|
|
16
|
+
* An operation already holds this thread: a run, compaction, prompt rebuild, configuration change,
|
|
17
|
+
* release or cancel (`holding`), admitted one at a time.
|
|
18
|
+
*/
|
|
22
19
|
export declare class ThreadBusyError extends Error {
|
|
23
20
|
readonly threadId: string;
|
|
24
21
|
readonly holding?: ThreadHolding;
|
|
@@ -48,7 +45,7 @@ export declare class StaleActivation extends Error {
|
|
|
48
45
|
constructor();
|
|
49
46
|
}
|
|
50
47
|
/**
|
|
51
|
-
* Thrown by a judgment whose fence broke while the activation stayed valid (`
|
|
48
|
+
* Thrown by a judgment whose fence broke while the activation stayed valid (`TurnRunner.fenced`): a
|
|
52
49
|
* required registration is gone or was replaced, or a fact a stop check declared it observed
|
|
53
50
|
* changed. The turn ends `interrupted` (`judgment-invalidated`), the answer still owed its checks.
|
|
54
51
|
*/
|
|
@@ -60,12 +57,6 @@ export declare class RecordedTurnFailure extends Error {
|
|
|
60
57
|
readonly cause: unknown;
|
|
61
58
|
constructor(cause: unknown);
|
|
62
59
|
}
|
|
63
|
-
/** A fork was asked for at a row it cannot be cut at; nothing was appended. */
|
|
64
|
-
export declare class ForkCutError extends Error {
|
|
65
|
-
readonly threadId: string;
|
|
66
|
-
readonly seq: number;
|
|
67
|
-
constructor(threadId: string, seq: number, reason: string);
|
|
68
|
-
}
|
|
69
60
|
/** What a thread's recorded birth says about one field of a request that differs from it. */
|
|
70
61
|
export type BirthConflict = {
|
|
71
62
|
readonly field: 'agent' | 'origin' | 'kind' | 'cut' | 'route' | 'environment' | 'installations' | 'requires';
|
|
@@ -123,20 +114,6 @@ export declare class ThreadUnsettledError extends Error {
|
|
|
123
114
|
readonly threadId: string;
|
|
124
115
|
constructor(threadId: string, reason: string);
|
|
125
116
|
}
|
|
126
|
-
/**
|
|
127
|
-
* A replacement `replaceSurface` refused: it breaks a rule of the surface it would land on (see
|
|
128
|
-
* `judgeReplacement`). Nothing of its group was recorded. Distinct from any other failure, so a
|
|
129
|
-
* strategy can tell a plan the surface refused from a journal that could not write.
|
|
130
|
-
*/
|
|
131
|
-
export declare class ReplacementRefusedError extends Error {
|
|
132
|
-
readonly index: number;
|
|
133
|
-
readonly rule: ReplacementRule;
|
|
134
|
-
constructor(message: string,
|
|
135
|
-
/** The refused replacement's position in the group it was offered with. */
|
|
136
|
-
index: number,
|
|
137
|
-
/** The surface rule it breaks. */
|
|
138
|
-
rule: ReplacementRule);
|
|
139
|
-
}
|
|
140
117
|
/**
|
|
141
118
|
* A thread whose surface refused a replacement row, one written past `replaceSurface`: a bug or a
|
|
142
119
|
* hand-edited store. Its history can be read, and forked before that row, but nothing executes on
|
package/dist/loop/hooks.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { AgentDefinition
|
|
2
|
-
import type {
|
|
1
|
+
import type { AgentDefinition } from './agent.js';
|
|
2
|
+
import type { ExtensionRecord, JournalEvent, JournalEventInput, QueuedInput, Seq, StepContribution, StepContributionInput, TurnRejection } from '../records/journal.js';
|
|
3
|
+
import type { ModelCallClient } from '../llm/failure.js';
|
|
4
|
+
import type { JsonObject, ParsedToolCall, ResponseFinish, ThinkingEffort } from '../llm/primitives.js';
|
|
5
|
+
import type { ModelRequest, RequestPurpose } from '../llm/request.js';
|
|
6
|
+
import type { ModelRoute } from '../llm/provider.js';
|
|
7
|
+
import type { StreamingLLMResponse } from '../llm/client.js';
|
|
3
8
|
import type { LoopRuntime } from './runtime.js';
|
|
4
|
-
import type { RowRef } from '
|
|
9
|
+
import type { RowRef } from '../state/index.js';
|
|
5
10
|
import type { InvocationContext, Tool, ToolOutcome } from './tool.js';
|
|
6
11
|
/**
|
|
7
12
|
* Every point at which the loop hands control to a plugin.
|
|
@@ -24,6 +29,12 @@ export interface ToolAuthorizationRequest {
|
|
|
24
29
|
readonly toolCall: ParsedToolCall;
|
|
25
30
|
readonly agent: AgentDefinition;
|
|
26
31
|
readonly threadId: string;
|
|
32
|
+
/** Runtime provenance is explicit; an absent origin is an ordinary model tool call. */
|
|
33
|
+
readonly origin?: {
|
|
34
|
+
readonly owner: string;
|
|
35
|
+
readonly candidateSeq: Seq;
|
|
36
|
+
readonly requestSeq: Seq;
|
|
37
|
+
};
|
|
27
38
|
}
|
|
28
39
|
/** A denial that tells the model why, so it can change course rather than retry the call. */
|
|
29
40
|
export interface ToolDenial {
|
|
@@ -147,6 +158,18 @@ export type StopVerdict = {
|
|
|
147
158
|
decision: 'reject';
|
|
148
159
|
reason: string;
|
|
149
160
|
source: ExtensionRecord;
|
|
161
|
+
} | {
|
|
162
|
+
decision: 'prepare';
|
|
163
|
+
request: CompletionRequest;
|
|
164
|
+
};
|
|
165
|
+
/** A pure plan. Core owns its durable dispatch after every stop check permits preparation. */
|
|
166
|
+
export type CompletionRequest = {
|
|
167
|
+
readonly owner: string;
|
|
168
|
+
readonly key: string;
|
|
169
|
+
readonly operation: {
|
|
170
|
+
readonly name: string;
|
|
171
|
+
readonly arguments: JsonObject;
|
|
172
|
+
};
|
|
150
173
|
};
|
|
151
174
|
/** What the checks concluded together. */
|
|
152
175
|
export type StopJudgement = {
|
|
@@ -157,16 +180,26 @@ export type StopJudgement = {
|
|
|
157
180
|
} | {
|
|
158
181
|
kind: 'reject';
|
|
159
182
|
rejections: TurnRejection[];
|
|
183
|
+
} | {
|
|
184
|
+
kind: 'prepare';
|
|
185
|
+
requests: CompletionRequest[];
|
|
160
186
|
};
|
|
161
187
|
/**
|
|
162
188
|
* Asks every stop check about an answer. The outcome is independent of registration order: any
|
|
163
|
-
* rejection ends the turn, otherwise any continuation sends the model back, otherwise
|
|
164
|
-
* is accepted. A throwing check, or an invalid
|
|
189
|
+
* rejection ends the turn, otherwise any continuation sends the model back, otherwise a preparation
|
|
190
|
+
* plan runs before rejudgment, otherwise the answer is accepted. A throwing check, or an invalid
|
|
191
|
+
* verdict, fails the check without deciding anything.
|
|
165
192
|
* The facts the checks declare they observed collect in `observations`, which the caller validates
|
|
166
193
|
* when it records the outcome.
|
|
167
194
|
*/
|
|
168
195
|
export declare function judgeAnswer(runtime: LoopRuntime, stop: Omit<TurnStop, 'observe'>, observations: StopObservation[]): Promise<StopJudgement>;
|
|
169
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Runs `use` with the confinement operation of one tool execution, opened for it and ended when it
|
|
198
|
+
* settles, whatever it did: the file access its tool was given dies with the call, and what it still
|
|
199
|
+
* had open is closed.
|
|
200
|
+
*/
|
|
201
|
+
export declare function withOperation<T>(runtime: LoopRuntime, threadId: string, signal: AbortSignal, use: (operation: InvocationContext['operation']) => Promise<T>): Promise<T>;
|
|
202
|
+
/** Runs middleware and binds its final result to the dispatched call, for every execution path. */
|
|
170
203
|
export declare const executeTool: (runtime: LoopRuntime, invocation: ToolInvocation, run: () => Promise<ToolOutcome>) => Promise<ToolOutcome>;
|
|
171
204
|
/**
|
|
172
205
|
* A model request as `lagent/llm/request` middleware sees it. The turn's route is fixed, so `model`
|
package/dist/loop/index.d.ts
CHANGED
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What the rest of the package may use from the loop.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* activation drives execution through LoopAgent; plugins extend it through tools and hooks.
|
|
2
|
+
* What the rest of the package may use from the loop: live execution against an activation. A live
|
|
3
|
+
* thread activation drives execution through TurnRunner; plugins extend it through tools and hooks.
|
|
4
|
+
* What the journal records, without a runtime, is `state/`.
|
|
6
5
|
*/
|
|
7
|
-
export * from './projections.js';
|
|
8
|
-
export * from './surface.js';
|
|
9
|
-
export * from './threadState.js';
|
|
10
6
|
export * from './chunks.js';
|
|
11
7
|
export * from './errors.js';
|
|
12
|
-
export * from './limits.js';
|
|
13
8
|
export * from './runtime.js';
|
|
14
|
-
export { Inbox } from './inbox.js';
|
|
15
|
-
export { isVeto } from './inbox.js';
|
|
16
|
-
export type { BirthSpec, ForkOpening, FreshOpening } from './opening.js';
|
|
17
|
-
export type { Refusal, RowsResult, RowsWrite, InputReceipt, SendOptions, SendOutcome, WithdrawOptions, WithdrawOutcome, WithdrawRows, WriteRows, } from './inbox.js';
|
|
18
|
-
export { closeInterruptedTurn, hasThreadWork, inputFate, lastAssistantMessage, refusedReplacement, unfinishedConfirmations, } from './state.js';
|
|
19
|
-
export type { InputFate } from './state.js';
|
|
20
|
-
export * from './summary.js';
|
|
21
|
-
export * from './requests.js';
|
|
22
|
-
export { chainStanding } from './chain.js';
|
|
23
|
-
export type { ChainStanding } from './chain.js';
|
|
24
|
-
export * from './wake.js';
|
|
25
|
-
export * from './route.js';
|
|
26
|
-
export * from './holds.js';
|
|
27
|
-
export * from './continuation.js';
|
|
28
|
-
export * from './forks.js';
|
|
29
9
|
export * from './hooks.js';
|
|
30
10
|
export type { AuxiliaryCall, AuxiliaryReply } from './auxiliary.js';
|
|
31
|
-
export
|
|
32
|
-
export type { ReplacementContext, ReplacementInput } from './replace.js';
|
|
11
|
+
export * from './agent.js';
|
|
33
12
|
export * from './strategy.js';
|
|
34
13
|
export * from './tool.js';
|
|
35
|
-
export { declarePolicyState
|
|
36
|
-
export {
|
|
37
|
-
export type { CompactOptions, ServedRun } from './
|
|
14
|
+
export { declarePolicyState } from './authorization.js';
|
|
15
|
+
export { TurnRunner } from './runner.js';
|
|
16
|
+
export type { CompactOptions, ServedRun } from './runner.js';
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Seq, TurnEndReason } from '../records/journal.js';
|
|
2
|
+
import type { DeepReadonly, JsonValue } from '../util/json.js';
|
|
3
|
+
import type { SurfacePrepareOutcome } from './hooks.js';
|
|
4
|
+
import type { Lease, LoopRuntime } from './runtime.js';
|
|
5
|
+
/**
|
|
6
|
+
* What one `compact()` is given: a cancellation signal, and options for the strategy, which the
|
|
7
|
+
* engine passes on as they are and never reads.
|
|
8
|
+
*/
|
|
9
|
+
export type CompactOptions = {
|
|
10
|
+
readonly signal?: AbortSignal;
|
|
11
|
+
readonly options?: JsonValue;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The run request an execution serves, as its turns see it: the id every `turn/start` records, the
|
|
15
|
+
* attempt cutoff of the execution, and the continuation decision, asked after each turn whether to
|
|
16
|
+
* open another.
|
|
17
|
+
*/
|
|
18
|
+
export type ServedRun = {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly attemptCutoff: Seq;
|
|
21
|
+
continueAfter(ending: DeepReadonly<TurnEndReason>, turnStart: Seq): boolean;
|
|
22
|
+
};
|
|
23
|
+
/** Executes journal-driven turns. Admission, readiness and cancellation ownership live outside the loop. */
|
|
24
|
+
export declare class TurnRunner {
|
|
25
|
+
private readonly runtime;
|
|
26
|
+
private readonly threadId;
|
|
27
|
+
private readonly agentName;
|
|
28
|
+
private readonly inbox;
|
|
29
|
+
constructor(options: {
|
|
30
|
+
runtime: LoopRuntime;
|
|
31
|
+
threadId: string;
|
|
32
|
+
agentName: string;
|
|
33
|
+
});
|
|
34
|
+
private stepsTaken;
|
|
35
|
+
/**
|
|
36
|
+
* The caller already owns the lease, has resolved the agent in a ready runtime, has decided the
|
|
37
|
+
* run should advance, and supplies a combined turn signal and the run it serves. Opens a turn,
|
|
38
|
+
* then another for as long as the run's continuation decision says to advance.
|
|
39
|
+
*/
|
|
40
|
+
run(options: {
|
|
41
|
+
signal: AbortSignal;
|
|
42
|
+
lease: Lease;
|
|
43
|
+
served: ServedRun;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* One turn: decide, do it, append what happened, decide again.
|
|
47
|
+
*
|
|
48
|
+
* Every branch of the decision lives in {@link nextAction}; this only carries out what it asked
|
|
49
|
+
* for.
|
|
50
|
+
*/
|
|
51
|
+
private turn;
|
|
52
|
+
/**
|
|
53
|
+
* Why a judgment made under `fence` may not stand, or `null` when it does. `activation-changed`:
|
|
54
|
+
* the activation's plugins changed since readiness, and takes precedence. `judgment-invalidated`:
|
|
55
|
+
* the constraint registrations the thread requires, by origin too, are not those it was judged
|
|
56
|
+
* under, one missing or replaced, or a fact a check declared it observed reads differently now.
|
|
57
|
+
* Such a registration's owner, or a plugin of the activation, can be the checker that would
|
|
58
|
+
* object, and core accepts whatever no check objects to; one that came back meanwhile did not
|
|
59
|
+
* judge it; and a verdict resting on a fact that moved while another check awaited is no verdict
|
|
60
|
+
* on the answer as it stands. Read inside the write that records the judgment.
|
|
61
|
+
*/
|
|
62
|
+
private fenced;
|
|
63
|
+
/**
|
|
64
|
+
* Records how a judged turn ends, `ending` the checks' verdict or their failure, decided inside
|
|
65
|
+
* the write: one whose fence broke ends the turn `interrupted` instead, the answer still owed its
|
|
66
|
+
* checks, so a later run judges it again, held while a required owner is missing, rather than
|
|
67
|
+
* accepting it unchecked or failing the task because its checker was briefly gone or a fact it
|
|
68
|
+
* read moved. Returns the reason recorded.
|
|
69
|
+
*/
|
|
70
|
+
private endJudged;
|
|
71
|
+
/**
|
|
72
|
+
* Records `turn/start` with the thread's route and the run the turn serves, decided in the write's
|
|
73
|
+
* builder, the turn's opening point: a cancel that landed while the loop awaited opens nothing,
|
|
74
|
+
* and a route whose provider is not registered opens nothing either, claims no input, and throws
|
|
75
|
+
* `RouteUnavailableError`, which fails the run before the turn. A provider lost once the row is
|
|
76
|
+
* built, its append still waiting on storage included, fails the opened turn.
|
|
77
|
+
*
|
|
78
|
+
* The route is the turn's for good, since every model step builds its client from it; it cannot
|
|
79
|
+
* change under an execution, which holds the thread while its request is pending.
|
|
80
|
+
*/
|
|
81
|
+
private openTurn;
|
|
82
|
+
/** The thread's route as its rows stand. */
|
|
83
|
+
private threadRoute;
|
|
84
|
+
/**
|
|
85
|
+
* Asks the thread's strategy for a plan for a caller between turns (the `request` trigger): no turn
|
|
86
|
+
* opens, no step hook runs and no queued input is claimed; the route is resolved as a turn's would
|
|
87
|
+
* be. The caller owns the lease, as for a run, and composed the signal as a run's is. An
|
|
88
|
+
* interrupted open turn is closed first, as a run closes it; a thread with a tool call unanswered,
|
|
89
|
+
* a confirmation open or an answer unjudged is refused with `ThreadUnsettledError`. Resolves with
|
|
90
|
+
* the outcome, cancellation included.
|
|
91
|
+
*/
|
|
92
|
+
compact(options: {
|
|
93
|
+
signal: AbortSignal;
|
|
94
|
+
lease: Lease;
|
|
95
|
+
options: JsonValue | null;
|
|
96
|
+
}): Promise<SurfacePrepareOutcome>;
|
|
97
|
+
/** One request to the thread's strategy, carried out by the engine. */
|
|
98
|
+
private prepare;
|
|
99
|
+
/**
|
|
100
|
+
* Asks the stop checks about the provisional answer. Returns how the turn ends — accepted as
|
|
101
|
+
* `completed`, or `rejected` — or `null` once their continuation messages are recorded.
|
|
102
|
+
*
|
|
103
|
+
* An acceptance ends the turn at once. Steering that arrived while the checks ran is still in the
|
|
104
|
+
* `next-step` inbox, and `run()` opens another turn for it.
|
|
105
|
+
*/
|
|
106
|
+
private judge;
|
|
107
|
+
/**
|
|
108
|
+
* Lets the surface be prepared (`pressure`), then records plugin contributions and the claimed
|
|
109
|
+
* input, then asks the model.
|
|
110
|
+
*
|
|
111
|
+
* The dispatch is the first `await` between deciding this step and recording its input, and the
|
|
112
|
+
* lease does not exclude `send()` or `withdraw()`. So once it settles the signal is checked and the
|
|
113
|
+
* inbox read again: only input this step was decided on that is still queued is claimed, so a
|
|
114
|
+
* withdrawn input stays withdrawn, and input that arrived meanwhile waits for the next step. A step
|
|
115
|
+
* left with nothing to claim and no reply owed ends without a model call, and the decider decides
|
|
116
|
+
* again.
|
|
117
|
+
*/
|
|
118
|
+
private askModel;
|
|
119
|
+
/** Reports a dispatch a listener ended in failure; one that was cancelled is the turn's to report. */
|
|
120
|
+
private reportFailedDispatch;
|
|
121
|
+
/** Runs a step's tool calls. What they did — answered, waited, ended the turn — lands in the journal. */
|
|
122
|
+
private answerCalls;
|
|
123
|
+
/**
|
|
124
|
+
* One model call. What it produced goes to the journal — `assistant/message`, or
|
|
125
|
+
* `assistant/attempt` when the stream gave nothing usable, which keeps it off the conversation.
|
|
126
|
+
*
|
|
127
|
+
* A request the provider refused as longer than the context window is recorded as an attempt
|
|
128
|
+
* marked `overflow`, and the thread's strategy is asked with `overflow` inside this step, before
|
|
129
|
+
* any `error` row. The rule is one sentence: an overflow fails the turn unless that request
|
|
130
|
+
* committed a replacement, however it ended. When it did, the step ends without an error and the
|
|
131
|
+
* decider asks the model again, from the replaced surface, in a new step.
|
|
132
|
+
*/
|
|
133
|
+
private callModel;
|
|
134
|
+
}
|
package/dist/loop/runtime.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Context, Scoped } from '@leuduan/cordis';
|
|
2
|
-
import type { ModelCallClient
|
|
2
|
+
import type { ModelCallClient } from '../llm/failure.js';
|
|
3
|
+
import type { ModelRoute, ModelSelection } from '../llm/provider.js';
|
|
4
|
+
import type { ToolSpec } from '../llm/primitives.js';
|
|
3
5
|
import type { DeepReadonly } from '../util/json.js';
|
|
4
6
|
import type { Journal } from '../journal/index.js';
|
|
5
|
-
import type { AgentDefinition } from '
|
|
7
|
+
import type { AgentDefinition } from './agent.js';
|
|
6
8
|
import type { ChunkChannel } from './chunks.js';
|
|
7
|
-
import type { TurnLimits } from '
|
|
9
|
+
import type { TurnLimits } from '../state/index.js';
|
|
8
10
|
import type { SurfaceStrategy } from './strategy.js';
|
|
9
11
|
import type { Tool } from './tool.js';
|
|
10
|
-
/** Anything advertised to the model — a
|
|
12
|
+
/** Anything advertised to the model — a registered tool or a sub-agent. */
|
|
11
13
|
export type ToolEntry = {
|
|
12
14
|
readonly name: string;
|
|
13
15
|
readonly tool: Tool;
|
|
@@ -17,17 +19,6 @@ export type ToolEntry = {
|
|
|
17
19
|
*/
|
|
18
20
|
readonly spec: DeepReadonly<ToolSpec>;
|
|
19
21
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Route fields to fold over a route (`LlmService.resolveRoute`): absent fields keep the route's own;
|
|
22
|
-
* naming a different provider resets what is left unnamed to that provider's defaults. A `null`
|
|
23
|
-
* effort names the provider's own default, as a route records it, so a complete route resolves to
|
|
24
|
-
* itself.
|
|
25
|
-
*/
|
|
26
|
-
export type ModelSelection = {
|
|
27
|
-
readonly provider?: string;
|
|
28
|
-
readonly model?: string;
|
|
29
|
-
readonly thinkingEffort?: ThinkingEffort | null;
|
|
30
|
-
};
|
|
31
22
|
/**
|
|
32
23
|
* What the loop runs against.
|
|
33
24
|
*
|
|
@@ -72,7 +63,7 @@ export interface LoopRuntime extends LoopServices {
|
|
|
72
63
|
* new once they have, and ends the turn as `interrupted` at its next boundary.
|
|
73
64
|
*/
|
|
74
65
|
stale(): boolean;
|
|
75
|
-
/** The strategy that prepares the thread's surface, if one is provided (`
|
|
66
|
+
/** The strategy that prepares the thread's surface, if one is provided (`registerSurfaceStrategy`). */
|
|
76
67
|
strategy(): SurfaceStrategy | undefined;
|
|
77
68
|
}
|
|
78
69
|
/**
|
package/dist/loop/strategy.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from '@leuduan/cordis';
|
|
2
|
+
import type { ExtensionRecord, QueuedInput, ReplacementTrigger } from '../records/journal.js';
|
|
2
3
|
import type { JsonValue } from '../util/json.js';
|
|
3
|
-
import type { ModelRoute } from '../llm/
|
|
4
|
+
import type { ModelRoute } from '../llm/provider.js';
|
|
4
5
|
import type { AuxiliaryCall, AuxiliaryReply } from './auxiliary.js';
|
|
5
|
-
import type { ReplacementInput } from '
|
|
6
|
+
import type { ReplacementInput } from '../state/index.js';
|
|
6
7
|
/** What a strategy is told about one request to prepare the surface. */
|
|
7
8
|
export type SurfacePrepareInput = {
|
|
8
9
|
readonly threadId: string;
|
|
@@ -69,3 +70,11 @@ export interface SurfaceStrategy {
|
|
|
69
70
|
readonly name: string;
|
|
70
71
|
plan(input: SurfacePrepareInput): SurfacePlan | Promise<SurfacePlan>;
|
|
71
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Makes `strategy` the one that prepares `threadId`'s surface, for as long as the calling plugin's
|
|
75
|
+
* fiber lives. A thread runs one strategy: a second, from another mount or installation, throws, so
|
|
76
|
+
* the plugin that came later fails, and with it the activation, rather than running beside the first.
|
|
77
|
+
*/
|
|
78
|
+
export declare function registerSurfaceStrategy(ctx: Context, threadId: string, strategy: SurfaceStrategy): void;
|
|
79
|
+
/** The strategy that prepares `threadId`'s surface, if any. */
|
|
80
|
+
export declare function strategyOf(ctx: Context, threadId: string): SurfaceStrategy | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { QueuedInput, ReplacementTrigger } from '../
|
|
1
|
+
import type { QueuedInput, ReplacementTrigger } from '../records/journal.js';
|
|
2
2
|
import type { JsonValue } from '../util/json.js';
|
|
3
|
-
import { type ModelRoute } from '../llm/
|
|
3
|
+
import { type ModelRoute } from '../llm/provider.js';
|
|
4
4
|
import type { SurfacePrepareOutcome } from './hooks.js';
|
|
5
5
|
import type { Lease, LoopRuntime } from './runtime.js';
|
|
6
6
|
/** One request to prepare the surface, as the loop or `thread.compact()` starts it. */
|
package/dist/loop/tool.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Context } from '@leuduan/cordis';
|
|
2
|
-
import type { InterruptionPolicy,
|
|
2
|
+
import type { InterruptionPolicy, Seq, ThreadEnvironment } from '../records/journal.js';
|
|
3
|
+
import type { JsonValue } from '../util/json.js';
|
|
4
|
+
import type { ToolResult } from '../records/toolResult.js';
|
|
3
5
|
import type { ReadonlyJsonValue } from '../util/json.js';
|
|
4
|
-
import type { ModelRoute
|
|
6
|
+
import type { ModelRoute } from '../llm/provider.js';
|
|
7
|
+
import type { ParsedToolCall, ToolCall, ToolSpec } from '../llm/primitives.js';
|
|
8
|
+
/** An error result answering the dispatched call. */
|
|
9
|
+
export declare const errorResult: (call: ToolCall, output: string) => ToolResult;
|
|
5
10
|
/**
|
|
6
11
|
* How a tool's calls may overlap. `exclusive` forms a barrier: it starts only once the calls before
|
|
7
12
|
* it have settled, and nothing starts beside it.
|
|
@@ -39,7 +44,7 @@ export type ResolvedWait = {
|
|
|
39
44
|
};
|
|
40
45
|
};
|
|
41
46
|
/**
|
|
42
|
-
* What a tool implements. `defineTool` in `
|
|
47
|
+
* What a tool implements. `defineTool` in `services/tools.ts` builds one, with validation and timing; this
|
|
43
48
|
* is the contract underneath it.
|
|
44
49
|
*/
|
|
45
50
|
export interface Tool {
|
|
@@ -75,14 +80,14 @@ export interface InvocationContext {
|
|
|
75
80
|
readonly threadId: string;
|
|
76
81
|
readonly callId: string;
|
|
77
82
|
/**
|
|
78
|
-
* The `tool/call` row this invocation
|
|
79
|
-
*
|
|
83
|
+
* The `tool/call` or runtime `execution/requested` row this invocation serves. The durable
|
|
84
|
+
* identity of the dispatch: unique in the journal, where a provider's `callId` may not be.
|
|
80
85
|
*/
|
|
81
86
|
readonly callSeq: Seq;
|
|
82
87
|
/**
|
|
83
88
|
* The `llm/request` row that produced this call: exactly what the model was sent when it asked.
|
|
84
89
|
* Where a tool that forks this thread cuts, so the fork shares that request's cached prefix.
|
|
85
|
-
* `null`
|
|
90
|
+
* `null` for runtime completion preparation, which has no model request.
|
|
86
91
|
*/
|
|
87
92
|
readonly requestSeq: Seq | null;
|
|
88
93
|
/** Where this thread's work happens. */
|
package/dist/loop/toolCalls.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ThreadEnvironment } from '../records/journal.js';
|
|
2
|
+
import type { ToolCall } from '../llm/primitives.js';
|
|
3
|
+
import type { ModelRoute } from '../llm/provider.js';
|
|
3
4
|
import type { LoopRuntime } from './runtime.js';
|
|
4
5
|
export type ExecuteToolCallsOptions = {
|
|
5
6
|
runtime: LoopRuntime;
|
|
@@ -13,8 +14,6 @@ export type ExecuteToolCallsOptions = {
|
|
|
13
14
|
calls: readonly ToolCall[];
|
|
14
15
|
signal: AbortSignal;
|
|
15
16
|
};
|
|
16
|
-
/** An error result for a call. */
|
|
17
|
-
export declare const errorResult: (call: ToolCall, output: string) => ToolResult;
|
|
18
17
|
/**
|
|
19
18
|
* Runs one step's tool calls.
|
|
20
19
|
*
|
|
@@ -34,9 +33,3 @@ export declare const errorResult: (call: ToolCall, output: string) => ToolResult
|
|
|
34
33
|
* disagreeing.
|
|
35
34
|
*/
|
|
36
35
|
export declare function executeToolCalls(options: ExecuteToolCallsOptions): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Declares the `ext` rows of one plugin event state a `lagent/tool/authorize` listener decides
|
|
39
|
-
* from: one that lands while a call is authorized sends the decision round again, which no other
|
|
40
|
-
* `ext` row does. `defineExtensionEvent({ policyState: true })` is the way in.
|
|
41
|
-
*/
|
|
42
|
-
export declare function declarePolicyState(record: Pick<ExtensionRecord, 'plugin' | 'instance_id' | 'kind'>): void;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The plugin-authoring
|
|
2
|
+
* The plugin-authoring door: what a plugin imports beside `@leuduan/cordis`.
|
|
3
3
|
*
|
|
4
4
|
* Registering a tool, an agent or a prompt contribution; granting a tool; defining, mounting and
|
|
5
5
|
* validating the configuration of a preset (`definePreset`, `mountPreset`, `parsePresetConfig`), and
|
|
6
6
|
* handing one down to the children a thread's calls create (`handDown`);
|
|
7
7
|
* defining a durable `ext` event, writing it beside a send or a creation (`WriteRows`), and reading what a thread was
|
|
8
8
|
* told; defining a set of durable modes (`defineModes`); adding a typed value to every thread's catalog entry (`defineContribution`); claiming a thread for one plugin, refusing a mount in a thread's scope (`requireUnscoped`)
|
|
9
|
-
* and refusing a missing root service (`requireService`);
|
|
10
|
-
*
|
|
9
|
+
* and refusing a missing root service (`requireService`); reading paths and git as the shipped tools
|
|
10
|
+
* do (`sys/`). A tool touches files and starts processes through `InvocationContext.operation`, so the
|
|
11
|
+
* confinement policy judges them; the raw process launches (`spawnCommand`, `runToCompletion`) are on
|
|
12
|
+
* the root door, for the host's own processes;
|
|
11
13
|
* the contracts a tool and a step hook implement; and the `ctx.*` service types every plugin reads.
|
|
12
14
|
* A value lives on one door: the application API is the root entry point, the model contracts are
|
|
13
15
|
* `@leuduan/lagent/llm`, the serialized shapes (`JournalEvent`, `Seq`, `ToolResult`, `stepContribution`,
|
|
14
|
-
* `toJsonSchema`) are `@leuduan/lagent/
|
|
16
|
+
* `toJsonSchema`) are `@leuduan/lagent/records`.
|
|
15
17
|
*/
|
|
16
18
|
export * from './context.js';
|
|
17
|
-
export { defineTool, errorResult,
|
|
18
|
-
export type { JsonSchemaParameters, ToolDefinition, ToolReply } from './
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export type {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export type {
|
|
29
|
-
export { handDown } from './services/presets.js';
|
|
30
|
-
export type { HandDown } from './services/presets.js';
|
|
31
|
-
export type { AgentDefinition, AgentDefinitionInput } from './models/index.js';
|
|
19
|
+
export { defineTool, errorResult, grantTool, registerTool } from './services/tools.js';
|
|
20
|
+
export type { JsonSchemaParameters, ToolDefinition, ToolReply } from './services/tools.js';
|
|
21
|
+
export { claimThread, drainBeforeUnload, requireService, requireUnscoped } from './services/plugins.js';
|
|
22
|
+
export { defineModes } from './services/modes.js';
|
|
23
|
+
export type { Modes, ModesDefinition } from './services/modes.js';
|
|
24
|
+
export { AgentSelectorSchema, isScopedAgentName, registerAgent, selects } from './services/agents.js';
|
|
25
|
+
export type { AgentSelector } from './services/agents.js';
|
|
26
|
+
export { definePreset, mountPreset, parsePresetConfig } from './services/presets/definition.js';
|
|
27
|
+
export type { Preset, PresetInstallation, PresetMountOptions, PresetPlace, PresetPlacement, PresetSelection, } from './services/presets/definition.js';
|
|
28
|
+
export { handDown } from './services/presets/installations.js';
|
|
29
|
+
export type { HandDown } from './services/presets/installations.js';
|
|
30
|
+
export type { AgentDefinition, AgentDefinitionInput } from './loop/index.js';
|
|
32
31
|
export { contributePrompt } from './services/prompts.js';
|
|
33
|
-
export { defineContribution } from './services/
|
|
34
|
-
export type { ContributionDefinition, ContributionReading } from './services/
|
|
32
|
+
export { defineContribution } from './services/catalogContributions.js';
|
|
33
|
+
export type { ContributionDefinition, ContributionReading } from './services/catalogContributions.js';
|
|
35
34
|
export type { PromptContribution, PromptRenderInput, PromptSlot } from './services/prompts.js';
|
|
36
|
-
export { ExtensionVersionError, defineExtensionEvent, latestNotice, latestVisible, tellOnStep, } from './
|
|
37
|
-
export type { NoticeEvent, StepNotice, ToldNotice, ToldNotices } from './
|
|
35
|
+
export { ExtensionVersionError, defineExtensionEvent, latestNotice, latestVisible, tellOnStep, } from './services/extensionEvents.js';
|
|
36
|
+
export type { NoticeEvent, StepNotice, ToldNotice, ToldNotices } from './services/extensionEvents.js';
|
|
38
37
|
export { ProjectionFailedError, projection } from './journal/index.js';
|
|
39
38
|
export type { AppendOptions, Committed, PluginJournal, PluginProjection, Transaction } from './journal/index.js';
|
|
40
39
|
export type { CallerChain, OriginBreak, OriginOpening, Origins, RequiredOwner, RequiredOwners, } from './journal/index.js';
|
|
41
|
-
export type { BirthSpec, ForkOpening, FreshOpening, Refusal, RowsResult, RowsWrite, WriteRows } from './
|
|
42
|
-
export { isWaitRequest,
|
|
43
|
-
export {
|
|
44
|
-
export
|
|
40
|
+
export type { BirthSpec, ForkOpening, FreshOpening, Refusal, RowsResult, RowsWrite, WriteRows } from './state/index.js';
|
|
41
|
+
export { isWaitRequest, waitFor } from './loop/index.js';
|
|
42
|
+
export { lastAssistantMessage } from './state/index.js';
|
|
43
|
+
export { registerSurfaceStrategy } from './loop/index.js';
|
|
44
|
+
export type { AuxiliaryCall, AuxiliaryReply, CompletionRequest, InvocationContext, ModelRequestDraft, ModelStep, SentModelRequest, SentRequest, StopVerdict, AuxiliaryAnswer, FinalPlan, SurfacePlan, SurfacePrepareInput, SurfaceStrategy, Tool, ToolAuthorizationRequest, ToolDenial, ToolEntry, ToolExecutionMode, ToolInvocation, ToolOutcome, ToolPolicyDecision, TurnStop, WaitRequest, ResolvedWait, } from './loop/index.js';
|
|
45
|
+
export type { ReplacementInput } from './state/index.js';
|
|
45
46
|
export { stableStringify } from './util/json.js';
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
export type { Clock, TimerQueue } from './kit/timers.js';
|
|
49
|
-
export { pathBoundary } from './sys/paths.js';
|
|
50
|
-
export type { BoundaryScope, PathAccess, PathBoundary } from './sys/paths.js';
|
|
51
|
-
export { runToCompletion, spawnCommand } from './sys/spawn.js';
|
|
47
|
+
export { systemClock, timerQueue } from './util/timers.js';
|
|
48
|
+
export type { Clock, TimerQueue } from './util/timers.js';
|
|
52
49
|
export type { AppendEntry } from './journal/index.js';
|
|
53
|
-
export type { SpawnEnvironment
|
|
50
|
+
export type { SpawnEnvironment } from './sys/spawn.js';
|
package/dist/plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as N}from"./chunks/DDZ7YF26.js";import{b as t}from"./chunks/KUZCL2SH.js";import{c as P}from"./chunks/CQEVREBT.js";import{b as w,d as F}from"./chunks/HK6ZSONF.js";import{a as M}from"./chunks/7VAPNE3L.js";import{b}from"./chunks/EPYQ5M3B.js";import"./chunks/5IRF47YB.js";import{a as u,b as S,e as E}from"./chunks/OL5A6ITQ.js";import{b as A,c as T,e as h}from"./chunks/JFX2MXBA.js";import{a as l,b as c,c as d,d as g}from"./chunks/S34ZA2R6.js";import{a as q,b as y,c as C,d as j,e as v}from"./chunks/6FRNHMCV.js";import{b as m,c as p,d as a,e as x}from"./chunks/CUK7CGC7.js";import{U as i,V as n,W as s,Y as f}from"./chunks/BPRCULZH.js";import"./chunks/FJLU4UH3.js";import"./chunks/DDANMY45.js";import{c as e,h as r,j as o}from"./chunks/BBCW2FZK.js";import"./chunks/MMNNZCBO.js";import"./chunks/G44LG6VL.js";import"./chunks/D4PQP5MA.js";export{p as AgentSelectorSchema,q as ExtensionVersionError,o as ProjectionFailedError,l as claimThread,b as contributePrompt,M as defineContribution,y as defineExtensionEvent,N as defineModes,u as definePreset,A as defineTool,c as drainBeforeUnload,i as errorResult,h as grantTool,P as handDown,x as isScopedAgentName,s as isWaitRequest,t as lastAssistantMessage,C as latestNotice,j as latestVisible,S as mountPreset,E as parsePresetConfig,r as projection,m as registerAgent,f as registerSurfaceStrategy,T as registerTool,d as requireService,g as requireUnscoped,a as selects,e as stableStringify,w as systemClock,v as tellOnStep,F as timerQueue,n as waitFor};
|