@tessar/core 0.0.0-stage → 0.1.0-alpha.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 +30 -2
- package/dist/agent.d.ts +128 -0
- package/dist/agent.js +1204 -0
- package/dist/agent.js.map +1 -0
- package/dist/controller.d.ts +53 -0
- package/dist/controller.js +206 -0
- package/dist/controller.js.map +1 -0
- package/dist/engine/abort.d.ts +1 -0
- package/dist/engine/abort.js +17 -0
- package/dist/engine/abort.js.map +1 -0
- package/dist/engine/context.d.ts +6 -0
- package/dist/engine/context.js +20 -0
- package/dist/engine/context.js.map +1 -0
- package/dist/engine/delivery.d.ts +35 -0
- package/dist/engine/delivery.js +147 -0
- package/dist/engine/delivery.js.map +1 -0
- package/dist/engine/interrupt.d.ts +23 -0
- package/dist/engine/interrupt.js +14 -0
- package/dist/engine/interrupt.js.map +1 -0
- package/dist/engine/lineage.d.ts +15 -0
- package/dist/engine/lineage.js +66 -0
- package/dist/engine/lineage.js.map +1 -0
- package/dist/engine/recovery.d.ts +18 -0
- package/dist/engine/recovery.js +21 -0
- package/dist/engine/recovery.js.map +1 -0
- package/dist/engine/resume.d.ts +20 -0
- package/dist/engine/resume.js +61 -0
- package/dist/engine/resume.js.map +1 -0
- package/dist/engine/tool-executor.d.ts +2 -0
- package/dist/engine/tool-executor.js +18 -0
- package/dist/engine/tool-executor.js.map +1 -0
- package/dist/engine/tracked-effects.d.ts +89 -0
- package/dist/engine/tracked-effects.js +143 -0
- package/dist/engine/tracked-effects.js.map +1 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.js +58 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/catalog.d.ts +242 -0
- package/dist/events/catalog.js +89 -0
- package/dist/events/catalog.js.map +1 -0
- package/dist/events/definition.d.ts +48 -0
- package/dist/events/definition.js +39 -0
- package/dist/events/definition.js.map +1 -0
- package/dist/events/dispatcher.d.ts +5 -0
- package/dist/events/dispatcher.js +56 -0
- package/dist/events/dispatcher.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/instruction.d.ts +9 -0
- package/dist/instructions/instruction.js +18 -0
- package/dist/instructions/instruction.js.map +1 -0
- package/dist/json.d.ts +17 -0
- package/dist/json.js +46 -0
- package/dist/json.js.map +1 -0
- package/dist/loop.d.ts +20 -0
- package/dist/loop.js +407 -0
- package/dist/loop.js.map +1 -0
- package/dist/messages/codec.d.ts +5 -0
- package/dist/messages/codec.js +48 -0
- package/dist/messages/codec.js.map +1 -0
- package/dist/messages/message.d.ts +43 -0
- package/dist/messages/message.js +85 -0
- package/dist/messages/message.js.map +1 -0
- package/dist/messages/parts.d.ts +21 -0
- package/dist/messages/parts.js +2 -0
- package/dist/messages/parts.js.map +1 -0
- package/dist/models/cache.d.ts +12 -0
- package/dist/models/cache.js +17 -0
- package/dist/models/cache.js.map +1 -0
- package/dist/models/catalog.d.ts +8 -0
- package/dist/models/catalog.js +3 -0
- package/dist/models/catalog.js.map +1 -0
- package/dist/models/catalog.snapshot.json +1 -0
- package/dist/models/contract.d.ts +57 -0
- package/dist/models/contract.js +2 -0
- package/dist/models/contract.js.map +1 -0
- package/dist/models/normalize-catalog.d.ts +5 -0
- package/dist/models/normalize-catalog.js +84 -0
- package/dist/models/normalize-catalog.js.map +1 -0
- package/dist/models/profile.d.ts +55 -0
- package/dist/models/profile.js +2 -0
- package/dist/models/profile.js.map +1 -0
- package/dist/models/registry.d.ts +22 -0
- package/dist/models/registry.js +134 -0
- package/dist/models/registry.js.map +1 -0
- package/dist/models/resolver.d.ts +23 -0
- package/dist/models/resolver.js +154 -0
- package/dist/models/resolver.js.map +1 -0
- package/dist/models/stream.d.ts +3 -0
- package/dist/models/stream.js +24 -0
- package/dist/models/stream.js.map +1 -0
- package/dist/plugins/context.d.ts +47 -0
- package/dist/plugins/context.js +2 -0
- package/dist/plugins/context.js.map +1 -0
- package/dist/plugins/host.d.ts +28 -0
- package/dist/plugins/host.js +213 -0
- package/dist/plugins/host.js.map +1 -0
- package/dist/plugins/registry.d.ts +42 -0
- package/dist/plugins/registry.js +25 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/session-events.d.ts +60 -0
- package/dist/session-events.js +14 -0
- package/dist/session-events.js.map +1 -0
- package/dist/session.d.ts +77 -0
- package/dist/session.js +353 -0
- package/dist/session.js.map +1 -0
- package/dist/state/commit.d.ts +8 -0
- package/dist/state/commit.js +67 -0
- package/dist/state/commit.js.map +1 -0
- package/dist/state/fork.d.ts +15 -0
- package/dist/state/fork.js +37 -0
- package/dist/state/fork.js.map +1 -0
- package/dist/state/memory-backend.d.ts +5 -0
- package/dist/state/memory-backend.js +88 -0
- package/dist/state/memory-backend.js.map +1 -0
- package/dist/state/plugin-state.d.ts +52 -0
- package/dist/state/plugin-state.js +80 -0
- package/dist/state/plugin-state.js.map +1 -0
- package/dist/state/queries.d.ts +50 -0
- package/dist/state/queries.js +76 -0
- package/dist/state/queries.js.map +1 -0
- package/dist/state/schema.d.ts +145 -0
- package/dist/state/schema.js +2 -0
- package/dist/state/schema.js.map +1 -0
- package/dist/state/scope.d.ts +3 -0
- package/dist/state/scope.js +15 -0
- package/dist/state/scope.js.map +1 -0
- package/dist/state/storage-ports.d.ts +80 -0
- package/dist/state/storage-ports.js +2 -0
- package/dist/state/storage-ports.js.map +1 -0
- package/dist/state/threads.d.ts +28 -0
- package/dist/state/threads.js +49 -0
- package/dist/state/threads.js.map +1 -0
- package/dist/testing/harness.d.ts +35 -0
- package/dist/testing/harness.js +91 -0
- package/dist/testing/harness.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/scripted-provider.d.ts +18 -0
- package/dist/testing/scripted-provider.js +59 -0
- package/dist/testing/scripted-provider.js.map +1 -0
- package/dist/testing/storage-conformance.d.ts +3 -0
- package/dist/testing/storage-conformance.js +93 -0
- package/dist/testing/storage-conformance.js.map +1 -0
- package/dist/thread.d.ts +75 -0
- package/dist/thread.js +121 -0
- package/dist/thread.js.map +1 -0
- package/dist/tools/input-definition.d.ts +5 -0
- package/dist/tools/input-definition.js +2 -0
- package/dist/tools/input-definition.js.map +1 -0
- package/dist/tools/tool.d.ts +51 -0
- package/dist/tools/tool.js +27 -0
- package/dist/tools/tool.js.map +1 -0
- package/dist/trace/records.d.ts +85 -0
- package/dist/trace/records.js +2 -0
- package/dist/trace/records.js.map +1 -0
- package/dist/trace/usage.d.ts +23 -0
- package/dist/trace/usage.js +55 -0
- package/dist/trace/usage.js.map +1 -0
- package/package.json +41 -3
- package/src/models/catalog.LICENSE +21 -0
package/README.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tessar/core
|
|
2
2
|
|
|
3
|
-
|
|
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@next
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
- `Agent` owns its model/instructions/limits and the agent loop.
|
|
11
|
+
- `Controller({ id, agent, plugins })` owns plugin setup, resources and sessions.
|
|
12
|
+
- Call `controller.initialize()` before Agent or Session execution, and
|
|
13
|
+
`controller.dispose()` when finished.
|
|
14
|
+
- `agent.stream()` creates an independent task; `agent.generate()` collects the
|
|
15
|
+
same execution. A Session manages a continuing conversation with
|
|
16
|
+
`session.subscribe()` and queued `session.followUp()` inputs.
|
|
17
|
+
- Core manages state and checkpoints, using memory storage by default.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Agent, Controller, HumanMessage, type Plugin } from "@tessar/core";
|
|
21
|
+
import { createTool, toolResult } from "@tessar/core/tool";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Built-in and custom plugins use classes instantiated with `new`, implementing
|
|
25
|
+
the same `Plugin` instance contract. Providers and persistence backends are
|
|
26
|
+
separate plugins: `@tessar/openai` and `@tessar/sqlite`.
|
|
27
|
+
|
|
28
|
+
This is an alpha release. See the
|
|
29
|
+
[repository](https://github.com/hphucdev-04/tessar) for complete TypeScript
|
|
30
|
+
examples and the current API contracts. The bundled model catalog includes its
|
|
31
|
+
upstream license at `src/models/catalog.LICENSE`.
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Controller } from "./controller.js";
|
|
2
|
+
import type { Model } from "./models/profile.js";
|
|
3
|
+
import type { Scope, InterruptRecord } from "./state/schema.js";
|
|
4
|
+
import { type Stream, type DeliveryTarget, type Attachment } from "./engine/delivery.js";
|
|
5
|
+
export type { Stream, DeliveryTarget } from "./engine/delivery.js";
|
|
6
|
+
import { type ErrorInfo } from "./errors.js";
|
|
7
|
+
import { type Clock, type IdGenerator, type JsonObject, type JsonValue } from "./json.js";
|
|
8
|
+
import { type Instruction } from "./instructions/instruction.js";
|
|
9
|
+
import { type MessageData } from "./messages/message.js";
|
|
10
|
+
import type { ModelRef } from "./models/contract.js";
|
|
11
|
+
import { PluginHost } from "./plugins/host.js";
|
|
12
|
+
import type { RegistryLease } from "./plugins/registry.js";
|
|
13
|
+
import { PluginStateAccess } from "./state/plugin-state.js";
|
|
14
|
+
import type { StorageBackend, Lease } from "./state/storage-ports.js";
|
|
15
|
+
import type { Checkpoint, RecordEntry, StreamLimits } from "./state/schema.js";
|
|
16
|
+
import type { StreamRecord } from "./trace/records.js";
|
|
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 {
|
|
45
|
+
id: string;
|
|
46
|
+
model?: Model | ModelRef;
|
|
47
|
+
instructions?: string | Instruction;
|
|
48
|
+
limits?: Partial<StreamLimits>;
|
|
49
|
+
}
|
|
50
|
+
export interface AgentExecutionOptions {
|
|
51
|
+
input: MessageData | readonly MessageData[];
|
|
52
|
+
model?: Model | ModelRef;
|
|
53
|
+
scope?: Scope;
|
|
54
|
+
context?: JsonObject;
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
limits?: Partial<StreamLimits>;
|
|
57
|
+
}
|
|
58
|
+
export interface GenerateOutcome {
|
|
59
|
+
threadId: string;
|
|
60
|
+
streamId: string;
|
|
61
|
+
status: StreamRecord["status"];
|
|
62
|
+
output: readonly MessageData[];
|
|
63
|
+
usage: import("./trace/usage.js").UsageSummary;
|
|
64
|
+
interrupt: InterruptRecord | null;
|
|
65
|
+
error: ErrorInfo | null;
|
|
66
|
+
}
|
|
67
|
+
export declare function inputMessages(input: MessageData | readonly MessageData[]): readonly MessageData[];
|
|
68
|
+
export interface ExecutionFrame {
|
|
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 {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly model: Readonly<ModelRef> | undefined;
|
|
88
|
+
private controller?;
|
|
89
|
+
/** @internal */ attachController(controller: Controller): void;
|
|
90
|
+
private runtime;
|
|
91
|
+
get backend(): StorageBackend;
|
|
92
|
+
get registry(): PluginHost;
|
|
93
|
+
readonly ids: IdGenerator;
|
|
94
|
+
readonly clock: Clock;
|
|
95
|
+
readonly limits: StreamLimits;
|
|
96
|
+
readonly instructions: Instruction;
|
|
97
|
+
private readonly jobs;
|
|
98
|
+
private readonly active;
|
|
99
|
+
private closed;
|
|
100
|
+
private readonly resumeAdmissions;
|
|
101
|
+
constructor(options: AgentOptions);
|
|
102
|
+
stream(options: AgentExecutionOptions): Stream;
|
|
103
|
+
generate(options: AgentExecutionOptions): Promise<GenerateOutcome>;
|
|
104
|
+
/** @internal Shared admission for Thread, Session and testing. */
|
|
105
|
+
admit(request: ExecutionRequest, target?: DeliveryTarget, prepare?: () => Promise<void>): Stream;
|
|
106
|
+
private execute;
|
|
107
|
+
private eventContext;
|
|
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>;
|
|
127
|
+
shutdown(): Promise<void>;
|
|
128
|
+
}
|