@akagilnc/pi-workflow-roles 0.1.5478 → 0.1.5504
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/acp-host/production-host.js +4945 -4980
- package/dist/analyst-gate-cycles-read.js +11 -29
- package/dist/analyst-ledger.js +10 -12
- package/dist/archivist-record-entry.js +4 -3
- package/dist/archivist-record-pointer.js +59 -32
- package/dist/atomic-write.js +2 -2
- package/dist/auditor-dossier-tool.js +8 -4
- package/dist/auditor-soul.js +2 -1
- package/dist/collector-config.js +6 -5
- package/dist/doctor-evidence.js +5 -1
- package/dist/engine-detour-usage.js +4 -10
- package/dist/headless-host/description.js +251 -0
- package/dist/headless-host/production-host.js +2787 -2658
- package/dist/ledger-session-read.js +5 -0
- package/dist/migrate-book-topology.js +129 -100
- package/dist/navigator-public-session.js +13 -17
- package/dist/notary-source-run.js +7 -15
- package/dist/packaged-role-registry.js +0 -12
- package/dist/pi/durable-principal.js +2 -3
- package/dist/pi/role-turn-host.js +27 -13
- package/dist/public-cli/instruction-seat-run.js +4 -4
- package/dist/public-cli/invocation.js +17 -45
- package/dist/public-cli/main.js +1074 -1085
- package/dist/public-cli/run-lifecycle.js +17 -47
- package/dist/public-cli/settlement.js +28 -128
- package/dist/public-cli/terminal.js +0 -12
- package/dist/role-run-placement.js +52 -5
- package/dist/role-run-relocation.js +39 -2
- package/dist/run-terminal-artifacts.js +2 -6
- package/dist/run-ticket-number.js +33 -4
- package/dist/session-assistant-usage.js +9 -18
- package/dist/session-identity.js +3 -4
- package/dist/sitian-appender.js +20 -6
- package/dist/submission-ledger.js +4 -4
- package/dist/ticket-provenance-contracts.js +2 -8
- package/dist/ticket-provenance.js +5 -4
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +2 -2
- package/src/analyst-gate-cycles-read.ts +11 -34
- package/src/analyst-ledger.ts +14 -14
- package/src/archivist-record-entry.ts +4 -3
- package/src/archivist-record-pointer.ts +70 -34
- package/src/atomic-write.ts +3 -1
- package/src/auditor-dossier-tool.ts +8 -4
- package/src/auditor-soul.ts +2 -1
- package/src/collector-config.ts +5 -3
- package/src/doctor-evidence.ts +5 -1
- package/src/engine-detour-usage.ts +10 -13
- package/src/factory-board.ts +16 -81
- package/src/headless-host/description.ts +248 -1
- package/src/headless-host/production-host.ts +1 -2
- package/src/headless-host/role-turn-host.ts +10 -9
- package/src/ledger-session-read.ts +6 -0
- package/src/navigator-public-session.ts +13 -18
- package/src/navigator-work-context.ts +3 -1
- package/src/notary-role.ts +2 -1
- package/src/notary-source-run.ts +7 -17
- package/src/packaged-role-registry.ts +0 -15
- package/src/pi/durable-principal.ts +2 -4
- package/src/pi/role-turn-host.ts +35 -12
- package/src/public-cli/instruction-seat-run.ts +4 -4
- package/src/public-cli/invocation.ts +29 -57
- package/src/public-cli/run-lifecycle.ts +20 -43
- package/src/public-cli/settlement.ts +30 -173
- package/src/public-cli/terminal.ts +0 -60
- package/src/role-envelope.ts +4 -2
- package/src/role-run-placement.ts +63 -4
- package/src/role-run-relocation.ts +39 -2
- package/src/role-runtime.ts +40 -59
- package/src/run-terminal-artifacts.ts +3 -5
- package/src/run-ticket-number.ts +41 -3
- package/src/session-assistant-usage.ts +8 -20
- package/src/session-identity.ts +3 -4
- package/src/sitian-appender.ts +20 -12
- package/src/submission-ledger.ts +4 -4
- package/src/ticket-provenance-contracts.ts +3 -6
- package/src/ticket-provenance.ts +5 -6
- package/src/ticket-snapshot.ts +3 -2
- package/src/ticket-trajectory.ts +85 -99
|
@@ -54,6 +54,257 @@ function codexTomlStringTable(entries) {
|
|
|
54
54
|
const parts = Object.entries(entries).map(([key, value]) => `${key}=${codexTomlString(value)}`);
|
|
55
55
|
return `{${parts.join(",")}}`;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Free-form JSON leaf for Type.Unknown under Codex strict transport.
|
|
59
|
+
* Declared contract objects still close with additionalProperties:false.
|
|
60
|
+
* For Unknown, a $defs anyOf of JSON values with nested additionalProperties
|
|
61
|
+
* as $ref is accepted by Codex and keeps non-empty object receipts expressible
|
|
62
|
+
* (native probe). Package code still does not validate or reject the receipt.
|
|
63
|
+
*/
|
|
64
|
+
const CODEX_JSON_VALUE_DEF = "codexJsonValue";
|
|
65
|
+
const CODEX_JSON_VALUE_REF = `#/$defs/${CODEX_JSON_VALUE_DEF}`;
|
|
66
|
+
const CODEX_JSON_VALUE_SCHEMA = Object.freeze({
|
|
67
|
+
anyOf: Object.freeze([
|
|
68
|
+
Object.freeze({ type: "string" }),
|
|
69
|
+
Object.freeze({ type: "number" }),
|
|
70
|
+
Object.freeze({ type: "boolean" }),
|
|
71
|
+
Object.freeze({ type: "null" }),
|
|
72
|
+
Object.freeze({ type: "array", items: Object.freeze({ $ref: CODEX_JSON_VALUE_REF }) }),
|
|
73
|
+
Object.freeze({
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: Object.freeze({}),
|
|
76
|
+
required: Object.freeze([]),
|
|
77
|
+
additionalProperties: Object.freeze({ $ref: CODEX_JSON_VALUE_REF }),
|
|
78
|
+
}),
|
|
79
|
+
]),
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Derive a Codex/OpenAI-strict transport schema from the package open schema.
|
|
83
|
+
* Legal open schema is untouched; this is a host-only transmission projection
|
|
84
|
+
* (#1148 / #646 / ADR 0057 / ADR 0054): every object closes, every property is
|
|
85
|
+
* required, originally-optional fields become a null union (official guidance),
|
|
86
|
+
* and originally-required declared nullability stays. Nested open-tool anyOf
|
|
87
|
+
* wrappers are flattened so every branch carries `type`, keeping descriptions.
|
|
88
|
+
* Type.Unknown / description-only leaves become the closed JSON-value $ref.
|
|
89
|
+
* Package code still does not validate or reject the receipt.
|
|
90
|
+
*/
|
|
91
|
+
export function closeJsonSchemaForCodex(schema) {
|
|
92
|
+
const closed = closeSchemaNode(schema);
|
|
93
|
+
const existingDefs = isRecord(closed.$defs)
|
|
94
|
+
? closed.$defs
|
|
95
|
+
: {};
|
|
96
|
+
return {
|
|
97
|
+
...closed,
|
|
98
|
+
$defs: {
|
|
99
|
+
...existingDefs,
|
|
100
|
+
[CODEX_JSON_VALUE_DEF]: CODEX_JSON_VALUE_SCHEMA,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** Pure null leaf only — composite type|null is stripped in-leaf, not dropped whole. */
|
|
105
|
+
function isPureNullTypeSchema(value) {
|
|
106
|
+
if (!isRecord(value))
|
|
107
|
+
return false;
|
|
108
|
+
if (value.type === "null")
|
|
109
|
+
return true;
|
|
110
|
+
if (Array.isArray(value.type) && value.type.length > 0 && value.type.every((t) => t === "null")) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/** Declared nullability on the open schema (type|null, anyOf null leaf, or pure null). */
|
|
116
|
+
function schemaDeclaresNull(schema) {
|
|
117
|
+
if (!isRecord(schema))
|
|
118
|
+
return false;
|
|
119
|
+
if (isPureNullTypeSchema(schema))
|
|
120
|
+
return true;
|
|
121
|
+
if (Array.isArray(schema.type) && schema.type.includes("null"))
|
|
122
|
+
return true;
|
|
123
|
+
if (Array.isArray(schema.anyOf) && schema.anyOf.some(schemaDeclaresNull))
|
|
124
|
+
return true;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Within a leaf, remove null members from type arrays.
|
|
129
|
+
* Null is re-added when the union or property edge originally declared it.
|
|
130
|
+
*/
|
|
131
|
+
function stripNullFromLeafType(leaf) {
|
|
132
|
+
if (!isRecord(leaf) || !Array.isArray(leaf.type))
|
|
133
|
+
return leaf;
|
|
134
|
+
const nonNull = leaf.type.filter((t) => t !== "null");
|
|
135
|
+
if (nonNull.length === leaf.type.length)
|
|
136
|
+
return leaf;
|
|
137
|
+
if (nonNull.length === 0)
|
|
138
|
+
return { ...leaf, type: "null" };
|
|
139
|
+
if (nonNull.length === 1)
|
|
140
|
+
return { ...leaf, type: nonNull[0] };
|
|
141
|
+
return { ...leaf, type: nonNull };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Flatten nested anyOf wrappers into concrete leaf schemas.
|
|
145
|
+
* Open-tool unions often wrap leaves in description-only anyOf shells that
|
|
146
|
+
* lack `type`; strict structured output rejects those intermediate nodes.
|
|
147
|
+
* Nested shell descriptions attach to leaves that lack their own (not onto $ref).
|
|
148
|
+
* The outermost union keeps its description on the closed node via the caller.
|
|
149
|
+
*/
|
|
150
|
+
function flattenUnionLeaves(schema, attachShellDescription = false) {
|
|
151
|
+
if (!isRecord(schema))
|
|
152
|
+
return [schema];
|
|
153
|
+
if (!Array.isArray(schema.anyOf))
|
|
154
|
+
return [schema];
|
|
155
|
+
const shellDescription = attachShellDescription && typeof schema.description === "string"
|
|
156
|
+
? schema.description
|
|
157
|
+
: undefined;
|
|
158
|
+
return schema.anyOf.flatMap((branch) => {
|
|
159
|
+
const leaves = flattenUnionLeaves(branch, true);
|
|
160
|
+
if (shellDescription === undefined)
|
|
161
|
+
return leaves;
|
|
162
|
+
return leaves.map((leaf) => {
|
|
163
|
+
if (!isRecord(leaf) || typeof leaf.$ref === "string")
|
|
164
|
+
return leaf;
|
|
165
|
+
if (typeof leaf.description === "string")
|
|
166
|
+
return leaf;
|
|
167
|
+
return { ...leaf, description: shellDescription };
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/** Drop pure-null leaves after in-leaf null stripping; property edge may re-add null. */
|
|
172
|
+
function nonNullLeaves(schema) {
|
|
173
|
+
return flattenUnionLeaves(schema)
|
|
174
|
+
.map(stripNullFromLeafType)
|
|
175
|
+
.filter((leaf) => !isPureNullTypeSchema(leaf));
|
|
176
|
+
}
|
|
177
|
+
function withDescription(closed, description) {
|
|
178
|
+
if (description.description === undefined)
|
|
179
|
+
return closed;
|
|
180
|
+
// Codex strict does not allow sibling keys on $ref; wrap so guidance is kept.
|
|
181
|
+
if (isRecord(closed) && typeof closed.$ref === "string") {
|
|
182
|
+
return { anyOf: [closed], ...description };
|
|
183
|
+
}
|
|
184
|
+
// Prefer a leaf's own description (nested anyOf shell) over the outer copy.
|
|
185
|
+
if (isRecord(closed) && typeof closed.description === "string")
|
|
186
|
+
return closed;
|
|
187
|
+
return isRecord(closed) ? { ...closed, ...description } : closed;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Property edge under strict transport.
|
|
191
|
+
* Optional → closed leaf(s) + null. Required with declared nullability keeps null.
|
|
192
|
+
* Required without declared null stays non-nullable.
|
|
193
|
+
*/
|
|
194
|
+
function closePropertySchema(schema, optional) {
|
|
195
|
+
const description = isRecord(schema) && typeof schema.description === "string"
|
|
196
|
+
? { description: schema.description }
|
|
197
|
+
: {};
|
|
198
|
+
const keepNull = optional || schemaDeclaresNull(schema);
|
|
199
|
+
const leaves = nonNullLeaves(schema).map(closeSchemaNode);
|
|
200
|
+
if (leaves.length === 0)
|
|
201
|
+
return { type: "null", ...description };
|
|
202
|
+
if (!keepNull) {
|
|
203
|
+
const closed = leaves.length === 1 ? leaves[0] : { anyOf: leaves };
|
|
204
|
+
return withDescription(closed, description);
|
|
205
|
+
}
|
|
206
|
+
return { anyOf: [...leaves, { type: "null" }], ...description };
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Strict generators require every schema node to declare `type` (or a $ref).
|
|
210
|
+
* Type.Unknown / description-only leaves → free JSON $ref (not string): array
|
|
211
|
+
* and object receipts stay expressible under --output-schema.
|
|
212
|
+
*/
|
|
213
|
+
function ensureTypedLeaf(schema) {
|
|
214
|
+
if (schema.type !== undefined)
|
|
215
|
+
return schema;
|
|
216
|
+
if (typeof schema.$ref === "string")
|
|
217
|
+
return schema;
|
|
218
|
+
if (isRecord(schema.properties) || schema.additionalProperties !== undefined) {
|
|
219
|
+
return { ...schema, type: "object" };
|
|
220
|
+
}
|
|
221
|
+
if (schema.items !== undefined) {
|
|
222
|
+
return { ...schema, type: "array" };
|
|
223
|
+
}
|
|
224
|
+
if (schema.const !== undefined) {
|
|
225
|
+
const value = schema.const;
|
|
226
|
+
if (value === null)
|
|
227
|
+
return { ...schema, type: "null" };
|
|
228
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
229
|
+
return { ...schema, type: typeof value };
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
233
|
+
const sample = schema.enum.find((item) => item !== null);
|
|
234
|
+
if (typeof sample === "string" || typeof sample === "number" || typeof sample === "boolean") {
|
|
235
|
+
return { ...schema, type: typeof sample };
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Free JSON via $defs. $ref must stand alone (strict rejects sibling keys).
|
|
239
|
+
return { $ref: CODEX_JSON_VALUE_REF };
|
|
240
|
+
}
|
|
241
|
+
function originalRequiredNames(node) {
|
|
242
|
+
if (!Array.isArray(node.required))
|
|
243
|
+
return new Set();
|
|
244
|
+
return new Set(node.required.filter((item) => typeof item === "string"));
|
|
245
|
+
}
|
|
246
|
+
function closeSchemaNode(node) {
|
|
247
|
+
if (!isRecord(node))
|
|
248
|
+
return node;
|
|
249
|
+
// Already a ref (free-JSON leaf or pre-existing) — do not retype.
|
|
250
|
+
if (typeof node.$ref === "string")
|
|
251
|
+
return node;
|
|
252
|
+
// Union node: flatten then close each concrete leaf (do not keep untyped shells).
|
|
253
|
+
// Declared null stays — including nested unions such as array items.
|
|
254
|
+
if (Array.isArray(node.anyOf)) {
|
|
255
|
+
const description = typeof node.description === "string" ? { description: node.description } : {};
|
|
256
|
+
const keepNull = schemaDeclaresNull(node);
|
|
257
|
+
const leaves = nonNullLeaves(node).map(closeSchemaNode);
|
|
258
|
+
if (leaves.length === 0)
|
|
259
|
+
return { type: "null", ...description };
|
|
260
|
+
if (!keepNull) {
|
|
261
|
+
if (leaves.length === 1)
|
|
262
|
+
return withDescription(leaves[0], description);
|
|
263
|
+
return { anyOf: leaves, ...description };
|
|
264
|
+
}
|
|
265
|
+
return { anyOf: [...leaves, { type: "null" }], ...description };
|
|
266
|
+
}
|
|
267
|
+
let out = { ...node };
|
|
268
|
+
if (node.items !== undefined) {
|
|
269
|
+
out.items = closeSchemaNode(node.items);
|
|
270
|
+
}
|
|
271
|
+
if (isRecord(node.$defs)) {
|
|
272
|
+
out.$defs = Object.fromEntries(Object.entries(node.$defs).map(([key, value]) => [key, closeSchemaNode(value)]));
|
|
273
|
+
}
|
|
274
|
+
const hasProperties = isRecord(node.properties);
|
|
275
|
+
const isObjectType = node.type === "object"
|
|
276
|
+
|| (Array.isArray(node.type) && node.type.includes("object"))
|
|
277
|
+
|| hasProperties
|
|
278
|
+
|| node.additionalProperties !== undefined;
|
|
279
|
+
if (hasProperties) {
|
|
280
|
+
const props = node.properties;
|
|
281
|
+
const wasRequired = originalRequiredNames(node);
|
|
282
|
+
const closedProps = {};
|
|
283
|
+
const required = [];
|
|
284
|
+
for (const [name, propSchema] of Object.entries(props)) {
|
|
285
|
+
required.push(name);
|
|
286
|
+
closedProps[name] = closePropertySchema(propSchema, !wasRequired.has(name));
|
|
287
|
+
}
|
|
288
|
+
out.properties = closedProps;
|
|
289
|
+
out.required = required;
|
|
290
|
+
out.additionalProperties = false;
|
|
291
|
+
if (out.type === undefined)
|
|
292
|
+
out.type = "object";
|
|
293
|
+
// Object nodes must not also carry residual anyOf from the open copy.
|
|
294
|
+
delete out.anyOf;
|
|
295
|
+
}
|
|
296
|
+
else if (isObjectType) {
|
|
297
|
+
out.additionalProperties = false;
|
|
298
|
+
if (!Array.isArray(out.required))
|
|
299
|
+
out.required = [];
|
|
300
|
+
if (out.type === undefined)
|
|
301
|
+
out.type = "object";
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
out = ensureTypedLeaf(out);
|
|
305
|
+
}
|
|
306
|
+
return out;
|
|
307
|
+
}
|
|
57
308
|
/**
|
|
58
309
|
* Project shared-envelope MCP rows into `codex -c mcp_servers.<name>.*` argv pairs.
|
|
59
310
|
* Dot-path + TOML values per official config-advanced; spawn argv (no shell).
|