@stigmer/react 0.0.68 → 0.0.69
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/README.md +1 -1
- package/composer/SessionComposer.d.ts.map +1 -1
- package/composer/SessionComposer.js +12 -3
- package/composer/SessionComposer.js.map +1 -1
- package/demo/__tests__/demo-client.test.d.ts +2 -0
- package/demo/__tests__/demo-client.test.d.ts.map +1 -0
- package/demo/__tests__/demo-client.test.js +133 -0
- package/demo/__tests__/demo-client.test.js.map +1 -0
- package/demo/__tests__/fixtures.test.d.ts +2 -0
- package/demo/__tests__/fixtures.test.d.ts.map +1 -0
- package/demo/__tests__/fixtures.test.js +135 -0
- package/demo/__tests__/fixtures.test.js.map +1 -0
- package/demo/__tests__/samples.test.d.ts +2 -0
- package/demo/__tests__/samples.test.d.ts.map +1 -0
- package/demo/__tests__/samples.test.js +152 -0
- package/demo/__tests__/samples.test.js.map +1 -0
- package/demo/client.d.ts +29 -0
- package/demo/client.d.ts.map +1 -0
- package/demo/client.js +52 -0
- package/demo/client.js.map +1 -0
- package/demo/fixtures.d.ts +190 -0
- package/demo/fixtures.d.ts.map +1 -0
- package/demo/fixtures.js +263 -0
- package/demo/fixtures.js.map +1 -0
- package/demo/index.d.ts +6 -0
- package/demo/index.d.ts.map +1 -0
- package/demo/index.js +6 -0
- package/demo/index.js.map +1 -0
- package/demo/samples.d.ts +166 -0
- package/demo/samples.d.ts.map +1 -0
- package/demo/samples.js +308 -0
- package/demo/samples.js.map +1 -0
- package/demo/transport.d.ts +59 -0
- package/demo/transport.d.ts.map +1 -0
- package/demo/transport.js +75 -0
- package/demo/transport.js.map +1 -0
- package/demo/types.d.ts +62 -0
- package/demo/types.d.ts.map +1 -0
- package/demo/types.js +16 -0
- package/demo/types.js.map +1 -0
- package/environment/EnvVarForm.d.ts.map +1 -1
- package/environment/EnvVarForm.js +1 -1
- package/environment/EnvVarForm.js.map +1 -1
- package/environment/__tests__/systemEnvVars.test.d.ts +2 -0
- package/environment/__tests__/systemEnvVars.test.d.ts.map +1 -0
- package/environment/__tests__/systemEnvVars.test.js +76 -0
- package/environment/__tests__/systemEnvVars.test.js.map +1 -0
- package/environment/index.d.ts +1 -0
- package/environment/index.d.ts.map +1 -1
- package/environment/index.js +1 -0
- package/environment/index.js.map +1 -1
- package/environment/systemEnvVars.d.ts +52 -0
- package/environment/systemEnvVars.d.ts.map +1 -0
- package/environment/systemEnvVars.js +91 -0
- package/environment/systemEnvVars.js.map +1 -0
- package/execution/ApprovalCard.d.ts.map +1 -1
- package/execution/ApprovalCard.js +3 -3
- package/execution/ApprovalCard.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/internal/Tabs.d.ts +41 -0
- package/internal/Tabs.d.ts.map +1 -0
- package/internal/Tabs.js +65 -0
- package/internal/Tabs.js.map +1 -0
- package/mcp-server/McpServerDetailView.d.ts +33 -7
- package/mcp-server/McpServerDetailView.d.ts.map +1 -1
- package/mcp-server/McpServerDetailView.js +53 -37
- package/mcp-server/McpServerDetailView.js.map +1 -1
- package/mcp-server/useMcpServerCredentials.d.ts.map +1 -1
- package/mcp-server/useMcpServerCredentials.js +2 -1
- package/mcp-server/useMcpServerCredentials.js.map +1 -1
- package/models/index.d.ts +1 -1
- package/models/index.d.ts.map +1 -1
- package/models/index.js +1 -1
- package/models/index.js.map +1 -1
- package/models/registry.d.ts +10 -0
- package/models/registry.d.ts.map +1 -1
- package/models/registry.js +13 -0
- package/models/registry.js.map +1 -1
- package/models/useModelRegistry.d.ts.map +1 -1
- package/models/useModelRegistry.js +7 -3
- package/models/useModelRegistry.js.map +1 -1
- package/package.json +9 -5
- package/src/composer/SessionComposer.tsx +21 -3
- package/src/demo/__tests__/demo-client.test.tsx +213 -0
- package/src/demo/__tests__/fixtures.test.ts +214 -0
- package/src/demo/__tests__/samples.test.ts +171 -0
- package/src/demo/client.ts +78 -0
- package/src/demo/fixtures.ts +401 -0
- package/src/demo/index.ts +12 -0
- package/src/demo/samples.ts +470 -0
- package/src/demo/transport.ts +116 -0
- package/src/demo/types.ts +69 -0
- package/src/environment/EnvVarForm.tsx +1 -0
- package/src/environment/__tests__/systemEnvVars.test.ts +120 -0
- package/src/environment/index.ts +6 -0
- package/src/environment/systemEnvVars.ts +104 -0
- package/src/execution/ApprovalCard.tsx +4 -0
- package/src/index.ts +5 -1
- package/src/internal/Tabs.tsx +166 -0
- package/src/mcp-server/McpServerDetailView.tsx +273 -204
- package/src/mcp-server/useMcpServerCredentials.ts +4 -1
- package/src/models/index.ts +1 -1
- package/src/models/registry.ts +14 -0
- package/src/models/useModelRegistry.ts +7 -2
- package/styles.css +1 -1
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
|
|
2
|
+
import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
|
|
3
|
+
import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
|
|
4
|
+
import { AgentExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/query_pb";
|
|
5
|
+
import { AgentInstanceCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/command_pb";
|
|
6
|
+
import { AgentInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/query_pb";
|
|
7
|
+
import { EnvironmentCommandController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/command_pb";
|
|
8
|
+
import { EnvironmentQueryController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/query_pb";
|
|
9
|
+
import { McpServerCommandController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/command_pb";
|
|
10
|
+
import { McpServerQueryController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/query_pb";
|
|
11
|
+
import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
|
|
12
|
+
import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
|
|
13
|
+
import { SkillCommandController } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/command_pb";
|
|
14
|
+
import { SkillQueryController } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/query_pb";
|
|
15
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
16
|
+
import { ApiKeyCommandController } from "@stigmer/protos/ai/stigmer/iam/apikey/v1/command_pb";
|
|
17
|
+
import { ApiKeyQueryController } from "@stigmer/protos/ai/stigmer/iam/apikey/v1/query_pb";
|
|
18
|
+
import { GitHubService } from "@stigmer/protos/ai/stigmer/platform/github/v1/service_pb";
|
|
19
|
+
import { SearchService } from "@stigmer/protos/ai/stigmer/search/v1/query_pb";
|
|
20
|
+
import { OrganizationCommandController } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/command_pb";
|
|
21
|
+
import type {
|
|
22
|
+
DemoScenario,
|
|
23
|
+
FixtureEntry,
|
|
24
|
+
StreamFixtureHandler,
|
|
25
|
+
UnaryFixtureHandler,
|
|
26
|
+
} from "./types";
|
|
27
|
+
import { rpcKey } from "./types";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A fixture specification returned by fixture entry helpers.
|
|
31
|
+
*
|
|
32
|
+
* Pass one or more specs to {@link buildScenario} to construct a
|
|
33
|
+
* {@link DemoScenario} ready for {@link createDemoClient}.
|
|
34
|
+
*
|
|
35
|
+
* The `searchResourceKind` field is set automatically by search-backed
|
|
36
|
+
* helpers (`fixtures.agent.list`, `fixtures.skill.list`,
|
|
37
|
+
* `fixtures.mcpServer.list`). Do not set it manually.
|
|
38
|
+
*/
|
|
39
|
+
export interface FixtureSpec {
|
|
40
|
+
readonly key: string;
|
|
41
|
+
readonly entry: FixtureEntry;
|
|
42
|
+
readonly searchResourceKind?: ApiResourceKind;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Internal helpers
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
function unarySpec(
|
|
50
|
+
service: { readonly typeName: string },
|
|
51
|
+
method: string,
|
|
52
|
+
handler: UnaryFixtureHandler,
|
|
53
|
+
): FixtureSpec {
|
|
54
|
+
return { key: rpcKey(service, method), entry: { unary: handler } };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function streamSpec(
|
|
58
|
+
service: { readonly typeName: string },
|
|
59
|
+
method: string,
|
|
60
|
+
handler: StreamFixtureHandler,
|
|
61
|
+
): FixtureSpec {
|
|
62
|
+
return { key: rpcKey(service, method), entry: { stream: handler } };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function searchListSpec(
|
|
66
|
+
kind: ApiResourceKind,
|
|
67
|
+
handler: UnaryFixtureHandler,
|
|
68
|
+
): FixtureSpec {
|
|
69
|
+
return {
|
|
70
|
+
key: rpcKey(SearchService, "search"),
|
|
71
|
+
entry: { unary: handler },
|
|
72
|
+
searchResourceKind: kind,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Fixture entry helpers — organized by resource domain
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Fixture entry helpers mirroring the `Stigmer` SDK client shape.
|
|
82
|
+
*
|
|
83
|
+
* Each method wraps a user-provided handler into a {@link FixtureSpec}
|
|
84
|
+
* that {@link buildScenario} assembles into a {@link DemoScenario}.
|
|
85
|
+
*
|
|
86
|
+
* Method names match the SDK client methods (e.g. `fixtures.session.get`
|
|
87
|
+
* mirrors `client.session.get`). JSDoc on each method documents which
|
|
88
|
+
* React hooks consume that RPC.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { fixtures, buildScenario, createDemoClient } from "@stigmer/react/demo";
|
|
93
|
+
*
|
|
94
|
+
* const scenario = buildScenario(
|
|
95
|
+
* fixtures.session.get(() => mySession),
|
|
96
|
+
* fixtures.agentExecution.listBySession(() => myExecutionList),
|
|
97
|
+
* fixtures.agentExecution.subscribe(() => [snapshot1, snapshot2]),
|
|
98
|
+
* );
|
|
99
|
+
* const client = createDemoClient(scenario);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export const fixtures = {
|
|
103
|
+
// ---- Session ----
|
|
104
|
+
|
|
105
|
+
session: {
|
|
106
|
+
/** Hooks: `useSession`, `useSessionConversation` */
|
|
107
|
+
get: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
108
|
+
unarySpec(SessionQueryController, "get", handler),
|
|
109
|
+
|
|
110
|
+
/** Hooks: `useSessionList` */
|
|
111
|
+
list: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
112
|
+
unarySpec(SessionQueryController, "list", handler),
|
|
113
|
+
|
|
114
|
+
/** Hooks: `useCreateSession`, `useTriggerApprovalPolicySession` */
|
|
115
|
+
create: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
116
|
+
unarySpec(SessionCommandController, "create", handler),
|
|
117
|
+
|
|
118
|
+
/** Hooks: `useUpdateSession`, `useSessionConversation` */
|
|
119
|
+
update: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
120
|
+
unarySpec(SessionCommandController, "update", handler),
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
// ---- Agent Execution ----
|
|
124
|
+
|
|
125
|
+
agentExecution: {
|
|
126
|
+
/** Hooks: `useCreateAgentExecution`, `useTriggerApprovalPolicySession` */
|
|
127
|
+
create: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
128
|
+
unarySpec(AgentExecutionCommandController, "create", handler),
|
|
129
|
+
|
|
130
|
+
/** Hooks: `useSessionExecutions`, `useSessionConversation` */
|
|
131
|
+
listBySession: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
132
|
+
unarySpec(AgentExecutionQueryController, "listBySession", handler),
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Hooks: `useExecutionStream`, `useSessionConversation`
|
|
136
|
+
*
|
|
137
|
+
* The handler returns an **array** of `AgentExecution` snapshots that
|
|
138
|
+
* the transport yields as a server stream.
|
|
139
|
+
*/
|
|
140
|
+
subscribe: (handler: StreamFixtureHandler): FixtureSpec =>
|
|
141
|
+
streamSpec(AgentExecutionQueryController, "subscribe", handler),
|
|
142
|
+
|
|
143
|
+
/** Hooks: `useSubmitApproval`, `useSessionConversation` */
|
|
144
|
+
submitApproval: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
145
|
+
unarySpec(AgentExecutionCommandController, "submitApproval", handler),
|
|
146
|
+
|
|
147
|
+
/** Hooks: `useArtifactContent`, `useDetectSkillPackage` */
|
|
148
|
+
getArtifactContent: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
149
|
+
unarySpec(AgentExecutionQueryController, "getArtifactContent", handler),
|
|
150
|
+
|
|
151
|
+
/** Hooks: `useAttachments`, `useTriggerApprovalPolicySession` */
|
|
152
|
+
uploadAttachment: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
153
|
+
unarySpec(AgentExecutionCommandController, "uploadAttachment", handler),
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
// ---- Agent ----
|
|
157
|
+
|
|
158
|
+
agent: {
|
|
159
|
+
/** Hooks: `useAgentRefFromSession` */
|
|
160
|
+
get: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
161
|
+
unarySpec(AgentQueryController, "get", handler),
|
|
162
|
+
|
|
163
|
+
/** Hooks: `useAgent`, `useCreateSession`, `useAgentSetup`, `useTriggerApprovalPolicySession` */
|
|
164
|
+
getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
165
|
+
unarySpec(AgentQueryController, "getByReference", handler),
|
|
166
|
+
|
|
167
|
+
/** Hooks: `useDefaultAgent` */
|
|
168
|
+
getDefault: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
169
|
+
unarySpec(AgentQueryController, "getDefault", handler),
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Hooks: `useAgentList`, `useAgentSearch`, `useAgentCount`
|
|
173
|
+
*
|
|
174
|
+
* Routes through `SearchService` — use {@link buildScenario} to avoid
|
|
175
|
+
* key collisions with `fixtures.skill.list` and `fixtures.mcpServer.list`.
|
|
176
|
+
*/
|
|
177
|
+
list: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
178
|
+
searchListSpec(ApiResourceKind.agent, handler),
|
|
179
|
+
|
|
180
|
+
/** Hooks: `useApplyResource` */
|
|
181
|
+
apply: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
182
|
+
unarySpec(AgentCommandController, "apply", handler),
|
|
183
|
+
|
|
184
|
+
/** Hooks: `useUpdateVisibility` (when kind is Agent) */
|
|
185
|
+
updateVisibility: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
186
|
+
unarySpec(AgentCommandController, "updateVisibility", handler),
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
// ---- Skill ----
|
|
190
|
+
|
|
191
|
+
skill: {
|
|
192
|
+
/** Hooks: `useSkill` */
|
|
193
|
+
getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
194
|
+
unarySpec(SkillQueryController, "getByReference", handler),
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Hooks: `useSkillList`, `useSkillSearch`, `useSkillCount`
|
|
198
|
+
*
|
|
199
|
+
* Routes through `SearchService` — use {@link buildScenario} to avoid
|
|
200
|
+
* key collisions with `fixtures.agent.list` and `fixtures.mcpServer.list`.
|
|
201
|
+
*/
|
|
202
|
+
list: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
203
|
+
searchListSpec(ApiResourceKind.skill, handler),
|
|
204
|
+
|
|
205
|
+
/** Hooks: `useApplyResource` (when kind is Skill) */
|
|
206
|
+
pushFromExecutionArtifact: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
207
|
+
unarySpec(SkillCommandController, "pushFromExecutionArtifact", handler),
|
|
208
|
+
|
|
209
|
+
/** Hooks: `useUpdateVisibility` (when kind is Skill) */
|
|
210
|
+
updateVisibility: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
211
|
+
unarySpec(SkillCommandController, "updateVisibility", handler),
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
// ---- MCP Server ----
|
|
215
|
+
|
|
216
|
+
mcpServer: {
|
|
217
|
+
/** Hooks: `useMcpServer`, `useMcpServerSetup` */
|
|
218
|
+
getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
219
|
+
unarySpec(McpServerQueryController, "getByReference", handler),
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Hooks: `useMcpServerList`, `useMcpServerSearch`, `useMcpServerCount`
|
|
223
|
+
*
|
|
224
|
+
* Routes through `SearchService` — use {@link buildScenario} to avoid
|
|
225
|
+
* key collisions with `fixtures.agent.list` and `fixtures.skill.list`.
|
|
226
|
+
*/
|
|
227
|
+
list: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
228
|
+
searchListSpec(ApiResourceKind.mcp_server, handler),
|
|
229
|
+
|
|
230
|
+
/** Hooks: `useDiscoverCapabilities` */
|
|
231
|
+
discoverCapabilities: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
232
|
+
unarySpec(McpServerCommandController, "discoverCapabilities", handler),
|
|
233
|
+
|
|
234
|
+
/** Hooks: `useApplyResource` (when kind is McpServer) */
|
|
235
|
+
apply: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
236
|
+
unarySpec(McpServerCommandController, "apply", handler),
|
|
237
|
+
|
|
238
|
+
/** Hooks: `useUpdateVisibility` (when kind is McpServer) */
|
|
239
|
+
updateVisibility: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
240
|
+
unarySpec(McpServerCommandController, "updateVisibility", handler),
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
// ---- Environment ----
|
|
244
|
+
|
|
245
|
+
environment: {
|
|
246
|
+
/** Components: `EnvironmentVariableEditor` */
|
|
247
|
+
get: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
248
|
+
unarySpec(EnvironmentQueryController, "get", handler),
|
|
249
|
+
|
|
250
|
+
/** Hooks: `useEnvironment` */
|
|
251
|
+
getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
252
|
+
unarySpec(EnvironmentQueryController, "getByReference", handler),
|
|
253
|
+
|
|
254
|
+
/** Hooks: `useEnvironmentList`, `usePersonalEnvironment`, `useTriggerApprovalPolicySession` */
|
|
255
|
+
list: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
256
|
+
unarySpec(EnvironmentQueryController, "list", handler),
|
|
257
|
+
|
|
258
|
+
/** Hooks: `useCreateEnvironment`, `usePersonalEnvironment` */
|
|
259
|
+
create: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
260
|
+
unarySpec(EnvironmentCommandController, "create", handler),
|
|
261
|
+
|
|
262
|
+
/** Hooks: `useUpdateEnvironment` */
|
|
263
|
+
update: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
264
|
+
unarySpec(EnvironmentCommandController, "update", handler),
|
|
265
|
+
|
|
266
|
+
/** Hooks: `useUpdateEnvironmentVariables`, `usePersonalEnvironment` */
|
|
267
|
+
updateVariables: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
268
|
+
unarySpec(EnvironmentCommandController, "updateVariables", handler),
|
|
269
|
+
|
|
270
|
+
/** Hooks: `useRemoveEnvironmentVariables`, `usePersonalEnvironment` */
|
|
271
|
+
removeVariables: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
272
|
+
unarySpec(EnvironmentCommandController, "removeVariables", handler),
|
|
273
|
+
|
|
274
|
+
/** Hooks: `useRevealSecretValue`, `useGitHubConnection` */
|
|
275
|
+
getSecretValue: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
276
|
+
unarySpec(EnvironmentQueryController, "getSecretValue", handler),
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
// ---- Agent Instance ----
|
|
280
|
+
|
|
281
|
+
agentInstance: {
|
|
282
|
+
/** Hooks: `useAgentRefFromSession` */
|
|
283
|
+
get: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
284
|
+
unarySpec(AgentInstanceQueryController, "get", handler),
|
|
285
|
+
|
|
286
|
+
/** Hooks: `useAgentInstance` */
|
|
287
|
+
getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
288
|
+
unarySpec(AgentInstanceQueryController, "getByReference", handler),
|
|
289
|
+
|
|
290
|
+
/** Hooks: `useAgentInstanceList`, `useAgentSetup`, `useTriggerApprovalPolicySession` */
|
|
291
|
+
list: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
292
|
+
unarySpec(AgentInstanceQueryController, "list", handler),
|
|
293
|
+
|
|
294
|
+
/** Hooks: `useCreateAgentInstance`, `usePersonalAgentInstance`, `useAgentSetup`, `useTriggerApprovalPolicySession` */
|
|
295
|
+
create: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
296
|
+
unarySpec(AgentInstanceCommandController, "create", handler),
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
// ---- Organization ----
|
|
300
|
+
|
|
301
|
+
organization: {
|
|
302
|
+
/** Hooks: `useCreateOrganization` */
|
|
303
|
+
create: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
304
|
+
unarySpec(OrganizationCommandController, "create", handler),
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
// ---- API Key ----
|
|
308
|
+
|
|
309
|
+
apiKey: {
|
|
310
|
+
/** Hooks: `useApiKeyList` */
|
|
311
|
+
findAll: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
312
|
+
unarySpec(ApiKeyQueryController, "findAll", handler),
|
|
313
|
+
|
|
314
|
+
/** Hooks: `useCreateApiKey` */
|
|
315
|
+
create: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
316
|
+
unarySpec(ApiKeyCommandController, "create", handler),
|
|
317
|
+
|
|
318
|
+
/** Hooks: `useDeleteApiKey` */
|
|
319
|
+
delete: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
320
|
+
unarySpec(ApiKeyCommandController, "delete", handler),
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
// ---- GitHub ----
|
|
324
|
+
|
|
325
|
+
github: {
|
|
326
|
+
/** Hooks: `useGitHubConnection` */
|
|
327
|
+
getOAuthAuthorizeUrl: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
328
|
+
unarySpec(GitHubService, "getOAuthAuthorizeUrl", handler),
|
|
329
|
+
|
|
330
|
+
/** Hooks: `useGitHubConnection` */
|
|
331
|
+
exchangeOAuthCode: (handler: UnaryFixtureHandler): FixtureSpec =>
|
|
332
|
+
unarySpec(GitHubService, "exchangeOAuthCode", handler),
|
|
333
|
+
},
|
|
334
|
+
} as const;
|
|
335
|
+
|
|
336
|
+
// ---------------------------------------------------------------------------
|
|
337
|
+
// Scenario builder
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Assemble {@link FixtureSpec} entries into a {@link DemoScenario}.
|
|
342
|
+
*
|
|
343
|
+
* This is the recommended way to construct scenarios because it correctly
|
|
344
|
+
* merges search-backed list fixtures (`agent.list`, `skill.list`,
|
|
345
|
+
* `mcpServer.list`) that share the same underlying `SearchService` RPC.
|
|
346
|
+
* Using `new Map([...])` directly with these helpers would cause silent
|
|
347
|
+
* key collisions where the last entry wins.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* import { fixtures, buildScenario, createDemoClient } from "@stigmer/react/demo";
|
|
352
|
+
*
|
|
353
|
+
* const scenario = buildScenario(
|
|
354
|
+
* fixtures.session.get(() => mySession),
|
|
355
|
+
* fixtures.agent.list(() => myAgentSearchResponse),
|
|
356
|
+
* fixtures.skill.list(() => mySkillSearchResponse),
|
|
357
|
+
* );
|
|
358
|
+
* const client = createDemoClient(scenario);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
export function buildScenario(...specs: FixtureSpec[]): DemoScenario {
|
|
362
|
+
const entries: [string, FixtureEntry][] = [];
|
|
363
|
+
const searchHandlers = new Map<ApiResourceKind, UnaryFixtureHandler>();
|
|
364
|
+
|
|
365
|
+
for (const spec of specs) {
|
|
366
|
+
if (spec.searchResourceKind !== undefined) {
|
|
367
|
+
if (spec.entry.unary) {
|
|
368
|
+
searchHandlers.set(spec.searchResourceKind, spec.entry.unary);
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
entries.push([spec.key, spec.entry]);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (searchHandlers.size > 0) {
|
|
376
|
+
const searchKey = rpcKey(SearchService, "search");
|
|
377
|
+
entries.push([
|
|
378
|
+
searchKey,
|
|
379
|
+
{
|
|
380
|
+
unary: (request: unknown) => {
|
|
381
|
+
const req = request as { kinds?: ApiResourceKind[] };
|
|
382
|
+
const kind = req.kinds?.[0];
|
|
383
|
+
if (kind !== undefined) {
|
|
384
|
+
const handler = searchHandlers.get(kind);
|
|
385
|
+
if (handler) return handler(request);
|
|
386
|
+
}
|
|
387
|
+
const registered = [...searchHandlers.keys()]
|
|
388
|
+
.map((k) => ApiResourceKind[k])
|
|
389
|
+
.join(", ");
|
|
390
|
+
throw new Error(
|
|
391
|
+
`No search fixture for resource kind ${kind !== undefined ? ApiResourceKind[kind] ?? kind : "(none)"}. ` +
|
|
392
|
+
`Registered kinds: ${registered || "(none)"}. ` +
|
|
393
|
+
`Add a fixture with fixtures.agent.list(), fixtures.skill.list(), or fixtures.mcpServer.list().`,
|
|
394
|
+
);
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
]);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return { fixtures: new Map(entries) };
|
|
401
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createDemoClient } from "./client";
|
|
2
|
+
export { buildScenario, fixtures, type FixtureSpec } from "./fixtures";
|
|
3
|
+
export { samples } from "./samples";
|
|
4
|
+
export { DemoTransport } from "./transport";
|
|
5
|
+
export {
|
|
6
|
+
rpcKey,
|
|
7
|
+
type DemoScenario,
|
|
8
|
+
type FixtureEntry,
|
|
9
|
+
type FixtureRegistry,
|
|
10
|
+
type StreamFixtureHandler,
|
|
11
|
+
type UnaryFixtureHandler,
|
|
12
|
+
} from "./types";
|