@jskit-ai/assistant-runtime 0.1.133 → 0.1.134
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/package.json +10 -7
- package/src/server/registerRoutes.js +5 -15
- package/test/lazyAppConfig.test.js +97 -5
package/package.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/assistant-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.134",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "node --test"
|
|
7
|
+
},
|
|
5
8
|
"exports": {
|
|
6
9
|
"./client": "./src/client/index.js",
|
|
7
10
|
"./shared": "./src/shared/index.js",
|
|
8
11
|
"./server/actionIds": "./src/server/actionIds.js"
|
|
9
12
|
},
|
|
10
13
|
"dependencies": {
|
|
11
|
-
"@jskit-ai/assistant-core": "0.1.
|
|
12
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
13
|
-
"@jskit-ai/http-web": "0.1.
|
|
14
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
15
|
-
"@jskit-ai/kernel": "0.1.
|
|
16
|
-
"@jskit-ai/shell-web": "0.1.
|
|
14
|
+
"@jskit-ai/assistant-core": "0.1.139",
|
|
15
|
+
"@jskit-ai/database-runtime": "0.1.163",
|
|
16
|
+
"@jskit-ai/http-web": "0.1.8",
|
|
17
|
+
"@jskit-ai/http-runtime": "0.1.161",
|
|
18
|
+
"@jskit-ai/kernel": "0.1.163",
|
|
19
|
+
"@jskit-ai/shell-web": "0.1.167",
|
|
17
20
|
"json-rest-schema": "^1.0.17"
|
|
18
21
|
},
|
|
19
22
|
"peerDependencies": {
|
|
@@ -219,9 +219,7 @@ function registerSettingsRoutes(
|
|
|
219
219
|
|
|
220
220
|
const response = await request.executeAction({
|
|
221
221
|
actionId: actionIds.settingsRead,
|
|
222
|
-
|
|
223
|
-
surface: routeState.hostSurfaceId
|
|
224
|
-
},
|
|
222
|
+
surface: routeState.hostSurfaceId,
|
|
225
223
|
input: routeState.actionInput
|
|
226
224
|
});
|
|
227
225
|
|
|
@@ -259,9 +257,7 @@ function registerSettingsRoutes(
|
|
|
259
257
|
|
|
260
258
|
const response = await request.executeAction({
|
|
261
259
|
actionId: actionIds.settingsUpdate,
|
|
262
|
-
|
|
263
|
-
surface: routeState.hostSurfaceId
|
|
264
|
-
},
|
|
260
|
+
surface: routeState.hostSurfaceId,
|
|
265
261
|
input: {
|
|
266
262
|
...routeState.actionInput,
|
|
267
263
|
patch: request.input.body
|
|
@@ -374,9 +370,7 @@ function registerRuntimeRoutes(
|
|
|
374
370
|
|
|
375
371
|
await request.executeAction({
|
|
376
372
|
actionId: actionIds.chatStream,
|
|
377
|
-
|
|
378
|
-
surface: routeState.hostSurfaceId
|
|
379
|
-
},
|
|
373
|
+
surface: routeState.hostSurfaceId,
|
|
380
374
|
input: buildChatStreamActionInput(routeState.actionInput, requestBody),
|
|
381
375
|
deps: {
|
|
382
376
|
streamWriter,
|
|
@@ -440,9 +434,7 @@ function registerRuntimeRoutes(
|
|
|
440
434
|
|
|
441
435
|
const response = await request.executeAction({
|
|
442
436
|
actionId: actionIds.conversationsList,
|
|
443
|
-
|
|
444
|
-
surface: routeState.hostSurfaceId
|
|
445
|
-
},
|
|
437
|
+
surface: routeState.hostSurfaceId,
|
|
446
438
|
input: {
|
|
447
439
|
...routeState.actionInput,
|
|
448
440
|
query: request.input.query
|
|
@@ -482,9 +474,7 @@ function registerRuntimeRoutes(
|
|
|
482
474
|
|
|
483
475
|
const response = await request.executeAction({
|
|
484
476
|
actionId: actionIds.conversationMessagesList,
|
|
485
|
-
|
|
486
|
-
surface: routeState.hostSurfaceId
|
|
487
|
-
},
|
|
477
|
+
surface: routeState.hostSurfaceId,
|
|
488
478
|
input: {
|
|
489
479
|
...routeState.actionInput,
|
|
490
480
|
conversationId: request.input.params.conversationId,
|
|
@@ -3,6 +3,7 @@ import test from "node:test";
|
|
|
3
3
|
import { createSchema } from "json-rest-schema";
|
|
4
4
|
import { AppError } from "@jskit-ai/kernel/server/runtime";
|
|
5
5
|
import { createRouter } from "../../kernel/server/http/lib/router.js";
|
|
6
|
+
import { actionIds } from "../src/server/actionIds.js";
|
|
6
7
|
import { registerRoutes } from "../src/server/registerRoutes.js";
|
|
7
8
|
import { createChatService } from "../src/server/services/chatService.js";
|
|
8
9
|
|
|
@@ -104,6 +105,96 @@ test("registerRoutes exposes JSON:API contracts for assistant settings and trans
|
|
|
104
105
|
assert.equal(publicConversationMessagesRoute?.schema?.response?.[200]?.required?.[0], "data");
|
|
105
106
|
});
|
|
106
107
|
|
|
108
|
+
test("registerRoutes forwards the resolved host surface through every direct action", async () => {
|
|
109
|
+
const workspaceScopeSupport = createWorkspaceServerScopeSupport();
|
|
110
|
+
const testApp = createAssistantTestApp({ workspaceScopeSupport });
|
|
111
|
+
registerRoutes(testApp.router, { config: createAssistantAppConfig(), workspaceScopeSupport });
|
|
112
|
+
const routes = testApp.router.list();
|
|
113
|
+
const routeCases = [
|
|
114
|
+
{
|
|
115
|
+
actionId: actionIds.settingsRead,
|
|
116
|
+
method: "GET",
|
|
117
|
+
path: "/api/w/:workspaceSlug/assistant/:surfaceId/settings"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
actionId: actionIds.settingsUpdate,
|
|
121
|
+
body: { data: { attributes: {} } },
|
|
122
|
+
method: "PATCH",
|
|
123
|
+
path: "/api/w/:workspaceSlug/assistant/:surfaceId/settings"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
actionId: actionIds.chatStream,
|
|
127
|
+
body: { input: "hello", messageId: "msg_1" },
|
|
128
|
+
method: "POST",
|
|
129
|
+
path: "/api/w/:workspaceSlug/assistant/:surfaceId/chat/stream"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
actionId: actionIds.conversationsList,
|
|
133
|
+
method: "GET",
|
|
134
|
+
path: "/api/w/:workspaceSlug/assistant/:surfaceId/conversations"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
actionId: actionIds.conversationMessagesList,
|
|
138
|
+
method: "GET",
|
|
139
|
+
path: "/api/w/:workspaceSlug/assistant/:surfaceId/conversations/:conversationId/messages"
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
for (const routeCase of routeCases) {
|
|
144
|
+
const route = findRoute(routes, routeCase);
|
|
145
|
+
assert.ok(route, `Expected ${routeCase.method} ${routeCase.path} to be registered.`);
|
|
146
|
+
let capturedAction = null;
|
|
147
|
+
const reply = {
|
|
148
|
+
raw: {
|
|
149
|
+
end() {},
|
|
150
|
+
flushHeaders() {},
|
|
151
|
+
write() {}
|
|
152
|
+
},
|
|
153
|
+
code() {
|
|
154
|
+
return this;
|
|
155
|
+
},
|
|
156
|
+
header() {
|
|
157
|
+
return this;
|
|
158
|
+
},
|
|
159
|
+
hijack() {
|
|
160
|
+
return this;
|
|
161
|
+
},
|
|
162
|
+
send() {
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
await route.handler(
|
|
167
|
+
{
|
|
168
|
+
raw: {
|
|
169
|
+
off() {},
|
|
170
|
+
on() {}
|
|
171
|
+
},
|
|
172
|
+
headers: {
|
|
173
|
+
"x-jskit-surface": "admin"
|
|
174
|
+
},
|
|
175
|
+
input: {
|
|
176
|
+
body: routeCase.body || {},
|
|
177
|
+
params: {
|
|
178
|
+
conversationId: "conversation_1",
|
|
179
|
+
surfaceId: "admin",
|
|
180
|
+
workspaceSlug: "dogandgroom"
|
|
181
|
+
},
|
|
182
|
+
query: {
|
|
183
|
+
limit: 20
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
async executeAction(action) {
|
|
187
|
+
capturedAction = action;
|
|
188
|
+
return {};
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
reply
|
|
192
|
+
);
|
|
193
|
+
assert.equal(capturedAction?.actionId, routeCase.actionId);
|
|
194
|
+
assert.equal(capturedAction?.surface, "admin");
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
107
198
|
test("registerRoutes builds workspace action input from explicit config and scope support", async () => {
|
|
108
199
|
const workspaceScopeSupport = createWorkspaceServerScopeSupport();
|
|
109
200
|
const testApp = createAssistantTestApp({
|
|
@@ -120,7 +211,7 @@ test("registerRoutes builds workspace action input from explicit config and scop
|
|
|
120
211
|
|
|
121
212
|
assert.ok(route, "Expected workspace assistant conversations route to be registered.");
|
|
122
213
|
|
|
123
|
-
let
|
|
214
|
+
let capturedAction = null;
|
|
124
215
|
const reply = {
|
|
125
216
|
statusCode: 0,
|
|
126
217
|
payload: null,
|
|
@@ -148,8 +239,8 @@ test("registerRoutes builds workspace action input from explicit config and scop
|
|
|
148
239
|
limit: 20
|
|
149
240
|
}
|
|
150
241
|
},
|
|
151
|
-
executeAction: async (
|
|
152
|
-
|
|
242
|
+
executeAction: async (action) => {
|
|
243
|
+
capturedAction = action;
|
|
153
244
|
return {
|
|
154
245
|
entries: [],
|
|
155
246
|
pagination: {
|
|
@@ -165,8 +256,9 @@ test("registerRoutes builds workspace action input from explicit config and scop
|
|
|
165
256
|
);
|
|
166
257
|
|
|
167
258
|
assert.equal(reply.statusCode, 200);
|
|
168
|
-
assert.equal(
|
|
169
|
-
assert.equal(
|
|
259
|
+
assert.equal(capturedAction?.surface, "admin");
|
|
260
|
+
assert.equal(capturedAction?.input?.targetSurfaceId, "admin");
|
|
261
|
+
assert.equal(capturedAction?.input?.workspaceSlug, "dogandgroom");
|
|
170
262
|
});
|
|
171
263
|
|
|
172
264
|
test("registerRoutes returns clear AppError payload for pre-stream assistant failures", async () => {
|