@hyperwindmill/caretaker-cli 0.36.0 → 0.37.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.
- package/dist/cli/orchestrator_demo.d.ts +2 -0
- package/dist/cli/orchestrator_demo.d.ts.map +1 -1
- package/dist/cli/orchestrator_demo.js +3 -1
- package/dist/cli/web/orchestrator.d.ts +4 -1
- package/dist/cli/web/orchestrator.d.ts.map +1 -1
- package/dist/cli/web/orchestrator.js +57 -24
- package/dist/cli/web/orchestrator_core.d.ts +2 -0
- package/dist/cli/web/orchestrator_core.d.ts.map +1 -1
- package/dist/cli/web/orchestrator_core.js +4 -0
- package/package.json +3 -3
|
@@ -29,6 +29,8 @@ export interface DemoOrchestrator {
|
|
|
29
29
|
export declare function createDemoOrchestrator(opts: {
|
|
30
30
|
token: string;
|
|
31
31
|
name?: string;
|
|
32
|
+
/** Called when a result is first recorded, before the poll response is built. */
|
|
33
|
+
onResult?: (instanceId: string, result: DemoResult) => void;
|
|
32
34
|
}): DemoOrchestrator;
|
|
33
35
|
export declare function startDemoOrchestrator(opts: {
|
|
34
36
|
port: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator_demo.d.ts","sourceRoot":"","sources":["../../src/cli/orchestrator_demo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAA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C;IAC3F,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,EAAE,CAAC;IAC1C,SAAS,IAAI,YAAY,EAAE,CAAC;CAC7B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CAC7D,GAAG,gBAAgB,CA2GnB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAYP"}
|
|
@@ -65,7 +65,9 @@ export function createDemoOrchestrator(opts) {
|
|
|
65
65
|
}
|
|
66
66
|
for (const r of body.results ?? []) {
|
|
67
67
|
if (r && typeof r.id === 'string' && !instResults.has(r.id)) {
|
|
68
|
-
|
|
68
|
+
const recorded = { id: r.id, status: r.status, body: r.body ?? null };
|
|
69
|
+
instResults.set(r.id, recorded);
|
|
70
|
+
opts.onResult?.(instanceId, recorded);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
const pending = (queues.get(instanceId) ?? []).filter((m) => !instResults.has(m.id));
|
|
@@ -14,6 +14,8 @@ export interface OrchestratorStatus {
|
|
|
14
14
|
lastPollAt?: string;
|
|
15
15
|
lastError?: string;
|
|
16
16
|
}
|
|
17
|
+
/** Floor between two cycles while results wait; pollSeconds is the maximum gap. */
|
|
18
|
+
export declare const EARLY_POLL_MS = 250;
|
|
17
19
|
/**
|
|
18
20
|
* Runs one request against the in-process Hono app. Never throws.
|
|
19
21
|
* Refuses (404) when the normalized pathname is not documented in OpenAPI.
|
|
@@ -25,8 +27,9 @@ export declare function applyMessage(app: AppLike, msg: RemoteMessage): Promise<
|
|
|
25
27
|
}>;
|
|
26
28
|
/**
|
|
27
29
|
* One register-if-needed + poll cycle. Never throws; failures land in status.
|
|
30
|
+
* Resolves true when the poll round-trip succeeded.
|
|
28
31
|
*/
|
|
29
|
-
export declare function runCycle(deps: CycleDeps): Promise<
|
|
32
|
+
export declare function runCycle(deps: CycleDeps): Promise<boolean>;
|
|
30
33
|
/**
|
|
31
34
|
* Approves or rejects a pending ledger message.
|
|
32
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/cli/web/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAUjC,OAAO,
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/cli/web/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAUjC,OAAO,EAaL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACzE,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,GAAG,aAAa,GAAG,WAAW,GAAG,OAAO,CAAC;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,mFAAmF;AACnF,eAAO,MAAM,aAAa,MAAM,CAAC;AAkEjC;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CA2C5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAO1D;AAgRD;;GAEG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAC7B,OAAO,CAAC,IAAI,GAAG,WAAW,GAAG,aAAa,CAAC,CA4C7C;AAED,wBAAgB,kBAAkB,IAAI,kBAAkB,CAEvD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED,mEAAmE;AACnE,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAQvC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,GAAE,OAAO,KAAa,GAAG,IAAI,CAkCrF;AAqBD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,GAAE,OAAO,KAAa,GAAG,IAAI,CAqGrF"}
|
|
@@ -2,14 +2,20 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { decrypt, encrypt } from '../../lib/encryption.js';
|
|
3
3
|
import { loadLedger, loadOrchestrator, saveLedger, saveOrchestrator, } from '../../store/orchestrator.js';
|
|
4
4
|
import { isDocumentedRoute } from './openapi.js';
|
|
5
|
-
import { endpointUrl, MAX_BODY_BYTES, mergeConfigSave, needsApproval, parseMessage, PROTOCOL_VERSION, recoverLedger, summarizeLedger, trimLedger, validateEndpoint, } from './orchestrator_core.js';
|
|
5
|
+
import { endpointUrl, isUndeliveredResult, MAX_BODY_BYTES, mergeConfigSave, needsApproval, parseMessage, PROTOCOL_VERSION, recoverLedger, summarizeLedger, trimLedger, validateEndpoint, } from './orchestrator_core.js';
|
|
6
6
|
import { sameHost } from './voice_proxy.js';
|
|
7
7
|
const OUTBOUND_TIMEOUT_MS = 30_000;
|
|
8
|
+
/** Floor between two cycles while results wait; pollSeconds is the maximum gap. */
|
|
9
|
+
export const EARLY_POLL_MS = 250;
|
|
8
10
|
let status = { state: 'off' };
|
|
9
11
|
let registered = false;
|
|
10
12
|
let recoveredThisProcess = false;
|
|
11
13
|
let ledgerMutex = Promise.resolve();
|
|
12
14
|
let loopTimer = null;
|
|
15
|
+
/** The running loop's tick, for pollSoon(); null when no loop runs. */
|
|
16
|
+
let loopTick = null;
|
|
17
|
+
/** A result was produced outside the loop (approve/reject) while a cycle ran. */
|
|
18
|
+
let wakeRequested = false;
|
|
13
19
|
let loopGen = 0;
|
|
14
20
|
/** Bumped by every config save. A cycle that started under an older generation
|
|
15
21
|
* stops touching the ledger, the registration and the status: after a host
|
|
@@ -104,10 +110,11 @@ export async function applyMessage(app, msg) {
|
|
|
104
110
|
}
|
|
105
111
|
/**
|
|
106
112
|
* One register-if-needed + poll cycle. Never throws; failures land in status.
|
|
113
|
+
* Resolves true when the poll round-trip succeeded.
|
|
107
114
|
*/
|
|
108
115
|
export function runCycle(deps) {
|
|
109
116
|
const run = cycleChain.then(() => cycleOnce(deps));
|
|
110
|
-
cycleChain = run.
|
|
117
|
+
cycleChain = run.then(() => undefined, () => undefined);
|
|
111
118
|
return run;
|
|
112
119
|
}
|
|
113
120
|
async function cycleOnce(deps) {
|
|
@@ -118,17 +125,17 @@ async function cycleOnce(deps) {
|
|
|
118
125
|
await ensureRecovered(now);
|
|
119
126
|
const cfg = await loadOrchestrator();
|
|
120
127
|
if (stale())
|
|
121
|
-
return;
|
|
128
|
+
return false;
|
|
122
129
|
if (!cfg.enabled) {
|
|
123
130
|
registered = false;
|
|
124
131
|
status = { state: 'off' };
|
|
125
|
-
return;
|
|
132
|
+
return false;
|
|
126
133
|
}
|
|
127
134
|
const token = cfg.token ? decrypt(cfg.token) : '';
|
|
128
135
|
if (!cfg.endpoint || !token) {
|
|
129
136
|
registered = false;
|
|
130
137
|
status = { state: 'error', lastError: 'Endpoint and token are required.' };
|
|
131
|
-
return;
|
|
138
|
+
return false;
|
|
132
139
|
}
|
|
133
140
|
const headers = {
|
|
134
141
|
authorization: `Bearer ${token}`,
|
|
@@ -152,10 +159,10 @@ async function cycleOnce(deps) {
|
|
|
152
159
|
signal: AbortSignal.timeout(OUTBOUND_TIMEOUT_MS),
|
|
153
160
|
});
|
|
154
161
|
if (stale())
|
|
155
|
-
return;
|
|
162
|
+
return false;
|
|
156
163
|
if (!regRes.ok) {
|
|
157
164
|
status = { ...status, state: 'error', lastError: `Register failed: HTTP ${regRes.status}` };
|
|
158
|
-
return;
|
|
165
|
+
return false;
|
|
159
166
|
}
|
|
160
167
|
let regData;
|
|
161
168
|
try {
|
|
@@ -163,15 +170,15 @@ async function cycleOnce(deps) {
|
|
|
163
170
|
}
|
|
164
171
|
catch {
|
|
165
172
|
if (stale())
|
|
166
|
-
return;
|
|
173
|
+
return false;
|
|
167
174
|
status = { ...status, state: 'error', lastError: 'Register returned non-JSON response.' };
|
|
168
|
-
return;
|
|
175
|
+
return false;
|
|
169
176
|
}
|
|
170
177
|
if (stale())
|
|
171
|
-
return;
|
|
178
|
+
return false;
|
|
172
179
|
if (!regData || typeof regData !== 'object' || regData.ok !== true) {
|
|
173
180
|
status = { ...status, state: 'error', lastError: 'Register response did not confirm ok.' };
|
|
174
|
-
return;
|
|
181
|
+
return false;
|
|
175
182
|
}
|
|
176
183
|
const orchName = typeof regData.name === 'string'
|
|
177
184
|
? regData.name
|
|
@@ -186,7 +193,7 @@ async function cycleOnce(deps) {
|
|
|
186
193
|
const pendingResults = await withLedgerLock(async () => {
|
|
187
194
|
const records = await loadLedger();
|
|
188
195
|
return records
|
|
189
|
-
.filter(
|
|
196
|
+
.filter(isUndeliveredResult)
|
|
190
197
|
.map((r) => ({
|
|
191
198
|
id: r.id,
|
|
192
199
|
status: r.result.status,
|
|
@@ -203,18 +210,18 @@ async function cycleOnce(deps) {
|
|
|
203
210
|
signal: AbortSignal.timeout(OUTBOUND_TIMEOUT_MS),
|
|
204
211
|
});
|
|
205
212
|
if (stale())
|
|
206
|
-
return;
|
|
213
|
+
return false;
|
|
207
214
|
if (pollRes.status === 401 ||
|
|
208
215
|
pollRes.status === 403 ||
|
|
209
216
|
pollRes.status === 404 ||
|
|
210
217
|
pollRes.status === 409) {
|
|
211
218
|
registered = false;
|
|
212
219
|
status = { ...status, state: 'error', lastError: `Poll rejected: HTTP ${pollRes.status}` };
|
|
213
|
-
return;
|
|
220
|
+
return false;
|
|
214
221
|
}
|
|
215
222
|
if (!pollRes.ok) {
|
|
216
223
|
status = { ...status, state: 'error', lastError: `Poll failed: HTTP ${pollRes.status}` };
|
|
217
|
-
return;
|
|
224
|
+
return false;
|
|
218
225
|
}
|
|
219
226
|
let pollData;
|
|
220
227
|
try {
|
|
@@ -222,18 +229,18 @@ async function cycleOnce(deps) {
|
|
|
222
229
|
}
|
|
223
230
|
catch {
|
|
224
231
|
if (stale())
|
|
225
|
-
return;
|
|
232
|
+
return false;
|
|
226
233
|
status = { ...status, state: 'error', lastError: 'Poll returned non-JSON response.' };
|
|
227
|
-
return;
|
|
234
|
+
return false;
|
|
228
235
|
}
|
|
229
236
|
if (stale())
|
|
230
|
-
return;
|
|
237
|
+
return false;
|
|
231
238
|
if (!pollData ||
|
|
232
239
|
typeof pollData !== 'object' ||
|
|
233
240
|
Array.isArray(pollData) ||
|
|
234
241
|
!Array.isArray(pollData.messages)) {
|
|
235
242
|
status = { ...status, state: 'error', lastError: 'Poll response missing messages array.' };
|
|
236
|
-
return;
|
|
243
|
+
return false;
|
|
237
244
|
}
|
|
238
245
|
if (pendingResults.length > 0) {
|
|
239
246
|
const deliveredIds = new Set(pendingResults.map((r) => r.id));
|
|
@@ -261,7 +268,7 @@ async function cycleOnce(deps) {
|
|
|
261
268
|
const messages = pollData.messages;
|
|
262
269
|
for (const raw of messages) {
|
|
263
270
|
if (stale())
|
|
264
|
-
return;
|
|
271
|
+
return false;
|
|
265
272
|
const parsed = parseMessage(raw);
|
|
266
273
|
if (parsed === null) {
|
|
267
274
|
status = { ...status, lastError: 'The orchestrator sent a message without an id.' };
|
|
@@ -356,10 +363,23 @@ async function cycleOnce(deps) {
|
|
|
356
363
|
await saveLedger(trimLedger(records));
|
|
357
364
|
});
|
|
358
365
|
}
|
|
366
|
+
return true;
|
|
359
367
|
}
|
|
360
368
|
catch (err) {
|
|
361
369
|
if (!stale())
|
|
362
370
|
status = { ...status, state: 'error', lastError: oneLineError(err) };
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async function hasUndeliveredResults() {
|
|
375
|
+
return withLedgerLock(async () => (await loadLedger()).some(isUndeliveredResult));
|
|
376
|
+
}
|
|
377
|
+
/** Brings the next poll forward to EARLY_POLL_MS. A cycle in flight reads the flag when it reschedules. */
|
|
378
|
+
function pollSoon() {
|
|
379
|
+
wakeRequested = true;
|
|
380
|
+
if (loopTimer !== null && loopTick !== null) {
|
|
381
|
+
clearTimeout(loopTimer);
|
|
382
|
+
loopTimer = setTimeout(loopTick, EARLY_POLL_MS);
|
|
363
383
|
}
|
|
364
384
|
}
|
|
365
385
|
/**
|
|
@@ -391,6 +411,8 @@ export async function resolvePending(app, id, decision) {
|
|
|
391
411
|
await saveLedger(trimLedger(records));
|
|
392
412
|
return { status: 'apply', msg };
|
|
393
413
|
});
|
|
414
|
+
if (step.status === 'ok')
|
|
415
|
+
pollSoon();
|
|
394
416
|
if (step.status !== 'apply')
|
|
395
417
|
return step.status;
|
|
396
418
|
const applied = await applyMessage(app, step.msg);
|
|
@@ -406,6 +428,7 @@ export async function resolvePending(app, id, decision) {
|
|
|
406
428
|
rec.result = { status: applied.status, body: encryptJson(applied.body) };
|
|
407
429
|
await saveLedger(trimLedger(records));
|
|
408
430
|
});
|
|
431
|
+
pollSoon();
|
|
409
432
|
return 'ok';
|
|
410
433
|
}
|
|
411
434
|
export function orchestratorStatus() {
|
|
@@ -433,6 +456,8 @@ export function stopOrchestrator() {
|
|
|
433
456
|
clearTimeout(loopTimer);
|
|
434
457
|
loopTimer = null;
|
|
435
458
|
}
|
|
459
|
+
loopTick = null;
|
|
460
|
+
wakeRequested = false;
|
|
436
461
|
}
|
|
437
462
|
/**
|
|
438
463
|
* (Re)starts the self-rescheduling poll loop from the saved config.
|
|
@@ -444,9 +469,12 @@ export function startOrchestrator(app, fetchImpl = fetch) {
|
|
|
444
469
|
const tick = async () => {
|
|
445
470
|
if (gen !== loopGen)
|
|
446
471
|
return;
|
|
472
|
+
loopTimer = null; // a wake during this cycle must not start a second chain
|
|
473
|
+
wakeRequested = false; // this cycle delivers whatever already exists
|
|
474
|
+
let ok = false;
|
|
447
475
|
try {
|
|
448
476
|
await ensureRecovered(new Date());
|
|
449
|
-
await runCycle({ app, fetch: fetchImpl });
|
|
477
|
+
ok = await runCycle({ app, fetch: fetchImpl });
|
|
450
478
|
}
|
|
451
479
|
catch (err) {
|
|
452
480
|
console.error('[orchestrator]', err);
|
|
@@ -454,21 +482,26 @@ export function startOrchestrator(app, fetchImpl = fetch) {
|
|
|
454
482
|
if (gen !== loopGen)
|
|
455
483
|
return;
|
|
456
484
|
let delayMs = 15_000;
|
|
485
|
+
let waiting = false;
|
|
457
486
|
try {
|
|
458
487
|
const cfg = await loadOrchestrator();
|
|
459
488
|
if (!cfg.enabled)
|
|
460
489
|
return;
|
|
461
490
|
delayMs = cfg.pollSeconds * 1000;
|
|
491
|
+
if (ok)
|
|
492
|
+
waiting = await hasUndeliveredResults();
|
|
462
493
|
}
|
|
463
494
|
catch (err) {
|
|
464
495
|
console.error('[orchestrator]', err);
|
|
465
496
|
}
|
|
466
497
|
if (gen !== loopGen)
|
|
467
498
|
return;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
499
|
+
// No await below this line: a wake landing during the checks above is read here.
|
|
500
|
+
if (ok && (waiting || wakeRequested))
|
|
501
|
+
delayMs = EARLY_POLL_MS;
|
|
502
|
+
loopTimer = setTimeout(() => void tick(), delayMs);
|
|
471
503
|
};
|
|
504
|
+
loopTick = () => void tick();
|
|
472
505
|
void tick();
|
|
473
506
|
}
|
|
474
507
|
async function buildView() {
|
|
@@ -80,4 +80,6 @@ export declare function mergeConfigSave(saved: OrchestratorConfig, input: Config
|
|
|
80
80
|
* Request body is included only for `pending` records, with `repositoryToken` masked.
|
|
81
81
|
*/
|
|
82
82
|
export declare function summarizeLedger(records: LedgerRecord[]): MessageSummary[];
|
|
83
|
+
/** A result recorded and not yet acknowledged by a 2xx /poll. */
|
|
84
|
+
export declare function isUndeliveredResult(r: LedgerRecord): boolean;
|
|
83
85
|
//# sourceMappingURL=orchestrator_core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator_core.d.ts","sourceRoot":"","sources":["../../../src/cli/web/orchestrator_core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGxG,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,cAAc,UAAY,CAAC;AACxC,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,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acknowledged by a 2xx /poll. */
|
|
221
|
+
export function isUndeliveredResult(r) {
|
|
222
|
+
return r.state === 'done' && !r.delivered && r.result !== undefined;
|
|
223
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperwindmill/caretaker-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Caretaker — in-process agent harness, TUI, file-based state.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
"typescript": "^5.9.3",
|
|
90
90
|
"typescript-eslint": "^8.72.1",
|
|
91
91
|
"zod": "^4.6.7",
|
|
92
|
-
"caretaker-types": "0.
|
|
93
|
-
"webview-ui": "0.
|
|
92
|
+
"caretaker-types": "0.37.0",
|
|
93
|
+
"webview-ui": "0.37.0"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@agentclientprotocol/sdk": "^2.1.0",
|