pi-better-server 0.7.0 → 0.7.2
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/package.json +1 -1
- package/src/codex/return.ts +3 -2
- package/src/detach/extension.ts +20 -3
- package/src/event-log.ts +40 -12
- package/src/hosted-session.ts +11 -5
- package/src/remote-client/packages.ts +1 -4
- package/src/runtime/background-tools.ts +2 -1
- package/src/runtime/domain/background/registry.mjs +3 -0
- package/src/runtime/domain/background/shared-operation-coordinator/src/task-lifetime.mjs +6 -0
- package/src/runtime/domain/background/terminal-publication.mjs +5 -2
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +13 -0
- package/src/runtime/domain/background-service/managed-authority.ts +16 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +2 -2
- package/src/runtime/domain/background-service/managed-client.ts +2 -2
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +8 -4
- package/src/runtime/domain/background-service/observed-waits.ts +8 -4
- package/src/runtime/domain/background-service/registry.domain.mjs +3 -0
- package/src/runtime/domain/background-service/registry.ts +2 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +3 -2
- package/src/runtime/domain/background-service/runtime.ts +3 -2
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +2 -3
- package/src/runtime/domain/background-service/shared-harness-settings.ts +2 -5
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/expiry.domain.mjs +44 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/expiry.ts +44 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +8 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +8 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +3 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +5 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-lifetime.domain.mjs +7 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-lifetime.ts +7 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +22 -13
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +40 -32
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +12 -19
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +12 -16
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +1 -1
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +1 -1
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +1 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +12 -7
- package/src/runtime/domain/background-service/supervisor/generated/task-lifetime.mjs +9 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +12 -7
- package/src/runtime/domain/background-service/supervisor/runner.ts +12 -7
- package/src/runtime/domain/background-service/supervisor/types.ts +1 -1
- package/src/runtime/domain/background-service/tools.domain.mjs +3 -2
- package/src/runtime/domain/background-service/tools.ts +3 -2
- package/src/runtime/domain/catalog/catalog-preferences.mjs +1 -3
- package/src/runtime/domain/coordinator/src/expiry.mjs +43 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +8 -1
- package/src/runtime/domain/coordinator/src/store.mjs +3 -0
- package/src/runtime/domain/coordinator/src/task-lifetime.mjs +6 -0
- package/src/runtime/domain/coordinator/src/waits.mjs +22 -13
- package/src/runtime/domain/sandbox-policy/package.json +1 -1
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +2 -3
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +2 -5
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +12 -19
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +12 -16
- package/src/runtime/domain/shared-harness-settings.mjs +2 -3
- package/src/runtime/domain/subagents/README.md +2 -2
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +1 -3
- package/src/runtime/domain/subagents/catalog-preferences.ts +1 -5
- package/src/runtime/domain/subagents/cleanup.domain.mjs +5 -2
- package/src/runtime/domain/subagents/cleanup.ts +4 -1
- package/src/runtime/domain/subagents/config.ts +1 -1
- package/src/runtime/domain/subagents/extensions.mjs +1 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +34 -30
- package/src/runtime/domain/subagents/finalization.ts +30 -28
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +51 -6
- package/src/runtime/domain/subagents/git-workspace.ts +48 -6
- package/src/runtime/domain/subagents/index.domain.mjs +99 -54
- package/src/runtime/domain/subagents/index.ts +100 -51
- package/src/runtime/domain/subagents/isolated-workspace.domain.mjs +7 -14
- package/src/runtime/domain/subagents/isolated-workspace.ts +6 -12
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +28 -2
- package/src/runtime/domain/subagents/managed-launch-host.ts +26 -2
- package/src/runtime/domain/subagents/managed-launch-port.ts +2 -0
- package/src/runtime/domain/subagents/package.json +1 -1
- package/src/runtime/domain/subagents/registry-cleanup-worker.mjs +24 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +40 -14
- package/src/runtime/domain/subagents/registry.ts +26 -12
- package/src/runtime/domain/subagents/settings-page.domain.mjs +10 -10
- package/src/runtime/domain/subagents/settings-page.ts +10 -10
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +2 -3
- package/src/runtime/domain/subagents/shared-harness-settings.ts +2 -5
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/expiry.domain.mjs +44 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/expiry.ts +44 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +8 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +8 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +3 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +5 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-lifetime.domain.mjs +7 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-lifetime.ts +7 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +22 -13
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +40 -32
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +12 -19
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +12 -16
- package/src/runtime/domain/subagents/stop.domain.mjs +7 -5
- package/src/runtime/domain/subagents/stop.ts +7 -5
- package/src/runtime/domain/subagents/timing.domain.mjs +7 -3
- package/src/runtime/domain/subagents/timing.ts +11 -4
- package/src/runtime/domain/subagents/workspace-files.domain.mjs +6 -6
- package/src/runtime/domain/subagents/workspace-files.ts +6 -6
- package/src/runtime/domain/subagents/workspace-prepare-worker.mjs +12 -0
- package/src/runtime/task-expiry.ts +52 -0
- package/src/server.ts +4 -0
- package/src/shared-ssh-core/index.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
// Generated fixed launch domain from packages/pi-better-subagents/registry.ts. Do not edit directly.
|
|
2
2
|
import { reclaimWorkspace } from "./isolated-workspace.domain.mjs";
|
|
3
3
|
import { retainResult } from "./retained-result.domain.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Run registry — durable metadata for each spawned subagent.
|
|
6
|
+
*
|
|
7
|
+
* The authoritative record for every run is a `meta.json` sidecar on disk, so
|
|
8
|
+
* `list` / `output` / `result` keep working across foreground turns, `/reload`,
|
|
9
|
+
* and even a full pi restart. In-memory state holds only the live exit handlers
|
|
10
|
+
* for runs this process spawned.
|
|
11
|
+
*
|
|
12
|
+
* Catalog launches may attach an optional immutable `catalog` snapshot to that
|
|
13
|
+
* same record. Display-label reservations live under `{baseDir()}/labels`
|
|
14
|
+
* (see catalog-identity.ts). They are not a second registry, and removing a
|
|
15
|
+
* run directory does not delete them.
|
|
16
|
+
*/
|
|
17
|
+
import { taskDeadline } from "./shared-operation-coordinator/src/task-lifetime.domain.mjs";
|
|
4
18
|
import { assignmentRetainsEvidence } from "./assignment-outcomes.domain.mjs";
|
|
5
19
|
import { processStartToken } from "./process-identity.mjs";
|
|
6
20
|
export { processStartToken } from "./process-identity.mjs";
|
|
@@ -788,7 +802,8 @@ function takeToken(lockPath, payload, deadline, id) {
|
|
|
788
802
|
* decides who may recover or release it. A live pid — even one paused well
|
|
789
803
|
* past two seconds — is not stolen. Release renames the lock aside and deletes
|
|
790
804
|
* it only when the moved bytes are still ours, so a newer owner's lock stays.
|
|
791
|
-
* The lock is per run
|
|
805
|
+
* The lock is per run. Metadata transitions that depend on the current record
|
|
806
|
+
* use a patch so that the read and preconditions are repeated after lock loss.
|
|
792
807
|
*/
|
|
793
808
|
function withRunMetaLock(id, body) {
|
|
794
809
|
const directory = runDir(id);
|
|
@@ -1008,22 +1023,40 @@ export function writeMeta(meta, options = {}) {
|
|
|
1008
1023
|
written = true;
|
|
1009
1024
|
});
|
|
1010
1025
|
if (options.patch && !written)
|
|
1011
|
-
return;
|
|
1026
|
+
return undefined;
|
|
1012
1027
|
for (const listener of metaChangedListeners) {
|
|
1013
1028
|
try {
|
|
1014
1029
|
listener(meta);
|
|
1015
1030
|
}
|
|
1016
1031
|
catch { /* best effort */ }
|
|
1017
1032
|
}
|
|
1033
|
+
return written ? meta : undefined;
|
|
1018
1034
|
}
|
|
1019
1035
|
export function onMetaChanged(listener) {
|
|
1020
1036
|
metaChangedListeners.add(listener);
|
|
1021
1037
|
return () => metaChangedListeners.delete(listener);
|
|
1022
1038
|
}
|
|
1039
|
+
/** Drop volatile state in the process observing a committed cleanup. */
|
|
1040
|
+
export function notifyRunRemoved(id, meta = metaCache.get(id)) {
|
|
1041
|
+
metaCache.delete(id);
|
|
1042
|
+
for (const listener of metaChangedListeners) {
|
|
1043
|
+
try {
|
|
1044
|
+
listener(meta);
|
|
1045
|
+
}
|
|
1046
|
+
catch { /* best effort */ }
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function restoreTaskDeadline(meta) {
|
|
1050
|
+
if (meta.status !== "running" && meta.status !== "orphaned")
|
|
1051
|
+
return;
|
|
1052
|
+
meta.timing ??= { graceMs: 0 };
|
|
1053
|
+
meta.timing.ceilingAt = taskDeadline(meta.startedAt, meta.timing.ceilingAt);
|
|
1054
|
+
}
|
|
1023
1055
|
export function readMeta(id) {
|
|
1024
1056
|
try {
|
|
1025
1057
|
registryIo.metadataFileReads += 1;
|
|
1026
1058
|
const meta = JSON.parse(readFileSync(metaPathFor(id), "utf-8"));
|
|
1059
|
+
restoreTaskDeadline(meta);
|
|
1027
1060
|
metaCache.set(id, meta);
|
|
1028
1061
|
return meta;
|
|
1029
1062
|
}
|
|
@@ -1067,16 +1100,10 @@ export function removeMetaArtifacts(meta, options = {}) {
|
|
|
1067
1100
|
if (scratch) {
|
|
1068
1101
|
rmSync(scratch, { recursive: true, force: true });
|
|
1069
1102
|
}
|
|
1070
|
-
metaCache.delete(meta.id);
|
|
1071
1103
|
removeIndexEntry(join(baseDir(), "by-parent", String(meta.spawnPid)), meta.id);
|
|
1072
1104
|
removeIndexEntry(join(baseDir(), "by-parent-active", String(meta.spawnPid)), meta.id);
|
|
1073
1105
|
removeIndexEntry(join(baseDir(), "by-origin", originKey(originOf(meta))), meta.id);
|
|
1074
|
-
|
|
1075
|
-
try {
|
|
1076
|
-
listener(meta);
|
|
1077
|
-
}
|
|
1078
|
-
catch { /* best effort */ }
|
|
1079
|
-
}
|
|
1106
|
+
notifyRunRemoved(meta.id, meta);
|
|
1080
1107
|
return true;
|
|
1081
1108
|
}
|
|
1082
1109
|
catch (error) {
|
|
@@ -1327,6 +1354,7 @@ export function inspectRunMeta(id) {
|
|
|
1327
1354
|
metaCache.delete(id);
|
|
1328
1355
|
return { kind: "unreadable", detail: `invalid metadata: ${invalid}` };
|
|
1329
1356
|
}
|
|
1357
|
+
restoreTaskDeadline(meta);
|
|
1330
1358
|
metaCache.set(id, meta);
|
|
1331
1359
|
return { kind: "ok", meta };
|
|
1332
1360
|
}
|
|
@@ -1569,11 +1597,9 @@ export function dismissRun(id, at = Date.now()) {
|
|
|
1569
1597
|
const meta = readMeta(id);
|
|
1570
1598
|
if (!meta)
|
|
1571
1599
|
return undefined;
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
}
|
|
1576
|
-
return meta;
|
|
1600
|
+
return writeMeta(meta, {
|
|
1601
|
+
patch: current => current.dismissedAt === undefined ? { dismissedAt: at } : undefined,
|
|
1602
|
+
}) ?? readMeta(id);
|
|
1577
1603
|
}
|
|
1578
1604
|
/**
|
|
1579
1605
|
* Visible navigator runs: current-parent runs that are not dismissed. This is
|
|
@@ -14,6 +14,7 @@ import { retainResult } from "./retained-result.ts";
|
|
|
14
14
|
* run directory does not delete them.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { taskDeadline } from "./shared-operation-coordinator/src/task-lifetime.ts";
|
|
17
18
|
import type { RunTiming } from "./timing.ts";
|
|
18
19
|
import { assignmentRetainsEvidence } from "./assignment-outcomes.ts";
|
|
19
20
|
import type { SkillExposureSource } from "./skills.ts";
|
|
@@ -1092,7 +1093,8 @@ function takeToken(lockPath: string, payload: string, deadline: number, id: stri
|
|
|
1092
1093
|
* decides who may recover or release it. A live pid — even one paused well
|
|
1093
1094
|
* past two seconds — is not stolen. Release renames the lock aside and deletes
|
|
1094
1095
|
* it only when the moved bytes are still ours, so a newer owner's lock stays.
|
|
1095
|
-
* The lock is per run
|
|
1096
|
+
* The lock is per run. Metadata transitions that depend on the current record
|
|
1097
|
+
* use a patch so that the read and preconditions are repeated after lock loss.
|
|
1096
1098
|
*/
|
|
1097
1099
|
function withRunMetaLock(id: string, body: (owns: () => boolean) => void): void {
|
|
1098
1100
|
const directory = runDir(id);
|
|
@@ -1270,7 +1272,7 @@ export function writeMeta(meta: RunMeta, options: {
|
|
|
1270
1272
|
ifAbsent?: boolean;
|
|
1271
1273
|
/** Build a field update from current metadata under the existing run lock. */
|
|
1272
1274
|
patch?: (current: Readonly<RunMeta>) => Partial<RunMeta> | undefined;
|
|
1273
|
-
} = {}):
|
|
1275
|
+
} = {}): RunMeta | undefined {
|
|
1274
1276
|
if (options.patch && !readMeta(meta.id)) return;
|
|
1275
1277
|
mkdirSync(runDir(meta.id), { recursive: true });
|
|
1276
1278
|
let written = false;
|
|
@@ -1303,10 +1305,11 @@ export function writeMeta(meta: RunMeta, options: {
|
|
|
1303
1305
|
owns();
|
|
1304
1306
|
written = true;
|
|
1305
1307
|
});
|
|
1306
|
-
if (options.patch && !written) return;
|
|
1308
|
+
if (options.patch && !written) return undefined;
|
|
1307
1309
|
for (const listener of metaChangedListeners) {
|
|
1308
1310
|
try { listener(meta); } catch { /* best effort */ }
|
|
1309
1311
|
}
|
|
1312
|
+
return written ? meta : undefined;
|
|
1310
1313
|
}
|
|
1311
1314
|
|
|
1312
1315
|
export function onMetaChanged(listener: (meta?: RunMeta) => void): () => void {
|
|
@@ -1314,10 +1317,25 @@ export function onMetaChanged(listener: (meta?: RunMeta) => void): () => void {
|
|
|
1314
1317
|
return () => metaChangedListeners.delete(listener);
|
|
1315
1318
|
}
|
|
1316
1319
|
|
|
1320
|
+
/** Drop volatile state in the process observing a committed cleanup. */
|
|
1321
|
+
export function notifyRunRemoved(id: string, meta = metaCache.get(id)): void {
|
|
1322
|
+
metaCache.delete(id);
|
|
1323
|
+
for (const listener of metaChangedListeners) {
|
|
1324
|
+
try { listener(meta); } catch { /* best effort */ }
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
function restoreTaskDeadline(meta: RunMeta): void {
|
|
1329
|
+
if (meta.status !== "running" && meta.status !== "orphaned") return;
|
|
1330
|
+
meta.timing ??= { graceMs: 0 };
|
|
1331
|
+
meta.timing.ceilingAt = taskDeadline(meta.startedAt, meta.timing.ceilingAt);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1317
1334
|
export function readMeta(id: string): RunMeta | undefined {
|
|
1318
1335
|
try {
|
|
1319
1336
|
registryIo.metadataFileReads += 1;
|
|
1320
1337
|
const meta = JSON.parse(readFileSync(metaPathFor(id), "utf-8")) as RunMeta;
|
|
1338
|
+
restoreTaskDeadline(meta);
|
|
1321
1339
|
metaCache.set(id, meta);
|
|
1322
1340
|
return meta;
|
|
1323
1341
|
} catch (error) {
|
|
@@ -1374,13 +1392,10 @@ export function removeMetaArtifacts(meta: RunMeta, options: RemoveMetaArtifactsO
|
|
|
1374
1392
|
if (scratch) {
|
|
1375
1393
|
rmSync(scratch, { recursive: true, force: true });
|
|
1376
1394
|
}
|
|
1377
|
-
metaCache.delete(meta.id);
|
|
1378
1395
|
removeIndexEntry(join(baseDir(), "by-parent", String(meta.spawnPid)), meta.id);
|
|
1379
1396
|
removeIndexEntry(join(baseDir(), "by-parent-active", String(meta.spawnPid)), meta.id);
|
|
1380
1397
|
removeIndexEntry(join(baseDir(), "by-origin", originKey(originOf(meta))), meta.id);
|
|
1381
|
-
|
|
1382
|
-
try { listener(meta); } catch { /* best effort */ }
|
|
1383
|
-
}
|
|
1398
|
+
notifyRunRemoved(meta.id, meta);
|
|
1384
1399
|
return true;
|
|
1385
1400
|
} catch (error) {
|
|
1386
1401
|
options.errors?.push(meta.cwd + ": " + String(error));
|
|
@@ -1657,6 +1672,7 @@ export function inspectRunMeta(id: string): { kind: "ok"; meta: RunMeta } | { ki
|
|
|
1657
1672
|
metaCache.delete(id);
|
|
1658
1673
|
return { kind: "unreadable", detail: `invalid metadata: ${invalid}` };
|
|
1659
1674
|
}
|
|
1675
|
+
restoreTaskDeadline(meta);
|
|
1660
1676
|
metaCache.set(id, meta);
|
|
1661
1677
|
return { kind: "ok", meta };
|
|
1662
1678
|
}
|
|
@@ -1893,11 +1909,9 @@ export function isDismissed(meta: Pick<RunMeta, "dismissedAt">): boolean {
|
|
|
1893
1909
|
export function dismissRun(id: string, at: number = Date.now()): RunMeta | undefined {
|
|
1894
1910
|
const meta = readMeta(id);
|
|
1895
1911
|
if (!meta) return undefined;
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
}
|
|
1900
|
-
return meta;
|
|
1912
|
+
return writeMeta(meta, {
|
|
1913
|
+
patch: current => current.dismissedAt === undefined ? { dismissedAt: at } : undefined,
|
|
1914
|
+
}) ?? readMeta(id);
|
|
1901
1915
|
}
|
|
1902
1916
|
|
|
1903
1917
|
/**
|
|
@@ -3,7 +3,7 @@ import * as Tui from "@earendil-works/pi-tui";
|
|
|
3
3
|
import { isConcurrencyCap } from "./config.domain.mjs";
|
|
4
4
|
import { DELEGATION_MODES } from "./delegation.domain.mjs";
|
|
5
5
|
import { createSkillPicker } from "./skill-picker.domain.mjs";
|
|
6
|
-
import { isTimingMinutes,
|
|
6
|
+
import { isTimingMinutes, validatedTimingMinutes } from "./timing.domain.mjs";
|
|
7
7
|
const rows = [
|
|
8
8
|
{ kind: "mode", label: "Delegation mode" },
|
|
9
9
|
{ kind: "cap", label: "Concurrent subagents" },
|
|
@@ -22,14 +22,14 @@ const SKILL_MODES = [
|
|
|
22
22
|
{ mode: "none", label: "No skill catalog" },
|
|
23
23
|
{ mode: "explicit", label: "Selected skills" },
|
|
24
24
|
];
|
|
25
|
-
const
|
|
25
|
+
const MAX_TIMEOUT = "24 hours";
|
|
26
26
|
function parseRunTimeout(input) {
|
|
27
27
|
const text = input.trim();
|
|
28
|
-
if (
|
|
28
|
+
if (["no limit", MAX_TIMEOUT].includes(text.toLowerCase()))
|
|
29
29
|
return 0;
|
|
30
30
|
const minutes = Number(text);
|
|
31
|
-
if (!text || !isTimingMinutes(minutes)) {
|
|
32
|
-
throw new Error(
|
|
31
|
+
if (!text || !isTimingMinutes(minutes) || minutes > 1440) {
|
|
32
|
+
throw new Error("Enter 24 hours or a duration up to 1440 minutes.");
|
|
33
33
|
}
|
|
34
34
|
return minutes;
|
|
35
35
|
}
|
|
@@ -51,7 +51,7 @@ function settingValue(kind, s) {
|
|
|
51
51
|
case "mode": return s.mode;
|
|
52
52
|
case "cap": return String(s.maxConcurrent);
|
|
53
53
|
case "workspace": return s.gitWorkspace === "worktree" ? "Worktree" : "Clone";
|
|
54
|
-
case "timeout": return s.maxMinutes === 0 ?
|
|
54
|
+
case "timeout": return s.maxMinutes === 0 || s.maxMinutes >= 1440 ? MAX_TIMEOUT : `${s.maxMinutes} min`;
|
|
55
55
|
case "toolWait": return s.toolWaitMinutes === 0 ? "Off" : `${s.toolWaitMinutes} min`;
|
|
56
56
|
case "stuck": return s.stuckMinutes === 0 ? "Off" : `${s.stuckMinutes} min`;
|
|
57
57
|
case "skills": return skillLabel(s.skillsMode);
|
|
@@ -71,7 +71,7 @@ function description(kind, s) {
|
|
|
71
71
|
case "workspace": return s.gitWorkspace === "worktree"
|
|
72
72
|
? "Create a linked worktree that shares the repository’s Git metadata."
|
|
73
73
|
: "Create a separate local clone for each isolated Git workspace.";
|
|
74
|
-
case "timeout": return "Stop a subagent when its run reaches this limit.
|
|
74
|
+
case "timeout": return "Stop a subagent when its run reaches this limit. The maximum is 24 hours.";
|
|
75
75
|
case "toolWait": return "Notify the parent when a tool call stays open this long. Enter 0 to turn this alert off.";
|
|
76
76
|
case "stuck": return "Notify the parent after this long without progress. Time spent waiting for a tool is excluded. Enter 0 to turn this alert off.";
|
|
77
77
|
case "skills": return "Choose how new subagents discover skills.\n" + skillSource(s);
|
|
@@ -94,7 +94,7 @@ function shortcuts(kind, editing) {
|
|
|
94
94
|
const change = confirm ? `${confirm}/Space` : "Space";
|
|
95
95
|
const verb = kind === "agents" || kind === "choose" ? "open" : kind === "reset" ? "restore" : "change";
|
|
96
96
|
const actions = editing ? [confirm && `${confirm} to apply`]
|
|
97
|
-
: kind === "timeout" ? ["Space for
|
|
97
|
+
: kind === "timeout" ? ["Space for 24 hours", confirm && `${confirm} to edit minutes`]
|
|
98
98
|
: [`${change} to ${verb}`];
|
|
99
99
|
if (!editing)
|
|
100
100
|
actions.push("Ctrl+S to save defaults");
|
|
@@ -187,10 +187,10 @@ export function createSubagentSettingsPage(theme, handlers, requestRender, close
|
|
|
187
187
|
else if (selected.kind === "timeout") {
|
|
188
188
|
if (key === " ") {
|
|
189
189
|
handlers.changeTiming("maxMinutes", 0);
|
|
190
|
-
report("Run timeout set to
|
|
190
|
+
report("Run timeout set to 24 hours.");
|
|
191
191
|
}
|
|
192
192
|
else {
|
|
193
|
-
startEditing(selected, settings.maxMinutes === 0 ?
|
|
193
|
+
startEditing(selected, settings.maxMinutes === 0 || settings.maxMinutes >= 1440 ? MAX_TIMEOUT : String(settings.maxMinutes));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
else if (selected.kind === "skills") {
|
|
@@ -4,7 +4,7 @@ import { isConcurrencyCap } from "./config.ts";
|
|
|
4
4
|
import { DELEGATION_MODES, type DelegationMode } from "./delegation.ts";
|
|
5
5
|
import type { SkillExposureMode } from "./skills.ts";
|
|
6
6
|
import { createSkillPicker, type DiscoveredSkill } from "./skill-picker.ts";
|
|
7
|
-
import { isTimingMinutes,
|
|
7
|
+
import { isTimingMinutes, validatedTimingMinutes } from "./timing.ts";
|
|
8
8
|
|
|
9
9
|
export type TimingSettingKey = "maxMinutes" | "toolWaitMinutes" | "stuckMinutes";
|
|
10
10
|
|
|
@@ -72,14 +72,14 @@ const SKILL_MODES: readonly { mode: SkillExposureMode; label: string }[] = [
|
|
|
72
72
|
{ mode: "explicit", label: "Selected skills" },
|
|
73
73
|
];
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const MAX_TIMEOUT = "24 hours";
|
|
76
76
|
|
|
77
77
|
function parseRunTimeout(input: string): number {
|
|
78
78
|
const text = input.trim();
|
|
79
|
-
if (
|
|
79
|
+
if (["no limit", MAX_TIMEOUT].includes(text.toLowerCase())) return 0;
|
|
80
80
|
const minutes = Number(text);
|
|
81
|
-
if (!text || !isTimingMinutes(minutes)) {
|
|
82
|
-
throw new Error(
|
|
81
|
+
if (!text || !isTimingMinutes(minutes) || minutes > 1440) {
|
|
82
|
+
throw new Error("Enter 24 hours or a duration up to 1440 minutes.");
|
|
83
83
|
}
|
|
84
84
|
return minutes;
|
|
85
85
|
}
|
|
@@ -103,7 +103,7 @@ function settingValue(kind: Row["kind"], s: SubagentSettingsSnapshot): string {
|
|
|
103
103
|
case "mode": return s.mode;
|
|
104
104
|
case "cap": return String(s.maxConcurrent);
|
|
105
105
|
case "workspace": return s.gitWorkspace === "worktree" ? "Worktree" : "Clone";
|
|
106
|
-
case "timeout": return s.maxMinutes === 0 ?
|
|
106
|
+
case "timeout": return s.maxMinutes === 0 || s.maxMinutes >= 1440 ? MAX_TIMEOUT : `${s.maxMinutes} min`;
|
|
107
107
|
case "toolWait": return s.toolWaitMinutes === 0 ? "Off" : `${s.toolWaitMinutes} min`;
|
|
108
108
|
case "stuck": return s.stuckMinutes === 0 ? "Off" : `${s.stuckMinutes} min`;
|
|
109
109
|
case "skills": return skillLabel(s.skillsMode);
|
|
@@ -124,7 +124,7 @@ function description(kind: Row["kind"], s: SubagentSettingsSnapshot): string {
|
|
|
124
124
|
case "workspace": return s.gitWorkspace === "worktree"
|
|
125
125
|
? "Create a linked worktree that shares the repository’s Git metadata."
|
|
126
126
|
: "Create a separate local clone for each isolated Git workspace.";
|
|
127
|
-
case "timeout": return "Stop a subagent when its run reaches this limit.
|
|
127
|
+
case "timeout": return "Stop a subagent when its run reaches this limit. The maximum is 24 hours.";
|
|
128
128
|
case "toolWait": return "Notify the parent when a tool call stays open this long. Enter 0 to turn this alert off.";
|
|
129
129
|
case "stuck": return "Notify the parent after this long without progress. Time spent waiting for a tool is excluded. Enter 0 to turn this alert off.";
|
|
130
130
|
case "skills": return "Choose how new subagents discover skills.\n" + skillSource(s);
|
|
@@ -147,7 +147,7 @@ function shortcuts(kind: Row["kind"], editing: boolean): string {
|
|
|
147
147
|
const change = confirm ? `${confirm}/Space` : "Space";
|
|
148
148
|
const verb = kind === "agents" || kind === "choose" ? "open" : kind === "reset" ? "restore" : "change";
|
|
149
149
|
const actions = editing ? [confirm && `${confirm} to apply`]
|
|
150
|
-
: kind === "timeout" ? ["Space for
|
|
150
|
+
: kind === "timeout" ? ["Space for 24 hours", confirm && `${confirm} to edit minutes`]
|
|
151
151
|
: [`${change} to ${verb}`];
|
|
152
152
|
if (!editing) actions.push("Ctrl+S to save defaults");
|
|
153
153
|
if (cancel) actions.push(`${cancel} to ${editing ? "cancel" : "go back"}`);
|
|
@@ -244,9 +244,9 @@ export function createSubagentSettingsPage(
|
|
|
244
244
|
} else if (selected.kind === "timeout") {
|
|
245
245
|
if (key === " ") {
|
|
246
246
|
handlers.changeTiming("maxMinutes", 0);
|
|
247
|
-
report("Run timeout set to
|
|
247
|
+
report("Run timeout set to 24 hours.");
|
|
248
248
|
} else {
|
|
249
|
-
startEditing(selected, settings.maxMinutes === 0 ?
|
|
249
|
+
startEditing(selected, settings.maxMinutes === 0 || settings.maxMinutes >= 1440 ? MAX_TIMEOUT : String(settings.maxMinutes));
|
|
250
250
|
}
|
|
251
251
|
} else if (selected.kind === "skills") {
|
|
252
252
|
if (settings.skillsMode === "explicit") rememberedSkillPaths = [...settings.skillsPaths];
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Generated from packages/harness-settings/index.ts. Do not edit directly.
|
|
3
3
|
import { existsSync, lstatSync, realpathSync, readFileSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
-
import { createRequire } from "node:module";
|
|
6
5
|
import { join } from "node:path";
|
|
7
6
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
8
|
-
//
|
|
9
|
-
|
|
7
|
+
// A static import lets the compiled Pi loader resolve dependencies of the settings lock.
|
|
8
|
+
import lockfile from "proper-lockfile";
|
|
10
9
|
const NAMESPACE = "piBetterHarness";
|
|
11
10
|
export function harnessSettingsPath(seams = {}) {
|
|
12
11
|
return join((seams.agentDir ?? getAgentDir)(), "settings.json");
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
// Generated from packages/harness-settings/index.ts. Do not edit directly.
|
|
2
2
|
import { existsSync, lstatSync, realpathSync, readFileSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
4
|
import { join } from "node:path";
|
|
6
5
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
// A static import lets the compiled Pi loader resolve dependencies of the settings lock.
|
|
7
|
+
import lockfile from "proper-lockfile";
|
|
7
8
|
|
|
8
|
-
// Match Pi's settings lock without depending on a private SDK import.
|
|
9
|
-
const lockfile = createRequire(import.meta.url)("proper-lockfile") as {
|
|
10
|
-
lockSync(path: string, options: { realpath: boolean }): () => void;
|
|
11
|
-
};
|
|
12
9
|
const NAMESPACE = "piBetterHarness";
|
|
13
10
|
export interface HarnessSettingsSeams { agentDir?: () => string }
|
|
14
11
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/shared-operation-coordinator/src/expiry.ts. Do not edit directly.
|
|
2
|
+
// Generated from packages/operation-coordinator/src/expiry.ts. Do not edit directly.
|
|
3
|
+
import { bumpChangeRevision } from "./discovery.domain.mjs";
|
|
4
|
+
import { getOperation } from "./operations.domain.mjs";
|
|
5
|
+
import { columnNumber, columnText, getRows, run } from "./sqlite.domain.mjs";
|
|
6
|
+
import { MAX_TASK_LIFETIME_MS } from "./task-lifetime.domain.mjs";
|
|
7
|
+
import { cancelGeneration } from "./waits.domain.mjs";
|
|
8
|
+
const reason = "24-hour task lifetime exceeded";
|
|
9
|
+
const batch = 8;
|
|
10
|
+
export function overdueOperations(ctx) {
|
|
11
|
+
return getRows(ctx, `SELECT operation_id FROM operations WHERE phase = 'running' AND terminal_revision = 0
|
|
12
|
+
AND created_at <= ? ORDER BY created_at LIMIT ?`, ctx.now() - MAX_TASK_LIFETIME_MS, batch)
|
|
13
|
+
.map(row => getOperation(ctx, columnText(row, "operation_id")))
|
|
14
|
+
.filter(operation => operation.phase === "running");
|
|
15
|
+
}
|
|
16
|
+
export function expireWaits(ctx) {
|
|
17
|
+
const now = ctx.now();
|
|
18
|
+
const cutoff = now - MAX_TASK_LIFETIME_MS;
|
|
19
|
+
const waits = getRows(ctx, `SELECT wait_id, generation FROM waits WHERE phase NOT IN ('consumed', 'cancelled')
|
|
20
|
+
AND dispatch_disarmed = 0 AND created_at <= ? ORDER BY created_at LIMIT ?`, cutoff, batch);
|
|
21
|
+
const claims = getRows(ctx, `SELECT claim_id FROM resume_claims WHERE state IN ('claimed', 'published')
|
|
22
|
+
AND claimed_at <= ? ORDER BY claimed_at LIMIT ?`, cutoff, batch);
|
|
23
|
+
if (!waits.length && !claims.length)
|
|
24
|
+
return 0;
|
|
25
|
+
return ctx.transaction(() => {
|
|
26
|
+
let changed = 0;
|
|
27
|
+
for (const row of waits) {
|
|
28
|
+
const id = columnText(row, "wait_id"), generation = columnNumber(row, "generation");
|
|
29
|
+
if (!ctx.db.prepare(`SELECT 1 FROM waits WHERE wait_id = ? AND generation = ?
|
|
30
|
+
AND phase NOT IN ('consumed', 'cancelled') AND dispatch_disarmed = 0 AND created_at <= ?`).get(id, generation, cutoff))
|
|
31
|
+
continue;
|
|
32
|
+
cancelGeneration(ctx, id, generation, reason);
|
|
33
|
+
changed++;
|
|
34
|
+
}
|
|
35
|
+
// Published claims can outlive consumed waits or a disarmed assignment.
|
|
36
|
+
for (const row of claims) {
|
|
37
|
+
changed += run(ctx, `UPDATE resume_claims SET state = 'invalidated', invalidated_at = ?, reason = ?
|
|
38
|
+
WHERE claim_id = ? AND state IN ('claimed', 'published') AND claimed_at <= ?`, now, reason, columnText(row, "claim_id"), cutoff);
|
|
39
|
+
}
|
|
40
|
+
if (changed)
|
|
41
|
+
bumpChangeRevision(ctx);
|
|
42
|
+
return changed;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated from packages/operation-coordinator/src/expiry.ts. Do not edit directly.
|
|
2
|
+
import { bumpChangeRevision } from "./discovery.ts";
|
|
3
|
+
import { getOperation } from "./operations.ts";
|
|
4
|
+
import { columnNumber, columnText, getRows, run, type StoreContext } from "./sqlite.ts";
|
|
5
|
+
import { MAX_TASK_LIFETIME_MS } from "./task-lifetime.ts";
|
|
6
|
+
import { cancelGeneration } from "./waits.ts";
|
|
7
|
+
|
|
8
|
+
const reason = "24-hour task lifetime exceeded";
|
|
9
|
+
const batch = 8;
|
|
10
|
+
|
|
11
|
+
export function overdueOperations(ctx: StoreContext) {
|
|
12
|
+
return getRows(ctx, `SELECT operation_id FROM operations WHERE phase = 'running' AND terminal_revision = 0
|
|
13
|
+
AND created_at <= ? ORDER BY created_at LIMIT ?`, ctx.now() - MAX_TASK_LIFETIME_MS, batch)
|
|
14
|
+
.map(row => getOperation(ctx, columnText(row, "operation_id"))!)
|
|
15
|
+
.filter(operation => operation.phase === "running");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function expireWaits(ctx: StoreContext): number {
|
|
19
|
+
const now = ctx.now();
|
|
20
|
+
const cutoff = now - MAX_TASK_LIFETIME_MS;
|
|
21
|
+
const waits = getRows(ctx, `SELECT wait_id, generation FROM waits WHERE phase NOT IN ('consumed', 'cancelled')
|
|
22
|
+
AND dispatch_disarmed = 0 AND created_at <= ? ORDER BY created_at LIMIT ?`, cutoff, batch);
|
|
23
|
+
const claims = getRows(ctx, `SELECT claim_id FROM resume_claims WHERE state IN ('claimed', 'published')
|
|
24
|
+
AND claimed_at <= ? ORDER BY claimed_at LIMIT ?`, cutoff, batch);
|
|
25
|
+
if (!waits.length && !claims.length) return 0;
|
|
26
|
+
return ctx.transaction(() => {
|
|
27
|
+
let changed = 0;
|
|
28
|
+
for (const row of waits) {
|
|
29
|
+
const id = columnText(row, "wait_id"), generation = columnNumber(row, "generation");
|
|
30
|
+
if (!ctx.db.prepare(`SELECT 1 FROM waits WHERE wait_id = ? AND generation = ?
|
|
31
|
+
AND phase NOT IN ('consumed', 'cancelled') AND dispatch_disarmed = 0 AND created_at <= ?`).get(id, generation, cutoff)) continue;
|
|
32
|
+
cancelGeneration(ctx, id, generation, reason);
|
|
33
|
+
changed++;
|
|
34
|
+
}
|
|
35
|
+
// Published claims can outlive consumed waits or a disarmed assignment.
|
|
36
|
+
for (const row of claims) {
|
|
37
|
+
changed += run(ctx, `UPDATE resume_claims SET state = 'invalidated', invalidated_at = ?, reason = ?
|
|
38
|
+
WHERE claim_id = ? AND state IN ('claimed', 'published') AND claimed_at <= ?`,
|
|
39
|
+
now, reason, columnText(row, "claim_id"), cutoff);
|
|
40
|
+
}
|
|
41
|
+
if (changed) bumpChangeRevision(ctx);
|
|
42
|
+
return changed;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -60,6 +60,11 @@ const ASSIGNMENT_ATTEMPTS_DDL = `CREATE TABLE IF NOT EXISTS assignment_attempts
|
|
|
60
60
|
assignment_id TEXT NOT NULL REFERENCES assignment_bindings (assignment_id)
|
|
61
61
|
)`;
|
|
62
62
|
const ASSIGNMENT_ATTEMPT_COLUMN = `assignment_attempt_id TEXT REFERENCES assignment_attempts (attempt_id)`;
|
|
63
|
+
const EXPIRY_INDEXES = [
|
|
64
|
+
"CREATE INDEX IF NOT EXISTS operations_expiry ON operations(created_at) WHERE phase = 'running' AND terminal_revision = 0",
|
|
65
|
+
"CREATE INDEX IF NOT EXISTS waits_expiry ON waits(created_at) WHERE phase NOT IN ('consumed', 'cancelled') AND dispatch_disarmed = 0",
|
|
66
|
+
"CREATE INDEX IF NOT EXISTS claims_expiry ON resume_claims(claimed_at) WHERE state IN ('claimed', 'published')",
|
|
67
|
+
];
|
|
63
68
|
const ASSIGNMENT_CLEANUP_INDEX = `CREATE INDEX IF NOT EXISTS operations_assignment_cleanup
|
|
64
69
|
ON operations (operation_id, assignment_attempt_id)
|
|
65
70
|
WHERE assignment_attempt_id IS NOT NULL`;
|
|
@@ -301,7 +306,7 @@ export function ensureSchema(ctx) {
|
|
|
301
306
|
throw new StoreError("schema-version", `The database at this path holds tables (${tables.join(", ")}) but no ${SCHEMA_VERSION_KEY}. It was not written by the operation coordinator; refusing to reuse or clear it.`);
|
|
302
307
|
}
|
|
303
308
|
ctx.transaction(() => {
|
|
304
|
-
for (const statement of DDL)
|
|
309
|
+
for (const statement of [...DDL, ...EXPIRY_INDEXES])
|
|
305
310
|
ctx.db.exec(statement);
|
|
306
311
|
run(ctx, "INSERT INTO schema_meta (key, value) VALUES (?, ?)", SCHEMA_VERSION_KEY, String(SCHEMA_VERSION));
|
|
307
312
|
});
|
|
@@ -351,6 +356,8 @@ export function ensureSchema(ctx) {
|
|
|
351
356
|
ensureAssignmentCleanupSchema(ctx);
|
|
352
357
|
}
|
|
353
358
|
function ensureAssignmentCleanupSchema(ctx) {
|
|
359
|
+
for (const statement of EXPIRY_INDEXES)
|
|
360
|
+
ctx.db.exec(statement);
|
|
354
361
|
const hasColumn = () => getRows(ctx, "PRAGMA table_info(operations)").some(row => row.name === "assignment_attempt_id");
|
|
355
362
|
if (hasColumn() && getRow(ctx, "SELECT 1 FROM sqlite_master WHERE name = 'operations_assignment_cleanup'"))
|
|
356
363
|
return;
|
|
@@ -62,6 +62,12 @@ const ASSIGNMENT_ATTEMPTS_DDL = `CREATE TABLE IF NOT EXISTS assignment_attempts
|
|
|
62
62
|
assignment_id TEXT NOT NULL REFERENCES assignment_bindings (assignment_id)
|
|
63
63
|
)`;
|
|
64
64
|
const ASSIGNMENT_ATTEMPT_COLUMN = `assignment_attempt_id TEXT REFERENCES assignment_attempts (attempt_id)`;
|
|
65
|
+
const EXPIRY_INDEXES = [
|
|
66
|
+
"CREATE INDEX IF NOT EXISTS operations_expiry ON operations(created_at) WHERE phase = 'running' AND terminal_revision = 0",
|
|
67
|
+
"CREATE INDEX IF NOT EXISTS waits_expiry ON waits(created_at) WHERE phase NOT IN ('consumed', 'cancelled') AND dispatch_disarmed = 0",
|
|
68
|
+
"CREATE INDEX IF NOT EXISTS claims_expiry ON resume_claims(claimed_at) WHERE state IN ('claimed', 'published')",
|
|
69
|
+
];
|
|
70
|
+
|
|
65
71
|
const ASSIGNMENT_CLEANUP_INDEX = `CREATE INDEX IF NOT EXISTS operations_assignment_cleanup
|
|
66
72
|
ON operations (operation_id, assignment_attempt_id)
|
|
67
73
|
WHERE assignment_attempt_id IS NOT NULL`;
|
|
@@ -313,7 +319,7 @@ export function ensureSchema(ctx: StoreContext): void {
|
|
|
313
319
|
);
|
|
314
320
|
}
|
|
315
321
|
ctx.transaction(() => {
|
|
316
|
-
for (const statement of DDL) ctx.db.exec(statement);
|
|
322
|
+
for (const statement of [...DDL, ...EXPIRY_INDEXES]) ctx.db.exec(statement);
|
|
317
323
|
run(ctx, "INSERT INTO schema_meta (key, value) VALUES (?, ?)", SCHEMA_VERSION_KEY, String(SCHEMA_VERSION));
|
|
318
324
|
});
|
|
319
325
|
return;
|
|
@@ -369,6 +375,7 @@ export function ensureSchema(ctx: StoreContext): void {
|
|
|
369
375
|
}
|
|
370
376
|
|
|
371
377
|
function ensureAssignmentCleanupSchema(ctx: StoreContext): void {
|
|
378
|
+
for (const statement of EXPIRY_INDEXES) ctx.db.exec(statement);
|
|
372
379
|
const hasColumn = () => getRows(ctx, "PRAGMA table_info(operations)").some(row => row.name === "assignment_attempt_id");
|
|
373
380
|
if (hasColumn() && getRow(ctx, "SELECT 1 FROM sqlite_master WHERE name = 'operations_assignment_cleanup'")) return;
|
|
374
381
|
ctx.transaction(() => {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* synchronous and transactional; a refusal throws `StoreError` with a typed code
|
|
9
9
|
* and leaves no partial record.
|
|
10
10
|
*/
|
|
11
|
+
import { expireWaits, overdueOperations } from "./expiry.domain.mjs";
|
|
11
12
|
import { setUpgradeFence } from "./upgrade.domain.mjs";
|
|
12
13
|
import { setParentCallbackPending, listPendingParentCallbacks, listRecentBackgroundTerminals, seedPendingParentCallbacks } from "./background-parent-callbacks.domain.mjs";
|
|
13
14
|
import { BackgroundRequests } from "./background-requests.domain.mjs";
|
|
@@ -51,6 +52,8 @@ export function openStore(options) {
|
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
const store = {
|
|
55
|
+
overdueOperations() { alive(); return overdueOperations(ctx); },
|
|
56
|
+
expireWaits() { alive(); return expireWaits(ctx); },
|
|
54
57
|
subagentLaunchJournal() { alive(); return new SubagentLaunchJournal(ctx, alive); },
|
|
55
58
|
resultScopeManaged(scope) { alive(); return resultScopeManaged(ctx, scope); },
|
|
56
59
|
handoffResultScope(input) { alive(); return handoffResultScope(ctx, input); },
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* synchronous and transactional; a refusal throws `StoreError` with a typed code
|
|
8
8
|
* and leaves no partial record.
|
|
9
9
|
*/
|
|
10
|
+
import { expireWaits, overdueOperations } from "./expiry.ts";
|
|
10
11
|
import { setUpgradeFence } from "./upgrade.ts";
|
|
11
12
|
import { setParentCallbackPending, listPendingParentCallbacks, listRecentBackgroundTerminals, seedPendingParentCallbacks, type ParentCallbackScope, type ParentCallbackPage, type RecentBackgroundTerminalPage } from './background-parent-callbacks.ts';
|
|
12
13
|
import { BackgroundRequests } from "./background-requests.ts";
|
|
@@ -127,6 +128,8 @@ import {
|
|
|
127
128
|
} from "./types.ts";
|
|
128
129
|
|
|
129
130
|
export interface Store {
|
|
131
|
+
overdueOperations(): OperationRecord[];
|
|
132
|
+
expireWaits(): number;
|
|
130
133
|
hasSubagentManagement(): boolean;
|
|
131
134
|
resultSupervisionChanges(after?: Parameters<typeof resultSupervisionChanges>[1]): ReturnType<typeof resultSupervisionChanges>;
|
|
132
135
|
subagentLaunchJournal(): SubagentLaunchJournal;
|
|
@@ -359,6 +362,8 @@ export function openStore(options: StoreOptions): Store {
|
|
|
359
362
|
};
|
|
360
363
|
|
|
361
364
|
const store: Store = {
|
|
365
|
+
overdueOperations() { alive(); return overdueOperations(ctx); },
|
|
366
|
+
expireWaits() { alive(); return expireWaits(ctx); },
|
|
362
367
|
subagentLaunchJournal() { alive(); return new SubagentLaunchJournal(ctx, alive); },
|
|
363
368
|
resultScopeManaged(scope) { alive(); return resultScopeManaged(ctx, scope); },
|
|
364
369
|
handoffResultScope(input) { alive(); return handoffResultScope(ctx, input); },
|
package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-lifetime.domain.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/shared-operation-coordinator/src/task-lifetime.ts. Do not edit directly.
|
|
2
|
+
// Generated from packages/operation-coordinator/src/task-lifetime.ts. Do not edit directly.
|
|
3
|
+
/** Absolute wall-clock limit, including time spent waiting for a runner. */
|
|
4
|
+
export const MAX_TASK_LIFETIME_MS = 24 * 60 * 60 * 1000;
|
|
5
|
+
export function taskDeadline(startedAt, requestedDeadline) {
|
|
6
|
+
return Math.min(startedAt + MAX_TASK_LIFETIME_MS, requestedDeadline ?? Infinity);
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Generated from packages/operation-coordinator/src/task-lifetime.ts. Do not edit directly.
|
|
2
|
+
/** Absolute wall-clock limit, including time spent waiting for a runner. */
|
|
3
|
+
export const MAX_TASK_LIFETIME_MS = 24 * 60 * 60 * 1000;
|
|
4
|
+
|
|
5
|
+
export function taskDeadline(startedAt: number, requestedDeadline?: number): number {
|
|
6
|
+
return Math.min(startedAt + MAX_TASK_LIFETIME_MS, requestedDeadline ?? Infinity);
|
|
7
|
+
}
|