@principles/codex-adapter 0.10.1 → 0.11.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/pd-hook.js +34 -4
- package/package.json +4 -4
package/dist/pd-hook.js
CHANGED
|
@@ -66,15 +66,28 @@ function redactStringFields(data) {
|
|
|
66
66
|
* writer, so the Codex host path stays independent of the OpenClaw plugin
|
|
67
67
|
* (codex-adapter must not depend on principles-disciple — bundle guard).
|
|
68
68
|
*/
|
|
69
|
-
function codexEventEmitter(stateDir, evidence) {
|
|
69
|
+
function codexEventEmitter(stateDir, evidence, readAdaptiveFact) {
|
|
70
70
|
return {
|
|
71
71
|
recordRuntimeActivationsInjected(data) {
|
|
72
|
+
// Adaptive Activation fact for this turn. Appended ONLY on the final
|
|
73
|
+
// assembly basis: a selection whose id did not reach `activationIds`
|
|
74
|
+
// (dropped by budget, replaced, failed packing) is not an append.
|
|
75
|
+
const fact = readAdaptiveFact?.() ?? null;
|
|
76
|
+
const adaptive = fact === null
|
|
77
|
+
? undefined
|
|
78
|
+
: {
|
|
79
|
+
resultCode: `${fact.status}:${fact.reason}`.slice(0, 240),
|
|
80
|
+
scored: fact.sends > 0,
|
|
81
|
+
...(fact.targetActivationId !== null && data.activationIds.includes(fact.targetActivationId)
|
|
82
|
+
? { appendedActivationId: fact.targetActivationId }
|
|
83
|
+
: {}),
|
|
84
|
+
};
|
|
72
85
|
appendEventLogLine(stateDir, {
|
|
73
86
|
ts: new Date().toISOString(),
|
|
74
87
|
type: 'runtime_v2_prompt_activations_injected',
|
|
75
88
|
category: 'injected',
|
|
76
89
|
sessionId: data.sessionId,
|
|
77
|
-
data,
|
|
90
|
+
data: adaptive === undefined ? data : { ...data, adaptive },
|
|
78
91
|
});
|
|
79
92
|
// PD v2 Phase 1: the durable source line is appended — now record the
|
|
80
93
|
// normalized agent-context delivery attempts (submitted, not delivered).
|
|
@@ -436,6 +449,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
436
449
|
// top of the PD hook. `host.codex.enabled` remains the whole-hook gate.
|
|
437
450
|
const adaptiveDiagnostics = [];
|
|
438
451
|
let adaptivePriorityProvider;
|
|
452
|
+
let adaptiveTurnFact = null;
|
|
439
453
|
if (event.kind === 'before_prompt_build' && flags['host.codex.adaptive_activation']?.enabled === true) {
|
|
440
454
|
const adaptive = createAdaptivePriorityProviderForConfig(config.effective.config, resolution.workspaceDir, {
|
|
441
455
|
env: _env,
|
|
@@ -444,13 +458,29 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
444
458
|
requestTimeoutMs: deps.requestTimeoutMs ?? CODEX_ADAPTIVE_DECISION_MS,
|
|
445
459
|
...(deps.minExecutableBudgetMs !== undefined ? { minExecutableBudgetMs: deps.minExecutableBudgetMs } : {}),
|
|
446
460
|
outerDeadlineAt: adaptiveDeadlineAt,
|
|
447
|
-
onDiagnostic: (line) => {
|
|
461
|
+
onDiagnostic: (line) => {
|
|
462
|
+
adaptiveDiagnostics.push(adaptiveSelectionDiagnostic(line));
|
|
463
|
+
adaptiveTurnFact = {
|
|
464
|
+
status: line.status,
|
|
465
|
+
reason: line.reason,
|
|
466
|
+
sends: line.sends,
|
|
467
|
+
targetActivationId: line.targetActivationId,
|
|
468
|
+
};
|
|
469
|
+
},
|
|
448
470
|
});
|
|
449
471
|
if (adaptive.ok) {
|
|
450
472
|
adaptivePriorityProvider = adaptive.provider;
|
|
451
473
|
}
|
|
452
474
|
else {
|
|
453
475
|
// rc-9: an enabled-but-unusable switch is observable, never silent.
|
|
476
|
+
// `sends: 0` is a fact, not an assumption: no request can leave when
|
|
477
|
+
// the effective configuration cannot build a model.
|
|
478
|
+
adaptiveTurnFact = {
|
|
479
|
+
status: 'needs_setup',
|
|
480
|
+
reason: adaptive.reason,
|
|
481
|
+
sends: 0,
|
|
482
|
+
targetActivationId: null,
|
|
483
|
+
};
|
|
454
484
|
adaptiveDiagnostics.push(diagnostic(`adaptive_activation_${adaptive.readiness}:${adaptive.reason}`, adaptive.nextAction));
|
|
455
485
|
}
|
|
456
486
|
}
|
|
@@ -484,7 +514,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
484
514
|
currentToolUseId: event.context.toolCallId ?? '',
|
|
485
515
|
toolSemantics,
|
|
486
516
|
}),
|
|
487
|
-
events: codexEventEmitter(path.join(resolution.workspaceDir, '.state'), evidenceContext),
|
|
517
|
+
events: codexEventEmitter(path.join(resolution.workspaceDir, '.state'), evidenceContext, () => adaptiveTurnFact),
|
|
488
518
|
}).dispatch(event);
|
|
489
519
|
// PRI-813: the shared gate's evaluation facts leave through metadata —
|
|
490
520
|
// persist them here (telemetry persistence is host-side business; the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"lint": "eslint \"src/**/*.ts\""
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@principles/core": "^7.
|
|
37
|
-
"@principles/host-runtime": "^4.
|
|
36
|
+
"@principles/core": "^7.7.0",
|
|
37
|
+
"@principles/host-runtime": "^4.2.0",
|
|
38
38
|
"@principles/install-layout": "^0.8.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7feb0044cae3768b8bf278dad1cb58e77410b6f9"
|
|
56
56
|
}
|