@artyfacts/claude 1.2.6 → 1.3.1
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/cli.js +58 -0
- package/dist/cli.mjs +58 -0
- 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/cli.ts +73 -0
- 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/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
|
|
26
26
|
// src/cli.ts
|
|
27
27
|
var import_commander = require("commander");
|
|
28
|
+
var import_child_process2 = require("child_process");
|
|
28
29
|
|
|
29
30
|
// src/auth.ts
|
|
30
31
|
var fs = __toESM(require("fs"));
|
|
@@ -771,6 +772,62 @@ function createListener(config) {
|
|
|
771
772
|
// src/cli.ts
|
|
772
773
|
var VERSION = "0.1.0";
|
|
773
774
|
var DEFAULT_BASE_URL3 = "https://artyfacts.dev/api/v1";
|
|
775
|
+
function isMcpConfigured() {
|
|
776
|
+
try {
|
|
777
|
+
const result = (0, import_child_process2.spawnSync)("claude", ["mcp", "get", "artyfacts"], {
|
|
778
|
+
encoding: "utf-8",
|
|
779
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
780
|
+
});
|
|
781
|
+
return result.status === 0;
|
|
782
|
+
} catch {
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
function configureMcp(apiKey, baseUrl) {
|
|
787
|
+
console.log("\u{1F527} Configuring Artyfacts tools for Claude Code...");
|
|
788
|
+
try {
|
|
789
|
+
const result = (0, import_child_process2.spawnSync)("claude", [
|
|
790
|
+
"mcp",
|
|
791
|
+
"add",
|
|
792
|
+
"--transport",
|
|
793
|
+
"stdio",
|
|
794
|
+
"--scope",
|
|
795
|
+
"user",
|
|
796
|
+
// Available across all projects
|
|
797
|
+
"--env",
|
|
798
|
+
`ARTYFACTS_API_KEY=${apiKey}`,
|
|
799
|
+
"--env",
|
|
800
|
+
`ARTYFACTS_BASE_URL=${baseUrl}`,
|
|
801
|
+
"artyfacts",
|
|
802
|
+
"--",
|
|
803
|
+
"npx",
|
|
804
|
+
"-y",
|
|
805
|
+
"@artyfacts/mcp-server"
|
|
806
|
+
], {
|
|
807
|
+
encoding: "utf-8",
|
|
808
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
809
|
+
});
|
|
810
|
+
if (result.status === 0) {
|
|
811
|
+
console.log("\u2705 MCP tools configured! Claude Code now has access to Artyfacts.");
|
|
812
|
+
return true;
|
|
813
|
+
} else {
|
|
814
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", result.stderr || result.stdout);
|
|
815
|
+
console.log(" You can manually add it with:");
|
|
816
|
+
console.log(` claude mcp add --transport stdio artyfacts -- npx -y @artyfacts/mcp-server`);
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
} catch (error) {
|
|
820
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", error instanceof Error ? error.message : error);
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function ensureMcpConfigured(apiKey, baseUrl) {
|
|
825
|
+
if (isMcpConfigured()) {
|
|
826
|
+
console.log("\u2705 Artyfacts MCP tools already configured");
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
configureMcp(apiKey, baseUrl);
|
|
830
|
+
}
|
|
774
831
|
var program = new import_commander.Command();
|
|
775
832
|
program.name("artyfacts-claude").description("Claude adapter for Artyfacts - Execute tasks using Claude API").version(VERSION);
|
|
776
833
|
program.command("run", { isDefault: true }).description("Start listening for and executing tasks").option("--base-url <url>", "Artyfacts API base URL", DEFAULT_BASE_URL3).option("--dry-run", "Print tasks but do not execute", false).action(async (options) => {
|
|
@@ -924,6 +981,7 @@ async function runAgent(options) {
|
|
|
924
981
|
console.error("\u274C Authentication failed:", error instanceof Error ? error.message : error);
|
|
925
982
|
process.exit(1);
|
|
926
983
|
}
|
|
984
|
+
ensureMcpConfigured(credentials.apiKey, options.baseUrl);
|
|
927
985
|
let executor = null;
|
|
928
986
|
if (!options.dryRun) {
|
|
929
987
|
executor = createExecutor({
|
package/dist/cli.mjs
CHANGED
|
@@ -10,8 +10,65 @@ import {
|
|
|
10
10
|
|
|
11
11
|
// src/cli.ts
|
|
12
12
|
import { Command } from "commander";
|
|
13
|
+
import { spawnSync } from "child_process";
|
|
13
14
|
var VERSION = "0.1.0";
|
|
14
15
|
var DEFAULT_BASE_URL = "https://artyfacts.dev/api/v1";
|
|
16
|
+
function isMcpConfigured() {
|
|
17
|
+
try {
|
|
18
|
+
const result = spawnSync("claude", ["mcp", "get", "artyfacts"], {
|
|
19
|
+
encoding: "utf-8",
|
|
20
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
21
|
+
});
|
|
22
|
+
return result.status === 0;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function configureMcp(apiKey, baseUrl) {
|
|
28
|
+
console.log("\u{1F527} Configuring Artyfacts tools for Claude Code...");
|
|
29
|
+
try {
|
|
30
|
+
const result = spawnSync("claude", [
|
|
31
|
+
"mcp",
|
|
32
|
+
"add",
|
|
33
|
+
"--transport",
|
|
34
|
+
"stdio",
|
|
35
|
+
"--scope",
|
|
36
|
+
"user",
|
|
37
|
+
// Available across all projects
|
|
38
|
+
"--env",
|
|
39
|
+
`ARTYFACTS_API_KEY=${apiKey}`,
|
|
40
|
+
"--env",
|
|
41
|
+
`ARTYFACTS_BASE_URL=${baseUrl}`,
|
|
42
|
+
"artyfacts",
|
|
43
|
+
"--",
|
|
44
|
+
"npx",
|
|
45
|
+
"-y",
|
|
46
|
+
"@artyfacts/mcp-server"
|
|
47
|
+
], {
|
|
48
|
+
encoding: "utf-8",
|
|
49
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
50
|
+
});
|
|
51
|
+
if (result.status === 0) {
|
|
52
|
+
console.log("\u2705 MCP tools configured! Claude Code now has access to Artyfacts.");
|
|
53
|
+
return true;
|
|
54
|
+
} else {
|
|
55
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", result.stderr || result.stdout);
|
|
56
|
+
console.log(" You can manually add it with:");
|
|
57
|
+
console.log(` claude mcp add --transport stdio artyfacts -- npx -y @artyfacts/mcp-server`);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", error instanceof Error ? error.message : error);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function ensureMcpConfigured(apiKey, baseUrl) {
|
|
66
|
+
if (isMcpConfigured()) {
|
|
67
|
+
console.log("\u2705 Artyfacts MCP tools already configured");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
configureMcp(apiKey, baseUrl);
|
|
71
|
+
}
|
|
15
72
|
var program = new Command();
|
|
16
73
|
program.name("artyfacts-claude").description("Claude adapter for Artyfacts - Execute tasks using Claude API").version(VERSION);
|
|
17
74
|
program.command("run", { isDefault: true }).description("Start listening for and executing tasks").option("--base-url <url>", "Artyfacts API base URL", DEFAULT_BASE_URL).option("--dry-run", "Print tasks but do not execute", false).action(async (options) => {
|
|
@@ -165,6 +222,7 @@ async function runAgent(options) {
|
|
|
165
222
|
console.error("\u274C Authentication failed:", error instanceof Error ? error.message : error);
|
|
166
223
|
process.exit(1);
|
|
167
224
|
}
|
|
225
|
+
ensureMcpConfigured(credentials.apiKey, options.baseUrl);
|
|
168
226
|
let executor = null;
|
|
169
227
|
if (!options.dryRun) {
|
|
170
228
|
executor = createExecutor({
|
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 };
|