@satori-sh/cli 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -0
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +11 -2
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/info-display.d.ts.map +1 -1
- package/dist/lib/info-display.js +2 -12
- package/dist/lib/info-display.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-5x6wts8n.js +0 -27331
- package/dist/chunk-kc0c4n2e.js +0 -23
- package/dist/chunk-pgay1aps.js +0 -27331
- package/dist/chunk-zhxnt6w7.js +0 -32
- package/dist/highlights-eq9cgrbb.scm +0 -604
- package/dist/highlights-ghv9g403.scm +0 -205
- package/dist/highlights-hk7bwhj4.scm +0 -284
- package/dist/highlights-r812a2qc.scm +0 -150
- package/dist/highlights-x6tmsnaa.scm +0 -115
- package/dist/injections-73j83es3.scm +0 -27
- package/dist/src/add.d.ts +0 -23
- package/dist/src/add.d.ts.map +0 -1
- package/dist/src/add.js +0 -50
- package/dist/src/add.js.map +0 -1
- package/dist/src/config.d.ts +0 -51
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -195
- package/dist/src/config.js.map +0 -1
- package/dist/src/index.d.ts +0 -14
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -446
- package/dist/src/index.js.map +0 -1
- package/dist/src/memory.d.ts +0 -41
- package/dist/src/memory.d.ts.map +0 -1
- package/dist/src/memory.js +0 -93
- package/dist/src/memory.js.map +0 -1
- package/dist/src/search.d.ts +0 -14
- package/dist/src/search.d.ts.map +0 -1
- package/dist/src/search.js +0 -43
- package/dist/src/search.js.map +0 -1
- package/dist/src/types.d.ts +0 -74
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/tests/index.test.d.ts +0 -2
- package/dist/tests/index.test.d.ts.map +0 -1
- package/dist/tests/index.test.js +0 -252
- package/dist/tests/index.test.js.map +0 -1
- package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/dist/ui-4LVANHF6.js +0 -2678
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/99ddf573531c4dbe53f743ecbc1595af5eb1d32f/queries/markdown_inline/highlights.scm
|
|
2
|
-
; From MDeiml/tree-sitter-markdown
|
|
3
|
-
(code_span) @markup.raw @nospell
|
|
4
|
-
|
|
5
|
-
(emphasis) @markup.italic
|
|
6
|
-
|
|
7
|
-
(strong_emphasis) @markup.strong
|
|
8
|
-
|
|
9
|
-
(strikethrough) @markup.strikethrough
|
|
10
|
-
|
|
11
|
-
(shortcut_link
|
|
12
|
-
(link_text) @nospell)
|
|
13
|
-
|
|
14
|
-
[
|
|
15
|
-
(backslash_escape)
|
|
16
|
-
(hard_line_break)
|
|
17
|
-
] @string.escape
|
|
18
|
-
|
|
19
|
-
; Conceal codeblock and text style markers
|
|
20
|
-
([
|
|
21
|
-
(code_span_delimiter)
|
|
22
|
-
(emphasis_delimiter)
|
|
23
|
-
] @conceal
|
|
24
|
-
(#set! conceal ""))
|
|
25
|
-
|
|
26
|
-
; Inline links - style all parts
|
|
27
|
-
(inline_link
|
|
28
|
-
["[" "(" ")"] @markup.link)
|
|
29
|
-
|
|
30
|
-
(inline_link
|
|
31
|
-
"]" @markup.link.bracket.close)
|
|
32
|
-
|
|
33
|
-
; Conceal opening bracket
|
|
34
|
-
((inline_link
|
|
35
|
-
"[" @conceal)
|
|
36
|
-
(#set! conceal ""))
|
|
37
|
-
|
|
38
|
-
; Conceal closing bracket with space replacement
|
|
39
|
-
((inline_link
|
|
40
|
-
"]" @conceal)
|
|
41
|
-
(#set! conceal " "))
|
|
42
|
-
|
|
43
|
-
; Conceal image links
|
|
44
|
-
(image
|
|
45
|
-
[
|
|
46
|
-
"!"
|
|
47
|
-
"["
|
|
48
|
-
"]"
|
|
49
|
-
"("
|
|
50
|
-
(link_destination)
|
|
51
|
-
")"
|
|
52
|
-
] @markup.link
|
|
53
|
-
(#set! conceal ""))
|
|
54
|
-
|
|
55
|
-
; Conceal full reference links
|
|
56
|
-
(full_reference_link
|
|
57
|
-
[
|
|
58
|
-
"["
|
|
59
|
-
"]"
|
|
60
|
-
(link_label)
|
|
61
|
-
] @markup.link
|
|
62
|
-
(#set! conceal ""))
|
|
63
|
-
|
|
64
|
-
; Conceal collapsed reference links
|
|
65
|
-
(collapsed_reference_link
|
|
66
|
-
[
|
|
67
|
-
"["
|
|
68
|
-
"]"
|
|
69
|
-
] @markup.link
|
|
70
|
-
(#set! conceal ""))
|
|
71
|
-
|
|
72
|
-
; Conceal shortcut links
|
|
73
|
-
(shortcut_link
|
|
74
|
-
[
|
|
75
|
-
"["
|
|
76
|
-
"]"
|
|
77
|
-
] @markup.link
|
|
78
|
-
(#set! conceal ""))
|
|
79
|
-
|
|
80
|
-
[
|
|
81
|
-
(link_destination)
|
|
82
|
-
(uri_autolink)
|
|
83
|
-
] @markup.link.url @nospell
|
|
84
|
-
|
|
85
|
-
[
|
|
86
|
-
(link_label)
|
|
87
|
-
(link_text)
|
|
88
|
-
(link_title)
|
|
89
|
-
(image_description)
|
|
90
|
-
] @markup.link.label
|
|
91
|
-
|
|
92
|
-
; Replace common HTML entities.
|
|
93
|
-
((entity_reference) @character.special
|
|
94
|
-
(#eq? @character.special " ")
|
|
95
|
-
(#set! conceal ""))
|
|
96
|
-
|
|
97
|
-
((entity_reference) @character.special
|
|
98
|
-
(#eq? @character.special "<")
|
|
99
|
-
(#set! conceal "<"))
|
|
100
|
-
|
|
101
|
-
((entity_reference) @character.special
|
|
102
|
-
(#eq? @character.special ">")
|
|
103
|
-
(#set! conceal ">"))
|
|
104
|
-
|
|
105
|
-
((entity_reference) @character.special
|
|
106
|
-
(#eq? @character.special "&")
|
|
107
|
-
(#set! conceal "&"))
|
|
108
|
-
|
|
109
|
-
((entity_reference) @character.special
|
|
110
|
-
(#eq? @character.special """)
|
|
111
|
-
(#set! conceal "\""))
|
|
112
|
-
|
|
113
|
-
((entity_reference) @character.special
|
|
114
|
-
(#any-of? @character.special " " " ")
|
|
115
|
-
(#set! conceal " "))
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/markdown/injections.scm
|
|
2
|
-
(fenced_code_block
|
|
3
|
-
(info_string
|
|
4
|
-
(language) @_lang)
|
|
5
|
-
(code_fence_content) @injection.content
|
|
6
|
-
(#set-lang-from-info-string! @_lang))
|
|
7
|
-
|
|
8
|
-
((html_block) @injection.content
|
|
9
|
-
(#set! injection.language "html")
|
|
10
|
-
(#set! injection.combined)
|
|
11
|
-
(#set! injection.include-children))
|
|
12
|
-
|
|
13
|
-
((minus_metadata) @injection.content
|
|
14
|
-
(#set! injection.language "yaml")
|
|
15
|
-
(#offset! @injection.content 1 0 -1 0)
|
|
16
|
-
(#set! injection.include-children))
|
|
17
|
-
|
|
18
|
-
((plus_metadata) @injection.content
|
|
19
|
-
(#set! injection.language "toml")
|
|
20
|
-
(#offset! @injection.content 1 0 -1 0)
|
|
21
|
-
(#set! injection.include-children))
|
|
22
|
-
|
|
23
|
-
([
|
|
24
|
-
(inline)
|
|
25
|
-
(pipe_table_cell)
|
|
26
|
-
] @injection.content
|
|
27
|
-
(#set! injection.language "markdown_inline"))
|
package/dist/src/add.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds a new memory to the Satori server.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} text - The text content to add as a memory
|
|
5
|
-
* @param {object} [options] - Additional options for the memory
|
|
6
|
-
* @param {string} [options.memoryId] - Optional memory ID for scoping
|
|
7
|
-
* @returns {Promise<void>} Logs success or error messages to console
|
|
8
|
-
* @throws {Error} If the text is empty
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```bash
|
|
12
|
-
* satori add "I like pizza"
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* await addMemories("User prefers dark mode", { memoryId: "session-123" });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function addMemories(text: string, options?: {
|
|
21
|
-
memoryId?: string;
|
|
22
|
-
}): Promise<void>;
|
|
23
|
-
//# sourceMappingURL=add.d.ts.map
|
package/dist/src/add.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/add.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BlG"}
|
package/dist/src/add.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { getConfig } from './config.js';
|
|
2
|
-
/**
|
|
3
|
-
* Adds a new memory to the Satori server.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} text - The text content to add as a memory
|
|
6
|
-
* @param {object} [options] - Additional options for the memory
|
|
7
|
-
* @param {string} [options.memoryId] - Optional memory ID for scoping
|
|
8
|
-
* @returns {Promise<void>} Logs success or error messages to console
|
|
9
|
-
* @throws {Error} If the text is empty
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```bash
|
|
13
|
-
* satori add "I like pizza"
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* await addMemories("User prefers dark mode", { memoryId: "session-123" });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export async function addMemories(text, options = {}) {
|
|
22
|
-
if (!text || !text.trim()) {
|
|
23
|
-
console.error('Text cannot be empty');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
const config = await getConfig();
|
|
28
|
-
const response = await fetch(`${config.baseUrl}/memories`, {
|
|
29
|
-
method: 'POST',
|
|
30
|
-
headers: {
|
|
31
|
-
'Content-Type': 'application/json',
|
|
32
|
-
'Authorization': `Bearer ${config.apiKey}`
|
|
33
|
-
},
|
|
34
|
-
body: JSON.stringify({ messages: [{ role: "user", content: text }], ...(options.memoryId && { memory_id: options.memoryId }) })
|
|
35
|
-
});
|
|
36
|
-
if (response.status === 402) {
|
|
37
|
-
console.error('Free tier exceeded. Run `npx @satori-sh sub` to subscribe');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
console.error(`HTTP error: ${response.status} ${response.statusText}`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
await response.json();
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error(`Error adding memory: ${error instanceof Error ? error.message : error}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=add.js.map
|
package/dist/src/add.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,UAAiC,EAAE;IACjF,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;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|
3
|
-
* Checks write access to the config directory by attempting to create, write, and delete a temporary file.
|
|
4
|
-
*
|
|
5
|
-
* @throws {Error} If write access is denied or any operation fails
|
|
6
|
-
*/
|
|
7
|
-
export declare function checkWriteAccess(): Promise<void>;
|
|
8
|
-
type ConfigOverrides = {
|
|
9
|
-
apiKey?: string;
|
|
10
|
-
memoryId?: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const setConfigOverrides: (overrides: ConfigOverrides) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Saves the API key to the config file.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} apiKey - The API key to save
|
|
17
|
-
* @throws {Error} If write access fails or saving fails
|
|
18
|
-
*/
|
|
19
|
-
export declare function saveApiKey(apiKey: string): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Reads the stored API key from the config file only.
|
|
22
|
-
*
|
|
23
|
-
* @returns {Promise<string | null>} The stored API key or null
|
|
24
|
-
*/
|
|
25
|
-
export declare function getStoredApiKey(): Promise<string | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Saves the memory ID to the config file.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} memoryId - The memory ID to save
|
|
30
|
-
* @throws {Error} If write access fails or saving fails
|
|
31
|
-
*/
|
|
32
|
-
export declare function saveMemoryId(memoryId: string): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Retrieves and validates configuration from file and environment variables.
|
|
35
|
-
* Fetches the memory_id and api_key from the config file in ~/.config/satori/satori.json.
|
|
36
|
-
*
|
|
37
|
-
* If the API key isn't in the config, it looks in SATORI_API_KEY.
|
|
38
|
-
* If there is no API key in either place it will call the API to get a new key.
|
|
39
|
-
*
|
|
40
|
-
* @returns {Promise<Config>} The validated configuration object
|
|
41
|
-
* @throws {Error} If required environment variables are missing or invalid
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* const config = await getConfig();
|
|
46
|
-
* console.log(config.apiKey); // API key from ~/.config/satori/satori.json or SATORI_API_KEY env var, or null
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare function getConfig(): Promise<Config>;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAKpC;;;;GAIG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAatD;AAED,KAAK,eAAe,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,kBAAkB,GAAI,WAAW,eAAe,SAE5D,CAAC;AAIF;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAa9D;AAED;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAM9D;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAalE;AAsBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CA6EjD"}
|
package/dist/src/config.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
/**
|
|
5
|
-
* Checks write access to the config directory by attempting to create, write, and delete a temporary file.
|
|
6
|
-
*
|
|
7
|
-
* @throws {Error} If write access is denied or any operation fails
|
|
8
|
-
*/
|
|
9
|
-
export async function checkWriteAccess() {
|
|
10
|
-
// Dynamic import used instead of static import at top-level to enable mocking with Bun's mock.module() in tests.
|
|
11
|
-
// Static imports cannot be overridden by module mocks in Bun, so this allows fs operations to be properly mocked.
|
|
12
|
-
const { promises: fs } = await import('node:fs');
|
|
13
|
-
const dir = join(homedir(), '.config', 'satori');
|
|
14
|
-
try {
|
|
15
|
-
await fs.mkdir(dir, { recursive: true });
|
|
16
|
-
const tempFile = join(dir, `temp-${randomUUID()}.txt`);
|
|
17
|
-
await fs.writeFile(tempFile, 'test');
|
|
18
|
-
await fs.unlink(tempFile);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
throw new Error(`Cannot write to config directory: ${error instanceof Error ? error.message : error}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
let configOverrides = null;
|
|
25
|
-
export const setConfigOverrides = (overrides) => {
|
|
26
|
-
configOverrides = { ...overrides };
|
|
27
|
-
};
|
|
28
|
-
const getConfigOverrides = () => configOverrides ?? {};
|
|
29
|
-
/**
|
|
30
|
-
* Saves the API key to the config file.
|
|
31
|
-
*
|
|
32
|
-
* @param {string} apiKey - The API key to save
|
|
33
|
-
* @throws {Error} If write access fails or saving fails
|
|
34
|
-
*/
|
|
35
|
-
export async function saveApiKey(apiKey) {
|
|
36
|
-
// Dynamic import used instead of static import at top-level to enable mocking with Bun's mock.module() in tests.
|
|
37
|
-
// Static imports cannot be overridden by module mocks in Bun, so this allows fs operations to be properly mocked.
|
|
38
|
-
const { promises: fs } = await import('node:fs');
|
|
39
|
-
await checkWriteAccess();
|
|
40
|
-
const configPath = join(homedir(), '.config', 'satori', 'satori.json');
|
|
41
|
-
try {
|
|
42
|
-
const existing = await loadConfigFile();
|
|
43
|
-
const config = { ...existing, api_key: apiKey };
|
|
44
|
-
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw new Error(`Failed to save API key: ${error instanceof Error ? error.message : error}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Reads the stored API key from the config file only.
|
|
52
|
-
*
|
|
53
|
-
* @returns {Promise<string | null>} The stored API key or null
|
|
54
|
-
*/
|
|
55
|
-
export async function getStoredApiKey() {
|
|
56
|
-
const data = await loadConfigFile();
|
|
57
|
-
if (typeof data.api_key === 'string') {
|
|
58
|
-
return data.api_key;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Saves the memory ID to the config file.
|
|
64
|
-
*
|
|
65
|
-
* @param {string} memoryId - The memory ID to save
|
|
66
|
-
* @throws {Error} If write access fails or saving fails
|
|
67
|
-
*/
|
|
68
|
-
export async function saveMemoryId(memoryId) {
|
|
69
|
-
// Dynamic import used instead of static import at top-level to enable mocking with Bun's mock.module() in tests.
|
|
70
|
-
// Static imports cannot be overridden by module mocks in Bun, so this allows fs operations to be properly mocked.
|
|
71
|
-
const { promises: fs } = await import('node:fs');
|
|
72
|
-
await checkWriteAccess();
|
|
73
|
-
const configPath = join(homedir(), '.config', 'satori', 'satori.json');
|
|
74
|
-
try {
|
|
75
|
-
const existing = await loadConfigFile();
|
|
76
|
-
const config = { ...existing, memory_id: memoryId };
|
|
77
|
-
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
throw new Error(`Failed to save memory ID: ${error instanceof Error ? error.message : error}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Loads the config file data.
|
|
85
|
-
*
|
|
86
|
-
* @returns {Promise<Record<string, unknown>>} The config data
|
|
87
|
-
*/
|
|
88
|
-
async function loadConfigFile() {
|
|
89
|
-
try {
|
|
90
|
-
const { promises: fs } = await import('node:fs');
|
|
91
|
-
const configPath = join(homedir(), '.config', 'satori', 'satori.json');
|
|
92
|
-
const raw = await fs.readFile(configPath, 'utf8');
|
|
93
|
-
const data = JSON.parse(raw);
|
|
94
|
-
if (data && typeof data === 'object') {
|
|
95
|
-
return data;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
// Ignore errors
|
|
100
|
-
}
|
|
101
|
-
return {};
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Retrieves and validates configuration from file and environment variables.
|
|
105
|
-
* Fetches the memory_id and api_key from the config file in ~/.config/satori/satori.json.
|
|
106
|
-
*
|
|
107
|
-
* If the API key isn't in the config, it looks in SATORI_API_KEY.
|
|
108
|
-
* If there is no API key in either place it will call the API to get a new key.
|
|
109
|
-
*
|
|
110
|
-
* @returns {Promise<Config>} The validated configuration object
|
|
111
|
-
* @throws {Error} If required environment variables are missing or invalid
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* const config = await getConfig();
|
|
116
|
-
* console.log(config.apiKey); // API key from ~/.config/satori/satori.json or SATORI_API_KEY env var, or null
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export async function getConfig() {
|
|
120
|
-
if (process.platform !== 'darwin') {
|
|
121
|
-
throw new Error('We do not currently support Windows yet, email support@satori.sh to request Windows support');
|
|
122
|
-
}
|
|
123
|
-
const overrides = getConfigOverrides();
|
|
124
|
-
const shouldSkipFile = Boolean(overrides.apiKey || overrides.memoryId);
|
|
125
|
-
let apiKey = overrides.apiKey ?? null;
|
|
126
|
-
let memoryId = overrides.memoryId;
|
|
127
|
-
const openaiApiKey = process.env.OPENAI_API_KEY || null;
|
|
128
|
-
if (!shouldSkipFile) {
|
|
129
|
-
try {
|
|
130
|
-
const data = await loadConfigFile();
|
|
131
|
-
if (typeof data.api_key === 'string') {
|
|
132
|
-
apiKey = data.api_key;
|
|
133
|
-
}
|
|
134
|
-
if (typeof data.memory_id === 'string') {
|
|
135
|
-
memoryId = data.memory_id;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
// If file reading or parsing fails, apiKey and memoryId remain default
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// Fallback to environment variable if not set from file
|
|
143
|
-
if (!apiKey) {
|
|
144
|
-
apiKey = process.env.SATORI_API_KEY || null;
|
|
145
|
-
}
|
|
146
|
-
const nodeEnv = process.env.NODE_ENV;
|
|
147
|
-
const baseUrl = process.env.SATORI_BASE_URL
|
|
148
|
-
|| (nodeEnv !== 'production' ? 'http://localhost:8000' : 'https://api.satori.sh');
|
|
149
|
-
const checkoutUrl = process.env.SATORI_CHECKOUT_URL
|
|
150
|
-
|| (nodeEnv === 'production'
|
|
151
|
-
? 'https://buy.stripe.com/aFabJ03GIez6bH53Ckew800'
|
|
152
|
-
: 'https://buy.stripe.com/test_14AeVc5TZc2GapagZp0gw00');
|
|
153
|
-
try {
|
|
154
|
-
new URL(baseUrl);
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
throw new Error('Invalid SATORI_BASE_URL format');
|
|
158
|
-
}
|
|
159
|
-
if (checkoutUrl) {
|
|
160
|
-
try {
|
|
161
|
-
new URL(checkoutUrl);
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
throw new Error('Invalid SATORI_CHECKOUT_URL format');
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// Generate new API key if still null
|
|
168
|
-
if (!apiKey) {
|
|
169
|
-
try {
|
|
170
|
-
const response = await fetch(`${baseUrl}/orgs`, {
|
|
171
|
-
method: 'POST',
|
|
172
|
-
});
|
|
173
|
-
if (!response.ok) {
|
|
174
|
-
throw new Error(`HTTP error: ${response.status} ${response.statusText}`);
|
|
175
|
-
}
|
|
176
|
-
const data = await response.json();
|
|
177
|
-
if (data && typeof data.api_key === 'string') {
|
|
178
|
-
apiKey = data.api_key;
|
|
179
|
-
await saveApiKey(apiKey);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
throw new Error('Invalid response: missing api_key');
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
catch (error) {
|
|
186
|
-
throw new Error(`Failed to generate API key: ${error instanceof Error ? error.message : error}`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Fallback to config file memoryId if not set via env
|
|
190
|
-
if (!memoryId) {
|
|
191
|
-
memoryId = process.env.SATORI_MEMORY_ID;
|
|
192
|
-
}
|
|
193
|
-
return { apiKey, openaiApiKey, baseUrl, checkoutUrl, memoryId };
|
|
194
|
-
}
|
|
195
|
-
//# sourceMappingURL=config.js.map
|
package/dist/src/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,iHAAiH;IACjH,kHAAkH;IAClH,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,QAAQ,UAAU,EAAE,MAAM,CAAC,CAAC;QACvD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,YAAY,KAAK,CA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MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;gBACtB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;IAED,sDAAsD;IACtD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAClE,CAAC"}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
export { searchMemories } from './search.js';
|
|
3
|
-
export { addMemories } from './add.js';
|
|
4
|
-
/**
|
|
5
|
-
* Main entry point for the Satori CLI application.
|
|
6
|
-
*
|
|
7
|
-
* Parses command-line arguments and executes the appropriate command.
|
|
8
|
-
* Sets up the CLI with available commands: search, add, and chat.
|
|
9
|
-
*
|
|
10
|
-
* @returns {Promise<void>}
|
|
11
|
-
* @throws {Error} If configuration validation fails
|
|
12
|
-
*/
|
|
13
|
-
export declare function main(): Promise<void>;
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAyBA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAsdvC;;;;;;;;GAQG;AACH,wBAAsB,IAAI,kBA+BzB"}
|