@intentic/sandbox-contract 1.389.0 → 1.391.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/README.md +6 -1
- package/dist/contracts/agents.contract.d.ts +69 -0
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.js +10 -0
- package/dist/contracts/agents.contract.js.map +1 -1
- package/dist/contracts/device.contract.d.ts +14 -0
- package/dist/contracts/device.contract.d.ts.map +1 -1
- package/dist/contracts/device.contract.js +2 -2
- package/dist/contracts/device.contract.js.map +1 -1
- package/dist/contracts/ports.contract.d.ts +5 -0
- package/dist/contracts/ports.contract.d.ts.map +1 -1
- package/dist/contracts/ports.contract.js +1 -1
- package/dist/contracts/ports.contract.js.map +1 -1
- package/dist/contracts/runner.contract.d.ts +12 -4
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/runs.contract.d.ts +17 -0
- package/dist/contracts/runs.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.d.ts +16 -0
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +66 -0
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.js +10 -1
- package/dist/contracts/system.contract.js.map +1 -1
- package/dist/events/agent-events.d.ts +4 -0
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-events.js +1 -0
- package/dist/events/agent-events.js.map +1 -1
- package/dist/events/agent-transcript.d.ts +1 -0
- package/dist/events/agent-transcript.d.ts.map +1 -1
- package/dist/events/failure-rows.js +1 -1
- package/dist/events/failure-rows.js.map +1 -1
- package/dist/events/land-conflict.d.ts +1 -0
- package/dist/events/land-conflict.d.ts.map +1 -1
- package/dist/events/land-conflict.js +4 -3
- package/dist/events/land-conflict.js.map +1 -1
- package/dist/events/requests.d.ts +1 -0
- package/dist/events/requests.d.ts.map +1 -1
- package/dist/events/requests.js +1 -1
- package/dist/events/requests.js.map +1 -1
- package/dist/events/resume.d.ts +2 -0
- package/dist/events/resume.d.ts.map +1 -1
- package/dist/events/resume.js +2 -0
- package/dist/events/resume.js.map +1 -1
- package/dist/events/sandbox-notice.d.ts +1 -0
- package/dist/events/sandbox-notice.d.ts.map +1 -1
- package/dist/events/sandbox-notice.js +1 -0
- package/dist/events/sandbox-notice.js.map +1 -1
- package/dist/events/system-events.d.ts +12 -0
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/transcript.d.ts +1 -0
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/events/transcript.js +4 -0
- package/dist/events/transcript.js.map +1 -1
- package/dist/index.d.ts +173 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/models/agent-standing.d.ts +2 -0
- package/dist/models/agent-standing.d.ts.map +1 -1
- package/dist/models/agent-standing.js.map +1 -1
- package/dist/models/model-setups.d.ts.map +1 -1
- package/dist/models/model-setups.js +2 -1
- package/dist/models/model-setups.js.map +1 -1
- package/dist/policy/failure-codes.d.ts +158 -0
- package/dist/policy/failure-codes.d.ts.map +1 -0
- package/dist/policy/failure-codes.js +50 -0
- package/dist/policy/failure-codes.js.map +1 -0
- package/dist/protocol/raw/raw-routes.d.ts +12 -0
- package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-routes.js +3 -0
- package/dist/protocol/raw/raw-routes.js.map +1 -1
- package/dist/schemas/agent-press.d.ts +13 -0
- package/dist/schemas/agent-press.d.ts.map +1 -0
- package/dist/schemas/agent-press.js +14 -0
- package/dist/schemas/agent-press.js.map +1 -0
- package/dist/schemas/agents-list.d.ts +6 -0
- package/dist/schemas/agents-list.d.ts.map +1 -1
- package/dist/schemas/agents.d.ts +11 -0
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/agents.js +5 -6
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/device-resources.d.ts +54 -0
- package/dist/schemas/device-resources.d.ts.map +1 -0
- package/dist/schemas/device-resources.js +29 -0
- package/dist/schemas/device-resources.js.map +1 -0
- package/dist/schemas/devices.d.ts +2 -52
- package/dist/schemas/devices.d.ts.map +1 -1
- package/dist/schemas/devices.js +2 -27
- package/dist/schemas/devices.js.map +1 -1
- package/dist/schemas/git/clone.d.ts +12 -0
- package/dist/schemas/git/clone.d.ts.map +1 -0
- package/dist/schemas/git/clone.js +14 -0
- package/dist/schemas/git/clone.js.map +1 -0
- package/dist/schemas/hosts.d.ts +37 -0
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +22 -0
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/metrics.d.ts +59 -0
- package/dist/schemas/metrics.d.ts.map +1 -1
- package/dist/schemas/metrics.js +19 -0
- package/dist/schemas/metrics.js.map +1 -1
- package/dist/schemas/ports.d.ts +10 -0
- package/dist/schemas/ports.d.ts.map +1 -1
- package/dist/schemas/ports.js +8 -0
- package/dist/schemas/ports.js.map +1 -1
- package/dist/schemas/providers/handoff.d.ts +1 -0
- package/dist/schemas/providers/handoff.d.ts.map +1 -1
- package/dist/schemas/providers/handoff.js +4 -1
- package/dist/schemas/providers/handoff.js.map +1 -1
- package/dist/schemas/providers/plan-limits.js +1 -1
- package/dist/schemas/providers/plan-limits.js.map +1 -1
- package/dist/schemas/run-targets.d.ts +36 -0
- package/dist/schemas/run-targets.d.ts.map +1 -1
- package/dist/schemas/run-targets.js +11 -0
- package/dist/schemas/run-targets.js.map +1 -1
- package/dist/schemas/settings.d.ts +29 -0
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +17 -0
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/stranded-clone.d.ts +9 -0
- package/dist/schemas/stranded-clone.d.ts.map +1 -0
- package/dist/schemas/stranded-clone.js +12 -0
- package/dist/schemas/stranded-clone.js.map +1 -0
- package/dist/state/definition.d.ts +20 -0
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/fix-stance.js +1 -1
- package/dist/state/fix-stance.js.map +1 -1
- package/dist/state/runtime-state.d.ts +3 -0
- package/dist/state/runtime-state.d.ts.map +1 -1
- package/dist/state/runtime-state.js +1 -0
- package/dist/state/runtime-state.js.map +1 -1
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +1 -1
- package/dist/state/workspace-state.js.map +1 -1
- package/dist/text/transcript-fold.d.ts.map +1 -1
- package/dist/text/transcript-fold.js +6 -6
- package/dist/text/transcript-fold.js.map +1 -1
- package/dist/text/transcript-interruption.d.ts +4 -0
- package/dist/text/transcript-interruption.d.ts.map +1 -0
- package/dist/text/transcript-interruption.js +27 -0
- package/dist/text/transcript-interruption.js.map +1 -0
- package/package.json +5 -5
- package/src/contracts/agents.contract.ts +12 -0
- package/src/contracts/device.contract.ts +4 -3
- package/src/contracts/ports.contract.ts +3 -2
- package/src/contracts/system.contract.ts +12 -1
- package/src/events/agent-events.ts +2 -0
- package/src/events/failure-rows.ts +1 -1
- package/src/events/land-conflict.test.ts +13 -1
- package/src/events/land-conflict.ts +8 -4
- package/src/events/requests.ts +1 -1
- package/src/events/resume.test.ts +7 -1
- package/src/events/resume.ts +3 -0
- package/src/events/sandbox-notice.ts +1 -0
- package/src/events/transcript.ts +6 -0
- package/src/models/agent-standing.ts +4 -0
- package/src/models/model-setups.test.ts +11 -0
- package/src/models/model-setups.ts +4 -1
- package/src/policy/failure-codes.ts +157 -0
- package/src/policy/tests/failure-codes.test.ts +141 -0
- package/src/protocol/raw/raw-routes.ts +5 -0
- package/src/schemas/agent-press.test.ts +46 -0
- package/src/schemas/agent-press.ts +34 -0
- package/src/schemas/agents.ts +8 -8
- package/src/schemas/device-resources.ts +58 -0
- package/src/schemas/devices.ts +20 -56
- package/src/schemas/git/clone.ts +22 -0
- package/src/schemas/hosts.ts +62 -0
- package/src/schemas/metrics.ts +28 -0
- package/src/schemas/ports.ts +12 -0
- package/src/schemas/providers/handoff.test.ts +7 -0
- package/src/schemas/providers/handoff.ts +4 -1
- package/src/schemas/providers/plan-limits.ts +1 -1
- package/src/schemas/run-targets.ts +31 -1
- package/src/schemas/settings.ts +32 -0
- package/src/schemas/stranded-clone.ts +15 -0
- package/src/state/fix-stance.ts +1 -1
- package/src/state/runtime-state.ts +4 -0
- package/src/state/workspace-state.ts +3 -2
- package/src/text/transcript-fold.test.ts +21 -7
- package/src/text/transcript-fold.ts +5 -6
- package/src/text/transcript-interruption.ts +30 -0
- package/dist/policy/turned-away.d.ts +0 -3
- package/dist/policy/turned-away.d.ts.map +0 -1
- package/dist/policy/turned-away.js +0 -33
- package/dist/policy/turned-away.js.map +0 -1
- package/src/policy/turned-away.ts +0 -52
package/src/schemas/devices.ts
CHANGED
|
@@ -1,71 +1,35 @@
|
|
|
1
1
|
// What one of the user's own machines is running.
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import {
|
|
4
|
+
SandboxResourcesAskSchema,
|
|
5
|
+
SandboxResourcesSchema,
|
|
6
|
+
SandboxShapeSchema,
|
|
7
|
+
SandboxShapeWhenSchema,
|
|
8
|
+
type SandboxShape,
|
|
9
|
+
type SandboxShapeWhen,
|
|
10
|
+
} from "./device-resources.js";
|
|
3
11
|
import { PortNumberSchema } from "./device-commands.js";
|
|
4
12
|
import { DeviceBridgeHoldSchema, DeviceConflictSchema, DeviceCopySchema, DeviceLowDiskSchema } from "./device-folder.js";
|
|
5
13
|
import { parseHostConnection, type DeviceFacts, DeviceFactsSchema, MachineIdentitySchema, MachineIdSchema, userDistrosOf, WslEnvironmentSchema } from "./hosts.js";
|
|
6
14
|
import { EgressOwnerKeysSchema, EgressPolicySchema, EgressProofSchema, EgressStatusSchema } from "./egress.js";
|
|
7
15
|
import { RollbackTargetSchema, UpdateOutcomeSchema } from "./updates.js";
|
|
8
16
|
import { DEV_VERSION } from "../state/versions.js";
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
SandboxResourcesAskFieldsSchema,
|
|
20
|
+
SandboxResourcesAskSchema,
|
|
21
|
+
SandboxResourcesSchema,
|
|
22
|
+
SandboxShapeSchema,
|
|
23
|
+
SandboxShapeWhenSchema,
|
|
24
|
+
type SandboxResources,
|
|
25
|
+
type SandboxResourcesAsk,
|
|
26
|
+
type SandboxShape,
|
|
27
|
+
type SandboxShapeWhen,
|
|
28
|
+
} from "./device-resources.js";
|
|
9
29
|
// Desktop-sync report shape shared by the agent, daemon and browser, produced only by the agent's own `deviceReport`.
|
|
10
30
|
// The agent never reports `sandboxes`; the docker half is filled in by whoever reads the report, scoped to the reader's
|
|
11
31
|
// own pairing.
|
|
12
32
|
|
|
13
|
-
// One sandbox's resource share as docker currently enforces it, read off the container by the machine agent.
|
|
14
|
-
// `overlayRuntime` is the environment's locked demand; `hostRuntime` is the owner's addition; `privileged`/`gpu` are
|
|
15
|
-
// docker's enforced truth.
|
|
16
|
-
// A delta against what runs: absent means leave it, `null` on the two caps means back to the default; at least one key
|
|
17
|
-
// must be set. What the old `reshape` op carries, which the machine agent carries out as `ic sandbox shape --set` (its
|
|
18
|
-
// `olderResizePlan`); `set-shape` carries a whole shape instead.
|
|
19
|
-
export const SandboxResourcesAskFieldsSchema = z.object({
|
|
20
|
-
memoryGib: z.int().positive().nullable().optional(),
|
|
21
|
-
cpus: z.int().positive().nullable().optional(),
|
|
22
|
-
privileged: z.boolean().optional(),
|
|
23
|
-
gpu: z.boolean().optional(),
|
|
24
|
-
});
|
|
25
|
-
// A sandbox's shape, WHOLE: the owner's own ask for its share of the machine, every field a value. `null` on a cap is
|
|
26
|
-
// the contract's default (the share derived from the engine, or every core). The switches are the owner's ask, not
|
|
27
|
-
// docker's answer: a directive the approved environment demands rides beside it (`overlayRuntime`), and a host
|
|
28
|
-
// without the NVIDIA runtime drops the GPU. `ic` stores it, validates it against the image's run contract when it is
|
|
29
|
-
// saved, and prints it in `ic sandbox list --json`; nobody else merges anything into it.
|
|
30
|
-
export const SandboxShapeSchema = z.object({
|
|
31
|
-
memoryGib: z.int().positive().nullable(),
|
|
32
|
-
cpus: z.int().positive().nullable(),
|
|
33
|
-
privileged: z.boolean(),
|
|
34
|
-
gpu: z.boolean(),
|
|
35
|
-
});
|
|
36
|
-
export type SandboxShape = z.infer<typeof SandboxShapeSchema>;
|
|
37
|
-
// When a `set-shape` takes effect: `now` restarts the sandbox onto it; `nextRestart` saves it in ic's record and
|
|
38
|
-
// restarts nothing, and the next restart through ic applies it — Restart or Start from any door, an update, a rollback
|
|
39
|
-
// or a rebuild. Docker restarting the container by itself (after a crash or a reboot) does not: only ic recreates one.
|
|
40
|
-
export const SandboxShapeWhenSchema = z.enum(["now", "nextRestart"]);
|
|
41
|
-
export type SandboxShapeWhen = z.infer<typeof SandboxShapeWhenSchema>;
|
|
42
|
-
|
|
43
|
-
export const SandboxResourcesSchema = z.object({
|
|
44
|
-
// The cgroup memory ceiling in bytes; absent when docker imposes none (the hosted shape).
|
|
45
|
-
memoryBytes: z.number().optional(),
|
|
46
|
-
// The CFS quota as whole cores; absent when the container may use every core (the default).
|
|
47
|
-
cpus: z.number().optional(),
|
|
48
|
-
privileged: z.boolean(),
|
|
49
|
-
gpu: z.boolean(),
|
|
50
|
-
hostRuntime: z.array(z.string()),
|
|
51
|
-
overlayRuntime: z.array(z.string()),
|
|
52
|
-
// The shape the container runs with (the owner's ask it carries). Absent from an agent older than `set-shape`.
|
|
53
|
-
shape: SandboxShapeSchema.optional(),
|
|
54
|
-
// The shape saved for the sandbox's next restart through ic, and not yet in force. Absent when nothing is saved.
|
|
55
|
-
desired: SandboxShapeSchema.optional(),
|
|
56
|
-
// READ-ONLY, from agents older than `set-shape`: their saved share, a delta against what runs. Nothing new writes
|
|
57
|
-
// it; kept one release so a newer page can still show what an older agent saved. Remove with `later`.
|
|
58
|
-
saved: SandboxResourcesAskFieldsSchema.optional(),
|
|
59
|
-
});
|
|
60
|
-
export type SandboxResources = z.infer<typeof SandboxResourcesSchema>;
|
|
61
|
-
|
|
62
|
-
// Fields also exported separately for callers that compose them and enforce the at-least-one rule themselves.
|
|
63
|
-
// Strict like every device input (DeviceSandboxFlowSchema says why): it is only ever sent to a device.
|
|
64
|
-
export const SandboxResourcesAskSchema = SandboxResourcesAskFieldsSchema.strict().refine((ask) => Object.values(ask).some((value) => value !== undefined), {
|
|
65
|
-
message: "a reshape must change at least one thing",
|
|
66
|
-
});
|
|
67
|
-
export type SandboxResourcesAsk = z.infer<typeof SandboxResourcesAskSchema>;
|
|
68
|
-
|
|
69
33
|
// One sandbox container on the machine, the docker half, filled in by the reader, never by the sync agent.
|
|
70
34
|
export const DeviceSandboxSchema = z.object({
|
|
71
35
|
slug: z.string(),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// A clone of its own a turn left inside its copy (TurnReach.stranded), settled one of two ways: folded into the
|
|
4
|
+
// repository it sits in, its own `.git` removed so its files land with the rest, or moved into the workspace as a
|
|
5
|
+
// repository of its own.
|
|
6
|
+
export const AgentCloneSchema = z.object({
|
|
7
|
+
id: z.string().min(1).describe("Which conversation."),
|
|
8
|
+
dir: z.string().min(1).describe("The clone, exactly as the card's reach names it: a folder relative to the conversation's copy of the workspace."),
|
|
9
|
+
action: z
|
|
10
|
+
.enum(["fold", "adopt"])
|
|
11
|
+
.describe(
|
|
12
|
+
"`fold`: remove the clone's own `.git`, so its files are ordinary work of the repository it sits in and land with it. `adopt`: move it into your workspace at the same folder, `.git` and all, as a repository of its own.",
|
|
13
|
+
),
|
|
14
|
+
dropCommits: z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe(
|
|
19
|
+
"For `fold` of a clone that holds commits: how many the caller was shown and agreed to drop. The files stay; only that history goes. Refused when absent or not the clone's count now.",
|
|
20
|
+
),
|
|
21
|
+
});
|
|
22
|
+
export type AgentClone = z.infer<typeof AgentCloneSchema>;
|
package/src/schemas/hosts.ts
CHANGED
|
@@ -107,6 +107,68 @@ export const DeviceFactsSchema = z.object({
|
|
|
107
107
|
});
|
|
108
108
|
export type DeviceFacts = z.infer<typeof DeviceFactsSchema>;
|
|
109
109
|
|
|
110
|
+
/* THE HOST'S OWN MEMORY, ON EVERY HEARTBEAT (2026-11-02). A sandbox on a Windows PC runs inside Docker Desktop's WSL2
|
|
111
|
+
VM, so everything it reads about memory (its cgroup, the VM's /proc/meminfo) is the VM's. On 2026-11-02 rog's Windows
|
|
112
|
+
was down to 1.1 GB available while the VM held 20 GB, half of it file cache, and the sandbox's heavy-command queue
|
|
113
|
+
kept admitting builds until Windows paged itself into a 43 s freeze. So the Windows side's agent answers the daemon's
|
|
114
|
+
heartbeat (`ping`, every HOST_HEARTBEAT_MS) with what Windows has, and the daemon holds heavy work back while the
|
|
115
|
+
machine that runs it is short. Only the Windows side says it: a distro's agent would read the same VM the sandbox
|
|
116
|
+
already reads, a Linux host's containers read the host kernel's meminfo themselves, and macOS's `os.freemem()` counts
|
|
117
|
+
free pages only, not what the system could give, so it would read short all the time. */
|
|
118
|
+
const HostMemorySchema = z.object({
|
|
119
|
+
// Physical memory the OS could hand out now (Windows' ullAvailPhys, standby cache included), in bytes.
|
|
120
|
+
availableBytes: z.number().nonnegative(),
|
|
121
|
+
totalBytes: z.number().positive(),
|
|
122
|
+
});
|
|
123
|
+
export type HostMemory = z.infer<typeof HostMemorySchema>;
|
|
124
|
+
|
|
125
|
+
/* THE HOST'S GPU RESETS AND CRASHES, ON EVERY HEARTBEAT (2026-11-03). On 2026-11-02 a sandbox agent rendered a page on
|
|
126
|
+
rog's display GPU through WSL (Mesa d3d12 over /dev/dxg); the driver lost the device (LiveKernelEvent 0x141) and the
|
|
127
|
+
PC powered off. All the sandbox could say afterwards was "killed without warning". So the Windows side's agent reads
|
|
128
|
+
Windows' own record of such events (the event log: a GPU timeout or reset, a bluescreen, an unexpected power-off) and
|
|
129
|
+
answers each heartbeat with those of the last day; the daemon keeps every one it has not seen, names them where it
|
|
130
|
+
explains a restart, and pauses GPU work after a GPU reset until the owner resumes it (`gpu.pausedFor` in settings). */
|
|
131
|
+
export const HostCrashEventSchema = z.object({
|
|
132
|
+
// Stable across heartbeats, so the daemon keeps each once: the log and its record id (`System:48213`), or a WER
|
|
133
|
+
// report's own id (`WER:<guid>`), since Windows logs a queued report again every few minutes.
|
|
134
|
+
id: z.string().min(1).max(120),
|
|
135
|
+
// When it happened, ISO 8601 UTC: when Windows logged it, or a WER report's dump time. A Kernel-Power 41 is logged as
|
|
136
|
+
// Windows boots again, after the power-off.
|
|
137
|
+
at: z.string().min(1),
|
|
138
|
+
// `gpu-reset`: the display driver timed out or was reset (LiveKernelEvent 141/117/116, Display 4101, a 0x116/0x117
|
|
139
|
+
// bluescreen). `host-crash`: Windows itself went down (Kernel-Power 41, any other bluescreen).
|
|
140
|
+
kind: z.enum(["gpu-reset", "host-crash"]),
|
|
141
|
+
// Windows' name for it: "LiveKernelEvent 141", "Display 4101", "Kernel-Power 41", "BugCheck 0x116".
|
|
142
|
+
code: z.string().min(1).max(80),
|
|
143
|
+
// Windows' own first line about it, trimmed.
|
|
144
|
+
detail: z.string().max(400).optional(),
|
|
145
|
+
});
|
|
146
|
+
export type HostCrashEvent = z.infer<typeof HostCrashEventSchema>;
|
|
147
|
+
|
|
148
|
+
// How far back the Windows side reports, and how many: a heartbeat answer stays small, and a day covers the reboot.
|
|
149
|
+
export const HOST_CRASH_LOOKBACK_MS = 24 * 60 * 60_000;
|
|
150
|
+
export const HOST_CRASHES_MAX = 20;
|
|
151
|
+
|
|
152
|
+
// The heartbeat's answer. `memory` and `crashes` are absent from an agent older than them and from every side but Windows
|
|
153
|
+
// (above); an older daemon reads the `ok` and nothing else.
|
|
154
|
+
export const DevicePingSchema = z.object({
|
|
155
|
+
ok: z.literal(true),
|
|
156
|
+
memory: HostMemorySchema.optional(),
|
|
157
|
+
crashes: z.array(HostCrashEventSchema).max(HOST_CRASHES_MAX).optional(),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const GIB = 1024 ** 3;
|
|
161
|
+
|
|
162
|
+
/* WHEN A HOST COUNTS AS SHORT OF MEMORY: under 1.5 GiB available or under a tenth of its memory, whichever is more.
|
|
163
|
+
One line both sides keep: below it the Windows side's agent gives the WSL VM's file cache back to Windows
|
|
164
|
+
(environments/wsl-cache-drop.ts in @intentic/machine), and the sandbox holds back heavy work that would take the host
|
|
165
|
+
below it. Windows' memory manager trims working sets and pages hard well before it reaches zero: rog froze with 1.1 GB
|
|
166
|
+
left, so the floor sits above that. A tenth scales it with the machine, where one browser or a game can take a few
|
|
167
|
+
gigabytes in a second and 1.5 GiB of a 64 GiB machine is no margin at all. */
|
|
168
|
+
const HOST_LOW_FLOOR_BYTES = 1.5 * GIB;
|
|
169
|
+
const HOST_LOW_SHARE = 0.1;
|
|
170
|
+
export const hostMemoryLowBytes = (totalBytes: number): number => Math.max(HOST_LOW_FLOOR_BYTES, HOST_LOW_SHARE * totalBytes);
|
|
171
|
+
|
|
110
172
|
// Optional device capabilities gate calls to older agents: never send an operation unless its advertised feature permits it.
|
|
111
173
|
// set-shape, rollback-to, background-prepare and sleep depend on ic support; keyring also requires a local installation.
|
|
112
174
|
// reshape-later protects legacy deferred reshapes from becoming immediate; project-delivery otherwise waits for Bring back.
|
package/src/schemas/metrics.ts
CHANGED
|
@@ -233,6 +233,9 @@ export const STORAGE_CLEANABILITY = {
|
|
|
233
233
|
packageStores: "safe",
|
|
234
234
|
// Build tools' output caches.
|
|
235
235
|
buildCaches: "safe",
|
|
236
|
+
// What builds left inside conversation checkouts (a Rust `target/`, Gradle and Flutter output): only checkouts whose
|
|
237
|
+
// conversation has nothing running are cleaned, and their next build makes it again. The checkout itself stays.
|
|
238
|
+
buildOutputs: "safe",
|
|
236
239
|
} as const satisfies Record<string, StorageCleanability>;
|
|
237
240
|
export type StorageCategoryId = keyof typeof STORAGE_CLEANABILITY;
|
|
238
241
|
export const StorageCategoryIdSchema = z.enum(Object.keys(STORAGE_CLEANABILITY) as StorageCategoryId[]);
|
|
@@ -303,6 +306,31 @@ export const StorageReportSchema = z.object({
|
|
|
303
306
|
});
|
|
304
307
|
export type StorageReport = z.infer<typeof StorageReportSchema>;
|
|
305
308
|
|
|
309
|
+
// How close the history volume is to full, as the daemon's disk-pressure watch last read it (GET /system/disk-pressure).
|
|
310
|
+
// `reaping`: under 15% free, settled checkouts' build output is being removed; `low` and `critical` are under 10% and
|
|
311
|
+
// 5%, which the owner is told about once each.
|
|
312
|
+
export const DiskPressureLevelSchema = z.enum(["ok", "reaping", "low", "critical"]);
|
|
313
|
+
export type DiskPressureLevel = z.infer<typeof DiskPressureLevelSchema>;
|
|
314
|
+
|
|
315
|
+
export const DiskPressureSchema = z.object({
|
|
316
|
+
level: DiskPressureLevelSchema,
|
|
317
|
+
freeBytes: z.number().describe("Space available on the history volume at the last reading."),
|
|
318
|
+
totalBytes: z.number().describe("The history volume's size."),
|
|
319
|
+
measuredAt: z.number().describe("When it was read, in milliseconds; 0 before the first reading."),
|
|
320
|
+
reaped: z
|
|
321
|
+
.object({
|
|
322
|
+
bytes: z.number().describe("Space the removals gave back, as the volume measured it before and after."),
|
|
323
|
+
checkouts: z.number().describe("How many conversation checkouts had build output removed."),
|
|
324
|
+
at: z.number().describe("When that pass ended, in milliseconds."),
|
|
325
|
+
})
|
|
326
|
+
.optional()
|
|
327
|
+
.describe("The last pass that removed build output because the disk was short. Absent until one has."),
|
|
328
|
+
using: z
|
|
329
|
+
.array(z.object({ id: StorageCategoryIdSchema, bytes: z.number() }))
|
|
330
|
+
.describe("The biggest categories in the last finished storage scan, largest first, at most three; empty before a scan."),
|
|
331
|
+
});
|
|
332
|
+
export type DiskPressure = z.infer<typeof DiskPressureSchema>;
|
|
333
|
+
|
|
306
334
|
export const StorageCleanInputSchema = z.object({
|
|
307
335
|
category: StorageCategoryIdSchema.describe("The category to clean; one whose cleanability is `none` is refused."),
|
|
308
336
|
});
|
package/src/schemas/ports.ts
CHANGED
|
@@ -55,6 +55,18 @@ export const PortSummarySchema = z.object({
|
|
|
55
55
|
})
|
|
56
56
|
.optional()
|
|
57
57
|
.describe("The background job an agent left running for you on this port, when that is what answers here."),
|
|
58
|
+
// (2026-11-03) In the owner's shinobi workspace 53 conversations ran ss and pgrep to find whose server held a port,
|
|
59
|
+
// and one agent's scratch server sat on the owner's 7878, which the desktop mirror put on his own localhost.
|
|
60
|
+
owner: z
|
|
61
|
+
.object({
|
|
62
|
+
conversationId: z.string().describe("The conversation whose agent opened it, in its shell or a background job."),
|
|
63
|
+
jobId: z.string().optional().describe("The background job serving it, when one job of that conversation can be named."),
|
|
64
|
+
label: z.string().optional().describe("What that job is, in the agent's own words when it gave any."),
|
|
65
|
+
})
|
|
66
|
+
.optional()
|
|
67
|
+
.describe(
|
|
68
|
+
"Which conversation's agent is listening here, when it can be told. Such a port stays off the owner's computers (the desktop mirror leaves it out) unless the job was left running for them (`job`) or the owner asks for it there.",
|
|
69
|
+
),
|
|
58
70
|
forwarded: z.boolean().describe("Whether it is currently reachable from outside."),
|
|
59
71
|
// `https://port-<slot>-<sandboxId>.<zone>`.
|
|
60
72
|
previewUrl: z.string().optional().describe("Where to open it. Present only while forwarded, and only on a sandbox that has an outside address."),
|
|
@@ -62,3 +62,10 @@ describe("a home's fresh start", () => {
|
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
test("a failed summary carries its reason into both the notice and readable line", () => {
|
|
68
|
+
const event = { mode: "summary", fellBack: true, reason: "Every summary model is out of allowance" } as const;
|
|
69
|
+
expect(handedOffNotice(event)).toEqual({ code: "handedOff", params: event });
|
|
70
|
+
expect(handedOffLine(event)).toBe("Could not write a summary for the hand-off, so the fresh session opened with the recent conversation and where the work stands instead. Reason: Every summary model is out of allowance");
|
|
71
|
+
});
|
|
@@ -90,6 +90,7 @@ export const HandedOffSchema = z.object({
|
|
|
90
90
|
cleared: z.number().optional().describe("Older tool outputs a trimmed copy cleared."),
|
|
91
91
|
model: z.string().optional().describe("The model that wrote the summary."),
|
|
92
92
|
fellBack: z.boolean().optional(),
|
|
93
|
+
reason: z.string().optional().describe("Why the requested hand-off could not be built."),
|
|
93
94
|
});
|
|
94
95
|
export type HandedOff = z.infer<typeof HandedOffSchema>;
|
|
95
96
|
|
|
@@ -102,15 +103,17 @@ export const handedOffNotice = (event: HandedOff): Extract<SandboxNotice, { code
|
|
|
102
103
|
...(event.cleared === undefined ? {} : { cleared: event.cleared }),
|
|
103
104
|
...(event.model === undefined ? {} : { model: event.model }),
|
|
104
105
|
...(event.fellBack === true ? { fellBack: true } : {}),
|
|
106
|
+
...(event.reason === undefined ? {} : { reason: event.reason }),
|
|
105
107
|
},
|
|
106
108
|
});
|
|
107
109
|
|
|
108
110
|
/** The transcript's line for how a held turn continued. */
|
|
109
111
|
export const handedOffLine = (event: HandedOff): string => {
|
|
110
112
|
if (event.fellBack === true) {
|
|
111
|
-
|
|
113
|
+
const line = event.mode === "trim"
|
|
112
114
|
? "Could not trim the session for the hand-off, so it was carried whole."
|
|
113
115
|
: "Could not write a summary for the hand-off, so the fresh session opened with the recent conversation and where the work stands instead.";
|
|
116
|
+
return event.reason === undefined ? line : `${line} Reason: ${event.reason}`;
|
|
114
117
|
}
|
|
115
118
|
const tokens = event.tokens === undefined ? undefined : tokensLabel(event.tokens);
|
|
116
119
|
switch (event.mode) {
|
|
@@ -198,7 +198,7 @@ export const AgentReplySchema = z.discriminatedUnion("kind", [
|
|
|
198
198
|
.describe(
|
|
199
199
|
"Whether to go ahead. Approving means the plan then runs without a prompt per tool, because being asked whether a plan you just approved may run its first command is not a question worth having.",
|
|
200
200
|
),
|
|
201
|
-
feedback: z.string().optional().describe("
|
|
201
|
+
feedback: z.string().optional().describe("Instructions to follow while executing an approved plan, or changes requested when rejecting it."),
|
|
202
202
|
}),
|
|
203
203
|
// Keyed by question text, valued by chosen option label(s), including free-text "Other".
|
|
204
204
|
z.object({
|
|
@@ -14,6 +14,9 @@ import { ArtifactNameSchema } from "./device-artifacts.js";
|
|
|
14
14
|
|
|
15
15
|
export const RUN_TARGETS_FILE = `${STATE_DIR}/run.json`;
|
|
16
16
|
|
|
17
|
+
// The longest a target may ask a stop to wait before forcing it (the machine's app_start takes the same bound).
|
|
18
|
+
export const MAX_STOP_GRACE_SECONDS = 600;
|
|
19
|
+
|
|
17
20
|
// The files under the workspace root's `.intentic/` that are the project's rather than the sandbox's, which no store of
|
|
18
21
|
// the daemon's owns: a project kept at the workspace root declares its targets there, as any repository does in its own.
|
|
19
22
|
// The root repo tracks them (VERSIONED_STATE_PATHS in state/workspace-state.ts), so an agent's edit lands like code.
|
|
@@ -58,6 +61,11 @@ export const RunTargetSchema = z
|
|
|
58
61
|
// The device's own loopback ports the sandbox needs to reach while it runs (its local API, a dev server), each
|
|
59
62
|
// opened at the same port in the sandbox.
|
|
60
63
|
reach: z.array(z.int().min(1).max(65535)).max(16).default([]),
|
|
64
|
+
// On a computer: how long a stop waits, once the program was asked to close (WM_CLOSE to its window, a
|
|
65
|
+
// Ctrl-Break to a console program, SIGTERM elsewhere), before forcing it. Absent is the computer's own five
|
|
66
|
+
// seconds; a program that saves on exit on a machine short of memory (a game server writing its world) can
|
|
67
|
+
// need far more.
|
|
68
|
+
stopGraceSeconds: z.int().min(1).max(MAX_STOP_GRACE_SECONDS).optional(),
|
|
61
69
|
})
|
|
62
70
|
.strict()
|
|
63
71
|
.refine(
|
|
@@ -118,6 +126,22 @@ export const RunStartedSchema = z.object({ session: z.string() });
|
|
|
118
126
|
export const DeviceRunStateSchema = z.enum(["running", "ended", "unknown"]);
|
|
119
127
|
export type DeviceRunState = z.infer<typeof DeviceRunStateSchema>;
|
|
120
128
|
|
|
129
|
+
// WHAT A RUN WAS BUILT FROM: the repository's commit and how much of its tree was uncommitted when `devices run` began
|
|
130
|
+
// its build (in the owner's tree that is mostly landed work, since a land leaves its changes uncommitted), and whether
|
|
131
|
+
// the tree moved while it compiled. With `landsSince` on the run, the Run dialog says whether the program on the
|
|
132
|
+
// computer is the newest work or a restart would bring more.
|
|
133
|
+
export const RunBuiltFromSchema = z.object({
|
|
134
|
+
// The full sha of HEAD when the build began.
|
|
135
|
+
commit: z.string().min(1).max(64),
|
|
136
|
+
// Paths with uncommitted changes then (`git status`): 0 is a clean tree.
|
|
137
|
+
changed: z.int().nonnegative(),
|
|
138
|
+
// When the build began.
|
|
139
|
+
at: z.string(),
|
|
140
|
+
// The tree changed while it compiled (a land that was already writing, the owner's own edits): it may mix versions.
|
|
141
|
+
movedDuringBuild: z.boolean().optional(),
|
|
142
|
+
});
|
|
143
|
+
export type RunBuiltFrom = z.infer<typeof RunBuiltFromSchema>;
|
|
144
|
+
|
|
121
145
|
export const DeviceRunSchema = z.object({
|
|
122
146
|
device: z.string(),
|
|
123
147
|
// The run id the computer's app_status, app_logs and app_stop take.
|
|
@@ -125,7 +149,7 @@ export const DeviceRunSchema = z.object({
|
|
|
125
149
|
name: z.string(),
|
|
126
150
|
// `unknown`: its process is alive but the computer cannot tell whether it is still this run, so it will not stop it.
|
|
127
151
|
state: DeviceRunStateSchema,
|
|
128
|
-
// The computer's own words for it: "running, pid 4120", "exited with code 101", "stopped by the
|
|
152
|
+
// The computer's own words for it: "running, pid 4120", "exited with code 101", "stopped by the Run dialog's Stop".
|
|
129
153
|
said: z.string(),
|
|
130
154
|
// How it ended, when it exited by itself with a code.
|
|
131
155
|
exitCode: z.int().optional(),
|
|
@@ -135,6 +159,12 @@ export const DeviceRunSchema = z.object({
|
|
|
135
159
|
repo: z.string().optional(),
|
|
136
160
|
// The computer's ports the sandbox reaches for it (the target's `reach`), open while it runs, closed when it stops.
|
|
137
161
|
ports: z.array(z.int().min(1).max(65535)),
|
|
162
|
+
// Who started it, when this sandbox did since its last restart: "the Run dialog", "conversation <id>", "a terminal".
|
|
163
|
+
startedBy: z.string().optional(),
|
|
164
|
+
// What its build was made from, when `devices run` built it (RunBuiltFromSchema).
|
|
165
|
+
builtFrom: RunBuiltFromSchema.optional(),
|
|
166
|
+
// Lands into its repository since its build began, as far as this sandbox has seen since it came up.
|
|
167
|
+
landsSince: z.int().nonnegative().optional(),
|
|
138
168
|
});
|
|
139
169
|
export type DeviceRun = z.infer<typeof DeviceRunSchema>;
|
|
140
170
|
|
package/src/schemas/settings.ts
CHANGED
|
@@ -239,6 +239,35 @@ export const MemberAudienceSchema = z.object({
|
|
|
239
239
|
});
|
|
240
240
|
export type MemberAudience = z.infer<typeof MemberAudienceSchema>;
|
|
241
241
|
|
|
242
|
+
/* THE HOST GPU, FOR A SANDBOX WHOSE GPU SWITCH IS ON (2026-11-03). On a Windows PC that GPU is the owner's display GPU,
|
|
243
|
+
shared through WSL (/dev/dxg). Until 2026-11-03 the engine put its driver libraries on every process's library path,
|
|
244
|
+
so 65 conversations' browsers and shells rendered on it unasked, and one GPU hang powered rog off. Now nothing uses it
|
|
245
|
+
unless asked: `gpu-run <command>` runs one command with it (bin/gpu-run), and `shells: "all"` gives it to every
|
|
246
|
+
command an agent runs. Read by the daemon (gpu/gpu-state.ts), which hands gpu-run what it needs in a state file. */
|
|
247
|
+
export const GpuShellsSchema = z.enum(["on-request", "all"]);
|
|
248
|
+
export const GpuSettingsSchema = z.object({
|
|
249
|
+
shells: GpuShellsSchema.default("on-request").describe(
|
|
250
|
+
"Which of an agent's commands may use this sandbox's GPU. `on-request` (the default): only a command run through `gpu-run`, so a browser, a test run or a build never lands on your display GPU by accident. `all`: every command an agent runs, as if each one went through gpu-run.",
|
|
251
|
+
),
|
|
252
|
+
timeoutMinutes: z
|
|
253
|
+
.number()
|
|
254
|
+
.int()
|
|
255
|
+
.min(0)
|
|
256
|
+
.max(24 * 60)
|
|
257
|
+
.default(0)
|
|
258
|
+
.describe("How long one gpu-run command may run before it is stopped, in minutes. Zero (the default) never stops it; `gpu-run --timeout` sets it for one command."),
|
|
259
|
+
// Written by the daemon when the computer this sandbox runs on reported a GPU reset (hosts/host-crashes.ts); cleared
|
|
260
|
+
// by the owner, which is the "resume" press. A sentence, so whoever reads the file sees why.
|
|
261
|
+
pausedFor: z
|
|
262
|
+
.string()
|
|
263
|
+
.max(400)
|
|
264
|
+
.optional()
|
|
265
|
+
.describe(
|
|
266
|
+
"Set by the sandbox when the computer it runs on reported that its GPU was reset or hung, naming the event: while it is set, gpu-run refuses, and every command runs without the GPU. Clear it once you have looked, to let agents use the GPU again.",
|
|
267
|
+
),
|
|
268
|
+
});
|
|
269
|
+
export type GpuSettings = z.infer<typeof GpuSettingsSchema>;
|
|
270
|
+
|
|
242
271
|
export const SandboxSettingsSchema = z.object({
|
|
243
272
|
// The zone every WALL-CLOCK RULE in this sandbox is meant in — an automation's cron, and anything else that says
|
|
244
273
|
// "at 09:00" instead of naming an instant. It is not a display preference: nothing formats through it, and an
|
|
@@ -557,6 +586,9 @@ export const SandboxSettingsSchema = z.object({
|
|
|
557
586
|
),
|
|
558
587
|
// Speaking replies aloud (schemas/voice.ts): which voice speaks each language, and whether a hands-free turn is
|
|
559
588
|
// answered out loud. Read by the daemon's voice engine on every utterance, so a change is heard on the next one.
|
|
589
|
+
gpu: GpuSettingsSchema.prefault({}).describe(
|
|
590
|
+
"This sandbox's use of the host GPU, where its GPU switch is on: whether agents' commands get it only through gpu-run or all of them do, how long one gpu-run command may run, and whether GPU work is paused after the host reported a GPU reset.",
|
|
591
|
+
),
|
|
560
592
|
voice: VoiceSettingsSchema.prefault({}).describe(
|
|
561
593
|
"How the agent's replies are spoken aloud: whether a hands-free conversation is answered out loud, which voice speaks each language, and a speech provider of your own if you connected one.",
|
|
562
594
|
),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// A repository a conversation cloned (or `git init`ed) inside its own copy of the workspace and left work in: it never
|
|
4
|
+
// rides that conversation's land, so the review lists it with what folding it into its parent, or keeping it as a
|
|
5
|
+
// workspace repository of its own, would carry.
|
|
6
|
+
export const StrandedCloneSchema = z.object({
|
|
7
|
+
dir: z.string().describe("The clone, as a folder relative to its own copy of the workspace."),
|
|
8
|
+
uncommitted: z.number().describe("Files changed in it and never committed."),
|
|
9
|
+
unpushed: z.number().describe("Commits in it its upstream does not have, or that no remote has when it follows none."),
|
|
10
|
+
commits: z
|
|
11
|
+
.number()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Commits it holds at all, 0 for a repository `git init` made and nothing was committed in: what folding it would drop. Absent from a sandbox too old to count them."),
|
|
14
|
+
parent: z.string().optional().describe("The workspace repository it sits inside, `root` for the workspace's own: where folding puts its files."),
|
|
15
|
+
});
|
package/src/state/fix-stance.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { turnedAwayCode } from "../policy/
|
|
1
|
+
import { turnedAwayCode } from "../policy/failure-codes.js";
|
|
2
2
|
import { type AgentSummary, awaitsWake } from "../schemas/agents.js";
|
|
3
3
|
|
|
4
4
|
/* WHAT BECAME OF THE AGENT A SURFACE SENT AFTER A FAILURE — a failed pipeline row, a refused push. */
|
|
@@ -70,6 +70,10 @@ const RUNTIME_DOMAINS = [
|
|
|
70
70
|
// machine: what every page needs to hear before the sandbox goes quiet under it, wherever the reader is.
|
|
71
71
|
{ domain: "update", invalidates: [["update"]] },
|
|
72
72
|
|
|
73
|
+
// The disk watch's level moved or it removed build output to make room (system/resources/storage/disk-pressure.ts):
|
|
74
|
+
// the attention row and the Storage card read it, and no file under /work changes when the history volume fills.
|
|
75
|
+
{ domain: "disk", invalidates: [["disk"]] },
|
|
76
|
+
|
|
73
77
|
// A standing yes written or taken back outside a need's answer: a permission card's pass, a release, a purge. They
|
|
74
78
|
// live under the auth root, which no file push watches, and the Allowed list must move with the card that wrote one.
|
|
75
79
|
{ domain: "grants", invalidates: [["grants"]] },
|
|
@@ -666,8 +666,9 @@ export const REPORTED_MANIFEST_PATHS: readonly string[] = WORKSPACE_STATE_FILES.
|
|
|
666
666
|
// Files on the daemon's own volume whose unreadable records are reported too, named by their absolute path there: the
|
|
667
667
|
// conversation registry's rows, one of which this build could not read costs that conversation until a build that can
|
|
668
668
|
// runs. Reported, never repaired from the card (no route edits them), and refreshed whenever the card is fetched. The
|
|
669
|
-
// boot record (2026-10-05) is reported when a restart storm kept a boot from resuming the turns it cut
|
|
670
|
-
|
|
669
|
+
// boot record (2026-10-05) is reported when a restart storm kept a boot from resuming the turns it cut, and the git dirs
|
|
670
|
+
// (2026-11-03) when a check after an unclean stop found objects nothing could rebuild (git/integrity/crash-check.ts).
|
|
671
|
+
export const REPORTED_VOLUME_FILES: readonly string[] = [`${HISTORY_ROOT}/conversations.db`, `${HISTORY_ROOT}/boot-history.json`, `${HISTORY_ROOT}/gits`];
|
|
671
672
|
|
|
672
673
|
// Accepts either separator; the daemon holds these as platform paths and normalizing at every call site is what
|
|
673
674
|
// eventually gets forgotten.
|
|
@@ -32,7 +32,7 @@ describe("foldTurn", () => {
|
|
|
32
32
|
];
|
|
33
33
|
expect(foldOf("look", events).slice(1)).toEqual([
|
|
34
34
|
{ role: "assistant", text: "I'll look" },
|
|
35
|
-
{ role: "assistant", text: "found it", tools: [{ id: "t1", name: "Read", category: "read", status: "
|
|
35
|
+
{ role: "assistant", text: "found it", tools: [{ id: "t1", name: "Read", category: "read", status: "interrupted" }] },
|
|
36
36
|
{ role: "assistant", text: "and here's why" },
|
|
37
37
|
]);
|
|
38
38
|
});
|
|
@@ -100,9 +100,9 @@ describe("foldTurn", () => {
|
|
|
100
100
|
expect(Object.keys(bash ?? {})).not.toContain("input");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it("
|
|
103
|
+
it("marks an unanswered call interrupted when the turn ends", () => {
|
|
104
104
|
const events: AgentEvent[] = [{ kind: "tool_call", id: "t1", name: "Bash", category: "execute", status: "in_progress" }];
|
|
105
|
-
expect(foldOf("run", events).at(-1)?.tools?.[0]?.status).toBe("
|
|
105
|
+
expect(foldOf("run", events).at(-1)?.tools?.[0]?.status).toBe("interrupted");
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it("nests a subagent's calls, thinking and live state under the card that spawned them", () => {
|
|
@@ -121,7 +121,7 @@ describe("foldTurn", () => {
|
|
|
121
121
|
id: "task-1",
|
|
122
122
|
name: "Agent",
|
|
123
123
|
category: "other",
|
|
124
|
-
status: "
|
|
124
|
+
status: "interrupted",
|
|
125
125
|
thinking: "hmm",
|
|
126
126
|
children: [{ id: "t2", name: "Read", category: "read", status: "completed" }],
|
|
127
127
|
subagent: { kind: "subagent", agentType: "Explore", background: true, status: "completed", toolUses: 1 },
|
|
@@ -294,7 +294,7 @@ describe("foldTurn", () => {
|
|
|
294
294
|
{ content: "step 2", status: "in_progress", activeForm: "Running step 2" },
|
|
295
295
|
{ content: "step 3", status: "pending" },
|
|
296
296
|
],
|
|
297
|
-
tools: [{ id: "t1", name: "Bash", category: "execute", status: "
|
|
297
|
+
tools: [{ id: "t1", name: "Bash", category: "execute", status: "interrupted" }],
|
|
298
298
|
},
|
|
299
299
|
]);
|
|
300
300
|
});
|
|
@@ -863,6 +863,7 @@ describe("patches", () => {
|
|
|
863
863
|
"replace",
|
|
864
864
|
"replace",
|
|
865
865
|
"replace",
|
|
866
|
+
"replace",
|
|
866
867
|
]);
|
|
867
868
|
});
|
|
868
869
|
|
|
@@ -892,9 +893,9 @@ describe("patches", () => {
|
|
|
892
893
|
{ op: "toolThinking", index: 1, id: "task-1", text: "in" },
|
|
893
894
|
{ op: "toolThinking", index: 1, id: "task-1", text: "ner" },
|
|
894
895
|
]);
|
|
895
|
-
const update = patches.
|
|
896
|
+
const update = patches.findLast((patch) => patch.op === "tool");
|
|
896
897
|
expect(update?.op === "tool" ? update.tool : undefined).toEqual({ id: "task-1", name: "Agent", category: "other", status: "completed" });
|
|
897
|
-
expect(applied[1]?.tools?.[0]).toMatchObject({ status: "completed", thinking: "inner", children: [{ id: "t2" }] });
|
|
898
|
+
expect(applied[1]?.tools?.[0]).toMatchObject({ status: "completed", thinking: "inner", children: [{ id: "t2", status: "interrupted" }] });
|
|
898
899
|
});
|
|
899
900
|
|
|
900
901
|
// The other half of the wake's delivery: a live turn takes it as a steer. It is the daemon's own words either way,
|
|
@@ -1453,3 +1454,16 @@ describe("transcriptIncidents", () => {
|
|
|
1453
1454
|
expect(sandboxNoticeOf(accountMovedRow({ why: "cold", from: "Work", to: "Home" }))).toEqual({ code: "accountMoved", params: { why: "cold", from: "Work", to: "Home" } });
|
|
1454
1455
|
});
|
|
1455
1456
|
});
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
test.each(["settled", "stopped"] as const)("%s interrupts open top-level and nested calls and leaves completed calls intact", (ending) => {
|
|
1460
|
+
const fold = new TranscriptFold([], () => 123);
|
|
1461
|
+
fold.apply({ kind: "tool_call", id: "parent", name: "Agent", category: "execute", status: "in_progress" });
|
|
1462
|
+
fold.apply({ kind: "tool_call", id: "nested", name: "Bash", category: "execute", status: "pending", parentToolUseId: "parent" });
|
|
1463
|
+
fold.apply({ kind: "tool_call", id: "done", name: "Read", category: "read", status: "completed" });
|
|
1464
|
+
fold.finish(ending);
|
|
1465
|
+
expect(fold.rows[0]?.tools).toMatchObject([
|
|
1466
|
+
{ id: "parent", status: "interrupted", endedAt: 123, children: [{ id: "nested", status: "interrupted", endedAt: 123 }] },
|
|
1467
|
+
{ id: "done", status: "completed" },
|
|
1468
|
+
]);
|
|
1469
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { interruptAssistant } from "./transcript-interruption.js";
|
|
2
|
+
import { settledRequests } from "../policy/request-status.js";
|
|
2
3
|
import type { AgentEvent } from "../events/agent-events.js";
|
|
3
4
|
import { drawInline, type InlineEvent, supersedeEarlier } from "./transcript-inline.js";
|
|
4
5
|
import {
|
|
5
6
|
REQUEST_FIELDS,
|
|
6
7
|
holdsRequest,
|
|
7
|
-
isAwaitingDecision,
|
|
8
8
|
type TranscriptRequests,
|
|
9
9
|
type TranscriptPatch,
|
|
10
10
|
type TranscriptRow,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { keptWarmLine, keptWarmNotice } from "../schemas/keep-warm.js";
|
|
15
15
|
import { isStartingFrame, startingRow } from "./notice-rows.js";
|
|
16
16
|
import { isLandConflict } from "../events/land-conflict.js";
|
|
17
|
-
import { turnedAwayCode } from "../policy/
|
|
17
|
+
import { turnedAwayCode } from "../policy/failure-codes.js";
|
|
18
18
|
import { errorRow, RENEWAL_WITHDRAWN, RENEWING } from "../events/failure-rows.js";
|
|
19
19
|
import { mentionedPathTokens } from "./mentions.js";
|
|
20
20
|
import { unspokenPromptRow } from "../events/agent-words.js";
|
|
@@ -60,7 +60,7 @@ const resultWords = (tool: TranscriptTool): string =>
|
|
|
60
60
|
.join("\n");
|
|
61
61
|
|
|
62
62
|
// Whether a call's status is final: the moment it turns so is when its result arrived.
|
|
63
|
-
const ended = (status: TranscriptTool["status"]): boolean => status === "completed" || status === "failed";
|
|
63
|
+
const ended = (status: TranscriptTool["status"]): boolean => status === "completed" || status === "failed" || status === "interrupted";
|
|
64
64
|
|
|
65
65
|
// `at` is the fold's clock reading as the call is seen, absent for a fold without one; a call that arrives already
|
|
66
66
|
// finished started and ended in that same moment, as far as anyone here can tell.
|
|
@@ -493,8 +493,7 @@ export class TranscriptFold {
|
|
|
493
493
|
finish(ending: TurnEnding): TranscriptPatch[] {
|
|
494
494
|
const patches = this.closeBubble();
|
|
495
495
|
for (const [index, row] of this.rows.entries()) {
|
|
496
|
-
if (row.
|
|
497
|
-
Object.assign(row, cancelledRequests(row));
|
|
496
|
+
if (interruptAssistant(row, this.now?.())) {
|
|
498
497
|
patches.push(this.replace(index));
|
|
499
498
|
}
|
|
500
499
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cancelledRequests } from "../policy/request-status.js";
|
|
2
|
+
import { isAwaitingDecision, type TranscriptRow, type TranscriptTool } from "../events/transcript.js";
|
|
3
|
+
|
|
4
|
+
// A turn cannot leave a call running, including a helper's nested calls.
|
|
5
|
+
export const interruptTools = (tools: readonly TranscriptTool[], at: number | undefined): boolean => {
|
|
6
|
+
let changed = false;
|
|
7
|
+
for (const tool of tools) {
|
|
8
|
+
if (tool.status === "pending" || tool.status === "in_progress") {
|
|
9
|
+
tool.status = "interrupted";
|
|
10
|
+
if (at !== undefined) {
|
|
11
|
+
tool.endedAt = at;
|
|
12
|
+
}
|
|
13
|
+
changed = true;
|
|
14
|
+
}
|
|
15
|
+
changed = interruptTools(tool.children ?? [], at) || changed;
|
|
16
|
+
}
|
|
17
|
+
return changed;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Freeze decisions whose waiter ended, and calls whose result will no longer arrive. */
|
|
21
|
+
export const interruptAssistant = (row: TranscriptRow, at: number | undefined): boolean => {
|
|
22
|
+
if (row.role !== "assistant") {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const awaiting = isAwaitingDecision(row);
|
|
26
|
+
if (awaiting) {
|
|
27
|
+
Object.assign(row, cancelledRequests(row));
|
|
28
|
+
}
|
|
29
|
+
return interruptTools(row.tools ?? [], at) || awaiting;
|
|
30
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"turned-away.d.ts","sourceRoot":"","sources":["../../src/policy/turned-away.ts"],"names":[],"mappings":"AAgDA,eAAO,MAAM,kBAAkB,SAAU,MAAM,GAAG,SAAS,KAAG,OAA+D,CAAC;AAG9H,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,SAAS,KAAG,OAAsD,CAAC"}
|