@cruxy/cli 1.0.3 → 1.0.5

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 +2 -2
  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,73 +0,0 @@
1
- /**
2
- * Version-control / forge types for PR generation (C.15). The {@link ForgeProvider}
3
- * interface is the swap seam — GitHub ships first, GitLab/Bitbucket slot in later
4
- * without touching call sites (same discipline as `VectorStore`/`Embedder`).
5
- */
6
- /**
7
- * The forge-target identity parsed from the `origin` remote — just host/owner/repo,
8
- * no network lookup. This is the value the C.26 Step-4 wrong-repo guard compares
9
- * across the preview→API-call window (see {@link ForgeProvider.resolveRepoIdentity}).
10
- */
11
- export interface RepoIdentity {
12
- /** Forge host, e.g. `github.com`. */
13
- readonly host: string;
14
- /** Repository owner (user or org). */
15
- readonly owner: string;
16
- /** Repository name (no `.git` suffix). */
17
- readonly repo: string;
18
- }
19
- /** Where a repository lives and who owns it, parsed from the `origin` remote. */
20
- export interface RepoInfo extends RepoIdentity {
21
- /** Default branch, when the provider can resolve it (PR base fallback). */
22
- readonly defaultBranch?: string;
23
- }
24
- /** Everything needed to open one pull request. */
25
- export interface PullRequestSpec {
26
- readonly title: string;
27
- readonly body: string;
28
- /** The branch carrying the change. */
29
- readonly head: string;
30
- /** The branch to merge into. */
31
- readonly base: string;
32
- readonly draft?: boolean;
33
- }
34
- /** The outcome of opening (or finding an already-open) pull request. */
35
- export interface PullRequestResult {
36
- readonly url: string;
37
- readonly number: number;
38
- /** True when a PR for this head already existed and we returned it. */
39
- readonly alreadyExists: boolean;
40
- }
41
- /**
42
- * An abstract forge. The orchestrator depends only on this; the concrete
43
- * GitHub/GitLab implementation is chosen by {@link createForgeProvider}.
44
- */
45
- export interface ForgeProvider {
46
- /** Stable id, e.g. `"github"`. */
47
- readonly id: string;
48
- /** Parse the repository's `origin` remote into structured {@link RepoInfo}. */
49
- getRepoInfo(cwd: string): Promise<RepoInfo>;
50
- /**
51
- * Re-parse just the `origin` remote's {@link RepoIdentity} — LOCAL only, no
52
- * network. The C.26 Step-4 wrong-repo guard calls this immediately before the
53
- * pull-request API call and compares it against the identity shown at approval;
54
- * a mismatch (a mid-run `git remote set-url`) refuses the PR. It stays local so
55
- * the re-check is cheap and cannot fail on a network hiccup. Throws the same
56
- * coded usage errors as {@link getRepoInfo} when there is no parseable `origin`.
57
- */
58
- resolveRepoIdentity(cwd: string): RepoIdentity;
59
- /** Open a pull request and return its URL (idempotent on already-exists). */
60
- createPullRequest(repo: RepoInfo, spec: PullRequestSpec): Promise<PullRequestResult>;
61
- }
62
- /**
63
- * The full set of fields a PR publish needs, produced by `generate.ts`. The
64
- * commit subject and PR title are the same conventional-commit line; the bodies
65
- * may differ (the PR body is the richer, structured summary).
66
- */
67
- export interface GeneratedContent {
68
- readonly branchName: string;
69
- readonly commitSubject: string;
70
- readonly commitBody: string;
71
- readonly prTitle: string;
72
- readonly prBody: string;
73
- }
@@ -1,13 +0,0 @@
1
- import type { SearchResult } from "./types.js";
2
- /**
3
- * Wrap a list of already-bounded search results as untrusted data for the model.
4
- * Each field (title/url/snippet) is sanitized; the whole block is fenced so the
5
- * model treats it as reference data, never commands.
6
- */
7
- export declare function demarcateSearchResults(query: string, results: SearchResult[]): string;
8
- /**
9
- * Wrap a fetched page's text as untrusted data for the model. Same discipline as
10
- * search results: sanitized, fence-neutralized, and clearly boxed as data. The
11
- * caller passes the FINAL url (post-redirect) and any truncation note.
12
- */
13
- export declare function demarcatePage(url: string, rawText: string, note?: string): string;
@@ -1,11 +0,0 @@
1
- import type { FetchResult, WebConfig, WebDeps } from "./types.js";
2
- /**
3
- * Fetch one URL as text, enforcing every bound. Returns a {@link FetchResult}.
4
- * Throws {@link webBlockedHost} for an SSRF-refused URL (never dispatched),
5
- * {@link webFetchFailed} for a network error / timeout / non-text or over-redirect
6
- * response. A page fetched successfully but empty of text is a valid result with
7
- * empty `text` (the tool surfaces it as `ok:true`, not an error).
8
- */
9
- export declare function fetchUrl(rawUrl: string, config: WebConfig, deps?: WebDeps): Promise<FetchResult>;
10
- /** Fetch a URL and render it as a demarcated, scrubbed, untrusted-data block. */
11
- export declare function runWebFetch(rawUrl: string, config: WebConfig, deps?: WebDeps): Promise<string>;
@@ -1,7 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./provider.js";
3
- export * from "./search.js";
4
- export * from "./fetch.js";
5
- export * from "./ssrf.js";
6
- export * from "./demarcate.js";
7
- export * from "./tools.js";
@@ -1,29 +0,0 @@
1
- import type { SearchProvider, SearchResult, WebConfig, WebDeps } from "./types.js";
2
- /**
3
- * Search-provider seam (C.20). `createSearchProvider` resolves the configured
4
- * backend and its API key. There is no gateway search endpoint today (the SDK
5
- * Provider only streams chat), so the direct Tavily provider sits behind the seam;
6
- * a gateway-backed provider would slot in here with no change to the tools.
7
- *
8
- * A missing key or unknown provider throws {@link webUnavailable} — a coded,
9
- * actionable failure, NEVER a silent empty result (the honesty rule: "no provider"
10
- * must not read as "no results").
11
- */
12
- export declare function createSearchProvider(config: WebConfig, deps?: WebDeps): SearchProvider;
13
- /**
14
- * Tavily direct provider. The API key travels ONLY in the `Authorization` header
15
- * (never in the query text or URL, never logged), so the outbound query carries no
16
- * secret. Any non-2xx / network / timeout outcome becomes a thrown
17
- * {@link webSearchFailed}; an empty `results` array is a legitimate zero-result
18
- * outcome and is returned as `[]` (the tool renders "no results" as `ok:true`).
19
- */
20
- export declare class TavilyProvider implements SearchProvider {
21
- private readonly apiKey;
22
- private readonly fetchImpl;
23
- readonly name = "tavily";
24
- constructor(apiKey: string, fetchImpl: typeof fetch);
25
- search(query: string, opts: {
26
- maxResults: number;
27
- signal: AbortSignal;
28
- }): Promise<SearchResult[]>;
29
- }
@@ -1,17 +0,0 @@
1
- import type { SearchResult, WebConfig, WebDeps } from "./types.js";
2
- /**
3
- * Apply the top-N and per-snippet caps. The provider is asked for `maxResults`,
4
- * but we re-cap defensively (a provider may over-return) and truncate each snippet
5
- * with a visible marker so a long body can't blow the context budget.
6
- */
7
- export declare function boundResults(results: SearchResult[], config: WebConfig): SearchResult[];
8
- /**
9
- * Run one web search and return the demarcated, bounded, scrubbed result block.
10
- *
11
- * Throws coded errors for the two failure modes the caller must NOT collapse into
12
- * an empty result: {@link webUnavailable} (no provider/key — via
13
- * `createSearchProvider`) and {@link webSearchFailed} (the search errored — via the
14
- * provider). A search that runs and finds nothing returns a demarcated "(no
15
- * results)" block — an ordinary success the tool surfaces as `ok:true`.
16
- */
17
- export declare function runWebSearch(query: string, config: WebConfig, deps?: WebDeps): Promise<string>;
@@ -1,41 +0,0 @@
1
- import { type Dispatcher } from "undici";
2
- import type { HostResolver } from "./types.js";
3
- /**
4
- * SSRF guard (C.20). A URL the MODEL chose must not be able to reach the user's
5
- * internal network, cloud metadata service, or loopback interface. Three layers:
6
- *
7
- * 1. Scheme allowlist — only `http`/`https` (blocks `file:`, `data:`, `gopher:`…).
8
- * 2. Address check — the hostname is RESOLVED and every returned address is
9
- * checked against private/loopback/link-local/reserved ranges (v4 and v6,
10
- * including IPv4-mapped and alternate IP encodings).
11
- * 3. Connection pinning — the connection is pinned to the exact address the check
12
- * validated (see {@link createPinnedDispatcher}). Without this, resolving-then-
13
- * fetching re-resolves the hostname at connect time, so a DNS-rebind attacker
14
- * can pass the check with a public IP and have the socket land on 127.0.0.1
15
- * (a TOCTOU hole). Pinning closes it: the connection can only reach a validated
16
- * address, and the host header / TLS SNI still carry the original hostname.
17
- *
18
- * The check runs BEFORE any request is dispatched, and again on every redirect hop
19
- * (see fetch.ts). A block is a security refusal, distinct from a network failure.
20
- *
21
- * The IP range math, the pin shim, and the error types now live in the shared
22
- * {@link ../net/ip-guard ip-guard} module (JC-A) — the ONE owner of "is this IP
23
- * allowed"; this file keeps only the web-specific policy (scheme + the
24
- * `allowPrivateHosts` escape hatch) and the web one-shot dispatcher.
25
- */
26
- export { BlockedHostError, HostUnresolvedError, isBlockedAddress, defaultResolveHost, pinnedLookup, } from "../net/ip-guard.js";
27
- /** An undici dispatcher whose connections are pinned to `addresses`. */
28
- export declare function createPinnedDispatcher(addresses: string[]): Dispatcher;
29
- /**
30
- * Assert that `url` may be fetched and return the validated addresses to pin the
31
- * connection to. Throws {@link BlockedHostError} for a bad scheme or a host
32
- * resolving into a blocked range, or `HostUnresolvedError` if the host cannot be
33
- * resolved.
34
- *
35
- * The returned list is the exact set of addresses the caller must restrict the
36
- * connection to (via {@link createPinnedDispatcher}). An empty list means "do not
37
- * pin" — only returned under `allowPrivate`, the deliberate internal-network escape
38
- * hatch (from `web.allowPrivateHosts`), which bypasses the address check and lets
39
- * the transport resolve normally. The scheme check always applies.
40
- */
41
- export declare function assertFetchable(url: URL, resolveHost: HostResolver, allowPrivate: boolean): Promise<string[]>;
@@ -1,20 +0,0 @@
1
- import { z } from "zod";
2
- import type { Tool } from "../tools/types.js";
3
- import type { WebDeps } from "./types.js";
4
- declare const searchParams: z.ZodObject<{
5
- query: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- query: string;
8
- }, {
9
- query: string;
10
- }>;
11
- export declare function createWebSearchTool(deps?: WebDeps): Tool<typeof searchParams>;
12
- declare const fetchParams: z.ZodObject<{
13
- url: z.ZodString;
14
- }, "strip", z.ZodTypeAny, {
15
- url: string;
16
- }, {
17
- url: string;
18
- }>;
19
- export declare function createWebFetchTool(deps?: WebDeps): Tool<typeof fetchParams>;
20
- export {};
@@ -1,64 +0,0 @@
1
- import type { HostResolver } from "../net/ip-guard.js";
2
- import type { WebConfig } from "../config/index.js";
3
- /**
4
- * Web subtool seams + shapes (C.20). Everything the `web_search`/`web_fetch`
5
- * tools touch is defined here so the injectable dependencies (HTTP, DNS) have one
6
- * home and tests can substitute them without patching globals.
7
- */
8
- /** One ranked search hit — the only fields we surface to the model. */
9
- export interface SearchResult {
10
- title: string;
11
- url: string;
12
- snippet: string;
13
- }
14
- /** The outcome of reading a single URL as text. */
15
- export interface FetchResult {
16
- /** The final URL actually read (after any followed, re-validated redirects). */
17
- url: string;
18
- /** The response's declared content type (lower-cased, params stripped). */
19
- contentType: string;
20
- /** The decoded, size-capped body text. */
21
- text: string;
22
- /** True when the body was truncated at the byte cap. */
23
- truncated: boolean;
24
- }
25
- /**
26
- * The swappable search backend. A direct provider (Tavily) implements this today;
27
- * a gateway-backed provider would implement the SAME interface if the backend ever
28
- * proxies search. Implementations translate provider errors into thrown
29
- * {@link CruxyError}s (never a silent empty) — the tool layer owns the honesty
30
- * split between "search failed" and "search found nothing".
31
- */
32
- export interface SearchProvider {
33
- /** Stable id for logging/tests (e.g. "tavily"). */
34
- readonly name: string;
35
- /**
36
- * Run one query. Returns the provider's results (the tool applies the top-N and
37
- * snippet caps). Throws on provider/network/timeout failure. An empty array is a
38
- * legitimate "no results" — NOT an error.
39
- */
40
- search(query: string, opts: {
41
- maxResults: number;
42
- signal: AbortSignal;
43
- }): Promise<SearchResult[]>;
44
- }
45
- /**
46
- * Resolve a hostname to its IP addresses. Injected so the SSRF guard can be tested
47
- * deterministically (a hostname that "resolves" to an internal IP) without real
48
- * DNS. Owned by the shared {@link ../net/ip-guard ip-guard} module (JC-A) and
49
- * re-exported here for web importers.
50
- */
51
- export type { HostResolver } from "../net/ip-guard.js";
52
- /**
53
- * Injectable dependencies for the web tools. Defaults wire the real `fetch` and
54
- * DNS; tests pass spies/fakes. No global is ever patched.
55
- */
56
- export interface WebDeps {
57
- /** HTTP transport (default: global `fetch`). */
58
- fetchImpl?: typeof fetch;
59
- /** DNS resolver used by the SSRF guard (default: `dns.lookup`, all addresses). */
60
- resolveHost?: HostResolver;
61
- /** Read the provider API key from the environment (default: `process.env`). */
62
- env?: NodeJS.ProcessEnv;
63
- }
64
- export type { WebConfig };
@@ -1,27 +0,0 @@
1
- import type { RootSpec } from "./types.js";
2
- import { Workspace } from "./workspace.js";
3
- /**
4
- * The interactive add-root path (C.26 step 5). Adding a workspace root is an
5
- * EXPLICIT HUMAN act — it grows the trust surface (a new root can carry its own
6
- * hooks / MCP / project memory), so it is:
7
- *
8
- * - reachable ONLY from the REPL command and the CLI, never as a model tool.
9
- * The model can act only through the tool registry (`registry.get(name)`),
10
- * and no tool is registered for this — the allowlist argument is unchanged.
11
- * - TTY-only: refused (coded) when there is no interactive human to vouch.
12
- * - held to the SAME validation as `--root`: the new root must exist, be a
13
- * directory, have a unique name, and NOT nest/overlap an existing root
14
- * (CRUXY_E_ROOT_OVERLAP) — reusing {@link buildWorkspace}, the single
15
- * Workspace constructor from user input.
16
- *
17
- * Returns the NEW immutable Workspace (the root set only ever grows by
18
- * constructing a new one). A freshly added root starts UNTRUSTED; its hooks and
19
- * project memory stay inert until explicitly trusted.
20
- */
21
- export interface AddRootOptions {
22
- /** Base dir for resolving a relative `path` (the session's primary root). */
23
- cwd: string;
24
- /** Whether stdin is a TTY — add-root is refused without an interactive human. */
25
- tty: boolean;
26
- }
27
- export declare function addRootToWorkspace(current: Workspace, spec: RootSpec, opts: AddRootOptions): Promise<Workspace>;
@@ -1,6 +0,0 @@
1
- export type { DeclaredRoot, RootSpec } from "./types.js";
2
- export { Workspace, buildWorkspace, sessionWorkspace } from "./workspace.js";
3
- export { PathEscapeError, confineToRoot, isInside, resolveInWorkspace, } from "./resolve.js";
4
- export { selectRoot } from "./select.js";
5
- export type { RootRef, SelectedRoot } from "./select.js";
6
- export { addRootToWorkspace, type AddRootOptions } from "./add-root.js";
@@ -1,54 +0,0 @@
1
- import { CruxyError } from "../errors/index.js";
2
- import type { Workspace } from "./workspace.js";
3
- /**
4
- * The single path-confinement funnel for the whole CLI (C.26). Two things live
5
- * here so there is exactly ONE confinement implementation, not several:
6
- * • {@link confineToRoot} — the pure 2-layer check (lexical + symlink) against
7
- * ONE root. It never sees any other root, which is the structural argument
8
- * that a validated target can't cross into a sibling root.
9
- * • {@link resolveInWorkspace} — select the one named root, then confine to it.
10
- */
11
- /**
12
- * Thrown when a tool argument resolves to a path outside the root it is acting in
13
- * — via `../` traversal, an absolute path, an outward symlink, OR a path that
14
- * lands in a *different* declared root. A cross-root path is deliberately the
15
- * SAME error as any other escape (R2): a distinct code would wrongly imply
16
- * "less bad". A {@link CruxyError} (code CRUXY_E_PATH_ESCAPE) so it carries a code
17
- * if it reaches the boundary; tools still catch it and surface `{ ok:false }`.
18
- */
19
- export declare class PathEscapeError extends CruxyError {
20
- constructor(message: string);
21
- }
22
- /** Is `target` the root itself or a descendant of it? */
23
- export declare function isInside(root: string, target: string): boolean;
24
- /**
25
- * Resolve `p` against a SINGLE root and prove it stays inside — the pure kernel
26
- * every file tool ultimately funnels through.
27
- *
28
- * Two layers: (1) a lexical check that the resolved absolute path is within root
29
- * (rejects `../` and absolute-outside before touching the FS); (2) a symlink
30
- * check that the real target — or, for a new path, its nearest existing parent —
31
- * resolves inside the *real* root. The root is realpath'd too, so this is correct
32
- * even when the root itself sits under a symlink (macOS `/var → /private/var`).
33
- *
34
- * Crucially, this function is a pure function of `(one root, the path)`. The rest
35
- * of the declared root set is NOT in scope here, so there is no code path by
36
- * which a target validated against this root can be accepted into another root.
37
- *
38
- * @returns the resolved absolute path (lexical, not realpath'd — so callers
39
- * operate on the intended location).
40
- * @throws {PathEscapeError} if the path escapes the root.
41
- */
42
- export declare function confineToRoot(rootAbsPath: string, p: string): Promise<string>;
43
- /**
44
- * Resolve a tool-supplied path against ONE named root of the workspace and prove
45
- * it stays inside that root. Selection happens first (by exact name — see
46
- * {@link Workspace.rootByName}, which fail-loud refuses an unknown name), and
47
- * confinement runs against only that one root's path. A `../otherRoot/x` that
48
- * would land in a sibling declared root is refused exactly as any escape is (R2),
49
- * because {@link confineToRoot} is only ever handed this one root.
50
- *
51
- * @throws {CruxyError} CRUXY_E_ROOT_UNKNOWN if `rootName` is not declared.
52
- * @throws {PathEscapeError} if `p` escapes the selected root.
53
- */
54
- export declare function resolveInWorkspace(ws: Workspace, rootName: string, p: string): Promise<string>;
@@ -1,41 +0,0 @@
1
- import type { DeclaredRoot } from "./types.js";
2
- import type { Workspace } from "./workspace.js";
3
- /**
4
- * How a tool call addresses a workspace root (C.26, R1). Either an explicit `root`
5
- * name plus a root-relative `path`, or just a `path` that may carry a leading
6
- * root-name segment. Bare relative paths fall back to the primary root; absolute
7
- * paths select the unique root that contains them.
8
- */
9
- export interface RootRef {
10
- /** Explicit root name (`root: "service"`). Wins over any name in `path`. */
11
- readonly root?: string;
12
- /** The path argument (root-relative, name-prefixed, or absolute). */
13
- readonly path: string;
14
- }
15
- /** The outcome of resolving a {@link RootRef}: the chosen root + a path within it. */
16
- export interface SelectedRoot {
17
- readonly root: DeclaredRoot;
18
- /** The path to hand to `confineToRoot` (root-relative or absolute-inside). */
19
- readonly relPath: string;
20
- }
21
- /**
22
- * Resolve a {@link RootRef} to exactly one declared root and a path within it —
23
- * the selection half of confinement, run BEFORE any resolution so a call always
24
- * commits to a single root first (§1.1). Precedence:
25
- *
26
- * 1. explicit `root` name → that root, exactly (fail-loud on unknown name);
27
- * 2. absolute `path` → the unique declared root containing it (fail-loud on
28
- * unknown / — defensively — ambiguous);
29
- * 3. `path` whose first segment exactly matches a declared root name → that
30
- * root, with the segment stripped (only when the name is unambiguous);
31
- * 4. bare relative `path` → the primary root.
32
- *
33
- * `requireExplicit` (set by mutating tools per ⚖︎#3) refuses the case-4 default
34
- * in a multi-root session: a write must NAME its root rather than silently land
35
- * in the primary. Read/enumeration tools leave it false.
36
- *
37
- * @throws CRUXY_E_ROOT_UNKNOWN / CRUXY_E_ROOT_AMBIGUOUS per the rules above.
38
- */
39
- export declare function selectRoot(ws: Workspace, ref: RootRef, opts?: {
40
- requireExplicit?: boolean;
41
- }): SelectedRoot;
@@ -1,30 +0,0 @@
1
- /**
2
- * Multi-repo workspace model (C.26). A session may operate across N repo/package
3
- * roots. The {@link Workspace} is the single value that carries the declared root
4
- * set; every path-taking tool resolves *through* it rather than through a bare
5
- * `cwd` string.
6
- *
7
- * Two invariants the type system helps enforce:
8
- * • The root set is **immutable for the session** — a {@link Workspace} exposes
9
- * no mutator, so nothing the model can call adds a root. The set only grows by
10
- * the CLI constructing a *new* Workspace from an explicit human act (argv, or
11
- * an interactive add-root that prompts + trusts first).
12
- * • Roots are addressed by a stable **name** (R1), matched **exactly** — never
13
- * by prefix or nearest-match. An unknown name is a fail-loud refusal.
14
- */
15
- /** One declared workspace root: a stable name + its resolved absolute path. */
16
- export interface DeclaredRoot {
17
- /** Stable, user-facing identifier (assigned at declaration, unique per session). */
18
- readonly name: string;
19
- /** Absolute, lexically-resolved path (realpath is applied at confinement time). */
20
- readonly absPath: string;
21
- /** Exactly one root is primary — the default for bare relative paths + git info. */
22
- readonly primary: boolean;
23
- }
24
- /** A root as declared on the CLI (or interactively), before resolution/validation. */
25
- export interface RootSpec {
26
- /** Explicit name (`--root name=path`); defaults to a deduped basename of `path`. */
27
- readonly name?: string;
28
- /** Path as supplied (resolved against `process.cwd()` by `buildWorkspace`). */
29
- readonly path: string;
30
- }
@@ -1,61 +0,0 @@
1
- import type { DeclaredRoot, RootSpec } from "./types.js";
2
- /**
3
- * The declared workspace root set for a session (C.26). Immutable by design: it
4
- * exposes readers only, no mutator. The root set grows solely by the CLI building
5
- * a *new* Workspace from an explicit human act — so no tool, and nothing the model
6
- * emits, can add a root. Roots are addressed by exact name (R1).
7
- */
8
- export declare class Workspace {
9
- private readonly rootsByName;
10
- private readonly ordered;
11
- private readonly primaryRoot;
12
- constructor(roots: readonly DeclaredRoot[]);
13
- /** All declared roots, in declaration order. */
14
- roots(): readonly DeclaredRoot[];
15
- /** The primary root — the default for bare relative paths and git/instructions. */
16
- primary(): DeclaredRoot;
17
- /** True when more than one root is declared (i.e. a genuine multi-repo session). */
18
- get isMultiRoot(): boolean;
19
- /**
20
- * Look up a root by EXACT name (R1). Never fuzzy-, prefix-, or nearest-matched
21
- * — a silent near-match would be a cross-root misfire.
22
- * @throws {CruxyError} CRUXY_E_ROOT_UNKNOWN if no root has that exact name.
23
- */
24
- rootByName(name: string): DeclaredRoot;
25
- /** Like {@link rootByName} but returns undefined instead of throwing. */
26
- tryRootByName(name: string): DeclaredRoot | undefined;
27
- /**
28
- * The single declared root that contains `absPath`. Roots never overlap (that's
29
- * refused at declaration), so at most one can match.
30
- * @throws CRUXY_E_ROOT_UNKNOWN if the path is inside no declared root.
31
- * @throws CRUXY_E_ROOT_AMBIGUOUS if — defensively — it matches more than one.
32
- */
33
- rootContaining(absPath: string): DeclaredRoot;
34
- }
35
- /**
36
- * Build a {@link Workspace} from declared specs (R1, ⚖︎#5). Each path is resolved
37
- * against `process.cwd()`, must exist and be a directory, and the set must not
38
- * overlap (a root nested in / equal to another is refused — declare the monorepo
39
- * root OR its packages, never both). The first spec is primary unless one is
40
- * marked. Names are explicit-or-basename, validated, and deduped.
41
- *
42
- * This is the ONLY constructor of a Workspace from user input; it is called by the
43
- * CLI from argv and by the interactive add-root path — never from a tool.
44
- *
45
- * @throws CRUXY_E_ROOT_OVERLAP on a nested/overlapping/duplicate root.
46
- * @throws CRUXY_E_USAGE on a missing path, non-directory, or bad/duplicate name.
47
- */
48
- export declare function buildWorkspace(specs: readonly RootSpec[], opts?: {
49
- cwd?: string;
50
- }): Promise<Workspace>;
51
- /**
52
- * Build THE session's workspace from a single absolute path — the trivial
53
- * single-root case. This is a *session construction* primitive, not a per-call
54
- * fallback: after C.26 Step 6 it is called ONLY at the two CLI entry points that
55
- * turn argv into a session (`cli/commands/run.ts`, `cli/onboard.ts`), never in the
56
- * middle of a subsystem. Synthesizing one elsewhere would silently scope that
57
- * subsystem to its own cwd while the fan tools see N roots (a split-brain) — the
58
- * `no-split-brain` guard fails on any `sessionWorkspace(` outside those two files.
59
- * The one root is primary and named by its basename.
60
- */
61
- export declare function sessionWorkspace(absPath: string): Workspace;