@dharma-ai-labs/agent-fabric 0.2.164 → 0.2.165
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/codexBootstrapCompletion.test.js +8 -0
- package/dist/codexBootstrapCompletion.test.js.map +1 -1
- package/dist/codexSetupDiagnostic.d.ts +11 -0
- package/dist/codexSetupDiagnostic.d.ts.map +1 -0
- package/dist/codexSetupDiagnostic.js +49 -0
- package/dist/codexSetupDiagnostic.js.map +1 -0
- package/dist/codexSetupDiagnostic.test.d.ts +2 -0
- package/dist/codexSetupDiagnostic.test.d.ts.map +1 -0
- package/dist/codexSetupDiagnostic.test.js +97 -0
- package/dist/codexSetupDiagnostic.test.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -23
- package/dist/index.js.map +1 -1
- package/dist/pidLock.test.js +111 -1
- package/dist/pidLock.test.js.map +1 -1
- package/dist/schemas/codex-setup-failure-diagnostic.schema.json +13 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ import { registerRepositoryRoleMetadata, discoverRepositoryRoleMetadata } from '
|
|
|
48
48
|
import { askRepositoryRoleQuestion, readRepositoryRoleReply } from './repositoryRoleQuestion.js';
|
|
49
49
|
import { deriveRepositoryRole } from './repositoryRoleDerivation.js';
|
|
50
50
|
import { withOnboardingStage } from './onboardingStage.js';
|
|
51
|
+
import { reportCodexSetupFailure } from './codexSetupDiagnostic.js';
|
|
51
52
|
import { waitForRepositoryReadiness } from './repositoryReadinessWait.js';
|
|
52
53
|
import { connectDemoDevice, verifyDemoDevice } from './demoEnrollment.js';
|
|
53
54
|
import { performDemoPeerAction, withDemoDeviceLock } from './demoPeer.js';
|
|
@@ -89,7 +90,7 @@ import { assertCodexSetupExecutionLease } from './codexSetupAdmission.js';
|
|
|
89
90
|
import { parseLocalCodexSetupReadiness } from '@dharma-ai-labs/agent-fabric-local-vault/setup-readiness';
|
|
90
91
|
import { writeBootstrapHostJson, writeBootstrapHostText } from './bootstrapHostFiles.js';
|
|
91
92
|
export { openCooperativeInboxSession } from './cooperativeInboxSession.js';
|
|
92
|
-
const VERSION = '0.2.
|
|
93
|
+
const VERSION = '0.2.165';
|
|
93
94
|
const USAGE = CLI_USAGE;
|
|
94
95
|
const execFileAsync = promisify(execFile);
|
|
95
96
|
const LOCAL_PROVIDER_IDS = ['codex', 'claude', 'agy', 'hermes'];
|
|
@@ -784,14 +785,22 @@ async function acquirePidLock(lockPath, timeoutMs, timeoutMessage) {
|
|
|
784
785
|
}
|
|
785
786
|
catch (inspectionError) {
|
|
786
787
|
let disappeared = inspectionError.code === 'ENOENT';
|
|
787
|
-
|
|
788
|
+
// Invalid owner metadata rethrows renameError and remains an immediate denial.
|
|
789
|
+
if (!disappeared && inspectionError !== renameError
|
|
790
|
+
&& inspectionError.code === 'EPERM') {
|
|
788
791
|
// Windows can deny owner reads while its directory is being
|
|
789
|
-
// deleted.
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
792
|
+
// deleted. Observe only; never republish until absence is verified.
|
|
793
|
+
while (Date.now() < deadline) {
|
|
794
|
+
try {
|
|
795
|
+
await step(() => lstat(recoveryPath));
|
|
796
|
+
}
|
|
797
|
+
catch (readbackError) {
|
|
798
|
+
if (readbackError.code !== 'ENOENT')
|
|
799
|
+
throw renameError;
|
|
800
|
+
disappeared = true;
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
await step(() => new Promise((resolvePromise) => setTimeout(resolvePromise, 25)));
|
|
795
804
|
}
|
|
796
805
|
}
|
|
797
806
|
if (disappeared && Date.now() < deadline) {
|
|
@@ -2503,13 +2512,15 @@ export async function bootstrapFromCodexSetup(input) {
|
|
|
2503
2512
|
}
|
|
2504
2513
|
}
|
|
2505
2514
|
/** Native-owner continuation: no caller-selected flags or replacement authority. */
|
|
2506
|
-
export async function bootstrapFromCodexSetupScope(scope) {
|
|
2515
|
+
export async function bootstrapFromCodexSetupScope(scope, observeFailure) {
|
|
2507
2516
|
try {
|
|
2508
2517
|
return await runCodexBootstrapHostScope(scope, prepared => run(['bootstrap',
|
|
2509
2518
|
...[...prepared.flags].flatMap(([key, value]) => value === true ? [`--${key}`] : [`--${key}`, String(value)]),
|
|
2510
2519
|
]));
|
|
2511
2520
|
}
|
|
2512
2521
|
catch (error) {
|
|
2522
|
+
if (observeFailure)
|
|
2523
|
+
reportCodexSetupFailure(observeFailure, error, 'bootstrap');
|
|
2513
2524
|
if (error instanceof Error && error.message === 'setup_session_sender_unavailable') {
|
|
2514
2525
|
return { ok: false, stage: 'host_setup_unavailable',
|
|
2515
2526
|
code: 'codex_setup_host_execution_unqualified', effects: false, grantRedeemed: false };
|
|
@@ -2740,7 +2751,7 @@ async function observeCodexBootstrapRuntime(prepared, vault, firstLearning, inte
|
|
|
2740
2751
|
expiresAt: new Date(Math.min(Date.parse(intent.expiresAt), Date.parse(policy.serverAuthorization.expiresAt), Date.parse(startupPolicy.serverAuthorization.expiresAt), Date.parse(binding.expiresAt), signed.expiresAt ? Date.parse(signed.expiresAt) : Infinity)).toISOString() });
|
|
2741
2752
|
}
|
|
2742
2753
|
/** Trusted native host composition, not an MCP/model/peer tool. */
|
|
2743
|
-
export async function createCodexBootstrapCompletionOwner(scope, vault) {
|
|
2754
|
+
export async function createCodexBootstrapCompletionOwner(scope, vault, observeFailure) {
|
|
2744
2755
|
const prepared = await runCodexBootstrapHostScope(scope, async (value) => value);
|
|
2745
2756
|
let firstLearning;
|
|
2746
2757
|
const readiness = createCodexSetupReadinessOwner({ intent: prepared.intent,
|
|
@@ -2754,16 +2765,25 @@ export async function createCodexBootstrapCompletionOwner(scope, vault) {
|
|
|
2754
2765
|
} });
|
|
2755
2766
|
return Object.freeze({
|
|
2756
2767
|
execute: async (lease) => {
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
||
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2768
|
+
try {
|
|
2769
|
+
await scope.step(() => assertCodexSetupExecutionLease(lease, prepared.intent));
|
|
2770
|
+
const result = await withCodexSetupSessionSender({ scope, vault, lease }, () => bootstrapFromCodexSetupScope(scope, observeFailure));
|
|
2771
|
+
await scope.step(() => assertCodexSetupExecutionLease(lease, prepared.intent));
|
|
2772
|
+
const workflow = result.workflowReadiness;
|
|
2773
|
+
if (result.ok !== true || result.stage !== 'complete' || !workflow
|
|
2774
|
+
|| !['synchronized', 'no_eligible_history', 'denied_disclosure'].includes(String(workflow.firstLearning))) {
|
|
2775
|
+
if (observeFailure)
|
|
2776
|
+
reportCodexSetupFailure(observeFailure, new Error(typeof result.stage === 'string' ? result.stage : 'setup_execution_unconfirmed'), 'completion');
|
|
2777
|
+
return { state: 'unconfirmed', code: 'setup_execution_unconfirmed' };
|
|
2778
|
+
}
|
|
2779
|
+
firstLearning = workflow.firstLearning;
|
|
2780
|
+
return await readiness.record(lease);
|
|
2781
|
+
}
|
|
2782
|
+
catch (error) {
|
|
2783
|
+
if (observeFailure)
|
|
2784
|
+
reportCodexSetupFailure(observeFailure, error, 'completion');
|
|
2785
|
+
throw error;
|
|
2786
|
+
}
|
|
2767
2787
|
},
|
|
2768
2788
|
verify: readiness.verify,
|
|
2769
2789
|
});
|
|
@@ -2816,7 +2836,8 @@ export async function openCodexBootstrapNativeHost(input) {
|
|
|
2816
2836
|
}
|
|
2817
2837
|
});
|
|
2818
2838
|
void settled.catch(() => { });
|
|
2819
|
-
return Object.freeze({ threadId: host.threadId, turnId: host.turnId, close, settled
|
|
2839
|
+
return Object.freeze({ threadId: host.threadId, turnId: host.turnId, close, settled,
|
|
2840
|
+
get diagnostics() { return ownedHost.diagnostics; } });
|
|
2820
2841
|
}
|
|
2821
2842
|
catch {
|
|
2822
2843
|
let cleanupFailed = false;
|
|
@@ -2909,7 +2930,10 @@ export async function startCodexBootstrapNativeHost(input) {
|
|
|
2909
2930
|
const root = resolve(dharmaHome(), 'vault');
|
|
2910
2931
|
let completion;
|
|
2911
2932
|
let ownerScope;
|
|
2912
|
-
|
|
2933
|
+
const failures = [];
|
|
2934
|
+
const observeFailure = failure => { if (failures.length < 16)
|
|
2935
|
+
failures.push(failure); };
|
|
2936
|
+
const host = await startCodexSetupNativeHost({ ...input,
|
|
2913
2937
|
openJournal: async (scope) => {
|
|
2914
2938
|
let vault;
|
|
2915
2939
|
try {
|
|
@@ -2918,7 +2942,7 @@ export async function startCodexBootstrapNativeHost(input) {
|
|
|
2918
2942
|
// The original ALS scope selects the scoped LocalVault overload.
|
|
2919
2943
|
vault = await openBootstrapVault({ root });
|
|
2920
2944
|
});
|
|
2921
|
-
completion = await createCodexBootstrapCompletionOwner(scope, vault);
|
|
2945
|
+
completion = await createCodexBootstrapCompletionOwner(scope, vault, observeFailure);
|
|
2922
2946
|
ownerScope = scope;
|
|
2923
2947
|
return Object.freeze({
|
|
2924
2948
|
claim: (operationId, intentDigest) => vault.claimCodexSetupOperation(operationId, intentDigest),
|
|
@@ -2947,6 +2971,7 @@ export async function startCodexBootstrapNativeHost(input) {
|
|
|
2947
2971
|
return false;
|
|
2948
2972
|
return completion.verify(receiptId, intent, digest);
|
|
2949
2973
|
}, });
|
|
2974
|
+
return Object.freeze({ ...host, get diagnostics() { return Object.freeze([...failures]); } });
|
|
2950
2975
|
}
|
|
2951
2976
|
async function bootstrap(flags, hostScope) {
|
|
2952
2977
|
const step = (operation) => hostScope ? hostScope.step(operation) : operation();
|