@dharma-ai-labs/agent-fabric 0.2.55 → 0.2.58

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.
@@ -7,11 +7,23 @@ import { join } from 'node:path';
7
7
  import test from 'node:test';
8
8
  import { fileURLToPath, pathToFileURL } from 'node:url';
9
9
  import { promisify } from 'node:util';
10
- import { acceptedTrajectoryHead, activateAgyPlugin, attestAgySkillActivation, attestHermesSkillBundleActivation, actionDecisionCapabilityFreshUntil, canonicalFilesystemPath, controlAgentDecisionUrl, installAvailableNativeAgentFabricBootstraps, assertCapsuleAuthorizedByCurrentPolicy, assertRecoveredTaskWorkspacePolicy, assertTaskWorkspacePolicy, assertTaskSkillPin, installNativeAgentFabricBootstrap, installClaudeReadOnlyProjectPermissions, installRepositoryAgentFabricSkill, isDirectExecution, isTransientBootstrapError, materializeWorkspacePolicy, applyServerEvidencePolicy, materializeInlineSkillFiles, validateSkillBundleSources, nativeSkillDirectory, normalizeGitRemoteIdentity, postTaskOutcome, parseCliOptions, parseSelectedProviderIds, pathExistsOrThrow, portalUrl, providerHintFromEnvironment, providerHintFromProcessArgv, probeRelayConnection, preflightBootstrapWorkspaceIdentity, rawLocalRetentionDays, requireCompletedBootstrapEvidence, retryBootstrapOnboarding, synchronizeBootstrapEvidence, deferUnavailableRelayRetention, recoverLegacySkillBundleIdAfterAuthorizationFailure, installedBundleIdForSkillPollAfterAuthorizationFailure, recoveredTaskPolicyWasSuperseded, relayProcessState, releaseDailyContentUpload, reserveDailyContentUpload, run, runAssistantCommand, sourceRepositoryFingerprint, stableRepositoryLauncherContents, summarizeBootstrapOrganizationApi, ensureAgyReadOnlyAttestationPermission, attestAgySkillBundleActivation, responseTextFromEvent, taskResponsePreview, taskReceiptSession, taskSkillPinFailureCode, verifyAgentFabricSkillInstallation, waitForRelayReadiness, withWorkspacePolicyRefreshLock, withWorkspaceSkillActivationLock, } from './index.js';
10
+ import { acceptedTrajectoryHead, activateAgyPlugin, attestAgySkillActivation, attestHermesSkillBundleActivation, actionDecisionCapabilityFreshUntil, canonicalFilesystemPath, controlAgentDecisionUrl, installAvailableNativeAgentFabricBootstraps, assertCapsuleAuthorizedByCurrentPolicy, assertRecoveredTaskWorkspacePolicy, assertTaskWorkspacePolicy, assertTaskSkillPin, installNativeAgentFabricBootstrap, installClaudeReadOnlyProjectPermissions, installRepositoryAgentFabricSkill, isDirectExecution, isTransientBootstrapError, loadOrCreateInstallationId, materializeWorkspacePolicy, applyServerEvidencePolicy, materializeInlineSkillFiles, validateSkillBundleSources, nativeSkillDirectory, normalizeGitRemoteIdentity, postTaskOutcome, parseCliOptions, parseSelectedProviderIds, pathExistsOrThrow, portalUrl, providerHintFromEnvironment, providerHintFromProcessArgv, probeRelayConnection, preflightBootstrapWorkspaceIdentity, rawLocalRetentionDays, requireCompletedBootstrapEvidence, retryBootstrapOnboarding, synchronizeBootstrapEvidence, deferUnavailableRelayRetention, recoverLegacySkillBundleIdAfterAuthorizationFailure, installedBundleIdForSkillPollAfterAuthorizationFailure, recoveredTaskPolicyWasSuperseded, relayProcessState, releaseDailyContentUpload, reserveDailyContentUpload, run, runAssistantCommand, sourceRepositoryFingerprint, stableRepositoryLauncherContents, summarizeBootstrapOrganizationApi, ensureAgyReadOnlyAttestationPermission, attestAgySkillBundleActivation, responseTextFromEvent, taskResponsePreview, taskReceiptSession, taskSkillPinFailureCode, verifyAgentFabricSkillInstallation, waitForRelayReadiness, withWorkspacePolicyRefreshLock, withWorkspaceSkillActivationLock, } from './index.js';
11
11
  import { canonicalize, signCanonicalObject } from '@dharma-ai-labs/agent-fabric-contracts';
12
12
  import { buildTrajectoryCapsule } from '@dharma-ai-labs/agent-fabric-evidence-reduction';
13
13
  import { CLI_USAGE } from './usage.js';
14
14
  import { isSupportedNodeVersion, launchWithRuntime, nodeRuntimeCandidates, runtimeBootstrapHint, } from './runtime-bootstrap.js';
15
+ test('installation identity is durable per DHARMA_HOME and rejects corrupt state', async () => {
16
+ const root = await mkdtemp(join(tmpdir(), 'dharma-installation-identity-'));
17
+ const path = join(root, 'installation.json');
18
+ const first = await loadOrCreateInstallationId(path);
19
+ const second = await loadOrCreateInstallationId(path);
20
+ assert.match(first, /^[0-9a-f-]{36}$/i);
21
+ assert.equal(second, first);
22
+ if (process.platform !== 'win32')
23
+ assert.equal((await stat(path)).mode & 0o777, 0o600);
24
+ await writeFile(path, '{"schema":"dharma.installation-identity/v1","installationId":"invalid"}\n');
25
+ await assert.rejects(loadOrCreateInstallationId(path), /Installation identity is invalid/);
26
+ });
15
27
  const execFileAsync = promisify(execFile);
16
28
  test('bootstrap retries transient relay failures without retrying validation failures', async () => {
17
29
  const waits = [];
@@ -1555,13 +1567,13 @@ test('relay probe opens an authenticated session without polling or leasing work
1555
1567
  },
1556
1568
  openSession: async (version) => {
1557
1569
  sessions += 1;
1558
- assert.equal(version, '0.2.55');
1570
+ assert.equal(version, '0.2.58');
1559
1571
  return { ok: true };
1560
1572
  },
1561
1573
  }));
1562
1574
  assert.equal(sessions, 1);
1563
1575
  assert.deepEqual(result, {
1564
- ok: true, connected: true, organizationId: 'org_test', deviceId: 'device_test', relayVersion: '0.2.55',
1576
+ ok: true, connected: true, organizationId: 'org_test', deviceId: 'device_test', relayVersion: '0.2.58',
1565
1577
  });
1566
1578
  });
1567
1579
  test('relay probe fails closed when the server does not acknowledge the session', async () => {
@@ -1681,6 +1693,59 @@ test('native bootstrap installation makes the repository skill verifiable by Cod
1681
1693
  assert.equal(verified.repositoryInstalled, true);
1682
1694
  assert.equal(verified.nativeInstalled, true);
1683
1695
  });
1696
+ test('signed native ownership remains installed after bootstrap replacement', async () => {
1697
+ const root = await mkdtemp(join(tmpdir(), 'dharma-signed-native-skill-'));
1698
+ const home = join(root, 'home');
1699
+ const workspace = join(root, 'repo');
1700
+ const workspaceId = 'workspace_test';
1701
+ await mkdir(workspace, { recursive: true });
1702
+ await installRepositoryAgentFabricSkill({
1703
+ workspace,
1704
+ hqUrl: 'https://www.dharma-ai.io',
1705
+ organizationId: 'org_test',
1706
+ workspaceId,
1707
+ policyRevision: 'agent-fabric-policy-v1',
1708
+ });
1709
+ const skillRoot = join(nativeSkillDirectory('codex', {}, home), 'dharma-agent-fabric');
1710
+ await mkdir(skillRoot, { recursive: true });
1711
+ await writeFile(join(skillRoot, 'SKILL.md'), '# Signed managed skill\n');
1712
+ await writeFile(join(skillRoot, '.dharma-agent-fabric.json'), JSON.stringify({
1713
+ bundleId: '11111111-1111-4111-8111-111111111111',
1714
+ skillId: 'dharma-agent-fabric',
1715
+ workspaceId,
1716
+ }));
1717
+ const verified = await verifyAgentFabricSkillInstallation({ provider: 'codex', workspace, home });
1718
+ assert.equal(verified.ready, true);
1719
+ assert.equal(verified.nativeInstalled, true);
1720
+ assert.equal(verified.nativeManaged, true);
1721
+ assert.equal(verified.nativeDiscovered, true);
1722
+ assert.equal(verified.signedLifecycleReady, false);
1723
+ });
1724
+ test('signed native ownership rejects a foreign workspace marker', async () => {
1725
+ const root = await mkdtemp(join(tmpdir(), 'dharma-foreign-signed-native-skill-'));
1726
+ const home = join(root, 'home');
1727
+ const workspace = join(root, 'repo');
1728
+ await mkdir(workspace, { recursive: true });
1729
+ await installRepositoryAgentFabricSkill({
1730
+ workspace,
1731
+ hqUrl: 'https://www.dharma-ai.io',
1732
+ organizationId: 'org_test',
1733
+ workspaceId: 'workspace_test',
1734
+ policyRevision: 'agent-fabric-policy-v1',
1735
+ });
1736
+ const skillRoot = join(nativeSkillDirectory('codex', {}, home), 'dharma-agent-fabric');
1737
+ await mkdir(skillRoot, { recursive: true });
1738
+ await writeFile(join(skillRoot, 'SKILL.md'), '# Foreign managed skill\n');
1739
+ await writeFile(join(skillRoot, '.dharma-agent-fabric.json'), JSON.stringify({
1740
+ bundleId: '11111111-1111-4111-8111-111111111111',
1741
+ skillId: 'dharma-agent-fabric',
1742
+ workspaceId: 'workspace_foreign',
1743
+ }));
1744
+ const verified = await verifyAgentFabricSkillInstallation({ provider: 'codex', workspace, home });
1745
+ assert.equal(verified.ready, false);
1746
+ assert.equal(verified.nativeInstalled, false);
1747
+ assert.equal(verified.nativeManaged, false);
1748
+ });
1684
1749
  test('native Claude bootstrap installs the bounded project completion policy', async () => {
1685
1750
  const root = await mkdtemp(join(tmpdir(), 'dharma-native-claude-skill-'));
1686
1751
  const home = join(root, 'home');