@junghanacs/entwurf 0.41.2 → 0.45.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/AGENTS.md +1 -0
- package/CHANGELOG.md +159 -0
- package/ENTWURF.json +236 -0
- package/README.md +12 -7
- package/docs/setup-clean-host.md +8 -8
- package/mcp/entwurf-bridge/dist/ENTWURF.json +236 -0
- package/mcp/entwurf-bridge/dist/mcp/entwurf-bridge/src/index.js +27 -188
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/agent-guidance.js +299 -0
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-surface.js +21 -25
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/entwurf-v2-visible-resume.js +15 -11
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/mux-fresh-call.js +23 -20
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/mux-resume-call.js +18 -16
- package/mcp/entwurf-bridge/dist/pi-extensions/lib/remote-pair-send.js +7 -4
- package/mcp/entwurf-bridge/dist/pi-extensions/meta-bridge-pi-durable.js +23 -45
- package/mcp/entwurf-bridge/src/index.ts +121 -319
- package/package.json +3 -2
- package/pi-extensions/lib/agent-guidance.ts +341 -0
- package/pi-extensions/lib/entwurf-v2-surface.ts +25 -31
- package/pi-extensions/lib/entwurf-v2-visible-resume.ts +15 -16
- package/pi-extensions/lib/mux-fresh-call.ts +23 -26
- package/pi-extensions/lib/mux-resume-call.ts +18 -19
- package/pi-extensions/lib/remote-pair-send.ts +7 -4
- package/pi-extensions/meta-bridge-pi-durable.ts +23 -64
- package/run.sh +9 -0
- package/scripts/build-bridge.sh +10 -0
- package/scripts/check-capability-bundle-reach.ts +86 -0
- package/scripts/check-entwurf-self-address.ts +3 -3
- package/scripts/check-entwurf-v2-surface.ts +94 -98
- package/scripts/check-gate-qualification.ts +9 -7
- package/scripts/check-mux-resume-call.ts +20 -3
- package/scripts/mutants/agent-guidance.json +160 -0
- package/scripts/mutants/bridge-boot-resume.json +6 -8
- package/scripts/mutants/capability-bundle-reach.json +124 -0
- package/scripts/mutants/control-send-receipt.json +21 -4
- package/scripts/mutants/mux-fresh-call.json +14 -3
- package/scripts/mutants/mux-resume-call.json +28 -3
- package/scripts/mutants/pi-durable.json +17 -5
- package/scripts/mutants/remote-pair-send.json +21 -2
- package/scripts/mutants/self-address.json +10 -10
- package/scripts/mutants/v2-surface.json +50 -64
- package/scripts/mutants/v2-visible-resume.json +11 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product-owned natural-language logic, authored only in root ENTWURF.json (#154).
|
|
3
|
+
* One module-relative file, read once. The compiled layout carries an exact copy at
|
|
4
|
+
* dist/ENTWURF.json; no cwd/HOME search, override, old-text fallback or hot reload.
|
|
5
|
+
* Existing operator engraving and user-configuration contracts are unrelated.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
|
|
9
|
+
const TOOL_SPEC = {
|
|
10
|
+
entwurf_v2: { durable: true, parameters: ["target", "intent", "message", "mode", "wants_reply"] },
|
|
11
|
+
entwurf_self: { durable: true, parameters: [] },
|
|
12
|
+
entwurf_peers: { durable: true, parameters: [] },
|
|
13
|
+
entwurf_inbox_read: { durable: true, parameters: ["gardenId"] },
|
|
14
|
+
entwurf_register_native: { durable: false, parameters: ["backend", "nativeSessionId", "cwd"] },
|
|
15
|
+
entwurf_fresh_call: {
|
|
16
|
+
durable: true,
|
|
17
|
+
parameters: ["backend", "model", "task", "cwd", "placement.tmuxSession", "placement"],
|
|
18
|
+
},
|
|
19
|
+
entwurf_resume_call: { durable: true, parameters: ["target"] },
|
|
20
|
+
entwurf_retire_call: { durable: true, parameters: ["target"] },
|
|
21
|
+
entwurf_callback: { durable: true, parameters: [] },
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/** Frozen entwurf_v2 reject wire ids whose static next-step hint text lives in the root file. */
|
|
25
|
+
const REJECT_HINT_REASONS = [
|
|
26
|
+
"dormant-fire-forget-unsupported",
|
|
27
|
+
"indeterminate-no-spawn",
|
|
28
|
+
"native-push-target-dead",
|
|
29
|
+
"native-push-probe-indeterminate",
|
|
30
|
+
"native-push-paused",
|
|
31
|
+
] as const;
|
|
32
|
+
|
|
33
|
+
export type RejectHintReason = (typeof REJECT_HINT_REASONS)[number];
|
|
34
|
+
|
|
35
|
+
/** Frozen entwurf_resume_call record/liveness reject wire ids whose static hint text lives in the root file. */
|
|
36
|
+
const RESUME_REJECT_HINT_REASONS = [
|
|
37
|
+
"target-invalid",
|
|
38
|
+
"target-backend-unsupported",
|
|
39
|
+
"target-locked",
|
|
40
|
+
"target-live",
|
|
41
|
+
"target-indeterminate",
|
|
42
|
+
"target-receiver-absent",
|
|
43
|
+
"target-receiver-corrupt",
|
|
44
|
+
"target-receiver-mismatch",
|
|
45
|
+
"target-receiver-unbound",
|
|
46
|
+
"target-address-conflict",
|
|
47
|
+
"launch-refused",
|
|
48
|
+
] as const;
|
|
49
|
+
|
|
50
|
+
export type ResumeRejectHintReason = (typeof RESUME_REJECT_HINT_REASONS)[number];
|
|
51
|
+
|
|
52
|
+
/** Frozen entwurf_fresh_call tmux launch-stage reject wire ids whose static hint text lives in the root file. */
|
|
53
|
+
const FRESH_LAUNCH_REJECT_HINT_REASONS = [
|
|
54
|
+
"no-tmux-context",
|
|
55
|
+
"anchor-malformed",
|
|
56
|
+
"anchor-unresolved",
|
|
57
|
+
"anchor-mismatch",
|
|
58
|
+
"caller-identity-unavailable",
|
|
59
|
+
"cwd-not-absolute",
|
|
60
|
+
"cwd-format-token",
|
|
61
|
+
"cwd-missing",
|
|
62
|
+
"cwd-not-directory",
|
|
63
|
+
"tmux-session-name-invalid",
|
|
64
|
+
"tmux-session-missing",
|
|
65
|
+
"model-empty",
|
|
66
|
+
"task-empty",
|
|
67
|
+
"runtime-unresolved",
|
|
68
|
+
"runtime-not-absolute",
|
|
69
|
+
"runtime-path-whitespace",
|
|
70
|
+
"runtime-missing",
|
|
71
|
+
"runtime-not-regular-file",
|
|
72
|
+
"runtime-not-executable",
|
|
73
|
+
] as const;
|
|
74
|
+
|
|
75
|
+
export type FreshLaunchRejectHintReason = (typeof FRESH_LAUNCH_REJECT_HINT_REASONS)[number];
|
|
76
|
+
|
|
77
|
+
/** Frozen entwurf_resume_call tmux launch-stage reject wire ids whose static hint text lives in the root file. */
|
|
78
|
+
const RESUME_LAUNCH_REJECT_HINT_REASONS = [
|
|
79
|
+
"no-tmux-context",
|
|
80
|
+
"anchor-malformed",
|
|
81
|
+
"anchor-unresolved",
|
|
82
|
+
"anchor-mismatch",
|
|
83
|
+
"cwd-not-absolute",
|
|
84
|
+
"cwd-format-token",
|
|
85
|
+
"cwd-missing",
|
|
86
|
+
"cwd-not-directory",
|
|
87
|
+
"herdr-resume-unsupported",
|
|
88
|
+
"runtime-unresolved",
|
|
89
|
+
"runtime-not-absolute",
|
|
90
|
+
"runtime-path-whitespace",
|
|
91
|
+
"runtime-missing",
|
|
92
|
+
"runtime-not-regular-file",
|
|
93
|
+
"runtime-not-executable",
|
|
94
|
+
] as const;
|
|
95
|
+
|
|
96
|
+
export type ResumeLaunchRejectHintReason = (typeof RESUME_LAUNCH_REJECT_HINT_REASONS)[number];
|
|
97
|
+
|
|
98
|
+
/** Frozen keys of the static delivery-result clauses whose text lives in the root file; the
|
|
99
|
+
* receipts around them (syntax, branch conditions, slots, punctuation) stay code-owned. */
|
|
100
|
+
const DELIVERY_RESULT_CLAUSE_KEYS = [
|
|
101
|
+
"finalized-rejected",
|
|
102
|
+
"dirty-lock",
|
|
103
|
+
"remote-accepted",
|
|
104
|
+
"remote-reported-error",
|
|
105
|
+
"remote-indeterminate",
|
|
106
|
+
] as const;
|
|
107
|
+
|
|
108
|
+
export type DeliveryResultClauseKey = (typeof DELIVERY_RESULT_CLAUSE_KEYS)[number];
|
|
109
|
+
|
|
110
|
+
/** Frozen wire ids of the reject hints whose authored text sits on either side of ONE code-owned
|
|
111
|
+
* slot, and each one's exact segment keys. The slot value, the reason branch and the
|
|
112
|
+
* concatenation stay code-owned; the root file holds only the text around the slot. */
|
|
113
|
+
const SLOTTED_REJECT_HINT_SEGMENTS = {
|
|
114
|
+
"record-less-socket": ["beforeFreshCutPrescription", "afterFreshCutPrescription"],
|
|
115
|
+
} as const;
|
|
116
|
+
|
|
117
|
+
export type SlottedRejectHintReason = keyof typeof SLOTTED_REJECT_HINT_SEGMENTS;
|
|
118
|
+
type SlottedRejectHints = {
|
|
119
|
+
readonly [R in SlottedRejectHintReason]: Readonly<Record<(typeof SLOTTED_REJECT_HINT_SEGMENTS)[R][number], string>>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
type ToolName = keyof typeof TOOL_SPEC;
|
|
123
|
+
type ToolGuidance<K extends ToolName> = {
|
|
124
|
+
readonly descriptions: (typeof TOOL_SPEC)[K]["durable"] extends true
|
|
125
|
+
? { readonly mcp: string; readonly durable: string }
|
|
126
|
+
: { readonly mcp: string };
|
|
127
|
+
readonly parameters: Readonly<Record<(typeof TOOL_SPEC)[K]["parameters"][number], string>>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export interface EntwurfGuidance {
|
|
131
|
+
readonly _about: Readonly<Record<"purpose" | "ownership" | "scope" | "editing", string>>;
|
|
132
|
+
readonly schemaVersion: 6;
|
|
133
|
+
readonly revision: number;
|
|
134
|
+
readonly history: readonly {
|
|
135
|
+
readonly revision: number;
|
|
136
|
+
readonly source: string;
|
|
137
|
+
readonly issue: string;
|
|
138
|
+
readonly change: string;
|
|
139
|
+
}[];
|
|
140
|
+
readonly tools: { readonly [K in ToolName]: ToolGuidance<K> };
|
|
141
|
+
readonly rejectHints: Readonly<Record<RejectHintReason, string>>;
|
|
142
|
+
readonly resumeRejectHints: Readonly<Record<ResumeRejectHintReason, string>>;
|
|
143
|
+
readonly freshLaunchRejectHints: Readonly<Record<FreshLaunchRejectHintReason, string>>;
|
|
144
|
+
readonly resumeLaunchRejectHints: Readonly<Record<ResumeLaunchRejectHintReason, string>>;
|
|
145
|
+
readonly deliveryResultClauses: Readonly<Record<DeliveryResultClauseKey, string>>;
|
|
146
|
+
readonly slottedRejectHints: SlottedRejectHints;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function record(value: unknown, at: string): asserts value is Record<string, unknown> {
|
|
150
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
151
|
+
throw new Error(`ENTWURF.json ${at}: expected an object`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function keys(value: Record<string, unknown>, expected: readonly string[], at: string): void {
|
|
156
|
+
const actual = Object.keys(value).sort();
|
|
157
|
+
const wanted = [...expected].sort();
|
|
158
|
+
if (actual.length !== wanted.length || actual.some((key, i) => key !== wanted[i])) {
|
|
159
|
+
throw new Error(`ENTWURF.json ${at}: keys must be exactly ${wanted.join(", ")}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function text(value: unknown, at: string): void {
|
|
164
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
165
|
+
throw new Error(`ENTWURF.json ${at}: expected a non-empty string`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* JSON.parse owns strict grammar, but its last-key-wins value is never enough.
|
|
171
|
+
* Walk the ORIGINAL, already grammar-checked tokens and reject duplicate DECODED
|
|
172
|
+
* object keys before returning data. Object scopes are independent; strings that
|
|
173
|
+
* are values (including punctuation and escaped quotes) are never key tokens.
|
|
174
|
+
*/
|
|
175
|
+
function rejectDuplicateKeys(source: string): void {
|
|
176
|
+
let pos = 0;
|
|
177
|
+
const space = (): void => {
|
|
178
|
+
while (pos < source.length && /[\x20\t\r\n]/.test(source[pos])) pos++;
|
|
179
|
+
};
|
|
180
|
+
const string = (): string => {
|
|
181
|
+
const start = pos++;
|
|
182
|
+
while (pos < source.length) {
|
|
183
|
+
if (source[pos] === "\\") pos += 2;
|
|
184
|
+
else if (source[pos++] === '"') return JSON.parse(source.slice(start, pos)) as string;
|
|
185
|
+
}
|
|
186
|
+
throw new Error("ENTWURF.json: unterminated string");
|
|
187
|
+
};
|
|
188
|
+
const value = (): void => {
|
|
189
|
+
space();
|
|
190
|
+
if (source[pos] === "{") {
|
|
191
|
+
pos++;
|
|
192
|
+
space();
|
|
193
|
+
const seen = new Set<string>();
|
|
194
|
+
if (source[pos] !== "}") {
|
|
195
|
+
for (;;) {
|
|
196
|
+
space();
|
|
197
|
+
const key = string();
|
|
198
|
+
if (seen.has(key)) throw new Error(`ENTWURF.json: duplicate object key ${JSON.stringify(key)}`);
|
|
199
|
+
seen.add(key);
|
|
200
|
+
space();
|
|
201
|
+
pos++; // colon; JSON.parse already certified the grammar
|
|
202
|
+
value();
|
|
203
|
+
space();
|
|
204
|
+
if (source[pos] !== ",") break;
|
|
205
|
+
pos++;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
pos++;
|
|
209
|
+
} else if (source[pos] === "[") {
|
|
210
|
+
pos++;
|
|
211
|
+
space();
|
|
212
|
+
if (source[pos] !== "]") {
|
|
213
|
+
for (;;) {
|
|
214
|
+
value();
|
|
215
|
+
space();
|
|
216
|
+
if (source[pos] !== ",") break;
|
|
217
|
+
pos++;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
pos++;
|
|
221
|
+
} else if (source[pos] === '"') {
|
|
222
|
+
string();
|
|
223
|
+
} else {
|
|
224
|
+
while (pos < source.length && !/[\x20\t\r\n,}\]]/.test(source[pos])) pos++;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
value();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function freeze(value: unknown): void {
|
|
231
|
+
if (value === null || typeof value !== "object") return;
|
|
232
|
+
for (const child of Object.values(value)) freeze(child);
|
|
233
|
+
Object.freeze(value);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Pure data-validation seam; production always reads the one fixed module URL below. */
|
|
237
|
+
export function parseEntwurfGuidance(source: string): EntwurfGuidance {
|
|
238
|
+
const data: unknown = JSON.parse(source);
|
|
239
|
+
rejectDuplicateKeys(source);
|
|
240
|
+
record(data, "root");
|
|
241
|
+
if (data.schemaVersion !== 6) throw new Error("ENTWURF.json: unsupported schemaVersion");
|
|
242
|
+
keys(
|
|
243
|
+
data,
|
|
244
|
+
[
|
|
245
|
+
"_about",
|
|
246
|
+
"schemaVersion",
|
|
247
|
+
"revision",
|
|
248
|
+
"history",
|
|
249
|
+
"tools",
|
|
250
|
+
"rejectHints",
|
|
251
|
+
"resumeRejectHints",
|
|
252
|
+
"freshLaunchRejectHints",
|
|
253
|
+
"resumeLaunchRejectHints",
|
|
254
|
+
"deliveryResultClauses",
|
|
255
|
+
"slottedRejectHints",
|
|
256
|
+
],
|
|
257
|
+
"root",
|
|
258
|
+
);
|
|
259
|
+
if (!Number.isSafeInteger(data.revision) || (data.revision as number) < 1) {
|
|
260
|
+
throw new Error("ENTWURF.json: revision must be a positive safe integer");
|
|
261
|
+
}
|
|
262
|
+
record(data._about, "_about");
|
|
263
|
+
keys(data._about, ["purpose", "ownership", "scope", "editing"], "_about");
|
|
264
|
+
for (const [key, value] of Object.entries(data._about)) text(value, `_about.${key}`);
|
|
265
|
+
if (!Array.isArray(data.history) || data.history.length === 0) {
|
|
266
|
+
throw new Error("ENTWURF.json: history must be a non-empty array");
|
|
267
|
+
}
|
|
268
|
+
for (const entry of data.history) {
|
|
269
|
+
record(entry, "history entry");
|
|
270
|
+
keys(entry, ["revision", "source", "issue", "change"], "history entry");
|
|
271
|
+
if (
|
|
272
|
+
!Number.isSafeInteger(entry.revision) ||
|
|
273
|
+
(entry.revision as number) < 1 ||
|
|
274
|
+
(entry.revision as number) > (data.revision as number)
|
|
275
|
+
) {
|
|
276
|
+
throw new Error("ENTWURF.json: history revision must name an existing payload revision");
|
|
277
|
+
}
|
|
278
|
+
for (const key of ["source", "issue", "change"] as const) text(entry[key], `history.${key}`);
|
|
279
|
+
}
|
|
280
|
+
record(data.tools, "tools");
|
|
281
|
+
keys(data.tools, Object.keys(TOOL_SPEC), "tools");
|
|
282
|
+
for (const name of Object.keys(TOOL_SPEC) as ToolName[]) {
|
|
283
|
+
const tool = data.tools[name];
|
|
284
|
+
record(tool, name);
|
|
285
|
+
keys(tool, ["descriptions", "parameters"], name);
|
|
286
|
+
record(tool.descriptions, `${name}.descriptions`);
|
|
287
|
+
keys(tool.descriptions, TOOL_SPEC[name].durable ? ["mcp", "durable"] : ["mcp"], `${name}.descriptions`);
|
|
288
|
+
for (const [rail, value] of Object.entries(tool.descriptions)) text(value, `${name}.descriptions.${rail}`);
|
|
289
|
+
record(tool.parameters, `${name}.parameters`);
|
|
290
|
+
keys(tool.parameters, TOOL_SPEC[name].parameters, `${name}.parameters`);
|
|
291
|
+
for (const [field, value] of Object.entries(tool.parameters)) text(value, `${name}.parameters.${field}`);
|
|
292
|
+
}
|
|
293
|
+
record(data.rejectHints, "rejectHints");
|
|
294
|
+
keys(data.rejectHints, REJECT_HINT_REASONS, "rejectHints");
|
|
295
|
+
for (const [reason, value] of Object.entries(data.rejectHints)) text(value, `rejectHints.${reason}`);
|
|
296
|
+
record(data.resumeRejectHints, "resumeRejectHints");
|
|
297
|
+
keys(data.resumeRejectHints, RESUME_REJECT_HINT_REASONS, "resumeRejectHints");
|
|
298
|
+
for (const [reason, value] of Object.entries(data.resumeRejectHints)) text(value, `resumeRejectHints.${reason}`);
|
|
299
|
+
record(data.freshLaunchRejectHints, "freshLaunchRejectHints");
|
|
300
|
+
keys(data.freshLaunchRejectHints, FRESH_LAUNCH_REJECT_HINT_REASONS, "freshLaunchRejectHints");
|
|
301
|
+
for (const [reason, value] of Object.entries(data.freshLaunchRejectHints))
|
|
302
|
+
text(value, `freshLaunchRejectHints.${reason}`);
|
|
303
|
+
record(data.resumeLaunchRejectHints, "resumeLaunchRejectHints");
|
|
304
|
+
keys(data.resumeLaunchRejectHints, RESUME_LAUNCH_REJECT_HINT_REASONS, "resumeLaunchRejectHints");
|
|
305
|
+
for (const [reason, value] of Object.entries(data.resumeLaunchRejectHints))
|
|
306
|
+
text(value, `resumeLaunchRejectHints.${reason}`);
|
|
307
|
+
record(data.deliveryResultClauses, "deliveryResultClauses");
|
|
308
|
+
keys(data.deliveryResultClauses, DELIVERY_RESULT_CLAUSE_KEYS, "deliveryResultClauses");
|
|
309
|
+
for (const [key, value] of Object.entries(data.deliveryResultClauses)) text(value, `deliveryResultClauses.${key}`);
|
|
310
|
+
record(data.slottedRejectHints, "slottedRejectHints");
|
|
311
|
+
keys(data.slottedRejectHints, Object.keys(SLOTTED_REJECT_HINT_SEGMENTS), "slottedRejectHints");
|
|
312
|
+
for (const reason of Object.keys(SLOTTED_REJECT_HINT_SEGMENTS) as SlottedRejectHintReason[]) {
|
|
313
|
+
const segments = data.slottedRejectHints[reason];
|
|
314
|
+
record(segments, `slottedRejectHints.${reason}`);
|
|
315
|
+
keys(segments, SLOTTED_REJECT_HINT_SEGMENTS[reason], `slottedRejectHints.${reason}`);
|
|
316
|
+
for (const [key, value] of Object.entries(segments)) text(value, `slottedRejectHints.${reason}.${key}`);
|
|
317
|
+
}
|
|
318
|
+
freeze(data);
|
|
319
|
+
return data as unknown as EntwurfGuidance;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const guidance = parseEntwurfGuidance(readFileSync(new URL("../../ENTWURF.json", import.meta.url), "utf8"));
|
|
323
|
+
|
|
324
|
+
/** Only these exact payload strings enter tool schemas; _about/history never do. */
|
|
325
|
+
export const ENTWURF_TOOL_GUIDANCE = guidance.tools;
|
|
326
|
+
/** Static next-step text appended to these entwurf_v2 rejections; the decider and wire ids stay code-owned. */
|
|
327
|
+
export const ENTWURF_REJECT_HINTS = guidance.rejectHints;
|
|
328
|
+
/** Static next-step text in these entwurf_resume_call record/liveness rejections; the verb and the shared ACP model hint stay code-owned. */
|
|
329
|
+
export const ENTWURF_RESUME_REJECT_HINTS = guidance.resumeRejectHints;
|
|
330
|
+
/** Static tmux launch-stage hints of entwurf_fresh_call; slot-bearing, ACP and preflight-leaf hints stay code-owned. */
|
|
331
|
+
export const ENTWURF_FRESH_LAUNCH_REJECT_HINTS = guidance.freshLaunchRejectHints;
|
|
332
|
+
/** Static tmux launch-stage hints of entwurf_resume_call, kept apart from the fresh verb even where the text matches. */
|
|
333
|
+
export const ENTWURF_RESUME_LAUNCH_REJECT_HINTS = guidance.resumeLaunchRejectHints;
|
|
334
|
+
/** Static delivery-result clauses of the entwurf_v2 dirty-lock and remote-pair receipts; the receipt syntax around them stays code-owned. */
|
|
335
|
+
export const ENTWURF_DELIVERY_RESULT_CLAUSES = guidance.deliveryResultClauses;
|
|
336
|
+
/** Text on either side of one code-owned slot per reject reason; the slot value and the concatenation stay with the consumer. */
|
|
337
|
+
export const ENTWURF_SLOTTED_REJECT_HINTS = guidance.slottedRejectHints;
|
|
338
|
+
export const ENTWURF_GUIDANCE_VERSION = Object.freeze({
|
|
339
|
+
schemaVersion: guidance.schemaVersion,
|
|
340
|
+
revision: guidance.revision,
|
|
341
|
+
});
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { basename } from "node:path";
|
|
21
|
+
import {
|
|
22
|
+
ENTWURF_DELIVERY_RESULT_CLAUSES,
|
|
23
|
+
ENTWURF_REJECT_HINTS,
|
|
24
|
+
ENTWURF_SLOTTED_REJECT_HINTS,
|
|
25
|
+
} from "./agent-guidance.ts";
|
|
21
26
|
import type { SenderEnvelope } from "./entwurf-control-rpc.ts";
|
|
22
27
|
import type { DispatchInput, EntwurfV2Mode } from "./entwurf-v2-decider.ts";
|
|
23
28
|
import { makeProductionEntwurfV2Deps, type ProductionEntwurfV2Opts } from "./entwurf-v2-production.ts";
|
|
@@ -65,7 +70,9 @@ export function toDispatchInput(params: SurfaceEntwurfV2Params): DispatchInput {
|
|
|
65
70
|
* Detour B (B-a) — actionable rendering of an honest reject. The decider is UNCHANGED:
|
|
66
71
|
* a reject stays a reject (Hard Rule 3). This only appends a one-line "what to do instead"
|
|
67
72
|
* to the reject TEXT, so an honest reject stops reading as "delivery impossible". Returns
|
|
68
|
-
* undefined for rejects with no useful next step.
|
|
73
|
+
* undefined for rejects with no useful next step. Hint English is authored in root ENTWURF.json
|
|
74
|
+
* (#154); the reason switch stays here, and so do the record-less-socket slot value and its
|
|
75
|
+
* concatenation (#154 E1b).
|
|
69
76
|
*/
|
|
70
77
|
export function actionableRejectHint(reason: string): string | undefined {
|
|
71
78
|
switch (reason) {
|
|
@@ -74,13 +81,7 @@ export function actionableRejectHint(reason: string): string | undefined {
|
|
|
74
81
|
// state — the citizen exists and is not running — matters more than ever now that
|
|
75
82
|
// there is no verb behind it: a caller that reads "reject" as "wrong id" goes
|
|
76
83
|
// looking in the wrong place.
|
|
77
|
-
return
|
|
78
|
-
"this citizen's record is intact but its session is not running, and delivery has no way to wake it. " +
|
|
79
|
-
"The resume that used to answer here launched a hidden background child and was withdrawn under the " +
|
|
80
|
-
"visible-first rule; the visible same-id resume is the separate lifecycle verb entwurf_resume_call. " +
|
|
81
|
-
"Only on an explicit operator request, use entwurf_resume_call {target} for Pi or Claude Code; " +
|
|
82
|
-
"it submits no prompt. This capability hint is not permission to resume automatically."
|
|
83
|
-
);
|
|
84
|
+
return ENTWURF_REJECT_HINTS["dormant-fire-forget-unsupported"];
|
|
84
85
|
case "indeterminate-no-spawn":
|
|
85
86
|
// The socket probe did not settle, so liveness is UNKNOWN — an unestablished probe
|
|
86
87
|
// is not a measured death, and dispatching into it could double-deliver. Say
|
|
@@ -91,35 +92,27 @@ export function actionableRejectHint(reason: string): string | undefined {
|
|
|
91
92
|
// (never dispatch into an indeterminate target), not a capability that still
|
|
92
93
|
// exists. So the hint's job is to say plainly what did NOT happen: nothing
|
|
93
94
|
// delivered, nothing started.
|
|
94
|
-
return
|
|
95
|
-
"the control-socket probe was inconclusive, so the target's liveness is UNKNOWN — this is not a " +
|
|
96
|
-
"measured death. NOTHING was delivered and NO process was started (the reason id keeps its frozen " +
|
|
97
|
-
"'-no-spawn' wire spelling from an era when one could be; entwurf_v2 starts nothing on any rail). " +
|
|
98
|
-
"Re-run entwurf_peers to re-probe; if it stays indeterminate, check for a stale socket file left at " +
|
|
99
|
-
"that garden id by a session that died without cleaning up."
|
|
100
|
-
);
|
|
95
|
+
return ENTWURF_REJECT_HINTS["indeterminate-no-spawn"];
|
|
101
96
|
case "native-push-target-dead":
|
|
102
97
|
// The adapter probe found no live native host serving this conversation/thread. Stays
|
|
103
98
|
// backend-neutral: agy speaks conversations over an LS port, Codex threads over an
|
|
104
99
|
// app-server socket, and this hint is read by callers of both.
|
|
105
|
-
return "
|
|
100
|
+
return ENTWURF_REJECT_HINTS["native-push-target-dead"];
|
|
106
101
|
case "native-push-probe-indeterminate":
|
|
107
102
|
// Native host up, but nothing served this conversation/thread — inconclusive, not a
|
|
108
103
|
// hard dead. Backend-neutral for the same reason as the dead cell above.
|
|
109
|
-
return "
|
|
104
|
+
return ENTWURF_REJECT_HINTS["native-push-probe-indeterminate"];
|
|
110
105
|
case "native-push-paused":
|
|
111
106
|
// #152: a policy refusal, not a liveness verdict — this dispatch probed and sent nothing.
|
|
112
|
-
return "native-push
|
|
113
|
-
case "record-less-socket":
|
|
107
|
+
return ENTWURF_REJECT_HINTS["native-push-paused"];
|
|
108
|
+
case "record-less-socket": {
|
|
114
109
|
// #50 C4: name the true cause AND the fix — a bare socket is a diagnostic
|
|
115
|
-
// state, not an addressable citizen (the record is the address).
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
`${FRESH_CUT_PRESCRIPTION}. A stale/forged socket should be removed.`
|
|
122
|
-
);
|
|
110
|
+
// state, not an addressable citizen (the record is the address). The text on either
|
|
111
|
+
// side of the fix command is authored in root ENTWURF.json; the command itself stays
|
|
112
|
+
// with its owner (meta-session.ts), so the root file never copies it.
|
|
113
|
+
const hint = ENTWURF_SLOTTED_REJECT_HINTS["record-less-socket"];
|
|
114
|
+
return `${hint.beforeFreshCutPrescription}${FRESH_CUT_PRESCRIPTION}${hint.afterFreshCutPrescription}`;
|
|
115
|
+
}
|
|
123
116
|
default:
|
|
124
117
|
return undefined;
|
|
125
118
|
}
|
|
@@ -221,17 +214,18 @@ export function renderEntwurfV2Result(result: EntwurfV2RunResult): EntwurfV2Surf
|
|
|
221
214
|
// the same acceptance vocabulary the ordinary receipt uses is named here too — a
|
|
222
215
|
// dirty lock is a reason to be MORE precise about what happened, not less, because
|
|
223
216
|
// the operator is about to decide by hand whether anything needs re-sending.
|
|
217
|
+
// The two static clauses are authored in root ENTWURF.json (#154 E1a); this receipt's
|
|
218
|
+
// syntax, branches and slots stay here.
|
|
224
219
|
const what =
|
|
225
220
|
result.finalizedOutcome === "rejected"
|
|
226
|
-
? `rejected${result.finalizedRejectReason ? ` (${result.finalizedRejectReason})` : ""} —
|
|
221
|
+
? `rejected${result.finalizedRejectReason ? ` (${result.finalizedRejectReason})` : ""} — ${ENTWURF_DELIVERY_RESULT_CLAUSES["finalized-rejected"]}`
|
|
227
222
|
: `${result.finalizedBoundary ?? "mailbox-enqueued"}${
|
|
228
223
|
result.finalizedMessagePath ? ` (enqueued ${basename(result.finalizedMessagePath)})` : ""
|
|
229
224
|
}`;
|
|
230
225
|
return {
|
|
231
226
|
text:
|
|
232
|
-
`entwurf_v2 ${result.transport} finalized as ${what}, and
|
|
233
|
-
|
|
234
|
-
`\n error: ${result.error}`,
|
|
227
|
+
`entwurf_v2 ${result.transport} finalized as ${what}, and ` +
|
|
228
|
+
`${ENTWURF_DELIVERY_RESULT_CLAUSES["dirty-lock"]}\n error: ${result.error}`,
|
|
235
229
|
isError: true,
|
|
236
230
|
};
|
|
237
231
|
}
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
*/
|
|
75
75
|
|
|
76
76
|
import { ACP_MODEL_NOT_CURATED_HINT, AcpModelNotCuratedError } from "./acp/model-ids.js";
|
|
77
|
+
import { ENTWURF_RESUME_REJECT_HINTS } from "./agent-guidance.ts";
|
|
77
78
|
import { buildResumePiArgs } from "./entwurf-resume-args.ts";
|
|
78
79
|
import {
|
|
79
80
|
type AcquireLockResult,
|
|
@@ -633,24 +634,22 @@ export async function observeSameGidSocket(
|
|
|
633
634
|
}
|
|
634
635
|
}
|
|
635
636
|
|
|
637
|
+
// The static record/liveness hint text is authored in root ENTWURF.json (#154 C1-C); the reasons,
|
|
638
|
+
// this total table and the renderer stay here. acp-model-not-curated keeps the shared ACP constant,
|
|
639
|
+
// and the launch-stage mux hints folded into `detail` stay behind the mux import fence.
|
|
636
640
|
const REJECT_HINT: Record<VisibleResumeRejectReason, string> = {
|
|
637
|
-
"target-invalid": "
|
|
638
|
-
"target-backend-unsupported":
|
|
639
|
-
"that citizen's backend has no same-id resume (only pi and Claude Code do) — reach it with entwurf_v2, or open a fresh sibling",
|
|
641
|
+
"target-invalid": ENTWURF_RESUME_REJECT_HINTS["target-invalid"],
|
|
642
|
+
"target-backend-unsupported": ENTWURF_RESUME_REJECT_HINTS["target-backend-unsupported"],
|
|
640
643
|
"acp-model-not-curated": ACP_MODEL_NOT_CURATED_HINT,
|
|
641
|
-
"target-locked": "
|
|
642
|
-
"target-live": "
|
|
643
|
-
"target-indeterminate":
|
|
644
|
-
|
|
645
|
-
"target-receiver-
|
|
646
|
-
|
|
647
|
-
"target-receiver-
|
|
648
|
-
"target-
|
|
649
|
-
|
|
650
|
-
"target-receiver-unbound":
|
|
651
|
-
"the dead receiver owner is not bound to the record's last arm (none observed, a later attach, or the record moved), so a Claude Code process may still hold the session — if its window is closed, reopen it yourself",
|
|
652
|
-
"target-address-conflict": "that citizen's control-socket path is corrupt",
|
|
653
|
-
"launch-refused": "tmux was never asked to open a window",
|
|
644
|
+
"target-locked": ENTWURF_RESUME_REJECT_HINTS["target-locked"],
|
|
645
|
+
"target-live": ENTWURF_RESUME_REJECT_HINTS["target-live"],
|
|
646
|
+
"target-indeterminate": ENTWURF_RESUME_REJECT_HINTS["target-indeterminate"],
|
|
647
|
+
"target-receiver-absent": ENTWURF_RESUME_REJECT_HINTS["target-receiver-absent"],
|
|
648
|
+
"target-receiver-corrupt": ENTWURF_RESUME_REJECT_HINTS["target-receiver-corrupt"],
|
|
649
|
+
"target-receiver-mismatch": ENTWURF_RESUME_REJECT_HINTS["target-receiver-mismatch"],
|
|
650
|
+
"target-receiver-unbound": ENTWURF_RESUME_REJECT_HINTS["target-receiver-unbound"],
|
|
651
|
+
"target-address-conflict": ENTWURF_RESUME_REJECT_HINTS["target-address-conflict"],
|
|
652
|
+
"launch-refused": ENTWURF_RESUME_REJECT_HINTS["launch-refused"],
|
|
654
653
|
};
|
|
655
654
|
|
|
656
655
|
/**
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
89
|
import { ACP_MODEL_NOT_CURATED_HINT } from "./acp/model-ids.js";
|
|
90
|
+
import { ENTWURF_FRESH_LAUNCH_REJECT_HINTS } from "./agent-guidance.ts";
|
|
90
91
|
import { callbackEnvAssignments } from "./callback-env.ts";
|
|
91
92
|
import { classifyTmuxCwd, type TmuxCwdRejectReason } from "./classify-tmux-cwd.ts";
|
|
92
93
|
import {
|
|
@@ -629,7 +630,9 @@ export function freshCall(
|
|
|
629
630
|
}
|
|
630
631
|
|
|
631
632
|
/** Why each refusal happened, in the caller's terms. A reason a caller cannot act on is a reason
|
|
632
|
-
* they will guess about.
|
|
633
|
+
* they will guess about. The static tmux launch-stage text is authored in root
|
|
634
|
+
* ENTWURF.json (#154 C1-D) and bound key by key, never spread, so a duplicate or missing reason
|
|
635
|
+
* still fails typecheck; slot-bearing, ACP and preflight-leaf hints stay code-owned. */
|
|
633
636
|
const REJECT_HINT: Record<FreshCallRejectReason, string> = {
|
|
634
637
|
// The Copilot capability reasons keep their repair text on the leaf that decides them, so
|
|
635
638
|
// the sentence an operator reads cannot drift away from the predicate that produced it.
|
|
@@ -641,34 +644,28 @@ const REJECT_HINT: Record<FreshCallRejectReason, string> = {
|
|
|
641
644
|
...CODEX_CALLER_PREFLIGHT_HINT,
|
|
642
645
|
...CODEX_CALLER_SEAT_HINT,
|
|
643
646
|
...FRESH_CALL_PROVIDER_HINT,
|
|
644
|
-
"no-tmux-context": "
|
|
645
|
-
"anchor-malformed": "
|
|
646
|
-
"anchor-unresolved": "
|
|
647
|
-
"anchor-mismatch": "
|
|
648
|
-
"caller-identity-unavailable":
|
|
649
|
-
|
|
650
|
-
"cwd-
|
|
651
|
-
|
|
652
|
-
"cwd-
|
|
653
|
-
|
|
654
|
-
"
|
|
655
|
-
|
|
656
|
-
"cwd-not-directory": "the requested cwd exists but is not a directory",
|
|
657
|
-
"tmux-session-name-invalid":
|
|
658
|
-
"the requested tmux session name is outside the shape this rail addresses (start with a letter or digit, then letters, digits, '_' or '-') — some other shapes tmux cannot resolve at all ('#' is expanded when the name is stored; '.' and ':' are its own pane/window separators inside a target; a name like '$0' loses to the session id '$0'), and the rest are declined to keep one narrow grammar, so rename the session or open one whose name fits",
|
|
659
|
-
"tmux-session-missing":
|
|
660
|
-
"no session with that exact name answers on this agent's tmux server (or that server stopped answering) — nothing was created, so open the session yourself and call again",
|
|
661
|
-
"model-empty": "model is empty after trimming; fresh calls require an explicit model",
|
|
647
|
+
"no-tmux-context": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["no-tmux-context"],
|
|
648
|
+
"anchor-malformed": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["anchor-malformed"],
|
|
649
|
+
"anchor-unresolved": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["anchor-unresolved"],
|
|
650
|
+
"anchor-mismatch": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["anchor-mismatch"],
|
|
651
|
+
"caller-identity-unavailable": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["caller-identity-unavailable"],
|
|
652
|
+
"cwd-not-absolute": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["cwd-not-absolute"],
|
|
653
|
+
"cwd-format-token": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["cwd-format-token"],
|
|
654
|
+
"cwd-missing": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["cwd-missing"],
|
|
655
|
+
"cwd-not-directory": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["cwd-not-directory"],
|
|
656
|
+
"tmux-session-name-invalid": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["tmux-session-name-invalid"],
|
|
657
|
+
"tmux-session-missing": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["tmux-session-missing"],
|
|
658
|
+
"model-empty": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["model-empty"],
|
|
662
659
|
"model-invalid": `model must be one ${MODEL_MAX_CHARS}-character argv-safe id/alias without whitespace or tmux syntax`,
|
|
663
660
|
"acp-model-not-curated": ACP_MODEL_NOT_CURATED_HINT,
|
|
664
|
-
"task-empty": "task
|
|
661
|
+
"task-empty": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["task-empty"],
|
|
665
662
|
"task-too-long": `task exceeds ${TASK_MAX_CHARS} characters`,
|
|
666
|
-
"runtime-unresolved": "
|
|
667
|
-
"runtime-not-absolute": "
|
|
668
|
-
"runtime-path-whitespace": "
|
|
669
|
-
"runtime-missing": "
|
|
670
|
-
"runtime-not-regular-file": "
|
|
671
|
-
"runtime-not-executable": "
|
|
663
|
+
"runtime-unresolved": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["runtime-unresolved"],
|
|
664
|
+
"runtime-not-absolute": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["runtime-not-absolute"],
|
|
665
|
+
"runtime-path-whitespace": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["runtime-path-whitespace"],
|
|
666
|
+
"runtime-missing": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["runtime-missing"],
|
|
667
|
+
"runtime-not-regular-file": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["runtime-not-regular-file"],
|
|
668
|
+
"runtime-not-executable": ENTWURF_FRESH_LAUNCH_REJECT_HINTS["runtime-not-executable"],
|
|
672
669
|
};
|
|
673
670
|
|
|
674
671
|
/**
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
* to acceptance, not to the product's launch receipt.
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
+
import { ENTWURF_RESUME_LAUNCH_REJECT_HINTS } from "./agent-guidance.ts";
|
|
52
53
|
import { classifyTmuxCwd, type TmuxCwdRejectReason } from "./classify-tmux-cwd.ts";
|
|
53
54
|
import {
|
|
54
55
|
assertLaunchTarget,
|
|
@@ -187,24 +188,22 @@ export function resumeCall(
|
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
/** Why each refusal happened, in the caller's terms. A reason a caller cannot act on is a reason
|
|
190
|
-
* they will guess about.
|
|
191
|
+
* they will guess about. The text is authored in root ENTWURF.json (#154 C1-D); each
|
|
192
|
+
* key is bound explicitly so the reason union stays exhaustive here. */
|
|
191
193
|
export const RESUME_CALL_REJECT_HINT: Record<ResumeCallRejectReason, string> = {
|
|
192
|
-
"no-tmux-context": "
|
|
193
|
-
"anchor-malformed": "
|
|
194
|
-
"anchor-unresolved": "
|
|
195
|
-
"anchor-mismatch": "
|
|
196
|
-
"cwd-not-absolute": "
|
|
197
|
-
"cwd-format-token":
|
|
198
|
-
|
|
199
|
-
"cwd-
|
|
200
|
-
|
|
201
|
-
"
|
|
202
|
-
"
|
|
203
|
-
|
|
204
|
-
"runtime-
|
|
205
|
-
"runtime-not-
|
|
206
|
-
"runtime-
|
|
207
|
-
"runtime-missing": "nothing exists at the resolved runtime path",
|
|
208
|
-
"runtime-not-regular-file": "the resolved runtime path is not a regular file",
|
|
209
|
-
"runtime-not-executable": "the resolved runtime path is not executable",
|
|
194
|
+
"no-tmux-context": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["no-tmux-context"],
|
|
195
|
+
"anchor-malformed": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["anchor-malformed"],
|
|
196
|
+
"anchor-unresolved": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["anchor-unresolved"],
|
|
197
|
+
"anchor-mismatch": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["anchor-mismatch"],
|
|
198
|
+
"cwd-not-absolute": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["cwd-not-absolute"],
|
|
199
|
+
"cwd-format-token": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["cwd-format-token"],
|
|
200
|
+
"cwd-missing": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["cwd-missing"],
|
|
201
|
+
"cwd-not-directory": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["cwd-not-directory"],
|
|
202
|
+
"herdr-resume-unsupported": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["herdr-resume-unsupported"],
|
|
203
|
+
"runtime-unresolved": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["runtime-unresolved"],
|
|
204
|
+
"runtime-not-absolute": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["runtime-not-absolute"],
|
|
205
|
+
"runtime-path-whitespace": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["runtime-path-whitespace"],
|
|
206
|
+
"runtime-missing": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["runtime-missing"],
|
|
207
|
+
"runtime-not-regular-file": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["runtime-not-regular-file"],
|
|
208
|
+
"runtime-not-executable": ENTWURF_RESUME_LAUNCH_REJECT_HINTS["runtime-not-executable"],
|
|
210
209
|
};
|