@artyfacts/claude 1.2.6 → 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/dist/index.d.mts +225 -7
- package/dist/index.d.ts +225 -7
- package/dist/index.js +5185 -2
- package/dist/index.mjs +5173 -1
- package/package.json +1 -1
- package/src/executor-with-tools.ts +402 -0
- package/src/index.ts +34 -0
- package/src/tools/api-client.ts +68 -0
- package/src/tools/handlers.ts +460 -0
- package/src/tools/index.ts +30 -0
- package/src/tools/registry.ts +780 -0
- package/src/tools/types.ts +82 -0
package/dist/index.d.mts
CHANGED
|
@@ -63,7 +63,7 @@ declare function getCredentials(options?: {
|
|
|
63
63
|
* Now supports fetching full context (organization, project, artifact, related sections)
|
|
64
64
|
* to provide Claude with the information needed to complete tasks effectively.
|
|
65
65
|
*/
|
|
66
|
-
interface TaskContext {
|
|
66
|
+
interface TaskContext$1 {
|
|
67
67
|
/** Task ID (section ID) */
|
|
68
68
|
taskId: string;
|
|
69
69
|
/** Task heading/title */
|
|
@@ -79,7 +79,7 @@ interface TaskContext {
|
|
|
79
79
|
/** Additional context */
|
|
80
80
|
context?: Record<string, unknown>;
|
|
81
81
|
}
|
|
82
|
-
interface ExecutionResult {
|
|
82
|
+
interface ExecutionResult$1 {
|
|
83
83
|
/** Whether execution was successful */
|
|
84
84
|
success: boolean;
|
|
85
85
|
/** The generated output */
|
|
@@ -91,7 +91,7 @@ interface ExecutionResult {
|
|
|
91
91
|
/** The prompt that was used (for debugging) */
|
|
92
92
|
promptUsed?: string;
|
|
93
93
|
}
|
|
94
|
-
interface ExecutorConfig {
|
|
94
|
+
interface ExecutorConfig$1 {
|
|
95
95
|
/** Path to claude CLI (default: 'claude') */
|
|
96
96
|
claudePath?: string;
|
|
97
97
|
/** Timeout in milliseconds (default: 5 minutes) */
|
|
@@ -108,14 +108,14 @@ interface ExecutorConfig {
|
|
|
108
108
|
declare class ClaudeExecutor {
|
|
109
109
|
private config;
|
|
110
110
|
private contextFetcher;
|
|
111
|
-
constructor(config?: ExecutorConfig);
|
|
111
|
+
constructor(config?: ExecutorConfig$1);
|
|
112
112
|
/**
|
|
113
113
|
* Execute a task using Claude Code CLI
|
|
114
114
|
*
|
|
115
115
|
* If full context is available (baseUrl + apiKey configured), fetches
|
|
116
116
|
* organization, project, artifact, and related sections for a rich prompt.
|
|
117
117
|
*/
|
|
118
|
-
execute(task: TaskContext): Promise<ExecutionResult>;
|
|
118
|
+
execute(task: TaskContext$1): Promise<ExecutionResult$1>;
|
|
119
119
|
/**
|
|
120
120
|
* Run Claude Code CLI with the given prompt
|
|
121
121
|
*/
|
|
@@ -140,7 +140,7 @@ declare class ClaudeExecutor {
|
|
|
140
140
|
/**
|
|
141
141
|
* Create a Claude executor
|
|
142
142
|
*/
|
|
143
|
-
declare function createExecutor(config?: ExecutorConfig): ClaudeExecutor;
|
|
143
|
+
declare function createExecutor(config?: ExecutorConfig$1): ClaudeExecutor;
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* SSE Event Listener for Artyfacts task assignments
|
|
@@ -316,4 +316,222 @@ declare class ContextFetcher {
|
|
|
316
316
|
declare function buildPromptWithContext(context: TaskFullContext): string;
|
|
317
317
|
declare function createContextFetcher(config: ContextFetcherConfig): ContextFetcher;
|
|
318
318
|
|
|
319
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Tool Types for Artyfacts
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* JSON Schema for tool input
|
|
324
|
+
*/
|
|
325
|
+
interface ToolInputSchema {
|
|
326
|
+
type: 'object';
|
|
327
|
+
properties: Record<string, {
|
|
328
|
+
type: string;
|
|
329
|
+
description?: string;
|
|
330
|
+
enum?: string[] | number[];
|
|
331
|
+
default?: unknown;
|
|
332
|
+
items?: {
|
|
333
|
+
type: string;
|
|
334
|
+
properties?: Record<string, unknown>;
|
|
335
|
+
};
|
|
336
|
+
}>;
|
|
337
|
+
required: string[];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Tool schema (for Claude tool_use)
|
|
341
|
+
*/
|
|
342
|
+
interface ToolSchema {
|
|
343
|
+
name: string;
|
|
344
|
+
description: string;
|
|
345
|
+
input_schema: ToolInputSchema;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Tool execution result
|
|
349
|
+
*/
|
|
350
|
+
interface ToolResult {
|
|
351
|
+
success: boolean;
|
|
352
|
+
data?: unknown;
|
|
353
|
+
error?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* API client interface for tool handlers
|
|
357
|
+
*/
|
|
358
|
+
interface ApiClient {
|
|
359
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
360
|
+
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
361
|
+
patch<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
362
|
+
delete<T = unknown>(path: string): Promise<T>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Tool handler function
|
|
366
|
+
*/
|
|
367
|
+
type ToolHandler = (args: Record<string, unknown>, client: ApiClient) => Promise<ToolResult>;
|
|
368
|
+
/**
|
|
369
|
+
* Tool call from Claude
|
|
370
|
+
*/
|
|
371
|
+
interface ToolCall {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
input: Record<string, unknown>;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Tool result to send back to Claude
|
|
378
|
+
*/
|
|
379
|
+
interface ToolCallResult {
|
|
380
|
+
type: 'tool_result';
|
|
381
|
+
tool_use_id: string;
|
|
382
|
+
content: string;
|
|
383
|
+
is_error?: boolean;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Artyfacts Tools Registry
|
|
388
|
+
*
|
|
389
|
+
* Defines all tools available to agents for interacting with Artyfacts.
|
|
390
|
+
* Tools are mapped to permissions - agents only get tools they have permission for.
|
|
391
|
+
*/
|
|
392
|
+
|
|
393
|
+
declare const permissionToTools: Record<string, string[]>;
|
|
394
|
+
/**
|
|
395
|
+
* Get all tool schemas
|
|
396
|
+
*/
|
|
397
|
+
declare function getAllToolSchemas(): ToolSchema[];
|
|
398
|
+
/**
|
|
399
|
+
* Get tool schema by name
|
|
400
|
+
*/
|
|
401
|
+
declare function getToolSchema(name: string): ToolSchema | undefined;
|
|
402
|
+
/**
|
|
403
|
+
* Get tools available for a set of permissions
|
|
404
|
+
*/
|
|
405
|
+
declare function getToolsForPermissions(permissions: string[]): ToolSchema[];
|
|
406
|
+
/**
|
|
407
|
+
* Check if a tool is allowed for a set of permissions
|
|
408
|
+
*/
|
|
409
|
+
declare function isToolAllowed(toolName: string, permissions: string[]): boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Get the permission required for a tool
|
|
412
|
+
*/
|
|
413
|
+
declare function getRequiredPermission(toolName: string): string | undefined;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Tool Handlers for Artyfacts
|
|
417
|
+
*
|
|
418
|
+
* Each handler calls the corresponding Artyfacts API endpoint.
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
declare const handlers: Record<string, ToolHandler>;
|
|
422
|
+
/**
|
|
423
|
+
* Execute a tool with the given arguments
|
|
424
|
+
*/
|
|
425
|
+
declare function executeTool(toolName: string, args: Record<string, unknown>, client: ApiClient): Promise<ToolResult>;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* API Client for Artyfacts Tools
|
|
429
|
+
*
|
|
430
|
+
* Simple HTTP client that wraps the Artyfacts API.
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
interface ApiClientConfig {
|
|
434
|
+
baseUrl: string;
|
|
435
|
+
apiKey: string;
|
|
436
|
+
agentId?: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Create an API client for Artyfacts
|
|
440
|
+
*/
|
|
441
|
+
declare function createApiClient(config: ApiClientConfig): ApiClient;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Claude Executor with Tools Support
|
|
445
|
+
*
|
|
446
|
+
* Executes tasks using Claude with full tool support.
|
|
447
|
+
* Uses the Anthropic SDK directly (not the CLI) to enable function calling.
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
interface TaskContext {
|
|
451
|
+
/** Task ID (UUID or section_id) */
|
|
452
|
+
taskId: string;
|
|
453
|
+
/** Task heading/title */
|
|
454
|
+
heading: string;
|
|
455
|
+
/** Task content/description */
|
|
456
|
+
content: string;
|
|
457
|
+
/** Parent artifact ID */
|
|
458
|
+
artifactId: string;
|
|
459
|
+
/** Parent artifact title */
|
|
460
|
+
artifactTitle?: string;
|
|
461
|
+
/** Task priority (1=high, 2=medium, 3=low) */
|
|
462
|
+
priority?: number;
|
|
463
|
+
/** Additional context */
|
|
464
|
+
context?: Record<string, unknown>;
|
|
465
|
+
}
|
|
466
|
+
interface ExecutionResult {
|
|
467
|
+
/** Whether execution was successful */
|
|
468
|
+
success: boolean;
|
|
469
|
+
/** The generated output */
|
|
470
|
+
output: string;
|
|
471
|
+
/** Summary of what was accomplished */
|
|
472
|
+
summary: string;
|
|
473
|
+
/** Any error message if failed */
|
|
474
|
+
error?: string;
|
|
475
|
+
/** The prompt that was used (for debugging) */
|
|
476
|
+
promptUsed?: string;
|
|
477
|
+
/** Tool calls made during execution */
|
|
478
|
+
toolCalls?: Array<{
|
|
479
|
+
name: string;
|
|
480
|
+
input: Record<string, unknown>;
|
|
481
|
+
output: unknown;
|
|
482
|
+
}>;
|
|
483
|
+
}
|
|
484
|
+
interface ExecutorConfig {
|
|
485
|
+
/** Anthropic API key */
|
|
486
|
+
anthropicApiKey?: string;
|
|
487
|
+
/** Model to use (default: claude-sonnet-4-20250514) */
|
|
488
|
+
model?: string;
|
|
489
|
+
/** Timeout in milliseconds (default: 5 minutes) */
|
|
490
|
+
timeout?: number;
|
|
491
|
+
/** System prompt prefix */
|
|
492
|
+
systemPromptPrefix?: string;
|
|
493
|
+
/** Artyfacts API base URL */
|
|
494
|
+
baseUrl: string;
|
|
495
|
+
/** Artyfacts API key */
|
|
496
|
+
apiKey: string;
|
|
497
|
+
/** Agent's permissions (determines available tools) */
|
|
498
|
+
permissions?: string[];
|
|
499
|
+
/** Whether to use full context from API (default: true) */
|
|
500
|
+
useFullContext?: boolean;
|
|
501
|
+
/** Max tool call iterations (default: 10) */
|
|
502
|
+
maxToolIterations?: number;
|
|
503
|
+
}
|
|
504
|
+
declare class ClaudeExecutorWithTools {
|
|
505
|
+
private config;
|
|
506
|
+
private anthropic;
|
|
507
|
+
private contextFetcher;
|
|
508
|
+
private apiClient;
|
|
509
|
+
private tools;
|
|
510
|
+
constructor(config: ExecutorConfig);
|
|
511
|
+
/**
|
|
512
|
+
* Execute a task using Claude with tools
|
|
513
|
+
*/
|
|
514
|
+
execute(task: TaskContext): Promise<ExecutionResult>;
|
|
515
|
+
/**
|
|
516
|
+
* Build the task prompt (fallback when full context unavailable)
|
|
517
|
+
*/
|
|
518
|
+
private buildTaskPrompt;
|
|
519
|
+
/**
|
|
520
|
+
* Parse the response to extract output and summary
|
|
521
|
+
*/
|
|
522
|
+
private parseResponse;
|
|
523
|
+
/**
|
|
524
|
+
* Get available tools for this executor
|
|
525
|
+
*/
|
|
526
|
+
getAvailableTools(): ToolSchema[];
|
|
527
|
+
/**
|
|
528
|
+
* Update permissions (recalculates available tools)
|
|
529
|
+
*/
|
|
530
|
+
setPermissions(permissions: string[]): void;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Create a Claude executor with tools support
|
|
534
|
+
*/
|
|
535
|
+
declare function createExecutorWithTools(config: ExecutorConfig): ClaudeExecutorWithTools;
|
|
536
|
+
|
|
537
|
+
export { type ApiClient, type ArtifactContext, type ArtyfactsEvent, ArtyfactsListener, ClaudeExecutor, ClaudeExecutorWithTools, type ConnectedEvent, type ConnectionState, ContextFetcher, type ContextFetcherConfig, type Credentials, type DeviceAuthResponse, type EventCallback, type ExecutionResult$1 as ExecutionResult, type ExecutorConfig$1 as ExecutorConfig, type ExecutorConfig as ExecutorWithToolsConfig, type HeartbeatEvent, type ListenerConfig, type OrganizationContext, type ProjectContext, type SectionContext, type TaskAssignedEvent, type TaskContext$1 as TaskContext, type TaskFullContext, type TokenResponse, type ToolCall, type ToolCallResult, type ToolHandler, type ToolResult, type ToolSchema, buildPromptWithContext, clearCredentials, createApiClient, createContextFetcher, createExecutor, createExecutorWithTools, createListener, executeTool, getAllToolSchemas, getCredentials, getRequiredPermission, getToolSchema, getToolsForPermissions, isToolAllowed, loadCredentials, permissionToTools, promptForApiKey, runDeviceAuth, saveCredentials, handlers as toolHandlers };
|
package/dist/index.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ declare function getCredentials(options?: {
|
|
|
63
63
|
* Now supports fetching full context (organization, project, artifact, related sections)
|
|
64
64
|
* to provide Claude with the information needed to complete tasks effectively.
|
|
65
65
|
*/
|
|
66
|
-
interface TaskContext {
|
|
66
|
+
interface TaskContext$1 {
|
|
67
67
|
/** Task ID (section ID) */
|
|
68
68
|
taskId: string;
|
|
69
69
|
/** Task heading/title */
|
|
@@ -79,7 +79,7 @@ interface TaskContext {
|
|
|
79
79
|
/** Additional context */
|
|
80
80
|
context?: Record<string, unknown>;
|
|
81
81
|
}
|
|
82
|
-
interface ExecutionResult {
|
|
82
|
+
interface ExecutionResult$1 {
|
|
83
83
|
/** Whether execution was successful */
|
|
84
84
|
success: boolean;
|
|
85
85
|
/** The generated output */
|
|
@@ -91,7 +91,7 @@ interface ExecutionResult {
|
|
|
91
91
|
/** The prompt that was used (for debugging) */
|
|
92
92
|
promptUsed?: string;
|
|
93
93
|
}
|
|
94
|
-
interface ExecutorConfig {
|
|
94
|
+
interface ExecutorConfig$1 {
|
|
95
95
|
/** Path to claude CLI (default: 'claude') */
|
|
96
96
|
claudePath?: string;
|
|
97
97
|
/** Timeout in milliseconds (default: 5 minutes) */
|
|
@@ -108,14 +108,14 @@ interface ExecutorConfig {
|
|
|
108
108
|
declare class ClaudeExecutor {
|
|
109
109
|
private config;
|
|
110
110
|
private contextFetcher;
|
|
111
|
-
constructor(config?: ExecutorConfig);
|
|
111
|
+
constructor(config?: ExecutorConfig$1);
|
|
112
112
|
/**
|
|
113
113
|
* Execute a task using Claude Code CLI
|
|
114
114
|
*
|
|
115
115
|
* If full context is available (baseUrl + apiKey configured), fetches
|
|
116
116
|
* organization, project, artifact, and related sections for a rich prompt.
|
|
117
117
|
*/
|
|
118
|
-
execute(task: TaskContext): Promise<ExecutionResult>;
|
|
118
|
+
execute(task: TaskContext$1): Promise<ExecutionResult$1>;
|
|
119
119
|
/**
|
|
120
120
|
* Run Claude Code CLI with the given prompt
|
|
121
121
|
*/
|
|
@@ -140,7 +140,7 @@ declare class ClaudeExecutor {
|
|
|
140
140
|
/**
|
|
141
141
|
* Create a Claude executor
|
|
142
142
|
*/
|
|
143
|
-
declare function createExecutor(config?: ExecutorConfig): ClaudeExecutor;
|
|
143
|
+
declare function createExecutor(config?: ExecutorConfig$1): ClaudeExecutor;
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* SSE Event Listener for Artyfacts task assignments
|
|
@@ -316,4 +316,222 @@ declare class ContextFetcher {
|
|
|
316
316
|
declare function buildPromptWithContext(context: TaskFullContext): string;
|
|
317
317
|
declare function createContextFetcher(config: ContextFetcherConfig): ContextFetcher;
|
|
318
318
|
|
|
319
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Tool Types for Artyfacts
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* JSON Schema for tool input
|
|
324
|
+
*/
|
|
325
|
+
interface ToolInputSchema {
|
|
326
|
+
type: 'object';
|
|
327
|
+
properties: Record<string, {
|
|
328
|
+
type: string;
|
|
329
|
+
description?: string;
|
|
330
|
+
enum?: string[] | number[];
|
|
331
|
+
default?: unknown;
|
|
332
|
+
items?: {
|
|
333
|
+
type: string;
|
|
334
|
+
properties?: Record<string, unknown>;
|
|
335
|
+
};
|
|
336
|
+
}>;
|
|
337
|
+
required: string[];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Tool schema (for Claude tool_use)
|
|
341
|
+
*/
|
|
342
|
+
interface ToolSchema {
|
|
343
|
+
name: string;
|
|
344
|
+
description: string;
|
|
345
|
+
input_schema: ToolInputSchema;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Tool execution result
|
|
349
|
+
*/
|
|
350
|
+
interface ToolResult {
|
|
351
|
+
success: boolean;
|
|
352
|
+
data?: unknown;
|
|
353
|
+
error?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* API client interface for tool handlers
|
|
357
|
+
*/
|
|
358
|
+
interface ApiClient {
|
|
359
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
360
|
+
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
361
|
+
patch<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
362
|
+
delete<T = unknown>(path: string): Promise<T>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Tool handler function
|
|
366
|
+
*/
|
|
367
|
+
type ToolHandler = (args: Record<string, unknown>, client: ApiClient) => Promise<ToolResult>;
|
|
368
|
+
/**
|
|
369
|
+
* Tool call from Claude
|
|
370
|
+
*/
|
|
371
|
+
interface ToolCall {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
input: Record<string, unknown>;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Tool result to send back to Claude
|
|
378
|
+
*/
|
|
379
|
+
interface ToolCallResult {
|
|
380
|
+
type: 'tool_result';
|
|
381
|
+
tool_use_id: string;
|
|
382
|
+
content: string;
|
|
383
|
+
is_error?: boolean;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Artyfacts Tools Registry
|
|
388
|
+
*
|
|
389
|
+
* Defines all tools available to agents for interacting with Artyfacts.
|
|
390
|
+
* Tools are mapped to permissions - agents only get tools they have permission for.
|
|
391
|
+
*/
|
|
392
|
+
|
|
393
|
+
declare const permissionToTools: Record<string, string[]>;
|
|
394
|
+
/**
|
|
395
|
+
* Get all tool schemas
|
|
396
|
+
*/
|
|
397
|
+
declare function getAllToolSchemas(): ToolSchema[];
|
|
398
|
+
/**
|
|
399
|
+
* Get tool schema by name
|
|
400
|
+
*/
|
|
401
|
+
declare function getToolSchema(name: string): ToolSchema | undefined;
|
|
402
|
+
/**
|
|
403
|
+
* Get tools available for a set of permissions
|
|
404
|
+
*/
|
|
405
|
+
declare function getToolsForPermissions(permissions: string[]): ToolSchema[];
|
|
406
|
+
/**
|
|
407
|
+
* Check if a tool is allowed for a set of permissions
|
|
408
|
+
*/
|
|
409
|
+
declare function isToolAllowed(toolName: string, permissions: string[]): boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Get the permission required for a tool
|
|
412
|
+
*/
|
|
413
|
+
declare function getRequiredPermission(toolName: string): string | undefined;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Tool Handlers for Artyfacts
|
|
417
|
+
*
|
|
418
|
+
* Each handler calls the corresponding Artyfacts API endpoint.
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
declare const handlers: Record<string, ToolHandler>;
|
|
422
|
+
/**
|
|
423
|
+
* Execute a tool with the given arguments
|
|
424
|
+
*/
|
|
425
|
+
declare function executeTool(toolName: string, args: Record<string, unknown>, client: ApiClient): Promise<ToolResult>;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* API Client for Artyfacts Tools
|
|
429
|
+
*
|
|
430
|
+
* Simple HTTP client that wraps the Artyfacts API.
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
interface ApiClientConfig {
|
|
434
|
+
baseUrl: string;
|
|
435
|
+
apiKey: string;
|
|
436
|
+
agentId?: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Create an API client for Artyfacts
|
|
440
|
+
*/
|
|
441
|
+
declare function createApiClient(config: ApiClientConfig): ApiClient;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Claude Executor with Tools Support
|
|
445
|
+
*
|
|
446
|
+
* Executes tasks using Claude with full tool support.
|
|
447
|
+
* Uses the Anthropic SDK directly (not the CLI) to enable function calling.
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
interface TaskContext {
|
|
451
|
+
/** Task ID (UUID or section_id) */
|
|
452
|
+
taskId: string;
|
|
453
|
+
/** Task heading/title */
|
|
454
|
+
heading: string;
|
|
455
|
+
/** Task content/description */
|
|
456
|
+
content: string;
|
|
457
|
+
/** Parent artifact ID */
|
|
458
|
+
artifactId: string;
|
|
459
|
+
/** Parent artifact title */
|
|
460
|
+
artifactTitle?: string;
|
|
461
|
+
/** Task priority (1=high, 2=medium, 3=low) */
|
|
462
|
+
priority?: number;
|
|
463
|
+
/** Additional context */
|
|
464
|
+
context?: Record<string, unknown>;
|
|
465
|
+
}
|
|
466
|
+
interface ExecutionResult {
|
|
467
|
+
/** Whether execution was successful */
|
|
468
|
+
success: boolean;
|
|
469
|
+
/** The generated output */
|
|
470
|
+
output: string;
|
|
471
|
+
/** Summary of what was accomplished */
|
|
472
|
+
summary: string;
|
|
473
|
+
/** Any error message if failed */
|
|
474
|
+
error?: string;
|
|
475
|
+
/** The prompt that was used (for debugging) */
|
|
476
|
+
promptUsed?: string;
|
|
477
|
+
/** Tool calls made during execution */
|
|
478
|
+
toolCalls?: Array<{
|
|
479
|
+
name: string;
|
|
480
|
+
input: Record<string, unknown>;
|
|
481
|
+
output: unknown;
|
|
482
|
+
}>;
|
|
483
|
+
}
|
|
484
|
+
interface ExecutorConfig {
|
|
485
|
+
/** Anthropic API key */
|
|
486
|
+
anthropicApiKey?: string;
|
|
487
|
+
/** Model to use (default: claude-sonnet-4-20250514) */
|
|
488
|
+
model?: string;
|
|
489
|
+
/** Timeout in milliseconds (default: 5 minutes) */
|
|
490
|
+
timeout?: number;
|
|
491
|
+
/** System prompt prefix */
|
|
492
|
+
systemPromptPrefix?: string;
|
|
493
|
+
/** Artyfacts API base URL */
|
|
494
|
+
baseUrl: string;
|
|
495
|
+
/** Artyfacts API key */
|
|
496
|
+
apiKey: string;
|
|
497
|
+
/** Agent's permissions (determines available tools) */
|
|
498
|
+
permissions?: string[];
|
|
499
|
+
/** Whether to use full context from API (default: true) */
|
|
500
|
+
useFullContext?: boolean;
|
|
501
|
+
/** Max tool call iterations (default: 10) */
|
|
502
|
+
maxToolIterations?: number;
|
|
503
|
+
}
|
|
504
|
+
declare class ClaudeExecutorWithTools {
|
|
505
|
+
private config;
|
|
506
|
+
private anthropic;
|
|
507
|
+
private contextFetcher;
|
|
508
|
+
private apiClient;
|
|
509
|
+
private tools;
|
|
510
|
+
constructor(config: ExecutorConfig);
|
|
511
|
+
/**
|
|
512
|
+
* Execute a task using Claude with tools
|
|
513
|
+
*/
|
|
514
|
+
execute(task: TaskContext): Promise<ExecutionResult>;
|
|
515
|
+
/**
|
|
516
|
+
* Build the task prompt (fallback when full context unavailable)
|
|
517
|
+
*/
|
|
518
|
+
private buildTaskPrompt;
|
|
519
|
+
/**
|
|
520
|
+
* Parse the response to extract output and summary
|
|
521
|
+
*/
|
|
522
|
+
private parseResponse;
|
|
523
|
+
/**
|
|
524
|
+
* Get available tools for this executor
|
|
525
|
+
*/
|
|
526
|
+
getAvailableTools(): ToolSchema[];
|
|
527
|
+
/**
|
|
528
|
+
* Update permissions (recalculates available tools)
|
|
529
|
+
*/
|
|
530
|
+
setPermissions(permissions: string[]): void;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Create a Claude executor with tools support
|
|
534
|
+
*/
|
|
535
|
+
declare function createExecutorWithTools(config: ExecutorConfig): ClaudeExecutorWithTools;
|
|
536
|
+
|
|
537
|
+
export { type ApiClient, type ArtifactContext, type ArtyfactsEvent, ArtyfactsListener, ClaudeExecutor, ClaudeExecutorWithTools, type ConnectedEvent, type ConnectionState, ContextFetcher, type ContextFetcherConfig, type Credentials, type DeviceAuthResponse, type EventCallback, type ExecutionResult$1 as ExecutionResult, type ExecutorConfig$1 as ExecutorConfig, type ExecutorConfig as ExecutorWithToolsConfig, type HeartbeatEvent, type ListenerConfig, type OrganizationContext, type ProjectContext, type SectionContext, type TaskAssignedEvent, type TaskContext$1 as TaskContext, type TaskFullContext, type TokenResponse, type ToolCall, type ToolCallResult, type ToolHandler, type ToolResult, type ToolSchema, buildPromptWithContext, clearCredentials, createApiClient, createContextFetcher, createExecutor, createExecutorWithTools, createListener, executeTool, getAllToolSchemas, getCredentials, getRequiredPermission, getToolSchema, getToolsForPermissions, isToolAllowed, loadCredentials, permissionToTools, promptForApiKey, runDeviceAuth, saveCredentials, handlers as toolHandlers };
|