@principles/codex-adapter 0.17.0 → 0.17.2

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).
@@ -28,7 +28,7 @@
28
28
  import fs from 'node:fs';
29
29
  import path from 'node:path';
30
30
  import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, PDRuntimeError, } from '@principles/core/runtime';
31
- import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, runIdleTurnAuditCycle, createIdleTurnAuditorForWorkspace, createSignalClassifierForWorkspace, createConsentLedgerSourceMaterialAuthorization, resolveWorkspacePipelineHostDeps, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
31
+ import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, executeQueuedDiagnosisWithInboxRecovery, runInternalizationConsumerCycle, runStage2CorrectionCycle, runIdleTurnAuditCycle, createIdleTurnAuditorForWorkspace, createSignalClassifierForWorkspace, createConsentLedgerSourceMaterialAuthorization, resolveWorkspacePipelineHostDeps, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
32
32
  import { catchUpCodexIngestion } from '../ingestion/catch-up.js';
33
33
  import { readCodexTargetTurnEvidence } from '../ingestion/pain-receipt-fallback.js';
34
34
  import { CODEX_TOOL_SEMANTIC_MAPPINGS, CODEX_TOOL_SEMANTICS } from '../tool-semantics.js';
@@ -376,7 +376,10 @@ export async function runCodexWorkspaceWorkerCycle(options) {
376
376
  // automatic_hook tasks at the bridge's execution boundary.
377
377
  isAutoPainSubmissionAuthorized: hostDeps.isAutoPainSubmissionAuthorized,
378
378
  }, (release) => { releaseBridge = release; });
379
- const executed = await bridge.executePendingDiagnosis({ taskId: candidate.taskId });
379
+ const executed = await executeQueuedDiagnosisWithInboxRecovery({
380
+ workspaceDir, task: candidate, stateManager: handle.stateManager,
381
+ execute: () => bridge.executePendingDiagnosis({ taskId: candidate.taskId }),
382
+ });
380
383
  // PRI-917 v0.3.3 review fix (P2-2): forward the parked-candidate
381
384
  // dispositions so the Owner sees the pending items instead of a bare
382
385
  // degraded status with no subject.
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.2",
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": "^10.0.0",
37
+ "@principles/host-runtime": "^5.0.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": "293825348a6f4a40cc561f6a59fc42c64d532766"
56
56
  }