electric-ax 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,44 @@
1
+ "use strict";
2
+ const require_chunk = require('./chunk-BCwAaXi7.cjs');
3
+ const __durable_streams_state = require_chunk.__toESM(require("@durable-streams/state"));
4
+ const __electric_ax_agents_runtime = require_chunk.__toESM(require("@electric-ax/agents-runtime"));
5
+
6
+ //#region src/entity-stream-db.ts
7
+ function getMainStreamPath(entityUrl, entity) {
8
+ return entity.streams?.main ?? `${entityUrl}/main`;
9
+ }
10
+ async function createEntityStreamDB(opts) {
11
+ const { baseUrl, entityUrl, initialOffset } = opts;
12
+ console.log(`[createEntityStreamDB] Creating entity stream DB for ${baseUrl}${entityUrl}`);
13
+ let res;
14
+ try {
15
+ res = await fetch(`${baseUrl}${entityUrl}`, { headers: { "content-type": `application/json` } });
16
+ } catch (err) {
17
+ throw new Error(`Could not connect to the Electric Agents server at ${baseUrl} — is it running?\n ${err instanceof Error ? err.message : String(err)}`);
18
+ }
19
+ if (!res.ok) throw new Error(`Failed to fetch entity at ${entityUrl}: ${res.statusText}`);
20
+ const entity = await res.json();
21
+ const streamPath = getMainStreamPath(entityUrl, entity);
22
+ const streamUrl = `${baseUrl}${streamPath}`;
23
+ const db = (0, __durable_streams_state.createStreamDB)({
24
+ streamOptions: {
25
+ url: streamUrl,
26
+ contentType: `application/json`,
27
+ ...initialOffset ? { offset: initialOffset } : {}
28
+ },
29
+ state: __electric_ax_agents_runtime.entityStateSchema
30
+ });
31
+ await db.preload();
32
+ return {
33
+ db,
34
+ close: () => db.close()
35
+ };
36
+ }
37
+
38
+ //#endregion
39
+ Object.defineProperty(exports, 'createEntityStreamDB', {
40
+ enumerable: true,
41
+ get: function () {
42
+ return createEntityStreamDB;
43
+ }
44
+ });
@@ -0,0 +1,3 @@
1
+ const require_entity_stream_db = require('./entity-stream-db-Djo-7a11.cjs');
2
+
3
+ exports.createEntityStreamDB = require_entity_stream_db.createEntityStreamDB
@@ -0,0 +1,2 @@
1
+ import { EntityStreamDB, createEntityStreamDB } from "./entity-stream-db-C2C3t_hD.cjs";
2
+ export { EntityStreamDB, createEntityStreamDB };
@@ -0,0 +1,2 @@
1
+ import { EntityStreamDB, createEntityStreamDB$1 as createEntityStreamDB } from "./entity-stream-db-BzuIvhSy.js";
2
+ export { EntityStreamDB, createEntityStreamDB };
@@ -0,0 +1,3 @@
1
+ import { createEntityStreamDB } from "./entity-stream-db-CGP2xVeJ.js";
2
+
3
+ export { createEntityStreamDB };
@@ -0,0 +1,83 @@
1
+ import { Command } from "commander";
2
+
3
+ //#region src/start.d.ts
4
+ interface StartedDevEnvironment {
5
+ port: number;
6
+ uiUrl: string;
7
+ composeProjectName: string;
8
+ }
9
+ interface StoppedDevEnvironment {
10
+ composeProjectName: string;
11
+ removedVolumes: boolean;
12
+ }
13
+ interface StartedBuiltinAgentsEnvironment {
14
+ port: number;
15
+ url: string;
16
+ registeredBaseUrl: string;
17
+ agentServerUrl: string;
18
+ } //#endregion
19
+ //#region src/index.d.ts
20
+ declare const DEFAULT_ELECTRIC_AGENTS_URL = "http://localhost:4437";
21
+ interface ElectricCliEnv {
22
+ electricAgentsUrl: string;
23
+ electricAgentsIdentity: string;
24
+ }
25
+ interface SpawnCommandOptions {
26
+ args?: string;
27
+ }
28
+ interface SendCommandOptions {
29
+ type?: string;
30
+ json?: boolean;
31
+ }
32
+ interface ObserveCommandOptions {
33
+ from?: string;
34
+ }
35
+ interface PsCommandOptions {
36
+ type?: string;
37
+ status?: string;
38
+ parent?: string;
39
+ }
40
+ interface StartCommandOptions {}
41
+ interface StartBuiltinCommandOptions {
42
+ anthropicApiKey?: string;
43
+ }
44
+ interface StopCommandOptions {
45
+ removeVolumes?: boolean;
46
+ }
47
+ interface ElectricCliHandlers {
48
+ listTypes: () => Promise<void>;
49
+ inspectType: (name: string) => Promise<void>;
50
+ deleteType: (name: string) => Promise<void>;
51
+ spawn: (urlPath: string, options: SpawnCommandOptions) => Promise<void>;
52
+ send: (url: string, message: string, options: SendCommandOptions) => Promise<void>;
53
+ observe: (url: string, options: ObserveCommandOptions) => Promise<void>;
54
+ inspect: (url: string) => Promise<void>;
55
+ ps: (options: PsCommandOptions) => Promise<void>;
56
+ kill: (url: string) => Promise<void>;
57
+ start: (options: StartCommandOptions) => Promise<StartedDevEnvironment>;
58
+ startBuiltin: (options: StartBuiltinCommandOptions) => Promise<StartedBuiltinAgentsEnvironment>;
59
+ stop: (options: StopCommandOptions) => Promise<StoppedDevEnvironment>;
60
+ quickstart: (options: StartBuiltinCommandOptions) => Promise<void>;
61
+ }
62
+ interface InvocationEnv {
63
+ npm_command?: string;
64
+ npm_config_user_agent?: string;
65
+ }
66
+ declare function getElectricCliEnv(env?: NodeJS.ProcessEnv): ElectricCliEnv;
67
+ declare function resolveCommandPrefix(argv: Array<string>, env?: InvocationEnv): string;
68
+ declare function createElectricCliHandlers(env: ElectricCliEnv, commandPrefix?: string): ElectricCliHandlers;
69
+ declare function createElectricProgram({
70
+ env,
71
+ commandName,
72
+ commandPrefix,
73
+ handlers
74
+ }?: {
75
+ env?: ElectricCliEnv;
76
+ handlers?: ElectricCliHandlers;
77
+ commandName?: string;
78
+ commandPrefix?: string;
79
+ }): Command;
80
+ declare function run(argv?: Array<string>): Promise<void>;
81
+
82
+ //#endregion
83
+ export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run };
@@ -0,0 +1,83 @@
1
+ import { Command } from "commander";
2
+
3
+ //#region src/start.d.ts
4
+ interface StartedDevEnvironment {
5
+ port: number;
6
+ uiUrl: string;
7
+ composeProjectName: string;
8
+ }
9
+ interface StoppedDevEnvironment {
10
+ composeProjectName: string;
11
+ removedVolumes: boolean;
12
+ }
13
+ interface StartedBuiltinAgentsEnvironment {
14
+ port: number;
15
+ url: string;
16
+ registeredBaseUrl: string;
17
+ agentServerUrl: string;
18
+ } //#endregion
19
+ //#region src/index.d.ts
20
+ declare const DEFAULT_ELECTRIC_AGENTS_URL = "http://localhost:4437";
21
+ interface ElectricCliEnv {
22
+ electricAgentsUrl: string;
23
+ electricAgentsIdentity: string;
24
+ }
25
+ interface SpawnCommandOptions {
26
+ args?: string;
27
+ }
28
+ interface SendCommandOptions {
29
+ type?: string;
30
+ json?: boolean;
31
+ }
32
+ interface ObserveCommandOptions {
33
+ from?: string;
34
+ }
35
+ interface PsCommandOptions {
36
+ type?: string;
37
+ status?: string;
38
+ parent?: string;
39
+ }
40
+ interface StartCommandOptions {}
41
+ interface StartBuiltinCommandOptions {
42
+ anthropicApiKey?: string;
43
+ }
44
+ interface StopCommandOptions {
45
+ removeVolumes?: boolean;
46
+ }
47
+ interface ElectricCliHandlers {
48
+ listTypes: () => Promise<void>;
49
+ inspectType: (name: string) => Promise<void>;
50
+ deleteType: (name: string) => Promise<void>;
51
+ spawn: (urlPath: string, options: SpawnCommandOptions) => Promise<void>;
52
+ send: (url: string, message: string, options: SendCommandOptions) => Promise<void>;
53
+ observe: (url: string, options: ObserveCommandOptions) => Promise<void>;
54
+ inspect: (url: string) => Promise<void>;
55
+ ps: (options: PsCommandOptions) => Promise<void>;
56
+ kill: (url: string) => Promise<void>;
57
+ start: (options: StartCommandOptions) => Promise<StartedDevEnvironment>;
58
+ startBuiltin: (options: StartBuiltinCommandOptions) => Promise<StartedBuiltinAgentsEnvironment>;
59
+ stop: (options: StopCommandOptions) => Promise<StoppedDevEnvironment>;
60
+ quickstart: (options: StartBuiltinCommandOptions) => Promise<void>;
61
+ }
62
+ interface InvocationEnv {
63
+ npm_command?: string;
64
+ npm_config_user_agent?: string;
65
+ }
66
+ declare function getElectricCliEnv(env?: NodeJS.ProcessEnv): ElectricCliEnv;
67
+ declare function resolveCommandPrefix(argv: Array<string>, env?: InvocationEnv): string;
68
+ declare function createElectricCliHandlers(env: ElectricCliEnv, commandPrefix?: string): ElectricCliHandlers;
69
+ declare function createElectricProgram({
70
+ env,
71
+ commandName,
72
+ commandPrefix,
73
+ handlers
74
+ }?: {
75
+ env?: ElectricCliEnv;
76
+ handlers?: ElectricCliHandlers;
77
+ commandName?: string;
78
+ commandPrefix?: string;
79
+ }): Command;
80
+ declare function run(argv?: Array<string>): Promise<void>;
81
+
82
+ //#endregion
83
+ export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, getElectricCliEnv, resolveCommandPrefix, run };