@lite-agent/core 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 ADDED
@@ -0,0 +1,38 @@
1
+ # @lite-agent/core
2
+
3
+ Pluggable, event-driven agent core SDK — a lean kernel plus strategy interfaces (model provider, tool-call codec, tools, compaction, permission, approval, input, store), an onion middleware pipeline, and a typed event stream.
4
+
5
+ > **Status: Phase 1 (foundation / walking skeleton).** Real local-model providers, permission + human approval, `ask_user`, context compaction, and sessions land in later phases.
6
+
7
+ ## Quick start
8
+
9
+ ```ts
10
+ import {
11
+ createAgent,
12
+ nativeCodec,
13
+ fakeProvider,
14
+ textBlock,
15
+ } from "@lite-agent/core";
16
+
17
+ const agent = createAgent({
18
+ model: fakeProvider([
19
+ { text: "hi", message: { role: "assistant", content: [textBlock("hi")] } },
20
+ ]),
21
+ codec: nativeCodec(),
22
+ });
23
+
24
+ // Stream typed events
25
+ for await (const ev of agent.run("hello")) {
26
+ if (ev.type === "text_delta") process.stdout.write(ev.text);
27
+ }
28
+
29
+ // Or await the final result
30
+ const result = await agent.send("hello");
31
+ console.log(result.text);
32
+ ```
33
+
34
+ ## Concepts
35
+
36
+ - **Strategies** (swap a part): `ModelProvider`, `ToolCallCodec`, `Tool`, `Compactor`, `PermissionPolicy`, `ApprovalHandler`, `InputHandler`, `Store`.
37
+ - **Middleware** (compose cross-cutting behavior): `wrapModelCall`, `wrapToolCall`, and lifecycle hooks (`beforeAgent`/`afterAgent`/`beforeModel`).
38
+ - **Events** (observe / control): a typed `AgentEvent` stream from `run()`.
@@ -0,0 +1,287 @@
1
+ import { ZodType } from 'zod';
2
+
3
+ type Role = "system" | "user" | "assistant" | "tool";
4
+ type TextBlock = {
5
+ type: "text";
6
+ text: string;
7
+ };
8
+ type ToolCallBlock = {
9
+ type: "tool_call";
10
+ id: string;
11
+ name: string;
12
+ input: unknown;
13
+ };
14
+ type ToolResultBlock = {
15
+ type: "tool_result";
16
+ id: string;
17
+ content: string;
18
+ isError?: boolean;
19
+ };
20
+ type ContentBlock = TextBlock | ToolCallBlock | ToolResultBlock;
21
+ type Message = {
22
+ role: Role;
23
+ content: string | ContentBlock[];
24
+ };
25
+ type AssistantMessage = {
26
+ role: "assistant";
27
+ content: ContentBlock[];
28
+ };
29
+ type ToolCall = {
30
+ id: string;
31
+ name: string;
32
+ input: unknown;
33
+ };
34
+ type ToolResult = {
35
+ id: string;
36
+ name: string;
37
+ content: string;
38
+ isError?: boolean;
39
+ };
40
+ type Usage = {
41
+ inputTokens: number;
42
+ outputTokens: number;
43
+ };
44
+ type StopReason = "stop" | "tool_use" | "max_tokens";
45
+ type UserQuestion = {
46
+ question: string;
47
+ options?: string[];
48
+ multiSelect?: boolean;
49
+ };
50
+ type UserAnswer = {
51
+ text?: string;
52
+ selected?: string[];
53
+ };
54
+ type ToolSpec = {
55
+ name: string;
56
+ description: string;
57
+ parameters: Record<string, unknown>;
58
+ };
59
+ type ModelRequest = {
60
+ model: string;
61
+ system?: string;
62
+ messages: Message[];
63
+ tools?: ToolSpec[];
64
+ maxTokens?: number;
65
+ stopSequences?: string[];
66
+ };
67
+ type ModelChunk = {
68
+ type: "text_delta";
69
+ text: string;
70
+ } | {
71
+ type: "message_done";
72
+ message: AssistantMessage;
73
+ usage: Usage;
74
+ };
75
+ declare const textBlock: (text: string) => TextBlock;
76
+ declare const toolResultBlock: (id: string, content: string, isError?: boolean) => ToolResultBlock;
77
+ declare const isToolCallBlock: (b: ContentBlock) => b is ToolCallBlock;
78
+ declare const isTextBlock: (b: ContentBlock) => b is TextBlock;
79
+
80
+ type RunResult = {
81
+ messages: Message[];
82
+ text: string;
83
+ usage: Usage;
84
+ stopReason: "stop" | "aborted" | "max_turns";
85
+ };
86
+ declare class AgentError extends Error {
87
+ }
88
+ declare class ProviderError extends AgentError {
89
+ readonly status?: number | undefined;
90
+ constructor(message: string, status?: number | undefined);
91
+ }
92
+ declare class ToolError extends AgentError {
93
+ constructor(message: string);
94
+ }
95
+ declare class CodecError extends AgentError {
96
+ constructor(message: string);
97
+ }
98
+ declare class MaxTurnsError extends AgentError {
99
+ constructor(message: string);
100
+ }
101
+ declare class AbortError extends AgentError {
102
+ constructor(message?: string);
103
+ }
104
+ type AgentEvent = {
105
+ type: "turn_start";
106
+ turn: number;
107
+ } | {
108
+ type: "text_delta";
109
+ text: string;
110
+ } | {
111
+ type: "message";
112
+ message: AssistantMessage;
113
+ } | {
114
+ type: "tool_use";
115
+ call: ToolCall;
116
+ } | {
117
+ type: "approval_request";
118
+ call: ToolCall;
119
+ reason?: string;
120
+ } | {
121
+ type: "approval_resolved";
122
+ id: string;
123
+ decision: "allow" | "deny";
124
+ by: string;
125
+ } | {
126
+ type: "input_request";
127
+ call: ToolCall;
128
+ question: UserQuestion;
129
+ } | {
130
+ type: "input_resolved";
131
+ id: string;
132
+ answer: UserAnswer;
133
+ } | {
134
+ type: "tool_result";
135
+ result: ToolResult;
136
+ } | {
137
+ type: "compaction";
138
+ kind: "micro" | "auto";
139
+ before: number;
140
+ after: number;
141
+ } | {
142
+ type: "turn_end";
143
+ turn: number;
144
+ stopReason: StopReason;
145
+ } | {
146
+ type: "error";
147
+ error: AgentError;
148
+ fatal: boolean;
149
+ } | {
150
+ type: "done";
151
+ reason: "stop" | "aborted" | "max_turns";
152
+ result: RunResult;
153
+ };
154
+
155
+ interface ModelProvider {
156
+ readonly id: string;
157
+ stream(req: ModelRequest, signal?: AbortSignal): AsyncIterable<ModelChunk>;
158
+ }
159
+ interface ToolCallCodec {
160
+ encode(req: ModelRequest, tools: ToolSpec[]): ModelRequest;
161
+ decode(message: AssistantMessage): {
162
+ text: string;
163
+ calls: ToolCall[];
164
+ };
165
+ }
166
+ interface ToolContext {
167
+ readonly sessionId: string;
168
+ readonly signal: AbortSignal;
169
+ emit(ev: AgentEvent): void;
170
+ readonly approval?: ApprovalHandler;
171
+ readonly input?: InputHandler;
172
+ readonly sandbox?: Sandbox;
173
+ readonly call?: ToolCall;
174
+ }
175
+ interface Tool<I = unknown> {
176
+ name: string;
177
+ description: string;
178
+ schema: ZodType<I>;
179
+ execute(input: I, ctx: ToolContext): Promise<string> | string;
180
+ }
181
+ type CompactResult = {
182
+ messages: Message[];
183
+ kind?: "micro" | "auto";
184
+ before?: number;
185
+ after?: number;
186
+ };
187
+ interface Compactor {
188
+ maybeCompact(messages: Message[], usage: Usage): Promise<CompactResult>;
189
+ }
190
+ type Decision = "allow" | "deny" | "ask";
191
+ interface PolicyContext {
192
+ readonly sessionId: string;
193
+ }
194
+ interface PermissionPolicy {
195
+ check(call: ToolCall, ctx: PolicyContext): Decision | Promise<Decision>;
196
+ }
197
+ interface ApprovalHandler {
198
+ request(call: ToolCall): Promise<"allow" | "deny">;
199
+ }
200
+ interface InputHandler {
201
+ request(q: UserQuestion): Promise<UserAnswer>;
202
+ }
203
+ interface SandboxWrapOptions {
204
+ readonly cwd: string;
205
+ }
206
+ interface Sandbox {
207
+ readonly id: string;
208
+ wrap(command: string, opts: SandboxWrapOptions): Promise<string> | string;
209
+ dispose?(): Promise<void> | void;
210
+ }
211
+ interface Store {
212
+ load(id: string): Promise<Message[] | null>;
213
+ save(id: string, messages: Message[]): Promise<void>;
214
+ }
215
+
216
+ interface AgentContext {
217
+ readonly sessionId: string;
218
+ messages: Message[];
219
+ readonly turn: number;
220
+ readonly signal: AbortSignal;
221
+ emit(ev: AgentEvent): void;
222
+ state: Map<string, unknown>;
223
+ }
224
+ interface ToolCallContext extends AgentContext {
225
+ readonly call: ToolCall;
226
+ }
227
+ type ModelCall = () => AsyncIterable<ModelChunk>;
228
+ type ToolExec = () => Promise<ToolResult>;
229
+ type LifecycleHook = "beforeAgent" | "afterAgent" | "beforeModel";
230
+ interface Middleware {
231
+ name: string;
232
+ beforeAgent?(ctx: AgentContext): void | Promise<void>;
233
+ afterAgent?(ctx: AgentContext): void | Promise<void>;
234
+ beforeModel?(ctx: AgentContext): void | Promise<void>;
235
+ wrapModelCall?(ctx: AgentContext, next: ModelCall): AsyncIterable<ModelChunk>;
236
+ wrapToolCall?(ctx: ToolCallContext, next: ToolExec): Promise<ToolResult>;
237
+ }
238
+ declare function composeModelCall(mws: Middleware[], ctx: AgentContext, base: ModelCall): ModelCall;
239
+ declare function composeToolCall(mws: Middleware[], ctx: ToolCallContext, base: ToolExec): ToolExec;
240
+ declare function runLifecycle(mws: Middleware[], hook: LifecycleHook, ctx: AgentContext): Promise<void>;
241
+
242
+ interface CreateAgentConfig {
243
+ model: ModelProvider;
244
+ modelName?: string;
245
+ codec: ToolCallCodec;
246
+ tools?: Tool[];
247
+ use?: Middleware[];
248
+ system?: string;
249
+ maxTurns?: number;
250
+ maxTokens?: number;
251
+ sandbox?: Sandbox;
252
+ input?: InputHandler;
253
+ }
254
+ type RunOptions = {
255
+ signal?: AbortSignal;
256
+ sessionId?: string;
257
+ };
258
+ interface Agent {
259
+ run(input: string | Message[], opts?: RunOptions): AsyncGenerator<AgentEvent, RunResult>;
260
+ send(input: string | Message[], opts?: RunOptions): Promise<RunResult>;
261
+ }
262
+ declare function createAgent(cfg: CreateAgentConfig): Agent;
263
+
264
+ declare function nativeCodec(): ToolCallCodec;
265
+
266
+ declare function defineTool<I>(def: Tool<I>): Tool<I>;
267
+ declare function toToolSpec(tool: Tool): ToolSpec;
268
+
269
+ type FakeTurn = {
270
+ text?: string;
271
+ message: AssistantMessage;
272
+ usage?: Usage;
273
+ };
274
+ declare function fakeProvider(turns: FakeTurn[]): ModelProvider;
275
+
276
+ declare function noopSandbox(): Sandbox;
277
+
278
+ interface PolicyOptions {
279
+ allow?: string[];
280
+ ask?: string[];
281
+ deny?: string[];
282
+ default?: Decision;
283
+ }
284
+ declare function policy(opts?: PolicyOptions): PermissionPolicy;
285
+ declare function permission(pol: PermissionPolicy, approval?: ApprovalHandler): Middleware;
286
+
287
+ export { AbortError, type Agent, type AgentContext, AgentError, type AgentEvent, type ApprovalHandler, type AssistantMessage, CodecError, type CompactResult, type Compactor, type ContentBlock, type CreateAgentConfig, type Decision, type FakeTurn, type InputHandler, MaxTurnsError, type Message, type Middleware, type ModelCall, type ModelChunk, type ModelProvider, type ModelRequest, type PermissionPolicy, type PolicyContext, type PolicyOptions, ProviderError, type Role, type RunOptions, type RunResult, type Sandbox, type SandboxWrapOptions, type StopReason, type Store, type TextBlock, type Tool, type ToolCall, type ToolCallBlock, type ToolCallCodec, type ToolCallContext, type ToolContext, ToolError, type ToolExec, type ToolResult, type ToolResultBlock, type ToolSpec, type Usage, type UserAnswer, type UserQuestion, composeModelCall, composeToolCall, createAgent, defineTool, fakeProvider, isTextBlock, isToolCallBlock, nativeCodec, noopSandbox, permission, policy, runLifecycle, textBlock, toToolSpec, toolResultBlock };
package/dist/index.js ADDED
@@ -0,0 +1,295 @@
1
+ // src/sandbox.ts
2
+ function noopSandbox() {
3
+ return { id: "noop", wrap: (command) => command };
4
+ }
5
+
6
+ // src/types.ts
7
+ var textBlock = (text) => ({ type: "text", text });
8
+ var toolResultBlock = (id, content, isError = false) => isError ? { type: "tool_result", id, content, isError: true } : { type: "tool_result", id, content };
9
+ var isToolCallBlock = (b) => b.type === "tool_call";
10
+ var isTextBlock = (b) => b.type === "text";
11
+
12
+ // src/events.ts
13
+ var AgentError = class extends Error {
14
+ };
15
+ var ProviderError = class extends AgentError {
16
+ constructor(message, status) {
17
+ super(message);
18
+ this.status = status;
19
+ this.name = "ProviderError";
20
+ }
21
+ };
22
+ var ToolError = class extends AgentError {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = "ToolError";
26
+ }
27
+ };
28
+ var CodecError = class extends AgentError {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = "CodecError";
32
+ }
33
+ };
34
+ var MaxTurnsError = class extends AgentError {
35
+ constructor(message) {
36
+ super(message);
37
+ this.name = "MaxTurnsError";
38
+ }
39
+ };
40
+ var AbortError = class extends AgentError {
41
+ constructor(message = "aborted") {
42
+ super(message);
43
+ this.name = "AbortError";
44
+ }
45
+ };
46
+
47
+ // src/middleware.ts
48
+ function composeModelCall(mws, ctx, base) {
49
+ return mws.filter((m) => m.wrapModelCall).reduceRight((next, m) => () => m.wrapModelCall(ctx, next), base);
50
+ }
51
+ function composeToolCall(mws, ctx, base) {
52
+ return mws.filter((m) => m.wrapToolCall).reduceRight((next, m) => () => m.wrapToolCall(ctx, next), base);
53
+ }
54
+ async function runLifecycle(mws, hook, ctx) {
55
+ for (const m of mws) {
56
+ const fn = m[hook];
57
+ if (fn) await fn.call(m, ctx);
58
+ }
59
+ }
60
+
61
+ // src/tools/define.ts
62
+ import { z } from "zod";
63
+ function defineTool(def) {
64
+ return def;
65
+ }
66
+ function toToolSpec(tool) {
67
+ return {
68
+ name: tool.name,
69
+ description: tool.description,
70
+ parameters: z.toJSONSchema(tool.schema)
71
+ };
72
+ }
73
+
74
+ // src/kernel.ts
75
+ async function* runKernel(cfg, input, signal, sessionId) {
76
+ let messages = typeof input === "string" ? [{ role: "user", content: input }] : [...input];
77
+ const queue = [];
78
+ const emit = (ev) => {
79
+ queue.push(ev);
80
+ };
81
+ const toolMap = new Map(cfg.tools.map((t) => [t.name, t]));
82
+ const toolSpecs = cfg.tools.map(toToolSpec);
83
+ const state = /* @__PURE__ */ new Map();
84
+ let usage = { inputTokens: 0, outputTokens: 0 };
85
+ function* drain() {
86
+ while (queue.length) yield queue.shift();
87
+ }
88
+ const mkCtx = (turn) => ({ sessionId, messages, turn, signal, emit, state });
89
+ await runLifecycle(cfg.middleware, "beforeAgent", mkCtx(0));
90
+ yield* drain();
91
+ let stopReason = "max_turns";
92
+ for (let turn = 1; turn <= cfg.maxTurns; turn++) {
93
+ if (signal.aborted) {
94
+ stopReason = "aborted";
95
+ break;
96
+ }
97
+ const ctx = mkCtx(turn);
98
+ yield { type: "turn_start", turn };
99
+ await runLifecycle(cfg.middleware, "beforeModel", ctx);
100
+ yield* drain();
101
+ messages = ctx.messages;
102
+ const req = cfg.codec.encode(
103
+ { model: cfg.model, system: cfg.system, messages: ctx.messages, maxTokens: cfg.maxTokens },
104
+ toolSpecs
105
+ );
106
+ const modelCall = composeModelCall(cfg.middleware, ctx, () => cfg.provider.stream(req, signal));
107
+ let assistant;
108
+ for await (const chunk of modelCall()) {
109
+ if (chunk.type === "text_delta") yield { type: "text_delta", text: chunk.text };
110
+ else {
111
+ assistant = chunk.message;
112
+ usage = {
113
+ inputTokens: usage.inputTokens + chunk.usage.inputTokens,
114
+ outputTokens: usage.outputTokens + chunk.usage.outputTokens
115
+ };
116
+ }
117
+ }
118
+ yield* drain();
119
+ if (!assistant) throw new ProviderError("provider produced no message_done chunk");
120
+ ctx.messages.push(assistant);
121
+ yield { type: "message", message: assistant };
122
+ const { calls } = cfg.codec.decode(assistant);
123
+ if (calls.length === 0) {
124
+ yield { type: "turn_end", turn, stopReason: "stop" };
125
+ stopReason = "stop";
126
+ break;
127
+ }
128
+ const resultBlocks = [];
129
+ for (const call of calls) {
130
+ yield { type: "tool_use", call };
131
+ const tctx = { ...ctx, call };
132
+ const tool = toolMap.get(call.name);
133
+ const baseExec = async () => {
134
+ if (!tool) return { id: call.id, name: call.name, content: `Error: unknown tool '${call.name}'`, isError: true };
135
+ try {
136
+ const parsed = tool.schema.parse(call.input);
137
+ const out = await tool.execute(parsed, { sessionId, signal, emit, sandbox: cfg.sandbox, input: cfg.input, call });
138
+ return { id: call.id, name: call.name, content: String(out) };
139
+ } catch (e) {
140
+ return { id: call.id, name: call.name, content: `Error: ${e.message}`, isError: true };
141
+ }
142
+ };
143
+ const result2 = await composeToolCall(cfg.middleware, tctx, baseExec)();
144
+ yield* drain();
145
+ resultBlocks.push(toolResultBlock(result2.id, result2.content, result2.isError));
146
+ yield { type: "tool_result", result: result2 };
147
+ }
148
+ ctx.messages.push({ role: "user", content: resultBlocks });
149
+ yield { type: "turn_end", turn, stopReason: "tool_use" };
150
+ }
151
+ await runLifecycle(cfg.middleware, "afterAgent", mkCtx(0));
152
+ yield* drain();
153
+ const result = { messages, text: lastAssistantText(messages), usage, stopReason };
154
+ yield { type: "done", reason: stopReason, result };
155
+ return result;
156
+ }
157
+ function lastAssistantText(messages) {
158
+ for (let i = messages.length - 1; i >= 0; i--) {
159
+ const m = messages[i];
160
+ if (m && m.role === "assistant" && Array.isArray(m.content)) {
161
+ return m.content.filter(isTextBlock).map((b) => b.text).join("");
162
+ }
163
+ }
164
+ return "";
165
+ }
166
+
167
+ // src/createAgent.ts
168
+ var sessionCounter = 0;
169
+ function createAgent(cfg) {
170
+ const kernelCfg = {
171
+ provider: cfg.model,
172
+ codec: cfg.codec,
173
+ tools: cfg.tools ?? [],
174
+ middleware: cfg.use ?? [],
175
+ model: cfg.modelName ?? cfg.model.id,
176
+ system: cfg.system,
177
+ maxTurns: cfg.maxTurns ?? 50,
178
+ maxTokens: cfg.maxTokens,
179
+ sandbox: cfg.sandbox ?? noopSandbox(),
180
+ input: cfg.input
181
+ };
182
+ const agent = {
183
+ run(input, opts) {
184
+ const signal = opts?.signal ?? new AbortController().signal;
185
+ const sessionId = opts?.sessionId ?? `s${++sessionCounter}`;
186
+ return runKernel(kernelCfg, input, signal, sessionId);
187
+ },
188
+ async send(input, opts) {
189
+ const gen = agent.run(input, opts);
190
+ let r = await gen.next();
191
+ while (!r.done) r = await gen.next();
192
+ return r.value;
193
+ }
194
+ };
195
+ return agent;
196
+ }
197
+
198
+ // src/codecs/native.ts
199
+ function nativeCodec() {
200
+ return {
201
+ encode(req, tools) {
202
+ return tools.length ? { ...req, tools } : req;
203
+ },
204
+ decode(message) {
205
+ const calls = [];
206
+ let text = "";
207
+ for (const block of message.content) {
208
+ if (block.type === "text") text += block.text;
209
+ else if (isToolCallBlock(block)) calls.push({ id: block.id, name: block.name, input: block.input });
210
+ }
211
+ return { text, calls };
212
+ }
213
+ };
214
+ }
215
+
216
+ // src/testing/fakeProvider.ts
217
+ function fakeProvider(turns) {
218
+ let i = 0;
219
+ return {
220
+ id: "fake",
221
+ async *stream() {
222
+ const turn = turns[Math.min(i, turns.length - 1)];
223
+ i++;
224
+ if (!turn) throw new Error("fakeProvider: no turns configured");
225
+ if (turn.text) for (const ch of turn.text) yield { type: "text_delta", text: ch };
226
+ yield {
227
+ type: "message_done",
228
+ message: turn.message,
229
+ usage: turn.usage ?? { inputTokens: 0, outputTokens: 0 }
230
+ };
231
+ }
232
+ };
233
+ }
234
+
235
+ // src/permission.ts
236
+ function globToRegExp(pattern) {
237
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
238
+ return new RegExp(`^${escaped}$`);
239
+ }
240
+ function policy(opts = {}) {
241
+ const compile = (pats) => (pats ?? []).map(globToRegExp);
242
+ const deny = compile(opts.deny);
243
+ const ask = compile(opts.ask);
244
+ const allow = compile(opts.allow);
245
+ const fallback = opts.default ?? "allow";
246
+ const hit = (res, name) => res.some((re) => re.test(name));
247
+ return {
248
+ check(call) {
249
+ if (hit(deny, call.name)) return "deny";
250
+ if (hit(ask, call.name)) return "ask";
251
+ if (hit(allow, call.name)) return "allow";
252
+ return fallback;
253
+ }
254
+ };
255
+ }
256
+ function denied(ctx, reason) {
257
+ return { id: ctx.call.id, name: ctx.call.name, content: `Error: ${reason}`, isError: true };
258
+ }
259
+ function permission(pol, approval) {
260
+ return {
261
+ name: "permission",
262
+ async wrapToolCall(ctx, next) {
263
+ const decision = await pol.check(ctx.call, { sessionId: ctx.sessionId });
264
+ if (decision === "allow") return next();
265
+ if (decision === "deny") return denied(ctx, "blocked by policy");
266
+ ctx.emit({ type: "approval_request", call: ctx.call });
267
+ const resolved = approval ? await approval.request(ctx.call) : "deny";
268
+ ctx.emit({ type: "approval_resolved", id: ctx.call.id, decision: resolved, by: approval ? "user" : "auto" });
269
+ return resolved === "allow" ? next() : denied(ctx, "denied by user");
270
+ }
271
+ };
272
+ }
273
+ export {
274
+ AbortError,
275
+ AgentError,
276
+ CodecError,
277
+ MaxTurnsError,
278
+ ProviderError,
279
+ ToolError,
280
+ composeModelCall,
281
+ composeToolCall,
282
+ createAgent,
283
+ defineTool,
284
+ fakeProvider,
285
+ isTextBlock,
286
+ isToolCallBlock,
287
+ nativeCodec,
288
+ noopSandbox,
289
+ permission,
290
+ policy,
291
+ runLifecycle,
292
+ textBlock,
293
+ toToolSpec,
294
+ toolResultBlock
295
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@lite-agent/core",
3
+ "version": "0.1.0",
4
+ "description": "Pluggable, event-driven agent core: kernel, strategy interfaces, middleware pipeline, and normalized types.",
5
+ "license": "ISC",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "sideEffects": false,
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "keywords": [
23
+ "agent",
24
+ "ai",
25
+ "llm",
26
+ "agent-sdk",
27
+ "tool-use"
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/NelsonYong/lite-agent.git",
32
+ "directory": "packages/core"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup src/index.ts --format esm --dts --clean --tsconfig tsconfig.build.json",
39
+ "test": "vitest run",
40
+ "typecheck": "tsc --noEmit"
41
+ },
42
+ "dependencies": {
43
+ "zod": "^4.3.6"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^25.5.0",
47
+ "tsup": "^8.3.0",
48
+ "typescript": "^6.0.2",
49
+ "vitest": "^2.1.0"
50
+ }
51
+ }