@pikku/core 0.11.2 → 0.12.1
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.
- package/CHANGELOG.md +57 -2
- package/dist/crypto-utils.d.ts +2 -0
- package/dist/crypto-utils.js +78 -0
- package/dist/errors/errors.d.ts +14 -0
- package/dist/errors/errors.js +26 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/function/function-runner.d.ts +10 -4
- package/dist/function/function-runner.js +126 -45
- package/dist/function/functions.types.d.ts +32 -87
- package/dist/function/functions.types.js +16 -46
- package/dist/function/index.d.ts +2 -2
- package/dist/function/index.js +1 -2
- package/dist/handle-error.d.ts +2 -2
- package/dist/handle-error.js +3 -12
- package/dist/index.d.ts +30 -26
- package/dist/index.js +19 -29
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +2 -0
- package/dist/middleware/auth-apikey.d.ts +2 -2
- package/dist/middleware/auth-apikey.js +3 -3
- package/dist/middleware/auth-bearer.d.ts +3 -3
- package/dist/middleware/auth-bearer.js +4 -7
- package/dist/middleware/auth-cookie.d.ts +4 -4
- package/dist/middleware/auth-cookie.js +7 -9
- package/dist/middleware/cors.d.ts +46 -0
- package/dist/middleware/cors.js +81 -0
- package/dist/middleware/index.d.ts +5 -3
- package/dist/middleware/index.js +5 -3
- package/dist/middleware/remote-auth.d.ts +5 -0
- package/dist/middleware/remote-auth.js +55 -0
- package/dist/middleware/timeout.d.ts +2 -2
- package/dist/middleware-runner.d.ts +1 -1
- package/dist/middleware-runner.js +8 -10
- package/dist/permissions.d.ts +2 -2
- package/dist/permissions.js +11 -15
- package/dist/pikku-state.d.ts +10 -8
- package/dist/pikku-state.js +48 -25
- package/dist/schema.d.ts +4 -4
- package/dist/schema.js +20 -15
- package/dist/services/ai-agent-runner-service.d.ts +43 -0
- package/dist/services/ai-agent-runner-service.js +1 -0
- package/dist/services/ai-run-state-service.d.ts +13 -0
- package/dist/services/ai-run-state-service.js +1 -0
- package/dist/services/ai-storage-service.d.ts +18 -0
- package/dist/services/ai-storage-service.js +1 -0
- package/dist/services/content-service.d.ts +6 -0
- package/dist/services/deployment-service.d.ts +19 -0
- package/dist/services/deployment-service.js +1 -0
- package/dist/services/gopass-secrets.d.ts +47 -0
- package/dist/services/gopass-secrets.js +97 -0
- package/dist/services/in-memory-ai-run-state-service.d.ts +15 -0
- package/dist/services/in-memory-ai-run-state-service.js +44 -0
- package/dist/services/in-memory-trigger-service.d.ts +22 -0
- package/dist/services/in-memory-trigger-service.js +48 -0
- package/dist/services/in-memory-workflow-service.d.ts +59 -0
- package/dist/services/in-memory-workflow-service.js +287 -0
- package/dist/services/index.d.ts +26 -11
- package/dist/services/index.js +11 -13
- package/dist/services/local-content.d.ts +2 -1
- package/dist/services/local-content.js +6 -1
- package/dist/services/local-secrets.d.ts +25 -2
- package/dist/services/local-secrets.js +45 -0
- package/dist/services/local-variables.d.ts +6 -1
- package/dist/services/local-variables.js +18 -0
- package/dist/services/logger-console.d.ts +2 -1
- package/dist/services/scheduler-service.d.ts +9 -1
- package/dist/services/scheduler-service.js +8 -0
- package/dist/services/schema-service.d.ts +6 -0
- package/dist/services/scoped-secret-service.d.ts +16 -0
- package/dist/services/scoped-secret-service.js +35 -0
- package/dist/services/secret-service.d.ts +25 -4
- package/dist/services/trigger-service.d.ts +16 -0
- package/dist/services/trigger-service.js +1 -0
- package/dist/services/typed-secret-service.d.ts +30 -0
- package/dist/services/typed-secret-service.js +40 -0
- package/dist/services/typed-variables-service.d.ts +27 -0
- package/dist/services/typed-variables-service.js +46 -0
- package/dist/services/user-session-service.d.ts +15 -2
- package/dist/services/user-session-service.js +17 -0
- package/dist/services/variables-service.d.ts +5 -0
- package/dist/services/workflow-service.d.ts +9 -5
- package/dist/types/core.types.d.ts +67 -25
- package/dist/types/core.types.js +8 -1
- package/dist/types/state.types.d.ts +53 -59
- package/dist/utils.d.ts +7 -6
- package/dist/utils.js +27 -12
- package/dist/version.d.ts +6 -0
- package/dist/version.js +19 -0
- package/dist/wirings/ai-agent/ai-agent-assistant-ui.d.ts +5 -0
- package/dist/wirings/ai-agent/ai-agent-assistant-ui.js +146 -0
- package/dist/wirings/ai-agent/ai-agent-helpers.d.ts +28 -0
- package/dist/wirings/ai-agent/ai-agent-helpers.js +40 -0
- package/dist/wirings/ai-agent/ai-agent-memory.d.ts +29 -0
- package/dist/wirings/ai-agent/ai-agent-memory.js +199 -0
- package/dist/wirings/ai-agent/ai-agent-model-config.d.ts +9 -0
- package/dist/wirings/ai-agent/ai-agent-model-config.js +36 -0
- package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +59 -0
- package/dist/wirings/ai-agent/ai-agent-prepare.js +348 -0
- package/dist/wirings/ai-agent/ai-agent-registry.d.ts +15 -0
- package/dist/wirings/ai-agent/ai-agent-registry.js +47 -0
- package/dist/wirings/ai-agent/ai-agent-runner.d.ts +3 -0
- package/dist/wirings/ai-agent/ai-agent-runner.js +195 -0
- package/dist/wirings/ai-agent/ai-agent-stream.d.ts +12 -0
- package/dist/wirings/ai-agent/ai-agent-stream.js +662 -0
- package/dist/wirings/ai-agent/ai-agent.types.d.ts +313 -0
- package/dist/wirings/ai-agent/ai-agent.types.js +1 -0
- package/dist/wirings/ai-agent/index.d.ts +7 -0
- package/dist/wirings/ai-agent/index.js +6 -0
- package/dist/wirings/channel/channel-common.d.ts +8 -5
- package/dist/wirings/channel/channel-common.js +15 -8
- package/dist/wirings/channel/channel-handler.d.ts +3 -3
- package/dist/wirings/channel/channel-handler.js +15 -6
- package/dist/wirings/channel/channel-middleware-runner.d.ts +9 -0
- package/dist/wirings/channel/channel-middleware-runner.js +73 -0
- package/dist/wirings/channel/channel-runner.d.ts +5 -5
- package/dist/wirings/channel/channel-runner.js +10 -9
- package/dist/wirings/channel/channel-store.d.ts +1 -1
- package/dist/wirings/channel/channel.types.d.ts +9 -7
- package/dist/wirings/channel/define-channel-routes.d.ts +21 -0
- package/dist/wirings/channel/define-channel-routes.js +23 -0
- package/dist/wirings/channel/index.d.ts +10 -8
- package/dist/wirings/channel/index.js +7 -8
- package/dist/wirings/channel/local/index.d.ts +3 -3
- package/dist/wirings/channel/local/index.js +3 -3
- package/dist/wirings/channel/local/local-channel-runner.d.ts +7 -2
- package/dist/wirings/channel/local/local-channel-runner.js +22 -9
- package/dist/wirings/channel/local/local-eventhub-service.d.ts +2 -2
- package/dist/wirings/channel/log-channels.d.ts +1 -1
- package/dist/wirings/channel/pikku-abstract-channel-handler.d.ts +1 -1
- package/dist/wirings/channel/serverless/index.d.ts +1 -1
- package/dist/wirings/channel/serverless/index.js +1 -1
- package/dist/wirings/channel/serverless/serverless-channel-runner.d.ts +4 -4
- package/dist/wirings/channel/serverless/serverless-channel-runner.js +40 -23
- package/dist/wirings/cli/channel/cli-channel-runner.d.ts +1 -1
- package/dist/wirings/cli/channel/index.d.ts +1 -1
- package/dist/wirings/cli/channel/index.js +1 -1
- package/dist/wirings/cli/cli-runner.d.ts +3 -3
- package/dist/wirings/cli/cli-runner.js +12 -8
- package/dist/wirings/cli/cli.types.d.ts +9 -9
- package/dist/wirings/cli/command-parser.d.ts +1 -1
- package/dist/wirings/cli/define-cli-commands.d.ts +19 -0
- package/dist/wirings/cli/define-cli-commands.js +20 -0
- package/dist/wirings/cli/index.d.ts +2 -3
- package/dist/wirings/cli/index.js +1 -3
- package/dist/wirings/http/http-routes.d.ts +69 -0
- package/dist/wirings/http/http-routes.js +139 -0
- package/dist/wirings/http/http-runner.d.ts +9 -9
- package/dist/wirings/http/http-runner.js +79 -34
- package/dist/wirings/http/http.types.d.ts +77 -41
- package/dist/wirings/http/index.d.ts +5 -4
- package/dist/wirings/http/index.js +4 -3
- package/dist/wirings/http/log-http-routes.d.ts +1 -1
- package/dist/wirings/http/pikku-fetch-http-request.d.ts +1 -1
- package/dist/wirings/http/pikku-fetch-http-response.d.ts +2 -2
- package/dist/wirings/http/pikku-fetch-http-response.js +6 -1
- package/dist/wirings/http/routers/http-router.d.ts +1 -1
- package/dist/wirings/http/routers/path-to-regex.d.ts +2 -2
- package/dist/wirings/mcp/index.d.ts +4 -3
- package/dist/wirings/mcp/index.js +3 -3
- package/dist/wirings/mcp/mcp-endpoint-registry.d.ts +1 -1
- package/dist/wirings/mcp/mcp-runner.d.ts +1 -6
- package/dist/wirings/mcp/mcp-runner.js +28 -40
- package/dist/wirings/mcp/mcp.types.d.ts +5 -5
- package/dist/wirings/node/index.d.ts +2 -0
- package/dist/wirings/node/index.js +1 -0
- package/dist/wirings/node/node.types.d.ts +20 -0
- package/dist/wirings/node/node.types.js +1 -0
- package/dist/wirings/oauth2/index.d.ts +3 -0
- package/dist/wirings/oauth2/index.js +2 -0
- package/dist/wirings/oauth2/oauth2-client.d.ts +47 -0
- package/dist/wirings/oauth2/oauth2-client.js +267 -0
- package/dist/wirings/oauth2/oauth2.types.d.ts +65 -0
- package/dist/wirings/oauth2/oauth2.types.js +4 -0
- package/dist/wirings/oauth2/wire-oauth2-credential.d.ts +20 -0
- package/dist/wirings/oauth2/wire-oauth2-credential.js +21 -0
- package/dist/wirings/queue/index.d.ts +1 -1
- package/dist/wirings/queue/queue-runner.d.ts +1 -5
- package/dist/wirings/queue/queue-runner.js +11 -8
- package/dist/wirings/queue/queue.types.d.ts +5 -5
- package/dist/wirings/queue/register-queue-helper.d.ts +2 -2
- package/dist/wirings/queue/register-queue-helper.js +1 -1
- package/dist/wirings/queue/validate-worker-config.d.ts +1 -1
- package/dist/wirings/rpc/index.d.ts +3 -1
- package/dist/wirings/rpc/index.js +2 -1
- package/dist/wirings/rpc/rpc-runner.d.ts +58 -8
- package/dist/wirings/rpc/rpc-runner.js +177 -31
- package/dist/wirings/rpc/rpc-types.d.ts +20 -4
- package/dist/wirings/rpc/wire-addon.d.ts +10 -0
- package/dist/wirings/rpc/wire-addon.js +9 -0
- package/dist/wirings/scheduler/index.d.ts +2 -2
- package/dist/wirings/scheduler/index.js +1 -2
- package/dist/wirings/scheduler/log-schedulers.d.ts +1 -1
- package/dist/wirings/scheduler/scheduler-runner.d.ts +3 -5
- package/dist/wirings/scheduler/scheduler-runner.js +11 -14
- package/dist/wirings/scheduler/scheduler.types.d.ts +2 -2
- package/dist/wirings/secret/index.d.ts +3 -0
- package/dist/wirings/secret/index.js +2 -0
- package/dist/wirings/secret/secret.types.d.ts +27 -0
- package/dist/wirings/secret/secret.types.js +1 -0
- package/dist/wirings/secret/validate-secret-definitions.d.ts +6 -0
- package/dist/wirings/secret/validate-secret-definitions.js +55 -0
- package/dist/wirings/trigger/index.d.ts +3 -2
- package/dist/wirings/trigger/index.js +2 -2
- package/dist/wirings/trigger/pikku-trigger-service.d.ts +22 -0
- package/dist/wirings/trigger/pikku-trigger-service.js +70 -0
- package/dist/wirings/trigger/trigger-runner.d.ts +18 -9
- package/dist/wirings/trigger/trigger-runner.js +48 -19
- package/dist/wirings/trigger/trigger.types.d.ts +99 -11
- package/dist/wirings/trigger/trigger.types.js +40 -1
- package/dist/wirings/variable/index.d.ts +3 -0
- package/dist/wirings/variable/index.js +2 -0
- package/dist/wirings/variable/validate-variable-definitions.d.ts +6 -0
- package/dist/wirings/variable/validate-variable-definitions.js +45 -0
- package/dist/wirings/variable/variable.types.d.ts +18 -0
- package/dist/wirings/variable/variable.types.js +1 -0
- package/dist/wirings/workflow/dsl/index.d.ts +1 -1
- package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +7 -1
- package/dist/wirings/workflow/dsl/workflow-runner.js +3 -2
- package/dist/wirings/workflow/graph/graph-node.d.ts +1 -6
- package/dist/wirings/workflow/graph/graph-runner.d.ts +5 -31
- package/dist/wirings/workflow/graph/graph-runner.js +384 -296
- package/dist/wirings/workflow/graph/index.d.ts +4 -3
- package/dist/wirings/workflow/graph/index.js +3 -3
- package/dist/wirings/workflow/graph/template.d.ts +15 -0
- package/dist/wirings/workflow/graph/template.js +27 -0
- package/dist/wirings/workflow/graph/wire-workflow-graph.d.ts +15 -0
- package/dist/wirings/workflow/graph/wire-workflow-graph.js +8 -0
- package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +0 -13
- package/dist/wirings/workflow/index.d.ts +6 -6
- package/dist/wirings/workflow/index.js +6 -4
- package/dist/wirings/workflow/pikku-workflow-service.d.ts +29 -19
- package/dist/wirings/workflow/pikku-workflow-service.js +217 -82
- package/dist/wirings/workflow/workflow-helpers.d.ts +36 -0
- package/dist/wirings/workflow/workflow-helpers.js +38 -0
- package/dist/wirings/workflow/workflow.types.d.ts +42 -95
- package/package.json +14 -15
- package/run-tests.sh +4 -1
- package/src/crypto-utils.test.ts +116 -0
- package/src/crypto-utils.ts +99 -0
- package/src/errors/error.test.ts +143 -2
- package/src/errors/errors.ts +27 -0
- package/src/errors/index.ts +1 -1
- package/src/factory-functions.test.ts +42 -2
- package/src/function/function-runner.test.ts +6 -13
- package/src/function/function-runner.ts +161 -53
- package/src/function/functions.types.ts +63 -132
- package/src/function/index.ts +5 -2
- package/src/handle-error.test.ts +361 -0
- package/src/handle-error.ts +6 -14
- package/src/index.ts +97 -30
- package/src/internal.ts +6 -0
- package/src/middleware/auth-apikey.test.ts +16 -13
- package/src/middleware/auth-apikey.ts +3 -3
- package/src/middleware/auth-bearer.test.ts +18 -15
- package/src/middleware/auth-bearer.ts +27 -32
- package/src/middleware/auth-cookie.test.ts +17 -14
- package/src/middleware/auth-cookie.ts +9 -13
- package/src/middleware/cors.test.ts +424 -0
- package/src/middleware/cors.ts +104 -0
- package/src/middleware/index.ts +5 -3
- package/src/middleware/remote-auth.test.ts +488 -0
- package/src/middleware/remote-auth.ts +68 -0
- package/src/middleware-runner.test.ts +123 -1
- package/src/middleware-runner.ts +13 -13
- package/src/permissions.test.ts +83 -9
- package/src/permissions.ts +17 -19
- package/src/pikku-state.test.ts +224 -0
- package/src/pikku-state.ts +59 -35
- package/src/run-tests-script.test.ts +49 -0
- package/src/schema.test.ts +198 -6
- package/src/schema.ts +28 -21
- package/src/services/ai-agent-runner-service.ts +41 -0
- package/src/services/ai-run-state-service.ts +20 -0
- package/src/services/ai-storage-service.ts +39 -0
- package/src/services/content-service.ts +7 -0
- package/src/services/deployment-service.ts +22 -0
- package/src/services/gopass-secrets.ts +98 -0
- package/src/services/in-memory-ai-run-state-service.ts +73 -0
- package/src/services/in-memory-trigger-service.ts +64 -0
- package/src/services/in-memory-workflow-service.test.ts +351 -0
- package/src/services/in-memory-workflow-service.ts +395 -0
- package/src/services/index.ts +50 -14
- package/src/services/local-content.ts +9 -3
- package/src/services/local-secrets.test.ts +80 -0
- package/src/services/local-secrets.ts +53 -2
- package/src/services/local-variables.test.ts +61 -0
- package/src/services/local-variables.ts +23 -1
- package/src/services/logger-console.test.ts +118 -0
- package/src/services/logger-console.ts +2 -1
- package/src/services/scheduler-service.ts +11 -1
- package/src/services/schema-service.ts +7 -0
- package/src/services/scoped-secret-service.test.ts +74 -0
- package/src/services/scoped-secret-service.ts +41 -0
- package/src/services/secret-service.ts +25 -4
- package/src/services/trigger-service.ts +17 -0
- package/src/services/typed-secret-service.test.ts +93 -0
- package/src/services/typed-secret-service.ts +70 -0
- package/src/services/typed-variables-service.test.ts +73 -0
- package/src/services/typed-variables-service.ts +81 -0
- package/src/services/user-session-service.test.ts +113 -0
- package/src/services/user-session-service.ts +25 -2
- package/src/services/variables-service.ts +5 -0
- package/src/services/workflow-service.ts +23 -13
- package/src/time-utils.test.ts +1 -1
- package/src/types/core.types.ts +95 -24
- package/src/types/state.types.ts +56 -73
- package/src/utils.test.ts +350 -0
- package/src/utils.ts +33 -18
- package/src/version.test.ts +80 -0
- package/src/version.ts +25 -0
- package/src/wirings/ai-agent/ai-agent-assistant-ui.test.ts +363 -0
- package/src/wirings/ai-agent/ai-agent-assistant-ui.ts +214 -0
- package/src/wirings/ai-agent/ai-agent-helpers.test.ts +152 -0
- package/src/wirings/ai-agent/ai-agent-helpers.ts +76 -0
- package/src/wirings/ai-agent/ai-agent-memory.ts +300 -0
- package/src/wirings/ai-agent/ai-agent-model-config.test.ts +115 -0
- package/src/wirings/ai-agent/ai-agent-model-config.ts +43 -0
- package/src/wirings/ai-agent/ai-agent-prepare.ts +504 -0
- package/src/wirings/ai-agent/ai-agent-registry.test.ts +37 -0
- package/src/wirings/ai-agent/ai-agent-registry.ts +82 -0
- package/src/wirings/ai-agent/ai-agent-runner.test.ts +317 -0
- package/src/wirings/ai-agent/ai-agent-runner.ts +251 -0
- package/src/wirings/ai-agent/ai-agent-stream.test.ts +652 -0
- package/src/wirings/ai-agent/ai-agent-stream.ts +1049 -0
- package/src/wirings/ai-agent/ai-agent.types.ts +328 -0
- package/src/wirings/ai-agent/index.ts +39 -0
- package/src/wirings/channel/channel-common.ts +33 -20
- package/src/wirings/channel/channel-handler.ts +26 -9
- package/src/wirings/channel/channel-middleware-runner.ts +119 -0
- package/src/wirings/channel/channel-runner.ts +15 -16
- package/src/wirings/channel/channel-store.ts +1 -1
- package/src/wirings/channel/channel.types.ts +21 -9
- package/src/wirings/channel/define-channel-routes.ts +25 -0
- package/src/wirings/channel/index.ts +23 -8
- package/src/wirings/channel/local/index.ts +3 -3
- package/src/wirings/channel/local/local-channel-runner.test.ts +57 -7
- package/src/wirings/channel/local/local-channel-runner.ts +40 -19
- package/src/wirings/channel/local/local-eventhub-service.test.ts +2 -2
- package/src/wirings/channel/local/local-eventhub-service.ts +2 -2
- package/src/wirings/channel/log-channels.ts +1 -1
- package/src/wirings/channel/pikku-abstract-channel-handler.ts +1 -1
- package/src/wirings/channel/serverless/index.ts +5 -1
- package/src/wirings/channel/serverless/serverless-channel-runner.ts +57 -36
- package/src/wirings/cli/channel/cli-channel-runner.ts +1 -1
- package/src/wirings/cli/channel/index.ts +1 -1
- package/src/wirings/cli/cli-runner.test.ts +10 -10
- package/src/wirings/cli/cli-runner.ts +28 -14
- package/src/wirings/cli/cli.types.ts +14 -14
- package/src/wirings/cli/command-parser.test.ts +9 -9
- package/src/wirings/cli/command-parser.ts +1 -1
- package/src/wirings/cli/define-cli-commands.ts +24 -0
- package/src/wirings/cli/index.ts +10 -4
- package/src/wirings/http/http-routes.test.ts +322 -0
- package/src/wirings/http/http-routes.ts +198 -0
- package/src/wirings/http/http-runner.test.ts +12 -20
- package/src/wirings/http/http-runner.ts +101 -51
- package/src/wirings/http/http.types.ts +119 -48
- package/src/wirings/http/index.ts +16 -4
- package/src/wirings/http/log-http-routes.ts +1 -1
- package/src/wirings/http/pikku-fetch-http-request.ts +1 -1
- package/src/wirings/http/pikku-fetch-http-response.ts +12 -5
- package/src/wirings/http/routers/http-router.ts +1 -1
- package/src/wirings/http/routers/path-to-regex.test.ts +1 -1
- package/src/wirings/http/routers/path-to-regex.ts +4 -3
- package/src/wirings/mcp/index.ts +27 -3
- package/src/wirings/mcp/mcp-endpoint-registry.test.ts +3 -3
- package/src/wirings/mcp/mcp-endpoint-registry.ts +5 -1
- package/src/wirings/mcp/mcp-runner.ts +48 -65
- package/src/wirings/mcp/mcp.types.ts +5 -5
- package/src/wirings/node/index.ts +2 -0
- package/src/wirings/node/node.types.ts +23 -0
- package/src/wirings/oauth2/index.ts +3 -0
- package/src/wirings/oauth2/oauth2-client.test.ts +929 -0
- package/src/wirings/oauth2/oauth2-client.ts +335 -0
- package/src/wirings/oauth2/oauth2.types.ts +69 -0
- package/src/wirings/oauth2/wire-oauth2-credential.ts +23 -0
- package/src/wirings/queue/index.ts +13 -2
- package/src/wirings/queue/queue-runner.test.ts +142 -73
- package/src/wirings/queue/queue-runner.ts +18 -14
- package/src/wirings/queue/queue.types.ts +5 -5
- package/src/wirings/queue/register-queue-helper.ts +3 -5
- package/src/wirings/queue/validate-worker-config.test.ts +108 -0
- package/src/wirings/queue/validate-worker-config.ts +4 -1
- package/src/wirings/rpc/index.ts +3 -1
- package/src/wirings/rpc/rpc-runner.ts +254 -41
- package/src/wirings/rpc/rpc-types.ts +28 -4
- package/src/wirings/rpc/wire-addon.ts +20 -0
- package/src/wirings/scheduler/index.ts +6 -4
- package/src/wirings/scheduler/log-schedulers.ts +1 -1
- package/src/wirings/scheduler/scheduler-runner.test.ts +78 -45
- package/src/wirings/scheduler/scheduler-runner.ts +20 -27
- package/src/wirings/scheduler/scheduler.types.ts +2 -2
- package/src/wirings/secret/index.ts +9 -0
- package/src/wirings/secret/secret.types.ts +32 -0
- package/src/wirings/secret/validate-secret-definitions.test.ts +140 -0
- package/src/wirings/secret/validate-secret-definitions.ts +82 -0
- package/src/wirings/trigger/index.ts +10 -2
- package/src/wirings/trigger/pikku-trigger-service.ts +112 -0
- package/src/wirings/trigger/trigger-runner.test.ts +79 -0
- package/src/wirings/trigger/trigger-runner.ts +80 -41
- package/src/wirings/trigger/trigger.types.ts +144 -22
- package/src/wirings/variable/index.ts +8 -0
- package/src/wirings/variable/validate-variable-definitions.test.ts +91 -0
- package/src/wirings/variable/validate-variable-definitions.ts +69 -0
- package/src/wirings/variable/variable.types.ts +22 -0
- package/src/wirings/workflow/dsl/index.ts +1 -0
- package/src/wirings/workflow/dsl/workflow-dsl.types.ts +9 -1
- package/src/wirings/workflow/dsl/workflow-runner.ts +4 -3
- package/src/wirings/workflow/graph/graph-node.ts +1 -6
- package/src/wirings/workflow/graph/graph-runner.test.ts +487 -0
- package/src/wirings/workflow/graph/graph-runner.ts +496 -374
- package/src/wirings/workflow/graph/index.ts +14 -3
- package/src/wirings/workflow/graph/template.test.ts +49 -0
- package/src/wirings/workflow/graph/template.ts +42 -0
- package/src/wirings/workflow/graph/wire-workflow-graph.ts +29 -0
- package/src/wirings/workflow/graph/workflow-graph.types.ts +0 -22
- package/src/wirings/workflow/index.ts +21 -10
- package/src/wirings/workflow/pikku-workflow-service.test.ts +200 -0
- package/src/wirings/workflow/pikku-workflow-service.ts +308 -105
- package/src/wirings/workflow/workflow-helpers.test.ts +129 -0
- package/src/wirings/workflow/workflow-helpers.ts +79 -0
- package/src/wirings/workflow/workflow.types.ts +47 -92
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/wirings/forge-node/forge-node.types.d.ts +0 -120
- package/dist/wirings/forge-node/forge-node.types.js +0 -38
- package/dist/wirings/forge-node/index.d.ts +0 -1
- package/dist/wirings/forge-node/index.js +0 -1
- package/dist/wirings/workflow/wire-workflow.d.ts +0 -42
- package/dist/wirings/workflow/wire-workflow.js +0 -53
- package/dist/wirings/workflow/workflow-utils.d.ts +0 -23
- package/dist/wirings/workflow/workflow-utils.js +0 -66
- package/src/wirings/forge-node/forge-node.types.ts +0 -135
- package/src/wirings/forge-node/index.ts +0 -1
- package/src/wirings/workflow/wire-workflow.ts +0 -94
- package/src/wirings/workflow/workflow-utils.ts +0 -120
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { VariablesService } from './variables-service.js'
|
|
2
|
+
|
|
3
|
+
export interface VariableStatus {
|
|
4
|
+
variableId: string
|
|
5
|
+
name: string
|
|
6
|
+
displayName: string
|
|
7
|
+
isConfigured: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type VariableMeta = {
|
|
11
|
+
name: string
|
|
12
|
+
displayName: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class TypedVariablesService<TMap = Record<string, unknown>>
|
|
16
|
+
implements VariablesService
|
|
17
|
+
{
|
|
18
|
+
constructor(
|
|
19
|
+
private variables: VariablesService,
|
|
20
|
+
private variablesMeta: Record<string, VariableMeta>
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
get(
|
|
24
|
+
name: keyof TMap & string
|
|
25
|
+
): Promise<string | undefined> | string | undefined
|
|
26
|
+
get(name: string): Promise<string | undefined> | string | undefined
|
|
27
|
+
get(name: string): Promise<string | undefined> | string | undefined {
|
|
28
|
+
return this.variables.get(name)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getJSON<K extends keyof TMap & string>(
|
|
32
|
+
name: K
|
|
33
|
+
): Promise<TMap[K] | undefined> | TMap[K] | undefined
|
|
34
|
+
getJSON<T = unknown>(name: string): Promise<T | undefined> | T | undefined
|
|
35
|
+
getJSON(name: string): Promise<unknown> | unknown {
|
|
36
|
+
return this.variables.getJSON(name)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getAll():
|
|
40
|
+
| Promise<Record<string, string | undefined>>
|
|
41
|
+
| Record<string, string | undefined> {
|
|
42
|
+
return this.variables.getAll()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set(name: string, value: string): Promise<void> | void {
|
|
46
|
+
return this.variables.set(name, value)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setJSON(name: string, value: unknown): Promise<void> | void {
|
|
50
|
+
return this.variables.setJSON(name, value)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
has(name: string): Promise<boolean> | boolean {
|
|
54
|
+
return this.variables.has(name)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
delete(name: string): Promise<void> | void {
|
|
58
|
+
return this.variables.delete(name)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getAllStatus(): Promise<VariableStatus[]> {
|
|
62
|
+
const results: VariableStatus[] = []
|
|
63
|
+
const all = await this.variables.getAll()
|
|
64
|
+
|
|
65
|
+
for (const [variableId, meta] of Object.entries(this.variablesMeta)) {
|
|
66
|
+
results.push({
|
|
67
|
+
variableId,
|
|
68
|
+
name: meta.name,
|
|
69
|
+
displayName: meta.displayName,
|
|
70
|
+
isConfigured: all[variableId] !== undefined,
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return results
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async getMissing(): Promise<VariableStatus[]> {
|
|
78
|
+
const all = await this.getAllStatus()
|
|
79
|
+
return all.filter((v) => !v.isConfigured)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { describe, test } from 'node:test'
|
|
2
|
+
import assert from 'node:assert'
|
|
3
|
+
import {
|
|
4
|
+
PikkuSessionService,
|
|
5
|
+
createMiddlewareSessionWireProps,
|
|
6
|
+
createFunctionSessionWireProps,
|
|
7
|
+
} from './user-session-service.js'
|
|
8
|
+
|
|
9
|
+
describe('PikkuSessionService', () => {
|
|
10
|
+
test('should set and get session', () => {
|
|
11
|
+
const service = new PikkuSessionService()
|
|
12
|
+
service.setInitial({ userId: 'user-1' })
|
|
13
|
+
const session = service.get()
|
|
14
|
+
assert.deepStrictEqual(session, { userId: 'user-1' })
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test('should return undefined when no session set', () => {
|
|
18
|
+
const service = new PikkuSessionService()
|
|
19
|
+
assert.strictEqual(service.get(), undefined)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('should mark sessionChanged when set is called', () => {
|
|
23
|
+
const service = new PikkuSessionService()
|
|
24
|
+
assert.strictEqual(service.sessionChanged, false)
|
|
25
|
+
service.set({ userId: 'user-1' })
|
|
26
|
+
assert.strictEqual(service.sessionChanged, true)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('should clear session', () => {
|
|
30
|
+
const service = new PikkuSessionService()
|
|
31
|
+
service.setInitial({ userId: 'user-1' })
|
|
32
|
+
service.clear()
|
|
33
|
+
assert.strictEqual(service.get(), undefined)
|
|
34
|
+
assert.strictEqual(service.sessionChanged, true)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('should freeze initial session', () => {
|
|
38
|
+
const service = new PikkuSessionService()
|
|
39
|
+
service.setInitial({ userId: 'user-1' })
|
|
40
|
+
const frozen = service.freezeInitial()
|
|
41
|
+
assert.deepStrictEqual(frozen, { userId: 'user-1' })
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('should only freeze initial once', () => {
|
|
45
|
+
const service = new PikkuSessionService()
|
|
46
|
+
service.setInitial({ userId: 'user-1' })
|
|
47
|
+
service.freezeInitial()
|
|
48
|
+
service.set({ userId: 'user-2' })
|
|
49
|
+
const frozen2 = service.freezeInitial()
|
|
50
|
+
assert.deepStrictEqual(frozen2, { userId: 'user-1' })
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('should throw when channelStore provided without channelId', () => {
|
|
54
|
+
assert.throws(() => new PikkuSessionService({} as any), {
|
|
55
|
+
message: 'Channel ID is required when using channel store',
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('should use channelStore when provided', async () => {
|
|
60
|
+
let storedSession: any
|
|
61
|
+
const store = {
|
|
62
|
+
setUserSession: (id: string, session: any) => {
|
|
63
|
+
storedSession = session
|
|
64
|
+
},
|
|
65
|
+
getChannelAndSession: (id: string) => ({ session: { userId: 'stored' } }),
|
|
66
|
+
}
|
|
67
|
+
const service = new PikkuSessionService(store as any, 'ch-1')
|
|
68
|
+
service.set({ userId: 'new' })
|
|
69
|
+
assert.deepStrictEqual(storedSession, { userId: 'new' })
|
|
70
|
+
|
|
71
|
+
const session = service.get()
|
|
72
|
+
assert.deepStrictEqual(session, { userId: 'stored' })
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('createMiddlewareSessionWireProps', () => {
|
|
77
|
+
test('should return session wire props', () => {
|
|
78
|
+
const service = new PikkuSessionService()
|
|
79
|
+
service.setInitial({ userId: 'user-1' })
|
|
80
|
+
const props = createMiddlewareSessionWireProps(service)
|
|
81
|
+
assert.ok('session' in props)
|
|
82
|
+
assert.ok('setSession' in props)
|
|
83
|
+
assert.ok('getSession' in props)
|
|
84
|
+
assert.ok('hasSessionChanged' in props)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('setSession should call setInitial', () => {
|
|
88
|
+
const service = new PikkuSessionService()
|
|
89
|
+
const props = createMiddlewareSessionWireProps(service)
|
|
90
|
+
props.setSession({ userId: 'user-2' })
|
|
91
|
+
assert.deepStrictEqual(service.get(), { userId: 'user-2' })
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe('createFunctionSessionWireProps', () => {
|
|
96
|
+
test('should return function session wire props', () => {
|
|
97
|
+
const service = new PikkuSessionService()
|
|
98
|
+
service.setInitial({ userId: 'user-1' })
|
|
99
|
+
const props = createFunctionSessionWireProps(service)
|
|
100
|
+
assert.ok('session' in props)
|
|
101
|
+
assert.ok('setSession' in props)
|
|
102
|
+
assert.ok('clearSession' in props)
|
|
103
|
+
assert.ok('getSession' in props)
|
|
104
|
+
assert.ok('hasSessionChanged' in props)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('session should be frozen initial', () => {
|
|
108
|
+
const service = new PikkuSessionService()
|
|
109
|
+
service.setInitial({ userId: 'user-1' })
|
|
110
|
+
const props = createFunctionSessionWireProps(service)
|
|
111
|
+
assert.deepStrictEqual(props.session, { userId: 'user-1' })
|
|
112
|
+
})
|
|
113
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChannelStore } from '../wirings/channel/channel-store.js'
|
|
2
|
-
import { CoreUserSession } from '../types/core.types.js'
|
|
1
|
+
import type { ChannelStore } from '../wirings/channel/channel-store.js'
|
|
2
|
+
import type { CoreUserSession } from '../types/core.types.js'
|
|
3
3
|
|
|
4
4
|
export interface SessionService<UserSession extends CoreUserSession> {
|
|
5
5
|
sessionChanged: boolean
|
|
@@ -61,3 +61,26 @@ export class PikkuSessionService<UserSession extends CoreUserSession>
|
|
|
61
61
|
return this.session
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
export function createMiddlewareSessionWireProps<
|
|
66
|
+
UserSession extends CoreUserSession,
|
|
67
|
+
>(session: SessionService<UserSession>) {
|
|
68
|
+
return {
|
|
69
|
+
session: session.get() as UserSession | undefined,
|
|
70
|
+
setSession: (s: UserSession) => session.setInitial(s),
|
|
71
|
+
getSession: () => session.get(),
|
|
72
|
+
hasSessionChanged: () => session.sessionChanged,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function createFunctionSessionWireProps<
|
|
77
|
+
UserSession extends CoreUserSession,
|
|
78
|
+
>(session: SessionService<UserSession>) {
|
|
79
|
+
return {
|
|
80
|
+
session: session.freezeInitial(),
|
|
81
|
+
setSession: (s: UserSession) => session.set(s),
|
|
82
|
+
clearSession: () => session.clear(),
|
|
83
|
+
getSession: () => session.get(),
|
|
84
|
+
hasSessionChanged: () => session.sessionChanged,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export interface VariablesService {
|
|
2
2
|
get: (name: string) => Promise<string | undefined> | string | undefined
|
|
3
|
+
getJSON: <T = unknown>(name: string) => Promise<T | undefined> | T | undefined
|
|
3
4
|
getAll: () =>
|
|
4
5
|
| Promise<Record<string, string | undefined>>
|
|
5
6
|
| Record<string, string | undefined>
|
|
7
|
+
set: (name: string, value: string) => Promise<void> | void
|
|
8
|
+
setJSON: (name: string, value: unknown) => Promise<void> | void
|
|
9
|
+
has: (name: string) => Promise<boolean> | boolean
|
|
10
|
+
delete: (name: string) => Promise<void> | void
|
|
6
11
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
CoreSingletonServices,
|
|
4
|
-
CreateWireServices,
|
|
5
|
-
CoreConfig,
|
|
6
|
-
} from '../types/core.types.js'
|
|
7
|
-
import {
|
|
1
|
+
import type { SerializedError } from '../types/core.types.js'
|
|
2
|
+
import type {
|
|
8
3
|
WorkflowRun,
|
|
4
|
+
WorkflowRunWire,
|
|
9
5
|
StepState,
|
|
10
6
|
WorkflowStatus,
|
|
11
7
|
} from '../wirings/workflow/workflow.types.js'
|
|
@@ -16,7 +12,13 @@ import {
|
|
|
16
12
|
*/
|
|
17
13
|
export interface WorkflowService {
|
|
18
14
|
// Run-level state operations
|
|
19
|
-
createRun(
|
|
15
|
+
createRun(
|
|
16
|
+
workflowName: string,
|
|
17
|
+
input: any,
|
|
18
|
+
inline: boolean,
|
|
19
|
+
graphHash: string,
|
|
20
|
+
wire: WorkflowRunWire
|
|
21
|
+
): Promise<string>
|
|
20
22
|
getRun(id: string): Promise<WorkflowRun | null>
|
|
21
23
|
getRunHistory(runId: string): Promise<Array<StepState & { stepName: string }>>
|
|
22
24
|
updateRunStatus(
|
|
@@ -30,14 +32,10 @@ export interface WorkflowService {
|
|
|
30
32
|
|
|
31
33
|
// Orchestration operations
|
|
32
34
|
resumeWorkflow(runId: string): Promise<void>
|
|
33
|
-
setServices(
|
|
34
|
-
singletonServices: CoreSingletonServices,
|
|
35
|
-
createWireServices: CreateWireServices,
|
|
36
|
-
config: CoreConfig
|
|
37
|
-
): void
|
|
38
35
|
startWorkflow<I>(
|
|
39
36
|
name: string,
|
|
40
37
|
input: I,
|
|
38
|
+
wire: WorkflowRunWire,
|
|
41
39
|
rpcService: any,
|
|
42
40
|
options?: { inline?: boolean; startNode?: string }
|
|
43
41
|
): Promise<{ runId: string }>
|
|
@@ -71,4 +69,16 @@ export interface WorkflowService {
|
|
|
71
69
|
data: any,
|
|
72
70
|
rpcService: any
|
|
73
71
|
): Promise<void>
|
|
72
|
+
|
|
73
|
+
// Version operations
|
|
74
|
+
upsertWorkflowVersion(
|
|
75
|
+
name: string,
|
|
76
|
+
graphHash: string,
|
|
77
|
+
graph: any,
|
|
78
|
+
source: string
|
|
79
|
+
): Promise<void>
|
|
80
|
+
getWorkflowVersion(
|
|
81
|
+
name: string,
|
|
82
|
+
graphHash: string
|
|
83
|
+
): Promise<{ graph: any; source: string } | null>
|
|
74
84
|
}
|
package/src/time-utils.test.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { describe, test } from 'node:test'
|
|
2
2
|
import assert from 'node:assert/strict'
|
|
3
3
|
|
|
4
|
+
import type { RelativeTimeInput } from './time-utils'
|
|
4
5
|
import {
|
|
5
6
|
getRelativeTimeOffset,
|
|
6
7
|
getRelativeTimeOffsetFromNow,
|
|
7
|
-
RelativeTimeInput,
|
|
8
8
|
} from './time-utils'
|
|
9
9
|
|
|
10
10
|
const approxEqual = (a: number, b: number, delta: number = 10): boolean =>
|
package/src/types/core.types.ts
CHANGED
|
@@ -1,41 +1,58 @@
|
|
|
1
1
|
import type { Logger, LogLevel } from '../services/logger.js'
|
|
2
|
-
import { VariablesService } from '../services/variables-service.js'
|
|
3
|
-
import { SecretService } from '../services/secret-service.js'
|
|
4
|
-
import { SchemaService } from '../services/schema-service.js'
|
|
5
|
-
import { JWTService } from '../services/jwt-service.js'
|
|
6
|
-
import { PikkuHTTP } from '../wirings/http/http.types.js'
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
2
|
+
import type { VariablesService } from '../services/variables-service.js'
|
|
3
|
+
import type { SecretService } from '../services/secret-service.js'
|
|
4
|
+
import type { SchemaService } from '../services/schema-service.js'
|
|
5
|
+
import type { JWTService } from '../services/jwt-service.js'
|
|
6
|
+
import type { PikkuHTTP } from '../wirings/http/http.types.js'
|
|
7
|
+
import type {
|
|
8
|
+
PikkuChannel,
|
|
9
|
+
CorePikkuChannelMiddleware,
|
|
10
|
+
CorePikkuChannelMiddlewareFactory,
|
|
11
|
+
} from '../wirings/channel/channel.types.js'
|
|
12
|
+
import type { PikkuRPC } from '../wirings/rpc/rpc-types.js'
|
|
13
|
+
import type { PikkuMCP } from '../wirings/mcp/mcp.types.js'
|
|
14
|
+
import type { PikkuScheduledTask } from '../wirings/scheduler/scheduler.types.js'
|
|
15
|
+
import type { PikkuQueue, QueueService } from '../wirings/queue/queue.types.js'
|
|
16
|
+
import type { PikkuCLI } from '../wirings/cli/cli.types.js'
|
|
17
|
+
import type {
|
|
15
18
|
PikkuWorkflowWire,
|
|
16
19
|
WorkflowService,
|
|
17
20
|
WorkflowServiceConfig,
|
|
18
21
|
WorkflowStepWire,
|
|
19
22
|
} from '../wirings/workflow/workflow.types.js'
|
|
20
23
|
import type { PikkuGraphWire } from '../wirings/workflow/graph/workflow-graph.types.js'
|
|
21
|
-
import { PikkuTrigger } from '../wirings/trigger/trigger.types.js'
|
|
22
|
-
import { SchedulerService } from '../services/scheduler-service.js'
|
|
24
|
+
import type { PikkuTrigger } from '../wirings/trigger/trigger.types.js'
|
|
25
|
+
import type { SchedulerService } from '../services/scheduler-service.js'
|
|
26
|
+
import type { DeploymentService } from '../services/deployment-service.js'
|
|
27
|
+
import type { AIStorageService } from '../services/ai-storage-service.js'
|
|
28
|
+
|
|
29
|
+
import type { ContentService } from '../services/content-service.js'
|
|
30
|
+
import type { AIAgentRunnerService } from '../services/ai-agent-runner-service.js'
|
|
31
|
+
import type { AIRunStateService } from '../services/ai-run-state-service.js'
|
|
32
|
+
import type { PikkuAIMiddlewareHooks } from '../wirings/ai-agent/ai-agent.types.js'
|
|
23
33
|
|
|
24
34
|
export type PikkuWiringTypes =
|
|
25
35
|
| 'http'
|
|
26
36
|
| 'scheduler'
|
|
37
|
+
| 'trigger'
|
|
27
38
|
| 'channel'
|
|
28
39
|
| 'rpc'
|
|
29
40
|
| 'queue'
|
|
30
41
|
| 'mcp'
|
|
31
42
|
| 'cli'
|
|
32
43
|
| 'workflow'
|
|
44
|
+
| 'agent'
|
|
33
45
|
|
|
34
46
|
export interface FunctionServicesMeta {
|
|
35
47
|
optimized: boolean
|
|
36
48
|
services: string[]
|
|
37
49
|
}
|
|
38
50
|
|
|
51
|
+
export interface FunctionWiresMeta {
|
|
52
|
+
optimized: boolean
|
|
53
|
+
wires: string[]
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
/**
|
|
40
57
|
* Metadata for middleware at any level
|
|
41
58
|
* - type: 'http' = HTTP route middleware group (references httpGroup in pikkuState)
|
|
@@ -79,19 +96,29 @@ export type PermissionMetadata =
|
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
export type FunctionRuntimeMeta = {
|
|
82
|
-
|
|
99
|
+
pikkuFuncId: string
|
|
83
100
|
inputSchemaName: string | null
|
|
84
101
|
outputSchemaName: string | null
|
|
85
102
|
expose?: boolean
|
|
86
|
-
|
|
103
|
+
remote?: boolean
|
|
104
|
+
mcp?: boolean
|
|
105
|
+
readonly?: boolean
|
|
106
|
+
sessionless?: boolean
|
|
107
|
+
version?: number
|
|
108
|
+
requiresApproval?: boolean
|
|
109
|
+
contractHash?: string
|
|
110
|
+
inputHash?: string
|
|
111
|
+
outputHash?: string
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
export type FunctionMeta = FunctionRuntimeMeta &
|
|
90
115
|
Partial<
|
|
91
116
|
{
|
|
92
117
|
name: string
|
|
118
|
+
functionType: 'user' | 'inline' | 'helper'
|
|
119
|
+
funcWrapper: string
|
|
93
120
|
services: FunctionServicesMeta
|
|
94
|
-
|
|
121
|
+
wires: FunctionWiresMeta
|
|
95
122
|
inputs: string[] | null
|
|
96
123
|
outputs: string[] | null
|
|
97
124
|
middleware: MiddlewareMetadata[]
|
|
@@ -180,6 +207,17 @@ export interface CoreSingletonServices<Config extends CoreConfig = CoreConfig> {
|
|
|
180
207
|
queueService?: QueueService
|
|
181
208
|
/** The scheduler service */
|
|
182
209
|
schedulerService?: SchedulerService
|
|
210
|
+
/** The deployment service for service discovery */
|
|
211
|
+
deploymentService?: DeploymentService
|
|
212
|
+
/** AI agent storage service (threads, messages, working memory) */
|
|
213
|
+
aiStorage?: AIStorageService
|
|
214
|
+
|
|
215
|
+
/** Content service for file storage and retrieval */
|
|
216
|
+
content?: ContentService
|
|
217
|
+
/** AI agent runner service (model calls + tool loop) */
|
|
218
|
+
aiAgentRunner?: AIAgentRunnerService
|
|
219
|
+
/** AI run state service (run lifecycle + approval persistence) */
|
|
220
|
+
aiRunState?: AIRunStateService
|
|
183
221
|
}
|
|
184
222
|
|
|
185
223
|
/**
|
|
@@ -196,6 +234,8 @@ export type PikkuWire<
|
|
|
196
234
|
TypedWorkflow extends PikkuWorkflowWire | never = PikkuWorkflowWire,
|
|
197
235
|
TriggerOutput = unknown,
|
|
198
236
|
> = Partial<{
|
|
237
|
+
wireType: PikkuWiringTypes
|
|
238
|
+
wireId: string
|
|
199
239
|
http: PikkuHTTP<In>
|
|
200
240
|
mcp: PikkuMCP<MCPTools>
|
|
201
241
|
rpc: TypedRPC
|
|
@@ -209,10 +249,17 @@ export type PikkuWire<
|
|
|
209
249
|
workflowStep: WorkflowStepWire
|
|
210
250
|
graph: PikkuGraphWire
|
|
211
251
|
trigger: PikkuTrigger<TriggerOutput>
|
|
212
|
-
|
|
252
|
+
session: HasInitialSession extends true
|
|
213
253
|
? UserSession
|
|
214
254
|
: UserSession | undefined
|
|
215
|
-
session
|
|
255
|
+
/** Update and persist the current session */
|
|
256
|
+
setSession: (session: CoreUserSession) => Promise<void> | void
|
|
257
|
+
/** Clear and persist the current session */
|
|
258
|
+
clearSession: () => Promise<void> | void
|
|
259
|
+
/** Fetch the latest session (may read from backing store) */
|
|
260
|
+
getSession: () => Promise<UserSession> | UserSession | undefined
|
|
261
|
+
/** Whether the session was modified during this run */
|
|
262
|
+
hasSessionChanged: () => boolean
|
|
216
263
|
}>
|
|
217
264
|
|
|
218
265
|
/**
|
|
@@ -239,8 +286,8 @@ export type CorePikkuMiddlewareConfig<
|
|
|
239
286
|
> = {
|
|
240
287
|
/** The middleware function */
|
|
241
288
|
func: CorePikkuMiddleware<SingletonServices, UserSession>
|
|
242
|
-
/** Optional human-readable
|
|
243
|
-
|
|
289
|
+
/** Optional human-readable name for the middleware */
|
|
290
|
+
name?: string
|
|
244
291
|
/** Optional description of what the middleware does */
|
|
245
292
|
description?: string
|
|
246
293
|
}
|
|
@@ -283,7 +330,7 @@ export type CorePikkuMiddlewareGroup<
|
|
|
283
330
|
*
|
|
284
331
|
* // Configuration object syntax with metadata
|
|
285
332
|
* export const logMiddleware = pikkuMiddleware({
|
|
286
|
-
*
|
|
333
|
+
* name: 'Request Logger',
|
|
287
334
|
* description: 'Logs request information',
|
|
288
335
|
* func: async ({ logger }, next) => {
|
|
289
336
|
* logger.info('Request started')
|
|
@@ -326,6 +373,30 @@ export const pikkuMiddlewareFactory = <In = any>(
|
|
|
326
373
|
return factory
|
|
327
374
|
}
|
|
328
375
|
|
|
376
|
+
export const pikkuChannelMiddleware = <
|
|
377
|
+
SingletonServices extends CoreSingletonServices = CoreSingletonServices,
|
|
378
|
+
Event = unknown,
|
|
379
|
+
>(
|
|
380
|
+
middleware: CorePikkuChannelMiddleware<SingletonServices, Event>
|
|
381
|
+
): CorePikkuChannelMiddleware<SingletonServices, Event> => {
|
|
382
|
+
return middleware
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export const pikkuChannelMiddlewareFactory = <In = any>(
|
|
386
|
+
factory: CorePikkuChannelMiddlewareFactory<In>
|
|
387
|
+
): CorePikkuChannelMiddlewareFactory<In> => {
|
|
388
|
+
return factory
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export type { PikkuAIMiddlewareHooks } from '../wirings/ai-agent/ai-agent.types.js'
|
|
392
|
+
|
|
393
|
+
export const pikkuAIMiddleware = <
|
|
394
|
+
State extends Record<string, unknown> = Record<string, unknown>,
|
|
395
|
+
SingletonServices extends CoreSingletonServices = CoreSingletonServices,
|
|
396
|
+
>(
|
|
397
|
+
hooks: PikkuAIMiddlewareHooks<State, SingletonServices>
|
|
398
|
+
): PikkuAIMiddlewareHooks<State, SingletonServices> => hooks
|
|
399
|
+
|
|
329
400
|
/**
|
|
330
401
|
* Represents the core services used by Pikku, including singleton services.
|
|
331
402
|
*/
|
|
@@ -373,7 +444,7 @@ export type CreateConfig<
|
|
|
373
444
|
* Represents the documentation for a route, including summary, description, tags, and errors.
|
|
374
445
|
*/
|
|
375
446
|
export type CommonWireMeta = {
|
|
376
|
-
|
|
447
|
+
pikkuFuncId: string
|
|
377
448
|
|
|
378
449
|
title?: string
|
|
379
450
|
tags?: string[]
|