@artyfacts/claude 1.1.2 → 1.2.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/chunk-EROV5RIA.mjs +741 -0
- package/dist/cli.js +192 -7
- package/dist/cli.mjs +18 -6
- package/dist/index.d.mts +79 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +181 -2
- package/dist/index.mjs +7 -1
- package/package.json +1 -1
- package/src/cli.ts +23 -6
- package/src/context.ts +260 -0
- package/src/executor.ts +44 -2
- package/src/index.ts +17 -0
package/dist/cli.js
CHANGED
|
@@ -216,6 +216,153 @@ async function getCredentials(options) {
|
|
|
216
216
|
|
|
217
217
|
// src/executor.ts
|
|
218
218
|
var import_child_process = require("child_process");
|
|
219
|
+
|
|
220
|
+
// src/context.ts
|
|
221
|
+
var ContextFetcher = class {
|
|
222
|
+
config;
|
|
223
|
+
constructor(config) {
|
|
224
|
+
this.config = config;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Fetch full context for a task
|
|
228
|
+
*/
|
|
229
|
+
async fetchTaskContext(taskId) {
|
|
230
|
+
const response = await fetch(
|
|
231
|
+
`${this.config.baseUrl}/tasks/${taskId}/context`,
|
|
232
|
+
{
|
|
233
|
+
headers: {
|
|
234
|
+
"Authorization": `Bearer ${this.config.apiKey}`,
|
|
235
|
+
"Accept": "application/json"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
if (!response.ok) {
|
|
240
|
+
const errorText = await response.text().catch(() => "Unknown error");
|
|
241
|
+
throw new Error(`Failed to fetch task context: ${response.status} - ${errorText}`);
|
|
242
|
+
}
|
|
243
|
+
const data = await response.json();
|
|
244
|
+
return data;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
function buildPromptWithContext(context) {
|
|
248
|
+
const parts = [];
|
|
249
|
+
parts.push(`You are an AI agent working within the Artyfacts task management system.
|
|
250
|
+
|
|
251
|
+
Your job is to complete the assigned task. You have full context about the organization, project, and related work.
|
|
252
|
+
|
|
253
|
+
Guidelines:
|
|
254
|
+
- Be thorough but concise
|
|
255
|
+
- If the task requires code, provide working code
|
|
256
|
+
- If the task requires analysis, provide structured findings
|
|
257
|
+
- If the task requires a decision, explain your reasoning
|
|
258
|
+
- If you cannot complete the task, explain why
|
|
259
|
+
|
|
260
|
+
Format your response as follows:
|
|
261
|
+
1. First, provide your main output (the task deliverable)
|
|
262
|
+
2. End with a brief summary line starting with "SUMMARY:"`);
|
|
263
|
+
parts.push("");
|
|
264
|
+
parts.push("---");
|
|
265
|
+
parts.push("");
|
|
266
|
+
parts.push("## Organization Context");
|
|
267
|
+
parts.push(`**${context.organization.name}**`);
|
|
268
|
+
if (context.organization.context) {
|
|
269
|
+
parts.push("");
|
|
270
|
+
parts.push(formatOrgContext(context.organization.context));
|
|
271
|
+
}
|
|
272
|
+
parts.push("");
|
|
273
|
+
if (context.project) {
|
|
274
|
+
parts.push(`## Project: ${context.project.name}`);
|
|
275
|
+
if (context.project.description) {
|
|
276
|
+
parts.push(context.project.description);
|
|
277
|
+
}
|
|
278
|
+
parts.push("");
|
|
279
|
+
}
|
|
280
|
+
parts.push(`## Artifact: ${context.artifact.title}`);
|
|
281
|
+
if (context.artifact.summary) {
|
|
282
|
+
parts.push(context.artifact.summary);
|
|
283
|
+
}
|
|
284
|
+
if (context.artifact.description) {
|
|
285
|
+
parts.push("");
|
|
286
|
+
parts.push(context.artifact.description);
|
|
287
|
+
}
|
|
288
|
+
parts.push("");
|
|
289
|
+
const relatedSections = context.artifact.sections.filter(
|
|
290
|
+
(s) => s.id !== context.task.id
|
|
291
|
+
);
|
|
292
|
+
if (relatedSections.length > 0) {
|
|
293
|
+
parts.push("### Related Sections:");
|
|
294
|
+
for (const section of relatedSections) {
|
|
295
|
+
const preview = section.content ? section.content.substring(0, 200) + (section.content.length > 200 ? "..." : "") : "No content";
|
|
296
|
+
const statusBadge = section.task_status ? ` [${section.task_status}]` : "";
|
|
297
|
+
parts.push(`- **${section.heading}**${statusBadge}: ${preview}`);
|
|
298
|
+
}
|
|
299
|
+
parts.push("");
|
|
300
|
+
}
|
|
301
|
+
parts.push("---");
|
|
302
|
+
parts.push("");
|
|
303
|
+
parts.push(`## Your Task: ${context.task.heading}`);
|
|
304
|
+
if (context.task.priority) {
|
|
305
|
+
const priorityLabels = ["\u{1F534} High", "\u{1F7E1} Medium", "\u{1F7E2} Low"];
|
|
306
|
+
parts.push(`**Priority:** ${priorityLabels[context.task.priority - 1] || "Medium"}`);
|
|
307
|
+
}
|
|
308
|
+
parts.push("");
|
|
309
|
+
parts.push("### Description");
|
|
310
|
+
parts.push(context.task.content || "No additional description provided.");
|
|
311
|
+
parts.push("");
|
|
312
|
+
if (context.task.expected_output) {
|
|
313
|
+
parts.push("### Expected Output");
|
|
314
|
+
if (context.task.expected_output.format) {
|
|
315
|
+
parts.push(`**Format:** ${context.task.expected_output.format}`);
|
|
316
|
+
}
|
|
317
|
+
if (context.task.expected_output.requirements && context.task.expected_output.requirements.length > 0) {
|
|
318
|
+
parts.push("**Requirements:**");
|
|
319
|
+
for (const req of context.task.expected_output.requirements) {
|
|
320
|
+
parts.push(`- ${req}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
parts.push("");
|
|
324
|
+
}
|
|
325
|
+
parts.push("---");
|
|
326
|
+
parts.push("");
|
|
327
|
+
parts.push("Complete this task and provide your output below.");
|
|
328
|
+
return parts.join("\n");
|
|
329
|
+
}
|
|
330
|
+
function formatOrgContext(context) {
|
|
331
|
+
const trimmed = context.trim();
|
|
332
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
333
|
+
try {
|
|
334
|
+
const parsed = JSON.parse(trimmed);
|
|
335
|
+
return formatContextObject(parsed);
|
|
336
|
+
} catch {
|
|
337
|
+
return context;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return context;
|
|
341
|
+
}
|
|
342
|
+
function formatContextObject(obj, indent = "") {
|
|
343
|
+
if (typeof obj !== "object" || obj === null) {
|
|
344
|
+
return String(obj);
|
|
345
|
+
}
|
|
346
|
+
if (Array.isArray(obj)) {
|
|
347
|
+
return obj.map((item) => `${indent}- ${formatContextObject(item, indent + " ")}`).join("\n");
|
|
348
|
+
}
|
|
349
|
+
const lines = [];
|
|
350
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
351
|
+
const label = key.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
352
|
+
if (typeof value === "object" && value !== null) {
|
|
353
|
+
lines.push(`${indent}**${label}:**`);
|
|
354
|
+
lines.push(formatContextObject(value, indent + " "));
|
|
355
|
+
} else {
|
|
356
|
+
lines.push(`${indent}- **${label}:** ${value}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return lines.join("\n");
|
|
360
|
+
}
|
|
361
|
+
function createContextFetcher(config) {
|
|
362
|
+
return new ContextFetcher(config);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/executor.ts
|
|
219
366
|
var DEFAULT_TIMEOUT = 5 * 60 * 1e3;
|
|
220
367
|
var DEFAULT_SYSTEM_PROMPT = `You are an AI agent working within the Artyfacts task management system.
|
|
221
368
|
|
|
@@ -236,25 +383,51 @@ Format your response as follows:
|
|
|
236
383
|
2. End with a brief summary line starting with "SUMMARY:"`;
|
|
237
384
|
var ClaudeExecutor = class {
|
|
238
385
|
config;
|
|
386
|
+
contextFetcher = null;
|
|
239
387
|
constructor(config = {}) {
|
|
240
388
|
this.config = {
|
|
241
389
|
...config,
|
|
242
390
|
timeout: config.timeout || DEFAULT_TIMEOUT,
|
|
243
391
|
claudePath: config.claudePath || "claude"
|
|
244
392
|
};
|
|
393
|
+
if (config.baseUrl && config.apiKey) {
|
|
394
|
+
this.contextFetcher = createContextFetcher({
|
|
395
|
+
baseUrl: config.baseUrl,
|
|
396
|
+
apiKey: config.apiKey
|
|
397
|
+
});
|
|
398
|
+
}
|
|
245
399
|
}
|
|
246
400
|
/**
|
|
247
401
|
* Execute a task using Claude Code CLI
|
|
402
|
+
*
|
|
403
|
+
* If full context is available (baseUrl + apiKey configured), fetches
|
|
404
|
+
* organization, project, artifact, and related sections for a rich prompt.
|
|
248
405
|
*/
|
|
249
406
|
async execute(task) {
|
|
250
407
|
try {
|
|
251
|
-
|
|
408
|
+
let prompt;
|
|
409
|
+
let fullContext = null;
|
|
410
|
+
const useFullContext = this.config.useFullContext !== false && this.contextFetcher;
|
|
411
|
+
if (useFullContext) {
|
|
412
|
+
try {
|
|
413
|
+
fullContext = await this.contextFetcher.fetchTaskContext(task.taskId);
|
|
414
|
+
prompt = buildPromptWithContext(fullContext);
|
|
415
|
+
console.log(" \u{1F4DA} Using full context (org, project, artifact, related sections)");
|
|
416
|
+
} catch (contextError) {
|
|
417
|
+
console.warn(" \u26A0\uFE0F Could not fetch full context, using minimal prompt");
|
|
418
|
+
console.warn(` ${contextError instanceof Error ? contextError.message : contextError}`);
|
|
419
|
+
prompt = this.buildTaskPrompt(task);
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
prompt = this.buildTaskPrompt(task);
|
|
423
|
+
}
|
|
252
424
|
const output = await this.runClaude(prompt);
|
|
253
425
|
const { content, summary } = this.parseResponse(output, task.heading);
|
|
254
426
|
return {
|
|
255
427
|
success: true,
|
|
256
428
|
output: content,
|
|
257
|
-
summary
|
|
429
|
+
summary,
|
|
430
|
+
promptUsed: prompt
|
|
258
431
|
};
|
|
259
432
|
} catch (error) {
|
|
260
433
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -673,6 +846,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
673
846
|
console.log(` \u26A0\uFE0F Could not claim: ${error.error || "Unknown error"}`);
|
|
674
847
|
continue;
|
|
675
848
|
}
|
|
849
|
+
const claimedTask = await claimResponse.json().catch(() => ({ id: task.id }));
|
|
850
|
+
const taskUuid = claimedTask.id || task.id;
|
|
676
851
|
activeTasks.add(task.section_id);
|
|
677
852
|
console.log(" \u2713 Claimed!");
|
|
678
853
|
if (dryRun) {
|
|
@@ -683,7 +858,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
683
858
|
console.log(" \u2192 Executing with Claude...");
|
|
684
859
|
try {
|
|
685
860
|
const result = await executor.execute({
|
|
686
|
-
taskId:
|
|
861
|
+
taskId: taskUuid,
|
|
862
|
+
// Use UUID instead of section_id
|
|
687
863
|
heading: task.heading,
|
|
688
864
|
content: task.content,
|
|
689
865
|
artifactId: task.artifact_id,
|
|
@@ -694,7 +870,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
694
870
|
await completeTask({
|
|
695
871
|
baseUrl,
|
|
696
872
|
apiKey,
|
|
697
|
-
taskId:
|
|
873
|
+
taskId: taskUuid,
|
|
874
|
+
// Use UUID instead of section_id
|
|
698
875
|
output: result.output,
|
|
699
876
|
summary: result.summary
|
|
700
877
|
});
|
|
@@ -704,7 +881,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
704
881
|
await blockTask({
|
|
705
882
|
baseUrl,
|
|
706
883
|
apiKey,
|
|
707
|
-
taskId:
|
|
884
|
+
taskId: taskUuid,
|
|
885
|
+
// Use UUID instead of section_id
|
|
708
886
|
reason: result.error || "Execution failed"
|
|
709
887
|
});
|
|
710
888
|
}
|
|
@@ -730,7 +908,11 @@ async function runAgent(options) {
|
|
|
730
908
|
}
|
|
731
909
|
let executor = null;
|
|
732
910
|
if (!options.dryRun) {
|
|
733
|
-
executor = createExecutor(
|
|
911
|
+
executor = createExecutor({
|
|
912
|
+
// Pass API credentials so executor can fetch full context
|
|
913
|
+
baseUrl: options.baseUrl,
|
|
914
|
+
apiKey: credentials.apiKey
|
|
915
|
+
});
|
|
734
916
|
const installed = await executor.isInstalled();
|
|
735
917
|
if (!installed) {
|
|
736
918
|
console.error("\u274C Claude Code CLI not found");
|
|
@@ -746,6 +928,7 @@ async function runAgent(options) {
|
|
|
746
928
|
process.exit(1);
|
|
747
929
|
}
|
|
748
930
|
console.log("\u2705 Claude Code connected");
|
|
931
|
+
console.log("\u{1F4DA} Context fetching enabled (will fetch org/project/artifact context)");
|
|
749
932
|
}
|
|
750
933
|
const listener = createListener({
|
|
751
934
|
apiKey: credentials.apiKey,
|
|
@@ -759,7 +942,9 @@ async function runAgent(options) {
|
|
|
759
942
|
case "connected":
|
|
760
943
|
console.log(`\u2705 Connected as ${credentials.agentId}`);
|
|
761
944
|
console.log("\u{1F442} Listening for tasks...\n");
|
|
762
|
-
|
|
945
|
+
if (!options.dryRun) {
|
|
946
|
+
checkAndClaimTasks(options.baseUrl, credentials.apiKey, credentials.agentId, activeTasks, executor, options.dryRun);
|
|
947
|
+
}
|
|
763
948
|
break;
|
|
764
949
|
case "reconnecting":
|
|
765
950
|
console.log("\u{1F504} Reconnecting...");
|
package/dist/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getCredentials,
|
|
7
7
|
loadCredentials,
|
|
8
8
|
promptForApiKey
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EROV5RIA.mjs";
|
|
10
10
|
|
|
11
11
|
// src/cli.ts
|
|
12
12
|
import { Command } from "commander";
|
|
@@ -101,6 +101,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
101
101
|
console.log(` \u26A0\uFE0F Could not claim: ${error.error || "Unknown error"}`);
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
|
+
const claimedTask = await claimResponse.json().catch(() => ({ id: task.id }));
|
|
105
|
+
const taskUuid = claimedTask.id || task.id;
|
|
104
106
|
activeTasks.add(task.section_id);
|
|
105
107
|
console.log(" \u2713 Claimed!");
|
|
106
108
|
if (dryRun) {
|
|
@@ -111,7 +113,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
111
113
|
console.log(" \u2192 Executing with Claude...");
|
|
112
114
|
try {
|
|
113
115
|
const result = await executor.execute({
|
|
114
|
-
taskId:
|
|
116
|
+
taskId: taskUuid,
|
|
117
|
+
// Use UUID instead of section_id
|
|
115
118
|
heading: task.heading,
|
|
116
119
|
content: task.content,
|
|
117
120
|
artifactId: task.artifact_id,
|
|
@@ -122,7 +125,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
122
125
|
await completeTask({
|
|
123
126
|
baseUrl,
|
|
124
127
|
apiKey,
|
|
125
|
-
taskId:
|
|
128
|
+
taskId: taskUuid,
|
|
129
|
+
// Use UUID instead of section_id
|
|
126
130
|
output: result.output,
|
|
127
131
|
summary: result.summary
|
|
128
132
|
});
|
|
@@ -132,7 +136,8 @@ async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executo
|
|
|
132
136
|
await blockTask({
|
|
133
137
|
baseUrl,
|
|
134
138
|
apiKey,
|
|
135
|
-
taskId:
|
|
139
|
+
taskId: taskUuid,
|
|
140
|
+
// Use UUID instead of section_id
|
|
136
141
|
reason: result.error || "Execution failed"
|
|
137
142
|
});
|
|
138
143
|
}
|
|
@@ -158,7 +163,11 @@ async function runAgent(options) {
|
|
|
158
163
|
}
|
|
159
164
|
let executor = null;
|
|
160
165
|
if (!options.dryRun) {
|
|
161
|
-
executor = createExecutor(
|
|
166
|
+
executor = createExecutor({
|
|
167
|
+
// Pass API credentials so executor can fetch full context
|
|
168
|
+
baseUrl: options.baseUrl,
|
|
169
|
+
apiKey: credentials.apiKey
|
|
170
|
+
});
|
|
162
171
|
const installed = await executor.isInstalled();
|
|
163
172
|
if (!installed) {
|
|
164
173
|
console.error("\u274C Claude Code CLI not found");
|
|
@@ -174,6 +183,7 @@ async function runAgent(options) {
|
|
|
174
183
|
process.exit(1);
|
|
175
184
|
}
|
|
176
185
|
console.log("\u2705 Claude Code connected");
|
|
186
|
+
console.log("\u{1F4DA} Context fetching enabled (will fetch org/project/artifact context)");
|
|
177
187
|
}
|
|
178
188
|
const listener = createListener({
|
|
179
189
|
apiKey: credentials.apiKey,
|
|
@@ -187,7 +197,9 @@ async function runAgent(options) {
|
|
|
187
197
|
case "connected":
|
|
188
198
|
console.log(`\u2705 Connected as ${credentials.agentId}`);
|
|
189
199
|
console.log("\u{1F442} Listening for tasks...\n");
|
|
190
|
-
|
|
200
|
+
if (!options.dryRun) {
|
|
201
|
+
checkAndClaimTasks(options.baseUrl, credentials.apiKey, credentials.agentId, activeTasks, executor, options.dryRun);
|
|
202
|
+
}
|
|
191
203
|
break;
|
|
192
204
|
case "reconnecting":
|
|
193
205
|
console.log("\u{1F504} Reconnecting...");
|
package/dist/index.d.mts
CHANGED
|
@@ -59,6 +59,9 @@ declare function getCredentials(options?: {
|
|
|
59
59
|
*
|
|
60
60
|
* Executes tasks by shelling out to the Claude Code CLI (claude).
|
|
61
61
|
* This uses the user's existing Claude Code authentication - no separate API key needed.
|
|
62
|
+
*
|
|
63
|
+
* Now supports fetching full context (organization, project, artifact, related sections)
|
|
64
|
+
* to provide Claude with the information needed to complete tasks effectively.
|
|
62
65
|
*/
|
|
63
66
|
interface TaskContext {
|
|
64
67
|
/** Task ID (section ID) */
|
|
@@ -85,6 +88,8 @@ interface ExecutionResult {
|
|
|
85
88
|
summary: string;
|
|
86
89
|
/** Any error message if failed */
|
|
87
90
|
error?: string;
|
|
91
|
+
/** The prompt that was used (for debugging) */
|
|
92
|
+
promptUsed?: string;
|
|
88
93
|
}
|
|
89
94
|
interface ExecutorConfig {
|
|
90
95
|
/** Path to claude CLI (default: 'claude') */
|
|
@@ -93,12 +98,22 @@ interface ExecutorConfig {
|
|
|
93
98
|
timeout?: number;
|
|
94
99
|
/** System prompt prefix */
|
|
95
100
|
systemPromptPrefix?: string;
|
|
101
|
+
/** Artyfacts API base URL (for fetching context) */
|
|
102
|
+
baseUrl?: string;
|
|
103
|
+
/** Artyfacts API key (for fetching context) */
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
/** Whether to use full context from API (default: true if apiKey provided) */
|
|
106
|
+
useFullContext?: boolean;
|
|
96
107
|
}
|
|
97
108
|
declare class ClaudeExecutor {
|
|
98
109
|
private config;
|
|
110
|
+
private contextFetcher;
|
|
99
111
|
constructor(config?: ExecutorConfig);
|
|
100
112
|
/**
|
|
101
113
|
* Execute a task using Claude Code CLI
|
|
114
|
+
*
|
|
115
|
+
* If full context is available (baseUrl + apiKey configured), fetches
|
|
116
|
+
* organization, project, artifact, and related sections for a rich prompt.
|
|
102
117
|
*/
|
|
103
118
|
execute(task: TaskContext): Promise<ExecutionResult>;
|
|
104
119
|
/**
|
|
@@ -238,4 +253,67 @@ declare class ArtyfactsListener {
|
|
|
238
253
|
*/
|
|
239
254
|
declare function createListener(config: ListenerConfig): ArtyfactsListener;
|
|
240
255
|
|
|
241
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Context fetcher for Artyfacts tasks
|
|
258
|
+
*
|
|
259
|
+
* Fetches full context including organization, project, artifact, and related sections.
|
|
260
|
+
*/
|
|
261
|
+
interface OrganizationContext {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
context?: string;
|
|
265
|
+
}
|
|
266
|
+
interface ProjectContext {
|
|
267
|
+
id: string;
|
|
268
|
+
name: string;
|
|
269
|
+
description?: string;
|
|
270
|
+
}
|
|
271
|
+
interface SectionContext {
|
|
272
|
+
id: string;
|
|
273
|
+
heading: string;
|
|
274
|
+
content?: string;
|
|
275
|
+
section_type?: string;
|
|
276
|
+
task_status?: string;
|
|
277
|
+
}
|
|
278
|
+
interface ArtifactContext {
|
|
279
|
+
id: string;
|
|
280
|
+
title: string;
|
|
281
|
+
summary?: string;
|
|
282
|
+
description?: string;
|
|
283
|
+
artifact_type?: string;
|
|
284
|
+
sections: SectionContext[];
|
|
285
|
+
}
|
|
286
|
+
interface TaskFullContext {
|
|
287
|
+
task: {
|
|
288
|
+
id: string;
|
|
289
|
+
heading: string;
|
|
290
|
+
content: string;
|
|
291
|
+
expected_output?: {
|
|
292
|
+
format?: string;
|
|
293
|
+
requirements?: string[];
|
|
294
|
+
};
|
|
295
|
+
priority?: number;
|
|
296
|
+
};
|
|
297
|
+
artifact: ArtifactContext;
|
|
298
|
+
project?: ProjectContext;
|
|
299
|
+
organization: OrganizationContext;
|
|
300
|
+
}
|
|
301
|
+
interface ContextFetcherConfig {
|
|
302
|
+
baseUrl: string;
|
|
303
|
+
apiKey: string;
|
|
304
|
+
}
|
|
305
|
+
declare class ContextFetcher {
|
|
306
|
+
private config;
|
|
307
|
+
constructor(config: ContextFetcherConfig);
|
|
308
|
+
/**
|
|
309
|
+
* Fetch full context for a task
|
|
310
|
+
*/
|
|
311
|
+
fetchTaskContext(taskId: string): Promise<TaskFullContext>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Build a rich prompt with full context
|
|
315
|
+
*/
|
|
316
|
+
declare function buildPromptWithContext(context: TaskFullContext): string;
|
|
317
|
+
declare function createContextFetcher(config: ContextFetcherConfig): ContextFetcher;
|
|
318
|
+
|
|
319
|
+
export { type ArtifactContext, type ArtyfactsEvent, ArtyfactsListener, ClaudeExecutor, type ConnectedEvent, type ConnectionState, ContextFetcher, type ContextFetcherConfig, type Credentials, type DeviceAuthResponse, type EventCallback, type ExecutionResult, type ExecutorConfig, type HeartbeatEvent, type ListenerConfig, type OrganizationContext, type ProjectContext, type SectionContext, type TaskAssignedEvent, type TaskContext, type TaskFullContext, type TokenResponse, buildPromptWithContext, clearCredentials, createContextFetcher, createExecutor, createListener, getCredentials, loadCredentials, promptForApiKey, runDeviceAuth, saveCredentials };
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,9 @@ declare function getCredentials(options?: {
|
|
|
59
59
|
*
|
|
60
60
|
* Executes tasks by shelling out to the Claude Code CLI (claude).
|
|
61
61
|
* This uses the user's existing Claude Code authentication - no separate API key needed.
|
|
62
|
+
*
|
|
63
|
+
* Now supports fetching full context (organization, project, artifact, related sections)
|
|
64
|
+
* to provide Claude with the information needed to complete tasks effectively.
|
|
62
65
|
*/
|
|
63
66
|
interface TaskContext {
|
|
64
67
|
/** Task ID (section ID) */
|
|
@@ -85,6 +88,8 @@ interface ExecutionResult {
|
|
|
85
88
|
summary: string;
|
|
86
89
|
/** Any error message if failed */
|
|
87
90
|
error?: string;
|
|
91
|
+
/** The prompt that was used (for debugging) */
|
|
92
|
+
promptUsed?: string;
|
|
88
93
|
}
|
|
89
94
|
interface ExecutorConfig {
|
|
90
95
|
/** Path to claude CLI (default: 'claude') */
|
|
@@ -93,12 +98,22 @@ interface ExecutorConfig {
|
|
|
93
98
|
timeout?: number;
|
|
94
99
|
/** System prompt prefix */
|
|
95
100
|
systemPromptPrefix?: string;
|
|
101
|
+
/** Artyfacts API base URL (for fetching context) */
|
|
102
|
+
baseUrl?: string;
|
|
103
|
+
/** Artyfacts API key (for fetching context) */
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
/** Whether to use full context from API (default: true if apiKey provided) */
|
|
106
|
+
useFullContext?: boolean;
|
|
96
107
|
}
|
|
97
108
|
declare class ClaudeExecutor {
|
|
98
109
|
private config;
|
|
110
|
+
private contextFetcher;
|
|
99
111
|
constructor(config?: ExecutorConfig);
|
|
100
112
|
/**
|
|
101
113
|
* Execute a task using Claude Code CLI
|
|
114
|
+
*
|
|
115
|
+
* If full context is available (baseUrl + apiKey configured), fetches
|
|
116
|
+
* organization, project, artifact, and related sections for a rich prompt.
|
|
102
117
|
*/
|
|
103
118
|
execute(task: TaskContext): Promise<ExecutionResult>;
|
|
104
119
|
/**
|
|
@@ -238,4 +253,67 @@ declare class ArtyfactsListener {
|
|
|
238
253
|
*/
|
|
239
254
|
declare function createListener(config: ListenerConfig): ArtyfactsListener;
|
|
240
255
|
|
|
241
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Context fetcher for Artyfacts tasks
|
|
258
|
+
*
|
|
259
|
+
* Fetches full context including organization, project, artifact, and related sections.
|
|
260
|
+
*/
|
|
261
|
+
interface OrganizationContext {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
context?: string;
|
|
265
|
+
}
|
|
266
|
+
interface ProjectContext {
|
|
267
|
+
id: string;
|
|
268
|
+
name: string;
|
|
269
|
+
description?: string;
|
|
270
|
+
}
|
|
271
|
+
interface SectionContext {
|
|
272
|
+
id: string;
|
|
273
|
+
heading: string;
|
|
274
|
+
content?: string;
|
|
275
|
+
section_type?: string;
|
|
276
|
+
task_status?: string;
|
|
277
|
+
}
|
|
278
|
+
interface ArtifactContext {
|
|
279
|
+
id: string;
|
|
280
|
+
title: string;
|
|
281
|
+
summary?: string;
|
|
282
|
+
description?: string;
|
|
283
|
+
artifact_type?: string;
|
|
284
|
+
sections: SectionContext[];
|
|
285
|
+
}
|
|
286
|
+
interface TaskFullContext {
|
|
287
|
+
task: {
|
|
288
|
+
id: string;
|
|
289
|
+
heading: string;
|
|
290
|
+
content: string;
|
|
291
|
+
expected_output?: {
|
|
292
|
+
format?: string;
|
|
293
|
+
requirements?: string[];
|
|
294
|
+
};
|
|
295
|
+
priority?: number;
|
|
296
|
+
};
|
|
297
|
+
artifact: ArtifactContext;
|
|
298
|
+
project?: ProjectContext;
|
|
299
|
+
organization: OrganizationContext;
|
|
300
|
+
}
|
|
301
|
+
interface ContextFetcherConfig {
|
|
302
|
+
baseUrl: string;
|
|
303
|
+
apiKey: string;
|
|
304
|
+
}
|
|
305
|
+
declare class ContextFetcher {
|
|
306
|
+
private config;
|
|
307
|
+
constructor(config: ContextFetcherConfig);
|
|
308
|
+
/**
|
|
309
|
+
* Fetch full context for a task
|
|
310
|
+
*/
|
|
311
|
+
fetchTaskContext(taskId: string): Promise<TaskFullContext>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Build a rich prompt with full context
|
|
315
|
+
*/
|
|
316
|
+
declare function buildPromptWithContext(context: TaskFullContext): string;
|
|
317
|
+
declare function createContextFetcher(config: ContextFetcherConfig): ContextFetcher;
|
|
318
|
+
|
|
319
|
+
export { type ArtifactContext, type ArtyfactsEvent, ArtyfactsListener, ClaudeExecutor, type ConnectedEvent, type ConnectionState, ContextFetcher, type ContextFetcherConfig, type Credentials, type DeviceAuthResponse, type EventCallback, type ExecutionResult, type ExecutorConfig, type HeartbeatEvent, type ListenerConfig, type OrganizationContext, type ProjectContext, type SectionContext, type TaskAssignedEvent, type TaskContext, type TaskFullContext, type TokenResponse, buildPromptWithContext, clearCredentials, createContextFetcher, createExecutor, createListener, getCredentials, loadCredentials, promptForApiKey, runDeviceAuth, saveCredentials };
|