omnicell-router 0.8.1 → 0.8.4

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.
Files changed (89) hide show
  1. package/backend/dist/auth/api-keys.js +11 -0
  2. package/backend/dist/auth/key-models.d.ts +36 -0
  3. package/backend/dist/auth/key-models.js +99 -0
  4. package/backend/dist/cli/clients/activity.d.ts +35 -0
  5. package/backend/dist/cli/clients/activity.js +69 -0
  6. package/backend/dist/cli/clients/codex.d.ts +70 -0
  7. package/backend/dist/cli/clients/codex.js +470 -57
  8. package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
  9. package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
  10. package/backend/dist/cli/clients/index.js +7 -1
  11. package/backend/dist/cli/clients/opencode.js +3 -2
  12. package/backend/dist/cli/clients/reserved.js +2 -0
  13. package/backend/dist/cli/types.d.ts +18 -0
  14. package/backend/dist/config/comments-en.js +5 -1
  15. package/backend/dist/config/comments-zh.js +5 -1
  16. package/backend/dist/config/defaults.d.ts +98 -1
  17. package/backend/dist/config/defaults.js +98 -1
  18. package/backend/dist/config/index.d.ts +15 -1
  19. package/backend/dist/config/index.js +35 -1
  20. package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
  21. package/backend/dist/config/migrations/v4-to-v5.js +42 -0
  22. package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
  23. package/backend/dist/config/migrations/v5-to-v6.js +29 -0
  24. package/backend/dist/config/schema.d.ts +3 -3
  25. package/backend/dist/config/schema.js +8 -4
  26. package/backend/dist/config/types.d.ts +54 -3
  27. package/backend/dist/forward-proxy/egress.js +13 -0
  28. package/backend/dist/forward-proxy/h2-forward.js +6 -5
  29. package/backend/dist/forward-proxy/index.js +5 -0
  30. package/backend/dist/forward-proxy/server.d.ts +12 -0
  31. package/backend/dist/forward-proxy/server.js +113 -15
  32. package/backend/dist/index.js +6 -1
  33. package/backend/dist/ir/adapters/openai-chat.js +5 -3
  34. package/backend/dist/ir/adapters/openai-responses-output.js +2 -2
  35. package/backend/dist/ir/adapters/openai-responses.d.ts +33 -0
  36. package/backend/dist/ir/adapters/openai-responses.js +44 -2
  37. package/backend/dist/ir/capabilities.js +4 -0
  38. package/backend/dist/ir/validate.d.ts +24 -0
  39. package/backend/dist/ir/validate.js +113 -63
  40. package/backend/dist/opencode/catalog/auto-pull.js +8 -7
  41. package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
  42. package/backend/dist/opencode/catalog/ocr-store.js +2 -2
  43. package/backend/dist/opencode/catalog/overrides-store.d.ts +5 -3
  44. package/backend/dist/opencode/catalog/overrides-store.js +22 -19
  45. package/backend/dist/opencode/catalog/repository.js +3 -3
  46. package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
  47. package/backend/dist/opencode/catalog/sources/models-dev.js +29 -11
  48. package/backend/dist/opencode/catalog/types.d.ts +7 -9
  49. package/backend/dist/opencode/credentials/def-materialize.js +27 -21
  50. package/backend/dist/opencode/migrate/engine.d.ts +20 -0
  51. package/backend/dist/opencode/migrate/engine.js +71 -0
  52. package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
  53. package/backend/dist/opencode/migrate/migrator.js +6 -0
  54. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
  55. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
  56. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
  57. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
  58. package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
  59. package/backend/dist/opencode/provider-def-adapters.js +43 -27
  60. package/backend/dist/opencode/provider-defs.d.ts +10 -16
  61. package/backend/dist/opencode/provider-defs.js +45 -45
  62. package/backend/dist/opencode/user-config.d.ts +23 -26
  63. package/backend/dist/opencode/user-config.js +95 -77
  64. package/backend/dist/pipeline/orchestrator.js +17 -7
  65. package/backend/dist/plugins/builtin/model-gateway.js +38 -12
  66. package/backend/dist/plugins/host.d.ts +2 -2
  67. package/backend/dist/plugins/host.js +15 -12
  68. package/backend/dist/providers/boot-direct.js +32 -8
  69. package/backend/dist/providers/dial-wire.d.ts +17 -0
  70. package/backend/dist/providers/dial-wire.js +49 -0
  71. package/backend/dist/providers/protocols-field.d.ts +24 -0
  72. package/backend/dist/providers/protocols-field.js +66 -0
  73. package/backend/dist/providers/registry.d.ts +3 -1
  74. package/backend/dist/providers/registry.js +23 -7
  75. package/backend/dist/quota/cli-login.js +3 -1
  76. package/backend/dist/routes/console.js +120 -95
  77. package/backend/dist/server.js +99 -2
  78. package/backend/dist/surfaces/anthropic.js +4 -1
  79. package/backend/dist/surfaces/body-admission.d.ts +279 -0
  80. package/backend/dist/surfaces/body-admission.js +613 -0
  81. package/backend/dist/surfaces/transport-node-http.d.ts +44 -5
  82. package/backend/dist/surfaces/transport-node-http.js +86 -13
  83. package/backend/dist/utils/server-liveness.d.ts +27 -0
  84. package/backend/dist/utils/server-liveness.js +31 -0
  85. package/frontend/dist/assets/{index-Cn3QMOQx.js → index-Dk76uc7e.js} +398 -363
  86. package/frontend/dist/assets/{index-DxZ9MHKB.css → index-KI1OW5x6.css} +1 -1
  87. package/frontend/dist/assets/workbuddy.color-DOMpQkxJ.svg +29 -0
  88. package/frontend/dist/index.html +2 -2
  89. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
1
  import { appendClientResponseChunk, markClientResponseStreamStart, emitClientResponse, } from '../observability/http-exchange.js';
2
+ import { bodyLimitFor, payloadTooLarge, requestBodyTimeout } from './body-admission.js';
3
+ import { REQUEST_BODY_IDLE_TIMEOUT_MS } from '../config/defaults.js';
2
4
  import { createClientLegWatchdog, writeWithBackpressure } from './transport-backpressure.js';
3
5
  /**
4
6
  * Raw node:http transport (the MITM forward-proxy leg) — the second
@@ -17,27 +19,79 @@ import { createClientLegWatchdog, writeWithBackpressure } from './transport-back
17
19
  * "fix" this by inventing key headers the caller cannot send.
18
20
  * (Authoritative text — interceptor.ts keeps only a pointer here.)
19
21
  */
20
- const MAX_BODY_BYTES = 32 * 1024 * 1024;
21
22
  /**
22
- * Read the request body with a hard 32 MB cap (migrated verbatim from the
23
- * pre-refactor interceptor). Oversized bodies reject with 'Request body
24
- * too large' → the caller maps that to 413 via surface.errorBody.
23
+ * Read the request body with the gateway's hard cap (`bodyLimitFor('gateway')` —
24
+ * the SAME number the native Fastify routes pass as bodyLimit, so one admission
25
+ * ceiling covers both legs; `client.bodyLimits.maxBytes` moves it for both at the
26
+ * next boot). Oversized bodies reject with a BodyAdmissionError
27
+ * that already carries the 413 status, the `payload_too_large` code and the
28
+ * client-facing sentence; the caller only has to answer with it.
29
+ *
30
+ * The cap is measured on the WIRE here (this leg buffers before decoding), and
31
+ * `model-gateway.ts` re-checks after `decompressBody`, so a compressed body
32
+ * cannot slip past the ceiling that the native leg applies to its inflated
33
+ * stream.
34
+ *
35
+ * A STALLED body is refused too, with 408 (see `requestBodyTimeout`). The
36
+ * server-level `requestTimeout` cannot express it: that clock covers the whole
37
+ * request, so one byte per minute never trips it — and on Bun no such clock is
38
+ * armed at all. This timer is re-armed on every chunk, so liveness is measured on
39
+ * the axis that actually fails in practice: progress, not elapsed time.
40
+ *
41
+ * `idleMs` is a seam (a test cannot wait a minute, and a later config knob needs
42
+ * one call site); production callers pass nothing and get the single-source default.
25
43
  */
26
- export function readRequestBody(req) {
44
+ export function readRequestBody(req, idleMs = REQUEST_BODY_IDLE_TIMEOUT_MS) {
27
45
  return new Promise((resolve, reject) => {
28
46
  const chunks = [];
47
+ const capBytes = bodyLimitFor('gateway');
29
48
  let total = 0;
49
+ let idle;
50
+ const clearIdle = () => {
51
+ if (idle)
52
+ clearTimeout(idle);
53
+ idle = undefined;
54
+ };
55
+ const armIdle = () => {
56
+ clearIdle();
57
+ idle = setTimeout(() => {
58
+ idle = undefined;
59
+ // Same shape as the size overflow: stop consuming, let the caller answer,
60
+ // and let `sendPreDispatchError` close the connection.
61
+ req.pause();
62
+ reject(requestBodyTimeout());
63
+ }, idleMs);
64
+ // Never hold the event loop open for a client that has stopped talking.
65
+ idle.unref?.();
66
+ };
30
67
  req.on('data', (d) => {
68
+ armIdle();
31
69
  total += d.length;
32
- if (total > MAX_BODY_BYTES) {
33
- reject(new Error('Request body too large'));
34
- req.destroy();
70
+ if (total > capBytes) {
71
+ clearIdle();
72
+ // RFC 9110 15.5.14: an oversized payload is refused with a 413 — an
73
+ // ANSWER, not a reset. Destroying the request here tore the socket down
74
+ // before the caller could write the status, so the client saw a bare
75
+ // ECONNRESET with no code at all (verified on bun and node). Pause
76
+ // instead — the ceiling is already crossed, so stop consuming and let
77
+ // `sendPreDispatchError` answer, flush and close.
78
+ req.pause();
79
+ reject(payloadTooLarge(capBytes));
35
80
  return;
36
81
  }
37
82
  chunks.push(d);
38
83
  });
39
- req.on('end', () => resolve(Buffer.concat(chunks)));
40
- req.on('error', reject);
84
+ req.on('end', () => {
85
+ clearIdle();
86
+ resolve(Buffer.concat(chunks));
87
+ });
88
+ // A client that hangs up mid-body is not a stalled body: no 408 answer to send,
89
+ // just stop the clock.
90
+ req.on('close', clearIdle);
91
+ req.on('error', (err) => {
92
+ clearIdle();
93
+ reject(err);
94
+ });
41
95
  });
42
96
  }
43
97
  /**
@@ -46,18 +100,37 @@ export function readRequestBody(req) {
46
100
  * capture events exist on this path on either leg (contract §4: 400/403
47
101
  * precede process). Adapters never throw — write failures are logged loud.
48
102
  */
49
- export function sendPreDispatchError(res, surface, status, message) {
103
+ export function sendPreDispatchError(res, surface, status, message, code,
104
+ /** The rejection's negotiation headers (`Accept-Encoding` for a refused coding,
105
+ * `Accept` for a refused media type). Carried through so the MITM leg advertises
106
+ * exactly what the native leg does — a client that only reads the headers learns
107
+ * the fix on neither leg if they are dropped here. */
108
+ headers) {
50
109
  let serialized;
51
110
  try {
52
- serialized = JSON.stringify(surface.errorBody(status, message));
111
+ serialized = JSON.stringify(surface.errorBody(status, message, code));
53
112
  }
54
113
  catch (err) {
55
114
  logWriteError(err, 'node-http pre-dispatch error body serialization failed');
56
115
  return;
57
116
  }
58
117
  try {
59
- res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
118
+ // The MITM leg serves BOTH HTTP/1.1 and the http2 compatibility API. h2
119
+ // forbids connection-specific fields (writeHead throws
120
+ // ERR_HTTP2_INVALID_CONNECTION_HEADERS, which used to eat the whole
121
+ // envelope), so `connection: close` is spoken only on the h1 leg.
122
+ const isH2 = res.stream !== undefined;
123
+ res.writeHead(status, {
124
+ 'content-type': 'application/json; charset=utf-8',
125
+ ...(isH2 ? {} : { connection: 'close' }),
126
+ ...(headers ?? {}),
127
+ });
60
128
  res.end(serialized);
129
+ // The body was deliberately left unread, so this connection is not reusable.
130
+ // destroySoon() — never destroy() — flushes the answer first and then closes
131
+ // the transport; on the h2 leg it ends the affected stream, not the
132
+ // multiplexed session.
133
+ res.destroySoon?.();
61
134
  }
62
135
  catch (err) {
63
136
  logWriteError(err, 'node-http pre-dispatch error write failed');
@@ -0,0 +1,27 @@
1
+ import type http from 'node:http';
2
+ /**
3
+ * INBOUND liveness bounds, spelled ONCE for every listener the gateway owns.
4
+ *
5
+ * The numbers live in `config/defaults.ts` (single source); this module only turns
6
+ * them into the two shapes a server needs, so a future fourth listener cannot
7
+ * quietly re-pick its own timeouts. Leaving these to the runtime is not neutral:
8
+ * Node ships 300s / 60s / 5s, Bun ships none, so the same slow client holds a
9
+ * socket open forever on one runtime and is reaped on the other. These values
10
+ * match Node's shipped numbers deliberately — on Node this changes nothing, it
11
+ * makes Bun behave like Node instead of behaving undefined.
12
+ *
13
+ * Per-chunk body progress is a DIFFERENT bound that a server-level clock cannot
14
+ * express (`requestTimeout` measures the whole request, so a trickling client never
15
+ * trips it): see `REQUEST_BODY_IDLE_TIMEOUT_MS` in
16
+ * `surfaces/transport-node-http.ts`.
17
+ */
18
+ /** Option-object form — Fastify and `http.createServer` both take these keys.
19
+ * Mutable widened type on purpose: an `as const` object makes Fastify's generic
20
+ * inference pick a different server type and the instance stops typechecking. */
21
+ export declare const INBOUND_LIVENESS_OPTIONS: {
22
+ requestTimeout: number;
23
+ headersTimeout: number;
24
+ keepAliveTimeout: number;
25
+ };
26
+ /** Assignment form — for a server instance that was already constructed. */
27
+ export declare function applyInboundLiveness(server: http.Server): void;
@@ -0,0 +1,31 @@
1
+ import { SERVER_HEADERS_TIMEOUT_MS, SERVER_KEEP_ALIVE_TIMEOUT_MS, SERVER_REQUEST_TIMEOUT_MS, } from '../config/defaults.js';
2
+ /**
3
+ * INBOUND liveness bounds, spelled ONCE for every listener the gateway owns.
4
+ *
5
+ * The numbers live in `config/defaults.ts` (single source); this module only turns
6
+ * them into the two shapes a server needs, so a future fourth listener cannot
7
+ * quietly re-pick its own timeouts. Leaving these to the runtime is not neutral:
8
+ * Node ships 300s / 60s / 5s, Bun ships none, so the same slow client holds a
9
+ * socket open forever on one runtime and is reaped on the other. These values
10
+ * match Node's shipped numbers deliberately — on Node this changes nothing, it
11
+ * makes Bun behave like Node instead of behaving undefined.
12
+ *
13
+ * Per-chunk body progress is a DIFFERENT bound that a server-level clock cannot
14
+ * express (`requestTimeout` measures the whole request, so a trickling client never
15
+ * trips it): see `REQUEST_BODY_IDLE_TIMEOUT_MS` in
16
+ * `surfaces/transport-node-http.ts`.
17
+ */
18
+ /** Option-object form — Fastify and `http.createServer` both take these keys.
19
+ * Mutable widened type on purpose: an `as const` object makes Fastify's generic
20
+ * inference pick a different server type and the instance stops typechecking. */
21
+ export const INBOUND_LIVENESS_OPTIONS = {
22
+ requestTimeout: SERVER_REQUEST_TIMEOUT_MS,
23
+ headersTimeout: SERVER_HEADERS_TIMEOUT_MS,
24
+ keepAliveTimeout: SERVER_KEEP_ALIVE_TIMEOUT_MS,
25
+ };
26
+ /** Assignment form — for a server instance that was already constructed. */
27
+ export function applyInboundLiveness(server) {
28
+ server.requestTimeout = SERVER_REQUEST_TIMEOUT_MS;
29
+ server.headersTimeout = SERVER_HEADERS_TIMEOUT_MS;
30
+ server.keepAliveTimeout = SERVER_KEEP_ALIVE_TIMEOUT_MS;
31
+ }