electric-ax 0.2.21 → 0.2.23

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.
@@ -1,4 +1,4 @@
1
- import { ElectricCliEnv } from "./index-_AHIJdEA.cjs";
1
+ import { ElectricCliEnv } from "./index-BGw1zeGA.cjs";
2
2
 
3
3
  //#region src/completions.d.ts
4
4
  declare function fetchEntityTypeNames(env: ElectricCliEnv): Promise<Array<string>>;
@@ -1,4 +1,4 @@
1
- import { ElectricCliEnv } from "./index-CQN8S3b9.js";
1
+ import { ElectricCliEnv } from "./index-gzb1Ju8x.js";
2
2
 
3
3
  //#region src/completions.d.ts
4
4
  declare function fetchEntityTypeNames(env: ElectricCliEnv): Promise<Array<string>>;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('./chunk-BCwAaXi7.cjs');
3
3
  const __electric_ax_agents_runtime = require_chunk.__toESM(require("@electric-ax/agents-runtime"));
4
- const __durable_streams_state_db = require_chunk.__toESM(require("@durable-streams/state/db"));
5
4
 
6
5
  //#region src/entity-api.ts
7
6
  function withLeadingSlash(path) {
@@ -35,15 +34,10 @@ async function createEntityStreamDB(opts) {
35
34
  const entity = await res.json();
36
35
  const streamPath = getMainStreamPath(entityUrl, entity);
37
36
  const streamUrl = (0, __electric_ax_agents_runtime.appendPathToUrl)(baseUrl, streamPath);
38
- const db = (0, __durable_streams_state_db.createStreamDB)({
39
- streamOptions: {
40
- url: streamUrl,
41
- headers: requestHeaders,
42
- contentType: `application/json`,
43
- ...initialOffset ? { offset: initialOffset } : {}
44
- },
45
- state: __electric_ax_agents_runtime.entityStateSchema
46
- });
37
+ const db = (0, __electric_ax_agents_runtime.createEntityStreamDB)(streamUrl, void 0, void 0, { streamOptions: {
38
+ headers: requestHeaders,
39
+ ...initialOffset ? { offset: initialOffset } : {}
40
+ } });
47
41
  await db.preload();
48
42
  return {
49
43
  db,
@@ -2,7 +2,7 @@ import { EntityStreamDB, EntityStreamDB as EntityStreamDB$1 } from "@electric-ax
2
2
 
3
3
  //#region src/entity-stream-db.d.ts
4
4
 
5
- declare function createEntityStreamDB(opts: {
5
+ declare function createEntityStreamDB$1(opts: {
6
6
  baseUrl: string;
7
7
  entityUrl: string;
8
8
  initialOffset?: string;
@@ -11,4 +11,4 @@ declare function createEntityStreamDB(opts: {
11
11
  db: EntityStreamDB;
12
12
  close: () => void;
13
13
  }>; //#endregion
14
- export { EntityStreamDB$1 as EntityStreamDB, createEntityStreamDB as createEntityStreamDB$1 };
14
+ export { EntityStreamDB$1 as EntityStreamDB, createEntityStreamDB$1 };
@@ -1,5 +1,4 @@
1
- import { appendPathToUrl, entityStateSchema } from "@electric-ax/agents-runtime";
2
- import { createStreamDB } from "@durable-streams/state/db";
1
+ import { appendPathToUrl, createEntityStreamDB } from "@electric-ax/agents-runtime";
3
2
 
4
3
  //#region src/entity-api.ts
5
4
  function withLeadingSlash(path) {
@@ -17,7 +16,7 @@ function entityApiUrl(baseUrl, entityUrl, suffix = ``) {
17
16
  function getMainStreamPath(entityUrl, entity) {
18
17
  return entity.streams?.main ?? `${entityUrl}/main`;
19
18
  }
20
- async function createEntityStreamDB(opts) {
19
+ async function createEntityStreamDB$1(opts) {
21
20
  const { baseUrl, entityUrl, initialOffset, headers: serverHeaders } = opts;
22
21
  const requestHeaders = {
23
22
  "content-type": `application/json`,
@@ -33,15 +32,10 @@ async function createEntityStreamDB(opts) {
33
32
  const entity = await res.json();
34
33
  const streamPath = getMainStreamPath(entityUrl, entity);
35
34
  const streamUrl = appendPathToUrl(baseUrl, streamPath);
36
- const db = createStreamDB({
37
- streamOptions: {
38
- url: streamUrl,
39
- headers: requestHeaders,
40
- contentType: `application/json`,
41
- ...initialOffset ? { offset: initialOffset } : {}
42
- },
43
- state: entityStateSchema
44
- });
35
+ const db = createEntityStreamDB(streamUrl, void 0, void 0, { streamOptions: {
36
+ headers: requestHeaders,
37
+ ...initialOffset ? { offset: initialOffset } : {}
38
+ } });
45
39
  await db.preload();
46
40
  return {
47
41
  db,
@@ -50,4 +44,4 @@ async function createEntityStreamDB(opts) {
50
44
  }
51
45
 
52
46
  //#endregion
53
- export { createEntityStreamDB, entityApiPath, entityApiUrl };
47
+ export { createEntityStreamDB$1 as createEntityStreamDB, entityApiPath, entityApiUrl };
@@ -1,3 +1,3 @@
1
- const require_entity_stream_db = require('./entity-stream-db-uLb8jOQA.cjs');
1
+ const require_entity_stream_db = require('./entity-stream-db-DJU-Famv.cjs');
2
2
 
3
3
  exports.createEntityStreamDB = require_entity_stream_db.createEntityStreamDB
@@ -1,2 +1,2 @@
1
- import { EntityStreamDB, createEntityStreamDB$1 as createEntityStreamDB } from "./entity-stream-db-BROzlu7p.js";
1
+ import { EntityStreamDB, createEntityStreamDB$1 as createEntityStreamDB } from "./entity-stream-db-DRQk9DHe.js";
2
2
  export { EntityStreamDB, createEntityStreamDB };
@@ -1,3 +1,3 @@
1
- import { createEntityStreamDB } from "./entity-stream-db-UBN2gowE.js";
1
+ import { createEntityStreamDB } from "./entity-stream-db-thqr5ONI.js";
2
2
 
3
3
  export { createEntityStreamDB };
@@ -35,6 +35,7 @@ declare function getStoppedEnvironmentMessage(stopped: StoppedDevEnvironment): s
35
35
  declare function getStartedBuiltinAgentsMessage(started: StartedBuiltinAgentsEnvironment): string;
36
36
  declare function resolvePullWakeRunnerId(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
37
37
  declare function resolvePullWakeOwnerPrincipal(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
38
+ declare function resolveBuiltinServerHeaders(env: NodeJS.ProcessEnv, fileEnv: Record<string, string>, ownerPrincipal: string): Record<string, string> | undefined;
38
39
  declare function resolveComposeProjectName(_cwd?: string, env?: NodeJS.ProcessEnv): string;
39
40
  declare function waitForElectricAgentsServer(baseUrl: string, options?: WaitForServerOptions): Promise<void>;
40
41
  declare function startElectricAgentsDevEnvironment(_options?: StartCommandOptions, env?: NodeJS.ProcessEnv, cwd?: string): Promise<StartedDevEnvironment>;
@@ -132,4 +133,4 @@ declare function createElectricProgram({
132
133
  declare function run(argv?: Array<string>): Promise<void>;
133
134
 
134
135
  //#endregion
135
- export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveCommandPrefix, resolveComposeProjectName, resolveElectricAgentsPort, resolvePullWakeOwnerPrincipal, resolvePullWakeRunnerId, run, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer };
136
+ export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinServerHeaders, resolveCommandPrefix, resolveComposeProjectName, resolveElectricAgentsPort, resolvePullWakeOwnerPrincipal, resolvePullWakeRunnerId, run, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer };
@@ -35,6 +35,7 @@ declare function getStoppedEnvironmentMessage(stopped: StoppedDevEnvironment): s
35
35
  declare function getStartedBuiltinAgentsMessage(started: StartedBuiltinAgentsEnvironment): string;
36
36
  declare function resolvePullWakeRunnerId(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
37
37
  declare function resolvePullWakeOwnerPrincipal(env?: NodeJS.ProcessEnv, fileEnv?: Record<string, string>): string;
38
+ declare function resolveBuiltinServerHeaders(env: NodeJS.ProcessEnv, fileEnv: Record<string, string>, ownerPrincipal: string): Record<string, string> | undefined;
38
39
  declare function resolveComposeProjectName(_cwd?: string, env?: NodeJS.ProcessEnv): string;
39
40
  declare function waitForElectricAgentsServer(baseUrl: string, options?: WaitForServerOptions): Promise<void>;
40
41
  declare function startElectricAgentsDevEnvironment(_options?: StartCommandOptions, env?: NodeJS.ProcessEnv, cwd?: string): Promise<StartedDevEnvironment>;
@@ -132,4 +133,4 @@ declare function createElectricProgram({
132
133
  declare function run(argv?: Array<string>): Promise<void>;
133
134
 
134
135
  //#endregion
135
- export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveCommandPrefix, resolveComposeProjectName, resolveElectricAgentsPort, resolvePullWakeOwnerPrincipal, resolvePullWakeRunnerId, run, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer };
136
+ export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, getStartedBuiltinAgentsMessage, getStartedEnvironmentMessage, getStoppedEnvironmentMessage, readDotEnvFile, resolveAnthropicApiKey, resolveBuiltinServerHeaders, resolveCommandPrefix, resolveComposeProjectName, resolveElectricAgentsPort, resolvePullWakeOwnerPrincipal, resolvePullWakeRunnerId, run, startBuiltinAgentsServer, startElectricAgentsDevEnvironment, stopElectricAgentsDevEnvironment, waitForElectricAgentsServer };
package/dist/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
  "use strict";
3
3
  const require_chunk = require('./chunk-BCwAaXi7.cjs');
4
4
  const require_completions = require('./completions-BJ1fys8I.cjs');
5
- const require_entity_stream_db = require('./entity-stream-db-uLb8jOQA.cjs');
6
- const require_version = require('./version-BU1gpSFU.cjs');
5
+ const require_entity_stream_db = require('./entity-stream-db-DJU-Famv.cjs');
6
+ const require_version = require('./version-Dp_ZxaMK.cjs');
7
7
  const __electric_ax_agents_runtime = require_chunk.__toESM(require("@electric-ax/agents-runtime"));
8
8
  const node_fs = require_chunk.__toESM(require("node:fs"));
9
9
  const node_os = require_chunk.__toESM(require("node:os"));
@@ -219,8 +219,8 @@ var CliError = class extends Error {};
219
219
  function getDefaultElectricAgentsIdentity() {
220
220
  return `${(0, node_os.userInfo)().username}@${(0, node_os.hostname)()}`;
221
221
  }
222
- function getDefaultElectricAgentsPrincipal() {
223
- return `system:cli-${(0, node_os.userInfo)().username}`;
222
+ function defaultElectricAgentsPrincipalForIdentity(identity) {
223
+ return `user:${identity}`;
224
224
  }
225
225
  function parseElectricAgentsHeaders(raw) {
226
226
  const trimmed = raw?.trim();
@@ -244,10 +244,11 @@ function getElectricCliEnv(env = process.env) {
244
244
  const explicitIdentity = env.ELECTRIC_AGENTS_IDENTITY?.trim();
245
245
  const explicitPrincipal = env.ELECTRIC_AGENTS_PRINCIPAL?.trim();
246
246
  const headers = parseElectricAgentsHeaders(env.ELECTRIC_AGENTS_SERVER_HEADERS);
247
+ const electricAgentsIdentity = explicitIdentity || getDefaultElectricAgentsIdentity();
247
248
  return {
248
249
  electricAgentsUrl: env.ELECTRIC_AGENTS_URL || DEFAULT_ELECTRIC_AGENTS_URL,
249
- electricAgentsIdentity: explicitIdentity || getDefaultElectricAgentsIdentity(),
250
- electricAgentsHeaders: (0, __electric_ax_agents_server_headers.mergeElectricPrincipalHeader)(headers, explicitPrincipal || getDefaultElectricAgentsPrincipal())
250
+ electricAgentsIdentity,
251
+ electricAgentsHeaders: (0, __electric_ax_agents_server_headers.mergeElectricPrincipalHeader)(headers, explicitPrincipal || defaultElectricAgentsPrincipalForIdentity(electricAgentsIdentity))
251
252
  };
252
253
  }
253
254
  function getErrorMessage(error) {
@@ -672,7 +673,7 @@ function getHelpText(commandName) {
672
673
  Environment:
673
674
  ELECTRIC_AGENTS_URL Base URL of the server (default: ${DEFAULT_ELECTRIC_AGENTS_URL})
674
675
  ELECTRIC_AGENTS_IDENTITY Sender identity for messages (default: ${getDefaultElectricAgentsIdentity()})
675
- ELECTRIC_AGENTS_PRINCIPAL Principal key sent as the Electric-Principal header (default: ${getDefaultElectricAgentsPrincipal()})
676
+ ELECTRIC_AGENTS_PRINCIPAL Principal key sent as the Electric-Principal header (default: user:<ELECTRIC_AGENTS_IDENTITY>)
676
677
  ELECTRIC_AGENTS_SERVER_HEADERS Optional JSON object of additional server headers
677
678
  ANTHROPIC_API_KEY Required for '${agentsCommand} start-builtin' and '${agentsCommand} quickstart'
678
679
 
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, resolveCommandPrefix, run } from "./index-_AHIJdEA.cjs";
2
+ import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, resolveCommandPrefix, run } from "./index-BGw1zeGA.cjs";
3
3
  export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, resolveCommandPrefix, run };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, resolveCommandPrefix, run } from "./index-CQN8S3b9.js";
2
+ import { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, resolveCommandPrefix, run } from "./index-gzb1Ju8x.js";
3
3
  export { DEFAULT_ELECTRIC_AGENTS_URL, ElectricCliEnv, ElectricCliHandlers, EntitySignal, ObserveCommandOptions, PsCommandOptions, SendCommandOptions, SignalCommandOptions, SpawnCommandOptions, StartBuiltinCommandOptions, StartCommandOptions, StartedBuiltinAgentsEnvironment, StartedDevEnvironment, StopCommandOptions, StoppedDevEnvironment, createElectricCliHandlers, createElectricProgram, formatQuickstartBackendStartedMessage, getElectricCliEnv, resolveCommandPrefix, run };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { installCompletions, setupCompletions } from "./completions-BkhbBSPI.js";
3
- import { createEntityStreamDB, entityApiPath } from "./entity-stream-db-UBN2gowE.js";
4
- import { ELECTRIC_AX_CLI_VERSION, resolveAnthropicApiKey$1 as resolveAnthropicApiKey } from "./version-BXm4o7Lz.js";
3
+ import { createEntityStreamDB, entityApiPath } from "./entity-stream-db-thqr5ONI.js";
4
+ import { ELECTRIC_AX_CLI_VERSION, resolveAnthropicApiKey$1 as resolveAnthropicApiKey } from "./version-D62IOgCl.js";
5
5
  import { appendPathToUrl, buildEntityTimelineData, buildSections } from "@electric-ax/agents-runtime";
6
6
  import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
7
7
  import { hostname, userInfo } from "node:os";
@@ -217,8 +217,8 @@ var CliError = class extends Error {};
217
217
  function getDefaultElectricAgentsIdentity() {
218
218
  return `${userInfo().username}@${hostname()}`;
219
219
  }
220
- function getDefaultElectricAgentsPrincipal() {
221
- return `system:cli-${userInfo().username}`;
220
+ function defaultElectricAgentsPrincipalForIdentity(identity) {
221
+ return `user:${identity}`;
222
222
  }
223
223
  function parseElectricAgentsHeaders(raw) {
224
224
  const trimmed = raw?.trim();
@@ -242,10 +242,11 @@ function getElectricCliEnv(env = process.env) {
242
242
  const explicitIdentity = env.ELECTRIC_AGENTS_IDENTITY?.trim();
243
243
  const explicitPrincipal = env.ELECTRIC_AGENTS_PRINCIPAL?.trim();
244
244
  const headers = parseElectricAgentsHeaders(env.ELECTRIC_AGENTS_SERVER_HEADERS);
245
+ const electricAgentsIdentity = explicitIdentity || getDefaultElectricAgentsIdentity();
245
246
  return {
246
247
  electricAgentsUrl: env.ELECTRIC_AGENTS_URL || DEFAULT_ELECTRIC_AGENTS_URL,
247
- electricAgentsIdentity: explicitIdentity || getDefaultElectricAgentsIdentity(),
248
- electricAgentsHeaders: mergeElectricPrincipalHeader(headers, explicitPrincipal || getDefaultElectricAgentsPrincipal())
248
+ electricAgentsIdentity,
249
+ electricAgentsHeaders: mergeElectricPrincipalHeader(headers, explicitPrincipal || defaultElectricAgentsPrincipalForIdentity(electricAgentsIdentity))
249
250
  };
250
251
  }
251
252
  function getErrorMessage(error) {
@@ -670,7 +671,7 @@ function getHelpText(commandName) {
670
671
  Environment:
671
672
  ELECTRIC_AGENTS_URL Base URL of the server (default: ${DEFAULT_ELECTRIC_AGENTS_URL})
672
673
  ELECTRIC_AGENTS_IDENTITY Sender identity for messages (default: ${getDefaultElectricAgentsIdentity()})
673
- ELECTRIC_AGENTS_PRINCIPAL Principal key sent as the Electric-Principal header (default: ${getDefaultElectricAgentsPrincipal()})
674
+ ELECTRIC_AGENTS_PRINCIPAL Principal key sent as the Electric-Principal header (default: user:<ELECTRIC_AGENTS_IDENTITY>)
674
675
  ELECTRIC_AGENTS_SERVER_HEADERS Optional JSON object of additional server headers
675
676
  ANTHROPIC_API_KEY Required for '${agentsCommand} start-builtin' and '${agentsCommand} quickstart'
676
677