@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
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pins the session domain against Go's pkg/domain/session tests — through
|
|
3
3
|
* the REAL stack: a composed server on an ephemeral port, a native gRPC
|
|
4
|
-
* client, the full interceptor chain
|
|
5
|
-
* agentinstance CREATE edge (session create's default-instance self-heal
|
|
6
|
-
* runs through the router transport).
|
|
4
|
+
* client, and the full interceptor chain.
|
|
7
5
|
*
|
|
8
6
|
* The load-bearing pins:
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
* session
|
|
12
|
-
*
|
|
13
|
-
* not-public arms carry Go WrapError's exact double-wrapped copy;
|
|
7
|
+
* - an empty agent_instance_id is the built-in assistant: create stores
|
|
8
|
+
* it empty (nothing resolves it into an instance), an explicit id is
|
|
9
|
+
* kept as given, and a session may gain an agent or drop back to the
|
|
10
|
+
* assistant on update — the instance is not an immutable field;
|
|
14
11
|
* - harness immutability locks only once harness_state_id is non-empty,
|
|
15
12
|
* with UNSPECIFIED==NATIVE equivalence in both directions and the
|
|
16
13
|
* exact FAILED_PRECONDITION copy;
|
|
@@ -39,11 +36,8 @@ import { createGrpcTransport } from "@connectrpc/connect-node";
|
|
|
39
36
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
40
37
|
|
|
41
38
|
import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
|
|
42
|
-
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
43
39
|
import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
44
40
|
import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
45
|
-
import { AgentInstanceSchema } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/api_pb";
|
|
46
|
-
import { AgentInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/query_pb";
|
|
47
41
|
import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
|
|
48
42
|
import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
|
|
49
43
|
import { SessionSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
@@ -53,7 +47,6 @@ import {
|
|
|
53
47
|
ExecutionTarget,
|
|
54
48
|
Harness,
|
|
55
49
|
} from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
56
|
-
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
57
50
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
58
51
|
|
|
59
52
|
import { loadConfig } from "../../../boot/config.js";
|
|
@@ -70,10 +63,6 @@ import {
|
|
|
70
63
|
ROUTING_GLOBAL,
|
|
71
64
|
newConfigFromEnv,
|
|
72
65
|
} from "../../agentexecution/temporal/config.js";
|
|
73
|
-
import {
|
|
74
|
-
DEFAULT_AGENT_LABEL,
|
|
75
|
-
DEFAULT_AGENT_LABEL_VALUE,
|
|
76
|
-
} from "../../agent/defaultagent.js";
|
|
77
66
|
import { newValidateExecutionTargetImmutabilityStep } from "../steps.js";
|
|
78
67
|
|
|
79
68
|
const silentLogger = createLogger({
|
|
@@ -92,7 +81,6 @@ let dir: string;
|
|
|
92
81
|
let server: ComposedServer;
|
|
93
82
|
let transport: Transport;
|
|
94
83
|
let agentCommand: Client<typeof AgentCommandController>;
|
|
95
|
-
let instanceQuery: Client<typeof AgentInstanceQueryController>;
|
|
96
84
|
let command: Client<typeof SessionCommandController>;
|
|
97
85
|
let query: Client<typeof SessionQueryController>;
|
|
98
86
|
|
|
@@ -120,7 +108,6 @@ beforeAll(async () => {
|
|
|
120
108
|
const port = await server.start();
|
|
121
109
|
transport = createGrpcTransport({ baseUrl: `http://127.0.0.1:${port}` });
|
|
122
110
|
agentCommand = createClient(AgentCommandController, transport);
|
|
123
|
-
instanceQuery = createClient(AgentInstanceQueryController, transport);
|
|
124
111
|
command = createClient(SessionCommandController, transport);
|
|
125
112
|
query = createClient(SessionQueryController, transport);
|
|
126
113
|
});
|
|
@@ -141,33 +128,6 @@ async function createAgent(name: string) {
|
|
|
141
128
|
});
|
|
142
129
|
}
|
|
143
130
|
|
|
144
|
-
/**
|
|
145
|
-
* Stamps the default-agent label (and optionally visibility_public)
|
|
146
|
-
* directly on the stored agent row — the reserved stigmer.ai/* label is
|
|
147
|
-
* operator-seeded state, not something the OSS write path guards, and the
|
|
148
|
-
* direct write keeps the test independent of create-time visibility rules.
|
|
149
|
-
*/
|
|
150
|
-
async function markDefaultAgent(
|
|
151
|
-
agentId: string,
|
|
152
|
-
opts: { public: boolean },
|
|
153
|
-
): Promise<void> {
|
|
154
|
-
const stored = await server.store.getResource(
|
|
155
|
-
ApiResourceKind.agent,
|
|
156
|
-
agentId,
|
|
157
|
-
AgentSchema,
|
|
158
|
-
);
|
|
159
|
-
stored.metadata!.labels[DEFAULT_AGENT_LABEL] = DEFAULT_AGENT_LABEL_VALUE;
|
|
160
|
-
if (opts.public) {
|
|
161
|
-
stored.metadata!.visibility = ApiResourceVisibility.visibility_public;
|
|
162
|
-
}
|
|
163
|
-
await server.store.saveResource(
|
|
164
|
-
ApiResourceKind.agent,
|
|
165
|
-
agentId,
|
|
166
|
-
AgentSchema,
|
|
167
|
-
stored,
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
131
|
let sessionCounter = 0;
|
|
172
132
|
async function createSession(
|
|
173
133
|
spec: Partial<Omit<SessionSpec, "$typeName">> = {},
|
|
@@ -252,108 +212,36 @@ async function grpcError(run: () => Promise<unknown>): Promise<ConnectError> {
|
|
|
252
212
|
}
|
|
253
213
|
}
|
|
254
214
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
expect(error.rawMessage).toBe(
|
|
263
|
-
"No default agent available. Ensure an agent with label " +
|
|
264
|
-
"stigmer.ai/default-agent=true and visibility_public exists: " +
|
|
265
|
-
"no default agent available on this platform: " +
|
|
266
|
-
"no agent labeled stigmer.ai/default-agent=true",
|
|
267
|
-
);
|
|
215
|
+
describe("session create and update — the built-in assistant", () => {
|
|
216
|
+
it("stores an empty agent_instance_id as given: no agent is resolved for the session", async () => {
|
|
217
|
+
const session = await createSession({});
|
|
218
|
+
expect(session.spec?.agentInstanceId).toBe("");
|
|
219
|
+
const fetched = await query.get({ value: session.metadata!.id });
|
|
220
|
+
expect(fetched.spec?.agentInstanceId).toBe("");
|
|
221
|
+
await command.delete({ value: session.metadata!.id });
|
|
268
222
|
});
|
|
269
223
|
|
|
270
|
-
it("
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const error = await grpcError(() => createSession({}));
|
|
275
|
-
expect(error.code).toBe(Code.FailedPrecondition);
|
|
276
|
-
expect(error.rawMessage).toBe(
|
|
277
|
-
"Default agent exists but is not visibility_public: " +
|
|
278
|
-
"agents labeled stigmer.ai/default-agent=true exist but none is visibility_public",
|
|
279
|
-
);
|
|
280
|
-
} finally {
|
|
281
|
-
await agentCommand.delete({ value: agent.metadata!.id });
|
|
282
|
-
}
|
|
224
|
+
it("keeps an explicit agent_instance_id as given", async () => {
|
|
225
|
+
const session = await createSession({ agentInstanceId: "ain_explicit" });
|
|
226
|
+
expect(session.spec?.agentInstanceId).toBe("ain_explicit");
|
|
227
|
+
await command.delete({ value: session.metadata!.id });
|
|
283
228
|
});
|
|
284
229
|
|
|
285
|
-
it("
|
|
286
|
-
const
|
|
287
|
-
const defaultInstanceId = agent.status!.defaultInstanceId;
|
|
288
|
-
expect(defaultInstanceId).not.toBe("");
|
|
289
|
-
await markDefaultAgent(agent.metadata!.id, { public: true });
|
|
290
|
-
try {
|
|
291
|
-
const session = await createSession({});
|
|
292
|
-
// The resolve step wrote newState.spec (the clone Persist saves) —
|
|
293
|
-
// the id survives the round trip to storage.
|
|
294
|
-
expect(session.spec?.agentInstanceId).toBe(defaultInstanceId);
|
|
295
|
-
const fetched = await query.get({ value: session.metadata!.id });
|
|
296
|
-
expect(fetched.spec?.agentInstanceId).toBe(defaultInstanceId);
|
|
297
|
-
await command.delete({ value: session.metadata!.id });
|
|
298
|
-
} finally {
|
|
299
|
-
await agentCommand.delete({ value: agent.metadata!.id });
|
|
300
|
-
}
|
|
301
|
-
});
|
|
230
|
+
it("lets a conversation gain an agent and drop back to the assistant on update", async () => {
|
|
231
|
+
const session = await createSession({});
|
|
302
232
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// the legacy shape the self-heal path exists for.
|
|
306
|
-
const agentId = "agt_sessiontest_selfheal";
|
|
307
|
-
const seeded = create(AgentSchema, {
|
|
308
|
-
apiVersion: API_VERSION,
|
|
309
|
-
kind: "Agent",
|
|
310
|
-
metadata: {
|
|
311
|
-
id: agentId,
|
|
312
|
-
name: "Self Heal Default Agent",
|
|
313
|
-
slug: "self-heal-default-agent",
|
|
314
|
-
org: ORG,
|
|
315
|
-
visibility: ApiResourceVisibility.visibility_public,
|
|
316
|
-
labels: { [DEFAULT_AGENT_LABEL]: DEFAULT_AGENT_LABEL_VALUE },
|
|
317
|
-
},
|
|
318
|
-
spec: { instructions: "seeded for the self-heal path" },
|
|
319
|
-
});
|
|
320
|
-
await server.store.saveResource(
|
|
321
|
-
ApiResourceKind.agent,
|
|
322
|
-
agentId,
|
|
323
|
-
AgentSchema,
|
|
324
|
-
seeded,
|
|
233
|
+
const withAgent = await command.update(
|
|
234
|
+
updateInput(session, { agentInstanceId: "ain_picked" }),
|
|
325
235
|
);
|
|
326
|
-
|
|
327
|
-
const session = await createSession({});
|
|
328
|
-
const resolvedId = session.spec?.agentInstanceId ?? "";
|
|
329
|
-
expect(resolvedId).not.toBe("");
|
|
330
|
-
|
|
331
|
-
// The created instance is real (rode the in-process CREATE edge and
|
|
332
|
-
// its full pipeline) and follows the defaultinstance factory shape.
|
|
333
|
-
const instance = await instanceQuery.get({ value: resolvedId });
|
|
334
|
-
expect(instance.spec?.agentId).toBe(agentId);
|
|
335
|
-
expect(instance.metadata?.slug).toBe("self-heal-default-agent-default");
|
|
336
|
-
|
|
337
|
-
// The agent's server-owned pointer was persisted (explicit agent
|
|
338
|
-
// kind — the pipeline's own ctx kind is session).
|
|
339
|
-
const storedAgent = await server.store.getResource(
|
|
340
|
-
ApiResourceKind.agent,
|
|
341
|
-
agentId,
|
|
342
|
-
AgentSchema,
|
|
343
|
-
);
|
|
344
|
-
expect(storedAgent.status?.defaultInstanceId).toBe(resolvedId);
|
|
236
|
+
expect(withAgent.spec?.agentInstanceId).toBe("ain_picked");
|
|
345
237
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
238
|
+
const dropped = await command.update(
|
|
239
|
+
updateInput(withAgent, { agentInstanceId: "" }),
|
|
240
|
+
);
|
|
241
|
+
expect(dropped.spec?.agentInstanceId).toBe("");
|
|
242
|
+
const fetched = await query.get({ value: session.metadata!.id });
|
|
243
|
+
expect(fetched.spec?.agentInstanceId).toBe("");
|
|
351
244
|
|
|
352
|
-
it("is a no-op when agent_instance_id is provided (no default agent needed)", async () => {
|
|
353
|
-
// No labeled agent exists at this point; an explicit id must not
|
|
354
|
-
// trigger resolution.
|
|
355
|
-
const session = await createSession({ agentInstanceId: "ain_explicit" });
|
|
356
|
-
expect(session.spec?.agentInstanceId).toBe("ain_explicit");
|
|
357
245
|
await command.delete({ value: session.metadata!.id });
|
|
358
246
|
});
|
|
359
247
|
});
|
|
@@ -716,67 +604,3 @@ describe("session delete — active-execution guard and cascade", () => {
|
|
|
716
604
|
await command.delete({ value: survivor.metadata!.id });
|
|
717
605
|
});
|
|
718
606
|
});
|
|
719
|
-
|
|
720
|
-
describe("session create — CreateAsSystem failure wire contract (oss#852)", () => {
|
|
721
|
-
it("answers the inner code with Go's %w-wrapped transport-formatted message", async () => {
|
|
722
|
-
// A labeled public default agent with NO status.default_instance_id
|
|
723
|
-
// (the self-heal shape) whose deterministic default-instance slug is
|
|
724
|
-
// already occupied: the in-process CreateAsSystem hits CheckDuplicate's
|
|
725
|
-
// AlreadyExists. Go wraps that error with fmt.Errorf("%w"), so the
|
|
726
|
-
// wire message embeds grpc-go's `rpc error: code = X desc = ...`
|
|
727
|
-
// rendering of the inner error — the leak filed as stigmer/stigmer#852,
|
|
728
|
-
// mirrored byte-for-byte until the both-editions post-cutover fix.
|
|
729
|
-
const agentId = "agt_wrap_session";
|
|
730
|
-
const seeded = create(AgentSchema, {
|
|
731
|
-
apiVersion: API_VERSION,
|
|
732
|
-
kind: "Agent",
|
|
733
|
-
metadata: {
|
|
734
|
-
id: agentId,
|
|
735
|
-
name: "Wrap Mirror Default Agent",
|
|
736
|
-
slug: "wrap-mirror-default-agent",
|
|
737
|
-
org: ORG,
|
|
738
|
-
visibility: ApiResourceVisibility.visibility_public,
|
|
739
|
-
labels: { [DEFAULT_AGENT_LABEL]: DEFAULT_AGENT_LABEL_VALUE },
|
|
740
|
-
},
|
|
741
|
-
spec: { instructions: "seeded for the wrapped-error mirror test" },
|
|
742
|
-
});
|
|
743
|
-
await server.store.saveResource(
|
|
744
|
-
ApiResourceKind.agent,
|
|
745
|
-
agentId,
|
|
746
|
-
AgentSchema,
|
|
747
|
-
seeded,
|
|
748
|
-
);
|
|
749
|
-
const occupier = create(AgentInstanceSchema, {
|
|
750
|
-
apiVersion: API_VERSION,
|
|
751
|
-
kind: "AgentInstance",
|
|
752
|
-
metadata: {
|
|
753
|
-
id: "ain_wrap_occupied",
|
|
754
|
-
name: "wrap-mirror-default-agent-default",
|
|
755
|
-
slug: "wrap-mirror-default-agent-default",
|
|
756
|
-
org: ORG,
|
|
757
|
-
},
|
|
758
|
-
spec: { agentId },
|
|
759
|
-
});
|
|
760
|
-
await server.store.saveResource(
|
|
761
|
-
ApiResourceKind.agent_instance,
|
|
762
|
-
"ain_wrap_occupied",
|
|
763
|
-
AgentInstanceSchema,
|
|
764
|
-
occupier,
|
|
765
|
-
);
|
|
766
|
-
|
|
767
|
-
try {
|
|
768
|
-
const error = await grpcError(() => createSession({}));
|
|
769
|
-
expect(error.code).toBe(Code.AlreadyExists);
|
|
770
|
-
expect(error.rawMessage).toBe(
|
|
771
|
-
"failed to create default instance for default agent: rpc error: " +
|
|
772
|
-
"code = AlreadyExists desc = AgentInstance already exists: slug " +
|
|
773
|
-
"'wrap-mirror-default-agent-default' in org 'acme' " +
|
|
774
|
-
"(id: ain_wrap_occupied)",
|
|
775
|
-
);
|
|
776
|
-
} finally {
|
|
777
|
-
// The cascade sweeps the occupying instance (spec.agent_id match)
|
|
778
|
-
// and removes the default-agent label with the agent.
|
|
779
|
-
await agentCommand.delete({ value: agentId });
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
});
|
|
@@ -110,11 +110,9 @@ import {
|
|
|
110
110
|
newListAllSessionsStep,
|
|
111
111
|
newRecordHarnessStateHistoryStep,
|
|
112
112
|
newRejectDeleteWithActiveExecutionsStep,
|
|
113
|
-
newResolveDefaultAgentInstanceStep,
|
|
114
113
|
newValidateExecutionTargetImmutabilityStep,
|
|
115
114
|
newValidateHarnessImmutabilityStep,
|
|
116
115
|
} from "./steps.js";
|
|
117
|
-
import type { AgentInstanceCreatorProvider } from "./steps.js";
|
|
118
116
|
|
|
119
117
|
export interface SessionControllerDeps {
|
|
120
118
|
readonly store: Store;
|
|
@@ -129,12 +127,6 @@ export interface SessionControllerDeps {
|
|
|
129
127
|
* same deployment default dispatch uses (oss#397).
|
|
130
128
|
*/
|
|
131
129
|
readonly temporalConfig: AgentExecutionTemporalConfig;
|
|
132
|
-
/**
|
|
133
|
-
* The agentinstance in-process CREATE edge — a lazy provider because the
|
|
134
|
-
* routes↔clients definition cycle resolves at request time (the ratified
|
|
135
|
-
* DI story, DD-002).
|
|
136
|
-
*/
|
|
137
|
-
readonly agentInstanceCreator: AgentInstanceCreatorProvider;
|
|
138
130
|
/** The composed slot registrations — this domain's create slot (O4). */
|
|
139
131
|
readonly gateSteps: ResolvedGateSteps;
|
|
140
132
|
/**
|
|
@@ -177,23 +169,19 @@ function kindOf(ctx: HandlerContext): ApiResourceKind {
|
|
|
177
169
|
}
|
|
178
170
|
|
|
179
171
|
/**
|
|
180
|
-
* Create — chain per Go buildCreatePipeline.
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* the
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* default-instance creation INSIDE the resolution step still precedes it —
|
|
189
|
-
* the inherited pre-gate side effect recorded below, unchanged here.
|
|
172
|
+
* Create — chain per Go buildCreatePipeline. AuthorizeRunTarget (the run
|
|
173
|
+
* gate, P1 sp.run-gate) runs right after Authorize: the instance the
|
|
174
|
+
* session binds to is the caller's own spec, so a caller who may not run
|
|
175
|
+
* that instance is refused before validation reads anything further and
|
|
176
|
+
* before any step the chain owns side-effects. An empty agent_instance_id
|
|
177
|
+
* is the built-in assistant, for which the gate makes no target check:
|
|
178
|
+
* Authorize's can_create_session on the organization already admitted the
|
|
179
|
+
* conversation (sessionRunTarget's header).
|
|
190
180
|
*
|
|
191
181
|
* The pre-side-effect gate slot splices before Persist, after the last
|
|
192
182
|
* pure step (O4 plan-gate ruling Q2, mirroring the Java baseline's
|
|
193
|
-
* post-resolution gate position).
|
|
194
|
-
*
|
|
195
|
-
* created default instance behind; inherited Java semantics, not a new
|
|
196
|
-
* compromise.
|
|
183
|
+
* post-resolution gate position). Every step above it is pure, so a gate
|
|
184
|
+
* refusal leaves nothing behind.
|
|
197
185
|
*/
|
|
198
186
|
async function createSession(
|
|
199
187
|
deps: SessionControllerDeps,
|
|
@@ -213,14 +201,6 @@ async function createSession(
|
|
|
213
201
|
.addStep(
|
|
214
202
|
newAuthorizeStep(SessionCommandController.method.create, deps.authorizer),
|
|
215
203
|
)
|
|
216
|
-
.addStep(
|
|
217
|
-
newResolveDefaultAgentInstanceStep(
|
|
218
|
-
deps.store,
|
|
219
|
-
deps.agentInstanceCreator,
|
|
220
|
-
deps.logger,
|
|
221
|
-
deps.authorizationLifecycle,
|
|
222
|
-
),
|
|
223
|
-
)
|
|
224
204
|
.addStep(newAuthorizeRunTargetStep(deps.authorizer, sessionRunTarget))
|
|
225
205
|
.addStep(newValidateProtoStep())
|
|
226
206
|
.addStep(newValidateVisibilityStep())
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The session run-target resolver (P1 sp.run-gate): a session
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The session run-target resolver (P1 sp.run-gate): a session bound to an
|
|
3
|
+
* agent instance has that instance as its run target —
|
|
4
|
+
* agent_instance#can_execute on spec.agent_instance_id.
|
|
5
5
|
*
|
|
6
|
-
* Pure over the record being built.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* Pure over the record being built. An empty id is the built-in assistant
|
|
7
|
+
* (session/v1/spec.proto): there is no blueprint to spend, so the answer is
|
|
8
|
+
* "no target" and the gate makes no check. What admits the conversation is
|
|
9
|
+
* the Authorize step ahead of the gate — can_create_session on the
|
|
10
|
+
* organization — and each turn is admitted by the session's own
|
|
11
|
+
* can_create_execution_in on the execution chain.
|
|
11
12
|
*/
|
|
12
13
|
import type { Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
13
14
|
|