@orkestrel/toolbox 0.0.5 → 0.0.7
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/src/core/index.cjs +77 -209
- package/dist/src/core/index.d.cts +34 -94
- package/dist/src/core/index.d.ts +34 -94
- package/dist/src/core/index.js +78 -209
- package/dist/src/server/index.cjs +16 -19
- package/dist/src/server/index.d.cts +0 -34
- package/dist/src/server/index.d.ts +0 -34
- package/dist/src/server/index.js +18 -20
- package/package.json +14 -12
- package/dist/src/core/index.cjs.map +0 -1
- package/dist/src/core/index.js.map +0 -1
- package/dist/src/server/index.cjs.map +0 -1
- package/dist/src/server/index.js.map +0 -1
package/dist/src/server/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { HEADER_TOKEN, defaultTimer,
|
|
1
|
+
import { HEADER_TOKEN, defaultTimer, serializeExpire, serializePending } from "@orkestrel/terminal";
|
|
2
|
+
import { isFormValues } from "@orkestrel/form";
|
|
3
|
+
import { isNonEmptyString, isRecord } from "@orkestrel/contract";
|
|
2
4
|
import { ContentTooLargeError, DEFAULT_BODY_LIMIT, collectRequestBody, openStream } from "@orkestrel/server";
|
|
3
5
|
//#region src/server/constants.ts
|
|
4
6
|
/**
|
|
@@ -18,13 +20,9 @@ var TERMINAL_KEEPALIVE_MS = 15e3;
|
|
|
18
20
|
/**
|
|
19
21
|
* Own one terminal SSE connection's replay, subscriptions, keepalive, and teardown.
|
|
20
22
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* const connection = new TerminalConnection(manager, name, request, stream, accepts, timer, 15_000)
|
|
26
|
-
* const response = connection.open()
|
|
27
|
-
* ```
|
|
23
|
+
* Internal to this module: `TerminalRoutes` builds the `accepts` predicate from its own token
|
|
24
|
+
* option and opens the stream, so no consumer can construct one. Reach this behaviour through
|
|
25
|
+
* `createTerminalRoutes`.
|
|
28
26
|
*/
|
|
29
27
|
var TerminalConnection = class {
|
|
30
28
|
#manager;
|
|
@@ -43,7 +41,7 @@ var TerminalConnection = class {
|
|
|
43
41
|
/**
|
|
44
42
|
* Create a terminal stream connection.
|
|
45
43
|
*
|
|
46
|
-
* @param manager - Terminal manager supplying pending
|
|
44
|
+
* @param manager - Terminal manager supplying pending forms and lifecycle events
|
|
47
45
|
* @param name - Terminal endpoint streamed by this connection
|
|
48
46
|
* @param request - Request whose abort signal owns the connection lifetime
|
|
49
47
|
* @param stream - Open SSE stream
|
|
@@ -66,7 +64,7 @@ var TerminalConnection = class {
|
|
|
66
64
|
this.#tickHandler = this.#tick.bind(this);
|
|
67
65
|
}
|
|
68
66
|
/**
|
|
69
|
-
* Open the connection by replaying pending
|
|
67
|
+
* Open the connection by replaying pending forms, subscribing, and arming keepalive handling.
|
|
70
68
|
*
|
|
71
69
|
* @returns The SSE response
|
|
72
70
|
*/
|
|
@@ -76,7 +74,7 @@ var TerminalConnection = class {
|
|
|
76
74
|
return this.#stream.response;
|
|
77
75
|
}
|
|
78
76
|
if (this.#cancel !== void 0) return this.#stream.response;
|
|
79
|
-
for (const
|
|
77
|
+
for (const form of this.#manager.pending(this.#name)) this.#write(serializePending(form));
|
|
80
78
|
this.#manager.emitter.on("pending", this.#pendingHandler);
|
|
81
79
|
this.#manager.emitter.on("expire", this.#expireHandler);
|
|
82
80
|
this.#cancel = this.#timer(this.#tickHandler, this.#keepalive);
|
|
@@ -90,13 +88,13 @@ var TerminalConnection = class {
|
|
|
90
88
|
...wire.id === void 0 ? {} : { id: wire.id }
|
|
91
89
|
});
|
|
92
90
|
}
|
|
93
|
-
#pending(
|
|
94
|
-
if (
|
|
91
|
+
#pending(form) {
|
|
92
|
+
if (form.to !== this.#name) return;
|
|
95
93
|
if (this.#stream.closed) {
|
|
96
94
|
this.#destroy();
|
|
97
95
|
return;
|
|
98
96
|
}
|
|
99
|
-
this.#write(serializePending(
|
|
97
|
+
this.#write(serializePending(form));
|
|
100
98
|
}
|
|
101
99
|
#expire(to, id) {
|
|
102
100
|
if (to !== this.#name) return;
|
|
@@ -222,11 +220,11 @@ var TerminalRoutes = class {
|
|
|
222
220
|
} catch {
|
|
223
221
|
return new Response(null, { status: 400 });
|
|
224
222
|
}
|
|
225
|
-
if (!
|
|
226
|
-
const result = this.#manager.answer(name, body.id, body.
|
|
227
|
-
if (result.success) return
|
|
228
|
-
if (result.error === "terminal") return
|
|
229
|
-
return
|
|
223
|
+
if (!isRecord(body) || !isNonEmptyString(body.id) || !isFormValues(body.values)) return new Response(null, { status: 422 });
|
|
224
|
+
const result = this.#manager.answer(name, body.id, body.values);
|
|
225
|
+
if (result.success) return Response.json(result);
|
|
226
|
+
if (result.error.reason === "terminal") return Response.json(result, { status: 404 });
|
|
227
|
+
return Response.json(result, { status: 422 });
|
|
230
228
|
}
|
|
231
229
|
};
|
|
232
230
|
//#endregion
|
|
@@ -257,6 +255,6 @@ function createTerminalRoutes(manager, options) {
|
|
|
257
255
|
return new TerminalRoutes(manager, options).routes();
|
|
258
256
|
}
|
|
259
257
|
//#endregion
|
|
260
|
-
export { TERMINAL_KEEPALIVE_MS, TERMINAL_ROUTES_PATH,
|
|
258
|
+
export { TERMINAL_KEEPALIVE_MS, TERMINAL_ROUTES_PATH, TerminalRoutes, createTerminalRoutes };
|
|
261
259
|
|
|
262
260
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orkestrel/toolbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Concrete LLM-callable tools for the @orkestrel line — workflow authoring, workspace editing, sub-agent delegation, and more, over the @orkestrel/tool runtime, with pluggable stores. Part of the @orkestrel line.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -78,20 +78,22 @@
|
|
|
78
78
|
"prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@orkestrel/agent": "^0.0.
|
|
82
|
-
"@orkestrel/contract": "^0.0.
|
|
83
|
-
"@orkestrel/database": "^0.0.
|
|
84
|
-
"@orkestrel/
|
|
85
|
-
"@orkestrel/
|
|
86
|
-
"@orkestrel/
|
|
87
|
-
"@orkestrel/
|
|
88
|
-
"@orkestrel/
|
|
89
|
-
"@orkestrel/
|
|
81
|
+
"@orkestrel/agent": "^0.0.16",
|
|
82
|
+
"@orkestrel/contract": "^0.0.12",
|
|
83
|
+
"@orkestrel/database": "^0.0.10",
|
|
84
|
+
"@orkestrel/form": "^0.0.2",
|
|
85
|
+
"@orkestrel/relation": "^0.0.9",
|
|
86
|
+
"@orkestrel/server": "^0.0.13",
|
|
87
|
+
"@orkestrel/terminal": "^0.0.10",
|
|
88
|
+
"@orkestrel/tool": "^0.0.11",
|
|
89
|
+
"@orkestrel/workflow": "^0.0.13",
|
|
90
|
+
"@orkestrel/workspace": "^0.0.5"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@microsoft/api-extractor": "^7.58.12",
|
|
93
|
-
"@orkestrel/guide": "^0.0.
|
|
94
|
-
"@orkestrel/scaffold": "^0.0.
|
|
94
|
+
"@orkestrel/guide": "^0.0.12",
|
|
95
|
+
"@orkestrel/scaffold": "^0.0.40",
|
|
96
|
+
"@orkestrel/test": "^0.0.6",
|
|
95
97
|
"@types/node": "^26.1.2",
|
|
96
98
|
"@vitest/browser-playwright": "^4.1.10",
|
|
97
99
|
"oxfmt": "^0.62.0",
|