@artyfacts/claude 1.1.1 → 1.2.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/chunk-EROV5RIA.mjs +741 -0
- package/dist/cli.js +266 -3
- package/dist/cli.mjs +92 -2
- 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 +136 -2
- 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);
|
|
@@ -637,6 +810,88 @@ program.command("status").description("Check authentication and connection statu
|
|
|
637
810
|
console.log(" Install: npm install -g @anthropic-ai/claude-code");
|
|
638
811
|
}
|
|
639
812
|
});
|
|
813
|
+
async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executor, dryRun) {
|
|
814
|
+
try {
|
|
815
|
+
const response = await fetch(`${baseUrl}/tasks/queue?limit=5`, {
|
|
816
|
+
headers: {
|
|
817
|
+
"Authorization": `Bearer ${apiKey}`
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
if (!response.ok) {
|
|
821
|
+
console.log("\u26A0\uFE0F Could not fetch task queue");
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
const data = await response.json();
|
|
825
|
+
const tasks = data.tasks || [];
|
|
826
|
+
if (tasks.length === 0) {
|
|
827
|
+
console.log("\u{1F4ED} No claimable tasks in queue");
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
console.log(`\u{1F4EC} Found ${tasks.length} claimable task(s)`);
|
|
831
|
+
for (const task of tasks) {
|
|
832
|
+
if (activeTasks.has(task.section_id)) {
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
console.log(`
|
|
836
|
+
[Claiming] ${task.heading}`);
|
|
837
|
+
const claimResponse = await fetch(`${baseUrl}/tasks/${task.section_id}/claim`, {
|
|
838
|
+
method: "POST",
|
|
839
|
+
headers: {
|
|
840
|
+
"Authorization": `Bearer ${apiKey}`,
|
|
841
|
+
"Content-Type": "application/json"
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
if (!claimResponse.ok) {
|
|
845
|
+
const error = await claimResponse.json().catch(() => ({}));
|
|
846
|
+
console.log(` \u26A0\uFE0F Could not claim: ${error.error || "Unknown error"}`);
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
activeTasks.add(task.section_id);
|
|
850
|
+
console.log(" \u2713 Claimed!");
|
|
851
|
+
if (dryRun) {
|
|
852
|
+
console.log(" \u{1F4CB} Dry run - not executing");
|
|
853
|
+
activeTasks.delete(task.section_id);
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
console.log(" \u2192 Executing with Claude...");
|
|
857
|
+
try {
|
|
858
|
+
const result = await executor.execute({
|
|
859
|
+
taskId: task.section_id,
|
|
860
|
+
heading: task.heading,
|
|
861
|
+
content: task.content,
|
|
862
|
+
artifactId: task.artifact_id,
|
|
863
|
+
artifactTitle: task.artifact_title,
|
|
864
|
+
priority: task.priority
|
|
865
|
+
});
|
|
866
|
+
if (result.success) {
|
|
867
|
+
await completeTask({
|
|
868
|
+
baseUrl,
|
|
869
|
+
apiKey,
|
|
870
|
+
taskId: task.section_id,
|
|
871
|
+
output: result.output,
|
|
872
|
+
summary: result.summary
|
|
873
|
+
});
|
|
874
|
+
console.log(` \u2192 \u2705 Completed! ${result.summary}`);
|
|
875
|
+
} else {
|
|
876
|
+
console.log(` \u2192 \u274C Failed: ${result.error}`);
|
|
877
|
+
await blockTask({
|
|
878
|
+
baseUrl,
|
|
879
|
+
apiKey,
|
|
880
|
+
taskId: task.section_id,
|
|
881
|
+
reason: result.error || "Execution failed"
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
} catch (error) {
|
|
885
|
+
console.error(` \u2192 \u274C Error:`, error instanceof Error ? error.message : error);
|
|
886
|
+
} finally {
|
|
887
|
+
activeTasks.delete(task.section_id);
|
|
888
|
+
}
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
} catch (error) {
|
|
892
|
+
console.error("Error checking task queue:", error instanceof Error ? error.message : error);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
640
895
|
async function runAgent(options) {
|
|
641
896
|
console.log("\u{1F517} Connecting to Artyfacts...");
|
|
642
897
|
let credentials;
|
|
@@ -648,7 +903,11 @@ async function runAgent(options) {
|
|
|
648
903
|
}
|
|
649
904
|
let executor = null;
|
|
650
905
|
if (!options.dryRun) {
|
|
651
|
-
executor = createExecutor(
|
|
906
|
+
executor = createExecutor({
|
|
907
|
+
// Pass API credentials so executor can fetch full context
|
|
908
|
+
baseUrl: options.baseUrl,
|
|
909
|
+
apiKey: credentials.apiKey
|
|
910
|
+
});
|
|
652
911
|
const installed = await executor.isInstalled();
|
|
653
912
|
if (!installed) {
|
|
654
913
|
console.error("\u274C Claude Code CLI not found");
|
|
@@ -664,6 +923,7 @@ async function runAgent(options) {
|
|
|
664
923
|
process.exit(1);
|
|
665
924
|
}
|
|
666
925
|
console.log("\u2705 Claude Code connected");
|
|
926
|
+
console.log("\u{1F4DA} Context fetching enabled (will fetch org/project/artifact context)");
|
|
667
927
|
}
|
|
668
928
|
const listener = createListener({
|
|
669
929
|
apiKey: credentials.apiKey,
|
|
@@ -677,6 +937,9 @@ async function runAgent(options) {
|
|
|
677
937
|
case "connected":
|
|
678
938
|
console.log(`\u2705 Connected as ${credentials.agentId}`);
|
|
679
939
|
console.log("\u{1F442} Listening for tasks...\n");
|
|
940
|
+
if (!options.dryRun) {
|
|
941
|
+
checkAndClaimTasks(options.baseUrl, credentials.apiKey, credentials.agentId, activeTasks, executor, options.dryRun);
|
|
942
|
+
}
|
|
680
943
|
break;
|
|
681
944
|
case "reconnecting":
|
|
682
945
|
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";
|
|
@@ -65,6 +65,88 @@ program.command("status").description("Check authentication and connection statu
|
|
|
65
65
|
console.log(" Install: npm install -g @anthropic-ai/claude-code");
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
async function checkAndClaimTasks(baseUrl, apiKey, agentId, activeTasks, executor, dryRun) {
|
|
69
|
+
try {
|
|
70
|
+
const response = await fetch(`${baseUrl}/tasks/queue?limit=5`, {
|
|
71
|
+
headers: {
|
|
72
|
+
"Authorization": `Bearer ${apiKey}`
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
console.log("\u26A0\uFE0F Could not fetch task queue");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const data = await response.json();
|
|
80
|
+
const tasks = data.tasks || [];
|
|
81
|
+
if (tasks.length === 0) {
|
|
82
|
+
console.log("\u{1F4ED} No claimable tasks in queue");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
console.log(`\u{1F4EC} Found ${tasks.length} claimable task(s)`);
|
|
86
|
+
for (const task of tasks) {
|
|
87
|
+
if (activeTasks.has(task.section_id)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
console.log(`
|
|
91
|
+
[Claiming] ${task.heading}`);
|
|
92
|
+
const claimResponse = await fetch(`${baseUrl}/tasks/${task.section_id}/claim`, {
|
|
93
|
+
method: "POST",
|
|
94
|
+
headers: {
|
|
95
|
+
"Authorization": `Bearer ${apiKey}`,
|
|
96
|
+
"Content-Type": "application/json"
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (!claimResponse.ok) {
|
|
100
|
+
const error = await claimResponse.json().catch(() => ({}));
|
|
101
|
+
console.log(` \u26A0\uFE0F Could not claim: ${error.error || "Unknown error"}`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
activeTasks.add(task.section_id);
|
|
105
|
+
console.log(" \u2713 Claimed!");
|
|
106
|
+
if (dryRun) {
|
|
107
|
+
console.log(" \u{1F4CB} Dry run - not executing");
|
|
108
|
+
activeTasks.delete(task.section_id);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
console.log(" \u2192 Executing with Claude...");
|
|
112
|
+
try {
|
|
113
|
+
const result = await executor.execute({
|
|
114
|
+
taskId: task.section_id,
|
|
115
|
+
heading: task.heading,
|
|
116
|
+
content: task.content,
|
|
117
|
+
artifactId: task.artifact_id,
|
|
118
|
+
artifactTitle: task.artifact_title,
|
|
119
|
+
priority: task.priority
|
|
120
|
+
});
|
|
121
|
+
if (result.success) {
|
|
122
|
+
await completeTask({
|
|
123
|
+
baseUrl,
|
|
124
|
+
apiKey,
|
|
125
|
+
taskId: task.section_id,
|
|
126
|
+
output: result.output,
|
|
127
|
+
summary: result.summary
|
|
128
|
+
});
|
|
129
|
+
console.log(` \u2192 \u2705 Completed! ${result.summary}`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log(` \u2192 \u274C Failed: ${result.error}`);
|
|
132
|
+
await blockTask({
|
|
133
|
+
baseUrl,
|
|
134
|
+
apiKey,
|
|
135
|
+
taskId: task.section_id,
|
|
136
|
+
reason: result.error || "Execution failed"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error(` \u2192 \u274C Error:`, error instanceof Error ? error.message : error);
|
|
141
|
+
} finally {
|
|
142
|
+
activeTasks.delete(task.section_id);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error("Error checking task queue:", error instanceof Error ? error.message : error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
68
150
|
async function runAgent(options) {
|
|
69
151
|
console.log("\u{1F517} Connecting to Artyfacts...");
|
|
70
152
|
let credentials;
|
|
@@ -76,7 +158,11 @@ async function runAgent(options) {
|
|
|
76
158
|
}
|
|
77
159
|
let executor = null;
|
|
78
160
|
if (!options.dryRun) {
|
|
79
|
-
executor = createExecutor(
|
|
161
|
+
executor = createExecutor({
|
|
162
|
+
// Pass API credentials so executor can fetch full context
|
|
163
|
+
baseUrl: options.baseUrl,
|
|
164
|
+
apiKey: credentials.apiKey
|
|
165
|
+
});
|
|
80
166
|
const installed = await executor.isInstalled();
|
|
81
167
|
if (!installed) {
|
|
82
168
|
console.error("\u274C Claude Code CLI not found");
|
|
@@ -92,6 +178,7 @@ async function runAgent(options) {
|
|
|
92
178
|
process.exit(1);
|
|
93
179
|
}
|
|
94
180
|
console.log("\u2705 Claude Code connected");
|
|
181
|
+
console.log("\u{1F4DA} Context fetching enabled (will fetch org/project/artifact context)");
|
|
95
182
|
}
|
|
96
183
|
const listener = createListener({
|
|
97
184
|
apiKey: credentials.apiKey,
|
|
@@ -105,6 +192,9 @@ async function runAgent(options) {
|
|
|
105
192
|
case "connected":
|
|
106
193
|
console.log(`\u2705 Connected as ${credentials.agentId}`);
|
|
107
194
|
console.log("\u{1F442} Listening for tasks...\n");
|
|
195
|
+
if (!options.dryRun) {
|
|
196
|
+
checkAndClaimTasks(options.baseUrl, credentials.apiKey, credentials.agentId, activeTasks, executor, options.dryRun);
|
|
197
|
+
}
|
|
108
198
|
break;
|
|
109
199
|
case "reconnecting":
|
|
110
200
|
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 };
|