@intentic/sandbox-contract 1.403.0 → 1.404.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/dist/contracts/agent.contract.d.ts +8 -0
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +40 -0
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +246 -246
- package/dist/contracts/seal.contract.d.ts +10 -0
- package/dist/contracts/seal.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +30 -18
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/translator.contract.d.ts +16 -0
- package/dist/contracts/translator.contract.d.ts.map +1 -1
- package/dist/events/system-events.d.ts +8 -0
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/models/plan-pools.d.ts +5 -34
- package/dist/models/plan-pools.d.ts.map +1 -1
- package/dist/models/plan-pools.js +4 -95
- package/dist/models/plan-pools.js.map +1 -1
- package/dist/models/verdict/pool-gates.d.ts +17 -0
- package/dist/models/verdict/pool-gates.d.ts.map +1 -0
- package/dist/models/verdict/pool-gates.js +41 -0
- package/dist/models/verdict/pool-gates.js.map +1 -0
- package/dist/models/verdict/refusal-verdict.d.ts +21 -0
- package/dist/models/verdict/refusal-verdict.d.ts.map +1 -0
- package/dist/models/verdict/refusal-verdict.js +68 -0
- package/dist/models/verdict/refusal-verdict.js.map +1 -0
- package/dist/protocol/raw/raw-json-routes.d.ts +196 -0
- package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-json-routes.js +5 -0
- package/dist/protocol/raw/raw-json-routes.js.map +1 -1
- package/dist/protocol/raw/raw-routes.d.ts +31 -0
- package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-routes.js +7 -0
- package/dist/protocol/raw/raw-routes.js.map +1 -1
- package/dist/schemas/agent-next.d.ts +1 -0
- package/dist/schemas/agent-next.d.ts.map +1 -1
- package/dist/schemas/agent-next.js +4 -0
- package/dist/schemas/agent-next.js.map +1 -1
- package/dist/schemas/agent.d.ts +126 -0
- package/dist/schemas/agent.d.ts.map +1 -1
- package/dist/schemas/agent.js +15 -4
- package/dist/schemas/agent.js.map +1 -1
- package/dist/schemas/agents-list.d.ts +4 -0
- package/dist/schemas/agents-list.d.ts.map +1 -1
- package/dist/schemas/agents.d.ts +6 -0
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/diagnostics.d.ts +248 -0
- package/dist/schemas/diagnostics.d.ts.map +1 -0
- package/dist/schemas/diagnostics.js +114 -0
- package/dist/schemas/diagnostics.js.map +1 -0
- package/dist/schemas/hosts.d.ts +1 -0
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +2 -1
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/links.d.ts +6 -0
- package/dist/schemas/links.d.ts.map +1 -1
- package/dist/schemas/links.js +6 -0
- package/dist/schemas/links.js.map +1 -1
- package/dist/schemas/providers/plan-limits.d.ts +22 -1
- package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
- package/dist/schemas/providers/plan-limits.js +10 -1
- package/dist/schemas/providers/plan-limits.js.map +1 -1
- package/dist/schemas/providers/refusals.d.ts +5 -0
- package/dist/schemas/providers/refusals.d.ts.map +1 -1
- package/dist/schemas/providers/refusals.js +4 -0
- package/dist/schemas/providers/refusals.js.map +1 -1
- package/package.json +5 -5
- package/src/models/plan-pools.test.ts +96 -5
- package/src/models/plan-pools.ts +22 -212
- package/src/models/verdict/pool-gates.ts +94 -0
- package/src/models/verdict/refusal-verdict.ts +148 -0
- package/src/protocol/raw/raw-json-routes.ts +7 -0
- package/src/protocol/raw/raw-routes.ts +17 -0
- package/src/schemas/agent-next.ts +6 -0
- package/src/schemas/agent.ts +50 -29
- package/src/schemas/diagnostics.ts +166 -0
- package/src/schemas/hosts.ts +8 -2
- package/src/schemas/links.ts +9 -0
- package/src/schemas/providers/plan-limits.ts +16 -1
- package/src/schemas/providers/refusals.ts +12 -3
package/src/schemas/agent.ts
CHANGED
|
@@ -283,6 +283,16 @@ const AgentTurnFieldsSchema = z.object({
|
|
|
283
283
|
sendAfter: ConversationIdSchema.optional().describe(
|
|
284
284
|
"Hold this message until the conversation named here has finished and all of its work has landed in the workspace, instead of starting a turn now: for work that builds on another agent's. It waits in this conversation's queue, where it can be sent early, reworded, rescheduled or removed. Sent at once when that conversation has nothing running and nothing left to land.",
|
|
285
285
|
),
|
|
286
|
+
// What `sendAfter` waits for, when it is not the land: the named conversation's turn ending clean, with its work still
|
|
287
|
+
// on its own branch. What a code review or a test pass booked on a session still at work waits by (a fresh session's
|
|
288
|
+
// opening message, `freshOf`), so it starts the moment the work holds still rather than after somebody lands it. A
|
|
289
|
+
// modifier, as `sendAtReopen` is of `sendAt`: a daemon from before it reads the land, which only waits longer.
|
|
290
|
+
sendAfterTurn: z
|
|
291
|
+
.literal(true)
|
|
292
|
+
.optional()
|
|
293
|
+
.describe(
|
|
294
|
+
"Says `sendAfter` waits for that conversation's turn to end, not for its work to land: the message goes once that conversation has finished a turn cleanly (nothing running, not stopped on a question, a permission or a failure, no checklist left open, nothing waiting to wake it) with work of its own to look at, whether or not that work has landed. Sent at once when it already rests so. Only with `sendAfter`.",
|
|
295
|
+
),
|
|
286
296
|
// Decided like `isolated`: the opening turn's answer, latched on the entry it opens. A maintainer's alone, since the
|
|
287
297
|
// standing answer it sets is what `agents.autoLand` sets, and that route is a maintainer's.
|
|
288
298
|
conversationAutoLand: z
|
|
@@ -292,35 +302,40 @@ const AgentTurnFieldsSchema = z.object({
|
|
|
292
302
|
"Whether this conversation's finished work merges into the workspace by itself from now on: its own answer to the sandbox-wide setting, the one `agents.autoLand` changes later. Read only from the message that opens the conversation, and only from a maintainer. Unlike `autoLand`, it holds for every later turn.",
|
|
293
303
|
),
|
|
294
304
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
305
|
+
// A turn says something: words, or files alone. A Continue a queue keeps says nothing by design (WordlessTurnSchema).
|
|
306
|
+
export const turnHasWords = (turn: { readonly prompt: string; readonly attachments?: readonly unknown[] | undefined }): boolean =>
|
|
307
|
+
turn.prompt.trim().length > 0 || (turn.attachments?.length ?? 0) > 0;
|
|
308
|
+
const withTurnRules = (fields: typeof AgentTurnFieldsSchema) =>
|
|
309
|
+
fields
|
|
310
|
+
.refine((turn) => turn.isolated !== true || turn.conversationId !== undefined, {
|
|
311
|
+
message: "isolated requires conversationId",
|
|
312
|
+
})
|
|
313
|
+
.refine((turn) => turn.worktreeBase === undefined || (turn.isolated === true && turn.conversationId !== undefined), {
|
|
314
|
+
message: "worktreeBase requires an isolated conversationId",
|
|
315
|
+
})
|
|
316
|
+
.refine((turn) => turn.origin === undefined || turn.conversationId !== undefined, {
|
|
317
|
+
message: "origin requires conversationId",
|
|
318
|
+
})
|
|
319
|
+
.refine((turn) => turn.forkOf === undefined || turn.conversationId !== undefined, {
|
|
320
|
+
message: "forkOf requires conversationId",
|
|
321
|
+
})
|
|
322
|
+
// "then" needs a checkout of its own; rolling back the shared tree under everyone else is what it must never mean.
|
|
323
|
+
.refine((turn) => turn.forkOf?.files !== "then" || turn.isolated === true, {
|
|
324
|
+
message: 'forkOf.files "then" requires isolated',
|
|
325
|
+
})
|
|
326
|
+
.superRefine(freshOfIssues)
|
|
327
|
+
.superRefine(fromBranchIssues)
|
|
328
|
+
.refine((turn) => turn.sendAt === undefined || turn.sendAfter === undefined, {
|
|
329
|
+
message: "sendAt and sendAfter are two different holds: name one",
|
|
330
|
+
})
|
|
331
|
+
.refine((turn) => turn.sendAfter === undefined || turn.sendAfter !== turn.conversationId, {
|
|
332
|
+
message: "a conversation cannot wait for its own work to land",
|
|
333
|
+
})
|
|
334
|
+
.refine((turn) => turn.sendAfterTurn === undefined || turn.sendAfter !== undefined, {
|
|
335
|
+
message: "sendAfterTurn says what sendAfter waits for: name the conversation in sendAfter",
|
|
336
|
+
});
|
|
337
|
+
export const AgentTurnSchema = withTurnRules(AgentTurnFieldsSchema.refine(turnHasWords, { message: "prompt or attachments required" }));
|
|
338
|
+
export const WordlessTurnSchema = withTurnRules(AgentTurnFieldsSchema);
|
|
324
339
|
export type AgentTurn = z.infer<typeof AgentTurnSchema>;
|
|
325
340
|
// What `agent.run` takes: a turn, plus the one field only a request carries and no stored turn keeps. A daemon from before
|
|
326
341
|
// `continues` reads past it and takes `prompt` as the words, which is why a client still sends some.
|
|
@@ -518,6 +533,12 @@ export const QueuedMessageSchema = z.object({
|
|
|
518
533
|
after: ConversationIdSchema.optional().describe(
|
|
519
534
|
"The conversation whose finished work must land before this message goes out by itself, in place of `until`.",
|
|
520
535
|
),
|
|
536
|
+
afterTurn: z
|
|
537
|
+
.literal(true)
|
|
538
|
+
.optional()
|
|
539
|
+
.describe(
|
|
540
|
+
"Says `after` waits for that conversation's turn to end cleanly with work to look at, not for its work to land (`sendAfterTurn`). Absent on a land booking, and from sandboxes older than the field.",
|
|
541
|
+
),
|
|
521
542
|
reopenOf: QueuedReopenSchema.optional().describe(
|
|
522
543
|
"The allowance this message's `until` waits out: it was booked for that account's reopen, by the composer or by the sandbox holding words it would not send into a spent allowance, rather than for a time somebody chose. Absent on any other booking, and from sandboxes older than the field.",
|
|
523
544
|
),
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// THE DIAGNOSTICS QUERIES: read-only questions over what a sandbox's daemon already recorded (its log, the editor's
|
|
4
|
+
// reports, slow spans and rollups, the turn ledger, the resource series, its boots, one conversation's timeline). One
|
|
5
|
+
// set of arguments serves every door that asks them: the `diagnostics` tools a turn mounts, the `diagnostics` command on
|
|
6
|
+
// the agent's PATH (POST /diagnostics), and a linked sandbox reading this one's records (POST /link/records/diagnostics).
|
|
7
|
+
// Each answers with text written to be read, never the raw lines, and each takes a window.
|
|
8
|
+
|
|
9
|
+
// Two weeks and a day: the perf rollups keep two weeks; every other record reaches less far, and says so.
|
|
10
|
+
export const DIAGNOSTICS_MAX_MINUTES = 15 * 24 * 60;
|
|
11
|
+
// Bounds one answer's rows; a caller that hits the cap is told and narrows.
|
|
12
|
+
export const DIAGNOSTICS_MAX_LINES = 200;
|
|
13
|
+
|
|
14
|
+
const levels = ["trace", "debug", "info", "warn", "error", "fatal"] as const;
|
|
15
|
+
export const DiagnosticsLevelSchema = z.enum(levels);
|
|
16
|
+
|
|
17
|
+
const minutes = () => z.number().int().min(1).max(DIAGNOSTICS_MAX_MINUTES).optional();
|
|
18
|
+
const limit = () => z.number().int().min(1).max(DIAGNOSTICS_MAX_LINES).optional();
|
|
19
|
+
const instant = () => z.iso.datetime({ offset: true });
|
|
20
|
+
|
|
21
|
+
/** `errors`: the daemon's log or the editor's reports, newest first. */
|
|
22
|
+
export const DiagnosticsErrorsArgs = {
|
|
23
|
+
source: z
|
|
24
|
+
.enum(["daemon", "browser"])
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Whose account of it: the sandbox's own log, or what the editor sent about itself. Defaults to the daemon."),
|
|
27
|
+
sinceMinutes: minutes().describe("How far back to look. Leave it out for everything the file still holds."),
|
|
28
|
+
from: instant()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Start of an absolute window (ISO time, e.g. `2026-11-07T23:40:00Z`), instead of `sinceMinutes`: for reading around a moment you already know."),
|
|
31
|
+
until: instant()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("End of the window (ISO time): lines after it are left out. With `from`, reads exactly the lines between the two."),
|
|
34
|
+
level: DiagnosticsLevelSchema.optional().describe("Lowest level to include, and it includes worse ones. Defaults to `warn`, which is what went wrong."),
|
|
35
|
+
contains: z
|
|
36
|
+
.string()
|
|
37
|
+
.max(200)
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Case-insensitive substring, matched anywhere in the line: a conversation id, an error code, a route, a message."),
|
|
40
|
+
group: z
|
|
41
|
+
.boolean()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("true: one row per kind of message, with its count and first and last time. false: every line. Left out, lines are grouped once there are more than `limit`."),
|
|
44
|
+
stacks: z.boolean().optional().describe("Include each exception's stack. Off by default: stacks dwarf the line they belong to."),
|
|
45
|
+
limit: limit(),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** `slow`: operations over their budget, or every span's rollups. */
|
|
49
|
+
export const DiagnosticsSlowArgs = {
|
|
50
|
+
source: z
|
|
51
|
+
.enum(["slow", "rollups"])
|
|
52
|
+
.optional()
|
|
53
|
+
.describe(
|
|
54
|
+
"`slow` (the default): the spans over budget, one by one, from perf.jsonl (about a week). `rollups`: the distribution of every span from perf-rollups.jsonl (two weeks), with no single span or load to show.",
|
|
55
|
+
),
|
|
56
|
+
sinceMinutes: minutes(),
|
|
57
|
+
op: z
|
|
58
|
+
.string()
|
|
59
|
+
.max(100)
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("One operation by its exact name (`git.run` is not `git.run.wait`), or every one under a prefix ending in `.` or `*` (`git.`, `devices.*`)."),
|
|
62
|
+
groupBy: z
|
|
63
|
+
.enum(["op", "op+path", "none"])
|
|
64
|
+
.optional()
|
|
65
|
+
.describe(
|
|
66
|
+
"`op` one row per operation; `op+path` splits each by its subject (the route of a request, the git subcommand, the hook's tool); `none` every span. Left out, spans are grouped by op once there are more than `limit`. Rollups have no single spans, so `none` reads as `op+path` there.",
|
|
67
|
+
),
|
|
68
|
+
limit: limit(),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** `turns`: how recent agent turns ended, from the spend ledger. */
|
|
72
|
+
export const DiagnosticsTurnsArgs = {
|
|
73
|
+
sinceMinutes: minutes(),
|
|
74
|
+
conversationId: z.string().max(200).optional().describe("Narrow to one conversation."),
|
|
75
|
+
only: z
|
|
76
|
+
.enum(["failed", "unproven", "silent", "interrupted"])
|
|
77
|
+
.optional()
|
|
78
|
+
.describe(
|
|
79
|
+
'Narrow to one kind of ending: "failed" is turns that failed or were cancelled, "unproven" is turns that ' +
|
|
80
|
+
"changed code and finished with nothing having checked it (including ones whose last check broke), " +
|
|
81
|
+
'"silent" is turns that ran but called no tool and changed no file, "interrupted" is turns a restart or ' +
|
|
82
|
+
"a spent allowance cut off. Leave it out for every turn.",
|
|
83
|
+
),
|
|
84
|
+
limit: limit(),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** `resources`: one field of the resource series over time. */
|
|
88
|
+
export const DiagnosticsResourcesArgs = {
|
|
89
|
+
field: z.string().min(1).max(200).describe("Dotted path into one sample, e.g. `system.cgroup.event_oom_kill`."),
|
|
90
|
+
sinceMinutes: minutes(),
|
|
91
|
+
limit: limit(),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** `restarts`: the daemon's boots and why each run before ended. */
|
|
95
|
+
export const DiagnosticsRestartsArgs = { sinceMinutes: minutes(), limit: limit() };
|
|
96
|
+
|
|
97
|
+
/** `timeline`: everything recorded about one conversation, oldest first. */
|
|
98
|
+
export const DiagnosticsTimelineArgs = {
|
|
99
|
+
conversationId: z.string().min(1).max(200).describe("The conversation's id, e.g. `wise-fern-usz1`."),
|
|
100
|
+
sinceMinutes: minutes(),
|
|
101
|
+
level: DiagnosticsLevelSchema.optional().describe("Lowest daemon.log level to include. Defaults to `info`, so the turn's own lifecycle lines are in."),
|
|
102
|
+
limit: z.number().int().min(1).max(DIAGNOSTICS_MAX_LINES).optional().describe("The newest this many events. Defaults to 100."),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// One query, named by `query`, with that query's own arguments.
|
|
106
|
+
export const DiagnosticsQuerySchema = z.discriminatedUnion("query", [
|
|
107
|
+
z.object({ query: z.literal("errors"), ...DiagnosticsErrorsArgs }),
|
|
108
|
+
z.object({ query: z.literal("slow"), ...DiagnosticsSlowArgs }),
|
|
109
|
+
z.object({ query: z.literal("turns"), ...DiagnosticsTurnsArgs }),
|
|
110
|
+
z.object({ query: z.literal("resources"), ...DiagnosticsResourcesArgs }),
|
|
111
|
+
z.object({ query: z.literal("restarts"), ...DiagnosticsRestartsArgs }),
|
|
112
|
+
z.object({ query: z.literal("timeline"), ...DiagnosticsTimelineArgs }),
|
|
113
|
+
]);
|
|
114
|
+
export type DiagnosticsQuery = z.infer<typeof DiagnosticsQuerySchema>;
|
|
115
|
+
export type DiagnosticsQueryName = DiagnosticsQuery["query"];
|
|
116
|
+
export const DIAGNOSTICS_QUERY_NAMES = ["errors", "slow", "turns", "resources", "restarts", "timeline"] as const satisfies readonly DiagnosticsQueryName[];
|
|
117
|
+
|
|
118
|
+
// POST /diagnostics: one query of this sandbox's records, or, with `on`, of the linked sandbox that card names, read
|
|
119
|
+
// through the link (its owner must share records on it).
|
|
120
|
+
export const DiagnosticsAskSchema = z.intersection(
|
|
121
|
+
DiagnosticsQuerySchema,
|
|
122
|
+
z.object({
|
|
123
|
+
on: z
|
|
124
|
+
.string()
|
|
125
|
+
.min(1)
|
|
126
|
+
.max(100)
|
|
127
|
+
.optional()
|
|
128
|
+
.describe("A link card's id: ask the linked sandbox instead of this one. `agents links` names the links this turn may use."),
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
export type DiagnosticsAsk = z.infer<typeof DiagnosticsAskSchema>;
|
|
132
|
+
|
|
133
|
+
export const DiagnosticsAnswerSchema = z.object({
|
|
134
|
+
text: z.string().describe("The answer, as the diagnostics tools word it: what it searched, how far back the record reaches, then the rows."),
|
|
135
|
+
sandbox: z.string().optional().describe("Whose records these are, when they are a linked sandbox's."),
|
|
136
|
+
});
|
|
137
|
+
export type DiagnosticsAnswer = z.infer<typeof DiagnosticsAnswerSchema>;
|
|
138
|
+
|
|
139
|
+
/* A CONVERSATION'S DEBUG BUNDLE: one file holding what a person or an agent elsewhere needs to look into what happened
|
|
140
|
+
* to one conversation, without access to the sandbox it ran in. GET /fleet/{handle}/bundle (and the link's records door)
|
|
141
|
+
* answers it; `agents bundle` writes it, and the editor downloads it. Every part is what the sandbox already shows its
|
|
142
|
+
* own agents: secrets ride as their `{{secret:name}}` references, as they are stored. */
|
|
143
|
+
|
|
144
|
+
export const CONVERSATION_BUNDLE_KIND = "intentic.conversation-bundle";
|
|
145
|
+
|
|
146
|
+
export const ConversationBundleSchema = z.object({
|
|
147
|
+
kind: z.literal(CONVERSATION_BUNDLE_KIND),
|
|
148
|
+
version: z.literal(1),
|
|
149
|
+
exportedAt: z.string().describe("When it was put together, ISO time."),
|
|
150
|
+
sandbox: z.object({
|
|
151
|
+
name: z.string().describe("What the sandbox calls itself."),
|
|
152
|
+
version: z.string().optional().describe("The daemon's version: 0.0.0 is an unreleased build."),
|
|
153
|
+
}),
|
|
154
|
+
conversation: z.string().describe("The conversation's id."),
|
|
155
|
+
// What `agents show` answers, as JSON: what it was asked, where it got to, its branch, how it ended.
|
|
156
|
+
show: z.unknown(),
|
|
157
|
+
// The record as stored, newest last, bounded: `total` says how many rows it has.
|
|
158
|
+
transcript: z.unknown(),
|
|
159
|
+
// The diagnostics answers about it, each as the `diagnostics` command words it.
|
|
160
|
+
timeline: z.string(),
|
|
161
|
+
turns: z.string(),
|
|
162
|
+
errors: z.string(),
|
|
163
|
+
restarts: z.string(),
|
|
164
|
+
browser: z.string().describe("What the editor reported about itself while the conversation ran."),
|
|
165
|
+
});
|
|
166
|
+
export type ConversationBundle = z.infer<typeof ConversationBundleSchema>;
|
package/src/schemas/hosts.ts
CHANGED
|
@@ -211,8 +211,14 @@ export const deviceFeatures = (facts: Pick<DeviceFacts, "features"> | undefined)
|
|
|
211
211
|
});
|
|
212
212
|
export const deviceSupports = (facts: Pick<DeviceFacts, "features"> | undefined, feature: DeviceFeature): boolean => deviceFeatures(facts).includes(feature);
|
|
213
213
|
|
|
214
|
-
//
|
|
215
|
-
export const
|
|
214
|
+
// The distro `ic engine install` imports to run Intentic's own Docker engine (ic's engine::DISTRO).
|
|
215
|
+
export const WSL_ENGINE_DISTRO = "intentic-engine";
|
|
216
|
+
|
|
217
|
+
// Distros that are an engine's, not the user's: Docker Desktop's two and Intentic's own. `wsl -l -q` lists them like any
|
|
218
|
+
// other, and none ever runs an agent or holds a checkout. Leaving the engine's out of this set made a PC with one distro
|
|
219
|
+
// of its own read as having two, so its Windows side refused to cross into the one holding the dev checkout and
|
|
220
|
+
// "Rebuild from checkout" fell back to its copyable command whenever the distro's own door was slow (2026-11-07).
|
|
221
|
+
export const WSL_SYSTEM_DISTROS: ReadonlySet<string> = new Set(["docker-desktop", "docker-desktop-data", WSL_ENGINE_DISTRO]);
|
|
216
222
|
|
|
217
223
|
// The distros a Windows side lists that are the user's own: the only ones any screen offers, crosses into or boots.
|
|
218
224
|
export const userDistrosOf = (facts: Pick<DeviceFacts, "wslDistros"> | undefined): string[] =>
|
package/src/schemas/links.ts
CHANGED
|
@@ -36,6 +36,11 @@ const turnsPerHourTerm = z
|
|
|
36
36
|
const tasksTerm = z
|
|
37
37
|
.boolean()
|
|
38
38
|
.describe("Whether the link may hand this sandbox tasks at all. An accounts link is minted without: it only borrows and copies the accounts below.");
|
|
39
|
+
const recordsTerm = z
|
|
40
|
+
.boolean()
|
|
41
|
+
.describe(
|
|
42
|
+
"Whether the asking sandbox may read this sandbox's records without starting a turn: its conversations (every one but a private one) and their transcripts, its daemon's log and diagnostics. Read-only, and each read is logged here. For looking into a problem from the other sandbox; off unless its owner turns it on.",
|
|
43
|
+
);
|
|
39
44
|
const accountsTerm = z
|
|
40
45
|
.array(SharedAccountRefSchema)
|
|
41
46
|
.max(64)
|
|
@@ -58,6 +63,7 @@ export const LinkTermsSchema = z.object({
|
|
|
58
63
|
approve: approveTerm.default(false),
|
|
59
64
|
turnsPerHour: turnsPerHourTerm.default(LINK_TURNS_PER_HOUR_DEFAULT),
|
|
60
65
|
tasks: tasksTerm.default(true),
|
|
66
|
+
records: recordsTerm.default(false),
|
|
61
67
|
accounts: accountsTerm.default([]),
|
|
62
68
|
});
|
|
63
69
|
export type LinkTerms = z.infer<typeof LinkTermsSchema>;
|
|
@@ -117,6 +123,7 @@ export const InboundLinkTermsUpdateSchema = z.object({
|
|
|
117
123
|
approve: approveTerm.optional(),
|
|
118
124
|
turnsPerHour: turnsPerHourTerm.optional(),
|
|
119
125
|
tasks: tasksTerm.optional(),
|
|
126
|
+
records: recordsTerm.optional(),
|
|
120
127
|
accounts: accountsTerm.optional(),
|
|
121
128
|
});
|
|
122
129
|
export type InboundLinkTermsUpdate = z.infer<typeof InboundLinkTermsUpdateSchema>;
|
|
@@ -137,6 +144,8 @@ export const LinkHelloSchema = z.object({
|
|
|
137
144
|
// Absent from a sandbox older than accounts links, which takes tasks and lends nothing.
|
|
138
145
|
tasks: z.boolean().optional(),
|
|
139
146
|
accounts: z.number().int().nonnegative().optional().describe("How many accounts the link may use."),
|
|
147
|
+
// Absent from a sandbox older than records over links, which shares none.
|
|
148
|
+
records: z.boolean().optional().describe("Whether the link may read this sandbox's records (its conversations, logs and diagnostics)."),
|
|
140
149
|
}),
|
|
141
150
|
maxHops: z.number().int(),
|
|
142
151
|
});
|
|
@@ -5,6 +5,7 @@ import { AgentHarnessSchema, AgentProviderSchema, ConversationIdSchema, EditorCo
|
|
|
5
5
|
import { MENTION_LIMIT } from "../../text/mentions.js";
|
|
6
6
|
import { HandoffModeSchema } from "./handoff.js";
|
|
7
7
|
import { NightAnswerSchema } from "../night-hours.js";
|
|
8
|
+
import { ModelCooldownSchema } from "./refusals.js";
|
|
8
9
|
// Headroom is one shape shared by every provider, not a Claude idea others imitate: a native account and a routed
|
|
9
10
|
// subscription differ in who holds the credential, never in what a reading is. Every surface that draws a percentage
|
|
10
11
|
// reads this one type.
|
|
@@ -150,7 +151,7 @@ export const LimitResetClaimSchema = z.object({
|
|
|
150
151
|
detail: z.string().optional().describe("What went wrong, in words, for the two outcomes that are this sandbox's fault rather than the plan's."),
|
|
151
152
|
});
|
|
152
153
|
export type LimitResetClaim = z.infer<typeof LimitResetClaimSchema>;
|
|
153
|
-
export { type ProviderRefusal, ProviderRefusalSchema, type ProviderRefusals, ProviderRefusalsSchema } from "./refusals.js";
|
|
154
|
+
export { type ModelCooldown, ModelCooldownSchema, type ProviderRefusal, ProviderRefusalSchema, type ProviderRefusals, ProviderRefusalsSchema } from "./refusals.js";
|
|
154
155
|
// `name` is CLIProxyAPI's auth-file name, the stable key a disconnect addresses; `label` is the reported sign-in
|
|
155
156
|
// identity (email, else the file name).
|
|
156
157
|
export const TranslatorAccountSchema = z.object({
|
|
@@ -175,6 +176,11 @@ export const TranslatorAccountSchema = z.object({
|
|
|
175
176
|
verify: z.string().optional(),
|
|
176
177
|
})
|
|
177
178
|
.optional(),
|
|
179
|
+
// The proxy's per-model benches: the provider refused this account on one model, for its allowance, and said when
|
|
180
|
+
// to try again. Each is a spent allowance that names its account, its model and the provider's own instant, which the
|
|
181
|
+
// serviceability rule reads like a refusal filed for this account (refusal-verdict.ts cooldownRefusals). A bench on
|
|
182
|
+
// one model never benches the account's others: a Google account out of Claude still serves Gemini.
|
|
183
|
+
cooldowns: z.array(ModelCooldownSchema).optional(),
|
|
178
184
|
});
|
|
179
185
|
export type TranslatorAccount = z.infer<typeof TranslatorAccountSchema>;
|
|
180
186
|
// A list per provider, not a flag: CLIProxyAPI holds several auth files per provider and balances across them. Built
|
|
@@ -479,6 +485,12 @@ export const QueueScheduleSchema = z
|
|
|
479
485
|
.describe(
|
|
480
486
|
"Says `sendAt` is the reopen of the allowance what waits would be refused by, not a time you chose; the queue records it as `reopenOf`. Only with `sendAt`.",
|
|
481
487
|
),
|
|
488
|
+
sendAfterTurn: z
|
|
489
|
+
.literal(true)
|
|
490
|
+
.optional()
|
|
491
|
+
.describe(
|
|
492
|
+
"Says `sendAfter` waits for that conversation's turn to end cleanly with work to look at, not for its work to land (AgentTurn `sendAfterTurn`). Only with `sendAfter`.",
|
|
493
|
+
),
|
|
482
494
|
ids: z
|
|
483
495
|
.array(z.string().min(1))
|
|
484
496
|
.optional()
|
|
@@ -489,6 +501,9 @@ export const QueueScheduleSchema = z
|
|
|
489
501
|
})
|
|
490
502
|
.refine((input) => input.sendAfter !== input.conversationId, {
|
|
491
503
|
message: "a conversation cannot wait for its own work to land",
|
|
504
|
+
})
|
|
505
|
+
.refine((input) => input.sendAfterTurn === undefined || input.sendAfter !== undefined, {
|
|
506
|
+
message: "sendAfterTurn says what sendAfter waits for: name the conversation in sendAfter",
|
|
492
507
|
});
|
|
493
508
|
export type QueueSchedule = z.infer<typeof QueueScheduleSchema>;
|
|
494
509
|
// Books the conversation to carry on from where its last turn stopped, at an instant or once another conversation's work
|
|
@@ -3,8 +3,9 @@ import { z } from "zod";
|
|
|
3
3
|
// WHAT A PROVIDER SAID WHEN IT REFUSED A TURN, and the ledger of them the sandbox answers with. Kept out of plan-limits.ts,
|
|
4
4
|
// which re-exports both, so the plan and turn schemas there stay within one file's reach.
|
|
5
5
|
|
|
6
|
-
// Observed and exact, unlike a polled usage snapshot that can be stale;
|
|
7
|
-
//
|
|
6
|
+
// Observed and exact, unlike a polled usage snapshot that can be stale; filed by provider, naming the account it refused
|
|
7
|
+
// wherever that is known (a routed turn's since the daemon's gateway places each request on one: 2026-11-08), and judged
|
|
8
|
+
// on that account alone. `kind` is read off what the provider said, not the frame code.
|
|
8
9
|
export const ProviderRefusalSchema = z.object({
|
|
9
10
|
// Read side by side with `AccountUsage.measuredAt` (also ms).
|
|
10
11
|
at: z.number().describe("When it refused, in milliseconds."),
|
|
@@ -15,7 +16,8 @@ export const ProviderRefusalSchema = z.object({
|
|
|
15
16
|
"Three different noes, kept apart because what fixes each is different. A spent allowance is answered by waiting; a refused credential by signing in again; and an entitlement refusal, where somebody has switched this off for your seat, by neither of those. That last one authenticates fine and reports healthy limits the whole time it refuses everything.",
|
|
16
17
|
),
|
|
17
18
|
message: z.string().describe("The provider's own words, verbatim. The only part that says which limit or which credential."),
|
|
18
|
-
//
|
|
19
|
+
// Absent only where nothing names the account that refused: such a refusal is judged on each account by that
|
|
20
|
+
// account's own reading (refusal-verdict.ts).
|
|
19
21
|
account: z.string().optional().describe("Which account was serving, where that is known."),
|
|
20
22
|
// Lets a `limit` refusal be read against the pool that model spends (`UsageWindow.gates`), not the account's
|
|
21
23
|
// fullest pool.
|
|
@@ -46,6 +48,13 @@ export const ProviderRefusalSchema = z.object({
|
|
|
46
48
|
),
|
|
47
49
|
});
|
|
48
50
|
export type ProviderRefusal = z.infer<typeof ProviderRefusalSchema>;
|
|
51
|
+
// A routed account's per-model bench as the translator holds it: the provider's own refusal of that account on that
|
|
52
|
+
// model, kept where the translator keeps it rather than copied onto the ledger, so it ends when the provider said.
|
|
53
|
+
export const ModelCooldownSchema = z.object({
|
|
54
|
+
model: z.string().describe("The model the provider refused this account on, as the translator names it."),
|
|
55
|
+
until: z.number().describe("When the provider said to try again, in epoch seconds."),
|
|
56
|
+
});
|
|
57
|
+
export type ModelCooldown = z.infer<typeof ModelCooldownSchema>;
|
|
49
58
|
// A released daemon (1.345.0 and earlier) answers one refusal per provider, its last: read as a list of one, as the
|
|
50
59
|
// /events frame's `refusal` is (refusalsOf). What this build sends, and its output shape, is still the list.
|
|
51
60
|
const RefusalsOnFileSchema = z.codec(z.union([z.array(ProviderRefusalSchema), ProviderRefusalSchema]), z.array(ProviderRefusalSchema), {
|