@namzu/cli 2.0.0 → 2.1.1

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 (176) hide show
  1. package/dist/tui/App.d.ts.map +1 -1
  2. package/dist/tui/App.js +8 -0
  3. package/dist/tui/App.js.map +1 -1
  4. package/dist/tui/agent.d.ts +10 -0
  5. package/dist/tui/agent.d.ts.map +1 -1
  6. package/dist/tui/agent.js +10 -0
  7. package/dist/tui/agent.js.map +1 -1
  8. package/dist/tui/slashCommands.d.ts +46 -0
  9. package/dist/tui/slashCommands.d.ts.map +1 -1
  10. package/dist/tui/slashCommands.js +96 -0
  11. package/dist/tui/slashCommands.js.map +1 -1
  12. package/package.json +11 -6
  13. package/dist/__tests__/environment-reaches-the-turn.test.d.ts +0 -17
  14. package/dist/__tests__/environment-reaches-the-turn.test.d.ts.map +0 -1
  15. package/dist/__tests__/environment-reaches-the-turn.test.js +0 -128
  16. package/dist/__tests__/environment-reaches-the-turn.test.js.map +0 -1
  17. package/dist/__tests__/headless-trust-gate.test.d.ts +0 -23
  18. package/dist/__tests__/headless-trust-gate.test.d.ts.map +0 -1
  19. package/dist/__tests__/headless-trust-gate.test.js +0 -227
  20. package/dist/__tests__/headless-trust-gate.test.js.map +0 -1
  21. package/dist/__tests__/mcp-servers-reach-the-session.test.d.ts +0 -17
  22. package/dist/__tests__/mcp-servers-reach-the-session.test.d.ts.map +0 -1
  23. package/dist/__tests__/mcp-servers-reach-the-session.test.js +0 -171
  24. package/dist/__tests__/mcp-servers-reach-the-session.test.js.map +0 -1
  25. package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts +0 -31
  26. package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts.map +0 -1
  27. package/dist/__tests__/permission-rules-reach-the-turn.test.js +0 -132
  28. package/dist/__tests__/permission-rules-reach-the-turn.test.js.map +0 -1
  29. package/dist/__tests__/project-instructions-reach-the-turn.test.d.ts +0 -24
  30. package/dist/__tests__/project-instructions-reach-the-turn.test.d.ts.map +0 -1
  31. package/dist/__tests__/project-instructions-reach-the-turn.test.js +0 -153
  32. package/dist/__tests__/project-instructions-reach-the-turn.test.js.map +0 -1
  33. package/dist/cli.test.d.ts +0 -2
  34. package/dist/cli.test.d.ts.map +0 -1
  35. package/dist/cli.test.js +0 -108
  36. package/dist/cli.test.js.map +0 -1
  37. package/dist/commands/__tests__/eval.test.d.ts +0 -2
  38. package/dist/commands/__tests__/eval.test.d.ts.map +0 -1
  39. package/dist/commands/__tests__/eval.test.js +0 -165
  40. package/dist/commands/__tests__/eval.test.js.map +0 -1
  41. package/dist/commands/__tests__/passthrough-help.test.d.ts +0 -2
  42. package/dist/commands/__tests__/passthrough-help.test.d.ts.map +0 -1
  43. package/dist/commands/__tests__/passthrough-help.test.js +0 -96
  44. package/dist/commands/__tests__/passthrough-help.test.js.map +0 -1
  45. package/dist/commands/__tests__/resume.test.d.ts +0 -15
  46. package/dist/commands/__tests__/resume.test.d.ts.map +0 -1
  47. package/dist/commands/__tests__/resume.test.js +0 -116
  48. package/dist/commands/__tests__/resume.test.js.map +0 -1
  49. package/dist/commands/__tests__/run-exit-code.test.d.ts +0 -2
  50. package/dist/commands/__tests__/run-exit-code.test.d.ts.map +0 -1
  51. package/dist/commands/__tests__/run-exit-code.test.js +0 -100
  52. package/dist/commands/__tests__/run-exit-code.test.js.map +0 -1
  53. package/dist/commands/__tests__/run-flags.test.d.ts +0 -11
  54. package/dist/commands/__tests__/run-flags.test.d.ts.map +0 -1
  55. package/dist/commands/__tests__/run-flags.test.js +0 -238
  56. package/dist/commands/__tests__/run-flags.test.js.map +0 -1
  57. package/dist/commands/__tests__/run-stream-flags.test.d.ts +0 -2
  58. package/dist/commands/__tests__/run-stream-flags.test.d.ts.map +0 -1
  59. package/dist/commands/__tests__/run-stream-flags.test.js +0 -295
  60. package/dist/commands/__tests__/run-stream-flags.test.js.map +0 -1
  61. package/dist/commands/doctor.test.d.ts +0 -2
  62. package/dist/commands/doctor.test.d.ts.map +0 -1
  63. package/dist/commands/doctor.test.js +0 -82
  64. package/dist/commands/doctor.test.js.map +0 -1
  65. package/dist/config/load.test.d.ts +0 -2
  66. package/dist/config/load.test.d.ts.map +0 -1
  67. package/dist/config/load.test.js +0 -57
  68. package/dist/config/load.test.js.map +0 -1
  69. package/dist/context/__tests__/environment.test.d.ts +0 -10
  70. package/dist/context/__tests__/environment.test.d.ts.map +0 -1
  71. package/dist/context/__tests__/environment.test.js +0 -84
  72. package/dist/context/__tests__/environment.test.js.map +0 -1
  73. package/dist/context/__tests__/project.test.d.ts +0 -12
  74. package/dist/context/__tests__/project.test.d.ts.map +0 -1
  75. package/dist/context/__tests__/project.test.js +0 -201
  76. package/dist/context/__tests__/project.test.js.map +0 -1
  77. package/dist/doctor/checks/credentials.test.d.ts +0 -10
  78. package/dist/doctor/checks/credentials.test.d.ts.map +0 -1
  79. package/dist/doctor/checks/credentials.test.js +0 -47
  80. package/dist/doctor/checks/credentials.test.js.map +0 -1
  81. package/dist/doctor/checks/sandbox.test.d.ts +0 -2
  82. package/dist/doctor/checks/sandbox.test.d.ts.map +0 -1
  83. package/dist/doctor/checks/sandbox.test.js +0 -59
  84. package/dist/doctor/checks/sandbox.test.js.map +0 -1
  85. package/dist/doctor/registry.test.d.ts +0 -7
  86. package/dist/doctor/registry.test.d.ts.map +0 -1
  87. package/dist/doctor/registry.test.js +0 -379
  88. package/dist/doctor/registry.test.js.map +0 -1
  89. package/dist/integrations/mcp/__tests__/connect.test.d.ts +0 -11
  90. package/dist/integrations/mcp/__tests__/connect.test.d.ts.map +0 -1
  91. package/dist/integrations/mcp/__tests__/connect.test.js +0 -231
  92. package/dist/integrations/mcp/__tests__/connect.test.js.map +0 -1
  93. package/dist/integrations/providers/discover.test.d.ts +0 -2
  94. package/dist/integrations/providers/discover.test.d.ts.map +0 -1
  95. package/dist/integrations/providers/discover.test.js +0 -93
  96. package/dist/integrations/providers/discover.test.js.map +0 -1
  97. package/dist/integrations/providers/keychain.test.d.ts +0 -2
  98. package/dist/integrations/providers/keychain.test.d.ts.map +0 -1
  99. package/dist/integrations/providers/keychain.test.js +0 -21
  100. package/dist/integrations/providers/keychain.test.js.map +0 -1
  101. package/dist/integrations/providers/oauth.test.d.ts +0 -2
  102. package/dist/integrations/providers/oauth.test.d.ts.map +0 -1
  103. package/dist/integrations/providers/oauth.test.js +0 -86
  104. package/dist/integrations/providers/oauth.test.js.map +0 -1
  105. package/dist/integrations/providers/preferences.test.d.ts +0 -2
  106. package/dist/integrations/providers/preferences.test.d.ts.map +0 -1
  107. package/dist/integrations/providers/preferences.test.js +0 -76
  108. package/dist/integrations/providers/preferences.test.js.map +0 -1
  109. package/dist/integrations/sessions/__tests__/archived-workspace.test.d.ts +0 -21
  110. package/dist/integrations/sessions/__tests__/archived-workspace.test.d.ts.map +0 -1
  111. package/dist/integrations/sessions/__tests__/archived-workspace.test.js +0 -62
  112. package/dist/integrations/sessions/__tests__/archived-workspace.test.js.map +0 -1
  113. package/dist/integrations/subagents/__tests__/delegation-trace.test.d.ts +0 -2
  114. package/dist/integrations/subagents/__tests__/delegation-trace.test.d.ts.map +0 -1
  115. package/dist/integrations/subagents/__tests__/delegation-trace.test.js +0 -114
  116. package/dist/integrations/subagents/__tests__/delegation-trace.test.js.map +0 -1
  117. package/dist/integrations/trust/store.test.d.ts +0 -2
  118. package/dist/integrations/trust/store.test.d.ts.map +0 -1
  119. package/dist/integrations/trust/store.test.js +0 -50
  120. package/dist/integrations/trust/store.test.js.map +0 -1
  121. package/dist/memory/store.test.d.ts +0 -2
  122. package/dist/memory/store.test.d.ts.map +0 -1
  123. package/dist/memory/store.test.js +0 -63
  124. package/dist/memory/store.test.js.map +0 -1
  125. package/dist/output/formatter.test.d.ts +0 -2
  126. package/dist/output/formatter.test.d.ts.map +0 -1
  127. package/dist/output/formatter.test.js +0 -88
  128. package/dist/output/formatter.test.js.map +0 -1
  129. package/dist/output/rendered-payload.test.d.ts +0 -2
  130. package/dist/output/rendered-payload.test.d.ts.map +0 -1
  131. package/dist/output/rendered-payload.test.js +0 -61
  132. package/dist/output/rendered-payload.test.js.map +0 -1
  133. package/dist/permissions/__tests__/mode.test.d.ts +0 -10
  134. package/dist/permissions/__tests__/mode.test.d.ts.map +0 -1
  135. package/dist/permissions/__tests__/mode.test.js +0 -115
  136. package/dist/permissions/__tests__/mode.test.js.map +0 -1
  137. package/dist/permissions/__tests__/rules.test.d.ts +0 -10
  138. package/dist/permissions/__tests__/rules.test.d.ts.map +0 -1
  139. package/dist/permissions/__tests__/rules.test.js +0 -196
  140. package/dist/permissions/__tests__/rules.test.js.map +0 -1
  141. package/dist/skills/store.test.d.ts +0 -2
  142. package/dist/skills/store.test.d.ts.map +0 -1
  143. package/dist/skills/store.test.js +0 -80
  144. package/dist/skills/store.test.js.map +0 -1
  145. package/dist/tui/__tests__/context-gauge.test.d.ts +0 -2
  146. package/dist/tui/__tests__/context-gauge.test.d.ts.map +0 -1
  147. package/dist/tui/__tests__/context-gauge.test.js +0 -83
  148. package/dist/tui/__tests__/context-gauge.test.js.map +0 -1
  149. package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts +0 -24
  150. package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts.map +0 -1
  151. package/dist/tui/__tests__/deferred-tool-discovery.test.js +0 -111
  152. package/dist/tui/__tests__/deferred-tool-discovery.test.js.map +0 -1
  153. package/dist/tui/__tests__/to-agent-event.test.d.ts +0 -2
  154. package/dist/tui/__tests__/to-agent-event.test.d.ts.map +0 -1
  155. package/dist/tui/__tests__/to-agent-event.test.js +0 -230
  156. package/dist/tui/__tests__/to-agent-event.test.js.map +0 -1
  157. package/dist/tui/__tests__/working-directory.test.d.ts +0 -13
  158. package/dist/tui/__tests__/working-directory.test.d.ts.map +0 -1
  159. package/dist/tui/__tests__/working-directory.test.js +0 -109
  160. package/dist/tui/__tests__/working-directory.test.js.map +0 -1
  161. package/dist/tui/agent.test.d.ts +0 -2
  162. package/dist/tui/agent.test.d.ts.map +0 -1
  163. package/dist/tui/agent.test.js +0 -225
  164. package/dist/tui/agent.test.js.map +0 -1
  165. package/dist/tui/markdownParser.test.d.ts +0 -2
  166. package/dist/tui/markdownParser.test.d.ts.map +0 -1
  167. package/dist/tui/markdownParser.test.js +0 -90
  168. package/dist/tui/markdownParser.test.js.map +0 -1
  169. package/dist/tui/mentions.test.d.ts +0 -2
  170. package/dist/tui/mentions.test.d.ts.map +0 -1
  171. package/dist/tui/mentions.test.js +0 -35
  172. package/dist/tui/mentions.test.js.map +0 -1
  173. package/dist/tui/slashCommands.test.d.ts +0 -2
  174. package/dist/tui/slashCommands.test.d.ts.map +0 -1
  175. package/dist/tui/slashCommands.test.js +0 -114
  176. package/dist/tui/slashCommands.test.js.map +0 -1
@@ -1,111 +0,0 @@
1
- /**
2
- * `search_tools` is mounted where there is something to find, and not where
3
- * there is not.
4
- *
5
- * The two registries come from the same builder, so "does the CLI register
6
- * search_tools" has one answer from one call site and a different correct
7
- * answer from the other — the shape that hides behind a green suite. The
8
- * session passes a `taskStore`, so `query()` registers the task tools deferred
9
- * and the search has a roster of three. A sub-agent is built with no task
10
- * store, so nothing in its registry is deferred and the tool could only ever
11
- * answer "no deferred tools matching X" — a capability advertised every turn
12
- * that costs a turn to discover it is unusable.
13
- *
14
- * Removing the peer-daemon catalog is what created the asymmetry: that catalog
15
- * used to supply BOTH registries, so both were justified in mounting the tool.
16
- * Only one lost its supplier, and from the side that still works the loss is
17
- * invisible.
18
- *
19
- * So this asserts the CONTRAST, not either half: a test that only checked the
20
- * session would pass with the tool wrongly mounted on the sub-agent, which is
21
- * exactly the state this file was written against.
22
- */
23
- import { mkdtempSync, rmSync } from 'node:fs';
24
- import { tmpdir } from 'node:os';
25
- import { join } from 'node:path';
26
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
27
- vi.mock('@namzu/sdk', async (importOriginal) => {
28
- const actual = await importOriginal();
29
- return {
30
- ...actual,
31
- query: () => (async function* () { })(),
32
- };
33
- });
34
- // The sub-agent's registry is built by a callback the session hands to this
35
- // factory, so capturing the callback is the only way to see what a sub-agent
36
- // would actually get — and it is the real wiring, not a re-derivation of it.
37
- let capturedBuildTools = null;
38
- vi.mock('../../integrations/subagents/runtime.js', () => ({
39
- createSubagentRuntime: async (opts) => {
40
- capturedBuildTools = opts.buildTools;
41
- return {
42
- gateway: {},
43
- agentTool: {
44
- name: 'Agent',
45
- description: 'stub',
46
- inputSchema: { type: 'object', properties: {} },
47
- execute: async () => ({ success: true, output: '' }),
48
- },
49
- allowedAgentIds: [],
50
- };
51
- },
52
- }));
53
- let workDir;
54
- beforeEach(() => {
55
- capturedBuildTools = null;
56
- workDir = mkdtempSync(join(tmpdir(), 'namzu-deferred-'));
57
- });
58
- afterEach(() => {
59
- rmSync(workDir, { recursive: true, force: true });
60
- });
61
- const prefs = {
62
- version: 2,
63
- provider: 'anthropic',
64
- subagents: { active: [] },
65
- };
66
- function detectedAnthropic() {
67
- return [
68
- {
69
- entry: {
70
- id: 'anthropic',
71
- label: 'Anthropic',
72
- defaultModel: 'claude-sonnet-4-5',
73
- requiresApiKey: true,
74
- envVars: ['ANTHROPIC_API_KEY'],
75
- },
76
- source: 'env',
77
- apiKey: 'sk-ant-not-a-real-key',
78
- alternatives: [],
79
- },
80
- ];
81
- }
82
- describe('search_tools is mounted only where a deferred roster exists', () => {
83
- it('the session offers it and a sub-agent does not', async () => {
84
- const { createAgentSession } = await import('../agent.js');
85
- const session = await createAgentSession(prefs, detectedAnthropic(), { cwd: workDir });
86
- expect(session.hasProvider).toBe(true);
87
- // The session opens a task store, so query() defers the task tools and
88
- // the search has a roster.
89
- expect(session.toolNames).toContain('search_tools');
90
- expect(capturedBuildTools, 'the session must hand the sub-agent factory a tool builder').not.toBeNull();
91
- const subagentTools = capturedBuildTools();
92
- const subagentNames = subagentTools.listNames();
93
- // The whole point: same builder, and this side must NOT have it.
94
- expect(subagentNames).not.toContain('search_tools');
95
- // And the sub-agent is not stripped of everything else in the process —
96
- // an assertion that would still hold if `buildTools` returned an empty
97
- // registry, which would "pass" the line above for the wrong reason.
98
- expect(subagentNames).toContain('bash');
99
- expect(subagentNames).toContain('read');
100
- });
101
- it('leaves the sub-agent nothing deferred, which is why the tool is withheld', async () => {
102
- const { createAgentSession } = await import('../agent.js');
103
- await createAgentSession(prefs, detectedAnthropic(), { cwd: workDir });
104
- const subagentTools = capturedBuildTools();
105
- const deferred = subagentTools
106
- .listNames()
107
- .filter((n) => subagentTools.getAvailability(n) === 'deferred');
108
- expect(deferred).toEqual([]);
109
- });
110
- });
111
- //# sourceMappingURL=deferred-tool-discovery.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deferred-tool-discovery.test.js","sourceRoot":"","sources":["../../../src/tui/__tests__/deferred-tool-discovery.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAMxE,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAC9C,MAAM,MAAM,GAAG,MAAM,cAAc,EAA+B,CAAA;IAClE,OAAO;QACN,GAAG,MAAM;QACT,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,MAAK,CAAC,CAAC,EAAE;KACtC,CAAA;AACF,CAAC,CAAC,CAAA;AAEF,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,IAAI,kBAAkB,GAAwC,IAAI,CAAA;AAClE,EAAE,CAAC,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,CAAC;IACzD,qBA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,MAAM,QAAQ,GAAG,aAAa;aAC5B,SAAS,EAAE;aACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAA;QAChE,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=to-agent-event.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to-agent-event.test.d.ts","sourceRoot":"","sources":["../../../src/tui/__tests__/to-agent-event.test.ts"],"names":[],"mappings":""}
@@ -1,230 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { toAgentEvent } from '../agent.js';
3
- /**
4
- * The seam between the kernel and the command.
5
- *
6
- * The SDK test proves `run_completed` carries a stop reason and the `run` test
7
- * proves the command acts on one, and both of those passed while this function
8
- * threw the field away in between — the mutation that reverted it to a bare
9
- * `{ kind: 'done' }` was caught by nothing. Two tested ends and an untested
10
- * middle is the shape that lets a value be produced and consumed and still
11
- * never arrive.
12
- */
13
- const runId = 'run_test';
14
- describe('toAgentEvent carries the stop reason across', () => {
15
- it('passes a non-normal stop through to the done event', () => {
16
- const mapped = toAgentEvent({
17
- type: 'run_completed',
18
- runId,
19
- result: '',
20
- stopReason: 'output_guardrail',
21
- });
22
- expect(mapped).toEqual({ kind: 'done', stopReason: 'output_guardrail' });
23
- });
24
- it('passes end_turn through rather than inventing it downstream', () => {
25
- // The command treats a MISSING reason as success, so the difference
26
- // between "finished normally" and "we did not say" must be preserved
27
- // here rather than reconstructed by whoever reads it.
28
- const mapped = toAgentEvent({
29
- type: 'run_completed',
30
- runId,
31
- result: 'hi',
32
- stopReason: 'end_turn',
33
- });
34
- expect(mapped).toEqual({ kind: 'done', stopReason: 'end_turn' });
35
- });
36
- it('still maps a completion that carries no reason', () => {
37
- const mapped = toAgentEvent({ type: 'run_completed', runId, result: 'hi' });
38
- expect(mapped).toEqual({ kind: 'done' });
39
- });
40
- it('maps a failure to an error, not to done', () => {
41
- const mapped = toAgentEvent({
42
- type: 'run_failed',
43
- runId,
44
- error: 'boom',
45
- });
46
- expect(mapped).toEqual({ kind: 'error', message: 'boom' });
47
- });
48
- });
49
- describe('compaction is reported, not silent', () => {
50
- // Compaction deletes messages irrecoverably. The kernel emits both outcomes
51
- // specifically so a host can surface the loss; this host used to drop them
52
- // at `default: return null`, one function from the screen.
53
- it('says which counts became which, and nothing it cannot substantiate', () => {
54
- const mapped = toAgentEvent({
55
- type: 'compaction_completed',
56
- runId: 'run_1',
57
- iteration: 3,
58
- messagesBefore: 42,
59
- messagesAfter: 9,
60
- tokensBefore: 120_000,
61
- tokensAfter: 38_000,
62
- measuredBy: 'provider',
63
- contextWindowTokens: 200_000,
64
- windowSource: 'model-table',
65
- reachedResetThreshold: true,
66
- });
67
- expect(mapped).toMatchObject({ kind: 'context', shed: true });
68
- const text = mapped.text;
69
- expect(text).toContain('42');
70
- expect(text).toContain('9');
71
- expect(text).toContain('120k');
72
- // It must NOT claim to know what was lost — only the counts are checkable.
73
- expect(text).not.toMatch(/turns? \d+-\d+|removed the/i);
74
- });
75
- it('marks an estimate as an estimate', () => {
76
- // Quoting an estimate as a measurement is the same lie as quoting a
77
- // summary as an enumeration, in miniature.
78
- const mapped = toAgentEvent({
79
- type: 'compaction_completed',
80
- runId: 'run_1',
81
- iteration: 3,
82
- messagesBefore: 10,
83
- messagesAfter: 4,
84
- tokensBefore: 9000,
85
- tokensAfter: 3000,
86
- measuredBy: 'estimate',
87
- contextWindowTokens: 200_000,
88
- windowSource: 'default',
89
- reachedResetThreshold: false,
90
- });
91
- expect(mapped.text).toContain('estimated');
92
- });
93
- });
94
- describe('the three decline causes get three sentences', () => {
95
- // Collapsing them into "compaction failed" puts the reader back where the
96
- // silence did — the same reason a rule denial had to quote the rule.
97
- function failure(cause, error) {
98
- const mapped = toAgentEvent({
99
- type: 'compaction_failed',
100
- runId: 'run_1',
101
- iteration: 2,
102
- cause,
103
- messages: 31,
104
- ...(error ? { error } : {}),
105
- });
106
- expect(mapped).toMatchObject({ kind: 'context', shed: false });
107
- return mapped.text;
108
- }
109
- it('a thrown reducer may work next time, and carries its own error', () => {
110
- const text = failure('reducer_threw', 'provider returned 400');
111
- expect(text).toContain('provider returned 400');
112
- expect(text).toContain('a later pass may succeed');
113
- });
114
- it('shedding nothing is a fact, not an error, and will not change', () => {
115
- const text = failure('shed_nothing');
116
- expect(text).toContain('later passes will answer the same');
117
- // Not dressed as a failure: an irreducible history is a true statement
118
- // about the conversation, and calling it one sends someone hunting a
119
- // bug that is not there.
120
- expect(text).not.toMatch(/failed|error/i);
121
- });
122
- it('a split tool pair is a reducer bug and suggests no user action', () => {
123
- const text = failure('split_tool_pair');
124
- expect(text).toContain('bug in the reducer');
125
- expect(text).not.toMatch(/try again|later pass|retry/i);
126
- });
127
- it('every cause states the history is unchanged', () => {
128
- for (const cause of ['reducer_threw', 'shed_nothing', 'split_tool_pair']) {
129
- expect(failure(cause)).toContain('31 messages unchanged');
130
- }
131
- });
132
- it('no two causes produce the same sentence', () => {
133
- const texts = ['reducer_threw', 'shed_nothing', 'split_tool_pair'].map((c) => failure(c));
134
- expect(new Set(texts).size).toBe(3);
135
- });
136
- });
137
- /**
138
- * A tool the summary list does not know still gets a label, not a blob.
139
- *
140
- * `Agent` requires a `description` on its schema — the model writes one every
141
- * call — and the summariser picked from a key list that did not include it, so
142
- * a delegation was rendered as a truncated `JSON.stringify` of its own
143
- * arguments. The label was demanded and then discarded.
144
- *
145
- * Driven through `toAgentEvent` rather than the summariser directly: the
146
- * helper's own behaviour was never in doubt, only whether the caller reaches
147
- * it with this input.
148
- */
149
- describe('toAgentEvent labels a delegation with the label it required', () => {
150
- const executing = (toolName, input) => toAgentEvent({ type: 'tool_executing', toolName, toolUseId: 'tu_1', input });
151
- it('summarises an Agent call with its description', () => {
152
- const mapped = executing('Agent', {
153
- description: 'Audit the auth flow',
154
- prompt: 'Read every file under src/auth and report risks.',
155
- role: 'You are a security auditor',
156
- });
157
- expect(mapped).toMatchObject({ summary: 'Audit the auth flow' });
158
- });
159
- it('does not render the arguments as JSON', () => {
160
- const mapped = executing('Agent', { description: 'Audit the auth flow', prompt: 'x' });
161
- expect(mapped.summary).not.toContain('{');
162
- expect(mapped.summary).not.toContain('prompt');
163
- });
164
- it('still prefers a more specific field when one exists', () => {
165
- // `description` is the LAST fallback. A tool with a real subject keeps
166
- // it, so adding this key cannot quietly relabel the tools that already
167
- // summarised correctly.
168
- const mapped = executing('bash', { command: 'ls -la', description: 'list files' });
169
- expect(mapped).toMatchObject({ summary: 'ls -la' });
170
- });
171
- });
172
- /**
173
- * The context figures cross the same seam, and used to stop at it.
174
- *
175
- * The kernel measured the context and resolved a window; the status gauge
176
- * consumed a fraction. Both ends worked. This function threw the four fields
177
- * away in between, so the gauge fell back to dividing CUMULATIVE spend by a
178
- * window guessed from the model name — a number that rose with turn count and
179
- * read FULL on a conversation with room left. Producing a value and consuming
180
- * one are not the same as carrying it.
181
- */
182
- describe('toAgentEvent carries the context figures across', () => {
183
- const usageEvent = (extra) => toAgentEvent({
184
- type: 'token_usage_updated',
185
- runId,
186
- usage: { totalTokens: 90 },
187
- cost: { totalCost: 0.5 },
188
- ...extra,
189
- });
190
- it('carries both terms and both provenances', () => {
191
- expect(usageEvent({
192
- contextTokens: 12_000,
193
- contextMeasuredBy: 'provider',
194
- contextWindowTokens: 200_000,
195
- windowSource: 'model-table',
196
- })).toEqual({
197
- kind: 'usage',
198
- totalTokens: 90,
199
- costUsd: 0.5,
200
- contextTokens: 12_000,
201
- contextMeasuredBy: 'provider',
202
- contextWindowTokens: 200_000,
203
- windowSource: 'model-table',
204
- });
205
- });
206
- it('leaves an unreported context absent rather than zero', () => {
207
- // The kernel omits all four when a run resolved no window. A `0` here
208
- // would be indistinguishable from an empty context and would render a
209
- // gauge reading 0% — a confident wrong answer where the contract is
210
- // to show no proportion at all.
211
- const mapped = usageEvent({});
212
- expect(mapped).toEqual({ kind: 'usage', totalTokens: 90, costUsd: 0.5 });
213
- expect(mapped).not.toHaveProperty('contextTokens');
214
- expect(mapped).not.toHaveProperty('contextWindowTokens');
215
- });
216
- it('keeps context distinct from cumulative spend', () => {
217
- // The defect in one assertion. Ten turns over a 200k window accumulate
218
- // far more spend than the window holds, because every turn re-sends the
219
- // history and counts it again — while the context stays modest. Any
220
- // mapping that reaches for `totalTokens` fails here.
221
- expect(usageEvent({
222
- usage: { totalTokens: 500_000 },
223
- contextTokens: 40_000,
224
- contextMeasuredBy: 'provider',
225
- contextWindowTokens: 200_000,
226
- windowSource: 'model-table',
227
- })).toMatchObject({ totalTokens: 500_000, contextTokens: 40_000 });
228
- });
229
- });
230
- //# sourceMappingURL=to-agent-event.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to-agent-event.test.js","sourceRoot":"","sources":["../../../src/tui/__tests__/to-agent-event.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAI7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C;;;;;;;;;GASG;AAEH,MAAM,KAAK,GAAG,UAAmB,CAAA;AAEjC,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;IAC5D,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC7D,MAAM,MAAM,GAAG,YAAY,CAAC;YAC3B,IAAI,EAAE,eAAe;YACrB,KAAK;YACL,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,kBAAkB;SAClB,CAAC,CAAA;QAEd,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6DAA6D,EAAE,GAAG,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was parsed, and reached the session store and the skill search, and
5
- * stopped there: the agent run itself was started with the PROCESS's directory,
6
- * so a run pointed at another checkout globbed this one and reported finding
7
- * nothing — which reads as "the file isn't there" rather than "I looked in the
8
- * wrong place". Nothing caught it because no test ran a file tool against a
9
- * directory that was not the process's own, so both directories were the same
10
- * string in every assertion. These two do.
11
- */
12
- export {};
13
- //# sourceMappingURL=working-directory.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"working-directory.test.d.ts","sourceRoot":"","sources":["../../../src/tui/__tests__/working-directory.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -1,109 +0,0 @@
1
- /**
2
- * The directory the agent actually works in.
3
- *
4
- * `--cwd` was parsed, and reached the session store and the skill search, and
5
- * stopped there: the agent run itself was started with the PROCESS's directory,
6
- * so a run pointed at another checkout globbed this one and reported finding
7
- * nothing — which reads as "the file isn't there" rather than "I looked in the
8
- * wrong place". Nothing caught it because no test ran a file tool against a
9
- * directory that was not the process's own, so both directories were the same
10
- * string in every assertion. These two do.
11
- */
12
- import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
13
- import { tmpdir } from 'node:os';
14
- import { join } from 'node:path';
15
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
16
- import { getBuiltinTools } from '@namzu/sdk';
17
- // Only `query` is replaced; everything else the module under test imports —
18
- // the tool registry, the disk stores, the provider registry the vendor package
19
- // registers into — stays real, because a fake of those would not be able to
20
- // tell us which directory the real ones were handed.
21
- const queryCalls = [];
22
- vi.mock('@namzu/sdk', async (importOriginal) => {
23
- const actual = await importOriginal();
24
- return {
25
- ...actual,
26
- query: (params) => {
27
- queryCalls.push(params);
28
- return (async function* () { })();
29
- },
30
- };
31
- });
32
- let workDir;
33
- beforeEach(() => {
34
- queryCalls.length = 0;
35
- workDir = mkdtempSync(join(tmpdir(), 'namzu-cwd-'));
36
- writeFileSync(join(workDir, 'notes.txt'), 'a file that only exists in the --cwd\n');
37
- });
38
- afterEach(() => {
39
- rmSync(workDir, { recursive: true, force: true });
40
- });
41
- function toolContext(workingDirectory) {
42
- return {
43
- runId: 'run_test',
44
- workingDirectory,
45
- abortSignal: new AbortController().signal,
46
- env: {},
47
- log: () => { },
48
- };
49
- }
50
- describe('a file tool resolves against the working directory it is given', () => {
51
- it('finds a file that exists only outside the process directory', async () => {
52
- const glob = getBuiltinTools().find((t) => t.name === 'glob');
53
- expect(glob, 'the glob builtin is what the reported run called').toBeDefined();
54
- const found = await glob?.execute({ pattern: '**/notes.txt' }, toolContext(workDir));
55
- expect(found?.success).toBe(true);
56
- expect(found?.data).toMatchObject({ count: 1 });
57
- // The same call in the process's own directory is the reported failure:
58
- // the file is real, and the answer is that there is no file. Asserted on
59
- // the count, because the "no files found" text quotes the pattern back
60
- // and so contains the filename either way.
61
- const missed = await glob?.execute({ pattern: '**/notes.txt' }, toolContext(process.cwd()));
62
- expect(missed?.data).toMatchObject({ count: 0 });
63
- });
64
- });
65
- describe('createAgentSession runs where it is told to', () => {
66
- const prefs = {
67
- version: 2,
68
- provider: 'anthropic',
69
- subagents: { active: [] },
70
- };
71
- function detectedAnthropic() {
72
- return [
73
- {
74
- entry: {
75
- id: 'anthropic',
76
- label: 'Anthropic',
77
- defaultModel: 'claude-sonnet-4-5',
78
- requiresApiKey: true,
79
- envVars: ['ANTHROPIC_API_KEY'],
80
- },
81
- source: 'env',
82
- apiKey: 'sk-ant-not-a-real-key',
83
- alternatives: [],
84
- },
85
- ];
86
- }
87
- it('passes the caller-supplied cwd to the run, not the process directory', async () => {
88
- const { createAgentSession } = await import('../agent.js');
89
- const session = await createAgentSession(prefs, detectedAnthropic(), { cwd: workDir });
90
- expect(session.hasProvider).toBe(true);
91
- for await (const _ of session.send([
92
- { role: 'user', content: 'read notes.txt', timestamp: 0 },
93
- ])) {
94
- // drained; the assertion is on what `query` was handed
95
- }
96
- expect(queryCalls).toHaveLength(1);
97
- expect(queryCalls[0].workingDirectory).toBe(workDir);
98
- expect(queryCalls[0].workingDirectory).not.toBe(process.cwd());
99
- });
100
- it('falls back to the process directory when no cwd is supplied', async () => {
101
- const { createAgentSession } = await import('../agent.js');
102
- const session = await createAgentSession(prefs, detectedAnthropic());
103
- for await (const _ of session.send([{ role: 'user', content: 'hello', timestamp: 0 }])) {
104
- // drained
105
- }
106
- expect(queryCalls[0].workingDirectory).toBe(process.cwd());
107
- });
108
- });
109
- //# sourceMappingURL=working-directory.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"working-directory.test.js","sourceRoot":"","sources":["../../../src/tui/__tests__/working-directory.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK5C,4EAA4E;AAC5E,+EAA+E;AAC/E,4EAA4E;AAC5E,qDAAqD;AACrD,MAAM,UAAU,GAA8B,EAAE,CAAA;AAChD,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAC9C,MAAM,MAAM,GAAG,MAAM,cAAc,EAA+B,CAAA;IAClE,OAAO;QACN,GAAG,MAAM;QACT,KAAK,EAAE,CAAC,MAA+B,EAAE,EAAE;YAC1C,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACvB,OAAO,CAAC,KAAK,SAAS,CAAC,MAAK,CAAC,CAAC,EAAE,CAAA;QACjC,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA;AAEF,IAAI,OAAe,CAAA;AAEnB,UAAU,CAAC,GAAG,EAAE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