@stigmer/server 3.20.0 → 3.22.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/evaluator.d.ts +7 -1
- package/dist/authorization/evaluator.d.ts.map +1 -1
- 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 +19 -11
- package/dist/authorization/list-read-scope.js.map +1 -1
- package/dist/authorization/model/organization.d.ts.map +1 -1
- package/dist/authorization/model/organization.js +2 -0
- package/dist/authorization/model/organization.js.map +1 -1
- package/dist/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +0 -1
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/inprocess.d.ts +0 -2
- package/dist/boot/inprocess.d.ts.map +1 -1
- package/dist/boot/inprocess.js +0 -6
- package/dist/boot/inprocess.js.map +1 -1
- package/dist/domain/agent/controller.d.ts +2 -2
- package/dist/domain/agent/controller.d.ts.map +1 -1
- package/dist/domain/agent/controller.js +3 -17
- package/dist/domain/agent/controller.js.map +1 -1
- package/dist/domain/agent/steps.d.ts +0 -1
- package/dist/domain/agent/steps.d.ts.map +1 -1
- package/dist/domain/agent/steps.js +1 -40
- package/dist/domain/agent/steps.js.map +1 -1
- package/dist/domain/agentchannel/controller.d.ts.map +1 -1
- package/dist/domain/agentchannel/controller.js +6 -1
- package/dist/domain/agentchannel/controller.js.map +1 -1
- package/dist/domain/agentchannel/steps.d.ts +19 -0
- package/dist/domain/agentchannel/steps.d.ts.map +1 -1
- package/dist/domain/agentchannel/steps.js +32 -0
- package/dist/domain/agentchannel/steps.js.map +1 -1
- package/dist/domain/agentexecution/controller.d.ts.map +1 -1
- package/dist/domain/agentexecution/controller.js +7 -9
- package/dist/domain/agentexecution/controller.js.map +1 -1
- package/dist/domain/agentexecution/create-execution-context-step.d.ts +0 -2
- package/dist/domain/agentexecution/create-execution-context-step.d.ts.map +1 -1
- package/dist/domain/agentexecution/create-execution-context-step.js +179 -60
- package/dist/domain/agentexecution/create-execution-context-step.js.map +1 -1
- package/dist/domain/agentexecution/create-steps.d.ts +16 -31
- package/dist/domain/agentexecution/create-steps.d.ts.map +1 -1
- package/dist/domain/agentexecution/create-steps.js +36 -102
- package/dist/domain/agentexecution/create-steps.js.map +1 -1
- package/dist/domain/agentexecution/run-target.d.ts +7 -3
- package/dist/domain/agentexecution/run-target.d.ts.map +1 -1
- package/dist/domain/agentexecution/run-target.js.map +1 -1
- package/dist/domain/agentinstance/controller.d.ts +5 -5
- package/dist/domain/agentinstance/controller.d.ts.map +1 -1
- package/dist/domain/agentinstance/controller.js +6 -1
- package/dist/domain/agentinstance/controller.js.map +1 -1
- package/dist/domain/agentinstance/steps.d.ts +43 -8
- package/dist/domain/agentinstance/steps.d.ts.map +1 -1
- package/dist/domain/agentinstance/steps.js +71 -8
- package/dist/domain/agentinstance/steps.js.map +1 -1
- package/dist/domain/agentshare/controller.d.ts.map +1 -1
- package/dist/domain/agentshare/controller.js +7 -1
- package/dist/domain/agentshare/controller.js.map +1 -1
- package/dist/domain/agentshare/steps.d.ts +58 -0
- package/dist/domain/agentshare/steps.d.ts.map +1 -1
- package/dist/domain/agentshare/steps.js +109 -4
- package/dist/domain/agentshare/steps.js.map +1 -1
- package/dist/domain/artifact/controller.js +21 -25
- package/dist/domain/artifact/controller.js.map +1 -1
- package/dist/domain/channelapp/controller.d.ts.map +1 -1
- package/dist/domain/channelapp/controller.js +2 -0
- package/dist/domain/channelapp/controller.js.map +1 -1
- package/dist/domain/environment/controller.d.ts.map +1 -1
- package/dist/domain/environment/controller.js +2 -0
- package/dist/domain/environment/controller.js.map +1 -1
- package/dist/domain/environment/personal.d.ts +42 -0
- package/dist/domain/environment/personal.d.ts.map +1 -0
- package/dist/domain/environment/personal.js +96 -0
- package/dist/domain/environment/personal.js.map +1 -0
- package/dist/domain/executioncontext/controller.d.ts.map +1 -1
- package/dist/domain/executioncontext/controller.js +2 -0
- package/dist/domain/executioncontext/controller.js.map +1 -1
- package/dist/domain/executioncontext/steps.d.ts.map +1 -1
- package/dist/domain/executioncontext/steps.js +2 -1
- package/dist/domain/executioncontext/steps.js.map +1 -1
- package/dist/domain/mcpserver/connect.d.ts +0 -2
- package/dist/domain/mcpserver/connect.d.ts.map +1 -1
- package/dist/domain/mcpserver/connect.js +24 -79
- package/dist/domain/mcpserver/connect.js.map +1 -1
- package/dist/domain/mcpserver/controller.d.ts.map +1 -1
- package/dist/domain/mcpserver/controller.js +2 -0
- package/dist/domain/mcpserver/controller.js.map +1 -1
- package/dist/domain/mcpserver/start-connect.d.ts.map +1 -1
- package/dist/domain/mcpserver/start-connect.js +8 -7
- package/dist/domain/mcpserver/start-connect.js.map +1 -1
- package/dist/domain/memory/controller.d.ts.map +1 -1
- package/dist/domain/memory/controller.js +6 -1
- package/dist/domain/memory/controller.js.map +1 -1
- package/dist/domain/memory/steps.d.ts +23 -0
- package/dist/domain/memory/steps.d.ts.map +1 -1
- package/dist/domain/memory/steps.js +35 -0
- package/dist/domain/memory/steps.js.map +1 -1
- package/dist/domain/oauthapp/controller.d.ts.map +1 -1
- package/dist/domain/oauthapp/controller.js +2 -0
- package/dist/domain/oauthapp/controller.js.map +1 -1
- package/dist/domain/plugin/controller.d.ts.map +1 -1
- package/dist/domain/plugin/controller.js +5 -24
- package/dist/domain/plugin/controller.js.map +1 -1
- package/dist/domain/plugin/overlay/sanitize.js +2 -2
- package/dist/domain/schedule/controller.d.ts.map +1 -1
- package/dist/domain/schedule/controller.js +7 -1
- package/dist/domain/schedule/controller.js.map +1 -1
- package/dist/domain/schedule/steps.d.ts +19 -0
- package/dist/domain/schedule/steps.d.ts.map +1 -1
- package/dist/domain/schedule/steps.js +32 -0
- package/dist/domain/schedule/steps.js.map +1 -1
- package/dist/domain/session/controller.d.ts +0 -7
- package/dist/domain/session/controller.d.ts.map +1 -1
- package/dist/domain/session/controller.js +11 -16
- package/dist/domain/session/controller.js.map +1 -1
- package/dist/domain/session/run-target.d.ts +9 -8
- package/dist/domain/session/run-target.d.ts.map +1 -1
- package/dist/domain/session/run-target.js.map +1 -1
- package/dist/domain/session/steps.d.ts +8 -36
- package/dist/domain/session/steps.d.ts.map +1 -1
- package/dist/domain/session/steps.js +27 -172
- package/dist/domain/session/steps.js.map +1 -1
- package/dist/domain/skill/controller.d.ts.map +1 -1
- package/dist/domain/skill/controller.js +8 -17
- 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 +30 -107
- package/dist/domain/workflow/controller.js.map +1 -1
- package/dist/domain/workflow/version-resolution.d.ts +5 -0
- package/dist/domain/workflow/version-resolution.d.ts.map +1 -0
- package/dist/domain/workflow/version-resolution.js +113 -0
- package/dist/domain/workflow/version-resolution.js.map +1 -0
- package/dist/domain/workflowexecution/create-steps.d.ts +4 -3
- package/dist/domain/workflowexecution/create-steps.d.ts.map +1 -1
- package/dist/domain/workflowexecution/create-steps.js +4 -3
- package/dist/domain/workflowexecution/create-steps.js.map +1 -1
- package/dist/domain/workflowinstance/controller.d.ts.map +1 -1
- package/dist/domain/workflowinstance/controller.js +6 -1
- package/dist/domain/workflowinstance/controller.js.map +1 -1
- package/dist/domain/workflowinstance/steps.d.ts +20 -0
- package/dist/domain/workflowinstance/steps.d.ts.map +1 -1
- package/dist/domain/workflowinstance/steps.js +39 -0
- package/dist/domain/workflowinstance/steps.js.map +1 -1
- package/dist/extensions/identity.d.ts +19 -0
- package/dist/extensions/identity.d.ts.map +1 -1
- package/dist/extensions/identity.js +22 -3
- package/dist/extensions/identity.js.map +1 -1
- package/dist/extensions/list-read-scope.d.ts +41 -7
- package/dist/extensions/list-read-scope.d.ts.map +1 -1
- package/dist/extensions/list-read-scope.js +13 -2
- package/dist/extensions/list-read-scope.js.map +1 -1
- package/dist/pipeline/apiresource-labels.d.ts +2 -2
- package/dist/pipeline/apiresource-labels.js +2 -2
- package/dist/pipeline/errors.d.ts +2 -2
- package/dist/pipeline/errors.js +2 -2
- package/dist/pipeline/steps/authorize-resolved-target.d.ts +88 -0
- package/dist/pipeline/steps/authorize-resolved-target.d.ts.map +1 -0
- package/dist/pipeline/steps/authorize-resolved-target.js +36 -0
- package/dist/pipeline/steps/authorize-resolved-target.js.map +1 -0
- package/dist/pipeline/steps/authorize.d.ts +27 -0
- package/dist/pipeline/steps/authorize.d.ts.map +1 -1
- package/dist/pipeline/steps/authorize.js +49 -10
- package/dist/pipeline/steps/authorize.js.map +1 -1
- package/dist/pipeline/steps/guard-memory-capture.d.ts.map +1 -1
- package/dist/pipeline/steps/guard-memory-capture.js +2 -1
- package/dist/pipeline/steps/guard-memory-capture.js.map +1 -1
- package/dist/pipeline/steps/guard-reserved-labels.d.ts.map +1 -1
- package/dist/pipeline/steps/guard-reserved-labels.js +12 -12
- package/dist/pipeline/steps/guard-reserved-labels.js.map +1 -1
- package/dist/pipeline/steps/helpers.d.ts +9 -5
- package/dist/pipeline/steps/helpers.d.ts.map +1 -1
- package/dist/pipeline/steps/helpers.js +11 -15
- package/dist/pipeline/steps/helpers.js.map +1 -1
- package/dist/pipeline/steps/version-history.d.ts +11 -0
- package/dist/pipeline/steps/version-history.d.ts.map +1 -1
- package/dist/pipeline/steps/version-history.js +26 -0
- package/dist/pipeline/steps/version-history.js.map +1 -1
- package/package.json +6 -6
- package/src/authorization/__tests__/list-read-scope.test.ts +23 -12
- package/src/authorization/__tests__/skip-lane-inventory.test.ts +160 -0
- package/src/authorization/__tests__/wire-permissions.test.ts +5 -5
- package/src/authorization/evaluator.ts +7 -0
- package/src/authorization/list-read-scope.ts +22 -11
- package/src/authorization/model/__tests__/registry.test.ts +2 -0
- package/src/authorization/model/organization.ts +2 -0
- package/src/boot/compose.ts +0 -1
- package/src/boot/inprocess.ts +0 -9
- package/src/domain/agent/__tests__/agent.test.ts +0 -68
- package/src/domain/agent/controller.ts +11 -36
- package/src/domain/agent/steps.ts +1 -60
- package/src/domain/agentchannel/__tests__/create-authorization.test.ts +58 -0
- package/src/domain/agentchannel/controller.ts +19 -0
- package/src/domain/agentchannel/steps.ts +40 -0
- package/src/domain/agentexecution/__tests__/create-execution-context-step.test.ts +216 -0
- package/src/domain/agentexecution/__tests__/create-steps.test.ts +70 -145
- package/src/domain/agentexecution/controller.ts +6 -10
- package/src/domain/agentexecution/create-execution-context-step.ts +271 -83
- package/src/domain/agentexecution/create-steps.ts +38 -138
- package/src/domain/agentexecution/run-target.ts +7 -3
- package/src/domain/agentinstance/__tests__/create-authorization.composed.test.ts +243 -0
- package/src/domain/agentinstance/__tests__/create-authorization.test.ts +144 -0
- package/src/domain/agentinstance/controller.ts +24 -5
- package/src/domain/agentinstance/steps.ts +82 -8
- package/src/domain/agentshare/__tests__/create-authorization.test.ts +86 -0
- package/src/domain/agentshare/__tests__/member-audience.test.ts +113 -0
- package/src/domain/agentshare/controller.ts +21 -0
- package/src/domain/agentshare/steps.ts +181 -15
- package/src/domain/artifact/controller.ts +18 -22
- package/src/domain/channelapp/controller.ts +10 -0
- package/src/domain/environment/__tests__/personal.test.ts +143 -0
- package/src/domain/environment/controller.ts +10 -0
- package/src/domain/environment/personal.ts +141 -0
- package/src/domain/executioncontext/__tests__/executioncontext.test.ts +1 -0
- package/src/domain/executioncontext/controller.ts +10 -0
- package/src/domain/executioncontext/steps.ts +2 -1
- package/src/domain/mcpserver/connect.ts +32 -92
- package/src/domain/mcpserver/controller.ts +13 -1
- package/src/domain/mcpserver/start-connect.ts +17 -11
- package/src/domain/memory/__tests__/create-authorization.test.ts +59 -0
- package/src/domain/memory/controller.ts +11 -0
- package/src/domain/memory/steps.ts +41 -0
- package/src/domain/oauthapp/controller.ts +10 -0
- package/src/domain/plugin/controller.ts +22 -36
- package/src/domain/plugin/overlay/sanitize.ts +2 -2
- package/src/domain/schedule/__tests__/create-authorization.test.ts +58 -0
- package/src/domain/schedule/controller.ts +20 -0
- package/src/domain/schedule/steps.ts +45 -2
- package/src/domain/session/__tests__/run-gate.test.ts +19 -52
- package/src/domain/session/__tests__/session.test.ts +27 -203
- package/src/domain/session/controller.ts +10 -30
- package/src/domain/session/run-target.ts +9 -8
- package/src/domain/session/steps.ts +33 -267
- package/src/domain/skill/controller.ts +24 -23
- package/src/domain/workflow/controller.ts +58 -145
- package/src/domain/workflow/version-resolution.ts +166 -0
- package/src/domain/workflowexecution/create-steps.ts +4 -3
- package/src/domain/workflowinstance/__tests__/create-authorization.test.ts +109 -0
- package/src/domain/workflowinstance/controller.ts +19 -0
- package/src/domain/workflowinstance/steps.ts +49 -1
- package/src/extensions/__tests__/composed-support.ts +38 -4
- package/src/extensions/__tests__/identity.test.ts +44 -1
- package/src/extensions/__tests__/list-read-scope-composed.test.ts +87 -1
- package/src/extensions/__tests__/list-read-scope.test.ts +63 -0
- package/src/extensions/identity.ts +23 -5
- package/src/extensions/list-read-scope.ts +47 -7
- package/src/pipeline/apiresource-labels.ts +2 -2
- package/src/pipeline/errors.ts +2 -2
- package/src/pipeline/steps/__tests__/authorize-resolved-target.test.ts +285 -0
- package/src/pipeline/steps/authorize-resolved-target.ts +129 -0
- package/src/pipeline/steps/authorize.ts +70 -13
- package/src/pipeline/steps/guard-memory-capture.ts +2 -1
- package/src/pipeline/steps/guard-reserved-labels.ts +12 -14
- package/src/pipeline/steps/helpers.ts +11 -15
- package/src/pipeline/steps/version-history.ts +34 -0
- package/dist/domain/agent/defaultagent.d.ts +0 -37
- package/dist/domain/agent/defaultagent.d.ts.map +0 -1
- package/dist/domain/agent/defaultagent.js +0 -104
- package/dist/domain/agent/defaultagent.js.map +0 -1
- package/src/domain/agent/defaultagent.ts +0 -135
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
* record_harness_state_history.go) and its steps/ package
|
|
7
7
|
* (filter_by_agent_instance.go, filter_by_channel.go). Shared steps stay
|
|
8
8
|
* in src/pipeline/steps/; these exist because they embody
|
|
9
|
-
* session-specific contracts: the
|
|
10
|
-
* harness
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* session-specific contracts: the harness/execution-target immutability
|
|
10
|
+
* sentinels, the server-owned harness-state history, the active-execution
|
|
11
|
+
* delete guard with its execution cascade, and the list filters.
|
|
12
|
+
*
|
|
13
|
+
* An empty spec.agent_instance_id is a legal shape and stays empty: the
|
|
14
|
+
* session runs the built-in assistant (session/v1/spec.proto). No step here
|
|
15
|
+
* resolves it into an instance, and no step guards it on update, because
|
|
16
|
+
* a conversation may gain an agent or drop back to the assistant; the
|
|
17
|
+
* immutable fields are the harness and the execution target below.
|
|
13
18
|
*/
|
|
14
|
-
import { Code, ConnectError } from "@connectrpc/connect";
|
|
15
19
|
import { create, fromBinary } from "@bufbuild/protobuf";
|
|
16
20
|
import type { DescMessage } from "@bufbuild/protobuf";
|
|
17
21
|
|
|
18
|
-
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
19
|
-
import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
20
|
-
import { AgentStatusSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/status_pb";
|
|
21
22
|
import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
22
23
|
import type { AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
23
24
|
import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
24
|
-
import type { AgentInstance } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/api_pb";
|
|
25
25
|
import { SessionSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
26
26
|
import type { Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
27
27
|
import {
|
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
} from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
31
31
|
import { SessionListSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/io_pb";
|
|
32
32
|
import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
|
|
33
|
-
import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
|
|
34
33
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
35
34
|
import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
|
|
36
35
|
|
|
@@ -38,29 +37,19 @@ import type { Logger } from "../../boot/logger.js";
|
|
|
38
37
|
import type { AgentExecutionTemporalConfig } from "../agentexecution/temporal/config.js";
|
|
39
38
|
import {
|
|
40
39
|
failedPreconditionError,
|
|
41
|
-
goWrappedStatusError,
|
|
42
40
|
internalError,
|
|
43
41
|
invalidArgumentError,
|
|
44
42
|
} from "../../pipeline/errors.js";
|
|
45
43
|
import type { PipelineStep } from "../../pipeline/pipeline.js";
|
|
46
|
-
import type { CallerIdentity } from "../../extensions/identity.js";
|
|
47
44
|
import type { Authorizer } from "../../extensions/authorizer.js";
|
|
48
45
|
import type { ListReadScope } from "../../extensions/list-read-scope.js";
|
|
49
46
|
import { restrictListByReadScope } from "../../extensions/list-read-scope.js";
|
|
50
|
-
import
|
|
51
|
-
import { authorizeResolvedResource } from "../../pipeline/steps/authorize.js";
|
|
52
|
-
import { notifyDefaultInstanceLinked } from "../../pipeline/steps/authorization-tuples.js";
|
|
47
|
+
import { newAuthorizeResolvedTargetStep } from "../../pipeline/steps/authorize-resolved-target.js";
|
|
53
48
|
import type { RequestContext } from "../../pipeline/request-context.js";
|
|
54
49
|
import { RESOURCE_ID_KEY } from "../../pipeline/steps/delete.js";
|
|
55
50
|
import { compareCreatedAtDesc } from "../../pipeline/steps/helpers.js";
|
|
56
51
|
import { EXISTING_RESOURCE_KEY } from "../../pipeline/steps/load-existing.js";
|
|
57
52
|
import type { Store } from "../../store/interface.js";
|
|
58
|
-
import { buildDefaultInstanceRequest } from "../agentinstance/defaultinstance.js";
|
|
59
|
-
import {
|
|
60
|
-
DefaultAgentNotConfiguredError,
|
|
61
|
-
DefaultAgentNotPublicError,
|
|
62
|
-
findDefaultAgent,
|
|
63
|
-
} from "../agent/defaultagent.js";
|
|
64
53
|
|
|
65
54
|
type SessionDesc = typeof SessionSchema;
|
|
66
55
|
|
|
@@ -74,221 +63,6 @@ export const LIST_RESULT_KEY = "listResult";
|
|
|
74
63
|
*/
|
|
75
64
|
const CHANNEL_ID_LABEL_KEY = "stigmer.ai/channel-id";
|
|
76
65
|
|
|
77
|
-
/**
|
|
78
|
-
* The narrow in-process surface the session domain needs from
|
|
79
|
-
* agentinstance — consumer-defined so the dependency reads at the domain
|
|
80
|
-
* boundary (the Go twin is pkg/downstream/agentinstance.Client). This is
|
|
81
|
-
* the CREATE RPC (Go CreateAsSystem), not apply: the resolve step only
|
|
82
|
-
* reaches it when the default instance is known to be missing, and a
|
|
83
|
-
* duplicate-slug collision must surface as AlreadyExists, not silently
|
|
84
|
-
* update. Calls ride the in-process router transport, traversing the full
|
|
85
|
-
* interceptor chain (DD-002).
|
|
86
|
-
*/
|
|
87
|
-
export interface AgentInstanceCreator {
|
|
88
|
-
/**
|
|
89
|
-
* Creates AS THE ORIGINAL CALLER (C2 Stage 3, ruling R5 — the Java
|
|
90
|
-
* createAsCaller posture): the propagated identity gives the created
|
|
91
|
-
* instance real owner attribution under an enforcing Authorizer.
|
|
92
|
-
*/
|
|
93
|
-
createAsCaller(
|
|
94
|
-
instance: AgentInstance,
|
|
95
|
-
caller: CallerIdentity,
|
|
96
|
-
): Promise<AgentInstance>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Lazy provider for the in-process agentinstance edge — resolved at call
|
|
101
|
-
* time, never at construction (the ratified DI story, D2 §2).
|
|
102
|
-
*/
|
|
103
|
-
export type AgentInstanceCreatorProvider = () => AgentInstanceCreator;
|
|
104
|
-
|
|
105
|
-
// ---------------------------------------------------------------------------
|
|
106
|
-
// ResolveDefaultAgentInstance — create.go:62-182: when agent_instance_id is
|
|
107
|
-
// not provided, resolve the platform default agent (shared defaultagent
|
|
108
|
-
// implementation: label stigmer.ai/default-agent=true, visibility_public,
|
|
109
|
-
// deterministic incumbent-wins tie-break), get or create its default
|
|
110
|
-
// instance, and set agent_instance_id on the session spec. This enables the
|
|
111
|
-
// session-first UX where users create a session (with workspace entries)
|
|
112
|
-
// without knowing the agent instance — the backend resolves it
|
|
113
|
-
// automatically.
|
|
114
|
-
//
|
|
115
|
-
// Runs FIRST in the create chain, before ValidateProto — resolution must
|
|
116
|
-
// fill agent_instance_id before validation sees the spec.
|
|
117
|
-
//
|
|
118
|
-
// The id lands on ctx.newState.spec, NEVER on input: the pipeline cloned
|
|
119
|
-
// input into newState at construction and Persist saves newState, so
|
|
120
|
-
// mutating input does not propagate (Go's documented clone gotcha,
|
|
121
|
-
// create.go:168-170).
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
|
-
|
|
124
|
-
export function newResolveDefaultAgentInstanceStep(
|
|
125
|
-
store: Store,
|
|
126
|
-
creator: AgentInstanceCreatorProvider,
|
|
127
|
-
logger: Logger,
|
|
128
|
-
authorizationLifecycle?: ResourceAuthorizationLifecycle,
|
|
129
|
-
): PipelineStep<SessionDesc> {
|
|
130
|
-
return {
|
|
131
|
-
name: "ResolveDefaultAgentInstance",
|
|
132
|
-
async execute(ctx: RequestContext<SessionDesc>): Promise<void> {
|
|
133
|
-
if ((ctx.input.spec?.agentInstanceId ?? "") !== "") {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
logger.info(
|
|
138
|
-
"agent_instance_id not provided on session, resolving platform default agent",
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
// 1. Resolve the default agent. The error copy is Go WrapError's
|
|
142
|
-
// "%s: %v" — the sentinel's text RIDES the wire message, and the
|
|
143
|
-
// NotFound arm carries Go's DOUBLE wrap (fmt.Errorf("no default
|
|
144
|
-
// agent available on this platform: %w", err) inside WrapError).
|
|
145
|
-
// Byte-pinned.
|
|
146
|
-
let defaultAgent: Agent;
|
|
147
|
-
try {
|
|
148
|
-
defaultAgent = await findDefaultAgent(store, logger);
|
|
149
|
-
} catch (error) {
|
|
150
|
-
if (error instanceof DefaultAgentNotConfiguredError) {
|
|
151
|
-
logger.error("No platform default agent configured", {
|
|
152
|
-
error: error.message,
|
|
153
|
-
});
|
|
154
|
-
throw new ConnectError(
|
|
155
|
-
`No default agent available. Ensure an agent with label stigmer.ai/default-agent=true and visibility_public exists: no default agent available on this platform: ${error.message}`,
|
|
156
|
-
Code.NotFound,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
if (error instanceof DefaultAgentNotPublicError) {
|
|
160
|
-
logger.error("Default agent is not visibility_public", {
|
|
161
|
-
error: error.message,
|
|
162
|
-
});
|
|
163
|
-
throw new ConnectError(
|
|
164
|
-
`Default agent exists but is not visibility_public: ${error.message}`,
|
|
165
|
-
Code.FailedPrecondition,
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
// Store/decode failure — an internal fault, not "no default
|
|
169
|
-
// agent". InternalError keeps the cause off the wire
|
|
170
|
-
// (stigmer/stigmer#478).
|
|
171
|
-
logger.error("Failed to resolve platform default agent", {
|
|
172
|
-
error: error instanceof Error ? error.message : String(error),
|
|
173
|
-
});
|
|
174
|
-
throw internalError(
|
|
175
|
-
error,
|
|
176
|
-
"failed to resolve the platform default agent",
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const metadata = defaultAgent.metadata;
|
|
181
|
-
if (metadata === undefined) {
|
|
182
|
-
// Unreachable: findDefaultAgent only returns public-visibility
|
|
183
|
-
// candidates, whose metadata is necessarily set.
|
|
184
|
-
throw internalError(
|
|
185
|
-
new Error("default agent metadata is nil"),
|
|
186
|
-
"failed to resolve the platform default agent",
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
const agentId = metadata.id;
|
|
190
|
-
logger.info("Resolved platform default agent", {
|
|
191
|
-
agentId,
|
|
192
|
-
agentName: metadata.name,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// 2. Get or create the default instance.
|
|
196
|
-
let defaultInstanceId = defaultAgent.status?.defaultInstanceId ?? "";
|
|
197
|
-
if (defaultInstanceId === "") {
|
|
198
|
-
logger.info("Default instance missing, creating one", { agentId });
|
|
199
|
-
|
|
200
|
-
const instanceRequest = buildDefaultInstanceRequest(metadata);
|
|
201
|
-
|
|
202
|
-
// Go create.go:144-148 wraps the downstream error with fmt.Errorf
|
|
203
|
-
// ("failed to create default instance for default agent: %w") and
|
|
204
|
-
// PipelineError.GRPCStatus's errors.As branch keeps the inner
|
|
205
|
-
// CODE but rewrites the wire MESSAGE to the wrapped text —
|
|
206
|
-
// transport formatting (`rpc error: code = X desc = ...`)
|
|
207
|
-
// included. Mirrored byte-for-byte via goWrappedStatusError; the
|
|
208
|
-
// leak is stigmer/stigmer#852 (both-editions post-cutover fix).
|
|
209
|
-
// Unstatused failures fall to the pipeline's Internal fallback,
|
|
210
|
-
// exactly Go's plain-error path.
|
|
211
|
-
let createdInstance: AgentInstance;
|
|
212
|
-
try {
|
|
213
|
-
createdInstance = await creator().createAsCaller(
|
|
214
|
-
instanceRequest,
|
|
215
|
-
ctx.callerIdentity,
|
|
216
|
-
);
|
|
217
|
-
} catch (error) {
|
|
218
|
-
logger.error("Failed to create default instance", {
|
|
219
|
-
agentId,
|
|
220
|
-
error: error instanceof Error ? error.message : String(error),
|
|
221
|
-
});
|
|
222
|
-
if (error instanceof ConnectError) {
|
|
223
|
-
throw goWrappedStatusError(
|
|
224
|
-
"failed to create default instance for default agent",
|
|
225
|
-
error,
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
throw new Error(
|
|
229
|
-
`failed to create default instance for default agent: ${error instanceof Error ? error.message : String(error)}`,
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
defaultInstanceId = createdInstance.metadata?.id ?? "";
|
|
234
|
-
|
|
235
|
-
// Persist default_instance_id on the agent — EXPLICITLY the agent
|
|
236
|
-
// kind: this pipeline's ctx kind is session (Go hardcodes
|
|
237
|
-
// ApiResourceKind_agent here too).
|
|
238
|
-
if (defaultAgent.status === undefined) {
|
|
239
|
-
defaultAgent.status = create(AgentStatusSchema, {});
|
|
240
|
-
}
|
|
241
|
-
defaultAgent.status.defaultInstanceId = defaultInstanceId;
|
|
242
|
-
try {
|
|
243
|
-
await store.saveResource(
|
|
244
|
-
ApiResourceKind.agent,
|
|
245
|
-
agentId,
|
|
246
|
-
AgentSchema,
|
|
247
|
-
defaultAgent,
|
|
248
|
-
);
|
|
249
|
-
} catch (error) {
|
|
250
|
-
logger.error("Failed to persist agent with default_instance_id", {
|
|
251
|
-
agentId,
|
|
252
|
-
error: error instanceof Error ? error.message : String(error),
|
|
253
|
-
});
|
|
254
|
-
// Go wraps as a plain error → the pipeline's Internal fallback.
|
|
255
|
-
throw new Error(
|
|
256
|
-
`failed to persist agent with default instance: ${error instanceof Error ? error.message : String(error)}`,
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// The default_of invariant rides the pointer persist (C2 Stage 3).
|
|
261
|
-
await notifyDefaultInstanceLinked(authorizationLifecycle, {
|
|
262
|
-
instanceKind: ApiResourceKind.agent_instance,
|
|
263
|
-
instanceId: defaultInstanceId,
|
|
264
|
-
blueprintKind: ApiResourceKind.agent,
|
|
265
|
-
blueprintId: agentId,
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
logger.info("Created default instance for default agent", {
|
|
269
|
-
instanceId: defaultInstanceId,
|
|
270
|
-
agentId,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// 3. Set agent_instance_id on the session's newState (not input) —
|
|
275
|
-
// see the module-level clone gotcha note.
|
|
276
|
-
const newState = ctx.newState;
|
|
277
|
-
if (newState.spec === undefined) {
|
|
278
|
-
newState.spec = create(SessionSpecSchema, {});
|
|
279
|
-
}
|
|
280
|
-
newState.spec.agentInstanceId = defaultInstanceId;
|
|
281
|
-
|
|
282
|
-
logger.info(
|
|
283
|
-
"Set agent_instance_id on session from platform default agent",
|
|
284
|
-
{
|
|
285
|
-
agentInstanceId: defaultInstanceId,
|
|
286
|
-
},
|
|
287
|
-
);
|
|
288
|
-
},
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
66
|
// ---------------------------------------------------------------------------
|
|
293
67
|
// ValidateHarnessImmutability — validate_harness_immutability.go: rejects
|
|
294
68
|
// session updates that attempt to change the harness after the session has
|
|
@@ -759,41 +533,33 @@ export function newFilterByAgentInstanceStep(
|
|
|
759
533
|
|
|
760
534
|
/**
|
|
761
535
|
* AuthorizeChannelAccess — the Java SessionListByChannelHandler's
|
|
762
|
-
* two-stage authorization, stage one
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
* checks only a named channel.
|
|
536
|
+
* two-stage authorization, stage one: an explicit can_view check on the
|
|
537
|
+
* TARGET agent_channel before any session work, so a caller without
|
|
538
|
+
* channel access learns nothing about the channel's sessions. The
|
|
539
|
+
* mid-chain resolved-target evaluation (the is_skip_authorization
|
|
540
|
+
* annotation makes the position-1 step a no-op on this lane); deny copy is
|
|
541
|
+
* the Java handler's byte-pinned "unauthorized to list channel
|
|
542
|
+
* conversations". The blank-id refusal stays FilterByChannel's (the step
|
|
543
|
+
* behind this gate) — the gate asks nothing when no channel is named.
|
|
771
544
|
*/
|
|
772
545
|
export function newAuthorizeChannelAccessStep(
|
|
773
546
|
authorizer: Authorizer,
|
|
774
547
|
): PipelineStep<typeof SessionQueryController.method.listByChannel.input> {
|
|
775
|
-
return
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
resourceKind: ApiResourceKind.agent_channel,
|
|
791
|
-
resourceId: ctx.input.channelId,
|
|
792
|
-
},
|
|
793
|
-
"unauthorized to list channel conversations",
|
|
794
|
-
);
|
|
795
|
-
},
|
|
796
|
-
};
|
|
548
|
+
return newAuthorizeResolvedTargetStep(
|
|
549
|
+
authorizer,
|
|
550
|
+
({ input }) =>
|
|
551
|
+
input.channelId === ""
|
|
552
|
+
? []
|
|
553
|
+
: [
|
|
554
|
+
{
|
|
555
|
+
permission: IamPermission.can_view,
|
|
556
|
+
resourceKind: ApiResourceKind.agent_channel,
|
|
557
|
+
resourceId: input.channelId,
|
|
558
|
+
deniedMessage: "unauthorized to list channel conversations",
|
|
559
|
+
},
|
|
560
|
+
],
|
|
561
|
+
"AuthorizeChannelAccess",
|
|
562
|
+
);
|
|
797
563
|
}
|
|
798
564
|
|
|
799
565
|
/**
|
|
@@ -53,7 +53,6 @@ import type {
|
|
|
53
53
|
UpdateVisibilityInput,
|
|
54
54
|
} from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
55
55
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
56
|
-
import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
|
|
57
56
|
|
|
58
57
|
import type { ArtifactStorage } from "../../artifactstorage/artifact-storage.js";
|
|
59
58
|
import type { Logger } from "../../boot/logger.js";
|
|
@@ -70,10 +69,12 @@ import { newPipeline } from "../../pipeline/pipeline.js";
|
|
|
70
69
|
import type { PipelineStep } from "../../pipeline/pipeline.js";
|
|
71
70
|
import { callerIdentityOf } from "../../pipeline/interceptors/auth.js";
|
|
72
71
|
import { RequestContext } from "../../pipeline/request-context.js";
|
|
72
|
+
import { newAuthorizeStep } from "../../pipeline/steps/authorize.js";
|
|
73
73
|
import {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} from "../../pipeline/steps/authorize.js";
|
|
74
|
+
loadedTargetAsMethod,
|
|
75
|
+
newAuthorizeResolvedTargetStep,
|
|
76
|
+
} from "../../pipeline/steps/authorize-resolved-target.js";
|
|
77
|
+
import { versionHistoryTarget } from "../../pipeline/steps/version-history.js";
|
|
77
78
|
import { newAuthorizeVisibilityTransitionStep } from "../../pipeline/steps/visibility-gates.js";
|
|
78
79
|
import {
|
|
79
80
|
newCleanupIamPoliciesStep,
|
|
@@ -677,6 +678,12 @@ async function getByReference(
|
|
|
677
678
|
)
|
|
678
679
|
.addStep(newValidateProtoStep())
|
|
679
680
|
.addStep(newLoadSkillByReferenceStep(deps.store))
|
|
681
|
+
.addStep(
|
|
682
|
+
newAuthorizeResolvedTargetStep(
|
|
683
|
+
deps.authorizer,
|
|
684
|
+
loadedTargetAsMethod(SkillQueryController.method.get),
|
|
685
|
+
),
|
|
686
|
+
)
|
|
680
687
|
.build()
|
|
681
688
|
.execute(reqCtx);
|
|
682
689
|
return reqCtx.get(TARGET_RESOURCE_KEY) as Skill;
|
|
@@ -808,26 +815,20 @@ async function listVersions(
|
|
|
808
815
|
)
|
|
809
816
|
.addStep(newValidateProtoStep())
|
|
810
817
|
.addStep(newResolveSkillBySlugStep(deps.store))
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
await authorizeResolvedResource(
|
|
820
|
-
deps.authorizer,
|
|
821
|
-
stepCtx.callerIdentity,
|
|
822
|
-
{
|
|
823
|
-
permission: IamPermission.can_view,
|
|
824
|
-
resourceKind: ApiResourceKind.skill,
|
|
825
|
-
resourceId: stepCtx.get(LIST_VERSIONS_SKILL_ID_KEY) as string,
|
|
826
|
-
},
|
|
818
|
+
// The Java SkillListVersionsHandler's mid-chain can_view on the RESOLVED
|
|
819
|
+
// skill id; the copy is the Java handler's byte-pinned error_msg, and an
|
|
820
|
+
// unknown slug was already answered NOT_FOUND by the resolve step above.
|
|
821
|
+
.addStep(
|
|
822
|
+
newAuthorizeResolvedTargetStep(
|
|
823
|
+
deps.authorizer,
|
|
824
|
+
versionHistoryTarget(
|
|
825
|
+
ApiResourceKind.skill,
|
|
827
826
|
"unauthorized to view skill version history",
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
827
|
+
LIST_VERSIONS_SKILL_ID_KEY,
|
|
828
|
+
),
|
|
829
|
+
"AuthorizeResolvedSkill",
|
|
830
|
+
),
|
|
831
|
+
)
|
|
831
832
|
.addStep(newLoadAndMapVersionsStep(deps.store))
|
|
832
833
|
.build()
|
|
833
834
|
.execute(reqCtx);
|