dsh-agentic-pet 0.4.7 → 0.4.8
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as globalFilePath, d as readJsonl, f as readPetName, h as writePetName, i as installPetDriver, l as readAffectionRaw, m as writeGlobalJson, n as installPetService, p as writeAffectionRaw, r as petHome, s as eventsFile, u as readGlobalJson } from "./service-
|
|
1
|
+
import { c as globalFilePath, d as readJsonl, f as readPetName, h as writePetName, i as installPetDriver, l as readAffectionRaw, m as writeGlobalJson, n as installPetService, p as writeAffectionRaw, r as petHome, s as eventsFile, u as readGlobalJson } from "./service-Df8olC1E.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { execFileSync, spawn } from "node:child_process";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -5449,7 +5449,9 @@ function bootOrder(pets) {
|
|
|
5449
5449
|
}
|
|
5450
5450
|
/** Every live pet in boot order. Dead-pid entries are skipped — they expire
|
|
5451
5451
|
* by omission the next time their file is rewritten — and so are silent
|
|
5452
|
-
* entries (pid alive, control plane unresponsive).
|
|
5452
|
+
* entries (pid alive, control plane unresponsive). Probes run CONCURRENTLY:
|
|
5453
|
+
* wall time per pass is the slowest pet (≤800ms frozen budget), not the
|
|
5454
|
+
* serial sum. */
|
|
5453
5455
|
async function readAllPets(home) {
|
|
5454
5456
|
let names = [];
|
|
5455
5457
|
try {
|
|
@@ -5457,30 +5459,30 @@ async function readAllPets(home) {
|
|
|
5457
5459
|
} catch {
|
|
5458
5460
|
return [];
|
|
5459
5461
|
}
|
|
5460
|
-
|
|
5461
|
-
for (const name of names) {
|
|
5462
|
+
return bootOrder((await Promise.all(names.map(async (name) => {
|
|
5462
5463
|
const id = name.slice(0, -5);
|
|
5463
|
-
if (id === "")
|
|
5464
|
+
if (id === "") return null;
|
|
5464
5465
|
try {
|
|
5465
5466
|
const raw = JSON.parse(await readFile(join(home, REGISTRY_DIR, name), "utf8"));
|
|
5466
5467
|
const port = typeof raw.port === "number" ? raw.port : NaN;
|
|
5467
5468
|
const pid = typeof raw.pid === "number" ? raw.pid : NaN;
|
|
5468
|
-
if (!Number.isFinite(port) || !Number.isFinite(pid))
|
|
5469
|
+
if (!Number.isFinite(port) || !Number.isFinite(pid)) return null;
|
|
5469
5470
|
try {
|
|
5470
5471
|
process.kill(pid, 0);
|
|
5471
5472
|
} catch {
|
|
5472
|
-
|
|
5473
|
+
return null;
|
|
5473
5474
|
}
|
|
5474
|
-
if (!await probeControlPlane(port))
|
|
5475
|
-
|
|
5475
|
+
if (!await probeControlPlane(port)) return null;
|
|
5476
|
+
return {
|
|
5476
5477
|
id,
|
|
5477
5478
|
port,
|
|
5478
5479
|
pid,
|
|
5479
5480
|
since: typeof raw.since === "number" ? raw.since : 0
|
|
5480
|
-
}
|
|
5481
|
-
} catch {
|
|
5482
|
-
|
|
5483
|
-
|
|
5481
|
+
};
|
|
5482
|
+
} catch {
|
|
5483
|
+
return null;
|
|
5484
|
+
}
|
|
5485
|
+
}))).filter((entry) => entry !== null));
|
|
5484
5486
|
}
|
|
5485
5487
|
/**
|
|
5486
5488
|
* The default pet for UNNAMED targets: the earliest-booted live entry
|
|
@@ -7280,12 +7282,23 @@ var PetHttpService = class PetHttpService extends PetService {
|
|
|
7280
7282
|
home;
|
|
7281
7283
|
capsCache = /* @__PURE__ */ new Map();
|
|
7282
7284
|
static CAPS_TTL_MS = 3e4;
|
|
7285
|
+
listCache;
|
|
7286
|
+
static LIST_TTL_MS = 1e3;
|
|
7283
7287
|
constructor(ctx, home = petHome()) {
|
|
7284
7288
|
super(ctx);
|
|
7285
7289
|
this.home = home;
|
|
7286
7290
|
}
|
|
7291
|
+
/** Every live pet in boot order, served from the 1s single-flight cache:
|
|
7292
|
+
* concurrent callers share the running probe pass. */
|
|
7287
7293
|
list() {
|
|
7288
|
-
|
|
7294
|
+
const hit = this.listCache;
|
|
7295
|
+
if (hit !== void 0 && Date.now() - hit.at < PetHttpService.LIST_TTL_MS) return hit.flight;
|
|
7296
|
+
const flight = readAllPets(this.home);
|
|
7297
|
+
this.listCache = {
|
|
7298
|
+
at: Date.now(),
|
|
7299
|
+
flight
|
|
7300
|
+
};
|
|
7301
|
+
return flight;
|
|
7289
7302
|
}
|
|
7290
7303
|
async snapshot(entry) {
|
|
7291
7304
|
try {
|
|
@@ -7391,6 +7404,7 @@ function createUnregisteredPetHttp(home = petHome()) {
|
|
|
7391
7404
|
const instance = Object.create(PetHttpService.prototype);
|
|
7392
7405
|
instance.home = home;
|
|
7393
7406
|
instance.capsCache = /* @__PURE__ */ new Map();
|
|
7407
|
+
instance.listCache = void 0;
|
|
7394
7408
|
return instance;
|
|
7395
7409
|
}
|
|
7396
7410
|
/**
|
package/lib/tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as logStamp, o as registerPetTools, r as petHome, t as createUnregisteredPetHttp } from "./service-
|
|
1
|
+
import { a as logStamp, o as registerPetTools, r as petHome, t as createUnregisteredPetHttp } from "./service-Df8olC1E.js";
|
|
2
2
|
import { appendFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
// lib/types/tools.js
|
package/lib/types/registry.d.ts
CHANGED
|
@@ -40,7 +40,9 @@ export declare function probeControlPlane(port: number): Promise<boolean>;
|
|
|
40
40
|
export declare function bootOrder(pets: PetEntry[]): PetEntry[];
|
|
41
41
|
/** Every live pet in boot order. Dead-pid entries are skipped — they expire
|
|
42
42
|
* by omission the next time their file is rewritten — and so are silent
|
|
43
|
-
* entries (pid alive, control plane unresponsive).
|
|
43
|
+
* entries (pid alive, control plane unresponsive). Probes run CONCURRENTLY:
|
|
44
|
+
* wall time per pass is the slowest pet (≤800ms frozen budget), not the
|
|
45
|
+
* serial sum. */
|
|
44
46
|
export declare function readAllPets(home: string): Promise<PetEntry[]>;
|
|
45
47
|
/**
|
|
46
48
|
* The default pet for UNNAMED targets: the earliest-booted live entry
|
package/lib/types/service.d.ts
CHANGED
|
@@ -119,7 +119,11 @@ export declare class PetHttpService extends PetService {
|
|
|
119
119
|
readonly home: string;
|
|
120
120
|
private readonly capsCache;
|
|
121
121
|
private static readonly CAPS_TTL_MS;
|
|
122
|
+
private listCache;
|
|
123
|
+
private static readonly LIST_TTL_MS;
|
|
122
124
|
constructor(ctx: Context, home?: string);
|
|
125
|
+
/** Every live pet in boot order, served from the 1s single-flight cache:
|
|
126
|
+
* concurrent callers share the running probe pass. */
|
|
123
127
|
list(): Promise<PetEntry[]>;
|
|
124
128
|
snapshot(entry: PetEntry): Promise<PetSnapshot>;
|
|
125
129
|
capabilities(entry: PetEntry): Promise<PetCapabilities>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agentic-pet",
|
|
3
3
|
"description": "The pet-surface bundle: serves the desktop pet renderer over the web composition, turning dsh into a surface the desktop pet attaches to as an authenticated client",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.8",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|