warden-code 0.1.4 → 1.0.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/README.md +27 -7
- package/dist/cli/commands/build.d.ts +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +235 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/chat.d.ts +3 -0
- package/dist/cli/commands/chat.d.ts.map +1 -0
- package/dist/cli/commands/chat.js +214 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/index.d.ts +2 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +2 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/new.d.ts.map +1 -1
- package/dist/cli/commands/new.js +4 -1
- package/dist/cli/commands/new.js.map +1 -1
- package/dist/cli/index.js +5 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/services/agent/a2a-client.d.ts +21 -0
- package/dist/cli/services/agent/a2a-client.d.ts.map +1 -0
- package/dist/cli/services/agent/a2a-client.js +78 -0
- package/dist/cli/services/agent/a2a-client.js.map +1 -0
- package/dist/cli/services/agent/langgraph-client.d.ts +10 -0
- package/dist/cli/services/agent/langgraph-client.d.ts.map +1 -0
- package/dist/cli/services/agent/langgraph-client.js +50 -0
- package/dist/cli/services/agent/langgraph-client.js.map +1 -0
- package/dist/cli/services/agent/probe.d.ts +3 -0
- package/dist/cli/services/agent/probe.d.ts.map +1 -0
- package/dist/cli/services/agent/probe.js +58 -0
- package/dist/cli/services/agent/probe.js.map +1 -0
- package/dist/cli/services/agent/types.d.ts +94 -0
- package/dist/cli/services/agent/types.d.ts.map +1 -0
- package/dist/cli/services/agent/types.js +2 -0
- package/dist/cli/services/agent/types.js.map +1 -0
- package/dist/cli/services/ai/anthropic.d.ts +8 -0
- package/dist/cli/services/ai/anthropic.d.ts.map +1 -0
- package/dist/cli/services/ai/anthropic.js +25 -0
- package/dist/cli/services/ai/anthropic.js.map +1 -0
- package/dist/cli/services/ai/context.d.ts +12 -0
- package/dist/cli/services/ai/context.d.ts.map +1 -0
- package/dist/cli/services/ai/context.js +72 -0
- package/dist/cli/services/ai/context.js.map +1 -0
- package/dist/cli/services/ai/openai.d.ts +8 -0
- package/dist/cli/services/ai/openai.d.ts.map +1 -0
- package/dist/cli/services/ai/openai.js +20 -0
- package/dist/cli/services/ai/openai.js.map +1 -0
- package/dist/cli/services/ai/provider.d.ts +15 -0
- package/dist/cli/services/ai/provider.d.ts.map +1 -0
- package/dist/cli/services/ai/provider.js +83 -0
- package/dist/cli/services/ai/provider.js.map +1 -0
- package/dist/cli/services/config.d.ts +8 -0
- package/dist/cli/services/config.d.ts.map +1 -0
- package/dist/cli/services/config.js +22 -0
- package/dist/cli/services/config.js.map +1 -0
- package/dist/templates/gitignore.template +1 -0
- package/package.json +3 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as readline from "node:readline";
|
|
3
3
|
import { createContext } from "./context.js";
|
|
4
|
-
import { CommandRegistry, createHelpCommand, clearCommand, exitCommand, newCommand, } from "./commands/index.js";
|
|
4
|
+
import { CommandRegistry, createHelpCommand, clearCommand, exitCommand, newCommand, buildCommand, chatCommand, } from "./commands/index.js";
|
|
5
5
|
import { banner, prompt } from "./ui/format.js";
|
|
6
6
|
async function main() {
|
|
7
7
|
const context = createContext(process.cwd());
|
|
@@ -11,12 +11,16 @@ async function main() {
|
|
|
11
11
|
registry.register(clearCommand);
|
|
12
12
|
registry.register(exitCommand);
|
|
13
13
|
registry.register(newCommand);
|
|
14
|
+
registry.register(buildCommand);
|
|
15
|
+
registry.register(chatCommand);
|
|
14
16
|
// Display welcome banner and available commands
|
|
15
17
|
console.log(banner());
|
|
16
18
|
await registry.execute("/help", context);
|
|
19
|
+
const history = [];
|
|
17
20
|
const createRl = () => readline.createInterface({
|
|
18
21
|
input: process.stdin,
|
|
19
22
|
output: process.stdout,
|
|
23
|
+
history,
|
|
20
24
|
});
|
|
21
25
|
let rl = createRl();
|
|
22
26
|
let pausedForCommand = false;
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEhD,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IAEvC,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,WAAW,C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KAAK,CAAC;gBACzB,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,GAAG,CACb,2DAA2D,CAC5D,CAAC;YACJ,CAAC;YAED,UAAU,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,UAAU,EAAE,CAAC;AACf,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AgentClient } from "./types.js";
|
|
2
|
+
export declare class AgentRequestError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly body: string;
|
|
5
|
+
constructor(status: number, body: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class AgentProtocolError extends Error {
|
|
8
|
+
readonly code: number;
|
|
9
|
+
readonly detail: string;
|
|
10
|
+
constructor(code: number, detail: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class A2AClient implements AgentClient {
|
|
13
|
+
private readonly baseUrl;
|
|
14
|
+
readonly protocol: "a2a";
|
|
15
|
+
private contextId;
|
|
16
|
+
private messageCounter;
|
|
17
|
+
constructor(baseUrl: string);
|
|
18
|
+
connect(): Promise<void>;
|
|
19
|
+
send(message: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=a2a-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-client.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/agent/a2a-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,YAAY,CAAC;AAEpB,qBAAa,iBAAkB,SAAQ,KAAK;aAExB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CAK/B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;aAEzB,IAAI,EAAE,MAAM;aACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAKjC;AAED,qBAAa,SAAU,YAAW,WAAW;IAK/B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,QAAQ,CAAC,QAAQ,EAAG,KAAK,CAAU;IACnC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,cAAc,CAAK;gBAEE,OAAO,EAAE,MAAM;IAEtC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAuD7C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export class AgentRequestError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
body;
|
|
4
|
+
constructor(status, body) {
|
|
5
|
+
super(`Agent returned HTTP ${status}`);
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.body = body;
|
|
8
|
+
this.name = "AgentRequestError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class AgentProtocolError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
detail;
|
|
14
|
+
constructor(code, detail) {
|
|
15
|
+
super(`Agent protocol error ${code}: ${detail}`);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.detail = detail;
|
|
18
|
+
this.name = "AgentProtocolError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class A2AClient {
|
|
22
|
+
baseUrl;
|
|
23
|
+
protocol = "a2a";
|
|
24
|
+
contextId;
|
|
25
|
+
messageCounter = 0;
|
|
26
|
+
constructor(baseUrl) {
|
|
27
|
+
this.baseUrl = baseUrl;
|
|
28
|
+
}
|
|
29
|
+
async connect() {
|
|
30
|
+
// A2A is stateless on connect; contextId is established on first response
|
|
31
|
+
}
|
|
32
|
+
async send(message) {
|
|
33
|
+
const messageId = `msg-${++this.messageCounter}-${Date.now()}`;
|
|
34
|
+
const body = {
|
|
35
|
+
jsonrpc: "2.0",
|
|
36
|
+
id: messageId,
|
|
37
|
+
method: "message/send",
|
|
38
|
+
params: {
|
|
39
|
+
message: {
|
|
40
|
+
role: "user",
|
|
41
|
+
parts: [{ kind: "text", text: message }],
|
|
42
|
+
messageId,
|
|
43
|
+
...(this.contextId ? { contextId: this.contextId } : {}),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const res = await fetch(this.baseUrl, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: { "Content-Type": "application/json" },
|
|
50
|
+
body: JSON.stringify(body),
|
|
51
|
+
});
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
throw new AgentRequestError(res.status, await res.text());
|
|
54
|
+
}
|
|
55
|
+
const json = (await res.json());
|
|
56
|
+
if (json.error) {
|
|
57
|
+
throw new AgentProtocolError(json.error.code, json.error.message);
|
|
58
|
+
}
|
|
59
|
+
if (json.result?.context_id) {
|
|
60
|
+
this.contextId = json.result.context_id;
|
|
61
|
+
}
|
|
62
|
+
// Extract agent text from history (preferred) or artifacts (fallback)
|
|
63
|
+
const historyTexts = (json.result?.history ?? [])
|
|
64
|
+
.filter((m) => m.role === "agent")
|
|
65
|
+
.flatMap((m) => m.parts)
|
|
66
|
+
.filter((p) => p.kind === "text")
|
|
67
|
+
.map((p) => p.text);
|
|
68
|
+
if (historyTexts.length > 0) {
|
|
69
|
+
return historyTexts.join("\n");
|
|
70
|
+
}
|
|
71
|
+
const artifactTexts = (json.result?.artifacts ?? [])
|
|
72
|
+
.flatMap((a) => a.parts)
|
|
73
|
+
.filter((p) => p.kind === "text")
|
|
74
|
+
.map((p) => p.text);
|
|
75
|
+
return artifactTexts.join("\n") || "(empty response)";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=a2a-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-client.js","sourceRoot":"","sources":["../../../../src/cli/services/agent/a2a-client.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAExB;IACA;IAFlB,YACkB,MAAc,EACd,IAAY;QAE5B,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;QAHvB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEzB;IACA;IAFlB,YACkB,IAAY,EACZ,MAAc;QAE9B,KAAK,CAAC,wBAAwB,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;QAHjC,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QAG9B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,SAAS;IAKS;IAJpB,QAAQ,GAAG,KAAc,CAAC;IAC3B,SAAS,CAAqB;IAC9B,cAAc,GAAG,CAAC,CAAC;IAE3B,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,KAAK,CAAC,OAAO;QACX,0EAA0E;IAC5E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAe;QACxB,MAAM,SAAS,GAAG,OAAO,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAE/D,MAAM,IAAI,GAAsB;YAC9B,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,SAAS;YACb,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ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AC;aACvB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;aAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAEtB,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAED,MAAM,aAAa,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;aACjD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;aACvB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;aAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAEtB,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentClient } from "./types.js";
|
|
2
|
+
export declare class LangGraphClient implements AgentClient {
|
|
3
|
+
private readonly baseUrl;
|
|
4
|
+
readonly protocol: "langgraph";
|
|
5
|
+
private threadId;
|
|
6
|
+
constructor(baseUrl: string);
|
|
7
|
+
connect(): Promise<void>;
|
|
8
|
+
send(message: string): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=langgraph-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langgraph-client.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/agent/langgraph-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAIZ,MAAM,YAAY,CAAC;AAGpB,qBAAa,eAAgB,YAAW,WAAW;IAIrC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,QAAQ,CAAC,QAAQ,EAAG,WAAW,CAAU;IACzC,OAAO,CAAC,QAAQ,CAAqB;gBAER,OAAO,EAAE,MAAM;IAEtC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAexB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA0C7C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AgentRequestError } from "./a2a-client.js";
|
|
2
|
+
export class LangGraphClient {
|
|
3
|
+
baseUrl;
|
|
4
|
+
protocol = "langgraph";
|
|
5
|
+
threadId;
|
|
6
|
+
constructor(baseUrl) {
|
|
7
|
+
this.baseUrl = baseUrl;
|
|
8
|
+
}
|
|
9
|
+
async connect() {
|
|
10
|
+
const res = await fetch(`${this.baseUrl}/threads`, {
|
|
11
|
+
method: "POST",
|
|
12
|
+
headers: { "Content-Type": "application/json" },
|
|
13
|
+
body: JSON.stringify({}),
|
|
14
|
+
});
|
|
15
|
+
if (!res.ok) {
|
|
16
|
+
throw new AgentRequestError(res.status, await res.text());
|
|
17
|
+
}
|
|
18
|
+
const thread = (await res.json());
|
|
19
|
+
this.threadId = thread.thread_id;
|
|
20
|
+
}
|
|
21
|
+
async send(message) {
|
|
22
|
+
if (!this.threadId) {
|
|
23
|
+
throw new Error("Not connected. Call connect() first.");
|
|
24
|
+
}
|
|
25
|
+
const body = {
|
|
26
|
+
assistant_id: "default",
|
|
27
|
+
input: {
|
|
28
|
+
messages: [{ role: "human", content: message }],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const res = await fetch(`${this.baseUrl}/threads/${this.threadId}/runs/wait`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: { "Content-Type": "application/json" },
|
|
34
|
+
body: JSON.stringify(body),
|
|
35
|
+
});
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
throw new AgentRequestError(res.status, await res.text());
|
|
38
|
+
}
|
|
39
|
+
const json = (await res.json());
|
|
40
|
+
// Try values.messages (actual), then output.messages, then top-level
|
|
41
|
+
const messages = json.values?.messages ?? json.output?.messages ?? json.messages ?? [];
|
|
42
|
+
// Messages use "type" (actual) or "role" to indicate the sender
|
|
43
|
+
const aiMessages = messages.filter((m) => m.type === "ai" || m.role === "ai");
|
|
44
|
+
if (aiMessages.length === 0) {
|
|
45
|
+
return "(empty response)";
|
|
46
|
+
}
|
|
47
|
+
return aiMessages.map((m) => m.content).join("\n");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=langgraph-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langgraph-client.js","sourceRoot":"","sources":["../../../../src/cli/services/agent/langgraph-client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,OAAO,eAAe;IAIG;IAHpB,QAAQ,GAAG,WAAoB,CAAC;IACjC,QAAQ,CAAqB;IAErC,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,KAAK,CAAC,OAAO;QACX,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,UAAU,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;SACzB,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAoB,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC;IACnC,CAAC;IA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CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/agent/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,WAAW,EAAgB,MAAM,YAAY,CAAC;AAwDvE,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAMtE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const PROBE_TIMEOUT_MS = 5_000;
|
|
2
|
+
function isJsonResponse(res) {
|
|
3
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
4
|
+
return ct.includes("application/json");
|
|
5
|
+
}
|
|
6
|
+
async function probeA2A(baseUrl) {
|
|
7
|
+
try {
|
|
8
|
+
const res = await fetch(`${baseUrl}/.well-known/agent-card.json`, {
|
|
9
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
10
|
+
});
|
|
11
|
+
if (!res.ok || !isJsonResponse(res))
|
|
12
|
+
return null;
|
|
13
|
+
const card = (await res.json());
|
|
14
|
+
if (!card.name)
|
|
15
|
+
return null;
|
|
16
|
+
return {
|
|
17
|
+
protocol: "a2a",
|
|
18
|
+
name: card.name,
|
|
19
|
+
description: card.description,
|
|
20
|
+
capabilities: [
|
|
21
|
+
card.capabilities?.streaming ? "streaming" : "",
|
|
22
|
+
card.capabilities?.multiTurn ? "multi-turn" : "",
|
|
23
|
+
...(card.skills?.map((s) => s.name) ?? []),
|
|
24
|
+
].filter(Boolean),
|
|
25
|
+
url: baseUrl,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function probeLangGraph(baseUrl) {
|
|
33
|
+
try {
|
|
34
|
+
const infoRes = await fetch(`${baseUrl}/info`, {
|
|
35
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
36
|
+
});
|
|
37
|
+
if (!infoRes.ok || !isJsonResponse(infoRes))
|
|
38
|
+
return null;
|
|
39
|
+
const info = (await infoRes.json());
|
|
40
|
+
return {
|
|
41
|
+
protocol: "langgraph",
|
|
42
|
+
name: info.name || "LangGraph Agent",
|
|
43
|
+
description: info.description,
|
|
44
|
+
url: baseUrl,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function probeAgent(baseUrl) {
|
|
52
|
+
const [a2a, langgraph] = await Promise.all([
|
|
53
|
+
probeA2A(baseUrl),
|
|
54
|
+
probeLangGraph(baseUrl),
|
|
55
|
+
]);
|
|
56
|
+
return { a2a, langgraph };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../../../src/cli/services/agent/probe.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,SAAS,cAAc,CAAC,GAAa;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACjD,OAAO,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AACzC,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,OAAe;IACrC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,8BAA8B,EAAE;YAChE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC;SAC9C,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC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,EAAE,OAAO;SACb,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzC,QAAQ,CAAC,OAAO,CAAC;QACjB,cAAc,CAAC,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type ProtocolKind = "a2a" | "langgraph";
|
|
2
|
+
export interface AgentInfo {
|
|
3
|
+
protocol: ProtocolKind;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
capabilities?: string[];
|
|
7
|
+
url: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ProbeResult {
|
|
10
|
+
a2a: AgentInfo | null;
|
|
11
|
+
langgraph: AgentInfo | null;
|
|
12
|
+
}
|
|
13
|
+
export interface AgentClient {
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
send(message: string): Promise<string>;
|
|
16
|
+
readonly protocol: ProtocolKind;
|
|
17
|
+
}
|
|
18
|
+
export interface A2AAgentCard {
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
url: string;
|
|
22
|
+
capabilities?: {
|
|
23
|
+
streaming?: boolean;
|
|
24
|
+
multiTurn?: boolean;
|
|
25
|
+
};
|
|
26
|
+
skills?: Array<{
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export interface A2APart {
|
|
33
|
+
kind: "text";
|
|
34
|
+
text: string;
|
|
35
|
+
}
|
|
36
|
+
export interface A2AMessage {
|
|
37
|
+
role: "user" | "agent";
|
|
38
|
+
parts: A2APart[];
|
|
39
|
+
messageId: string;
|
|
40
|
+
contextId?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface A2AJsonRpcRequest {
|
|
43
|
+
jsonrpc: "2.0";
|
|
44
|
+
id: string;
|
|
45
|
+
method: "message/send";
|
|
46
|
+
params: {
|
|
47
|
+
message: A2AMessage;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface A2AJsonRpcResponse {
|
|
51
|
+
jsonrpc: "2.0";
|
|
52
|
+
id: string;
|
|
53
|
+
result?: {
|
|
54
|
+
context_id?: string;
|
|
55
|
+
history?: Array<{
|
|
56
|
+
role: "user" | "agent";
|
|
57
|
+
parts: A2APart[];
|
|
58
|
+
}>;
|
|
59
|
+
artifacts?: Array<{
|
|
60
|
+
parts: A2APart[];
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
63
|
+
error?: {
|
|
64
|
+
code: number;
|
|
65
|
+
message: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export interface LangGraphThread {
|
|
69
|
+
thread_id: string;
|
|
70
|
+
}
|
|
71
|
+
export interface LangGraphMessage {
|
|
72
|
+
type?: "human" | "ai";
|
|
73
|
+
role?: "human" | "ai";
|
|
74
|
+
content: string;
|
|
75
|
+
}
|
|
76
|
+
export interface LangGraphRunRequest {
|
|
77
|
+
assistant_id: string;
|
|
78
|
+
input: {
|
|
79
|
+
messages: Array<{
|
|
80
|
+
role: "human";
|
|
81
|
+
content: string;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface LangGraphRunResponse {
|
|
86
|
+
values?: {
|
|
87
|
+
messages?: LangGraphMessage[];
|
|
88
|
+
};
|
|
89
|
+
output?: {
|
|
90
|
+
messages?: LangGraphMessage[];
|
|
91
|
+
};
|
|
92
|
+
messages?: LangGraphMessage[];
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types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AQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/cli/services/agent/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AIProvider, Message } from "./provider.js";
|
|
2
|
+
export declare class AnthropicProvider implements AIProvider {
|
|
3
|
+
private client;
|
|
4
|
+
private model;
|
|
5
|
+
constructor(apiKey: string, model: string);
|
|
6
|
+
chat(messages: Message[]): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/ai/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEzD,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKnC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBjD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
export class AnthropicProvider {
|
|
3
|
+
client;
|
|
4
|
+
model;
|
|
5
|
+
constructor(apiKey, model) {
|
|
6
|
+
this.client = new Anthropic({ apiKey });
|
|
7
|
+
this.model = model;
|
|
8
|
+
}
|
|
9
|
+
async chat(messages) {
|
|
10
|
+
const systemMessage = messages.find((m) => m.role === "system");
|
|
11
|
+
const nonSystemMessages = messages.filter((m) => m.role !== "system");
|
|
12
|
+
const response = await this.client.messages.create({
|
|
13
|
+
model: this.model,
|
|
14
|
+
max_tokens: 8192,
|
|
15
|
+
system: systemMessage?.content || "",
|
|
16
|
+
messages: nonSystemMessages.map((m) => ({
|
|
17
|
+
role: m.role,
|
|
18
|
+
content: m.content,
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
21
|
+
const textBlock = response.content.find((block) => block.type === "text");
|
|
22
|
+
return textBlock && "text" in textBlock ? textBlock.text : "";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../../src/cli/services/ai/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAG1C,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAY;IAClB,KAAK,CAAS;IAEtB,YAAY,MAAc,EAAE,KAAa;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAmB;QAC5B,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;QAChE,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;QAEtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YACjD,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,aAAa,EAAE,OAAO,IAAI,EAAE;YACpC,QAAQ,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACtC,IAAI,EAAE,CAAC,CAAC,IAA4B;gBACpC,OAAO,EAAE,CAAC,CAAC,OAAO;aACnB,CAAC,CAAC;SACJ,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QAC1E,OAAO,SAAS,IAAI,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function buildProjectContext(projectDir: string): Promise<string>;
|
|
2
|
+
export interface FileChange {
|
|
3
|
+
filePath: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseResponse(response: string): {
|
|
7
|
+
text: string;
|
|
8
|
+
changes: FileChange[];
|
|
9
|
+
};
|
|
10
|
+
export declare function applyChanges(projectDir: string, changes: FileChange[]): Promise<string[]>;
|
|
11
|
+
export declare const SYSTEM_PROMPT = "You are an expert AI agent developer. You help users build and modify agents built with the @wardenprotocol/agent-kit package.\n\nThe user has a scaffolded agent project. You will receive the current project files as context.\n\nWhen the user asks you to make changes, respond with:\n1. A brief explanation of what you're changing and why\n2. The updated file contents using code blocks tagged with the file path\n\nFormat code changes like this:\n```typescript:src/agent.ts\n// full updated file content here\n```\n\nImportant rules:\n- Always include the COMPLETE file content in code blocks, not just the changed parts\n- Only include code blocks for files you are actually modifying\n- The agent handler is in src/agent.ts \u2014 this is the main file users work on\n- The server setup is in src/server.ts \u2014 only modify this if the user specifically asks for server changes\n- If the user needs new npm packages, mention them and update package.json\n- Keep code clean, well-typed, and following TypeScript best practices\n- The project uses ES modules (\"type\": \"module\") with NodeNext module resolution\n";
|
|
12
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/ai/context.ts"],"names":[],"mappings":"AAWA,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB,CAoBA;AAED,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAU,EAAE,GACpB,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB;AAED,eAAO,MAAM,aAAa,mmCAqBzB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { writeFile } from "../project.js";
|
|
4
|
+
const PROJECT_FILES = [
|
|
5
|
+
"src/agent.ts",
|
|
6
|
+
"src/server.ts",
|
|
7
|
+
"package.json",
|
|
8
|
+
".env.example",
|
|
9
|
+
];
|
|
10
|
+
export async function buildProjectContext(projectDir) {
|
|
11
|
+
const sections = [];
|
|
12
|
+
for (const file of PROJECT_FILES) {
|
|
13
|
+
try {
|
|
14
|
+
const content = await fs.readFile(path.join(projectDir, file), "utf-8");
|
|
15
|
+
sections.push(`--- ${file} ---\n${content}`);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// File may not exist, skip it
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return sections.join("\n\n");
|
|
22
|
+
}
|
|
23
|
+
export function parseResponse(response) {
|
|
24
|
+
const changes = [];
|
|
25
|
+
// Match code blocks with file path annotation: ```language:path
|
|
26
|
+
const codeBlockRegex = /```\w+:([^\n]+)\n([\s\S]*?)```/g;
|
|
27
|
+
let match;
|
|
28
|
+
while ((match = codeBlockRegex.exec(response)) !== null) {
|
|
29
|
+
changes.push({
|
|
30
|
+
filePath: match[1].trim(),
|
|
31
|
+
content: match[2],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Strip code blocks from response to get explanation text
|
|
35
|
+
const text = response
|
|
36
|
+
.replace(/```\w+:[^\n]+\n[\s\S]*?```/g, "")
|
|
37
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
38
|
+
.trim();
|
|
39
|
+
return { text, changes };
|
|
40
|
+
}
|
|
41
|
+
export async function applyChanges(projectDir, changes) {
|
|
42
|
+
const applied = [];
|
|
43
|
+
for (const change of changes) {
|
|
44
|
+
const fullPath = path.join(projectDir, change.filePath);
|
|
45
|
+
await writeFile(fullPath, change.content);
|
|
46
|
+
applied.push(change.filePath);
|
|
47
|
+
}
|
|
48
|
+
return applied;
|
|
49
|
+
}
|
|
50
|
+
export const SYSTEM_PROMPT = `You are an expert AI agent developer. You help users build and modify agents built with the @wardenprotocol/agent-kit package.
|
|
51
|
+
|
|
52
|
+
The user has a scaffolded agent project. You will receive the current project files as context.
|
|
53
|
+
|
|
54
|
+
When the user asks you to make changes, respond with:
|
|
55
|
+
1. A brief explanation of what you're changing and why
|
|
56
|
+
2. The updated file contents using code blocks tagged with the file path
|
|
57
|
+
|
|
58
|
+
Format code changes like this:
|
|
59
|
+
\`\`\`typescript:src/agent.ts
|
|
60
|
+
// full updated file content here
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
Important rules:
|
|
64
|
+
- Always include the COMPLETE file content in code blocks, not just the changed parts
|
|
65
|
+
- Only include code blocks for files you are actually modifying
|
|
66
|
+
- The agent handler is in src/agent.ts — this is the main file users work on
|
|
67
|
+
- The server setup is in src/server.ts — only modify this if the user specifically asks for server changes
|
|
68
|
+
- If the user needs new npm packages, mention them and update package.json
|
|
69
|
+
- Keep code clean, well-typed, and following TypeScript best practices
|
|
70
|
+
- The project uses ES modules ("type": "module") with NodeNext module resolution
|
|
71
|
+
`;
|
|
72
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/cli/services/ai/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,aAAa,GAAG;IACpB,cAAc;IACd,eAAe;IACf,cAAc;IACd,cAAc;CACf,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB;IAElB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,EAC3B,OAAO,CACR,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,SAAS,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAOD,MAAM,UAAU,aAAa,CAAC,QAAgB;IAI5C,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,gEAAgE;IAChE,MAAM,cAAc,GAAG,iCAAiC,CAAC;IACzD,IAAI,KAAK,CAAC;IAEV,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC;YACX,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE;YAC1B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAE;SACnB,CAAC,CAAC;IACL,CAAC;IAED,0DAA0D;IAC1D,MAAM,IAAI,GAAG,QAAQ;SAClB,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC;SAC1C,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,IAAI,EAAE,CAAC;IAEV,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,OAAqB;IAErB,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxD,MAAM,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AIProvider, Message } from "./provider.js";
|
|
2
|
+
export declare class OpenAIProvider implements AIProvider {
|
|
3
|
+
private client;
|
|
4
|
+
private model;
|
|
5
|
+
constructor(apiKey: string, model: string);
|
|
6
|
+
chat(messages: Message[]): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/ai/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEzD,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKnC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAWjD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
export class OpenAIProvider {
|
|
3
|
+
client;
|
|
4
|
+
model;
|
|
5
|
+
constructor(apiKey, model) {
|
|
6
|
+
this.client = new OpenAI({ apiKey });
|
|
7
|
+
this.model = model;
|
|
8
|
+
}
|
|
9
|
+
async chat(messages) {
|
|
10
|
+
const response = await this.client.chat.completions.create({
|
|
11
|
+
model: this.model,
|
|
12
|
+
messages: messages.map((m) => ({
|
|
13
|
+
role: m.role,
|
|
14
|
+
content: m.content,
|
|
15
|
+
})),
|
|
16
|
+
});
|
|
17
|
+
return response.choices[0]?.message?.content || "";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../../src/cli/services/ai/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,MAAM,OAAO,cAAc;IACjB,MAAM,CAAS;IACf,KAAK,CAAS;IAEtB,YAAY,MAAc,EAAE,KAAa;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAmB;QAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACzD,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC7B,IAAI,EAAE,CAAC,CAAC,IAAuC;gBAC/C,OAAO,EAAE,CAAC,CAAC,OAAO;aACnB,CAAC,CAAC;SACJ,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BuildConfig } from "../config.js";
|
|
2
|
+
export interface Message {
|
|
3
|
+
role: "system" | "user" | "assistant";
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AIProvider {
|
|
7
|
+
chat(messages: Message[]): Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createProvider(config: BuildConfig): AIProvider;
|
|
10
|
+
/**
|
|
11
|
+
* Returns whether the error is non-recoverable and the build loop should exit.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isNonRecoverableError(error: unknown): boolean;
|
|
14
|
+
export declare function formatAPIError(error: unknown): string;
|
|
15
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/ai/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAO9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI7D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAuCrD"}
|