@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
@@ -29,6 +29,77 @@ describe('pikku-workflow-service worker registration', () => {
29
29
  })
30
30
  })
31
31
 
32
+ describe('pikku-workflow-service per-workflow queue warning', () => {
33
+ // Losing the per-workflow orchestrator queues is silent — dispatch just falls
34
+ // back to the single shared queue and one slow step starves every workflow
35
+ // behind it. These assert the misconfiguration is announced at wiring time.
36
+ const setup = (workflowNames: string[], perWorkflowQueues: string[] = []) => {
37
+ resetPikkuState()
38
+ const warnings: string[] = []
39
+ pikkuState(null, 'package', 'singletonServices', {
40
+ logger: {
41
+ error: () => {},
42
+ info: () => {},
43
+ debug: () => {},
44
+ warn: (message: string) => warnings.push(message),
45
+ },
46
+ } as any)
47
+
48
+ const metaState = pikkuState(null, 'workflows', 'meta')
49
+ for (const name of workflowNames) {
50
+ metaState[name] = {
51
+ name,
52
+ pikkuFuncId: name,
53
+ source: 'dsl',
54
+ graphHash: `${name}-hash`,
55
+ } as any
56
+ }
57
+
58
+ const queueMeta = pikkuState(null, 'queue', 'meta')
59
+ for (const queueName of perWorkflowQueues) {
60
+ queueMeta[queueName] = {
61
+ pikkuFuncId: queueName,
62
+ name: queueName,
63
+ } as any
64
+ }
65
+
66
+ return warnings
67
+ }
68
+
69
+ test('warns when workflows exist but no per-workflow orchestrator queue is registered', () => {
70
+ const warnings = setup(['someWorkflow'])
71
+
72
+ new InMemoryWorkflowService().wireQueueWorkers()
73
+
74
+ assert.ok(
75
+ warnings.some((w) => /no per-workflow orchestrator queues/.test(w)),
76
+ `expected a per-workflow queue warning, got: ${JSON.stringify(warnings)}`
77
+ )
78
+ })
79
+
80
+ test('does not warn when per-workflow orchestrator queues are present', () => {
81
+ const warnings = setup(['someWorkflow'], ['wf-orchestrator-some-workflow'])
82
+
83
+ new InMemoryWorkflowService().wireQueueWorkers()
84
+
85
+ assert.ok(
86
+ !warnings.some((w) => /no per-workflow orchestrator queues/.test(w)),
87
+ `expected no warning, got: ${JSON.stringify(warnings)}`
88
+ )
89
+ })
90
+
91
+ test('does not warn when the app registers no workflows at all', () => {
92
+ const warnings = setup([])
93
+
94
+ new InMemoryWorkflowService().wireQueueWorkers()
95
+
96
+ assert.ok(
97
+ !warnings.some((w) => /no per-workflow orchestrator queues/.test(w)),
98
+ `expected no warning, got: ${JSON.stringify(warnings)}`
99
+ )
100
+ })
101
+ })
102
+
32
103
  describe('pikku-workflow-service run-level inline', () => {
33
104
  test('workflow runs inline (and queues nothing) when no queue service is configured', async () => {
34
105
  const ws = new InMemoryWorkflowService()
@@ -804,3 +875,58 @@ describe('pikku-workflow-service approval', () => {
804
875
  cleanup()
805
876
  })
806
877
  })
878
+
879
+ describe('pikku-workflow-service run identity on failure', () => {
880
+ // A failing inline run throws before startWorkflow can return `{ runId }`,
881
+ // so a caller that wants to read the run back — its steps, which one failed,
882
+ // what it was called with — has nothing to read it by. `onRunCreated` fires
883
+ // as soon as the run exists, which is the only moment guaranteed to happen
884
+ // whether the run goes on to pass, fail, or suspend.
885
+ const runFailing = async (name: string) => {
886
+ resetPikkuState()
887
+ const ws = new InMemoryWorkflowService()
888
+ pikkuState(null, 'package', 'singletonServices', {
889
+ logger: { error() {}, info() {}, warn() {}, debug() {} },
890
+ } as any)
891
+
892
+ const metaState = pikkuState(null, 'workflows', 'meta')
893
+ metaState[name] = {
894
+ name,
895
+ pikkuFuncId: name,
896
+ source: 'scenario',
897
+ graphHash: `${name}-hash`,
898
+ } as any
899
+ pikkuState(null, 'function', 'meta')[name] = {
900
+ name,
901
+ sessionless: true,
902
+ permissions: [],
903
+ } as any
904
+
905
+ addWorkflow(name, {
906
+ func: async () => {
907
+ throw new Error('the scenario blew up')
908
+ },
909
+ } as any)
910
+
911
+ const created: string[] = []
912
+ let error: any
913
+ try {
914
+ await ws.startWorkflow(name, {}, {} as any, {}, {
915
+ onRunCreated: (runId: string) => created.push(runId),
916
+ } as any)
917
+ } catch (e: any) {
918
+ error = e
919
+ }
920
+ return { ws, created, error }
921
+ }
922
+
923
+ test('reports the run id of a run that fails inline', async () => {
924
+ const { ws, created, error } = await runFailing('onRunCreatedFailing')
925
+
926
+ assert.equal(error?.message, 'the scenario blew up')
927
+ assert.equal(created.length, 1, 'the run existed, so its id must be known')
928
+ const run = await ws.getRun(created[0]!)
929
+ assert.equal(run?.status, 'failed')
930
+ assert.equal(run?.error?.message, 'the scenario blew up')
931
+ })
932
+ })