@pikku/core 0.12.82 → 0.12.84
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 +101 -0
- package/README.md +1 -1
- package/dist/ecosystem/agent-scorer.d.ts +12 -0
- package/dist/ecosystem/agent-scorer.js +5 -0
- package/dist/ecosystem/agent.d.ts +18 -0
- package/dist/ecosystem/agent.js +6 -0
- package/dist/ecosystem/ai-agent.d.ts +18 -0
- package/dist/ecosystem/ai-agent.js +6 -0
- package/dist/ecosystem/ai-scorer.d.ts +12 -0
- package/dist/ecosystem/ai-scorer.js +5 -0
- package/dist/ecosystem/channel/local.d.ts +1 -0
- package/dist/ecosystem/channel/local.js +1 -0
- package/dist/ecosystem/channel.d.ts +12 -0
- package/dist/ecosystem/channel.js +4 -0
- package/dist/ecosystem/cli/channel.d.ts +16 -0
- package/dist/ecosystem/cli/channel.js +2 -0
- package/dist/ecosystem/cli.d.ts +9 -0
- package/dist/ecosystem/cli.js +2 -0
- package/dist/ecosystem/credential.d.ts +9 -0
- package/dist/ecosystem/credential.js +1 -0
- package/dist/ecosystem/dev.d.ts +8 -0
- package/dist/ecosystem/dev.js +1 -0
- package/dist/ecosystem/function.d.ts +13 -0
- package/dist/ecosystem/function.js +2 -0
- package/dist/ecosystem/gateway.d.ts +1 -0
- package/dist/ecosystem/gateway.js +1 -0
- package/dist/ecosystem/hmac.d.ts +1 -0
- package/dist/ecosystem/hmac.js +1 -0
- package/dist/ecosystem/http.d.ts +11 -0
- package/dist/ecosystem/http.js +3 -0
- package/dist/ecosystem/mcp.d.ts +3 -0
- package/dist/ecosystem/mcp.js +2 -0
- package/dist/ecosystem/middleware.d.ts +17 -0
- package/dist/ecosystem/middleware.js +6 -0
- package/dist/ecosystem/node-host-resolver.d.ts +1 -0
- package/dist/ecosystem/node-host-resolver.js +1 -0
- package/dist/ecosystem/node.d.ts +1 -0
- package/dist/ecosystem/node.js +1 -0
- package/dist/ecosystem/oauth2.d.ts +1 -0
- package/dist/ecosystem/oauth2.js +1 -0
- package/dist/ecosystem/persona.d.ts +15 -0
- package/dist/ecosystem/persona.js +4 -0
- package/dist/ecosystem/queue.d.ts +11 -0
- package/dist/ecosystem/queue.js +2 -0
- package/dist/ecosystem/remote.d.ts +8 -0
- package/dist/ecosystem/remote.js +1 -0
- package/dist/ecosystem/role.d.ts +3 -0
- package/dist/ecosystem/role.js +2 -0
- package/dist/ecosystem/rpc.d.ts +4 -0
- package/dist/ecosystem/rpc.js +2 -0
- package/dist/ecosystem/safe-fetch.d.ts +7 -0
- package/dist/ecosystem/safe-fetch.js +1 -0
- package/dist/ecosystem/scenario.d.ts +15 -0
- package/dist/ecosystem/scenario.js +4 -0
- package/dist/ecosystem/scheduler.d.ts +2 -0
- package/dist/ecosystem/scheduler.js +1 -0
- package/dist/ecosystem/schema.d.ts +1 -0
- package/dist/ecosystem/schema.js +1 -0
- package/dist/ecosystem/scope.d.ts +3 -0
- package/dist/ecosystem/scope.js +2 -0
- package/dist/ecosystem/secret.d.ts +9 -0
- package/dist/ecosystem/secret.js +1 -0
- package/dist/ecosystem/services/istanbul-coverage.d.ts +1 -0
- package/dist/ecosystem/services/istanbul-coverage.js +1 -0
- package/dist/ecosystem/services/local-content-request-handler.d.ts +9 -0
- package/dist/ecosystem/services/local-content-request-handler.js +1 -0
- package/dist/ecosystem/services/local-content.d.ts +1 -0
- package/dist/ecosystem/services/local-content.js +1 -0
- package/dist/ecosystem/services/v8-coverage.d.ts +1 -0
- package/dist/ecosystem/services/v8-coverage.js +1 -0
- package/dist/ecosystem/services.d.ts +28 -0
- package/dist/ecosystem/services.js +6 -0
- package/dist/ecosystem/testing.d.ts +7 -0
- package/dist/ecosystem/testing.js +1 -0
- package/dist/ecosystem/trigger.d.ts +1 -0
- package/dist/ecosystem/trigger.js +1 -0
- package/dist/ecosystem/types.d.ts +9 -0
- package/dist/ecosystem/types.js +5 -0
- package/dist/ecosystem/variable.d.ts +8 -0
- package/dist/ecosystem/variable.js +1 -0
- package/dist/ecosystem/virtual-user.d.ts +21 -0
- package/dist/ecosystem/virtual-user.js +5 -0
- package/dist/ecosystem/workflow.d.ts +18 -0
- package/dist/ecosystem/workflow.js +4 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +3 -3
- package/dist/middleware/auth-apikey.d.ts +1 -1
- package/dist/middleware/auth-bearer.d.ts +1 -1
- package/dist/middleware/auth-cookie.d.ts +1 -1
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/remote-auth.d.ts +1 -1
- package/dist/middleware/telemetry.d.ts +2 -2
- package/dist/services/agent-run-state-service.d.ts +29 -0
- package/dist/services/agent-run-state-service.js +1 -0
- package/dist/services/agent-runner-service.d.ts +220 -0
- package/dist/services/agent-runner-service.js +1 -0
- package/dist/services/agent-storage-service.d.ts +18 -0
- package/dist/services/agent-storage-service.js +1 -0
- package/dist/services/http-personas.d.ts +1 -1
- package/dist/services/http-personas.js +3 -3
- package/dist/services/in-memory-agent-run-state-service.d.ts +19 -0
- package/dist/services/in-memory-agent-run-state-service.js +54 -0
- package/dist/services/index.d.ts +9 -10
- package/dist/services/index.js +3 -3
- package/dist/services/meta-service.d.ts +5 -4
- package/dist/testing/service-tests/agent-run-service-tests.d.ts +1 -1
- package/dist/testing/service-tests/agent-run-service-tests.js +3 -3
- package/dist/testing/service-tests/agent-storage-service-tests.d.ts +3 -0
- package/dist/testing/service-tests/agent-storage-service-tests.js +302 -0
- package/dist/testing/service-tests.d.ts +4 -4
- package/dist/testing/service-tests.js +4 -4
- package/dist/types/core.types.d.ts +12 -11
- package/dist/types/core.types.js +1 -1
- package/dist/types/state.types.d.ts +11 -6
- package/dist/wirings/actor-flow/run-conversation.d.ts +2 -2
- package/dist/wirings/agent/agent-agui.d.ts +79 -0
- package/dist/wirings/agent/agent-agui.js +327 -0
- package/dist/wirings/agent/agent-finalize.d.ts +58 -0
- package/dist/wirings/agent/agent-finalize.js +138 -0
- package/dist/wirings/agent/agent-helpers.d.ts +35 -0
- package/dist/wirings/agent/agent-helpers.js +47 -0
- package/dist/wirings/agent/agent-interrupt.d.ts +153 -0
- package/dist/wirings/agent/agent-interrupt.js +257 -0
- package/dist/wirings/agent/agent-memory.d.ts +42 -0
- package/dist/wirings/agent/agent-memory.js +333 -0
- package/dist/wirings/agent/agent-model-config.d.ts +16 -0
- package/dist/wirings/agent/agent-model-config.js +51 -0
- package/dist/wirings/agent/agent-prepare.d.ts +117 -0
- package/dist/wirings/agent/agent-prepare.js +728 -0
- package/dist/wirings/agent/agent-registry.d.ts +16 -0
- package/dist/wirings/agent/agent-registry.js +51 -0
- package/dist/wirings/agent/agent-rpc.d.ts +15 -0
- package/dist/wirings/agent/agent-rpc.js +53 -0
- package/dist/wirings/agent/agent-runner.d.ts +7 -0
- package/dist/wirings/agent/agent-runner.js +580 -0
- package/dist/wirings/agent/agent-stream.d.ts +41 -0
- package/dist/wirings/agent/agent-stream.js +1029 -0
- package/dist/wirings/agent/agent-turn.d.ts +57 -0
- package/dist/wirings/agent/agent-turn.js +82 -0
- package/dist/wirings/agent/agent-utils.d.ts +1 -0
- package/dist/wirings/agent/agent-utils.js +1 -0
- package/dist/wirings/agent/agent.types.d.ts +625 -0
- package/dist/wirings/agent/agent.types.js +1 -0
- package/dist/wirings/agent/index.d.ts +12 -0
- package/dist/wirings/agent/index.js +10 -0
- package/dist/wirings/agent/voice-input.d.ts +69 -0
- package/dist/wirings/agent/voice-input.js +150 -0
- package/dist/wirings/agent/voice-output.d.ts +85 -0
- package/dist/wirings/agent/voice-output.js +196 -0
- package/dist/wirings/agent-scorer/agent-scorer-grade.d.ts +26 -0
- package/dist/wirings/agent-scorer/agent-scorer-grade.js +33 -0
- package/dist/wirings/agent-scorer/agent-scorer-judge.d.ts +17 -0
- package/dist/wirings/agent-scorer/agent-scorer-judge.js +92 -0
- package/dist/wirings/agent-scorer/agent-scorer-live.d.ts +15 -0
- package/dist/wirings/agent-scorer/agent-scorer-live.js +38 -0
- package/dist/wirings/agent-scorer/agent-scorer-registry.d.ts +18 -0
- package/dist/wirings/agent-scorer/agent-scorer-registry.js +46 -0
- package/dist/wirings/agent-scorer/agent-scorer-sampling.d.ts +8 -0
- package/dist/wirings/agent-scorer/agent-scorer-sampling.js +31 -0
- package/dist/wirings/agent-scorer/agent-scorer-snapshots.d.ts +10 -0
- package/dist/wirings/agent-scorer/agent-scorer-snapshots.js +40 -0
- package/dist/wirings/agent-scorer/agent-scorer-worker.d.ts +15 -0
- package/dist/wirings/agent-scorer/agent-scorer-worker.js +60 -0
- package/dist/wirings/agent-scorer/agent-scorer.d.ts +39 -0
- package/dist/wirings/agent-scorer/agent-scorer.js +40 -0
- package/dist/wirings/agent-scorer/agent-scorer.types.d.ts +90 -0
- package/dist/wirings/agent-scorer/agent-scorer.types.js +4 -0
- package/dist/wirings/agent-scorer/index.d.ts +6 -0
- package/dist/wirings/agent-scorer/index.js +5 -0
- package/dist/wirings/ai-agent/ai-agent-prepare.js +2 -0
- package/dist/wirings/ai-agent/voice-output.d.ts +1 -2
- package/dist/wirings/channel/channel-rpc.types.d.ts +2 -2
- package/dist/wirings/rpc/addon-runner.d.ts +4 -0
- package/dist/wirings/rpc/addon-runner.js +14 -2
- package/dist/wirings/rpc/rpc-runner.d.ts +1 -1
- package/dist/wirings/rpc/rpc-runner.js +4 -2
- package/dist/wirings/rpc/rpc-types.d.ts +5 -1
- package/dist/wirings/rpc/wire-addon.d.ts +12 -0
- package/dist/wirings/rpc/wire-addon.js +4 -0
- package/dist/wirings/virtual-user/prepare-virtual-user-run.js +1 -1
- package/dist/wirings/virtual-user/virtual-user-agents.d.ts +1 -1
- package/dist/wirings/workflow/feature.d.ts +2 -1
- package/dist/wirings/workflow/index.d.ts +3 -14
- package/dist/wirings/workflow/index.js +0 -8
- package/dist/wirings/workflow/pikku-scenario-service.d.ts +10 -0
- package/dist/wirings/workflow/pikku-scenario-service.js +9 -0
- package/dist/wirings/workflow/run-timeline.d.ts +1 -2
- package/dist/wirings/workflow/scenario.types.d.ts +37 -0
- package/dist/wirings/workflow/scenario.types.js +1 -0
- package/dist/wirings/workflow/workflow.types.d.ts +2 -37
- package/knowledge/decisions/internals/{a-non-streaming-agent-run-registers-with-airunstate-too.md → a-non-streaming-agent-run-registers-with-agentrunstate-too.md} +6 -6
- package/knowledge/decisions/internals/a-resumed-agent-turn-is-as-interruptible-as-the-first.md +1 -1
- package/knowledge/decisions/internals/actor-flow-drives-the-target-through-a-transport-seam.md +1 -1
- package/knowledge/decisions/internals/{ai-agent-agui-bridge-obeys-the-client-ordering-contract.md → agent-agui-bridge-obeys-the-client-ordering-contract.md} +5 -5
- package/knowledge/decisions/internals/{ai-agent-audio-chunks-carry-the-format-the-provider-returned.md → agent-audio-chunks-carry-the-format-the-provider-returned.md} +2 -2
- package/knowledge/decisions/internals/agent-context-waits-for-a-tool-result-still-being-written.md +1 -1
- package/knowledge/decisions/internals/{ai-agent-credential-suspensions-hide-the-tool-result.md → agent-credential-suspensions-hide-the-tool-result.md} +2 -2
- package/knowledge/decisions/internals/{ai-agent-delegate-and-supervise-hide-different-text.md → agent-delegate-and-supervise-hide-different-text.md} +4 -4
- package/knowledge/decisions/internals/{ai-agent-llm-tool-arguments-have-nulls-stripped.md → agent-llm-tool-arguments-have-nulls-stripped.md} +3 -3
- package/knowledge/decisions/internals/{ai-agent-model-config-stays-a-single-resolution-seam.md → agent-model-config-stays-a-single-resolution-seam.md} +3 -3
- package/knowledge/decisions/internals/{ai-agent-onerror-hooks-cannot-change-the-failure.md → agent-onerror-hooks-cannot-change-the-failure.md} +6 -6
- package/knowledge/decisions/internals/{ai-agent-runner-methods-must-keep-their-receiver.md → agent-runner-methods-must-keep-their-receiver.md} +4 -4
- package/knowledge/decisions/internals/agent-speech-travels-as-a-custom-agui-event.md +1 -1
- package/knowledge/decisions/internals/{ai-agent-stream-persistence-is-best-effort.md → agent-stream-persistence-is-best-effort.md} +4 -4
- package/knowledge/decisions/internals/{ai-agent-sub-agents-inherit-the-parent-context-block.md → agent-sub-agents-inherit-the-parent-context-block.md} +3 -3
- package/knowledge/decisions/internals/{ai-agent-tool-execute-failures-are-logged-unconditionally.md → agent-tool-execute-failures-are-logged-unconditionally.md} +3 -3
- package/knowledge/decisions/internals/{ai-agent-voice-input-transcribes-audio-parts-in-place.md → agent-voice-input-transcribes-audio-parts-in-place.md} +2 -2
- package/knowledge/decisions/internals/{ai-agent-working-memory-is-persisted-only-when-valid.md → agent-working-memory-is-persisted-only-when-valid.md} +2 -2
- package/knowledge/decisions/internals/an-agent-interrupt-is-not-a-failure.md +2 -2
- package/knowledge/decisions/internals/an-agent-run-owned-by-another-instance-says-so.md +3 -3
- package/knowledge/decisions/internals/an-agent-stream-send-must-return-the-inner-sends-promise.md +2 -2
- package/knowledge/decisions/internals/an-empty-text-part-is-omitted-from-an-agent-message.md +1 -1
- package/knowledge/decisions/internals/an-empty-transcript-is-not-recorded.md +1 -1
- package/knowledge/decisions/internals/speech-synthesis-picks-a-voice-per-sentence-and-warns-once.md +1 -1
- package/knowledge/decisions/internals/the-agent-done-event-goes-through-the-middleware-and-is-awaited.md +1 -1
- package/knowledge/decisions/internals/the-embedding-model-is-pinned-per-service-and-doc-query-embedding-is-split.md +1 -1
- package/knowledge/decisions/internals/the-per-invocation-rpc-view-is-a-class.md +5 -5
- package/knowledge/decisions/internals/the-transcript-event-is-sent-ahead-of-the-run.md +2 -2
- package/knowledge/decisions/internals/thread-history-records-the-transcript-not-the-audio.md +2 -2
- package/knowledge/decisions/internals/voice-output-speaks-unless-voice-input-explicitly-says-otherwise.md +1 -1
- package/knowledge/decisions/security/{ai-agent-approval-forwarding-requires-a-symbol-brand.md → agent-approval-forwarding-requires-a-symbol-brand.md} +3 -3
- package/knowledge/decisions/security/{ai-agent-credential-requests-are-symbol-branded.md → agent-credential-requests-are-symbol-branded.md} +4 -4
- package/knowledge/decisions/security/{ai-agent-gate-requires-a-session-only-when-auth-is-true.md → agent-gate-requires-a-session-only-when-auth-is-true.md} +3 -3
- package/knowledge/decisions/security/{ai-agent-ownership-failures-never-echo-the-resource.md → agent-ownership-failures-never-echo-the-resource.md} +2 -2
- package/knowledge/decisions/security/{ai-agent-resume-re-runs-the-authorization-gate.md → agent-resume-re-runs-the-authorization-gate.md} +4 -4
- package/knowledge/decisions/security/{ai-agent-sessionless-deployments-have-no-thread-ownership.md → agent-sessionless-deployments-have-no-thread-ownership.md} +5 -5
- package/knowledge/decisions/security/{ai-agent-thread-ownership-composes-the-session-principal.md → agent-thread-ownership-composes-the-session-principal.md} +2 -2
- package/knowledge/decisions/security/{ai-agent-tool-filtering-reads-the-live-function-config.md → agent-tool-filtering-reads-the-live-function-config.md} +2 -2
- package/knowledge/decisions/security/an-agent-approval-is-claimed-before-the-tool-runs.md +3 -3
- package/knowledge/decisions/security/an-empty-owners-constraint-matches-nothing.md +3 -3
- package/knowledge/decisions/security/console-addon-privileged-functions-gate-themselves.md +20 -13
- package/knowledge/decisions/security/index.md +1 -2
- package/package.json +4 -4
- package/scripts/generate-api-report.mts +32 -8
- package/src/agent-naming.test.ts +68 -0
- package/src/ecosystem/agent-scorer.ts +24 -0
- package/src/ecosystem/agent.ts +42 -0
- package/src/ecosystem/channel/local.ts +1 -0
- package/src/ecosystem/channel.ts +22 -0
- package/src/ecosystem/cli/channel.ts +25 -0
- package/src/ecosystem/cli.ts +21 -0
- package/src/ecosystem/credential.ts +10 -0
- package/src/ecosystem/dev.ts +12 -0
- package/src/ecosystem/function.ts +28 -0
- package/src/ecosystem/gateway.ts +4 -0
- package/src/ecosystem/hmac.ts +1 -0
- package/src/ecosystem/http.ts +22 -0
- package/src/ecosystem/mcp.ts +17 -0
- package/src/ecosystem/middleware.ts +27 -0
- package/src/ecosystem/node-host-resolver.ts +1 -0
- package/src/ecosystem/node.ts +5 -0
- package/src/ecosystem/oauth2.ts +4 -0
- package/src/ecosystem/persona.ts +30 -0
- package/src/ecosystem/queue.ts +23 -0
- package/src/ecosystem/remote.ts +9 -0
- package/src/ecosystem/role.ts +13 -0
- package/src/ecosystem/rpc.ts +7 -0
- package/src/ecosystem/safe-fetch.ts +8 -0
- package/src/ecosystem/scenario.ts +32 -0
- package/src/ecosystem/scheduler.ts +5 -0
- package/src/ecosystem/schema.ts +1 -0
- package/src/ecosystem/scope.ts +14 -0
- package/src/ecosystem/secret.ts +15 -0
- package/src/ecosystem/services/istanbul-coverage.ts +1 -0
- package/src/ecosystem/services/local-content-request-handler.ts +16 -0
- package/src/ecosystem/services/local-content.ts +1 -0
- package/src/ecosystem/services/v8-coverage.ts +1 -0
- package/src/ecosystem/services.ts +82 -0
- package/src/ecosystem/testing.ts +8 -0
- package/src/ecosystem/trigger.ts +7 -0
- package/src/ecosystem/types.ts +34 -0
- package/src/ecosystem/variable.ts +14 -0
- package/src/ecosystem/virtual-user.ts +48 -0
- package/src/ecosystem/workflow.ts +68 -0
- package/src/index.ts +8 -19
- package/src/pikku-state.ts +3 -3
- package/src/public-surface.json +183 -91
- package/src/public-surface.json.README +20 -2
- package/src/public-surface.test.ts +31 -3
- package/src/services/{ai-run-state-service.ts → agent-run-state-service.ts} +5 -5
- package/src/services/{ai-agent-runner-service.ts → agent-runner-service.ts} +18 -18
- package/src/services/{ai-storage-service.ts → agent-storage-service.ts} +7 -7
- package/src/services/http-personas-converse.test.ts +3 -3
- package/src/services/http-personas.ts +4 -4
- package/src/services/{in-memory-ai-run-state-service.ts → in-memory-agent-run-state-service.ts} +7 -7
- package/src/services/index.ts +13 -24
- package/src/services/meta-service.ts +5 -7
- package/src/testing/service-tests/agent-run-service-tests.ts +4 -4
- package/src/testing/service-tests/{ai-storage-service-tests.ts → agent-storage-service-tests.ts} +8 -8
- package/src/testing/service-tests.ts +10 -8
- package/src/types/core.types.ts +13 -13
- package/src/types/state.types.ts +11 -10
- package/src/wirings/actor-flow/run-conversation.test.ts +2 -2
- package/src/wirings/actor-flow/run-conversation.ts +7 -9
- package/src/wirings/{ai-agent/ai-agent-agui.test.ts → agent/agent-agui.test.ts} +126 -105
- package/src/wirings/{ai-agent/ai-agent-agui.ts → agent/agent-agui.ts} +7 -7
- package/src/wirings/{ai-agent/ai-agent-authorization.test.ts → agent/agent-authorization.test.ts} +6 -6
- package/src/wirings/{ai-agent/ai-agent-finalize.test.ts → agent/agent-finalize.test.ts} +17 -16
- package/src/wirings/{ai-agent/ai-agent-finalize.ts → agent/agent-finalize.ts} +22 -22
- package/src/wirings/{ai-agent/ai-agent-helpers.test.ts → agent/agent-helpers.test.ts} +1 -1
- package/src/wirings/{ai-agent/ai-agent-helpers.ts → agent/agent-helpers.ts} +1 -1
- package/src/wirings/{ai-agent/ai-agent-interrupt.test.ts → agent/agent-interrupt.test.ts} +67 -77
- package/src/wirings/{ai-agent/ai-agent-interrupt.ts → agent/agent-interrupt.ts} +5 -5
- package/src/wirings/{ai-agent/ai-agent-memory.test.ts → agent/agent-memory.test.ts} +12 -12
- package/src/wirings/{ai-agent/ai-agent-memory.ts → agent/agent-memory.ts} +36 -36
- package/src/wirings/{ai-agent/ai-agent-model-config.test.ts → agent/agent-model-config.test.ts} +2 -5
- package/src/wirings/{ai-agent/ai-agent-model-config.ts → agent/agent-model-config.ts} +1 -1
- package/src/wirings/{ai-agent/ai-agent-prepare.test.ts → agent/agent-prepare.test.ts} +18 -18
- package/src/wirings/{ai-agent/ai-agent-prepare.ts → agent/agent-prepare.ts} +54 -51
- package/src/wirings/{ai-agent/ai-agent-registry.test.ts → agent/agent-registry.test.ts} +49 -43
- package/src/wirings/{ai-agent/ai-agent-registry.ts → agent/agent-registry.ts} +14 -14
- package/src/wirings/{ai-agent/ai-agent-resume-authorization.test.ts → agent/agent-resume-authorization.test.ts} +18 -18
- package/src/wirings/{ai-agent → agent}/agent-rpc.ts +16 -20
- package/src/wirings/{ai-agent/ai-agent-runner.test.ts → agent/agent-runner.test.ts} +105 -106
- package/src/wirings/{ai-agent/ai-agent-runner.ts → agent/agent-runner.ts} +90 -80
- package/src/wirings/{ai-agent/ai-agent-stream-output-hooks.test.ts → agent/agent-stream-output-hooks.test.ts} +25 -25
- package/src/wirings/{ai-agent/ai-agent-stream.test.ts → agent/agent-stream.test.ts} +147 -143
- package/src/wirings/{ai-agent/ai-agent-stream.ts → agent/agent-stream.ts} +147 -146
- package/src/wirings/{ai-agent/ai-agent-thread-ownership.test.ts → agent/agent-thread-ownership.test.ts} +24 -28
- package/src/wirings/{ai-agent/ai-agent-turn.test.ts → agent/agent-turn.test.ts} +3 -5
- package/src/wirings/{ai-agent/ai-agent-turn.ts → agent/agent-turn.ts} +7 -7
- package/src/wirings/{ai-agent/ai-agent.types.ts → agent/agent.types.ts} +51 -48
- package/src/wirings/agent/index.ts +56 -0
- package/src/wirings/{ai-agent → agent}/voice-input.test.ts +15 -15
- package/src/wirings/{ai-agent → agent}/voice-input.ts +11 -11
- package/src/wirings/{ai-agent → agent}/voice-output.test.ts +23 -23
- package/src/wirings/{ai-agent → agent}/voice-output.ts +11 -11
- package/src/wirings/{ai-scorer/ai-scorer-grade.test.ts → agent-scorer/agent-scorer-grade.test.ts} +8 -8
- package/src/wirings/{ai-scorer/ai-scorer-grade.ts → agent-scorer/agent-scorer-grade.ts} +9 -9
- package/src/wirings/{ai-scorer/ai-scorer-judge.test.ts → agent-scorer/agent-scorer-judge.test.ts} +11 -14
- package/src/wirings/{ai-scorer/ai-scorer-judge.ts → agent-scorer/agent-scorer-judge.ts} +11 -11
- package/src/wirings/{ai-scorer/ai-scorer-live.test.ts → agent-scorer/agent-scorer-live.test.ts} +11 -11
- package/src/wirings/{ai-scorer/ai-scorer-live.ts → agent-scorer/agent-scorer-live.ts} +3 -3
- package/src/wirings/{ai-scorer/ai-scorer-registry.ts → agent-scorer/agent-scorer-registry.ts} +11 -8
- package/src/wirings/{ai-scorer/ai-scorer-sampling.test.ts → agent-scorer/agent-scorer-sampling.test.ts} +1 -1
- package/src/wirings/{ai-scorer/ai-scorer-snapshots.test.ts → agent-scorer/agent-scorer-snapshots.test.ts} +2 -2
- package/src/wirings/{ai-scorer/ai-scorer-snapshots.ts → agent-scorer/agent-scorer-snapshots.ts} +1 -1
- package/src/wirings/{ai-scorer/ai-scorer-worker.test.ts → agent-scorer/agent-scorer-worker.test.ts} +15 -15
- package/src/wirings/{ai-scorer/ai-scorer-worker.ts → agent-scorer/agent-scorer-worker.ts} +9 -7
- package/src/wirings/{ai-scorer/ai-scorer.ts → agent-scorer/agent-scorer.ts} +7 -7
- package/src/wirings/{ai-scorer/ai-scorer.types.ts → agent-scorer/agent-scorer.types.ts} +6 -6
- package/src/wirings/agent-scorer/index.ts +22 -0
- package/src/wirings/channel/channel-rpc.types.ts +2 -2
- package/src/wirings/rpc/addon-runner.ts +31 -3
- package/src/wirings/rpc/addon-secrets.test.ts +130 -0
- package/src/wirings/rpc/rpc-runner.ts +4 -2
- package/src/wirings/rpc/rpc-types.ts +5 -1
- package/src/wirings/rpc/wire-addon.ts +16 -0
- package/src/wirings/virtual-user/prepare-virtual-user-run.ts +1 -1
- package/src/wirings/virtual-user/run-virtual-user.test.ts +2 -2
- package/src/wirings/virtual-user/run-virtual-user.ts +3 -3
- package/src/wirings/virtual-user/virtual-user-agents.ts +1 -1
- package/src/wirings/workflow/feature.ts +2 -5
- package/src/wirings/workflow/index.ts +1 -49
- package/src/wirings/workflow/pikku-scenario-service.ts +21 -1
- package/src/wirings/workflow/run-timeline.ts +1 -1
- package/src/wirings/workflow/scenario.types.ts +63 -0
- package/src/wirings/workflow/workflow.types.ts +1 -54
- package/src/wirings-stay-decoupled.test.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/src/wirings/ai-agent/index.ts +0 -65
- package/src/wirings/ai-scorer/index.ts +0 -24
- /package/src/wirings/{ai-agent/ai-agent-utils.ts → agent/agent-utils.ts} +0 -0
- /package/src/wirings/{ai-scorer/ai-scorer-sampling.ts → agent-scorer/agent-scorer-sampling.ts} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class InMemoryAgentRunStateService {
|
|
2
|
+
runs = new Map();
|
|
3
|
+
scores = new Map();
|
|
4
|
+
counter = 0;
|
|
5
|
+
async createRun(run) {
|
|
6
|
+
const runId = `run-${++this.counter}-${Date.now()}`;
|
|
7
|
+
this.runs.set(runId, { ...run, runId });
|
|
8
|
+
return runId;
|
|
9
|
+
}
|
|
10
|
+
async updateRun(runId, updates) {
|
|
11
|
+
const run = this.runs.get(runId);
|
|
12
|
+
if (run) {
|
|
13
|
+
Object.assign(run, updates, { updatedAt: new Date() });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async getRun(runId) {
|
|
17
|
+
return this.runs.get(runId) ?? null;
|
|
18
|
+
}
|
|
19
|
+
async getRunsByThread(threadId) {
|
|
20
|
+
return [...this.runs.values()].filter((r) => r.threadId === threadId);
|
|
21
|
+
}
|
|
22
|
+
async resolveApproval(toolCallId, status) {
|
|
23
|
+
for (const run of this.runs.values()) {
|
|
24
|
+
if (run.pendingApprovals) {
|
|
25
|
+
const approval = run.pendingApprovals.find((a) => a.toolCallId === toolCallId);
|
|
26
|
+
if (approval) {
|
|
27
|
+
run.pendingApprovals = run.pendingApprovals.filter((a) => a.toolCallId !== toolCallId);
|
|
28
|
+
run.updatedAt = new Date();
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
async findRunByToolCallId(toolCallId) {
|
|
36
|
+
for (const run of this.runs.values()) {
|
|
37
|
+
if (run.pendingApprovals) {
|
|
38
|
+
const approval = run.pendingApprovals.find((a) => a.toolCallId === toolCallId);
|
|
39
|
+
if (approval) {
|
|
40
|
+
return { run, approval };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
async saveScore(score) {
|
|
47
|
+
const existing = this.scores.get(score.runId) ?? [];
|
|
48
|
+
existing.push({ ...score, createdAt: new Date() });
|
|
49
|
+
this.scores.set(score.runId, existing);
|
|
50
|
+
}
|
|
51
|
+
async getScores(runId) {
|
|
52
|
+
return [...(this.scores.get(runId) ?? [])];
|
|
53
|
+
}
|
|
54
|
+
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ScopedSecretService } from './scoped-secret-service.js';
|
|
|
3
3
|
export { ScopedCredentialService } from './scoped-credential-service.js';
|
|
4
4
|
export { PikkuSessionService, createMiddlewareSessionWireProps, } from './user-session-service.js';
|
|
5
5
|
export { TypedSecretService } from './typed-secret-service.js';
|
|
6
|
-
export { PikkuCredentialWireService
|
|
6
|
+
export { PikkuCredentialWireService } from './credential-wire-service.js';
|
|
7
7
|
export { TypedVariablesService } from './typed-variables-service.js';
|
|
8
8
|
export { LocalSecretService } from './local-secrets.js';
|
|
9
9
|
export { LocalEmailService } from './local-email-service.js';
|
|
@@ -14,11 +14,10 @@ export { InMemoryWorkflowService } from './in-memory-workflow-service.js';
|
|
|
14
14
|
export { QueueWebhookService, pikkuWebhookWorkerFunc, } from './queue-webhook-service.js';
|
|
15
15
|
export { InMemoryQueueService } from './in-memory-queue-service.js';
|
|
16
16
|
export { InMemoryTriggerService } from './in-memory-trigger-service.js';
|
|
17
|
-
export {
|
|
17
|
+
export { InMemoryAgentRunStateService } from './in-memory-agent-run-state-service.js';
|
|
18
18
|
export { LocalGatewayService } from './local-gateway-service.js';
|
|
19
19
|
export type { ContentService, SignContentKeyArgs, SignURLArgs, GetUploadURLArgs, UploadURLResult, BucketKeyArgs, WriteFileArgs, CopyFileArgs, } from './content-service.js';
|
|
20
|
-
export type { ScenarioPersona, ResolvedPersona, ScenarioPersonas,
|
|
21
|
-
export type { HttpPersonasConfig } from './http-personas.js';
|
|
20
|
+
export type { ScenarioPersona, ResolvedPersona, ScenarioPersonas, } from './personas-service.js';
|
|
22
21
|
export type { JWTService } from './jwt-service.js';
|
|
23
22
|
export type { EmailService, SendEmailInput, SendEmailResult, SendHTMLEmailInput, SendTemplateEmailInput, SendTextEmailInput, } from './email-service.js';
|
|
24
23
|
export { DEFAULT_WEBHOOK_RETRIES, PIKKU_OUTGOING_WEBHOOK_QUEUE_NAME, WebhookService, type SendWebhookInput, type SendWebhookResult, type WebhookAttemptResult, type WebhookDeliveryRecord, type WebhookDeliveryWithAttempts, type WebhookJobData, type WebhookServiceConfig, } from './webhook-service.js';
|
|
@@ -31,20 +30,20 @@ export type { ScheduledTaskSummary, ScheduledTaskInfo, SchedulerService, } from
|
|
|
31
30
|
export type { TriggerService } from './trigger-service.js';
|
|
32
31
|
export type { GatewayService } from './gateway-service.js';
|
|
33
32
|
export type { DeploymentService, DeploymentConfig, DeploymentInfo, DeploymentServiceConfig, } from './deployment-service.js';
|
|
34
|
-
export type {
|
|
35
|
-
export type {
|
|
33
|
+
export type { AgentStorageService } from './agent-storage-service.js';
|
|
34
|
+
export type { AgentRunnerParams, AgentRunnerResult, AgentStepResult, AgentRunnerService, } from './agent-runner-service.js';
|
|
36
35
|
export type { AIEmbeddingService } from './ai-embedding-service.js';
|
|
37
|
-
export type { CreateRunInput, SaveScoreInput,
|
|
38
|
-
export type { CredentialMeta
|
|
36
|
+
export type { CreateRunInput, SaveScoreInput, AgentRunStateService, } from './agent-run-state-service.js';
|
|
37
|
+
export type { CredentialMeta } from './typed-secret-service.js';
|
|
39
38
|
export type { CredentialService } from './credential-service.js';
|
|
40
39
|
export { TypedCredentialService } from './typed-credential-service.js';
|
|
41
|
-
export type { CredentialMetaInfo
|
|
40
|
+
export type { CredentialMetaInfo } from './typed-credential-service.js';
|
|
42
41
|
export type { VariableMeta } from './typed-variables-service.js';
|
|
43
42
|
export type { MetaService } from './meta-service.js';
|
|
44
43
|
export type { SessionStore } from './session-store.js';
|
|
45
44
|
export type { ScopeService, Role } from './scope-service.js';
|
|
46
45
|
export type { IsSystemRole } from './system-role-guard.js';
|
|
47
|
-
export { NoopAuditService, createInvocationAudit
|
|
46
|
+
export { NoopAuditService, createInvocationAudit } from './audit-service.js';
|
|
48
47
|
export type { AuditConfig, AuditDurability, AuditEvent, AuditEventBatch, AuditLog, AuditService, AuditUserIdentity, ResolvedAuditConfig, } from './audit-service.js';
|
|
49
48
|
export { InMemorySessionStore } from './in-memory-session-store.js';
|
|
50
49
|
export type { MCPMeta, RPCMetaRecord, ServiceMeta, ServicesMetaRecord, MiddlewareDefinitionMeta, MiddlewareInstanceMeta, GroupMeta, MiddlewareGroupsMeta, PermissionDefinitionMeta, PermissionsGroupsMeta, FunctionsMeta, FunctionMeta, MiddlewareMeta, PermissionMeta, AgentsMeta, AgentMeta, EmailsMeta, EmailTemplateMeta, } from './meta-service.js';
|
package/dist/services/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { ScopedSecretService } from './scoped-secret-service.js';
|
|
|
3
3
|
export { ScopedCredentialService } from './scoped-credential-service.js';
|
|
4
4
|
export { PikkuSessionService, createMiddlewareSessionWireProps, } from './user-session-service.js';
|
|
5
5
|
export { TypedSecretService } from './typed-secret-service.js';
|
|
6
|
-
export { PikkuCredentialWireService
|
|
6
|
+
export { PikkuCredentialWireService } from './credential-wire-service.js';
|
|
7
7
|
export { TypedVariablesService } from './typed-variables-service.js';
|
|
8
8
|
export { LocalSecretService } from './local-secrets.js';
|
|
9
9
|
export { LocalEmailService } from './local-email-service.js';
|
|
@@ -14,11 +14,11 @@ export { InMemoryWorkflowService } from './in-memory-workflow-service.js';
|
|
|
14
14
|
export { QueueWebhookService, pikkuWebhookWorkerFunc, } from './queue-webhook-service.js';
|
|
15
15
|
export { InMemoryQueueService } from './in-memory-queue-service.js';
|
|
16
16
|
export { InMemoryTriggerService } from './in-memory-trigger-service.js';
|
|
17
|
-
export {
|
|
17
|
+
export { InMemoryAgentRunStateService } from './in-memory-agent-run-state-service.js';
|
|
18
18
|
export { LocalGatewayService } from './local-gateway-service.js';
|
|
19
19
|
export { DEFAULT_WEBHOOK_RETRIES, PIKKU_OUTGOING_WEBHOOK_QUEUE_NAME, WebhookService, } from './webhook-service.js';
|
|
20
20
|
export { TypedCredentialService } from './typed-credential-service.js';
|
|
21
|
-
export { NoopAuditService, createInvocationAudit
|
|
21
|
+
export { NoopAuditService, createInvocationAudit } from './audit-service.js';
|
|
22
22
|
export { InMemorySessionStore } from './in-memory-session-store.js';
|
|
23
23
|
export { StubTracker, createStubProxy, getStubTracker, isTestRun, stub, spy, } from './stub-tracker.js';
|
|
24
24
|
export { SecretHostNotAllowedError, assertSecretAllowedForHost, } from './secret-host-binding.js';
|
|
@@ -5,7 +5,8 @@ import type { ScheduledTasksMeta } from '../wirings/scheduler/scheduler.types.js
|
|
|
5
5
|
import type { QueueWorkersMeta } from '../wirings/queue/queue.types.js';
|
|
6
6
|
import type { CLIMeta } from '../wirings/cli/cli.types.js';
|
|
7
7
|
import type { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '../wirings/mcp/mcp.types.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { WorkflowsMeta } from '../wirings/workflow/workflow.types.js';
|
|
9
|
+
import type { FeaturesMeta } from '../wirings/workflow/scenario.types.js';
|
|
9
10
|
import type { ResolvedPersona } from './personas-service.js';
|
|
10
11
|
import type { SystemRoleDefinitionsMeta } from '../wirings/role/role.types.js';
|
|
11
12
|
import type { TriggerMeta, TriggerSourceMeta } from '../wirings/trigger/trigger.types.js';
|
|
@@ -13,11 +14,11 @@ import type { SecretDefinitionsMeta } from '../wirings/secret/secret.types.js';
|
|
|
13
14
|
import type { CredentialDefinitionsMeta } from '../wirings/credential/credential.types.js';
|
|
14
15
|
import type { VariableDefinitionsMeta } from '../wirings/variable/variable.types.js';
|
|
15
16
|
import type { FunctionMeta, FunctionsMeta, MiddlewareMetadata, PermissionMetadata } from '../types/core.types.js';
|
|
16
|
-
import type {
|
|
17
|
+
import type { AgentsMeta } from '../wirings/agent/agent.types.js';
|
|
17
18
|
import type { GatewaysMeta } from '../wirings/gateway/gateway.types.js';
|
|
18
19
|
export type { FunctionMeta, FunctionsMeta, MiddlewareMetadata as MiddlewareMeta, PermissionMetadata as PermissionMeta, };
|
|
19
|
-
export type AgentsMeta
|
|
20
|
-
export type AgentMeta =
|
|
20
|
+
export type { AgentsMeta };
|
|
21
|
+
export type AgentMeta = AgentsMeta[string];
|
|
21
22
|
export interface MCPMeta {
|
|
22
23
|
resources: MCPResourceMeta;
|
|
23
24
|
tools: MCPToolMeta;
|
|
@@ -7,4 +7,4 @@ export declare const defineAgentRunServiceTests: (name: string, agentRunService:
|
|
|
7
7
|
* only runs when a backend supplies both. Passed explicitly rather than
|
|
8
8
|
* closed over, so the dependency is visible in the signature.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
agentStorageService?: ServiceTestConfig["services"]["agentStorageService"]) => void;
|
|
@@ -8,7 +8,7 @@ export const defineAgentRunServiceTests = (name, agentRunService,
|
|
|
8
8
|
* only runs when a backend supplies both. Passed explicitly rather than
|
|
9
9
|
* closed over, so the dependency is visible in the signature.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
agentStorageService) => {
|
|
12
12
|
const factory = agentRunService;
|
|
13
13
|
describe(`AgentRunService [${name}]`, () => {
|
|
14
14
|
let agentService;
|
|
@@ -19,8 +19,8 @@ aiStorageService) => {
|
|
|
19
19
|
const threads = await agentService.listThreads();
|
|
20
20
|
assert.ok(Array.isArray(threads));
|
|
21
21
|
});
|
|
22
|
-
if (
|
|
23
|
-
const storageFactory =
|
|
22
|
+
if (agentStorageService) {
|
|
23
|
+
const storageFactory = agentStorageService;
|
|
24
24
|
// The `owners` constraint is what keeps the generated thread-management
|
|
25
25
|
// functions from leaking across tenants: a caller may only list threads
|
|
26
26
|
// owned by one of their session principals, matching the
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ServiceTestConfig } from '../service-tests.js';
|
|
2
|
+
/** Conformance suite for `agentStorageService`. Runs only when a backend supplies one. */
|
|
3
|
+
export declare const defineAiStorageServiceTests: (name: string, agentStorageService: NonNullable<ServiceTestConfig["services"]["agentStorageService"]>) => void;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { describe, test, before } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
/** Conformance suite for `agentStorageService`. Runs only when a backend supplies one. */
|
|
4
|
+
export const defineAiStorageServiceTests = (name, agentStorageService) => {
|
|
5
|
+
const factory = agentStorageService;
|
|
6
|
+
describe(`AgentStorageService [${name}]`, () => {
|
|
7
|
+
let storage;
|
|
8
|
+
before(async () => {
|
|
9
|
+
storage = await factory();
|
|
10
|
+
});
|
|
11
|
+
test('createThread and getThread', async () => {
|
|
12
|
+
const thread = await storage.createThread('resource-1', {
|
|
13
|
+
title: 'Test Thread',
|
|
14
|
+
metadata: { key: 'val' },
|
|
15
|
+
});
|
|
16
|
+
assert.ok(thread.id);
|
|
17
|
+
assert.equal(thread.resourceId, 'resource-1');
|
|
18
|
+
assert.equal(thread.title, 'Test Thread');
|
|
19
|
+
assert.deepEqual(thread.metadata, { key: 'val' });
|
|
20
|
+
const fetched = await storage.getThread(thread.id);
|
|
21
|
+
assert.equal(fetched.id, thread.id);
|
|
22
|
+
assert.equal(fetched.title, 'Test Thread');
|
|
23
|
+
});
|
|
24
|
+
test('getThreads', async () => {
|
|
25
|
+
const threads = await storage.getThreads('resource-1');
|
|
26
|
+
assert.ok(threads.length >= 1);
|
|
27
|
+
assert.ok(threads.every((t) => t.resourceId === 'resource-1'));
|
|
28
|
+
});
|
|
29
|
+
test('getThread throws for missing', async () => {
|
|
30
|
+
await assert.rejects(() => storage.getThread('missing-thread'));
|
|
31
|
+
});
|
|
32
|
+
test('saveMessages and getMessages', async () => {
|
|
33
|
+
const thread = await storage.createThread('resource-2');
|
|
34
|
+
const now = new Date();
|
|
35
|
+
await storage.saveMessages(thread.id, [
|
|
36
|
+
{ id: 'msg-1', role: 'user', content: 'Hello', createdAt: now },
|
|
37
|
+
{
|
|
38
|
+
id: 'msg-2',
|
|
39
|
+
role: 'assistant',
|
|
40
|
+
content: 'Hi there',
|
|
41
|
+
createdAt: new Date(now.getTime() + 1000),
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
const messages = await storage.getMessages(thread.id);
|
|
45
|
+
assert.equal(messages.length, 2);
|
|
46
|
+
assert.equal(messages[0].role, 'user');
|
|
47
|
+
assert.equal(messages[0].content, 'Hello');
|
|
48
|
+
assert.equal(messages[1].role, 'assistant');
|
|
49
|
+
assert.equal(messages[1].content, 'Hi there');
|
|
50
|
+
});
|
|
51
|
+
test('saveMessages with tool calls and results', async () => {
|
|
52
|
+
const thread = await storage.createThread('resource-3');
|
|
53
|
+
const now = new Date();
|
|
54
|
+
await storage.saveMessages(thread.id, [
|
|
55
|
+
{
|
|
56
|
+
id: 'msg-tc',
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
content: 'Let me call a tool',
|
|
59
|
+
toolCalls: [{ id: 'tc-1', name: 'search', args: { query: 'test' } }],
|
|
60
|
+
createdAt: now,
|
|
61
|
+
},
|
|
62
|
+
]);
|
|
63
|
+
await storage.saveMessages(thread.id, [
|
|
64
|
+
{
|
|
65
|
+
id: 'tool-results-msg-tc',
|
|
66
|
+
role: 'tool',
|
|
67
|
+
toolResults: [{ id: 'tc-1', name: 'search', result: 'found it' }],
|
|
68
|
+
createdAt: new Date(now.getTime() + 1000),
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
const messages = await storage.getMessages(thread.id);
|
|
72
|
+
assert.equal(messages.length, 2);
|
|
73
|
+
const assistantMsg = messages[0];
|
|
74
|
+
assert.equal(assistantMsg.role, 'assistant');
|
|
75
|
+
assert.ok(assistantMsg.toolCalls);
|
|
76
|
+
assert.equal(assistantMsg.toolCalls[0].name, 'search');
|
|
77
|
+
const toolMsg = messages[1];
|
|
78
|
+
assert.equal(toolMsg.role, 'tool');
|
|
79
|
+
assert.ok(toolMsg.toolResults);
|
|
80
|
+
assert.equal(toolMsg.toolResults[0].result, 'found it');
|
|
81
|
+
});
|
|
82
|
+
test('getMessages with lastN', async () => {
|
|
83
|
+
const thread = await storage.createThread('resource-4');
|
|
84
|
+
const base = Date.now();
|
|
85
|
+
await storage.saveMessages(thread.id, Array.from({ length: 5 }, (_, i) => ({
|
|
86
|
+
id: `bulk-msg-${i}`,
|
|
87
|
+
role: 'user',
|
|
88
|
+
content: `Message ${i}`,
|
|
89
|
+
createdAt: new Date(base + i * 1000),
|
|
90
|
+
})));
|
|
91
|
+
const messages = await storage.getMessages(thread.id, { lastN: 2 });
|
|
92
|
+
assert.equal(messages.length, 2);
|
|
93
|
+
assert.equal(messages[0].content, 'Message 3');
|
|
94
|
+
assert.equal(messages[1].content, 'Message 4');
|
|
95
|
+
});
|
|
96
|
+
test('working memory: save and get', async () => {
|
|
97
|
+
await storage.saveWorkingMemory('res-1', 'resource', {
|
|
98
|
+
key: 'value',
|
|
99
|
+
});
|
|
100
|
+
const mem = await storage.getWorkingMemory('res-1', 'resource');
|
|
101
|
+
assert.deepEqual(mem, { key: 'value' });
|
|
102
|
+
});
|
|
103
|
+
test('working memory: upsert overwrites', async () => {
|
|
104
|
+
await storage.saveWorkingMemory('res-1', 'resource', {
|
|
105
|
+
key: 'updated',
|
|
106
|
+
});
|
|
107
|
+
const mem = await storage.getWorkingMemory('res-1', 'resource');
|
|
108
|
+
assert.deepEqual(mem, { key: 'updated' });
|
|
109
|
+
});
|
|
110
|
+
test('working memory: returns null for missing', async () => {
|
|
111
|
+
const mem = await storage.getWorkingMemory('missing', 'thread');
|
|
112
|
+
assert.equal(mem, null);
|
|
113
|
+
});
|
|
114
|
+
test('createRun and getRun', async () => {
|
|
115
|
+
const thread = await storage.createThread('resource-5');
|
|
116
|
+
const now = new Date();
|
|
117
|
+
const runId = await storage.createRun({
|
|
118
|
+
agentName: 'test-agent',
|
|
119
|
+
threadId: thread.id,
|
|
120
|
+
resourceId: 'resource-5',
|
|
121
|
+
status: 'running',
|
|
122
|
+
usage: { inputTokens: 100, outputTokens: 50, model: 'test-model' },
|
|
123
|
+
createdAt: now,
|
|
124
|
+
updatedAt: now,
|
|
125
|
+
});
|
|
126
|
+
assert.ok(runId);
|
|
127
|
+
const run = await storage.getRun(runId);
|
|
128
|
+
assert.ok(run);
|
|
129
|
+
assert.equal(run.agentName, 'test-agent');
|
|
130
|
+
assert.equal(run.status, 'running');
|
|
131
|
+
assert.equal(run.usage.inputTokens, 100);
|
|
132
|
+
});
|
|
133
|
+
test('updateRun', async () => {
|
|
134
|
+
const thread = await storage.createThread('resource-6');
|
|
135
|
+
const now = new Date();
|
|
136
|
+
const runId = await storage.createRun({
|
|
137
|
+
agentName: 'update-agent',
|
|
138
|
+
threadId: thread.id,
|
|
139
|
+
resourceId: 'resource-6',
|
|
140
|
+
status: 'running',
|
|
141
|
+
usage: { inputTokens: 0, outputTokens: 0, model: 'test' },
|
|
142
|
+
createdAt: now,
|
|
143
|
+
updatedAt: now,
|
|
144
|
+
});
|
|
145
|
+
await storage.updateRun(runId, {
|
|
146
|
+
status: 'completed',
|
|
147
|
+
usage: { inputTokens: 200, outputTokens: 100, model: 'test-v2' },
|
|
148
|
+
});
|
|
149
|
+
const run = await storage.getRun(runId);
|
|
150
|
+
assert.ok(run);
|
|
151
|
+
assert.equal(run.status, 'completed');
|
|
152
|
+
assert.equal(run.usage.inputTokens, 200);
|
|
153
|
+
assert.equal(run.usage.model, 'test-v2');
|
|
154
|
+
});
|
|
155
|
+
test('getRunsByThread', async () => {
|
|
156
|
+
const thread = await storage.createThread('resource-7');
|
|
157
|
+
const now = new Date();
|
|
158
|
+
await storage.createRun({
|
|
159
|
+
agentName: 'multi-agent',
|
|
160
|
+
threadId: thread.id,
|
|
161
|
+
resourceId: 'resource-7',
|
|
162
|
+
status: 'completed',
|
|
163
|
+
usage: { inputTokens: 10, outputTokens: 5, model: 'test' },
|
|
164
|
+
createdAt: now,
|
|
165
|
+
updatedAt: now,
|
|
166
|
+
});
|
|
167
|
+
const runs = await storage.getRunsByThread(thread.id);
|
|
168
|
+
assert.ok(runs.length >= 1);
|
|
169
|
+
assert.ok(runs.every((r) => r.threadId === thread.id));
|
|
170
|
+
});
|
|
171
|
+
test('saveScore and getScores', async () => {
|
|
172
|
+
const thread = await storage.createThread('resource-score');
|
|
173
|
+
const now = new Date();
|
|
174
|
+
const runId = await storage.createRun({
|
|
175
|
+
agentName: 'scored-agent',
|
|
176
|
+
threadId: thread.id,
|
|
177
|
+
resourceId: 'resource-score',
|
|
178
|
+
status: 'completed',
|
|
179
|
+
usage: { inputTokens: 10, outputTokens: 5, model: 'test' },
|
|
180
|
+
createdAt: now,
|
|
181
|
+
updatedAt: now,
|
|
182
|
+
});
|
|
183
|
+
await storage.saveScore({
|
|
184
|
+
runId,
|
|
185
|
+
scorerName: 'tool-error-rate',
|
|
186
|
+
score: 1,
|
|
187
|
+
});
|
|
188
|
+
await storage.saveScore({
|
|
189
|
+
runId,
|
|
190
|
+
scorerName: 'helpfulness',
|
|
191
|
+
score: 0.75,
|
|
192
|
+
reason: 'answered the question but skipped the fee',
|
|
193
|
+
metadata: { subScores: { accuracy: 0.9 }, judgeTokens: 412 },
|
|
194
|
+
});
|
|
195
|
+
const scores = await storage.getScores(runId);
|
|
196
|
+
assert.equal(scores.length, 2);
|
|
197
|
+
const byName = new Map(scores.map((s) => [s.scorerName, s]));
|
|
198
|
+
const clean = byName.get('tool-error-rate');
|
|
199
|
+
assert.ok(clean);
|
|
200
|
+
assert.equal(clean.score, 1);
|
|
201
|
+
assert.equal(clean.reason, undefined);
|
|
202
|
+
assert.equal(clean.metadata, undefined);
|
|
203
|
+
const helpful = byName.get('helpfulness');
|
|
204
|
+
assert.ok(helpful);
|
|
205
|
+
// A fractional score has to survive the round trip: an integer column
|
|
206
|
+
// would quietly turn every grade into 0 or 1.
|
|
207
|
+
assert.equal(helpful.score, 0.75);
|
|
208
|
+
assert.equal(helpful.reason, 'answered the question but skipped the fee');
|
|
209
|
+
assert.deepEqual(helpful.metadata, {
|
|
210
|
+
subScores: { accuracy: 0.9 },
|
|
211
|
+
judgeTokens: 412,
|
|
212
|
+
});
|
|
213
|
+
assert.ok(helpful.createdAt instanceof Date);
|
|
214
|
+
});
|
|
215
|
+
test('a re-grade appends rather than replacing the grade that was acted on', async () => {
|
|
216
|
+
const thread = await storage.createThread('resource-regrade');
|
|
217
|
+
const now = new Date();
|
|
218
|
+
const runId = await storage.createRun({
|
|
219
|
+
agentName: 'regraded-agent',
|
|
220
|
+
threadId: thread.id,
|
|
221
|
+
resourceId: 'resource-regrade',
|
|
222
|
+
status: 'completed',
|
|
223
|
+
usage: { inputTokens: 1, outputTokens: 1, model: 'test' },
|
|
224
|
+
createdAt: now,
|
|
225
|
+
updatedAt: now,
|
|
226
|
+
});
|
|
227
|
+
await storage.saveScore({ runId, scorerName: 'helpfulness', score: 0.2 });
|
|
228
|
+
await storage.saveScore({ runId, scorerName: 'helpfulness', score: 0.8 });
|
|
229
|
+
const scores = await storage.getScores(runId);
|
|
230
|
+
assert.equal(scores.length, 2);
|
|
231
|
+
assert.deepEqual(scores.map((s) => s.score), [0.2, 0.8]);
|
|
232
|
+
});
|
|
233
|
+
test('getScores is empty for a run nothing graded', async () => {
|
|
234
|
+
const thread = await storage.createThread('resource-ungraded');
|
|
235
|
+
const now = new Date();
|
|
236
|
+
const runId = await storage.createRun({
|
|
237
|
+
agentName: 'ungraded-agent',
|
|
238
|
+
threadId: thread.id,
|
|
239
|
+
resourceId: 'resource-ungraded',
|
|
240
|
+
status: 'completed',
|
|
241
|
+
usage: { inputTokens: 1, outputTokens: 1, model: 'test' },
|
|
242
|
+
createdAt: now,
|
|
243
|
+
updatedAt: now,
|
|
244
|
+
});
|
|
245
|
+
assert.deepEqual(await storage.getScores(runId), []);
|
|
246
|
+
});
|
|
247
|
+
test('resolveApproval', async () => {
|
|
248
|
+
const thread = await storage.createThread('resource-8');
|
|
249
|
+
const now = new Date();
|
|
250
|
+
await storage.saveMessages(thread.id, [
|
|
251
|
+
{
|
|
252
|
+
id: 'approval-msg',
|
|
253
|
+
role: 'assistant',
|
|
254
|
+
toolCalls: [{ id: 'approval-tc', name: 'dangerous-tool', args: {} }],
|
|
255
|
+
createdAt: now,
|
|
256
|
+
},
|
|
257
|
+
]);
|
|
258
|
+
const runId = await storage.createRun({
|
|
259
|
+
agentName: 'approval-agent',
|
|
260
|
+
threadId: thread.id,
|
|
261
|
+
resourceId: 'resource-8',
|
|
262
|
+
status: 'suspended',
|
|
263
|
+
suspendReason: 'approval',
|
|
264
|
+
pendingApprovals: [
|
|
265
|
+
{
|
|
266
|
+
type: 'tool-call',
|
|
267
|
+
toolCallId: 'approval-tc',
|
|
268
|
+
toolName: 'dangerous-tool',
|
|
269
|
+
args: {},
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
usage: { inputTokens: 0, outputTokens: 0, model: 'test' },
|
|
273
|
+
createdAt: now,
|
|
274
|
+
updatedAt: now,
|
|
275
|
+
});
|
|
276
|
+
let run = await storage.getRun(runId);
|
|
277
|
+
assert.ok(run);
|
|
278
|
+
assert.ok(run.pendingApprovals);
|
|
279
|
+
assert.equal(run.pendingApprovals.length, 1);
|
|
280
|
+
const claimed = await storage.resolveApproval('approval-tc', 'approved');
|
|
281
|
+
assert.equal(claimed, true, 'the first approver claims the approval');
|
|
282
|
+
run = await storage.getRun(runId);
|
|
283
|
+
assert.ok(run);
|
|
284
|
+
assert.equal(run.pendingApprovals, undefined);
|
|
285
|
+
const second = await storage.resolveApproval('approval-tc', 'approved');
|
|
286
|
+
assert.equal(second, false, 'a second approver of the same tool call claims nothing');
|
|
287
|
+
});
|
|
288
|
+
test('deleteThread cascades', async () => {
|
|
289
|
+
const thread = await storage.createThread('resource-del');
|
|
290
|
+
await storage.saveMessages(thread.id, [
|
|
291
|
+
{
|
|
292
|
+
id: 'del-msg',
|
|
293
|
+
role: 'user',
|
|
294
|
+
content: 'goodbye',
|
|
295
|
+
createdAt: new Date(),
|
|
296
|
+
},
|
|
297
|
+
]);
|
|
298
|
+
await storage.deleteThread(thread.id);
|
|
299
|
+
await assert.rejects(() => storage.getThread(thread.id));
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
@@ -3,11 +3,11 @@ import type { EventHubStore } from '../wirings/channel/eventhub-store.js';
|
|
|
3
3
|
import type { PikkuWorkflowService } from '../wirings/workflow/pikku-workflow-service.js';
|
|
4
4
|
import type { WorkflowRunService } from '../wirings/workflow/workflow.types.js';
|
|
5
5
|
import type { DeploymentService } from '../services/deployment-service.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type { AgentStorageService } from '../services/agent-storage-service.js';
|
|
7
|
+
import type { AgentRunStateService } from '../services/agent-run-state-service.js';
|
|
8
8
|
import type { SecretService } from '../services/secret-service.js';
|
|
9
9
|
import type { CredentialService } from '../services/credential-service.js';
|
|
10
|
-
import type { AgentRunService } from '../wirings/
|
|
10
|
+
import type { AgentRunService } from '../wirings/agent/agent.types.js';
|
|
11
11
|
import type { SessionStore } from '../services/session-store.js';
|
|
12
12
|
export interface ServiceTestConfig {
|
|
13
13
|
name: string;
|
|
@@ -19,7 +19,7 @@ export interface ServiceTestConfig {
|
|
|
19
19
|
deploymentService?: () => Promise<DeploymentService & {
|
|
20
20
|
stop(): Promise<void>;
|
|
21
21
|
}>;
|
|
22
|
-
|
|
22
|
+
agentStorageService?: () => Promise<AgentStorageService & AgentRunStateService>;
|
|
23
23
|
agentRunService?: () => Promise<AgentRunService>;
|
|
24
24
|
secretService?: (config: {
|
|
25
25
|
key: string;
|
|
@@ -2,7 +2,7 @@ import { defineChannelStoreTests } from './service-tests/channel-store-tests.js'
|
|
|
2
2
|
import { defineEventHubStoreTests } from './service-tests/event-hub-store-tests.js';
|
|
3
3
|
import { defineWorkflowServiceTests } from './service-tests/workflow-service-tests.js';
|
|
4
4
|
import { defineWorkflowRunServiceTests } from './service-tests/workflow-run-service-tests.js';
|
|
5
|
-
import { defineAiStorageServiceTests } from './service-tests/
|
|
5
|
+
import { defineAiStorageServiceTests } from './service-tests/agent-storage-service-tests.js';
|
|
6
6
|
import { defineDeploymentServiceTests } from './service-tests/deployment-service-tests.js';
|
|
7
7
|
import { defineSecretServiceTests } from './service-tests/secret-service-tests.js';
|
|
8
8
|
import { defineCredentialServiceTests } from './service-tests/credential-service-tests.js';
|
|
@@ -28,8 +28,8 @@ export function defineServiceTests(config) {
|
|
|
28
28
|
if (services.workflowRunService) {
|
|
29
29
|
defineWorkflowRunServiceTests(name, services.workflowRunService);
|
|
30
30
|
}
|
|
31
|
-
if (services.
|
|
32
|
-
defineAiStorageServiceTests(name, services.
|
|
31
|
+
if (services.agentStorageService) {
|
|
32
|
+
defineAiStorageServiceTests(name, services.agentStorageService);
|
|
33
33
|
}
|
|
34
34
|
if (services.deploymentService) {
|
|
35
35
|
defineDeploymentServiceTests(name, services.deploymentService);
|
|
@@ -41,7 +41,7 @@ export function defineServiceTests(config) {
|
|
|
41
41
|
defineCredentialServiceTests(name, services.credentialService);
|
|
42
42
|
}
|
|
43
43
|
if (services.agentRunService) {
|
|
44
|
-
defineAgentRunServiceTests(name, services.agentRunService, services.
|
|
44
|
+
defineAgentRunServiceTests(name, services.agentRunService, services.agentStorageService);
|
|
45
45
|
}
|
|
46
46
|
if (services.sessionStore) {
|
|
47
47
|
defineSessionStoreTests(name, services.sessionStore);
|
|
@@ -11,22 +11,23 @@ import type { PikkuMCP } from '../wirings/mcp/mcp.types.js';
|
|
|
11
11
|
import type { PikkuScheduledTask } from '../wirings/scheduler/scheduler.types.js';
|
|
12
12
|
import type { PikkuQueue, QueueService } from '../wirings/queue/queue.types.js';
|
|
13
13
|
import type { PikkuCLI } from '../wirings/cli/cli.types.js';
|
|
14
|
-
import type { PikkuWorkflowWire,
|
|
14
|
+
import type { PikkuWorkflowWire, WorkflowService, WorkflowServiceConfig, WorkflowStepWire } from '../wirings/workflow/workflow.types.js';
|
|
15
|
+
import type { PikkuScenarioWire } from '../wirings/workflow/scenario.types.js';
|
|
15
16
|
import type { PikkuBrowserWire, PikkuScenarioStepWire, ScenarioStepKind, ScenarioSurface } from '../wirings/workflow/scenario-step.types.js';
|
|
16
17
|
import type { PikkuGraphWire } from '../wirings/workflow/graph/workflow-graph.types.js';
|
|
17
18
|
import type { PikkuTrigger } from '../wirings/trigger/trigger.types.js';
|
|
18
19
|
import type { PikkuGateway } from '../wirings/gateway/gateway.types.js';
|
|
19
20
|
import type { SchedulerService } from '../services/scheduler-service.js';
|
|
20
21
|
import type { DeploymentService } from '../services/deployment-service.js';
|
|
21
|
-
import type {
|
|
22
|
+
import type { AgentStorageService } from '../services/agent-storage-service.js';
|
|
22
23
|
import type { ContentService } from '../services/content-service.js';
|
|
23
24
|
import type { ScenarioPersonaOf, ScenarioPersonas } from '../services/personas-service.js';
|
|
24
|
-
import type {
|
|
25
|
+
import type { AgentRunnerService } from '../services/agent-runner-service.js';
|
|
25
26
|
import type { AIEmbeddingService } from '../services/ai-embedding-service.js';
|
|
26
|
-
import type {
|
|
27
|
-
import type { AgentRunService } from '../wirings/
|
|
27
|
+
import type { AgentRunStateService } from '../services/agent-run-state-service.js';
|
|
28
|
+
import type { AgentRunService } from '../wirings/agent/agent.types.js';
|
|
28
29
|
import type { VirtualUserRunStore } from '../wirings/virtual-user/virtual-user-run-store.js';
|
|
29
|
-
import type {
|
|
30
|
+
import type { PikkuAgentMiddlewareHooks } from '../wirings/agent/agent.types.js';
|
|
30
31
|
import type { WorkflowRunService } from '../wirings/workflow/workflow.types.js';
|
|
31
32
|
import type { CredentialService } from '../services/credential-service.js';
|
|
32
33
|
import type { EmailService } from '../services/email-service.js';
|
|
@@ -258,11 +259,11 @@ export interface CoreSingletonServices<Config extends CoreConfig = CoreConfig> {
|
|
|
258
259
|
eventHub?: EventHubService<Record<string, any>>;
|
|
259
260
|
schedulerService?: SchedulerService;
|
|
260
261
|
deploymentService?: DeploymentService;
|
|
261
|
-
|
|
262
|
+
agentStorage?: AgentStorageService;
|
|
262
263
|
content?: ContentService;
|
|
263
|
-
|
|
264
|
+
agentRunner?: AgentRunnerService;
|
|
264
265
|
aiEmbedding?: AIEmbeddingService;
|
|
265
|
-
|
|
266
|
+
agentRunState?: AgentRunStateService;
|
|
266
267
|
agentRunService?: AgentRunService;
|
|
267
268
|
workflowRunService?: WorkflowRunService;
|
|
268
269
|
credentialService?: CredentialService;
|
|
@@ -386,8 +387,8 @@ export declare const pikkuMiddleware: <SingletonServices extends CoreSingletonSe
|
|
|
386
387
|
export declare const pikkuMiddlewareFactory: <In = any>(factory: CorePikkuMiddlewareFactory<In>) => CorePikkuMiddlewareFactory<In>;
|
|
387
388
|
export declare const pikkuChannelMiddleware: <SingletonServices extends CoreSingletonServices = CoreSingletonServices, Event = unknown>(middleware: CorePikkuChannelMiddleware<SingletonServices, Event>) => CorePikkuChannelMiddleware<SingletonServices, Event>;
|
|
388
389
|
export declare const pikkuChannelMiddlewareFactory: <In = any>(factory: CorePikkuChannelMiddlewareFactory<In>) => CorePikkuChannelMiddlewareFactory<In>;
|
|
389
|
-
export type {
|
|
390
|
-
export declare const
|
|
390
|
+
export type { PikkuAgentMiddlewareHooks } from '../wirings/agent/agent.types.js';
|
|
391
|
+
export declare const pikkuAgentMiddleware: <State extends Record<string, unknown> = Record<string, unknown>, SingletonServices extends CoreSingletonServices = CoreSingletonServices>(hooks: PikkuAgentMiddlewareHooks<State, SingletonServices>) => PikkuAgentMiddlewareHooks<State, SingletonServices>;
|
|
391
392
|
export type CoreServices<SingletonServices = CoreSingletonServices> = SingletonServices;
|
|
392
393
|
/** Strips `secrets` from a services type. */
|
|
393
394
|
export type SecretlessServices<Services> = Omit<Services, 'secrets'>;
|
package/dist/types/core.types.js
CHANGED