@tangle-network/agent-app 0.60.101 → 0.60.102

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.
@@ -19,6 +19,7 @@ import {
19
19
  SandboxRecoveryFailedError,
20
20
  SandboxRuntimeAuthRefreshError,
21
21
  WARM_LEASE_DECLINED_UNTIL_DDL,
22
+ WARM_LEASE_PENDING_DDL,
22
23
  WARM_LEASE_TABLE_DDL,
23
24
  WARM_SLOTS,
24
25
  adaptSandboxStream,
@@ -89,7 +90,7 @@ import {
89
90
  warmBinOf,
90
91
  warmWeekdayOf,
91
92
  writeProfileFilesToBox
92
- } from "../chunk-MWJK4HLU.js";
93
+ } from "../chunk-P2EKAQUB.js";
93
94
  import {
94
95
  EGRESS_PROXY_RECOVERY_PHASE,
95
96
  EGRESS_PROXY_RECOVERY_REQUIRED,
@@ -164,6 +165,7 @@ export {
164
165
  SandboxRuntimeAuthRefreshError,
165
166
  SandboxTransientDeadlineError,
166
167
  WARM_LEASE_DECLINED_UNTIL_DDL,
168
+ WARM_LEASE_PENDING_DDL,
167
169
  WARM_LEASE_TABLE_DDL,
168
170
  WARM_SLOTS,
169
171
  WORKSPACE_SANDBOX_HOST_EXHAUSTED,
@@ -15,9 +15,11 @@ import { type WarmLeaseStore } from './warm-lease';
15
15
  */
16
16
  export declare const DEFAULT_WARM_LEASE_TABLE = "sandbox_warm_lease";
17
17
  /** Paste into a migration. Times are epoch milliseconds; 0 means never. */
18
- export declare const WARM_LEASE_TABLE_DDL = "CREATE TABLE IF NOT EXISTS sandbox_warm_lease (\n key TEXT PRIMARY KEY,\n lease_id TEXT,\n reason TEXT,\n started_at INTEGER NOT NULL DEFAULT 0,\n hold_until INTEGER NOT NULL DEFAULT 0,\n warm_at INTEGER NOT NULL DEFAULT 0,\n used_at INTEGER NOT NULL DEFAULT 0,\n resumed INTEGER NOT NULL DEFAULT 0,\n ping_at INTEGER NOT NULL DEFAULT 0,\n last_turn_at INTEGER NOT NULL DEFAULT 0,\n day TEXT NOT NULL DEFAULT '',\n day_warm_ms INTEGER NOT NULL DEFAULT 0,\n threshold REAL NOT NULL DEFAULT 0,\n slots TEXT NOT NULL DEFAULT '',\n slots_at INTEGER NOT NULL DEFAULT 0,\n first_seen_at INTEGER NOT NULL DEFAULT 0,\n predicted_at INTEGER NOT NULL DEFAULT 0,\n declined_until INTEGER NOT NULL DEFAULT 0\n)";
18
+ export declare const WARM_LEASE_TABLE_DDL = "CREATE TABLE IF NOT EXISTS sandbox_warm_lease (\n key TEXT PRIMARY KEY,\n lease_id TEXT,\n reason TEXT,\n started_at INTEGER NOT NULL DEFAULT 0,\n hold_until INTEGER NOT NULL DEFAULT 0,\n warm_at INTEGER NOT NULL DEFAULT 0,\n used_at INTEGER NOT NULL DEFAULT 0,\n resumed INTEGER NOT NULL DEFAULT 0,\n ping_at INTEGER NOT NULL DEFAULT 0,\n last_turn_at INTEGER NOT NULL DEFAULT 0,\n day TEXT NOT NULL DEFAULT '',\n day_warm_ms INTEGER NOT NULL DEFAULT 0,\n threshold REAL NOT NULL DEFAULT 0,\n slots TEXT NOT NULL DEFAULT '',\n slots_at INTEGER NOT NULL DEFAULT 0,\n first_seen_at INTEGER NOT NULL DEFAULT 0,\n predicted_at INTEGER NOT NULL DEFAULT 0,\n declined_until INTEGER NOT NULL DEFAULT 0,\n pending_warm_at INTEGER NOT NULL DEFAULT 0,\n pending_ms INTEGER NOT NULL DEFAULT 0,\n pending_reason TEXT\n)";
19
19
  /** For a table created from an earlier \`WARM_LEASE_TABLE_DDL\`: paste into a migration. */
20
20
  export declare const WARM_LEASE_DECLINED_UNTIL_DDL = "ALTER TABLE sandbox_warm_lease ADD COLUMN declined_until INTEGER NOT NULL DEFAULT 0";
21
+ /** For a table created before pending charges: paste each into a migration. */
22
+ export declare const WARM_LEASE_PENDING_DDL: readonly ["ALTER TABLE sandbox_warm_lease ADD COLUMN pending_warm_at INTEGER NOT NULL DEFAULT 0", "ALTER TABLE sandbox_warm_lease ADD COLUMN pending_ms INTEGER NOT NULL DEFAULT 0", "ALTER TABLE sandbox_warm_lease ADD COLUMN pending_reason TEXT"];
21
23
  /** The D1 surface this store uses: `prepare().bind()` with `first`, `run` and `all`. A real `D1Database` satisfies it. */
22
24
  export interface WarmLeaseD1Like {
23
25
  prepare(query: string): {
@@ -138,6 +138,12 @@ export interface WarmLeaseRow {
138
138
  /** Signals are refused without calling the product's warm until this time:
139
139
  * set after an 'absent' or 'capacity' outcome, cleared by a turn. */
140
140
  declinedUntil: number;
141
+ /** An ended, unused warm whose box may still be up: settled at the span no
142
+ * turn used, when a turn arrives or its idle window closes. 0 when none. */
143
+ pendingWarmAt: number;
144
+ /** The most the pending warm can be charged: until the box's idle timeout. */
145
+ pendingMs: number;
146
+ pendingReason: string | null;
141
147
  }
142
148
  /** Persistence for leases. `begin` and `markUsed` must be atomic across isolates. */
143
149
  export interface WarmLeaseStore {
@@ -170,6 +176,16 @@ export interface WarmLeaseStore {
170
176
  markPredicted(key: string, at: number): Promise<void>;
171
177
  /** Refuse signals for `key` until `until` (cleared by the next turn). */
172
178
  markDeclined(key: string, until: number): Promise<void>;
179
+ /** Record an ended, unused warm whose charge is settled later. */
180
+ markPending(key: string, warmAt: number, maxMs: number, reason: string): Promise<void>;
181
+ /**
182
+ * Charge the pending warm that started at `warmAt` `chargeMs` to `day` and
183
+ * clear it. Only the first settler of a given warm succeeds (a turn and a
184
+ * sweep may race); returns whether this call settled it.
185
+ */
186
+ settlePending(key: string, warmAt: number, day: string, chargeMs: number): Promise<boolean>;
187
+ /** Pending warms whose idle window has closed by `now`. */
188
+ listPendingDue(now: number, limit: number): Promise<WarmLeaseRow[]>;
173
189
  /** Bounded batches for `sweep`. */
174
190
  listExpired(now: number, limit: number): Promise<WarmLeaseRow[]>;
175
191
  listHeld(now: number, limit: number): Promise<WarmLeaseRow[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.60.101",
3
+ "version": "0.60.102",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [