@stigmer/server 3.24.0 → 3.26.0
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/dist/authorization/authorizer.d.ts +10 -4
- package/dist/authorization/authorizer.d.ts.map +1 -1
- package/dist/authorization/authorizer.js +11 -4
- package/dist/authorization/authorizer.js.map +1 -1
- package/dist/authorization/model/index.d.ts +4 -4
- package/dist/authorization/model/index.d.ts.map +1 -1
- package/dist/authorization/model/index.js +2 -0
- package/dist/authorization/model/index.js.map +1 -1
- package/dist/authorization/model/oauth_app.d.ts.map +1 -1
- package/dist/authorization/model/oauth_app.js +3 -2
- package/dist/authorization/model/oauth_app.js.map +1 -1
- package/dist/authorization/model/platform_client.d.ts +2 -0
- package/dist/authorization/model/platform_client.d.ts.map +1 -0
- package/dist/authorization/model/platform_client.js +31 -0
- package/dist/authorization/model/platform_client.js.map +1 -0
- package/dist/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +99 -13
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/list-indexes.d.ts +3 -0
- package/dist/boot/list-indexes.d.ts.map +1 -0
- package/dist/boot/list-indexes.js +24 -0
- package/dist/boot/list-indexes.js.map +1 -0
- package/dist/boot/route-shadowing.d.ts +25 -0
- package/dist/boot/route-shadowing.d.ts.map +1 -0
- package/dist/boot/route-shadowing.js +17 -0
- package/dist/boot/route-shadowing.js.map +1 -0
- package/dist/domain/agentexecution/controller.d.ts.map +1 -1
- package/dist/domain/agentexecution/controller.js +6 -8
- package/dist/domain/agentexecution/controller.js.map +1 -1
- package/dist/domain/agentexecution/list-index.d.ts +2 -0
- package/dist/domain/agentexecution/list-index.d.ts.map +1 -0
- package/dist/domain/agentexecution/list-index.js +23 -0
- package/dist/domain/agentexecution/list-index.js.map +1 -0
- package/dist/domain/agentexecution/steps.d.ts +17 -33
- package/dist/domain/agentexecution/steps.d.ts.map +1 -1
- package/dist/domain/agentexecution/steps.js +94 -95
- package/dist/domain/agentexecution/steps.js.map +1 -1
- package/dist/domain/agentexecution/usage.d.ts.map +1 -1
- package/dist/domain/agentexecution/usage.js +37 -14
- package/dist/domain/agentexecution/usage.js.map +1 -1
- package/dist/domain/artifact/controller.d.ts.map +1 -1
- package/dist/domain/artifact/controller.js +27 -15
- package/dist/domain/artifact/controller.js.map +1 -1
- package/dist/domain/artifact/list-index.d.ts +2 -0
- package/dist/domain/artifact/list-index.d.ts.map +1 -0
- package/dist/domain/artifact/list-index.js +21 -0
- package/dist/domain/artifact/list-index.js.map +1 -0
- package/dist/domain/iampolicy/membership.d.ts +6 -1
- package/dist/domain/iampolicy/membership.d.ts.map +1 -1
- package/dist/domain/iampolicy/membership.js +8 -2
- package/dist/domain/iampolicy/membership.js.map +1 -1
- package/dist/domain/identityaccount/constants.d.ts +13 -0
- package/dist/domain/identityaccount/constants.d.ts.map +1 -1
- package/dist/domain/identityaccount/constants.js +17 -0
- package/dist/domain/identityaccount/constants.js.map +1 -1
- package/dist/domain/identityaccount/controller.d.ts +3 -1
- package/dist/domain/identityaccount/controller.d.ts.map +1 -1
- package/dist/domain/identityaccount/controller.js +15 -6
- package/dist/domain/identityaccount/controller.js.map +1 -1
- package/dist/domain/identityaccount/operator.d.ts.map +1 -1
- package/dist/domain/identityaccount/operator.js +1 -0
- package/dist/domain/identityaccount/operator.js.map +1 -1
- package/dist/domain/identityaccount/provisioning.d.ts +18 -0
- package/dist/domain/identityaccount/provisioning.d.ts.map +1 -1
- package/dist/domain/identityaccount/provisioning.js +1 -0
- package/dist/domain/identityaccount/provisioning.js.map +1 -1
- package/dist/domain/identityaccount/resource-store.js +9 -5
- package/dist/domain/identityaccount/resource-store.js.map +1 -1
- package/dist/domain/identityaccount/steps.d.ts +11 -2
- package/dist/domain/identityaccount/steps.d.ts.map +1 -1
- package/dist/domain/identityaccount/steps.js +42 -4
- package/dist/domain/identityaccount/steps.js.map +1 -1
- package/dist/domain/identityaccount/store-contract.d.ts.map +1 -1
- package/dist/domain/identityaccount/store-contract.js +33 -0
- package/dist/domain/identityaccount/store-contract.js.map +1 -1
- package/dist/domain/identityaccount/store.d.ts +7 -5
- package/dist/domain/identityaccount/store.d.ts.map +1 -1
- package/dist/domain/identityaccount/store.js.map +1 -1
- package/dist/domain/platform/controller.d.ts +10 -0
- package/dist/domain/platform/controller.d.ts.map +1 -1
- package/dist/domain/platform/controller.js +2 -1
- package/dist/domain/platform/controller.js.map +1 -1
- package/dist/domain/platformclient/constants.d.ts +60 -0
- package/dist/domain/platformclient/constants.d.ts.map +1 -0
- package/dist/domain/platformclient/constants.js +78 -0
- package/dist/domain/platformclient/constants.js.map +1 -0
- package/dist/domain/platformclient/controller.d.ts +59 -0
- package/dist/domain/platformclient/controller.d.ts.map +1 -0
- package/dist/domain/platformclient/controller.js +191 -0
- package/dist/domain/platformclient/controller.js.map +1 -0
- package/dist/domain/platformclient/credentials.d.ts +13 -0
- package/dist/domain/platformclient/credentials.d.ts.map +1 -0
- package/dist/domain/platformclient/credentials.js +56 -0
- package/dist/domain/platformclient/credentials.js.map +1 -0
- package/dist/domain/platformclient/mint.d.ts +23 -0
- package/dist/domain/platformclient/mint.d.ts.map +1 -0
- package/dist/domain/platformclient/mint.js +254 -0
- package/dist/domain/platformclient/mint.js.map +1 -0
- package/dist/domain/platformclient/origin-guard.d.ts +9 -0
- package/dist/domain/platformclient/origin-guard.d.ts.map +1 -0
- package/dist/domain/platformclient/origin-guard.js +81 -0
- package/dist/domain/platformclient/origin-guard.js.map +1 -0
- package/dist/domain/platformclient/resource-store.d.ts +4 -0
- package/dist/domain/platformclient/resource-store.d.ts.map +1 -0
- package/dist/domain/platformclient/resource-store.js +117 -0
- package/dist/domain/platformclient/resource-store.js.map +1 -0
- package/dist/domain/platformclient/steps.d.ts +51 -0
- package/dist/domain/platformclient/steps.d.ts.map +1 -0
- package/dist/domain/platformclient/steps.js +339 -0
- package/dist/domain/platformclient/steps.js.map +1 -0
- package/dist/domain/platformclient/store-contract.d.ts +8 -0
- package/dist/domain/platformclient/store-contract.d.ts.map +1 -0
- package/dist/domain/platformclient/store-contract.js +208 -0
- package/dist/domain/platformclient/store-contract.js.map +1 -0
- package/dist/domain/platformclient/store.d.ts +58 -0
- package/dist/domain/platformclient/store.d.ts.map +1 -0
- package/dist/domain/platformclient/store.js +13 -0
- package/dist/domain/platformclient/store.js.map +1 -0
- package/dist/domain/platformclient/system-managed.d.ts +18 -0
- package/dist/domain/platformclient/system-managed.d.ts.map +1 -0
- package/dist/domain/platformclient/system-managed.js +80 -0
- package/dist/domain/platformclient/system-managed.js.map +1 -0
- package/dist/domain/platformclient/token-controller.d.ts +11 -0
- package/dist/domain/platformclient/token-controller.d.ts.map +1 -0
- package/dist/domain/platformclient/token-controller.js +32 -0
- package/dist/domain/platformclient/token-controller.js.map +1 -0
- package/dist/domain/platformclient/verifier.d.ts +10 -0
- package/dist/domain/platformclient/verifier.d.ts.map +1 -0
- package/dist/domain/platformclient/verifier.js +76 -0
- package/dist/domain/platformclient/verifier.js.map +1 -0
- package/dist/domain/session/list-index.d.ts +4 -0
- package/dist/domain/session/list-index.d.ts.map +1 -0
- package/dist/domain/session/list-index.js +26 -0
- package/dist/domain/session/list-index.js.map +1 -0
- package/dist/domain/session/steps.d.ts +7 -8
- package/dist/domain/session/steps.d.ts.map +1 -1
- package/dist/domain/session/steps.js +76 -78
- package/dist/domain/session/steps.js.map +1 -1
- package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
- package/dist/domain/workflowexecution/controller.js +53 -55
- package/dist/domain/workflowexecution/controller.js.map +1 -1
- package/dist/domain/workflowexecution/execution-filter.d.ts +4 -0
- package/dist/domain/workflowexecution/execution-filter.d.ts.map +1 -1
- package/dist/domain/workflowexecution/execution-filter.js +11 -5
- package/dist/domain/workflowexecution/execution-filter.js.map +1 -1
- package/dist/domain/workflowexecution/get-execution-summary.d.ts.map +1 -1
- package/dist/domain/workflowexecution/get-execution-summary.js +23 -17
- package/dist/domain/workflowexecution/get-execution-summary.js.map +1 -1
- package/dist/domain/workflowexecution/list-index.d.ts +2 -0
- package/dist/domain/workflowexecution/list-index.d.ts.map +1 -0
- package/dist/domain/workflowexecution/list-index.js +21 -0
- package/dist/domain/workflowexecution/list-index.js.map +1 -0
- package/dist/domain/workflowexecution/list-pending-approvals.d.ts.map +1 -1
- package/dist/domain/workflowexecution/list-pending-approvals.js +69 -32
- package/dist/domain/workflowexecution/list-pending-approvals.js.map +1 -1
- package/dist/domain/workflowexecution/queries.d.ts +30 -4
- package/dist/domain/workflowexecution/queries.d.ts.map +1 -1
- package/dist/domain/workflowexecution/queries.js +76 -22
- package/dist/domain/workflowexecution/queries.js.map +1 -1
- package/dist/encryption/key-manager.d.ts +20 -3
- package/dist/encryption/key-manager.d.ts.map +1 -1
- package/dist/encryption/key-manager.js +64 -42
- package/dist/encryption/key-manager.js.map +1 -1
- package/dist/extensions/caller-guards.d.ts +8 -3
- package/dist/extensions/caller-guards.d.ts.map +1 -1
- package/dist/extensions/drivers.d.ts +37 -0
- package/dist/extensions/drivers.d.ts.map +1 -1
- package/dist/extensions/guest-token-minting.d.ts +26 -0
- package/dist/extensions/guest-token-minting.d.ts.map +1 -0
- package/dist/extensions/guest-token-minting.js +2 -0
- package/dist/extensions/guest-token-minting.js.map +1 -0
- package/dist/extensions/identity.d.ts +6 -4
- package/dist/extensions/identity.d.ts.map +1 -1
- package/dist/extensions/identity.js.map +1 -1
- package/dist/extensions/list-read-scope.d.ts +9 -12
- package/dist/extensions/list-read-scope.d.ts.map +1 -1
- package/dist/extensions/list-read-scope.js.map +1 -1
- package/dist/extensions/registry.d.ts +30 -1
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/extensions/registry.js +34 -1
- package/dist/extensions/registry.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/interceptors/auth.d.ts +14 -0
- package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
- package/dist/pipeline/interceptors/auth.js +24 -0
- package/dist/pipeline/interceptors/auth.js.map +1 -1
- package/dist/pipeline/steps/build-update-state.d.ts +11 -1
- package/dist/pipeline/steps/build-update-state.d.ts.map +1 -1
- package/dist/pipeline/steps/build-update-state.js +5 -2
- package/dist/pipeline/steps/build-update-state.js.map +1 -1
- package/dist/pipeline/steps/list-page.d.ts +63 -0
- package/dist/pipeline/steps/list-page.d.ts.map +1 -0
- package/dist/pipeline/steps/list-page.js +187 -0
- package/dist/pipeline/steps/list-page.js.map +1 -0
- package/dist/platformtoken/envelope.d.ts +100 -0
- package/dist/platformtoken/envelope.d.ts.map +1 -0
- package/dist/platformtoken/envelope.js +184 -0
- package/dist/platformtoken/envelope.js.map +1 -0
- package/dist/platformtoken/key-ring.d.ts +85 -0
- package/dist/platformtoken/key-ring.d.ts.map +1 -0
- package/dist/platformtoken/key-ring.js +164 -0
- package/dist/platformtoken/key-ring.js.map +1 -0
- package/dist/query/activity/handler.d.ts +6 -7
- package/dist/query/activity/handler.d.ts.map +1 -1
- package/dist/query/activity/handler.js +42 -59
- package/dist/query/activity/handler.js.map +1 -1
- package/dist/store/interface.d.ts +29 -0
- package/dist/store/interface.d.ts.map +1 -1
- package/dist/store/interface.js.map +1 -1
- package/dist/store/list-index.d.ts +123 -0
- package/dist/store/list-index.d.ts.map +1 -0
- package/dist/store/list-index.js +277 -0
- package/dist/store/list-index.js.map +1 -0
- package/dist/store/logger.d.ts +3 -0
- package/dist/store/logger.d.ts.map +1 -1
- package/dist/store/logger.js +5 -1
- package/dist/store/logger.js.map +1 -1
- package/dist/store/postgres/migrations.d.ts +10 -6
- package/dist/store/postgres/migrations.d.ts.map +1 -1
- package/dist/store/postgres/migrations.js +64 -6
- package/dist/store/postgres/migrations.js.map +1 -1
- package/dist/store/postgres/store.d.ts +26 -5
- package/dist/store/postgres/store.d.ts.map +1 -1
- package/dist/store/postgres/store.js +377 -22
- package/dist/store/postgres/store.js.map +1 -1
- package/dist/store/sqlite/migrations.d.ts +11 -5
- package/dist/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/store/sqlite/migrations.js +50 -4
- package/dist/store/sqlite/migrations.js.map +1 -1
- package/dist/store/sqlite/store.d.ts +18 -3
- package/dist/store/sqlite/store.d.ts.map +1 -1
- package/dist/store/sqlite/store.js +321 -15
- package/dist/store/sqlite/store.js.map +1 -1
- package/package.json +6 -6
- package/src/authorization/README.md +1 -1
- package/src/authorization/__tests__/authorizer.test.ts +6 -2
- package/src/authorization/__tests__/drivers.ts +6 -1
- package/src/authorization/__tests__/wire-permissions.test.ts +1 -0
- package/src/authorization/authorizer.ts +11 -4
- package/src/authorization/model/__tests__/registry.test.ts +8 -1
- package/src/authorization/model/index.ts +6 -4
- package/src/authorization/model/oauth_app.ts +3 -2
- package/src/authorization/model/platform_client.ts +43 -0
- package/src/boot/__tests__/auth-enabled-composition.test.ts +2 -1
- package/src/boot/__tests__/list-indexes.test.ts +65 -0
- package/src/boot/__tests__/route-shadowing.test.ts +67 -0
- package/src/boot/compose.ts +113 -18
- package/src/boot/list-indexes.ts +25 -0
- package/src/boot/route-shadowing.ts +47 -0
- package/src/domain/agentexecution/__tests__/agentexecution.test.ts +85 -3
- package/src/domain/agentexecution/controller.ts +8 -10
- package/src/domain/agentexecution/list-index.ts +24 -0
- package/src/domain/agentexecution/steps.ts +118 -115
- package/src/domain/agentexecution/usage.ts +38 -17
- package/src/domain/artifact/controller.ts +28 -18
- package/src/domain/artifact/list-index.ts +22 -0
- package/src/domain/iampolicy/__tests__/membership.test.ts +7 -0
- package/src/domain/iampolicy/membership.ts +8 -2
- package/src/domain/identityaccount/__tests__/platform-client-accounts.test.ts +124 -0
- package/src/domain/identityaccount/__tests__/resource-store.test.ts +1 -0
- package/src/domain/identityaccount/constants.ts +20 -0
- package/src/domain/identityaccount/controller.ts +16 -4
- package/src/domain/identityaccount/operator.ts +1 -0
- package/src/domain/identityaccount/provisioning.ts +17 -0
- package/src/domain/identityaccount/resource-store.ts +9 -5
- package/src/domain/identityaccount/steps.ts +58 -3
- package/src/domain/identityaccount/store-contract.ts +51 -0
- package/src/domain/identityaccount/store.ts +7 -5
- package/src/domain/platform/__tests__/platform.test.ts +7 -1
- package/src/domain/platform/controller.ts +12 -1
- package/src/domain/platformclient/__tests__/controller.test.ts +397 -0
- package/src/domain/platformclient/__tests__/credentials.test.ts +46 -0
- package/src/domain/platformclient/__tests__/mint.test.ts +415 -0
- package/src/domain/platformclient/__tests__/resource-store.test.ts +140 -0
- package/src/domain/platformclient/__tests__/system-managed.test.ts +101 -0
- package/src/domain/platformclient/__tests__/verifier-and-guard.test.ts +207 -0
- package/src/domain/platformclient/constants.ts +120 -0
- package/src/domain/platformclient/controller.ts +449 -0
- package/src/domain/platformclient/credentials.ts +68 -0
- package/src/domain/platformclient/mint.ts +412 -0
- package/src/domain/platformclient/origin-guard.ts +117 -0
- package/src/domain/platformclient/resource-store.ts +150 -0
- package/src/domain/platformclient/steps.ts +472 -0
- package/src/domain/platformclient/store-contract.ts +318 -0
- package/src/domain/platformclient/store.ts +63 -0
- package/src/domain/platformclient/system-managed.ts +115 -0
- package/src/domain/platformclient/token-controller.ts +49 -0
- package/src/domain/platformclient/verifier.ts +106 -0
- package/src/domain/session/list-index.ts +28 -0
- package/src/domain/session/steps.ts +108 -123
- package/src/domain/workflowexecution/__tests__/list-read-scope-summaries.test.ts +155 -99
- package/src/domain/workflowexecution/__tests__/workflowexecution.test.ts +193 -31
- package/src/domain/workflowexecution/controller.ts +54 -82
- package/src/domain/workflowexecution/execution-filter.ts +20 -7
- package/src/domain/workflowexecution/get-execution-summary.ts +31 -24
- package/src/domain/workflowexecution/list-index.ts +22 -0
- package/src/domain/workflowexecution/list-pending-approvals.ts +82 -25
- package/src/domain/workflowexecution/queries.ts +134 -23
- package/src/encryption/key-manager.ts +87 -44
- package/src/extensions/__tests__/extension-composition.test.ts +3 -2
- package/src/extensions/__tests__/platform-client-composed.test.ts +288 -0
- package/src/extensions/__tests__/registry.test.ts +4 -1
- package/src/extensions/__tests__/tier-truthfulness.test.ts +8 -0
- package/src/extensions/caller-guards.ts +8 -3
- package/src/extensions/drivers.ts +37 -0
- package/src/extensions/guest-token-minting.ts +32 -0
- package/src/extensions/identity.ts +6 -4
- package/src/extensions/list-read-scope.ts +9 -12
- package/src/extensions/registry.ts +77 -3
- package/src/index.ts +65 -1
- package/src/pipeline/interceptors/auth.ts +27 -0
- package/src/pipeline/steps/__tests__/list-page.test.ts +186 -0
- package/src/pipeline/steps/__tests__/references.test.ts +2 -0
- package/src/pipeline/steps/build-update-state.ts +5 -2
- package/src/pipeline/steps/list-page.ts +284 -0
- package/src/platformtoken/__tests__/envelope.test.ts +277 -0
- package/src/platformtoken/__tests__/key-ring.test.ts +205 -0
- package/src/platformtoken/envelope.ts +276 -0
- package/src/platformtoken/key-ring.ts +266 -0
- package/src/query/activity/handler.ts +57 -78
- package/src/runnerauth/__tests__/runner-subject-composed.test.ts +9 -3
- package/src/store/README.md +51 -32
- package/src/store/__tests__/list-index.measure.test.ts +293 -0
- package/src/store/__tests__/list-index.test.ts +328 -0
- package/src/store/__tests__/store-contract.ts +346 -3
- package/src/store/interface.ts +39 -0
- package/src/store/list-index.ts +465 -0
- package/src/store/logger.ts +8 -1
- package/src/store/postgres/__tests__/list-index-repair.test.ts +133 -0
- package/src/store/postgres/__tests__/migrations.test.ts +27 -19
- package/src/store/postgres/__tests__/store-contract.test.ts +50 -3
- package/src/store/postgres/migrations.ts +69 -7
- package/src/store/postgres/store.ts +485 -29
- package/src/store/sqlite/__tests__/migrations.test.ts +51 -7
- package/src/store/sqlite/__tests__/store-contract.test.ts +70 -16
- package/src/store/sqlite/__tests__/support.ts +12 -3
- package/src/store/sqlite/migrations.ts +57 -6
- package/src/store/sqlite/store.ts +462 -21
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ListPendingApprovals — ports list_pending_approvals.go (T14 dashboard):
|
|
3
|
-
*
|
|
4
|
-
* and projects them into PendingApproval
|
|
5
|
-
*
|
|
3
|
+
* reads the org's IN_PROGRESS executions for tasks in
|
|
4
|
+
* WORKFLOW_TASK_WAITING_APPROVAL and projects them into PendingApproval
|
|
5
|
+
* entries, newest execution first. total_count is the whole set's; the
|
|
6
|
+
* entries are one page (default 20, at most 100), continued by a token
|
|
7
|
+
* whose position is an execution's list-index cursor plus the approval's
|
|
8
|
+
* place among its waiting tasks — stable while approvals land and resolve
|
|
9
|
+
* between pages, where an offset would skip or repeat them.
|
|
6
10
|
*/
|
|
7
11
|
import { create } from "@bufbuild/protobuf";
|
|
8
12
|
import { timestampFromMs } from "@bufbuild/protobuf/wkt";
|
|
@@ -10,54 +14,87 @@ import { ExecutionPhase, WorkflowTaskStatus, } from "@stigmer/protos/ai/stigmer/
|
|
|
10
14
|
import { PendingApprovalSchema, PendingApprovalsListSchema, } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/io_pb";
|
|
11
15
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
12
16
|
import { restrictListByReadScope } from "../../extensions/list-read-scope.js";
|
|
17
|
+
import { invalidArgumentError } from "../../pipeline/errors.js";
|
|
18
|
+
import { decodeListPageToken, encodeListPageToken, listPageFingerprint, } from "../../pipeline/steps/list-page.js";
|
|
19
|
+
import { compareListIndexOrder, listIndexInstant, } from "../../store/list-index.js";
|
|
13
20
|
import { DEFAULT_PENDING_APPROVALS_PAGE_SIZE, MAX_PENDING_APPROVALS_PAGE_SIZE, } from "./constants.js";
|
|
14
21
|
import { parseRfc3339Ms } from "./execution-filter.js";
|
|
15
|
-
import {
|
|
22
|
+
import { loadWorkflowExecutions } from "./queries.js";
|
|
16
23
|
export async function listPendingApprovals(deps, req, identity) {
|
|
17
|
-
// Census lane 8
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// Census lane 8: the org's executions that CAN carry a
|
|
25
|
+
// pending approval (in progress, a task waiting) through the list index,
|
|
26
|
+
// then the scope — the last per-row predicate, so a composed driver is
|
|
27
|
+
// asked about a handful of rows — before the approvals projection and
|
|
28
|
+
// its pagination, the Java WorkflowExecutionListPendingApprovalsHandler
|
|
29
|
+
// order.
|
|
30
|
+
if (req.pageSize < 0) {
|
|
31
|
+
throw invalidArgumentError("page_size must not be negative");
|
|
32
|
+
}
|
|
33
|
+
const fingerprint = listPageFingerprint({
|
|
34
|
+
lane: "workflowExecution.listPendingApprovals",
|
|
35
|
+
org: req.org,
|
|
36
|
+
});
|
|
37
|
+
const after = req.pageToken === ""
|
|
38
|
+
? undefined
|
|
39
|
+
: decodeListPageToken(req.pageToken, fingerprint);
|
|
40
|
+
const executions = await restrictListByReadScope(deps.listReadScope, identity, ApiResourceKind.workflow_execution, (await loadWorkflowExecutions(deps.store, deps.logger, { org: req.org }, "failed to list workflow executions for pending approvals")).filter(mayHavePendingApproval), "");
|
|
26
41
|
let pageSize = req.pageSize;
|
|
27
|
-
if (pageSize
|
|
42
|
+
if (pageSize === 0) {
|
|
28
43
|
pageSize = DEFAULT_PENDING_APPROVALS_PAGE_SIZE;
|
|
29
44
|
}
|
|
30
45
|
if (pageSize > MAX_PENDING_APPROVALS_PAGE_SIZE) {
|
|
31
46
|
pageSize = MAX_PENDING_APPROVALS_PAGE_SIZE;
|
|
32
47
|
}
|
|
33
|
-
|
|
48
|
+
// Newest execution first (the index's order), an execution's waiting
|
|
49
|
+
// tasks in their order; each approval's position is its execution's
|
|
50
|
+
// cursor and its place among that execution's waiting tasks.
|
|
51
|
+
const approvals = [];
|
|
34
52
|
for (const execution of executions) {
|
|
53
|
+
const cursor = {
|
|
54
|
+
createdAt: listIndexInstant(execution.status?.audit?.specAudit?.createdAt),
|
|
55
|
+
id: execution.metadata?.id ?? "",
|
|
56
|
+
};
|
|
57
|
+
let position = 0;
|
|
35
58
|
for (const task of execution.status?.tasks ?? []) {
|
|
36
59
|
if (task.status !== WorkflowTaskStatus.WORKFLOW_TASK_WAITING_APPROVAL) {
|
|
37
60
|
continue;
|
|
38
61
|
}
|
|
39
|
-
approvals.push(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
approvals.push({
|
|
63
|
+
approval: create(PendingApprovalSchema, {
|
|
64
|
+
executionId: execution.metadata?.id ?? "",
|
|
65
|
+
workflowName: execution.metadata?.name ?? "",
|
|
66
|
+
// task_name, not task_id: the composite task_id ("gate:2")
|
|
67
|
+
// would break submitWorkflowTaskApproval, whose runner-side
|
|
68
|
+
// signal is keyed by the plain task name.
|
|
69
|
+
taskName: task.taskName,
|
|
70
|
+
requester: execution.status?.audit?.specAudit?.createdBy?.id ?? "",
|
|
71
|
+
requestedAt: parseTimestampString(task.startedAt),
|
|
72
|
+
uiHint: task.uiHint,
|
|
73
|
+
}),
|
|
74
|
+
at: { cursor, position },
|
|
75
|
+
});
|
|
76
|
+
position += 1;
|
|
50
77
|
}
|
|
51
78
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
approvals
|
|
55
|
-
|
|
79
|
+
const start = after === undefined
|
|
80
|
+
? 0
|
|
81
|
+
: approvals.findIndex((a) => comesAfter(a.at, after));
|
|
82
|
+
const remaining = start < 0 ? [] : approvals.slice(start);
|
|
83
|
+
const page = remaining.slice(0, pageSize);
|
|
84
|
+
const last = page[page.length - 1];
|
|
56
85
|
return create(PendingApprovalsListSchema, {
|
|
57
|
-
entries:
|
|
58
|
-
totalCount,
|
|
86
|
+
entries: page.map((a) => a.approval),
|
|
87
|
+
totalCount: approvals.length,
|
|
88
|
+
nextPageToken: remaining.length > pageSize && last !== undefined
|
|
89
|
+
? encodeListPageToken(last.at.cursor, fingerprint, last.at.position)
|
|
90
|
+
: "",
|
|
59
91
|
});
|
|
60
92
|
}
|
|
93
|
+
/** Whether an approval comes strictly after a token's position. */
|
|
94
|
+
function comesAfter(at, after) {
|
|
95
|
+
const order = compareListIndexOrder(at.cursor, after.cursor);
|
|
96
|
+
return order > 0 || (order === 0 && at.position > (after.position ?? -1));
|
|
97
|
+
}
|
|
61
98
|
/** Go parseTimestampString: RFC3339 or nothing (nil on parse failure). */
|
|
62
99
|
function parseTimestampString(value) {
|
|
63
100
|
const ms = parseRfc3339Ms(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-pending-approvals.js","sourceRoot":"","sources":["../../../src/domain/workflowexecution/list-pending-approvals.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"list-pending-approvals.js","sourceRoot":"","sources":["../../../src/domain/workflowexecution/list-pending-approvals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,EACL,cAAc,EACd,kBAAkB,GACnB,MAAM,iEAAiE,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,+DAA+D,CAAC;AAOvE,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAKtH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AA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AC;AAED;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,SAA4B;IAC1D,MAAM,KAAK,GACT,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,cAAc,CAAC,2BAA2B,CAAC;IACxE,OAAO,CACL,KAAK,KAAK,cAAc,CAAC,qBAAqB;QAC9C,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAClC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,MAAM,KAAK,kBAAkB,CAAC,8BAA8B,CACpE,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import type { WorkflowExecution } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
|
|
2
|
+
import { ExecutionSortField } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/io_pb";
|
|
3
|
+
import type { WorkflowExecutionList } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/io_pb";
|
|
2
4
|
import type { Logger } from "../../boot/logger.js";
|
|
5
|
+
import type { CallerIdentity } from "../../extensions/identity.js";
|
|
6
|
+
import type { ListReadScope } from "../../extensions/list-read-scope.js";
|
|
7
|
+
import type { ListPageRequest } from "../../pipeline/steps/list-page.js";
|
|
3
8
|
import type { Store } from "../../store/interface.js";
|
|
9
|
+
import type { ListIndexQuery } from "../../store/list-index.js";
|
|
10
|
+
/** The keys the workflow-execution index declares. */
|
|
11
|
+
export type WorkflowExecutionListKey = "workflow" | "workflow_instance";
|
|
12
|
+
/** A stored row, or undefined (logged) when it does not decode. */
|
|
13
|
+
export declare function decodeWorkflowExecution(data: Uint8Array, logger: Logger): WorkflowExecution | undefined;
|
|
4
14
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Go (each handler wraps the same
|
|
7
|
-
* caller supplies it.
|
|
15
|
+
* Every workflow execution the query matches, newest created first. The
|
|
16
|
+
* Internal message varies by caller in Go (each handler wraps the same
|
|
17
|
+
* store error with its own text), so the caller supplies it.
|
|
8
18
|
*/
|
|
9
|
-
export declare function
|
|
19
|
+
export declare function loadWorkflowExecutions(store: Store, logger: Logger, query: ListIndexQuery<WorkflowExecutionListKey>, internalMessage: string): Promise<WorkflowExecution[]>;
|
|
20
|
+
export interface WorkflowExecutionListRead {
|
|
21
|
+
readonly store: Store;
|
|
22
|
+
readonly logger: Logger;
|
|
23
|
+
readonly listReadScope: ListReadScope | undefined;
|
|
24
|
+
readonly identity: CallerIdentity;
|
|
25
|
+
readonly query: ListIndexQuery<WorkflowExecutionListKey>;
|
|
26
|
+
readonly request: ListPageRequest;
|
|
27
|
+
readonly sortField: ExecutionSortField;
|
|
28
|
+
readonly sortAscending: boolean;
|
|
29
|
+
/** The lane's filters beyond the indexed predicates. */
|
|
30
|
+
readonly keep: (execution: WorkflowExecution) => boolean;
|
|
31
|
+
/** The request's other fields, which its token is bound to. */
|
|
32
|
+
readonly fingerprint: Readonly<Record<string, unknown>>;
|
|
33
|
+
}
|
|
34
|
+
/** One list response: a page in the default order, or the whole set sorted by another field. */
|
|
35
|
+
export declare function readWorkflowExecutionList(read: WorkflowExecutionListRead): Promise<WorkflowExecutionList>;
|
|
10
36
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/domain/workflowexecution/queries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/domain/workflowexecution/queries.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AAExG,OAAO,EACL,kBAAkB,EAEnB,MAAM,+DAA+D,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAC;AAG3G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE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AAC,CAAC,CAAC;CACzD;AAED,gGAAgG;AAChG,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAsDhC"}
|
|
@@ -1,40 +1,94 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* listByWorkflow, getExecutionSummary, listPendingApprovals)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* The workflowexecution read surfaces' shared reads (list,
|
|
3
|
+
* listByWorkflow, getExecutionSummary, listPendingApprovals), all through
|
|
4
|
+
* the list index (list-index.ts beside this file; the store's contract in
|
|
5
|
+
* store/interface.ts) — the request's org or workflow key narrows in the
|
|
6
|
+
* store, newest created first. Malformed rows are skipped rather than
|
|
7
|
+
* failing the read, Go's proto.Unmarshal-continue loop.
|
|
8
|
+
*
|
|
9
|
+
* The two lists share one reader: the default order pages
|
|
10
|
+
* (pipeline/steps/list-page.ts), with the lane's filters and then the read
|
|
11
|
+
* scope on each batch; another sort field sorts the whole matching set and
|
|
12
|
+
* returns its first page_size entries with no token, because only the
|
|
13
|
+
* creation order is an index order.
|
|
6
14
|
*/
|
|
7
|
-
import { fromBinary } from "@bufbuild/protobuf";
|
|
15
|
+
import { create, fromBinary } from "@bufbuild/protobuf";
|
|
8
16
|
import { WorkflowExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
|
|
17
|
+
import { ExecutionSortField, WorkflowExecutionListSchema, } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/io_pb";
|
|
9
18
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
10
|
-
import {
|
|
19
|
+
import { restrictListByReadScope } from "../../extensions/list-read-scope.js";
|
|
20
|
+
import { internalError, invalidArgumentError } from "../../pipeline/errors.js";
|
|
21
|
+
import { LIST_PAGE_MAX_SIZE, listPageFingerprint, readListPage, } from "../../pipeline/steps/list-page.js";
|
|
22
|
+
import { applySortField } from "./execution-filter.js";
|
|
23
|
+
import { workflowExecutionListIndex } from "./list-index.js";
|
|
24
|
+
/** A stored row, or undefined (logged) when it does not decode. */
|
|
25
|
+
export function decodeWorkflowExecution(data, logger) {
|
|
26
|
+
try {
|
|
27
|
+
return fromBinary(WorkflowExecutionSchema, data);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
logger.warn("Failed to unmarshal workflow execution, skipping", {
|
|
31
|
+
error: error instanceof Error ? error.message : String(error),
|
|
32
|
+
});
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
11
36
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Go (each handler wraps the same
|
|
14
|
-
* caller supplies it.
|
|
37
|
+
* Every workflow execution the query matches, newest created first. The
|
|
38
|
+
* Internal message varies by caller in Go (each handler wraps the same
|
|
39
|
+
* store error with its own text), so the caller supplies it.
|
|
15
40
|
*/
|
|
16
|
-
export async function
|
|
41
|
+
export async function loadWorkflowExecutions(store, logger, query, internalMessage) {
|
|
17
42
|
let rows;
|
|
18
43
|
try {
|
|
19
|
-
rows = await store.
|
|
44
|
+
rows = await store.queryResources(workflowExecutionListIndex, query);
|
|
20
45
|
}
|
|
21
46
|
catch (error) {
|
|
22
47
|
throw internalError(error, internalMessage);
|
|
23
48
|
}
|
|
24
49
|
const executions = [];
|
|
25
|
-
for (const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
execution
|
|
50
|
+
for (const row of rows) {
|
|
51
|
+
const execution = decodeWorkflowExecution(row.data, logger);
|
|
52
|
+
if (execution !== undefined) {
|
|
53
|
+
executions.push(execution);
|
|
29
54
|
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
logger.warn("Failed to unmarshal workflow execution, skipping", {
|
|
32
|
-
error: error instanceof Error ? error.message : String(error),
|
|
33
|
-
});
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
executions.push(execution);
|
|
37
55
|
}
|
|
38
56
|
return executions;
|
|
39
57
|
}
|
|
58
|
+
/** One list response: a page in the default order, or the whole set sorted by another field. */
|
|
59
|
+
export async function readWorkflowExecutionList(read) {
|
|
60
|
+
const scope = (executions) => restrictListByReadScope(read.listReadScope, read.identity, ApiResourceKind.workflow_execution, executions, "");
|
|
61
|
+
if (read.sortField === ExecutionSortField.UNSPECIFIED) {
|
|
62
|
+
const page = await readListPage({
|
|
63
|
+
store: read.store,
|
|
64
|
+
declaration: workflowExecutionListIndex,
|
|
65
|
+
query: read.query,
|
|
66
|
+
request: read.request,
|
|
67
|
+
fingerprint: listPageFingerprint(read.fingerprint),
|
|
68
|
+
decode: (data) => decodeWorkflowExecution(data, read.logger),
|
|
69
|
+
keep: read.keep,
|
|
70
|
+
scope,
|
|
71
|
+
failure: "failed to list workflow executions",
|
|
72
|
+
});
|
|
73
|
+
return create(WorkflowExecutionListSchema, {
|
|
74
|
+
entries: page.entries,
|
|
75
|
+
nextPageToken: page.nextPageToken,
|
|
76
|
+
totalPages: page.nextPageToken === "" ? 1 : 0,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Another sort field never issues a token, so none can be continued.
|
|
80
|
+
if (read.request.pageToken !== "") {
|
|
81
|
+
throw invalidArgumentError("invalid page_token");
|
|
82
|
+
}
|
|
83
|
+
if (read.request.pageSize < 0) {
|
|
84
|
+
throw invalidArgumentError("page_size must not be negative");
|
|
85
|
+
}
|
|
86
|
+
const executions = await scope((await loadWorkflowExecutions(read.store, read.logger, read.query, "failed to list workflow executions")).filter(read.keep));
|
|
87
|
+
applySortField(executions, read.sortField, read.sortAscending);
|
|
88
|
+
const size = Math.min(read.request.pageSize, LIST_PAGE_MAX_SIZE);
|
|
89
|
+
return create(WorkflowExecutionListSchema, {
|
|
90
|
+
entries: size === 0 ? executions : executions.slice(0, size),
|
|
91
|
+
totalPages: 1,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
40
94
|
//# sourceMappingURL=queries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/domain/workflowexecution/queries.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/domain/workflowexecution/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gEAAgE,CAAC;AACzG,OAAO,EACL,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,+DAA+D,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAKtH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAK7D,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CACrC,IAAgB,EAChB,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,kDAAkD,EAAE;YAC9D,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAY,EACZ,MAAc,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eyLoaderOptions {
|
|
|
13
13
|
readonly homeDir?: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* What one kind of key is, for the ladder. `fromEnv` receives the env
|
|
17
|
+
* value already strictly Base64-decoded and THROWS when the bytes are not
|
|
18
|
+
* a usable key (explicit configuration is never silently ignored);
|
|
19
|
+
* `fromFile` answers `undefined` for content it does not accept, so the
|
|
20
|
+
* ladder falls through exactly as it does for a wrong-sized raw key.
|
|
21
|
+
*/
|
|
22
|
+
export interface KeyCodec<Key> {
|
|
23
|
+
fromEnv(envVar: string, decoded: Buffer): Key;
|
|
24
|
+
fromFile(content: Buffer): Key | undefined;
|
|
25
|
+
generate(): Key;
|
|
26
|
+
toFile(key: Key): Buffer;
|
|
27
|
+
}
|
|
28
|
+
/** The 32 raw bytes the encryption and runner-token keys are. */
|
|
29
|
+
export declare const RAW_32_BYTE_KEY: KeyCodec<Buffer>;
|
|
30
|
+
/**
|
|
31
|
+
* Go GetOrCreateNamedKey: env var → key file → auto-generate, for a 32-byte
|
|
32
|
+
* raw key. Throws only on unusable EXPLICIT configuration (bad env value)
|
|
33
|
+
* or when no key can be produced at all.
|
|
19
34
|
*/
|
|
20
35
|
export declare function getOrCreateNamedKey(envVar: string, fileName: string, options?: KeyLoaderOptions): Buffer;
|
|
36
|
+
/** The ladder over any codec: env var → key file → auto-generate. */
|
|
37
|
+
export declare function getOrCreateKey<Key>(codec: KeyCodec<Key>, envVar: string, fileName: string, options?: KeyLoaderOptions): Key;
|
|
21
38
|
/** Path to a named key file under <home>/.stigmer. */
|
|
22
39
|
export declare function namedKeyFilePath(fileName: string, options?: KeyLoaderOptions): string;
|
|
23
40
|
//# sourceMappingURL=key-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../src/encryption/key-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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AAqB,GAC7B,MAAM,CAGR"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Named-key loader — ports pkg/encryption/keymanager.go.
|
|
3
3
|
*
|
|
4
|
-
* One convention for every
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* One convention for every key the server holds: env var (Base64) →
|
|
5
|
+
* ~/.stigmer/<file> (0600) → auto-generate and persist. The
|
|
6
|
+
* loader is generalized over the env var, the file name and a KeyCodec so
|
|
7
|
+
* sibling key material rides the same ladder instead of growing a
|
|
8
|
+
* divergent loader: the runner-token signing key (oss#535) and the
|
|
9
|
+
* encryption key are 32 raw bytes (RAW_32_BYTE_KEY); the platform-token
|
|
10
|
+
* signing key is an RSA private key (platformtoken/key-ring.ts). The codec
|
|
11
|
+
* says what a key IS — how an env value and a file decode, how one is
|
|
12
|
+
* generated and written — and nothing about the ladder, which stays one.
|
|
9
13
|
*
|
|
10
|
-
* Ladder semantics, exactly Go's:
|
|
14
|
+
* Ladder semantics, exactly Go's, for every codec:
|
|
11
15
|
* - An EXPLICITLY configured env key that is unusable (bad Base64, wrong
|
|
12
|
-
* length) is an ERROR, never a
|
|
13
|
-
* configuration would be worse
|
|
16
|
+
* length, not the key type the codec holds) is an ERROR, never a
|
|
17
|
+
* degrade — silently ignoring deliberate configuration would be worse
|
|
18
|
+
* than refusing to boot.
|
|
14
19
|
* - A key file that fails its load checks (permissions other than 0600,
|
|
15
|
-
*
|
|
16
|
-
* auto-generate, which overwrites the file's content —
|
|
17
|
-
* behavior (loadKeyFromFile error → generate → save),
|
|
20
|
+
* content the codec does not accept) is never adopted; the ladder
|
|
21
|
+
* FALLS THROUGH to auto-generate, which overwrites the file's content —
|
|
22
|
+
* Go's shipped behavior (loadKeyFromFile error → generate → save),
|
|
23
|
+
* ported as-is.
|
|
18
24
|
* - Auto-generation persists for future boots; a persist FAILURE is a
|
|
19
25
|
* stderr warning only — the key is still usable for this process.
|
|
20
26
|
*
|
|
@@ -37,28 +43,52 @@ export const KEY_FILE_DIR = ".stigmer";
|
|
|
37
43
|
export const KEY_FILE_PERMISSIONS = 0o600;
|
|
38
44
|
/** Key directory permissions — Go KeyDirPermissions. */
|
|
39
45
|
export const KEY_DIR_PERMISSIONS = 0o700;
|
|
46
|
+
/** The 32 raw bytes the encryption and runner-token keys are. */
|
|
47
|
+
export const RAW_32_BYTE_KEY = {
|
|
48
|
+
fromEnv(envVar, decoded) {
|
|
49
|
+
if (decoded.length !== KEY_SIZE) {
|
|
50
|
+
throw new Error(`${envVar} must be exactly 32 bytes (256 bits) when decoded, got ${decoded.length} bytes`);
|
|
51
|
+
}
|
|
52
|
+
return decoded;
|
|
53
|
+
},
|
|
54
|
+
fromFile(content) {
|
|
55
|
+
return content.length === KEY_SIZE ? content : undefined;
|
|
56
|
+
},
|
|
57
|
+
generate() {
|
|
58
|
+
return randomBytes(KEY_SIZE);
|
|
59
|
+
},
|
|
60
|
+
toFile(key) {
|
|
61
|
+
return key;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
40
64
|
/**
|
|
41
|
-
* Go GetOrCreateNamedKey: env var → key file → auto-generate
|
|
42
|
-
* on unusable EXPLICIT configuration (bad env value)
|
|
43
|
-
* produced at all.
|
|
65
|
+
* Go GetOrCreateNamedKey: env var → key file → auto-generate, for a 32-byte
|
|
66
|
+
* raw key. Throws only on unusable EXPLICIT configuration (bad env value)
|
|
67
|
+
* or when no key can be produced at all.
|
|
44
68
|
*/
|
|
45
69
|
export function getOrCreateNamedKey(envVar, fileName, options = {}) {
|
|
70
|
+
return getOrCreateKey(RAW_32_BYTE_KEY, envVar, fileName, options);
|
|
71
|
+
}
|
|
72
|
+
/** The ladder over any codec: env var → key file → auto-generate. */
|
|
73
|
+
export function getOrCreateKey(codec, envVar, fileName, options = {}) {
|
|
46
74
|
const env = options.env ?? process.env;
|
|
47
|
-
// 1. Environment variable (highest priority) — Base64-encoded
|
|
75
|
+
// 1. Environment variable (highest priority) — Base64-encoded.
|
|
48
76
|
const envValue = env[envVar];
|
|
49
77
|
if (envValue !== undefined && envValue !== "") {
|
|
50
|
-
return
|
|
78
|
+
return codec.fromEnv(envVar, decodeEnvBase64(envVar, envValue));
|
|
51
79
|
}
|
|
52
|
-
// 2. Local key file —
|
|
80
|
+
// 2. Local key file — refused on insecure permissions or content the
|
|
81
|
+
// codec does not accept.
|
|
53
82
|
const keyPath = namedKeyFilePath(fileName, options);
|
|
54
|
-
const
|
|
83
|
+
const content = readKeyFile(keyPath);
|
|
84
|
+
const fromFile = content === undefined ? undefined : codec.fromFile(content);
|
|
55
85
|
if (fromFile !== undefined) {
|
|
56
86
|
return fromFile;
|
|
57
87
|
}
|
|
58
88
|
// 3. Auto-generate (local development); persist for future boots.
|
|
59
|
-
const key =
|
|
89
|
+
const key = codec.generate();
|
|
60
90
|
try {
|
|
61
|
-
saveKeyToFile(keyPath, key);
|
|
91
|
+
saveKeyToFile(keyPath, codec.toFile(key));
|
|
62
92
|
}
|
|
63
93
|
catch (error) {
|
|
64
94
|
// Warn but don't fail — the key is still usable (Go's posture).
|
|
@@ -66,20 +96,17 @@ export function getOrCreateNamedKey(envVar, fileName, options = {}) {
|
|
|
66
96
|
}
|
|
67
97
|
return key;
|
|
68
98
|
}
|
|
69
|
-
/** Strict Base64 decode
|
|
70
|
-
function
|
|
71
|
-
const
|
|
99
|
+
/** Strict Base64 decode for an env-configured key. */
|
|
100
|
+
function decodeEnvBase64(envVar, value) {
|
|
101
|
+
const decoded = Buffer.from(value, "base64");
|
|
72
102
|
// Node's base64 decoder is lenient (skips invalid characters, accepts
|
|
73
103
|
// missing padding) and never throws; Go's StdEncoding errors on any
|
|
74
104
|
// non-canonical input. Round-tripping — Buffer always re-emits the
|
|
75
105
|
// canonical padded form — restores Go's strictness.
|
|
76
|
-
if (
|
|
106
|
+
if (decoded.toString("base64") !== value) {
|
|
77
107
|
throw new Error(`invalid Base64 encoding in ${envVar}`);
|
|
78
108
|
}
|
|
79
|
-
|
|
80
|
-
throw new Error(`${envVar} must be exactly 32 bytes (256 bits) when decoded, got ${key.length} bytes`);
|
|
81
|
-
}
|
|
82
|
-
return key;
|
|
109
|
+
return decoded;
|
|
83
110
|
}
|
|
84
111
|
/** Path to a named key file under <home>/.stigmer. */
|
|
85
112
|
export function namedKeyFilePath(fileName, options = {}) {
|
|
@@ -87,13 +114,13 @@ export function namedKeyFilePath(fileName, options = {}) {
|
|
|
87
114
|
return path.join(home, KEY_FILE_DIR, fileName);
|
|
88
115
|
}
|
|
89
116
|
/**
|
|
90
|
-
* Reads
|
|
91
|
-
* undefined (fall through the ladder); present
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
117
|
+
* Reads a key file's bytes, mirroring Go loadKeyFromFile: missing file →
|
|
118
|
+
* undefined (fall through the ladder); present with insecure permissions
|
|
119
|
+
* also falls through — exactly Go's behavior, where any load error falls
|
|
120
|
+
* to auto-generate. The 0600 check is skipped on Windows, where POSIX
|
|
121
|
+
* modes are not meaningful.
|
|
95
122
|
*/
|
|
96
|
-
function
|
|
123
|
+
function readKeyFile(keyPath) {
|
|
97
124
|
let stat;
|
|
98
125
|
try {
|
|
99
126
|
stat = fs.statSync(keyPath);
|
|
@@ -107,24 +134,19 @@ function loadKeyFromFile(keyPath) {
|
|
|
107
134
|
return undefined;
|
|
108
135
|
}
|
|
109
136
|
}
|
|
110
|
-
let key;
|
|
111
137
|
try {
|
|
112
|
-
|
|
138
|
+
return fs.readFileSync(keyPath);
|
|
113
139
|
}
|
|
114
140
|
catch {
|
|
115
141
|
return undefined;
|
|
116
142
|
}
|
|
117
|
-
if (key.length !== KEY_SIZE) {
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
return key;
|
|
121
143
|
}
|
|
122
144
|
/** Writes the key with secure permissions (dir 0700, file 0600). */
|
|
123
|
-
function saveKeyToFile(keyPath,
|
|
145
|
+
function saveKeyToFile(keyPath, content) {
|
|
124
146
|
fs.mkdirSync(path.dirname(keyPath), {
|
|
125
147
|
recursive: true,
|
|
126
148
|
mode: KEY_DIR_PERMISSIONS,
|
|
127
149
|
});
|
|
128
|
-
fs.writeFileSync(keyPath,
|
|
150
|
+
fs.writeFileSync(keyPath, content, { mode: KEY_FILE_PERMISSIONS });
|
|
129
151
|
}
|
|
130
152
|
//# sourceMappingURL=key-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-manager.js","sourceRoot":"","sources":["../../src/encryption/key-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"key-manager.js","sourceRoot":"","sources":["../../src/encryption/key-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,yEAAyE;AACzE,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC;AAE3B,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AAEvC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAuBzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAqB;IAC/C,OAAO,CAAC,MAAM,EAAE,OAAO;QACrB,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,0DAA0D,OAAO,CAAC,MAAM,QAAQ,CAC1F,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,QAAQ,CAAC,OAAO;QACd,OAAO,OAAO,CAAC,MAAM,KAAK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I,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAC/B,IAAI,IAAI,KAAK,oBAAoB,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,oEAAoE;AACpE,SAAS,aAAa,CAAC,OAAe,EAAE,OAAe;IACrD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAClC,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,mBAAmB;KAC1B,CAAC,CAAC;IACH,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -10,9 +10,14 @@
|
|
|
10
10
|
* allowed_origins, oss#375). Java separates the two classes the same way.
|
|
11
11
|
*
|
|
12
12
|
* List point — guards concatenate in unit order and run in composed
|
|
13
|
-
* order; the first throw wins.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* order; the first throw wins. Open source's own guards run first (the
|
|
14
|
+
* verifier list's "OSS entries first" rule): today the PlatformClient
|
|
15
|
+
* origin guard (domain/platformclient/origin-guard.ts), composed only
|
|
16
|
+
* under an authentication posture, where PlatformClient tokens exist.
|
|
17
|
+
* Liveness is not a guard in open source: the PlatformClient verifier
|
|
18
|
+
* refuses a deleted client's tokens itself, so verifier-only lanes (the
|
|
19
|
+
* extension HTTP edges) refuse them too. With no posture and no unit
|
|
20
|
+
* guards, the serving chain runs no guard at all.
|
|
16
21
|
*
|
|
17
22
|
* The in-process exemption is STRUCTURAL, not policed: guards are a
|
|
18
23
|
* parameter of the serving chain's identity source only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caller-guards.d.ts","sourceRoot":"","sources":["../../src/extensions/caller-guards.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"caller-guards.d.ts","sourceRoot":"","sources":["../../src/extensions/caller-guards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,KAAK,CACH,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
|