@leitwerk-dev/process-sdk 0.1.8 → 0.2.0

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 (171) hide show
  1. package/dist/{chunk-TRQJ5PRM.js → chunk-TA4KO53Q.js} +1 -5
  2. package/dist/chunk-TA4KO53Q.js.map +1 -0
  3. package/dist/{chunk-5RJZ2E7D.js → chunk-WFY2WWZE.js} +2 -6
  4. package/dist/{chunk-5RJZ2E7D.js.map → chunk-WFY2WWZE.js.map} +1 -1
  5. package/dist/core-capabilities.d.ts +76 -34
  6. package/dist/core-capabilities.d.ts.map +1 -1
  7. package/dist/define-process.d.ts +36 -55
  8. package/dist/define-process.d.ts.map +1 -1
  9. package/dist/{extension-api-CqPGRqc9.d.ts → extension-api-CcqZCYJx.d.ts} +160 -74
  10. package/dist/extension-api.d.ts +120 -5
  11. package/dist/extension-api.d.ts.map +1 -1
  12. package/dist/external-action-source.d.ts +7 -0
  13. package/dist/external-action-source.d.ts.map +1 -0
  14. package/dist/external-source-poll.d.ts +15 -0
  15. package/dist/external-source-poll.d.ts.map +1 -0
  16. package/dist/flow.d.ts +92 -110
  17. package/dist/flow.d.ts.map +1 -1
  18. package/dist/fs-utils.d.ts +2 -0
  19. package/dist/fs-utils.d.ts.map +1 -1
  20. package/dist/git-binary.js +25 -33
  21. package/dist/git-binary.js.map +1 -1
  22. package/dist/index.d.ts +21 -9
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4694 -29
  25. package/dist/index.js.map +1 -1
  26. package/dist/integration-http.d.ts +21 -0
  27. package/dist/integration-http.d.ts.map +1 -0
  28. package/dist/json-data.d.ts +3 -0
  29. package/dist/json-data.d.ts.map +1 -0
  30. package/dist/leaf-outcome-renderer.js +74 -64
  31. package/dist/leaf-outcome-renderer.js.map +1 -1
  32. package/dist/leaf-outcomes.d.ts.map +1 -1
  33. package/dist/model-provider.d.ts.map +1 -1
  34. package/dist/pi-config.d.ts +1 -5
  35. package/dist/pi-config.d.ts.map +1 -1
  36. package/dist/pi-config.js +20 -180
  37. package/dist/pi-config.js.map +1 -1
  38. package/dist/process-flow-view.d.ts.map +1 -1
  39. package/dist/process-graph.d.ts +1 -2
  40. package/dist/process-graph.d.ts.map +1 -1
  41. package/dist/process-watcher-source.d.ts +3 -1
  42. package/dist/process-watcher-source.d.ts.map +1 -1
  43. package/dist/project-binding.d.ts +9 -0
  44. package/dist/project-binding.d.ts.map +1 -0
  45. package/dist/registry-utils.d.ts.map +1 -1
  46. package/dist/repository-feedback.d.ts +29 -0
  47. package/dist/repository-feedback.d.ts.map +1 -0
  48. package/dist/repository-git-env.d.ts +2 -0
  49. package/dist/repository-git-env.d.ts.map +1 -1
  50. package/dist/repository-http.d.ts +19 -0
  51. package/dist/repository-http.d.ts.map +1 -0
  52. package/dist/repository-https.d.ts +3 -0
  53. package/dist/repository-https.d.ts.map +1 -0
  54. package/dist/repository-issue-watcher.d.ts +31 -0
  55. package/dist/repository-issue-watcher.d.ts.map +1 -0
  56. package/dist/repository-source-config.d.ts +32 -0
  57. package/dist/repository-source-config.d.ts.map +1 -0
  58. package/dist/repository-types.d.ts +36 -0
  59. package/dist/repository-types.d.ts.map +1 -0
  60. package/dist/review-flow.js +12 -43
  61. package/dist/review-flow.js.map +1 -1
  62. package/dist/runtime-internals.js +18 -2
  63. package/dist/runtime-internals.js.map +1 -1
  64. package/dist/state-helpers.d.ts +3 -2
  65. package/dist/state-helpers.d.ts.map +1 -1
  66. package/dist/subprocess-env.d.ts +1 -0
  67. package/dist/subprocess-env.d.ts.map +1 -1
  68. package/dist/tool-arguments.d.ts +7 -0
  69. package/dist/tool-arguments.d.ts.map +1 -0
  70. package/dist/turn-semantics.d.ts +5 -6
  71. package/dist/turn-semantics.d.ts.map +1 -1
  72. package/dist/types.d.ts +5 -15
  73. package/dist/types.d.ts.map +1 -1
  74. package/package.json +6 -5
  75. package/src/core-capabilities.ts +90 -37
  76. package/src/define-process.ts +231 -277
  77. package/src/extension-api.ts +148 -4
  78. package/src/external-action-source.ts +12 -0
  79. package/src/external-source-poll.ts +49 -0
  80. package/src/flow.ts +427 -646
  81. package/src/fs-utils.ts +17 -2
  82. package/src/index.ts +56 -13
  83. package/src/integration-http.ts +58 -0
  84. package/src/json-data.ts +25 -0
  85. package/src/leaf-outcomes.ts +1 -9
  86. package/src/model-provider.ts +10 -23
  87. package/src/pi-config.ts +1 -6
  88. package/src/process-flow-view.ts +32 -88
  89. package/src/process-graph.ts +25 -54
  90. package/src/process-watcher-source.ts +13 -8
  91. package/src/project-binding.ts +36 -0
  92. package/src/registry-utils.ts +1 -5
  93. package/src/repository-feedback.ts +59 -0
  94. package/src/repository-git-env.ts +34 -0
  95. package/src/repository-http.ts +71 -0
  96. package/src/repository-https.ts +22 -0
  97. package/src/repository-issue-watcher.ts +92 -0
  98. package/src/repository-source-config.ts +60 -0
  99. package/src/repository-types.ts +25 -0
  100. package/src/state-helpers.ts +8 -9
  101. package/src/subprocess-env.ts +6 -0
  102. package/src/tool-arguments.ts +37 -0
  103. package/src/turn-semantics.ts +31 -75
  104. package/src/types.ts +5 -15
  105. package/dist/browser-ui-extension.js +0 -2
  106. package/dist/browser-ui-extension.js.map +0 -1
  107. package/dist/capabilities.js +0 -7
  108. package/dist/capabilities.js.map +0 -1
  109. package/dist/chunk-TRQJ5PRM.js.map +0 -1
  110. package/dist/codecs.js +0 -9
  111. package/dist/codecs.js.map +0 -1
  112. package/dist/commit-message.js +0 -3
  113. package/dist/commit-message.js.map +0 -1
  114. package/dist/core-capabilities.js +0 -6
  115. package/dist/core-capabilities.js.map +0 -1
  116. package/dist/define-process.js +0 -1040
  117. package/dist/define-process.js.map +0 -1
  118. package/dist/event-bus.js +0 -31
  119. package/dist/event-bus.js.map +0 -1
  120. package/dist/extension-api.js +0 -5
  121. package/dist/extension-api.js.map +0 -1
  122. package/dist/flow.js +0 -1565
  123. package/dist/flow.js.map +0 -1
  124. package/dist/form-contract.js +0 -2
  125. package/dist/form-contract.js.map +0 -1
  126. package/dist/fs-utils.js +0 -23
  127. package/dist/fs-utils.js.map +0 -1
  128. package/dist/graph-fragments.js +0 -57
  129. package/dist/graph-fragments.js.map +0 -1
  130. package/dist/host-capabilities.js +0 -42
  131. package/dist/host-capabilities.js.map +0 -1
  132. package/dist/launcher-contract.js +0 -2
  133. package/dist/launcher-contract.js.map +0 -1
  134. package/dist/leaf-outcomes.js +0 -52
  135. package/dist/leaf-outcomes.js.map +0 -1
  136. package/dist/model-provider.js +0 -171
  137. package/dist/model-provider.js.map +0 -1
  138. package/dist/process-definition-internals.js +0 -25
  139. package/dist/process-definition-internals.js.map +0 -1
  140. package/dist/process-flow-view.js +0 -418
  141. package/dist/process-flow-view.js.map +0 -1
  142. package/dist/process-graph.js +0 -213
  143. package/dist/process-graph.js.map +0 -1
  144. package/dist/process-launcher-builder.js +0 -43
  145. package/dist/process-launcher-builder.js.map +0 -1
  146. package/dist/process-watcher-builder.js +0 -40
  147. package/dist/process-watcher-builder.js.map +0 -1
  148. package/dist/process-watcher-source.js +0 -45
  149. package/dist/process-watcher-source.js.map +0 -1
  150. package/dist/registry-utils.js +0 -18
  151. package/dist/registry-utils.js.map +0 -1
  152. package/dist/repository-git-env.js +0 -26
  153. package/dist/repository-git-env.js.map +0 -1
  154. package/dist/server-events.js +0 -2
  155. package/dist/server-events.js.map +0 -1
  156. package/dist/server-process-builder.js +0 -52
  157. package/dist/server-process-builder.js.map +0 -1
  158. package/dist/state-helpers.js +0 -20
  159. package/dist/state-helpers.js.map +0 -1
  160. package/dist/subprocess-env.js +0 -34
  161. package/dist/subprocess-env.js.map +0 -1
  162. package/dist/tool-renderers.js +0 -63
  163. package/dist/tool-renderers.js.map +0 -1
  164. package/dist/turn-semantics.js +0 -365
  165. package/dist/turn-semantics.js.map +0 -1
  166. package/dist/types.js +0 -23
  167. package/dist/types.js.map +0 -1
  168. package/dist/ui-process-builder.js +0 -30
  169. package/dist/ui-process-builder.js.map +0 -1
  170. package/dist/worker-process-builder.js +0 -22
  171. package/dist/worker-process-builder.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ Actor,
2
3
  InputKind,
3
4
  InputSource,
4
5
  LaunchModelConfigInput,
@@ -10,6 +11,7 @@ import type {
10
11
  ProcessSemanticEntryRefKey,
11
12
  ProcessTurnRecord,
12
13
  TurnId,
14
+ TurnProgressReport,
13
15
  } from "@leitwerk-dev/domain";
14
16
  import type { WatcherPresentationField } from "@leitwerk-dev/protocol";
15
17
  import type { CapabilityToken } from "./capabilities.js";
@@ -100,6 +102,8 @@ export interface ProcessLaunchConfig<TParams = unknown> {
100
102
  metadata?: Record<string, unknown> | null;
101
103
  defaultModelProfileId?: string | null;
102
104
  turnConfigs?: Record<string, { modelProfileId?: string | null }>;
105
+ /** Skill ids resolved to active immutable revisions before process creation. */
106
+ skillIds?: readonly string[];
103
107
  projects?: readonly ProcessLaunchProjectConfig[];
104
108
  }
105
109
 
@@ -113,6 +117,32 @@ export type UiLauncherConfigResolution<TParams = unknown> =
113
117
  errors: readonly LauncherValidationError[];
114
118
  };
115
119
 
120
+ export interface LaunchPreparationContext<TParams = unknown> {
121
+ readonly signal: AbortSignal;
122
+ readonly launchConfig: ProcessLaunchConfig<TParams>;
123
+ readonly logger: {
124
+ info(message: string): void;
125
+ warn(message: string): void;
126
+ };
127
+ }
128
+
129
+ export interface LaunchPreparationCheck<TParams = unknown> {
130
+ readonly id: string;
131
+ readonly label: string;
132
+ run(ctx: LaunchPreparationContext<TParams>): Promise<void>;
133
+ }
134
+
135
+ /** A launcher check may throw this error to expose bounded operator-safe remediation. */
136
+ export class SafeLaunchPreparationError extends Error {
137
+ constructor(
138
+ message: string,
139
+ readonly safeSummary: string,
140
+ ) {
141
+ super(message);
142
+ this.name = "SafeLaunchPreparationError";
143
+ }
144
+ }
145
+
116
146
  export interface UiLauncherDefinition<TParams = unknown> {
117
147
  card: LauncherCardMetadata;
118
148
  launchConfigSchema: LauncherSchemaDefinition;
@@ -133,6 +163,10 @@ export interface UiLauncherDefinition<TParams = unknown> {
133
163
  previousInput: Record<string, unknown>,
134
164
  ctx: LauncherContext,
135
165
  ): Record<string, unknown> | Promise<Record<string, unknown>>;
166
+ preparationChecks?(
167
+ input: Record<string, unknown>,
168
+ launchConfig: ProcessLaunchConfig<TParams>,
169
+ ): readonly LaunchPreparationCheck<TParams>[];
136
170
  resolveLaunchConfig(
137
171
  input: Record<string, unknown>,
138
172
  ctx: LauncherContext,
@@ -168,6 +202,10 @@ export interface ProcessWatcherDefinition<TParams = unknown, TEvent = unknown, T
168
202
  description: string;
169
203
  source: ProcessWatcherSource<TConfig, TEvent>;
170
204
  matches?(event: TEvent, ctx: LauncherContext): boolean | Promise<boolean>;
205
+ preparationChecks?(
206
+ event: TEvent,
207
+ launchConfig: ProcessLaunchConfig<TParams>,
208
+ ): readonly LaunchPreparationCheck<TParams>[];
171
209
  resolveLaunchConfig(
172
210
  event: TEvent,
173
211
  ctx: LauncherContext,
@@ -200,6 +238,7 @@ export interface ProcessLaunchPlan {
200
238
  titleSourceFields?: readonly ProcessTitleSourceField[];
201
239
  projectInputs: readonly ProcessLaunchProjectConfig[];
202
240
  startTurnId: TurnId | null;
241
+ skillIds?: readonly string[];
203
242
  }
204
243
 
205
244
  export interface ResolvedProcessLauncher<TParams = unknown> {
@@ -235,6 +274,11 @@ export interface ProcessLauncherService {
235
274
  previousInput: Record<string, unknown>,
236
275
  ctx?: LauncherContext,
237
276
  ): Promise<Record<string, unknown>>;
277
+ resolvePreparationChecks?(
278
+ launcherId: string,
279
+ input: Record<string, unknown>,
280
+ launchConfig: ProcessLaunchConfig,
281
+ ): readonly LaunchPreparationCheck[];
238
282
  resolveUiLauncher(
239
283
  launcherId: string,
240
284
  input: Record<string, unknown>,
@@ -378,6 +422,12 @@ export type ExternalSourceEffect<
378
422
  ctx: ExternalSourceEffectContext<TParams, TState, TEvent, TInput>,
379
423
  ) => ProcessEffectPlan<TState> | Promise<ProcessEffectPlan<TState> | undefined> | undefined;
380
424
 
425
+ export interface ExternalEventDescription {
426
+ summary: string;
427
+ markdown?: string;
428
+ links?: import("@leitwerk-dev/domain").TurnProgressLink[];
429
+ }
430
+
381
431
  export interface ExternalActionSource<
382
432
  TParams = unknown,
383
433
  TState = unknown,
@@ -387,6 +437,8 @@ export interface ExternalActionSource<
387
437
  kind: string;
388
438
  label?: string;
389
439
  description?: string;
440
+ /** Pure description captured when the event is consumed. */
441
+ describeEvent?(event: _TEvent): ExternalEventDescription;
390
442
  /**
391
443
  * Extension-owned opaque config. Core may persist, hash, and display it, but must not
392
444
  * interpret provider-specific fields.
@@ -448,12 +500,19 @@ export interface WorkerProcessContext<TParams = unknown, TState = unknown>
448
500
  readonly turnResultMarkdownByProduct?: Readonly<Record<string, string>>;
449
501
  /** Absolute workspace root for the current process instance, when available. */
450
502
  readonly workspaceRoot?: string;
503
+ /** Durable output produced by this LLM turn's preparation phase, when declared. */
504
+ readonly prepared?: unknown;
505
+ /** Invoke a server-owned integration tool authorized for this automatic turn or LLM preparation. */
506
+ callIntegrationTool?(name: string, args: Record<string, unknown>): Promise<unknown>;
507
+ /** Replace the durable operator-facing progress report for this turn attempt. */
508
+ reportProgress?(report: TurnProgressReport): void;
451
509
  }
452
510
 
453
511
  export interface WorkerCompleteInput<TOutcome extends string = string> {
454
512
  outcome: TOutcome;
455
513
  params?: Record<string, unknown>;
456
514
  markdown?: string | null;
515
+ resultSummary?: string;
457
516
  }
458
517
 
459
518
  export interface WorkerRunHandle<TParams = unknown, TState = unknown> {
@@ -505,7 +564,7 @@ export interface ProcessTurnBinding<TTurn = TurnDefinition> {
505
564
  definition: TTurn;
506
565
  }
507
566
 
508
- export type RepositoryCredentialKind = "git_ssh";
567
+ export type RepositoryCredentialKind = "git_ssh" | "git_https";
509
568
 
510
569
  /** Non-secret, code-defined repository authentication request. */
511
570
  export interface RepositoryCredentialRequirement {
@@ -528,15 +587,31 @@ export interface GitSshCredentialMaterial {
528
587
  readonly knownHosts: string;
529
588
  }
530
589
 
531
- export interface RepositoryCredentialProvider {
532
- readonly kind: RepositoryCredentialKind;
533
- resolve(credentialRef: string): GitSshCredentialMaterial | null;
590
+ export interface GitHttpsCredentialMaterial {
591
+ /** HTTPS origin authorized by the credential-owning extension. */
592
+ readonly origin: string;
593
+ readonly username: string;
594
+ readonly password: string;
534
595
  }
535
596
 
597
+ export type RepositoryCredentialProvider =
598
+ | { readonly kind: "git_ssh"; resolve(credentialRef: string): GitSshCredentialMaterial | null }
599
+ | {
600
+ readonly kind: "git_https";
601
+ resolve(credentialRef: string): GitHttpsCredentialMaterial | null;
602
+ };
603
+
536
604
  export interface RepositoryCredentialRegistrar {
537
605
  register(provider: RepositoryCredentialProvider): void;
538
606
  }
539
607
 
608
+ export interface ProcessRuntimeCapabilities {
609
+ /** Install repository-declared development tools with mise before accepting work. */
610
+ readonly developmentTools?: boolean;
611
+ /** Require a Docker CLI connected to a private or explicitly acknowledged daemon. */
612
+ readonly docker?: boolean;
613
+ }
614
+
540
615
  export interface ExtensionProcessDefinition<TParams = unknown, TState = unknown> {
541
616
  id: string;
542
617
  displayName: string;
@@ -555,6 +630,18 @@ export interface ExtensionProcessDefinition<TParams = unknown, TState = unknown>
555
630
  paramsCodec: Codec<TParams>;
556
631
  stateCodec: Codec<TState>;
557
632
  initialState(params: TParams): TState;
633
+ /** Process-owned runtime capabilities. All capabilities default to disabled. */
634
+ runtime?: ProcessRuntimeCapabilities;
635
+ /**
636
+ * Server-only Kubernetes process-volume size, derived from extension configuration.
637
+ * Explicit process storage_size wins; undefined uses the runner default.
638
+ * Called before provisioning on worker starts. Must be synchronous and side-effect free;
639
+ * repeated calls never resize or replace an existing volume.
640
+ */
641
+ resolveStorageSize?(input: {
642
+ params: TParams;
643
+ projects: readonly ProcessProject[];
644
+ }): string | undefined;
558
645
  /** Runtime-only requirements; references are non-secret and remain in opaque params JSON. */
559
646
  repositoryCredentials?(input: {
560
647
  params: TParams;
@@ -587,11 +674,66 @@ export interface ServerExtensionLogger {
587
674
  error?(payload: Record<string, unknown>, message?: string): void;
588
675
  }
589
676
 
677
+ export interface TicketCreationDestinationSummary {
678
+ /** Adapter-owned opaque identifier. Browsers must not construct or interpret it. */
679
+ readonly id: string;
680
+ readonly displayName: string;
681
+ readonly group?: string;
682
+ readonly description?: string;
683
+ }
684
+
685
+ export interface TicketCreationDestinationList {
686
+ readonly destinations: readonly TicketCreationDestinationSummary[];
687
+ readonly warnings?: readonly string[];
688
+ }
689
+
690
+ export interface TicketCreationDestinationSnapshot {
691
+ readonly summary: TicketCreationDestinationSummary;
692
+ /** Adapter-owned, JSON-serializable immutable destination state. */
693
+ readonly data: unknown;
694
+ /** Untrusted destination context included in the ticket agent prompt. */
695
+ readonly agentContext?: string;
696
+ }
697
+
698
+ export interface TicketCreationDestinationContext {
699
+ readonly actor: Actor;
700
+ }
701
+
702
+ export interface TicketCreationDestinationProvider {
703
+ list(ctx: TicketCreationDestinationContext): Promise<TicketCreationDestinationList>;
704
+ resolve(
705
+ ctx: TicketCreationDestinationContext & { destinationId: string },
706
+ ): Promise<TicketCreationDestinationSnapshot>;
707
+ /** Rejects stale, renamed, transferred, or otherwise invalid snapshots. */
708
+ validate(snapshot: TicketCreationDestinationSnapshot): Promise<void>;
709
+ }
710
+
711
+ export interface TicketCreationCapability {
712
+ readonly kind: "ticket_creation";
713
+ readonly displayName: string;
714
+ /** Extension-owned process launched by the generic derived-ticket route. */
715
+ readonly processId: string;
716
+ /** Entry turn selected when the derived process starts. */
717
+ readonly startTurnId: TurnId;
718
+ /** RFC 6901 JSON Pointer into the tool arguments. */
719
+ readonly titlePath?: string;
720
+ /** RFC 6901 JSON Pointer into the tool arguments. */
721
+ readonly descriptionPath?: string;
722
+ readonly destinations?: TicketCreationDestinationProvider;
723
+ }
724
+
725
+ export interface TicketCreationReceipt {
726
+ readonly externalId: string;
727
+ readonly url: string;
728
+ readonly result?: unknown;
729
+ }
730
+
590
731
  export interface IntegrationToolExecutionContext {
591
732
  readonly process: ProcessInstance;
592
733
  readonly projects: readonly ProcessProject[];
593
734
  readonly turn: ProcessTurnRecord;
594
735
  readonly project: ProcessProject | null;
736
+ readonly ticketDestination?: TicketCreationDestinationSnapshot;
595
737
  /** Stable for a single Pi tool call, including reconnect/replay. */
596
738
  readonly idempotencyKey: string;
597
739
  /** Aborted when the worker stops waiting for this tool call. */
@@ -602,6 +744,8 @@ export interface IntegrationToolDefinition<TArgs = Record<string, unknown>> {
602
744
  readonly name: string;
603
745
  readonly description: string;
604
746
  readonly parameters: Record<string, unknown>;
747
+ /** Sanitized discovery metadata; credentials and adapter configuration never belong here. */
748
+ readonly capability?: TicketCreationCapability;
605
749
  parse?(value: unknown): TArgs;
606
750
  execute(ctx: IntegrationToolExecutionContext, args: TArgs): Promise<unknown>;
607
751
  }
@@ -0,0 +1,12 @@
1
+ import type { ExternalActionSource } from "./extension-api.js";
2
+
3
+ /** Define a resolver-based source with no provider input. */
4
+ export function defineExternalActionSource<TConfig>(
5
+ metadata: Pick<ExternalActionSource, "kind" | "label" | "description" | "describeEvent">,
6
+ ) {
7
+ return function source<TParams, TState>(
8
+ resolve: (ctx: { params: TParams; state: TState }) => TConfig,
9
+ ): ExternalActionSource<TParams, TState> {
10
+ return { ...metadata, config: {}, inputMode: "none", resolve };
11
+ };
12
+ }
@@ -0,0 +1,49 @@
1
+ import type {
2
+ ExternalObservationInput,
3
+ ExternalSourceArmingLike,
4
+ ExternalSourceServiceLike,
5
+ } from "./core-capabilities.js";
6
+
7
+ type Arming = Pick<ExternalSourceArmingLike, "id" | "instanceId" | "generation">;
8
+
9
+ /** Report one poll's effects without choosing events, scheduling, or subscription policy. */
10
+ export function createExternalSourcePollReporter(
11
+ sources: ExternalSourceServiceLike,
12
+ result: { created: string[]; errors: string[] },
13
+ options: { forwardGeneration?: boolean } = {},
14
+ ) {
15
+ return {
16
+ async poll(kind: string, read: (armed: ExternalSourceArmingLike) => Promise<void>) {
17
+ for (const armed of sources.listArmed(kind)) {
18
+ try {
19
+ await read(armed);
20
+ } catch (error) {
21
+ result.errors.push(
22
+ `${armed.id}:${error instanceof Error ? error.message : "poll_failed"}`,
23
+ );
24
+ }
25
+ }
26
+ },
27
+ async fire(armed: Arming, event: Record<string, unknown>, mergeKey: string): Promise<boolean> {
28
+ const fired = await sources.fire({
29
+ instanceId: armed.instanceId,
30
+ armingId: armed.id,
31
+ ...(options.forwardGeneration && armed.generation ? { generation: armed.generation } : {}),
32
+ event,
33
+ mergeKey,
34
+ });
35
+ if (fired.ok) result.created.push(armed.id);
36
+ else result.errors.push(`${armed.id}:fire_failed`);
37
+ return fired.ok;
38
+ },
39
+ observe(armed: Arming, input: Pick<ExternalObservationInput, "observation" | "refreshError">) {
40
+ if (sources.observe && armed.generation)
41
+ return sources.observe({
42
+ instanceId: armed.instanceId,
43
+ armingId: armed.id,
44
+ generation: armed.generation,
45
+ ...input,
46
+ });
47
+ },
48
+ };
49
+ }