@wraith-ai/core 0.1.0 → 0.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 (153) hide show
  1. package/README.md +1 -1
  2. package/dist/{attempt-BeB7EltG.d.mts → attempt-HgararU3.d.mts} +2 -1
  3. package/dist/attempt-HgararU3.d.mts.map +1 -0
  4. package/dist/{capabilities-BPb5HSH6.d.mts → capabilities-CNsPrkB7.d.mts} +2 -1
  5. package/dist/capabilities-CNsPrkB7.d.mts.map +1 -0
  6. package/dist/index.d.mts +6 -5
  7. package/dist/index.d.mts.map +1 -0
  8. package/dist/index.mjs +11 -9
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/{methods-CZp6XGn8.mjs → methods-7Ryz6zbd.mjs} +4 -2
  11. package/dist/methods-7Ryz6zbd.mjs.map +1 -0
  12. package/dist/{model-B6tJ9kX_.mjs → model-C16NUwXW.mjs} +2 -0
  13. package/dist/model-C16NUwXW.mjs.map +1 -0
  14. package/dist/{model-D6LQSveS.d.mts → model-_wqePNTL.d.mts} +4 -3
  15. package/dist/model-_wqePNTL.d.mts.map +1 -0
  16. package/dist/{models-dev-Y0ZikMBQ.d.mts → models-dev-DNgymZy3.d.mts} +3 -2
  17. package/dist/models-dev-DNgymZy3.d.mts.map +1 -0
  18. package/dist/{openai-codex-BhtZvNpm.mjs → openai-codex-Bz1EFPEi.mjs} +3 -1
  19. package/dist/openai-codex-Bz1EFPEi.mjs.map +1 -0
  20. package/dist/{openai-codex-Bk-iG7MZ.mjs → openai-codex-uvjhVoVy.mjs} +6 -4
  21. package/dist/openai-codex-uvjhVoVy.mjs.map +1 -0
  22. package/dist/{openai-compatible-hkXv-P74.mjs → openai-compatible-DBppnQ_N.mjs} +4 -2
  23. package/dist/openai-compatible-DBppnQ_N.mjs.map +1 -0
  24. package/dist/{openrouter-BflQBug2.mjs → openrouter-D8nTOAQo.mjs} +5 -3
  25. package/dist/openrouter-D8nTOAQo.mjs.map +1 -0
  26. package/dist/providers/openai-codex.d.mts +4 -3
  27. package/dist/providers/openai-codex.d.mts.map +1 -0
  28. package/dist/providers/openai-codex.mjs +1 -1
  29. package/dist/providers/openai-compatible.d.mts +3 -2
  30. package/dist/providers/openai-compatible.d.mts.map +1 -0
  31. package/dist/providers/openai-compatible.mjs +1 -1
  32. package/dist/providers/openrouter.d.mts +3 -2
  33. package/dist/providers/openrouter.d.mts.map +1 -0
  34. package/dist/providers/openrouter.mjs +1 -1
  35. package/dist/{shared-8d7RsyPH.mjs → shared-BIJaPhMm.mjs} +3 -1
  36. package/dist/shared-BIJaPhMm.mjs.map +1 -0
  37. package/dist/snapshot.d.mts +3 -2
  38. package/dist/snapshot.d.mts.map +1 -0
  39. package/dist/snapshot.mjs +4999 -4977
  40. package/dist/snapshot.mjs.map +1 -0
  41. package/dist/{turn-effort-DquDDwdE.mjs → turn-effort-C61L4JIt.mjs} +2 -0
  42. package/dist/turn-effort-C61L4JIt.mjs.map +1 -0
  43. package/package.json +3 -2
  44. package/src/agent/agent.ts +90 -0
  45. package/src/agent/attachments.ts +195 -0
  46. package/src/agent/classifier.ts +525 -0
  47. package/src/agent/compact.ts +384 -0
  48. package/src/agent/conversation.ts +300 -0
  49. package/src/agent/cost.ts +164 -0
  50. package/src/agent/inbox.ts +80 -0
  51. package/src/agent/instructions.ts +62 -0
  52. package/src/agent/loop.ts +675 -0
  53. package/src/agent/messages.ts +252 -0
  54. package/src/agent/on-demand.ts +58 -0
  55. package/src/agent/prompts.ts +35 -0
  56. package/src/agent/request-images.ts +94 -0
  57. package/src/agent/stop.ts +37 -0
  58. package/src/agent/title.ts +122 -0
  59. package/src/agent/tool-groups.ts +186 -0
  60. package/src/agent/tools.ts +106 -0
  61. package/src/app.ts +67 -0
  62. package/src/config/credential-file-store.ts +66 -0
  63. package/src/config/environment.ts +105 -0
  64. package/src/config/instructions.ts +157 -0
  65. package/src/config/load.ts +667 -0
  66. package/src/config/locked-file.ts +85 -0
  67. package/src/config/paths.ts +368 -0
  68. package/src/config/schema.ts +363 -0
  69. package/src/config/subagents.ts +156 -0
  70. package/src/config/trust.ts +53 -0
  71. package/src/config/write.ts +241 -0
  72. package/src/errors.ts +85 -0
  73. package/src/events/types.ts +258 -0
  74. package/src/glob.ts +161 -0
  75. package/src/index.ts +681 -0
  76. package/src/logger.ts +47 -0
  77. package/src/paths.ts +143 -0
  78. package/src/permissions/chain.ts +42 -0
  79. package/src/permissions/command.ts +233 -0
  80. package/src/permissions/layered.ts +77 -0
  81. package/src/permissions/match.ts +80 -0
  82. package/src/permissions/modes.ts +48 -0
  83. package/src/permissions/policy.ts +160 -0
  84. package/src/permissions/types.ts +159 -0
  85. package/src/providers/cache.ts +107 -0
  86. package/src/providers/capabilities.ts +77 -0
  87. package/src/providers/catalog-view.ts +91 -0
  88. package/src/providers/catalog.ts +65 -0
  89. package/src/providers/errors.ts +108 -0
  90. package/src/providers/factories/index.ts +15 -0
  91. package/src/providers/factories/openai-codex.ts +382 -0
  92. package/src/providers/factories/openai-compatible.ts +81 -0
  93. package/src/providers/factories/openrouter.ts +165 -0
  94. package/src/providers/factories/shared.ts +22 -0
  95. package/src/providers/model.ts +197 -0
  96. package/src/providers/models-dev.ts +355 -0
  97. package/src/providers/oauth/methods.ts +10 -0
  98. package/src/providers/oauth/openai-codex.ts +228 -0
  99. package/src/providers/oauth.ts +177 -0
  100. package/src/providers/openai-codex.ts +7 -0
  101. package/src/providers/openai-compatible.ts +2 -0
  102. package/src/providers/openrouter.ts +2 -0
  103. package/src/providers/registry.ts +464 -0
  104. package/src/providers/turn-effort.ts +156 -0
  105. package/src/providers/types.ts +83 -0
  106. package/src/session/backend.ts +44 -0
  107. package/src/session/file-store.ts +278 -0
  108. package/src/session/format.ts +1037 -0
  109. package/src/session/memory-store.ts +73 -0
  110. package/src/session/session.ts +153 -0
  111. package/src/session/store.ts +219 -0
  112. package/src/sign-in/attempt.ts +166 -0
  113. package/src/sign-in/loopback.ts +74 -0
  114. package/src/snapshot/data.json +8936 -0
  115. package/src/snapshot/index.ts +37 -0
  116. package/src/tools/bin.ts +364 -0
  117. package/src/tools/builtin.ts +48 -0
  118. package/src/tools/change.ts +88 -0
  119. package/src/tools/define.ts +267 -0
  120. package/src/tools/describe.ts +96 -0
  121. package/src/tools/fs/edit-file.ts +129 -0
  122. package/src/tools/fs/glob.ts +75 -0
  123. package/src/tools/fs/grep.ts +212 -0
  124. package/src/tools/fs/line-endings.ts +17 -0
  125. package/src/tools/fs/list-dir.ts +85 -0
  126. package/src/tools/fs/read-file.ts +230 -0
  127. package/src/tools/fs/ripgrep.ts +211 -0
  128. package/src/tools/fs/write-file.ts +97 -0
  129. package/src/tools/job.ts +252 -0
  130. package/src/tools/mcp/auth-store.ts +127 -0
  131. package/src/tools/mcp/command.ts +151 -0
  132. package/src/tools/mcp/config.ts +168 -0
  133. package/src/tools/mcp/servers.ts +463 -0
  134. package/src/tools/mcp/sign-in.ts +226 -0
  135. package/src/tools/mcp/stdio.ts +204 -0
  136. package/src/tools/mcp/tools.ts +173 -0
  137. package/src/tools/on-demand.ts +184 -0
  138. package/src/tools/registry.ts +935 -0
  139. package/src/tools/shell/bash.ts +217 -0
  140. package/src/tools/shell/find-bash.ts +162 -0
  141. package/src/tools/source.ts +35 -0
  142. package/src/tools/spill.ts +127 -0
  143. package/src/tools/subagents.ts +597 -0
  144. package/src/tools/tasks.ts +603 -0
  145. package/src/tools/to-model.ts +33 -0
  146. package/src/tools/web/address.ts +95 -0
  147. package/src/tools/web/exa.ts +163 -0
  148. package/src/tools/web/fetch.ts +373 -0
  149. package/src/tools/web/html.ts +173 -0
  150. package/src/tools/web/search.ts +111 -0
  151. package/src/tools/web/source.ts +51 -0
  152. package/src/units.ts +18 -0
  153. package/src/version.ts +23 -0
@@ -0,0 +1,173 @@
1
+ import TurndownService from "turndown";
2
+
3
+ /**
4
+ * A page as markdown, for a model that reads it. turndown parses with its own
5
+ * DOM, so this runs on Node as well as Bun.
6
+ */
7
+
8
+ /** Page furniture, not content. */
9
+ const NOISE = new Set([
10
+ "SCRIPT",
11
+ "STYLE",
12
+ "NAV",
13
+ "HEADER",
14
+ "FOOTER",
15
+ "ASIDE",
16
+ "NOSCRIPT",
17
+ "IFRAME",
18
+ "SVG",
19
+ "META",
20
+ "LINK",
21
+ ]);
22
+
23
+ const INVISIBLE = /[​-‍]/g;
24
+
25
+ export interface ConvertedPage {
26
+ /** The document's `<title>`, when it has one. */
27
+ title?: string;
28
+ markdown: string;
29
+ }
30
+
31
+ function oneLine(text: string): string {
32
+ return text.replace(INVISIBLE, "").replace(/\s+/g, " ").trim();
33
+ }
34
+
35
+ /** Where a link leads, in full — a relative one is no use outside its page. */
36
+ function target(href: string, baseUrl: string | undefined): string | undefined {
37
+ try {
38
+ const url = new URL(href, baseUrl);
39
+ return url.protocol === "http:" || url.protocol === "https:" ? url.href : undefined;
40
+ } catch {
41
+ return undefined;
42
+ }
43
+ }
44
+
45
+ function tableOf(node: Node): Element | undefined {
46
+ for (let parent = node.parentNode; parent; parent = parent.parentNode) {
47
+ if (parent.nodeName === "TABLE") return parent as Element;
48
+ }
49
+ return undefined;
50
+ }
51
+
52
+ /**
53
+ * The header row of a table of data, or `undefined`. A table without one is
54
+ * layout and is not drawn as a table, and neither is one holding a `<pre>`:
55
+ * a cell is one line, and code is not.
56
+ */
57
+ function findHeaderRow(table: Element): Element | undefined {
58
+ // turndown's DOM answers `undefined` for no match, where the standard says `null`.
59
+ const first = table.querySelector("tr") ?? undefined;
60
+ const code = table.querySelector("pre") ?? undefined;
61
+ if (first === undefined || code !== undefined) return undefined;
62
+ const cells = Array.from(first.children);
63
+ const heading =
64
+ first.parentElement?.nodeName === "THEAD" ||
65
+ (cells.length > 0 && cells.every((cell) => cell.nodeName === "TH"));
66
+ return heading ? first : undefined;
67
+ }
68
+
69
+ /** `language-ts` on the block or on the `<code>` inside it, which is the convention. */
70
+ function languageOf(pre: Element): string {
71
+ const classes = `${pre.getAttribute("class") ?? ""} ${pre.firstElementChild?.getAttribute("class") ?? ""}`;
72
+ return /(?:^|\s)lang(?:uage)?-([\w+#.-]+)/.exec(classes)?.[1] ?? "";
73
+ }
74
+
75
+ export function htmlToMarkdown(html: string, baseUrl?: string): ConvertedPage {
76
+ let title: string | undefined;
77
+
78
+ // Asked once per cell, so remembered per table.
79
+ const headers = new Map<Element, Element | undefined>();
80
+ const headerRow = (table: Element | undefined): Element | undefined => {
81
+ if (table === undefined) return undefined;
82
+ if (!headers.has(table)) headers.set(table, findHeaderRow(table));
83
+ return headers.get(table);
84
+ };
85
+
86
+ const service = new TurndownService({
87
+ headingStyle: "atx",
88
+ hr: "---",
89
+ bulletListMarker: "-",
90
+ codeBlockStyle: "fenced",
91
+ emDelimiter: "*",
92
+ });
93
+
94
+ // `nodeName` is upper case in HTML and as written inside an <svg>.
95
+ service.remove((node) => NOISE.has(node.nodeName.toUpperCase()));
96
+
97
+ service.addRule("title", {
98
+ // Upper case means the document's own: an <svg> has titles too, in lower case.
99
+ filter: (node) => node.nodeName === "TITLE",
100
+ replacement: (content) => {
101
+ title ??= oneLine(content);
102
+ return "";
103
+ },
104
+ });
105
+
106
+ // Images are outside what this tool returns, and their addresses are only noise.
107
+ service.addRule("image", { filter: "img", replacement: () => "" });
108
+
109
+ service.addRule("link", {
110
+ filter: (node) => node.nodeName === "A" && node.getAttribute("href") !== null,
111
+ replacement: (content, node) => {
112
+ const text = oneLine(content);
113
+ const href = (node as Element).getAttribute("href") ?? "";
114
+ // A heading's own anchor: the text stays, the "#" marker beside it goes.
115
+ if (href.startsWith("#")) return text === "#" ? "" : text;
116
+ if (text === "") return "";
117
+ const url = target(href, baseUrl);
118
+ return url === undefined ? text : `[${text}](${url})`;
119
+ },
120
+ });
121
+
122
+ // A heading wrapping a block element must stay on one line: otherwise its
123
+ // "##" sits on a line of its own.
124
+ service.addRule("heading", {
125
+ filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
126
+ replacement: (content, node) => {
127
+ const text = oneLine(content);
128
+ return text === "" ? "" : `\n\n${"#".repeat(Number(node.nodeName.charAt(1)))} ${text}\n\n`;
129
+ },
130
+ });
131
+
132
+ // Every <pre> is a code block, with or without a <code> inside it; matching
133
+ // only <pre><code> turns the code into escaped prose.
134
+ service.addRule("pre", {
135
+ filter: "pre",
136
+ replacement: (_content, node) => {
137
+ const code = (node.textContent ?? "").replace(/^\n+|\s+$/g, "");
138
+ if (code === "") return "";
139
+ let fence = "```";
140
+ while (code.includes(fence)) fence += "`";
141
+ return `\n\n${fence}${languageOf(node as Element)}\n${code}\n${fence}\n\n`;
142
+ },
143
+ });
144
+
145
+ // turndown has no table rules. These three handle tables of data only.
146
+ service.addRule("tableCell", {
147
+ filter: (node) =>
148
+ (node.nodeName === "TD" || node.nodeName === "TH") && headerRow(tableOf(node)) !== undefined,
149
+ replacement: (content) => ` ${oneLine(content).replace(/\|/g, "\\|")} |`,
150
+ });
151
+ service.addRule("tableRow", {
152
+ filter: (node) => node.nodeName === "TR" && headerRow(tableOf(node)) !== undefined,
153
+ replacement: (content, node) => {
154
+ const row = `|${content}\n`;
155
+ if (headerRow(tableOf(node)) !== node) return row;
156
+ return `${row}|${" --- |".repeat((node as Element).children.length)}\n`;
157
+ },
158
+ });
159
+ service.addRule("tableSection", {
160
+ // Otherwise each is a block, and a blank line between head and body ends the table.
161
+ filter: (node) =>
162
+ ["THEAD", "TBODY", "TFOOT"].includes(node.nodeName) && headerRow(tableOf(node)) !== undefined,
163
+ replacement: (content) => content,
164
+ });
165
+
166
+ const markdown = service
167
+ .turndown(html)
168
+ .replace(/[ \t]+$/gm, "")
169
+ .replace(/\n{3,}/g, "\n\n")
170
+ .trim();
171
+
172
+ return { markdown, ...(title === undefined || title === "" ? {} : { title }) };
173
+ }
@@ -0,0 +1,111 @@
1
+ import { z } from "zod";
2
+ import { AgentError } from "../../errors";
3
+ import { defineTool } from "../define";
4
+
5
+ /**
6
+ * Web search as an ordinary tool: one request to a search service, no model on
7
+ * the way, and the conversation's own model reads what comes back.
8
+ *
9
+ * The backend is a parameter: the tests inject one and never touch the
10
+ * network, and a host can supply its own.
11
+ */
12
+
13
+ export interface WebSearchResult {
14
+ title: string;
15
+ url: string;
16
+ /** When the page was published, if the service knows. */
17
+ published?: string;
18
+ /** The passages that matched — an excerpt, not the page. */
19
+ text: string;
20
+ }
21
+
22
+ export type WebSearch = (
23
+ query: string,
24
+ options: { limit: number; signal: AbortSignal },
25
+ ) => Promise<readonly WebSearchResult[]>;
26
+
27
+ const DEFAULT_RESULTS = 5;
28
+ const MAX_RESULTS = 10;
29
+ /** Exa returns 3–4 thousand characters a result; ten of those is too much to read. */
30
+ const RESULT_TEXT_CHARS = 1_500;
31
+ const TITLE_CHARS = 200;
32
+ const TIMEOUT_MS = 30_000;
33
+
34
+ interface WebSearchOutput {
35
+ query: string;
36
+ results: WebSearchResult[];
37
+ notice?: string;
38
+ }
39
+
40
+ function clip(text: string, limit: number): string {
41
+ return text.length <= limit ? text : `${text.slice(0, limit).trimEnd()}…`;
42
+ }
43
+
44
+ export function createWebSearchTool(search: WebSearch) {
45
+ return defineTool({
46
+ name: "web_search",
47
+ description:
48
+ "Search the web. Returns the best matching pages: title, address and the passages " +
49
+ "that matched. Describe the page you are looking for rather than listing keywords. " +
50
+ "Results are excerpts — use web_fetch on an address when you need the whole page. " +
51
+ "The query goes to an external search service, so keep secrets and private code out of it.",
52
+ danger: "network",
53
+ inputSchema: z.object({
54
+ query: z.string().min(1).describe("What to look for, in plain words."),
55
+ limit: z
56
+ .number()
57
+ .int()
58
+ .min(1)
59
+ .max(MAX_RESULTS)
60
+ .optional()
61
+ .describe(`How many results to return, ${String(DEFAULT_RESULTS)} by default.`),
62
+ }),
63
+ describe: (input) => input.query,
64
+ execute: async (input, context): Promise<WebSearchOutput> => {
65
+ const limit = input.limit ?? DEFAULT_RESULTS;
66
+ const timeout = AbortSignal.timeout(TIMEOUT_MS);
67
+
68
+ let found: readonly WebSearchResult[];
69
+ try {
70
+ found = await search(input.query, {
71
+ limit,
72
+ signal: AbortSignal.any([context.signal, timeout]),
73
+ });
74
+ } catch (error) {
75
+ if (error instanceof AgentError) throw error;
76
+ if (timeout.aborted) {
77
+ throw new AgentError(
78
+ "tool/timeout",
79
+ `The search service did not answer within ${String(TIMEOUT_MS)} ms.`,
80
+ { details: { query: input.query } },
81
+ );
82
+ }
83
+ // Cancelled by the user: the registry already answers for that.
84
+ if (context.signal.aborted) throw error;
85
+ throw new AgentError(
86
+ "tool/failed",
87
+ `The search failed: ${error instanceof Error ? error.message : String(error)}`,
88
+ { cause: error, details: { query: input.query } },
89
+ );
90
+ }
91
+
92
+ // Cut here, not in the backend: the ceiling has to hold for somebody else's too.
93
+ const results = found.slice(0, limit).map((result) => ({
94
+ title: clip(result.title, TITLE_CHARS),
95
+ url: result.url,
96
+ ...(result.published === undefined ? {} : { published: result.published }),
97
+ text: clip(result.text, RESULT_TEXT_CHARS),
98
+ }));
99
+
100
+ return {
101
+ query: input.query,
102
+ results,
103
+ ...(results.length === 0
104
+ ? { notice: "Nothing matched. Describe the page differently, or with fewer details." }
105
+ : {}),
106
+ };
107
+ },
108
+ describeResult: (output) =>
109
+ `${String(output.results.length)} ${output.results.length === 1 ? "result" : "results"}`,
110
+ });
111
+ }
@@ -0,0 +1,51 @@
1
+ import type { AgentTool } from "../define";
2
+ import type { ToolSource } from "../source";
3
+ import { exaSearch } from "./exa";
4
+ import { createWebFetchTool, webFetchTool, type WebFetchOptions } from "./fetch";
5
+ import { createWebSearchTool, type WebSearch } from "./search";
6
+
7
+ /**
8
+ * The two network tools, as a source of their own.
9
+ *
10
+ * Not built-ins: a host that does not add this source sends nothing to
11
+ * anybody, and that has to be true without reading a configuration.
12
+ */
13
+
14
+ export const WEB_SOURCE_ID = "web";
15
+
16
+ export interface WebToolOptions extends WebFetchOptions {
17
+ /**
18
+ * Where `web_search` asks. Absent means Exa's hosted endpoint, which needs no
19
+ * key; `false` leaves the tool out.
20
+ */
21
+ search?: WebSearch | false;
22
+ /** For the default backend only: lifts its free quota. */
23
+ exaApiKey?: string;
24
+ /** For the default backend only: how a user of this application stores that key. */
25
+ exaKeyHint?: string;
26
+ }
27
+
28
+ export function webToolSource(options: WebToolOptions = {}): ToolSource {
29
+ const tools: AgentTool[] = [createWebFetchTool(options)];
30
+
31
+ if (options.search !== false) {
32
+ tools.push(
33
+ createWebSearchTool(
34
+ options.search ??
35
+ exaSearch({
36
+ ...(options.exaApiKey === undefined ? {} : { apiKey: options.exaApiKey }),
37
+ ...(options.exaKeyHint === undefined ? {} : { keyHint: options.exaKeyHint }),
38
+ ...(options.fetch === undefined ? {} : { fetch: options.fetch }),
39
+ }),
40
+ ),
41
+ );
42
+ }
43
+
44
+ return {
45
+ id: WEB_SOURCE_ID,
46
+ list: async () => [...tools],
47
+ };
48
+ }
49
+
50
+ /** Both tools as an unconfigured host gets them: for listings and for describing stored calls. */
51
+ export const webTools: readonly AgentTool[] = [webFetchTool, createWebSearchTool(exaSearch())];
package/src/units.ts ADDED
@@ -0,0 +1,18 @@
1
+ /** Sizes and durations as words, for sentences a model or a person reads. */
2
+
3
+ /** "1.2 MB". */
4
+ export function formatBytes(bytes: number): string {
5
+ if (bytes < 1024) return `${String(bytes)} B`;
6
+ if (bytes < 1024 * 1024) return `${String(Math.round(bytes / 1024))} KB`;
7
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
8
+ }
9
+
10
+ /** "3m 04s". */
11
+ export function formatDuration(ms: number): string {
12
+ if (ms < 1_000) return `${String(Math.max(0, Math.round(ms)))} ms`;
13
+ const seconds = Math.round(ms / 1_000);
14
+ if (seconds < 60) return `${String(seconds)}s`;
15
+ const minutes = Math.floor(seconds / 60);
16
+ if (minutes < 60) return `${String(minutes)}m ${String(seconds % 60).padStart(2, "0")}s`;
17
+ return `${String(Math.floor(minutes / 60))}h ${String(minutes % 60).padStart(2, "0")}m`;
18
+ }
package/src/version.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The version, from one place, injected at build time.
3
+ *
4
+ * `--define` substitutes a bare identifier, not an exported constant, so this
5
+ * file declares a free identifier and reads it with `typeof`, which does not
6
+ * throw when the identifier is undeclared.
7
+ *
8
+ * Running from source says `0.0.0-dev`, which tells a checkout from a release.
9
+ * A binary that still says `0.0.0-dev` means the flag silently did nothing.
10
+ */
11
+
12
+ declare const WRAITH_VERSION: string | undefined;
13
+
14
+ /** What a run from the repository reports. Tests assert against it. */
15
+ export const DEV_VERSION = "0.0.0-dev";
16
+
17
+ export const CORE_VERSION: string =
18
+ typeof WRAITH_VERSION === "string" && WRAITH_VERSION !== "" ? WRAITH_VERSION : DEV_VERSION;
19
+
20
+ /** Whether this process is running from source rather than a compiled binary. */
21
+ export function isDevBuild(): boolean {
22
+ return CORE_VERSION === DEV_VERSION;
23
+ }