@tai42/api-client 31.1.0 → 33.0.0

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 (100) hide show
  1. package/dist/client/backend-client.d.ts +27 -0
  2. package/dist/client/backend-client.d.ts.map +1 -1
  3. package/dist/client/backup-client.d.ts +4 -0
  4. package/dist/client/backup-client.d.ts.map +1 -1
  5. package/dist/client/config-client.d.ts +31 -0
  6. package/dist/client/config-client.d.ts.map +1 -1
  7. package/dist/client/index.d.ts +148 -1
  8. package/dist/client/index.d.ts.map +1 -1
  9. package/dist/client/index.js +5 -0
  10. package/dist/client/index.js.map +1 -1
  11. package/dist/client/manifest-client.d.ts +33 -1
  12. package/dist/client/manifest-client.d.ts.map +1 -1
  13. package/dist/client/manifest-client.js +3 -3
  14. package/dist/client/manifest-client.js.map +1 -1
  15. package/dist/client/marketplace-client.d.ts +40 -0
  16. package/dist/client/marketplace-client.d.ts.map +1 -1
  17. package/dist/client/profiles-client.d.ts +4 -0
  18. package/dist/client/profiles-client.d.ts.map +1 -1
  19. package/dist/client/tool-extensions-client.d.ts +4 -0
  20. package/dist/client/tool-extensions-client.d.ts.map +1 -1
  21. package/dist/client/tools-client.d.ts +1 -0
  22. package/dist/client/tools-client.d.ts.map +1 -1
  23. package/dist/failed-mcp-roster.d.ts +30 -0
  24. package/dist/failed-mcp-roster.d.ts.map +1 -0
  25. package/dist/failed-mcp-roster.js +56 -0
  26. package/dist/failed-mcp-roster.js.map +1 -0
  27. package/dist/failed-reply-roll.d.ts +22 -0
  28. package/dist/failed-reply-roll.d.ts.map +1 -0
  29. package/dist/failed-reply-roll.js +46 -0
  30. package/dist/failed-reply-roll.js.map +1 -0
  31. package/dist/fleet-report.d.ts +78 -50
  32. package/dist/fleet-report.d.ts.map +1 -1
  33. package/dist/fleet-report.js +106 -89
  34. package/dist/fleet-report.js.map +1 -1
  35. package/dist/generated/api-routes.d.ts +4 -4
  36. package/dist/generated/api-routes.js +1 -1
  37. package/dist/generated/api-routes.js.map +1 -1
  38. package/dist/generated/openapi-schemas.d.ts +303 -30
  39. package/dist/generated/openapi-schemas.d.ts.map +1 -1
  40. package/dist/generated/openapi-schemas.js +14 -13
  41. package/dist/generated/openapi-schemas.js.map +1 -1
  42. package/dist/generated/served-schemas.d.ts +1 -1
  43. package/dist/generated/served-schemas.js +1 -1
  44. package/dist/generated/served-schemas.js.map +1 -1
  45. package/dist/http.d.ts.map +1 -1
  46. package/dist/http.js +5 -2
  47. package/dist/http.js.map +1 -1
  48. package/dist/index.d.ts +8 -3
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +4 -1
  51. package/dist/index.js.map +1 -1
  52. package/dist/mcp-failure.d.ts +18 -0
  53. package/dist/mcp-failure.d.ts.map +1 -0
  54. package/dist/mcp-failure.js +39 -0
  55. package/dist/mcp-failure.js.map +1 -0
  56. package/dist/schemas/backup.d.ts +8 -0
  57. package/dist/schemas/backup.d.ts.map +1 -1
  58. package/dist/schemas/fleet.d.ts +49 -10
  59. package/dist/schemas/fleet.d.ts.map +1 -1
  60. package/dist/schemas/fleet.js +20 -11
  61. package/dist/schemas/fleet.js.map +1 -1
  62. package/dist/schemas/manifest-mcp.d.ts +9 -6
  63. package/dist/schemas/manifest-mcp.d.ts.map +1 -1
  64. package/dist/schemas/manifest-mcp.js +4 -3
  65. package/dist/schemas/manifest-mcp.js.map +1 -1
  66. package/dist/schemas/marketplace.d.ts +44 -2
  67. package/dist/schemas/marketplace.d.ts.map +1 -1
  68. package/dist/schemas/marketplace.js +8 -2
  69. package/dist/schemas/marketplace.js.map +1 -1
  70. package/dist/schemas/profiles.d.ts +13 -7
  71. package/dist/schemas/profiles.d.ts.map +1 -1
  72. package/dist/schemas/profiles.js +9 -7
  73. package/dist/schemas/profiles.js.map +1 -1
  74. package/dist/schemas/served.d.ts +1 -1
  75. package/dist/schemas/system-kinds.d.ts +4 -0
  76. package/dist/schemas/system-kinds.d.ts.map +1 -1
  77. package/dist/schemas/system-kinds.js +5 -4
  78. package/dist/schemas/system-kinds.js.map +1 -1
  79. package/dist/schemas/tools.d.ts +5 -1
  80. package/dist/schemas/tools.d.ts.map +1 -1
  81. package/dist/schemas/tools.js +3 -1
  82. package/dist/schemas/tools.js.map +1 -1
  83. package/package.json +1 -1
  84. package/src/client/index.ts +5 -0
  85. package/src/client/manifest-client.ts +4 -4
  86. package/src/failed-mcp-roster.ts +70 -0
  87. package/src/failed-reply-roll.ts +71 -0
  88. package/src/fleet-report.ts +192 -118
  89. package/src/generated/api-routes.ts +1 -1
  90. package/src/generated/openapi-schemas.ts +16 -13
  91. package/src/generated/served-schemas.ts +1 -1
  92. package/src/http.ts +5 -2
  93. package/src/index.ts +9 -2
  94. package/src/mcp-failure.ts +46 -0
  95. package/src/schemas/fleet.ts +20 -11
  96. package/src/schemas/manifest-mcp.ts +4 -3
  97. package/src/schemas/marketplace.ts +8 -2
  98. package/src/schemas/profiles.ts +9 -7
  99. package/src/schemas/system-kinds.ts +5 -4
  100. package/src/schemas/tools.ts +3 -1
@@ -3,19 +3,28 @@
3
3
  * fleet broadcast. Every mutation surface (connector, backup, mcp-config, env,
4
4
  * extensions, single-MCP reload, fleet reload) routes its broadcast report through
5
5
  * this one function so a FAILED propagation is never invisible: an unconfirmed
6
- * sibling (any non-`applied` outcome) or an unreachable bus becomes an explicit
7
- * summary the UI renders as a loud, user-visible state — never a faked success on a
8
- * worker that did not converge.
6
+ * sibling (any non-`applied` outcome the operation's recycle roll did not settle) or an
7
+ * unreachable bus becomes an explicit summary the UI renders as a loud, user-visible
8
+ * state — never a faked success on a worker that did not converge.
9
9
  *
10
- * A mutation embeds its broadcast in one of two shapes: the mode-wrapped
11
- * {@link FleetReportFanout} (`fanout` field) or the bare {@link FleetResult} (the
12
- * fleet-reload and single-MCP-reload bodies). Both normalize to a
10
+ * A mutation embeds its broadcast in one of three shapes: the mode-wrapped
11
+ * {@link FleetReportFanout} (`fanout` field), the fleet soft restart's
12
+ * {@link FleetReloadResult}, or the bare {@link FleetResult} (the single-MCP reload,
13
+ * deregister and tool reload/remove bodies). Each normalizes to a
13
14
  * {@link FleetReportSummary} through the functions here; the SDK's `FleetReport`
14
15
  * component renders the summary.
15
16
  */
16
- import type { FleetOutcome, FleetReportFanout, FleetResult } from './schemas';
17
+ import type {
18
+ AwaitingWorker,
19
+ FleetOutcome,
20
+ FleetReloadResult,
21
+ FleetReportFanout,
22
+ FleetResult,
23
+ RecycleEntry,
24
+ RecycleRoll,
25
+ } from './schemas';
17
26
 
18
- /** A per-worker propagation FAILURE: a worker that did not confirm `applied`. */
27
+ /** The outcome of a worker's broadcast row that did not confirm `applied`. */
19
28
  export type FleetFailureOutcome = Exclude<FleetOutcome, 'applied'>;
20
29
 
21
30
  /** One worker that failed to converge, with the report's message for it. */
@@ -24,28 +33,50 @@ export interface FleetWorkerFailure {
24
33
  readonly outcome: FleetFailureOutcome;
25
34
  /** The failed apply's `error`, or the publisher's computed-outcome `detail`. */
26
35
  readonly message: string | null;
36
+ /**
37
+ * True when the reply states its reload was refused at its epoch build
38
+ * (the `withheld` {@link AwaitingRestartReading}): trying again may be refused the same way
39
+ * until the stored config is fixed.
40
+ */
41
+ readonly withheld: boolean;
27
42
  }
28
43
 
29
44
  /**
30
45
  * The interpreted state of one broadcast.
31
- * - `converged` — the bus was reached and every worker applied (or the change was
32
- * local-only on a lone worker). The caller renders its own success; the report
46
+ * - `converged` — the bus was reached and every worker applied or was settled by the
47
+ * operation's roll (or the change was local-only on a lone worker). The caller renders its own success; the report
33
48
  * needs no loud state.
34
- * - `degraded` — the bus was reached but one or more workers did not confirm; the
35
- * named `failures` are stale/unreached siblings the operator must see.
49
+ * - `degraded` — the bus was reached but one or more workers did not confirm and the
50
+ * operation's roll did not settle them; the named `failures` are stale/unreached
51
+ * siblings the operator must see.
36
52
  * - `unreachable` — the bus itself could not be reached, so no sibling was told;
37
53
  * `error` carries the transport failure.
38
54
  */
39
55
  export type FleetReportStatus = 'converged' | 'degraded' | 'unreachable';
40
56
 
41
57
  /**
42
- * One worker whose reload named recycle-class keys awaiting a respawn: their value
43
- * changed since the worker bound it (at boot, or when the plugin that declares them was
58
+ * What the reply says about a worker awaiting a respawn:
59
+ * - `restartable` — it carries the worker's broadcast row or recycle line, and neither
60
+ * states a refused build, so a restart applies its settings.
61
+ * - `withheld` — its reload was refused at its epoch build: the stored config did not build
62
+ * on it, so the operation left it running on its current config and a restart may fail
63
+ * the same way until that config is fixed. Its broadcast row is `failed` with a
64
+ * `discarded` payload, or its recycle line is `withheld`.
65
+ * - `unstated` — it carries neither a row nor a line for the worker (an upgrade-all's reply
66
+ * has no rows, nor has a lone worker's `local-only` fan-out), so it does not say which of
67
+ * the other two the worker is.
68
+ */
69
+ export type AwaitingRestartReading = 'restartable' | 'withheld' | 'unstated';
70
+
71
+ /**
72
+ * One worker an operation names as still awaiting a respawn: its recycle-class keys
73
+ * changed since the worker bound them (at boot, or when the plugin that declares them was
44
74
  * loaded), and they take effect only when it is respawned.
45
75
  */
46
76
  export interface FleetWorkerAwaitingRespawn {
47
77
  readonly name: string;
48
78
  readonly keys: readonly string[];
79
+ readonly reading: AwaitingRestartReading;
49
80
  }
50
81
 
51
82
  export interface FleetReportSummary {
@@ -56,8 +87,15 @@ export interface FleetReportSummary {
56
87
  readonly failures: readonly FleetWorkerFailure[];
57
88
  /** The bus-unreachable transport error — non-null only when `unreachable`. */
58
89
  readonly error: string | null;
59
- /** The workers whose reload named recycle-class keys awaiting a respawn. */
90
+ /** The workers the operation names as still awaiting a respawn. */
60
91
  readonly awaiting: readonly FleetWorkerAwaitingRespawn[];
92
+ /** The workers whose roll line is `self-deferred`: a restart the reply cannot confirm. */
93
+ readonly restartsPending: readonly string[];
94
+ /**
95
+ * The workers the roll settled without a confirmed fresh life whose broadcast row did not
96
+ * confirm `applied`: the reply states no restart is outstanding, not that they applied.
97
+ */
98
+ readonly reloadsUnconfirmed: readonly string[];
61
99
  /**
62
100
  * The config store's error releasing its exclusive write span after the persist, or
63
101
  * `null` when it released. Non-null means the change landed but the store may hold
@@ -66,18 +104,6 @@ export interface FleetReportSummary {
66
104
  readonly spanReleaseError: string | null;
67
105
  }
68
106
 
69
- /**
70
- * The recycle-class keys a worker's reload payload names under `awaiting_respawn`.
71
- * The per-worker payload is opaque on the wire, so it is read defensively: a payload
72
- * that is not a reload result names nothing.
73
- */
74
- function awaitingKeys(payload: unknown): string[] {
75
- if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) return [];
76
- const keys = (payload as Record<string, unknown>).awaiting_respawn;
77
- if (!Array.isArray(keys)) return [];
78
- return keys.filter((key): key is string => typeof key === 'string');
79
- }
80
-
81
107
  /**
82
108
  * True when a summary describes a failure the operator must be shown: a propagation
83
109
  * that did not converge, or a write span the store did not release.
@@ -87,24 +113,105 @@ export function isFleetReportFailure(summary: FleetReportSummary | null): boolea
87
113
  }
88
114
 
89
115
  /**
90
- * Interpret a bare {@link FleetResult} (the fleet-reload / single-MCP-reload body).
91
- * An unreachable bus is `unreachable`; a reachable report with any non-`applied`
92
- * worker is `degraded` (those workers named); otherwise `converged`. Every worker whose
93
- * reload payload names `awaiting_respawn` keys is listed under `awaiting`, whatever the
94
- * status.
116
+ * Interpret a bare {@link FleetResult} (the single-MCP reload, deregister, and tool
117
+ * reload/remove bodies). An unreachable bus is `unreachable`; a reachable report with
118
+ * any non-`applied` worker is `degraded` (those workers named); otherwise `converged`.
119
+ * A bare report states no verdict on workers awaiting a respawn, so `awaiting` is empty.
95
120
  */
96
121
  export function summarizeFleetResult(result: Omit<FleetResult, 'ok'>): FleetReportSummary {
97
- const awaiting: FleetWorkerAwaitingRespawn[] = result.results
98
- .map((entry) => ({ name: entry.name, keys: awaitingKeys(entry.payload) }))
99
- .filter((entry) => entry.keys.length > 0);
100
- return summarizeWith(result, awaiting, null);
122
+ return summarizeWith(result, [], NO_ROLL, null);
123
+ }
124
+
125
+ /**
126
+ * Interpret a fleet soft restart's {@link FleetReloadResult}: its per-worker report
127
+ * judged as {@link summarizeFleetResult} judges it, with `awaiting` the operation's own
128
+ * `awaiting_respawn` verdict. Each worker's reload payload states the keys that worker
129
+ * found moved before the operation's recycle roll ran; the roll restarts those workers,
130
+ * so only the verdict says which still await a respawn. Its rows and its roll's lines
131
+ * give the reading of each ({@link AwaitingRestartReading}), and the roll settles the
132
+ * workers whose rows did not confirm ({@link settledWorkers}).
133
+ */
134
+ export function summarizeFleetReload(reply: Omit<FleetReloadResult, 'ok'>): FleetReportSummary {
135
+ return summarizeWith(reply, reply.awaiting_respawn, reply.recycle ?? NO_ROLL, null);
136
+ }
137
+
138
+ /** What a roll states of each worker: its lines, and the workers it left running as clean. */
139
+ type RollStatements = NonNullable<FleetFanoutReply['recycle']>;
140
+
141
+ const NO_ROLL: RollStatements = { recycle: [], skipped: [] };
142
+
143
+ /** Whether a broadcast row states that its worker's reload was refused at its epoch build. */
144
+ function statesDiscardedBuild(row: FleetResult['results'][number]): boolean {
145
+ if (row.outcome !== 'failed') return false;
146
+ const payload = row.payload;
147
+ return (
148
+ typeof payload === 'object' &&
149
+ payload !== null &&
150
+ (payload as Record<string, unknown>).status === 'discarded'
151
+ );
152
+ }
153
+
154
+ /**
155
+ * The workers the reply states as withheld, the one reading of it: a broadcast row states
156
+ * a discarded build, or a recycle line is `withheld`.
157
+ */
158
+ function withheldWorkers(
159
+ rows: FleetResult['results'],
160
+ recycle: readonly RecycleEntry[],
161
+ ): ReadonlySet<string> {
162
+ return new Set([
163
+ ...rows.filter(statesDiscardedBuild).map((row) => row.name),
164
+ ...recycle.filter((line) => line.status === 'withheld').map((line) => line.name),
165
+ ]);
166
+ }
167
+
168
+ /**
169
+ * The workers whose latest statement is the roll's and leaves nothing to converge, the one
170
+ * reading of it, whatever their broadcast rows say: a line `recycled` or `self-deferred`, or a
171
+ * worker named in `skipped`. A discarded build with no moved keys is skipped on that row alone,
172
+ * with no later statement, so its row still stands: the stored configuration did not build there.
173
+ */
174
+ function settledWorkers(rows: FleetResult['results'], roll: RollStatements): ReadonlySet<string> {
175
+ const discarded = new Set(rows.filter(statesDiscardedBuild).map((row) => row.name));
176
+ return new Set([
177
+ ...roll.recycle
178
+ .filter((line) => line.status === 'recycled' || line.status === 'self-deferred')
179
+ .map((line) => line.name),
180
+ ...roll.skipped.filter((name) => !discarded.has(name)),
181
+ ]);
182
+ }
183
+
184
+ function awaitingWorkers(
185
+ verdict: readonly AwaitingWorker[],
186
+ rows: FleetResult['results'],
187
+ recycle: readonly RecycleEntry[],
188
+ ): FleetWorkerAwaitingRespawn[] {
189
+ const withheld = withheldWorkers(rows, recycle);
190
+ const stated = new Set([...rows, ...recycle].map((statement) => statement.name));
191
+ return verdict.map((worker) => ({
192
+ name: worker.name,
193
+ keys: worker.keys,
194
+ reading: withheld.has(worker.name)
195
+ ? 'withheld'
196
+ : stated.has(worker.name)
197
+ ? 'restartable'
198
+ : 'unstated',
199
+ }));
200
+ }
201
+
202
+ /** The worker lines of one status, by name. */
203
+ function linesWith(roll: RollStatements, status: string): string[] {
204
+ return roll.recycle.filter((line) => line.status === status).map((line) => line.name);
101
205
  }
102
206
 
103
207
  function summarizeWith(
104
208
  result: Omit<FleetResult, 'ok'>,
105
- awaiting: readonly FleetWorkerAwaitingRespawn[],
209
+ verdict: readonly AwaitingWorker[],
210
+ roll: RollStatements,
106
211
  spanReleaseError: string | null,
107
212
  ): FleetReportSummary {
213
+ const awaiting = awaitingWorkers(verdict, result.results, roll.recycle);
214
+ const restartsPending = linesWith(roll, 'self-deferred');
108
215
  if (!result.reachable) {
109
216
  return {
110
217
  status: 'unreachable',
@@ -112,15 +219,22 @@ function summarizeWith(
112
219
  failures: [],
113
220
  error: result.error,
114
221
  awaiting,
222
+ restartsPending,
223
+ reloadsUnconfirmed: [],
115
224
  spanReleaseError,
116
225
  };
117
226
  }
118
- const failures: FleetWorkerFailure[] = result.results
119
- .filter((entry) => entry.outcome !== 'applied')
227
+ const withheld = withheldWorkers(result.results, roll.recycle);
228
+ const settled = settledWorkers(result.results, roll);
229
+ const recycled = new Set(linesWith(roll, 'recycled'));
230
+ const unconfirmed = result.results.filter((entry) => entry.outcome !== 'applied');
231
+ const failures: FleetWorkerFailure[] = unconfirmed
232
+ .filter((entry) => !settled.has(entry.name))
120
233
  .map((entry) => ({
121
234
  name: entry.name,
122
235
  outcome: entry.outcome as FleetFailureOutcome,
123
236
  message: entry.error ?? entry.detail ?? null,
237
+ withheld: withheld.has(entry.name),
124
238
  }));
125
239
  return {
126
240
  status: failures.length > 0 ? 'degraded' : 'converged',
@@ -128,96 +242,56 @@ function summarizeWith(
128
242
  failures,
129
243
  error: null,
130
244
  awaiting,
245
+ restartsPending,
246
+ reloadsUnconfirmed: unconfirmed
247
+ .map((entry) => entry.name)
248
+ .filter((name) => settled.has(name) && !recycled.has(name)),
131
249
  spanReleaseError,
132
250
  };
133
251
  }
134
252
 
135
253
  /**
136
- * Interpret a mutation's mode-wrapped {@link FleetReportFanout}. `null`/`undefined`
137
- * (the response path mutated no manifest) yields `null` — there is nothing to report.
138
- * A `local-only` fan-out is `converged` with its note; `fleet`/`unreachable` carry a
139
- * bare {@link FleetResult} judged as {@link summarizeFleetResult} judges its failures.
140
- * `awaiting` is the mutation's own verdict (its response's `awaiting_respawn`, or `[]`
141
- * for a mutation that states none): the operation knows whether its recycle roll
142
- * carried a worker's moved env, so its per-worker rows are never re-read for it.
143
- * `spanReleaseError` is the response's `span_release_error`: a non-null value makes the
144
- * summary a failure ({@link isFleetReportFailure}) whatever the fan-out reports, and a
145
- * response that mutated no manifest still yields a summary carrying it.
254
+ * The slice of a mutation's reply its fleet report reads, under the reply's own field names.
255
+ * A reply states only what its operation has: `fanout` is absent or `null` when it reloaded
256
+ * no manifest, `awaiting_respawn` absent when it states no verdict, and `recycle` absent or
257
+ * `null` when it ran no roll.
146
258
  */
147
- export function summarizeFleetFanout(
148
- fanout: FleetReportFanout | null | undefined,
149
- awaiting: readonly FleetWorkerAwaitingRespawn[],
150
- spanReleaseError: string | null,
151
- ): FleetReportSummary | null {
152
- if (fanout === null || fanout === undefined) {
153
- if (spanReleaseError === null) return null;
154
- return {
155
- status: 'converged',
156
- note: null,
157
- failures: [],
158
- error: null,
159
- awaiting,
160
- spanReleaseError,
161
- };
162
- }
163
- if (fanout.mode === 'local-only') {
259
+ export interface FleetFanoutReply {
260
+ readonly fanout?: FleetReportFanout | null;
261
+ readonly awaiting_respawn?: readonly AwaitingWorker[];
262
+ /** The roll the operation ran. A reply carrying its roll's fields flat passes itself here. */
263
+ readonly recycle?: Pick<RecycleRoll, 'recycle' | 'skipped'> | null;
264
+ readonly span_release_error: string | null;
265
+ }
266
+
267
+ /**
268
+ * Interpret a mutation's reply. A reply with no fan-out, no unreleased span and no worker
269
+ * awaiting a respawn yields `null`: there is nothing to report. A `local-only` fan-out is
270
+ * `converged` with its note; `fleet`/`unreachable` carry a bare {@link FleetResult} judged
271
+ * as {@link summarizeFleetResult} judges it. `awaiting_respawn` is the operation's own
272
+ * verdict: it knows whether its recycle roll carried a worker's moved env, so its per-worker
273
+ * rows are never re-read for it. The roll's lines, with the broadcast rows, give the reading of
274
+ * each worker it names ({@link AwaitingRestartReading}), and the roll settles the workers whose
275
+ * rows did not confirm ({@link settledWorkers}). A non-null `span_release_error` makes the summary a failure
276
+ * ({@link isFleetReportFailure}) whatever the fan-out reports.
277
+ */
278
+ export function summarizeFleetFanout(reply: FleetFanoutReply): FleetReportSummary | null {
279
+ const { fanout, span_release_error: spanReleaseError } = reply;
280
+ const verdict = reply.awaiting_respawn ?? [];
281
+ const roll = reply.recycle ?? NO_ROLL;
282
+ if (fanout === null || fanout === undefined || fanout.mode === 'local-only') {
283
+ const note = fanout?.note ?? null;
284
+ if (note === null && spanReleaseError === null && verdict.length === 0) return null;
164
285
  return {
165
286
  status: 'converged',
166
- note: fanout.note,
287
+ note,
167
288
  failures: [],
168
289
  error: null,
169
- awaiting,
290
+ awaiting: awaitingWorkers(verdict, [], roll.recycle),
291
+ restartsPending: linesWith(roll, 'self-deferred'),
292
+ reloadsUnconfirmed: [],
170
293
  spanReleaseError,
171
294
  };
172
295
  }
173
- return summarizeWith(fanout, awaiting, spanReleaseError);
174
- }
175
-
176
- /** One MCP server skipped by the viability check — its title, a coarse status, and the
177
- * credential-free failure detail the platform records when present: `category` (`auth`
178
- * for a 401/403, `unreachable` for a transport error or timeout, `error` otherwise),
179
- * the redacted `message`, and the `http_status` the failure carried (`null` for a pure
180
- * transport failure). The three detail fields are absent when the reporting server
181
- * omitted them. */
182
- export interface FailedMcpEntry {
183
- readonly title: string;
184
- readonly status: string;
185
- readonly category?: string;
186
- readonly message?: string;
187
- readonly http_status?: number | null;
188
- }
189
-
190
- /**
191
- * The failed-MCP roster carried by a `GET /api/mcp-status/failed` broadcast report.
192
- * The query op rides the fleet fan-out primitive, so each worker's own failed list
193
- * arrives as its per-worker `payload` (opaque on the wire). This unions those lists
194
- * by title — a server failed on ANY worker is a server the operator must see — and
195
- * name-sorts the result, tolerating a worker whose payload is absent or malformed
196
- * (skipped, never a throw: a partial fleet report still yields the roster it can).
197
- */
198
- export function failedMcpsFromReport(result: Omit<FleetResult, 'ok'>): FailedMcpEntry[] {
199
- const byTitle = new Map<string, FailedMcpEntry>();
200
- for (const worker of result.results) {
201
- const payload: unknown = worker.payload;
202
- if (!Array.isArray(payload)) continue;
203
- for (const entry of payload) {
204
- if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) continue;
205
- const record = entry as Record<string, unknown>;
206
- const { title, status, category, message } = record;
207
- if (typeof title !== 'string' || title === '') continue;
208
- // First-seen wins: a server's earliest failure record carries the whole row,
209
- // detail fields included, and a later worker's echo of the same title is ignored.
210
- if (byTitle.has(title)) continue;
211
- byTitle.set(title, {
212
- title,
213
- status: typeof status === 'string' ? status : 'unavailable',
214
- ...(typeof category === 'string' ? { category } : {}),
215
- ...(typeof message === 'string' ? { message } : {}),
216
- ...(typeof record.http_status === 'number' || record.http_status === null
217
- ? { http_status: record.http_status }
218
- : {}),
219
- });
220
- }
221
- }
222
- return [...byTitle.values()].sort((a, b) => a.title.localeCompare(b.title));
296
+ return summarizeWith(fanout, verdict, roll, spanReleaseError);
223
297
  }
@@ -101,6 +101,7 @@ export const apiRoutes = {
101
101
  get_api_mcp_config_schema: { method: "GET", path: "/api/mcp-config/schema" },
102
102
  get_api_mcp_status: { method: "GET", path: "/api/mcp-status" },
103
103
  get_api_mcp_status_failed: { method: "GET", path: "/api/mcp-status/failed" },
104
+ get_api_mcp_status_title_advertised_tools: { method: "GET", path: "/api/mcp-status/{title}/advertised-tools" },
104
105
  get_api_notifications: { method: "GET", path: "/api/notifications" },
105
106
  get_api_observability_capabilities: { method: "GET", path: "/api/observability/capabilities" },
106
107
  get_api_observability_metrics: { method: "GET", path: "/api/observability/metrics" },
@@ -216,7 +217,6 @@ export const apiRoutes = {
216
217
  post_api_mcp_config_entries: { method: "POST", path: "/api/mcp-config/entries" },
217
218
  post_api_mcp_config_secret_env: { method: "POST", path: "/api/mcp-config/secret-env" },
218
219
  post_api_mcp_status_reload_failed: { method: "POST", path: "/api/mcp-status/reload-failed" },
219
- post_api_mcp_status_title_advertised_tools: { method: "POST", path: "/api/mcp-status/{title}/advertised-tools" },
220
220
  post_api_mcp_status_title_deregister: { method: "POST", path: "/api/mcp-status/{title}/deregister" },
221
221
  post_api_mcp_status_title_reload: { method: "POST", path: "/api/mcp-status/{title}/reload" },
222
222
  post_api_notifications: { method: "POST", path: "/api/notifications" },
@@ -181,16 +181,16 @@ export type FanoutSummary = z.infer<typeof fanoutSummary>;
181
181
  export const freshLife = z.object({ "generation": z.number().int(), "kind": z.string(), "name": z.string() });
182
182
  export type FreshLife = z.infer<typeof freshLife>;
183
183
 
184
- export const recycleEntry = z.object({ "detail": z.string().nullable().default(null), "generation_before": z.number().int(), "kind": z.string(), "name": z.string(), "status": z.string() });
184
+ export const recycleEntry = z.object({ "detail": z.string().nullable().default(null), "generation_before": z.number().int(), "keys": z.array(z.string()), "kind": z.string(), "name": z.string(), "status": z.string() });
185
185
  export type RecycleEntry = z.infer<typeof recycleEntry>;
186
186
 
187
187
  export const recycleStop = z.object({ "detail": z.string(), "kind": z.string(), "name": z.string().nullable() });
188
188
  export type RecycleStop = z.infer<typeof recycleStop>;
189
189
 
190
- export const recycleRoll = z.object({ "fresh": z.array(freshLife), "recycle": z.array(recycleEntry), "recycle_stopped": recycleStop.nullable().default(null) });
190
+ export const recycleRoll = z.object({ "fresh": z.array(freshLife), "recycle": z.array(recycleEntry), "recycle_stopped": recycleStop.nullable().default(null), "skipped": z.array(z.string()) });
191
191
  export type RecycleRoll = z.infer<typeof recycleRoll>;
192
192
 
193
- export const applyResponse = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "env_keys": z.number().int(), "fanout": fanoutSummary, "recycle": recycleRoll.nullable().default(null), "span_release_error": z.string().nullable().default(null), "status": z.string() });
193
+ export const applyResponse = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "env_keys": z.number().int(), "fanout": fanoutSummary, "recycle": recycleRoll.nullable().default(null), "roll_deferred": z.boolean().default(false), "roll_deferred_to": z.string().nullable().default(null), "span_release_error": z.string().nullable().default(null), "status": z.string() });
194
194
  export type ApplyResponse = z.infer<typeof applyResponse>;
195
195
 
196
196
  export const applyResult = z.object({ "applied": z.boolean(), "data": z.record(z.string(), z.unknown()).nullable().default(null), "seq": z.number().nullable().default(null), "skipped": z.array(z.record(z.string(), z.unknown())).default([]) }).strict();
@@ -238,7 +238,7 @@ export type BackupExportDocument = z.infer<typeof backupExportDocument>;
238
238
  export const backupImport = z.object({ "document": z.record(z.string(), z.unknown()), "mode": z.enum(["skip","overwrite"]).default("skip"), "sections": z.array(z.string()) });
239
239
  export type BackupImport = z.infer<typeof backupImport>;
240
240
 
241
- export const backupSectionReport = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "created": z.number().int().default(0), "details": z.record(z.string(), z.unknown()).default({}), "errors": z.array(z.string()).default([]), "fanout": fanoutSummary.nullable().default(null), "recycle": recycleRoll.nullable().default(null), "skipped": z.number().int().default(0), "span_release_error": z.string().nullable().default(null), "updated": z.number().int().default(0) }).strict();
241
+ export const backupSectionReport = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "created": z.number().int().default(0), "details": z.record(z.string(), z.unknown()).default({}), "errors": z.array(z.string()).default([]), "fanout": fanoutSummary.nullable().default(null), "recycle": recycleRoll.nullable().default(null), "roll_deferred": z.boolean().default(false), "roll_deferred_to": z.string().nullable().default(null), "skipped": z.number().int().default(0), "span_release_error": z.string().nullable().default(null), "updated": z.number().int().default(0) }).strict();
242
242
  export type BackupSectionReport = z.infer<typeof backupSectionReport>;
243
243
 
244
244
  export const backupImportResult = z.object({ "ok": z.boolean(), "sections": z.record(z.string(), backupSectionReport) });
@@ -424,6 +424,9 @@ export type OpOutcome = z.infer<typeof opOutcome>;
424
424
  export const workerResult = z.object({ "detail": z.string().nullable().default(null), "error": z.string().nullable().default(null), "name": z.string(), "outcome": opOutcome, "payload": z.unknown().nullable().default(null) });
425
425
  export type WorkerResult = z.infer<typeof workerResult>;
426
426
 
427
+ export const fleetReloadResponse = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "error": z.string().nullable().default(null), "local_only": z.boolean().default(false), "ok": z.boolean().readonly(), "op": z.string(), "reachable": z.boolean().default(true), "recycle": recycleRoll.nullable().default(null), "results": z.array(workerResult).default([]), "roll_deferred": z.boolean().default(false), "roll_deferred_to": z.string().nullable().default(null) });
428
+ export type FleetReloadResponse = z.infer<typeof fleetReloadResponse>;
429
+
427
430
  export const fleetResult = z.object({ "error": z.string().nullable().default(null), "local_only": z.boolean().default(false), "ok": z.boolean().readonly(), "op": z.string(), "reachable": z.boolean().default(true), "results": z.array(workerResult).default([]) });
428
431
  export type FleetResult = z.infer<typeof fleetResult>;
429
432
 
@@ -568,7 +571,7 @@ export type LoginMethodsListing = z.infer<typeof loginMethodsListing>;
568
571
  export const logoutResult = z.object({ "end_session_url": z.string().nullable().default(null), "revoked": z.boolean() });
569
572
  export type LogoutResult = z.infer<typeof logoutResult>;
570
573
 
571
- export const mCPConfig = z.object({ "args": z.array(z.string()).default([]), "command": z.string().nullable().default(null), "env": z.record(z.string(), z.string()).default({}), "headers": z.record(z.string(), z.string()).default({}), "type": z.string().nullable().default(null), "uds": z.string().nullable().default(null), "url": z.string().nullable().default(null) }).strict();
574
+ export const mCPConfig = z.object({ "args": z.array(z.string()).default([]), "command": z.string().nullable().default(null), "env": z.record(z.string(), z.string()).default({}), "headers": z.record(z.string(), z.string()).default({}), "type": z.enum(["http","uds","stdio"]).nullable().default(null), "uds": z.string().nullable().default(null), "url": z.string().nullable().default(null) }).strict();
572
575
  export type MCPConfig = z.infer<typeof mCPConfig>;
573
576
 
574
577
  export const manifestExtensionMap = z.object({ "extensions": z.record(z.string(), z.array(z.array(z.union([z.string(), z.record(z.string(), z.unknown())])))), "title": z.string() });
@@ -592,7 +595,7 @@ export type MarketplaceUninstall = z.infer<typeof marketplaceUninstall>;
592
595
  export const marketplaceUpdate = z.object({ "accept_public_routes": z.boolean().default(false), "env": z.record(z.string(), z.string()).nullable().default(null), "ref": z.string(), "route_mounts": z.record(z.string(), z.string()).nullable().default(null), "secret_keys": z.array(z.string()).nullable().default(null), "version": z.string().nullable().default(null) });
593
596
  export type MarketplaceUpdate = z.infer<typeof marketplaceUpdate>;
594
597
 
595
- export const mcpAdvertisedTool = z.object({ "bound": z.boolean(), "description": z.string().nullable(), "name": z.string(), "selected": z.boolean(), "title": z.string().nullable(), "unbound_reason": z.enum(["server_failed","not_loaded","preset_conflict","unusable_schema","not_listed_at_bind"]).nullable() });
598
+ export const mcpAdvertisedTool = z.object({ "bound": z.boolean(), "description": z.string().nullable(), "name": z.string(), "selected": z.boolean(), "title": z.string().nullable(), "unbound_reason": z.enum(["preset_conflict","unusable_schema","pending_bind"]).nullable() });
596
599
  export type McpAdvertisedTool = z.infer<typeof mcpAdvertisedTool>;
597
600
 
598
601
  export const mcpAdvertisedTools = z.object({ "exclude": z.array(z.string()), "include": z.array(z.string()), "title": z.string(), "tools": z.array(mcpAdvertisedTool), "unadvertised": z.array(z.string()) });
@@ -814,7 +817,7 @@ export type PrincipalRef = z.infer<typeof principalRef>;
814
817
  export const principalUpdate = z.object({ "disabled": z.boolean().nullable().default(null), "display_name": z.string().min(1).nullable().default(null) });
815
818
  export type PrincipalUpdate = z.infer<typeof principalUpdate>;
816
819
 
817
- export const profileApplyResponse = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "fanout": fanoutSummary, "fresh": z.array(freshLife), "hot": z.array(z.string()), "recycle": z.array(recycleEntry), "recycle_stopped": recycleStop.nullable().default(null), "refused": z.array(z.string()), "span_release_error": z.string().nullable().default(null) });
820
+ export const profileApplyResponse = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "fanout": fanoutSummary, "fresh": z.array(freshLife), "hot": z.array(z.string()), "recycle": z.array(recycleEntry), "recycle_stopped": recycleStop.nullable().default(null), "refused": z.array(z.string()), "roll_deferred": z.boolean().default(false), "roll_deferred_to": z.string().nullable().default(null), "skipped": z.array(z.string()), "span_release_error": z.string().nullable().default(null) });
818
821
  export type ProfileApplyResponse = z.infer<typeof profileApplyResponse>;
819
822
 
820
823
  export const profileDiffChange = z.object({ "key": z.string(), "new": z.string(), "old": z.string() });
@@ -1318,7 +1321,7 @@ export type ToolRunView = z.infer<typeof toolRunView>;
1318
1321
  export const toolSchemaView = z.object({ "description": z.string().nullable(), "input": z.record(z.string(), jsonValue), "output": z.record(z.string(), jsonValue).nullable() });
1319
1322
  export type ToolSchemaView = z.infer<typeof toolSchemaView>;
1320
1323
 
1321
- export const toolTagRow = z.object({ "badges": z.array(z.string()), "hidden": z.boolean(), "name": z.string(), "schedulable": z.boolean(), "tags": z.array(z.string()) });
1324
+ export const toolTagRow = z.object({ "badges": z.array(z.string()), "description": z.string().nullable(), "hidden": z.boolean(), "name": z.string(), "schedulable": z.boolean(), "tags": z.array(z.string()) });
1322
1325
  export type ToolTagRow = z.infer<typeof toolTagRow>;
1323
1326
 
1324
1327
  export const toolTagListResponse = z.array(toolTagRow);
@@ -1354,13 +1357,13 @@ export type TriggerLinkView = z.infer<typeof triggerLinkView>;
1354
1357
  export const triggerLinkListView = z.object({ "items": z.array(triggerLinkView), "total": z.number().int() });
1355
1358
  export type TriggerLinkListView = z.infer<typeof triggerLinkListView>;
1356
1359
 
1357
- export const uninstallResult = z.object({ "notes": z.array(z.string()), "ref": z.string(), "reload": applyResponse.nullable(), "uninstalled": z.boolean() });
1360
+ export const uninstallResult = z.object({ "manifest_written": z.boolean(), "notes": z.array(z.string()), "ref": z.string(), "reload": applyResponse.nullable(), "uninstalled": z.boolean() });
1358
1361
  export type UninstallResult = z.infer<typeof uninstallResult>;
1359
1362
 
1360
1363
  export const upgradeRow = z.object({ "detail": z.string(), "outcome": z.enum(["upgraded","up-to-date","no-compatible-version","failed"]), "ref": z.string(), "span_release_error": z.string().nullable() });
1361
1364
  export type UpgradeRow = z.infer<typeof upgradeRow>;
1362
1365
 
1363
- export const upgradeAllResult = z.object({ "results": z.array(upgradeRow) });
1366
+ export const upgradeAllResult = z.object({ "awaiting_respawn": z.array(awaitingWorker).default([]), "recycle": recycleRoll.nullable().default(null), "results": z.array(upgradeRow), "roll_deferred": z.boolean().default(false), "roll_deferred_to": z.string().nullable().default(null) });
1364
1367
  export type UpgradeAllResult = z.infer<typeof upgradeAllResult>;
1365
1368
 
1366
1369
  export const urlAck = z.object({ "url": z.string() });
@@ -1480,6 +1483,7 @@ export const responseSchemas = {
1480
1483
  get_api_mcp_config_schema: opaqueJson,
1481
1484
  get_api_mcp_status: mcpStatusSnapshot,
1482
1485
  get_api_mcp_status_failed: fleetResult,
1486
+ get_api_mcp_status_title_advertised_tools: mcpAdvertisedTools,
1483
1487
  get_api_notifications: notificationListing,
1484
1488
  get_api_observability_capabilities: observabilityCapabilities,
1485
1489
  get_api_observability_metrics: metricsResult,
@@ -1554,7 +1558,7 @@ export const responseSchemas = {
1554
1558
  post_api_config_profiles_name_apply: profileApplyResponse,
1555
1559
  post_api_config_profiles_name_diff: profileDiff,
1556
1560
  post_api_config_profiles_name_rollback: profileWriteResult,
1557
- post_api_config_reload: fleetResult,
1561
+ post_api_config_reload: fleetReloadResponse,
1558
1562
  post_api_connectors_connections_connection_id_reconnect: startConnectResponse,
1559
1563
  post_api_connectors_connections_start: startConnectOutcome,
1560
1564
  post_api_connectors_oauth_complete: oAuthCompletionResult,
@@ -1567,7 +1571,7 @@ export const responseSchemas = {
1567
1571
  post_api_conversations_route_name_thread_messages: threadMessageAck,
1568
1572
  post_api_delete_template: templateDeleteResult,
1569
1573
  post_api_delete_template_dir: templateDeleteResult,
1570
- post_api_fleet_reload_config: fleetResult,
1574
+ post_api_fleet_reload_config: fleetReloadResponse,
1571
1575
  post_api_hook_runs_id_retry: hookRunView,
1572
1576
  post_api_hooks: hookRegisterResult,
1573
1577
  post_api_hooks_trigger_links: triggerLinkCreated,
@@ -1587,7 +1591,6 @@ export const responseSchemas = {
1587
1591
  post_api_mcp_config_entries: applyResponse,
1588
1592
  post_api_mcp_config_secret_env: applyResponse,
1589
1593
  post_api_mcp_status_reload_failed: fleetResult,
1590
- post_api_mcp_status_title_advertised_tools: mcpAdvertisedTools,
1591
1594
  post_api_mcp_status_title_deregister: fleetResult,
1592
1595
  post_api_mcp_status_title_reload: fleetResult,
1593
1596
  post_api_notifications: notifyResult,
@@ -5876,7 +5876,7 @@ export const servedDocumentsJson = {
5876
5876
  }
5877
5877
  },
5878
5878
  "additionalProperties": false,
5879
- "description": "One row of the schedule listing: no arguments, no kwargs.",
5879
+ "description": "One row of the schedule listing: no arguments, no kwargs.\n\n``next_run_at_ts`` is the next run's POSIX timestamp, ``None`` when the schedule has no next\nrun (``0.0`` is a timestamp like any other). ``next_run_at_iso`` is derived from it, the UTC\nISO-8601 form or ``None``: a row is built without it, and a given value that disagrees with\nthe timestamp is refused.",
5880
5880
  "properties": {
5881
5881
  "cadence": {
5882
5882
  "discriminator": {
package/src/http.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  import type { z } from 'zod';
11
11
 
12
12
  import { ApiConflictError, ApiError, ApiSchemaError, ApiUnauthorizedError } from './errors';
13
+ import { checkFailedReplyRoll } from './failed-reply-roll';
13
14
  import { API_KEY_HEADER } from './headers';
14
15
 
15
16
  /** Supplies the current API key (in-memory or sessionStorage-backed) + base URL. */
@@ -109,8 +110,9 @@ function retryAfterSeconds(header: string | null): number | undefined {
109
110
  * Read the JSON body of a request response, applying the transport's error
110
111
  * policy: a non-2xx status throws (a 409 as `ApiConflictError` carrying the
111
112
  * parsed body, every other as `ApiError` with the server message/code and the
112
- * named `Retry-After` delay), and a body that is not JSON throws `ApiSchemaError`
113
- * on a 2xx or `ApiError` otherwise. Returns the parsed payload only for a 2xx.
113
+ * named `Retry-After` delay), a non-2xx whose recycle roll does not match its schema
114
+ * throws `ApiSchemaError`, and a body that is not JSON throws `ApiSchemaError` on a
115
+ * 2xx or `ApiError` otherwise. Returns the parsed payload only for a 2xx.
114
116
  */
115
117
  async function readJsonPayload(
116
118
  response: Response,
@@ -131,6 +133,7 @@ async function readJsonPayload(
131
133
  }
132
134
 
133
135
  if (!response.ok) {
136
+ checkFailedReplyRoll(path, payload);
134
137
  const { message, code } = extractError(payload);
135
138
  const text = message ?? (response.statusText || 'request failed');
136
139
  // The parsed body rides the error so a caller can key a follow-up on its structured
package/src/index.ts CHANGED
@@ -62,18 +62,23 @@ export {
62
62
  ApiSetupFailedError,
63
63
  ApiUnauthorizedError,
64
64
  } from './errors';
65
+ export type { FailedMcpEntry } from './failed-mcp-roster';
66
+ export { failedMcpsFromReport } from './failed-mcp-roster';
67
+ export type { FailedReplyRoll } from './failed-reply-roll';
68
+ export { failedReplyRoll } from './failed-reply-roll';
65
69
  export type {
66
- FailedMcpEntry,
70
+ AwaitingRestartReading,
67
71
  FleetFailureOutcome,
72
+ FleetFanoutReply,
68
73
  FleetReportStatus,
69
74
  FleetReportSummary,
70
75
  FleetWorkerAwaitingRespawn,
71
76
  FleetWorkerFailure,
72
77
  } from './fleet-report';
73
78
  export {
74
- failedMcpsFromReport,
75
79
  isFleetReportFailure,
76
80
  summarizeFleetFanout,
81
+ summarizeFleetReload,
77
82
  summarizeFleetResult,
78
83
  } from './fleet-report';
79
84
  export type { ApiOperationId, ApiPathPrefix, ApiPathTemplate } from './generated/api-routes';
@@ -81,6 +86,7 @@ export { apiPathPrefixes, apiRoutes, buildPath } from './generated/api-routes';
81
86
  export { API_KEY_HEADER } from './headers';
82
87
  export type { ApiConfig, RequestOptions } from './http';
83
88
  export { apiDownload, apiRequest, apiText } from './http';
89
+ export { isMcpStarting } from './mcp-failure';
84
90
  export type {
85
91
  AnswerFormat,
86
92
  AnswerPageWording,
@@ -91,6 +97,7 @@ export type {
91
97
  AttachmentMediaKind,
92
98
  AuthCapabilities,
93
99
  AuthRoute,
100
+ AwaitingWorker,
94
101
  BackendInfo,
95
102
  BackupDocument,
96
103
  BackupExportDocument,