@electric-ax/agents-server 0.4.5 → 0.4.7
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 +404 -68
- package/dist/index.cjs +421 -67
- package/dist/index.d.cts +97 -11
- package/dist/index.d.ts +97 -11
- package/dist/index.js +414 -69
- package/drizzle/0009_entity_signal_statuses.sql +3 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +6 -6
- package/src/db/schema.ts +1 -1
- package/src/electric-agents-types.ts +76 -1
- package/src/entity-manager.ts +256 -33
- package/src/entity-registry.ts +57 -20
- package/src/entrypoint-lib.ts +5 -0
- package/src/index.ts +33 -0
- package/src/routing/context.ts +6 -0
- package/src/routing/dispatch-policy.ts +6 -0
- package/src/routing/durable-streams-router.ts +62 -13
- package/src/routing/entities-router.ts +57 -1
- package/src/routing/internal-router.ts +147 -23
- package/src/routing/runners-router.ts +1 -1
- package/src/runtime.ts +5 -1
- package/src/server.ts +18 -0
- package/src/stream-client.ts +10 -4
- package/src/webhook-signing.ts +173 -0
package/dist/index.d.cts
CHANGED
|
@@ -187,11 +187,12 @@ 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 } from "@electric-ax/agents-runtime";
|
|
190
|
+
import { EntityTags, 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";
|
|
194
194
|
import { Agent } from "undici";
|
|
195
|
+
import { JsonWebKey, KeyObject } from "node:crypto";
|
|
195
196
|
|
|
196
197
|
//#region rolldown:runtime
|
|
197
198
|
declare namespace schema_d_exports {
|
|
@@ -3225,7 +3226,10 @@ interface Principal {
|
|
|
3225
3226
|
type WakeNotification = WebhookNotification;
|
|
3226
3227
|
type RequestPrincipal = Principal;
|
|
3227
3228
|
type AuthenticateRequest = (request: Request) => Promise<Principal | null> | Principal | null;
|
|
3228
|
-
type EntityStatus = `spawning` | `running` | `idle` | `stopped`;
|
|
3229
|
+
type EntityStatus = `spawning` | `running` | `idle` | `paused` | `stopping` | `stopped` | `killed`;
|
|
3230
|
+
declare const ENTITY_SIGNALS: readonly ["SIGINT", "SIGHUP", "SIGTERM", "SIGKILL", "SIGSTOP", "SIGCONT", "SIGUSR"];
|
|
3231
|
+
type EntitySignal = (typeof ENTITY_SIGNALS)[number];
|
|
3232
|
+
declare function assertEntityStatus(s: string): EntityStatus;
|
|
3229
3233
|
type DispatchTarget = {
|
|
3230
3234
|
type: `webhook`;
|
|
3231
3235
|
url: string;
|
|
@@ -3352,6 +3356,10 @@ interface ConsumerClaim {
|
|
|
3352
3356
|
acked_streams?: Array<SourceStreamOffset>;
|
|
3353
3357
|
updated_at: string;
|
|
3354
3358
|
}
|
|
3359
|
+
declare function assertEntitySignal(s: string): EntitySignal;
|
|
3360
|
+
declare function isTerminalEntityStatus(status: EntityStatus): boolean;
|
|
3361
|
+
declare function rejectsNormalWrites(status: EntityStatus): boolean;
|
|
3362
|
+
declare function expectedSignalStatus(status: EntityStatus, signal: EntitySignal): EntityStatus;
|
|
3355
3363
|
interface ElectricAgentsEntity {
|
|
3356
3364
|
url: string;
|
|
3357
3365
|
type: string;
|
|
@@ -3374,7 +3382,26 @@ interface ElectricAgentsEntity {
|
|
|
3374
3382
|
updated_at: number;
|
|
3375
3383
|
}
|
|
3376
3384
|
/** Public-facing entity — internal fields stripped. Standalone type so new internal fields don't silently leak. */
|
|
3377
|
-
|
|
3385
|
+
interface PublicElectricAgentsEntity {
|
|
3386
|
+
url: string;
|
|
3387
|
+
type: string;
|
|
3388
|
+
status: EntityStatus;
|
|
3389
|
+
streams: {
|
|
3390
|
+
main: string;
|
|
3391
|
+
error: string;
|
|
3392
|
+
};
|
|
3393
|
+
dispatch_policy?: DispatchPolicy;
|
|
3394
|
+
tags: Record<string, string>;
|
|
3395
|
+
spawn_args?: Record<string, unknown>;
|
|
3396
|
+
parent?: string;
|
|
3397
|
+
created_by?: string;
|
|
3398
|
+
created_at: number;
|
|
3399
|
+
updated_at: number;
|
|
3400
|
+
}
|
|
3401
|
+
/** Entity row as stored in Postgres / returned by Electric shapes (no derived `streams` field). */
|
|
3402
|
+
type ElectricAgentsEntityRow = Omit<PublicElectricAgentsEntity, `streams`>;
|
|
3403
|
+
/** Strip internal fields (write_token, subscription_id) from an entity. */
|
|
3404
|
+
declare function toPublicEntity(entity: ElectricAgentsEntity): PublicElectricAgentsEntity;
|
|
3378
3405
|
interface ElectricAgentsEntityType {
|
|
3379
3406
|
name: string;
|
|
3380
3407
|
description: string;
|
|
@@ -3424,9 +3451,27 @@ interface SendRequest {
|
|
|
3424
3451
|
mode?: `immediate` | `queued` | `paused` | `steer`;
|
|
3425
3452
|
position?: string;
|
|
3426
3453
|
}
|
|
3454
|
+
interface SignalRequest {
|
|
3455
|
+
signal: EntitySignal;
|
|
3456
|
+
reason?: string;
|
|
3457
|
+
payload?: unknown;
|
|
3458
|
+
}
|
|
3459
|
+
interface SignalResponse {
|
|
3460
|
+
url: string;
|
|
3461
|
+
signal: EntitySignal;
|
|
3462
|
+
previous_state: EntityStatus;
|
|
3463
|
+
new_state: EntityStatus;
|
|
3464
|
+
created_at: number;
|
|
3465
|
+
txid: number;
|
|
3466
|
+
}
|
|
3427
3467
|
interface SetTagRequest {
|
|
3428
3468
|
value: string;
|
|
3429
3469
|
}
|
|
3470
|
+
interface EntityListFilter {
|
|
3471
|
+
type?: string;
|
|
3472
|
+
status?: EntityStatus;
|
|
3473
|
+
created_by?: string;
|
|
3474
|
+
}
|
|
3430
3475
|
|
|
3431
3476
|
//#endregion
|
|
3432
3477
|
//#region src/entity-registry.d.ts
|
|
@@ -3523,7 +3568,10 @@ declare class PostgresRegistry {
|
|
|
3523
3568
|
setRunnerAdminStatus(runnerId: string, adminStatus: RunnerAdminStatus): Promise<ElectricAgentsRunner | null>;
|
|
3524
3569
|
materializeActiveClaim(input: MaterializeActiveClaimInput): Promise<void>;
|
|
3525
3570
|
materializeHeartbeatClaim(input: MaterializeHeartbeatClaimInput): Promise<void>;
|
|
3526
|
-
materializeReleasedClaim(input: MaterializeReleasedClaimInput): Promise<
|
|
3571
|
+
materializeReleasedClaim(input: MaterializeReleasedClaimInput): Promise<{
|
|
3572
|
+
claim: ConsumerClaim | null;
|
|
3573
|
+
entityCleared: boolean;
|
|
3574
|
+
}>;
|
|
3527
3575
|
getActiveClaimsForRunner(runnerId: string): Promise<Array<ConsumerClaim>>;
|
|
3528
3576
|
getDispatchStatsForRunner(runnerId: string): Promise<{
|
|
3529
3577
|
entities_with_active_claim: number;
|
|
@@ -3555,7 +3603,8 @@ declare class PostgresRegistry {
|
|
|
3555
3603
|
total: number;
|
|
3556
3604
|
}>;
|
|
3557
3605
|
updateStatus(entityUrl: string, status: EntityStatus): Promise<void>;
|
|
3558
|
-
updateStatusWithTxid(entityUrl: string, status: EntityStatus): Promise<number>;
|
|
3606
|
+
updateStatusWithTxid(entityUrl: string, status: EntityStatus): Promise<number | null>;
|
|
3607
|
+
touchEntityWithTxid(entityUrl: string): Promise<number | null>;
|
|
3559
3608
|
setEntityTag(url: string, key: string, value: string): Promise<{
|
|
3560
3609
|
entity: ElectricAgentsEntity | null;
|
|
3561
3610
|
changed: boolean;
|
|
@@ -3631,11 +3680,15 @@ interface SubscriptionResponse {
|
|
|
3631
3680
|
streams?: Array<string | SubscriptionStreamInfo>;
|
|
3632
3681
|
webhook?: {
|
|
3633
3682
|
url?: string;
|
|
3683
|
+
signing?: {
|
|
3684
|
+
alg?: string;
|
|
3685
|
+
kid?: string;
|
|
3686
|
+
jwks_url?: string;
|
|
3687
|
+
};
|
|
3634
3688
|
};
|
|
3635
3689
|
wake_stream?: string;
|
|
3636
3690
|
callback_url?: string;
|
|
3637
3691
|
callback_token?: string;
|
|
3638
|
-
webhook_secret?: string;
|
|
3639
3692
|
}
|
|
3640
3693
|
interface SubscriptionCreateInput {
|
|
3641
3694
|
type: `webhook` | `pull-wake`;
|
|
@@ -3691,10 +3744,7 @@ declare class StreamClient {
|
|
|
3691
3744
|
contentType: string;
|
|
3692
3745
|
}): Promise<void>;
|
|
3693
3746
|
exists(path: string): Promise<boolean>;
|
|
3694
|
-
createSubscription(pattern: string, subscriptionId: string, webhookUrl: string, description?: string): Promise<
|
|
3695
|
-
subscription_id: string;
|
|
3696
|
-
webhook_secret?: string;
|
|
3697
|
-
}>;
|
|
3747
|
+
createSubscription(pattern: string, subscriptionId: string, webhookUrl: string, description?: string): Promise<SubscriptionResponse>;
|
|
3698
3748
|
putSubscription(subscriptionId: string, input: SubscriptionCreateInput): Promise<SubscriptionResponse>;
|
|
3699
3749
|
getSubscription(subscriptionId: string): Promise<SubscriptionResponse | null>;
|
|
3700
3750
|
deleteSubscription(subscriptionId: string): Promise<void>;
|
|
@@ -4188,9 +4238,12 @@ declare class EntityManager {
|
|
|
4188
4238
|
*/
|
|
4189
4239
|
private extractRunResponse;
|
|
4190
4240
|
private buildWakeMessage;
|
|
4241
|
+
signal(entityUrl: string, req: SignalRequest): Promise<SignalResponse>;
|
|
4191
4242
|
kill(entityUrl: string): Promise<{
|
|
4192
4243
|
txid: number;
|
|
4193
4244
|
}>;
|
|
4245
|
+
private serverHandlingForSignal;
|
|
4246
|
+
private appendSignalEvent;
|
|
4194
4247
|
validateWriteEvent(entity: ElectricAgentsEntity, event: Record<string, unknown>): Promise<{
|
|
4195
4248
|
code: string;
|
|
4196
4249
|
message: string;
|
|
@@ -4368,6 +4421,37 @@ declare const streamRootDurableStreamsRoutingAdapter: DurableStreamsRoutingAdapt
|
|
|
4368
4421
|
declare const pathPrefixedSingleTenantDurableStreamsRoutingAdapter: DurableStreamsRoutingAdapter;
|
|
4369
4422
|
declare const tenantRootDurableStreamsRoutingAdapter: DurableStreamsRoutingAdapter;
|
|
4370
4423
|
|
|
4424
|
+
//#endregion
|
|
4425
|
+
//#region src/webhook-signing.d.ts
|
|
4426
|
+
interface WebhookPublicJwk {
|
|
4427
|
+
kty: `OKP`;
|
|
4428
|
+
crv: `Ed25519`;
|
|
4429
|
+
x: string;
|
|
4430
|
+
kid: string;
|
|
4431
|
+
use: `sig`;
|
|
4432
|
+
alg: `EdDSA`;
|
|
4433
|
+
}
|
|
4434
|
+
interface WebhookJwks {
|
|
4435
|
+
keys: Array<WebhookPublicJwk>;
|
|
4436
|
+
}
|
|
4437
|
+
interface WebhookSigningMetadata {
|
|
4438
|
+
alg: `ed25519`;
|
|
4439
|
+
kid: string;
|
|
4440
|
+
jwks_url: string;
|
|
4441
|
+
}
|
|
4442
|
+
interface WebhookSigner {
|
|
4443
|
+
sign: (body: Uint8Array | string) => string | Promise<string>;
|
|
4444
|
+
jwks: () => WebhookJwks | Promise<WebhookJwks>;
|
|
4445
|
+
}
|
|
4446
|
+
type WebhookSigningKeyInput = string | Buffer | JsonWebKey | KeyObject;
|
|
4447
|
+
interface Ed25519WebhookSignerOptions {
|
|
4448
|
+
privateKey?: WebhookSigningKeyInput;
|
|
4449
|
+
kid?: string;
|
|
4450
|
+
}
|
|
4451
|
+
declare function createEd25519WebhookSigner(options?: Ed25519WebhookSignerOptions): WebhookSigner;
|
|
4452
|
+
declare function getDefaultWebhookSigner(): WebhookSigner;
|
|
4453
|
+
declare function webhookSigningMetadata(signer: WebhookSigner, streamRootUrl: string): Promise<WebhookSigningMetadata>;
|
|
4454
|
+
|
|
4371
4455
|
//#endregion
|
|
4372
4456
|
//#region src/routing/context.d.ts
|
|
4373
4457
|
/**
|
|
@@ -4386,6 +4470,8 @@ interface TenantContext {
|
|
|
4386
4470
|
durableStreamsBearer?: DurableStreamsBearerProvider;
|
|
4387
4471
|
durableStreamsRouting?: DurableStreamsRoutingAdapter;
|
|
4388
4472
|
durableStreamsDispatcher: Agent;
|
|
4473
|
+
durableStreamsWebhookSignature?: false | Partial<WebhookSignatureVerifierConfig>;
|
|
4474
|
+
webhookSigner?: WebhookSigner;
|
|
4389
4475
|
electricUrl?: string;
|
|
4390
4476
|
electricSecret?: string;
|
|
4391
4477
|
ownAgentHandlerPaths?: ReadonlyArray<string>;
|
|
@@ -4413,4 +4499,4 @@ declare class UnregisteredTenantError extends Error {
|
|
|
4413
4499
|
declare function isUnregisteredTenantError(error: unknown): error is UnregisteredTenantError;
|
|
4414
4500
|
|
|
4415
4501
|
//#endregion
|
|
4416
|
-
export { AgentsHost, AgentsHostOptions, AgentsHostTenantConfig, AgentsHostTenantRuntime, AuthenticateRequest, ConsumerClaim, DEFAULT_TENANT_ID, DispatchPolicy, DispatchTarget, DrizzleDB, DurableStreamsBearerProvider, DurableStreamsRoutingAdapter, DurableStreamsRoutingInput, ElectricAgentsRunner, ElectricAgentsUser, EntityBridgeCoordinator, EntityDispatchState, GlobalRoutes, PgClient, Principal, PrincipalKind, PublicWakeNotification, RegisterRunnerRequest, RequestPrincipal, RunnerAdminStatus, RunnerHeartbeatRequest, RunnerKind, RunnerLiveness, SourceStreamOffset, StreamClient, StreamClientOptions, SubscriptionClaimResponse, SubscriptionCreateInput, SubscriptionResponse, SubscriptionStreamInfo, TenantContext, UnregisteredTenantError, WakeNotificationRow, createDb, globalRouter, isUnregisteredTenantError, pathPrefixedSingleTenantDurableStreamsRoutingAdapter, runMigrations, streamRootDurableStreamsRoutingAdapter, tenantRootDurableStreamsRoutingAdapter };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -188,7 +188,8 @@ import * as drizzle_orm_pg_core236 from "drizzle-orm/pg-core";
|
|
|
188
188
|
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
|
-
import {
|
|
191
|
+
import { JsonWebKey, KeyObject } from "node:crypto";
|
|
192
|
+
import { EntityTags, WebhookNotification, WebhookSignatureVerifierConfig } from "@electric-ax/agents-runtime";
|
|
192
193
|
import { MaybePromise } from "@durable-streams/client";
|
|
193
194
|
import "@sinclair/typebox";
|
|
194
195
|
import { AutoRouterType, IRequest } from "itty-router";
|
|
@@ -3226,7 +3227,10 @@ interface Principal {
|
|
|
3226
3227
|
type WakeNotification = WebhookNotification;
|
|
3227
3228
|
type RequestPrincipal = Principal;
|
|
3228
3229
|
type AuthenticateRequest = (request: Request) => Promise<Principal | null> | Principal | null;
|
|
3229
|
-
type EntityStatus = `spawning` | `running` | `idle` | `stopped`;
|
|
3230
|
+
type EntityStatus = `spawning` | `running` | `idle` | `paused` | `stopping` | `stopped` | `killed`;
|
|
3231
|
+
declare const ENTITY_SIGNALS: readonly ["SIGINT", "SIGHUP", "SIGTERM", "SIGKILL", "SIGSTOP", "SIGCONT", "SIGUSR"];
|
|
3232
|
+
type EntitySignal = (typeof ENTITY_SIGNALS)[number];
|
|
3233
|
+
declare function assertEntityStatus(s: string): EntityStatus;
|
|
3230
3234
|
type DispatchTarget = {
|
|
3231
3235
|
type: `webhook`;
|
|
3232
3236
|
url: string;
|
|
@@ -3353,6 +3357,10 @@ interface ConsumerClaim {
|
|
|
3353
3357
|
acked_streams?: Array<SourceStreamOffset>;
|
|
3354
3358
|
updated_at: string;
|
|
3355
3359
|
}
|
|
3360
|
+
declare function assertEntitySignal(s: string): EntitySignal;
|
|
3361
|
+
declare function isTerminalEntityStatus(status: EntityStatus): boolean;
|
|
3362
|
+
declare function rejectsNormalWrites(status: EntityStatus): boolean;
|
|
3363
|
+
declare function expectedSignalStatus(status: EntityStatus, signal: EntitySignal): EntityStatus;
|
|
3356
3364
|
interface ElectricAgentsEntity {
|
|
3357
3365
|
url: string;
|
|
3358
3366
|
type: string;
|
|
@@ -3375,7 +3383,26 @@ interface ElectricAgentsEntity {
|
|
|
3375
3383
|
updated_at: number;
|
|
3376
3384
|
}
|
|
3377
3385
|
/** Public-facing entity — internal fields stripped. Standalone type so new internal fields don't silently leak. */
|
|
3378
|
-
|
|
3386
|
+
interface PublicElectricAgentsEntity {
|
|
3387
|
+
url: string;
|
|
3388
|
+
type: string;
|
|
3389
|
+
status: EntityStatus;
|
|
3390
|
+
streams: {
|
|
3391
|
+
main: string;
|
|
3392
|
+
error: string;
|
|
3393
|
+
};
|
|
3394
|
+
dispatch_policy?: DispatchPolicy;
|
|
3395
|
+
tags: Record<string, string>;
|
|
3396
|
+
spawn_args?: Record<string, unknown>;
|
|
3397
|
+
parent?: string;
|
|
3398
|
+
created_by?: string;
|
|
3399
|
+
created_at: number;
|
|
3400
|
+
updated_at: number;
|
|
3401
|
+
}
|
|
3402
|
+
/** Entity row as stored in Postgres / returned by Electric shapes (no derived `streams` field). */
|
|
3403
|
+
type ElectricAgentsEntityRow = Omit<PublicElectricAgentsEntity, `streams`>;
|
|
3404
|
+
/** Strip internal fields (write_token, subscription_id) from an entity. */
|
|
3405
|
+
declare function toPublicEntity(entity: ElectricAgentsEntity): PublicElectricAgentsEntity;
|
|
3379
3406
|
interface ElectricAgentsEntityType {
|
|
3380
3407
|
name: string;
|
|
3381
3408
|
description: string;
|
|
@@ -3425,9 +3452,27 @@ interface SendRequest {
|
|
|
3425
3452
|
mode?: `immediate` | `queued` | `paused` | `steer`;
|
|
3426
3453
|
position?: string;
|
|
3427
3454
|
}
|
|
3455
|
+
interface SignalRequest {
|
|
3456
|
+
signal: EntitySignal;
|
|
3457
|
+
reason?: string;
|
|
3458
|
+
payload?: unknown;
|
|
3459
|
+
}
|
|
3460
|
+
interface SignalResponse {
|
|
3461
|
+
url: string;
|
|
3462
|
+
signal: EntitySignal;
|
|
3463
|
+
previous_state: EntityStatus;
|
|
3464
|
+
new_state: EntityStatus;
|
|
3465
|
+
created_at: number;
|
|
3466
|
+
txid: number;
|
|
3467
|
+
}
|
|
3428
3468
|
interface SetTagRequest {
|
|
3429
3469
|
value: string;
|
|
3430
3470
|
}
|
|
3471
|
+
interface EntityListFilter {
|
|
3472
|
+
type?: string;
|
|
3473
|
+
status?: EntityStatus;
|
|
3474
|
+
created_by?: string;
|
|
3475
|
+
}
|
|
3431
3476
|
|
|
3432
3477
|
//#endregion
|
|
3433
3478
|
//#region src/entity-registry.d.ts
|
|
@@ -3524,7 +3569,10 @@ declare class PostgresRegistry {
|
|
|
3524
3569
|
setRunnerAdminStatus(runnerId: string, adminStatus: RunnerAdminStatus): Promise<ElectricAgentsRunner | null>;
|
|
3525
3570
|
materializeActiveClaim(input: MaterializeActiveClaimInput): Promise<void>;
|
|
3526
3571
|
materializeHeartbeatClaim(input: MaterializeHeartbeatClaimInput): Promise<void>;
|
|
3527
|
-
materializeReleasedClaim(input: MaterializeReleasedClaimInput): Promise<
|
|
3572
|
+
materializeReleasedClaim(input: MaterializeReleasedClaimInput): Promise<{
|
|
3573
|
+
claim: ConsumerClaim | null;
|
|
3574
|
+
entityCleared: boolean;
|
|
3575
|
+
}>;
|
|
3528
3576
|
getActiveClaimsForRunner(runnerId: string): Promise<Array<ConsumerClaim>>;
|
|
3529
3577
|
getDispatchStatsForRunner(runnerId: string): Promise<{
|
|
3530
3578
|
entities_with_active_claim: number;
|
|
@@ -3556,7 +3604,8 @@ declare class PostgresRegistry {
|
|
|
3556
3604
|
total: number;
|
|
3557
3605
|
}>;
|
|
3558
3606
|
updateStatus(entityUrl: string, status: EntityStatus): Promise<void>;
|
|
3559
|
-
updateStatusWithTxid(entityUrl: string, status: EntityStatus): Promise<number>;
|
|
3607
|
+
updateStatusWithTxid(entityUrl: string, status: EntityStatus): Promise<number | null>;
|
|
3608
|
+
touchEntityWithTxid(entityUrl: string): Promise<number | null>;
|
|
3560
3609
|
setEntityTag(url: string, key: string, value: string): Promise<{
|
|
3561
3610
|
entity: ElectricAgentsEntity | null;
|
|
3562
3611
|
changed: boolean;
|
|
@@ -3632,11 +3681,15 @@ interface SubscriptionResponse {
|
|
|
3632
3681
|
streams?: Array<string | SubscriptionStreamInfo>;
|
|
3633
3682
|
webhook?: {
|
|
3634
3683
|
url?: string;
|
|
3684
|
+
signing?: {
|
|
3685
|
+
alg?: string;
|
|
3686
|
+
kid?: string;
|
|
3687
|
+
jwks_url?: string;
|
|
3688
|
+
};
|
|
3635
3689
|
};
|
|
3636
3690
|
wake_stream?: string;
|
|
3637
3691
|
callback_url?: string;
|
|
3638
3692
|
callback_token?: string;
|
|
3639
|
-
webhook_secret?: string;
|
|
3640
3693
|
}
|
|
3641
3694
|
interface SubscriptionCreateInput {
|
|
3642
3695
|
type: `webhook` | `pull-wake`;
|
|
@@ -3692,10 +3745,7 @@ declare class StreamClient {
|
|
|
3692
3745
|
contentType: string;
|
|
3693
3746
|
}): Promise<void>;
|
|
3694
3747
|
exists(path: string): Promise<boolean>;
|
|
3695
|
-
createSubscription(pattern: string, subscriptionId: string, webhookUrl: string, description?: string): Promise<
|
|
3696
|
-
subscription_id: string;
|
|
3697
|
-
webhook_secret?: string;
|
|
3698
|
-
}>;
|
|
3748
|
+
createSubscription(pattern: string, subscriptionId: string, webhookUrl: string, description?: string): Promise<SubscriptionResponse>;
|
|
3699
3749
|
putSubscription(subscriptionId: string, input: SubscriptionCreateInput): Promise<SubscriptionResponse>;
|
|
3700
3750
|
getSubscription(subscriptionId: string): Promise<SubscriptionResponse | null>;
|
|
3701
3751
|
deleteSubscription(subscriptionId: string): Promise<void>;
|
|
@@ -4189,9 +4239,12 @@ declare class EntityManager {
|
|
|
4189
4239
|
*/
|
|
4190
4240
|
private extractRunResponse;
|
|
4191
4241
|
private buildWakeMessage;
|
|
4242
|
+
signal(entityUrl: string, req: SignalRequest): Promise<SignalResponse>;
|
|
4192
4243
|
kill(entityUrl: string): Promise<{
|
|
4193
4244
|
txid: number;
|
|
4194
4245
|
}>;
|
|
4246
|
+
private serverHandlingForSignal;
|
|
4247
|
+
private appendSignalEvent;
|
|
4195
4248
|
validateWriteEvent(entity: ElectricAgentsEntity, event: Record<string, unknown>): Promise<{
|
|
4196
4249
|
code: string;
|
|
4197
4250
|
message: string;
|
|
@@ -4369,6 +4422,37 @@ declare const streamRootDurableStreamsRoutingAdapter: DurableStreamsRoutingAdapt
|
|
|
4369
4422
|
declare const pathPrefixedSingleTenantDurableStreamsRoutingAdapter: DurableStreamsRoutingAdapter;
|
|
4370
4423
|
declare const tenantRootDurableStreamsRoutingAdapter: DurableStreamsRoutingAdapter;
|
|
4371
4424
|
|
|
4425
|
+
//#endregion
|
|
4426
|
+
//#region src/webhook-signing.d.ts
|
|
4427
|
+
interface WebhookPublicJwk {
|
|
4428
|
+
kty: `OKP`;
|
|
4429
|
+
crv: `Ed25519`;
|
|
4430
|
+
x: string;
|
|
4431
|
+
kid: string;
|
|
4432
|
+
use: `sig`;
|
|
4433
|
+
alg: `EdDSA`;
|
|
4434
|
+
}
|
|
4435
|
+
interface WebhookJwks {
|
|
4436
|
+
keys: Array<WebhookPublicJwk>;
|
|
4437
|
+
}
|
|
4438
|
+
interface WebhookSigningMetadata {
|
|
4439
|
+
alg: `ed25519`;
|
|
4440
|
+
kid: string;
|
|
4441
|
+
jwks_url: string;
|
|
4442
|
+
}
|
|
4443
|
+
interface WebhookSigner {
|
|
4444
|
+
sign: (body: Uint8Array | string) => string | Promise<string>;
|
|
4445
|
+
jwks: () => WebhookJwks | Promise<WebhookJwks>;
|
|
4446
|
+
}
|
|
4447
|
+
type WebhookSigningKeyInput = string | Buffer | JsonWebKey | KeyObject;
|
|
4448
|
+
interface Ed25519WebhookSignerOptions {
|
|
4449
|
+
privateKey?: WebhookSigningKeyInput;
|
|
4450
|
+
kid?: string;
|
|
4451
|
+
}
|
|
4452
|
+
declare function createEd25519WebhookSigner(options?: Ed25519WebhookSignerOptions): WebhookSigner;
|
|
4453
|
+
declare function getDefaultWebhookSigner(): WebhookSigner;
|
|
4454
|
+
declare function webhookSigningMetadata(signer: WebhookSigner, streamRootUrl: string): Promise<WebhookSigningMetadata>;
|
|
4455
|
+
|
|
4372
4456
|
//#endregion
|
|
4373
4457
|
//#region src/routing/context.d.ts
|
|
4374
4458
|
/**
|
|
@@ -4387,6 +4471,8 @@ interface TenantContext {
|
|
|
4387
4471
|
durableStreamsBearer?: DurableStreamsBearerProvider;
|
|
4388
4472
|
durableStreamsRouting?: DurableStreamsRoutingAdapter;
|
|
4389
4473
|
durableStreamsDispatcher: Agent;
|
|
4474
|
+
durableStreamsWebhookSignature?: false | Partial<WebhookSignatureVerifierConfig>;
|
|
4475
|
+
webhookSigner?: WebhookSigner;
|
|
4390
4476
|
electricUrl?: string;
|
|
4391
4477
|
electricSecret?: string;
|
|
4392
4478
|
ownAgentHandlerPaths?: ReadonlyArray<string>;
|
|
@@ -4414,4 +4500,4 @@ declare class UnregisteredTenantError extends Error {
|
|
|
4414
4500
|
declare function isUnregisteredTenantError(error: unknown): error is UnregisteredTenantError;
|
|
4415
4501
|
|
|
4416
4502
|
//#endregion
|
|
4417
|
-
export { AgentsHost, AgentsHostOptions, AgentsHostTenantConfig, AgentsHostTenantRuntime, AuthenticateRequest, ConsumerClaim, DEFAULT_TENANT_ID, DispatchPolicy, DispatchTarget, DrizzleDB, DurableStreamsBearerProvider, DurableStreamsRoutingAdapter, DurableStreamsRoutingInput, ElectricAgentsRunner, ElectricAgentsUser, EntityBridgeCoordinator, EntityDispatchState, GlobalRoutes, PgClient, Principal, PrincipalKind, PublicWakeNotification, RegisterRunnerRequest, RequestPrincipal, RunnerAdminStatus, RunnerHeartbeatRequest, RunnerKind, RunnerLiveness, SourceStreamOffset, StreamClient, StreamClientOptions, SubscriptionClaimResponse, SubscriptionCreateInput, SubscriptionResponse, SubscriptionStreamInfo, TenantContext, UnregisteredTenantError, WakeNotificationRow, createDb, globalRouter, isUnregisteredTenantError, pathPrefixedSingleTenantDurableStreamsRoutingAdapter, runMigrations, streamRootDurableStreamsRoutingAdapter, tenantRootDurableStreamsRoutingAdapter };
|
|
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 };
|