@defai.digital/ax-cli 3.6.1 → 3.6.2

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 (102) hide show
  1. package/README.md +26 -15
  2. package/config-defaults/settings.yaml +24 -0
  3. package/dist/constants.d.ts +13 -0
  4. package/dist/constants.js +28 -0
  5. package/dist/constants.js.map +1 -1
  6. package/dist/index.js +0 -0
  7. package/dist/schemas/settings-schemas.d.ts +17 -0
  8. package/dist/schemas/settings-schemas.js +15 -0
  9. package/dist/schemas/settings-schemas.js.map +1 -1
  10. package/dist/ui/components/chat-history.d.ts +2 -0
  11. package/dist/ui/components/chat-history.js +32 -81
  12. package/dist/ui/components/chat-history.js.map +1 -1
  13. package/dist/ui/components/chat-interface.js +3 -3
  14. package/dist/ui/components/chat-interface.js.map +1 -1
  15. package/dist/ui/components/status-bar.d.ts +2 -0
  16. package/dist/ui/components/status-bar.js +33 -9
  17. package/dist/ui/components/status-bar.js.map +1 -1
  18. package/dist/ui/components/tool-group-display.d.ts +15 -0
  19. package/dist/ui/components/tool-group-display.js +91 -0
  20. package/dist/ui/components/tool-group-display.js.map +1 -0
  21. package/dist/ui/hooks/use-enhanced-input.js +43 -6
  22. package/dist/ui/hooks/use-enhanced-input.js.map +1 -1
  23. package/dist/ui/hooks/use-input-handler.d.ts +2 -0
  24. package/dist/ui/hooks/use-input-handler.js +13 -7
  25. package/dist/ui/hooks/use-input-handler.js.map +1 -1
  26. package/dist/ui/utils/change-summarizer.d.ts +20 -0
  27. package/dist/ui/utils/change-summarizer.js +193 -0
  28. package/dist/ui/utils/change-summarizer.js.map +1 -0
  29. package/dist/ui/utils/tool-grouper.d.ts +62 -0
  30. package/dist/ui/utils/tool-grouper.js +224 -0
  31. package/dist/ui/utils/tool-grouper.js.map +1 -0
  32. package/dist/utils/config-loader.d.ts +4 -0
  33. package/dist/utils/config-loader.js.map +1 -1
  34. package/dist/utils/paste-utils.js +45 -19
  35. package/dist/utils/paste-utils.js.map +1 -1
  36. package/package.json +2 -2
  37. package/packages/schemas/package.json +1 -1
  38. package/.ax-cli/CUSTOM.md +0 -269
  39. package/.ax-cli/checkpoints/2025-11-20/checkpoint-11e9e0ba-c39d-4fd2-aa77-bc818811c921.json +0 -69
  40. package/.ax-cli/checkpoints/2025-11-20/checkpoint-2b260b98-b418-4c7c-9694-e2b94967e662.json +0 -24
  41. package/.ax-cli/checkpoints/2025-11-20/checkpoint-2dd84869-e62d-46c8-9885-7e45f37f36e2.json +0 -69
  42. package/.ax-cli/checkpoints/2025-11-20/checkpoint-484dc350-353f-4808-9ed1-ebb3cefdab37.json +0 -24
  43. package/.ax-cli/checkpoints/2025-11-20/checkpoint-74a18b87-6172-4215-962b-44bb9f46a662.json +0 -69
  44. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7e03601e-e8ab-4cd7-9841-a74b66adf78f.json +0 -69
  45. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7f9c6562-771f-4fd0-adcf-9e7e9ac34ae8.json +0 -44
  46. package/.ax-cli/checkpoints/2025-11-20/checkpoint-870a5fb9-6e82-4ff2-8ec8-af4c251cc514.json +0 -44
  47. package/.ax-cli/checkpoints/2025-11-20/checkpoint-93946601-0e83-456c-ba47-def9713124dd.json +0 -24
  48. package/.ax-cli/checkpoints/2025-11-20/checkpoint-e1ebe666-4c3a-4367-ba5c-27fe512a9c70.json +0 -24
  49. package/.ax-cli/checkpoints/2025-11-21/checkpoint-15743e7d-430c-4d76-b6fc-955d7a5c250c.json +0 -44
  50. package/.ax-cli/checkpoints/2025-11-21/checkpoint-25cf7679-0b3f-4988-83d7-704548fbba91.json +0 -69
  51. package/.ax-cli/checkpoints/2025-11-21/checkpoint-54aedbac-6db0-464e-8ebb-dbb3979e6dca.json +0 -24
  52. package/.ax-cli/checkpoints/2025-11-21/checkpoint-7658aed8-fe5d-4222-903f-1a7c63717ea7.json +0 -24
  53. package/.ax-cli/checkpoints/2025-11-21/checkpoint-c9c13497-40dc-4294-a327-6a5fc854eaa1.json +0 -69
  54. package/.ax-cli/checkpoints/metadata.json +0 -62
  55. package/.ax-cli/index.json +0 -44
  56. package/.ax-cli/memory.json +0 -62
  57. package/.ax-cli/settings.json +0 -1
  58. package/ax.config.json +0 -333
  59. package/dist/agent/chat-history-manager.d.ts +0 -56
  60. package/dist/agent/chat-history-manager.js +0 -150
  61. package/dist/agent/chat-history-manager.js.map +0 -1
  62. package/dist/agent/tool-manager.d.ts +0 -39
  63. package/dist/agent/tool-manager.js +0 -76
  64. package/dist/agent/tool-manager.js.map +0 -1
  65. package/dist/hooks/use-chat-reducer.d.ts +0 -61
  66. package/dist/hooks/use-chat-reducer.js +0 -118
  67. package/dist/hooks/use-chat-reducer.js.map +0 -1
  68. package/dist/hooks/use-enhanced-input.d.ts +0 -40
  69. package/dist/hooks/use-enhanced-input.js +0 -249
  70. package/dist/hooks/use-enhanced-input.js.map +0 -1
  71. package/dist/hooks/use-input-handler.d.ts +0 -46
  72. package/dist/hooks/use-input-handler.js +0 -1430
  73. package/dist/hooks/use-input-handler.js.map +0 -1
  74. package/dist/hooks/use-input-history.d.ts +0 -9
  75. package/dist/hooks/use-input-history.js +0 -112
  76. package/dist/hooks/use-input-history.js.map +0 -1
  77. package/dist/index.js.bak +0 -664
  78. package/dist/tools/web-search/engines/brave.d.ts +0 -16
  79. package/dist/tools/web-search/engines/brave.js +0 -99
  80. package/dist/tools/web-search/engines/brave.js.map +0 -1
  81. package/dist/tools/web-search/engines/tavily.d.ts +0 -17
  82. package/dist/tools/web-search/engines/tavily.js +0 -73
  83. package/dist/tools/web-search/engines/tavily.js.map +0 -1
  84. package/dist/utils/paste-collapse.d.ts +0 -46
  85. package/dist/utils/paste-collapse.js +0 -77
  86. package/dist/utils/paste-collapse.js.map +0 -1
  87. package/packages/schemas/dist/index.d.ts +0 -14
  88. package/packages/schemas/dist/index.d.ts.map +0 -1
  89. package/packages/schemas/dist/index.js +0 -19
  90. package/packages/schemas/dist/index.js.map +0 -1
  91. package/packages/schemas/dist/public/core/brand-types.d.ts +0 -308
  92. package/packages/schemas/dist/public/core/brand-types.d.ts.map +0 -1
  93. package/packages/schemas/dist/public/core/brand-types.js +0 -243
  94. package/packages/schemas/dist/public/core/brand-types.js.map +0 -1
  95. package/packages/schemas/dist/public/core/enums.d.ts +0 -227
  96. package/packages/schemas/dist/public/core/enums.d.ts.map +0 -1
  97. package/packages/schemas/dist/public/core/enums.js +0 -222
  98. package/packages/schemas/dist/public/core/enums.js.map +0 -1
  99. package/packages/schemas/dist/public/core/id-types.d.ts +0 -286
  100. package/packages/schemas/dist/public/core/id-types.d.ts.map +0 -1
  101. package/packages/schemas/dist/public/core/id-types.js +0 -136
  102. package/packages/schemas/dist/public/core/id-types.js.map +0 -1
@@ -1,99 +0,0 @@
1
- /**
2
- * Brave Search Engine
3
- * Privacy-focused independent search
4
- * https://brave.com/search/api/
5
- */
6
- import axios from "axios";
7
- export class BraveSearch {
8
- name = "brave";
9
- apiKey;
10
- baseUrl = "https://api.search.brave.com/res/v1/web/search";
11
- timeout = 10000; // 10 second timeout
12
- constructor() {
13
- this.apiKey = process.env.BRAVE_API_KEY;
14
- }
15
- isAvailable() {
16
- return !!this.apiKey;
17
- }
18
- async search(query, options) {
19
- if (!this.isAvailable()) {
20
- throw new Error("Brave API key not configured");
21
- }
22
- try {
23
- const params = new URLSearchParams({
24
- q: query,
25
- count: Math.min(options?.maxResults || 10, 20).toString(),
26
- offset: "0",
27
- text_decorations: "false",
28
- spellcheck: "true",
29
- });
30
- // Add freshness filter if specified
31
- if (options?.freshness) {
32
- const freshnessMap = {
33
- day: "pd",
34
- week: "pw",
35
- month: "pm",
36
- year: "py",
37
- };
38
- params.append("freshness", freshnessMap[options.freshness]);
39
- }
40
- const response = await axios.get(`${this.baseUrl}?${params.toString()}`, {
41
- timeout: options?.timeout || this.timeout,
42
- headers: {
43
- Accept: "application/json",
44
- "Accept-Encoding": "gzip",
45
- "X-Subscription-Token": this.apiKey,
46
- },
47
- });
48
- return this.formatResults(response.data);
49
- }
50
- catch (error) {
51
- if (axios.isAxiosError(error)) {
52
- if (error.code === "ECONNABORTED") {
53
- throw new Error("Brave search timeout");
54
- }
55
- if (error.response?.status === 401) {
56
- throw new Error("Invalid Brave API key");
57
- }
58
- if (error.response?.status === 429) {
59
- throw new Error("Brave rate limit exceeded");
60
- }
61
- throw new Error(`Brave API error: ${error.response?.data?.message || error.message}`);
62
- }
63
- throw error;
64
- }
65
- }
66
- formatResults(response) {
67
- const results = [];
68
- // Add web results
69
- if (response.web?.results) {
70
- results.push(...response.web.results.map((result, index) => ({
71
- title: result.title,
72
- url: result.url,
73
- snippet: result.description,
74
- source: this.name,
75
- relevanceScore: 100 - index * 5, // Simple scoring based on position
76
- publishedDate: result.age || result.page_age,
77
- metadata: {
78
- language: result.language,
79
- },
80
- })));
81
- }
82
- // Add news results if available
83
- if (response.news?.results) {
84
- results.push(...response.news.results.map((result, index) => ({
85
- title: result.title,
86
- url: result.url,
87
- snippet: result.description,
88
- source: `${this.name}-news`,
89
- relevanceScore: 95 - index * 5,
90
- publishedDate: result.age,
91
- metadata: {
92
- type: "news",
93
- },
94
- })));
95
- }
96
- return results;
97
- }
98
- }
99
- //# sourceMappingURL=brave.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"brave.js","sourceRoot":"","sources":["../../../../src/tools/web-search/engines/brave.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AA6B1B,MAAM,OAAO,WAAW;IACN,IAAI,GAAG,OAAO,CAAC;IACvB,MAAM,CAAqB;IAC3B,OAAO,GAAG,gDAAgD,CAAC;IAC3D,OAAO,GAAG,KAAK,CAAC,CAAC,oBAAoB;IAE7C;QACE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC1C,CAAC;IAED,WAAW;QACT,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,KAAK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QAChC,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,CACV,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC/C,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,OAAO,EAAE,MAAM,CAAC,WAAW;gBAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,OAAO;gBAC3B,cAAc,EAAE,EAAE,GAAG,KAAK,GAAG,CAAC;gBAC9B,aAAa,EAAE,MAAM,CAAC,GAAG;gBACzB,QAAQ,EAAE;oBACR,IAAI,EAAE,MAAM;iBACb;aACF,CAAC,CAAC,CACJ,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Tavily AI Search Engine
3
- * AI-optimized search designed for LLMs
4
- * https://tavily.com/
5
- */
6
- import type { SearchEngine, WebSearchResult, SearchOptions } from "../types.js";
7
- export declare class TavilySearch implements SearchEngine {
8
- readonly name = "tavily";
9
- private apiKey;
10
- private baseUrl;
11
- private timeout;
12
- constructor();
13
- isAvailable(): boolean;
14
- search(query: string, options?: SearchOptions): Promise<WebSearchResult[]>;
15
- private formatResults;
16
- getAnswer(results: WebSearchResult[]): string | undefined;
17
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * Tavily AI Search Engine
3
- * AI-optimized search designed for LLMs
4
- * https://tavily.com/
5
- */
6
- import axios from "axios";
7
- export class TavilySearch {
8
- name = "tavily";
9
- apiKey;
10
- baseUrl = "https://api.tavily.com/search";
11
- timeout = 10000; // 10 second timeout
12
- constructor() {
13
- this.apiKey = process.env.TAVILY_API_KEY;
14
- }
15
- isAvailable() {
16
- return !!this.apiKey;
17
- }
18
- async search(query, options) {
19
- if (!this.isAvailable()) {
20
- throw new Error("Tavily API key not configured");
21
- }
22
- try {
23
- const response = await axios.post(this.baseUrl, {
24
- api_key: this.apiKey,
25
- query: query,
26
- search_depth: options?.searchDepth || "basic",
27
- max_results: Math.min(options?.maxResults || 5, 10),
28
- include_answer: options?.includeAnswer ?? true,
29
- include_domains: options?.includeDomains || [],
30
- exclude_domains: options?.excludeDomains || [],
31
- }, {
32
- timeout: options?.timeout || this.timeout,
33
- headers: {
34
- "Content-Type": "application/json",
35
- },
36
- });
37
- return this.formatResults(response.data);
38
- }
39
- catch (error) {
40
- if (axios.isAxiosError(error)) {
41
- if (error.code === "ECONNABORTED") {
42
- throw new Error("Tavily search timeout");
43
- }
44
- if (error.response?.status === 401) {
45
- throw new Error("Invalid Tavily API key");
46
- }
47
- if (error.response?.status === 429) {
48
- throw new Error("Tavily rate limit exceeded");
49
- }
50
- throw new Error(`Tavily API error: ${error.response?.data?.message || error.message}`);
51
- }
52
- throw error;
53
- }
54
- }
55
- formatResults(response) {
56
- return response.results.map((result) => ({
57
- title: result.title,
58
- url: result.url,
59
- snippet: result.content,
60
- source: this.name,
61
- relevanceScore: result.score * 100, // Convert 0-1 to 0-100
62
- publishedDate: result.published_date,
63
- metadata: {
64
- answer: response.answer,
65
- responseTime: response.response_time,
66
- },
67
- }));
68
- }
69
- getAnswer(results) {
70
- return results[0]?.metadata?.answer;
71
- }
72
- }
73
- //# sourceMappingURL=tavily.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tavily.js","sourceRoot":"","sources":["../../../../src/tools/web-search/engines/tavily.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAsB1B,MAAM,OAAO,YAAY;IACP,IAAI,GAAG,QAAQ,CAAC;IACxB,MAAM,CAAqB;IAC3B,OAAO,GAAG,+BAA+B,CAAC;IAC1C,OAAO,GAAG,KAAK,CAAC,CAAC,oBAAoB;IAE7C;QACE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,C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I,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBAC5C,CAAC;gBACD,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAChD,CAAC;gBACD,MAAM,IAAI,KAAK,CACb,qBAAqB,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CACtE,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,QAAwB;QAC5C,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACvC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,cAAc,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,uBAAuB;YAC3D,aAAa,EAAE,MAAM,CAAC,cAAc;YACpC,QAAQ,EAAE;gBACR,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,YAAY,EAAE,QAAQ,CAAC,aAAa;aACrC;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,SAAS,CAAC,OAA0B;QAClC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC;IACtC,CAAC;CACF"}
@@ -1,46 +0,0 @@
1
- /**
2
- * Paste Collapse Utility
3
- * Handles collapsing and expanding large pasted content (Claude Code style)
4
- */
5
- export interface CollapsedPaste {
6
- id: number;
7
- fullText: string;
8
- lineCount: number;
9
- isCollapsed: boolean;
10
- placeholder: string;
11
- }
12
- /**
13
- * Count number of lines in text
14
- */
15
- export declare function countLines(text: string): number;
16
- /**
17
- * Check if text should be collapsed (>50 lines or >2000 chars)
18
- */
19
- export declare function shouldCollapsePaste(text: string): boolean;
20
- /**
21
- * Create a collapsed paste object
22
- */
23
- export declare function createCollapsedPaste(text: string): CollapsedPaste;
24
- /**
25
- * Replace collapsed paste placeholder with full text
26
- */
27
- export declare function expandPaste(input: string, paste: CollapsedPaste): string;
28
- /**
29
- * Replace full text with collapsed paste placeholder
30
- */
31
- export declare function collapsePaste(input: string, paste: CollapsedPaste): string;
32
- /**
33
- * Find all collapsed paste placeholders in text
34
- */
35
- export declare function findCollapsedPastes(input: string): RegExpMatchArray[];
36
- /**
37
- * Toggle between collapsed and expanded state
38
- */
39
- export declare function togglePasteState(input: string, paste: CollapsedPaste): {
40
- newInput: string;
41
- newState: boolean;
42
- };
43
- /**
44
- * Reset paste counter (for testing)
45
- */
46
- export declare function resetPasteCounter(): void;
@@ -1,77 +0,0 @@
1
- /**
2
- * Paste Collapse Utility
3
- * Handles collapsing and expanding large pasted content (Claude Code style)
4
- */
5
- let pasteCounter = 0;
6
- /**
7
- * Count number of lines in text
8
- */
9
- export function countLines(text) {
10
- if (!text)
11
- return 0;
12
- return text.split('\n').length;
13
- }
14
- /**
15
- * Check if text should be collapsed (>50 lines or >2000 chars)
16
- */
17
- export function shouldCollapsePaste(text) {
18
- const lineCount = countLines(text);
19
- const charCount = text.length;
20
- return lineCount > 50 || charCount > 2000;
21
- }
22
- /**
23
- * Create a collapsed paste object
24
- */
25
- export function createCollapsedPaste(text) {
26
- pasteCounter++;
27
- const lineCount = countLines(text);
28
- const placeholder = `[Pasted text #${pasteCounter} +${lineCount - 1} lines]`;
29
- return {
30
- id: pasteCounter,
31
- fullText: text,
32
- lineCount,
33
- isCollapsed: true,
34
- placeholder,
35
- };
36
- }
37
- /**
38
- * Replace collapsed paste placeholder with full text
39
- */
40
- export function expandPaste(input, paste) {
41
- return input.replace(paste.placeholder, paste.fullText);
42
- }
43
- /**
44
- * Replace full text with collapsed paste placeholder
45
- */
46
- export function collapsePaste(input, paste) {
47
- return input.replace(paste.fullText, paste.placeholder);
48
- }
49
- /**
50
- * Find all collapsed paste placeholders in text
51
- */
52
- export function findCollapsedPastes(input) {
53
- const regex = /\[Pasted text #(\d+) \+(\d+) lines\]/g;
54
- return Array.from(input.matchAll(regex));
55
- }
56
- /**
57
- * Toggle between collapsed and expanded state
58
- */
59
- export function togglePasteState(input, paste) {
60
- if (paste.isCollapsed) {
61
- // Expand: replace placeholder with full text
62
- const newInput = expandPaste(input, paste);
63
- return { newInput, newState: false };
64
- }
65
- else {
66
- // Collapse: replace full text with placeholder
67
- const newInput = collapsePaste(input, paste);
68
- return { newInput, newState: true };
69
- }
70
- }
71
- /**
72
- * Reset paste counter (for testing)
73
- */
74
- export function resetPasteCounter() {
75
- pasteCounter = 0;
76
- }
77
- //# sourceMappingURL=paste-collapse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paste-collapse.js","sourceRoot":"","sources":["../../src/utils/paste-collapse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,OAAO,SAAS,GAAG,EAAE,IAAI,SAAS,GAAG,IAAI,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,YAAY,EAAE,CAAC;IACf,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,iBAAiB,YAAY,KAAK,SAAS,GAAG,CAAC,SAAS,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of Truth Type System
3
- *
4
- * This package provides centralized Zod schemas, brand types, and enums
5
- * for the entire ax-cli ecosystem.
6
- *
7
- * SECURITY: All exports are controlled. Internal helpers are not exposed.
8
- *
9
- * @packageDocumentation
10
- */
11
- export { brand, unbrand, isBranded, createBrandFactory, type __brand, type Brand, type ExtractBrand, type ExtractBase, } from './public/core/brand-types.js';
12
- export { ApiResponseId, ToolCallId, ToolCallIdSchema, ModelId, ModelIdSchema, TenantId, ApiKeyId, MCPServerId, MCPServerIdSchema, UsageRecordId, PlanId, SessionId, RequestId, type ApiResponseId as ApiResponseIdType, type ToolCallId as ToolCallIdType, type ModelId as ModelIdType, type TenantId as TenantIdType, type ApiKeyId as ApiKeyIdType, type MCPServerId as MCPServerIdType, type UsageRecordId as UsageRecordIdType, type PlanId as PlanIdType, type SessionId as SessionIdType, type RequestId as RequestIdType, } from './public/core/id-types.js';
13
- export { MessageRoleEnum, FinishReasonEnum, TransportEnum, EditorCommandEnum, type MessageRole, type FinishReason, type Transport, type EditorCommand, } from './public/core/enums.js';
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,EACT,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,UAAU,IAAI,cAAc,EACjC,KAAK,OAAO,IAAI,WAAW,EAC3B,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,WAAW,IAAI,eAAe,EACnC,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,MAAM,IAAI,UAAU,EACzB,KAAK,SAAS,IAAI,aAAa,EAC/B,KAAK,SAAS,IAAI,aAAa,GAChC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * @ax-cli/schemas - Single Source of Truth Type System
3
- *
4
- * This package provides centralized Zod schemas, brand types, and enums
5
- * for the entire ax-cli ecosystem.
6
- *
7
- * SECURITY: All exports are controlled. Internal helpers are not exposed.
8
- *
9
- * @packageDocumentation
10
- */
11
- // Core brand type utilities
12
- export { brand, unbrand, isBranded, createBrandFactory, } from './public/core/brand-types.js';
13
- // ID Brand Types
14
- export { ApiResponseId, ToolCallId, ToolCallIdSchema, ModelId, ModelIdSchema, TenantId, ApiKeyId, MCPServerId, MCPServerIdSchema, UsageRecordId, PlanId, SessionId, RequestId, } from './public/core/id-types.js';
15
- // Centralized Enums
16
- export { MessageRoleEnum, FinishReasonEnum, TransportEnum, EditorCommandEnum, } from './public/core/enums.js';
17
- // Additional exports will be added as we implement them:
18
- // - Domain schemas (Usage, API, MCP)
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,4BAA4B;AAC5B,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GAKnB,MAAM,8BAA8B,CAAC;AAEtC,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,GAWV,MAAM,2BAA2B,CAAC;AAEnC,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAKlB,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,qCAAqC"}
@@ -1,308 +0,0 @@
1
- /**
2
- * Brand Types Utilities for @ax-cli/schemas
3
- *
4
- * CRITICAL SECURITY WARNING:
5
- * =========================
6
- * Brand types are COMPILE-TIME ONLY markers. They provide ZERO runtime validation.
7
- *
8
- * **YOU MUST VALIDATE ALL INPUTS AT SYSTEM BOUNDARIES**
9
- *
10
- * Unsafe usage (WILL FAIL IN PRODUCTION):
11
- * ```typescript
12
- * const tenantId = userInput as TenantId; // ❌ NO RUNTIME VALIDATION!
13
- * ```
14
- *
15
- * Safe usage (REQUIRED):
16
- * ```typescript
17
- * const result = TenantId.parse(userInput); // ✅ Validates with Zod
18
- * if (result.success) {
19
- * const tenantId = result.data; // Type-safe AND runtime-safe
20
- * }
21
- * ```
22
- *
23
- * WHEN TO USE BRAND TYPES:
24
- * - Preventing ID mixing at compile time (ApiKeyId vs TenantId)
25
- * - Enforcing domain boundaries in function signatures
26
- * - Type-level documentation of intent
27
- *
28
- * WHEN TO VALIDATE:
29
- * - API boundaries (HTTP requests, MCP inputs)
30
- * - File I/O (reading configs, user settings)
31
- * - Database queries (WHERE clauses with user IDs)
32
- * - Environment variables
33
- * - Command-line arguments
34
- *
35
- * PERFORMANCE:
36
- * Brand types have ZERO runtime cost. They are erased during compilation.
37
- *
38
- * @module brand-types
39
- * @see {@link https://github.com/microsoft/TypeScript/issues/4895|TypeScript Nominal Types}
40
- */
41
- /**
42
- * Unique symbol used as a phantom type marker for branding.
43
- * This symbol is exported for type compatibility but cannot be accessed at runtime,
44
- * making it impossible to forge branded types without using the
45
- * provided constructor functions.
46
- *
47
- * @internal
48
- */
49
- export declare const __brand: unique symbol;
50
- /**
51
- * Brand<T, B> creates a "nominal type" from a structural type.
52
- *
53
- * TypeScript uses structural typing by default:
54
- * ```typescript
55
- * type UserId = string;
56
- * type TenantId = string;
57
- *
58
- * const user: UserId = "user-123";
59
- * const tenant: TenantId = user; // ✅ No error! Strings are compatible.
60
- * ```
61
- *
62
- * Brand types enforce nominal typing:
63
- * ```typescript
64
- * type UserId = Brand<string, 'UserId'>;
65
- * type TenantId = Brand<string, 'TenantId'>;
66
- *
67
- * const user = brand<string, 'UserId'>("user-123");
68
- * const tenant: TenantId = user; // ❌ Compile error! Incompatible brands.
69
- * ```
70
- *
71
- * @template T - The base type (string, number, etc.)
72
- * @template B - The brand identifier (unique string literal)
73
- *
74
- * @example
75
- * ```typescript
76
- * type ApiKeyId = Brand<string, 'ApiKeyId'>;
77
- * type TenantId = Brand<string, 'TenantId'>;
78
- *
79
- * function updateUsage(apiKeyId: ApiKeyId, tenantId: TenantId) {
80
- * // This function signature makes it impossible to swap arguments
81
- * }
82
- *
83
- * const apiKey = brand<string, 'ApiKeyId'>("ak_123");
84
- * const tenant = brand<string, 'TenantId'>("tn_456");
85
- *
86
- * updateUsage(apiKey, tenant); // ✅ Correct
87
- * updateUsage(tenant, apiKey); // ❌ Compile error!
88
- * updateUsage("ak_123", "tn_456"); // ❌ Compile error!
89
- * ```
90
- */
91
- export type Brand<T, B extends string> = T & {
92
- readonly [__brand]: B;
93
- };
94
- /**
95
- * Creates a branded value.
96
- *
97
- * WARNING: This function performs NO VALIDATION. It is a type-level assertion only.
98
- *
99
- * Use this ONLY in trusted contexts after validation:
100
- * - Inside schema .transform() after Zod validation
101
- * - After database queries that return validated data
102
- * - In test fixtures with known-good values
103
- *
104
- * DO NOT use with user input directly:
105
- * ```typescript
106
- * // ❌ UNSAFE - No validation!
107
- * const userId = brand<string, 'UserId'>(req.body.userId);
108
- *
109
- * // ✅ SAFE - Validated first
110
- * const result = UserIdSchema.safeParse(req.body.userId);
111
- * if (result.success) {
112
- * const userId = result.data; // Already branded by schema
113
- * }
114
- * ```
115
- *
116
- * @template T - The base type
117
- * @template B - The brand identifier
118
- * @param value - The value to brand
119
- * @returns The same value, but with a brand type
120
- *
121
- * @example
122
- * ```typescript
123
- * // Safe usage in tests
124
- * const mockTenantId = brand<string, 'TenantId'>("test-tenant-123");
125
- *
126
- * // Safe usage after validation
127
- * const schema = z.string().uuid().transform(v => brand<string, 'TenantId'>(v));
128
- * const tenantId = schema.parse(userInput); // Validated AND branded
129
- * ```
130
- */
131
- export declare function brand<T, B extends string>(value: T): Brand<T, B>;
132
- /**
133
- * Type guard to check if a value is already branded with a specific brand.
134
- *
135
- * NOTE: This only works if the value was created using the brand() function.
136
- * It CANNOT detect fake brands created with `as` casts.
137
- *
138
- * @template T - The base type
139
- * @template B - The brand identifier
140
- * @param value - The value to check
141
- * @returns true if the value has the correct brand (compile-time only)
142
- *
143
- * @example
144
- * ```typescript
145
- * const value: string | TenantId = getTenantId();
146
- *
147
- * if (isBranded<string, 'TenantId'>(value)) {
148
- * const tenantId: TenantId = value; // TypeScript knows it's branded
149
- * }
150
- * ```
151
- */
152
- export declare function isBranded<T, B extends string>(_value: unknown): _value is Brand<T, B>;
153
- /**
154
- * Removes the brand from a branded type, returning the base type.
155
- *
156
- * Use this when you need to pass a branded value to a function that
157
- * expects the base type (e.g., logging, serialization).
158
- *
159
- * @template T - The base type
160
- * @template B - The brand identifier
161
- * @param value - The branded value
162
- * @returns The same value, but with the brand removed
163
- *
164
- * @example
165
- * ```typescript
166
- * const tenantId: TenantId = getTenantId();
167
- *
168
- * // Pass to function expecting plain string
169
- * console.log(unbrand(tenantId)); // string, not TenantId
170
- *
171
- * // Serialize to JSON
172
- * const json = JSON.stringify({ id: unbrand(tenantId) });
173
- * ```
174
- */
175
- export declare function unbrand<T, B extends string>(value: Brand<T, B>): T;
176
- /**
177
- * Utility type to extract the brand identifier from a branded type.
178
- *
179
- * @template T - The branded type
180
- *
181
- * @example
182
- * ```typescript
183
- * type TenantId = Brand<string, 'TenantId'>;
184
- * type BrandName = ExtractBrand<TenantId>; // 'TenantId'
185
- * ```
186
- */
187
- export type ExtractBrand<T> = T extends Brand<unknown, infer B> ? B : never;
188
- /**
189
- * Utility type to extract the base type from a branded type.
190
- *
191
- * @template T - The branded type
192
- *
193
- * @example
194
- * ```typescript
195
- * type TenantId = Brand<string, 'TenantId'>;
196
- * type BaseType = ExtractBase<TenantId>; // string
197
- * ```
198
- */
199
- export type ExtractBase<T> = T extends Brand<infer U, string> ? U : T;
200
- /**
201
- * Creates a type-safe brand factory with validation.
202
- *
203
- * This is the RECOMMENDED way to create brand types with runtime validation.
204
- *
205
- * @template T - The base type
206
- * @template B - The brand identifier
207
- * @param schema - Zod schema for validation
208
- * @param brandName - The brand identifier
209
- * @returns Object with parse, create, and is methods
210
- *
211
- * @example
212
- * ```typescript
213
- * import { z } from 'zod';
214
- *
215
- * const TenantId = createBrandFactory(
216
- * z.string().uuid(),
217
- * 'TenantId'
218
- * );
219
- *
220
- * // Type-safe parsing with validation
221
- * const result = TenantId.parse(userInput);
222
- * if (result.success) {
223
- * const tenantId = result.data; // Brand<string, 'TenantId'>
224
- * }
225
- *
226
- * // Create new ID
227
- * const newId = TenantId.create(); // Generates UUID
228
- *
229
- * // Type guard
230
- * if (TenantId.is(value)) {
231
- * // value is Brand<string, 'TenantId'>
232
- * }
233
- * ```
234
- */
235
- export declare function createBrandFactory<T, B extends string>(schema: {
236
- parse: (input: unknown) => T;
237
- safeParse: (input: unknown) => {
238
- success: boolean;
239
- data?: T;
240
- error?: unknown;
241
- };
242
- }, brandName: B): {
243
- /**
244
- * The Zod schema with brand transformation.
245
- */
246
- schema: {
247
- parse: (input: unknown) => Brand<T, B>;
248
- safeParse: (input: unknown) => {
249
- success: true;
250
- data: Brand<T, B>;
251
- } | {
252
- success: false;
253
- error: unknown;
254
- };
255
- };
256
- /**
257
- * Parse and validate input, returning branded value.
258
- * Throws on validation failure.
259
- */
260
- parse: (input: unknown) => Brand<T, B>;
261
- /**
262
- * Type guard to check if a value is this brand.
263
- */
264
- is: (value: unknown) => value is Brand<T, B>;
265
- /**
266
- * Brand name identifier.
267
- */
268
- brandName: B;
269
- };
270
- /**
271
- * BEST PRACTICES SUMMARY:
272
- * =======================
273
- *
274
- * 1. ALWAYS validate at boundaries:
275
- * - API inputs: Use Zod schemas
276
- * - Database outputs: Use Zod schemas
277
- * - File I/O: Use Zod schemas
278
- * - CLI args: Use Zod schemas
279
- *
280
- * 2. NEVER cast to brand types:
281
- * ❌ const id = userInput as TenantId;
282
- * ✅ const id = TenantIdSchema.parse(userInput);
283
- *
284
- * 3. Use createBrandFactory for all brand types:
285
- * - Provides validation
286
- * - Provides type guards
287
- * - Centralizes brand creation
288
- *
289
- * 4. Document which functions validate:
290
- * ```typescript
291
- * // @validates TenantId - performs Zod validation
292
- * function parseTenantId(input: string): TenantId {
293
- * return TenantIdSchema.parse(input);
294
- * }
295
- *
296
- * // @assumes TenantId - no validation, requires validated input
297
- * function formatTenantId(id: TenantId): string {
298
- * return `tenant:${unbrand(id)}`;
299
- * }
300
- * ```
301
- *
302
- * 5. Test brand type enforcement:
303
- * ```typescript
304
- * // Should fail to compile
305
- * const apiKey: ApiKeyId = getTenantId(); // ❌
306
- * ```
307
- */
308
- //# sourceMappingURL=brand-types.d.ts.map