@electric-ax/agents-server 0.4.16 → 0.4.17

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.
@@ -4,7 +4,7 @@ import { DurableStreamTestServer } from "@durable-streams/server";
4
4
  import { createServer } from "node:http";
5
5
  import { createServerAdapter } from "@whatwg-node/server";
6
6
  import { Agent } from "undici";
7
- import { appendPathToUrl, assertTags, buildEventSourceManifestEntry, buildTagsIndex, createEntityRegistry, createRuntimeHandler, entityStateSchema, eventSourceSubscriptionManifestKey, getCronStreamPath, getCronStreamPathFromSpec, getEntitiesStreamPath, getNextCronFireAt, getSharedStateStreamPath, getWebhookStreamPath, hashString, manifestChildKey, manifestSharedStateKey, manifestSourceKey, normalizeTags, parseCronStreamPath, resolveCronScheduleSpec, resolveEventSourceSubscription, sourceRefForTags, verifyWebhookSignature } from "@electric-ax/agents-runtime";
7
+ import { COMPOSER_INPUT_MESSAGE_TYPE, appendPathToUrl, assertTags, buildEventSourceManifestEntry, buildTagsIndex, createEntityRegistry, createRuntimeHandler, entityStateSchema, eventSourceSubscriptionManifestKey, getCronStreamPath, getCronStreamPathFromSpec, getEntitiesStreamPath, getNextCronFireAt, getSharedStateStreamPath, getWebhookStreamPath, hashString, manifestChildKey, manifestSharedStateKey, manifestSourceKey, normalizeTags, parseCronStreamPath, resolveCronScheduleSpec, resolveEventSourceSubscription, sourceRefForTags, validateComposerInputPayload, validateSlashCommandDefinitions, verifyWebhookSignature } from "@electric-ax/agents-runtime";
8
8
  import fs, { existsSync } from "node:fs";
9
9
  import path, { dirname, resolve } from "node:path";
10
10
  import { drizzle } from "drizzle-orm/postgres-js";
@@ -64,6 +64,7 @@ const entityTypes = pgTable(`entity_types`, {
64
64
  creationSchema: jsonb(`creation_schema`),
65
65
  inboxSchemas: jsonb(`inbox_schemas`),
66
66
  stateSchemas: jsonb(`state_schemas`),
67
+ slashCommands: jsonb(`slash_commands`),
67
68
  serveEndpoint: text(`serve_endpoint`),
68
69
  defaultDispatchPolicy: jsonb(`default_dispatch_policy`),
69
70
  revision: integer(`revision`).notNull().default(1),
@@ -1152,7 +1153,7 @@ function buildElectricProxyTarget(options) {
1152
1153
  permissionBypass: options.permissionBypass
1153
1154
  }));
1154
1155
  } else if (table === `entity_types`) {
1155
- target.searchParams.set(`columns`, `"tenant_id","name","description","creation_schema","inbox_schemas","state_schemas","serve_endpoint","default_dispatch_policy","revision","created_at","updated_at"`);
1156
+ target.searchParams.set(`columns`, `"tenant_id","name","description","creation_schema","inbox_schemas","state_schemas","slash_commands","serve_endpoint","default_dispatch_policy","revision","created_at","updated_at"`);
1156
1157
  applyShapeWhere(target, buildSpawnableEntityTypesWhere({
1157
1158
  tenantId: options.tenantId,
1158
1159
  principalUrl: options.principalUrl ?? ``,
@@ -2725,6 +2726,7 @@ var PostgresRegistry = class {
2725
2726
  creationSchema: et.creation_schema ?? null,
2726
2727
  inboxSchemas: et.inbox_schemas ?? null,
2727
2728
  stateSchemas: et.state_schemas ?? null,
2729
+ slashCommands: et.slash_commands ?? null,
2728
2730
  serveEndpoint: et.serve_endpoint ?? null,
2729
2731
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
2730
2732
  revision: et.revision,
@@ -2737,6 +2739,7 @@ var PostgresRegistry = class {
2737
2739
  creationSchema: et.creation_schema ?? null,
2738
2740
  inboxSchemas: et.inbox_schemas ?? null,
2739
2741
  stateSchemas: et.state_schemas ?? null,
2742
+ slashCommands: et.slash_commands ?? null,
2740
2743
  serveEndpoint: et.serve_endpoint ?? null,
2741
2744
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
2742
2745
  revision: et.revision,
@@ -2754,6 +2757,7 @@ var PostgresRegistry = class {
2754
2757
  creationSchema: et.creation_schema ?? null,
2755
2758
  inboxSchemas: et.inbox_schemas ?? null,
2756
2759
  stateSchemas: et.state_schemas ?? null,
2760
+ slashCommands: et.slash_commands ?? null,
2757
2761
  serveEndpoint: et.serve_endpoint ?? null,
2758
2762
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
2759
2763
  revision: et.revision,
@@ -2780,6 +2784,7 @@ var PostgresRegistry = class {
2780
2784
  creationSchema: et.creation_schema ?? null,
2781
2785
  inboxSchemas: et.inbox_schemas ?? null,
2782
2786
  stateSchemas: et.state_schemas ?? null,
2787
+ slashCommands: et.slash_commands ?? null,
2783
2788
  serveEndpoint: et.serve_endpoint ?? null,
2784
2789
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
2785
2790
  revision: et.revision,
@@ -3370,6 +3375,7 @@ var PostgresRegistry = class {
3370
3375
  creation_schema: row.creationSchema,
3371
3376
  inbox_schemas: row.inboxSchemas,
3372
3377
  state_schemas: row.stateSchemas,
3378
+ slash_commands: row.slashCommands ?? void 0,
3373
3379
  serve_endpoint: row.serveEndpoint ?? void 0,
3374
3380
  default_dispatch_policy: row.defaultDispatchPolicy ?? void 0,
3375
3381
  revision: row.revision,
@@ -3696,6 +3702,7 @@ var EntityManager = class {
3696
3702
  this.validateSchema(req.creation_schema);
3697
3703
  this.validateSchemaMap(req.inbox_schemas);
3698
3704
  this.validateSchemaMap(req.state_schemas);
3705
+ this.validateSlashCommands(req.slash_commands);
3699
3706
  const defaultDispatchPolicy = req.default_dispatch_policy ? this.validateDispatchPolicy(req.default_dispatch_policy, { label: `default_dispatch_policy` }) : void 0;
3700
3707
  const existing = await this.registry.getEntityType(req.name);
3701
3708
  const now = new Date().toISOString();
@@ -3705,6 +3712,7 @@ var EntityManager = class {
3705
3712
  creation_schema: req.creation_schema,
3706
3713
  inbox_schemas: req.inbox_schemas,
3707
3714
  state_schemas: req.state_schemas,
3715
+ slash_commands: req.slash_commands,
3708
3716
  serve_endpoint: req.serve_endpoint,
3709
3717
  default_dispatch_policy: defaultDispatchPolicy,
3710
3718
  revision: existing ? existing.revision + 1 : 1,
@@ -3866,6 +3874,18 @@ var EntityManager = class {
3866
3874
  }
3867
3875
  });
3868
3876
  const initialEvents = [createdEvent];
3877
+ const slashCommandTimestamp = new Date().toISOString();
3878
+ for (const command of entityType.slash_commands ?? []) {
3879
+ const slashCommandEvent = entityStateSchema.slashCommands.insert({
3880
+ key: command.name,
3881
+ value: {
3882
+ ...command,
3883
+ source: `static`,
3884
+ updated_at: slashCommandTimestamp
3885
+ }
3886
+ });
3887
+ initialEvents.push(slashCommandEvent);
3888
+ }
3869
3889
  if (req.initialMessage !== void 0) {
3870
3890
  const msgNow = new Date().toISOString();
3871
3891
  const inboxEvent = entityStateSchema.inbox.insert({
@@ -3873,6 +3893,7 @@ var EntityManager = class {
3873
3893
  value: {
3874
3894
  from: req.created_by ?? req.parent ?? `spawn`,
3875
3895
  payload: req.initialMessage,
3896
+ message_type: req.initialMessageType,
3876
3897
  timestamp: msgNow
3877
3898
  }
3878
3899
  });
@@ -5318,7 +5339,9 @@ var EntityManager = class {
5318
5339
  creation_schema: existing.creation_schema,
5319
5340
  inbox_schemas: mergedInbox,
5320
5341
  state_schemas: mergedState,
5342
+ slash_commands: existing.slash_commands,
5321
5343
  serve_endpoint: existing.serve_endpoint,
5344
+ default_dispatch_policy: existing.default_dispatch_policy,
5322
5345
  revision: nextRevision,
5323
5346
  created_at: existing.created_at,
5324
5347
  updated_at: now
@@ -5372,11 +5395,19 @@ var EntityManager = class {
5372
5395
  throw new ElectricAgentsError(ErrCodeInvalidRequest, error instanceof Error ? error.message : `Invalid tags`, 400);
5373
5396
  }
5374
5397
  }
5398
+ validateSlashCommands(input) {
5399
+ const validationError = validateSlashCommandDefinitions(input);
5400
+ if (!validationError) return;
5401
+ throw new ElectricAgentsError(ErrCodeSchemaValidationFailed, validationError.message, 422, validationError.details);
5402
+ }
5375
5403
  async validateSendRequest(entityUrl, req) {
5376
5404
  const entity = await this.registry.getEntity(entityUrl);
5377
5405
  if (!entity) throw new ElectricAgentsError(ErrCodeNotFound, `Entity not found`, 404);
5378
5406
  if (rejectsNormalWrites(entity.status)) throw new ElectricAgentsError(ErrCodeNotRunning, `Entity is not accepting writes`, 409);
5379
- if (req.type && entity.type) {
5407
+ if (req.type === COMPOSER_INPUT_MESSAGE_TYPE) {
5408
+ const valErr = validateComposerInputPayload(req.payload);
5409
+ if (valErr) throw new ElectricAgentsError(ErrCodeSchemaValidationFailed, valErr.message, 422, valErr.details);
5410
+ } else if (req.type && entity.type) {
5380
5411
  const { inboxSchemas } = await this.getEffectiveSchemas(entity);
5381
5412
  if (inboxSchemas) {
5382
5413
  const schema = inboxSchemas[req.type];
@@ -5657,6 +5688,7 @@ const spawnBodySchema = Type.Object({
5657
5688
  sandbox: Type.Optional(sandboxChoiceSchema),
5658
5689
  initialMessage: Type.Optional(Type.Unknown()),
5659
5690
  grants: Type.Optional(Type.Array(entityPermissionGrantInputSchema)),
5691
+ initialMessageType: Type.Optional(Type.String()),
5660
5692
  wake: Type.Optional(Type.Object({
5661
5693
  subscriberUrl: Type.String(),
5662
5694
  condition: wakeConditionSchema,
@@ -6212,6 +6244,7 @@ async function spawnEntity(request, ctx) {
6212
6244
  dispatch_policy: dispatchPolicy,
6213
6245
  sandbox: parsed.sandbox,
6214
6246
  initialMessage: void 0,
6247
+ initialMessageType: void 0,
6215
6248
  wake: parsed.wake,
6216
6249
  created_by: principal.url
6217
6250
  });
@@ -6230,7 +6263,8 @@ async function spawnEntity(request, ctx) {
6230
6263
  if (linkBeforeInitialMessage) await linkEntityDispatchSubscription(ctx, entity);
6231
6264
  if (parsed.initialMessage !== void 0) await ctx.entityManager.send(entity.url, {
6232
6265
  from: principal.url,
6233
- payload: parsed.initialMessage
6266
+ payload: parsed.initialMessage,
6267
+ type: parsed.initialMessageType
6234
6268
  });
6235
6269
  if (!linkBeforeInitialMessage) await linkEntityDispatchSubscription(ctx, entity);
6236
6270
  return json({
@@ -6277,6 +6311,21 @@ async function signalEntity(request, ctx) {
6277
6311
  //#region src/routing/entity-types-router.ts
6278
6312
  const jsonObjectSchema = Type.Record(Type.String(), Type.Unknown());
6279
6313
  const schemaMapSchema = Type.Record(Type.String(), jsonObjectSchema);
6314
+ const slashCommandArgumentSchema = Type.Object({
6315
+ name: Type.String(),
6316
+ type: Type.Union([
6317
+ Type.Literal(`string`),
6318
+ Type.Literal(`number`),
6319
+ Type.Literal(`boolean`)
6320
+ ]),
6321
+ required: Type.Optional(Type.Boolean()),
6322
+ description: Type.Optional(Type.String())
6323
+ }, { additionalProperties: false });
6324
+ const slashCommandSchema = Type.Object({
6325
+ name: Type.String(),
6326
+ description: Type.Optional(Type.String()),
6327
+ arguments: Type.Optional(Type.Array(slashCommandArgumentSchema))
6328
+ }, { additionalProperties: false });
6280
6329
  const typePermissionGrantInputSchema = Type.Object({
6281
6330
  subject_kind: Type.Union([Type.Literal(`principal`), Type.Literal(`principal_kind`)]),
6282
6331
  subject_value: Type.String(),
@@ -6289,6 +6338,7 @@ const registerEntityTypeBodySchema = Type.Object({
6289
6338
  creation_schema: Type.Optional(jsonObjectSchema),
6290
6339
  inbox_schemas: Type.Optional(schemaMapSchema),
6291
6340
  state_schemas: Type.Optional(schemaMapSchema),
6341
+ slash_commands: Type.Optional(Type.Array(slashCommandSchema)),
6292
6342
  serve_endpoint: Type.Optional(Type.String()),
6293
6343
  default_dispatch_policy: Type.Optional(dispatchPolicySchema),
6294
6344
  permission_grants: Type.Optional(Type.Array(typePermissionGrantInputSchema))
@@ -6430,6 +6480,7 @@ function normalizeEntityTypeRequest(parsed) {
6430
6480
  creation_schema: parsed.creation_schema,
6431
6481
  inbox_schemas: parsed.inbox_schemas,
6432
6482
  state_schemas: parsed.state_schemas,
6483
+ slash_commands: parsed.slash_commands,
6433
6484
  serve_endpoint: serveEndpoint,
6434
6485
  default_dispatch_policy: parsed.default_dispatch_policy ?? (serveEndpoint ? { targets: [{
6435
6486
  type: `webhook`,
package/dist/index.cjs CHANGED
@@ -78,6 +78,7 @@ const entityTypes = (0, drizzle_orm_pg_core.pgTable)(`entity_types`, {
78
78
  creationSchema: (0, drizzle_orm_pg_core.jsonb)(`creation_schema`),
79
79
  inboxSchemas: (0, drizzle_orm_pg_core.jsonb)(`inbox_schemas`),
80
80
  stateSchemas: (0, drizzle_orm_pg_core.jsonb)(`state_schemas`),
81
+ slashCommands: (0, drizzle_orm_pg_core.jsonb)(`slash_commands`),
81
82
  serveEndpoint: (0, drizzle_orm_pg_core.text)(`serve_endpoint`),
82
83
  defaultDispatchPolicy: (0, drizzle_orm_pg_core.jsonb)(`default_dispatch_policy`),
83
84
  revision: (0, drizzle_orm_pg_core.integer)(`revision`).notNull().default(1),
@@ -849,6 +850,7 @@ var PostgresRegistry = class {
849
850
  creationSchema: et.creation_schema ?? null,
850
851
  inboxSchemas: et.inbox_schemas ?? null,
851
852
  stateSchemas: et.state_schemas ?? null,
853
+ slashCommands: et.slash_commands ?? null,
852
854
  serveEndpoint: et.serve_endpoint ?? null,
853
855
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
854
856
  revision: et.revision,
@@ -861,6 +863,7 @@ var PostgresRegistry = class {
861
863
  creationSchema: et.creation_schema ?? null,
862
864
  inboxSchemas: et.inbox_schemas ?? null,
863
865
  stateSchemas: et.state_schemas ?? null,
866
+ slashCommands: et.slash_commands ?? null,
864
867
  serveEndpoint: et.serve_endpoint ?? null,
865
868
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
866
869
  revision: et.revision,
@@ -878,6 +881,7 @@ var PostgresRegistry = class {
878
881
  creationSchema: et.creation_schema ?? null,
879
882
  inboxSchemas: et.inbox_schemas ?? null,
880
883
  stateSchemas: et.state_schemas ?? null,
884
+ slashCommands: et.slash_commands ?? null,
881
885
  serveEndpoint: et.serve_endpoint ?? null,
882
886
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
883
887
  revision: et.revision,
@@ -904,6 +908,7 @@ var PostgresRegistry = class {
904
908
  creationSchema: et.creation_schema ?? null,
905
909
  inboxSchemas: et.inbox_schemas ?? null,
906
910
  stateSchemas: et.state_schemas ?? null,
911
+ slashCommands: et.slash_commands ?? null,
907
912
  serveEndpoint: et.serve_endpoint ?? null,
908
913
  defaultDispatchPolicy: et.default_dispatch_policy ?? null,
909
914
  revision: et.revision,
@@ -1494,6 +1499,7 @@ var PostgresRegistry = class {
1494
1499
  creation_schema: row.creationSchema,
1495
1500
  inbox_schemas: row.inboxSchemas,
1496
1501
  state_schemas: row.stateSchemas,
1502
+ slash_commands: row.slashCommands ?? void 0,
1497
1503
  serve_endpoint: row.serveEndpoint ?? void 0,
1498
1504
  default_dispatch_policy: row.defaultDispatchPolicy ?? void 0,
1499
1505
  revision: row.revision,
@@ -3387,6 +3393,7 @@ var EntityManager = class {
3387
3393
  this.validateSchema(req.creation_schema);
3388
3394
  this.validateSchemaMap(req.inbox_schemas);
3389
3395
  this.validateSchemaMap(req.state_schemas);
3396
+ this.validateSlashCommands(req.slash_commands);
3390
3397
  const defaultDispatchPolicy = req.default_dispatch_policy ? this.validateDispatchPolicy(req.default_dispatch_policy, { label: `default_dispatch_policy` }) : void 0;
3391
3398
  const existing = await this.registry.getEntityType(req.name);
3392
3399
  const now = new Date().toISOString();
@@ -3396,6 +3403,7 @@ var EntityManager = class {
3396
3403
  creation_schema: req.creation_schema,
3397
3404
  inbox_schemas: req.inbox_schemas,
3398
3405
  state_schemas: req.state_schemas,
3406
+ slash_commands: req.slash_commands,
3399
3407
  serve_endpoint: req.serve_endpoint,
3400
3408
  default_dispatch_policy: defaultDispatchPolicy,
3401
3409
  revision: existing ? existing.revision + 1 : 1,
@@ -3557,6 +3565,18 @@ var EntityManager = class {
3557
3565
  }
3558
3566
  });
3559
3567
  const initialEvents = [createdEvent];
3568
+ const slashCommandTimestamp = new Date().toISOString();
3569
+ for (const command of entityType.slash_commands ?? []) {
3570
+ const slashCommandEvent = __electric_ax_agents_runtime.entityStateSchema.slashCommands.insert({
3571
+ key: command.name,
3572
+ value: {
3573
+ ...command,
3574
+ source: `static`,
3575
+ updated_at: slashCommandTimestamp
3576
+ }
3577
+ });
3578
+ initialEvents.push(slashCommandEvent);
3579
+ }
3560
3580
  if (req.initialMessage !== void 0) {
3561
3581
  const msgNow = new Date().toISOString();
3562
3582
  const inboxEvent = __electric_ax_agents_runtime.entityStateSchema.inbox.insert({
@@ -3564,6 +3584,7 @@ var EntityManager = class {
3564
3584
  value: {
3565
3585
  from: req.created_by ?? req.parent ?? `spawn`,
3566
3586
  payload: req.initialMessage,
3587
+ message_type: req.initialMessageType,
3567
3588
  timestamp: msgNow
3568
3589
  }
3569
3590
  });
@@ -5009,7 +5030,9 @@ var EntityManager = class {
5009
5030
  creation_schema: existing.creation_schema,
5010
5031
  inbox_schemas: mergedInbox,
5011
5032
  state_schemas: mergedState,
5033
+ slash_commands: existing.slash_commands,
5012
5034
  serve_endpoint: existing.serve_endpoint,
5035
+ default_dispatch_policy: existing.default_dispatch_policy,
5013
5036
  revision: nextRevision,
5014
5037
  created_at: existing.created_at,
5015
5038
  updated_at: now
@@ -5063,11 +5086,19 @@ var EntityManager = class {
5063
5086
  throw new ElectricAgentsError(ErrCodeInvalidRequest, error instanceof Error ? error.message : `Invalid tags`, 400);
5064
5087
  }
5065
5088
  }
5089
+ validateSlashCommands(input) {
5090
+ const validationError = (0, __electric_ax_agents_runtime.validateSlashCommandDefinitions)(input);
5091
+ if (!validationError) return;
5092
+ throw new ElectricAgentsError(ErrCodeSchemaValidationFailed, validationError.message, 422, validationError.details);
5093
+ }
5066
5094
  async validateSendRequest(entityUrl, req) {
5067
5095
  const entity = await this.registry.getEntity(entityUrl);
5068
5096
  if (!entity) throw new ElectricAgentsError(ErrCodeNotFound, `Entity not found`, 404);
5069
5097
  if (rejectsNormalWrites(entity.status)) throw new ElectricAgentsError(ErrCodeNotRunning, `Entity is not accepting writes`, 409);
5070
- if (req.type && entity.type) {
5098
+ if (req.type === __electric_ax_agents_runtime.COMPOSER_INPUT_MESSAGE_TYPE) {
5099
+ const valErr = (0, __electric_ax_agents_runtime.validateComposerInputPayload)(req.payload);
5100
+ if (valErr) throw new ElectricAgentsError(ErrCodeSchemaValidationFailed, valErr.message, 422, valErr.details);
5101
+ } else if (req.type && entity.type) {
5071
5102
  const { inboxSchemas } = await this.getEffectiveSchemas(entity);
5072
5103
  if (inboxSchemas) {
5073
5104
  const schema = inboxSchemas[req.type];
@@ -7140,7 +7171,7 @@ function buildElectricProxyTarget(options) {
7140
7171
  permissionBypass: options.permissionBypass
7141
7172
  }));
7142
7173
  } else if (table === `entity_types`) {
7143
- target.searchParams.set(`columns`, `"tenant_id","name","description","creation_schema","inbox_schemas","state_schemas","serve_endpoint","default_dispatch_policy","revision","created_at","updated_at"`);
7174
+ target.searchParams.set(`columns`, `"tenant_id","name","description","creation_schema","inbox_schemas","state_schemas","slash_commands","serve_endpoint","default_dispatch_policy","revision","created_at","updated_at"`);
7144
7175
  applyShapeWhere(target, buildSpawnableEntityTypesWhere({
7145
7176
  tenantId: options.tenantId,
7146
7177
  principalUrl: options.principalUrl ?? ``,
@@ -7948,6 +7979,7 @@ const spawnBodySchema = __sinclair_typebox.Type.Object({
7948
7979
  sandbox: __sinclair_typebox.Type.Optional(sandboxChoiceSchema),
7949
7980
  initialMessage: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Unknown()),
7950
7981
  grants: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Array(entityPermissionGrantInputSchema)),
7982
+ initialMessageType: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.String()),
7951
7983
  wake: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Object({
7952
7984
  subscriberUrl: __sinclair_typebox.Type.String(),
7953
7985
  condition: wakeConditionSchema,
@@ -8503,6 +8535,7 @@ async function spawnEntity(request, ctx) {
8503
8535
  dispatch_policy: dispatchPolicy,
8504
8536
  sandbox: parsed.sandbox,
8505
8537
  initialMessage: void 0,
8538
+ initialMessageType: void 0,
8506
8539
  wake: parsed.wake,
8507
8540
  created_by: principal.url
8508
8541
  });
@@ -8521,7 +8554,8 @@ async function spawnEntity(request, ctx) {
8521
8554
  if (linkBeforeInitialMessage) await linkEntityDispatchSubscription(ctx, entity);
8522
8555
  if (parsed.initialMessage !== void 0) await ctx.entityManager.send(entity.url, {
8523
8556
  from: principal.url,
8524
- payload: parsed.initialMessage
8557
+ payload: parsed.initialMessage,
8558
+ type: parsed.initialMessageType
8525
8559
  });
8526
8560
  if (!linkBeforeInitialMessage) await linkEntityDispatchSubscription(ctx, entity);
8527
8561
  return (0, itty_router.json)({
@@ -8568,6 +8602,21 @@ async function signalEntity(request, ctx) {
8568
8602
  //#region src/routing/entity-types-router.ts
8569
8603
  const jsonObjectSchema = __sinclair_typebox.Type.Record(__sinclair_typebox.Type.String(), __sinclair_typebox.Type.Unknown());
8570
8604
  const schemaMapSchema = __sinclair_typebox.Type.Record(__sinclair_typebox.Type.String(), jsonObjectSchema);
8605
+ const slashCommandArgumentSchema = __sinclair_typebox.Type.Object({
8606
+ name: __sinclair_typebox.Type.String(),
8607
+ type: __sinclair_typebox.Type.Union([
8608
+ __sinclair_typebox.Type.Literal(`string`),
8609
+ __sinclair_typebox.Type.Literal(`number`),
8610
+ __sinclair_typebox.Type.Literal(`boolean`)
8611
+ ]),
8612
+ required: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Boolean()),
8613
+ description: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.String())
8614
+ }, { additionalProperties: false });
8615
+ const slashCommandSchema = __sinclair_typebox.Type.Object({
8616
+ name: __sinclair_typebox.Type.String(),
8617
+ description: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.String()),
8618
+ arguments: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Array(slashCommandArgumentSchema))
8619
+ }, { additionalProperties: false });
8571
8620
  const typePermissionGrantInputSchema = __sinclair_typebox.Type.Object({
8572
8621
  subject_kind: __sinclair_typebox.Type.Union([__sinclair_typebox.Type.Literal(`principal`), __sinclair_typebox.Type.Literal(`principal_kind`)]),
8573
8622
  subject_value: __sinclair_typebox.Type.String(),
@@ -8580,6 +8629,7 @@ const registerEntityTypeBodySchema = __sinclair_typebox.Type.Object({
8580
8629
  creation_schema: __sinclair_typebox.Type.Optional(jsonObjectSchema),
8581
8630
  inbox_schemas: __sinclair_typebox.Type.Optional(schemaMapSchema),
8582
8631
  state_schemas: __sinclair_typebox.Type.Optional(schemaMapSchema),
8632
+ slash_commands: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Array(slashCommandSchema)),
8583
8633
  serve_endpoint: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.String()),
8584
8634
  default_dispatch_policy: __sinclair_typebox.Type.Optional(dispatchPolicySchema),
8585
8635
  permission_grants: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Array(typePermissionGrantInputSchema))
@@ -8721,6 +8771,7 @@ function normalizeEntityTypeRequest(parsed) {
8721
8771
  creation_schema: parsed.creation_schema,
8722
8772
  inbox_schemas: parsed.inbox_schemas,
8723
8773
  state_schemas: parsed.state_schemas,
8774
+ slash_commands: parsed.slash_commands,
8724
8775
  serve_endpoint: serveEndpoint,
8725
8776
  default_dispatch_policy: parsed.default_dispatch_policy ?? (serveEndpoint ? { targets: [{
8726
8777
  type: `webhook`,