@stigmer/server 3.22.1-dev.20260922095755 → 3.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization/authorizer.d.ts +8 -4
- package/dist/authorization/authorizer.d.ts.map +1 -1
- package/dist/authorization/authorizer.js +9 -5
- package/dist/authorization/authorizer.js.map +1 -1
- package/dist/authorization/derived-tuples.d.ts.map +1 -1
- package/dist/authorization/derived-tuples.js +25 -10
- package/dist/authorization/derived-tuples.js.map +1 -1
- package/dist/authorization/evaluator.d.ts +8 -7
- package/dist/authorization/evaluator.d.ts.map +1 -1
- package/dist/authorization/evaluator.js +20 -4
- package/dist/authorization/evaluator.js.map +1 -1
- package/dist/authorization/list-read-scope.d.ts.map +1 -1
- package/dist/authorization/list-read-scope.js +9 -5
- package/dist/authorization/list-read-scope.js.map +1 -1
- package/dist/authorization/model/agent.d.ts.map +1 -1
- package/dist/authorization/model/agent.js +5 -4
- package/dist/authorization/model/agent.js.map +1 -1
- package/dist/authorization/model/agent_instance.d.ts.map +1 -1
- package/dist/authorization/model/agent_instance.js +2 -2
- package/dist/authorization/model/agent_instance.js.map +1 -1
- package/dist/authorization/model/mcp_server.d.ts.map +1 -1
- package/dist/authorization/model/mcp_server.js +2 -2
- package/dist/authorization/model/mcp_server.js.map +1 -1
- package/dist/authorization/model/plugin.d.ts.map +1 -1
- package/dist/authorization/model/plugin.js +4 -3
- package/dist/authorization/model/plugin.js.map +1 -1
- package/dist/authorization/model/rewrite.d.ts +10 -8
- package/dist/authorization/model/rewrite.d.ts.map +1 -1
- package/dist/authorization/model/rewrite.js +3 -0
- package/dist/authorization/model/rewrite.js.map +1 -1
- package/dist/authorization/model/skill.d.ts.map +1 -1
- package/dist/authorization/model/skill.js +2 -2
- package/dist/authorization/model/skill.js.map +1 -1
- package/dist/authorization/model/workflow.d.ts.map +1 -1
- package/dist/authorization/model/workflow.js +2 -2
- package/dist/authorization/model/workflow.js.map +1 -1
- package/dist/authorization/model/workflow_instance.d.ts.map +1 -1
- package/dist/authorization/model/workflow_instance.js +2 -2
- package/dist/authorization/model/workflow_instance.js.map +1 -1
- package/dist/authorization/organization-directory.d.ts.map +1 -1
- package/dist/authorization/organization-directory.js +3 -2
- package/dist/authorization/organization-directory.js.map +1 -1
- package/dist/authorization/store-test-kit.d.ts +6 -0
- package/dist/authorization/store-test-kit.d.ts.map +1 -1
- package/dist/authorization/store-test-kit.js +62 -16
- package/dist/authorization/store-test-kit.js.map +1 -1
- package/dist/authorization/tuples.d.ts +32 -13
- package/dist/authorization/tuples.d.ts.map +1 -1
- package/dist/authorization/tuples.js +11 -3
- package/dist/authorization/tuples.js.map +1 -1
- package/dist/domain/agent/controller.d.ts.map +1 -1
- package/dist/domain/agent/controller.js +4 -4
- package/dist/domain/agent/controller.js.map +1 -1
- package/dist/domain/agentchannel/controller.d.ts.map +1 -1
- package/dist/domain/agentchannel/controller.js +1 -3
- package/dist/domain/agentchannel/controller.js.map +1 -1
- package/dist/domain/agentexecution/controller.d.ts.map +1 -1
- package/dist/domain/agentexecution/controller.js +1 -3
- package/dist/domain/agentexecution/controller.js.map +1 -1
- package/dist/domain/agentinstance/controller.d.ts.map +1 -1
- package/dist/domain/agentinstance/controller.js +4 -3
- package/dist/domain/agentinstance/controller.js.map +1 -1
- package/dist/domain/agentshare/constants.d.ts +11 -6
- package/dist/domain/agentshare/constants.d.ts.map +1 -1
- package/dist/domain/agentshare/constants.js +16 -8
- package/dist/domain/agentshare/constants.js.map +1 -1
- package/dist/domain/agentshare/controller.d.ts.map +1 -1
- package/dist/domain/agentshare/controller.js +1 -3
- package/dist/domain/agentshare/controller.js.map +1 -1
- package/dist/domain/agentshare/steps.d.ts +25 -18
- package/dist/domain/agentshare/steps.d.ts.map +1 -1
- package/dist/domain/agentshare/steps.js +142 -41
- package/dist/domain/agentshare/steps.js.map +1 -1
- package/dist/domain/environment/controller.d.ts.map +1 -1
- package/dist/domain/environment/controller.js +3 -2
- package/dist/domain/environment/controller.js.map +1 -1
- package/dist/domain/executioncontext/controller.d.ts.map +1 -1
- package/dist/domain/executioncontext/controller.js +1 -2
- package/dist/domain/executioncontext/controller.js.map +1 -1
- package/dist/domain/mcpserver/controller.d.ts.map +1 -1
- package/dist/domain/mcpserver/controller.js +4 -3
- package/dist/domain/mcpserver/controller.js.map +1 -1
- package/dist/domain/plugin/controller.d.ts.map +1 -1
- package/dist/domain/plugin/controller.js +3 -1
- package/dist/domain/plugin/controller.js.map +1 -1
- package/dist/domain/plugin/push.d.ts +5 -7
- package/dist/domain/plugin/push.d.ts.map +1 -1
- package/dist/domain/plugin/push.js +14 -8
- package/dist/domain/plugin/push.js.map +1 -1
- package/dist/domain/schedule/controller.d.ts.map +1 -1
- package/dist/domain/schedule/controller.js +1 -3
- package/dist/domain/schedule/controller.js.map +1 -1
- package/dist/domain/session/controller.d.ts.map +1 -1
- package/dist/domain/session/controller.js +2 -3
- package/dist/domain/session/controller.js.map +1 -1
- package/dist/domain/skill/controller.d.ts.map +1 -1
- package/dist/domain/skill/controller.js +2 -0
- package/dist/domain/skill/controller.js.map +1 -1
- package/dist/domain/workflow/controller.d.ts.map +1 -1
- package/dist/domain/workflow/controller.js +6 -14
- package/dist/domain/workflow/controller.js.map +1 -1
- package/dist/domain/workflow/registry/data/task-kind-registry.json +1 -1
- package/dist/domain/workflow/validation/task-config-constraints.d.ts +1 -10
- package/dist/domain/workflow/validation/task-config-constraints.d.ts.map +1 -1
- package/dist/domain/workflow/validation/task-config-constraints.js +2 -3
- package/dist/domain/workflow/validation/task-config-constraints.js.map +1 -1
- package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
- package/dist/domain/workflowexecution/controller.js +2 -4
- package/dist/domain/workflowexecution/controller.js.map +1 -1
- package/dist/domain/workflowinstance/controller.d.ts.map +1 -1
- package/dist/domain/workflowinstance/controller.js +4 -3
- package/dist/domain/workflowinstance/controller.js.map +1 -1
- package/dist/extensions/authorization-queries.d.ts +5 -6
- package/dist/extensions/authorization-queries.d.ts.map +1 -1
- package/dist/extensions/list-read-scope.d.ts +1 -1
- package/dist/extensions/resource-authorization.d.ts +2 -3
- package/dist/extensions/resource-authorization.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/apiresource-meta.d.ts +3 -12
- package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
- package/dist/pipeline/apiresource-meta.js +10 -21
- package/dist/pipeline/apiresource-meta.js.map +1 -1
- package/dist/pipeline/steps/authorization-tuples.d.ts +3 -9
- package/dist/pipeline/steps/authorization-tuples.d.ts.map +1 -1
- package/dist/pipeline/steps/authorization-tuples.js +11 -9
- package/dist/pipeline/steps/authorization-tuples.js.map +1 -1
- package/dist/pipeline/steps/references.d.ts +20 -178
- package/dist/pipeline/steps/references.d.ts.map +1 -1
- package/dist/pipeline/steps/references.js +43 -344
- package/dist/pipeline/steps/references.js.map +1 -1
- package/dist/pipeline/steps/visibility-gates.d.ts +27 -0
- package/dist/pipeline/steps/visibility-gates.d.ts.map +1 -0
- package/dist/pipeline/steps/visibility-gates.js +139 -0
- package/dist/pipeline/steps/visibility-gates.js.map +1 -0
- package/dist/query/search/controller.js +1 -0
- package/dist/query/search/controller.js.map +1 -1
- package/dist/query/search/criteria.d.ts +5 -1
- package/dist/query/search/criteria.d.ts.map +1 -1
- package/dist/query/search/criteria.js +13 -3
- package/dist/query/search/criteria.js.map +1 -1
- package/dist/query/search/handler.d.ts +4 -5
- package/dist/query/search/handler.d.ts.map +1 -1
- package/dist/query/search/handler.js +6 -7
- package/dist/query/search/handler.js.map +1 -1
- package/dist/query/search/query-store.d.ts.map +1 -1
- package/dist/query/search/query-store.js +2 -0
- package/dist/query/search/query-store.js.map +1 -1
- package/dist/store/interface.d.ts +6 -3
- package/dist/store/interface.d.ts.map +1 -1
- package/dist/store/interface.js.map +1 -1
- package/dist/store/postgres/migrations.d.ts +1 -3
- package/dist/store/postgres/migrations.d.ts.map +1 -1
- package/dist/store/postgres/migrations.js +1 -35
- package/dist/store/postgres/migrations.js.map +1 -1
- package/dist/store/postgres/store.d.ts.map +1 -1
- package/dist/store/postgres/store.js +9 -4
- package/dist/store/postgres/store.js.map +1 -1
- package/dist/store/sqlite/migrations.d.ts +1 -3
- package/dist/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/store/sqlite/migrations.js +1 -36
- package/dist/store/sqlite/migrations.js.map +1 -1
- package/dist/store/sqlite/store.d.ts.map +1 -1
- package/dist/store/sqlite/store.js +8 -4
- package/dist/store/sqlite/store.js.map +1 -1
- package/package.json +6 -6
- package/src/authorization/README.md +26 -24
- package/src/authorization/__tests__/authorizer.test.ts +9 -10
- package/src/authorization/__tests__/derived-tuples.test.ts +11 -4
- package/src/authorization/__tests__/evaluator.test.ts +73 -14
- package/src/authorization/__tests__/facts.test.ts +2 -2
- package/src/authorization/__tests__/fixtures/fga/agent-instance-creation.fga.yaml +185 -0
- package/src/authorization/__tests__/fixtures/fga/blueprint-private-visibility.fga.yaml +98 -6
- package/src/authorization/__tests__/fixtures/fga/cross-org-share-creation.fga.yaml +98 -0
- package/src/authorization/__tests__/fixtures/fga/default-instance-inheritance.fga.yaml +61 -4
- package/src/authorization/__tests__/fixtures/fga/mcp-server-authoring.fga.yaml +143 -0
- package/src/authorization/__tests__/fixtures/fga/org-admin-owner-inheritance.fga.yaml +21 -1
- package/src/authorization/__tests__/fixtures/fga/platform-visibility.fga.yaml +25 -1
- package/src/authorization/__tests__/fixtures/fga/public-visibility-setter.fga.yaml +52 -0
- package/src/authorization/__tests__/fixtures/fga/workflow-execution-sharing.fga.yaml +3 -1
- package/src/authorization/__tests__/list-read-scope.test.ts +17 -18
- package/src/authorization/__tests__/store-tests.test.ts +8 -1
- package/src/authorization/__tests__/tuples.test.ts +11 -12
- package/src/authorization/authorizer.ts +9 -4
- package/src/authorization/derived-tuples.ts +31 -14
- package/src/authorization/evaluator.ts +44 -8
- package/src/authorization/list-read-scope.ts +11 -5
- package/src/authorization/model/agent.ts +5 -2
- package/src/authorization/model/agent_instance.ts +2 -0
- package/src/authorization/model/mcp_server.ts +2 -0
- package/src/authorization/model/plugin.ts +4 -1
- package/src/authorization/model/rewrite.ts +13 -8
- package/src/authorization/model/skill.ts +2 -0
- package/src/authorization/model/workflow.ts +2 -0
- package/src/authorization/model/workflow_instance.ts +2 -0
- package/src/authorization/organization-directory.ts +3 -1
- package/src/authorization/store-test-kit.ts +75 -16
- package/src/authorization/tuples.ts +39 -16
- package/src/domain/agent/__tests__/agent.test.ts +4 -11
- package/src/domain/agent/controller.ts +7 -7
- package/src/domain/agentchannel/__tests__/agentchannel.test.ts +48 -223
- package/src/domain/agentchannel/controller.ts +1 -6
- package/src/domain/agentexecution/controller.ts +1 -6
- package/src/domain/agentinstance/controller.ts +12 -6
- package/src/domain/agentshare/__tests__/agentshare.test.ts +172 -196
- package/src/domain/agentshare/__tests__/create-authorization.test.ts +31 -16
- package/src/domain/agentshare/constants.ts +26 -14
- package/src/domain/agentshare/controller.ts +1 -6
- package/src/domain/agentshare/steps.ts +194 -41
- package/src/domain/environment/controller.ts +8 -5
- package/src/domain/executioncontext/controller.ts +1 -5
- package/src/domain/mcpserver/__tests__/mcpserver.test.ts +28 -115
- package/src/domain/mcpserver/__tests__/oauth-handshake.test.ts +18 -53
- package/src/domain/mcpserver/controller.ts +12 -6
- package/src/domain/plugin/controller.ts +8 -1
- package/src/domain/plugin/push.ts +16 -8
- package/src/domain/schedule/controller.ts +1 -6
- package/src/domain/session/controller.ts +4 -12
- package/src/domain/skill/controller.ts +7 -0
- package/src/domain/workflow/controller.ts +10 -28
- package/src/domain/workflow/registry/data/task-kind-registry.json +1 -1
- package/src/domain/workflow/validation/task-config-constraints.ts +3 -7
- package/src/domain/workflowexecution/controller.ts +2 -7
- package/src/domain/workflowinstance/controller.ts +12 -6
- package/src/extensions/__tests__/built-in-authorization-composed.test.ts +19 -32
- package/src/extensions/__tests__/extension-composition.test.ts +4 -4
- package/src/extensions/__tests__/list-read-scope-composed.test.ts +6 -9
- package/src/extensions/authorization-queries.ts +5 -6
- package/src/extensions/list-read-scope.ts +1 -1
- package/src/extensions/resource-authorization.ts +5 -3
- package/src/index.ts +14 -0
- package/src/pipeline/apiresource-meta.ts +10 -21
- package/src/pipeline/steps/__tests__/authorization-tuples.test.ts +31 -18
- package/src/pipeline/steps/__tests__/visibility-gates.test.ts +187 -0
- package/src/pipeline/steps/authorization-tuples.ts +11 -9
- package/src/pipeline/steps/references.ts +70 -578
- package/src/pipeline/steps/visibility-gates.ts +174 -0
- package/src/query/search/__tests__/criteria.test.ts +4 -0
- package/src/query/search/__tests__/query-store.test.ts +40 -11
- package/src/query/search/controller.ts +1 -0
- package/src/query/search/criteria.ts +14 -0
- package/src/query/search/handler.ts +7 -6
- package/src/query/search/query-store.ts +2 -0
- package/src/store/__tests__/store-contract.ts +51 -6
- package/src/store/interface.ts +6 -3
- package/src/store/postgres/__tests__/migrations.test.ts +6 -187
- package/src/store/postgres/__tests__/store-contract.test.ts +2 -0
- package/src/store/postgres/migrations.ts +1 -48
- package/src/store/postgres/store.ts +11 -4
- package/src/store/sqlite/__tests__/migrations.test.ts +5 -191
- package/src/store/sqlite/migrations.ts +1 -45
- package/src/store/sqlite/store.ts +10 -4
- package/dist/domain/workflow/agent-call-references.d.ts +0 -54
- package/dist/domain/workflow/agent-call-references.d.ts.map +0 -1
- package/dist/domain/workflow/agent-call-references.js +0 -97
- package/dist/domain/workflow/agent-call-references.js.map +0 -1
- package/dist/store/public-visibility-retired.d.ts +0 -67
- package/dist/store/public-visibility-retired.d.ts.map +0 -1
- package/dist/store/public-visibility-retired.js +0 -55
- package/dist/store/public-visibility-retired.js.map +0 -1
- package/src/domain/workflow/__tests__/agent-call-references.test.ts +0 -222
- package/src/domain/workflow/agent-call-references.ts +0 -157
- package/src/pipeline/__tests__/supports-visibility.test.ts +0 -112
- package/src/pipeline/steps/__tests__/references.test.ts +0 -703
- package/src/store/__tests__/public-visibility-retired.test.ts +0 -127
- package/src/store/public-visibility-retired.ts +0 -119
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ValidateAgentCallReferences — the second collector for the reference rule
|
|
3
|
-
* (pipeline/steps/references.ts): a workflow's `agent_call` tasks name their
|
|
4
|
-
* agent as a STRING, `"slug"` or `"org/slug"`, inside a `google.protobuf.Struct`
|
|
5
|
-
* config the generic spec walker cannot see, so the rule would never meet
|
|
6
|
-
* them. This step parses each task's config through the converter's own
|
|
7
|
-
* strict decoder (`unmarshalTaskConfig`, the one reader of a task config),
|
|
8
|
-
* walks nested control-flow tasks exactly as the constraint validator does,
|
|
9
|
-
* turns every `agent` string into a reference with the workflow as parent,
|
|
10
|
-
* and asks the rule's one function — same clauses, same copy. It lives in
|
|
11
|
-
* the workflow domain and not inside `InProcessValidator` because the
|
|
12
|
-
* validator is pure over the spec by design and a rule that reads the
|
|
13
|
-
* target's row cannot be.
|
|
14
|
-
*
|
|
15
|
-
* The parser here is STRICT: exactly `slug` or `org/slug`, both segments
|
|
16
|
-
* non-empty, anything else refused at write naming the task. Two lenient
|
|
17
|
-
* readers of the same string exist downstream and disagree with each other
|
|
18
|
-
* (the runner's `parseAgentReference` in activities/call-agent.ts splits on
|
|
19
|
-
* the first `/` and drops a third segment; the CLI's `parseReference` in
|
|
20
|
-
* client-apps/cli/src/resources/reference.ts refuses a leading slash);
|
|
21
|
-
* refusing every malformed shape here means neither ever meets one. The
|
|
22
|
-
* three cannot share code — the packages share only the protos — so the
|
|
23
|
-
* execution conformance suite is where their agreement is proven.
|
|
24
|
-
*
|
|
25
|
-
* Runs after NormalizeReferences and ValidateReferences on the workflow
|
|
26
|
-
* create and update chains, so the org the walk sees is the workflow's own
|
|
27
|
-
* for a bare slug. Proven by __tests__/agent-call-references.test.ts and
|
|
28
|
-
* the workflow conformance suite's reference arm.
|
|
29
|
-
*/
|
|
30
|
-
import type { WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
|
|
31
|
-
import type { AgentCallTaskConfig } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/agent_call_pb";
|
|
32
|
-
import type {
|
|
33
|
-
WorkflowSpec,
|
|
34
|
-
WorkflowTask,
|
|
35
|
-
} from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/spec_pb";
|
|
36
|
-
import { WorkflowTaskKind } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/enum_pb";
|
|
37
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
38
|
-
|
|
39
|
-
import type { Store } from "../../store/interface.js";
|
|
40
|
-
import { internalError, invalidArgumentError } from "../../pipeline/errors.js";
|
|
41
|
-
import type { PipelineStep } from "../../pipeline/pipeline.js";
|
|
42
|
-
import type { RequestContext } from "../../pipeline/request-context.js";
|
|
43
|
-
import type {
|
|
44
|
-
ReferenceParent,
|
|
45
|
-
SpecReference,
|
|
46
|
-
} from "../../pipeline/steps/references.js";
|
|
47
|
-
import { checkReferences } from "../../pipeline/steps/references.js";
|
|
48
|
-
import { metadataOf } from "../../pipeline/steps/shapes.js";
|
|
49
|
-
import { unmarshalTaskConfig } from "./converter/unmarshal.js";
|
|
50
|
-
import { nestedTasks } from "./validation/task-config-constraints.js";
|
|
51
|
-
|
|
52
|
-
/** The one sentence for an `agent` string that is neither `slug` nor `org/slug`. */
|
|
53
|
-
export function malformedAgentReferenceMessage(
|
|
54
|
-
taskName: string,
|
|
55
|
-
agent: string,
|
|
56
|
-
): string {
|
|
57
|
-
return `task '${taskName}': agent '${agent}' is not a reference; write 'slug' for an agent of this organization or 'org/slug' for another organization's.`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* `slug` or `org/slug` → the reference, with `org` empty for the bare form
|
|
62
|
-
* (the caller fills the parent's). Returns undefined for any other shape.
|
|
63
|
-
*/
|
|
64
|
-
export function parseAgentReference(
|
|
65
|
-
agent: string,
|
|
66
|
-
): { readonly org: string; readonly slug: string } | undefined {
|
|
67
|
-
const parts = agent.split("/");
|
|
68
|
-
if (parts.length === 1) {
|
|
69
|
-
return parts[0] === "" ? undefined : { org: "", slug: parts[0]! };
|
|
70
|
-
}
|
|
71
|
-
if (parts.length === 2 && parts[0] !== "" && parts[1] !== "") {
|
|
72
|
-
return { org: parts[0]!, slug: parts[1]! };
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Every `agent_call` task's agent as a reference, nested tasks included in
|
|
79
|
-
* declaration order, the bare form resolved to `parentOrg`. Throws
|
|
80
|
-
* INVALID_ARGUMENT on the first malformed string. A config that does not
|
|
81
|
-
* decode is skipped: the spec validation step has already refused the
|
|
82
|
-
* workflow for it, and this collector never double-reports.
|
|
83
|
-
*/
|
|
84
|
-
export function collectAgentCallReferences(
|
|
85
|
-
spec: WorkflowSpec | undefined,
|
|
86
|
-
parentOrg: string,
|
|
87
|
-
): SpecReference[] {
|
|
88
|
-
const refs: SpecReference[] = [];
|
|
89
|
-
if (spec === undefined) {
|
|
90
|
-
return refs;
|
|
91
|
-
}
|
|
92
|
-
const visit = (task: WorkflowTask): void => {
|
|
93
|
-
if (task.taskConfig !== undefined) {
|
|
94
|
-
let config;
|
|
95
|
-
try {
|
|
96
|
-
config = unmarshalTaskConfig(task.kind, task.taskConfig);
|
|
97
|
-
} catch {
|
|
98
|
-
config = undefined;
|
|
99
|
-
}
|
|
100
|
-
if (config !== undefined) {
|
|
101
|
-
if (task.kind === WorkflowTaskKind.agent_call) {
|
|
102
|
-
const agent = (config as AgentCallTaskConfig).agent;
|
|
103
|
-
const parsed = parseAgentReference(agent);
|
|
104
|
-
if (parsed === undefined) {
|
|
105
|
-
throw invalidArgumentError(
|
|
106
|
-
malformedAgentReferenceMessage(task.name, agent),
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
refs.push({
|
|
110
|
-
kind: ApiResourceKind.agent,
|
|
111
|
-
org: parsed.org === "" ? parentOrg : parsed.org,
|
|
112
|
-
slug: parsed.slug,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
for (const nested of nestedTasks(config)) {
|
|
116
|
-
visit(nested);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
for (const compensate of task.compensate) {
|
|
121
|
-
visit(compensate);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
for (const task of spec.tasks) {
|
|
125
|
-
visit(task);
|
|
126
|
-
}
|
|
127
|
-
return refs;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function newValidateAgentCallReferencesStep(
|
|
131
|
-
store: Store,
|
|
132
|
-
): PipelineStep<typeof WorkflowSchema> {
|
|
133
|
-
return {
|
|
134
|
-
name: "ValidateAgentCallReferences",
|
|
135
|
-
async execute(ctx: RequestContext<typeof WorkflowSchema>): Promise<void> {
|
|
136
|
-
const metadata = metadataOf(ctx.newState);
|
|
137
|
-
if (metadata === undefined) {
|
|
138
|
-
throw internalError(
|
|
139
|
-
new Error("resource metadata is nil"),
|
|
140
|
-
"validate agent_call references",
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
const refs = collectAgentCallReferences(ctx.newState.spec, metadata.org);
|
|
144
|
-
if (refs.length === 0) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const parent: ReferenceParent = {
|
|
148
|
-
org: metadata.org,
|
|
149
|
-
visibility: metadata.visibility,
|
|
150
|
-
};
|
|
151
|
-
const refusal = await checkReferences(store, parent, refs);
|
|
152
|
-
if (refusal !== undefined) {
|
|
153
|
-
throw refusal;
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pins `supportsVisibility` and `supportedVisibilityLevels`
|
|
3
|
-
* (pipeline/apiresource-meta.ts), the one predicate behind the
|
|
4
|
-
* ValidateVisibility doors on every create and updateVisibility chain.
|
|
5
|
-
*
|
|
6
|
-
* The retired public level is the reason this file exists: no kind config
|
|
7
|
-
* declares it any more, so the predicate cannot read a flag for it and must
|
|
8
|
-
* answer from its own text. The first test walks EVERY kind that has
|
|
9
|
-
* `kind_meta` and asserts the level is refused; the door is one function,
|
|
10
|
-
* and this is the pin that it holds for kinds nobody thought to try. The
|
|
11
|
-
* rest of the file pins the levels that remain against the proto's
|
|
12
|
-
* declarations for the kinds whose configs differ (a blueprint, an
|
|
13
|
-
* instance, an org-only kind, a kind with no config), and the copy fragment
|
|
14
|
-
* both editions build the INVALID_ARGUMENT sentence from.
|
|
15
|
-
*/
|
|
16
|
-
import { describe, expect, it } from "vitest";
|
|
17
|
-
|
|
18
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
19
|
-
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
getKindMeta,
|
|
23
|
-
supportedVisibilityLevels,
|
|
24
|
-
supportsVisibility,
|
|
25
|
-
} from "../apiresource-meta.js";
|
|
26
|
-
|
|
27
|
-
const V = ApiResourceVisibility;
|
|
28
|
-
|
|
29
|
-
/** Every enum member that carries kind_meta (the unknown kind does not). */
|
|
30
|
-
const KINDS_WITH_META: ApiResourceKind[] = Object.values(ApiResourceKind)
|
|
31
|
-
.filter((value): value is ApiResourceKind => typeof value === "number")
|
|
32
|
-
.filter((kind) => {
|
|
33
|
-
try {
|
|
34
|
-
getKindMeta(kind);
|
|
35
|
-
return true;
|
|
36
|
-
} catch {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe("supportsVisibility", () => {
|
|
42
|
-
it("refuses the retired public level for every kind", () => {
|
|
43
|
-
expect(KINDS_WITH_META.length).toBeGreaterThan(20);
|
|
44
|
-
for (const kind of KINDS_WITH_META) {
|
|
45
|
-
expect(supportsVisibility(kind, V.visibility_public)).toBe(false);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("private and unspecified are supported by every kind", () => {
|
|
50
|
-
for (const kind of KINDS_WITH_META) {
|
|
51
|
-
expect(supportsVisibility(kind, V.visibility_private)).toBe(true);
|
|
52
|
-
expect(
|
|
53
|
-
supportsVisibility(kind, V.api_resource_visibility_unspecified),
|
|
54
|
-
).toBe(true);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("a blueprint kind holds org and platform", () => {
|
|
59
|
-
expect(supportsVisibility(ApiResourceKind.agent, V.visibility_org)).toBe(
|
|
60
|
-
true,
|
|
61
|
-
);
|
|
62
|
-
expect(
|
|
63
|
-
supportsVisibility(ApiResourceKind.agent, V.visibility_platform),
|
|
64
|
-
).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("an instance kind holds org but never platform (tenant isolation)", () => {
|
|
68
|
-
expect(
|
|
69
|
-
supportsVisibility(ApiResourceKind.agent_instance, V.visibility_org),
|
|
70
|
-
).toBe(true);
|
|
71
|
-
expect(
|
|
72
|
-
supportsVisibility(ApiResourceKind.agent_instance, V.visibility_platform),
|
|
73
|
-
).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("an org-only kind holds org alone (environment: secrets never cross the org)", () => {
|
|
77
|
-
expect(
|
|
78
|
-
supportsVisibility(ApiResourceKind.environment, V.visibility_org),
|
|
79
|
-
).toBe(true);
|
|
80
|
-
expect(
|
|
81
|
-
supportsVisibility(ApiResourceKind.environment, V.visibility_platform),
|
|
82
|
-
).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("a kind with no visibility config is private-only", () => {
|
|
86
|
-
expect(supportsVisibility(ApiResourceKind.session, V.visibility_org)).toBe(
|
|
87
|
-
false,
|
|
88
|
-
);
|
|
89
|
-
expect(
|
|
90
|
-
supportsVisibility(ApiResourceKind.session, V.visibility_platform),
|
|
91
|
-
).toBe(false);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("supportedVisibilityLevels (the copy fragment)", () => {
|
|
96
|
-
it("names the levels that remain, private first, never the retired one", () => {
|
|
97
|
-
expect(supportedVisibilityLevels(ApiResourceKind.agent)).toBe(
|
|
98
|
-
"visibility_private, visibility_org, visibility_platform",
|
|
99
|
-
);
|
|
100
|
-
expect(supportedVisibilityLevels(ApiResourceKind.agent_instance)).toBe(
|
|
101
|
-
"visibility_private, visibility_org",
|
|
102
|
-
);
|
|
103
|
-
expect(supportedVisibilityLevels(ApiResourceKind.session)).toBe(
|
|
104
|
-
"visibility_private",
|
|
105
|
-
);
|
|
106
|
-
for (const kind of KINDS_WITH_META) {
|
|
107
|
-
expect(supportedVisibilityLevels(kind)).not.toContain(
|
|
108
|
-
"visibility_public",
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|