@electric-ax/agents-server 0.4.7 → 0.4.11
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/dist/entrypoint.js +198 -83
- package/dist/index.cjs +195 -82
- package/dist/index.d.cts +26 -7
- package/dist/index.d.ts +26 -7
- package/dist/index.js +196 -83
- package/package.json +6 -6
- package/src/electric-agents/default-entity-schemas.ts +1 -1
- package/src/electric-agents-types.ts +2 -1
- package/src/entity-manager.ts +69 -5
- package/src/index.ts +9 -1
- package/src/manifest-side-effects.ts +11 -0
- package/src/routing/context.ts +18 -1
- package/src/routing/dispatch-policy.ts +1 -1
- package/src/routing/durable-streams-router.ts +1 -1
- package/src/routing/durable-streams-routing-adapter.ts +1 -3
- package/src/routing/entities-router.ts +133 -24
- package/src/routing/entity-types-router.ts +23 -26
- package/src/routing/hooks.ts +1 -1
- package/src/routing/internal-router.ts +83 -38
- package/src/routing/observations-router.ts +74 -0
- package/src/routing/runners-router.ts +1 -1
- package/src/server.ts +12 -0
- package/src/wake-registry.ts +1 -1
- package/src/routing/cron-router.ts +0 -45
package/dist/index.d.cts
CHANGED
|
@@ -187,7 +187,7 @@ import * as drizzle_orm_pg_core238 from "drizzle-orm/pg-core";
|
|
|
187
187
|
import * as drizzle_orm_pg_core239 from "drizzle-orm/pg-core";
|
|
188
188
|
import * as drizzle_orm73 from "drizzle-orm";
|
|
189
189
|
import * as drizzle_orm74 from "drizzle-orm";
|
|
190
|
-
import { EntityTags, WebhookNotification, WebhookSignatureVerifierConfig } from "@electric-ax/agents-runtime";
|
|
190
|
+
import { EntityTags, EventSourceBucket, EventSourceContract, EventSourceContract as EventSourceContract$1, EventSourceFilter, EventSourceSubscription, EventSourceSubscription as EventSourceSubscription$1, EventSourceSubscriptionInput, SubscriptionLifetime, WebhookNotification, WebhookSignatureVerifierConfig } from "@electric-ax/agents-runtime";
|
|
191
191
|
import "@sinclair/typebox";
|
|
192
192
|
import { MaybePromise } from "@durable-streams/client";
|
|
193
193
|
import { AutoRouterType, IRequest } from "itty-router";
|
|
@@ -3441,6 +3441,7 @@ interface TypedSpawnRequest {
|
|
|
3441
3441
|
debounceMs?: number;
|
|
3442
3442
|
timeoutMs?: number;
|
|
3443
3443
|
includeResponse?: boolean;
|
|
3444
|
+
manifestKey?: string;
|
|
3444
3445
|
};
|
|
3445
3446
|
}
|
|
3446
3447
|
interface SendRequest {
|
|
@@ -4157,7 +4158,7 @@ declare class EntityManager {
|
|
|
4157
4158
|
private syncManifestFutureSendSchedule;
|
|
4158
4159
|
private parseEntityUrl;
|
|
4159
4160
|
/**
|
|
4160
|
-
* Deliver a message to an entity's main stream, with optional
|
|
4161
|
+
* Deliver a message to an entity's main stream, with optional inbox schema
|
|
4161
4162
|
* validation.
|
|
4162
4163
|
*/
|
|
4163
4164
|
send(entityUrl: string, req: SendRequest, opts?: {
|
|
@@ -4171,8 +4172,8 @@ declare class EntityManager {
|
|
|
4171
4172
|
}): Promise<void>;
|
|
4172
4173
|
deleteInboxMessage(entityUrl: string, key: string): Promise<void>;
|
|
4173
4174
|
setTag(entityUrl: string, key: string, req: SetTagRequest, token: string): Promise<ElectricAgentsEntity>;
|
|
4174
|
-
|
|
4175
|
-
|
|
4175
|
+
deleteTag(entityUrl: string, key: string, token: string): Promise<ElectricAgentsEntity>;
|
|
4176
|
+
ensureEntitiesMembershipStream(tags: Record<string, string>): Promise<{
|
|
4176
4177
|
sourceRef: string;
|
|
4177
4178
|
streamUrl: string;
|
|
4178
4179
|
}>;
|
|
@@ -4205,6 +4206,18 @@ declare class EntityManager {
|
|
|
4205
4206
|
}): Promise<{
|
|
4206
4207
|
txid: string;
|
|
4207
4208
|
}>;
|
|
4209
|
+
upsertEventSourceSubscription(entityUrl: string, req: {
|
|
4210
|
+
subscription: EventSourceSubscription$1;
|
|
4211
|
+
manifest: Record<string, unknown>;
|
|
4212
|
+
}): Promise<{
|
|
4213
|
+
txid: string;
|
|
4214
|
+
subscription: EventSourceSubscription$1;
|
|
4215
|
+
}>;
|
|
4216
|
+
deleteEventSourceSubscription(entityUrl: string, req: {
|
|
4217
|
+
id: string;
|
|
4218
|
+
}): Promise<{
|
|
4219
|
+
txid: string;
|
|
4220
|
+
}>;
|
|
4208
4221
|
/**
|
|
4209
4222
|
* Register a wake subscription from a subscriber to a source entity.
|
|
4210
4223
|
*/
|
|
@@ -4250,7 +4263,7 @@ declare class EntityManager {
|
|
|
4250
4263
|
status: number;
|
|
4251
4264
|
} | null>;
|
|
4252
4265
|
/**
|
|
4253
|
-
* Add new
|
|
4266
|
+
* Add new inbox/state schema keys to an entity type directly in Postgres.
|
|
4254
4267
|
*/
|
|
4255
4268
|
amendSchemas(typeName: string, schemas: {
|
|
4256
4269
|
inbox_schemas?: Record<string, Record<string, unknown>>;
|
|
@@ -4258,7 +4271,7 @@ declare class EntityManager {
|
|
|
4258
4271
|
}): Promise<ElectricAgentsEntityType>;
|
|
4259
4272
|
/**
|
|
4260
4273
|
* Enrich webhook payload with entity context.
|
|
4261
|
-
* Called by ElectricAgentsServer during webhook
|
|
4274
|
+
* Called by ElectricAgentsServer during subscription webhook dispatch to inject entity context.
|
|
4262
4275
|
*/
|
|
4263
4276
|
enrichPayload(payload: Record<string, unknown>, consumer: {
|
|
4264
4277
|
primary_stream: string;
|
|
@@ -4454,6 +4467,10 @@ declare function webhookSigningMetadata(signer: WebhookSigner, streamRootUrl: st
|
|
|
4454
4467
|
|
|
4455
4468
|
//#endregion
|
|
4456
4469
|
//#region src/routing/context.d.ts
|
|
4470
|
+
interface EventSourceCatalog {
|
|
4471
|
+
listEventSources: () => Array<EventSourceContract$1> | Promise<Array<EventSourceContract$1>>;
|
|
4472
|
+
getEventSource: (sourceKey: string) => EventSourceContract$1 | undefined | Promise<EventSourceContract$1 | undefined>;
|
|
4473
|
+
}
|
|
4457
4474
|
/**
|
|
4458
4475
|
* Per-request tenant context passed through every router and handler.
|
|
4459
4476
|
*
|
|
@@ -4480,6 +4497,8 @@ interface TenantContext {
|
|
|
4480
4497
|
streamClient: StreamClient;
|
|
4481
4498
|
runtime: ElectricAgentsTenantRuntime;
|
|
4482
4499
|
entityBridgeManager: EntityBridgeCoordinator;
|
|
4500
|
+
eventSources?: EventSourceCatalog;
|
|
4501
|
+
ensureEventSourceWakeSource?: (sourceUrl: string) => Promise<void> | void;
|
|
4483
4502
|
isShuttingDown: () => boolean;
|
|
4484
4503
|
}
|
|
4485
4504
|
|
|
@@ -4499,4 +4518,4 @@ declare class UnregisteredTenantError extends Error {
|
|
|
4499
4518
|
declare function isUnregisteredTenantError(error: unknown): error is UnregisteredTenantError;
|
|
4500
4519
|
|
|
4501
4520
|
//#endregion
|
|
4502
|
-
export { AgentsHost, AgentsHostOptions, AgentsHostTenantConfig, AgentsHostTenantRuntime, AuthenticateRequest, ConsumerClaim, DEFAULT_TENANT_ID, DispatchPolicy, DispatchTarget, DrizzleDB, DurableStreamsBearerProvider, DurableStreamsRoutingAdapter, DurableStreamsRoutingInput, Ed25519WebhookSignerOptions, ElectricAgentsEntity, ElectricAgentsEntityRow, ElectricAgentsEntityType, ElectricAgentsRunner, ElectricAgentsUser, EntityBridgeCoordinator, EntityDispatchState, EntityListFilter, EntitySignal, EntityStatus, GlobalRoutes, PgClient, Principal, PrincipalKind, PublicElectricAgentsEntity, PublicWakeNotification, RegisterEntityTypeRequest, RegisterRunnerRequest, RequestPrincipal, RunnerAdminStatus, RunnerHeartbeatRequest, RunnerKind, RunnerLiveness, SendRequest, SignalRequest, SignalResponse, SourceStreamOffset, StreamClient, StreamClientOptions, SubscriptionClaimResponse, SubscriptionCreateInput, SubscriptionResponse, SubscriptionStreamInfo, TenantContext, TypedSpawnRequest, UnregisteredTenantError, WakeNotificationRow, WebhookJwks, WebhookPublicJwk, WebhookSigner, WebhookSigningKeyInput, WebhookSigningMetadata, assertEntitySignal, assertEntityStatus, createDb, createEd25519WebhookSigner, expectedSignalStatus, getDefaultWebhookSigner, globalRouter, isTerminalEntityStatus, isUnregisteredTenantError, pathPrefixedSingleTenantDurableStreamsRoutingAdapter, rejectsNormalWrites, runMigrations, streamRootDurableStreamsRoutingAdapter, tenantRootDurableStreamsRoutingAdapter, toPublicEntity, webhookSigningMetadata };
|
|
4521
|
+
export { AgentsHost, AgentsHostOptions, AgentsHostTenantConfig, AgentsHostTenantRuntime, AuthenticateRequest, ConsumerClaim, DEFAULT_TENANT_ID, DispatchPolicy, DispatchTarget, DrizzleDB, DurableStreamsBearerProvider, DurableStreamsRoutingAdapter, DurableStreamsRoutingInput, Ed25519WebhookSignerOptions, ElectricAgentsEntity, ElectricAgentsEntityRow, ElectricAgentsEntityType, ElectricAgentsRunner, ElectricAgentsUser, EntityBridgeCoordinator, EntityDispatchState, EntityListFilter, EntitySignal, EntityStatus, EventSourceBucket, EventSourceCatalog, EventSourceContract, EventSourceFilter, EventSourceSubscription, EventSourceSubscriptionInput, GlobalRoutes, PgClient, Principal, PrincipalKind, PublicElectricAgentsEntity, PublicWakeNotification, RegisterEntityTypeRequest, RegisterRunnerRequest, RequestPrincipal, RunnerAdminStatus, RunnerHeartbeatRequest, RunnerKind, RunnerLiveness, SendRequest, SignalRequest, SignalResponse, SourceStreamOffset, StreamClient, StreamClientOptions, SubscriptionClaimResponse, SubscriptionCreateInput, SubscriptionLifetime, SubscriptionResponse, SubscriptionStreamInfo, TenantContext, TypedSpawnRequest, UnregisteredTenantError, WakeNotificationRow, WebhookJwks, WebhookPublicJwk, WebhookSigner, WebhookSigningKeyInput, WebhookSigningMetadata, assertEntitySignal, assertEntityStatus, createDb, createEd25519WebhookSigner, expectedSignalStatus, getDefaultWebhookSigner, globalRouter, isTerminalEntityStatus, isUnregisteredTenantError, pathPrefixedSingleTenantDurableStreamsRoutingAdapter, rejectsNormalWrites, runMigrations, streamRootDurableStreamsRoutingAdapter, tenantRootDurableStreamsRoutingAdapter, toPublicEntity, webhookSigningMetadata };
|
package/dist/index.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ import * as drizzle_orm_pg_core237 from "drizzle-orm/pg-core";
|
|
|
189
189
|
import * as drizzle_orm_pg_core238 from "drizzle-orm/pg-core";
|
|
190
190
|
import * as drizzle_orm_pg_core239 from "drizzle-orm/pg-core";
|
|
191
191
|
import { JsonWebKey, KeyObject } from "node:crypto";
|
|
192
|
-
import { EntityTags, WebhookNotification, WebhookSignatureVerifierConfig } from "@electric-ax/agents-runtime";
|
|
192
|
+
import { EntityTags, EventSourceBucket, EventSourceContract, EventSourceContract as EventSourceContract$1, EventSourceFilter, EventSourceSubscription, EventSourceSubscription as EventSourceSubscription$1, EventSourceSubscriptionInput, SubscriptionLifetime, WebhookNotification, WebhookSignatureVerifierConfig } from "@electric-ax/agents-runtime";
|
|
193
193
|
import { MaybePromise } from "@durable-streams/client";
|
|
194
194
|
import "@sinclair/typebox";
|
|
195
195
|
import { AutoRouterType, IRequest } from "itty-router";
|
|
@@ -3442,6 +3442,7 @@ interface TypedSpawnRequest {
|
|
|
3442
3442
|
debounceMs?: number;
|
|
3443
3443
|
timeoutMs?: number;
|
|
3444
3444
|
includeResponse?: boolean;
|
|
3445
|
+
manifestKey?: string;
|
|
3445
3446
|
};
|
|
3446
3447
|
}
|
|
3447
3448
|
interface SendRequest {
|
|
@@ -4158,7 +4159,7 @@ declare class EntityManager {
|
|
|
4158
4159
|
private syncManifestFutureSendSchedule;
|
|
4159
4160
|
private parseEntityUrl;
|
|
4160
4161
|
/**
|
|
4161
|
-
* Deliver a message to an entity's main stream, with optional
|
|
4162
|
+
* Deliver a message to an entity's main stream, with optional inbox schema
|
|
4162
4163
|
* validation.
|
|
4163
4164
|
*/
|
|
4164
4165
|
send(entityUrl: string, req: SendRequest, opts?: {
|
|
@@ -4172,8 +4173,8 @@ declare class EntityManager {
|
|
|
4172
4173
|
}): Promise<void>;
|
|
4173
4174
|
deleteInboxMessage(entityUrl: string, key: string): Promise<void>;
|
|
4174
4175
|
setTag(entityUrl: string, key: string, req: SetTagRequest, token: string): Promise<ElectricAgentsEntity>;
|
|
4175
|
-
|
|
4176
|
-
|
|
4176
|
+
deleteTag(entityUrl: string, key: string, token: string): Promise<ElectricAgentsEntity>;
|
|
4177
|
+
ensureEntitiesMembershipStream(tags: Record<string, string>): Promise<{
|
|
4177
4178
|
sourceRef: string;
|
|
4178
4179
|
streamUrl: string;
|
|
4179
4180
|
}>;
|
|
@@ -4206,6 +4207,18 @@ declare class EntityManager {
|
|
|
4206
4207
|
}): Promise<{
|
|
4207
4208
|
txid: string;
|
|
4208
4209
|
}>;
|
|
4210
|
+
upsertEventSourceSubscription(entityUrl: string, req: {
|
|
4211
|
+
subscription: EventSourceSubscription$1;
|
|
4212
|
+
manifest: Record<string, unknown>;
|
|
4213
|
+
}): Promise<{
|
|
4214
|
+
txid: string;
|
|
4215
|
+
subscription: EventSourceSubscription$1;
|
|
4216
|
+
}>;
|
|
4217
|
+
deleteEventSourceSubscription(entityUrl: string, req: {
|
|
4218
|
+
id: string;
|
|
4219
|
+
}): Promise<{
|
|
4220
|
+
txid: string;
|
|
4221
|
+
}>;
|
|
4209
4222
|
/**
|
|
4210
4223
|
* Register a wake subscription from a subscriber to a source entity.
|
|
4211
4224
|
*/
|
|
@@ -4251,7 +4264,7 @@ declare class EntityManager {
|
|
|
4251
4264
|
status: number;
|
|
4252
4265
|
} | null>;
|
|
4253
4266
|
/**
|
|
4254
|
-
* Add new
|
|
4267
|
+
* Add new inbox/state schema keys to an entity type directly in Postgres.
|
|
4255
4268
|
*/
|
|
4256
4269
|
amendSchemas(typeName: string, schemas: {
|
|
4257
4270
|
inbox_schemas?: Record<string, Record<string, unknown>>;
|
|
@@ -4259,7 +4272,7 @@ declare class EntityManager {
|
|
|
4259
4272
|
}): Promise<ElectricAgentsEntityType>;
|
|
4260
4273
|
/**
|
|
4261
4274
|
* Enrich webhook payload with entity context.
|
|
4262
|
-
* Called by ElectricAgentsServer during webhook
|
|
4275
|
+
* Called by ElectricAgentsServer during subscription webhook dispatch to inject entity context.
|
|
4263
4276
|
*/
|
|
4264
4277
|
enrichPayload(payload: Record<string, unknown>, consumer: {
|
|
4265
4278
|
primary_stream: string;
|
|
@@ -4455,6 +4468,10 @@ declare function webhookSigningMetadata(signer: WebhookSigner, streamRootUrl: st
|
|
|
4455
4468
|
|
|
4456
4469
|
//#endregion
|
|
4457
4470
|
//#region src/routing/context.d.ts
|
|
4471
|
+
interface EventSourceCatalog {
|
|
4472
|
+
listEventSources: () => Array<EventSourceContract$1> | Promise<Array<EventSourceContract$1>>;
|
|
4473
|
+
getEventSource: (sourceKey: string) => EventSourceContract$1 | undefined | Promise<EventSourceContract$1 | undefined>;
|
|
4474
|
+
}
|
|
4458
4475
|
/**
|
|
4459
4476
|
* Per-request tenant context passed through every router and handler.
|
|
4460
4477
|
*
|
|
@@ -4481,6 +4498,8 @@ interface TenantContext {
|
|
|
4481
4498
|
streamClient: StreamClient;
|
|
4482
4499
|
runtime: ElectricAgentsTenantRuntime;
|
|
4483
4500
|
entityBridgeManager: EntityBridgeCoordinator;
|
|
4501
|
+
eventSources?: EventSourceCatalog;
|
|
4502
|
+
ensureEventSourceWakeSource?: (sourceUrl: string) => Promise<void> | void;
|
|
4484
4503
|
isShuttingDown: () => boolean;
|
|
4485
4504
|
}
|
|
4486
4505
|
|
|
@@ -4500,4 +4519,4 @@ declare class UnregisteredTenantError extends Error {
|
|
|
4500
4519
|
declare function isUnregisteredTenantError(error: unknown): error is UnregisteredTenantError;
|
|
4501
4520
|
|
|
4502
4521
|
//#endregion
|
|
4503
|
-
export { AgentsHost, AgentsHostOptions, AgentsHostTenantConfig, AgentsHostTenantRuntime, AuthenticateRequest, ConsumerClaim, DEFAULT_TENANT_ID, DispatchPolicy, DispatchTarget, DrizzleDB, DurableStreamsBearerProvider, DurableStreamsRoutingAdapter, DurableStreamsRoutingInput, Ed25519WebhookSignerOptions, ElectricAgentsEntity, ElectricAgentsEntityRow, ElectricAgentsEntityType, ElectricAgentsRunner, ElectricAgentsUser, EntityBridgeCoordinator, EntityDispatchState, EntityListFilter, EntitySignal, EntityStatus, GlobalRoutes, PgClient, Principal, PrincipalKind, PublicElectricAgentsEntity, PublicWakeNotification, RegisterEntityTypeRequest, RegisterRunnerRequest, RequestPrincipal, RunnerAdminStatus, RunnerHeartbeatRequest, RunnerKind, RunnerLiveness, SendRequest, SignalRequest, SignalResponse, SourceStreamOffset, StreamClient, StreamClientOptions, SubscriptionClaimResponse, SubscriptionCreateInput, SubscriptionResponse, SubscriptionStreamInfo, TenantContext, TypedSpawnRequest, UnregisteredTenantError, WakeNotificationRow, WebhookJwks, WebhookPublicJwk, WebhookSigner, WebhookSigningKeyInput, WebhookSigningMetadata, assertEntitySignal, assertEntityStatus, createDb, createEd25519WebhookSigner, expectedSignalStatus, getDefaultWebhookSigner, globalRouter, isTerminalEntityStatus, isUnregisteredTenantError, pathPrefixedSingleTenantDurableStreamsRoutingAdapter, rejectsNormalWrites, runMigrations, streamRootDurableStreamsRoutingAdapter, tenantRootDurableStreamsRoutingAdapter, toPublicEntity, webhookSigningMetadata };
|
|
4522
|
+
export { AgentsHost, AgentsHostOptions, AgentsHostTenantConfig, AgentsHostTenantRuntime, AuthenticateRequest, ConsumerClaim, DEFAULT_TENANT_ID, DispatchPolicy, DispatchTarget, DrizzleDB, DurableStreamsBearerProvider, DurableStreamsRoutingAdapter, DurableStreamsRoutingInput, Ed25519WebhookSignerOptions, ElectricAgentsEntity, ElectricAgentsEntityRow, ElectricAgentsEntityType, ElectricAgentsRunner, ElectricAgentsUser, EntityBridgeCoordinator, EntityDispatchState, EntityListFilter, EntitySignal, EntityStatus, EventSourceBucket, EventSourceCatalog, EventSourceContract, EventSourceFilter, EventSourceSubscription, EventSourceSubscriptionInput, GlobalRoutes, PgClient, Principal, PrincipalKind, PublicElectricAgentsEntity, PublicWakeNotification, RegisterEntityTypeRequest, RegisterRunnerRequest, RequestPrincipal, RunnerAdminStatus, RunnerHeartbeatRequest, RunnerKind, RunnerLiveness, SendRequest, SignalRequest, SignalResponse, SourceStreamOffset, StreamClient, StreamClientOptions, SubscriptionClaimResponse, SubscriptionCreateInput, SubscriptionLifetime, SubscriptionResponse, SubscriptionStreamInfo, TenantContext, TypedSpawnRequest, UnregisteredTenantError, WakeNotificationRow, WebhookJwks, WebhookPublicJwk, WebhookSigner, WebhookSigningKeyInput, WebhookSigningMetadata, assertEntitySignal, assertEntityStatus, createDb, createEd25519WebhookSigner, expectedSignalStatus, getDefaultWebhookSigner, globalRouter, isTerminalEntityStatus, isUnregisteredTenantError, pathPrefixedSingleTenantDurableStreamsRoutingAdapter, rejectsNormalWrites, runMigrations, streamRootDurableStreamsRoutingAdapter, tenantRootDurableStreamsRoutingAdapter, toPublicEntity, webhookSigningMetadata };
|