@yasaswy.nagavolu/agents 0.8.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.
package/lib/wiring.js ADDED
@@ -0,0 +1,379 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+ const { writeFileAtomic } = require('./fsutil');
7
+
8
+ class WiringError extends Error {}
9
+
10
+ const SETTINGS_FILE_NAME = 'settings.json';
11
+ // The manifest's wiring `command` strings use this repo-convention marker
12
+ // (see proxy/README.md) in place of a machine-specific install path.
13
+ const HOME_MARKER = '~/.claude';
14
+
15
+ function settingsPath(targetBase) {
16
+ return path.join(targetBase, SETTINGS_FILE_NAME);
17
+ }
18
+
19
+ function loadSettings(targetBase) {
20
+ const file = settingsPath(targetBase);
21
+ if (!fs.existsSync(file)) {
22
+ return {};
23
+ }
24
+ let raw;
25
+ try {
26
+ raw = JSON.parse(fs.readFileSync(file, 'utf8'));
27
+ } catch (err) {
28
+ throw new WiringError(`settings.json at ${file} is not valid JSON: ${err.message}`);
29
+ }
30
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
31
+ throw new WiringError(`settings.json at ${file} must be a JSON object at its root`);
32
+ }
33
+ return raw;
34
+ }
35
+
36
+ function saveSettings(targetBase, settings) {
37
+ writeFileAtomic(settingsPath(targetBase), `${JSON.stringify(settings, null, 2)}\n`);
38
+ }
39
+
40
+ /**
41
+ * Resolve a manifest wiring `command` against the real install target,
42
+ * matching the forward-slash, generally-unquoted convention the real
43
+ * ~/.claude/settings.json on this machine uses for hook commands (e.g.
44
+ * `python C:/Users/nyasa/.claude/proxy/reddit_intent_hook.py`) — except the
45
+ * resolved path IS wrapped in double quotes when it contains whitespace,
46
+ * since an unquoted path with a space would break the invoked command on any
47
+ * machine whose install directory has one (this machine's doesn't, hence the
48
+ * unquoted live example).
49
+ */
50
+ function resolveHookCommand(rawCommand, targetBase) {
51
+ const idx = rawCommand.indexOf(HOME_MARKER);
52
+ if (idx === -1) {
53
+ throw new WiringError(
54
+ `Hook wiring command "${rawCommand}" does not reference ${HOME_MARKER} — cannot resolve an install path`
55
+ );
56
+ }
57
+ const prefix = rawCommand.slice(0, idx);
58
+ const suffix = rawCommand.slice(idx + HOME_MARKER.length);
59
+ const resolvedBase = targetBase.split(path.sep).join('/');
60
+ const fullPath = `${resolvedBase}${suffix}`;
61
+ const needsQuoting = /\s/.test(fullPath);
62
+ return `${prefix}${needsQuoting ? `"${fullPath}"` : fullPath}`;
63
+ }
64
+
65
+ function defaultPythonChecker() {
66
+ for (const bin of ['python3', 'python']) {
67
+ const result = spawnSync(bin, ['--version'], { stdio: 'ignore' });
68
+ if (!result.error && result.status === 0) {
69
+ return bin;
70
+ }
71
+ }
72
+ return null;
73
+ }
74
+
75
+ function isPythonCommand(command) {
76
+ return /^python3?\s/.test(command.trim());
77
+ }
78
+
79
+ function asWiringList(wiring) {
80
+ if (!wiring) return [];
81
+ return Array.isArray(wiring) ? wiring : [wiring];
82
+ }
83
+
84
+ function blockKeyMatches(block, matcher, ifClause) {
85
+ const blockMatcher = block.matcher || null;
86
+ const blockIf = block.if || null;
87
+ return blockMatcher === (matcher || null) && blockIf === (ifClause || null);
88
+ }
89
+
90
+ function recordKey(record) {
91
+ return JSON.stringify([record.event, record.matcher || null, record.if || null, record.command]);
92
+ }
93
+
94
+ function mergeWiringRecords(existing, incoming) {
95
+ const seen = new Set((existing || []).map(recordKey));
96
+ const merged = [...(existing || [])];
97
+ for (const record of incoming) {
98
+ const key = recordKey(record);
99
+ if (!seen.has(key)) {
100
+ seen.add(key);
101
+ merged.push(record);
102
+ }
103
+ }
104
+ return merged;
105
+ }
106
+
107
+ /**
108
+ * One-time backup of the pre-existing settings.json, taken immediately
109
+ * before the FIRST write this CLI ever makes to it on this target. A marker
110
+ * on the ledger (`ledger.settingsBackup.taken`) makes this durable across
111
+ * separate CLI invocations, so later installs/uninstalls never re-backup.
112
+ * If settings.json didn't exist yet, there is nothing to protect — the
113
+ * marker is still recorded so we never attempt it later.
114
+ */
115
+ function ensureSettingsBackup(targetBase, ledger, timestamp) {
116
+ if (ledger.settingsBackup && ledger.settingsBackup.taken) {
117
+ return null;
118
+ }
119
+ const file = settingsPath(targetBase);
120
+ let backupFile = null;
121
+ if (fs.existsSync(file)) {
122
+ const safeStamp = timestamp.replace(/[:.]/g, '-');
123
+ backupFile = `${file}.bak-${safeStamp}`;
124
+ fs.copyFileSync(file, backupFile);
125
+ }
126
+ ledger.settingsBackup = { taken: true, at: timestamp, file: backupFile };
127
+ return backupFile;
128
+ }
129
+
130
+ /**
131
+ * Merge every hook item's wiring (kind === "hook", non-null wiring shaped
132
+ * like {event, type, command}) into <targetBase>/settings.json's `hooks`
133
+ * structure, and record the resulting (event, matcher, if, command) tuples
134
+ * under `ledger.wiring[bundleKey]` so `uninstallBundle` can remove exactly
135
+ * (and only) what this bundle wired later.
136
+ *
137
+ * Idempotent: re-running with the same items produces zero duplicate hook
138
+ * entries — the dedupe key is (event, matcher, if, resolvedCommand). Every
139
+ * unrelated key already in settings.json (other hook events/matchers,
140
+ * top-level settings) is preserved verbatim — the whole parsed object is
141
+ * round-tripped through JSON.parse/stringify and only the blocks we own are
142
+ * read or mutated.
143
+ *
144
+ * Skips (never errors on) a Python-backed hook when no python3/python is on
145
+ * PATH — those land in the returned `skippedNoPython` list; the caller is
146
+ * expected to tell the user to re-run `install --bundle <key> --yes` once
147
+ * Python is available.
148
+ */
149
+ function wireItems(items, { targetBase, bundleKey, ledger, timestamp, pythonChecker }) {
150
+ const hookItems = items.filter((item) => item.kind === 'hook' && item.wiring);
151
+ const wired = [];
152
+ const alreadyWired = [];
153
+ const skippedNoPython = [];
154
+ const ownedThisRun = [];
155
+
156
+ if (hookItems.length === 0) {
157
+ return { wired, alreadyWired, skippedNoPython, settingsChanged: false, backupFile: null };
158
+ }
159
+
160
+ const checker = pythonChecker || defaultPythonChecker;
161
+ let pythonBin = null;
162
+ let pythonChecked = false;
163
+
164
+ const settings = loadSettings(targetBase);
165
+ settings.hooks = settings.hooks && typeof settings.hooks === 'object' && !Array.isArray(settings.hooks) ? settings.hooks : {};
166
+
167
+ let mutated = false;
168
+
169
+ for (const item of hookItems) {
170
+ for (const wiring of asWiringList(item.wiring)) {
171
+ if (!wiring.event || !wiring.type || !wiring.command) {
172
+ // Non-hook-event wiring shapes are out of scope for this executor
173
+ // (e.g. statusline/mcp items are never kind:"hook", but guard here
174
+ // in case a future item mixes shapes).
175
+ continue;
176
+ }
177
+
178
+ if (isPythonCommand(wiring.command)) {
179
+ if (!pythonChecked) {
180
+ pythonBin = checker();
181
+ pythonChecked = true;
182
+ }
183
+ if (!pythonBin) {
184
+ skippedNoPython.push({ path: item.path, event: wiring.event });
185
+ continue;
186
+ }
187
+ }
188
+
189
+ const resolvedCommand = resolveHookCommand(wiring.command, targetBase);
190
+ if (!Array.isArray(settings.hooks[wiring.event])) {
191
+ settings.hooks[wiring.event] = [];
192
+ }
193
+ const eventArray = settings.hooks[wiring.event];
194
+
195
+ let block = eventArray.find((b) => blockKeyMatches(b, wiring.matcher, wiring.if));
196
+ if (!block) {
197
+ block = { hooks: [] };
198
+ if (wiring.matcher) block.matcher = wiring.matcher;
199
+ if (wiring.if) block.if = wiring.if;
200
+ eventArray.push(block);
201
+ }
202
+ if (!Array.isArray(block.hooks)) {
203
+ block.hooks = [];
204
+ }
205
+
206
+ const record = { event: wiring.event, matcher: wiring.matcher || null, if: wiring.if || null, command: resolvedCommand };
207
+ ownedThisRun.push(record);
208
+
209
+ const exists = block.hooks.some((h) => h.command === resolvedCommand);
210
+ if (exists) {
211
+ alreadyWired.push({ path: item.path, ...record });
212
+ continue;
213
+ }
214
+
215
+ const entry = { type: wiring.type, command: resolvedCommand };
216
+ if (wiring.timeout) entry.timeout = wiring.timeout;
217
+ block.hooks.push(entry);
218
+ wired.push({ path: item.path, ...record });
219
+ mutated = true;
220
+ }
221
+ }
222
+
223
+ if (ledger) {
224
+ ledger.wiring = ledger.wiring || {};
225
+ ledger.wiring[bundleKey] = mergeWiringRecords(ledger.wiring[bundleKey], ownedThisRun);
226
+ }
227
+
228
+ if (!mutated) {
229
+ return { wired, alreadyWired, skippedNoPython, settingsChanged: false, backupFile: null };
230
+ }
231
+
232
+ const backupFile = ensureSettingsBackup(targetBase, ledger || {}, timestamp);
233
+ saveSettings(targetBase, settings);
234
+
235
+ return { wired, alreadyWired, skippedNoPython, settingsChanged: true, backupFile };
236
+ }
237
+
238
+ /**
239
+ * Remove exactly the settings.json hook entries recorded under
240
+ * `ledger.wiring[bundleKey]` (nothing else — unrelated hook entries, blocks,
241
+ * and events are left untouched). Prunes now-empty hook blocks and now-empty
242
+ * event arrays so a fully-unwired bundle doesn't leave litter like
243
+ * `"SomeEvent": []` behind. No-op (not an error) if the bundle has no
244
+ * recorded wiring.
245
+ */
246
+ function unwireBundle(bundleKey, { targetBase, ledger }) {
247
+ const records = (ledger.wiring && ledger.wiring[bundleKey]) || [];
248
+ if (records.length === 0) {
249
+ return { removed: [], settingsChanged: false };
250
+ }
251
+
252
+ const settings = loadSettings(targetBase);
253
+ const removed = [];
254
+ let mutated = false;
255
+
256
+ if (settings.hooks && typeof settings.hooks === 'object') {
257
+ for (const record of records) {
258
+ const eventArray = settings.hooks[record.event];
259
+ if (!Array.isArray(eventArray)) continue;
260
+
261
+ for (let i = eventArray.length - 1; i >= 0; i -= 1) {
262
+ const block = eventArray[i];
263
+ if (!blockKeyMatches(block, record.matcher, record.if) || !Array.isArray(block.hooks)) continue;
264
+
265
+ const beforeLen = block.hooks.length;
266
+ block.hooks = block.hooks.filter((h) => h.command !== record.command);
267
+ if (block.hooks.length !== beforeLen) {
268
+ removed.push(record);
269
+ mutated = true;
270
+ }
271
+ if (block.hooks.length === 0) {
272
+ eventArray.splice(i, 1);
273
+ }
274
+ }
275
+
276
+ if (eventArray.length === 0) {
277
+ delete settings.hooks[record.event];
278
+ }
279
+ }
280
+ }
281
+
282
+ if (mutated) {
283
+ saveSettings(targetBase, settings);
284
+ }
285
+
286
+ delete ledger.wiring[bundleKey];
287
+
288
+ return { removed, settingsChanged: mutated };
289
+ }
290
+
291
+ /**
292
+ * Every (event, matcher, if, resolvedCommand) record the current manifest
293
+ * `items` declare for this bundle — independent of python availability, so
294
+ * a hook temporarily skipped for lack of python3/python is still "expected"
295
+ * (not pruned as stale). Used by the update command to detect when the
296
+ * manifest's wiring declarations changed since install.
297
+ */
298
+ function expectedWiringRecords(items, targetBase) {
299
+ const hookItems = items.filter((item) => item.kind === 'hook' && item.wiring);
300
+ const records = [];
301
+ for (const item of hookItems) {
302
+ for (const wiring of asWiringList(item.wiring)) {
303
+ if (!wiring.event || !wiring.type || !wiring.command) continue;
304
+ records.push({
305
+ event: wiring.event,
306
+ matcher: wiring.matcher || null,
307
+ if: wiring.if || null,
308
+ command: resolveHookCommand(wiring.command, targetBase),
309
+ });
310
+ }
311
+ }
312
+ return records;
313
+ }
314
+
315
+ /**
316
+ * Remove ledger.wiring[bundleKey] records that are no longer in
317
+ * `expectedRecords` (the manifest dropped or changed that wiring
318
+ * declaration) — nothing else. A stale record still present verbatim in
319
+ * settings.json is removed there too; one no longer present (user deleted it,
320
+ * or it was never wired e.g. skipped-no-python) is just dropped from the
321
+ * ledger. Unlike file/MCP updates, a hook record's ledger entry carries no
322
+ * separate "what we wrote" hash to compare against — this executor cannot
323
+ * distinguish "user hand-edited this exact hook entry" from "it's simply
324
+ * gone", so it never reports a hook-wiring conflict; callers that need that
325
+ * distinction should treat file-level conflicts as the authoritative signal.
326
+ */
327
+ function pruneStaleWiring(bundleKey, { targetBase, ledger, expectedRecords }) {
328
+ const existing = (ledger.wiring && ledger.wiring[bundleKey]) || [];
329
+ const expectedKeys = new Set(expectedRecords.map(recordKey));
330
+ const stale = existing.filter((r) => !expectedKeys.has(recordKey(r)));
331
+ if (stale.length === 0) {
332
+ return { removed: [], settingsChanged: false };
333
+ }
334
+
335
+ const settings = loadSettings(targetBase);
336
+ const removed = [];
337
+ let mutated = false;
338
+
339
+ if (settings.hooks && typeof settings.hooks === 'object') {
340
+ for (const record of stale) {
341
+ const eventArray = settings.hooks[record.event];
342
+ if (!Array.isArray(eventArray)) continue;
343
+
344
+ for (let i = eventArray.length - 1; i >= 0; i -= 1) {
345
+ const block = eventArray[i];
346
+ if (!blockKeyMatches(block, record.matcher, record.if) || !Array.isArray(block.hooks)) continue;
347
+ const beforeLen = block.hooks.length;
348
+ block.hooks = block.hooks.filter((h) => h.command !== record.command);
349
+ if (block.hooks.length !== beforeLen) mutated = true;
350
+ if (block.hooks.length === 0) eventArray.splice(i, 1);
351
+ }
352
+ if (eventArray.length === 0) delete settings.hooks[record.event];
353
+ }
354
+ }
355
+ removed.push(...stale);
356
+
357
+ if (mutated) {
358
+ saveSettings(targetBase, settings);
359
+ }
360
+
361
+ if (ledger.wiring) {
362
+ ledger.wiring[bundleKey] = existing.filter((r) => expectedKeys.has(recordKey(r)));
363
+ }
364
+
365
+ return { removed, settingsChanged: mutated };
366
+ }
367
+
368
+ module.exports = {
369
+ wireItems,
370
+ unwireBundle,
371
+ pruneStaleWiring,
372
+ expectedWiringRecords,
373
+ resolveHookCommand,
374
+ asWiringList,
375
+ settingsPath,
376
+ loadSettings,
377
+ saveSettings,
378
+ WiringError,
379
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@yasaswy.nagavolu/agents",
3
+ "version": "0.8.0",
4
+ "description": "CLI for installing the yasaswy.nagavolu agent/skill/hook bundle. `install` opens an interactive bundle menu in a TTY (or `--bundle <key> --yes` for non-interactive installs), with hash-tracked idempotent deploys, automatic hook wiring into settings.json, and masked secret prompting. `update` reconciles installed bundles against the current source (hash-tracked: silent overwrite, conflict diff+prompt, or --theirs/--keep-mine). `uninstall` removes a bundle's files and wiring. `secrets` re-runs secret prompting for already-installed bundles.",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "engines": {
8
+ "node": ">=18"
9
+ },
10
+ "bin": {
11
+ "agents-cli": "bin/cli.js"
12
+ },
13
+ "files": [
14
+ "bin/",
15
+ "lib/",
16
+ "templates/"
17
+ ],
18
+ "scripts": {
19
+ "test": "node --test test/index.js"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://gitlab.com/yasaswy22/my-agents.git",
27
+ "directory": "packages/cli"
28
+ },
29
+ "homepage": "https://gitlab.com/yasaswy22/my-agents",
30
+ "bugs": {
31
+ "url": "https://gitlab.com/yasaswy22/my-agents/-/issues"
32
+ },
33
+ "keywords": [
34
+ "cli",
35
+ "agents",
36
+ "claude",
37
+ "skills"
38
+ ]
39
+ }
@@ -0,0 +1,95 @@
1
+ # Public LiteLLM proxy config for @yasaswy.nagavolu/agents' LiteLLM-backed
2
+ # bundles (Councils, Review Council, Web Search, Model Routing, Agent
3
+ # Orchestration). Installed to <target>/litellm/config.yaml by the "litellm"
4
+ # component installer (packages/cli/lib/components.js) — nothing below is a
5
+ # real secret; every provider key is read from the process environment via
6
+ # LiteLLM's "os.environ/VAR_NAME" syntax.
7
+ #
8
+ # Start the proxy with <target>/litellm/start-litellm.ps1 (Windows) or
9
+ # start-litellm.sh (macOS/Linux). Both load <target>/agents.env into the
10
+ # process environment first, so keys you set via `agents-cli secrets` (or a
11
+ # real shell-exported env var, which always wins) actually reach LiteLLM —
12
+ # just placing the value in agents.env is not enough on its own, since this
13
+ # is a separate OS process from the CLI.
14
+ #
15
+ # A model whose provider key is unset simply fails to authenticate when
16
+ # called; LiteLLM starts up normally regardless — this repo's own production
17
+ # config (proxy/litellm/config.yaml, not shipped here) has run for months
18
+ # with a rotating subset of these keys unset, with no startup impact. Delete
19
+ # any block below you don't want registered at all, or add your own.
20
+ #
21
+ # model_name values below (litellm_gemini, litellm_deepseek, etc.) are fixed
22
+ # — the shipped skills/agents call these exact names. Don't rename them
23
+ # unless you're also changing every caller.
24
+
25
+ model_list:
26
+ - model_name: litellm_gemini
27
+ litellm_params:
28
+ model: gemini/gemini-3.5-flash
29
+ api_key: "os.environ/GAISTUDIO_API_KEY"
30
+ # Google AI Studio key: https://aistudio.google.com/apikey
31
+ # Used by: Councils, Review Council, Visual Check.
32
+
33
+ - model_name: litellm_deepseek
34
+ litellm_params:
35
+ model: deepseek/deepseek-v4-flash
36
+ api_key: "os.environ/DEEPSEEK_API_KEY"
37
+ # DeepSeek platform key: https://platform.deepseek.com/api_keys
38
+ # Used by: Councils, Review Council, Model Routing.
39
+
40
+ - model_name: litellm_deepseek_flash
41
+ litellm_params:
42
+ model: deepseek/deepseek-v4-flash
43
+ api_key: "os.environ/DEEPSEEK_API_KEY"
44
+ # Alias of litellm_deepseek above — some agents reference this name
45
+ # directly. Same model, same key.
46
+
47
+ - model_name: litellm_glm
48
+ litellm_params:
49
+ model: openai/glm-5.2
50
+ api_base: "https://api.z.ai/api/paas/v4"
51
+ api_key: "os.environ/ZAI_API_KEY"
52
+ # Z.AI platform key: https://z.ai/manage-apikey/apikey-list
53
+ # Used by: Councils, Review Council, Model Routing.
54
+
55
+ - model_name: litellm_qwen
56
+ litellm_params:
57
+ model: together_ai/Qwen/Qwen3.7-Max
58
+ api_key: "os.environ/TOGETHERAI_API_KEY"
59
+ allowed_openai_params: ["tools", "tool_choice"]
60
+ # Together AI key: https://api.together.ai/settings/api-keys
61
+ # Used by: Councils, Review Council, Model Routing.
62
+ # NOTE: this backend rejects a forced tool_choice ("any"/"required"/a
63
+ # named-tool object) while in thinking mode — leave tool_choice at
64
+ # "auto" or omit it entirely for any flow routed through this model.
65
+
66
+ - model_name: litellm_sonar
67
+ litellm_params:
68
+ model: perplexity/sonar-pro
69
+ api_key: "os.environ/PERPLEXITY_API_KEY"
70
+ # Perplexity key: https://www.perplexity.ai/settings/api
71
+ # Used by: Web Search.
72
+
73
+ - model_name: litellm_sonar_reasoning
74
+ litellm_params:
75
+ model: perplexity/sonar-reasoning-pro
76
+ api_key: "os.environ/PERPLEXITY_API_KEY"
77
+ # Used by: Web Search (default model for the web-search skill).
78
+
79
+ - model_name: litellm_gpt
80
+ litellm_params:
81
+ model: openai/gpt-5.1-mini
82
+ api_key: "os.environ/OPENAI_API_KEY"
83
+ # OpenAI platform key: https://platform.openai.com/api-keys
84
+ # Not called by any bundle in this package yet — included as a ready-to-
85
+ # use generic alias for your own skills/hooks. Delete freely.
86
+
87
+ general_settings:
88
+ master_key: "os.environ/LITELLM_MASTER_KEY"
89
+ # Optional Postgres-backed spend DB + /ui dashboard: set DATABASE_URL and
90
+ # uncomment the two lines below (LiteLLM runs its own migration on first
91
+ # connect — see LiteLLM's docs for the Postgres/DATABASE_URL setup this
92
+ # expects). Left out of this template because it's a separate piece of
93
+ # infrastructure (a Postgres instance) this package doesn't provision.
94
+ # database_url: "os.environ/DATABASE_URL"
95
+ # store_model_in_db: true
@@ -0,0 +1,47 @@
1
+ # start-litellm.ps1 -- foreground launcher for the LiteLLM proxy installed by
2
+ # @yasaswy.nagavolu/agents (packages/cli/lib/components.js). Loads
3
+ # <AGENTS_ENV_DIR or this script's parent dir>/agents.env into the process
4
+ # environment (a real env var of the same name always wins), then runs
5
+ # `litellm --config config.yaml --port <port>` in THIS terminal. No service
6
+ # supervision in this release -- Ctrl-C or closing the window stops the
7
+ # proxy; re-run this script to start it again (e.g. after a reboot).
8
+ #
9
+ # Usage:
10
+ # powershell -ExecutionPolicy Bypass -File start-litellm.ps1 # port 4000
11
+ # powershell -ExecutionPolicy Bypass -File start-litellm.ps1 -Port 4001
12
+
13
+ param(
14
+ [int]$Port = 4000
15
+ )
16
+
17
+ $ConfigFile = Join-Path $PSScriptRoot "config.yaml"
18
+ $EnvBase = if ($env:AGENTS_ENV_DIR) { $env:AGENTS_ENV_DIR } else { Split-Path $PSScriptRoot -Parent }
19
+ $EnvFile = Join-Path $EnvBase "agents.env"
20
+
21
+ if (Test-Path $EnvFile) {
22
+ Get-Content $EnvFile | ForEach-Object {
23
+ $line = $_.Trim()
24
+ if (-not $line -or $line.StartsWith("#") -or -not $line.Contains("=")) { return }
25
+ $key, $value = $line -split "=", 2
26
+ $key = $key.Trim()
27
+ $value = $value.Trim().Trim('"').Trim("'")
28
+ if ($key -and -not (Test-Path "env:$key")) {
29
+ [System.Environment]::SetEnvironmentVariable($key, $value, "Process")
30
+ }
31
+ }
32
+ } else {
33
+ Write-Host "[litellm] WARNING: no agents.env found at $EnvFile -- provider keys / LITELLM_MASTER_KEY may be missing. Run: agents-cli secrets" -ForegroundColor Yellow
34
+ }
35
+
36
+ if (-not (Get-Command litellm -ErrorAction SilentlyContinue)) {
37
+ Write-Error 'litellm not found on PATH. Install with: uv tool install "litellm[proxy]" (or: pipx install "litellm[proxy]")'
38
+ exit 1
39
+ }
40
+
41
+ # LiteLLM's startup banner contains non-ASCII characters that crash under
42
+ # Windows' default cp1252 console encoding -- force UTF-8 I/O.
43
+ $env:PYTHONIOENCODING = "utf-8"
44
+ $env:PYTHONUTF8 = "1"
45
+
46
+ Write-Host "[litellm] starting on port $Port (config: $ConfigFile) ..."
47
+ litellm --config $ConfigFile --port $Port
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ # start-litellm.sh -- foreground launcher for the LiteLLM proxy installed by
3
+ # @yasaswy.nagavolu/agents (packages/cli/lib/components.js). Loads
4
+ # ${AGENTS_ENV_DIR:-<this script's parent dir>}/agents.env into the process
5
+ # environment (a real exported env var of the same name always wins), then
6
+ # runs `litellm --config config.yaml --port <port>` in THIS terminal. No
7
+ # service supervision in this release -- Ctrl-C stops the proxy; re-run this
8
+ # script to start it again.
9
+ #
10
+ # Usage:
11
+ # ./start-litellm.sh # port 4000
12
+ # ./start-litellm.sh 4001 # custom port
13
+
14
+ set -euo pipefail
15
+
16
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ CONFIG_FILE="$SCRIPT_DIR/config.yaml"
18
+ PORT="${1:-4000}"
19
+ ENV_BASE="${AGENTS_ENV_DIR:-$(dirname "$SCRIPT_DIR")}"
20
+ ENV_FILE="$ENV_BASE/agents.env"
21
+
22
+ if [ -f "$ENV_FILE" ]; then
23
+ while IFS= read -r line || [ -n "$line" ]; do
24
+ case "$line" in
25
+ ''|'#'*) continue ;;
26
+ esac
27
+ case "$line" in
28
+ *=*) ;;
29
+ *) continue ;;
30
+ esac
31
+ key="${line%%=*}"
32
+ value="${line#*=}"
33
+ key="$(printf '%s' "$key" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
34
+ if [ -n "$key" ] && [ -z "${!key+x}" ]; then
35
+ export "$key=$value"
36
+ fi
37
+ done < "$ENV_FILE"
38
+ else
39
+ echo "[litellm] WARNING: no agents.env found at $ENV_FILE -- provider keys / LITELLM_MASTER_KEY may be missing. Run: agents-cli secrets" >&2
40
+ fi
41
+
42
+ if ! command -v litellm >/dev/null 2>&1; then
43
+ echo 'litellm not found on PATH. Install with: uv tool install "litellm[proxy]" (or: pipx install "litellm[proxy]")' >&2
44
+ exit 1
45
+ fi
46
+
47
+ export PYTHONIOENCODING=utf-8
48
+ export PYTHONUTF8=1
49
+
50
+ echo "[litellm] starting on port $PORT (config: $CONFIG_FILE) ..."
51
+ exec litellm --config "$CONFIG_FILE" --port "$PORT"