@dharma-ai-labs/agent-fabric 0.2.164 → 0.2.166
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/bootstrapRelayOrdering.test.js +20 -0
- package/dist/bootstrapRelayOrdering.test.js.map +1 -1
- 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/codexSetupSessionCaller.test.js +29 -4
- package/dist/codexSetupSessionCaller.test.js.map +1 -1
- package/dist/codexSetupSessionHandoff.d.ts +2 -0
- package/dist/codexSetupSessionHandoff.d.ts.map +1 -1
- package/dist/codexSetupSessionHandoff.js +9 -0
- package/dist/codexSetupSessionHandoff.js.map +1 -1
- package/dist/codexSetupSessionPolicy.test.d.ts +2 -0
- package/dist/codexSetupSessionPolicy.test.d.ts.map +1 -0
- package/dist/codexSetupSessionPolicy.test.js +133 -0
- package/dist/codexSetupSessionPolicy.test.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -30
- package/dist/index.js.map +1 -1
- package/dist/pidLock.test.js +111 -1
- package/dist/pidLock.test.js.map +1 -1
- package/dist/repositoryOnboardingCaller.test.js +2 -1
- package/dist/repositoryOnboardingCaller.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';
|
|
@@ -75,7 +76,7 @@ import { namedCodexEnvironment } from './namedCodexEnvironment.js';
|
|
|
75
76
|
import { namedCodexNodeOutputArguments } from './namedCodexNodeOutput.js';
|
|
76
77
|
import { namedCodexFilesystem } from './namedCodexFilesystem.js';
|
|
77
78
|
import { createNamedSessionChildOwner, currentNamedSessionChildOwner } from './namedSessionChildOwner.js';
|
|
78
|
-
import { awaitCodexSetupSession, consumeCodexSetupSessions, currentAcceptedSetupSessionScope, originalCodexSetupSessionSender, withCodexSetupSessionSender } from './codexSetupSessionHandoff.js';
|
|
79
|
+
import { awaitCodexSetupSession, codexSetupSessionPolicyHash, consumeCodexSetupSessions, currentAcceptedSetupSessionScope, originalCodexSetupSessionSender, withCodexSetupSessionSender } from './codexSetupSessionHandoff.js';
|
|
79
80
|
import { receiveCodexSetupChildStart, runCodexSetupChildStartup, sendCodexSetupChildStart } from './codexSetupChildStartup.js';
|
|
80
81
|
import { assertBootstrapHostSource, captureBootstrapHostChild, currentBootstrapHostScope, inspectCodexBootstrapHostPreparation, prepareCodexBootstrapHost, runCodexBootstrapHost, runCodexBootstrapHostScope } from './bootstrapHostScope.js';
|
|
81
82
|
// Trusted runtime composition only; these exports do not enable effectful setup.
|
|
@@ -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.166';
|
|
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) {
|
|
@@ -2314,7 +2323,7 @@ async function qualifyCodexSetupSessionSource(request) {
|
|
|
2314
2323
|
verifyServerAuthorizedPolicy({ policy, publicKeyEd25519: enrollment.serverPublicKeyEd25519,
|
|
2315
2324
|
organizationId: request.organizationId, workspaceId: request.workspaceId });
|
|
2316
2325
|
await assertWorkspaceAuthorizationCurrent(request.workspaceId, policy.serverAuthorization);
|
|
2317
|
-
if (policy.revision !== request.policyRevision ||
|
|
2326
|
+
if (policy.revision !== request.policyRevision || codexSetupSessionPolicyHash(policy) !== request.policyHash)
|
|
2318
2327
|
return false;
|
|
2319
2328
|
const fabric = await client();
|
|
2320
2329
|
await fetchRepositorySourceAuthorization(fabric, role);
|
|
@@ -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();
|
|
@@ -3237,9 +3262,9 @@ async function bootstrap(flags, hostScope) {
|
|
|
3237
3262
|
repository: onboarded,
|
|
3238
3263
|
};
|
|
3239
3264
|
}
|
|
3240
|
-
const launcher
|
|
3241
|
-
|
|
3242
|
-
|
|
3265
|
+
const { launcher, autostart } = flags.has('no-relay-daemon')
|
|
3266
|
+
? { launcher: await step(() => installStableRepositoryLauncher(workspace)),
|
|
3267
|
+
autostart: { state: 'disabled', backend: null } }
|
|
3243
3268
|
: await step(() => withOnboardingStage('autostart', String(onboarded.workspaceId || ''), `dharma bootstrap --resume --complete --portal-url ${hqUrl} --organization-id ${organizationId} --workspace . --policy-revision ${policyRevision}`
|
|
3244
3269
|
+ (joinedBindingId ? ` --join-repository-binding-id ${joinedBindingId} --join-source-fingerprint ${joinedFingerprint}` : ''), () => withRelayStartupMutation(async () => {
|
|
3245
3270
|
const home = dharmaHome();
|
|
@@ -3265,11 +3290,18 @@ async function bootstrap(flags, hostScope) {
|
|
|
3265
3290
|
if (canonical.length !== 1)
|
|
3266
3291
|
throw new Error('relay_workspace_conflict: startup policy route changed.');
|
|
3267
3292
|
await step(() => loadVerifiedWorkspacePolicy(anchor.policy, authorized.serverAuthorization?.workspaceId ?? ''));
|
|
3293
|
+
if (anchor.version !== VERSION) {
|
|
3294
|
+
throw new Error('relay_runtime_upgrade_required: upgrade the existing startup anchor before connecting another repository.');
|
|
3295
|
+
}
|
|
3268
3296
|
}
|
|
3269
3297
|
}
|
|
3270
|
-
|
|
3298
|
+
// Keep previous launcher bytes intact until startup ownership and version
|
|
3299
|
+
// admit this operation; the supported upgrade relies on those exact bytes.
|
|
3300
|
+
const launcher = await step(() => installStableRepositoryLauncher(workspace));
|
|
3301
|
+
const autostart = await step(() => enableRelayAutostart({ home, workspace, policy: resolve(workspace, '.dharma', 'approved-policy.json'),
|
|
3271
3302
|
launcher: resolve(workspace, process.platform === 'win32' ? launcher.windows : launcher.shell),
|
|
3272
3303
|
version: VERSION, preserveStandardAnchor: true }));
|
|
3304
|
+
return { launcher, autostart };
|
|
3273
3305
|
})));
|
|
3274
3306
|
let sharedRepositoryReady = onboarded.sharedRepositoryReady === true;
|
|
3275
3307
|
const completionRequested = flags.has('complete');
|
|
@@ -4666,7 +4698,7 @@ async function requestBootstrapNamedSession(hostScope, flags) {
|
|
|
4666
4698
|
organizationId: intent.organizationId, membershipId: intent.recipientMembershipId, deviceId: config.deviceId,
|
|
4667
4699
|
workspaceId, repositoryBindingId: role.repositoryBindingId, endpointId: role.endpointId, provider: 'codex',
|
|
4668
4700
|
origin: intent.origin, repositoryFingerprint: intent.repositoryFingerprint, policyRevision: policy.revision,
|
|
4669
|
-
policyHash:
|
|
4701
|
+
policyHash: codexSetupSessionPolicyHash(policy), scopeDigest: intent.scopeDigest, contractDigest: intent.contractDigest,
|
|
4670
4702
|
name, workspaceRoot: workspace, maximumCostCents: 1000, maximumTurnCostCents: 25,
|
|
4671
4703
|
issuedAt: new Date().toISOString(), expiresAt: new Date(Math.min(Date.parse(intent.expiresAt), Date.parse(policy.serverAuthorization.expiresAt))).toISOString() } });
|
|
4672
4704
|
await step(() => assertCodexSetupExecutionLease(sender.lease, intent));
|