@pikku/core 0.12.107 → 0.12.111
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 +344 -0
- package/dist/analytics/analytics.d.ts +6 -0
- package/dist/analytics/analytics.js +58 -0
- package/dist/analytics/analytics.types.d.ts +156 -0
- package/dist/analytics/analytics.types.js +1 -0
- package/dist/analytics/anonymous-analytics-identity.d.ts +23 -0
- package/dist/analytics/anonymous-analytics-identity.js +27 -0
- package/dist/analytics/compose-analytics-identity.d.ts +14 -0
- package/dist/analytics/compose-analytics-identity.js +33 -0
- package/dist/analytics/cookie-analytics-identity.d.ts +24 -0
- package/dist/analytics/cookie-analytics-identity.js +37 -0
- package/dist/analytics/define-analytics-events.d.ts +22 -0
- package/dist/analytics/define-analytics-events.js +9 -0
- package/dist/analytics/fan-out-analytics.d.ts +15 -0
- package/dist/analytics/fan-out-analytics.js +36 -0
- package/dist/analytics/index.d.ts +13 -0
- package/dist/analytics/index.js +8 -0
- package/dist/analytics/logger-analytics-service.d.ts +14 -0
- package/dist/analytics/logger-analytics-service.js +23 -0
- package/dist/analytics/mint-cookie.d.ts +44 -0
- package/dist/analytics/mint-cookie.js +55 -0
- package/dist/errors/errors.d.ts +7 -0
- package/dist/errors/errors.js +17 -0
- package/dist/function/function-meta.types.d.ts +2 -0
- package/dist/function/function-runner.js +29 -0
- package/dist/function/functions.types.d.ts +22 -3
- package/dist/middleware/auth-apikey.d.ts +1 -1
- package/dist/pikku-state.d.ts +1 -1
- package/dist/scopes.d.ts +11 -0
- package/dist/scopes.js +17 -0
- package/dist/services/credential-wire-service.d.ts +1 -1
- package/dist/services/feature-flag-service.d.ts +100 -0
- package/dist/services/feature-flag-service.js +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/meta-service.d.ts +16 -0
- package/dist/services/meta-service.js +19 -0
- package/dist/services/webhook-service.d.ts +7 -2
- package/dist/services/webhook-service.js +11 -6
- package/dist/testing/service-tests/agent-run-service-tests.d.ts +2 -2
- package/dist/testing/service-tests/agent-storage-service-tests.d.ts +1 -1
- package/dist/testing/service-tests/channel-store-tests.d.ts +1 -1
- package/dist/testing/service-tests/credential-service-tests.d.ts +1 -1
- package/dist/testing/service-tests/deployment-service-tests.d.ts +1 -1
- package/dist/testing/service-tests/event-hub-store-tests.d.ts +1 -1
- package/dist/testing/service-tests/secret-service-tests.d.ts +1 -1
- package/dist/testing/service-tests/session-store-tests.d.ts +1 -1
- package/dist/testing/service-tests/workflow-run-service-tests.d.ts +1 -1
- package/dist/testing/service-tests/workflow-service-tests.d.ts +1 -1
- package/dist/types/core.types.d.ts +23 -0
- package/dist/wirings/agent/agent-rpc.d.ts +1 -1
- package/dist/wirings/agent/agent-turn.d.ts +1 -1
- package/dist/wirings/agent-scorer/agent-scorer-live.d.ts +1 -1
- package/dist/wirings/channel/channel-common.d.ts +1 -1
- package/dist/wirings/channel/channel-rpc-validators.d.ts +2 -2
- package/dist/wirings/channel/channel-runner.d.ts +1 -1
- package/dist/wirings/channel/local/local-channel-runner.d.ts +1 -1
- package/dist/wirings/channel/serverless/serverless-channel-runner.d.ts +1 -1
- package/dist/wirings/cli/channel/cli-approval.d.ts +2 -2
- package/dist/wirings/flag/assert-feature-available.d.ts +15 -0
- package/dist/wirings/flag/assert-feature-available.js +23 -0
- package/dist/wirings/flag/cached-flag-source.d.ts +73 -0
- package/dist/wirings/flag/cached-flag-source.js +96 -0
- package/dist/wirings/flag/define-feature-flags.d.ts +33 -0
- package/dist/wirings/flag/define-feature-flags.js +32 -0
- package/dist/wirings/flag/flag.types.d.ts +97 -0
- package/dist/wirings/flag/flag.types.js +1 -0
- package/dist/wirings/flag/index.d.ts +7 -0
- package/dist/wirings/flag/index.js +5 -0
- package/dist/wirings/flag/resolve-flag.d.ts +52 -0
- package/dist/wirings/flag/resolve-flag.js +90 -0
- package/dist/wirings/flag/validate-flag-definitions.d.ts +26 -0
- package/dist/wirings/flag/validate-flag-definitions.js +103 -0
- package/dist/wirings/virtual-user/virtual-user-scaffold.d.ts +8 -8
- package/dist/wirings/virtual-user/virtual-user-schedule.d.ts +1 -1
- package/dist/wirings/workflow/workflow-queue-routing.d.ts +1 -1
- package/package.json +11 -5
- package/run-tests.sh +17 -9
- package/src/public-surface.json +26 -0
- package/src/agent-naming.test.ts +0 -68
- package/src/api-report.test.ts +0 -138
- package/src/app-alias-surface.test.ts +0 -179
- package/src/app-leaf-surface.test.ts +0 -222
- package/src/bootstrap-compat/root.ts +0 -20
- package/src/classification/column-form.test.ts +0 -97
- package/src/classification/column-form.ts +0 -55
- package/src/classification/data-classification.ts +0 -73
- package/src/classification/index.ts +0 -40
- package/src/classification/key-ids.ts +0 -2
- package/src/classification/secret-value.test.ts +0 -204
- package/src/classification/secret-value.ts +0 -106
- package/src/crypto-utils.test.ts +0 -668
- package/src/crypto-utils.ts +0 -460
- package/src/dev/hot-reload.test.ts +0 -587
- package/src/dev/hot-reload.ts +0 -225
- package/src/dev/module-runner.test.ts +0 -235
- package/src/dev/module-runner.ts +0 -138
- package/src/dev/reload-meta.test.ts +0 -183
- package/src/dev/reload-meta.ts +0 -144
- package/src/ecosystem-tier-removed.test.ts +0 -72
- package/src/env.ts +0 -1
- package/src/errors/error-handler.ts +0 -77
- package/src/errors/error.test.ts +0 -229
- package/src/errors/errors.ts +0 -393
- package/src/errors/index.ts +0 -11
- package/src/errors/serialized-error.ts +0 -12
- package/src/factory-functions.test.ts +0 -111
- package/src/function/abort-scope.test.ts +0 -97
- package/src/function/abort-scope.ts +0 -80
- package/src/function/function-meta.types.ts +0 -151
- package/src/function/function-runner.test.ts +0 -1619
- package/src/function/function-runner.ts +0 -499
- package/src/function/functions.types.ts +0 -319
- package/src/function/index.ts +0 -40
- package/src/function/list.types.test.ts +0 -100
- package/src/function/list.types.ts +0 -69
- package/src/function/pikku-request.test.ts +0 -35
- package/src/function/pikku-request.ts +0 -17
- package/src/gopass-secrets-removed.test.ts +0 -51
- package/src/handle-error.test.ts +0 -532
- package/src/handle-error.ts +0 -64
- package/src/middleware/auth-apikey.test.ts +0 -362
- package/src/middleware/auth-apikey.ts +0 -39
- package/src/middleware/auth-bearer.test.ts +0 -566
- package/src/middleware/auth-bearer.ts +0 -83
- package/src/middleware/auth-cookie.test.ts +0 -572
- package/src/middleware/auth-cookie.ts +0 -107
- package/src/middleware/cors.test.ts +0 -579
- package/src/middleware/cors.ts +0 -103
- package/src/middleware/index.ts +0 -30
- package/src/middleware/middleware-factories.ts +0 -76
- package/src/middleware/middleware.types.ts +0 -61
- package/src/middleware/remote-auth.test.ts +0 -547
- package/src/middleware/remote-auth.ts +0 -95
- package/src/middleware/remote-jobs-secret.ts +0 -35
- package/src/middleware/require-origin.test.ts +0 -115
- package/src/middleware/require-origin.ts +0 -79
- package/src/middleware/telemetry.ts +0 -83
- package/src/middleware-runner.test.ts +0 -578
- package/src/middleware-runner.ts +0 -232
- package/src/no-any-casts.test.ts +0 -57
- package/src/no-root-barrel.test.ts +0 -122
- package/src/permissions.test.ts +0 -256
- package/src/permissions.ts +0 -217
- package/src/pikku-state.test.ts +0 -198
- package/src/pikku-state.ts +0 -206
- package/src/production-barrels-stay-lean.test.ts +0 -110
- package/src/public-surface.test.ts +0 -133
- package/src/remote.test.ts +0 -173
- package/src/remote.ts +0 -56
- package/src/removed-legacy-exports.test.ts +0 -66
- package/src/run-tests-script.test.ts +0 -67
- package/src/schema.test.ts +0 -430
- package/src/schema.ts +0 -204
- package/src/scopes.test.ts +0 -203
- package/src/scopes.ts +0 -67
- package/src/services/agent-run-state-service.ts +0 -37
- package/src/services/agent-runner-service.ts +0 -238
- package/src/services/agent-storage-service.ts +0 -39
- package/src/services/ai-embedding-service.ts +0 -9
- package/src/services/audit-service.test.ts +0 -44
- package/src/services/audit-service.ts +0 -280
- package/src/services/content-service.ts +0 -65
- package/src/services/credential-service.ts +0 -20
- package/src/services/credential-wire-service.test.ts +0 -235
- package/src/services/credential-wire-service.ts +0 -120
- package/src/services/deployment-service.ts +0 -32
- package/src/services/email-service.test.ts +0 -100
- package/src/services/email-service.ts +0 -60
- package/src/services/email-template.test.ts +0 -311
- package/src/services/email-template.ts +0 -254
- package/src/services/file-scenario-run-store.test.ts +0 -349
- package/src/services/file-scenario-run-store.ts +0 -282
- package/src/services/gateway-service.ts +0 -5
- package/src/services/http-personas-converse.test.ts +0 -274
- package/src/services/http-personas.test.ts +0 -379
- package/src/services/http-personas.ts +0 -508
- package/src/services/in-memory-agent-run-state-service.ts +0 -87
- package/src/services/in-memory-queue-service.test.ts +0 -162
- package/src/services/in-memory-queue-service.ts +0 -78
- package/src/services/in-memory-session-store.test.ts +0 -58
- package/src/services/in-memory-session-store.ts +0 -20
- package/src/services/in-memory-trigger-service.ts +0 -47
- package/src/services/in-memory-workflow-service.test.ts +0 -430
- package/src/services/in-memory-workflow-service.ts +0 -595
- package/src/services/index.ts +0 -192
- package/src/services/istanbul-coverage-service.test.ts +0 -66
- package/src/services/istanbul-coverage-service.ts +0 -59
- package/src/services/jwt-service.ts +0 -15
- package/src/services/local-content-request-handler.test.ts +0 -240
- package/src/services/local-content-request-handler.ts +0 -295
- package/src/services/local-content.test.ts +0 -186
- package/src/services/local-content.ts +0 -242
- package/src/services/local-credential-service.ts +0 -63
- package/src/services/local-email-service.test.ts +0 -182
- package/src/services/local-email-service.ts +0 -43
- package/src/services/local-gateway-service.ts +0 -51
- package/src/services/local-secrets.test.ts +0 -95
- package/src/services/local-secrets.ts +0 -71
- package/src/services/local-variables.test.ts +0 -61
- package/src/services/local-variables.ts +0 -45
- package/src/services/logger-console.test.ts +0 -117
- package/src/services/logger-console.ts +0 -174
- package/src/services/logger.ts +0 -48
- package/src/services/meta-service.test.ts +0 -75
- package/src/services/meta-service.ts +0 -767
- package/src/services/persona-actor-secret.test.ts +0 -68
- package/src/services/persona-actor-secret.ts +0 -70
- package/src/services/persona-sign-in.test.ts +0 -219
- package/src/services/persona-sign-in.ts +0 -238
- package/src/services/personas-service.ts +0 -191
- package/src/services/pikku-user-id.test.ts +0 -62
- package/src/services/pikku-user-id.ts +0 -13
- package/src/services/queue-webhook-service.test.ts +0 -409
- package/src/services/queue-webhook-service.ts +0 -150
- package/src/services/remote-jobs.test.ts +0 -106
- package/src/services/remote-jobs.ts +0 -92
- package/src/services/scheduler-service.ts +0 -37
- package/src/services/schema-service.ts +0 -10
- package/src/services/scope-service.ts +0 -91
- package/src/services/scoped-credential-service.test.ts +0 -86
- package/src/services/scoped-credential-service.ts +0 -63
- package/src/services/scoped-secret-service.test.ts +0 -93
- package/src/services/scoped-secret-service.ts +0 -40
- package/src/services/secret-host-binding.test.ts +0 -138
- package/src/services/secret-host-binding.ts +0 -51
- package/src/services/secret-service.ts +0 -25
- package/src/services/secretless.test.ts +0 -54
- package/src/services/secretless.ts +0 -29
- package/src/services/session-store.ts +0 -9
- package/src/services/stub-tracker.test.ts +0 -104
- package/src/services/stub-tracker.ts +0 -175
- package/src/services/system-role-guard.test.ts +0 -96
- package/src/services/system-role-guard.ts +0 -71
- package/src/services/temporary-file-service.ts +0 -76
- package/src/services/trigger-service.ts +0 -5
- package/src/services/typed-credential-service.ts +0 -83
- package/src/services/typed-secret-service.test.ts +0 -204
- package/src/services/typed-secret-service.ts +0 -132
- package/src/services/typed-variables-service.test.ts +0 -166
- package/src/services/typed-variables-service.ts +0 -166
- package/src/services/user-session-service.test.ts +0 -147
- package/src/services/user-session-service.ts +0 -85
- package/src/services/v8-coverage-service.test.ts +0 -69
- package/src/services/v8-coverage-service.ts +0 -163
- package/src/services/variables-service.ts +0 -13
- package/src/services/webhook-service.ts +0 -147
- package/src/services/workflow-service.ts +0 -120
- package/src/side-effects-are-declared.test.ts +0 -84
- package/src/source-files-stay-composable.test.ts +0 -41
- package/src/template-alias-surface.test.ts +0 -240
- package/src/test-utils.ts +0 -38
- package/src/testing/index.ts +0 -3
- package/src/testing/service-tests/agent-run-service-tests.ts +0 -98
- package/src/testing/service-tests/agent-storage-service-tests.ts +0 -379
- package/src/testing/service-tests/channel-store-tests.ts +0 -98
- package/src/testing/service-tests/credential-service-tests.ts +0 -143
- package/src/testing/service-tests/deployment-service-tests.ts +0 -33
- package/src/testing/service-tests/event-hub-store-tests.ts +0 -48
- package/src/testing/service-tests/secret-service-tests.ts +0 -105
- package/src/testing/service-tests/session-store-tests.ts +0 -62
- package/src/testing/service-tests/workflow-run-service-tests.ts +0 -59
- package/src/testing/service-tests/workflow-service-tests.ts +0 -308
- package/src/testing/service-tests.ts +0 -95
- package/src/time-utils.test.ts +0 -56
- package/src/time-utils.ts +0 -89
- package/src/types/core.types.ts +0 -446
- package/src/types/index.ts +0 -25
- package/src/types/state.types.ts +0 -226
- package/src/types/typed-credentials.test.ts +0 -72
- package/src/utils/hash.test.ts +0 -68
- package/src/utils/hash.ts +0 -26
- package/src/utils/hmac.ts +0 -21
- package/src/utils/node-host-resolver.ts +0 -20
- package/src/utils/safe-fetch.test.ts +0 -515
- package/src/utils/safe-fetch.ts +0 -347
- package/src/utils.test.ts +0 -359
- package/src/utils.ts +0 -165
- package/src/version.test.ts +0 -80
- package/src/version.ts +0 -25
- package/src/wirings/actor-flow/actor-flow.types.ts +0 -40
- package/src/wirings/actor-flow/index.ts +0 -10
- package/src/wirings/actor-flow/run-conversation.test.ts +0 -187
- package/src/wirings/actor-flow/run-conversation.ts +0 -280
- package/src/wirings/addon/addon-auth-tags.test.ts +0 -219
- package/src/wirings/addon/addon-runner.ts +0 -236
- package/src/wirings/addon/addon-scopes.test.ts +0 -225
- package/src/wirings/addon/addon-secrets.test.ts +0 -391
- package/src/wirings/addon/index.ts +0 -12
- package/src/wirings/addon/remote-addon-auth.ts +0 -65
- package/src/wirings/addon/wire-addon.test.ts +0 -102
- package/src/wirings/addon/wire-addon.ts +0 -202
- package/src/wirings/addon/wire-remote-addon.ts +0 -41
- package/src/wirings/agent/agent-agui.test.ts +0 -1213
- package/src/wirings/agent/agent-agui.ts +0 -405
- package/src/wirings/agent/agent-authorization.test.ts +0 -208
- package/src/wirings/agent/agent-finalize.test.ts +0 -187
- package/src/wirings/agent/agent-finalize.ts +0 -197
- package/src/wirings/agent/agent-helpers.test.ts +0 -215
- package/src/wirings/agent/agent-helpers.ts +0 -96
- package/src/wirings/agent/agent-interrupt.test.ts +0 -833
- package/src/wirings/agent/agent-interrupt.ts +0 -400
- package/src/wirings/agent/agent-memory.test.ts +0 -397
- package/src/wirings/agent/agent-memory.ts +0 -496
- package/src/wirings/agent/agent-middleware.types.test.ts +0 -41
- package/src/wirings/agent/agent-model-config.test.ts +0 -103
- package/src/wirings/agent/agent-model-config.ts +0 -59
- package/src/wirings/agent/agent-prepare.test.ts +0 -977
- package/src/wirings/agent/agent-prepare.ts +0 -1083
- package/src/wirings/agent/agent-registry.test.ts +0 -455
- package/src/wirings/agent/agent-registry.ts +0 -99
- package/src/wirings/agent/agent-resume-authorization.test.ts +0 -206
- package/src/wirings/agent/agent-rpc.ts +0 -116
- package/src/wirings/agent/agent-runner.test.ts +0 -1229
- package/src/wirings/agent/agent-runner.ts +0 -858
- package/src/wirings/agent/agent-stream-delegate.test.ts +0 -381
- package/src/wirings/agent/agent-stream-output-hooks.test.ts +0 -353
- package/src/wirings/agent/agent-stream.test.ts +0 -1800
- package/src/wirings/agent/agent-stream.ts +0 -1639
- package/src/wirings/agent/agent-thread-ownership.test.ts +0 -297
- package/src/wirings/agent/agent-turn.test.ts +0 -65
- package/src/wirings/agent/agent-turn.ts +0 -122
- package/src/wirings/agent/agent-utils.ts +0 -20
- package/src/wirings/agent/agent.types.ts +0 -676
- package/src/wirings/agent/index.ts +0 -58
- package/src/wirings/agent/voice-input.test.ts +0 -220
- package/src/wirings/agent/voice-input.ts +0 -180
- package/src/wirings/agent/voice-output.test.ts +0 -510
- package/src/wirings/agent/voice-output.ts +0 -311
- package/src/wirings/agent-scorer/agent-scorer-grade.test.ts +0 -106
- package/src/wirings/agent-scorer/agent-scorer-grade.ts +0 -55
- package/src/wirings/agent-scorer/agent-scorer-judge.test.ts +0 -285
- package/src/wirings/agent-scorer/agent-scorer-judge.ts +0 -180
- package/src/wirings/agent-scorer/agent-scorer-live.test.ts +0 -174
- package/src/wirings/agent-scorer/agent-scorer-live.ts +0 -56
- package/src/wirings/agent-scorer/agent-scorer-registry.ts +0 -66
- package/src/wirings/agent-scorer/agent-scorer-sampling.test.ts +0 -34
- package/src/wirings/agent-scorer/agent-scorer-sampling.ts +0 -36
- package/src/wirings/agent-scorer/agent-scorer-snapshots.test.ts +0 -49
- package/src/wirings/agent-scorer/agent-scorer-snapshots.ts +0 -46
- package/src/wirings/agent-scorer/agent-scorer-worker.test.ts +0 -122
- package/src/wirings/agent-scorer/agent-scorer-worker.ts +0 -71
- package/src/wirings/agent-scorer/agent-scorer.ts +0 -102
- package/src/wirings/agent-scorer/agent-scorer.types.ts +0 -128
- package/src/wirings/agent-scorer/index.ts +0 -23
- package/src/wirings/channel/channel-common.ts +0 -102
- package/src/wirings/channel/channel-handler-shapes.test.ts +0 -72
- package/src/wirings/channel/channel-handler.test.ts +0 -322
- package/src/wirings/channel/channel-handler.ts +0 -259
- package/src/wirings/channel/channel-host-rpc.test.ts +0 -150
- package/src/wirings/channel/channel-host-rpc.ts +0 -69
- package/src/wirings/channel/channel-middleware-runner.test.ts +0 -188
- package/src/wirings/channel/channel-middleware-runner.ts +0 -126
- package/src/wirings/channel/channel-rpc-registry.ts +0 -116
- package/src/wirings/channel/channel-rpc-responder.ts +0 -117
- package/src/wirings/channel/channel-rpc-service.ts +0 -132
- package/src/wirings/channel/channel-rpc-validators.ts +0 -65
- package/src/wirings/channel/channel-rpc.test.ts +0 -841
- package/src/wirings/channel/channel-rpc.ts +0 -5
- package/src/wirings/channel/channel-rpc.types.ts +0 -160
- package/src/wirings/channel/channel-runner.ts +0 -164
- package/src/wirings/channel/channel-store.ts +0 -35
- package/src/wirings/channel/channel.types.ts +0 -193
- package/src/wirings/channel/define-channel-routes.ts +0 -5
- package/src/wirings/channel/eventhub-service.ts +0 -16
- package/src/wirings/channel/eventhub-store.ts +0 -13
- package/src/wirings/channel/index.ts +0 -40
- package/src/wirings/channel/local/index.ts +0 -3
- package/src/wirings/channel/local/local-channel-handler.ts +0 -98
- package/src/wirings/channel/local/local-channel-runner.test.ts +0 -339
- package/src/wirings/channel/local/local-channel-runner.ts +0 -271
- package/src/wirings/channel/local/local-eventhub-service.test.ts +0 -77
- package/src/wirings/channel/local/local-eventhub-service.ts +0 -69
- package/src/wirings/channel/log-channels.ts +0 -16
- package/src/wirings/channel/pikku-abstract-channel-handler.test.ts +0 -135
- package/src/wirings/channel/pikku-abstract-channel-handler.ts +0 -60
- package/src/wirings/channel/serverless/index.ts +0 -6
- package/src/wirings/channel/serverless/serverless-channel-runner.ts +0 -328
- package/src/wirings/cli/channel/cli-approval.test.ts +0 -177
- package/src/wirings/cli/channel/cli-approval.ts +0 -135
- package/src/wirings/cli/channel/cli-channel-runner.ts +0 -118
- package/src/wirings/cli/channel/cli-raw-channel-runner.test.ts +0 -192
- package/src/wirings/cli/channel/cli-raw-channel-runner.ts +0 -148
- package/src/wirings/cli/channel/cli-raw-client-runner.test.ts +0 -480
- package/src/wirings/cli/channel/cli-raw-client-runner.ts +0 -188
- package/src/wirings/cli/channel/index.ts +0 -6
- package/src/wirings/cli/cli-runner.test.ts +0 -969
- package/src/wirings/cli/cli-runner.ts +0 -538
- package/src/wirings/cli/cli.types.ts +0 -388
- package/src/wirings/cli/command-parser.test.ts +0 -1120
- package/src/wirings/cli/command-parser.ts +0 -713
- package/src/wirings/cli/define-cli-commands.ts +0 -13
- package/src/wirings/cli/format-cli-error.test.ts +0 -91
- package/src/wirings/cli/format-cli-error.ts +0 -96
- package/src/wirings/cli/index.ts +0 -19
- package/src/wirings/credential/credential.types.ts +0 -37
- package/src/wirings/credential/define-credential.ts +0 -49
- package/src/wirings/credential/index.ts +0 -7
- package/src/wirings/credential/validate-credential-definitions.ts +0 -63
- package/src/wirings/gateway/gateway-authorization.test.ts +0 -575
- package/src/wirings/gateway/gateway-channel-meta.test.ts +0 -44
- package/src/wirings/gateway/gateway-runner.test.ts +0 -581
- package/src/wirings/gateway/gateway-runner.ts +0 -411
- package/src/wirings/gateway/gateway.types.ts +0 -137
- package/src/wirings/gateway/index.ts +0 -15
- package/src/wirings/http/http-routes.test.ts +0 -318
- package/src/wirings/http/http-routes.ts +0 -111
- package/src/wirings/http/http-runner-addon-ref.test.ts +0 -238
- package/src/wirings/http/http-runner.test.ts +0 -503
- package/src/wirings/http/http-runner.ts +0 -462
- package/src/wirings/http/http.types.ts +0 -307
- package/src/wirings/http/index.ts +0 -27
- package/src/wirings/http/log-http-routes.ts +0 -18
- package/src/wirings/http/pikku-fetch-http-request.test.ts +0 -318
- package/src/wirings/http/pikku-fetch-http-request.ts +0 -260
- package/src/wirings/http/pikku-fetch-http-response.test.ts +0 -123
- package/src/wirings/http/pikku-fetch-http-response.ts +0 -149
- package/src/wirings/http/routers/http-router.ts +0 -13
- package/src/wirings/http/routers/path-to-regex.test.ts +0 -306
- package/src/wirings/http/routers/path-to-regex.ts +0 -115
- package/src/wirings/http/web-request.test.ts +0 -382
- package/src/wirings/http/web-request.ts +0 -162
- package/src/wirings/mcp/index.ts +0 -26
- package/src/wirings/mcp/mcp-endpoint-registry.test.ts +0 -388
- package/src/wirings/mcp/mcp-endpoint-registry.ts +0 -159
- package/src/wirings/mcp/mcp-runner.test.ts +0 -588
- package/src/wirings/mcp/mcp-runner.ts +0 -330
- package/src/wirings/mcp/mcp.types.ts +0 -199
- package/src/wirings/node/index.ts +0 -2
- package/src/wirings/node/node.types.ts +0 -23
- package/src/wirings/oauth2/index.ts +0 -1
- package/src/wirings/oauth2/oauth2.types.ts +0 -12
- package/src/wirings/persona/define-personas.ts +0 -33
- package/src/wirings/persona/index.ts +0 -75
- package/src/wirings/persona/persona-app-scopes.test.ts +0 -47
- package/src/wirings/persona/persona-app-scopes.ts +0 -74
- package/src/wirings/persona/persona-email.ts +0 -87
- package/src/wirings/persona/persona-environments.test.ts +0 -194
- package/src/wirings/persona/persona-environments.ts +0 -138
- package/src/wirings/persona/persona-mailbox.ts +0 -156
- package/src/wirings/persona/persona.test.ts +0 -230
- package/src/wirings/persona/persona.types.ts +0 -156
- package/src/wirings/persona/validate-personas.ts +0 -137
- package/src/wirings/queue/index.ts +0 -29
- package/src/wirings/queue/queue-identity.test.ts +0 -454
- package/src/wirings/queue/queue-identity.ts +0 -176
- package/src/wirings/queue/queue-runner.test.ts +0 -705
- package/src/wirings/queue/queue-runner.ts +0 -181
- package/src/wirings/queue/queue.types.ts +0 -161
- package/src/wirings/queue/register-queue-helper.ts +0 -46
- package/src/wirings/queue/signed-queue-service.ts +0 -60
- package/src/wirings/queue/validate-worker-config.test.ts +0 -108
- package/src/wirings/queue/validate-worker-config.ts +0 -90
- package/src/wirings/role/define-system-role.ts +0 -33
- package/src/wirings/role/index.ts +0 -13
- package/src/wirings/role/role.test.ts +0 -104
- package/src/wirings/role/role.types.ts +0 -47
- package/src/wirings/role/validate-role-definitions.ts +0 -93
- package/src/wirings/rpc/index.ts +0 -8
- package/src/wirings/rpc/rpc-runner.test.ts +0 -1130
- package/src/wirings/rpc/rpc-runner.ts +0 -569
- package/src/wirings/rpc/rpc-types.ts +0 -87
- package/src/wirings/scheduler/index.ts +0 -11
- package/src/wirings/scheduler/log-schedulers.ts +0 -16
- package/src/wirings/scheduler/scheduler-runner.test.ts +0 -835
- package/src/wirings/scheduler/scheduler-runner.ts +0 -138
- package/src/wirings/scheduler/scheduler.types.ts +0 -42
- package/src/wirings/scope/define-scope.ts +0 -33
- package/src/wirings/scope/index.ts +0 -15
- package/src/wirings/scope/scope.test.ts +0 -159
- package/src/wirings/scope/scope.types.ts +0 -42
- package/src/wirings/scope/validate-scope-definitions.ts +0 -107
- package/src/wirings/secret/index.ts +0 -9
- package/src/wirings/secret/secret.types.ts +0 -70
- package/src/wirings/secret/validate-secret-definitions.test.ts +0 -232
- package/src/wirings/secret/validate-secret-definitions.ts +0 -88
- package/src/wirings/trigger/index.ts +0 -9
- package/src/wirings/trigger/pikku-trigger-service.ts +0 -107
- package/src/wirings/trigger/trigger-runner.test.ts +0 -78
- package/src/wirings/trigger/trigger-runner.ts +0 -113
- package/src/wirings/trigger/trigger.types.ts +0 -100
- package/src/wirings/variable/index.ts +0 -8
- package/src/wirings/variable/validate-variable-definitions.test.ts +0 -115
- package/src/wirings/variable/validate-variable-definitions.ts +0 -71
- package/src/wirings/variable/variable.types.ts +0 -40
- package/src/wirings/virtual-user/index.ts +0 -107
- package/src/wirings/virtual-user/prepare-virtual-user-run.test.ts +0 -115
- package/src/wirings/virtual-user/prepare-virtual-user-run.ts +0 -95
- package/src/wirings/virtual-user/run-virtual-user.test.ts +0 -774
- package/src/wirings/virtual-user/run-virtual-user.ts +0 -684
- package/src/wirings/virtual-user/virtual-user-agents.test.ts +0 -72
- package/src/wirings/virtual-user/virtual-user-agents.ts +0 -62
- package/src/wirings/virtual-user/virtual-user-catalogue.test.ts +0 -215
- package/src/wirings/virtual-user/virtual-user-catalogue.ts +0 -184
- package/src/wirings/virtual-user/virtual-user-derive.test.ts +0 -426
- package/src/wirings/virtual-user/virtual-user-derive.ts +0 -161
- package/src/wirings/virtual-user/virtual-user-dispositions.test.ts +0 -68
- package/src/wirings/virtual-user/virtual-user-dispositions.ts +0 -210
- package/src/wirings/virtual-user/virtual-user-intents.test.ts +0 -218
- package/src/wirings/virtual-user/virtual-user-intents.ts +0 -185
- package/src/wirings/virtual-user/virtual-user-rng.test.ts +0 -72
- package/src/wirings/virtual-user/virtual-user-rng.ts +0 -50
- package/src/wirings/virtual-user/virtual-user-run-store.ts +0 -131
- package/src/wirings/virtual-user/virtual-user-scaffold.test.ts +0 -854
- package/src/wirings/virtual-user/virtual-user-scaffold.ts +0 -664
- package/src/wirings/virtual-user/virtual-user-schedule-store.ts +0 -93
- package/src/wirings/virtual-user/virtual-user-schedule.test.ts +0 -280
- package/src/wirings/virtual-user/virtual-user-schedule.ts +0 -156
- package/src/wirings/virtual-user/virtual-user-target.ts +0 -47
- package/src/wirings/virtual-user/virtual-user.types.ts +0 -215
- package/src/wirings/workflow/dsl/workflow-dsl.types.ts +0 -709
- package/src/wirings/workflow/dsl/workflow-runner.ts +0 -25
- package/src/wirings/workflow/feature.test.ts +0 -131
- package/src/wirings/workflow/feature.ts +0 -59
- package/src/wirings/workflow/graph/graph-foreach-queued.test.ts +0 -569
- package/src/wirings/workflow/graph/graph-foreach.test.ts +0 -626
- package/src/wirings/workflow/graph/graph-node.ts +0 -115
- package/src/wirings/workflow/graph/graph-runner.test.ts +0 -1049
- package/src/wirings/workflow/graph/graph-runner.ts +0 -1376
- package/src/wirings/workflow/graph/graph-validation.test.ts +0 -27
- package/src/wirings/workflow/graph/graph-validation.ts +0 -41
- package/src/wirings/workflow/graph/template.test.ts +0 -49
- package/src/wirings/workflow/graph/template.ts +0 -42
- package/src/wirings/workflow/graph/wire-workflow-graph.ts +0 -39
- package/src/wirings/workflow/graph/workflow-graph.types.ts +0 -75
- package/src/wirings/workflow/index.ts +0 -107
- package/src/wirings/workflow/pikku-scenario-service.ts +0 -1013
- package/src/wirings/workflow/pikku-workflow-service.test.ts +0 -963
- package/src/wirings/workflow/pikku-workflow-service.ts +0 -1993
- package/src/wirings/workflow/run-timeline.test.ts +0 -199
- package/src/wirings/workflow/run-timeline.ts +0 -185
- package/src/wirings/workflow/scenario-cookie-jar.test.ts +0 -107
- package/src/wirings/workflow/scenario-cookie-jar.ts +0 -57
- package/src/wirings/workflow/scenario-expectations.test.ts +0 -238
- package/src/wirings/workflow/scenario-hooks.test.ts +0 -259
- package/src/wirings/workflow/scenario-poll.test.ts +0 -64
- package/src/wirings/workflow/scenario-poll.ts +0 -27
- package/src/wirings/workflow/scenario-prose.test.ts +0 -275
- package/src/wirings/workflow/scenario-prose.ts +0 -86
- package/src/wirings/workflow/scenario-run.types.ts +0 -193
- package/src/wirings/workflow/scenario-service.test.ts +0 -147
- package/src/wirings/workflow/scenario-step-guards.ts +0 -23
- package/src/wirings/workflow/scenario-step.test.ts +0 -800
- package/src/wirings/workflow/scenario-step.types.ts +0 -262
- package/src/wirings/workflow/scenario-surface.test.ts +0 -146
- package/src/wirings/workflow/scenario-surface.ts +0 -71
- package/src/wirings/workflow/scenario.types.ts +0 -63
- package/src/wirings/workflow/workflow-approval-audit.ts +0 -47
- package/src/wirings/workflow/workflow-approval-policy.test.ts +0 -594
- package/src/wirings/workflow/workflow-approval-policy.ts +0 -68
- package/src/wirings/workflow/workflow-approval.ts +0 -290
- package/src/wirings/workflow/workflow-child-run-session.test.ts +0 -168
- package/src/wirings/workflow/workflow-constants.ts +0 -66
- package/src/wirings/workflow/workflow-dispatch-durability.test.ts +0 -116
- package/src/wirings/workflow/workflow-dispatch-payload.test.ts +0 -55
- package/src/wirings/workflow/workflow-dispatch-relay.test.ts +0 -128
- package/src/wirings/workflow/workflow-errors.ts +0 -132
- package/src/wirings/workflow/workflow-inline-authority.test.ts +0 -175
- package/src/wirings/workflow/workflow-invocation-id.test.ts +0 -51
- package/src/wirings/workflow/workflow-invocation-id.ts +0 -28
- package/src/wirings/workflow/workflow-meta-resolver.ts +0 -45
- package/src/wirings/workflow/workflow-mirror.test.ts +0 -171
- package/src/wirings/workflow/workflow-missing-meta.test.ts +0 -92
- package/src/wirings/workflow/workflow-on-error.test.ts +0 -145
- package/src/wirings/workflow/workflow-queue-routing.ts +0 -129
- package/src/wirings/workflow/workflow-queue-wiring.ts +0 -149
- package/src/wirings/workflow/workflow-queue-workers.test.ts +0 -131
- package/src/wirings/workflow/workflow-queue-workers.ts +0 -66
- package/src/wirings/workflow/workflow-recovery.ts +0 -192
- package/src/wirings/workflow/workflow-replay-snapshot.test.ts +0 -140
- package/src/wirings/workflow/workflow-retry-policy.test.ts +0 -113
- package/src/wirings/workflow/workflow-run-authority.test.ts +0 -212
- package/src/wirings/workflow/workflow-run-context.test.ts +0 -172
- package/src/wirings/workflow/workflow-run-engine.types.ts +0 -92
- package/src/wirings/workflow/workflow-run-ownership.ts +0 -37
- package/src/wirings/workflow/workflow-run-polling.test.ts +0 -127
- package/src/wirings/workflow/workflow-stalled-recovery.test.ts +0 -152
- package/src/wirings/workflow/workflow-status-stream.test.ts +0 -354
- package/src/wirings/workflow/workflow-status-stream.ts +0 -144
- package/src/wirings/workflow/workflow-step-claim.ts +0 -46
- package/src/wirings/workflow/workflow-step-ordinal.test.ts +0 -94
- package/src/wirings/workflow/workflow-step-session.test.ts +0 -87
- package/src/wirings/workflow/workflow-suspend.ts +0 -61
- package/src/wirings/workflow/workflow-terminal-run-guard.test.ts +0 -105
- package/src/wirings/workflow/workflow.types.ts +0 -268
- package/src/wirings-stay-decoupled.test.ts +0 -130
- package/tsconfig.json +0 -14
- package/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.type-tests.json +0 -15
|
@@ -1,1229 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, test } from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import { resetPikkuState, pikkuState } from '../../pikku-state.js'
|
|
5
|
-
import { runAgent, resumeAgentSync } from './agent-runner.js'
|
|
6
|
-
import type {
|
|
7
|
-
AgentRunState,
|
|
8
|
-
CoreAgent,
|
|
9
|
-
PikkuAgentMiddlewareHooks,
|
|
10
|
-
} from './agent.types.js'
|
|
11
|
-
import type { AgentStepResult } from '../../services/agent-runner-service.js'
|
|
12
|
-
import {
|
|
13
|
-
AIProviderNotConfiguredError,
|
|
14
|
-
ForbiddenError,
|
|
15
|
-
} from '../../errors/errors.js'
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
resetPikkuState()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const addTestAgent = (agentName: string) => {
|
|
22
|
-
const agent: CoreAgent = {
|
|
23
|
-
name: agentName,
|
|
24
|
-
description: 'test agent',
|
|
25
|
-
instructions: 'be helpful',
|
|
26
|
-
model: 'test/test-model',
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
pikkuState(null, 'agent', 'agentsMeta')[agentName] = {
|
|
30
|
-
...agent,
|
|
31
|
-
inputSchema: null,
|
|
32
|
-
outputSchema: null,
|
|
33
|
-
workingMemorySchema: null,
|
|
34
|
-
}
|
|
35
|
-
pikkuState(null, 'agent', 'agents').set(agentName, agent)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const makeStepResult = (
|
|
39
|
-
overrides?: Partial<AgentStepResult>
|
|
40
|
-
): AgentStepResult => ({
|
|
41
|
-
text: '',
|
|
42
|
-
toolCalls: [],
|
|
43
|
-
toolResults: [],
|
|
44
|
-
usage: { inputTokens: 0, outputTokens: 0 },
|
|
45
|
-
finishReason: 'stop',
|
|
46
|
-
...overrides,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const asOwner = (resourceId: string) => ({
|
|
50
|
-
sessionService: { get: () => ({ userId: resourceId }) } as never,
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
describe('runAgent', () => {
|
|
54
|
-
test('throws when agentRunState service is missing', async () => {
|
|
55
|
-
addTestAgent('missing-run-state-agent')
|
|
56
|
-
|
|
57
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
58
|
-
logger: {
|
|
59
|
-
info: () => {},
|
|
60
|
-
warn: () => {},
|
|
61
|
-
error: () => {},
|
|
62
|
-
debug: () => {},
|
|
63
|
-
},
|
|
64
|
-
agentRunner: {
|
|
65
|
-
run: async () => makeStepResult({ text: 'unused' }),
|
|
66
|
-
},
|
|
67
|
-
} as any)
|
|
68
|
-
|
|
69
|
-
await assert.rejects(
|
|
70
|
-
() =>
|
|
71
|
-
runAgent(
|
|
72
|
-
'missing-run-state-agent',
|
|
73
|
-
{ message: 'hello', threadId: 't', resourceId: 'r' },
|
|
74
|
-
{}
|
|
75
|
-
),
|
|
76
|
-
{
|
|
77
|
-
message: 'AgentRunStateService not available in singletonServices',
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
test('throws AIProviderNotConfiguredError when agentRunner is missing', async () => {
|
|
83
|
-
addTestAgent('no-provider-agent')
|
|
84
|
-
|
|
85
|
-
const mockServices = {
|
|
86
|
-
logger: {
|
|
87
|
-
info: () => {},
|
|
88
|
-
warn: () => {},
|
|
89
|
-
error: () => {},
|
|
90
|
-
debug: () => {},
|
|
91
|
-
},
|
|
92
|
-
agentRunState: {
|
|
93
|
-
createRun: async () => 'run-no-provider',
|
|
94
|
-
updateRun: async () => {},
|
|
95
|
-
},
|
|
96
|
-
} as any
|
|
97
|
-
|
|
98
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
99
|
-
|
|
100
|
-
await assert.rejects(
|
|
101
|
-
() =>
|
|
102
|
-
runAgent(
|
|
103
|
-
'no-provider-agent',
|
|
104
|
-
{ message: 'hello', threadId: 't', resourceId: 'r' },
|
|
105
|
-
{}
|
|
106
|
-
),
|
|
107
|
-
(error: unknown) => {
|
|
108
|
-
assert.ok(error instanceof AIProviderNotConfiguredError)
|
|
109
|
-
assert.match((error as Error).message, /AI provider/)
|
|
110
|
-
return true
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('marks run as failed when runner throws', async () => {
|
|
116
|
-
addTestAgent('failing-agent')
|
|
117
|
-
|
|
118
|
-
const updates: unknown[] = []
|
|
119
|
-
const expectedError = new Error('runner failed')
|
|
120
|
-
|
|
121
|
-
const mockServices = {
|
|
122
|
-
logger: {
|
|
123
|
-
info: () => {},
|
|
124
|
-
warn: () => {},
|
|
125
|
-
error: () => {},
|
|
126
|
-
debug: () => {},
|
|
127
|
-
},
|
|
128
|
-
agentRunner: {
|
|
129
|
-
run: async () => {
|
|
130
|
-
throw expectedError
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
agentRunState: {
|
|
134
|
-
createRun: async () => 'run-1',
|
|
135
|
-
updateRun: async (_runId: string, patch: unknown) => {
|
|
136
|
-
updates.push(patch)
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
} as any
|
|
140
|
-
|
|
141
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
142
|
-
|
|
143
|
-
await assert.rejects(
|
|
144
|
-
() =>
|
|
145
|
-
runAgent(
|
|
146
|
-
'failing-agent',
|
|
147
|
-
{
|
|
148
|
-
message: 'hello',
|
|
149
|
-
threadId: 'thread-1',
|
|
150
|
-
resourceId: 'resource-1',
|
|
151
|
-
},
|
|
152
|
-
{}
|
|
153
|
-
),
|
|
154
|
-
expectedError
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
assert.deepEqual(updates, [
|
|
158
|
-
{ status: 'failed', errorMessage: 'runner failed' },
|
|
159
|
-
])
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
test('loops through multiple steps and accumulates usage', async () => {
|
|
163
|
-
addTestAgent('multi-step-agent')
|
|
164
|
-
|
|
165
|
-
let callCount = 0
|
|
166
|
-
const mockServices = {
|
|
167
|
-
logger: {
|
|
168
|
-
info: () => {},
|
|
169
|
-
warn: () => {},
|
|
170
|
-
error: () => {},
|
|
171
|
-
debug: () => {},
|
|
172
|
-
},
|
|
173
|
-
agentRunner: {
|
|
174
|
-
run: async (): Promise<AgentStepResult> => {
|
|
175
|
-
callCount++
|
|
176
|
-
if (callCount === 1) {
|
|
177
|
-
return makeStepResult({
|
|
178
|
-
text: '',
|
|
179
|
-
toolCalls: [
|
|
180
|
-
{ toolCallId: 'tc-1', toolName: 'myTool', args: { q: 'test' } },
|
|
181
|
-
],
|
|
182
|
-
toolResults: [
|
|
183
|
-
{
|
|
184
|
-
toolCallId: 'tc-1',
|
|
185
|
-
toolName: 'myTool',
|
|
186
|
-
result: 'tool output',
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
usage: { inputTokens: 100, outputTokens: 50 },
|
|
190
|
-
finishReason: 'tool-calls',
|
|
191
|
-
})
|
|
192
|
-
}
|
|
193
|
-
return makeStepResult({
|
|
194
|
-
text: 'Final answer',
|
|
195
|
-
usage: { inputTokens: 80, outputTokens: 30 },
|
|
196
|
-
finishReason: 'stop',
|
|
197
|
-
})
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
agentRunState: {
|
|
201
|
-
createRun: async () => 'run-multi',
|
|
202
|
-
updateRun: async () => {},
|
|
203
|
-
},
|
|
204
|
-
} as any
|
|
205
|
-
|
|
206
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
207
|
-
|
|
208
|
-
const result = await runAgent(
|
|
209
|
-
'multi-step-agent',
|
|
210
|
-
{
|
|
211
|
-
message: 'hello',
|
|
212
|
-
threadId: 'thread-multi',
|
|
213
|
-
resourceId: 'resource-multi',
|
|
214
|
-
},
|
|
215
|
-
{}
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
assert.equal(callCount, 2)
|
|
219
|
-
assert.equal(result.text, 'Final answer')
|
|
220
|
-
assert.equal(result.usage.inputTokens, 180)
|
|
221
|
-
assert.equal(result.usage.outputTokens, 80)
|
|
222
|
-
assert.equal(result.steps.length, 2)
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test('afterStep hook is called for each step', async () => {
|
|
226
|
-
addTestAgent('afterstep-agent')
|
|
227
|
-
|
|
228
|
-
const afterStepCalls: unknown[] = []
|
|
229
|
-
const middleware: PikkuAgentMiddlewareHooks = {
|
|
230
|
-
afterStep: async (_services, ctx) => {
|
|
231
|
-
afterStepCalls.push(ctx)
|
|
232
|
-
},
|
|
233
|
-
}
|
|
234
|
-
const agent = pikkuState(null, 'agent', 'agents').get('afterstep-agent')!
|
|
235
|
-
agent.agentMiddleware = [middleware] as any
|
|
236
|
-
pikkuState(null, 'agent', 'agents').set('afterstep-agent', agent)
|
|
237
|
-
|
|
238
|
-
let callCount = 0
|
|
239
|
-
const mockServices = {
|
|
240
|
-
logger: {
|
|
241
|
-
info: () => {},
|
|
242
|
-
warn: () => {},
|
|
243
|
-
error: () => {},
|
|
244
|
-
debug: () => {},
|
|
245
|
-
},
|
|
246
|
-
agentRunner: {
|
|
247
|
-
run: async (): Promise<AgentStepResult> => {
|
|
248
|
-
callCount++
|
|
249
|
-
if (callCount === 1) {
|
|
250
|
-
return makeStepResult({
|
|
251
|
-
text: 'thinking...',
|
|
252
|
-
toolCalls: [
|
|
253
|
-
{ toolCallId: 'tc-1', toolName: 'myTool', args: { q: 'test' } },
|
|
254
|
-
],
|
|
255
|
-
toolResults: [
|
|
256
|
-
{ toolCallId: 'tc-1', toolName: 'myTool', result: 'output' },
|
|
257
|
-
],
|
|
258
|
-
usage: { inputTokens: 100, outputTokens: 50 },
|
|
259
|
-
finishReason: 'tool-calls',
|
|
260
|
-
})
|
|
261
|
-
}
|
|
262
|
-
return makeStepResult({
|
|
263
|
-
text: 'done',
|
|
264
|
-
usage: { inputTokens: 80, outputTokens: 30 },
|
|
265
|
-
finishReason: 'stop',
|
|
266
|
-
})
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
agentRunState: {
|
|
270
|
-
createRun: async () => 'run-afterstep',
|
|
271
|
-
updateRun: async () => {},
|
|
272
|
-
},
|
|
273
|
-
} as any
|
|
274
|
-
|
|
275
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
276
|
-
|
|
277
|
-
await runAgent(
|
|
278
|
-
'afterstep-agent',
|
|
279
|
-
{ message: 'hi', threadId: 't1', resourceId: 'r1' },
|
|
280
|
-
{}
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
assert.equal(afterStepCalls.length, 2)
|
|
284
|
-
const first = afterStepCalls[0] as any
|
|
285
|
-
assert.equal(first.stepNumber, 0)
|
|
286
|
-
assert.equal(first.finishReason, 'tool-calls')
|
|
287
|
-
assert.equal(first.toolCalls.length, 1)
|
|
288
|
-
const second = afterStepCalls[1] as any
|
|
289
|
-
assert.equal(second.stepNumber, 1)
|
|
290
|
-
assert.equal(second.finishReason, 'stop')
|
|
291
|
-
assert.equal(second.text, 'done')
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
test('onError hook is called when runner throws', async () => {
|
|
295
|
-
addTestAgent('onerror-agent')
|
|
296
|
-
|
|
297
|
-
const onErrorCalls: unknown[] = []
|
|
298
|
-
const middleware: PikkuAgentMiddlewareHooks = {
|
|
299
|
-
onError: async (_services, ctx) => {
|
|
300
|
-
onErrorCalls.push(ctx)
|
|
301
|
-
},
|
|
302
|
-
}
|
|
303
|
-
const agent = pikkuState(null, 'agent', 'agents').get('onerror-agent')!
|
|
304
|
-
agent.agentMiddleware = [middleware] as any
|
|
305
|
-
pikkuState(null, 'agent', 'agents').set('onerror-agent', agent)
|
|
306
|
-
|
|
307
|
-
const expectedError = new Error('boom')
|
|
308
|
-
const mockServices = {
|
|
309
|
-
logger: {
|
|
310
|
-
info: () => {},
|
|
311
|
-
warn: () => {},
|
|
312
|
-
error: () => {},
|
|
313
|
-
debug: () => {},
|
|
314
|
-
},
|
|
315
|
-
agentRunner: {
|
|
316
|
-
run: async () => {
|
|
317
|
-
throw expectedError
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
agentRunState: {
|
|
321
|
-
createRun: async () => 'run-err',
|
|
322
|
-
updateRun: async () => {},
|
|
323
|
-
},
|
|
324
|
-
} as any
|
|
325
|
-
|
|
326
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
327
|
-
|
|
328
|
-
await assert.rejects(
|
|
329
|
-
() =>
|
|
330
|
-
runAgent(
|
|
331
|
-
'onerror-agent',
|
|
332
|
-
{ message: 'hi', threadId: 't2', resourceId: 'r2' },
|
|
333
|
-
{}
|
|
334
|
-
),
|
|
335
|
-
expectedError
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
assert.equal(onErrorCalls.length, 1)
|
|
339
|
-
const call = onErrorCalls[0] as any
|
|
340
|
-
assert.equal(call.error.message, 'boom')
|
|
341
|
-
assert.equal(call.stepNumber, -1)
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
test('onError hook failure does not suppress original error', async () => {
|
|
345
|
-
addTestAgent('onerror-throws-agent')
|
|
346
|
-
|
|
347
|
-
const middleware: PikkuAgentMiddlewareHooks = {
|
|
348
|
-
onError: async () => {
|
|
349
|
-
throw new Error('hook error')
|
|
350
|
-
},
|
|
351
|
-
}
|
|
352
|
-
const agent = pikkuState(null, 'agent', 'agents').get(
|
|
353
|
-
'onerror-throws-agent'
|
|
354
|
-
)!
|
|
355
|
-
agent.agentMiddleware = [middleware] as any
|
|
356
|
-
pikkuState(null, 'agent', 'agents').set('onerror-throws-agent', agent)
|
|
357
|
-
|
|
358
|
-
const expectedError = new Error('original error')
|
|
359
|
-
const mockServices = {
|
|
360
|
-
logger: {
|
|
361
|
-
info: () => {},
|
|
362
|
-
warn: () => {},
|
|
363
|
-
error: () => {},
|
|
364
|
-
debug: () => {},
|
|
365
|
-
},
|
|
366
|
-
agentRunner: {
|
|
367
|
-
run: async () => {
|
|
368
|
-
throw expectedError
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
agentRunState: {
|
|
372
|
-
createRun: async () => 'run-safe',
|
|
373
|
-
updateRun: async () => {},
|
|
374
|
-
},
|
|
375
|
-
} as any
|
|
376
|
-
|
|
377
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
378
|
-
|
|
379
|
-
await assert.rejects(
|
|
380
|
-
() =>
|
|
381
|
-
runAgent(
|
|
382
|
-
'onerror-throws-agent',
|
|
383
|
-
{ message: 'hi', threadId: 't3', resourceId: 'r3' },
|
|
384
|
-
{}
|
|
385
|
-
),
|
|
386
|
-
expectedError
|
|
387
|
-
)
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
test('returns suspended run when required RPC tool is missing', async () => {
|
|
391
|
-
addTestAgent('missing-rpc-agent')
|
|
392
|
-
pikkuState(null, 'agent', 'agentsMeta')['missing-rpc-agent'].tools = [
|
|
393
|
-
'deployMissing',
|
|
394
|
-
]
|
|
395
|
-
|
|
396
|
-
const createdRuns: any[] = []
|
|
397
|
-
const mockServices = {
|
|
398
|
-
logger: {
|
|
399
|
-
info: () => {},
|
|
400
|
-
warn: () => {},
|
|
401
|
-
error: () => {},
|
|
402
|
-
debug: () => {},
|
|
403
|
-
},
|
|
404
|
-
agentRunner: {
|
|
405
|
-
run: async () => {
|
|
406
|
-
throw new Error('should not run')
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
agentRunState: {
|
|
410
|
-
createRun: async (run: any) => {
|
|
411
|
-
createdRuns.push(run)
|
|
412
|
-
return 'run-missing-rpc'
|
|
413
|
-
},
|
|
414
|
-
updateRun: async () => {},
|
|
415
|
-
},
|
|
416
|
-
} as any
|
|
417
|
-
|
|
418
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
419
|
-
|
|
420
|
-
const result = await runAgent(
|
|
421
|
-
'missing-rpc-agent',
|
|
422
|
-
{ message: 'deploy', threadId: 'thread-1', resourceId: 'resource-1' },
|
|
423
|
-
asOwner('resource-1')
|
|
424
|
-
)
|
|
425
|
-
|
|
426
|
-
assert.equal(result.runId, 'run-missing-rpc')
|
|
427
|
-
assert.equal(result.text, '')
|
|
428
|
-
assert.deepEqual(result.steps, [])
|
|
429
|
-
assert.deepEqual(result.usage, { inputTokens: 0, outputTokens: 0 })
|
|
430
|
-
assert.deepEqual(createdRuns, [
|
|
431
|
-
{
|
|
432
|
-
agentName: 'missing-rpc-agent',
|
|
433
|
-
threadId: 'thread-1',
|
|
434
|
-
resourceId: 'resource-1',
|
|
435
|
-
status: 'suspended',
|
|
436
|
-
suspendReason: 'rpc-missing',
|
|
437
|
-
missingRpcs: ['deployMissing'],
|
|
438
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
439
|
-
createdAt: createdRuns[0].createdAt,
|
|
440
|
-
updatedAt: createdRuns[0].updatedAt,
|
|
441
|
-
},
|
|
442
|
-
])
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
test('modifyInput and modifyOutput middleware transform the run payload', async () => {
|
|
446
|
-
addTestAgent('middleware-agent')
|
|
447
|
-
|
|
448
|
-
const seenRunnerParams: any[] = []
|
|
449
|
-
const inputMessages = [
|
|
450
|
-
{ id: 'extra', role: 'system', content: 'extra', createdAt: new Date() },
|
|
451
|
-
] as any
|
|
452
|
-
const middleware: PikkuAgentMiddlewareHooks = {
|
|
453
|
-
modifyInput: async (_services, ctx) => ({
|
|
454
|
-
instructions: `${ctx.instructions}\n\nextra rules`,
|
|
455
|
-
messages: [...ctx.messages, ...inputMessages],
|
|
456
|
-
}),
|
|
457
|
-
modifyOutput: async (_services, ctx) => ({
|
|
458
|
-
text: `${ctx.text} [postprocessed]`,
|
|
459
|
-
messages: [...ctx.messages],
|
|
460
|
-
}),
|
|
461
|
-
}
|
|
462
|
-
const agent = pikkuState(null, 'agent', 'agents').get('middleware-agent')!
|
|
463
|
-
agent.agentMiddleware = [middleware] as any
|
|
464
|
-
pikkuState(null, 'agent', 'agents').set('middleware-agent', agent)
|
|
465
|
-
|
|
466
|
-
const mockServices = {
|
|
467
|
-
logger: {
|
|
468
|
-
info: () => {},
|
|
469
|
-
warn: () => {},
|
|
470
|
-
error: () => {},
|
|
471
|
-
debug: () => {},
|
|
472
|
-
},
|
|
473
|
-
agentRunner: {
|
|
474
|
-
run: async (params: any): Promise<AgentStepResult> => {
|
|
475
|
-
seenRunnerParams.push({
|
|
476
|
-
instructions: params.instructions,
|
|
477
|
-
messages: params.messages,
|
|
478
|
-
})
|
|
479
|
-
return makeStepResult({
|
|
480
|
-
text: 'Final answer',
|
|
481
|
-
object: { ok: true },
|
|
482
|
-
usage: { inputTokens: 11, outputTokens: 7 },
|
|
483
|
-
} as any)
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
agentRunState: {
|
|
487
|
-
createRun: async () => 'run-middleware',
|
|
488
|
-
updateRun: async () => {},
|
|
489
|
-
},
|
|
490
|
-
} as any
|
|
491
|
-
|
|
492
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
493
|
-
|
|
494
|
-
const result = await runAgent(
|
|
495
|
-
'middleware-agent',
|
|
496
|
-
{ message: 'hello', threadId: 'thread-mw', resourceId: 'resource-mw' },
|
|
497
|
-
{}
|
|
498
|
-
)
|
|
499
|
-
|
|
500
|
-
assert.equal(seenRunnerParams.length, 1)
|
|
501
|
-
assert.match(seenRunnerParams[0].instructions, /extra rules/)
|
|
502
|
-
assert.equal(seenRunnerParams[0].messages.at(-1).content, 'extra')
|
|
503
|
-
assert.equal(result.text, 'Final answer [postprocessed]')
|
|
504
|
-
assert.deepEqual(result.object, { ok: true })
|
|
505
|
-
})
|
|
506
|
-
|
|
507
|
-
test('prepareStep can stop execution before calling the runner', async () => {
|
|
508
|
-
addTestAgent('prepare-stop-agent')
|
|
509
|
-
|
|
510
|
-
const agent = pikkuState(null, 'agent', 'agents').get('prepare-stop-agent')!
|
|
511
|
-
agent.prepareStep = ({ stop }) => {
|
|
512
|
-
stop()
|
|
513
|
-
}
|
|
514
|
-
pikkuState(null, 'agent', 'agents').set('prepare-stop-agent', agent)
|
|
515
|
-
|
|
516
|
-
let runnerCalls = 0
|
|
517
|
-
const updates: any[] = []
|
|
518
|
-
const mockServices = {
|
|
519
|
-
logger: {
|
|
520
|
-
info: () => {},
|
|
521
|
-
warn: () => {},
|
|
522
|
-
error: () => {},
|
|
523
|
-
debug: () => {},
|
|
524
|
-
},
|
|
525
|
-
agentRunner: {
|
|
526
|
-
run: async (): Promise<AgentStepResult> => {
|
|
527
|
-
runnerCalls++
|
|
528
|
-
return makeStepResult({ text: 'should not happen' })
|
|
529
|
-
},
|
|
530
|
-
},
|
|
531
|
-
agentRunState: {
|
|
532
|
-
createRun: async () => 'run-stop',
|
|
533
|
-
updateRun: async (_runId: string, patch: any) => {
|
|
534
|
-
updates.push(patch)
|
|
535
|
-
},
|
|
536
|
-
},
|
|
537
|
-
} as any
|
|
538
|
-
|
|
539
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
540
|
-
|
|
541
|
-
const result = await runAgent(
|
|
542
|
-
'prepare-stop-agent',
|
|
543
|
-
{
|
|
544
|
-
message: 'hello',
|
|
545
|
-
threadId: 'thread-stop',
|
|
546
|
-
resourceId: 'resource-stop',
|
|
547
|
-
},
|
|
548
|
-
{}
|
|
549
|
-
)
|
|
550
|
-
|
|
551
|
-
assert.equal(runnerCalls, 0)
|
|
552
|
-
assert.equal(result.text, '')
|
|
553
|
-
assert.deepEqual(result.steps, [])
|
|
554
|
-
assert.deepEqual(updates, [
|
|
555
|
-
{
|
|
556
|
-
status: 'completed',
|
|
557
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
558
|
-
},
|
|
559
|
-
])
|
|
560
|
-
})
|
|
561
|
-
|
|
562
|
-
test('suspends with approval details when a tool call requires approval', async () => {
|
|
563
|
-
addTestAgent('approval-agent')
|
|
564
|
-
pikkuState(null, 'agent', 'agentsMeta')['approval-agent'].tools = ['deploy']
|
|
565
|
-
pikkuState(null, 'rpc', 'meta').deploy = 'deploy'
|
|
566
|
-
pikkuState(null, 'function', 'meta').deploy = {
|
|
567
|
-
description: 'Deploy',
|
|
568
|
-
approvalRequired: true,
|
|
569
|
-
inputSchemaName: 'DeployInput',
|
|
570
|
-
sessionless: true,
|
|
571
|
-
}
|
|
572
|
-
pikkuState(null, 'misc', 'schemas').set('DeployInput', {
|
|
573
|
-
type: 'object',
|
|
574
|
-
properties: { env: { type: 'string' } },
|
|
575
|
-
})
|
|
576
|
-
pikkuState(null, 'function', 'functions').set('deploy', {
|
|
577
|
-
approvalDescription: async () => {
|
|
578
|
-
throw new Error('description failed')
|
|
579
|
-
},
|
|
580
|
-
})
|
|
581
|
-
|
|
582
|
-
const updates: any[] = []
|
|
583
|
-
const savedMessages: any[] = []
|
|
584
|
-
const mockServices = {
|
|
585
|
-
logger: {
|
|
586
|
-
info: () => {},
|
|
587
|
-
warn: () => {},
|
|
588
|
-
error: () => {},
|
|
589
|
-
debug: () => {},
|
|
590
|
-
},
|
|
591
|
-
agentRunner: {
|
|
592
|
-
run: async (): Promise<AgentStepResult> =>
|
|
593
|
-
makeStepResult({
|
|
594
|
-
text: 'Need approval',
|
|
595
|
-
toolCalls: [
|
|
596
|
-
{
|
|
597
|
-
toolCallId: 'tc-approve',
|
|
598
|
-
toolName: 'deploy',
|
|
599
|
-
args: { env: 'prod' },
|
|
600
|
-
},
|
|
601
|
-
],
|
|
602
|
-
usage: { inputTokens: 4, outputTokens: 2 },
|
|
603
|
-
finishReason: 'tool-calls',
|
|
604
|
-
}),
|
|
605
|
-
},
|
|
606
|
-
agentRunState: {
|
|
607
|
-
createRun: async () => 'run-approval',
|
|
608
|
-
updateRun: async (_runId: string, patch: any) => {
|
|
609
|
-
updates.push(patch)
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
agentStorage: {
|
|
613
|
-
createThread: async () => {},
|
|
614
|
-
getMessages: async () => [],
|
|
615
|
-
saveMessages: async (_threadId: string, messages: any[]) => {
|
|
616
|
-
savedMessages.push(messages)
|
|
617
|
-
},
|
|
618
|
-
},
|
|
619
|
-
} as any
|
|
620
|
-
|
|
621
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
622
|
-
|
|
623
|
-
const result = await runAgent(
|
|
624
|
-
'approval-agent',
|
|
625
|
-
{ message: 'deploy', threadId: 'thread-a', resourceId: 'resource-a' },
|
|
626
|
-
{}
|
|
627
|
-
)
|
|
628
|
-
|
|
629
|
-
assert.equal(result.status, 'suspended')
|
|
630
|
-
assert.equal(result.text, 'Need approval')
|
|
631
|
-
assert.deepEqual(result.pendingApprovals, [
|
|
632
|
-
{
|
|
633
|
-
toolCallId: 'tc-approve',
|
|
634
|
-
toolName: 'deploy',
|
|
635
|
-
args: { env: 'prod' },
|
|
636
|
-
reason: undefined,
|
|
637
|
-
runId: 'run-approval',
|
|
638
|
-
},
|
|
639
|
-
])
|
|
640
|
-
assert.deepEqual(updates, [
|
|
641
|
-
{
|
|
642
|
-
status: 'suspended',
|
|
643
|
-
suspendReason: 'approval',
|
|
644
|
-
pendingApprovals: [
|
|
645
|
-
{
|
|
646
|
-
type: 'tool-call',
|
|
647
|
-
toolCallId: 'tc-approve',
|
|
648
|
-
toolName: 'deploy',
|
|
649
|
-
args: { env: 'prod' },
|
|
650
|
-
},
|
|
651
|
-
],
|
|
652
|
-
usage: { inputTokens: 4, outputTokens: 2, model: 'test/test-model' },
|
|
653
|
-
},
|
|
654
|
-
])
|
|
655
|
-
assert.equal(savedMessages.length, 2)
|
|
656
|
-
assert.equal(savedMessages[0][0].role, 'user')
|
|
657
|
-
assert.equal(savedMessages[0][1].role, 'assistant')
|
|
658
|
-
assert.equal(savedMessages[1][0].role, 'assistant')
|
|
659
|
-
})
|
|
660
|
-
})
|
|
661
|
-
|
|
662
|
-
describe('resumeAgentSync', () => {
|
|
663
|
-
test('throws for missing services, missing runs, wrong status, and missing runner', async () => {
|
|
664
|
-
pikkuState(null, 'package', 'singletonServices', {} as any)
|
|
665
|
-
await assert.rejects(() => resumeAgentSync('run-x', [], {}), {
|
|
666
|
-
message: 'AgentRunStateService not available in singletonServices',
|
|
667
|
-
})
|
|
668
|
-
|
|
669
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
670
|
-
agentRunState: {
|
|
671
|
-
getRun: async () => null,
|
|
672
|
-
},
|
|
673
|
-
} as any)
|
|
674
|
-
await assert.rejects(() => resumeAgentSync('run-x', [], {}), {
|
|
675
|
-
message: 'No run found for runId run-x',
|
|
676
|
-
})
|
|
677
|
-
|
|
678
|
-
addTestAgent('resume-guard-agent')
|
|
679
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
680
|
-
agentRunState: {
|
|
681
|
-
getRun: async () => ({
|
|
682
|
-
runId: 'run-y',
|
|
683
|
-
agentName: 'resume-guard-agent',
|
|
684
|
-
threadId: 't',
|
|
685
|
-
resourceId: 'r',
|
|
686
|
-
status: 'completed',
|
|
687
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
688
|
-
createdAt: new Date(),
|
|
689
|
-
updatedAt: new Date(),
|
|
690
|
-
}),
|
|
691
|
-
},
|
|
692
|
-
} as any)
|
|
693
|
-
await assert.rejects(() => resumeAgentSync('run-y', [], asOwner('r')), {
|
|
694
|
-
message: 'Run run-y is not suspended (status: completed)',
|
|
695
|
-
})
|
|
696
|
-
|
|
697
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
698
|
-
agentRunState: {
|
|
699
|
-
getRun: async () => ({
|
|
700
|
-
runId: 'run-z',
|
|
701
|
-
agentName: 'resume-guard-agent',
|
|
702
|
-
threadId: 't',
|
|
703
|
-
resourceId: 'r',
|
|
704
|
-
status: 'suspended',
|
|
705
|
-
pendingApprovals: [],
|
|
706
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
707
|
-
createdAt: new Date(),
|
|
708
|
-
updatedAt: new Date(),
|
|
709
|
-
}),
|
|
710
|
-
resolveApproval: async () => true,
|
|
711
|
-
updateRun: async () => {},
|
|
712
|
-
},
|
|
713
|
-
} as any)
|
|
714
|
-
await assert.rejects(
|
|
715
|
-
() => resumeAgentSync('run-z', [], asOwner('r')),
|
|
716
|
-
(error: unknown) => error instanceof AIProviderNotConfiguredError
|
|
717
|
-
)
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
test('replays approved tool calls, strips nulls, and continues the run', async () => {
|
|
721
|
-
addTestAgent('resume-agent')
|
|
722
|
-
pikkuState(null, 'agent', 'agentsMeta')['resume-agent'].tools = ['deploy']
|
|
723
|
-
pikkuState(null, 'rpc', 'meta').deploy = 'deploy'
|
|
724
|
-
pikkuState(null, 'function', 'meta').deploy = {
|
|
725
|
-
description: 'Deploy',
|
|
726
|
-
inputSchemaName: 'DeployInput',
|
|
727
|
-
sessionless: true,
|
|
728
|
-
}
|
|
729
|
-
pikkuState(null, 'misc', 'schemas').set('DeployInput', {
|
|
730
|
-
type: 'object',
|
|
731
|
-
properties: { env: { type: 'string' }, optional: { type: 'string' } },
|
|
732
|
-
})
|
|
733
|
-
|
|
734
|
-
let executedInput: any
|
|
735
|
-
pikkuState(null, 'function', 'functions').set('deploy', {
|
|
736
|
-
func: async (_services: any, input: any) => {
|
|
737
|
-
executedInput = input
|
|
738
|
-
return { deployed: true }
|
|
739
|
-
},
|
|
740
|
-
})
|
|
741
|
-
|
|
742
|
-
const savedMessages: any[] = []
|
|
743
|
-
const updates: any[] = []
|
|
744
|
-
const resolveCalls: any[] = []
|
|
745
|
-
const run: AgentRunState = {
|
|
746
|
-
runId: 'run-resume',
|
|
747
|
-
agentName: 'resume-agent',
|
|
748
|
-
threadId: 'thread-resume',
|
|
749
|
-
resourceId: 'resource-resume',
|
|
750
|
-
status: 'suspended',
|
|
751
|
-
suspendReason: 'approval',
|
|
752
|
-
pendingApprovals: [
|
|
753
|
-
{
|
|
754
|
-
type: 'tool-call',
|
|
755
|
-
toolCallId: 'tc-1',
|
|
756
|
-
toolName: 'deploy',
|
|
757
|
-
args: JSON.stringify({ env: 'prod', optional: null }),
|
|
758
|
-
},
|
|
759
|
-
],
|
|
760
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
761
|
-
createdAt: new Date(),
|
|
762
|
-
updatedAt: new Date(),
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
const mockServices = {
|
|
766
|
-
logger: {
|
|
767
|
-
info: () => {},
|
|
768
|
-
warn: () => {},
|
|
769
|
-
error: () => {},
|
|
770
|
-
debug: () => {},
|
|
771
|
-
},
|
|
772
|
-
agentRunner: {
|
|
773
|
-
run: async (): Promise<AgentStepResult> =>
|
|
774
|
-
makeStepResult({
|
|
775
|
-
text: 'Resumed answer',
|
|
776
|
-
usage: { inputTokens: 5, outputTokens: 3 },
|
|
777
|
-
}),
|
|
778
|
-
},
|
|
779
|
-
agentRunState: {
|
|
780
|
-
getRun: async () => run,
|
|
781
|
-
createRun: async () => 'unused',
|
|
782
|
-
updateRun: async (_runId: string, patch: any) => {
|
|
783
|
-
updates.push(patch)
|
|
784
|
-
},
|
|
785
|
-
resolveApproval: async (toolCallId: string, status: string) => {
|
|
786
|
-
resolveCalls.push({ toolCallId, status })
|
|
787
|
-
return true
|
|
788
|
-
},
|
|
789
|
-
},
|
|
790
|
-
agentStorage: {
|
|
791
|
-
saveMessages: async (threadId: string, messages: any[]) => {
|
|
792
|
-
savedMessages.push({ threadId, messages })
|
|
793
|
-
},
|
|
794
|
-
getMessages: async () => [],
|
|
795
|
-
},
|
|
796
|
-
} as any
|
|
797
|
-
|
|
798
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
799
|
-
|
|
800
|
-
const result = await resumeAgentSync(
|
|
801
|
-
'run-resume',
|
|
802
|
-
[{ toolCallId: 'tc-1', approved: true }],
|
|
803
|
-
asOwner('resource-resume')
|
|
804
|
-
)
|
|
805
|
-
|
|
806
|
-
assert.deepEqual(resolveCalls, [{ toolCallId: 'tc-1', status: 'approved' }])
|
|
807
|
-
assert.deepEqual(executedInput, { env: 'prod' })
|
|
808
|
-
assert.equal(savedMessages.length, 2)
|
|
809
|
-
assert.equal(savedMessages[0].messages[0].role, 'tool')
|
|
810
|
-
assert.equal(result.text, 'Resumed answer')
|
|
811
|
-
assert.deepEqual(updates, [
|
|
812
|
-
{ status: 'running' },
|
|
813
|
-
{
|
|
814
|
-
status: 'completed',
|
|
815
|
-
usage: { inputTokens: 5, outputTokens: 3, model: 'test/test-model' },
|
|
816
|
-
},
|
|
817
|
-
])
|
|
818
|
-
})
|
|
819
|
-
|
|
820
|
-
test('an approver that loses the claim never runs the tool', async () => {
|
|
821
|
-
addTestAgent('claim-agent')
|
|
822
|
-
pikkuState(null, 'agent', 'agentsMeta')['claim-agent'].tools = ['refund']
|
|
823
|
-
pikkuState(null, 'rpc', 'meta').refund = 'refund'
|
|
824
|
-
pikkuState(null, 'function', 'meta').refund = {
|
|
825
|
-
description: 'Refund',
|
|
826
|
-
sessionless: true,
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
let executions = 0
|
|
830
|
-
pikkuState(null, 'function', 'functions').set('refund', {
|
|
831
|
-
func: async () => {
|
|
832
|
-
executions++
|
|
833
|
-
return { refunded: true }
|
|
834
|
-
},
|
|
835
|
-
})
|
|
836
|
-
|
|
837
|
-
const run: AgentRunState = {
|
|
838
|
-
runId: 'run-claim',
|
|
839
|
-
agentName: 'claim-agent',
|
|
840
|
-
threadId: 'thread-claim',
|
|
841
|
-
resourceId: 'resource-claim',
|
|
842
|
-
status: 'suspended',
|
|
843
|
-
suspendReason: 'approval',
|
|
844
|
-
pendingApprovals: [
|
|
845
|
-
{
|
|
846
|
-
type: 'tool-call',
|
|
847
|
-
toolCallId: 'tc-claim',
|
|
848
|
-
toolName: 'refund',
|
|
849
|
-
args: {},
|
|
850
|
-
},
|
|
851
|
-
],
|
|
852
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
853
|
-
createdAt: new Date(),
|
|
854
|
-
updatedAt: new Date(),
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// Every concurrent approver reads the same `suspended` run with the same
|
|
858
|
-
// pending list; the store hands the claim to exactly one of them.
|
|
859
|
-
let claimsLeft = 1
|
|
860
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
861
|
-
logger: {
|
|
862
|
-
info: () => {},
|
|
863
|
-
warn: () => {},
|
|
864
|
-
error: () => {},
|
|
865
|
-
debug: () => {},
|
|
866
|
-
},
|
|
867
|
-
agentRunner: {
|
|
868
|
-
run: async (): Promise<AgentStepResult> =>
|
|
869
|
-
makeStepResult({
|
|
870
|
-
text: 'Refunded',
|
|
871
|
-
usage: { inputTokens: 1, outputTokens: 1 },
|
|
872
|
-
}),
|
|
873
|
-
},
|
|
874
|
-
agentRunState: {
|
|
875
|
-
getRun: async () => run,
|
|
876
|
-
createRun: async () => 'unused',
|
|
877
|
-
updateRun: async () => {},
|
|
878
|
-
resolveApproval: async () => claimsLeft-- > 0,
|
|
879
|
-
},
|
|
880
|
-
agentStorage: {
|
|
881
|
-
saveMessages: async () => {},
|
|
882
|
-
getMessages: async () => [],
|
|
883
|
-
},
|
|
884
|
-
} as any)
|
|
885
|
-
|
|
886
|
-
const approvals = [{ toolCallId: 'tc-claim', approved: true }]
|
|
887
|
-
await resumeAgentSync('run-claim', approvals, asOwner('resource-claim'))
|
|
888
|
-
assert.equal(executions, 1, 'the winner ran the tool once')
|
|
889
|
-
|
|
890
|
-
await assert.rejects(
|
|
891
|
-
() => resumeAgentSync('run-claim', approvals, asOwner('resource-claim')),
|
|
892
|
-
/already resolved by another caller/
|
|
893
|
-
)
|
|
894
|
-
assert.equal(executions, 1, 'the loser did not run it a second time')
|
|
895
|
-
})
|
|
896
|
-
|
|
897
|
-
test('records denied approvals and rejects agent mismatches', async () => {
|
|
898
|
-
addTestAgent('resume-agent')
|
|
899
|
-
|
|
900
|
-
const baseRun: AgentRunState = {
|
|
901
|
-
runId: 'run-deny',
|
|
902
|
-
agentName: 'resume-agent',
|
|
903
|
-
threadId: 'thread-deny',
|
|
904
|
-
resourceId: 'resource-deny',
|
|
905
|
-
status: 'suspended',
|
|
906
|
-
suspendReason: 'approval',
|
|
907
|
-
pendingApprovals: [
|
|
908
|
-
{
|
|
909
|
-
type: 'tool-call',
|
|
910
|
-
toolCallId: 'tc-2',
|
|
911
|
-
toolName: 'deploy',
|
|
912
|
-
args: { env: 'prod' },
|
|
913
|
-
},
|
|
914
|
-
],
|
|
915
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
916
|
-
createdAt: new Date(),
|
|
917
|
-
updatedAt: new Date(),
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
const resolveCalls: any[] = []
|
|
921
|
-
const savedMessages: any[] = []
|
|
922
|
-
const mockServices = {
|
|
923
|
-
logger: {
|
|
924
|
-
info: () => {},
|
|
925
|
-
warn: () => {},
|
|
926
|
-
error: () => {},
|
|
927
|
-
debug: () => {},
|
|
928
|
-
},
|
|
929
|
-
agentRunner: {
|
|
930
|
-
run: async (): Promise<AgentStepResult> =>
|
|
931
|
-
makeStepResult({
|
|
932
|
-
text: 'Declined',
|
|
933
|
-
usage: { inputTokens: 1, outputTokens: 1 },
|
|
934
|
-
}),
|
|
935
|
-
},
|
|
936
|
-
agentRunState: {
|
|
937
|
-
getRun: async () => baseRun,
|
|
938
|
-
createRun: async () => 'unused',
|
|
939
|
-
updateRun: async () => {},
|
|
940
|
-
resolveApproval: async (toolCallId: string, status: string) => {
|
|
941
|
-
resolveCalls.push({ toolCallId, status })
|
|
942
|
-
return true
|
|
943
|
-
},
|
|
944
|
-
},
|
|
945
|
-
agentStorage: {
|
|
946
|
-
saveMessages: async (_threadId: string, messages: any[]) => {
|
|
947
|
-
savedMessages.push(messages)
|
|
948
|
-
},
|
|
949
|
-
getMessages: async () => [],
|
|
950
|
-
},
|
|
951
|
-
} as any
|
|
952
|
-
|
|
953
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
954
|
-
|
|
955
|
-
const denied = await resumeAgentSync(
|
|
956
|
-
'run-deny',
|
|
957
|
-
[{ toolCallId: 'tc-2', approved: false }],
|
|
958
|
-
asOwner('resource-deny')
|
|
959
|
-
)
|
|
960
|
-
|
|
961
|
-
assert.deepEqual(resolveCalls, [{ toolCallId: 'tc-2', status: 'denied' }])
|
|
962
|
-
assert.match(
|
|
963
|
-
savedMessages[0][0].toolResults[0].result,
|
|
964
|
-
/explicitly declined/
|
|
965
|
-
)
|
|
966
|
-
assert.equal(denied.text, 'Declined')
|
|
967
|
-
|
|
968
|
-
await assert.rejects(
|
|
969
|
-
() =>
|
|
970
|
-
resumeAgentSync(
|
|
971
|
-
'run-deny',
|
|
972
|
-
[{ toolCallId: 'tc-2', approved: false }],
|
|
973
|
-
asOwner('resource-deny'),
|
|
974
|
-
'other-agent'
|
|
975
|
-
),
|
|
976
|
-
{
|
|
977
|
-
message:
|
|
978
|
-
"Run run-deny belongs to agent 'resume-agent', not 'other-agent'",
|
|
979
|
-
}
|
|
980
|
-
)
|
|
981
|
-
})
|
|
982
|
-
|
|
983
|
-
test('captures tool execution errors during resume and persists them as tool results', async () => {
|
|
984
|
-
addTestAgent('resume-error-agent')
|
|
985
|
-
pikkuState(null, 'agent', 'agentsMeta')['resume-error-agent'].tools = [
|
|
986
|
-
'deploy',
|
|
987
|
-
]
|
|
988
|
-
pikkuState(null, 'rpc', 'meta').deploy = 'deploy'
|
|
989
|
-
pikkuState(null, 'function', 'meta').deploy = {
|
|
990
|
-
description: 'Deploy',
|
|
991
|
-
inputSchemaName: 'DeployInput',
|
|
992
|
-
sessionless: true,
|
|
993
|
-
}
|
|
994
|
-
pikkuState(null, 'misc', 'schemas').set('DeployInput', {
|
|
995
|
-
type: 'object',
|
|
996
|
-
properties: { env: { type: 'string' } },
|
|
997
|
-
})
|
|
998
|
-
pikkuState(null, 'function', 'functions').set('deploy', {
|
|
999
|
-
func: async () => {
|
|
1000
|
-
throw new Error('tool exploded')
|
|
1001
|
-
},
|
|
1002
|
-
})
|
|
1003
|
-
|
|
1004
|
-
const savedMessages: any[] = []
|
|
1005
|
-
const run: AgentRunState = {
|
|
1006
|
-
runId: 'run-error',
|
|
1007
|
-
agentName: 'resume-error-agent',
|
|
1008
|
-
threadId: 'thread-error',
|
|
1009
|
-
resourceId: 'resource-error',
|
|
1010
|
-
status: 'suspended',
|
|
1011
|
-
suspendReason: 'approval',
|
|
1012
|
-
pendingApprovals: [
|
|
1013
|
-
{
|
|
1014
|
-
type: 'tool-call',
|
|
1015
|
-
toolCallId: 'tc-error',
|
|
1016
|
-
toolName: 'deploy',
|
|
1017
|
-
args: { env: 'prod' },
|
|
1018
|
-
},
|
|
1019
|
-
],
|
|
1020
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
1021
|
-
createdAt: new Date(),
|
|
1022
|
-
updatedAt: new Date(),
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
1026
|
-
logger: {
|
|
1027
|
-
info: () => {},
|
|
1028
|
-
warn: () => {},
|
|
1029
|
-
error: () => {},
|
|
1030
|
-
debug: () => {},
|
|
1031
|
-
},
|
|
1032
|
-
agentRunner: {
|
|
1033
|
-
run: async (): Promise<AgentStepResult> =>
|
|
1034
|
-
makeStepResult({
|
|
1035
|
-
text: 'Recovered',
|
|
1036
|
-
usage: { inputTokens: 1, outputTokens: 1 },
|
|
1037
|
-
}),
|
|
1038
|
-
},
|
|
1039
|
-
agentRunState: {
|
|
1040
|
-
getRun: async () => run,
|
|
1041
|
-
resolveApproval: async () => true,
|
|
1042
|
-
updateRun: async () => {},
|
|
1043
|
-
},
|
|
1044
|
-
agentStorage: {
|
|
1045
|
-
saveMessages: async (_threadId: string, messages: any[]) => {
|
|
1046
|
-
savedMessages.push(messages)
|
|
1047
|
-
},
|
|
1048
|
-
getMessages: async () => [],
|
|
1049
|
-
},
|
|
1050
|
-
} as any)
|
|
1051
|
-
|
|
1052
|
-
const result = await resumeAgentSync(
|
|
1053
|
-
'run-error',
|
|
1054
|
-
[{ toolCallId: 'tc-error', approved: true }],
|
|
1055
|
-
asOwner('resource-error')
|
|
1056
|
-
)
|
|
1057
|
-
|
|
1058
|
-
assert.match(savedMessages[0][0].toolResults[0].result, /tool exploded/)
|
|
1059
|
-
assert.equal(result.text, 'Recovered')
|
|
1060
|
-
})
|
|
1061
|
-
})
|
|
1062
|
-
|
|
1063
|
-
describe('getCredential API key override', () => {
|
|
1064
|
-
test('uses withApiKey runner when getCredential returns apiKey', async () => {
|
|
1065
|
-
addTestAgent('api-key-agent')
|
|
1066
|
-
|
|
1067
|
-
const originalRunCalls: string[] = []
|
|
1068
|
-
const overrideRunCalls: string[] = []
|
|
1069
|
-
|
|
1070
|
-
const overrideRunner = {
|
|
1071
|
-
run: async (): Promise<AgentStepResult> => {
|
|
1072
|
-
overrideRunCalls.push('override')
|
|
1073
|
-
return makeStepResult({ text: 'from-override', finishReason: 'stop' })
|
|
1074
|
-
},
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
const mockServices = {
|
|
1078
|
-
logger: {
|
|
1079
|
-
info: () => {},
|
|
1080
|
-
warn: () => {},
|
|
1081
|
-
error: () => {},
|
|
1082
|
-
debug: () => {},
|
|
1083
|
-
},
|
|
1084
|
-
agentRunner: {
|
|
1085
|
-
run: async (): Promise<AgentStepResult> => {
|
|
1086
|
-
originalRunCalls.push('original')
|
|
1087
|
-
return makeStepResult({ text: 'from-original', finishReason: 'stop' })
|
|
1088
|
-
},
|
|
1089
|
-
withApiKey: (_key: string) => overrideRunner,
|
|
1090
|
-
},
|
|
1091
|
-
agentRunState: {
|
|
1092
|
-
createRun: async () => 'run-key-override',
|
|
1093
|
-
updateRun: async () => {},
|
|
1094
|
-
},
|
|
1095
|
-
} as any
|
|
1096
|
-
|
|
1097
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
1098
|
-
|
|
1099
|
-
const result = await runAgent(
|
|
1100
|
-
'api-key-agent',
|
|
1101
|
-
{ message: 'hi', threadId: 't-key', resourceId: 'r-key' },
|
|
1102
|
-
{ getCredential: async () => ({ apiKey: 'my-secret-key' }) }
|
|
1103
|
-
)
|
|
1104
|
-
|
|
1105
|
-
assert.equal(result.text, 'from-override')
|
|
1106
|
-
assert.equal(overrideRunCalls.length, 1)
|
|
1107
|
-
assert.equal(originalRunCalls.length, 0)
|
|
1108
|
-
})
|
|
1109
|
-
|
|
1110
|
-
test('uses original runner when getCredential returns null', async () => {
|
|
1111
|
-
addTestAgent('no-cred-agent')
|
|
1112
|
-
|
|
1113
|
-
const originalRunCalls: string[] = []
|
|
1114
|
-
|
|
1115
|
-
const mockServices = {
|
|
1116
|
-
logger: {
|
|
1117
|
-
info: () => {},
|
|
1118
|
-
warn: () => {},
|
|
1119
|
-
error: () => {},
|
|
1120
|
-
debug: () => {},
|
|
1121
|
-
},
|
|
1122
|
-
agentRunner: {
|
|
1123
|
-
run: async (): Promise<AgentStepResult> => {
|
|
1124
|
-
originalRunCalls.push('original')
|
|
1125
|
-
return makeStepResult({ text: 'from-original', finishReason: 'stop' })
|
|
1126
|
-
},
|
|
1127
|
-
withApiKey: (_key: string) => ({
|
|
1128
|
-
run: async () =>
|
|
1129
|
-
makeStepResult({
|
|
1130
|
-
text: 'should-not-be-called',
|
|
1131
|
-
finishReason: 'stop',
|
|
1132
|
-
}),
|
|
1133
|
-
}),
|
|
1134
|
-
},
|
|
1135
|
-
agentRunState: {
|
|
1136
|
-
createRun: async () => 'run-no-cred',
|
|
1137
|
-
updateRun: async () => {},
|
|
1138
|
-
},
|
|
1139
|
-
} as any
|
|
1140
|
-
|
|
1141
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
1142
|
-
|
|
1143
|
-
const result = await runAgent(
|
|
1144
|
-
'no-cred-agent',
|
|
1145
|
-
{ message: 'hi', threadId: 't-no-cred', resourceId: 'r-no-cred' },
|
|
1146
|
-
{ getCredential: async () => null }
|
|
1147
|
-
)
|
|
1148
|
-
|
|
1149
|
-
assert.equal(result.text, 'from-original')
|
|
1150
|
-
assert.equal(originalRunCalls.length, 1)
|
|
1151
|
-
})
|
|
1152
|
-
|
|
1153
|
-
test('uses original runner when runner does not implement withApiKey', async () => {
|
|
1154
|
-
addTestAgent('no-withkey-agent')
|
|
1155
|
-
|
|
1156
|
-
const originalRunCalls: string[] = []
|
|
1157
|
-
|
|
1158
|
-
const mockServices = {
|
|
1159
|
-
logger: {
|
|
1160
|
-
info: () => {},
|
|
1161
|
-
warn: () => {},
|
|
1162
|
-
error: () => {},
|
|
1163
|
-
debug: () => {},
|
|
1164
|
-
},
|
|
1165
|
-
agentRunner: {
|
|
1166
|
-
run: async (): Promise<AgentStepResult> => {
|
|
1167
|
-
originalRunCalls.push('original')
|
|
1168
|
-
return makeStepResult({ text: 'from-original', finishReason: 'stop' })
|
|
1169
|
-
},
|
|
1170
|
-
},
|
|
1171
|
-
agentRunState: {
|
|
1172
|
-
createRun: async () => 'run-no-withkey',
|
|
1173
|
-
updateRun: async () => {},
|
|
1174
|
-
},
|
|
1175
|
-
} as any
|
|
1176
|
-
|
|
1177
|
-
pikkuState(null, 'package', 'singletonServices', mockServices)
|
|
1178
|
-
|
|
1179
|
-
await runAgent(
|
|
1180
|
-
'no-withkey-agent',
|
|
1181
|
-
{ message: 'hi', threadId: 't-no-withkey', resourceId: 'r-no-withkey' },
|
|
1182
|
-
{ getCredential: async () => ({ apiKey: 'ignored-key' }) }
|
|
1183
|
-
)
|
|
1184
|
-
|
|
1185
|
-
assert.equal(originalRunCalls.length, 1)
|
|
1186
|
-
})
|
|
1187
|
-
})
|
|
1188
|
-
|
|
1189
|
-
describe('C2 resume run ownership', () => {
|
|
1190
|
-
const suspendedRun = (resourceId: string) => ({
|
|
1191
|
-
runId: 'run-owned',
|
|
1192
|
-
agentName: 'resume-owner-agent',
|
|
1193
|
-
threadId: 't',
|
|
1194
|
-
resourceId,
|
|
1195
|
-
status: 'suspended',
|
|
1196
|
-
pendingApprovals: [],
|
|
1197
|
-
usage: { inputTokens: 0, outputTokens: 0, model: 'test/test-model' },
|
|
1198
|
-
createdAt: new Date(),
|
|
1199
|
-
updatedAt: new Date(),
|
|
1200
|
-
})
|
|
1201
|
-
|
|
1202
|
-
const withSession = (userId: string) => ({
|
|
1203
|
-
sessionService: { get: () => ({ userId }) } as never,
|
|
1204
|
-
})
|
|
1205
|
-
|
|
1206
|
-
test('rejects resuming a run owned by another user', async () => {
|
|
1207
|
-
addTestAgent('resume-owner-agent')
|
|
1208
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
1209
|
-
agentRunState: { getRun: async () => suspendedRun('user-a') },
|
|
1210
|
-
} as any)
|
|
1211
|
-
|
|
1212
|
-
await assert.rejects(
|
|
1213
|
-
() => resumeAgentSync('run-owned', [], withSession('user-b')),
|
|
1214
|
-
(e: unknown) => e instanceof ForbiddenError
|
|
1215
|
-
)
|
|
1216
|
-
})
|
|
1217
|
-
|
|
1218
|
-
test('allows the owning user past the ownership gate', async () => {
|
|
1219
|
-
addTestAgent('resume-owner-agent')
|
|
1220
|
-
pikkuState(null, 'package', 'singletonServices', {
|
|
1221
|
-
agentRunState: { getRun: async () => suspendedRun('user-a') },
|
|
1222
|
-
} as any)
|
|
1223
|
-
|
|
1224
|
-
await assert.rejects(
|
|
1225
|
-
() => resumeAgentSync('run-owned', [], withSession('user-a')),
|
|
1226
|
-
(e: unknown) => e instanceof AIProviderNotConfiguredError
|
|
1227
|
-
)
|
|
1228
|
-
})
|
|
1229
|
-
})
|