@pikku/core 0.12.67 → 0.12.70

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 (96) hide show
  1. package/CHANGELOG.md +397 -0
  2. package/README.md +34 -2
  3. package/dist/function/functions.types.d.ts +27 -0
  4. package/dist/index.d.ts +1 -1
  5. package/dist/internal.d.ts +1 -1
  6. package/dist/internal.js +1 -1
  7. package/dist/pikku-state.js +1 -0
  8. package/dist/services/http-scenario-actors.d.ts +12 -4
  9. package/dist/services/http-scenario-actors.js +47 -45
  10. package/dist/services/in-memory-workflow-service.d.ts +2 -2
  11. package/dist/services/in-memory-workflow-service.js +2 -2
  12. package/dist/services/index.d.ts +2 -1
  13. package/dist/services/index.js +1 -0
  14. package/dist/services/meta-service.d.ts +5 -1
  15. package/dist/services/meta-service.js +44 -18
  16. package/dist/services/scenario-actors-service.d.ts +108 -2
  17. package/dist/services/scenario-actors-service.js +40 -1
  18. package/dist/types/core.types.d.ts +21 -3
  19. package/dist/types/state.types.d.ts +3 -1
  20. package/dist/wirings/actor-flow/actor-flow.types.d.ts +1 -1
  21. package/dist/wirings/actor-flow/index.d.ts +1 -1
  22. package/dist/wirings/actor-flow/run-conversation.d.ts +10 -10
  23. package/dist/wirings/actor-flow/run-conversation.js +27 -27
  24. package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +18 -1
  25. package/dist/wirings/ai-agent/ai-agent-prepare.js +26 -4
  26. package/dist/wirings/cli/command-parser.js +11 -1
  27. package/dist/wirings/queue/index.d.ts +1 -1
  28. package/dist/wirings/queue/queue.types.d.ts +30 -0
  29. package/dist/wirings/rpc/rpc-runner.js +1 -1
  30. package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +52 -3
  31. package/dist/wirings/workflow/feature.d.ts +28 -0
  32. package/dist/wirings/workflow/feature.js +57 -0
  33. package/dist/wirings/workflow/index.d.ts +13 -2
  34. package/dist/wirings/workflow/index.js +15 -0
  35. package/dist/wirings/workflow/pikku-scenario-service.d.ts +121 -0
  36. package/dist/wirings/workflow/pikku-scenario-service.js +419 -0
  37. package/dist/wirings/workflow/pikku-workflow-service.d.ts +118 -12
  38. package/dist/wirings/workflow/pikku-workflow-service.js +166 -153
  39. package/dist/wirings/workflow/scenario-cookie-jar.d.ts +29 -0
  40. package/dist/wirings/workflow/scenario-cookie-jar.js +51 -0
  41. package/dist/wirings/workflow/scenario-poll.d.ts +20 -0
  42. package/dist/wirings/workflow/scenario-poll.js +25 -0
  43. package/dist/wirings/workflow/scenario-prose.d.ts +38 -0
  44. package/dist/wirings/workflow/scenario-prose.js +45 -0
  45. package/dist/wirings/workflow/scenario-step-guards.d.ts +16 -0
  46. package/dist/wirings/workflow/scenario-step-guards.js +29 -0
  47. package/dist/wirings/workflow/scenario-step.types.d.ts +148 -0
  48. package/dist/wirings/workflow/scenario-step.types.js +1 -0
  49. package/dist/wirings/workflow/workflow.types.d.ts +119 -2
  50. package/package.json +3 -1
  51. package/src/function/functions.types.ts +32 -0
  52. package/src/index.ts +1 -0
  53. package/src/internal.ts +5 -1
  54. package/src/pikku-state.ts +1 -0
  55. package/src/services/http-scenario-actors.test.ts +85 -1
  56. package/src/services/http-scenario-actors.ts +65 -51
  57. package/src/services/in-memory-workflow-service.test.ts +50 -1
  58. package/src/services/in-memory-workflow-service.ts +3 -2
  59. package/src/services/index.ts +5 -0
  60. package/src/services/meta-service.test.ts +79 -0
  61. package/src/services/meta-service.ts +61 -26
  62. package/src/services/scenario-actors-service.ts +157 -2
  63. package/src/types/core.types.ts +27 -2
  64. package/src/types/state.types.ts +3 -0
  65. package/src/wirings/actor-flow/actor-flow.types.ts +1 -1
  66. package/src/wirings/actor-flow/index.ts +1 -1
  67. package/src/wirings/actor-flow/run-conversation.test.ts +12 -6
  68. package/src/wirings/actor-flow/run-conversation.ts +36 -41
  69. package/src/wirings/ai-agent/ai-agent-prepare.test.ts +29 -0
  70. package/src/wirings/ai-agent/ai-agent-prepare.ts +38 -4
  71. package/src/wirings/cli/command-parser.test.ts +60 -0
  72. package/src/wirings/cli/command-parser.ts +12 -1
  73. package/src/wirings/queue/index.ts +2 -0
  74. package/src/wirings/queue/queue.types.ts +32 -0
  75. package/src/wirings/rpc/rpc-runner.test.ts +28 -5
  76. package/src/wirings/rpc/rpc-runner.ts +1 -1
  77. package/src/wirings/workflow/dsl/workflow-dsl.types.ts +86 -2
  78. package/src/wirings/workflow/feature.test.ts +131 -0
  79. package/src/wirings/workflow/feature.ts +78 -0
  80. package/src/wirings/workflow/index.ts +74 -0
  81. package/src/wirings/workflow/pikku-scenario-service.ts +682 -0
  82. package/src/wirings/workflow/pikku-workflow-service.test.ts +126 -0
  83. package/src/wirings/workflow/pikku-workflow-service.ts +306 -228
  84. package/src/wirings/workflow/scenario-cookie-jar.test.ts +108 -0
  85. package/src/wirings/workflow/scenario-cookie-jar.ts +65 -0
  86. package/src/wirings/workflow/scenario-hooks.test.ts +212 -0
  87. package/src/wirings/workflow/scenario-poll.test.ts +66 -0
  88. package/src/wirings/workflow/scenario-poll.ts +36 -0
  89. package/src/wirings/workflow/scenario-prose.test.ts +152 -0
  90. package/src/wirings/workflow/scenario-prose.ts +79 -0
  91. package/src/wirings/workflow/scenario-service.test.ts +155 -0
  92. package/src/wirings/workflow/scenario-step-guards.ts +43 -0
  93. package/src/wirings/workflow/scenario-step.test.ts +441 -8
  94. package/src/wirings/workflow/scenario-step.types.ts +157 -0
  95. package/src/wirings/workflow/workflow.types.ts +137 -1
  96. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,9 @@
1
1
  import type { SerializedError, CommonWireMeta } from '../../types/core.types.js'
2
- import type { CorePikkuFunctionConfig } from '../../function/functions.types.js'
2
+ import type {
3
+ CorePikkuFunctionConfig,
4
+ CorePikkuFunctionHook,
5
+ } from '../../function/functions.types.js'
6
+ import type { GroupConcurrencyConfig } from '../queue/queue.types.js'
3
7
 
4
8
  // Re-export WorkflowService from services module
5
9
  export type { WorkflowService } from '../../services/workflow-service.js'
@@ -37,12 +41,23 @@ export type {
37
41
  SwitchStepMeta,
38
42
  FilterStepMeta,
39
43
  ArrayPredicateStepMeta,
44
+ ScenarioStepInvocation,
45
+ ScenarioStepMeta,
40
46
  WorkflowStepMeta,
41
47
  WorkflowStepWire,
42
48
  PikkuWorkflowWire,
43
49
  PikkuScenarioWire,
44
50
  } from './dsl/workflow-dsl.types.js'
45
51
 
52
+ // Re-export scenario step types
53
+ export type {
54
+ ScenarioStepPhase,
55
+ ScenarioStepOptions,
56
+ PikkuScenarioStepWire,
57
+ PikkuBrowserWire,
58
+ ScenarioBrowserProvider,
59
+ } from './scenario-step.types.js'
60
+
46
61
  import type { WorkflowStepMeta } from './dsl/workflow-dsl.types.js'
47
62
 
48
63
  export interface WorkflowRunWire {
@@ -62,6 +77,44 @@ export interface WorkflowServiceConfig {
62
77
  sleeperRPCName: string
63
78
  }
64
79
 
80
+ /**
81
+ * How a workflow service spreads its jobs across queues.
82
+ *
83
+ * Passed to the service constructor rather than read from `config.workflow`:
84
+ * the queues are wired during construction, before singleton services (and so
85
+ * before `config`) exist.
86
+ */
87
+ export interface WorkflowQueueOptions {
88
+ /**
89
+ * - `'per-workflow'` (default) — each workflow gets its own
90
+ * `wf-orchestrator-*` / `wf-step-*` queue. Complete isolation, and it's
91
+ * what lets serverless providers deploy one unit per workflow. Costs one
92
+ * set of pollers per queue, which adds up on pull-based backends.
93
+ * - `'shared-groups'` — every workflow shares the orchestrator/step-worker
94
+ * queues and stays isolated via {@link queueGroupConcurrency}, so no
95
+ * workflow can occupy more than its share. One set of pollers total.
96
+ * Only for single-process (monolith) runtimes; a per-unit serverless
97
+ * deploy needs the per-workflow queues to route to its units.
98
+ */
99
+ queueStrategy?: 'per-workflow' | 'shared-groups'
100
+ /**
101
+ * Total concurrent workflow jobs per node under `'shared-groups'`.
102
+ * Defaults to 20.
103
+ */
104
+ queueConcurrency?: number
105
+ /**
106
+ * How many jobs of one workflow may run at once under `'shared-groups'`.
107
+ * Defaults to 2. Tiers are keyed by workflow name, so a specific workflow
108
+ * can be given its own limit without any extra wiring.
109
+ *
110
+ * Note tiers can only lower a workflow's limit, not raise it above
111
+ * `default`: the backend's pre-fetch exclusion is applied per group using
112
+ * `default` alone. To give one workflow more room, raise `default` and
113
+ * restrict the others by tier.
114
+ */
115
+ queueGroupConcurrency?: number | GroupConcurrencyConfig
116
+ }
117
+
65
118
  export interface WorkflowPlannedStep {
66
119
  /** Durable step key — matches the runtime step name stored in the DB */
67
120
  stepName: string
@@ -290,6 +343,82 @@ export type CoreWorkflow<
290
343
  tags?: string[]
291
344
  }
292
345
 
346
+ /**
347
+ * A scenario as a feature references it: either the scenario itself, or the
348
+ * scenario paired with the input to run it with. The paired form is gherkin's
349
+ * `Examples:` — the same scenario run once per row, written as an ordinary
350
+ * loop rather than a table.
351
+ */
352
+ export type CoreFeatureScenario =
353
+ | CorePikkuFunctionConfig<any, any, any>
354
+ | { scenario: CorePikkuFunctionConfig<any, any, any>; data: unknown }
355
+
356
+ /**
357
+ * A feature: an ordered group of scenarios, mirroring gherkin's Feature ↔
358
+ * Scenario structure. Scenarios are referenced by imported identifier, so a
359
+ * renamed or deleted scenario is a compile error rather than a silent skip.
360
+ *
361
+ * Hooks run **once around the whole group** (`before → a → b → c → after`),
362
+ * not per scenario — per-scenario setup is the scenario's own `before`. That
363
+ * is the one thing a feature deliberately cannot express: gherkin's
364
+ * `Background:` runs per scenario.
365
+ */
366
+ export type CoreFeature = {
367
+ /** Human-readable name. The export identifier is the id. */
368
+ name: string
369
+ description?: string
370
+ tags?: string[]
371
+ /** Readonly because `pikkuFeature`'s `const` generic infers a readonly tuple. */
372
+ scenarios: readonly CoreFeatureScenario[]
373
+ before?: CorePikkuFunctionHook
374
+ after?: CorePikkuFunctionHook
375
+ }
376
+
377
+ /** One entry of a feature's scenario list, as extracted from the source. */
378
+ export type FeatureMetaEntry = {
379
+ /** The scenario's declared export name — its key in `WorkflowsMeta`. */
380
+ scenario: string
381
+ /** The input this entry runs the scenario with — gherkin's `Examples:`. */
382
+ data?: unknown
383
+ }
384
+
385
+ /**
386
+ * A feature as the console reads it: the document structure around a group of
387
+ * scenarios. Generated to `scenarios/features.gen.json` and read off disk, so
388
+ * nothing app-facing has to import the scenario bootstrap to describe one.
389
+ */
390
+ export type FeatureMeta = {
391
+ /** The export identifier. */
392
+ id: string
393
+ name: string
394
+ description?: string
395
+ tags: string[]
396
+ /** In declared order — a feature's reading order is its declaration order. */
397
+ entries: FeatureMetaEntry[]
398
+ /**
399
+ * Entries that could not be read statically (a spread, a `.map()`). Their
400
+ * membership is only known once the scenario bootstrap has been evaluated,
401
+ * so a non-zero count means this listing is partial.
402
+ */
403
+ unresolvedEntries: number
404
+ /** Hooks are runtime-only; only their presence is knowable from meta. */
405
+ hasBefore: boolean
406
+ hasAfter: boolean
407
+ }
408
+
409
+ export type FeaturesMeta = Record<string, FeatureMeta>
410
+
411
+ /** One planned scenario run, resolved from a feature's scenario list. */
412
+ export type FeaturePlanEntry = {
413
+ featureId: string
414
+ featureName: string
415
+ scenarioName: string
416
+ /** The input this entry runs the scenario with, if the feature supplied one. */
417
+ data?: unknown
418
+ /** The scenario's own tags unioned with the containing feature's. */
419
+ tags: string[]
420
+ }
421
+
293
422
  /**
294
423
  * Workflow client interface
295
424
  */
@@ -332,6 +461,13 @@ export type WorkflowsMeta = Record<
332
461
  expose?: boolean
333
462
  /** True for pikkuScenario workflows (complex + actor steps). */
334
463
  scenario?: boolean
464
+ /**
465
+ * Why a scenario is held out of a default run. Stating the reason in code
466
+ * keeps the quarantine next to the scenario it applies to, rather than in
467
+ * a CI invocation nobody reads. Naming the scenario with `--flows` runs it
468
+ * regardless.
469
+ */
470
+ skip?: string
335
471
  /** Actor names a scenario declares (personas it runs steps as). */
336
472
  actors?: string[]
337
473
  }