@tessar/core 0.1.0-alpha.0 → 0.1.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 +168 -31
- package/dist/agent.d.ts +37 -87
- package/dist/agent.js +101 -1116
- package/dist/agent.js.map +1 -1
- package/dist/controller.d.ts +13 -4
- package/dist/controller.js +184 -19
- package/dist/controller.js.map +1 -1
- package/dist/engine/call.d.ts +8 -0
- package/dist/engine/call.js +136 -0
- package/dist/engine/call.js.map +1 -0
- package/dist/engine/checkpoint.d.ts +11 -0
- package/dist/engine/checkpoint.js +187 -0
- package/dist/engine/checkpoint.js.map +1 -0
- package/dist/engine/delivery.js +6 -13
- package/dist/engine/delivery.js.map +1 -1
- package/dist/engine/execution.d.ts +5 -0
- package/dist/engine/execution.js +292 -0
- package/dist/engine/execution.js.map +1 -0
- package/dist/engine/frame.d.ts +77 -0
- package/dist/engine/frame.js +83 -0
- package/dist/engine/frame.js.map +1 -0
- package/dist/engine/hooks.d.ts +4 -0
- package/dist/engine/hooks.js +138 -0
- package/dist/engine/hooks.js.map +1 -0
- package/dist/engine/interrupt.d.ts +1 -1
- package/dist/engine/lineage.d.ts +1 -1
- package/dist/engine/recovery.d.ts +1 -2
- package/dist/engine/recovery.js +4 -2
- package/dist/engine/recovery.js.map +1 -1
- package/dist/engine/resume.d.ts +12 -1
- package/dist/engine/resume.js +189 -0
- package/dist/engine/resume.js.map +1 -1
- package/dist/engine/runtime.d.ts +16 -0
- package/dist/engine/runtime.js +29 -0
- package/dist/engine/runtime.js.map +1 -0
- package/dist/engine/services.d.ts +3 -0
- package/dist/engine/services.js +125 -0
- package/dist/engine/services.js.map +1 -0
- package/dist/engine/tool-executor.d.ts +8 -2
- package/dist/engine/tool-executor.js +266 -3
- package/dist/engine/tool-executor.js.map +1 -1
- package/dist/engine/tracked-effects.js +5 -6
- package/dist/engine/tracked-effects.js.map +1 -1
- package/dist/errors.js +24 -9
- package/dist/errors.js.map +1 -1
- package/dist/events/definition.d.ts +2 -0
- package/dist/events/definition.js +2 -0
- package/dist/events/definition.js.map +1 -1
- package/dist/events/dispatcher.d.ts +1 -1
- package/dist/events/dispatcher.js +35 -4
- package/dist/events/dispatcher.js.map +1 -1
- package/dist/events/observer.d.ts +3 -0
- package/dist/events/observer.js +13 -0
- package/dist/events/observer.js.map +1 -0
- package/dist/events/{catalog.d.ts → type.d.ts} +170 -47
- package/dist/events/type.js +175 -0
- package/dist/events/type.js.map +1 -0
- package/dist/identity.d.ts +1 -0
- package/dist/identity.js +23 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions/instruction.d.ts +2 -0
- package/dist/instructions/instruction.js +10 -3
- package/dist/instructions/instruction.js.map +1 -1
- package/dist/loop.d.ts +5 -5
- package/dist/loop.js +44 -204
- package/dist/loop.js.map +1 -1
- package/dist/messages/codec.js +4 -2
- package/dist/messages/codec.js.map +1 -1
- package/dist/messages/message.d.ts +2 -3
- package/dist/messages/message.js +3 -3
- package/dist/messages/message.js.map +1 -1
- package/dist/models/contract.d.ts +15 -0
- package/dist/models/options.d.ts +3 -0
- package/dist/models/options.js +13 -0
- package/dist/models/options.js.map +1 -0
- package/dist/models/registry.d.ts +2 -0
- package/dist/models/registry.js +18 -1
- package/dist/models/registry.js.map +1 -1
- package/dist/models/resolver.d.ts +4 -2
- package/dist/models/resolver.js +9 -4
- package/dist/models/resolver.js.map +1 -1
- package/dist/models/stream.d.ts +6 -0
- package/dist/models/stream.js +61 -2
- package/dist/models/stream.js.map +1 -1
- package/dist/plugins/context.d.ts +27 -2
- package/dist/plugins/host.d.ts +5 -1
- package/dist/plugins/host.js +33 -11
- package/dist/plugins/host.js.map +1 -1
- package/dist/plugins/registry.d.ts +1 -1
- package/dist/plugins/registry.js +18 -10
- package/dist/plugins/registry.js.map +1 -1
- package/dist/session.d.ts +16 -6
- package/dist/session.js +126 -55
- package/dist/session.js.map +1 -1
- package/dist/state/commit.d.ts +5 -0
- package/dist/state/commit.js +50 -5
- package/dist/state/commit.js.map +1 -1
- package/dist/state/fork.js +27 -6
- package/dist/state/fork.js.map +1 -1
- package/dist/state/memory-backend.js +307 -38
- package/dist/state/memory-backend.js.map +1 -1
- package/dist/state/plugin-state.js +73 -18
- package/dist/state/plugin-state.js.map +1 -1
- package/dist/state/queries.d.ts +14 -14
- package/dist/state/queries.js +150 -48
- package/dist/state/queries.js.map +1 -1
- package/dist/state/schema.d.ts +47 -6
- package/dist/state/schema.js +9 -1
- package/dist/state/schema.js.map +1 -1
- package/dist/state/scope.js +3 -2
- package/dist/state/scope.js.map +1 -1
- package/dist/state/sessions.d.ts +2 -0
- package/dist/state/sessions.js +21 -0
- package/dist/state/sessions.js.map +1 -0
- package/dist/state/storage-ports.d.ts +16 -2
- package/dist/state/threads.d.ts +1 -0
- package/dist/state/threads.js +77 -12
- package/dist/state/threads.js.map +1 -1
- package/dist/testing/harness.d.ts +2 -1
- package/dist/testing/harness.js +6 -4
- package/dist/testing/harness.js.map +1 -1
- package/dist/testing/scripted-provider.d.ts +1 -0
- package/dist/testing/scripted-provider.js +7 -0
- package/dist/testing/scripted-provider.js.map +1 -1
- package/dist/testing/storage-conformance.js +111 -0
- package/dist/testing/storage-conformance.js.map +1 -1
- package/dist/thread.d.ts +4 -2
- package/dist/thread.js +14 -6
- package/dist/thread.js.map +1 -1
- package/dist/tools/tool.d.ts +11 -12
- package/dist/tools/tool.js +27 -10
- package/dist/tools/tool.js.map +1 -1
- package/dist/trace/records.d.ts +11 -6
- package/dist/trace/records.js +28 -1
- package/dist/trace/records.js.map +1 -1
- package/package.json +7 -1
- package/dist/events/catalog.js +0 -89
- package/dist/events/catalog.js.map +0 -1
- package/dist/models/cache.d.ts +0 -12
- package/dist/models/cache.js +0 -17
- package/dist/models/cache.js.map +0 -1
- package/dist/session-events.d.ts +0 -60
- package/dist/session-events.js +0 -14
- package/dist/session-events.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,31 +1,168 @@
|
|
|
1
|
-
# @tessar/core
|
|
2
|
-
|
|
3
|
-
Tessar's TypeScript API for Agent, Controller, Session, Thread, messages,
|
|
4
|
-
tools, hooks, state and checkpoints. Requires Node 24.14 or newer.
|
|
5
|
-
|
|
6
|
-
```sh
|
|
7
|
-
npm install @tessar/core@
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
- `Agent` owns its model
|
|
11
|
-
- `Controller({ id, agent, plugins })` owns plugin setup, resources and sessions.
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
# @tessar/core
|
|
2
|
+
|
|
3
|
+
Tessar's TypeScript API for Agent, Controller, Session, Thread, messages,
|
|
4
|
+
tools, hooks, state and checkpoints. Requires Node 24.14 or newer.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install @tessar/core @tessar/openai zod
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
- `Agent` owns its model, instructions, tools, limits and the agent loop.
|
|
11
|
+
- `Controller({ id, agent, plugins })` owns plugin setup, resources and sessions.
|
|
12
|
+
- An executable model lets Agent run directly, without public init/dispose.
|
|
13
|
+
- When opting into Controller, initialize it before its sessions or plugin-backed
|
|
14
|
+
executions and dispose it when finished.
|
|
15
|
+
- `agent.stream()` creates an independent task; `agent.generate()` collects the
|
|
16
|
+
same execution. A Session manages a continuing conversation with
|
|
17
|
+
`session.subscribe()` and queued `session.followUp()` inputs.
|
|
18
|
+
- Core manages state and checkpoints, using memory storage by default.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { Agent, Controller, HumanMessage, ToolMessage } from "@tessar/core";
|
|
22
|
+
import { createTool } from "@tessar/core/tool";
|
|
23
|
+
import { OpenAIProvider } from "@tessar/openai";
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
|
|
26
|
+
const addTool = createTool({
|
|
27
|
+
name: "add",
|
|
28
|
+
description: "Add two numbers",
|
|
29
|
+
schema: z.object({ a: z.number(), b: z.number() }),
|
|
30
|
+
execute: ({ a, b }) => ({ sum: a + b }),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const agent = new Agent({
|
|
34
|
+
id: "assistant",
|
|
35
|
+
model: new OpenAIProvider({
|
|
36
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
37
|
+
model: process.env.OPENAI_MODEL!,
|
|
38
|
+
}),
|
|
39
|
+
tools: { addTool },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const result = await agent.generate("What is 1 + 2?");
|
|
43
|
+
console.log(result.output);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Tools can also be registered by plugins using `tessar.tools.register(addTool)`.
|
|
47
|
+
Both paths share hooks and execution. Tool names must be unique.
|
|
48
|
+
`tools: { concurrency: 4, addTool }` optionally limits active calls, including
|
|
49
|
+
plugin tools; omit concurrency to execute the model's tool calls without a
|
|
50
|
+
scheduling limit. Tools are authorized before dispatch; results enter the
|
|
51
|
+
conversation in call order after the executions complete. Execution budgets
|
|
52
|
+
such as `limits.maxToolCalls` still apply.
|
|
53
|
+
|
|
54
|
+
`Agent.model` is required. `stream(message, options?)` and
|
|
55
|
+
`generate(message, options?)` accept a string, a message, or message history.
|
|
56
|
+
Each direct call has independent context and automatic per-execution cleanup.
|
|
57
|
+
Use a Session when the host needs a continuing conversation.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const stream = agent.stream("Explain briefly", {
|
|
61
|
+
model: "another-model-on-the-same-connection",
|
|
62
|
+
modelOptions: { reasoning: { effort: "low" } },
|
|
63
|
+
});
|
|
64
|
+
for await (const event of stream) console.log(event);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
A string model override keeps the default connection. An executable model
|
|
68
|
+
instance selects its own connection and request defaults. `modelOptions`
|
|
69
|
+
replaces top-level values, including whole nested objects, for that call only.
|
|
70
|
+
Omitted provider settings are left to the provider SDK. Legacy object-input
|
|
71
|
+
overloads/model references remain for existing Controller integrations.
|
|
72
|
+
|
|
73
|
+
Zod validates arguments and infers executor input; Tessar generates the model's
|
|
74
|
+
JSON Schema. Return text or JSON directly: Tessar wraps it in a `ToolMessage`
|
|
75
|
+
and binds the toolCallId. Undefined and non-JSON returns fail explicitly.
|
|
76
|
+
To supply content parts or metadata, return a message yourself:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
new ToolMessage("Already calculated", { metadata: { source: "cache" } });
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
All messages have an ID, role, content and optional metadata. Constructors infer
|
|
83
|
+
the role and generate an ID unless supplied. Metadata is persisted for hosts and
|
|
84
|
+
plugins and is not automatically sent to a model. Standalone ToolMessages may
|
|
85
|
+
omit toolCallId; encoding history requires it, and the tool runtime binds it
|
|
86
|
+
automatically. OpenAI Responses serializes JSON tool data as JSON text.
|
|
87
|
+
|
|
88
|
+
Retry, conditional availability and permissions belong in tool implementations
|
|
89
|
+
or plugins. Use `tools.select` for advertised tools and `tool.before` to enforce
|
|
90
|
+
execution policy. Skills and subagents are host/plugin orchestration, expressed
|
|
91
|
+
to providers through instructions, messages and tools.
|
|
92
|
+
|
|
93
|
+
Build instructions from sections when plugins need to append their own content:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { buildInstruction } from "@tessar/core";
|
|
97
|
+
|
|
98
|
+
const instructions = buildInstruction([
|
|
99
|
+
{ id: "base", content: "You are an assistant.", order: 0 },
|
|
100
|
+
{ id: "skills", content: "<skills>...</skills>", order: 100 },
|
|
101
|
+
{ id: "current-context", content: "Current task details", order: 1000 },
|
|
102
|
+
]);
|
|
103
|
+
const agent = new Agent({ id: "assistant", model, instructions });
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Sections sort by ascending `order`, with omitted order comparing as zero. Equal
|
|
107
|
+
orders sort by ordinal ID, independent of plugin registration order. Use distinct
|
|
108
|
+
orders when sequence matters. IDs must be unique and orders finite numbers.
|
|
109
|
+
Building copies/freezes the data; it does not mutate caller arrays or inject a
|
|
110
|
+
default order. String instructions remain supported. Final requests are normalized
|
|
111
|
+
after `context.prepare` and `model.request`, including sections added by plugins.
|
|
112
|
+
Ordering controls content placement; provider adapters own serialization and cache
|
|
113
|
+
behavior. Core adds no cache markers or history breakpoint API.
|
|
114
|
+
|
|
115
|
+
Built-in and custom plugins use classes instantiated with `new`, implementing
|
|
116
|
+
the same `Plugin` instance contract. Provider adapters are separate packages,
|
|
117
|
+
such as `@tessar/openai`; persistence backends such as `@tessar/sqlite` attach
|
|
118
|
+
through Controller plugins.
|
|
119
|
+
|
|
120
|
+
All hooks share `tessar.hook` and one typed EventMap. Import event groups directly:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { model, thread, session } from "@tessar/core";
|
|
124
|
+
|
|
125
|
+
tessar.hook(model.usage, event => console.log(event.payload.usage));
|
|
126
|
+
tessar.hook(thread.beforeDelete, () => ({ decision: "deny", reason: "Keep history" }));
|
|
127
|
+
tessar.hook(session.model.beforeChange, event => console.log(event.payload.model));
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Keys start lowercase and use camelCase for hyphens in the string identifier:
|
|
131
|
+
`thread.beforeDelete === "thread.before-delete"`. There is no `events` prefix.
|
|
132
|
+
The old `AgentEvents` and `SessionEvents` exports are replaced by these groups.
|
|
133
|
+
Session selection policies are asynchronous: use `await session.setModel(model)`
|
|
134
|
+
before queuing input that should use the new model. See
|
|
135
|
+
[plugin authoring](../../docs/plugin-authoring.md) for decisions and capabilities.
|
|
136
|
+
|
|
137
|
+
This is an early 0.x release. See the
|
|
138
|
+
[repository](https://github.com/hphucdev-04/tessar) for complete TypeScript
|
|
139
|
+
examples and the current API contracts. The bundled model catalog includes its
|
|
140
|
+
upstream license at `src/models/catalog.LICENSE`.
|
|
141
|
+
|
|
142
|
+
## Persistent Sessions
|
|
143
|
+
|
|
144
|
+
`await controller.createSession({ scope, metadata })` commits a Session record
|
|
145
|
+
before returning the handle. `session.id` is generated by Tessar. Use
|
|
146
|
+
`await controller.getSession(id, { scope })` to restore it and
|
|
147
|
+
`await controller.listSessions({ scope, limit, cursor })` to browse this Agent's
|
|
148
|
+
Sessions. A restored handle does not automatically resume unfinished work.
|
|
149
|
+
|
|
150
|
+
Selections use compare-and-set: stale handles fail `CommitConflict`; reload the
|
|
151
|
+
Session before retrying. Thread creation may succeed before selection fails,
|
|
152
|
+
so the unselected thread remains available in the scoped thread list. Closing
|
|
153
|
+
a Session keeps its record. Soft-deleting a thread clears stored selections in
|
|
154
|
+
the same transaction. Subscribers and unadmitted followUp queues stay in memory.
|
|
155
|
+
|
|
156
|
+
There is no Agent table. The application constructs its Agent and supplies the
|
|
157
|
+
same `agentId` and compatible providers/plugins on restart. Controller's ID is
|
|
158
|
+
not a persistence key. Session creation notifications are available to Controller
|
|
159
|
+
plugins; subscribe on the returned handle for subsequent events. Restoration
|
|
160
|
+
does not emit another `session.created` notification.
|
|
161
|
+
|
|
162
|
+
`controller.deleteThread` is a soft delete. `controller.purgeThread` permanently
|
|
163
|
+
removes only a deleted, inactive, unowned thread with no retained fork referencing
|
|
164
|
+
it. Both invoke thread deletion policy; purge supplies `permanent: true`.
|
|
165
|
+
|
|
166
|
+
Storage adapter authors must implement the new `sessions` CAS port, backend page
|
|
167
|
+
and history queries, `threads.get(..., { includeDeleted })` and `threads.purge`.
|
|
168
|
+
These are breaking storage-port changes; run storage conformance and query tests.
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,55 +1,36 @@
|
|
|
1
1
|
import type { Controller } from "./controller.js";
|
|
2
2
|
import type { Model } from "./models/profile.js";
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
3
|
+
import type { ModelAdapter, ModelOptions, ModelRef } from "./models/contract.js";
|
|
4
|
+
import type { Scope, InterruptRecord, StreamLimits } from "./state/schema.js";
|
|
5
|
+
import type { StreamRecord } from "./trace/records.js";
|
|
6
|
+
import type { StorageBackend } from "./state/storage-ports.js";
|
|
7
|
+
import type { PluginHost } from "./plugins/host.js";
|
|
8
|
+
import { type Stream, type DeliveryTarget } from "./engine/delivery.js";
|
|
5
9
|
export type { Stream, DeliveryTarget } from "./engine/delivery.js";
|
|
6
10
|
import { type ErrorInfo } from "./errors.js";
|
|
7
|
-
import { type Clock, type IdGenerator, type JsonObject
|
|
11
|
+
import { type Clock, type IdGenerator, type JsonObject } from "./json.js";
|
|
8
12
|
import { type Instruction } from "./instructions/instruction.js";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export interface ExecutionOrigin {
|
|
18
|
-
parentStreamId: string;
|
|
19
|
-
parentToolExecutionId?: string;
|
|
20
|
-
dispatchId: string;
|
|
21
|
-
}
|
|
22
|
-
export type ExecutionRequest = ({
|
|
23
|
-
kind: "input";
|
|
24
|
-
threadId: string;
|
|
25
|
-
input: readonly MessageData[];
|
|
26
|
-
model: ModelRef;
|
|
27
|
-
origin?: ExecutionOrigin;
|
|
28
|
-
context?: JsonObject;
|
|
29
|
-
limits?: Partial<StreamLimits>;
|
|
30
|
-
} | {
|
|
31
|
-
kind: "resume";
|
|
32
|
-
threadId: string;
|
|
33
|
-
interruptId: string;
|
|
34
|
-
value: JsonValue;
|
|
35
|
-
model?: ModelRef;
|
|
36
|
-
} | {
|
|
37
|
-
kind: "recover";
|
|
38
|
-
threadId: string;
|
|
39
|
-
streamId: string;
|
|
40
|
-
model?: ModelRef;
|
|
41
|
-
}) & {
|
|
42
|
-
signal?: AbortSignal;
|
|
43
|
-
};
|
|
44
|
-
export interface AgentOptions {
|
|
13
|
+
import type { MessageData } from "./messages/message.js";
|
|
14
|
+
import { Tool } from "./tools/tool.js";
|
|
15
|
+
import type { ExecutionRequest } from "./engine/frame.js";
|
|
16
|
+
export type { ExecutionFrame, ExecutionRequest, ExecutionOrigin, } from "./engine/frame.js";
|
|
17
|
+
import type { ExecutionRuntime } from "./engine/runtime.js";
|
|
18
|
+
export type ModelSelection = ModelAdapter | Model | ModelRef;
|
|
19
|
+
export type AgentInput = string | MessageData | readonly MessageData[];
|
|
20
|
+
export interface AgentOptions<M extends ModelSelection = ModelSelection> {
|
|
45
21
|
id: string;
|
|
46
|
-
model
|
|
22
|
+
model: M;
|
|
47
23
|
instructions?: string | Instruction;
|
|
48
24
|
limits?: Partial<StreamLimits>;
|
|
25
|
+
tools?: AgentTools;
|
|
26
|
+
}
|
|
27
|
+
export interface AgentTools {
|
|
28
|
+
concurrency?: number;
|
|
29
|
+
readonly [alias: string]: Tool | number | undefined;
|
|
49
30
|
}
|
|
50
|
-
export interface AgentExecutionOptions {
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
export interface AgentExecutionOptions<M = ModelAdapter> {
|
|
32
|
+
model?: M | Model | ModelRef | string;
|
|
33
|
+
modelOptions?: ModelOptions<M>;
|
|
53
34
|
scope?: Scope;
|
|
54
35
|
context?: JsonObject;
|
|
55
36
|
signal?: AbortSignal;
|
|
@@ -65,26 +46,11 @@ export interface GenerateOutcome {
|
|
|
65
46
|
error: ErrorInfo | null;
|
|
66
47
|
}
|
|
67
48
|
export declare function inputMessages(input: MessageData | readonly MessageData[]): readonly MessageData[];
|
|
68
|
-
export
|
|
69
|
-
effectLocks?: Map<string, Promise<unknown>>;
|
|
70
|
-
commitQueue?: Promise<void>;
|
|
71
|
-
currentToolExecutionId?: string;
|
|
72
|
-
heartbeat?: ReturnType<typeof setInterval>;
|
|
73
|
-
ownershipError?: ErrorInfo;
|
|
74
|
-
request: ExecutionRequest;
|
|
75
|
-
sink: Attachment;
|
|
76
|
-
registry: RegistryLease;
|
|
77
|
-
lease: Lease;
|
|
78
|
-
cp: Checkpoint;
|
|
79
|
-
stream: StreamRecord;
|
|
80
|
-
records: Map<string, RecordEntry>;
|
|
81
|
-
state: PluginStateAccess;
|
|
82
|
-
admitted: boolean;
|
|
83
|
-
sequence: number;
|
|
84
|
-
}
|
|
85
|
-
export declare class Agent {
|
|
49
|
+
export declare class Agent<M extends ModelSelection = ModelSelection> {
|
|
86
50
|
readonly id: string;
|
|
87
|
-
readonly
|
|
51
|
+
readonly tools: readonly Tool[];
|
|
52
|
+
/** @internal */ readonly toolConcurrency: number;
|
|
53
|
+
readonly model: M;
|
|
88
54
|
private controller?;
|
|
89
55
|
/** @internal */ attachController(controller: Controller): void;
|
|
90
56
|
private runtime;
|
|
@@ -95,34 +61,18 @@ export declare class Agent {
|
|
|
95
61
|
readonly limits: StreamLimits;
|
|
96
62
|
readonly instructions: Instruction;
|
|
97
63
|
private readonly jobs;
|
|
64
|
+
private readonly outcomes;
|
|
98
65
|
private readonly active;
|
|
66
|
+
private readonly pendingModels;
|
|
99
67
|
private closed;
|
|
68
|
+
private readonly releaseId;
|
|
100
69
|
private readonly resumeAdmissions;
|
|
101
|
-
constructor(options: AgentOptions);
|
|
102
|
-
stream(
|
|
103
|
-
generate(
|
|
70
|
+
constructor(options: AgentOptions<M>);
|
|
71
|
+
stream<T extends ModelAdapter = Extract<M, ModelAdapter>>(input: AgentInput, options?: AgentExecutionOptions<T>): Stream;
|
|
72
|
+
generate<T extends ModelAdapter = Extract<M, ModelAdapter>>(input: AgentInput, options?: AgentExecutionOptions<T>): Promise<GenerateOutcome>;
|
|
104
73
|
/** @internal Shared admission for Thread, Session and testing. */
|
|
105
|
-
admit(request: ExecutionRequest, target?: DeliveryTarget, prepare?: () => Promise<void>): Stream;
|
|
106
|
-
private
|
|
107
|
-
|
|
108
|
-
private watchLease;
|
|
109
|
-
private hook;
|
|
110
|
-
private put;
|
|
111
|
-
private rows;
|
|
112
|
-
private services;
|
|
113
|
-
private auxiliary;
|
|
114
|
-
private updateUsage;
|
|
115
|
-
private commit;
|
|
116
|
-
private commitNow;
|
|
117
|
-
private prepareMessage;
|
|
118
|
-
private appendMessage;
|
|
119
|
-
private loop;
|
|
120
|
-
private restoreFrame;
|
|
121
|
-
private prepareRecovery;
|
|
122
|
-
private suspend;
|
|
123
|
-
private prepareResume;
|
|
124
|
-
private prepareResumeFrame;
|
|
125
|
-
private finish;
|
|
126
|
-
cancel(threadId: string, streamId: string, reason?: string, target?: DeliveryTarget): Promise<void>;
|
|
74
|
+
admit(request: ExecutionRequest, target?: DeliveryTarget, prepare?: () => Promise<void>, runtime?: ExecutionRuntime, cleanup?: () => Promise<void>): Stream;
|
|
75
|
+
private executionContext;
|
|
76
|
+
cancel(threadId: string, streamId: string, reason?: string, target?: DeliveryTarget, context?: Pick<ExecutionRequest, "session" | "thread">): Promise<void>;
|
|
127
77
|
shutdown(): Promise<void>;
|
|
128
78
|
}
|