@electric-ax/agents 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.
@@ -0,0 +1,184 @@
1
+ import { AgentTool, EntityRegistry, EntityStreamDBWithActions, HandlerContext, RuntimeHandler, WakeEvent } from "@electric-ax/agents-runtime";
2
+ import { ChangeEvent } from "@durable-streams/state";
3
+ import { AgentTool as AgentTool$1, StreamFn } from "@mariozechner/pi-agent-core";
4
+ import { IncomingMessage, ServerResponse } from "node:http";
5
+
6
+ //#region src/bootstrap.d.ts
7
+
8
+ declare const DEFAULT_BUILTIN_AGENT_HANDLER_PATH = "/_electric/builtin-agent-handler";
9
+ interface AgentHandlerResult {
10
+ handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
11
+ runtime: RuntimeHandler;
12
+ registry: EntityRegistry;
13
+ typeNames: Array<string>;
14
+ }
15
+ interface BuiltinAgentHandlerOptions {
16
+ agentServerUrl: string;
17
+ serveEndpoint?: string;
18
+ workingDirectory?: string;
19
+ streamFn?: StreamFn;
20
+ createElectricTools?: (context: {
21
+ entityUrl: string;
22
+ entityType: string;
23
+ args: Readonly<Record<string, unknown>>;
24
+ db: EntityStreamDBWithActions;
25
+ events: Array<ChangeEvent>;
26
+ upsertCronSchedule: (opts: {
27
+ id: string;
28
+ expression: string;
29
+ timezone?: string;
30
+ payload?: unknown;
31
+ debounceMs?: number;
32
+ timeoutMs?: number;
33
+ }) => Promise<{
34
+ txid: string;
35
+ }>;
36
+ upsertFutureSendSchedule: (opts: {
37
+ id: string;
38
+ payload: unknown;
39
+ targetUrl?: string;
40
+ fireAt: string;
41
+ from?: string;
42
+ messageType?: string;
43
+ }) => Promise<{
44
+ txid: string;
45
+ }>;
46
+ deleteSchedule: (opts: {
47
+ id: string;
48
+ }) => Promise<{
49
+ txid: string;
50
+ }>;
51
+ }) => Array<AgentTool> | Promise<Array<AgentTool>>;
52
+ }
53
+ declare function createBuiltinAgentHandler(options: BuiltinAgentHandlerOptions): AgentHandlerResult | null;
54
+ declare function createAgentHandler(agentServerUrl: string, workingDirectory?: string, streamFn?: StreamFn, createElectricTools?: BuiltinAgentHandlerOptions[`createElectricTools`], serveEndpoint?: string): AgentHandlerResult | null;
55
+ declare function registerBuiltinAgentTypes(bootstrap: AgentHandlerResult): Promise<void>;
56
+ declare const registerAgentTypes: typeof registerBuiltinAgentTypes; //#endregion
57
+ //#region src/server.d.ts
58
+ interface BuiltinAgentsServerOptions {
59
+ agentServerUrl: string;
60
+ baseUrl?: string;
61
+ port: number;
62
+ host?: string;
63
+ workingDirectory?: string;
64
+ mockStreamFn?: StreamFn;
65
+ webhookPath?: string;
66
+ createElectricTools?: (context: {
67
+ entityUrl: string;
68
+ entityType: string;
69
+ args: Readonly<Record<string, unknown>>;
70
+ db: EntityStreamDBWithActions;
71
+ events: Array<ChangeEvent>;
72
+ upsertCronSchedule: (opts: {
73
+ id: string;
74
+ expression: string;
75
+ timezone?: string;
76
+ payload?: unknown;
77
+ debounceMs?: number;
78
+ timeoutMs?: number;
79
+ }) => Promise<{
80
+ txid: string;
81
+ }>;
82
+ upsertFutureSendSchedule: (opts: {
83
+ id: string;
84
+ payload: unknown;
85
+ targetUrl?: string;
86
+ fireAt: string;
87
+ from?: string;
88
+ messageType?: string;
89
+ }) => Promise<{
90
+ txid: string;
91
+ }>;
92
+ deleteSchedule: (opts: {
93
+ id: string;
94
+ }) => Promise<{
95
+ txid: string;
96
+ }>;
97
+ }) => Array<AgentTool> | Promise<Array<AgentTool>>;
98
+ }
99
+ declare class BuiltinAgentsServer {
100
+ private server;
101
+ private bootstrap;
102
+ private _url;
103
+ private publicBaseUrl;
104
+ readonly options: BuiltinAgentsServerOptions;
105
+ constructor(options: BuiltinAgentsServerOptions);
106
+ get url(): string;
107
+ get registeredBaseUrl(): string;
108
+ start(): Promise<string>;
109
+ stop(): Promise<void>;
110
+ private handleRequest;
111
+ }
112
+
113
+ //#endregion
114
+ //#region src/entrypoint-lib.d.ts
115
+ type EnvSource = Record<string, string | undefined>;
116
+ interface BuiltinAgentsEntrypointOptions extends BuiltinAgentsServerOptions {}
117
+ interface BuiltinAgentsEntrypointServer {
118
+ start: () => Promise<string>;
119
+ stop: () => Promise<void>;
120
+ }
121
+ interface RunBuiltinAgentsEntrypointOptions {
122
+ env?: EnvSource;
123
+ cwd?: string;
124
+ createServer?: (options: BuiltinAgentsEntrypointOptions) => BuiltinAgentsEntrypointServer;
125
+ }
126
+ declare function resolveBuiltinAgentsEntrypointOptions(env?: EnvSource, cwd?: string): BuiltinAgentsEntrypointOptions;
127
+ declare function runBuiltinAgentsEntrypoint({
128
+ env,
129
+ cwd,
130
+ createServer
131
+ }?: RunBuiltinAgentsEntrypointOptions): Promise<{
132
+ options: BuiltinAgentsEntrypointOptions;
133
+ server: BuiltinAgentsEntrypointServer;
134
+ url: string;
135
+ }>;
136
+
137
+ //#endregion
138
+ //#region src/agents/horton.d.ts
139
+ declare const HORTON_MODEL = "claude-sonnet-4-5-20250929";
140
+ declare function generateTitle(userMessage: string, llmCall?: (prompt: string) => Promise<string>): Promise<string>;
141
+ declare function buildHortonSystemPrompt(workingDirectory: string, opts?: {
142
+ hasDocsSupport?: boolean;
143
+ }): string;
144
+ declare function createHortonTools(workingDirectory: string, ctx: HandlerContext, readSet: Set<string>, opts?: {
145
+ docsSearchTool?: AgentTool$1;
146
+ }): Array<AgentTool$1>;
147
+ declare function registerHorton(registry: EntityRegistry, options: {
148
+ workingDirectory: string;
149
+ streamFn?: StreamFn;
150
+ }): Array<string>;
151
+
152
+ //#endregion
153
+ //#region src/agents/worker.d.ts
154
+ declare function registerWorker(registry: EntityRegistry, options: {
155
+ workingDirectory: string;
156
+ streamFn?: StreamFn;
157
+ }): void;
158
+
159
+ //#endregion
160
+ //#region src/tools/spawn-worker.d.ts
161
+ declare const WORKER_TOOL_NAMES: readonly ["bash", "read", "write", "edit", "brave_search", "fetch_url", "spawn_worker"];
162
+ type WorkerToolName = (typeof WORKER_TOOL_NAMES)[number];
163
+ declare function createSpawnWorkerTool(ctx: HandlerContext): AgentTool$1;
164
+
165
+ //#endregion
166
+ //#region src/docs/knowledge-base.d.ts
167
+ interface HortonDocsSupport {
168
+ createSearchTool: () => AgentTool;
169
+ resolveCurrentQuestion: (wake: WakeEvent, events: Array<Pick<ChangeEvent, `type` | `value`>>, inbox: Array<{
170
+ payload?: unknown;
171
+ }>) => string;
172
+ renderRetrievedDocsSource: (wake: WakeEvent, events: Array<Pick<ChangeEvent, `type` | `value`>>, inbox: Array<{
173
+ payload?: unknown;
174
+ }>) => Promise<string>;
175
+ renderCompressedToc: () => Promise<string>;
176
+ ensureReady: () => Promise<void>;
177
+ }
178
+ declare function createHortonDocsSupport(workingDirectory: string, opts?: {
179
+ docsRoot?: string;
180
+ dbPath?: string;
181
+ }): HortonDocsSupport | null;
182
+
183
+ //#endregion
184
+ export { AgentHandlerResult, BuiltinAgentHandlerOptions, BuiltinAgentsEntrypointOptions, BuiltinAgentsEntrypointServer, BuiltinAgentsServer, BuiltinAgentsServerOptions, DEFAULT_BUILTIN_AGENT_HANDLER_PATH, HORTON_MODEL, RunBuiltinAgentsEntrypointOptions, WORKER_TOOL_NAMES, WorkerToolName, buildHortonSystemPrompt, createAgentHandler, createBuiltinAgentHandler, createHortonDocsSupport, createHortonTools, createSpawnWorkerTool, generateTitle, registerAgentTypes, registerBuiltinAgentTypes, registerHorton, registerWorker, resolveBuiltinAgentsEntrypointOptions, runBuiltinAgentsEntrypoint };
@@ -0,0 +1,184 @@
1
+ import { AgentTool, EntityRegistry, EntityStreamDBWithActions, HandlerContext, RuntimeHandler, WakeEvent } from "@electric-ax/agents-runtime";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
3
+ import { ChangeEvent } from "@durable-streams/state";
4
+ import { AgentTool as AgentTool$1, StreamFn } from "@mariozechner/pi-agent-core";
5
+
6
+ //#region src/bootstrap.d.ts
7
+
8
+ declare const DEFAULT_BUILTIN_AGENT_HANDLER_PATH = "/_electric/builtin-agent-handler";
9
+ interface AgentHandlerResult {
10
+ handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
11
+ runtime: RuntimeHandler;
12
+ registry: EntityRegistry;
13
+ typeNames: Array<string>;
14
+ }
15
+ interface BuiltinAgentHandlerOptions {
16
+ agentServerUrl: string;
17
+ serveEndpoint?: string;
18
+ workingDirectory?: string;
19
+ streamFn?: StreamFn;
20
+ createElectricTools?: (context: {
21
+ entityUrl: string;
22
+ entityType: string;
23
+ args: Readonly<Record<string, unknown>>;
24
+ db: EntityStreamDBWithActions;
25
+ events: Array<ChangeEvent>;
26
+ upsertCronSchedule: (opts: {
27
+ id: string;
28
+ expression: string;
29
+ timezone?: string;
30
+ payload?: unknown;
31
+ debounceMs?: number;
32
+ timeoutMs?: number;
33
+ }) => Promise<{
34
+ txid: string;
35
+ }>;
36
+ upsertFutureSendSchedule: (opts: {
37
+ id: string;
38
+ payload: unknown;
39
+ targetUrl?: string;
40
+ fireAt: string;
41
+ from?: string;
42
+ messageType?: string;
43
+ }) => Promise<{
44
+ txid: string;
45
+ }>;
46
+ deleteSchedule: (opts: {
47
+ id: string;
48
+ }) => Promise<{
49
+ txid: string;
50
+ }>;
51
+ }) => Array<AgentTool> | Promise<Array<AgentTool>>;
52
+ }
53
+ declare function createBuiltinAgentHandler(options: BuiltinAgentHandlerOptions): AgentHandlerResult | null;
54
+ declare function createAgentHandler(agentServerUrl: string, workingDirectory?: string, streamFn?: StreamFn, createElectricTools?: BuiltinAgentHandlerOptions[`createElectricTools`], serveEndpoint?: string): AgentHandlerResult | null;
55
+ declare function registerBuiltinAgentTypes(bootstrap: AgentHandlerResult): Promise<void>;
56
+ declare const registerAgentTypes: typeof registerBuiltinAgentTypes; //#endregion
57
+ //#region src/server.d.ts
58
+ interface BuiltinAgentsServerOptions {
59
+ agentServerUrl: string;
60
+ baseUrl?: string;
61
+ port: number;
62
+ host?: string;
63
+ workingDirectory?: string;
64
+ mockStreamFn?: StreamFn;
65
+ webhookPath?: string;
66
+ createElectricTools?: (context: {
67
+ entityUrl: string;
68
+ entityType: string;
69
+ args: Readonly<Record<string, unknown>>;
70
+ db: EntityStreamDBWithActions;
71
+ events: Array<ChangeEvent>;
72
+ upsertCronSchedule: (opts: {
73
+ id: string;
74
+ expression: string;
75
+ timezone?: string;
76
+ payload?: unknown;
77
+ debounceMs?: number;
78
+ timeoutMs?: number;
79
+ }) => Promise<{
80
+ txid: string;
81
+ }>;
82
+ upsertFutureSendSchedule: (opts: {
83
+ id: string;
84
+ payload: unknown;
85
+ targetUrl?: string;
86
+ fireAt: string;
87
+ from?: string;
88
+ messageType?: string;
89
+ }) => Promise<{
90
+ txid: string;
91
+ }>;
92
+ deleteSchedule: (opts: {
93
+ id: string;
94
+ }) => Promise<{
95
+ txid: string;
96
+ }>;
97
+ }) => Array<AgentTool> | Promise<Array<AgentTool>>;
98
+ }
99
+ declare class BuiltinAgentsServer {
100
+ private server;
101
+ private bootstrap;
102
+ private _url;
103
+ private publicBaseUrl;
104
+ readonly options: BuiltinAgentsServerOptions;
105
+ constructor(options: BuiltinAgentsServerOptions);
106
+ get url(): string;
107
+ get registeredBaseUrl(): string;
108
+ start(): Promise<string>;
109
+ stop(): Promise<void>;
110
+ private handleRequest;
111
+ }
112
+
113
+ //#endregion
114
+ //#region src/entrypoint-lib.d.ts
115
+ type EnvSource = Record<string, string | undefined>;
116
+ interface BuiltinAgentsEntrypointOptions extends BuiltinAgentsServerOptions {}
117
+ interface BuiltinAgentsEntrypointServer {
118
+ start: () => Promise<string>;
119
+ stop: () => Promise<void>;
120
+ }
121
+ interface RunBuiltinAgentsEntrypointOptions {
122
+ env?: EnvSource;
123
+ cwd?: string;
124
+ createServer?: (options: BuiltinAgentsEntrypointOptions) => BuiltinAgentsEntrypointServer;
125
+ }
126
+ declare function resolveBuiltinAgentsEntrypointOptions(env?: EnvSource, cwd?: string): BuiltinAgentsEntrypointOptions;
127
+ declare function runBuiltinAgentsEntrypoint({
128
+ env,
129
+ cwd,
130
+ createServer
131
+ }?: RunBuiltinAgentsEntrypointOptions): Promise<{
132
+ options: BuiltinAgentsEntrypointOptions;
133
+ server: BuiltinAgentsEntrypointServer;
134
+ url: string;
135
+ }>;
136
+
137
+ //#endregion
138
+ //#region src/agents/horton.d.ts
139
+ declare const HORTON_MODEL = "claude-sonnet-4-5-20250929";
140
+ declare function generateTitle(userMessage: string, llmCall?: (prompt: string) => Promise<string>): Promise<string>;
141
+ declare function buildHortonSystemPrompt(workingDirectory: string, opts?: {
142
+ hasDocsSupport?: boolean;
143
+ }): string;
144
+ declare function createHortonTools(workingDirectory: string, ctx: HandlerContext, readSet: Set<string>, opts?: {
145
+ docsSearchTool?: AgentTool$1;
146
+ }): Array<AgentTool$1>;
147
+ declare function registerHorton(registry: EntityRegistry, options: {
148
+ workingDirectory: string;
149
+ streamFn?: StreamFn;
150
+ }): Array<string>;
151
+
152
+ //#endregion
153
+ //#region src/agents/worker.d.ts
154
+ declare function registerWorker(registry: EntityRegistry, options: {
155
+ workingDirectory: string;
156
+ streamFn?: StreamFn;
157
+ }): void;
158
+
159
+ //#endregion
160
+ //#region src/tools/spawn-worker.d.ts
161
+ declare const WORKER_TOOL_NAMES: readonly ["bash", "read", "write", "edit", "brave_search", "fetch_url", "spawn_worker"];
162
+ type WorkerToolName = (typeof WORKER_TOOL_NAMES)[number];
163
+ declare function createSpawnWorkerTool(ctx: HandlerContext): AgentTool$1;
164
+
165
+ //#endregion
166
+ //#region src/docs/knowledge-base.d.ts
167
+ interface HortonDocsSupport {
168
+ createSearchTool: () => AgentTool;
169
+ resolveCurrentQuestion: (wake: WakeEvent, events: Array<Pick<ChangeEvent, `type` | `value`>>, inbox: Array<{
170
+ payload?: unknown;
171
+ }>) => string;
172
+ renderRetrievedDocsSource: (wake: WakeEvent, events: Array<Pick<ChangeEvent, `type` | `value`>>, inbox: Array<{
173
+ payload?: unknown;
174
+ }>) => Promise<string>;
175
+ renderCompressedToc: () => Promise<string>;
176
+ ensureReady: () => Promise<void>;
177
+ }
178
+ declare function createHortonDocsSupport(workingDirectory: string, opts?: {
179
+ docsRoot?: string;
180
+ dbPath?: string;
181
+ }): HortonDocsSupport | null;
182
+
183
+ //#endregion
184
+ export { AgentHandlerResult, BuiltinAgentHandlerOptions, BuiltinAgentsEntrypointOptions, BuiltinAgentsEntrypointServer, BuiltinAgentsServer, BuiltinAgentsServerOptions, DEFAULT_BUILTIN_AGENT_HANDLER_PATH, HORTON_MODEL, RunBuiltinAgentsEntrypointOptions, WORKER_TOOL_NAMES, WorkerToolName, buildHortonSystemPrompt, createAgentHandler, createBuiltinAgentHandler, createHortonDocsSupport, createHortonTools, createSpawnWorkerTool, generateTitle, registerAgentTypes, registerBuiltinAgentTypes, registerHorton, registerWorker, resolveBuiltinAgentsEntrypointOptions, runBuiltinAgentsEntrypoint };