dsh-xdpool 2.5.0 → 2.5.1

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/lib/index.d.ts CHANGED
@@ -398,6 +398,15 @@ interface WorkBuddyTask {
398
398
  claimed: boolean;
399
399
  /** Upstream marked the task locked (not yet reachable). */
400
400
  locked: boolean;
401
+ /**
402
+ * The task's own deeplink, verbatim, or '' when it has none.
403
+ *
404
+ * Kept because for the "体验XX专家" family it is the ONLY source of the
405
+ * expert id: those experts are not in the marketplace listing, and the id
406
+ * appears nowhere else (#98). Named after the upstream field so a future
407
+ * reader can find it in a captured JSON body.
408
+ */
409
+ jumpUrl: string;
401
410
  }
402
411
  /**
403
412
  * Flatten one upstream task entry.
@@ -1205,7 +1214,7 @@ export declare class WorkBuddyAccountPool {
1205
1214
  * Counts are over the region's accounts, since a provider only ever sees its
1206
1215
  * own gateway.
1207
1216
  */
1208
- unavailableReason(modelId?: string, region?: WorkBuddyRegion): {
1217
+ unavailableReason(modelId?: string, region?: WorkBuddyRegion, reserveExempt?: ReadonlySet<string>): {
1209
1218
  total: number;
1210
1219
  cooling: number;
1211
1220
  disabled: number;
@@ -1295,9 +1304,11 @@ export declare class WorkBuddyAccountPool {
1295
1304
  * Scans on first use, and rescans when every known account is cooling down: a
1296
1305
  * fresh desktop login is the usual way out of an exhausted pool.
1297
1306
  *
1307
+ * `reserveExempt` is host-only: account ids whose own credentials freshly
1308
+ * confirmed a zero-credit model. It never bypasses disabled, dead credentials, cooldowns or region.
1298
1309
  * `conversationKey` is only consulted under `sticky`; other modes ignore it.
1299
1310
  */
1300
- acquire(modelId?: string, region?: WorkBuddyRegion, conversationKey?: string): Promise<WorkBuddyAccount | undefined>;
1311
+ acquire(modelId?: string, region?: WorkBuddyRegion, conversationKey?: string, reserveExempt?: ReadonlySet<string>): Promise<WorkBuddyAccount | undefined>;
1301
1312
  /** How the pool currently spreads requests. Shown on the card. */
1302
1313
  currentDistribution(): AccountDistribution;
1303
1314
  /**
@@ -1498,77 +1509,6 @@ interface PoolWebChannelModel {
1498
1509
  inputModalities?: readonly string[];
1499
1510
  description?: string;
1500
1511
  }
1501
- /**
1502
- * One billion-context session, reduced to what a dashboard may show.
1503
- *
1504
- * Counts, sizes and timestamps only. The proxy's own rows carry titles and
1505
- * first-block hints, which are the user's words; those stay on the machine that
1506
- * produced them and are not relayed.
1507
- */
1508
- interface PoolWebBillionSession {
1509
- /** The proxy's session id. Safe to show: it is a generated handle. */
1510
- id: string;
1511
- /** Which wire the session speaks; `openai` is what DSH's shim uses. */
1512
- protocol: string;
1513
- /** Whether a request hit this session in the last few seconds. */
1514
- live: boolean;
1515
- requests: number;
1516
- /** The compacted context size the proxy is holding, 0 when unknown. */
1517
- contextTokens: number;
1518
- /** Which measurement the context size came from; `usage` is the honest one. */
1519
- contextTokensSource: string;
1520
- /** Net tokens the proxy says compression saved. */
1521
- tokensSaved: number;
1522
- inputTokens: number;
1523
- cachedTokens: number;
1524
- outputTokens: number;
1525
- /** Cache hit rate 0-100, or -1 when no input tokens were ever counted. */
1526
- cacheHitPct: number;
1527
- /** How many compressed blocks this session holds. */
1528
- blocks: number;
1529
- /** The window the proxy believes the model has, 0 when unknown. */
1530
- contextWindow: number;
1531
- /** ISO timestamp of the last request, or '' when the session never had one. */
1532
- lastSeen: string;
1533
- /** The last model the session saw, or '' before the first request. */
1534
- lastModel: string;
1535
- }
1536
- /** The document {@link POOL_BILLION_PATH} answers with. */
1537
- interface PoolWebBillionStatus {
1538
- /**
1539
- * Whether a proxy was found and answered.
1540
- *
1541
- * `missing` is a normal, expected state, not an error: billion-context is a
1542
- * separate plugin, and a machine without it must get a page that explains
1543
- * that rather than a 503 or a blank panel.
1544
- */
1545
- state: 'ready' | 'missing' | 'unreachable';
1546
- /** Human text for a non-ready state; absent when ready. */
1547
- reason?: string;
1548
- /**
1549
- * The proxy's own loopback origin, absent only when none was recorded.
1550
- *
1551
- * The card needs this to hand the user a browser link: billion-context ships
1552
- * its own dashboard, including a per-session detail view, and duplicating
1553
- * those screens here would be a second and divergent copy of another
1554
- * plugin's interface. Linking out keeps one answer.
1555
- *
1556
- * This is a service address, not conversation material, and it is safe to
1557
- * publish for the same reason the route that carries it is loopback-only: a
1558
- * caller who can read this document can already reach that listener directly.
1559
- * It is present on `unreachable` too — a proxy that recorded its port and
1560
- * then went quiet is exactly the case where the URL is the only handle.
1561
- */
1562
- origin?: string;
1563
- /** The proxy's version, from its own manifest. */
1564
- version?: string;
1565
- /** When the proxy process started (epoch ms), 0 when unknown. */
1566
- startedAt?: number;
1567
- /** Sessions newest-first, capped by the route. */
1568
- sessions: readonly PoolWebBillionSession[];
1569
- /** How many sessions the proxy holds in total, including capped-out ones. */
1570
- totalSessions: number;
1571
- }
1572
1512
  /**
1573
1513
  * Where a registry provider's key goes: `apiKey`, `baseUrl`, or `enabled`.
1574
1514
  */
@@ -3405,6 +3345,16 @@ export declare class WorkBuddyScheduler {
3405
3345
  /** Host hooks that persist the ledger across restarts. */
3406
3346
  private readonly loadEarnings;
3407
3347
  private saveEarningsFn;
3348
+ /**
3349
+ * The most recent ledger write that may still be in flight.
3350
+ *
3351
+ * `persistEarnings` is synchronous from its callers' point of view, but the
3352
+ * host's settings write is not: it is an async document update. Keeping the
3353
+ * promise here is what lets {@link flushEarnings} wait for the write that
3354
+ * matters — the last one before a restart — without making every counter
3355
+ * update await disk.
3356
+ */
3357
+ private pendingEarningsWrite;
3408
3358
  constructor(pool: WorkBuddyAccountPool, client: WorkBuddyUpstreamClient, options?: AutomationOptions);
3409
3359
  /** Apply a new configuration; safe to call while running. */
3410
3360
  /**
@@ -3415,6 +3365,16 @@ export declare class WorkBuddyScheduler {
3415
3365
  * would have nowhere to go.
3416
3366
  */
3417
3367
  setEarningsPersistence(save: (ledger: AutomationLedger) => void | Promise<void>): void;
3368
+ /**
3369
+ * Wait for the ledger write that is (or was last) in flight.
3370
+ *
3371
+ * Called at the END of a task pass, right after the last claim, so the rewards
3372
+ * that were just collected are on disk before a restart can lose them. It is
3373
+ * deliberately NOT awaited on every counter bump: the settings document write
3374
+ * is the slow part, and paying it per account would slow the pass for no
3375
+ * benefit while the process is still alive.
3376
+ */
3377
+ flushEarnings(): Promise<void>;
3418
3378
  /**
3419
3379
  * Fold a previously persisted ledger back in, when it belongs to today.
3420
3380
  *
@@ -3528,6 +3488,14 @@ export declare class WorkBuddyScheduler {
3528
3488
  * Best effort on purpose: a failed save must never abort a run that has
3529
3489
  * already collected rewards, and the in-memory ledger keeps serving the card
3530
3490
  * for the rest of the session either way.
3491
+ *
3492
+ * The returned promise settles when the write has landed (or failed). Callers
3493
+ * that are about to END a run await it: reported in #98, a task pass that
3494
+ * claimed 21 tasks had its process restarted before the volatile settings
3495
+ * write reached disk, so `automationEarnings` still read `credit: 0` while
3496
+ * the upstream had really paid out. Fire-and-forget is fine for a counter the
3497
+ * card will re-read in this process; it is not fine for the last write before
3498
+ * exit.
3531
3499
  */
3532
3500
  private persistEarnings;
3533
3501
  /**
@@ -3584,6 +3552,19 @@ export declare class WorkBuddyScheduler {
3584
3552
  * this is async.
3585
3553
  */
3586
3554
  private chainsFor;
3555
+ /**
3556
+ * Summon-and-use one expert NAMED BY THE TASK.
3557
+ *
3558
+ * Structurally `expertChains` minus the marketplace: the expert id is read
3559
+ * from the task's deeplink instead of by browsing `marketExpertList`, because
3560
+ * this family's experts are not listed there at all (#98 measured 500 entries
3561
+ * across both `agent` and `team`, zero hits).
3562
+ *
3563
+ * Returns `[]` — not a throw — when the task carries no usable id: the caller
3564
+ * logs "could not be built" only for exceptions, and a task shape this code
3565
+ * does not understand is information, not a fault.
3566
+ */
3567
+ private taskExpertChains;
3587
3568
  /**
3588
3569
  * The summon-and-use chains for the expert tasks.
3589
3570
  *
@@ -3985,15 +3966,6 @@ interface PoolStatusRouteOptions {
3985
3966
  * document. The catalog refresh is what makes a new chain pickable at once.
3986
3967
  */
3987
3968
  saveCombos?: (raw: unknown) => Promise<PoolWebCombosStatus>;
3988
- /**
3989
- * What the locally running billion-context proxy is doing, read-only.
3990
- *
3991
- * Absent when the module could not be wired: the route then answers 503
3992
- * rather than pretending a third-party proxy reported nothing. It never
3993
- * rejects — a missing proxy is a normal state with its own `reason`, because
3994
- * billion-context is a separate optional plugin.
3995
- */
3996
- billionDocument?: () => Promise<PoolWebBillionStatus>;
3997
3969
  /**
3998
3970
  * The relay's current state, or undefined when this build has no relay.
3999
3971
  *