@leuduan/lagent 0.0.0-stage → 44.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +157 -2
- package/dist/chunks/2GCIWSOA.js +5 -0
- package/dist/chunks/2P47AHNK.js +7 -0
- package/dist/chunks/34KW6VNQ.js +1 -0
- package/dist/chunks/3UMZMPWW.js +1 -0
- package/dist/chunks/5IRF47YB.js +1 -0
- package/dist/chunks/6DRCKZ2C.js +1 -0
- package/dist/chunks/6FRNHMCV.js +1 -0
- package/dist/chunks/7LI64H5X.js +17 -0
- package/dist/chunks/7VAPNE3L.js +1 -0
- package/dist/chunks/ASSQZH3F.js +1 -0
- package/dist/chunks/B4FXK5ER.js +77 -0
- package/dist/chunks/BBCW2FZK.js +1 -0
- package/dist/chunks/BPRCULZH.js +1 -0
- package/dist/chunks/CANPZYTH.js +24 -0
- package/dist/chunks/CQEVREBT.js +1 -0
- package/dist/chunks/CUK7CGC7.js +1 -0
- package/dist/chunks/D4PQP5MA.js +3 -0
- package/dist/chunks/DDANMY45.js +3 -0
- package/dist/chunks/DDZ7YF26.js +1 -0
- package/dist/chunks/EMRB4KCN.js +6 -0
- package/dist/chunks/EPYQ5M3B.js +3 -0
- package/dist/chunks/FJLU4UH3.js +1 -0
- package/dist/chunks/G44LG6VL.js +1 -0
- package/dist/chunks/GGSVIIWJ.js +2 -0
- package/dist/chunks/HK6ZSONF.js +1 -0
- package/dist/chunks/IAAEP6VL.js +30 -0
- package/dist/chunks/JCTBX33H.js +36 -0
- package/dist/chunks/JFX2MXBA.js +4 -0
- package/dist/chunks/JFZZXVWD.js +15 -0
- package/dist/chunks/KUZCL2SH.js +1 -0
- package/dist/chunks/MHC6VPB4.js +7 -0
- package/dist/chunks/MMNNZCBO.js +5 -0
- package/dist/chunks/MNJ4SRF7.js +1 -0
- package/dist/chunks/N6IXG2VL.js +1 -0
- package/dist/chunks/OCBPT7KE.js +1 -0
- package/dist/chunks/OL5A6ITQ.js +1 -0
- package/dist/chunks/PUSUPTAT.js +1 -0
- package/dist/chunks/Q75FUN7D.js +2 -0
- package/dist/chunks/Q7S5LFGN.js +1 -0
- package/dist/chunks/RCIHV3KG.js +1 -0
- package/dist/chunks/S34ZA2R6.js +1 -0
- package/dist/chunks/SS3B5W34.js +12 -0
- package/dist/chunks/VYMT4TXD.js +1 -0
- package/dist/chunks/W57RW55W.js +1 -0
- package/dist/compositions/base.d.ts +11 -0
- package/dist/compositions/codex.d.ts +66 -0
- package/dist/compositions/codexPrompts.d.ts +56 -0
- package/dist/context.d.ts +109 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +1 -0
- package/dist/journal/catalog.d.ts +112 -0
- package/dist/journal/forkChain.d.ts +16 -0
- package/dist/journal/index.d.ts +15 -0
- package/dist/journal/journal.d.ts +475 -0
- package/dist/journal/projection.d.ts +87 -0
- package/dist/journal/store.d.ts +181 -0
- package/dist/llm/client.d.ts +135 -0
- package/dist/llm/content.d.ts +52 -0
- package/dist/llm/failure.d.ts +82 -0
- package/dist/llm/index.d.ts +22 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/primitives.d.ts +286 -0
- package/dist/llm/prompt.d.ts +21 -0
- package/dist/llm/provider.d.ts +74 -0
- package/dist/llm/readLedger.d.ts +24 -0
- package/dist/llm/request.d.ts +58 -0
- package/dist/loop/agent.d.ts +18 -0
- package/dist/loop/authorization.d.ts +41 -0
- package/dist/loop/auxiliary.d.ts +58 -0
- package/dist/loop/chunks.d.ts +27 -0
- package/dist/loop/completion.d.ts +17 -0
- package/dist/loop/errors.d.ts +139 -0
- package/dist/loop/hooks.d.ts +274 -0
- package/dist/loop/index.d.ts +16 -0
- package/dist/loop/runner.d.ts +134 -0
- package/dist/loop/runtime.d.ts +76 -0
- package/dist/loop/strategy.d.ts +80 -0
- package/dist/loop/surfacePrepare.d.ts +30 -0
- package/dist/loop/tool.d.ts +106 -0
- package/dist/loop/toolCalls.d.ts +35 -0
- package/dist/plugin.d.ts +50 -0
- package/dist/plugin.js +1 -0
- package/dist/plugins/agentsMd.d.ts +80 -0
- package/dist/plugins/agentsMd.js +1 -0
- package/dist/plugins/ask/index.d.ts +26 -0
- package/dist/plugins/ask/index.js +1 -0
- package/dist/plugins/ask/service.d.ts +125 -0
- package/dist/plugins/ask/tools.d.ts +9 -0
- package/dist/plugins/commands/index.d.ts +43 -0
- package/dist/plugins/commands/index.js +1 -0
- package/dist/plugins/commands/output.d.ts +115 -0
- package/dist/plugins/commands/record.d.ts +558 -0
- package/dist/plugins/commands/service.d.ts +321 -0
- package/dist/plugins/commands/shell.d.ts +25 -0
- package/dist/plugins/commands/tools.d.ts +10 -0
- package/dist/plugins/compaction/checkpoint.d.ts +94 -0
- package/dist/plugins/compaction/config.d.ts +133 -0
- package/dist/plugins/compaction/estimate.d.ts +37 -0
- package/dist/plugins/compaction/index.d.ts +87 -0
- package/dist/plugins/compaction/index.js +7 -0
- package/dist/plugins/compaction/planner.d.ts +207 -0
- package/dist/plugins/compaction/prune.d.ts +9 -0
- package/dist/plugins/compaction/record.d.ts +227 -0
- package/dist/plugins/compaction/segments.d.ts +23 -0
- package/dist/plugins/compaction/state.d.ts +68 -0
- package/dist/plugins/compaction/summarize.d.ts +13 -0
- package/dist/plugins/dateAndBranch.d.ts +47 -0
- package/dist/plugins/dateAndBranch.js +1 -0
- package/dist/plugins/delegations/answers.d.ts +39 -0
- package/dist/plugins/delegations/assignmentKey.d.ts +22 -0
- package/dist/plugins/delegations/cleanup.d.ts +161 -0
- package/dist/plugins/delegations/constraint.d.ts +76 -0
- package/dist/plugins/delegations/index.d.ts +39 -0
- package/dist/plugins/delegations/index.js +1 -0
- package/dist/plugins/delegations/notices.d.ts +261 -0
- package/dist/plugins/delegations/obligations.d.ts +210 -0
- package/dist/plugins/delegations/record.d.ts +633 -0
- package/dist/plugins/delegations/request.d.ts +384 -0
- package/dist/plugins/delegations/role.d.ts +30 -0
- package/dist/plugins/delegations/service.d.ts +563 -0
- package/dist/plugins/delegations/standing.d.ts +19 -0
- package/dist/plugins/delegations/stopCheck.d.ts +21 -0
- package/dist/plugins/delegations/tools.d.ts +71 -0
- package/dist/plugins/delegations/waitContracts.d.ts +118 -0
- package/dist/plugins/delegations/waitResolver.d.ts +116 -0
- package/dist/plugins/diagnostics/digest.d.ts +14 -0
- package/dist/plugins/diagnostics/index.d.ts +68 -0
- package/dist/plugins/diagnostics/index.js +1 -0
- package/dist/plugins/fileTools/config.d.ts +10 -0
- package/dist/plugins/fileTools/editFiles.d.ts +117 -0
- package/dist/plugins/fileTools/fsRead.d.ts +17 -0
- package/dist/plugins/fileTools/gitDiscovery.d.ts +9 -0
- package/dist/plugins/fileTools/index.d.ts +18 -0
- package/dist/plugins/fileTools/index.js +1 -0
- package/dist/plugins/fileTools/ripgrep.d.ts +20 -0
- package/dist/plugins/fileTools/textEdit.d.ts +67 -0
- package/dist/plugins/fileTools/tools.d.ts +6 -0
- package/dist/plugins/historyRecall/history.d.ts +9 -0
- package/dist/plugins/historyRecall/index.d.ts +31 -0
- package/dist/plugins/historyRecall/index.js +1 -0
- package/dist/plugins/historyRecall/render.d.ts +34 -0
- package/dist/plugins/historyRecall/tools.d.ts +4 -0
- package/dist/plugins/mcp/catalog.d.ts +36 -0
- package/dist/plugins/mcp/config.d.ts +63 -0
- package/dist/plugins/mcp/connection.d.ts +53 -0
- package/dist/plugins/mcp/errors.d.ts +32 -0
- package/dist/plugins/mcp/index.d.ts +33 -0
- package/dist/plugins/mcp/index.js +5 -0
- package/dist/plugins/mcp/mount.d.ts +98 -0
- package/dist/plugins/mcp/names.d.ts +25 -0
- package/dist/plugins/mcp/render.d.ts +29 -0
- package/dist/plugins/mcp/slots.d.ts +15 -0
- package/dist/plugins/mcp/stdio.d.ts +49 -0
- package/dist/plugins/mcp/tools.d.ts +41 -0
- package/dist/plugins/mcp/version.d.ts +2 -0
- package/dist/plugins/routeNotice.d.ts +22 -0
- package/dist/plugins/routeNotice.js +1 -0
- package/dist/plugins/sandbox/absent.d.ts +33 -0
- package/dist/plugins/sandbox/client.d.ts +39 -0
- package/dist/plugins/sandbox/files.d.ts +28 -0
- package/dist/plugins/sandbox/index.d.ts +52 -0
- package/dist/plugins/sandbox/index.js +4 -0
- package/dist/plugins/sandbox/mode.d.ts +57 -0
- package/dist/plugins/sandbox/policy.d.ts +163 -0
- package/dist/plugins/sandbox/protocol.d.ts +107 -0
- package/dist/plugins/sandbox/service.d.ts +153 -0
- package/dist/plugins/sandbox/worker.d.ts +12 -0
- package/dist/plugins/sandbox/worker.js +1 -0
- package/dist/plugins/schedules/index.d.ts +21 -0
- package/dist/plugins/schedules/index.js +5 -0
- package/dist/plugins/schedules/record.d.ts +396 -0
- package/dist/plugins/schedules/service.d.ts +120 -0
- package/dist/plugins/schedules/time.d.ts +26 -0
- package/dist/plugins/schedules/tools.d.ts +6 -0
- package/dist/plugins/skills/discovery.d.ts +83 -0
- package/dist/plugins/skills/index.d.ts +31 -0
- package/dist/plugins/skills/index.js +1 -0
- package/dist/plugins/skills/tools.d.ts +11 -0
- package/dist/plugins/subAgents/availableRoutes.d.ts +53 -0
- package/dist/plugins/subAgents/index.d.ts +67 -0
- package/dist/plugins/subAgents/index.js +1 -0
- package/dist/plugins/subAgents/tools.d.ts +67 -0
- package/dist/plugins/threadDirs.d.ts +36 -0
- package/dist/plugins/threadDirs.js +1 -0
- package/dist/plugins/toolPolicy/index.d.ts +61 -0
- package/dist/plugins/toolPolicy/index.js +1 -0
- package/dist/plugins/truncateToolOutput.d.ts +30 -0
- package/dist/plugins/truncateToolOutput.js +6 -0
- package/dist/plugins/usage/index.d.ts +26 -0
- package/dist/plugins/usage/index.js +1 -0
- package/dist/plugins/usage/tracker.d.ts +34 -0
- package/dist/plugins/verify/index.d.ts +27 -0
- package/dist/plugins/verify/index.js +6 -0
- package/dist/plugins/verify/judgement.d.ts +16 -0
- package/dist/plugins/verify/record.d.ts +382 -0
- package/dist/plugins/verify/service.d.ts +93 -0
- package/dist/plugins/verify/state.d.ts +58 -0
- package/dist/plugins/webTools/html.d.ts +23 -0
- package/dist/plugins/webTools/index.d.ts +34 -0
- package/dist/plugins/webTools/index.js +1 -0
- package/dist/plugins/webTools/network.d.ts +23 -0
- package/dist/plugins/webTools/web.d.ts +32 -0
- package/dist/plugins/workflows/assignment.d.ts +20 -0
- package/dist/plugins/workflows/cleanup.d.ts +38 -0
- package/dist/plugins/workflows/definition.d.ts +184 -0
- package/dist/plugins/workflows/entryPlan.d.ts +95 -0
- package/dist/plugins/workflows/hostBindings.d.ts +146 -0
- package/dist/plugins/workflows/index.d.ts +28 -0
- package/dist/plugins/workflows/index.js +11 -0
- package/dist/plugins/workflows/observations.d.ts +81 -0
- package/dist/plugins/workflows/participantModels.d.ts +28 -0
- package/dist/plugins/workflows/participants.d.ts +143 -0
- package/dist/plugins/workflows/policy.d.ts +112 -0
- package/dist/plugins/workflows/record.d.ts +2849 -0
- package/dist/plugins/workflows/routing.d.ts +116 -0
- package/dist/plugins/workflows/schema.d.ts +26 -0
- package/dist/plugins/workflows/service.d.ts +477 -0
- package/dist/plugins/workflows/state.d.ts +373 -0
- package/dist/plugins/workflows/stopCheck.d.ts +13 -0
- package/dist/plugins/workflows/tools.d.ts +13 -0
- package/dist/plugins/workflows/view.d.ts +103 -0
- package/dist/plugins/workflows/workStatus.d.ts +21 -0
- package/dist/plugins/workspaceNotice.d.ts +36 -0
- package/dist/plugins/workspaceNotice.js +1 -0
- package/dist/providers/anthropic.d.ts +178 -0
- package/dist/providers/anthropicMessages.d.ts +66 -0
- package/dist/providers/codex.d.ts +71 -0
- package/dist/providers/codexAuth.d.ts +116 -0
- package/dist/providers/deepseek.d.ts +59 -0
- package/dist/providers/failure.d.ts +23 -0
- package/dist/providers/gateway.d.ts +24 -0
- package/dist/providers/index.d.ts +18 -0
- package/dist/providers/index.js +6 -0
- package/dist/providers/openaiChat.d.ts +73 -0
- package/dist/providers/openaiResponses.d.ts +109 -0
- package/dist/providers/opencodeCopilot.d.ts +23 -0
- package/dist/providers/opencodeGo.d.ts +109 -0
- package/dist/providers/shared.d.ts +112 -0
- package/dist/providers/stream.d.ts +156 -0
- package/dist/records/index.d.ts +13 -0
- package/dist/records/index.js +1 -0
- package/dist/records/journal.d.ts +2968 -0
- package/dist/records/toolResult.d.ts +65 -0
- package/dist/services/agents.d.ts +62 -0
- package/dist/services/catalogContributions.d.ts +73 -0
- package/dist/services/confinement/files.d.ts +118 -0
- package/dist/services/confinement/service.d.ts +219 -0
- package/dist/services/core.d.ts +28 -0
- package/dist/services/extensionEvents.d.ts +181 -0
- package/dist/services/journal.d.ts +26 -0
- package/dist/services/llm.d.ts +82 -0
- package/dist/services/modes.d.ts +65 -0
- package/dist/services/plugins.d.ts +34 -0
- package/dist/services/presets/definition.d.ts +154 -0
- package/dist/services/presets/installations.d.ts +139 -0
- package/dist/services/prompts.d.ts +85 -0
- package/dist/services/threads/activation.d.ts +100 -0
- package/dist/services/threads/admission.d.ts +174 -0
- package/dist/services/threads/birth.d.ts +219 -0
- package/dist/services/threads/index.d.ts +14 -0
- package/dist/services/threads/runEvents.d.ts +79 -0
- package/dist/services/threads/runOwner.d.ts +368 -0
- package/dist/services/threads/service.d.ts +450 -0
- package/dist/services/threads/thread.d.ts +268 -0
- package/dist/services/threads/view.d.ts +93 -0
- package/dist/services/tools.d.ts +118 -0
- package/dist/state/birth.d.ts +62 -0
- package/dist/state/chain.d.ts +46 -0
- package/dist/state/confirmations.d.ts +64 -0
- package/dist/state/continuation.d.ts +167 -0
- package/dist/state/decide.d.ts +72 -0
- package/dist/state/dispatches.d.ts +54 -0
- package/dist/state/errors.d.ts +26 -0
- package/dist/state/forks.d.ts +61 -0
- package/dist/state/holds.d.ts +104 -0
- package/dist/state/inbox.d.ts +188 -0
- package/dist/state/index.d.ts +31 -0
- package/dist/state/inputs.d.ts +58 -0
- package/dist/state/installations.d.ts +28 -0
- package/dist/state/limits.d.ts +14 -0
- package/dist/state/prompt.d.ts +13 -0
- package/dist/state/recovery.d.ts +7 -0
- package/dist/state/replace.d.ts +33 -0
- package/dist/state/requests.d.ts +129 -0
- package/dist/state/route.d.ts +61 -0
- package/dist/state/summary.d.ts +16 -0
- package/dist/state/surface.d.ts +153 -0
- package/dist/state/surfaceRead.d.ts +20 -0
- package/dist/state/thread.d.ts +73 -0
- package/dist/state/turns.d.ts +87 -0
- package/dist/state/waits.d.ts +38 -0
- package/dist/state/wake.d.ts +32 -0
- package/dist/stores/durableObject.d.ts +23 -0
- package/dist/stores/durableObject.js +1 -0
- package/dist/stores/durableObjectConnection.d.ts +27 -0
- package/dist/stores/memory.d.ts +29 -0
- package/dist/stores/sql.d.ts +59 -0
- package/dist/stores/sqlite.d.ts +31 -0
- package/dist/stores/sqlite.js +1 -0
- package/dist/sys/environment.d.ts +42 -0
- package/dist/sys/git.d.ts +47 -0
- package/dist/sys/paths.d.ts +9 -0
- package/dist/sys/spawn.d.ts +186 -0
- package/dist/testing/clock.d.ts +17 -0
- package/dist/testing/fakeLlm.d.ts +76 -0
- package/dist/testing/fedLlm.d.ts +34 -0
- package/dist/testing/helpers.d.ts +362 -0
- package/dist/testing/index.d.ts +13 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/processes.d.ts +13 -0
- package/dist/testing/settlement.d.ts +6 -0
- package/dist/testing/tmpDirs.d.ts +17 -0
- package/dist/util/async.d.ts +8 -0
- package/dist/util/diff.d.ts +25 -0
- package/dist/util/dispatch.d.ts +8 -0
- package/dist/util/errors.d.ts +28 -0
- package/dist/util/foldState.d.ts +17 -0
- package/dist/util/freeze.d.ts +2 -0
- package/dist/util/ids.d.ts +2 -0
- package/dist/util/json.d.ts +37 -0
- package/dist/util/jsonSchema.d.ts +7 -0
- package/dist/util/log.d.ts +6 -0
- package/dist/util/retries.d.ts +25 -0
- package/dist/util/text.d.ts +21 -0
- package/dist/util/timers.d.ts +43 -0
- package/package.json +183 -3
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { StreamIdleError } from '../llm/client.js';
|
|
3
|
+
import type { ConversationMessage, JsonObject, LLMStreamChunk, ModelResponse, ToolCall } from '../llm/primitives.js';
|
|
4
|
+
import type { ModelRequest } from '../llm/request.js';
|
|
5
|
+
import type { StreamingLLMResponse } from '../llm/client.js';
|
|
6
|
+
/**
|
|
7
|
+
* How long one attempt may go without a single event from the provider, waiting for the first
|
|
8
|
+
* included, before it fails as `timeout`; `null` disables the deadline. Required: it is transport
|
|
9
|
+
* configuration, and a reasoning model that streams no reasoning needs a long one, or none.
|
|
10
|
+
*/
|
|
11
|
+
export declare const StreamIdleTimeoutSchema: z.ZodNullable<z.ZodNumber>;
|
|
12
|
+
/**
|
|
13
|
+
* A tool call with its arguments as a provider hands them over: already an object, or JSON still in
|
|
14
|
+
* a string. Absent or empty arguments are an empty object. Anything that is not a JSON object is kept
|
|
15
|
+
* as the model sent it, malformed, so its call alone is answered with an error and its siblings run.
|
|
16
|
+
*/
|
|
17
|
+
export declare function toolCall(callId: string, name: string, value: unknown): ToolCall;
|
|
18
|
+
/**
|
|
19
|
+
* Runs `work` with the idle deadline of the attempt whose transport is opening held: work the
|
|
20
|
+
* transport does on the attempt's behalf with a bound of its own, such as reading or recovering
|
|
21
|
+
* credentials, is not provider silence. Outside an attempt it runs `work` as it is.
|
|
22
|
+
*/
|
|
23
|
+
export declare function holdDeadline<T>(work: () => Promise<T>): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* One attempt's lifetime, made before its transport opens: the controller its SDK call is handed
|
|
26
|
+
* (aborted with the request's signal, or when the deadline passes), the idle timer, and their
|
|
27
|
+
* cleanup. The timer starts when the request is sent and resets on every raw provider event the
|
|
28
|
+
* stream sees (`events`), including events the adapter drops, since reasoning can be visibly silent;
|
|
29
|
+
* it is held while the transport works on the attempt's behalf (`holdDeadline`). Expiry is recorded
|
|
30
|
+
* before the controller aborts, so a read that ends afterwards, by an SDK abort error or quietly, is
|
|
31
|
+
* told from the caller's own cancel; nothing the transport delivers after expiry is read. The
|
|
32
|
+
* caller's cancel clears the deadline: a cancelled attempt never times out.
|
|
33
|
+
*/
|
|
34
|
+
export declare class AttemptLifetime {
|
|
35
|
+
private readonly controller;
|
|
36
|
+
/** What `close()` aborts with, kept so the read it ends can tell it from a failure of the transport. */
|
|
37
|
+
private readonly closure;
|
|
38
|
+
private timer;
|
|
39
|
+
private expiredAt;
|
|
40
|
+
private holds;
|
|
41
|
+
private readonly forward;
|
|
42
|
+
private readonly provider;
|
|
43
|
+
private readonly requestSignal;
|
|
44
|
+
private readonly idleMs;
|
|
45
|
+
constructor(provider: string, requestSignal: AbortSignal | undefined, idleMs: number | null);
|
|
46
|
+
/** Runs `open` as this attempt's: what it calls can hold the deadline (`holdDeadline`). */
|
|
47
|
+
opening<T>(open: () => Promise<T>): Promise<T>;
|
|
48
|
+
/** Stops the deadline until as many `release`s as `hold`s have been made. */
|
|
49
|
+
hold(): void;
|
|
50
|
+
release(): void;
|
|
51
|
+
/** What the attempt's SDK call is given: aborted by the caller's cancel or the deadline. */
|
|
52
|
+
get signal(): AbortSignal;
|
|
53
|
+
/** Whether the deadline passed before the attempt ended. */
|
|
54
|
+
get expired(): boolean;
|
|
55
|
+
/** The failure an expired attempt reports. */
|
|
56
|
+
idleError(): StreamIdleError;
|
|
57
|
+
/**
|
|
58
|
+
* `source`, resetting the deadline on every event it yields, and ending without another once the
|
|
59
|
+
* deadline passed: an event that arrives after expiry, terminal evidence included, is not read.
|
|
60
|
+
*/
|
|
61
|
+
events<T>(source: AsyncIterable<T>): AsyncGenerator<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Ends the attempt for a reader that closed its stream: aborts the controller the SDK was handed,
|
|
64
|
+
* which closes the transport, then disposes. Without the abort an unread response would hold its
|
|
65
|
+
* connection open, and nothing would close it once the caller's signal is no longer followed.
|
|
66
|
+
*/
|
|
67
|
+
close(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Whether `error` is the abort `close()` raised: a transport read through `fetch` fails with its
|
|
70
|
+
* abort's reason, so a reader that leaves would otherwise end its own read as a failure.
|
|
71
|
+
*/
|
|
72
|
+
closedBy(error: unknown): boolean;
|
|
73
|
+
/** Clears the timer and stops following the request's signal; safe to call more than once. */
|
|
74
|
+
dispose(): void;
|
|
75
|
+
private clearTimer;
|
|
76
|
+
private arm;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* What an owner of a protocol client adds to every call it sends: headers for one call, over the
|
|
80
|
+
* client's own. It receives the call and the request the client mapped from it, so a header can
|
|
81
|
+
* derive from either; nothing rebuilds the request for it.
|
|
82
|
+
*/
|
|
83
|
+
export type CallHeaders = (call: ModelRequest, request: Readonly<Record<string, unknown>>) => Record<string, string>;
|
|
84
|
+
/**
|
|
85
|
+
* Opens one attempt, the one place an adapter creates, ends and classifies it: the lifetime is made
|
|
86
|
+
* before `open` runs, so its deadline bounds the wait for the first event too, and `open` gets the
|
|
87
|
+
* signal its transport must carry. When `open` fails the lifetime is disposed, and the failure is
|
|
88
|
+
* the deadline's `StreamIdleError` if the deadline passed (the caller's own cancel clears the
|
|
89
|
+
* deadline, so a cancel never reads as a timeout), else `classify(error)`, which names a
|
|
90
|
+
* cancellation and a provider's overflow as the engine recognises them. On success the lifetime stays
|
|
91
|
+
* live for the stream that reads `opened`.
|
|
92
|
+
*/
|
|
93
|
+
export declare function openAttempt<T>(provider: string, requestSignal: AbortSignal | undefined, idleMs: number | null, open: (signal: AbortSignal) => Promise<T>, classify: (error: unknown) => unknown): Promise<{
|
|
94
|
+
readonly lifetime: AttemptLifetime;
|
|
95
|
+
readonly opened: T;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* The one enforcement of the reader rules `StreamingLLMResponse` states: a response is iterated at
|
|
99
|
+
* most once, `completed()` drains a response nobody has read and otherwise reports the outcome of
|
|
100
|
+
* the read that ended, and never settles while one is under way.
|
|
101
|
+
*
|
|
102
|
+
* A transport is consumed as it is read and a reader that stops early has already closed it, so only
|
|
103
|
+
* a stream nobody has touched can be drained; asking a consumed one for the rest returns what the
|
|
104
|
+
* read left rather than resuming, which would lose the whole message — including the text the reader
|
|
105
|
+
* had already seen. Everything a cut-off stream did say is accumulated by `read`.
|
|
106
|
+
*
|
|
107
|
+
* It owns one rule for every adapter: a response counts only once the provider said it was
|
|
108
|
+
* complete. A transport that ran to its end without saying so is a `transport` failure, and one that
|
|
109
|
+
* said so with no text and no tool call is an `empty` one (see {@link ResponseSettlementError}). A
|
|
110
|
+
* stream its reader stopped early, or whose request was aborted, is neither: the caller cut it off,
|
|
111
|
+
* and gets what arrived as a cut-off reply.
|
|
112
|
+
*/
|
|
113
|
+
export declare abstract class ReadOnceStream implements StreamingLLMResponse {
|
|
114
|
+
/** Whether the read is claimed: by the iterator, or by `completed()` draining. */
|
|
115
|
+
private claimed;
|
|
116
|
+
/** When the read has ended, whether it ran through, was stopped early or failed. */
|
|
117
|
+
private readonly ledger;
|
|
118
|
+
/** Whether the request was aborted when the read ended: fixed then, so a later abort changes nothing. */
|
|
119
|
+
private abortedAtEnd;
|
|
120
|
+
/** Whether the transport ran to its end, rather than its reader stopping or the read failing. */
|
|
121
|
+
private drained;
|
|
122
|
+
/** Whether its reader closed it early, before or while reading. */
|
|
123
|
+
private closedByReader;
|
|
124
|
+
/** The failure the read ended on, which `completed()` throws again rather than settling a partial. */
|
|
125
|
+
private readFailure;
|
|
126
|
+
protected readonly providerName: string;
|
|
127
|
+
protected readonly signal: AbortSignal | undefined;
|
|
128
|
+
private readonly lifetime;
|
|
129
|
+
protected constructor(providerName: string, signal: AbortSignal | undefined, lifetime: AttemptLifetime);
|
|
130
|
+
/**
|
|
131
|
+
* Claims the read, so a second iterator throws here and not at its first `next()`, and reads the
|
|
132
|
+
* transport through. When the attempt's deadline passed, the read's ending (an SDK abort error, or
|
|
133
|
+
* a quiet end) is that deadline's `StreamIdleError`, unless the provider's terminal evidence had
|
|
134
|
+
* already arrived: then the response stands, as complete as the provider said it was (Chat's usage,
|
|
135
|
+
* sent after the finish, may be missing). The lifetime ends with the read, however it ends, the
|
|
136
|
+
* reader abandoning it included.
|
|
137
|
+
*/
|
|
138
|
+
[Symbol.asyncIterator](): AsyncIterator<LLMStreamChunk>;
|
|
139
|
+
private readThrough;
|
|
140
|
+
/** Whether `error` is the caller's own cancellation; a failure that only coincided with one is not. */
|
|
141
|
+
private cancelled;
|
|
142
|
+
/** `error`, with what arrived before it kept beside it. */
|
|
143
|
+
private interrupted;
|
|
144
|
+
/** Reads the transport through, accumulating whatever `settle` and `partial` will need. */
|
|
145
|
+
protected abstract read(): AsyncGenerator<LLMStreamChunk>;
|
|
146
|
+
/** The response, once the provider's terminal evidence arrived; `undefined` before that. */
|
|
147
|
+
protected abstract settle(): ModelResponse | undefined;
|
|
148
|
+
/** What arrived so far: text and reasoning only, never a tool call nobody finished asking for. */
|
|
149
|
+
protected abstract partial(): {
|
|
150
|
+
message: ConversationMessage;
|
|
151
|
+
providerMetadata: JsonObject;
|
|
152
|
+
};
|
|
153
|
+
/** Remembers the failure the read ended on, and returns it to be thrown. */
|
|
154
|
+
private failed;
|
|
155
|
+
completed(): Promise<ModelResponse>;
|
|
156
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@leuduan/lagent/records`: the serialized contract, what a reader of the journal or a plugin writing
|
|
3
|
+
* rows needs. Journal rows, the types a row mentions, the helpers that read and write them and the
|
|
4
|
+
* JSON types they are written in. The Zod schemas, the tables the types derive from and the
|
|
5
|
+
* hand-written agent and prompt configuration stay in their modules, which the package imports
|
|
6
|
+
* directly.
|
|
7
|
+
*/
|
|
8
|
+
export { isForkSpawn, isSurfaceEvent, parseJournalEvent, queuedInput, stepContribution } from './journal.js';
|
|
9
|
+
export type { CancelIntent, ConfirmationDescriptor, ExtensionRecord, InboxTarget, InitialInstallation, InputRole, Installation, InstallationLifetime, InterruptionPolicy, JournalEvent, JournalEventData, JournalEventInput, JournalEventType, OriginCause, QueuedInput, ReplacementKind, ReplacementTrigger, RunChain, RunOutcomeKind, RunSettledReason, Seq, StepContribution, StepContributionInput, SurfaceEventType, ThreadEnvironment, ThreadFork, ThreadInput, ThreadOrigin, ThreadSummary, TurnEndReason, TurnRejection, WaitDescriptor, } from './journal.js';
|
|
10
|
+
export { toolResultMessageContent } from './toolResult.js';
|
|
11
|
+
export type { ToolResult, ToolResultPayload, ToolResultPayloadInput } from './toolResult.js';
|
|
12
|
+
export { toJsonSchema } from '../util/jsonSchema.js';
|
|
13
|
+
export type { DeepReadonly, JsonValue, ReadonlyJsonValue } from '../util/json.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"../chunks/FJLU4UH3.js";import{f as e,l as o,m as t,q as r,r as n,s}from"../chunks/MMNNZCBO.js";import"../chunks/G44LG6VL.js";import"../chunks/D4PQP5MA.js";export{n as isForkSpawn,s as isSurfaceEvent,r as parseJournalEvent,o as queuedInput,t as stepContribution,p as toJsonSchema,e as toolResultMessageContent};
|