@dharma-ai-labs/agent-fabric 0.2.196 → 0.2.197

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/index.js CHANGED
@@ -86,7 +86,7 @@ import { namedCodexEnvironment } from './namedCodexEnvironment.js';
86
86
  import { namedCodexNodeOutputArguments } from './namedCodexNodeOutput.js';
87
87
  import { namedCodexFilesystem } from './namedCodexFilesystem.js';
88
88
  import { createNamedSessionChildOwner, currentNamedSessionChildOwner } from './namedSessionChildOwner.js';
89
- import { awaitCodexSetupSession, codexSetupSessionPolicyHash, consumeCodexSetupSessions, currentAcceptedSetupSessionScope, originalCodexSetupSessionSender, withCodexSetupSessionSender } from './codexSetupSessionHandoff.js';
89
+ import { assertCodexSetupSessionPostCommitAcknowledged, awaitCodexSetupSession, clearCodexSetupSessionPostCommitAcknowledgment, codexSetupSessionPolicyHash, consumeCodexSetupSessions, currentAcceptedSetupSessionScope, originalCodexSetupSessionSender, withCodexSetupSessionSender } from './codexSetupSessionHandoff.js';
90
90
  import { receiveCodexSetupChildStart, runCodexSetupChildStartup, sendCodexSetupChildStart } from './codexSetupChildStartup.js';
91
91
  import { assertBootstrapHostSource, captureBootstrapHostChild, currentBootstrapHostScope, inspectCodexBootstrapHostPreparation, prepareCodexBootstrapHost, runCodexBootstrapHost, runCodexBootstrapHostScope } from './bootstrapHostScope.js';
92
92
  // Trusted runtime composition only; these exports do not enable effectful setup.
@@ -104,7 +104,7 @@ import { assertCodexSetupExecutionLease } from './codexSetupAdmission.js';
104
104
  import { parseLocalCodexSetupReadiness } from '@dharma-ai-labs/agent-fabric-local-vault/setup-readiness';
105
105
  import { writeBootstrapHostJson, writeBootstrapHostText } from './bootstrapHostFiles.js';
106
106
  export { openCooperativeInboxSession } from './cooperativeInboxSession.js';
107
- const VERSION = '0.2.196';
107
+ const VERSION = '0.2.197';
108
108
  const USAGE = CLI_USAGE;
109
109
  const execFileAsync = promisify(execFile);
110
110
  const LOCAL_PROVIDER_IDS = ['codex', 'claude', 'agy', 'hermes'];
@@ -2616,7 +2616,7 @@ async function readBootstrapRuntimeJson(path, scope) {
2616
2616
  }
2617
2617
  }
2618
2618
  /** Actual scoped runtime readback. No callback-supplied ready flag or receipt ID. */
2619
- async function observeCodexBootstrapRuntime(prepared, vault, firstLearning, intentDigest) {
2619
+ async function observeCodexBootstrapRuntime(prepared, vault, firstLearning, intentDigest, requirePostCommitAcknowledgment = false) {
2620
2620
  const { scope, intent } = prepared, workspace = String(prepared.flags.get('workspace'));
2621
2621
  const step = (operation) => scope.step(operation);
2622
2622
  await scope.assert();
@@ -2754,7 +2754,14 @@ async function observeCodexBootstrapRuntime(prepared, vault, firstLearning, inte
2754
2754
  throw new Error('setup_runtime_session_unconfirmed');
2755
2755
  const handoff = await step(() => vault.readCodexSetupSession(intent.operationId, intentDigest));
2756
2756
  const request = handoff?.request, result = handoff?.result;
2757
+ const acceptedAt = typeof handoff?.acceptedAt === 'string' ? Date.parse(handoff.acceptedAt) : NaN;
2758
+ const resultRecordedAt = typeof handoff?.resultRecordedAt === 'string' ? Date.parse(handoff.resultRecordedAt) : NaN;
2757
2759
  if (handoff?.state !== 'accepted' || !request || result?.state !== 'started'
2760
+ || !Number.isFinite(acceptedAt) || !Number.isFinite(resultRecordedAt)
2761
+ || new Date(acceptedAt).toISOString() !== handoff.acceptedAt
2762
+ || new Date(resultRecordedAt).toISOString() !== handoff.resultRecordedAt
2763
+ || acceptedAt < Date.parse(request.issuedAt) || acceptedAt >= Date.parse(request.expiresAt)
2764
+ || resultRecordedAt < acceptedAt || resultRecordedAt >= Date.parse(request.expiresAt)
2758
2765
  || request.setupReference !== intent.setupReference || request.membershipId !== intent.recipientMembershipId
2759
2766
  || request.organizationId !== intent.organizationId || request.deviceId !== config.deviceId
2760
2767
  || request.workspaceId !== item.workspaceId || request.workspaceRoot !== workspace || request.name !== name
@@ -2765,6 +2772,10 @@ async function observeCodexBootstrapRuntime(prepared, vault, firstLearning, inte
2765
2772
  || result.supervisorPid !== supervisorPid || result.sessionStartTicks !== processes[2].startTicks
2766
2773
  || result.supervisorStartTicks !== processes[0].startTicks)
2767
2774
  throw new Error('setup_runtime_session_unconfirmed');
2775
+ if (requirePostCommitAcknowledgment)
2776
+ assertCodexSetupSessionPostCommitAcknowledged(scope, {
2777
+ request, result, acceptedAt: handoff.acceptedAt, resultRecordedAt: handoff.resultRecordedAt,
2778
+ });
2768
2779
  }
2769
2780
  const supervisor = await readBootstrapRuntimeJson(resolve(home, 'relay', 'supervisor-workspace.json'), scope);
2770
2781
  if (supervisor.pid !== supervisorPid || supervisor.organizationId !== intent.organizationId || supervisor.deviceId !== config.deviceId
@@ -2824,7 +2835,7 @@ export async function createCodexBootstrapCompletionOwner(scope, vault, observeF
2824
2835
  if (!disposition)
2825
2836
  throw new Error('setup_runtime_first_learning_unconfirmed');
2826
2837
  // Keep the original execution's disposition; reobserve all live state.
2827
- return runCodexBootstrapHostScope(scope, current => observeCodexBootstrapRuntime(current, vault, disposition, intentDigest));
2838
+ return runCodexBootstrapHostScope(scope, current => observeCodexBootstrapRuntime(current, vault, disposition, intentDigest, retained === undefined));
2828
2839
  } });
2829
2840
  return Object.freeze({
2830
2841
  execute: async (lease) => {
@@ -2847,6 +2858,9 @@ export async function createCodexBootstrapCompletionOwner(scope, vault, observeF
2847
2858
  reportCodexSetupFailure(observeFailure, error, 'completion');
2848
2859
  throw error;
2849
2860
  }
2861
+ finally {
2862
+ clearCodexSetupSessionPostCommitAcknowledgment(scope);
2863
+ }
2850
2864
  },
2851
2865
  verify: readiness.verify,
2852
2866
  });