@cruxy/cli 1.0.3 → 1.0.4

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 (238) hide show
  1. package/package.json +1 -1
  2. package/dist/agent/budget.d.ts +0 -52
  3. package/dist/agent/index.d.ts +0 -3
  4. package/dist/agent/loop.d.ts +0 -159
  5. package/dist/agent/prompts.d.ts +0 -69
  6. package/dist/agent/session.d.ts +0 -212
  7. package/dist/approval/classify.d.ts +0 -18
  8. package/dist/approval/index.d.ts +0 -6
  9. package/dist/approval/mutex.d.ts +0 -45
  10. package/dist/approval/policy.d.ts +0 -43
  11. package/dist/approval/prompt.d.ts +0 -48
  12. package/dist/approval/service.d.ts +0 -36
  13. package/dist/approval/types.d.ts +0 -82
  14. package/dist/brand/index.d.ts +0 -1
  15. package/dist/brand/voice.d.ts +0 -94
  16. package/dist/checkpoint/capture.d.ts +0 -17
  17. package/dist/checkpoint/gate-hook.d.ts +0 -28
  18. package/dist/checkpoint/gate.d.ts +0 -71
  19. package/dist/checkpoint/git-store.d.ts +0 -61
  20. package/dist/checkpoint/index.d.ts +0 -10
  21. package/dist/checkpoint/restore.d.ts +0 -23
  22. package/dist/checkpoint/service.d.ts +0 -89
  23. package/dist/checkpoint/set-rollback.d.ts +0 -51
  24. package/dist/checkpoint/set.d.ts +0 -44
  25. package/dist/checkpoint/shadow-store.d.ts +0 -23
  26. package/dist/checkpoint/types.d.ts +0 -164
  27. package/dist/cli/commands/checkpoint.d.ts +0 -7
  28. package/dist/cli/commands/config.d.ts +0 -2
  29. package/dist/cli/commands/hooks.d.ts +0 -8
  30. package/dist/cli/commands/index.d.ts +0 -7
  31. package/dist/cli/commands/init.d.ts +0 -7
  32. package/dist/cli/commands/login.d.ts +0 -8
  33. package/dist/cli/commands/mcp.d.ts +0 -9
  34. package/dist/cli/commands/memory.d.ts +0 -8
  35. package/dist/cli/commands/pr.d.ts +0 -8
  36. package/dist/cli/commands/rollback.d.ts +0 -18
  37. package/dist/cli/commands/run.d.ts +0 -2
  38. package/dist/cli/commands/skills.d.ts +0 -8
  39. package/dist/cli/commands/test.d.ts +0 -9
  40. package/dist/cli/commands/usage.d.ts +0 -9
  41. package/dist/cli/onboard.d.ts +0 -25
  42. package/dist/cli/program.d.ts +0 -2
  43. package/dist/cli/repl.d.ts +0 -27
  44. package/dist/cli/session-factory.d.ts +0 -42
  45. package/dist/cli/stream-print.d.ts +0 -14
  46. package/dist/components/autocomplete.d.ts +0 -32
  47. package/dist/components/frame.d.ts +0 -28
  48. package/dist/components/fuzzy.d.ts +0 -61
  49. package/dist/components/index.d.ts +0 -6
  50. package/dist/components/input.d.ts +0 -78
  51. package/dist/components/keys.d.ts +0 -48
  52. package/dist/components/select.d.ts +0 -28
  53. package/dist/config/credentials.d.ts +0 -18
  54. package/dist/config/index.d.ts +0 -5
  55. package/dist/config/manager.d.ts +0 -39
  56. package/dist/config/owner-only.d.ts +0 -19
  57. package/dist/config/paths.d.ts +0 -9
  58. package/dist/config/project.d.ts +0 -10
  59. package/dist/config/schema.d.ts +0 -2143
  60. package/dist/constants.d.ts +0 -65
  61. package/dist/errors/boundary.d.ts +0 -43
  62. package/dist/errors/constructors.d.ts +0 -411
  63. package/dist/errors/format.d.ts +0 -31
  64. package/dist/errors/index.d.ts +0 -4
  65. package/dist/errors/types.d.ts +0 -270
  66. package/dist/hooks/config.d.ts +0 -21
  67. package/dist/hooks/index.d.ts +0 -7
  68. package/dist/hooks/router.d.ts +0 -58
  69. package/dist/hooks/runner.d.ts +0 -88
  70. package/dist/hooks/service.d.ts +0 -38
  71. package/dist/hooks/slash.d.ts +0 -48
  72. package/dist/hooks/trust.d.ts +0 -46
  73. package/dist/hooks/types.d.ts +0 -147
  74. package/dist/index.d.ts +0 -2
  75. package/dist/indexing/chunker.d.ts +0 -28
  76. package/dist/indexing/embedder.d.ts +0 -98
  77. package/dist/indexing/index.d.ts +0 -9
  78. package/dist/indexing/indexer.d.ts +0 -45
  79. package/dist/indexing/retriever.d.ts +0 -61
  80. package/dist/indexing/service.d.ts +0 -49
  81. package/dist/indexing/store.d.ts +0 -103
  82. package/dist/indexing/types.d.ts +0 -78
  83. package/dist/indexing/util.d.ts +0 -34
  84. package/dist/indexing/walker.d.ts +0 -53
  85. package/dist/jobs/approval-queue.d.ts +0 -85
  86. package/dist/jobs/dispatch-tool.d.ts +0 -34
  87. package/dist/jobs/index.d.ts +0 -6
  88. package/dist/jobs/log-buffer.d.ts +0 -31
  89. package/dist/jobs/log-renderer.d.ts +0 -32
  90. package/dist/jobs/manager.d.ts +0 -139
  91. package/dist/jobs/types.d.ts +0 -81
  92. package/dist/lsp/client.d.ts +0 -25
  93. package/dist/lsp/index.d.ts +0 -8
  94. package/dist/lsp/pool.d.ts +0 -48
  95. package/dist/lsp/registry.d.ts +0 -38
  96. package/dist/lsp/server.d.ts +0 -48
  97. package/dist/lsp/service.d.ts +0 -44
  98. package/dist/lsp/tools/common.d.ts +0 -50
  99. package/dist/lsp/tools/find-definition.d.ts +0 -23
  100. package/dist/lsp/tools/find-references.d.ts +0 -23
  101. package/dist/lsp/tools/get-diagnostics.d.ts +0 -17
  102. package/dist/lsp/tools/hover.d.ts +0 -23
  103. package/dist/lsp/tools/index.d.ts +0 -4
  104. package/dist/lsp/transport.d.ts +0 -39
  105. package/dist/lsp/types.d.ts +0 -107
  106. package/dist/mcp/adapter.d.ts +0 -44
  107. package/dist/mcp/bounds.d.ts +0 -35
  108. package/dist/mcp/client.d.ts +0 -19
  109. package/dist/mcp/demarcate.d.ts +0 -12
  110. package/dist/mcp/http-transport.d.ts +0 -89
  111. package/dist/mcp/index.d.ts +0 -12
  112. package/dist/mcp/service.d.ts +0 -71
  113. package/dist/mcp/sibling-banner.d.ts +0 -25
  114. package/dist/mcp/transport.d.ts +0 -30
  115. package/dist/mcp/trust-gate.d.ts +0 -59
  116. package/dist/mcp/trust.d.ts +0 -62
  117. package/dist/mcp/types.d.ts +0 -62
  118. package/dist/mcp/url-guard.d.ts +0 -48
  119. package/dist/memory/index.d.ts +0 -7
  120. package/dist/memory/recall.d.ts +0 -56
  121. package/dist/memory/remember-tool.d.ts +0 -28
  122. package/dist/memory/secrets.d.ts +0 -29
  123. package/dist/memory/service.d.ts +0 -92
  124. package/dist/memory/store.d.ts +0 -32
  125. package/dist/memory/trust.d.ts +0 -52
  126. package/dist/memory/types.d.ts +0 -101
  127. package/dist/net/ip-guard.d.ts +0 -55
  128. package/dist/onboarding/detect.d.ts +0 -26
  129. package/dist/onboarding/flow.d.ts +0 -28
  130. package/dist/onboarding/index.d.ts +0 -5
  131. package/dist/onboarding/io.d.ts +0 -9
  132. package/dist/onboarding/steps.d.ts +0 -17
  133. package/dist/onboarding/types.d.ts +0 -81
  134. package/dist/plan/approve.d.ts +0 -16
  135. package/dist/plan/execute.d.ts +0 -28
  136. package/dist/plan/index.d.ts +0 -7
  137. package/dist/plan/policy.d.ts +0 -26
  138. package/dist/plan/render.d.ts +0 -5
  139. package/dist/plan/service.d.ts +0 -58
  140. package/dist/plan/submit-plan.d.ts +0 -33
  141. package/dist/plan/types.d.ts +0 -60
  142. package/dist/render/capabilities.d.ts +0 -31
  143. package/dist/render/diff.d.ts +0 -18
  144. package/dist/render/highlight.d.ts +0 -47
  145. package/dist/render/index.d.ts +0 -22
  146. package/dist/render/layout.d.ts +0 -59
  147. package/dist/render/motion.d.ts +0 -76
  148. package/dist/render/plain-renderer.d.ts +0 -39
  149. package/dist/render/resize.d.ts +0 -36
  150. package/dist/render/screen-reader-renderer.d.ts +0 -45
  151. package/dist/render/state.d.ts +0 -49
  152. package/dist/render/tty-renderer.d.ts +0 -106
  153. package/dist/render/types.d.ts +0 -201
  154. package/dist/routing/index.d.ts +0 -2
  155. package/dist/routing/resolve.d.ts +0 -17
  156. package/dist/routing/router.d.ts +0 -47
  157. package/dist/routing/types.d.ts +0 -42
  158. package/dist/sandbox/detect.d.ts +0 -22
  159. package/dist/sandbox/docker-runtime.d.ts +0 -32
  160. package/dist/sandbox/index.d.ts +0 -7
  161. package/dist/sandbox/policy.d.ts +0 -26
  162. package/dist/sandbox/service.d.ts +0 -64
  163. package/dist/sandbox/types.d.ts +0 -123
  164. package/dist/skills/index.d.ts +0 -4
  165. package/dist/skills/loader.d.ts +0 -43
  166. package/dist/skills/parser.d.ts +0 -31
  167. package/dist/skills/service.d.ts +0 -41
  168. package/dist/skills/types.d.ts +0 -94
  169. package/dist/subagent/index.d.ts +0 -5
  170. package/dist/subagent/orchestrator.d.ts +0 -169
  171. package/dist/subagent/registry-scope.d.ts +0 -41
  172. package/dist/subagent/semaphore.d.ts +0 -56
  173. package/dist/subagent/spawn-tool.d.ts +0 -86
  174. package/dist/subagent/types.d.ts +0 -65
  175. package/dist/testing/detect.d.ts +0 -3
  176. package/dist/testing/index.d.ts +0 -5
  177. package/dist/testing/parse.d.ts +0 -33
  178. package/dist/testing/run-tests-tool.d.ts +0 -64
  179. package/dist/testing/runner.d.ts +0 -26
  180. package/dist/testing/sandbox-runner.d.ts +0 -16
  181. package/dist/testing/types.d.ts +0 -66
  182. package/dist/theme/index.d.ts +0 -2
  183. package/dist/theme/resolve.d.ts +0 -43
  184. package/dist/theme/tokens.d.ts +0 -125
  185. package/dist/tools/create-pull-request.d.ts +0 -27
  186. package/dist/tools/file/apply-patch.d.ts +0 -94
  187. package/dist/tools/file/edit-file.d.ts +0 -12
  188. package/dist/tools/file/glob.d.ts +0 -17
  189. package/dist/tools/file/grep-files.d.ts +0 -43
  190. package/dist/tools/file/index.d.ts +0 -7
  191. package/dist/tools/file/match.d.ts +0 -43
  192. package/dist/tools/file/paths.d.ts +0 -160
  193. package/dist/tools/file/read-file.d.ts +0 -8
  194. package/dist/tools/file/write-file.d.ts +0 -10
  195. package/dist/tools/git-status.d.ts +0 -15
  196. package/dist/tools/index.d.ts +0 -9
  197. package/dist/tools/list-files.d.ts +0 -13
  198. package/dist/tools/list-skills.d.ts +0 -9
  199. package/dist/tools/load-skill.d.ts +0 -21
  200. package/dist/tools/registry.d.ts +0 -23
  201. package/dist/tools/search-codebase.d.ts +0 -35
  202. package/dist/tools/shell/exec.d.ts +0 -53
  203. package/dist/tools/shell/index.d.ts +0 -1
  204. package/dist/tools/shell/resolve-shell.d.ts +0 -81
  205. package/dist/tools/shell/run-command.d.ts +0 -14
  206. package/dist/tools/types.d.ts +0 -257
  207. package/dist/usage/collect.d.ts +0 -53
  208. package/dist/usage/cost.d.ts +0 -19
  209. package/dist/usage/index.d.ts +0 -15
  210. package/dist/usage/store.d.ts +0 -37
  211. package/dist/usage/summary.d.ts +0 -32
  212. package/dist/usage/types.d.ts +0 -283
  213. package/dist/utils/child-tree.d.ts +0 -33
  214. package/dist/utils/git.d.ts +0 -17
  215. package/dist/utils/logger.d.ts +0 -18
  216. package/dist/utils/process-tree.d.ts +0 -16
  217. package/dist/vcs/auth.d.ts +0 -22
  218. package/dist/vcs/generate.d.ts +0 -74
  219. package/dist/vcs/git.d.ts +0 -60
  220. package/dist/vcs/github.d.ts +0 -50
  221. package/dist/vcs/guidance.d.ts +0 -20
  222. package/dist/vcs/index.d.ts +0 -7
  223. package/dist/vcs/service.d.ts +0 -61
  224. package/dist/vcs/types.d.ts +0 -73
  225. package/dist/web/demarcate.d.ts +0 -13
  226. package/dist/web/fetch.d.ts +0 -11
  227. package/dist/web/index.d.ts +0 -7
  228. package/dist/web/provider.d.ts +0 -29
  229. package/dist/web/search.d.ts +0 -17
  230. package/dist/web/ssrf.d.ts +0 -41
  231. package/dist/web/tools.d.ts +0 -20
  232. package/dist/web/types.d.ts +0 -64
  233. package/dist/workspace/add-root.d.ts +0 -27
  234. package/dist/workspace/index.d.ts +0 -6
  235. package/dist/workspace/resolve.d.ts +0 -54
  236. package/dist/workspace/select.d.ts +0 -41
  237. package/dist/workspace/types.d.ts +0 -30
  238. package/dist/workspace/workspace.d.ts +0 -61
@@ -1,53 +0,0 @@
1
- /**
2
- * Repository walker for the index. Enumerates indexable text files under a root,
3
- * honoring `.gitignore` and `.cruxyignore` (nested files included), an
4
- * always-ignore set, a hard secrets denylist, a per-file size cap, and a binary
5
- * sniff. Yielded paths are project-relative and POSIX-separated.
6
- */
7
- /** A file the walker considers indexable. */
8
- export interface WalkEntry {
9
- /** Project-relative POSIX path. */
10
- relPath: string;
11
- /** Absolute path on disk. */
12
- absPath: string;
13
- /** File size in bytes. */
14
- size: number;
15
- }
16
- export interface WalkOptions {
17
- /** Hard per-file size cap, in bytes. Larger files are skipped. */
18
- maxFileBytes: number;
19
- /** Ignore-file names to honor, relative to each directory (gitignore syntax). */
20
- ignoreFileNames?: string[];
21
- /**
22
- * Yield binary files too (default false). The index never wants them; the
23
- * checkpoint capturer (C.32) does — a snapshot must be complete to restore.
24
- */
25
- includeBinary?: boolean;
26
- }
27
- /**
28
- * The C.17 secrets denylist test, shared beyond the index: the checkpoint
29
- * capturer (C.32) applies the exact same rule so a working-tree snapshot can
30
- * never contain a secret-bearing file either.
31
- */
32
- export declare function isSecretPath(relPath: string): boolean;
33
- /**
34
- * A compiled set of gitignore-style patterns, matched against paths relative to
35
- * the file's own directory. Supports comments, blank lines, `!` negation,
36
- * leading-`/` anchoring, trailing-`/` directory-only rules, and `*`/`**`/`?`.
37
- */
38
- export declare class IgnoreMatcher {
39
- private readonly rules;
40
- constructor(patterns: string[]);
41
- private add;
42
- /**
43
- * Decide whether `relPath` is ignored: `true`/`false` when a rule matches
44
- * (last match wins), or `undefined` when no rule applies.
45
- */
46
- decide(relPath: string, isDir: boolean): boolean | undefined;
47
- }
48
- /**
49
- * Walk `root` and yield every indexable text file. Directories in the
50
- * always-ignore set are skipped wholesale; ignore files accumulate down the
51
- * tree; secret-bearing, oversized, and binary files are filtered out.
52
- */
53
- export declare function walkRepo(root: string, opts: WalkOptions): AsyncGenerator<WalkEntry>;
@@ -1,85 +0,0 @@
1
- import type { ApprovalDecision, RiskTier } from "../approval/index.js";
2
- /**
3
- * The single foreground pending-approval queue (C.28) — the seam that lets a
4
- * NON-interactive background job get a gated action approved by the ONE
5
- * interactive foreground human, without becoming a second interactive context.
6
- *
7
- * The §0 model: a background job is not a competing consumer of the terminal —
8
- * it is a PRODUCER on this queue. When a job hits a gated action it `submit`s the
9
- * request here and blocks on the returned promise; it holds no terminal, no
10
- * mutex, and (having released its execution slot) no compute while it waits. The
11
- * foreground drains the queue when it is idle (between turns): {@link serviceAll}
12
- * runs each request's `finalize` — the REAL U.3 prompt + checkpoint, serialized
13
- * through the shared approval mutex INSIDE `finalize` — and settles the producer
14
- * with the human's decision. Because the prompt happens on the foreground under
15
- * the shared mutex, a background job can never paint a second prompt over a
16
- * foreground one, and the action never executes until a human has decided.
17
- *
18
- * This queue is pure transport: it holds pending entries and settles them. It
19
- * knows nothing about checkpoints, the mutex, or how a decision is reached — the
20
- * manager composes that into each entry's `finalize`.
21
- */
22
- /** A read-only view of one pending request (for `/jobs` display + tests). */
23
- export interface PendingApproval {
24
- /** Queue-unique id. */
25
- readonly id: string;
26
- /** The job that is blocked on this decision. */
27
- readonly jobId: string;
28
- /** One plain line describing the action (e.g. "run: rm -rf build"). */
29
- readonly summary: string;
30
- /** Risk tier (mutate | destructive — reads never reach the queue). */
31
- readonly tier: RiskTier;
32
- }
33
- /** What a producing job submits: how to describe it, and how to actually decide. */
34
- export interface ApprovalSubmission {
35
- jobId: string;
36
- summary: string;
37
- tier: RiskTier;
38
- /**
39
- * Run the REAL decision: the interactive U.3 prompt + the job's checkpoint
40
- * snapshot, serialized on the shared approval mutex. Composed by the manager so
41
- * this queue stays decoupled. Called by {@link serviceAll} on the foreground;
42
- * its resolved decision settles the producer's `submit` promise. A throw
43
- * (e.g. a checkpoint failure) rejects the producer's promise so the job fails
44
- * loud rather than hanging.
45
- */
46
- finalize: () => Promise<ApprovalDecision>;
47
- }
48
- export declare class ApprovalQueue {
49
- private readonly queue;
50
- private seq;
51
- /**
52
- * A job submits a gated action and awaits the decision. Resolves when the
53
- * foreground services it ({@link serviceAll}) or a caller {@link withdraw}s it;
54
- * rejects if the finalize throws. The action does NOT execute here — the caller
55
- * only proceeds after this resolves `{allow:true}`.
56
- */
57
- submit(sub: ApprovalSubmission): Promise<ApprovalDecision>;
58
- /** Whether any request is waiting to be serviced. */
59
- hasPending(): boolean;
60
- /** Count of requests waiting. */
61
- get size(): number;
62
- /** Read-only snapshot of every pending request, FIFO order. */
63
- pending(): PendingApproval[];
64
- /** The pending request for one job (a job has at most one at a time), if any. */
65
- pendingFor(jobId: string): PendingApproval | undefined;
66
- /**
67
- * Foreground drain: service every currently-pending request, FIFO, ONE AT A
68
- * TIME — each `finalize` fully settles (including the human's keypress) before
69
- * the next begins, so two background prompts never overlap and the shared mutex
70
- * inside `finalize` also serializes them against any foreground action. Returns
71
- * the number serviced. Requests that arrive AFTER draining starts wait for the
72
- * next drain (bounded work per idle window). A finalize throw rejects that one
73
- * producer and drains on — one job's checkpoint failure never wedges the queue.
74
- */
75
- serviceAll(): Promise<number>;
76
- /**
77
- * Withdraw a job's pending request WITHOUT prompting — used when the job is
78
- * cancelled (or the session exits) while it is paused: settle the producer with
79
- * `decision` (a deny) so its `submit` promise resolves and the job can finish
80
- * tearing down instead of blocking forever. Returns true if one was withdrawn.
81
- */
82
- withdraw(jobId: string, decision: ApprovalDecision): boolean;
83
- /** Settle an entry exactly once (double-settle is a defensive no-op). */
84
- private settle;
85
- }
@@ -1,34 +0,0 @@
1
- import { z } from "zod";
2
- import type { Tool } from "../tools/index.js";
3
- import type { JobManager } from "./manager.js";
4
- /**
5
- * The `run_in_background` tool (C.28): the agent-facing seam for dispatching a
6
- * background job. Unlike `spawn_subagent`, it does NOT block — it returns a job
7
- * id immediately and the job runs CONCURRENTLY with the rest of the turn and the
8
- * session. The agent uses it for long-running, self-contained work it does not
9
- * want to wait on inline; the human watches it with `/jobs` and `/logs`, and any
10
- * side effect the job takes still requires a foreground approval.
11
- */
12
- export declare const RUN_IN_BACKGROUND_TOOL_NAME = "run_in_background";
13
- declare const parameters: z.ZodObject<{
14
- task: z.ZodString;
15
- tools: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
16
- root: z.ZodOptional<z.ZodString>;
17
- maxIterations: z.ZodOptional<z.ZodNumber>;
18
- maxTokens: z.ZodOptional<z.ZodNumber>;
19
- }, "strip", z.ZodTypeAny, {
20
- task: string;
21
- root?: string | undefined;
22
- maxIterations?: number | undefined;
23
- maxTokens?: number | undefined;
24
- tools?: [string, ...string[]] | undefined;
25
- }, {
26
- task: string;
27
- root?: string | undefined;
28
- maxIterations?: number | undefined;
29
- maxTokens?: number | undefined;
30
- tools?: [string, ...string[]] | undefined;
31
- }>;
32
- /** Build the `run_in_background` tool bound to the session's job manager. */
33
- export declare function makeRunInBackgroundTool(manager: JobManager): Tool<typeof parameters>;
34
- export {};
@@ -1,6 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./log-buffer.js";
3
- export * from "./log-renderer.js";
4
- export * from "./approval-queue.js";
5
- export * from "./manager.js";
6
- export * from "./dispatch-tool.js";
@@ -1,31 +0,0 @@
1
- /**
2
- * A bounded ring buffer of a background job's log lines (C.28). A job runs
3
- * non-interactively, so its progress isn't on screen — `cruxy logs <id>` reads
4
- * it back here. Bounded so a chatty job cannot grow memory without limit: once
5
- * `capacity` lines are held, the oldest roll off. When anything is dropped the
6
- * buffer records how many, so a reader is never misled into thinking a truncated
7
- * tail is the whole story (`cruxy logs` prints an honest "… N earlier lines").
8
- */
9
- export interface LogLine {
10
- /** Milliseconds since the job started (monotonic, injected — never wall clock
11
- * inside the buffer, so it stays deterministic and testable). */
12
- atMs: number;
13
- /** `out` for normal progress, `err` for diagnostics/failures. */
14
- stream: "out" | "err";
15
- /** The line text (no trailing newline). */
16
- text: string;
17
- }
18
- export declare class LogBuffer {
19
- private readonly capacity;
20
- private readonly lines;
21
- private droppedCount;
22
- constructor(capacity: number);
23
- /** Append a line, rolling the oldest off (and counting it) when at capacity. */
24
- append(line: LogLine): void;
25
- /** The retained lines, oldest-first (a copy — callers never mutate the buffer). */
26
- snapshot(): LogLine[];
27
- /** How many lines rolled off the front (0 when nothing was dropped). */
28
- get dropped(): number;
29
- /** Lines currently retained. */
30
- get size(): number;
31
- }
@@ -1,32 +0,0 @@
1
- import { type Theme } from "../theme/index.js";
2
- import type { RenderCapabilities, StreamRenderer, ToolLifecycleEvent } from "../render/index.js";
3
- /**
4
- * A {@link StreamRenderer} for a background job (C.28) that captures activity into
5
- * the job's log buffer and writes NOTHING to any terminal — a job runs
6
- * non-interactively, off screen, and its foreground session owns the terminal.
7
- * `cruxy logs <id>` (a REPL `/logs`) reads back what was captured here.
8
- *
9
- * Assistant text is accumulated and flushed a line at a time on `endSegment`;
10
- * committed chrome notes and tool-call completions are captured verbatim. The
11
- * live-region methods (status, phase, progress, prompt-resolved) are dropped —
12
- * transient decor has no meaning in an append-only log.
13
- */
14
- export declare class JobLogRenderer implements StreamRenderer {
15
- private readonly sink;
16
- readonly caps: RenderCapabilities;
17
- readonly theme: Theme;
18
- private pending;
19
- constructor(sink: (stream: "out" | "err", text: string) => void);
20
- beginTurn(): void;
21
- write(delta: string): void;
22
- endSegment(): void;
23
- note(text: string): void;
24
- toolLifecycle(event: ToolLifecycleEvent): void;
25
- endTurn(): void;
26
- preview(): void;
27
- status(): void;
28
- setPhase(): void;
29
- progress(): void;
30
- promptResolved(): void;
31
- close(): void;
32
- }
@@ -1,139 +0,0 @@
1
- import type { Provider } from "@cruxy/sdk";
2
- import { runAgent } from "../agent/loop.js";
3
- import { type ApprovalMutex, type PromptIO } from "../approval/index.js";
4
- import type { CruxyConfig } from "../config/index.js";
5
- import type { Router } from "../routing/index.js";
6
- import type { SandboxService } from "../sandbox/index.js";
7
- import { Semaphore } from "../subagent/index.js";
8
- import type { ToolRegistry } from "../tools/index.js";
9
- import type { logger as Logger } from "../utils/logger.js";
10
- import { Workspace } from "../workspace/index.js";
11
- import { ApprovalQueue } from "./approval-queue.js";
12
- import type { JobLog, JobSpec, JobView } from "./types.js";
13
- /**
14
- * Everything the manager needs from the surrounding session, injected by the
15
- * session factory. The SHARED members are the crux of C.28's "one system, not
16
- * two": `semaphore`, `approvalQueue`, and `approvalMutex` are the SAME instances
17
- * the foreground loop and subagents use, so a job contends for the one execution
18
- * cap and serializes its prompts/checkpoints on the one mutex — never a parallel
19
- * universe with its own limits.
20
- */
21
- export interface JobManagerDeps {
22
- config: CruxyConfig;
23
- provider: Provider;
24
- router?: Router;
25
- /** The parent's registry — the ceiling every job's tool scope derives from. */
26
- parentRegistry: ToolRegistry;
27
- cwd: string;
28
- workspace: Workspace;
29
- logger: typeof Logger;
30
- git?: {
31
- branch: string;
32
- dirty: boolean;
33
- } | null;
34
- projectInstructions?: string | null;
35
- sandbox?: SandboxService;
36
- /** The ONE execution semaphore, shared with subagents (JC-D, the shared cap). */
37
- semaphore: Semaphore;
38
- /** The ONE foreground pending-approval queue jobs produce onto. */
39
- approvalQueue: ApprovalQueue;
40
- /** The ONE approval mutex — job prompts/checkpoints serialize on it. */
41
- approvalMutex: ApprovalMutex;
42
- /**
43
- * Whether an interactive foreground exists to service the queue. FALSE (a
44
- * one-shot / piped run) means a job's gated action fails loud with
45
- * `CRUXY_E_APPROVAL_REQUIRED` — it never auto-approves and never hangs on a
46
- * human who will never come.
47
- */
48
- foregroundInteractive: boolean;
49
- /** The shared prompt I/O used when the foreground services a job's request. */
50
- promptIO: PromptIO;
51
- /** Test seam: the loop driver. Defaults to the real {@link runAgent}. */
52
- runAgentFn?: typeof runAgent;
53
- /** Test seam: deterministic job ids. Defaults to `job-<seq>-<rand>`. */
54
- idFactory?: () => string;
55
- /** Test seam: log-line clock (ms). Defaults to `Date.now`. */
56
- now?: () => number;
57
- }
58
- /**
59
- * Session-scoped background jobs (C.28). The main agent dispatches a job with
60
- * `run_in_background`; it runs the SAME agent loop as a subagent but CONCURRENTLY
61
- * with the foreground session, off screen (its output goes to a log buffer). A
62
- * gated action pauses the job, releases its execution slot, and enqueues an
63
- * approval request the foreground human services between turns; on approval the
64
- * job re-acquires a slot (with priority) and runs on — its pre- AND post-pause
65
- * mutations coalescing under ONE checkpoint. Cancel and session exit kill-tree a
66
- * job's process tree (via its cancellation signal), leaving no orphan.
67
- *
68
- * The manager is session-scoped and dies with the session (NOT a daemon): nothing
69
- * here persists a live registry across processes. What survives on disk is a
70
- * job's checkpoint set, so `cruxy rollback <id>` still works afterwards.
71
- */
72
- export declare class JobManager {
73
- private readonly deps;
74
- private readonly jobs;
75
- /** In-flight executions, awaited on {@link cancelAll} so teardown completes. */
76
- private readonly running;
77
- private readonly idFactory;
78
- private readonly now;
79
- private readonly runAgentFn;
80
- private seq;
81
- constructor(deps: JobManagerDeps);
82
- /**
83
- * Dispatch a background job (the `run_in_background` seam). Fails loud when the
84
- * feature is disabled, when the live-job ceiling is reached, or when a named
85
- * root is unknown — all BEFORE the job is registered, so a refused dispatch
86
- * leaves no ghost. Returns a view immediately; the job runs asynchronously.
87
- */
88
- dispatch(spec: JobSpec): JobView;
89
- /** Live view of every job this session, dispatch order. */
90
- list(): JobView[];
91
- /** One job's view, or undefined if the id is unknown. */
92
- get(id: string): JobView | undefined;
93
- /** One job's full log (for `/logs <id>`). Fails loud on an unknown id. */
94
- logs(id: string): JobLog;
95
- /**
96
- * Cancel one job: abort its run (kill-tree'ing any in-flight process via the
97
- * signal reaching `ctx.signal`) and, if it is paused, withdraw its queued
98
- * approval so it stops waiting. A checkpoint it already took SURVIVES for
99
- * review/rollback. Fails loud on an unknown id; a no-op on an already-terminal
100
- * job (returns false).
101
- */
102
- cancel(id: string): boolean;
103
- /**
104
- * Cancel EVERY live job (session exit / teardown) and AWAIT their teardown, so
105
- * nothing is left running or orphaned. Returns how many were cancelled — the
106
- * caller prints the honest "N job(s) cancelled". Idempotent.
107
- */
108
- cancelAll(reason: string): Promise<number>;
109
- /** Jobs that are not yet terminal (queued + running + paused). */
110
- liveCount(): number;
111
- /** Whether any job is paused awaiting a foreground approval (drive the drain). */
112
- hasPendingApprovals(): boolean;
113
- /** Service every pending job approval on the foreground (called between turns). */
114
- serviceApprovals(): Promise<number>;
115
- /** Abort a job's run and unblock it if paused (shared by cancel/cancelAll). */
116
- private abort;
117
- /** Drive one job to completion, mapping every outcome onto its status. */
118
- private execute;
119
- /** Build the {@link runAgent} args for a job: scoped registry, budget, ctx. */
120
- private runArgs;
121
- /**
122
- * The job's approval gate — the producer side of the pending-approval queue.
123
- * A read-tier action passes freely. A mutate/destructive action with NO
124
- * interactive foreground fails loud (never auto-approve, never hang). Otherwise
125
- * the job PAUSES: it releases its execution slot (JC-D), enqueues the request
126
- * for the foreground human, and blocks. On resolution it re-acquires a slot
127
- * with PRIORITY (so it is not starved by work dispatched while it waited) and
128
- * returns the decision. The real prompt + this job's checkpoint snapshot happen
129
- * inside `finalize` on the foreground, serialized on the shared mutex.
130
- */
131
- private makeJobApproval;
132
- /** Resolve a job's scope from an optional root name (fail-loud on unknown). */
133
- private jobScope;
134
- private statusFor;
135
- private errorFor;
136
- private requireJob;
137
- private log;
138
- private view;
139
- }
@@ -1,81 +0,0 @@
1
- import type { Usage } from "@cruxy/sdk";
2
- import type { LogLine } from "./log-buffer.js";
3
- /**
4
- * Types for session-scoped background jobs (C.28): non-interactive orchestration
5
- * the main agent dispatches with `run_in_background`. A job runs the SAME agent
6
- * loop as a subagent, but CONCURRENTLY with (and outliving the turn of) the
7
- * foreground session — bound to the session's lifetime, nothing survives exit
8
- * (NOT a daemon). Its gated actions enqueue approval requests into the one
9
- * foreground queue; a paused job releases its execution slot.
10
- */
11
- /**
12
- * A job's lifecycle state. Every state is HONEST — a job is `done` only when its
13
- * run actually completed, never a fabricated success. Terminal states are `done`,
14
- * `failed`, `cancelled`; the rest are live.
15
- * - `queued` — dispatched, waiting for an execution slot (the shared cap is full).
16
- * - `running` — holding a slot, executing its agent loop.
17
- * - `paused-needs-approval` — hit a gated action; its approval is enqueued for a
18
- * foreground human and it has RELEASED its slot until the human decides (JC-D).
19
- * - `done` — the run completed.
20
- * - `failed` — the run errored, exceeded budget, or hit a no-foreground approval
21
- * wall (`CRUXY_E_APPROVAL_REQUIRED`); `error` carries the coded reason.
22
- * - `cancelled` — `cruxy cancel <id>` or session exit stopped it; its process tree
23
- * was kill-tree'd and any checkpoint it took survives for review/rollback.
24
- */
25
- export type JobStatus = "queued" | "running" | "paused-needs-approval" | "done" | "failed" | "cancelled";
26
- /** The terminal states — a job in one of these will never run again. */
27
- export declare const TERMINAL_JOB_STATUSES: readonly JobStatus[];
28
- /** Whether a status is terminal (no further execution). */
29
- export declare function isTerminal(status: JobStatus): boolean;
30
- /**
31
- * What a background job should do — mirrors the self-contained subtask shape of a
32
- * subagent spawn (C.14/C.33). A job starts with NO context beyond `task`.
33
- */
34
- export interface JobSpec {
35
- /** The complete, self-contained task the job should perform. */
36
- task: string;
37
- /**
38
- * Tool names to grant, resolved against the parent registry — a job can only
39
- * scope DOWN. Omitted → the default read-only set. A job granted write/shell
40
- * tools takes real, gated actions in the background.
41
- */
42
- tools?: readonly string[];
43
- /**
44
- * The workspace root (by exact name, C.26) this job is confined to. Omitted →
45
- * the full session workspace (read-only, or a single-root session).
46
- */
47
- root?: string;
48
- /** Budget overrides, clamped to `subagent.defaultBudget` (never raised). */
49
- budget?: {
50
- maxIterations?: number;
51
- maxTokens?: number;
52
- };
53
- }
54
- /**
55
- * A read-only view of one job for `cruxy jobs` / the dispatch tool's result /
56
- * tests. Never exposes the live control handles (abort controller, checkpoint
57
- * gate) — those stay inside the manager.
58
- */
59
- export interface JobView {
60
- /** Stable, session-unique id (also the checkpoint run id for `cruxy rollback`). */
61
- id: string;
62
- status: JobStatus;
63
- /** One-line task excerpt (for listings). */
64
- label: string;
65
- /** Present on `failed`: the coded, actionable reason. */
66
- error?: string;
67
- /** Model turns consumed so far. */
68
- iterations: number;
69
- /** Token usage accumulated so far. */
70
- usage: Usage;
71
- /** A one-line summary of what's pending, when `paused-needs-approval`. */
72
- pendingApproval?: string;
73
- }
74
- /** The full log of one job, for `cruxy logs <id>`. */
75
- export interface JobLog {
76
- id: string;
77
- status: JobStatus;
78
- lines: LogLine[];
79
- /** How many earlier lines rolled off the ring buffer (0 when none). */
80
- dropped: number;
81
- }
@@ -1,25 +0,0 @@
1
- import type { LspPool } from "./pool.js";
2
- import type { LspDiagnostic, LspHover, LspLocation } from "./types.js";
3
- /**
4
- * Typed, normalized LSP queries over a {@link LspPool} (C.12). Its only real
5
- * job beyond delegating is the availability discipline: it resolves a file's
6
- * language and acquires a server, letting the pool's coded errors (no server /
7
- * timeout / crash) propagate — while a server's genuine `[]`/`null` answer flows
8
- * back untouched. That keeps "couldn't ask" and "asked, nothing found" distinct
9
- * all the way up to the tool boundary. Callers pass ABSOLUTE, in-root paths
10
- * (validated by the tool via `resolveInRoot`); the server relativizes results.
11
- */
12
- export declare class LspClient {
13
- private readonly pool;
14
- constructor(pool: LspPool);
15
- definition(file: string, line: number, col: number): Promise<LspLocation[]>;
16
- references(file: string, line: number, col: number): Promise<LspLocation[]>;
17
- hover(file: string, line: number, col: number): Promise<LspHover | null>;
18
- diagnostics(file: string): Promise<LspDiagnostic[]>;
19
- /**
20
- * Resolve the file's language and hand back a live server. An unmapped
21
- * extension is a coded, actionable failure (`no-spec`) — NOT an empty result,
22
- * so "unknown language" can never read as "no references found".
23
- */
24
- private serverFor;
25
- }
@@ -1,8 +0,0 @@
1
- export * from "./types.js";
2
- export { DEFAULT_SPECS, EXT_TO_LANGUAGE, LspRegistry, binaryOnPath, languageForFile, } from "./registry.js";
3
- export { StdioTransport, TransportTimeoutError, killTree, } from "./transport.js";
4
- export { Server, type ServerTimeouts } from "./server.js";
5
- export { LspPool, type PoolOptions, type PoolDeps } from "./pool.js";
6
- export { LspClient } from "./client.js";
7
- export { getLspService, resetLspServices, type LspService, type LspServiceDeps, } from "./service.js";
8
- export { findDefinitionTool, findReferencesTool, getDiagnosticsTool, hoverTool, } from "./tools/index.js";
@@ -1,48 +0,0 @@
1
- import { type ServerTimeouts } from "./server.js";
2
- import { LspRegistry } from "./registry.js";
3
- import type { LanguageServer, ServerSpec } from "./types.js";
4
- /** Pool bounds + timeouts, threaded from `lsp.*` config. */
5
- export interface PoolOptions extends ServerTimeouts {
6
- maxServers: number;
7
- idleTimeout: number;
8
- }
9
- /** Test seams: substitute the spawn+handshake and the clock. */
10
- export interface PoolDeps {
11
- /** Build+initialize a server for a spec. Defaults to a real stdio process. */
12
- startServer?: (spec: ServerSpec) => Promise<LanguageServer>;
13
- /** Monotonic-ish clock for idle accounting; defaults to `Date.now`. */
14
- now?: () => number;
15
- }
16
- /**
17
- * A per-project pool of language servers (C.12): one server per language,
18
- * spawned lazily on first use, reused across calls, evicted when idle or when
19
- * the `maxServers` cap forces it, restarted ONCE on crash then surfaced as a
20
- * coded error, and all shut down cleanly on teardown. Unavailability (no spec /
21
- * missing binary) throws an actionable error — never a silent empty result.
22
- */
23
- export declare class LspPool {
24
- private readonly registry;
25
- private readonly root;
26
- private readonly options;
27
- private readonly entries;
28
- private readonly starting;
29
- private readonly now;
30
- private readonly startServer;
31
- constructor(registry: LspRegistry, root: string, options: PoolOptions, deps?: PoolDeps);
32
- /**
33
- * Get a ready server for `language`, spawning lazily and reusing across calls.
34
- * Throws `CRUXY_E_LSP_SERVER_NOT_FOUND` when unavailable, `CRUXY_E_LSP_TIMEOUT`
35
- * on a startup timeout, or `CRUXY_E_LSP_CRASHED` when a crashed server cannot
36
- * be recovered by its single automatic restart.
37
- */
38
- acquire(language: string): Promise<LanguageServer>;
39
- /** Shut down every server idle beyond `idleTimeout` (called on each acquire). */
40
- sweepIdle(): void;
41
- /** Cleanly shut down all servers (session end / process teardown). */
42
- shutdownAll(force?: boolean): Promise<void>;
43
- /** Live server count — for tests asserting reuse and the maxServers bound. */
44
- size(): number;
45
- private startAndStore;
46
- /** Evict least-recently-used servers until there is room under the cap. */
47
- private evictToCap;
48
- }
@@ -1,38 +0,0 @@
1
- import type { BinaryPresent, LspConfig, ServerResolution, ServerSpec } from "./types.js";
2
- /**
3
- * The default language → server table (C.12). Documented and overridable per
4
- * language via `lsp.servers.<lang>`. cruxy never guesses a command: a language
5
- * is served only if it appears here or in config, and the binary must actually
6
- * be installed — otherwise the caller gets a coded, actionable failure.
7
- */
8
- export declare const DEFAULT_SPECS: Record<string, Omit<ServerSpec, "language">>;
9
- /**
10
- * File extension → language id. Extensions are matched case-insensitively and
11
- * include the leading dot. A file whose extension is absent here has no server
12
- * (the caller reports `no-spec`, distinct from a missing binary).
13
- */
14
- export declare const EXT_TO_LANGUAGE: Record<string, string>;
15
- /** The language id for a file path, or `null` when its extension is unmapped. */
16
- export declare function languageForFile(filePath: string): string | null;
17
- /**
18
- * Default binary-presence check: resolves `command` the way a shell would.
19
- * An absolute/relative path is tested directly; a bare name is searched across
20
- * `PATH` (with `PATHEXT` on win32). Pure filesystem probing — never spawns.
21
- * Injectable via {@link LspRegistry} so tests can force present/absent.
22
- */
23
- export declare const binaryOnPath: BinaryPresent;
24
- /**
25
- * Resolves a language to a launchable {@link ServerSpec}, or an explicit
26
- * "not available" verdict. Config overrides (`lsp.servers.<lang>`, a full
27
- * command line split on whitespace) win over the default table; the resolved
28
- * binary must be present or the verdict is `binary-missing`.
29
- */
30
- export declare class LspRegistry {
31
- private readonly config;
32
- private readonly present;
33
- constructor(config: LspConfig, present?: BinaryPresent);
34
- /** The server spec for a language, from config override or the default table. */
35
- specFor(language: string): ServerSpec | null;
36
- /** Explicit availability verdict — never conflates "no spec" with "no binary". */
37
- resolve(language: string): ServerResolution;
38
- }
@@ -1,48 +0,0 @@
1
- import type { LanguageServer, LspDiagnostic, LspHover, LspLocation, LspTransport, ServerSpec } from "./types.js";
2
- /** Bounds threaded from `lsp.*` config into a server. */
3
- export interface ServerTimeouts {
4
- startupTimeout: number;
5
- requestTimeout: number;
6
- }
7
- /**
8
- * An initialized {@link LanguageServer} over an {@link LspTransport} (C.12).
9
- * Owns the LSP handshake, lazily opens documents (servers answer only for open
10
- * files), converts LSP's 0-based positions / `file://` URIs to normalized
11
- * 1-based / path results, and shuts down cleanly. A missing/timed-out/crashed
12
- * server surfaces as a coded error; an empty answer stays an honest `[]`/`null`.
13
- */
14
- export declare class Server implements LanguageServer {
15
- private readonly transport;
16
- private readonly root;
17
- private readonly timeouts;
18
- readonly language: string;
19
- private _alive;
20
- private readonly openDocs;
21
- private readonly diagnosticsByUri;
22
- private readonly diagnosticsWaiters;
23
- private constructor();
24
- get alive(): boolean;
25
- /**
26
- * Spawn+handshake a server: `initialize` (bounded by `startupTimeout`) then
27
- * the `initialized` notification. A startup timeout throws a coded error after
28
- * the transport is force-disposed — never a hang.
29
- */
30
- static start(transport: LspTransport, root: string, spec: ServerSpec, timeouts: ServerTimeouts): Promise<Server>;
31
- definition(file: string, line: number, col: number): Promise<LspLocation[]>;
32
- references(file: string, line: number, col: number): Promise<LspLocation[]>;
33
- hover(file: string, line: number, col: number): Promise<LspHover | null>;
34
- diagnostics(file: string): Promise<LspDiagnostic[]>;
35
- shutdown(force?: boolean): Promise<void>;
36
- private uri;
37
- private ensureOpen;
38
- private query;
39
- /** One request with per-request timeout + coded-error mapping (timeout/crash). */
40
- private request;
41
- private onPublishDiagnostics;
42
- private waitForDiagnostics;
43
- private toLocations;
44
- private toLocation;
45
- private toDiagnostic;
46
- /** `file://` URI → project-relative path (falls back to the fs path on error). */
47
- private relativize;
48
- }