@principles/codex-adapter 0.17.0 → 0.17.1

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.
@@ -124,10 +124,20 @@ function collectVerifiedToolOutcomes(observations) {
124
124
  previewParts.push(stderr);
125
125
  if (typeof stdout === 'string' && stdout.length > 0)
126
126
  previewParts.push(stdout);
127
+ const factRecord = facts;
128
+ const rawCommand = factRecord.command;
129
+ // The transcript stores the physical process argv (often a shell wrapper),
130
+ // while the live Bash hook receives the semantic command string. Project the
131
+ // transcript fact to the live shape; for wrapper argv the semantic command is
132
+ // the final argument in the Codex fixture contract.
133
+ const liveShapeCommand = Array.isArray(rawCommand) && rawCommand.every((part) => typeof part === 'string')
134
+ ? rawCommand[rawCommand.length - 1]
135
+ : rawCommand;
127
136
  outcomes.push({
128
137
  toolUseId: observation.toolUseId,
138
+ ...(observation.hostTurnId !== undefined ? { hostTurnId: observation.hostTurnId } : {}),
129
139
  toolName,
130
- params: facts.command ?? undefined,
140
+ params: liveShapeCommand !== undefined ? { command: liveShapeCommand } : undefined,
131
141
  exitCode,
132
142
  ...(previewParts.length > 0 ? { outputPreview: previewParts.join('\n') } : {}),
133
143
  });
package/dist/pd-hook.js CHANGED
@@ -4,7 +4,7 @@ import path from 'node:path';
4
4
  import process from 'node:process';
5
5
  import { pathToFileURL, fileURLToPath } from 'node:url';
6
6
  import { appendEventLogLine, redactTelemetryString, isRuleHostEvaluatedEventData } from '@principles/core/runtime';
7
- import { ADAPTIVE_SELECTION_LIMITS, createAdaptivePriorityProviderForConfig, createCodexRuleContextProvider, createProductionHostRuntime, environmentFactDigestOrNull, loadPdConfigForPlugin, renderAcceptedAdaptiveAppend, resolveHostToolSemanticsForHook, resolveNearestPdWorkspace, recordIdleAuditTurnCompleted, } from '@principles/host-runtime';
7
+ import { ADAPTIVE_SELECTION_LIMITS, createAdaptivePriorityProviderForConfig, createCodexRuleContextProvider, createProductionHostRuntime, observeForwardTurnClose, environmentFactDigestOrNull, loadPdConfigForPlugin, renderAcceptedAdaptiveAppend, resolveHostToolSemanticsForHook, resolveNearestPdWorkspace, recordIdleAuditTurnCompleted } from '@principles/host-runtime';
8
8
  import { resolvePdHome } from '@principles/install-layout';
9
9
  import { classifyBashRisk } from '@principles/core/runtime/internalization/bash-risk';
10
10
  import { CODEX_TOOL_SEMANTIC_MAPPINGS, CODEX_TOOL_SEMANTICS } from './tool-semantics.js';
@@ -429,6 +429,12 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
429
429
  const adaptiveTiming = config.effective.config.adaptiveActivation?.timing === 'background' ? 'background' : 'sync';
430
430
  const backgroundSelectionEnabled = flags['host.codex.adaptive_activation']?.enabled === true && adaptiveTiming === 'background';
431
431
  if (event.kind === 'turn_complete') {
432
+ const closeWarnings = observeForwardTurnClose({
433
+ workspaceDir: resolution.workspaceDir,
434
+ hostKind: 'codex',
435
+ sessionId: event.context.sessionId,
436
+ ...(event.context.turnId !== undefined ? { turnId: event.context.turnId } : {}),
437
+ }).map((warning) => diagnostic(warning, 'Inspect trajectory.db forward evidence; Stop ingestion and host output remain non-blocking.'));
432
438
  // Withdraw the live turn context: once the turn completes, the
433
439
  // agent-assisted explicit entry must fail closed (turn_context_missing)
434
440
  // instead of binding an Owner statement to a finished turn. A withdrawal
@@ -449,8 +455,8 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
449
455
  // turn on stderr — never stdout, and never on the per-tool events (that
450
456
  // would be per-event noise).
451
457
  const stderr = ingestionEnabled
452
- ? [...clearDiagnostics, ...await runConversationIngestion({ rawPayload: parsed, kind: event.kind, workspaceDir: resolution.workspaceDir, env: _env })]
453
- : [...clearDiagnostics, diagnostic('feature_disabled', 'Enable bounded conversation ingestion in the selected Workspace .pd/config.yaml — in the existing "features:" block set codex_conversation_ingestion: {enabled: true} (one flat key, not nested).')];
458
+ ? [...closeWarnings, ...clearDiagnostics, ...await runConversationIngestion({ rawPayload: parsed, kind: event.kind, workspaceDir: resolution.workspaceDir, env: _env })]
459
+ : [...closeWarnings, ...clearDiagnostics, diagnostic('feature_disabled', 'Enable bounded conversation ingestion in the selected Workspace .pd/config.yaml — in the existing "features:" block set codex_conversation_ingestion: {enabled: true} (one flat key, not nested).')];
454
460
  // Clean up the background turn whenever THIS turn was tracked, even if the
455
461
  // timing was switched back to `sync` mid-turn: the started marker outlives
456
462
  // the setting, and leaving it behind would strand a late result (P1-2).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
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": "^9.0.0",
37
- "@principles/host-runtime": "^4.11.0",
36
+ "@principles/core": "^9.1.0",
37
+ "@principles/host-runtime": "^4.12.0",
38
38
  "@principles/install-layout": "^0.12.0"
39
39
  },
40
40
  "devDependencies": {
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "1e6fc5c3f3083d24dc50a65c420609e21307d9d5"
55
+ "gitHead": "e14270ad721ec3a3352d629bb8254be81842cc38"
56
56
  }