@elisym/sdk 0.4.0 → 0.5.0

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.
@@ -0,0 +1,334 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Zod schemas for elisym.yaml (public source of truth) and secrets.json (private).
5
+ * Shared between CLI (provider mode) and MCP (customer mode, future provider mode).
6
+ */
7
+
8
+ declare const AgentNameSchema: z.ZodString;
9
+ declare const PaymentSchema: z.ZodObject<{
10
+ chain: z.ZodLiteral<"solana">;
11
+ network: z.ZodEnum<["devnet"]>;
12
+ address: z.ZodString;
13
+ token: z.ZodOptional<z.ZodString>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ chain: "solana";
16
+ network: "devnet";
17
+ address: string;
18
+ token?: string | undefined;
19
+ }, {
20
+ chain: "solana";
21
+ network: "devnet";
22
+ address: string;
23
+ token?: string | undefined;
24
+ }>;
25
+ declare const LlmSchema: z.ZodObject<{
26
+ provider: z.ZodEnum<["anthropic", "openai"]>;
27
+ model: z.ZodString;
28
+ max_tokens: z.ZodDefault<z.ZodNumber>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ provider: "anthropic" | "openai";
31
+ model: string;
32
+ max_tokens: number;
33
+ }, {
34
+ provider: "anthropic" | "openai";
35
+ model: string;
36
+ max_tokens?: number | undefined;
37
+ }>;
38
+ declare const SecurityFlagsSchema: z.ZodObject<{
39
+ withdrawals_enabled: z.ZodDefault<z.ZodBoolean>;
40
+ agent_switch_enabled: z.ZodDefault<z.ZodBoolean>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ withdrawals_enabled: boolean;
43
+ agent_switch_enabled: boolean;
44
+ }, {
45
+ withdrawals_enabled?: boolean | undefined;
46
+ agent_switch_enabled?: boolean | undefined;
47
+ }>;
48
+ /**
49
+ * elisym.yaml schema. Public - committed to git.
50
+ * Agent name NOT stored here - derived from containing folder name.
51
+ */
52
+ declare const ElisymYamlSchema: z.ZodObject<{
53
+ /** Human-readable name shown in UI (optional). Falls back to folder name. */
54
+ display_name: z.ZodOptional<z.ZodString>;
55
+ description: z.ZodDefault<z.ZodString>;
56
+ /** Relative path (to this YAML) or absolute URL. */
57
+ picture: z.ZodOptional<z.ZodString>;
58
+ /** Relative path (to this YAML) or absolute URL. */
59
+ banner: z.ZodOptional<z.ZodString>;
60
+ relays: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
61
+ payments: z.ZodDefault<z.ZodArray<z.ZodObject<{
62
+ chain: z.ZodLiteral<"solana">;
63
+ network: z.ZodEnum<["devnet"]>;
64
+ address: z.ZodString;
65
+ token: z.ZodOptional<z.ZodString>;
66
+ }, "strip", z.ZodTypeAny, {
67
+ chain: "solana";
68
+ network: "devnet";
69
+ address: string;
70
+ token?: string | undefined;
71
+ }, {
72
+ chain: "solana";
73
+ network: "devnet";
74
+ address: string;
75
+ token?: string | undefined;
76
+ }>, "many">>;
77
+ llm: z.ZodOptional<z.ZodObject<{
78
+ provider: z.ZodEnum<["anthropic", "openai"]>;
79
+ model: z.ZodString;
80
+ max_tokens: z.ZodDefault<z.ZodNumber>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ provider: "anthropic" | "openai";
83
+ model: string;
84
+ max_tokens: number;
85
+ }, {
86
+ provider: "anthropic" | "openai";
87
+ model: string;
88
+ max_tokens?: number | undefined;
89
+ }>>;
90
+ security: z.ZodDefault<z.ZodObject<{
91
+ withdrawals_enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
92
+ agent_switch_enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ withdrawals_enabled?: boolean | undefined;
95
+ agent_switch_enabled?: boolean | undefined;
96
+ }, {
97
+ withdrawals_enabled?: boolean | undefined;
98
+ agent_switch_enabled?: boolean | undefined;
99
+ }>>;
100
+ }, "strict", z.ZodTypeAny, {
101
+ description: string;
102
+ relays: string[];
103
+ payments: {
104
+ chain: "solana";
105
+ network: "devnet";
106
+ address: string;
107
+ token?: string | undefined;
108
+ }[];
109
+ security: {
110
+ withdrawals_enabled?: boolean | undefined;
111
+ agent_switch_enabled?: boolean | undefined;
112
+ };
113
+ display_name?: string | undefined;
114
+ picture?: string | undefined;
115
+ banner?: string | undefined;
116
+ llm?: {
117
+ provider: "anthropic" | "openai";
118
+ model: string;
119
+ max_tokens: number;
120
+ } | undefined;
121
+ }, {
122
+ display_name?: string | undefined;
123
+ description?: string | undefined;
124
+ picture?: string | undefined;
125
+ banner?: string | undefined;
126
+ relays?: string[] | undefined;
127
+ payments?: {
128
+ chain: "solana";
129
+ network: "devnet";
130
+ address: string;
131
+ token?: string | undefined;
132
+ }[] | undefined;
133
+ llm?: {
134
+ provider: "anthropic" | "openai";
135
+ model: string;
136
+ max_tokens?: number | undefined;
137
+ } | undefined;
138
+ security?: {
139
+ withdrawals_enabled?: boolean | undefined;
140
+ agent_switch_enabled?: boolean | undefined;
141
+ } | undefined;
142
+ }>;
143
+ type ElisymYaml = z.infer<typeof ElisymYamlSchema>;
144
+ type PaymentEntry = z.infer<typeof PaymentSchema>;
145
+ type LlmEntry = z.infer<typeof LlmSchema>;
146
+ type SecurityFlags = z.infer<typeof SecurityFlagsSchema>;
147
+ /**
148
+ * secrets.json schema. Private - .gitignore.
149
+ * Values may be plaintext or `encrypted:v1:...` blobs (AES-256-GCM + scrypt).
150
+ */
151
+ declare const SecretsSchema: z.ZodObject<{
152
+ nostr_secret_key: z.ZodString;
153
+ solana_secret_key: z.ZodOptional<z.ZodString>;
154
+ llm_api_key: z.ZodOptional<z.ZodString>;
155
+ }, "strict", z.ZodTypeAny, {
156
+ nostr_secret_key: string;
157
+ solana_secret_key?: string | undefined;
158
+ llm_api_key?: string | undefined;
159
+ }, {
160
+ nostr_secret_key: string;
161
+ solana_secret_key?: string | undefined;
162
+ llm_api_key?: string | undefined;
163
+ }>;
164
+ type Secrets = z.infer<typeof SecretsSchema>;
165
+ interface MediaCacheEntry {
166
+ url: string;
167
+ sha256: string;
168
+ uploaded_at: string;
169
+ }
170
+ declare const MediaCacheEntrySchema: z.ZodType<MediaCacheEntry>;
171
+ declare const MediaCacheSchema: z.ZodRecord<z.ZodString, z.ZodType<MediaCacheEntry, z.ZodTypeDef, MediaCacheEntry>>;
172
+ type MediaCache = z.infer<typeof MediaCacheSchema>;
173
+
174
+ /**
175
+ * Path helpers for .elisym/ layout.
176
+ *
177
+ * Project-local (walk up from CWD until .git or $HOME):
178
+ * <project>/.elisym/<name>/{elisym.yaml, .secrets.json, .media-cache.json, .jobs.json, .gitignore}
179
+ *
180
+ * Home-global (~/.elisym/<name>/): same file structure.
181
+ *
182
+ * Node.js only - relies on `node:fs`/`node:os`/`node:path`.
183
+ */
184
+ declare const ELISYM_DIRNAME = ".elisym";
185
+ declare const YAML_FILENAME = "elisym.yaml";
186
+ declare const SECRETS_FILENAME = ".secrets.json";
187
+ declare const MEDIA_CACHE_FILENAME = ".media-cache.json";
188
+ declare const JOBS_FILENAME = ".jobs.json";
189
+ declare const GITIGNORE_FILENAME = ".gitignore";
190
+ declare const SKILLS_DIRNAME = "skills";
191
+ /** ~/.elisym/ */
192
+ declare function homeElisymDir(): string;
193
+ /**
194
+ * Walk up from `startDir` looking for `.elisym/` directory.
195
+ * Stops at (a) the first `.git` directory/file, (b) `$HOME`, (c) filesystem root,
196
+ * or (d) MAX_WALK_UP_DEPTH iterations. Returns absolute path or null.
197
+ */
198
+ declare function findProjectElisymDir(startDir: string): string | null;
199
+ interface AgentPaths {
200
+ dir: string;
201
+ yaml: string;
202
+ secrets: string;
203
+ mediaCache: string;
204
+ jobs: string;
205
+ gitignore: string;
206
+ skills: string;
207
+ }
208
+ /** Compute all file/dir paths for an agent given its root directory. */
209
+ declare function agentPaths(agentDir: string): AgentPaths;
210
+
211
+ /**
212
+ * Agent resolution: find <name>/elisym.yaml via project-local walk-up, fallback to home.
213
+ */
214
+
215
+ type AgentSource = 'project' | 'home';
216
+ interface ResolvedAgent {
217
+ name: string;
218
+ dir: string;
219
+ source: AgentSource;
220
+ /** true when both a project-local and a home-global agent exist with the same name. */
221
+ shadowsGlobal: boolean;
222
+ }
223
+ /**
224
+ * Resolve an agent by name. Precedence: project-local beats home-global.
225
+ * Returns null if not found in either location.
226
+ */
227
+ declare function resolveAgent(name: string, cwd: string): ResolvedAgent | null;
228
+ /** Return project-local agent dir if its YAML exists, else null. */
229
+ declare function resolveInProject(name: string, cwd: string): string | null;
230
+ /** Return home-global agent dir if its YAML exists, else null. */
231
+ declare function resolveInHome(name: string): string | null;
232
+ /** Path to the .elisym root (project or home) for a given target. */
233
+ declare function elisymRootFor(target: AgentSource, cwd: string): string | null;
234
+
235
+ /**
236
+ * Load an agent: parse elisym.yaml + .secrets.json, decrypt if encrypted.
237
+ */
238
+
239
+ interface LoadedAgent {
240
+ name: string;
241
+ dir: string;
242
+ source: AgentSource;
243
+ yaml: ElisymYaml;
244
+ secrets: Secrets;
245
+ /** true when at least one secret field was encrypted on disk. */
246
+ encrypted: boolean;
247
+ shadowsGlobal: boolean;
248
+ }
249
+ /** Raw resolve + read + parse, no decryption yet. Useful for ergonomic list views. */
250
+ declare function readAgentPublic(resolved: ResolvedAgent): Promise<{
251
+ resolved: ResolvedAgent;
252
+ yaml: ElisymYaml;
253
+ }>;
254
+ /**
255
+ * Load an agent by name. Searches project-local first, then home.
256
+ * Throws with clear error if missing or if encrypted secrets lack a passphrase.
257
+ */
258
+ declare function loadAgent(name: string, cwd: string, passphrase?: string): Promise<LoadedAgent>;
259
+ /** Load an agent whose location was already resolved. */
260
+ declare function loadResolvedAgent(resolved: ResolvedAgent, passphrase?: string): Promise<LoadedAgent>;
261
+
262
+ /**
263
+ * Write agent files: elisym.yaml, .secrets.json, .gitignore, and create agent dirs.
264
+ */
265
+
266
+ interface CreateAgentDirOptions {
267
+ target: AgentSource;
268
+ name: string;
269
+ cwd: string;
270
+ /**
271
+ * For `target: 'project'`: if no .elisym/ dir exists above cwd,
272
+ * where should we create one? Defaults to cwd.
273
+ */
274
+ projectRoot?: string;
275
+ }
276
+ interface CreatedAgentDir {
277
+ dir: string;
278
+ paths: AgentPaths;
279
+ source: AgentSource;
280
+ createdNewElisymRoot: boolean;
281
+ }
282
+ /**
283
+ * Create (or reuse) the directory layout for a new agent. Idempotent: if the
284
+ * agent directory already exists, returns its paths without overwriting.
285
+ * Writes `.gitignore` in project-local .elisym/ on first creation.
286
+ */
287
+ declare function createAgentDir(options: CreateAgentDirOptions): Promise<CreatedAgentDir>;
288
+ /** Write elisym.yaml atomically. Validates via Zod before writing. */
289
+ declare function writeYaml(agentDir: string, yaml: ElisymYaml): Promise<void>;
290
+ /**
291
+ * Write .secrets.json atomically. If `passphrase` is given, encrypts all
292
+ * plaintext secret fields (already-encrypted values are left as-is).
293
+ */
294
+ declare function writeSecrets(agentDir: string, secrets: Secrets, passphrase?: string): Promise<void>;
295
+ /** Atomic write: temp file + rename. Preserves mode. */
296
+ declare function writeFileAtomic(path: string, data: string | Buffer, mode: number): Promise<void>;
297
+
298
+ /**
299
+ * List all agents discoverable from the current working directory:
300
+ * - project-local: nearest .elisym/ (walk up to first .git or $HOME)
301
+ * - home-global: ~/.elisym/
302
+ * Project-local entries shadow home-global entries with the same name.
303
+ */
304
+
305
+ interface ListedAgent {
306
+ name: string;
307
+ source: AgentSource;
308
+ dir: string;
309
+ /** display_name from YAML, if present. */
310
+ displayName?: string;
311
+ /** true when this entry is project-local and a home-global agent with the same name exists. */
312
+ shadowsGlobal: boolean;
313
+ }
314
+ /** List agents in both locations, deduping by name (project wins). */
315
+ declare function listAgents(cwd: string): Promise<ListedAgent[]>;
316
+
317
+ /**
318
+ * Media cache: maps local image paths to uploaded URLs + sha256.
319
+ * On each start, the CLI hashes the file and skips re-upload if the hash matches.
320
+ */
321
+
322
+ /** Read .media-cache.json. Returns empty object if missing or corrupt. */
323
+ declare function readMediaCache(agentDir: string): Promise<MediaCache>;
324
+ declare function writeMediaCache(agentDir: string, cache: MediaCache): Promise<void>;
325
+ /** Compute sha256 hex of a file's contents. */
326
+ declare function hashFile(filePath: string): Promise<string>;
327
+ /**
328
+ * Look up a cached URL for a local file path. Returns the cached URL if
329
+ * the file's current hash matches the cache entry; otherwise null.
330
+ */
331
+ declare function lookupCachedUrl(cache: MediaCache, relativePath: string, absolutePath: string): Promise<string | null>;
332
+ declare function newCacheEntry(url: string, sha256: string): MediaCacheEntry;
333
+
334
+ export { AgentNameSchema, type AgentPaths, type AgentSource, type CreateAgentDirOptions, type CreatedAgentDir, ELISYM_DIRNAME, type ElisymYaml, ElisymYamlSchema, GITIGNORE_FILENAME, JOBS_FILENAME, type ListedAgent, type LlmEntry, LlmSchema, type LoadedAgent, MEDIA_CACHE_FILENAME, type MediaCache, type MediaCacheEntry, MediaCacheEntrySchema, MediaCacheSchema, type PaymentEntry, PaymentSchema, type ResolvedAgent, SECRETS_FILENAME, SKILLS_DIRNAME, type Secrets, SecretsSchema, type SecurityFlags, SecurityFlagsSchema, YAML_FILENAME, agentPaths, createAgentDir, elisymRootFor, findProjectElisymDir, hashFile, homeElisymDir, listAgents, loadAgent, loadResolvedAgent, lookupCachedUrl, newCacheEntry, readAgentPublic, readMediaCache, resolveAgent, resolveInHome, resolveInProject, writeFileAtomic, writeMediaCache, writeSecrets, writeYaml };
@@ -0,0 +1,334 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Zod schemas for elisym.yaml (public source of truth) and secrets.json (private).
5
+ * Shared between CLI (provider mode) and MCP (customer mode, future provider mode).
6
+ */
7
+
8
+ declare const AgentNameSchema: z.ZodString;
9
+ declare const PaymentSchema: z.ZodObject<{
10
+ chain: z.ZodLiteral<"solana">;
11
+ network: z.ZodEnum<["devnet"]>;
12
+ address: z.ZodString;
13
+ token: z.ZodOptional<z.ZodString>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ chain: "solana";
16
+ network: "devnet";
17
+ address: string;
18
+ token?: string | undefined;
19
+ }, {
20
+ chain: "solana";
21
+ network: "devnet";
22
+ address: string;
23
+ token?: string | undefined;
24
+ }>;
25
+ declare const LlmSchema: z.ZodObject<{
26
+ provider: z.ZodEnum<["anthropic", "openai"]>;
27
+ model: z.ZodString;
28
+ max_tokens: z.ZodDefault<z.ZodNumber>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ provider: "anthropic" | "openai";
31
+ model: string;
32
+ max_tokens: number;
33
+ }, {
34
+ provider: "anthropic" | "openai";
35
+ model: string;
36
+ max_tokens?: number | undefined;
37
+ }>;
38
+ declare const SecurityFlagsSchema: z.ZodObject<{
39
+ withdrawals_enabled: z.ZodDefault<z.ZodBoolean>;
40
+ agent_switch_enabled: z.ZodDefault<z.ZodBoolean>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ withdrawals_enabled: boolean;
43
+ agent_switch_enabled: boolean;
44
+ }, {
45
+ withdrawals_enabled?: boolean | undefined;
46
+ agent_switch_enabled?: boolean | undefined;
47
+ }>;
48
+ /**
49
+ * elisym.yaml schema. Public - committed to git.
50
+ * Agent name NOT stored here - derived from containing folder name.
51
+ */
52
+ declare const ElisymYamlSchema: z.ZodObject<{
53
+ /** Human-readable name shown in UI (optional). Falls back to folder name. */
54
+ display_name: z.ZodOptional<z.ZodString>;
55
+ description: z.ZodDefault<z.ZodString>;
56
+ /** Relative path (to this YAML) or absolute URL. */
57
+ picture: z.ZodOptional<z.ZodString>;
58
+ /** Relative path (to this YAML) or absolute URL. */
59
+ banner: z.ZodOptional<z.ZodString>;
60
+ relays: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
61
+ payments: z.ZodDefault<z.ZodArray<z.ZodObject<{
62
+ chain: z.ZodLiteral<"solana">;
63
+ network: z.ZodEnum<["devnet"]>;
64
+ address: z.ZodString;
65
+ token: z.ZodOptional<z.ZodString>;
66
+ }, "strip", z.ZodTypeAny, {
67
+ chain: "solana";
68
+ network: "devnet";
69
+ address: string;
70
+ token?: string | undefined;
71
+ }, {
72
+ chain: "solana";
73
+ network: "devnet";
74
+ address: string;
75
+ token?: string | undefined;
76
+ }>, "many">>;
77
+ llm: z.ZodOptional<z.ZodObject<{
78
+ provider: z.ZodEnum<["anthropic", "openai"]>;
79
+ model: z.ZodString;
80
+ max_tokens: z.ZodDefault<z.ZodNumber>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ provider: "anthropic" | "openai";
83
+ model: string;
84
+ max_tokens: number;
85
+ }, {
86
+ provider: "anthropic" | "openai";
87
+ model: string;
88
+ max_tokens?: number | undefined;
89
+ }>>;
90
+ security: z.ZodDefault<z.ZodObject<{
91
+ withdrawals_enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
92
+ agent_switch_enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ withdrawals_enabled?: boolean | undefined;
95
+ agent_switch_enabled?: boolean | undefined;
96
+ }, {
97
+ withdrawals_enabled?: boolean | undefined;
98
+ agent_switch_enabled?: boolean | undefined;
99
+ }>>;
100
+ }, "strict", z.ZodTypeAny, {
101
+ description: string;
102
+ relays: string[];
103
+ payments: {
104
+ chain: "solana";
105
+ network: "devnet";
106
+ address: string;
107
+ token?: string | undefined;
108
+ }[];
109
+ security: {
110
+ withdrawals_enabled?: boolean | undefined;
111
+ agent_switch_enabled?: boolean | undefined;
112
+ };
113
+ display_name?: string | undefined;
114
+ picture?: string | undefined;
115
+ banner?: string | undefined;
116
+ llm?: {
117
+ provider: "anthropic" | "openai";
118
+ model: string;
119
+ max_tokens: number;
120
+ } | undefined;
121
+ }, {
122
+ display_name?: string | undefined;
123
+ description?: string | undefined;
124
+ picture?: string | undefined;
125
+ banner?: string | undefined;
126
+ relays?: string[] | undefined;
127
+ payments?: {
128
+ chain: "solana";
129
+ network: "devnet";
130
+ address: string;
131
+ token?: string | undefined;
132
+ }[] | undefined;
133
+ llm?: {
134
+ provider: "anthropic" | "openai";
135
+ model: string;
136
+ max_tokens?: number | undefined;
137
+ } | undefined;
138
+ security?: {
139
+ withdrawals_enabled?: boolean | undefined;
140
+ agent_switch_enabled?: boolean | undefined;
141
+ } | undefined;
142
+ }>;
143
+ type ElisymYaml = z.infer<typeof ElisymYamlSchema>;
144
+ type PaymentEntry = z.infer<typeof PaymentSchema>;
145
+ type LlmEntry = z.infer<typeof LlmSchema>;
146
+ type SecurityFlags = z.infer<typeof SecurityFlagsSchema>;
147
+ /**
148
+ * secrets.json schema. Private - .gitignore.
149
+ * Values may be plaintext or `encrypted:v1:...` blobs (AES-256-GCM + scrypt).
150
+ */
151
+ declare const SecretsSchema: z.ZodObject<{
152
+ nostr_secret_key: z.ZodString;
153
+ solana_secret_key: z.ZodOptional<z.ZodString>;
154
+ llm_api_key: z.ZodOptional<z.ZodString>;
155
+ }, "strict", z.ZodTypeAny, {
156
+ nostr_secret_key: string;
157
+ solana_secret_key?: string | undefined;
158
+ llm_api_key?: string | undefined;
159
+ }, {
160
+ nostr_secret_key: string;
161
+ solana_secret_key?: string | undefined;
162
+ llm_api_key?: string | undefined;
163
+ }>;
164
+ type Secrets = z.infer<typeof SecretsSchema>;
165
+ interface MediaCacheEntry {
166
+ url: string;
167
+ sha256: string;
168
+ uploaded_at: string;
169
+ }
170
+ declare const MediaCacheEntrySchema: z.ZodType<MediaCacheEntry>;
171
+ declare const MediaCacheSchema: z.ZodRecord<z.ZodString, z.ZodType<MediaCacheEntry, z.ZodTypeDef, MediaCacheEntry>>;
172
+ type MediaCache = z.infer<typeof MediaCacheSchema>;
173
+
174
+ /**
175
+ * Path helpers for .elisym/ layout.
176
+ *
177
+ * Project-local (walk up from CWD until .git or $HOME):
178
+ * <project>/.elisym/<name>/{elisym.yaml, .secrets.json, .media-cache.json, .jobs.json, .gitignore}
179
+ *
180
+ * Home-global (~/.elisym/<name>/): same file structure.
181
+ *
182
+ * Node.js only - relies on `node:fs`/`node:os`/`node:path`.
183
+ */
184
+ declare const ELISYM_DIRNAME = ".elisym";
185
+ declare const YAML_FILENAME = "elisym.yaml";
186
+ declare const SECRETS_FILENAME = ".secrets.json";
187
+ declare const MEDIA_CACHE_FILENAME = ".media-cache.json";
188
+ declare const JOBS_FILENAME = ".jobs.json";
189
+ declare const GITIGNORE_FILENAME = ".gitignore";
190
+ declare const SKILLS_DIRNAME = "skills";
191
+ /** ~/.elisym/ */
192
+ declare function homeElisymDir(): string;
193
+ /**
194
+ * Walk up from `startDir` looking for `.elisym/` directory.
195
+ * Stops at (a) the first `.git` directory/file, (b) `$HOME`, (c) filesystem root,
196
+ * or (d) MAX_WALK_UP_DEPTH iterations. Returns absolute path or null.
197
+ */
198
+ declare function findProjectElisymDir(startDir: string): string | null;
199
+ interface AgentPaths {
200
+ dir: string;
201
+ yaml: string;
202
+ secrets: string;
203
+ mediaCache: string;
204
+ jobs: string;
205
+ gitignore: string;
206
+ skills: string;
207
+ }
208
+ /** Compute all file/dir paths for an agent given its root directory. */
209
+ declare function agentPaths(agentDir: string): AgentPaths;
210
+
211
+ /**
212
+ * Agent resolution: find <name>/elisym.yaml via project-local walk-up, fallback to home.
213
+ */
214
+
215
+ type AgentSource = 'project' | 'home';
216
+ interface ResolvedAgent {
217
+ name: string;
218
+ dir: string;
219
+ source: AgentSource;
220
+ /** true when both a project-local and a home-global agent exist with the same name. */
221
+ shadowsGlobal: boolean;
222
+ }
223
+ /**
224
+ * Resolve an agent by name. Precedence: project-local beats home-global.
225
+ * Returns null if not found in either location.
226
+ */
227
+ declare function resolveAgent(name: string, cwd: string): ResolvedAgent | null;
228
+ /** Return project-local agent dir if its YAML exists, else null. */
229
+ declare function resolveInProject(name: string, cwd: string): string | null;
230
+ /** Return home-global agent dir if its YAML exists, else null. */
231
+ declare function resolveInHome(name: string): string | null;
232
+ /** Path to the .elisym root (project or home) for a given target. */
233
+ declare function elisymRootFor(target: AgentSource, cwd: string): string | null;
234
+
235
+ /**
236
+ * Load an agent: parse elisym.yaml + .secrets.json, decrypt if encrypted.
237
+ */
238
+
239
+ interface LoadedAgent {
240
+ name: string;
241
+ dir: string;
242
+ source: AgentSource;
243
+ yaml: ElisymYaml;
244
+ secrets: Secrets;
245
+ /** true when at least one secret field was encrypted on disk. */
246
+ encrypted: boolean;
247
+ shadowsGlobal: boolean;
248
+ }
249
+ /** Raw resolve + read + parse, no decryption yet. Useful for ergonomic list views. */
250
+ declare function readAgentPublic(resolved: ResolvedAgent): Promise<{
251
+ resolved: ResolvedAgent;
252
+ yaml: ElisymYaml;
253
+ }>;
254
+ /**
255
+ * Load an agent by name. Searches project-local first, then home.
256
+ * Throws with clear error if missing or if encrypted secrets lack a passphrase.
257
+ */
258
+ declare function loadAgent(name: string, cwd: string, passphrase?: string): Promise<LoadedAgent>;
259
+ /** Load an agent whose location was already resolved. */
260
+ declare function loadResolvedAgent(resolved: ResolvedAgent, passphrase?: string): Promise<LoadedAgent>;
261
+
262
+ /**
263
+ * Write agent files: elisym.yaml, .secrets.json, .gitignore, and create agent dirs.
264
+ */
265
+
266
+ interface CreateAgentDirOptions {
267
+ target: AgentSource;
268
+ name: string;
269
+ cwd: string;
270
+ /**
271
+ * For `target: 'project'`: if no .elisym/ dir exists above cwd,
272
+ * where should we create one? Defaults to cwd.
273
+ */
274
+ projectRoot?: string;
275
+ }
276
+ interface CreatedAgentDir {
277
+ dir: string;
278
+ paths: AgentPaths;
279
+ source: AgentSource;
280
+ createdNewElisymRoot: boolean;
281
+ }
282
+ /**
283
+ * Create (or reuse) the directory layout for a new agent. Idempotent: if the
284
+ * agent directory already exists, returns its paths without overwriting.
285
+ * Writes `.gitignore` in project-local .elisym/ on first creation.
286
+ */
287
+ declare function createAgentDir(options: CreateAgentDirOptions): Promise<CreatedAgentDir>;
288
+ /** Write elisym.yaml atomically. Validates via Zod before writing. */
289
+ declare function writeYaml(agentDir: string, yaml: ElisymYaml): Promise<void>;
290
+ /**
291
+ * Write .secrets.json atomically. If `passphrase` is given, encrypts all
292
+ * plaintext secret fields (already-encrypted values are left as-is).
293
+ */
294
+ declare function writeSecrets(agentDir: string, secrets: Secrets, passphrase?: string): Promise<void>;
295
+ /** Atomic write: temp file + rename. Preserves mode. */
296
+ declare function writeFileAtomic(path: string, data: string | Buffer, mode: number): Promise<void>;
297
+
298
+ /**
299
+ * List all agents discoverable from the current working directory:
300
+ * - project-local: nearest .elisym/ (walk up to first .git or $HOME)
301
+ * - home-global: ~/.elisym/
302
+ * Project-local entries shadow home-global entries with the same name.
303
+ */
304
+
305
+ interface ListedAgent {
306
+ name: string;
307
+ source: AgentSource;
308
+ dir: string;
309
+ /** display_name from YAML, if present. */
310
+ displayName?: string;
311
+ /** true when this entry is project-local and a home-global agent with the same name exists. */
312
+ shadowsGlobal: boolean;
313
+ }
314
+ /** List agents in both locations, deduping by name (project wins). */
315
+ declare function listAgents(cwd: string): Promise<ListedAgent[]>;
316
+
317
+ /**
318
+ * Media cache: maps local image paths to uploaded URLs + sha256.
319
+ * On each start, the CLI hashes the file and skips re-upload if the hash matches.
320
+ */
321
+
322
+ /** Read .media-cache.json. Returns empty object if missing or corrupt. */
323
+ declare function readMediaCache(agentDir: string): Promise<MediaCache>;
324
+ declare function writeMediaCache(agentDir: string, cache: MediaCache): Promise<void>;
325
+ /** Compute sha256 hex of a file's contents. */
326
+ declare function hashFile(filePath: string): Promise<string>;
327
+ /**
328
+ * Look up a cached URL for a local file path. Returns the cached URL if
329
+ * the file's current hash matches the cache entry; otherwise null.
330
+ */
331
+ declare function lookupCachedUrl(cache: MediaCache, relativePath: string, absolutePath: string): Promise<string | null>;
332
+ declare function newCacheEntry(url: string, sha256: string): MediaCacheEntry;
333
+
334
+ export { AgentNameSchema, type AgentPaths, type AgentSource, type CreateAgentDirOptions, type CreatedAgentDir, ELISYM_DIRNAME, type ElisymYaml, ElisymYamlSchema, GITIGNORE_FILENAME, JOBS_FILENAME, type ListedAgent, type LlmEntry, LlmSchema, type LoadedAgent, MEDIA_CACHE_FILENAME, type MediaCache, type MediaCacheEntry, MediaCacheEntrySchema, MediaCacheSchema, type PaymentEntry, PaymentSchema, type ResolvedAgent, SECRETS_FILENAME, SKILLS_DIRNAME, type Secrets, SecretsSchema, type SecurityFlags, SecurityFlagsSchema, YAML_FILENAME, agentPaths, createAgentDir, elisymRootFor, findProjectElisymDir, hashFile, homeElisymDir, listAgents, loadAgent, loadResolvedAgent, lookupCachedUrl, newCacheEntry, readAgentPublic, readMediaCache, resolveAgent, resolveInHome, resolveInProject, writeFileAtomic, writeMediaCache, writeSecrets, writeYaml };