@keystrokehq/keystroke 1.0.14 → 1.0.15

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.
Files changed (53) hide show
  1. package/dist/action.cjs +1 -1
  2. package/dist/action.mjs +1 -1
  3. package/dist/agent.cjs +3 -3
  4. package/dist/agent.mjs +3 -3
  5. package/dist/app.cjs +1 -1
  6. package/dist/app.mjs +1 -1
  7. package/dist/client.cjs +1 -1
  8. package/dist/client.mjs +1 -1
  9. package/dist/config.d.cts +2 -2
  10. package/dist/config.d.cts.map +1 -1
  11. package/dist/config.d.mts +2 -2
  12. package/dist/config.d.mts.map +1 -1
  13. package/dist/credentials.cjs +1 -1
  14. package/dist/credentials.mjs +1 -1
  15. package/dist/{dist-DtejauR-.mjs → dist-BWGuF7Bi.mjs} +22 -9
  16. package/dist/dist-BWGuF7Bi.mjs.map +1 -0
  17. package/dist/{dist-C5UmW-zB.cjs → dist-CDMCEgV0.cjs} +22 -9
  18. package/dist/dist-CDMCEgV0.cjs.map +1 -0
  19. package/dist/{dist-DpZL1LE1.cjs → dist-CIXPxH8Y.cjs} +7 -3
  20. package/dist/dist-CIXPxH8Y.cjs.map +1 -0
  21. package/dist/{dist-DSbrc1sP.mjs → dist-DESn8Gyx.mjs} +3 -3
  22. package/dist/{dist-DSbrc1sP.mjs.map → dist-DESn8Gyx.mjs.map} +1 -1
  23. package/dist/{dist-Zh8nB_45.cjs → dist-jju5p8QW.cjs} +3 -3
  24. package/dist/{dist-Zh8nB_45.cjs.map → dist-jju5p8QW.cjs.map} +1 -1
  25. package/dist/{dist-D53HZMV9.mjs → dist-qrlBz5eZ.mjs} +7 -3
  26. package/dist/dist-qrlBz5eZ.mjs.map +1 -0
  27. package/dist/index-BTz2OMAM.d.cts.map +1 -1
  28. package/dist/index-Cq2F2XdS.d.mts.map +1 -1
  29. package/dist/index-WT4ULMiw.d.cts.map +1 -1
  30. package/dist/index-WT4ULMiw.d.mts.map +1 -1
  31. package/dist/{mistral-tahkZ8Hu.mjs → mistral-B3AiRi15.mjs} +2 -2
  32. package/dist/{mistral-tahkZ8Hu.mjs.map → mistral-B3AiRi15.mjs.map} +1 -1
  33. package/dist/{mistral-6XMKgah3.cjs → mistral-HS6Ekkp2.cjs} +2 -2
  34. package/dist/{mistral-6XMKgah3.cjs.map → mistral-HS6Ekkp2.cjs.map} +1 -1
  35. package/dist/{sse-CSbz_aIR.mjs → sse-DISKrIFa.mjs} +2 -2
  36. package/dist/{sse-CSbz_aIR.mjs.map → sse-DISKrIFa.mjs.map} +1 -1
  37. package/dist/{sse-PotOG2Pc.cjs → sse-ELfo0nZE.cjs} +2 -2
  38. package/dist/{sse-PotOG2Pc.cjs.map → sse-ELfo0nZE.cjs.map} +1 -1
  39. package/dist/trigger.cjs +135 -35
  40. package/dist/trigger.cjs.map +1 -1
  41. package/dist/trigger.d.cts +87 -20
  42. package/dist/trigger.d.cts.map +1 -1
  43. package/dist/trigger.d.mts +87 -20
  44. package/dist/trigger.d.mts.map +1 -1
  45. package/dist/trigger.mjs +122 -36
  46. package/dist/trigger.mjs.map +1 -1
  47. package/dist/workflow.cjs +1 -1
  48. package/dist/workflow.mjs +1 -1
  49. package/package.json +1 -1
  50. package/dist/dist-C5UmW-zB.cjs.map +0 -1
  51. package/dist/dist-D53HZMV9.mjs.map +0 -1
  52. package/dist/dist-DpZL1LE1.cjs.map +0 -1
  53. package/dist/dist-DtejauR-.mjs.map +0 -1
@@ -144,32 +144,71 @@ type AgentAttachOptions = {
144
144
  prompt: string | ((payload: unknown) => string);
145
145
  };
146
146
  type AttachOptions<TInput = unknown, TOutput = unknown> = WorkflowAttachOptions<TInput, TOutput> | AgentAttachOptions; //#endregion
147
+ //#region src/trigger-slug.d.ts
148
+ /** Optional human-facing metadata (same as agents/workflows). */
149
+ type TriggerMetaInput = {
150
+ name?: string;
151
+ description?: string;
152
+ };
153
+ /** Authoring input: `slug` is canonical; `key` is legacy. */
154
+ type TriggerAuthoringSlugInput = {
155
+ slug?: string; /** @deprecated Use `slug`. Accepted for backwards-compatible trigger definitions. */
156
+ key?: string;
157
+ };
158
+ /** Authoring options shared by all `define*Source` factories. */
159
+ type TriggerSourceAuthoringInput = TriggerAuthoringSlugInput & TriggerMetaInput;
160
+ /** Resolve slug from authoring options (`slug` preferred, `key` fallback). */
161
+ declare function resolveAuthoringSlug(input: TriggerAuthoringSlugInput, label?: string): string;
162
+ /** Composite attachment slug `{sourceSlug}:{targetSlug}`. */
163
+ declare function attachmentSlugFrom(sourceSlug: string, targetSlug: string): string;
164
+ /** Read slug from a trigger source (`slug` preferred, legacy `key` fallback). */
165
+ declare function sourceSlugFrom(source: {
166
+ slug?: string;
167
+ key?: string;
168
+ }): string;
169
+ /** Read slug from a trigger attachment (`slug` preferred, legacy `key` fallback). */
170
+ declare function attachmentSlugFromRecord(attachment: {
171
+ slug?: string;
172
+ key?: string;
173
+ }): string;
174
+ /** Source slug prefix from a composite attachment slug. */
175
+ declare function triggerSourceSlugFromAttachmentSlug(attachmentSlug: string): string;
176
+ /** Target slug suffix from a composite attachment slug. */
177
+ declare function triggerTargetSlugFromAttachmentSlug(attachmentSlug: string): string; //#endregion
147
178
  //#region src/sources/cron-source.d.ts
148
- type CronSource = {
179
+ type CronSource = TriggerSourceBase & {
149
180
  kind: "cron";
150
- key: string;
151
181
  schedule: CronSchedule;
152
182
  attach<TInput, TOutput>(options: AttachOptions<TInput, TOutput>): TriggerAttachment;
153
183
  };
184
+ type TriggerSourceBase = {
185
+ slug: string;
186
+ name?: string;
187
+ description?: string;
188
+ };
154
189
  /**
155
190
  * Defines a cron trigger source — fires its attached workflow on a schedule.
156
191
  *
157
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
192
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
193
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
194
+ * @param options.name - Optional human-readable name shown in the platform.
195
+ * @param options.description - Optional short description shown in the platform.
158
196
  * @param options.schedule - A cron expression. Pass a 5-field literal (e.g.
159
197
  * `"0 9 * * *"`) for compile-time shape checking, or wrap with
160
198
  * `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style
161
199
  * schedules. Validated at runtime; throws if the expression is invalid.
162
200
  * @example
163
- * defineCronSource({ key: "morning", schedule: "0 9 * * *" }).attach({ workflow });
201
+ * defineCronSource({ slug: "morning", schedule: "0 9 * * *" }).attach({ workflow });
164
202
  */
165
- declare function defineCronSource(options: {
166
- key: string;
203
+ declare function defineCronSource(options: TriggerSourceAuthoringInput & {
167
204
  schedule: CronScheduleInput;
168
205
  }): CronSource; //#endregion
169
206
  //#region src/sources/poll-source.d.ts
170
207
  type PollSource<TResult = unknown> = {
171
208
  kind: "poll";
172
- key: string;
209
+ slug: string;
210
+ name?: string;
211
+ description?: string;
173
212
  id?: string;
174
213
  schedule: CronSchedule;
175
214
  run: () => TResult | Promise<TResult>;
@@ -184,18 +223,18 @@ type PollSourceChain<TResult> = PollSource<TResult> & {
184
223
  * Defines a poll trigger source — runs `run` on a schedule and, when the result
185
224
  * passes any `.filter(...)`, fires the attached workflow with it.
186
225
  *
187
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
226
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
227
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
188
228
  * @param options.id - Optional group id; poll sources sharing an id poll together.
189
229
  * @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).
190
230
  * @param options.run - Produces the payload checked by `filter` and passed to the workflow.
191
231
  * @param options.filter - Source-level predicate; the workflow only fires when it returns true.
192
232
  * @example
193
- * definePollSource({ key: "inbox", schedule: "0 * * * *", run: fetchInbox })
233
+ * definePollSource({ slug: "inbox", schedule: "0 * * * *", run: fetchInbox })
194
234
  * .filter((r) => r.length > 0)
195
235
  * .attach({ workflow });
196
236
  */
197
- declare function definePollSource<TResult>(options: {
198
- key: string;
237
+ declare function definePollSource<TResult>(options: TriggerSourceAuthoringInput & {
199
238
  id?: string;
200
239
  schedule: CronScheduleInput;
201
240
  run: () => TResult | Promise<TResult>;
@@ -206,7 +245,9 @@ declare const TRIGGER_ATTACHMENT: unique symbol;
206
245
  /** Trigger source as seen from outside the source factories. */
207
246
  type TriggerSource = WebhookSource | CronSource | PollSource;
208
247
  type WorkflowTriggerAttachment = {
209
- key: string;
248
+ slug: string;
249
+ name?: string;
250
+ description?: string;
210
251
  source: TriggerSource;
211
252
  target: "workflow";
212
253
  workflow: WorkflowDefinition<any, any>;
@@ -214,7 +255,9 @@ type WorkflowTriggerAttachment = {
214
255
  readonly [TRIGGER_ATTACHMENT]: true;
215
256
  };
216
257
  type AgentTriggerAttachment = {
217
- key: string;
258
+ slug: string;
259
+ name?: string;
260
+ description?: string;
218
261
  source: TriggerSource;
219
262
  target: "agent";
220
263
  agent: Agent;
@@ -237,7 +280,9 @@ declare function isAgentTriggerAttachment(attachment: TriggerAttachment): attach
237
280
  declare function normalizeWebhookEndpoint(endpoint: string): string;
238
281
  type WebhookSource = {
239
282
  kind: "webhook";
240
- key: string;
283
+ slug: string;
284
+ name?: string;
285
+ description?: string;
241
286
  endpoint: string;
242
287
  request: z.ZodType;
243
288
  filter?: z.ZodType;
@@ -248,23 +293,23 @@ type WebhookSource = {
248
293
  * Defines a webhook trigger source — fires its attached workflow when a request
249
294
  * hits `/triggers/{endpoint}` and satisfies `request` plus any optional `filter`.
250
295
  *
251
- * @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.
296
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
297
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
252
298
  * @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `"stripe"`).
253
299
  */
254
- declare function defineWebhookSource<TRequestSchema extends z.ZodType, TFilterSchema extends z.ZodType | undefined = undefined>(options: {
255
- key: string;
300
+ declare function defineWebhookSource<TRequestSchema extends z.ZodType, TFilterSchema extends z.ZodType | undefined = undefined>(options: TriggerSourceAuthoringInput & {
256
301
  endpoint: string;
257
302
  request: TRequestSchema;
258
303
  filter?: TFilterSchema;
259
304
  }): WebhookSource; //#endregion
260
305
  //#region src/trigger-match-schema.d.ts
261
306
  type WebhookAttachmentSchema = {
262
- attachmentKey: string;
307
+ attachmentSlug: string;
263
308
  requestSchema: Record<string, unknown>;
264
309
  filterSchema?: Record<string, unknown>;
265
310
  };
266
311
  type WebhookPayloadMatch = {
267
- attachmentKey: string;
312
+ attachmentSlug: string;
268
313
  data: unknown;
269
314
  };
270
315
  declare function matchWebhookPayload(raw: unknown, schemas: WebhookAttachmentSchema[]): WebhookPayloadMatch[]; //#endregion
@@ -313,6 +358,28 @@ type PollSkipResponse = {
313
358
  ok: true;
314
359
  skipped: true;
315
360
  }; //#endregion
361
+ //#region src/trigger-meta.d.ts
362
+ declare function triggerMetaFromSource(source: TriggerSource): {
363
+ name?: string;
364
+ description?: string;
365
+ };
366
+ declare function triggerMetaFromAttachment(attachment: TriggerAttachment): {
367
+ name?: string;
368
+ description?: string;
369
+ };
370
+ declare function triggerMetaRecordFromAttachment(attachment: TriggerAttachment): {
371
+ name: string | null;
372
+ description: string | null;
373
+ }; //#endregion
374
+ //#region src/attachment-slug.d.ts
375
+ declare function workflowSlugFromDefinition(workflow: WorkflowDefinition<unknown, unknown>): string;
376
+ declare function agentSlugFromAgent(agent: Agent): string;
377
+ /** @deprecated Use {@link attachmentSlugFrom}. */
378
+ declare const attachmentKeyFrom: typeof attachmentSlugFrom;
379
+ /** @deprecated Use {@link workflowSlugFromDefinition}. */
380
+ declare const workflowKeyFromDefinition: typeof workflowSlugFromDefinition;
381
+ /** @deprecated Use {@link agentSlugFromAgent}. */
382
+ declare const agentKeyFromAgent: typeof agentSlugFromAgent; //#endregion
316
383
  //#endregion
317
- export { type AgentAttachOptions, type AgentTriggerAttachment, type AttachOptions, type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type EphemeralWebhookMatch, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerSource, type WebhookAttachmentSchema, type WebhookPayloadMatch, type WebhookSkipResponse, type WebhookSource, type WorkflowAttachOptions, type WorkflowTriggerAttachment, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveCronSchedule };
384
+ export { type AgentAttachOptions, type AgentTriggerAttachment, type AttachOptions, type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type EphemeralWebhookMatch, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerAuthoringSlugInput, type TriggerMetaInput, type TriggerSource, type TriggerSourceAuthoringInput, type WebhookAttachmentSchema, type WebhookPayloadMatch, type WebhookSkipResponse, type WebhookSource, type WorkflowAttachOptions, type WorkflowTriggerAttachment, agentKeyFromAgent, agentSlugFromAgent, attachmentKeyFrom, attachmentSlugFrom, attachmentSlugFromRecord, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveAuthoringSlug, resolveCronSchedule, sourceSlugFrom, triggerMetaFromAttachment, triggerMetaFromSource, triggerMetaRecordFromAttachment, triggerSourceSlugFromAttachmentSlug, triggerTargetSlugFromAttachmentSlug, workflowKeyFromDefinition, workflowSlugFromDefinition };
318
385
  //# sourceMappingURL=trigger.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.d.mts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","Agent","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","WorkflowAttachOptions","TInput","TOutput","workflow","transform","payload","AgentAttachOptions","agent","prompt","AttachOptions","CronSource","TriggerAttachment","kind","key","attach","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","passes","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","WorkflowTriggerAttachment","source","target","AgentTriggerAttachment","isTriggerAttachment","isWorkflowTriggerAttachment","attachment","isAgentTriggerAttachment","normalizeWebhookEndpoint","endpoint","ZodType","request","defineWebhookSource","TRequestSchema","TFilterSchema","WebhookAttachmentSchema","attachmentKey","requestSchema","filterSchema","WebhookPayloadMatch","data","matchWebhookPayload","raw","schemas","EphemeralWebhookMatch","matchToJsonSchema","match","interpolatePrompt","template","resolveAgentPrompt","resolveAttachmentTransform","resolveAttachmentInput","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,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A;;;;AA7JtD;KAoKhDK,qBAAAA,GAAwBjE,MAAM;;;;AAlKmB;AAAA;iBAwKrCkE,iBAAAA,CAAkBC,KAAAA,EAAOF,qBAAAA,GAAwBjE,MAAM;AAAA;AAtKT;AAAA;;;;AAAA,iBA8K9CoE,iBAAAA,CAAkBC,QAAAA,UAAkBtD,OAAgB;AAAA;;iBAIpDuD,kBAAAA,CAAmBvB,UAAAA,EAAYH,sBAAsB,EAAE7B,OAAAA;AAAAA;AAzKvE;AAAA;;;AAAA,iBAgLgBwD,0BAAAA,CAA2BxB,UAAAA,EAAY1B,iBAAiB,EAAEN,OAAAA;AA9Kd;AAAA,iBAgL5CyD,sBAAAA,CAAuBzB,UAAAA,EAAY1B,iBAAiB,EAAEN,OAAAA;AAAAA;AAAAA,KAGlE0D,UAAAA;EACHC,OAAAA;EACA3D,OAAAA;EACA4D,WAAAA,EAAanE,IAAAA;EACboE,WAAAA,GAAczF,oBAAoB;AAAA;AAAA,KAE/B0F,mBAAAA;EACHC,EAAAA;EACAC,OAAO;AAAA;AAAA,KAEJC,gBAAAA;EACHF,EAAAA;EACAC,OAAO;AAAA"}
1
+ {"version":3,"file":"trigger.d.mts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","Agent","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","WorkflowAttachOptions","TInput","TOutput","workflow","transform","payload","AgentAttachOptions","agent","prompt","AttachOptions","TriggerMetaInput","name","description","TriggerAuthoringSlugInput","slug","key","TriggerSourceAuthoringInput","resolveAuthoringSlug","input","label","attachmentSlugFrom","sourceSlug","targetSlug","sourceSlugFrom","source","attachmentSlugFromRecord","attachment","triggerSourceSlugFromAttachmentSlug","attachmentSlug","triggerTargetSlugFromAttachmentSlug","CronSource","TriggerSourceBase","TriggerAttachment","kind","attach","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","passes","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","WorkflowTriggerAttachment","target","AgentTriggerAttachment","isTriggerAttachment","isWorkflowTriggerAttachment","isAgentTriggerAttachment","normalizeWebhookEndpoint","endpoint","ZodType","request","defineWebhookSource","TRequestSchema","TFilterSchema","WebhookAttachmentSchema","requestSchema","filterSchema","WebhookPayloadMatch","data","matchWebhookPayload","raw","schemas","EphemeralWebhookMatch","matchToJsonSchema","match","interpolatePrompt","template","resolveAgentPrompt","resolveAttachmentTransform","resolveAttachmentInput","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse","triggerMetaFromSource","triggerMetaFromAttachment","triggerMetaRecordFromAttachment","workflowSlugFromDefinition","agentSlugFromAgent","attachmentKeyFrom","workflowKeyFromDefinition","agentKeyFromAgent"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAAA,SACRN,OAAAA,EAASO,aAAAA;EAAAA,SACTN,OAAAA,EAASM,aAAAA;EAAAA,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AAsBhE,MAAAA,EAAQyB,aAAa;EAC1DtC,IAAAA;EACAC,WAAAA;AAAAA;AAAAA,iBAEe6E,yBAAAA,CAA0B/D,UAAAA,EAAYM,iBAAiB;EACtErB,IAAAA;EACAC,WAAAA;AAAAA;AAAAA,iBAEe8E,+BAAAA,CAAgChE,UAAAA,EAAYM,iBAAiB;EAC5ErB,IAAAA;EACAC,WAAAA;AAAAA;AAAAA;AAAAA,iBAIe+E,0BAAAA,CAA2BxF,QAA8C,EAApC5B,kBAAkB;AAAA,iBACvDqH,kBAAAA,CAAmBrF,KAAY,EAAL/B,KAAK;;cAElCqH,iBAAAA,SAA0BzE,kBAAkB;AAnOgB;AAAA,cAqO5D0E,yBAAAA,SAAkCH,0BAA0B;;cAE5DI,iBAAAA,SAA0BH,kBAAkB"}
package/dist/trigger.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { s as isWorkflow } from "./dist-DSbrc1sP.mjs";
1
+ import { s as isWorkflow } from "./dist-DESn8Gyx.mjs";
2
2
  import { z } from "zod";
3
3
  //#region ../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js
4
4
  function extractDateElements(date) {
@@ -438,8 +438,21 @@ const zodSchema = z.custom((v) => v instanceof z.ZodType, "must be a Zod schema"
438
438
  const workflowSchema = z.custom((v) => isWorkflow(v), "must be defineWorkflow(...)");
439
439
  const agentSchema = z.custom((v) => typeof v === "object" && v !== null && typeof v.slug === "string" && v.slug.trim().length > 0 && typeof v.prompt === "function", "must be defineAgent(...)");
440
440
  const promptSchema = z.union([z.string(), z.function()]);
441
+ /** backwards-compat: normalize legacy `key` fields to canonical `slug` before validation. */
442
+ function normalizeLegacySlugFields(value) {
443
+ if (typeof value !== "object" || value === null) return value;
444
+ const next = { ...value };
445
+ if (typeof next.slug !== "string" && typeof next.key === "string") next.slug = next.key;
446
+ delete next.key;
447
+ if (typeof next.source === "object" && next.source !== null) next.source = normalizeLegacySlugFields(next.source);
448
+ return next;
449
+ }
450
+ const slugField = z.string().trim().min(1);
451
+ const optionalTextField = z.string().optional();
441
452
  const baseSourceShape = {
442
- key: z.string().trim().min(1),
453
+ slug: slugField,
454
+ name: optionalTextField,
455
+ description: optionalTextField,
443
456
  attach: z.function()
444
457
  };
445
458
  const webhookSourceSchema = z.object({
@@ -465,27 +478,32 @@ const pollSourceSchema = z.object({
465
478
  passes: z.function()
466
479
  });
467
480
  /** Runtime validation for a trigger source (webhook | cron | poll). */
468
- const triggerSourceSchema = z.discriminatedUnion("kind", [
481
+ const triggerSourceSchema = z.preprocess(normalizeLegacySlugFields, z.discriminatedUnion("kind", [
469
482
  webhookSourceSchema,
470
483
  cronSourceSchema,
471
484
  pollSourceSchema
472
- ]);
485
+ ]));
473
486
  const workflowAttachmentSchema = z.object({
474
- key: z.string().trim().min(1),
487
+ slug: slugField,
488
+ name: optionalTextField,
489
+ description: optionalTextField,
475
490
  source: triggerSourceSchema,
476
491
  target: z.literal("workflow"),
477
492
  workflow: workflowSchema,
478
493
  transform: z.function().optional()
479
494
  });
480
495
  const agentAttachmentSchema = z.object({
481
- key: z.string().trim().min(1),
496
+ slug: slugField,
497
+ name: optionalTextField,
498
+ description: optionalTextField,
482
499
  source: triggerSourceSchema,
483
500
  target: z.literal("agent"),
484
501
  agent: agentSchema,
485
502
  prompt: promptSchema
486
503
  });
504
+ const triggerAttachmentCoreSchemaBase = z.discriminatedUnion("target", [workflowAttachmentSchema, agentAttachmentSchema]);
487
505
  /** Runtime validation for an unbranded trigger attachment. */
488
- const triggerAttachmentCoreSchema = z.discriminatedUnion("target", [workflowAttachmentSchema, agentAttachmentSchema]);
506
+ const triggerAttachmentCoreSchema = z.preprocess(normalizeLegacySlugFields, triggerAttachmentCoreSchemaBase);
489
507
  const TRIGGER_ATTACHMENT = Symbol.for("keystroke.triggerAttachment");
490
508
  /**
491
509
  * Validates brand + shape via `triggerAttachmentCoreSchema` so server discovery
@@ -502,19 +520,54 @@ function isWorkflowTriggerAttachment(attachment) {
502
520
  function isAgentTriggerAttachment(attachment) {
503
521
  return attachment.target === "agent";
504
522
  }
505
- function workflowKeyFromDefinition(workflow) {
523
+ /** Resolve slug from authoring options (`slug` preferred, `key` fallback). */
524
+ function resolveAuthoringSlug(input, label = "trigger") {
525
+ const slug = input.slug?.trim() || input.key?.trim();
526
+ if (!slug) throw new Error(`${label} requires a non-empty slug`);
527
+ return slug;
528
+ }
529
+ /** Composite attachment slug `{sourceSlug}:{targetSlug}`. */
530
+ function attachmentSlugFrom(sourceSlug, targetSlug) {
531
+ return `${sourceSlug}:${targetSlug}`;
532
+ }
533
+ /** Read slug from a trigger source (`slug` preferred, legacy `key` fallback). */
534
+ function sourceSlugFrom(source) {
535
+ const slug = source.slug?.trim() || source.key?.trim();
536
+ if (!slug) throw new Error("Trigger source requires slug or legacy key");
537
+ return slug;
538
+ }
539
+ /** Read slug from a trigger attachment (`slug` preferred, legacy `key` fallback). */
540
+ function attachmentSlugFromRecord(attachment) {
541
+ const slug = attachment.slug?.trim() || attachment.key?.trim();
542
+ if (!slug) throw new Error("Trigger attachment requires slug or legacy key");
543
+ return slug;
544
+ }
545
+ /** Source slug prefix from a composite attachment slug. */
546
+ function triggerSourceSlugFromAttachmentSlug(attachmentSlug) {
547
+ const separator = attachmentSlug.indexOf(":");
548
+ return separator === -1 ? attachmentSlug : attachmentSlug.slice(0, separator);
549
+ }
550
+ /** Target slug suffix from a composite attachment slug. */
551
+ function triggerTargetSlugFromAttachmentSlug(attachmentSlug) {
552
+ const separator = attachmentSlug.indexOf(":");
553
+ return separator === -1 ? attachmentSlug : attachmentSlug.slice(separator + 1);
554
+ }
555
+ function workflowSlugFromDefinition(workflow) {
506
556
  const slug = workflow.slug?.trim();
507
557
  if (!slug) throw new Error("Workflow definition requires a non-empty slug");
508
558
  return slug;
509
559
  }
510
- function agentKeyFromAgent(agent) {
560
+ function agentSlugFromAgent(agent) {
511
561
  const slug = agent.slug?.trim();
512
562
  if (!slug) throw new Error("Agent definition requires a non-empty slug");
513
563
  return slug;
514
564
  }
515
- function attachmentKeyFrom(triggerKey, targetKey) {
516
- return `${triggerKey}:${targetKey}`;
517
- }
565
+ /** @deprecated Use {@link attachmentSlugFrom}. */
566
+ const attachmentKeyFrom = attachmentSlugFrom;
567
+ /** @deprecated Use {@link workflowSlugFromDefinition}. */
568
+ const workflowKeyFromDefinition = workflowSlugFromDefinition;
569
+ /** @deprecated Use {@link agentSlugFromAgent}. */
570
+ const agentKeyFromAgent = agentSlugFromAgent;
518
571
  function isAgentAttachOptions(options) {
519
572
  return "agent" in options;
520
573
  }
@@ -527,7 +580,7 @@ function defineTriggerAttachment(input) {
527
580
  const result = triggerAttachmentCoreSchema.safeParse(input);
528
581
  if (!result.success) throw new Error(`Invalid trigger attachment: ${formatIssues(result.error.issues)}`);
529
582
  return {
530
- ...input,
583
+ ...result.data,
531
584
  [TRIGGER_ATTACHMENT]: true
532
585
  };
533
586
  }
@@ -536,16 +589,40 @@ function formatIssues(issues) {
536
589
  return `${issue.path.length > 0 ? `${issue.path.join(".")}: ` : ""}${issue.message}`;
537
590
  }).join("; ");
538
591
  }
539
- function attachFromSource(source, triggerKey, options) {
592
+ function triggerMetaFromSource(source) {
593
+ return {
594
+ ...source.name !== void 0 ? { name: source.name } : {},
595
+ ...source.description !== void 0 ? { description: source.description } : {}
596
+ };
597
+ }
598
+ function triggerMetaFromAttachment(attachment) {
599
+ const name = attachment.name ?? attachment.source.name;
600
+ const description = attachment.description ?? attachment.source.description;
601
+ return {
602
+ ...name !== void 0 ? { name } : {},
603
+ ...description !== void 0 ? { description } : {}
604
+ };
605
+ }
606
+ function triggerMetaRecordFromAttachment(attachment) {
607
+ const meta = triggerMetaFromAttachment(attachment);
608
+ return {
609
+ name: meta.name ?? null,
610
+ description: meta.description ?? null
611
+ };
612
+ }
613
+ function attachFromSource(source, sourceSlug, options) {
614
+ const meta = triggerMetaFromSource(source);
540
615
  if (isAgentAttachOptions(options)) return defineTriggerAttachment({
541
- key: attachmentKeyFrom(triggerKey, agentKeyFromAgent(options.agent)),
616
+ slug: attachmentSlugFrom(sourceSlug, agentSlugFromAgent(options.agent)),
617
+ ...meta,
542
618
  source,
543
619
  target: "agent",
544
620
  agent: options.agent,
545
621
  prompt: options.prompt
546
622
  });
547
623
  return defineTriggerAttachment({
548
- key: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(options.workflow)),
624
+ slug: attachmentSlugFrom(sourceSlug, workflowSlugFromDefinition(options.workflow)),
625
+ ...meta,
549
626
  source,
550
627
  target: "workflow",
551
628
  workflow: options.workflow,
@@ -568,7 +645,7 @@ function matchWebhookPayload(raw, schemas) {
568
645
  const data = matchShapeAndFilter(z.fromJSONSchema(schema.requestSchema), schema.filterSchema ? z.fromJSONSchema(schema.filterSchema) : void 0, raw);
569
646
  if (data === void 0) continue;
570
647
  matches.push({
571
- attachmentKey: schema.attachmentKey,
648
+ attachmentSlug: schema.attachmentSlug,
572
649
  data
573
650
  });
574
651
  }
@@ -589,19 +666,21 @@ function webhookObjectSchema(schema) {
589
666
  * Defines a webhook trigger source — fires its attached workflow when a request
590
667
  * hits `/triggers/{endpoint}` and satisfies `request` plus any optional `filter`.
591
668
  *
592
- * @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.
669
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
670
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
593
671
  * @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `"stripe"`).
594
672
  */
595
673
  function defineWebhookSource(options) {
596
- const triggerKey = options.key.trim();
597
- if (!triggerKey) throw new Error("defineWebhookSource requires a non-empty key");
674
+ const sourceSlug = resolveAuthoringSlug(options, "defineWebhookSource");
598
675
  const endpoint = normalizeWebhookEndpoint(options.endpoint);
599
676
  if (!endpoint) throw new Error("defineWebhookSource requires a non-empty endpoint");
600
677
  const request = webhookObjectSchema(options.request);
601
678
  const filter = options.filter ? webhookObjectSchema(options.filter) : void 0;
602
679
  const source = {
603
680
  kind: "webhook",
604
- key: triggerKey,
681
+ slug: sourceSlug,
682
+ ...options.name !== void 0 ? { name: options.name } : {},
683
+ ...options.description !== void 0 ? { description: options.description } : {},
605
684
  endpoint,
606
685
  request,
607
686
  filter,
@@ -609,7 +688,7 @@ function defineWebhookSource(options) {
609
688
  return passesTriggerMatch(request, filter, payload);
610
689
  },
611
690
  attach(attachOptions) {
612
- return attachFromSource(source, triggerKey, attachOptions);
691
+ return attachFromSource(source, sourceSlug, attachOptions);
613
692
  }
614
693
  };
615
694
  return source;
@@ -617,23 +696,28 @@ function defineWebhookSource(options) {
617
696
  /**
618
697
  * Defines a cron trigger source — fires its attached workflow on a schedule.
619
698
  *
620
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
699
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
700
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
701
+ * @param options.name - Optional human-readable name shown in the platform.
702
+ * @param options.description - Optional short description shown in the platform.
621
703
  * @param options.schedule - A cron expression. Pass a 5-field literal (e.g.
622
704
  * `"0 9 * * *"`) for compile-time shape checking, or wrap with
623
705
  * `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style
624
706
  * schedules. Validated at runtime; throws if the expression is invalid.
625
707
  * @example
626
- * defineCronSource({ key: "morning", schedule: "0 9 * * *" }).attach({ workflow });
708
+ * defineCronSource({ slug: "morning", schedule: "0 9 * * *" }).attach({ workflow });
627
709
  */
628
710
  function defineCronSource(options) {
629
- const triggerKey = options.key.trim();
630
- if (!triggerKey) throw new Error("defineCronSource requires a non-empty key");
711
+ const sourceSlug = resolveAuthoringSlug(options, "defineCronSource");
712
+ const schedule = parseCronSchedule(options.schedule);
631
713
  const source = {
632
714
  kind: "cron",
633
- key: triggerKey,
634
- schedule: parseCronSchedule(options.schedule),
715
+ slug: sourceSlug,
716
+ ...options.name !== void 0 ? { name: options.name } : {},
717
+ ...options.description !== void 0 ? { description: options.description } : {},
718
+ schedule,
635
719
  attach(attachOptions) {
636
- return attachFromSource(source, triggerKey, attachOptions);
720
+ return attachFromSource(source, sourceSlug, attachOptions);
637
721
  }
638
722
  };
639
723
  return source;
@@ -642,25 +726,27 @@ function defineCronSource(options) {
642
726
  * Defines a poll trigger source — runs `run` on a schedule and, when the result
643
727
  * passes any `.filter(...)`, fires the attached workflow with it.
644
728
  *
645
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
729
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
730
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
646
731
  * @param options.id - Optional group id; poll sources sharing an id poll together.
647
732
  * @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).
648
733
  * @param options.run - Produces the payload checked by `filter` and passed to the workflow.
649
734
  * @param options.filter - Source-level predicate; the workflow only fires when it returns true.
650
735
  * @example
651
- * definePollSource({ key: "inbox", schedule: "0 * * * *", run: fetchInbox })
736
+ * definePollSource({ slug: "inbox", schedule: "0 * * * *", run: fetchInbox })
652
737
  * .filter((r) => r.length > 0)
653
738
  * .attach({ workflow });
654
739
  */
655
740
  function definePollSource(options) {
656
- const triggerKey = options.key.trim();
657
- if (!triggerKey) throw new Error("definePollSource requires a non-empty key");
741
+ const sourceSlug = resolveAuthoringSlug(options, "definePollSource");
658
742
  const schedule = parseCronSchedule(options.schedule);
659
743
  const filters = [];
660
744
  if (options.filter) filters.push(options.filter);
661
745
  const source = {
662
746
  kind: "poll",
663
- key: triggerKey,
747
+ slug: sourceSlug,
748
+ ...options.name !== void 0 ? { name: options.name } : {},
749
+ ...options.description !== void 0 ? { description: options.description } : {},
664
750
  id: options.id,
665
751
  schedule,
666
752
  run: options.run,
@@ -669,7 +755,7 @@ function definePollSource(options) {
669
755
  return source.filters.every((candidate) => candidate(payload));
670
756
  },
671
757
  attach(attachOptions) {
672
- return attachFromSource(source, triggerKey, attachOptions);
758
+ return attachFromSource(source, sourceSlug, attachOptions);
673
759
  }
674
760
  };
675
761
  const chain = source;
@@ -757,6 +843,6 @@ function resolveAttachmentInput(attachment, payload) {
757
843
  return applyAttachmentTransform(attachment, payload);
758
844
  }
759
845
  //#endregion
760
- export { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveCronSchedule };
846
+ export { TRIGGER_ATTACHMENT, agentKeyFromAgent, agentSlugFromAgent, attachmentKeyFrom, attachmentSlugFrom, attachmentSlugFromRecord, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveAuthoringSlug, resolveCronSchedule, sourceSlugFrom, triggerMetaFromAttachment, triggerMetaFromSource, triggerMetaRecordFromAttachment, triggerSourceSlugFromAttachmentSlug, triggerTargetSlugFromAttachmentSlug, workflowKeyFromDefinition, workflowSlugFromDefinition };
761
847
 
762
848
  //# sourceMappingURL=trigger.mjs.map