@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.
@@ -1,4 +1,6 @@
1
- import { HEADER_TOKEN, defaultTimer, isAnswerPayload, serializeExpire, serializePending } from "@orkestrel/terminal";
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
- * @example
22
- * ```ts
23
- * import { TerminalConnection } from '@orkestrel/toolbox/server'
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 prompts and lifecycle events
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 prompts, subscribing, and arming keepalive handling.
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 prompt of this.#manager.pending(this.#name)) this.#write(serializePending(prompt));
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(prompt) {
94
- if (prompt.to !== this.#name) return;
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(prompt));
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 (!isAnswerPayload(body)) return new Response(null, { status: 422 });
226
- const result = this.#manager.answer(name, body.id, body.value);
227
- if (result.success) return new Response(null, { status: 204 });
228
- if (result.error === "terminal") return new Response(result.error, { status: 404 });
229
- return new Response(result.error, { status: 422 });
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, TerminalConnection, TerminalRoutes, createTerminalRoutes };
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.5",
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.15",
82
- "@orkestrel/contract": "^0.0.11",
83
- "@orkestrel/database": "^0.0.8",
84
- "@orkestrel/relation": "^0.0.8",
85
- "@orkestrel/server": "^0.0.12",
86
- "@orkestrel/terminal": "^0.0.6",
87
- "@orkestrel/tool": "^0.0.10",
88
- "@orkestrel/workflow": "^0.0.11",
89
- "@orkestrel/workspace": "^0.0.4"
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.10",
94
- "@orkestrel/scaffold": "^0.0.30",
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",