@memnexus-ai/mx-agent-cli 0.1.295-next.0 → 0.1.296-next.0

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.
Files changed (53) hide show
  1. package/dist/__tests__/claude-local-sanitizer.test.d.ts +24 -0
  2. package/dist/__tests__/claude-local-sanitizer.test.d.ts.map +1 -0
  3. package/dist/__tests__/claude-local-sanitizer.test.js +906 -0
  4. package/dist/__tests__/claude-local-sanitizer.test.js.map +1 -0
  5. package/dist/__tests__/coordination-client.test.js +90 -1
  6. package/dist/__tests__/coordination-client.test.js.map +1 -1
  7. package/dist/__tests__/coordination-credential-endpoint.test.js +90 -30
  8. package/dist/__tests__/coordination-credential-endpoint.test.js.map +1 -1
  9. package/dist/__tests__/coordination-status-registration.test.js +8 -8
  10. package/dist/__tests__/coordination-status-registration.test.js.map +1 -1
  11. package/dist/__tests__/coordination-token-multitenant.test.js +14 -14
  12. package/dist/__tests__/coordination-token-multitenant.test.js.map +1 -1
  13. package/dist/__tests__/provision-completion-rows.test.js +96 -4
  14. package/dist/__tests__/provision-completion-rows.test.js.map +1 -1
  15. package/dist/__tests__/row15-detail-sanitizer.test.d.ts +20 -0
  16. package/dist/__tests__/row15-detail-sanitizer.test.d.ts.map +1 -0
  17. package/dist/__tests__/row15-detail-sanitizer.test.js +61 -0
  18. package/dist/__tests__/row15-detail-sanitizer.test.js.map +1 -0
  19. package/dist/commands/coordination.d.ts.map +1 -1
  20. package/dist/commands/coordination.js +5 -0
  21. package/dist/commands/coordination.js.map +1 -1
  22. package/dist/commands/create.d.ts +9 -0
  23. package/dist/commands/create.d.ts.map +1 -1
  24. package/dist/commands/create.js +98 -43
  25. package/dist/commands/create.js.map +1 -1
  26. package/dist/commands/start.d.ts.map +1 -1
  27. package/dist/commands/start.js +6 -0
  28. package/dist/commands/start.js.map +1 -1
  29. package/dist/lib/behavioral-injection.d.ts +9 -0
  30. package/dist/lib/behavioral-injection.d.ts.map +1 -1
  31. package/dist/lib/behavioral-injection.js +10 -1
  32. package/dist/lib/behavioral-injection.js.map +1 -1
  33. package/dist/lib/claude.d.ts +48 -0
  34. package/dist/lib/claude.d.ts.map +1 -1
  35. package/dist/lib/claude.js +172 -22
  36. package/dist/lib/claude.js.map +1 -1
  37. package/dist/lib/coordination-client.d.ts +29 -1
  38. package/dist/lib/coordination-client.d.ts.map +1 -1
  39. package/dist/lib/coordination-client.js +52 -0
  40. package/dist/lib/coordination-client.js.map +1 -1
  41. package/dist/lib/coordination-token.d.ts +42 -13
  42. package/dist/lib/coordination-token.d.ts.map +1 -1
  43. package/dist/lib/coordination-token.js +52 -28
  44. package/dist/lib/coordination-token.js.map +1 -1
  45. package/dist/lib/roster.d.ts +13 -1
  46. package/dist/lib/roster.d.ts.map +1 -1
  47. package/dist/lib/roster.js +7 -3
  48. package/dist/lib/roster.js.map +1 -1
  49. package/dist/lib/roster.test.js +4 -4
  50. package/dist/lib/roster.test.js.map +1 -1
  51. package/dist/lib/team-identity.js +2 -2
  52. package/dist/lib/team-identity.js.map +1 -1
  53. package/package.json +1 -1
@@ -431,11 +431,12 @@ vi.mock('../lib/project-config.js', () => ({
431
431
  })),
432
432
  }));
433
433
  vi.mock('../lib/config-generation.js', () => ({ checkConfigGeneration: vi.fn() }));
434
- import { runCreate, CompletionCheckError, __testing } from '../commands/create.js';
434
+ import { runCreate, CompletionCheckError, __testing, SELF_SERVICE_REFUSED_DETAIL } from '../commands/create.js';
435
435
  import { TEAM_BUILDER_ROLEGUIDE } from '../lib/templates.js';
436
436
  import { rosterEntryOnRef, rosterSourceHasSlug } from '../lib/roster.js';
437
437
  import { roleguideOnOriginMain } from '../lib/catalog.js';
438
438
  import { vaultTokenPresent } from '../lib/vault.js';
439
+ import { provisionCredentialForWorktree } from '../lib/coordination-token.js';
439
440
  import { BEHAVIORAL_START_MARKER, BEHAVIORAL_END_MARKER } from '../lib/behavioral-injection.js';
440
441
  const { checkCompletionRows, printCompletionRows } = __testing;
441
442
  class ExitCalled extends Error {
@@ -630,9 +631,13 @@ describe('completion check — the printed rows', () => {
630
631
  }
631
632
  expect(lines[7]).toMatch(/row 7: could not run/);
632
633
  expect(lines[7]).not.toMatch(/not asserted/);
633
- for (const n of [11, 12]) {
634
- expect(lines[n]).toMatch(/row \d+: not asserted/);
635
- }
634
+ expect(lines[11]).toMatch(/row 11: not asserted/);
635
+ // #507: this fixture's project, `mx-agent`, takes the credential endpoint
636
+ // and configures no URL, so the URL half of row 12 now resolves from the
637
+ // built-in mx-agent service URL. The roster-and-token half is still not
638
+ // checked, which is what `partly asserted` says.
639
+ expect(lines[12]).toMatch(/row 12: partly asserted/);
640
+ expect(lines[12]).toContain('coordination URL from default');
636
641
  });
637
642
  it('names what each unasserted row would have covered', async () => {
638
643
  await provision();
@@ -1514,6 +1519,8 @@ describe('completion check — row 12', () => {
1514
1519
  expect(row12).not.toContain('declares a different URL');
1515
1520
  });
1516
1521
  it('is not asserted when only the cwd project has a URL', async () => {
1522
+ // A Key Vault project: it has no #507 fallback, so an absent URL stays absent.
1523
+ credentialProjects = new Set();
1517
1524
  configuredCoordinationUrl = '';
1518
1525
  decoyCwdCoordinationUrl = 'https://some-other-repository.example';
1519
1526
  await provision();
@@ -1521,6 +1528,8 @@ describe('completion check — row 12', () => {
1521
1528
  expect(rowLines()[12]).toContain('no coordination-service-url in env, config, or mx-agent.config.json');
1522
1529
  });
1523
1530
  it('names the field that fixes it when no level holds a URL', async () => {
1531
+ // A Key Vault project: it has no #507 fallback, so an absent URL stays absent.
1532
+ credentialProjects = new Set();
1524
1533
  configuredCoordinationUrl = '';
1525
1534
  const { failure } = await provision();
1526
1535
  // Not asserted is not a failure: row 12 has never been required.
@@ -1531,6 +1540,15 @@ describe('completion check — row 12', () => {
1531
1540
  expect(row12).toContain('set coordinationServiceUrl in mx-agent.config.json');
1532
1541
  expect(row12).toContain('roster and token not checked (#15)');
1533
1542
  });
1543
+ it('a credential-endpoint project with no URL configured resolves the built-in mx-agent URL (#507)', async () => {
1544
+ configuredCoordinationUrl = '';
1545
+ const { failure } = await provision();
1546
+ expect(failure).toBeNull();
1547
+ const row12 = rowLines()[12];
1548
+ expect(row12).toMatch(/row 12: partly asserted/);
1549
+ expect(row12).toContain('coordination URL from default');
1550
+ expect(row12).toContain('roster and token not checked (#15)');
1551
+ });
1534
1552
  it('counts as not asserted either way, so the asserted total stays 12 of 15', async () => {
1535
1553
  configuredCoordinationUrl = 'https://coord.example.com';
1536
1554
  await provision();
@@ -1890,6 +1908,10 @@ describe('completion rows 9 and 10 — the coordination registration', () => {
1890
1908
  expect(failure).not.toBeNull();
1891
1909
  });
1892
1910
  it('row 10 asks for no credential until row 9 holds, and says which row it is waiting on', async () => {
1911
+ // A COMPILED credential-endpoint project: the roster file keys `mx-agent`
1912
+ // but not this team, so `absent`. The gate is unchanged by #507, which
1913
+ // lifts it only for a project the file keys no roster for (`project-absent`,
1914
+ // the tests below).
1893
1915
  rosterJsonState = 'absent';
1894
1916
  rosterSourceState = 'absent';
1895
1917
  credentialState = undefined;
@@ -1897,7 +1919,77 @@ describe('completion rows 9 and 10 — the coordination registration', () => {
1897
1919
  expect(line(10)).toMatch(/row 10: not asserted/);
1898
1920
  expect(line(10)).toContain('not token-eligible until the roster entry is on origin/main (row 9)');
1899
1921
  expect(line(10)).toContain('no credential requested');
1922
+ expect(vi.mocked(provisionCredentialForWorktree)).not.toHaveBeenCalled();
1923
+ expect(failure).not.toBeNull();
1924
+ });
1925
+ // ── A project the coordination service creates on login (#507) ────────────
1926
+ //
1927
+ // The roster file on the ref keys no roster for the project, so the project
1928
+ // is in no compiled roster and never will be. Row 10's credential request is
1929
+ // what registers the team, and row 9 is answered by it.
1930
+ it('#507: a login-created project requests the credential, holds rows 9 and 10, and prints Team Created!', async () => {
1931
+ rosterJsonState = 'project-absent';
1932
+ credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: 0o600 };
1933
+ const { failure } = await provision();
1934
+ expect(failure).toBeNull();
1935
+ expect(vi.mocked(provisionCredentialForWorktree)).toHaveBeenCalledTimes(1);
1936
+ expect(line(9)).toMatch(/row 9: asserted/);
1937
+ expect(line(9)).toContain('is in no compiled roster on origin/main');
1938
+ expect(line(9)).toContain('the credential request in row 10 succeeded');
1939
+ expect(line(9)).not.toContain('PROVISIONED_ROSTERS');
1940
+ expect(line(10)).toMatch(/row 10: asserted/);
1941
+ // The compiled-roster source is never consulted for such a project.
1942
+ expect(vi.mocked(rosterSourceHasSlug)).not.toHaveBeenCalled();
1943
+ expect(stdout.join('\n')).toContain('Team Created!');
1944
+ });
1945
+ it('#507: a refused login-created project names the owner rule, never the compiled roster', async () => {
1946
+ rosterJsonState = 'project-absent';
1947
+ credentialState = {
1948
+ kind: 'refused',
1949
+ reason: 'not-authorized',
1950
+ detail: 'this identity is not authorized to hold a credential for the requested team: no grant exists for it. '
1951
+ + 'An operator creates one with POST /admin/grant on the coordination service.',
1952
+ };
1953
+ const { failure } = await provision();
1954
+ expect(failure).not.toBeNull();
1955
+ expect(line(10)).toMatch(/row 10: not asserted/);
1956
+ expect(line(10)).toContain(SELF_SERVICE_REFUSED_DETAIL);
1957
+ expect(SELF_SERVICE_REFUSED_DETAIL).toContain("only the project's owner creates teams");
1958
+ expect(line(9)).toMatch(/row 9: not asserted/);
1959
+ expect(line(9)).toContain('it refused (row 10)');
1960
+ for (const n of [9, 10]) {
1961
+ expect(line(n)).not.toContain('PROVISIONED_ROSTERS');
1962
+ expect(line(n)).not.toContain('generate-rosters');
1963
+ expect(line(n)).not.toContain('(step 6a2)');
1964
+ }
1965
+ expect(stdout.join('\n')).not.toContain('Team Created!');
1966
+ });
1967
+ it('#507: a limit refusal on a login-created project reports the limit text unchanged', async () => {
1968
+ rosterJsonState = 'project-absent';
1969
+ credentialState = { kind: 'refused', reason: 'limit-reached', detail: 'LIMIT-TEXT' };
1970
+ const { failure } = await provision();
1900
1971
  expect(failure).not.toBeNull();
1972
+ expect(line(10)).toContain('LIMIT-TEXT');
1973
+ expect(line(10)).not.toContain(SELF_SERVICE_REFUSED_DETAIL);
1974
+ });
1975
+ it('#507: a login-created project whose request did not complete reads could-not-run on both rows', async () => {
1976
+ rosterJsonState = 'project-absent';
1977
+ credentialState = { kind: 'could-not-run', detail: 'the coordination service is UNAVAILABLE' };
1978
+ const { failure } = await provision();
1979
+ expect(failure).not.toBeNull();
1980
+ expect(line(9)).toMatch(/row 9: could not run/);
1981
+ expect(line(9)).toContain('did not complete');
1982
+ expect(line(10)).toMatch(/row 10: could not run/);
1983
+ });
1984
+ it('#507: a Key Vault project with no roster entry keeps the compiled-roster remedy', async () => {
1985
+ credentialProjects = new Set();
1986
+ rosterJsonState = 'project-absent';
1987
+ rosterSourceState = 'absent';
1988
+ const { failure } = await provision();
1989
+ expect(failure).not.toBeNull();
1990
+ expect(line(9)).toMatch(/row 9: not asserted/);
1991
+ expect(line(9)).toContain('PROVISIONED_ROSTERS');
1992
+ expect(vi.mocked(provisionCredentialForWorktree)).not.toHaveBeenCalled();
1901
1993
  });
1902
1994
  it('row 10 names an unreadable base ref as row 9\'s failure, not the credential\'s', async () => {
1903
1995
  rosterJsonState = 'unresolvable';