toolroll 0.9.34 → 0.9.37
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/CHANGELOG.md +102 -0
- package/README.md +7 -0
- package/dist/assignment-adapters.d.ts +12 -48
- package/dist/assignment-adapters.js +33 -43
- package/dist/assignment.d.ts +1 -0
- package/dist/assignment.js +2 -2
- package/dist/browser-workspace.d.ts +3 -3
- package/dist/build-review.d.ts +1 -1
- package/dist/build-review.js +2 -1
- package/dist/builder.js +4 -7
- package/dist/chat-acceptance.d.ts +2 -2
- package/dist/chat-actions.d.ts +18 -12
- package/dist/chat-actions.js +15 -65
- package/dist/chat-ask.js +5 -5
- package/dist/chat-decide.d.ts +14 -1
- package/dist/chat-decide.js +12 -6
- package/dist/chat-delivery-state.d.ts +12 -70
- package/dist/chat-delivery-state.js +17 -135
- package/dist/chat-delivery.js +58 -30
- package/dist/chat-flow.js +8 -6
- package/dist/chat-inbox.js +1 -1
- package/dist/coding-context.d.ts +2 -39
- package/dist/coding-context.js +2 -1
- package/dist/coding-handoff.d.ts +6 -25
- package/dist/coding-handoff.js +11 -5
- package/dist/coding-types.d.ts +2 -26
- package/dist/coding-workspace.d.ts +2 -0
- package/dist/coding-workspace.js +50 -14
- package/dist/contracts/acceptance-terms.d.ts +14 -0
- package/dist/contracts/acceptance-terms.js +16 -0
- package/dist/contracts/chat-actions.d.ts +328 -0
- package/dist/contracts/chat-actions.js +133 -0
- package/dist/contracts/chat-callback-rows.d.ts +59 -0
- package/dist/contracts/chat-callback-rows.js +46 -0
- package/dist/contracts/chat-content.d.ts +276 -0
- package/dist/contracts/chat-content.js +127 -0
- package/dist/contracts/chat-tables.d.ts +6 -0
- package/dist/contracts/chat-tables.js +136 -0
- package/dist/contracts/coding-context.d.ts +97 -0
- package/dist/contracts/coding-context.js +60 -0
- package/dist/contracts/coding-handoff.d.ts +44 -0
- package/dist/contracts/coding-handoff.js +47 -0
- package/dist/contracts/coding-workspace.d.ts +165 -0
- package/dist/contracts/coding-workspace.js +71 -0
- package/dist/contracts/contract.d.ts +40 -7
- package/dist/contracts/contract.js +155 -19
- package/dist/contracts/decision.d.ts +45 -0
- package/dist/contracts/decision.js +45 -0
- package/dist/contracts/discord-callback.d.ts +45 -0
- package/dist/contracts/discord-callback.js +34 -0
- package/dist/contracts/flow-card.d.ts +50 -0
- package/dist/contracts/flow-card.js +46 -0
- package/dist/contracts/flow-propose.d.ts +325 -0
- package/dist/contracts/flow-propose.js +41 -0
- package/dist/contracts/flow-send.d.ts +119 -0
- package/dist/contracts/flow-send.js +112 -0
- package/dist/contracts/flow.d.ts +19405 -0
- package/dist/contracts/flow.js +364 -0
- package/dist/contracts/gateway-tools.d.ts +374 -0
- package/dist/contracts/gateway-tools.js +94 -0
- package/dist/contracts/handoff.d.ts +91 -0
- package/dist/contracts/handoff.js +82 -0
- package/dist/contracts/lead-context.d.ts +165 -0
- package/dist/contracts/lead-context.js +73 -0
- package/dist/contracts/lead-tools.d.ts +1905 -0
- package/dist/contracts/lead-tools.js +265 -0
- package/dist/contracts/memory-pass.d.ts +158 -0
- package/dist/contracts/memory-pass.js +102 -0
- package/dist/contracts/project-knowledge.d.ts +126 -0
- package/dist/contracts/project-knowledge.js +93 -0
- package/dist/contracts/project-memory.d.ts +117 -0
- package/dist/contracts/project-memory.js +51 -0
- package/dist/contracts/project-skills.d.ts +121 -0
- package/dist/contracts/project-skills.js +76 -0
- package/dist/contracts/proof.d.ts +136 -0
- package/dist/contracts/proof.js +110 -0
- package/dist/contracts/review-findings.d.ts +46 -0
- package/dist/contracts/review-findings.js +48 -0
- package/dist/contracts/route.d.ts +484 -0
- package/dist/contracts/route.js +128 -0
- package/dist/contracts/scope.d.ts +105 -0
- package/dist/contracts/scope.js +114 -0
- package/dist/contracts/scout-report.d.ts +234 -0
- package/dist/contracts/scout-report.js +141 -0
- package/dist/contracts/slack-callback.d.ts +43 -0
- package/dist/contracts/slack-callback.js +35 -0
- package/dist/contracts/sort-answer.d.ts +83 -0
- package/dist/contracts/sort-answer.js +77 -0
- package/dist/contracts/stage-output.d.ts +127 -0
- package/dist/contracts/stage-output.js +166 -0
- package/dist/contracts/task-sizing.d.ts +24 -0
- package/dist/contracts/task-sizing.js +28 -0
- package/dist/contracts/teammate-turn.d.ts +43 -0
- package/dist/contracts/teammate-turn.js +51 -0
- package/dist/contracts/teams-callback.d.ts +14 -0
- package/dist/contracts/teams-callback.js +14 -0
- package/dist/contracts/telegram-callback.d.ts +120 -0
- package/dist/contracts/telegram-callback.js +97 -0
- package/dist/contracts/verification-receipt.d.ts +148 -0
- package/dist/contracts/verification-receipt.js +87 -0
- package/dist/decision.d.ts +11 -20
- package/dist/decision.js +86 -167
- package/dist/demo.js +28 -11
- package/dist/discord-chat.js +31 -20
- package/dist/evidence.d.ts +3 -40
- package/dist/evidence.js +5 -1
- package/dist/flow-engine.js +14 -17
- package/dist/flow-gallery.d.ts +3 -2
- package/dist/flow-items.d.ts +4 -13
- package/dist/flow-items.js +1 -15
- package/dist/flow-send.d.ts +6 -37
- package/dist/flow-send.js +18 -14
- package/dist/flow-share.d.ts +10 -32
- package/dist/flow-share.js +72 -84
- package/dist/flow-sort.d.ts +7 -26
- package/dist/flow-sort.js +25 -20
- package/dist/flow-starters.d.ts +2 -1
- package/dist/flow-steps.js +3 -2
- package/dist/flow-triggers.d.ts +15 -72
- package/dist/flow-triggers.js +94 -83
- package/dist/flows.d.ts +37 -220
- package/dist/flows.js +356 -387
- package/dist/invoke.js +4 -4
- package/dist/lead-context.d.ts +4 -2
- package/dist/lead-context.js +24 -17
- package/dist/mate-tools.d.ts +4 -0
- package/dist/mate-tools.js +111 -308
- package/dist/mcp-connect.d.ts +27 -4
- package/dist/mcp-connect.js +92 -17
- package/dist/mcp.js +84 -216
- package/dist/memory-pass.d.ts +17 -42
- package/dist/memory-pass.js +54 -26
- package/dist/operate.js +31 -2
- package/dist/phase-routing.d.ts +19 -72
- package/dist/phase-routing.js +34 -164
- package/dist/plan.d.ts +5 -5
- package/dist/plan.js +5 -25
- package/dist/process-recovery-eligibility.d.ts +2 -2
- package/dist/process-recovery-eligibility.js +13 -8
- package/dist/project-knowledge.d.ts +16 -35
- package/dist/project-knowledge.js +42 -21
- package/dist/project-memory.d.ts +2 -28
- package/dist/project-memory.js +28 -13
- package/dist/project-skills.d.ts +16 -38
- package/dist/project-skills.js +41 -32
- package/dist/project-tools.d.ts +1 -0
- package/dist/project-tools.js +4 -4
- package/dist/proof.d.ts +15 -91
- package/dist/proof.js +90 -249
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +4 -16
- package/dist/result-evidence-readers.d.ts +42 -0
- package/dist/result-evidence-readers.js +91 -0
- package/dist/result-shots.d.ts +1 -1
- package/dist/result-shots.js +2 -1
- package/dist/review-switch.d.ts +3 -8
- package/dist/reviewer.d.ts +8 -12
- package/dist/reviewer.js +11 -35
- package/dist/scope.d.ts +21 -43
- package/dist/scope.js +42 -128
- package/dist/scout-report.d.ts +9 -194
- package/dist/scout-report.js +113 -264
- package/dist/scout.js +15 -11
- package/dist/serve.js +17 -101
- package/dist/slack-chat.js +26 -20
- package/dist/slack-state.js +2 -1
- package/dist/store.d.ts +9 -32
- package/dist/store.js +18 -15
- package/dist/structured-output.js +2 -1
- package/dist/subscription-chat.d.ts +4 -0
- package/dist/subscription-chat.js +4 -1
- package/dist/surface.js +8 -1
- package/dist/task-review-brief.d.ts +69 -0
- package/dist/task-review-brief.js +179 -0
- package/dist/task-sizing.d.ts +3 -27
- package/dist/task-sizing.js +11 -26
- package/dist/task-text.d.ts +0 -5
- package/dist/task-text.js +1 -3
- package/dist/teammate-question.js +7 -5
- package/dist/teammate-work.js +9 -5
- package/dist/teammates.d.ts +13 -64
- package/dist/teammates.js +32 -33
- package/dist/teams-chat.js +20 -11
- package/dist/telegram-flow.js +4 -3
- package/dist/telegram-mate.d.ts +4 -14
- package/dist/telegram-mate.js +8 -7
- package/dist/telegram-team.d.ts +2 -19
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +52 -42
- package/dist/text-limits.d.ts +212 -1
- package/dist/text-limits.js +214 -1
- package/dist/tools-ui.d.ts +2 -1
- package/dist/tools-ui.js +7 -4
- package/dist/verification-evidence.js +24 -12
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The managed context a desktop coding session captures once (`prepareCodingContext` in coding-context.ts): the
|
|
3
|
+
* frozen text the agent is given, what it was selected from, and the digest that ties the two together. It is saved
|
|
4
|
+
* inside the session's workspace record and checked again (`verifyCodingContext`) before every resume.
|
|
5
|
+
*
|
|
6
|
+
* `metadata` keeps its own `version: 1` because it is part of the digest; its keys are listed in the order the digest
|
|
7
|
+
* was taken in, so a parsed capture digests exactly as it was saved. Repository identity, digest and the materialized
|
|
8
|
+
* skill files are checked in plain code after parsing.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { type ContractResult } from "./contract.js";
|
|
12
|
+
export declare const codingContextMetadataSchema: z.ZodObject<{
|
|
13
|
+
version: z.ZodLiteral<1>;
|
|
14
|
+
repo: z.ZodString;
|
|
15
|
+
identity: z.ZodString;
|
|
16
|
+
baseRevision: z.ZodString;
|
|
17
|
+
knowledge: z.ZodObject<{
|
|
18
|
+
revision: z.ZodInt;
|
|
19
|
+
selectionSha256: z.ZodString;
|
|
20
|
+
references: z.ZodArray<z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
title: z.ZodString;
|
|
23
|
+
path: z.ZodNullable<z.ZodString>;
|
|
24
|
+
sourceSha: z.ZodNullable<z.ZodString>;
|
|
25
|
+
sourceRevision: z.ZodNullable<z.ZodString>;
|
|
26
|
+
}, z.core.$strict>>;
|
|
27
|
+
omitted: z.ZodArray<z.ZodObject<{
|
|
28
|
+
title: z.ZodString;
|
|
29
|
+
reason: z.ZodString;
|
|
30
|
+
}, z.core.$strict>>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
skills: z.ZodObject<{
|
|
33
|
+
revision: z.ZodInt;
|
|
34
|
+
packages: z.ZodArray<z.ZodObject<{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
sha256: z.ZodString;
|
|
37
|
+
skillFile: z.ZodString;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
directory: z.ZodNullable<z.ZodString>;
|
|
41
|
+
files: z.ZodArray<z.ZodObject<{
|
|
42
|
+
path: z.ZodString;
|
|
43
|
+
sha256: z.ZodString;
|
|
44
|
+
}, z.core.$strict>>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export declare const CODING_CONTEXT_VERSION = 1;
|
|
47
|
+
export declare const codingContextSchema: z.ZodObject<{
|
|
48
|
+
version: z.ZodLiteral<1>;
|
|
49
|
+
text: z.ZodString;
|
|
50
|
+
metadata: z.ZodObject<{
|
|
51
|
+
version: z.ZodLiteral<1>;
|
|
52
|
+
repo: z.ZodString;
|
|
53
|
+
identity: z.ZodString;
|
|
54
|
+
baseRevision: z.ZodString;
|
|
55
|
+
knowledge: z.ZodObject<{
|
|
56
|
+
revision: z.ZodInt;
|
|
57
|
+
selectionSha256: z.ZodString;
|
|
58
|
+
references: z.ZodArray<z.ZodObject<{
|
|
59
|
+
id: z.ZodString;
|
|
60
|
+
title: z.ZodString;
|
|
61
|
+
path: z.ZodNullable<z.ZodString>;
|
|
62
|
+
sourceSha: z.ZodNullable<z.ZodString>;
|
|
63
|
+
sourceRevision: z.ZodNullable<z.ZodString>;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
omitted: z.ZodArray<z.ZodObject<{
|
|
66
|
+
title: z.ZodString;
|
|
67
|
+
reason: z.ZodString;
|
|
68
|
+
}, z.core.$strict>>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
skills: z.ZodObject<{
|
|
71
|
+
revision: z.ZodInt;
|
|
72
|
+
packages: z.ZodArray<z.ZodObject<{
|
|
73
|
+
name: z.ZodString;
|
|
74
|
+
sha256: z.ZodString;
|
|
75
|
+
skillFile: z.ZodString;
|
|
76
|
+
}, z.core.$strict>>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
directory: z.ZodNullable<z.ZodString>;
|
|
79
|
+
files: z.ZodArray<z.ZodObject<{
|
|
80
|
+
path: z.ZodString;
|
|
81
|
+
sha256: z.ZodString;
|
|
82
|
+
}, z.core.$strict>>;
|
|
83
|
+
}, z.core.$strict>;
|
|
84
|
+
sha256: z.ZodString;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
export type CodingContextMetadata = z.infer<typeof codingContextMetadataSchema>;
|
|
87
|
+
export type CodingContext = z.infer<typeof codingContextSchema>;
|
|
88
|
+
/**
|
|
89
|
+
* A capture saved before the envelope carried `version` (every session through 0.9.36), as version 1. Readers then
|
|
90
|
+
* read only these three fields; the metadata is kept exactly as saved, since its bytes are what the digest covers.
|
|
91
|
+
*/
|
|
92
|
+
export declare function upgradeUnversionedContext(body: Record<string, unknown>): Record<string, unknown>;
|
|
93
|
+
export declare const CODING_CONTEXT_UPGRADES: {
|
|
94
|
+
readonly 0: typeof upgradeUnversionedContext;
|
|
95
|
+
};
|
|
96
|
+
/** Read a saved capture: version 1 as itself, an unversioned one upgraded, a newer one refused plainly. */
|
|
97
|
+
export declare function readCodingContext(input: unknown): ContractResult<CodingContext>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The managed context a desktop coding session captures once (`prepareCodingContext` in coding-context.ts): the
|
|
3
|
+
* frozen text the agent is given, what it was selected from, and the digest that ties the two together. It is saved
|
|
4
|
+
* inside the session's workspace record and checked again (`verifyCodingContext`) before every resume.
|
|
5
|
+
*
|
|
6
|
+
* `metadata` keeps its own `version: 1` because it is part of the digest; its keys are listed in the order the digest
|
|
7
|
+
* was taken in, so a parsed capture digests exactly as it was saved. Repository identity, digest and the materialized
|
|
8
|
+
* skill files are checked in plain code after parsing.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { readVersioned, versioned } from "./contract.js";
|
|
12
|
+
export const codingContextMetadataSchema = z.strictObject({
|
|
13
|
+
version: z.literal(1),
|
|
14
|
+
repo: z.string(),
|
|
15
|
+
identity: z.string(),
|
|
16
|
+
baseRevision: z.string(),
|
|
17
|
+
knowledge: z.strictObject({
|
|
18
|
+
revision: z.int(),
|
|
19
|
+
selectionSha256: z.string(),
|
|
20
|
+
references: z.array(z.strictObject({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
title: z.string(),
|
|
23
|
+
path: z.string().nullable(),
|
|
24
|
+
sourceSha: z.string().nullable(),
|
|
25
|
+
sourceRevision: z.string().nullable(),
|
|
26
|
+
})),
|
|
27
|
+
omitted: z.array(z.strictObject({ title: z.string(), reason: z.string() })),
|
|
28
|
+
}),
|
|
29
|
+
skills: z.strictObject({
|
|
30
|
+
revision: z.int(),
|
|
31
|
+
packages: z.array(z.strictObject({ name: z.string(), sha256: z.string(), skillFile: z.string() })),
|
|
32
|
+
}),
|
|
33
|
+
directory: z.string().nullable(),
|
|
34
|
+
files: z.array(z.strictObject({ path: z.string(), sha256: z.string() })),
|
|
35
|
+
});
|
|
36
|
+
export const CODING_CONTEXT_VERSION = 1;
|
|
37
|
+
export const codingContextSchema = versioned(CODING_CONTEXT_VERSION, {
|
|
38
|
+
text: z.string(),
|
|
39
|
+
metadata: codingContextMetadataSchema,
|
|
40
|
+
/** learningSha of `{ text, metadata }`. */
|
|
41
|
+
sha256: z.string(),
|
|
42
|
+
});
|
|
43
|
+
const CONTEXT_FIELDS = ["text", "metadata", "sha256"];
|
|
44
|
+
/**
|
|
45
|
+
* A capture saved before the envelope carried `version` (every session through 0.9.36), as version 1. Readers then
|
|
46
|
+
* read only these three fields; the metadata is kept exactly as saved, since its bytes are what the digest covers.
|
|
47
|
+
*/
|
|
48
|
+
export function upgradeUnversionedContext(body) {
|
|
49
|
+
const out = { version: CODING_CONTEXT_VERSION };
|
|
50
|
+
for (const field of CONTEXT_FIELDS) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(body, field) && body[field] !== undefined)
|
|
52
|
+
out[field] = body[field];
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
export const CODING_CONTEXT_UPGRADES = { 0: upgradeUnversionedContext };
|
|
57
|
+
/** Read a saved capture: version 1 as itself, an unversioned one upgraded, a newer one refused plainly. */
|
|
58
|
+
export function readCodingContext(input) {
|
|
59
|
+
return readVersioned(codingContextSchema, input, CODING_CONTEXT_UPGRADES, { distinguishNull: true });
|
|
60
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The coding handoff receipt: the immutable terms under which a committed desktop coding session became an ordinary
|
|
3
|
+
* review task (`coding_handoff.payload`, coding-handoff.ts). Its bytes are hashed and sealed, and its id is the hash of
|
|
4
|
+
* its terms, so the keys are listed in the order the receipt has always been written in — `version` after the
|
|
5
|
+
* preview — and a parsed receipt serializes to exactly the bytes it was read from. The saved hash, derived identity,
|
|
6
|
+
* branch and scope seal are checked in plain code: the hash before parsing, the rest after.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { type ContractResult } from "./contract.js";
|
|
10
|
+
export declare const CODING_HANDOFF_VERSION = 1;
|
|
11
|
+
export declare const codingHandoffReceiptSchema: z.ZodObject<{
|
|
12
|
+
sessionId: z.ZodString;
|
|
13
|
+
repo: z.ZodString;
|
|
14
|
+
base: z.ZodString;
|
|
15
|
+
candidate: z.ZodString;
|
|
16
|
+
title: z.ZodString;
|
|
17
|
+
originalPrompt: z.ZodString;
|
|
18
|
+
changedPaths: z.ZodArray<z.ZodString>;
|
|
19
|
+
version: z.ZodLiteral<1>;
|
|
20
|
+
identity: z.ZodString;
|
|
21
|
+
actor: z.ZodString;
|
|
22
|
+
generation: z.ZodInt;
|
|
23
|
+
goal: z.ZodString;
|
|
24
|
+
acceptance: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
statement: z.ZodString;
|
|
27
|
+
how: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
evidence: z.ZodArray<z.ZodEnum<{
|
|
29
|
+
"changed-path": "changed-path";
|
|
30
|
+
check: "check";
|
|
31
|
+
"manual-review": "manual-review";
|
|
32
|
+
screenshot: "screenshot";
|
|
33
|
+
}>>;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
outOfScope: z.ZodString;
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
taskId: z.ZodString;
|
|
38
|
+
branch: z.ZodString;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export type CodingHandoffReceipt = z.infer<typeof codingHandoffReceiptSchema>;
|
|
41
|
+
/** Read a receipt: version 1 as itself, a newer one refused plainly. Receipts have always carried `version`. */
|
|
42
|
+
export declare function readCodingHandoffReceipt(input: unknown): ContractResult<CodingHandoffReceipt>;
|
|
43
|
+
/** Read a receipt's saved bytes: JSON first, then the schema. */
|
|
44
|
+
export declare function parseCodingHandoffReceipt(raw: string): ContractResult<CodingHandoffReceipt>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The coding handoff receipt: the immutable terms under which a committed desktop coding session became an ordinary
|
|
3
|
+
* review task (`coding_handoff.payload`, coding-handoff.ts). Its bytes are hashed and sealed, and its id is the hash of
|
|
4
|
+
* its terms, so the keys are listed in the order the receipt has always been written in — `version` after the
|
|
5
|
+
* preview — and a parsed receipt serializes to exactly the bytes it was read from. The saved hash, derived identity,
|
|
6
|
+
* branch and scope seal are checked in plain code: the hash before parsing, the rest after.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { readVersioned } from "./contract.js";
|
|
10
|
+
import { acceptanceCriterionSchema } from "./plan.js";
|
|
11
|
+
export const CODING_HANDOFF_VERSION = 1;
|
|
12
|
+
export const codingHandoffReceiptSchema = z.strictObject({
|
|
13
|
+
sessionId: z.string(),
|
|
14
|
+
repo: z.string(),
|
|
15
|
+
base: z.string(),
|
|
16
|
+
candidate: z.string(),
|
|
17
|
+
title: z.string(),
|
|
18
|
+
/** The session's first message, as the person wrote it. */
|
|
19
|
+
originalPrompt: z.string(),
|
|
20
|
+
changedPaths: z.array(z.string()),
|
|
21
|
+
version: z.literal(CODING_HANDOFF_VERSION),
|
|
22
|
+
identity: z.string(),
|
|
23
|
+
actor: z.string(),
|
|
24
|
+
generation: z.int(),
|
|
25
|
+
goal: z.string(),
|
|
26
|
+
acceptance: z.array(acceptanceCriterionSchema),
|
|
27
|
+
outOfScope: z.string(),
|
|
28
|
+
/** The first 32 hex of learningSha over every field above, in this order. */
|
|
29
|
+
id: z.string(),
|
|
30
|
+
taskId: z.string(),
|
|
31
|
+
branch: z.string(),
|
|
32
|
+
});
|
|
33
|
+
/** Read a receipt: version 1 as itself, a newer one refused plainly. Receipts have always carried `version`. */
|
|
34
|
+
export function readCodingHandoffReceipt(input) {
|
|
35
|
+
return readVersioned(codingHandoffReceiptSchema, input, {}, { distinguishNull: true });
|
|
36
|
+
}
|
|
37
|
+
/** Read a receipt's saved bytes: JSON first, then the schema. */
|
|
38
|
+
export function parseCodingHandoffReceipt(raw) {
|
|
39
|
+
let body;
|
|
40
|
+
try {
|
|
41
|
+
body = JSON.parse(raw);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return { ok: false, issues: [{ path: "payload", kind: "invalid", line: "payload: not JSON" }] };
|
|
45
|
+
}
|
|
46
|
+
return readCodingHandoffReceipt(body);
|
|
47
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace record: one desktop coding session as the coding catalog saves it (`coding_session.document`). The
|
|
3
|
+
* session itself is what the console, chat and the coding handoff read; the record is that session with its
|
|
4
|
+
* `version`. Row ownership, generation and recovery state are checked in plain code by the workspace after parsing.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { type ContractResult } from "./contract.js";
|
|
8
|
+
export declare const CODING_STATUSES: readonly ["starting", "ready", "working", "needs-input", "stopping", "interrupted", "failed", "uncertain", "closed"];
|
|
9
|
+
export declare const codingSessionSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
owner: z.ZodString;
|
|
12
|
+
generation: z.ZodInt;
|
|
13
|
+
repo: z.ZodString;
|
|
14
|
+
title: z.ZodString;
|
|
15
|
+
provider: z.ZodLiteral<"codex">;
|
|
16
|
+
model: z.ZodNullable<z.ZodString>;
|
|
17
|
+
branch: z.ZodString;
|
|
18
|
+
base: z.ZodString;
|
|
19
|
+
worktree: z.ZodString;
|
|
20
|
+
nativeThreadId: z.ZodNullable<z.ZodString>;
|
|
21
|
+
turnId: z.ZodNullable<z.ZodString>;
|
|
22
|
+
status: z.ZodEnum<{
|
|
23
|
+
closed: "closed";
|
|
24
|
+
failed: "failed";
|
|
25
|
+
interrupted: "interrupted";
|
|
26
|
+
"needs-input": "needs-input";
|
|
27
|
+
ready: "ready";
|
|
28
|
+
starting: "starting";
|
|
29
|
+
stopping: "stopping";
|
|
30
|
+
uncertain: "uncertain";
|
|
31
|
+
working: "working";
|
|
32
|
+
}>;
|
|
33
|
+
error: z.ZodNullable<z.ZodString>;
|
|
34
|
+
createdAt: z.ZodString;
|
|
35
|
+
updatedAt: z.ZodString;
|
|
36
|
+
deliveryReviewRequired: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
initialRequest: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
requestId: z.ZodString;
|
|
39
|
+
prompt: z.ZodString;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
version: z.ZodLiteral<1>;
|
|
43
|
+
text: z.ZodString;
|
|
44
|
+
metadata: z.ZodObject<{
|
|
45
|
+
version: z.ZodLiteral<1>;
|
|
46
|
+
repo: z.ZodString;
|
|
47
|
+
identity: z.ZodString;
|
|
48
|
+
baseRevision: z.ZodString;
|
|
49
|
+
knowledge: z.ZodObject<{
|
|
50
|
+
revision: z.ZodInt;
|
|
51
|
+
selectionSha256: z.ZodString;
|
|
52
|
+
references: z.ZodArray<z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
title: z.ZodString;
|
|
55
|
+
path: z.ZodNullable<z.ZodString>;
|
|
56
|
+
sourceSha: z.ZodNullable<z.ZodString>;
|
|
57
|
+
sourceRevision: z.ZodNullable<z.ZodString>;
|
|
58
|
+
}, z.core.$strict>>;
|
|
59
|
+
omitted: z.ZodArray<z.ZodObject<{
|
|
60
|
+
title: z.ZodString;
|
|
61
|
+
reason: z.ZodString;
|
|
62
|
+
}, z.core.$strict>>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
skills: z.ZodObject<{
|
|
65
|
+
revision: z.ZodInt;
|
|
66
|
+
packages: z.ZodArray<z.ZodObject<{
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
sha256: z.ZodString;
|
|
69
|
+
skillFile: z.ZodString;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
directory: z.ZodNullable<z.ZodString>;
|
|
73
|
+
files: z.ZodArray<z.ZodObject<{
|
|
74
|
+
path: z.ZodString;
|
|
75
|
+
sha256: z.ZodString;
|
|
76
|
+
}, z.core.$strict>>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
sha256: z.ZodString;
|
|
79
|
+
}, z.core.$strict>>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export declare const CODING_SESSION_VERSION = 1;
|
|
82
|
+
export declare const codingSessionRecordSchema: z.ZodObject<{
|
|
83
|
+
version: z.ZodLiteral<1>;
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
owner: z.ZodString;
|
|
86
|
+
generation: z.ZodInt;
|
|
87
|
+
repo: z.ZodString;
|
|
88
|
+
title: z.ZodString;
|
|
89
|
+
provider: z.ZodLiteral<"codex">;
|
|
90
|
+
model: z.ZodNullable<z.ZodString>;
|
|
91
|
+
branch: z.ZodString;
|
|
92
|
+
base: z.ZodString;
|
|
93
|
+
worktree: z.ZodString;
|
|
94
|
+
nativeThreadId: z.ZodNullable<z.ZodString>;
|
|
95
|
+
turnId: z.ZodNullable<z.ZodString>;
|
|
96
|
+
status: z.ZodEnum<{
|
|
97
|
+
closed: "closed";
|
|
98
|
+
failed: "failed";
|
|
99
|
+
interrupted: "interrupted";
|
|
100
|
+
"needs-input": "needs-input";
|
|
101
|
+
ready: "ready";
|
|
102
|
+
starting: "starting";
|
|
103
|
+
stopping: "stopping";
|
|
104
|
+
uncertain: "uncertain";
|
|
105
|
+
working: "working";
|
|
106
|
+
}>;
|
|
107
|
+
error: z.ZodNullable<z.ZodString>;
|
|
108
|
+
createdAt: z.ZodString;
|
|
109
|
+
updatedAt: z.ZodString;
|
|
110
|
+
deliveryReviewRequired: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
+
initialRequest: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
requestId: z.ZodString;
|
|
113
|
+
prompt: z.ZodString;
|
|
114
|
+
}, z.core.$strict>>;
|
|
115
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
116
|
+
version: z.ZodLiteral<1>;
|
|
117
|
+
text: z.ZodString;
|
|
118
|
+
metadata: z.ZodObject<{
|
|
119
|
+
version: z.ZodLiteral<1>;
|
|
120
|
+
repo: z.ZodString;
|
|
121
|
+
identity: z.ZodString;
|
|
122
|
+
baseRevision: z.ZodString;
|
|
123
|
+
knowledge: z.ZodObject<{
|
|
124
|
+
revision: z.ZodInt;
|
|
125
|
+
selectionSha256: z.ZodString;
|
|
126
|
+
references: z.ZodArray<z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
title: z.ZodString;
|
|
129
|
+
path: z.ZodNullable<z.ZodString>;
|
|
130
|
+
sourceSha: z.ZodNullable<z.ZodString>;
|
|
131
|
+
sourceRevision: z.ZodNullable<z.ZodString>;
|
|
132
|
+
}, z.core.$strict>>;
|
|
133
|
+
omitted: z.ZodArray<z.ZodObject<{
|
|
134
|
+
title: z.ZodString;
|
|
135
|
+
reason: z.ZodString;
|
|
136
|
+
}, z.core.$strict>>;
|
|
137
|
+
}, z.core.$strict>;
|
|
138
|
+
skills: z.ZodObject<{
|
|
139
|
+
revision: z.ZodInt;
|
|
140
|
+
packages: z.ZodArray<z.ZodObject<{
|
|
141
|
+
name: z.ZodString;
|
|
142
|
+
sha256: z.ZodString;
|
|
143
|
+
skillFile: z.ZodString;
|
|
144
|
+
}, z.core.$strict>>;
|
|
145
|
+
}, z.core.$strict>;
|
|
146
|
+
directory: z.ZodNullable<z.ZodString>;
|
|
147
|
+
files: z.ZodArray<z.ZodObject<{
|
|
148
|
+
path: z.ZodString;
|
|
149
|
+
sha256: z.ZodString;
|
|
150
|
+
}, z.core.$strict>>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
sha256: z.ZodString;
|
|
153
|
+
}, z.core.$strict>>;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
export type CodingStatus = z.infer<typeof codingSessionSchema>["status"];
|
|
156
|
+
export type CodingSession = z.infer<typeof codingSessionSchema>;
|
|
157
|
+
/**
|
|
158
|
+
* Unversioned records were read as a cast, including partial fields, nulls and unknown nested keys. Preserve that
|
|
159
|
+
* boundary exactly; only records explicitly written as version 1 are subject to its strict schema.
|
|
160
|
+
*/
|
|
161
|
+
export declare function readCodingSessionRecord(input: unknown): ContractResult<CodingSession>;
|
|
162
|
+
/** Read a saved `coding_session.document`, throwing a path-named refusal; the catalog was written by Toolroll alone. */
|
|
163
|
+
export declare function parseCodingSessionDocument(document: string): CodingSession;
|
|
164
|
+
/** Stamp the current version only if the entire record fits, without dropping any legacy fields. */
|
|
165
|
+
export declare function codingSessionDocument(session: CodingSession): string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace record: one desktop coding session as the coding catalog saves it (`coding_session.document`). The
|
|
3
|
+
* session itself is what the console, chat and the coding handoff read; the record is that session with its
|
|
4
|
+
* `version`. Row ownership, generation and recovery state are checked in plain code by the workspace after parsing.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { readVersioned, versioned } from "./contract.js";
|
|
8
|
+
import { CODING_CONTEXT_VERSION, codingContextSchema } from "./coding-context.js";
|
|
9
|
+
export const CODING_STATUSES = ["starting", "ready", "working", "needs-input", "stopping", "interrupted", "failed", "uncertain", "closed"];
|
|
10
|
+
export const codingSessionSchema = z.strictObject({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
owner: z.string(),
|
|
13
|
+
generation: z.int(),
|
|
14
|
+
repo: z.string(),
|
|
15
|
+
title: z.string(),
|
|
16
|
+
provider: z.literal("codex"),
|
|
17
|
+
model: z.string().nullable(),
|
|
18
|
+
branch: z.string(),
|
|
19
|
+
base: z.string(),
|
|
20
|
+
worktree: z.string(),
|
|
21
|
+
nativeThreadId: z.string().nullable(),
|
|
22
|
+
turnId: z.string().nullable(),
|
|
23
|
+
status: z.enum(CODING_STATUSES),
|
|
24
|
+
error: z.string().nullable(),
|
|
25
|
+
createdAt: z.string(),
|
|
26
|
+
updatedAt: z.string(),
|
|
27
|
+
/** Set once startup or the last message could not be confirmed; absent on sessions that never needed it. */
|
|
28
|
+
deliveryReviewRequired: z.boolean().optional(),
|
|
29
|
+
/** The request the session started with, kept so it is never resent. */
|
|
30
|
+
initialRequest: z.strictObject({ requestId: z.string(), prompt: z.string() }).optional(),
|
|
31
|
+
/** Absent when no managed context was captured. */
|
|
32
|
+
context: codingContextSchema.optional(),
|
|
33
|
+
});
|
|
34
|
+
export const CODING_SESSION_VERSION = 1;
|
|
35
|
+
export const codingSessionRecordSchema = versioned(CODING_SESSION_VERSION, codingSessionSchema.shape);
|
|
36
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
|
+
/**
|
|
38
|
+
* Unversioned records were read as a cast, including partial fields, nulls and unknown nested keys. Preserve that
|
|
39
|
+
* boundary exactly; only records explicitly written as version 1 are subject to its strict schema.
|
|
40
|
+
*/
|
|
41
|
+
export function readCodingSessionRecord(input) {
|
|
42
|
+
if (isRecord(input) && !Object.prototype.hasOwnProperty.call(input, "version"))
|
|
43
|
+
return { ok: true, value: input };
|
|
44
|
+
const read = readVersioned(codingSessionRecordSchema, input, {}, { distinguishNull: true });
|
|
45
|
+
if (!read.ok)
|
|
46
|
+
return read;
|
|
47
|
+
const { version: _version, ...session } = read.value;
|
|
48
|
+
return { ok: true, value: session };
|
|
49
|
+
}
|
|
50
|
+
/** Read a saved `coding_session.document`, throwing a path-named refusal; the catalog was written by Toolroll alone. */
|
|
51
|
+
export function parseCodingSessionDocument(document) {
|
|
52
|
+
let body;
|
|
53
|
+
try {
|
|
54
|
+
body = JSON.parse(document);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw Error("A saved coding session could not be read: payload: not JSON");
|
|
58
|
+
}
|
|
59
|
+
const read = readCodingSessionRecord(body);
|
|
60
|
+
if (!read.ok)
|
|
61
|
+
throw Error(`A saved coding session could not be read: ${read.issues.map(issue => issue.line).join("; ")}`);
|
|
62
|
+
return read.value;
|
|
63
|
+
}
|
|
64
|
+
/** Stamp the current version only if the entire record fits, without dropping any legacy fields. */
|
|
65
|
+
export function codingSessionDocument(session) {
|
|
66
|
+
const record = { version: CODING_SESSION_VERSION, ...session };
|
|
67
|
+
if (isRecord(record.context) && !Object.prototype.hasOwnProperty.call(record.context, "version")) {
|
|
68
|
+
record.context = { ...record.context, version: CODING_CONTEXT_VERSION };
|
|
69
|
+
}
|
|
70
|
+
return JSON.stringify(codingSessionRecordSchema.safeParse(record).success ? record : session);
|
|
71
|
+
}
|
|
@@ -12,9 +12,12 @@ import { type TextLimitKey } from "../text-limits.js";
|
|
|
12
12
|
* A string bounded by its TEXT_LIMITS entry, never a literal. The limit rule rides along as the field's description,
|
|
13
13
|
* so a model reads the bound before it writes. Zod counts UTF-16 code units; for a limit named in bytes this is the
|
|
14
14
|
* schema's necessary bound (a string within N bytes is within N code units), and the byte count itself is checked in
|
|
15
|
-
* plain code after parsing.
|
|
15
|
+
* plain code after parsing. `shorten: false` is for a contract with no shorten turn (a parked decision): its
|
|
16
|
+
* description states the bound without promising one.
|
|
16
17
|
*/
|
|
17
|
-
export declare function limited(field: string, limitKey: TextLimitKey
|
|
18
|
+
export declare function limited(field: string, limitKey: TextLimitKey, options?: {
|
|
19
|
+
shorten?: boolean;
|
|
20
|
+
}): z.ZodString;
|
|
18
21
|
/** A versioned payload envelope: a strict object whose `version` is exactly `version`. */
|
|
19
22
|
export declare function versioned<V extends number, S extends z.ZodRawShape>(version: V, shape: S): z.ZodObject<{
|
|
20
23
|
version: z.ZodLiteral<V>;
|
|
@@ -29,10 +32,39 @@ export type ContractIssue = {
|
|
|
29
32
|
};
|
|
30
33
|
/** `["steps", 0, "routes", 0, "goesTo"]` as `steps[0].routes[0].goesTo`. */
|
|
31
34
|
export declare function pathOf(path: readonly PropertyKey[]): string;
|
|
32
|
-
/**
|
|
33
|
-
|
|
35
|
+
/**
|
|
36
|
+
* How a contract names a key it doesn't know: the keys a person or model often writes for one it does (`onFail` for
|
|
37
|
+
* `ifFails`, `to` for `goesTo`), tried in order against the keys allowed at that place. Without one that fits, a key
|
|
38
|
+
* spelled close to an allowed one (a case or a letter or two off) is suggested.
|
|
39
|
+
*/
|
|
40
|
+
export type ContractOptions = {
|
|
41
|
+
aliases?: Readonly<Record<string, readonly string[]>>;
|
|
42
|
+
/** Report explicit null as a wrong value; omitted keeps the historical wording for existing contracts. */
|
|
43
|
+
distinguishNull?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type Where = {
|
|
46
|
+
schema?: z.ZodType;
|
|
47
|
+
input?: unknown;
|
|
48
|
+
options?: ContractOptions;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A Zod error as path-named issues, in the error's own order. Given the schema and input it came from, an unknown key
|
|
52
|
+
* also says which allowed key it most likely meant (`unknown key 'onFail' (did you mean ifFails?)`).
|
|
53
|
+
*/
|
|
54
|
+
export declare function contractIssues(error: z.ZodError, where?: Where): ContractIssue[];
|
|
34
55
|
/** A Zod error as path-named lines: `steps[0].routes[0].goesTo: required`, `routes[0]: unknown key 'to'`. */
|
|
35
|
-
export declare function contractError(error: z.ZodError): string[];
|
|
56
|
+
export declare function contractError(error: z.ZodError, where?: Where): string[];
|
|
57
|
+
/** A refusal as a reader reports it: a stable reason code, and the path-named line as the message. */
|
|
58
|
+
export type ContractProblem = {
|
|
59
|
+
reason: string;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A contract issue as a problem with a reason code built from its path — `missing-goal`, `criteria[0].how-too-long`,
|
|
64
|
+
* `checks-too-many`, `payload-unknown-key`, `bad-version`, `newer-version` — so callers that branch on a reason, and
|
|
65
|
+
* durable outcomes that recorded one, read the same as before the contract.
|
|
66
|
+
*/
|
|
67
|
+
export declare function contractProblemOf(issue: ContractIssue): ContractProblem;
|
|
36
68
|
export type ContractResult<T> = {
|
|
37
69
|
ok: true;
|
|
38
70
|
value: T;
|
|
@@ -41,7 +73,7 @@ export type ContractResult<T> = {
|
|
|
41
73
|
issues: ContractIssue[];
|
|
42
74
|
};
|
|
43
75
|
/** Parse with the input reported, so a missing field reads `required` rather than a wrong type. */
|
|
44
|
-
export declare function parseContract<T>(schema: z.ZodType<T>, input: unknown): ContractResult<T>;
|
|
76
|
+
export declare function parseContract<T>(schema: z.ZodType<T>, input: unknown, options?: ContractOptions): ContractResult<T>;
|
|
45
77
|
/**
|
|
46
78
|
* Read a versioned payload. The current version parses as itself; an older known version (0 for a payload saved
|
|
47
79
|
* before it carried `version`) is upgraded by its adapter and then parsed by the same schema; a newer version is
|
|
@@ -51,9 +83,10 @@ export declare function readVersioned<T>(schema: z.ZodType<T> & {
|
|
|
51
83
|
shape: {
|
|
52
84
|
version: z.ZodLiteral<number>;
|
|
53
85
|
};
|
|
54
|
-
}, input: unknown, upgrades?: Readonly<Record<number, (payload: Record<string, unknown>) => unknown
|
|
86
|
+
}, input: unknown, upgrades?: Readonly<Record<number, (payload: Record<string, unknown>) => unknown>>, options?: ContractOptions): ContractResult<T>;
|
|
55
87
|
/**
|
|
56
88
|
* The JSON Schema a model gets for `schema` (Claude's `--json-schema`). Throws when the schema uses refine,
|
|
57
89
|
* superRefine, transform or preprocess anywhere: what a model is told must be everything the schema checks.
|
|
58
90
|
*/
|
|
59
91
|
export declare function toModelSchema(schema: z.ZodType): Record<string, unknown>;
|
|
92
|
+
export {};
|