@syntero/orca-cli 1.2.17-next.1 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntero/orca-cli",
3
- "version": "1.2.17-next.1",
3
+ "version": "1.3.0",
4
4
  "description": "LLM-powered deployment troubleshooting assistant for Orca",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,99 +0,0 @@
1
- import Anthropic from '@anthropic-ai/sdk';
2
- import OpenAI from 'openai';
3
- import { Settings } from './settings.js';
4
- import { type DangerCheckResult } from './tools.js';
5
- import type { LLMClient } from './providers.js';
6
- /**
7
- * Result of command confirmation callback.
8
- */
9
- export interface CommandConfirmResult {
10
- /** Whether to proceed with the command */
11
- confirmed: boolean;
12
- /** Categories to add to session approvals (if user chose "allow category") */
13
- approveCategories?: string[];
14
- }
15
- /**
16
- * Callback type for confirming dangerous commands.
17
- * Called before executing potentially dangerous shell commands.
18
- *
19
- * @param command - The shell command to confirm
20
- * @param dangerCheck - Details about why the command is considered dangerous
21
- * @returns Promise resolving to the confirmation result
22
- */
23
- export type ConfirmCommandCallback = (command: string, dangerCheck: DangerCheckResult, gist?: string) => Promise<CommandConfirmResult>;
24
- export interface AnthropicMessage {
25
- role: 'user' | 'assistant';
26
- content: string | AnthropicContentBlock[];
27
- }
28
- interface AnthropicContentBlock {
29
- type: 'text' | 'tool_use' | 'tool_result';
30
- text?: string;
31
- id?: string;
32
- name?: string;
33
- input?: Record<string, unknown>;
34
- tool_use_id?: string;
35
- content?: string;
36
- }
37
- /**
38
- * Run assistant with Anthropic API with streaming.
39
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
40
- * @param confirmCommand - Optional callback to confirm dangerous commands
41
- * @param approvedCategories - Set of command categories approved for the session
42
- */
43
- export declare function runAssistantAnthropic(client: Anthropic, settings: Settings, userMessage: string, messages: AnthropicMessage[], signal?: AbortSignal, getQueuedMessage?: () => string | null, confirmCommand?: ConfirmCommandCallback, approvedCategories?: Set<string>): AsyncGenerator<string, AnthropicMessage[], void>;
44
- /**
45
- * Run assistant with Anthropic API without streaming.
46
- * Fetches complete responses in a single request to eliminate screen jitter.
47
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
48
- * @param confirmCommand - Optional callback to confirm dangerous commands
49
- * @param approvedCategories - Set of command categories approved for the session
50
- */
51
- export declare function runAssistantAnthropicNonStreaming(client: Anthropic, settings: Settings, userMessage: string, messages: AnthropicMessage[], signal?: AbortSignal, getQueuedMessage?: () => string | null, confirmCommand?: ConfirmCommandCallback, approvedCategories?: Set<string>): AsyncGenerator<string, AnthropicMessage[], void>;
52
- /**
53
- * Run assistant with OpenAI/Azure API with streaming.
54
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
55
- * @param confirmCommand - Optional callback to confirm dangerous commands
56
- * @param approvedCategories - Set of command categories approved for the session
57
- */
58
- export declare function runAssistantOpenAI(client: OpenAI, settings: Settings, userMessage: string, messages: AnthropicMessage[], isAzure?: boolean, signal?: AbortSignal, getQueuedMessage?: () => string | null, confirmCommand?: ConfirmCommandCallback, approvedCategories?: Set<string>): AsyncGenerator<string, AnthropicMessage[], void>;
59
- /**
60
- * Run assistant with OpenAI/Azure API without streaming.
61
- * Fetches complete responses in a single request to eliminate screen jitter.
62
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
63
- * @param confirmCommand - Optional callback to confirm dangerous commands
64
- * @param approvedCategories - Set of command categories approved for the session
65
- */
66
- export declare function runAssistantOpenAINonStreaming(client: OpenAI, settings: Settings, userMessage: string, messages: AnthropicMessage[], isAzure?: boolean, signal?: AbortSignal, getQueuedMessage?: () => string | null, confirmCommand?: ConfirmCommandCallback, approvedCategories?: Set<string>): AsyncGenerator<string, AnthropicMessage[], void>;
67
- /**
68
- * Run the assistant with the appropriate provider.
69
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
70
- * @param confirmCommand - Optional callback to confirm dangerous commands
71
- * @param approvedCategories - Set of command categories approved for the session
72
- */
73
- export declare function runAssistant(client: LLMClient, settings: Settings, userMessage: string, messages?: AnthropicMessage[], signal?: AbortSignal, getQueuedMessage?: () => string | null, confirmCommand?: ConfirmCommandCallback, approvedCategories?: Set<string>): AsyncGenerator<string, AnthropicMessage[], void>;
74
- /**
75
- * Summarize a conversation history.
76
- * Uses the configured LLM provider to generate a concise summary.
77
- *
78
- * @param client - The LLM client
79
- * @param settings - Current settings
80
- * @param messages - The conversation history to summarize
81
- * @param customInstructions - Optional custom instructions for what to preserve
82
- * @returns A summary string to use as context for a new conversation
83
- */
84
- export declare function summarizeConversation(client: LLMClient, settings: Settings, messages: AnthropicMessage[], customInstructions?: string): Promise<string>;
85
- /**
86
- * Generate an AI-based title for a conversation.
87
- * Uses the LLM to create a concise, descriptive title based on the conversation content.
88
- *
89
- * @param client - The LLM client
90
- * @param settings - Current settings
91
- * @param messages - The conversation messages (ChatMessage format)
92
- * @returns A short title string, or null if generation fails
93
- */
94
- export declare function generateAITitle(client: LLMClient, settings: Settings, messages: Array<{
95
- role: string;
96
- content: string;
97
- }>): Promise<string | null>;
98
- export {};
99
- //# sourceMappingURL=assistant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assistant.d.ts","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAY,MAAM,eAAe,CAAC;AACnD,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKhD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;A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CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAC/B,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,IAAI,CAAC,CA2ClD;AAkID;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAOD;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACjD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA2DxB"}
package/dist/assistant.js DELETED
@@ -1,974 +0,0 @@
1
- import { Provider } from './settings.js';
2
- import { TOOLS_ANTHROPIC, TOOLS_OPENAI, handleToolCall, checkCommand, allCategoriesApproved, } from './tools.js';
3
- import { Colors, color } from './utils.js';
4
- import { resolveAzureDeployment } from './providers.js';
5
- import { ModelRegistry } from './models.js';
6
- import { loadCredentials } from './auth.js';
7
- const SYSTEM_PROMPT = `You are an expert deployment assistant for Orca, a workflow automation application.
8
-
9
- ## Your Role
10
- Help users install, configure, diagnose, and resolve deployment issues. You have FULL access to:
11
- - Run shell commands (curl, docker, docker compose, etc.)
12
- - Docker containers, logs, and configuration
13
- - Deployment files (docker-compose.yml, .env template)
14
- - The main application database (read-only SQL)
15
- - Management scripts via docker exec
16
-
17
- ## Capabilities
18
- You CAN and SHOULD:
19
- - Authenticate with GHCR to pull Orca images
20
- - Run docker compose commands (up, down, pull, restart)
21
- - Edit configuration files
22
- - Execute any shell command needed to help the user
23
-
24
- Note: Potentially dangerous commands (rm, git reset --hard, docker rm, etc.) will prompt the user for confirmation before execution. The user can approve individual commands or allow entire categories for the session.
25
-
26
- ## Fresh Installation
27
- When a user asks to "install" Orca on a fresh machine:
28
- 1. Check prerequisites: Docker and Docker Compose must be installed
29
- 2. Authenticate with GHCR using the docker_login_ghcr tool (REQUIRED before pulling images)
30
- 3. Download deployment files using the download_deployment_files tool (specify target directory like ~/orca or /opt/orca)
31
- 4. Configure .env file:
32
- - Copy .env.example to .env
33
- - Auto-generate FLASK_SECRET_KEY using: python3 -c "import secrets; print(secrets.token_hex(32))"
34
- - Auto-detect PUID (host user ID): id -u
35
- - Auto-detect PGID (host group ID): id -g
36
- - Auto-detect DOCKER_GID (cross-platform): stat -c '%g' /var/run/docker.sock 2>/dev/null || stat -f '%g' /var/run/docker.sock 2>/dev/null || echo "Could not detect docker GID"
37
- - Auto-detect GUNICORN_WORKERS (2 per CPU core, min 2, max 12): CORES=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2); WORKERS=$((CORES * 2)); [ $WORKERS -lt 2 ] && WORKERS=2; [ $WORKERS -gt 12 ] && WORKERS=12; echo $WORKERS
38
- IMPORTANT: PUID and PGID are critical for avoiding permission issues. They must match the host user running Docker.
39
- 5. cd to deployment directory and run: docker compose pull
40
- 6. Start services: docker compose up -d
41
- 7. Wait for services to become healthy
42
- 8. Configure CORS for LAN access (see below)
43
- 9. **IMPORTANT**: After successful installation, use the save_deployment_dir tool to save the deployment directory path for future updates
44
-
45
- IMPORTANT: The user must run /token BEFORE installation to authenticate with the server.
46
- If GHCR authentication or deployment file download fails, tell the user to run /token first.
47
-
48
- ## CORS Configuration for LAN Access
49
- ALWAYS configure CORS at the end of installation:
50
- 1. Auto-detect the server's IP (cross-platform): hostname -I 2>/dev/null | awk '{print $1}' || ipconfig getifaddr en0 2>/dev/null || echo "IP detection failed - ask user"
51
- 2. Read current cors_origins.json from the deployment directory
52
- 3. Add both http:// and https:// origins for the detected IP (if not already present)
53
- 4. Write the updated cors_origins.json
54
- 5. Restart the backend: docker compose restart backend
55
- 6. Display access URLs to the user:
56
- - Local: http://localhost and https://localhost
57
- - LAN: http://<detected-ip> and https://<detected-ip>
58
-
59
- ## Container Discovery
60
- IMPORTANT: Never assume container names. Always discover them dynamically:
61
- \`\`\`
62
- docker ps --filter "name=orca-" --format "{{.Names}}"
63
- \`\`\`
64
-
65
- Typical containers (names may vary):
66
- - Backend: Flask app (port 5000)
67
- - Frontend: Nginx/React (ports 80/443)
68
- - Redis: Caching
69
- - Sandbox containers: Per-org Python sandboxes (dynamic)
70
- - Runtime data containers: Per-org PostgreSQL (dynamic)
71
-
72
- ## Running Management Scripts
73
- Use docker exec with the discovered backend container name:
74
- \`\`\`
75
- docker exec <backend-container> python -m backend.scripts.manage_users --list
76
- docker exec <backend-container> python -m backend.scripts.manage_api_keys --list-orgs
77
- \`\`\`
78
-
79
- ## Creating Users
80
- IMPORTANT: When creating users with manage_users.py:
81
- 1. ALWAYS use the org_id from check_auth_status tool (e.g., "org-syntero")
82
- 2. Use simple alphanumeric passwords (letters and numbers only, no special characters)
83
- - GOOD: 'SecurePass123', 'Admin2026xyz'
84
- - BAD: Generated passwords with special chars like '-' or '_' can cause shell expansion issues
85
- 3. **FIRST USER MUST BE super_admin** - Always use --role super_admin for the first user
86
-
87
- Example (first user during installation):
88
- \`\`\`
89
- docker exec <backend-container> python -m backend.scripts.manage_users \\
90
- --email admin@example.com --password 'SecurePass123' --name 'Admin' \\
91
- --org-id <org_id_from_check_auth_status> --org-name "Organization Name" \\
92
- --role super_admin
93
- \`\`\`
94
- This ensures:
95
- - The sandbox container name (orca-sandbox-{org_id}) matches correctly for sync
96
- - The password is stored correctly without shell interpolation issues
97
- - The first user has full admin privileges to manage the system
98
-
99
- ## Post-Installation Steps (IMPORTANT)
100
- After creating the super admin user, guide them through these steps:
101
-
102
- 1. **Log in to Orca** at https://localhost or https://<server-ip> with the super admin credentials
103
- 2. **Navigate to Super Admin Dashboard**: Click the user menu → "Super Admin"
104
- 3. **Create organization containers**: In the Workspaces Manager, find the organization row and click "Create Containers" (or "Recreate Containers" if they exist)
105
- 4. **Wait for containers to be ready**: The system creates:
106
- - \`orca-sandbox-{org_id}\` - Python execution sandbox
107
- - \`orca-runtime-data-{org_id}\` - PostgreSQL database for data_store
108
-
109
- **Why this is required:**
110
- - The CLI sync command needs a running sandbox container to write solution files to \`/workspace/library/\`
111
- - Without these containers, the sync will fail with "container not found" or permission errors
112
- - Each organization gets isolated containers with their own workspace volume
113
-
114
- **Verify containers exist:**
115
- \`\`\`
116
- docker ps --filter "name=orca-sandbox-" --filter "name=orca-runtime-data-"
117
- \`\`\`
118
-
119
- Only after containers are running can the user sync solutions using the CLI sync command.
120
-
121
- ## Common Issues
122
- - Backend crash loops: Check logs for database/migration errors
123
- - Missing tables: Usually migration issues
124
- - Permission errors: UID/GID mismatches
125
- - Network issues: Check cors_origins.json and orca-network
126
-
127
- ## Guidelines
128
- 1. Discover container names first with docker ps
129
- 2. Start with container status and logs
130
- 3. Use inspect_env (not read_file) for .env
131
- 4. Explain issues clearly with fix steps
132
- 5. Be thorough but concise
133
-
134
- ## Updating Installation
135
- When a user asks to "update" Orca:
136
-
137
- 1. First, use the get_deployment_dir tool to find where Orca is installed
138
- 2. If the deployment directory is not found, ask the user for the path
139
- 3. Once you have the path, cd to that directory and run these steps:
140
- a. docker rm -f orca-sandbox-keeper 2>/dev/null (remove sandbox keeper if running)
141
- b. docker compose up -d --pull always --force-recreate --remove-orphans (pull stable images and force-recreate containers)
142
- c. Wait for all services to be healthy by checking: docker ps --filter "name=orca-"
143
- d. docker system prune -af (clean up old images)
144
- e. Use rebuild_all_sandboxes to rebuild sandbox containers with the new image
145
- 4. If the deployment directory was provided by the user (not from settings), save it using save_deployment_dir tool for future updates
146
-
147
- ## Post-Update Container Management
148
- After updating (docker compose up -d --pull always), sandbox containers still run the OLD image.
149
- You MUST rebuild or recreate containers to pick up the new image:
150
-
151
- - **rebuild_all_sandboxes**: Pulls latest sandbox image and rebuilds all sandbox containers.
152
- Preserves workspace volumes (user data). Use this for routine updates.
153
- - **recreate_all_containers**: Removes ALL containers (sandbox, runtime-data, neo4j) for every
154
- org, then creates them fresh. Preserves volumes. Use this when a major update requires
155
- fresh containers for all types, not just sandboxes.
156
-
157
- Both tools require cloud authentication (/token). Always use rebuild_all_sandboxes first.
158
- Only use recreate_all_containers if instructed or if rebuild alone didn't resolve issues.
159
-
160
- ## Troubleshooting Guide
161
- IMPORTANT: After downloading deployment files, ALWAYS read TROUBLESHOOTING.md first:
162
- \`\`\`
163
- grep_file({ pattern: ".", path: "TROUBLESHOOTING.md", context_lines: 0 })
164
- \`\`\`
165
- This document contains critical guidance for installation and common issues.
166
-
167
- When diagnosing issues:
168
- 1. Search TROUBLESHOOTING.md for error messages or symptoms
169
- 2. Example: grep_file({ pattern: "502", path: "TROUBLESHOOTING.md", context_lines: 20 })
170
- 3. Follow documented solutions before attempting custom fixes
171
-
172
- ## Critical Behaviors (MUST FOLLOW)
173
- 1. **NEVER ask users to run commands you can run yourself** - You have full shell access
174
- 2. **VERIFY each step before proceeding**:
175
- - After "docker compose up -d", ALWAYS run: docker ps --filter "name=orca-"
176
- - If no containers shown, run "docker compose ps -a" and check logs
177
- - Don't configure CORS until containers are verified running
178
- 3. **Wait for async operations** - docker compose up may still be pulling images
179
- 4. **Don't restart non-existent containers** - Verify containers exist first with docker ps
180
- 5. **Act, don't over-explain** - Fix issues directly instead of theorizing
181
- 6. **Always call save_deployment_dir** after successful installation
182
- `;
183
- /**
184
- * Add cache_control to the last content block of the last message.
185
- * This enables incremental conversation caching for Anthropic - each API call
186
- * caches the conversation history up to the last message, so subsequent calls
187
- * can read the cached prefix instead of re-processing it.
188
- *
189
- * @param messages - List of conversation messages
190
- * @returns Deep copy of messages with cache_control added to last content block
191
- */
192
- function addMessageCacheControl(messages) {
193
- if (messages.length === 0) {
194
- return messages;
195
- }
196
- // Deep copy to avoid mutating the original
197
- const messagesCopy = JSON.parse(JSON.stringify(messages));
198
- // Get the last message
199
- const lastMessage = messagesCopy[messagesCopy.length - 1];
200
- const content = lastMessage.content;
201
- if (content === undefined || content === null) {
202
- return messagesCopy;
203
- }
204
- // Content can be a string or a list of content blocks
205
- if (typeof content === 'string') {
206
- // Convert string to content block format with cache_control
207
- lastMessage.content = [
208
- { type: 'text', text: content, cache_control: { type: 'ephemeral' } },
209
- ];
210
- }
211
- else if (Array.isArray(content) && content.length > 0) {
212
- // Add cache_control to the last content block
213
- const lastBlock = content[content.length - 1];
214
- lastBlock.cache_control = { type: 'ephemeral' };
215
- }
216
- return messagesCopy;
217
- }
218
- /**
219
- * Add cache_control to the last tool definition.
220
- * This allows Anthropic to cache the entire tool definitions array.
221
- *
222
- * @param tools - Array of tool definitions
223
- * @returns Copy of tools with cache_control on the last tool
224
- */
225
- function addToolsCacheControl(tools) {
226
- if (tools.length === 0) {
227
- return tools;
228
- }
229
- // Shallow copy the array, deep copy only the last tool
230
- const toolsCopy = [...tools];
231
- toolsCopy[toolsCopy.length - 1] = {
232
- ...toolsCopy[toolsCopy.length - 1],
233
- cache_control: { type: 'ephemeral' },
234
- };
235
- return toolsCopy;
236
- }
237
- /**
238
- * Resolve the OpenAI/Azure model name and registry ID.
239
- */
240
- function resolveOpenAIModel(settings, isAzure) {
241
- if (isAzure) {
242
- const modelIdForRegistry = settings.azure.deployment;
243
- const creds = loadCredentials();
244
- const model = creds?.llm
245
- ? resolveAzureDeployment(settings.azure.deployment, creds.llm)
246
- : settings.azure.deployment;
247
- return { model, modelIdForRegistry };
248
- }
249
- return { model: settings.openai.model, modelIdForRegistry: settings.openai.model };
250
- }
251
- /**
252
- * Convert Anthropic message history to OpenAI message format.
253
- */
254
- function convertMessagesToOpenAI(messages) {
255
- const openaiMessages = [{ role: 'system', content: SYSTEM_PROMPT }];
256
- for (const msg of messages) {
257
- if (msg.role === 'user') {
258
- if (Array.isArray(msg.content)) {
259
- for (const item of msg.content) {
260
- if (item.type === 'tool_result') {
261
- openaiMessages.push({
262
- role: 'tool',
263
- tool_call_id: item.tool_use_id || '',
264
- content: item.content || '',
265
- });
266
- }
267
- }
268
- }
269
- else {
270
- openaiMessages.push({ role: 'user', content: msg.content });
271
- }
272
- }
273
- else if (msg.role === 'assistant') {
274
- if (Array.isArray(msg.content)) {
275
- const toolCallsArr = [];
276
- let textContent = '';
277
- for (const item of msg.content) {
278
- if (item.type === 'text') {
279
- textContent = item.text || '';
280
- }
281
- else if (item.type === 'tool_use') {
282
- toolCallsArr.push({
283
- id: item.id || '',
284
- type: 'function',
285
- function: {
286
- name: item.name || '',
287
- arguments: JSON.stringify(item.input || {}),
288
- },
289
- });
290
- }
291
- }
292
- const assistantMsg = {
293
- role: 'assistant',
294
- content: textContent || null,
295
- };
296
- if (toolCallsArr.length > 0) {
297
- assistantMsg.tool_calls = toolCallsArr;
298
- }
299
- openaiMessages.push(assistantMsg);
300
- }
301
- }
302
- }
303
- return openaiMessages;
304
- }
305
- /**
306
- * Execute tool calls: display headers, check dangerous commands, run tools, collect results.
307
- */
308
- async function* executeToolCalls(toolCalls, confirmCommand, approvedCategories) {
309
- const anthropicResults = [];
310
- const openaiResults = [];
311
- for (const tc of toolCalls) {
312
- const input = tc.input;
313
- // Show tool header
314
- if (tc.name === 'run_command') {
315
- yield color(`\n\n[${tc.name}] `, Colors.dim);
316
- yield color(`${input.command}\n`, Colors.cyan);
317
- if (input.gist) {
318
- yield color(`${input.gist}\n`, Colors.dim);
319
- }
320
- }
321
- else {
322
- yield color(`\n\n[${tc.name}]\n`, Colors.dim);
323
- }
324
- let result;
325
- if (tc.name === 'run_command' && confirmCommand) {
326
- const command = input.command;
327
- const gist = input.gist;
328
- const dangerCheck = checkCommand(command);
329
- if (dangerCheck.isDangerous && !allCategoriesApproved(dangerCheck, approvedCategories || new Set())) {
330
- yield color(`Dangerous command detected. Waiting for confirmation...\n`, Colors.yellow);
331
- const confirmResult = await confirmCommand(command, dangerCheck, gist);
332
- if (!confirmResult.confirmed) {
333
- result = 'Command cancelled by user.';
334
- yield color(`${result}\n`, Colors.dim);
335
- }
336
- else {
337
- result = await handleToolCall(tc.name, tc.input);
338
- const preview = result.length > 500 ? result.slice(0, 500) + '...' : result;
339
- yield color(`${preview}\n`, Colors.dim);
340
- }
341
- }
342
- else {
343
- result = await handleToolCall(tc.name, tc.input);
344
- const preview = result.length > 500 ? result.slice(0, 500) + '...' : result;
345
- yield color(`${preview}\n`, Colors.dim);
346
- }
347
- }
348
- else {
349
- result = await handleToolCall(tc.name, tc.input);
350
- const preview = result.length > 500 ? result.slice(0, 500) + '...' : result;
351
- yield color(`${preview}\n`, Colors.dim);
352
- }
353
- anthropicResults.push({
354
- type: 'tool_result',
355
- tool_use_id: tc.id,
356
- content: result,
357
- });
358
- openaiResults.push({
359
- tool_call_id: tc.id,
360
- content: result,
361
- });
362
- }
363
- return { anthropicResults, openaiResults };
364
- }
365
- /**
366
- * Inject a queued user message into conversation history.
367
- */
368
- function* injectQueuedMessage(msg, messages, openaiMessages) {
369
- const injectedContent = `[User update while AI was working]: ${msg}`;
370
- messages.push({ role: 'user', content: injectedContent });
371
- if (openaiMessages) {
372
- openaiMessages.push({ role: 'user', content: injectedContent });
373
- }
374
- yield color(`\n[Queued message injected: "${msg.length > 50 ? msg.slice(0, 50) + '...' : msg}"]\n`, Colors.dim);
375
- }
376
- /**
377
- * Run assistant with Anthropic API with streaming.
378
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
379
- * @param confirmCommand - Optional callback to confirm dangerous commands
380
- * @param approvedCategories - Set of command categories approved for the session
381
- */
382
- export async function* runAssistantAnthropic(client, settings, userMessage, messages, signal, getQueuedMessage, confirmCommand, approvedCategories) {
383
- messages.push({ role: 'user', content: userMessage });
384
- while (true) {
385
- // Check for queued messages at the start of each iteration
386
- const queuedMessage = getQueuedMessage?.();
387
- if (queuedMessage) {
388
- yield* injectQueuedMessage(queuedMessage, messages);
389
- }
390
- let responseText = '';
391
- const toolCalls = [];
392
- // Anthropic prompt caching: Add cache_control markers to reduce token costs
393
- const cachedSystem = [
394
- { type: 'text', text: SYSTEM_PROMPT, cache_control: { type: 'ephemeral' } },
395
- ];
396
- const cachedTools = addToolsCacheControl(TOOLS_ANTHROPIC);
397
- const cachedMessages = addMessageCacheControl(messages);
398
- const stream = client.messages.stream({
399
- model: settings.anthropic.model,
400
- max_tokens: 8192,
401
- system: cachedSystem,
402
- tools: cachedTools,
403
- messages: cachedMessages,
404
- }, { signal });
405
- for await (const event of stream) {
406
- if (event.type === 'content_block_start') {
407
- const contentBlock = event.content_block;
408
- if (contentBlock?.type === 'tool_use') {
409
- toolCalls.push({
410
- id: contentBlock.id || '',
411
- name: contentBlock.name || '',
412
- input: '',
413
- });
414
- }
415
- }
416
- else if (event.type === 'content_block_delta') {
417
- const delta = event.delta;
418
- if (delta?.type === 'text_delta' && delta.text) {
419
- yield delta.text;
420
- responseText += delta.text;
421
- }
422
- else if (delta?.type === 'input_json_delta' && delta.partial_json && toolCalls.length > 0) {
423
- toolCalls[toolCalls.length - 1].input += delta.partial_json;
424
- }
425
- }
426
- }
427
- const finalMessage = await stream.finalMessage();
428
- // Build assistant content
429
- const assistantContent = [];
430
- if (responseText) {
431
- assistantContent.push({ type: 'text', text: responseText });
432
- }
433
- for (const tc of toolCalls) {
434
- try {
435
- tc.input = tc.input ? JSON.parse(tc.input) : {};
436
- }
437
- catch {
438
- tc.input = {};
439
- }
440
- assistantContent.push({
441
- type: 'tool_use',
442
- id: tc.id,
443
- name: tc.name,
444
- input: tc.input,
445
- });
446
- }
447
- messages.push({ role: 'assistant', content: assistantContent });
448
- if (finalMessage.stop_reason === 'tool_use') {
449
- const { anthropicResults } = yield* executeToolCalls(toolCalls, confirmCommand, approvedCategories);
450
- messages.push({ role: 'user', content: anthropicResults });
451
- }
452
- else {
453
- break;
454
- }
455
- }
456
- return messages;
457
- }
458
- /**
459
- * Run assistant with Anthropic API without streaming.
460
- * Fetches complete responses in a single request to eliminate screen jitter.
461
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
462
- * @param confirmCommand - Optional callback to confirm dangerous commands
463
- * @param approvedCategories - Set of command categories approved for the session
464
- */
465
- export async function* runAssistantAnthropicNonStreaming(client, settings, userMessage, messages, signal, getQueuedMessage, confirmCommand, approvedCategories) {
466
- messages.push({ role: 'user', content: userMessage });
467
- while (true) {
468
- // Check for queued messages at the start of each iteration
469
- const queuedMessage = getQueuedMessage?.();
470
- if (queuedMessage) {
471
- yield* injectQueuedMessage(queuedMessage, messages);
472
- }
473
- // Anthropic prompt caching: Add cache_control markers to reduce token costs
474
- const cachedSystem = [
475
- { type: 'text', text: SYSTEM_PROMPT, cache_control: { type: 'ephemeral' } },
476
- ];
477
- const cachedTools = addToolsCacheControl(TOOLS_ANTHROPIC);
478
- const cachedMessages = addMessageCacheControl(messages);
479
- // Make non-streaming API call
480
- const response = await client.messages.create({
481
- model: settings.anthropic.model,
482
- max_tokens: 8192,
483
- system: cachedSystem,
484
- tools: cachedTools,
485
- messages: cachedMessages,
486
- }, { signal });
487
- // Extract text and tool calls from response
488
- let responseText = '';
489
- const toolCalls = [];
490
- for (const block of response.content) {
491
- if (block.type === 'text') {
492
- responseText = block.text;
493
- }
494
- else if (block.type === 'tool_use') {
495
- toolCalls.push({
496
- id: block.id,
497
- name: block.name,
498
- input: block.input,
499
- });
500
- }
501
- }
502
- // Yield the complete response text at once
503
- if (responseText) {
504
- yield responseText;
505
- }
506
- // Build assistant content
507
- const assistantContent = [];
508
- if (responseText) {
509
- assistantContent.push({ type: 'text', text: responseText });
510
- }
511
- for (const tc of toolCalls) {
512
- assistantContent.push({
513
- type: 'tool_use',
514
- id: tc.id,
515
- name: tc.name,
516
- input: tc.input,
517
- });
518
- }
519
- messages.push({ role: 'assistant', content: assistantContent });
520
- if (response.stop_reason === 'tool_use') {
521
- const { anthropicResults } = yield* executeToolCalls(toolCalls, confirmCommand, approvedCategories);
522
- messages.push({ role: 'user', content: anthropicResults });
523
- }
524
- else {
525
- break;
526
- }
527
- }
528
- return messages;
529
- }
530
- /**
531
- * Run assistant with OpenAI/Azure API with streaming.
532
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
533
- * @param confirmCommand - Optional callback to confirm dangerous commands
534
- * @param approvedCategories - Set of command categories approved for the session
535
- */
536
- export async function* runAssistantOpenAI(client, settings, userMessage, messages, isAzure = false, signal, getQueuedMessage, confirmCommand, approvedCategories) {
537
- const { model, modelIdForRegistry } = resolveOpenAIModel(settings, isAzure);
538
- const openaiMessages = convertMessagesToOpenAI(messages);
539
- openaiMessages.push({ role: 'user', content: userMessage });
540
- messages.push({ role: 'user', content: userMessage });
541
- while (true) {
542
- // Check for queued messages at the start of each iteration
543
- const queuedMessage = getQueuedMessage?.();
544
- if (queuedMessage) {
545
- yield* injectQueuedMessage(queuedMessage, messages, openaiMessages);
546
- }
547
- let responseText = '';
548
- const toolCalls = {};
549
- let currentToolId = null;
550
- // Build request options with dynamic max_tokens parameter based on model ID (not deployment name)
551
- const maxTokensParam = ModelRegistry.getMaxTokensParam(modelIdForRegistry);
552
- const maxTokensValue = ModelRegistry.getMaxTokens(modelIdForRegistry);
553
- // Use type assertion through unknown to handle dynamic property names
554
- const baseOptions = {
555
- model,
556
- messages: openaiMessages,
557
- tools: TOOLS_OPENAI,
558
- stream: true,
559
- };
560
- const streamOptions = maxTokensParam === 'max_completion_tokens'
561
- ? { ...baseOptions, max_completion_tokens: maxTokensValue }
562
- : { ...baseOptions, max_tokens: maxTokensValue };
563
- const stream = await client.chat.completions.create(streamOptions, { signal });
564
- let finishReason = null;
565
- for await (const chunk of stream) {
566
- const delta = chunk.choices[0]?.delta;
567
- finishReason = chunk.choices[0]?.finish_reason || null;
568
- if (delta) {
569
- if (delta.content) {
570
- yield delta.content;
571
- responseText += delta.content;
572
- }
573
- if (delta.tool_calls) {
574
- for (const tc of delta.tool_calls) {
575
- if (tc.id) {
576
- currentToolId = tc.id;
577
- toolCalls[currentToolId] = {
578
- id: tc.id,
579
- name: tc.function?.name || '',
580
- input: '',
581
- };
582
- }
583
- if (tc.function?.arguments && currentToolId) {
584
- toolCalls[currentToolId].input += tc.function.arguments;
585
- }
586
- }
587
- }
588
- }
589
- }
590
- // Build assistant message
591
- const assistantContent = [];
592
- if (responseText) {
593
- assistantContent.push({ type: 'text', text: responseText });
594
- }
595
- const openaiAssistantMsg = {
596
- role: 'assistant',
597
- content: responseText || null,
598
- };
599
- if (Object.keys(toolCalls).length > 0) {
600
- openaiAssistantMsg.tool_calls = Object.values(toolCalls).map((tc) => ({
601
- id: tc.id,
602
- type: 'function',
603
- function: {
604
- name: tc.name,
605
- arguments: tc.input,
606
- },
607
- }));
608
- for (const tc of Object.values(toolCalls)) {
609
- try {
610
- tc.input = tc.input ? JSON.parse(tc.input) : {};
611
- }
612
- catch {
613
- tc.input = {};
614
- }
615
- assistantContent.push({
616
- type: 'tool_use',
617
- id: tc.id,
618
- name: tc.name,
619
- input: tc.input,
620
- });
621
- }
622
- }
623
- openaiMessages.push(openaiAssistantMsg);
624
- messages.push({ role: 'assistant', content: assistantContent });
625
- if (finishReason === 'tool_calls' && Object.keys(toolCalls).length > 0) {
626
- const { anthropicResults, openaiResults } = yield* executeToolCalls(Object.values(toolCalls), confirmCommand, approvedCategories);
627
- for (const r of openaiResults) {
628
- openaiMessages.push({ role: 'tool', tool_call_id: r.tool_call_id, content: r.content });
629
- }
630
- messages.push({ role: 'user', content: anthropicResults });
631
- }
632
- else {
633
- break;
634
- }
635
- }
636
- return messages;
637
- }
638
- /**
639
- * Run assistant with OpenAI/Azure API without streaming.
640
- * Fetches complete responses in a single request to eliminate screen jitter.
641
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
642
- * @param confirmCommand - Optional callback to confirm dangerous commands
643
- * @param approvedCategories - Set of command categories approved for the session
644
- */
645
- export async function* runAssistantOpenAINonStreaming(client, settings, userMessage, messages, isAzure = false, signal, getQueuedMessage, confirmCommand, approvedCategories) {
646
- const { model, modelIdForRegistry } = resolveOpenAIModel(settings, isAzure);
647
- const openaiMessages = convertMessagesToOpenAI(messages);
648
- openaiMessages.push({ role: 'user', content: userMessage });
649
- messages.push({ role: 'user', content: userMessage });
650
- while (true) {
651
- // Check for queued messages at the start of each iteration
652
- const queuedMessage = getQueuedMessage?.();
653
- if (queuedMessage) {
654
- yield* injectQueuedMessage(queuedMessage, messages, openaiMessages);
655
- }
656
- // Build request options with dynamic max_tokens parameter based on model ID (not deployment name)
657
- const maxTokensParam = ModelRegistry.getMaxTokensParam(modelIdForRegistry);
658
- const maxTokensValue = ModelRegistry.getMaxTokens(modelIdForRegistry);
659
- // Non-streaming request - no stream option
660
- const baseOptions = {
661
- model,
662
- messages: openaiMessages,
663
- tools: TOOLS_OPENAI,
664
- };
665
- const requestOptions = maxTokensParam === 'max_completion_tokens'
666
- ? { ...baseOptions, max_completion_tokens: maxTokensValue }
667
- : { ...baseOptions, max_tokens: maxTokensValue };
668
- const response = await client.chat.completions.create(requestOptions, { signal });
669
- const choice = response.choices[0];
670
- const responseText = choice?.message?.content || '';
671
- const toolCallsResponse = choice?.message?.tool_calls || [];
672
- const finishReason = choice?.finish_reason || null;
673
- // Yield the complete response text at once
674
- if (responseText) {
675
- yield responseText;
676
- }
677
- // Build assistant message
678
- const assistantContent = [];
679
- if (responseText) {
680
- assistantContent.push({ type: 'text', text: responseText });
681
- }
682
- const openaiAssistantMsg = {
683
- role: 'assistant',
684
- content: responseText || null,
685
- };
686
- const toolCalls = {};
687
- // Filter for function-type tool calls only
688
- const functionToolCalls = toolCallsResponse.filter(tc => tc.type === 'function');
689
- if (functionToolCalls.length > 0) {
690
- openaiAssistantMsg.tool_calls = functionToolCalls.map((tc) => ({
691
- id: tc.id,
692
- type: 'function',
693
- function: {
694
- name: tc.function.name,
695
- arguments: tc.function.arguments,
696
- },
697
- }));
698
- for (const tc of functionToolCalls) {
699
- const funcTc = tc;
700
- let parsedInput;
701
- try {
702
- parsedInput = funcTc.function.arguments ? JSON.parse(funcTc.function.arguments) : {};
703
- }
704
- catch {
705
- parsedInput = {};
706
- }
707
- toolCalls[funcTc.id] = {
708
- id: funcTc.id,
709
- name: funcTc.function.name,
710
- input: parsedInput,
711
- };
712
- assistantContent.push({
713
- type: 'tool_use',
714
- id: funcTc.id,
715
- name: funcTc.function.name,
716
- input: parsedInput,
717
- });
718
- }
719
- }
720
- openaiMessages.push(openaiAssistantMsg);
721
- messages.push({ role: 'assistant', content: assistantContent });
722
- if (finishReason === 'tool_calls' && Object.keys(toolCalls).length > 0) {
723
- const { anthropicResults, openaiResults } = yield* executeToolCalls(Object.values(toolCalls), confirmCommand, approvedCategories);
724
- for (const r of openaiResults) {
725
- openaiMessages.push({ role: 'tool', tool_call_id: r.tool_call_id, content: r.content });
726
- }
727
- messages.push({ role: 'user', content: anthropicResults });
728
- }
729
- else {
730
- break;
731
- }
732
- }
733
- return messages;
734
- }
735
- /**
736
- * Run the assistant with the appropriate provider.
737
- * @param getQueuedMessage - Optional callback to check for queued messages at each iteration
738
- * @param confirmCommand - Optional callback to confirm dangerous commands
739
- * @param approvedCategories - Set of command categories approved for the session
740
- */
741
- export async function* runAssistant(client, settings, userMessage, messages = [], signal, getQueuedMessage, confirmCommand, approvedCategories) {
742
- // Choose streaming or non-streaming based on settings
743
- const useStreaming = settings.streaming !== false; // Default to true
744
- if (settings.provider === Provider.ANTHROPIC) {
745
- if (useStreaming) {
746
- return yield* runAssistantAnthropic(client, settings, userMessage, messages, signal, getQueuedMessage, confirmCommand, approvedCategories);
747
- }
748
- else {
749
- return yield* runAssistantAnthropicNonStreaming(client, settings, userMessage, messages, signal, getQueuedMessage, confirmCommand, approvedCategories);
750
- }
751
- }
752
- else if (settings.provider === Provider.OPENAI) {
753
- if (useStreaming) {
754
- return yield* runAssistantOpenAI(client, settings, userMessage, messages, false, signal, getQueuedMessage, confirmCommand, approvedCategories);
755
- }
756
- else {
757
- return yield* runAssistantOpenAINonStreaming(client, settings, userMessage, messages, false, signal, getQueuedMessage, confirmCommand, approvedCategories);
758
- }
759
- }
760
- else if (settings.provider === Provider.AZURE) {
761
- if (useStreaming) {
762
- return yield* runAssistantOpenAI(client, settings, userMessage, messages, true, signal, getQueuedMessage, confirmCommand, approvedCategories);
763
- }
764
- else {
765
- return yield* runAssistantOpenAINonStreaming(client, settings, userMessage, messages, true, signal, getQueuedMessage, confirmCommand, approvedCategories);
766
- }
767
- }
768
- throw new Error(`Unknown provider: ${settings.provider}`);
769
- }
770
- /**
771
- * System prompt for conversation summarization.
772
- * Instructs the model to create a concise but comprehensive summary.
773
- */
774
- const SUMMARIZATION_PROMPT = `You are a conversation summarizer. Create a comprehensive summary of a deployment troubleshooting conversation that preserves essential context for continuing the work.
775
-
776
- Capture with high fidelity:
777
- 1. **Architectural Decisions**: Any design choices or configuration decisions made
778
- 2. **Unresolved Issues**: Bugs, errors, or problems still pending
779
- 3. **Key Findings**: Important discoveries during troubleshooting (specific error messages, root causes)
780
- 4. **Implementation Details**: Commands that worked, configuration values, container names
781
- 5. **Current State**: What is working, what is not
782
- 6. **Next Steps**: Any planned actions or recommendations
783
-
784
- Guidelines:
785
- - Aim for 12-20% of the original conversation size
786
- - Preserve specific technical details (container names, error messages, config values)
787
- - Remove redundant tool outputs and repetitive exchanges
788
- - Keep context needed to continue troubleshooting without re-discovering information
789
- - Use structured format with clear sections
790
-
791
- Respond with ONLY the summary.`;
792
- /**
793
- * Extract readable text from conversation history for summarization.
794
- */
795
- function conversationToText(messages) {
796
- const parts = [];
797
- for (const msg of messages) {
798
- const role = msg.role === 'user' ? 'User' : 'Assistant';
799
- let content = '';
800
- if (typeof msg.content === 'string') {
801
- content = msg.content;
802
- }
803
- else if (Array.isArray(msg.content)) {
804
- const textParts = [];
805
- for (const block of msg.content) {
806
- if (block.type === 'text' && block.text) {
807
- textParts.push(block.text);
808
- }
809
- else if (block.type === 'tool_use' && block.name) {
810
- textParts.push(`[Used tool: ${block.name}]`);
811
- }
812
- else if (block.type === 'tool_result' && block.content) {
813
- // Truncate long tool results
814
- const resultPreview = block.content.length > 500
815
- ? block.content.slice(0, 500) + '...(truncated)'
816
- : block.content;
817
- textParts.push(`[Tool result: ${resultPreview}]`);
818
- }
819
- }
820
- content = textParts.join('\n');
821
- }
822
- if (content.trim()) {
823
- parts.push(`${role}: ${content}`);
824
- }
825
- }
826
- return parts.join('\n\n---\n\n');
827
- }
828
- /**
829
- * Summarize a conversation using the Anthropic API.
830
- */
831
- async function summarizeWithAnthropic(client, settings, conversationText) {
832
- // Cache the system prompt for Anthropic (reduces token costs on repeated summarizations)
833
- const cachedSystem = [
834
- { type: 'text', text: SUMMARIZATION_PROMPT, cache_control: { type: 'ephemeral' } },
835
- ];
836
- const response = await client.messages.create({
837
- model: settings.anthropic.model,
838
- max_tokens: 2500,
839
- system: cachedSystem,
840
- messages: [
841
- {
842
- role: 'user',
843
- content: `Please summarize the following deployment troubleshooting conversation:\n\n${conversationText}`,
844
- },
845
- ],
846
- });
847
- // Extract text from response
848
- for (const block of response.content) {
849
- if (block.type === 'text') {
850
- return block.text;
851
- }
852
- }
853
- return 'Unable to generate summary.';
854
- }
855
- /**
856
- * Summarize a conversation using the OpenAI/Azure API.
857
- */
858
- async function summarizeWithOpenAI(client, settings, conversationText, isAzure) {
859
- const { model, modelIdForRegistry } = resolveOpenAIModel(settings, isAzure);
860
- // Build request options with dynamic max_tokens parameter based on model ID (not deployment name)
861
- const maxTokensParam = ModelRegistry.getMaxTokensParam(modelIdForRegistry);
862
- const baseOptions = {
863
- model,
864
- messages: [
865
- { role: 'system', content: SUMMARIZATION_PROMPT },
866
- {
867
- role: 'user',
868
- content: `Please summarize the following deployment troubleshooting conversation:\n\n${conversationText}`,
869
- },
870
- ],
871
- };
872
- const requestOptions = maxTokensParam === 'max_completion_tokens'
873
- ? { ...baseOptions, max_completion_tokens: 2500 }
874
- : { ...baseOptions, max_tokens: 2500 };
875
- const response = await client.chat.completions.create(requestOptions);
876
- return response.choices[0]?.message?.content || 'Unable to generate summary.';
877
- }
878
- /**
879
- * Summarize a conversation history.
880
- * Uses the configured LLM provider to generate a concise summary.
881
- *
882
- * @param client - The LLM client
883
- * @param settings - Current settings
884
- * @param messages - The conversation history to summarize
885
- * @param customInstructions - Optional custom instructions for what to preserve
886
- * @returns A summary string to use as context for a new conversation
887
- */
888
- export async function summarizeConversation(client, settings, messages, customInstructions) {
889
- if (messages.length === 0) {
890
- return '';
891
- }
892
- let conversationText = conversationToText(messages);
893
- // Add custom instructions if provided
894
- if (customInstructions) {
895
- conversationText += `\n\n[User's summarization instructions: ${customInstructions}]`;
896
- }
897
- if (settings.provider === Provider.ANTHROPIC) {
898
- return summarizeWithAnthropic(client, settings, conversationText);
899
- }
900
- else if (settings.provider === Provider.OPENAI) {
901
- return summarizeWithOpenAI(client, settings, conversationText, false);
902
- }
903
- else if (settings.provider === Provider.AZURE) {
904
- return summarizeWithOpenAI(client, settings, conversationText, true);
905
- }
906
- throw new Error(`Unknown provider: ${settings.provider}`);
907
- }
908
- /**
909
- * System prompt for generating conversation titles.
910
- */
911
- const TITLE_GENERATION_PROMPT = `Generate a short title (3-6 words) for this conversation. Return only the title, nothing else. No quotes, no punctuation at the end.`;
912
- /**
913
- * Generate an AI-based title for a conversation.
914
- * Uses the LLM to create a concise, descriptive title based on the conversation content.
915
- *
916
- * @param client - The LLM client
917
- * @param settings - Current settings
918
- * @param messages - The conversation messages (ChatMessage format)
919
- * @returns A short title string, or null if generation fails
920
- */
921
- export async function generateAITitle(client, settings, messages) {
922
- try {
923
- // Extract first few messages for context (limit to save tokens)
924
- const relevantMessages = messages
925
- .filter(m => m.role === 'user' || m.role === 'assistant')
926
- .slice(0, 4); // First 2 exchanges max
927
- if (relevantMessages.length === 0) {
928
- return null;
929
- }
930
- // Format messages for the prompt
931
- const conversationSnippet = relevantMessages
932
- .map(m => `${m.role === 'user' ? 'User' : 'Assistant'}: ${m.content.slice(0, 200)}${m.content.length > 200 ? '...' : ''}`)
933
- .join('\n');
934
- const prompt = `${TITLE_GENERATION_PROMPT}\n\nConversation:\n${conversationSnippet}`;
935
- if (settings.provider === Provider.ANTHROPIC) {
936
- const anthropicClient = client;
937
- const response = await anthropicClient.messages.create({
938
- model: settings.anthropic.model,
939
- max_tokens: 50,
940
- messages: [{ role: 'user', content: prompt }],
941
- });
942
- // Extract text from response
943
- for (const block of response.content) {
944
- if (block.type === 'text') {
945
- return block.text.trim();
946
- }
947
- }
948
- }
949
- else if (settings.provider === Provider.OPENAI || settings.provider === Provider.AZURE) {
950
- const openaiClient = client;
951
- const { model, modelIdForRegistry } = resolveOpenAIModel(settings, settings.provider === Provider.AZURE);
952
- // Build request options with dynamic max_tokens parameter based on model ID (not deployment name)
953
- const maxTokensParam = ModelRegistry.getMaxTokensParam(modelIdForRegistry);
954
- const baseOptions = {
955
- model,
956
- messages: [{ role: 'user', content: prompt }],
957
- };
958
- const requestOptions = maxTokensParam === 'max_completion_tokens'
959
- ? { ...baseOptions, max_completion_tokens: 50 }
960
- : { ...baseOptions, max_tokens: 50 };
961
- const response = await openaiClient.chat.completions.create(requestOptions);
962
- const content = response.choices[0]?.message?.content;
963
- if (content) {
964
- return content.trim();
965
- }
966
- }
967
- return null;
968
- }
969
- catch {
970
- // Silently fail - title generation is non-critical
971
- return null;
972
- }
973
- }
974
- //# sourceMappingURL=assistant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assistant.js","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,qBAAqB,GAEtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AA0B5C,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACH,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;YACzF,MAAM,YAAY,GAAG,MAAgB,CAAC;YACtC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC;YAEzG,kGAAkG;YAClG,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;YAC3E,MAAM,WAAW,GAAG;gBAClB,KAAK;gBACL,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;aACvD,CAAC;YACF,MAAM,cAAc,GAAG,cAAc,KAAK,uBAAuB;gBAC/D,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,qBAAqB,EAAE,EAAE,EAAE;gBAC/C,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;YAEvC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAE5E,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;YACtD,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,mDAAmD;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- export interface MultiSelectItem {
3
- id: string;
4
- label: string;
5
- description?: string;
6
- }
7
- interface MultiSelectListProps {
8
- items: MultiSelectItem[];
9
- onConfirm: (selected: string[]) => void;
10
- onBack: () => void;
11
- title?: string;
12
- }
13
- /**
14
- * MultiSelectList - Reusable checkbox-style multi-select component.
15
- *
16
- * Keyboard:
17
- * - Up/Down: navigate
18
- * - Space: toggle item
19
- * - 'a': toggle all
20
- * - Enter: confirm selection
21
- * - Esc: go back
22
- */
23
- export declare function MultiSelectList({ items, onConfirm, onBack, title, }: MultiSelectListProps): React.ReactElement;
24
- export {};
25
- //# sourceMappingURL=MultiSelectList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiSelectList.d.ts","sourceRoot":"","sources":["../../src/components/MultiSelectList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,oBAAoB;IAC5B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACxC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CA4F3C"}
@@ -1,70 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { Box, Text, useInput } from 'ink';
4
- /**
5
- * MultiSelectList - Reusable checkbox-style multi-select component.
6
- *
7
- * Keyboard:
8
- * - Up/Down: navigate
9
- * - Space: toggle item
10
- * - 'a': toggle all
11
- * - Enter: confirm selection
12
- * - Esc: go back
13
- */
14
- export function MultiSelectList({ items, onConfirm, onBack, title, }) {
15
- const [focusIndex, setFocusIndex] = useState(0);
16
- const [selected, setSelected] = useState(new Set());
17
- useInput((input, key) => {
18
- if (key.escape) {
19
- onBack();
20
- return;
21
- }
22
- if (key.upArrow) {
23
- setFocusIndex(prev => (prev > 0 ? prev - 1 : items.length - 1));
24
- return;
25
- }
26
- if (key.downArrow) {
27
- setFocusIndex(prev => (prev < items.length - 1 ? prev + 1 : 0));
28
- return;
29
- }
30
- // Space toggles current item
31
- if (input === ' ') {
32
- const item = items[focusIndex];
33
- if (!item)
34
- return;
35
- setSelected(prev => {
36
- const next = new Set(prev);
37
- if (next.has(item.id)) {
38
- next.delete(item.id);
39
- }
40
- else {
41
- next.add(item.id);
42
- }
43
- return next;
44
- });
45
- return;
46
- }
47
- // 'a' toggles all
48
- if (input === 'a') {
49
- setSelected(prev => {
50
- if (prev.size === items.length) {
51
- return new Set();
52
- }
53
- return new Set(items.map(i => i.id));
54
- });
55
- return;
56
- }
57
- // Enter confirms
58
- if (key.return) {
59
- onConfirm(Array.from(selected));
60
- return;
61
- }
62
- });
63
- return (_jsxs(Box, { flexDirection: "column", children: [title && (_jsx(Box, { marginBottom: 0, children: _jsx(Text, { bold: true, color: "cyan", children: title }) })), items.map((item, index) => {
64
- const isFocused = index === focusIndex;
65
- const isChecked = selected.has(item.id);
66
- const checkbox = isChecked ? '[x]' : '[ ]';
67
- return (_jsx(Box, { children: isFocused ? (_jsxs(Text, { inverse: true, bold: true, children: [' > ', checkbox, " ", item.label] })) : (_jsxs(Text, { children: [' ', checkbox, " ", item.label, item.description && (_jsxs(Text, { dimColor: true, children: [" - ", item.description] }))] })) }, item.id));
68
- }), _jsx(Box, { marginTop: 0, children: _jsxs(Text, { dimColor: true, children: [' ', "Space: toggle, a: toggle all, Enter: confirm (", selected.size, " selected), Esc: back"] }) })] }));
69
- }
70
- //# sourceMappingURL=MultiSelectList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiSelectList.js","sourceRoot":"","sources":["../../src/components/MultiSelectList.ts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