@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SerializeOptions } from 'cookie';
|
|
2
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
3
|
import type { PikkuError } from '../../errors/error-handler.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { CorePikkuMiddleware, CommonWireMeta } from '../../types/core.types.js';
|
|
4
5
|
import type { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission, CorePermissionGroup, CorePikkuFunctionConfig } from '../../function/functions.types.js';
|
|
5
6
|
type ExtractHTTPWiringParams<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param | ExtractHTTPWiringParams<`/${Rest}`> : S extends `${string}:${infer Param}` ? Param : never;
|
|
6
7
|
export type AssertHTTPWiringParams<In, HTTPWiring extends string> = ExtractHTTPWiringParams<HTTPWiring> extends keyof In ? unknown : [
|
|
@@ -17,30 +18,41 @@ export type RunHTTPWiringOptions = Partial<{
|
|
|
17
18
|
bubbleErrors: boolean;
|
|
18
19
|
generateRequestId: () => string;
|
|
19
20
|
}>;
|
|
20
|
-
export type RunHTTPWiringParams = {
|
|
21
|
-
singletonServices: CoreSingletonServices;
|
|
22
|
-
createWireServices: CreateWireServices<CoreSingletonServices, CoreServices<CoreSingletonServices>, CoreUserSession>;
|
|
23
|
-
};
|
|
24
21
|
/**
|
|
25
22
|
* Represents the HTTP methods supported for API HTTP wirings.
|
|
26
|
-
|
|
23
|
+
*/
|
|
27
24
|
export type HTTPMethod = 'post' | 'get' | 'delete' | 'patch' | 'head' | 'put' | 'options';
|
|
28
25
|
/**
|
|
29
|
-
*
|
|
26
|
+
* Header schema type for request header validation.
|
|
27
|
+
* Uses Standard Schema interface - works with Zod, Valibot, ArkType, Effect Schema, etc.
|
|
28
|
+
*/
|
|
29
|
+
export type HTTPHeadersSchema = StandardSchemaV1<Record<string, string | string[] | undefined>>;
|
|
30
|
+
/**
|
|
31
|
+
* Documentation config for OpenAPI generation
|
|
30
32
|
*/
|
|
31
|
-
export type
|
|
33
|
+
export type HTTPRouteDocsConfig = {
|
|
34
|
+
description?: string;
|
|
35
|
+
response?: string;
|
|
36
|
+
errors?: Array<typeof PikkuError>;
|
|
37
|
+
tags?: string[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Common HTTP route configuration shared between wireHTTP and wireHTTPRoutes
|
|
41
|
+
*/
|
|
42
|
+
export type HTTPRouteBaseConfig = {
|
|
32
43
|
contentType?: 'xml' | 'json';
|
|
44
|
+
timeout?: number;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
headers?: HTTPHeadersSchema;
|
|
47
|
+
docs?: HTTPRouteDocsConfig;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Represents an API HTTP wiring without a function, including metadata such as content type, route, and timeout settings.
|
|
51
|
+
*/
|
|
52
|
+
export type CoreHTTPFunction = HTTPRouteBaseConfig & {
|
|
33
53
|
route: string;
|
|
34
54
|
eventChannel?: false;
|
|
35
55
|
returnsJSON?: false;
|
|
36
|
-
timeout?: number;
|
|
37
|
-
tags?: string[];
|
|
38
|
-
docs?: Partial<{
|
|
39
|
-
description: string;
|
|
40
|
-
response: string;
|
|
41
|
-
errors: Array<typeof PikkuError>;
|
|
42
|
-
tags: string[];
|
|
43
|
-
}>;
|
|
44
56
|
};
|
|
45
57
|
/**
|
|
46
58
|
* Represents a http wire within Pikku, including a request and response.
|
|
@@ -67,13 +79,12 @@ export type PikkuQuery<T = Record<string, string | undefined>> = Record<string,
|
|
|
67
79
|
* @template PikkuFunctionSessionless - The sessionless API function type, defaults to `CorePikkuFunctionSessionless`.
|
|
68
80
|
* @template PikkuPermission - The permission function type, defaults to `CorePikkuPermission`.
|
|
69
81
|
*/
|
|
70
|
-
export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction extends CorePikkuFunction<In, Out, any, any> = CorePikkuFunction<In, Out>, PikkuFunctionSessionless extends CorePikkuFunctionSessionless<In, Out, any, any> = CorePikkuFunctionSessionless<In, Out>, PikkuPermission extends CorePikkuPermission<In, any, any> = CorePikkuPermission<In, any, any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any>> = (CoreHTTPFunction & {
|
|
82
|
+
export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction extends CorePikkuFunction<In, Out, any, any, any> = CorePikkuFunction<In, Out>, PikkuFunctionSessionless extends CorePikkuFunctionSessionless<In, Out, any, any, any> = CorePikkuFunctionSessionless<In, Out>, PikkuPermission extends CorePikkuPermission<In, any, any> = CorePikkuPermission<In, any, any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any>> = (CoreHTTPFunction & {
|
|
71
83
|
route: R;
|
|
72
84
|
method: HTTPMethod;
|
|
73
85
|
func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
|
|
74
86
|
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
75
87
|
auth?: true;
|
|
76
|
-
tags?: string[];
|
|
77
88
|
middleware?: PikkuMiddleware[];
|
|
78
89
|
sse?: undefined;
|
|
79
90
|
}) | (CoreHTTPFunction & {
|
|
@@ -82,7 +93,6 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
|
|
|
82
93
|
func: CorePikkuFunctionConfig<PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>;
|
|
83
94
|
permissions?: undefined;
|
|
84
95
|
auth?: false;
|
|
85
|
-
tags?: string[];
|
|
86
96
|
middleware?: PikkuMiddleware[];
|
|
87
97
|
sse?: undefined;
|
|
88
98
|
}) | (CoreHTTPFunction & {
|
|
@@ -91,27 +101,24 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
|
|
|
91
101
|
func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
|
|
92
102
|
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
93
103
|
auth?: true;
|
|
94
|
-
sse?: boolean;
|
|
95
|
-
tags?: string[];
|
|
96
104
|
middleware?: PikkuMiddleware[];
|
|
105
|
+
sse?: boolean;
|
|
97
106
|
}) | (CoreHTTPFunction & {
|
|
98
107
|
route: R;
|
|
99
108
|
method: 'get';
|
|
100
109
|
func: CorePikkuFunctionConfig<PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>;
|
|
101
110
|
permissions?: undefined;
|
|
102
111
|
auth?: false;
|
|
103
|
-
sse?: boolean;
|
|
104
|
-
tags?: string[];
|
|
105
112
|
middleware?: PikkuMiddleware[];
|
|
113
|
+
sse?: boolean;
|
|
106
114
|
}) | (CoreHTTPFunction & {
|
|
107
115
|
route: R;
|
|
108
116
|
method: 'post';
|
|
109
117
|
func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
|
|
110
118
|
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
111
119
|
auth?: true;
|
|
112
|
-
query?: Array<keyof In>;
|
|
113
|
-
tags?: string[];
|
|
114
120
|
middleware?: PikkuMiddleware[];
|
|
121
|
+
query?: Array<keyof In>;
|
|
115
122
|
sse?: undefined;
|
|
116
123
|
}) | (CoreHTTPFunction & {
|
|
117
124
|
route: R;
|
|
@@ -119,23 +126,10 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
|
|
|
119
126
|
func: CorePikkuFunctionConfig<PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>;
|
|
120
127
|
permissions?: undefined;
|
|
121
128
|
auth?: false;
|
|
122
|
-
query?: Array<keyof In>;
|
|
123
|
-
tags?: string[];
|
|
124
129
|
middleware?: PikkuMiddleware[];
|
|
130
|
+
query?: Array<keyof In>;
|
|
125
131
|
sse?: undefined;
|
|
126
|
-
})
|
|
127
|
-
/** Route triggers a workflow matched by route/method from workflow wires.http */
|
|
128
|
-
route: R;
|
|
129
|
-
method: HTTPMethod;
|
|
130
|
-
workflow: true;
|
|
131
|
-
func?: undefined;
|
|
132
|
-
permissions?: undefined;
|
|
133
|
-
auth?: undefined;
|
|
134
|
-
tags?: undefined;
|
|
135
|
-
middleware?: undefined;
|
|
136
|
-
returnsJSON?: undefined;
|
|
137
|
-
sse?: boolean;
|
|
138
|
-
};
|
|
132
|
+
});
|
|
139
133
|
/**
|
|
140
134
|
* Represents the input types for HTTP wiring metadata, including parameters, query, and body types.
|
|
141
135
|
*/
|
|
@@ -153,8 +147,9 @@ export type HTTPWiringMeta = CommonWireMeta & {
|
|
|
153
147
|
params?: string[];
|
|
154
148
|
query?: string[];
|
|
155
149
|
inputTypes?: HTTPFunctionMetaInputTypes;
|
|
150
|
+
headersSchemaName?: string;
|
|
156
151
|
sse?: true;
|
|
157
|
-
|
|
152
|
+
groupBasePath?: string;
|
|
158
153
|
};
|
|
159
154
|
export type HTTPWiringsMeta = Record<HTTPMethod, Record<string, HTTPWiringMeta>>;
|
|
160
155
|
export type HTTPFunctionsMeta = Array<{
|
|
@@ -188,4 +183,45 @@ export interface PikkuHTTPResponse<Out = unknown> {
|
|
|
188
183
|
close?: () => void;
|
|
189
184
|
setMode?: (mode: 'stream') => void;
|
|
190
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Single route configuration - supports all wireHTTP options
|
|
188
|
+
*/
|
|
189
|
+
export type HTTPRouteConfig<PikkuFunction extends CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any> = CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any>, PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = HTTPRouteBaseConfig & {
|
|
190
|
+
method: HTTPMethod;
|
|
191
|
+
route: string;
|
|
192
|
+
func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
|
|
193
|
+
auth?: boolean;
|
|
194
|
+
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
195
|
+
middleware?: PikkuMiddleware[];
|
|
196
|
+
sse?: boolean;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Group-level configuration applied to all routes
|
|
200
|
+
*/
|
|
201
|
+
export type HTTPRoutesGroupConfig<PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = {
|
|
202
|
+
basePath?: string;
|
|
203
|
+
tags?: string[];
|
|
204
|
+
auth?: boolean;
|
|
205
|
+
middleware?: PikkuMiddleware[];
|
|
206
|
+
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Nested route map - allows hierarchical organization
|
|
210
|
+
* Can contain individual routes, nested maps, or contracts with config
|
|
211
|
+
*/
|
|
212
|
+
export type HTTPRouteMap = {
|
|
213
|
+
[key: string]: HTTPRouteConfig | HTTPRouteMap | HTTPRouteContract;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* A route contract with optional group config (returned by defineRoutes)
|
|
217
|
+
*/
|
|
218
|
+
export type HTTPRouteContract<T extends HTTPRouteMap = HTTPRouteMap> = HTTPRoutesGroupConfig & {
|
|
219
|
+
routes: T;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Full configuration for wireHTTPRoutes
|
|
223
|
+
*/
|
|
224
|
+
export type WireHTTPRoutesConfig = HTTPRoutesGroupConfig & {
|
|
225
|
+
routes: HTTPRouteMap | HTTPRouteConfig[];
|
|
226
|
+
};
|
|
191
227
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { PikkuFetchHTTPRequest } from './pikku-fetch-http-request.js';
|
|
2
|
+
export { PikkuFetchHTTPResponse } from './pikku-fetch-http-response.js';
|
|
3
|
+
export { logRoutes } from './log-http-routes.js';
|
|
4
4
|
export { fetch, fetchData, wireHTTP, addHTTPMiddleware, addHTTPPermission, } from './http-runner.js';
|
|
5
|
-
export
|
|
5
|
+
export { wireHTTPRoutes, defineHTTPRoutes } from './http-routes.js';
|
|
6
|
+
export type { AssertHTTPWiringParams, CoreHTTPFunctionWiring, HTTPMethod, HTTPRouteBaseConfig, HTTPWiringsMeta, PikkuHTTPRequest, PikkuHTTPResponse, PikkuQuery, RunHTTPWiringOptions, } from './http.types.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { PikkuFetchHTTPRequest } from './pikku-fetch-http-request.js';
|
|
2
|
+
export { PikkuFetchHTTPResponse } from './pikku-fetch-http-response.js';
|
|
3
|
+
export { logRoutes } from './log-http-routes.js';
|
|
4
4
|
export { fetch, fetchData, wireHTTP, addHTTPMiddleware, addHTTPPermission, } from './http-runner.js';
|
|
5
|
+
export { wireHTTPRoutes, defineHTTPRoutes } from './http-routes.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PikkuHTTPResponse } from './http.types.js';
|
|
2
|
-
import { SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
1
|
+
import type { PikkuHTTPResponse } from './http.types.js';
|
|
2
|
+
import type { SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
3
3
|
export declare class PikkuFetchHTTPResponse implements PikkuHTTPResponse {
|
|
4
4
|
#private;
|
|
5
5
|
setMode(mode: 'stream'): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { serialize as serializeCookie
|
|
1
|
+
import { serialize as serializeCookie } from 'cookie';
|
|
2
2
|
export class PikkuFetchHTTPResponse {
|
|
3
3
|
#statusCode = 200;
|
|
4
4
|
#headers = new Headers();
|
|
@@ -76,6 +76,11 @@ export class PikkuFetchHTTPResponse {
|
|
|
76
76
|
// return this
|
|
77
77
|
// }
|
|
78
78
|
redirect(location, status = 302) {
|
|
79
|
+
if (!location.startsWith('/') &&
|
|
80
|
+
!location.startsWith('https://') &&
|
|
81
|
+
!location.startsWith('http://')) {
|
|
82
|
+
throw new Error('Invalid redirect location: must be a relative path or absolute URL');
|
|
83
|
+
}
|
|
79
84
|
this.#statusCode = status;
|
|
80
85
|
this.header('Location', location);
|
|
81
86
|
return this;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MatchResult, Router } from './http-router.js';
|
|
2
|
-
import { HTTPMethod } from '../http.types.js';
|
|
1
|
+
import type { MatchResult, Router } from './http-router.js';
|
|
2
|
+
import type { HTTPMethod } from '../http.types.js';
|
|
3
3
|
export declare class PathToRegexRouter implements Router {
|
|
4
4
|
private compiledRoutes;
|
|
5
5
|
private staticRoutes;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { MCPEndpointRegistry } from './mcp-endpoint-registry.js';
|
|
2
|
+
export { MCPError, wireMCPResource, wireMCPPrompt, runMCPResource, runMCPTool, runMCPPrompt, } from './mcp-runner.js';
|
|
3
|
+
export { getMCPResourcesMeta, getMCPToolsMeta, getMCPPromptsMeta, } from './mcp-runner.js';
|
|
4
|
+
export type { AssertMCPResourceURIParams, CoreMCPPrompt, CoreMCPResource, CoreMCPTool, MCPPromptResponse, MCPResourceMeta, MCPResourceResponse, MCPToolMeta, MCPToolResponse, MCPPromptMeta, PikkuMCP, } from './mcp.types.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { MCPEndpointRegistry } from './mcp-endpoint-registry.js';
|
|
2
|
+
export { MCPError, wireMCPResource, wireMCPPrompt, runMCPResource, runMCPTool, runMCPPrompt, } from './mcp-runner.js';
|
|
3
|
+
export { getMCPResourcesMeta, getMCPToolsMeta, getMCPPromptsMeta, } from './mcp-runner.js';
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, JsonRpcRequest, JsonRpcResponse, JsonRpcErrorResponse, PikkuMCP } from './mcp.types.js';
|
|
1
|
+
import type { CoreMCPResource, CoreMCPPrompt, JsonRpcRequest, JsonRpcResponse, JsonRpcErrorResponse, PikkuMCP } from './mcp.types.js';
|
|
3
2
|
import type { CorePikkuFunctionConfig, CorePikkuFunctionSessionless } from '../../function/functions.types.js';
|
|
4
3
|
export declare class MCPError extends Error {
|
|
5
4
|
readonly error: JsonRpcErrorResponse;
|
|
6
5
|
constructor(error: JsonRpcErrorResponse);
|
|
7
6
|
}
|
|
8
7
|
export type RunMCPEndpointParams<Tools extends string = any> = {
|
|
9
|
-
singletonServices: CoreSingletonServices;
|
|
10
8
|
mcp?: PikkuMCP<Tools>;
|
|
11
|
-
createWireServices?: CreateWireServices<CoreSingletonServices, CoreServices<CoreSingletonServices>, CoreUserSession>;
|
|
12
9
|
};
|
|
13
10
|
export type JsonRpcError = {
|
|
14
11
|
code: number;
|
|
@@ -16,12 +13,10 @@ export type JsonRpcError = {
|
|
|
16
13
|
data?: any;
|
|
17
14
|
};
|
|
18
15
|
export declare const wireMCPResource: <PikkuFunctionConfig extends CorePikkuFunctionConfig<CorePikkuFunctionSessionless<any, any>> = CorePikkuFunctionConfig<CorePikkuFunctionSessionless<any, any>>>(mcpResource: CoreMCPResource<PikkuFunctionConfig>) => void;
|
|
19
|
-
export declare const wireMCPTool: <PikkuFunctionConfig extends CorePikkuFunctionConfig<CorePikkuFunctionSessionless<any, any>> = CorePikkuFunctionConfig<CorePikkuFunctionSessionless<any, any>>>(mcpTool: CoreMCPTool<PikkuFunctionConfig>) => void;
|
|
20
16
|
export declare const wireMCPPrompt: <PikkuFunctionConfig extends CorePikkuFunctionConfig<CorePikkuFunctionSessionless<any, any>> = CorePikkuFunctionConfig<CorePikkuFunctionSessionless<any, any>>>(mcpPrompt: CoreMCPPrompt<PikkuFunctionConfig>) => void;
|
|
21
17
|
export declare function runMCPResource(request: JsonRpcRequest, params: RunMCPEndpointParams, uri: string): Promise<JsonRpcResponse>;
|
|
22
18
|
export declare function runMCPTool(request: JsonRpcRequest, params: RunMCPEndpointParams, name: string): Promise<JsonRpcResponse>;
|
|
23
19
|
export declare function runMCPPrompt(request: JsonRpcRequest, params: RunMCPEndpointParams, name: string): Promise<JsonRpcResponse>;
|
|
24
|
-
export declare const getMCPTools: () => Map<string, CoreMCPTool>;
|
|
25
20
|
export declare const getMCPResources: () => Map<string, CoreMCPResource>;
|
|
26
21
|
export declare const getMCPResourcesMeta: () => import("./mcp.types.js").MCPResourceMeta;
|
|
27
22
|
export declare const getMCPToolsMeta: () => import("./mcp.types.js").MCPToolMeta;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getErrorResponse } from '../../errors/error-handler.js';
|
|
2
2
|
import { closeWireServices } from '../../utils.js';
|
|
3
|
-
import { pikkuState } from '../../pikku-state.js';
|
|
3
|
+
import { pikkuState, getSingletonServices, getCreateWireServices, } from '../../pikku-state.js';
|
|
4
4
|
import { addFunction, runPikkuFunc } from '../../function/function-runner.js';
|
|
5
|
-
import { BadRequestError, NotFoundError } from '../../errors/errors.js';
|
|
6
|
-
import { PikkuSessionService } from '../../services/user-session-service.js';
|
|
5
|
+
import { BadRequestError, NotFoundError, PikkuMissingMetaError, } from '../../errors/errors.js';
|
|
6
|
+
import { PikkuSessionService, createMiddlewareSessionWireProps, } from '../../services/user-session-service.js';
|
|
7
7
|
export class MCPError extends Error {
|
|
8
8
|
error;
|
|
9
9
|
constructor(error) {
|
|
@@ -17,35 +17,22 @@ export const wireMCPResource = (mcpResource) => {
|
|
|
17
17
|
const resourcesMeta = pikkuState(null, 'mcp', 'resourcesMeta');
|
|
18
18
|
const mcpResourceMeta = resourcesMeta[mcpResource.uri];
|
|
19
19
|
if (!mcpResourceMeta) {
|
|
20
|
-
throw new
|
|
20
|
+
throw new PikkuMissingMetaError(`Missing generated metadata for MCP resource '${mcpResource.uri}'`);
|
|
21
21
|
}
|
|
22
|
-
addFunction(mcpResourceMeta.
|
|
22
|
+
addFunction(mcpResourceMeta.pikkuFuncId, mcpResource.func);
|
|
23
23
|
const resources = pikkuState(null, 'mcp', 'resources');
|
|
24
24
|
if (resources.has(mcpResource.uri)) {
|
|
25
25
|
throw new Error(`MCP resource already exists: ${mcpResource.uri}`);
|
|
26
26
|
}
|
|
27
27
|
resources.set(mcpResource.uri, mcpResource);
|
|
28
28
|
};
|
|
29
|
-
export const wireMCPTool = (mcpTool) => {
|
|
30
|
-
const toolsMeta = pikkuState(null, 'mcp', 'toolsMeta');
|
|
31
|
-
const mcpToolMeta = toolsMeta[mcpTool.name];
|
|
32
|
-
if (!mcpToolMeta) {
|
|
33
|
-
throw new Error(`MCP tool metadata not found for '${mcpTool.name}'`);
|
|
34
|
-
}
|
|
35
|
-
addFunction(mcpToolMeta.pikkuFuncName, mcpTool.func);
|
|
36
|
-
const tools = pikkuState(null, 'mcp', 'tools');
|
|
37
|
-
if (tools.has(mcpTool.name)) {
|
|
38
|
-
throw new Error(`MCP tool already exists: ${mcpTool.name}`);
|
|
39
|
-
}
|
|
40
|
-
tools.set(mcpTool.name, mcpTool);
|
|
41
|
-
};
|
|
42
29
|
export const wireMCPPrompt = (mcpPrompt) => {
|
|
43
30
|
const promptsMeta = pikkuState(null, 'mcp', 'promptsMeta');
|
|
44
31
|
const mcpPromptMeta = promptsMeta[mcpPrompt.name];
|
|
45
32
|
if (!mcpPromptMeta) {
|
|
46
|
-
throw new
|
|
33
|
+
throw new PikkuMissingMetaError(`Missing generated metadata for MCP prompt '${mcpPrompt.name}'`);
|
|
47
34
|
}
|
|
48
|
-
addFunction(mcpPromptMeta.
|
|
35
|
+
addFunction(mcpPromptMeta.pikkuFuncId, mcpPrompt.func);
|
|
49
36
|
const prompts = pikkuState(null, 'mcp', 'prompts');
|
|
50
37
|
if (prompts.has(mcpPrompt.name)) {
|
|
51
38
|
throw new Error(`MCP prompt already exists: ${mcpPrompt.name}`);
|
|
@@ -54,13 +41,13 @@ export const wireMCPPrompt = (mcpPrompt) => {
|
|
|
54
41
|
};
|
|
55
42
|
export async function runMCPResource(request, params, uri) {
|
|
56
43
|
let endpoint;
|
|
57
|
-
let
|
|
44
|
+
let pikkuFuncId;
|
|
58
45
|
let extractedParams = {};
|
|
59
46
|
const metas = pikkuState(null, 'mcp', 'resourcesMeta');
|
|
60
47
|
const endpoints = pikkuState(null, 'mcp', 'resources');
|
|
61
48
|
if (endpoints.has(uri)) {
|
|
62
49
|
endpoint = endpoints.get(uri);
|
|
63
|
-
|
|
50
|
+
pikkuFuncId = metas[uri]?.pikkuFuncId;
|
|
64
51
|
}
|
|
65
52
|
else {
|
|
66
53
|
for (const [uriTemplate, value] of endpoints.entries()) {
|
|
@@ -72,7 +59,7 @@ export async function runMCPResource(request, params, uri) {
|
|
|
72
59
|
const match = uri.match(regex);
|
|
73
60
|
if (match) {
|
|
74
61
|
endpoint = value;
|
|
75
|
-
|
|
62
|
+
pikkuFuncId = metas[uriTemplate]?.pikkuFuncId;
|
|
76
63
|
// Extract parameter values and create params object
|
|
77
64
|
for (let i = 0; i < paramNames.length; i++) {
|
|
78
65
|
extractedParams[paramNames[i]] = match[i + 1]; // match[0] is the full match
|
|
@@ -84,40 +71,40 @@ export async function runMCPResource(request, params, uri) {
|
|
|
84
71
|
return await runMCPPikkuFunc({
|
|
85
72
|
...request,
|
|
86
73
|
params: { ...request.params, ...extractedParams },
|
|
87
|
-
}, 'resource', uri, endpoint,
|
|
74
|
+
}, 'resource', uri, endpoint, pikkuFuncId, { ...params, mcp: { ...params.mcp, uri } });
|
|
88
75
|
}
|
|
89
76
|
export async function runMCPTool(request, params, name) {
|
|
90
|
-
const endpoint = pikkuState(null, 'mcp', 'tools').get(name);
|
|
91
77
|
const meta = pikkuState(null, 'mcp', 'toolsMeta')[name];
|
|
92
|
-
return await runMCPPikkuFunc(request, 'tool', name,
|
|
78
|
+
return await runMCPPikkuFunc(request, 'tool', name, undefined, meta?.pikkuFuncId, params);
|
|
93
79
|
}
|
|
94
80
|
export async function runMCPPrompt(request, params, name) {
|
|
95
81
|
const endpoint = pikkuState(null, 'mcp', 'prompts').get(name);
|
|
96
82
|
const meta = pikkuState(null, 'mcp', 'promptsMeta')[name];
|
|
97
|
-
return await runMCPPikkuFunc(request, 'prompt', name, endpoint, meta?.
|
|
83
|
+
return await runMCPPikkuFunc(request, 'prompt', name, endpoint, meta?.pikkuFuncId, params);
|
|
98
84
|
}
|
|
99
85
|
/**
|
|
100
86
|
* JSON-RPC 2.0 compatible MCP endpoint runner
|
|
101
87
|
*/
|
|
102
|
-
async function runMCPPikkuFunc(request, type, name, mcp,
|
|
88
|
+
async function runMCPPikkuFunc(request, type, name, mcp, pikkuFuncId, { mcp: mcpWire }) {
|
|
89
|
+
const singletonServices = getSingletonServices();
|
|
90
|
+
const createWireServices = getCreateWireServices();
|
|
103
91
|
let wireServices;
|
|
104
92
|
try {
|
|
105
|
-
// Validate JSON-RPC request structure
|
|
106
93
|
if (request.jsonrpc !== '2.0') {
|
|
107
94
|
throw new BadRequestError('Invalid JSON-RPC version, only supoorted version is 2.0');
|
|
108
95
|
}
|
|
109
|
-
if (
|
|
96
|
+
if (mcp === undefined && type !== 'tool') {
|
|
110
97
|
throw new NotFoundError(`MCP '${type}' registration not found for '${name}'`);
|
|
111
98
|
}
|
|
112
|
-
if (!
|
|
99
|
+
if (!pikkuFuncId) {
|
|
113
100
|
throw new NotFoundError(`MCP '${type}' PikkuFunction Mapping not found for '${name}'`);
|
|
114
101
|
}
|
|
115
102
|
singletonServices.logger.debug(`Running MCP ${type}: ${name}`);
|
|
103
|
+
const mcpSessionService = new PikkuSessionService();
|
|
116
104
|
const wire = {
|
|
117
105
|
mcp: mcpWire,
|
|
118
|
-
|
|
106
|
+
...createMiddlewareSessionWireProps(mcpSessionService),
|
|
119
107
|
};
|
|
120
|
-
// Get metadata for the MCP endpoint to access pre-resolved middleware
|
|
121
108
|
let meta;
|
|
122
109
|
if (type === 'resource') {
|
|
123
110
|
meta = pikkuState(null, 'mcp', 'resourcesMeta')[name];
|
|
@@ -128,17 +115,21 @@ async function runMCPPikkuFunc(request, type, name, mcp, pikkuFuncName, { single
|
|
|
128
115
|
else if (type === 'prompt') {
|
|
129
116
|
meta = pikkuState(null, 'mcp', 'promptsMeta')[name];
|
|
130
117
|
}
|
|
131
|
-
|
|
118
|
+
let result = await runPikkuFunc('mcp', `${type}:${name}`, pikkuFuncId, {
|
|
132
119
|
singletonServices,
|
|
133
120
|
createWireServices,
|
|
134
121
|
data: () => request.params,
|
|
135
122
|
inheritedMiddleware: meta?.middleware,
|
|
136
|
-
wireMiddleware: mcp
|
|
123
|
+
wireMiddleware: mcp?.middleware,
|
|
137
124
|
inheritedPermissions: meta?.permissions,
|
|
138
|
-
wirePermissions: mcp
|
|
139
|
-
tags: mcp
|
|
125
|
+
wirePermissions: mcp?.permissions,
|
|
126
|
+
tags: mcp?.tags,
|
|
140
127
|
wire,
|
|
128
|
+
sessionService: mcpSessionService,
|
|
141
129
|
});
|
|
130
|
+
if (type === 'tool' && meta?.outputSchema !== 'MCPToolResponse') {
|
|
131
|
+
result = [{ type: 'text', text: JSON.stringify(result) }];
|
|
132
|
+
}
|
|
142
133
|
return {
|
|
143
134
|
id: request.id,
|
|
144
135
|
result,
|
|
@@ -172,9 +163,6 @@ async function runMCPPikkuFunc(request, type, name, mcp, pikkuFuncName, { single
|
|
|
172
163
|
}
|
|
173
164
|
}
|
|
174
165
|
}
|
|
175
|
-
export const getMCPTools = () => {
|
|
176
|
-
return pikkuState(null, 'mcp', 'tools');
|
|
177
|
-
};
|
|
178
166
|
export const getMCPResources = () => {
|
|
179
167
|
return pikkuState(null, 'mcp', 'resources');
|
|
180
168
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CorePermissionGroup, CorePikkuFunctionConfig, CorePikkuFunctionSessionless, CorePikkuPermission } from '../../function/functions.types.js';
|
|
2
|
-
import { CorePikkuMiddleware, MiddlewareMetadata, PermissionMetadata } from '../../types/core.types.js';
|
|
1
|
+
import type { CorePermissionGroup, CorePikkuFunctionConfig, CorePikkuFunctionSessionless, CorePikkuPermission } from '../../function/functions.types.js';
|
|
2
|
+
import type { CorePikkuMiddleware, MiddlewareMetadata, PermissionMetadata } from '../../types/core.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Extract URI parameters from MCP resource URI template.
|
|
5
5
|
* E.g., "user/{userId}/post/{postId}" => "userId" | "postId"
|
|
@@ -26,7 +26,7 @@ export type PikkuMCP<Tools extends string = any> = {
|
|
|
26
26
|
* Represents metadata for MCP resources, including name, description, and documentation.
|
|
27
27
|
*/
|
|
28
28
|
export type MCPResourceMeta = Record<string, Omit<CoreMCPResource, 'func' | 'middleware' | 'permissions'> & {
|
|
29
|
-
|
|
29
|
+
pikkuFuncId: string;
|
|
30
30
|
inputSchema: string | null;
|
|
31
31
|
outputSchema: string | null;
|
|
32
32
|
middleware?: MiddlewareMetadata[];
|
|
@@ -36,7 +36,7 @@ export type MCPResourceMeta = Record<string, Omit<CoreMCPResource, 'func' | 'mid
|
|
|
36
36
|
* Represents metadata for MCP tools, including name, description, and documentation.
|
|
37
37
|
*/
|
|
38
38
|
export type MCPToolMeta = Record<string, Omit<CoreMCPTool, 'func' | 'middleware' | 'permissions'> & {
|
|
39
|
-
|
|
39
|
+
pikkuFuncId: string;
|
|
40
40
|
inputSchema: string | null;
|
|
41
41
|
outputSchema: string | null;
|
|
42
42
|
middleware?: MiddlewareMetadata[];
|
|
@@ -46,7 +46,7 @@ export type MCPToolMeta = Record<string, Omit<CoreMCPTool, 'func' | 'middleware'
|
|
|
46
46
|
* Represents metadata for MCP prompts, including name, description, and arguments.
|
|
47
47
|
*/
|
|
48
48
|
export type MCPPromptMeta = Record<string, Omit<CoreMCPPrompt, 'func' | 'middleware' | 'permissions'> & {
|
|
49
|
-
|
|
49
|
+
pikkuFuncId: string;
|
|
50
50
|
inputSchema: string | null;
|
|
51
51
|
outputSchema: string | null;
|
|
52
52
|
arguments: Array<{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type NodeType = 'trigger' | 'action' | 'end';
|
|
2
|
+
export type CoreNodeConfig = {
|
|
3
|
+
displayName: string;
|
|
4
|
+
category: string;
|
|
5
|
+
type: NodeType;
|
|
6
|
+
errorOutput?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type NodeMeta = {
|
|
9
|
+
name: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
category: string;
|
|
12
|
+
type: NodeType;
|
|
13
|
+
rpc: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
errorOutput: boolean;
|
|
16
|
+
inputSchemaName: string | null;
|
|
17
|
+
outputSchemaName: string | null;
|
|
18
|
+
tags?: string[];
|
|
19
|
+
};
|
|
20
|
+
export type NodesMeta = Record<string, NodeMeta>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { OAuth2Token } from './oauth2.types.js';
|
|
2
|
+
import type { OAuth2CredentialConfig } from '../secret/secret.types.js';
|
|
3
|
+
import type { SecretService } from '../../services/secret-service.js';
|
|
4
|
+
export declare class OAuth2Client {
|
|
5
|
+
private oauth2Config;
|
|
6
|
+
private appCredentialSecretId;
|
|
7
|
+
private secrets;
|
|
8
|
+
private cachedToken;
|
|
9
|
+
private cachedAppCredential;
|
|
10
|
+
private refreshPromise;
|
|
11
|
+
constructor(oauth2Config: OAuth2CredentialConfig, appCredentialSecretId: string, secrets: SecretService);
|
|
12
|
+
/**
|
|
13
|
+
* Make an authenticated request. Handles token caching and 401 refresh.
|
|
14
|
+
*/
|
|
15
|
+
request(url: string, options?: RequestInit, timeoutMs?: number): Promise<Response>;
|
|
16
|
+
/**
|
|
17
|
+
* Get cached token or load from secrets.
|
|
18
|
+
*/
|
|
19
|
+
getAccessToken(): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Refresh token and update cache.
|
|
22
|
+
* Uses a promise lock to prevent concurrent refresh attempts.
|
|
23
|
+
*/
|
|
24
|
+
private refreshAndGetToken;
|
|
25
|
+
/**
|
|
26
|
+
* Perform the actual token refresh.
|
|
27
|
+
*/
|
|
28
|
+
private doRefreshToken;
|
|
29
|
+
/**
|
|
30
|
+
* Check if token is valid (not expired).
|
|
31
|
+
*/
|
|
32
|
+
private isTokenValid;
|
|
33
|
+
/**
|
|
34
|
+
* Get app credentials (cached).
|
|
35
|
+
*/
|
|
36
|
+
private getAppCredential;
|
|
37
|
+
/**
|
|
38
|
+
* Generate OAuth2 authorization URL.
|
|
39
|
+
* Used by CLI during `pikku oauth connect`.
|
|
40
|
+
*/
|
|
41
|
+
getAuthorizationUrl(state: string, redirectUri: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Exchange authorization code for tokens.
|
|
44
|
+
* Used by CLI during `pikku oauth connect`.
|
|
45
|
+
*/
|
|
46
|
+
exchangeCode(code: string, redirectUri: string): Promise<OAuth2Token>;
|
|
47
|
+
}
|