@pikku/core 0.12.69 → 0.12.71

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 (118) hide show
  1. package/CHANGELOG.md +422 -0
  2. package/LICENSE +21 -0
  3. package/README.md +34 -2
  4. package/dist/function/functions.types.d.ts +27 -0
  5. package/dist/index.d.ts +1 -1
  6. package/dist/internal.d.ts +1 -1
  7. package/dist/internal.js +1 -1
  8. package/dist/pikku-state.js +1 -0
  9. package/dist/services/http-scenario-actors.d.ts +12 -4
  10. package/dist/services/http-scenario-actors.js +47 -45
  11. package/dist/services/in-memory-queue-service.d.ts +6 -0
  12. package/dist/services/in-memory-queue-service.js +8 -1
  13. package/dist/services/in-memory-workflow-service.d.ts +3 -5
  14. package/dist/services/in-memory-workflow-service.js +10 -19
  15. package/dist/services/index.d.ts +2 -1
  16. package/dist/services/index.js +1 -0
  17. package/dist/services/meta-service.d.ts +5 -1
  18. package/dist/services/meta-service.js +44 -18
  19. package/dist/services/scenario-actors-service.d.ts +108 -2
  20. package/dist/services/scenario-actors-service.js +40 -1
  21. package/dist/services/workflow-service.d.ts +7 -5
  22. package/dist/types/core.types.d.ts +28 -3
  23. package/dist/types/state.types.d.ts +3 -1
  24. package/dist/wirings/actor-flow/actor-flow.types.d.ts +1 -1
  25. package/dist/wirings/actor-flow/index.d.ts +1 -1
  26. package/dist/wirings/actor-flow/run-conversation.d.ts +10 -10
  27. package/dist/wirings/actor-flow/run-conversation.js +27 -27
  28. package/dist/wirings/ai-agent/ai-agent-agui.js +0 -8
  29. package/dist/wirings/ai-agent/ai-agent-prepare.js +1 -2
  30. package/dist/wirings/ai-agent/ai-agent.types.d.ts +0 -6
  31. package/dist/wirings/cli/command-parser.js +11 -1
  32. package/dist/wirings/rpc/rpc-runner.js +1 -1
  33. package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +52 -3
  34. package/dist/wirings/workflow/feature.d.ts +28 -0
  35. package/dist/wirings/workflow/feature.js +57 -0
  36. package/dist/wirings/workflow/graph/graph-runner.js +3 -2
  37. package/dist/wirings/workflow/graph/graph-validation.d.ts +0 -2
  38. package/dist/wirings/workflow/graph/graph-validation.js +0 -142
  39. package/dist/wirings/workflow/graph/index.d.ts +1 -1
  40. package/dist/wirings/workflow/graph/index.js +1 -1
  41. package/dist/wirings/workflow/index.d.ts +13 -3
  42. package/dist/wirings/workflow/index.js +15 -2
  43. package/dist/wirings/workflow/pikku-scenario-service.d.ts +121 -0
  44. package/dist/wirings/workflow/pikku-scenario-service.js +419 -0
  45. package/dist/wirings/workflow/pikku-workflow-service.d.ts +170 -23
  46. package/dist/wirings/workflow/pikku-workflow-service.js +338 -297
  47. package/dist/wirings/workflow/scenario-cookie-jar.d.ts +29 -0
  48. package/dist/wirings/workflow/scenario-cookie-jar.js +51 -0
  49. package/dist/wirings/workflow/scenario-poll.d.ts +20 -0
  50. package/dist/wirings/workflow/scenario-poll.js +25 -0
  51. package/dist/wirings/workflow/scenario-prose.d.ts +38 -0
  52. package/dist/wirings/workflow/scenario-prose.js +45 -0
  53. package/dist/wirings/workflow/scenario-step-guards.d.ts +16 -0
  54. package/dist/wirings/workflow/scenario-step-guards.js +29 -0
  55. package/dist/wirings/workflow/scenario-step.types.d.ts +148 -0
  56. package/dist/wirings/workflow/scenario-step.types.js +1 -0
  57. package/dist/wirings/workflow/workflow.types.d.ts +82 -8
  58. package/package.json +3 -1
  59. package/src/function/functions.types.ts +32 -0
  60. package/src/index.ts +1 -0
  61. package/src/internal.ts +5 -1
  62. package/src/pikku-state.ts +1 -0
  63. package/src/services/http-scenario-actors.test.ts +85 -1
  64. package/src/services/http-scenario-actors.ts +65 -51
  65. package/src/services/in-memory-queue-service.test.ts +66 -1
  66. package/src/services/in-memory-queue-service.ts +13 -2
  67. package/src/services/in-memory-workflow-service.ts +12 -25
  68. package/src/services/index.ts +5 -0
  69. package/src/services/meta-service.test.ts +79 -0
  70. package/src/services/meta-service.ts +61 -26
  71. package/src/services/scenario-actors-service.ts +157 -2
  72. package/src/services/workflow-service.ts +7 -4
  73. package/src/types/core.types.ts +34 -2
  74. package/src/types/state.types.ts +3 -0
  75. package/src/wirings/actor-flow/actor-flow.types.ts +1 -1
  76. package/src/wirings/actor-flow/index.ts +1 -1
  77. package/src/wirings/actor-flow/run-conversation.test.ts +12 -6
  78. package/src/wirings/actor-flow/run-conversation.ts +36 -41
  79. package/src/wirings/ai-agent/ai-agent-agui.test.ts +0 -16
  80. package/src/wirings/ai-agent/ai-agent-agui.ts +0 -9
  81. package/src/wirings/ai-agent/ai-agent-prepare.ts +1 -2
  82. package/src/wirings/ai-agent/ai-agent.types.ts +0 -7
  83. package/src/wirings/cli/command-parser.test.ts +60 -0
  84. package/src/wirings/cli/command-parser.ts +12 -1
  85. package/src/wirings/rpc/rpc-runner.test.ts +28 -5
  86. package/src/wirings/rpc/rpc-runner.ts +1 -1
  87. package/src/wirings/workflow/dsl/workflow-dsl.types.ts +86 -2
  88. package/src/wirings/workflow/feature.test.ts +131 -0
  89. package/src/wirings/workflow/feature.ts +78 -0
  90. package/src/wirings/workflow/graph/graph-runner.ts +3 -2
  91. package/src/wirings/workflow/graph/graph-validation.test.ts +1 -144
  92. package/src/wirings/workflow/graph/graph-validation.ts +0 -196
  93. package/src/wirings/workflow/graph/index.ts +1 -5
  94. package/src/wirings/workflow/index.ts +73 -6
  95. package/src/wirings/workflow/pikku-scenario-service.ts +682 -0
  96. package/src/wirings/workflow/pikku-workflow-service.test.ts +55 -0
  97. package/src/wirings/workflow/pikku-workflow-service.ts +572 -419
  98. package/src/wirings/workflow/scenario-cookie-jar.test.ts +108 -0
  99. package/src/wirings/workflow/scenario-cookie-jar.ts +65 -0
  100. package/src/wirings/workflow/scenario-expectations.test.ts +153 -0
  101. package/src/wirings/workflow/scenario-hooks.test.ts +212 -0
  102. package/src/wirings/workflow/scenario-poll.test.ts +66 -0
  103. package/src/wirings/workflow/scenario-poll.ts +36 -0
  104. package/src/wirings/workflow/scenario-prose.test.ts +152 -0
  105. package/src/wirings/workflow/scenario-prose.ts +79 -0
  106. package/src/wirings/workflow/scenario-service.test.ts +155 -0
  107. package/src/wirings/workflow/scenario-step-guards.ts +43 -0
  108. package/src/wirings/workflow/scenario-step.test.ts +442 -9
  109. package/src/wirings/workflow/scenario-step.types.ts +157 -0
  110. package/src/wirings/workflow/workflow-dispatch-durability.test.ts +1 -1
  111. package/src/wirings/workflow/workflow-dispatch-payload.test.ts +59 -0
  112. package/src/wirings/workflow/workflow-mirror.test.ts +178 -0
  113. package/src/wirings/workflow/workflow-replay-snapshot.test.ts +139 -0
  114. package/src/wirings/workflow/workflow-run-context.test.ts +177 -0
  115. package/src/wirings/workflow/workflow-run-polling.test.ts +132 -0
  116. package/src/wirings/workflow/workflow-step-ordinal.test.ts +4 -4
  117. package/src/wirings/workflow/workflow.types.ts +99 -5
  118. package/tsconfig.tsbuildinfo +1 -1
@@ -19,7 +19,7 @@ describe('same step name invoked multiple times in one run', () => {
19
19
  test('each reach gets its own row + invocationId (no clobber)', async () => {
20
20
  const ws = inlineService()
21
21
  const runId = await ws.createRun('flow', {}, true, 'hash', { type: 'test' })
22
- ;(ws as any).inlineRuns.add(runId)
22
+ ws.registerInlineRun(runId)
23
23
 
24
24
  // Two `do('process', fn)` reaches in the SAME replay (no reset between).
25
25
  const r1 = await (ws as any).inlineStep(runId, 'process', async () => 'first')
@@ -45,7 +45,7 @@ describe('same step name invoked multiple times in one run', () => {
45
45
  test('ordinal 0 is unchanged: a single call keeps the bare name + its old invocationId', async () => {
46
46
  const ws = inlineService()
47
47
  const runId = await ws.createRun('flow', {}, true, 'hash', { type: 'test' })
48
- ;(ws as any).inlineRuns.add(runId)
48
+ ws.registerInlineRun(runId)
49
49
 
50
50
  await (ws as any).inlineStep(runId, 'solo', async () => 'x')
51
51
  // Stored under the bare name, and the dedupe key matches the pre-ordinal hash.
@@ -57,7 +57,7 @@ describe('same step name invoked multiple times in one run', () => {
57
57
  test('a fresh replay resets ordinals so the same call resolves to the same row', async () => {
58
58
  const ws = inlineService()
59
59
  const runId = await ws.createRun('flow', {}, true, 'hash', { type: 'test' })
60
- ;(ws as any).inlineRuns.add(runId)
60
+ ws.registerInlineRun(runId)
61
61
 
62
62
  let runs = 0
63
63
  const r1 = await (ws as any).inlineStep(runId, 'once', async () => {
@@ -66,7 +66,7 @@ describe('same step name invoked multiple times in one run', () => {
66
66
  })
67
67
  // Next replay resets the counter; the same `do('once')` must hit the cached
68
68
  // row, not mint 'once#1'.
69
- ;(ws as any).resetStepOrdinals(runId)
69
+ await (ws as any).beginReplay(runId)
70
70
  const r2 = await (ws as any).inlineStep(runId, 'once', async () => {
71
71
  runs++
72
72
  return 'v2'
@@ -1,5 +1,8 @@
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'
3
6
  import type { GroupConcurrencyConfig } from '../queue/queue.types.js'
4
7
 
5
8
  // Re-export WorkflowService from services module
@@ -38,12 +41,23 @@ export type {
38
41
  SwitchStepMeta,
39
42
  FilterStepMeta,
40
43
  ArrayPredicateStepMeta,
44
+ ScenarioStepInvocation,
45
+ ScenarioStepMeta,
41
46
  WorkflowStepMeta,
42
47
  WorkflowStepWire,
43
48
  PikkuWorkflowWire,
44
49
  PikkuScenarioWire,
45
50
  } from './dsl/workflow-dsl.types.js'
46
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
+
47
61
  import type { WorkflowStepMeta } from './dsl/workflow-dsl.types.js'
48
62
 
49
63
  export interface WorkflowRunWire {
@@ -240,9 +254,6 @@ export interface WorkflowRunService {
240
254
  name: string,
241
255
  graphHash: string
242
256
  ): Promise<{ graph: any; source: string } | null>
243
- getAIGeneratedWorkflows(
244
- agentName?: string
245
- ): Promise<Array<{ workflowName: string; graphHash: string; graph: any }>>
246
257
  deleteRun(id: string): Promise<boolean>
247
258
  }
248
259
 
@@ -329,6 +340,82 @@ export type CoreWorkflow<
329
340
  tags?: string[]
330
341
  }
331
342
 
343
+ /**
344
+ * A scenario as a feature references it: either the scenario itself, or the
345
+ * scenario paired with the input to run it with. The paired form is gherkin's
346
+ * `Examples:` — the same scenario run once per row, written as an ordinary
347
+ * loop rather than a table.
348
+ */
349
+ export type CoreFeatureScenario =
350
+ | CorePikkuFunctionConfig<any, any, any>
351
+ | { scenario: CorePikkuFunctionConfig<any, any, any>; data: unknown }
352
+
353
+ /**
354
+ * A feature: an ordered group of scenarios, mirroring gherkin's Feature ↔
355
+ * Scenario structure. Scenarios are referenced by imported identifier, so a
356
+ * renamed or deleted scenario is a compile error rather than a silent skip.
357
+ *
358
+ * Hooks run **once around the whole group** (`before → a → b → c → after`),
359
+ * not per scenario — per-scenario setup is the scenario's own `before`. That
360
+ * is the one thing a feature deliberately cannot express: gherkin's
361
+ * `Background:` runs per scenario.
362
+ */
363
+ export type CoreFeature = {
364
+ /** Human-readable name. The export identifier is the id. */
365
+ name: string
366
+ description?: string
367
+ tags?: string[]
368
+ /** Readonly because `pikkuFeature`'s `const` generic infers a readonly tuple. */
369
+ scenarios: readonly CoreFeatureScenario[]
370
+ before?: CorePikkuFunctionHook
371
+ after?: CorePikkuFunctionHook
372
+ }
373
+
374
+ /** One entry of a feature's scenario list, as extracted from the source. */
375
+ export type FeatureMetaEntry = {
376
+ /** The scenario's declared export name — its key in `WorkflowsMeta`. */
377
+ scenario: string
378
+ /** The input this entry runs the scenario with — gherkin's `Examples:`. */
379
+ data?: unknown
380
+ }
381
+
382
+ /**
383
+ * A feature as the console reads it: the document structure around a group of
384
+ * scenarios. Generated to `scenarios/features.gen.json` and read off disk, so
385
+ * nothing app-facing has to import the scenario bootstrap to describe one.
386
+ */
387
+ export type FeatureMeta = {
388
+ /** The export identifier. */
389
+ id: string
390
+ name: string
391
+ description?: string
392
+ tags: string[]
393
+ /** In declared order — a feature's reading order is its declaration order. */
394
+ entries: FeatureMetaEntry[]
395
+ /**
396
+ * Entries that could not be read statically (a spread, a `.map()`). Their
397
+ * membership is only known once the scenario bootstrap has been evaluated,
398
+ * so a non-zero count means this listing is partial.
399
+ */
400
+ unresolvedEntries: number
401
+ /** Hooks are runtime-only; only their presence is knowable from meta. */
402
+ hasBefore: boolean
403
+ hasAfter: boolean
404
+ }
405
+
406
+ export type FeaturesMeta = Record<string, FeatureMeta>
407
+
408
+ /** One planned scenario run, resolved from a feature's scenario list. */
409
+ export type FeaturePlanEntry = {
410
+ featureId: string
411
+ featureName: string
412
+ scenarioName: string
413
+ /** The input this entry runs the scenario with, if the feature supplied one. */
414
+ data?: unknown
415
+ /** The scenario's own tags unioned with the containing feature's. */
416
+ tags: string[]
417
+ }
418
+
332
419
  /**
333
420
  * Workflow client interface
334
421
  */
@@ -371,6 +458,13 @@ export type WorkflowsMeta = Record<
371
458
  expose?: boolean
372
459
  /** True for pikkuScenario workflows (complex + actor steps). */
373
460
  scenario?: boolean
461
+ /**
462
+ * Why a scenario is held out of a default run. Stating the reason in code
463
+ * keeps the quarantine next to the scenario it applies to, rather than in
464
+ * a CI invocation nobody reads. Naming the scenario with `--flows` runs it
465
+ * regardless.
466
+ */
467
+ skip?: string
374
468
  /** Actor names a scenario declares (personas it runs steps as). */
375
469
  actors?: string[]
376
470
  }
@@ -387,7 +481,7 @@ export interface WorkflowRuntimeMeta {
387
481
  /** Pikku function name (for execution) */
388
482
  pikkuFuncId: string
389
483
  /** Source type: 'dsl' (serializable), 'complex' (has inline steps), 'graph', 'scenario' (complex + actor steps) */
390
- source: 'dsl' | 'complex' | 'graph' | 'dynamic-workflow' | 'scenario'
484
+ source: 'dsl' | 'complex' | 'graph' | 'scenario'
391
485
  /** Optional description */
392
486
  description?: string
393
487
  /** Tags for organization */