@0xmaxma/claude-gateway 1.1.4 → 1.1.5
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 +11 -0
- package/dist/agent/create-agent-prompts.d.ts +21 -0
- package/dist/agent/create-agent-prompts.d.ts.map +1 -0
- package/dist/agent/create-agent-prompts.js +109 -0
- package/dist/agent/create-agent-prompts.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +671 -0
- package/dist/api/router.js.map +1 -1
- package/dist/api/wizard-state.d.ts +30 -0
- package/dist/api/wizard-state.d.ts.map +1 -0
- package/dist/api/wizard-state.js +68 -0
- package/dist/api/wizard-state.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -405,6 +405,17 @@ Pass API key via `X-Api-Key: <key>` or `Authorization: Bearer <key>` header.
|
|
|
405
405
|
| `POST` | `/api/v1/agents/:agentId/chats/:chatId/sessions/:sessionId/messages` | Inject a message into an existing session |
|
|
406
406
|
| `POST` | `/api/v1/agents/:agentId/media` | Upload a media file (image or PDF) |
|
|
407
407
|
| `GET` | `/api/v1/agents/:agentId/media/*` | Serve a media file by path |
|
|
408
|
+
| `PUT` | `/api/v1/agents/:agentId/avatar` | Upload or replace agent avatar (admin/write) |
|
|
409
|
+
| `DELETE` | `/api/v1/agents/:agentId/avatar` | Remove agent avatar (admin/write) |
|
|
410
|
+
| `GET` | `/api/v1/agents/:agentId/avatar` | Serve agent avatar image |
|
|
411
|
+
| `POST` | `/api/v1/agents/wizard/start` | Start wizard: generate agent workspace via Claude (admin) |
|
|
412
|
+
| `PUT` | `/api/v1/agents/wizard/:wizardId/avatar` | Upload avatar to wizard before confirm (admin) |
|
|
413
|
+
| `POST` | `/api/v1/agents/wizard/:wizardId/confirm` | Write workspace to disk and add agent to config (admin) |
|
|
414
|
+
| `POST` | `/api/v1/agents/wizard/:wizardId/channel` | Verify bot token and generate pairing code (admin) |
|
|
415
|
+
| `POST` | `/api/v1/agents/wizard/:wizardId/channel/verify` | Poll for pairing code confirmation (admin) |
|
|
416
|
+
| `POST` | `/api/v1/agents/wizard/:wizardId/complete` | Skip channel and finalise wizard (admin) |
|
|
417
|
+
|
|
418
|
+
**Wizard API** — create agents programmatically with the same flow as the interactive `make create-agent` terminal wizard. The wizard generates workspace files via Claude, writes them on confirm, and optionally pairs a Telegram/Discord bot. State is in-memory with a 30-minute TTL; nothing is written until `/confirm`. See [API.md](./API.md) for the full wizard flow.
|
|
408
419
|
|
|
409
420
|
See **[API.md](./API.md)** for full reference with request/response schemas and curl examples.
|
|
410
421
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt templates and output parsers for the create-agent wizard.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Build the Claude generation prompt for workspace markdown files.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildGenerationPrompt(name: string, description: string, options?: {
|
|
8
|
+
signatureEmoji?: string;
|
|
9
|
+
}): string;
|
|
10
|
+
/**
|
|
11
|
+
* Parse Claude's generated output into a Map of filename -> content.
|
|
12
|
+
* Expects sections in the format:
|
|
13
|
+
* === filename.md ===
|
|
14
|
+
* <content here>
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseGeneratedFiles(output: string): Map<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Build the Claude update prompt for an existing agent.md file.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildUpdatePrompt(name: string, currentContent: string): string;
|
|
21
|
+
//# sourceMappingURL=create-agent-prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-agent-prompts.d.ts","sourceRoot":"","sources":["../../src/agent/create-agent-prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC,MAAM,CAwCR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA4BvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAwB9E"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompt templates and output parsers for the create-agent wizard.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildGenerationPrompt = buildGenerationPrompt;
|
|
7
|
+
exports.parseGeneratedFiles = parseGeneratedFiles;
|
|
8
|
+
exports.buildUpdatePrompt = buildUpdatePrompt;
|
|
9
|
+
/**
|
|
10
|
+
* Build the Claude generation prompt for workspace markdown files.
|
|
11
|
+
*/
|
|
12
|
+
function buildGenerationPrompt(name, description, options) {
|
|
13
|
+
const signatureNote = options?.signatureEmoji
|
|
14
|
+
? `\nThe agent has a signature emoji: ${options.signatureEmoji}. Include it in the Emoji Usage section as the signature emoji.`
|
|
15
|
+
: '';
|
|
16
|
+
// Prevent prompt injection via triple-quote delimiter escape
|
|
17
|
+
const safeDescription = description.replace(/"""/g, "'''");
|
|
18
|
+
return `You are helping configure a Claude Code agent for the claude-gateway multi-bot system.
|
|
19
|
+
|
|
20
|
+
The user described the agent as:
|
|
21
|
+
"""
|
|
22
|
+
${safeDescription}
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
Generate workspace markdown files for this agent. Output each file as:
|
|
26
|
+
|
|
27
|
+
=== AGENTS.md ===
|
|
28
|
+
<content here>
|
|
29
|
+
|
|
30
|
+
=== SOUL.md ===
|
|
31
|
+
<content here>
|
|
32
|
+
|
|
33
|
+
Rules:
|
|
34
|
+
- AGENTS.md is REQUIRED. Start with "# Agent: ${name}" on line 1.
|
|
35
|
+
Include: role, rules, what it can/cannot do, language to use.
|
|
36
|
+
Always include these rules under ## Rules:
|
|
37
|
+
"Report completion (mandatory): After finishing any task, ALWAYS send a reply summarising what
|
|
38
|
+
was done before the session ends. Never silently complete work without reporting the result back
|
|
39
|
+
to the user."
|
|
40
|
+
Also include an "## Emoji Usage" section in AGENTS.md with these guidelines:
|
|
41
|
+
- React to messages naturally — use the react tool. Max 1 reaction per message.
|
|
42
|
+
- Signature emoji: ${options?.signatureEmoji ? `Use ${options.signatureEmoji} as your signature emoji in greetings or sign-offs.` : 'None assigned.'}${signatureNote}
|
|
43
|
+
- IDENTITY.md (optional): agent name, emoji, avatar, creature, vibe. Omit if not needed.
|
|
44
|
+
- SOUL.md: tone and personality only (not rules). Omit if no distinct style.
|
|
45
|
+
- USER.md: target user profile. Omit if public/unknown.
|
|
46
|
+
- HEARTBEAT.md: only if proactive/scheduled tasks were described. Use YAML tasks format.
|
|
47
|
+
- Keep each file under 500 words.
|
|
48
|
+
- Omit files that are not relevant.
|
|
49
|
+
- IMPORTANT: On the very FIRST line of your output (before any === markers), output a single emoji that best represents this agent's personality or role. Just the emoji alone on line 1, nothing else.`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse Claude's generated output into a Map of filename -> content.
|
|
53
|
+
* Expects sections in the format:
|
|
54
|
+
* === filename.md ===
|
|
55
|
+
* <content here>
|
|
56
|
+
*/
|
|
57
|
+
function parseGeneratedFiles(output) {
|
|
58
|
+
const files = new Map();
|
|
59
|
+
// Match sections starting with === filename ===
|
|
60
|
+
const sectionRegex = /^=== ([^\s=][^=]*?) ===\s*$/gm;
|
|
61
|
+
const matches = [];
|
|
62
|
+
let match;
|
|
63
|
+
while ((match = sectionRegex.exec(output)) !== null) {
|
|
64
|
+
const headerStart = match.index;
|
|
65
|
+
const afterHeader = match.index + match[0].length;
|
|
66
|
+
// Skip the newline immediately after the header line
|
|
67
|
+
const contentStart = output[afterHeader] === '\n' ? afterHeader + 1 : afterHeader;
|
|
68
|
+
matches.push({ filename: match[1].trim(), headerStart, contentStart });
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < matches.length; i++) {
|
|
71
|
+
const { filename, contentStart } = matches[i];
|
|
72
|
+
// Content ends at the start of the next section header (not mid-header)
|
|
73
|
+
const contentEnd = i + 1 < matches.length ? matches[i + 1].headerStart : output.length;
|
|
74
|
+
const content = output.slice(contentStart, contentEnd).trimEnd();
|
|
75
|
+
if (content.length > 0) {
|
|
76
|
+
files.set(filename, content);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return files;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build the Claude update prompt for an existing agent.md file.
|
|
83
|
+
*/
|
|
84
|
+
function buildUpdatePrompt(name, currentContent) {
|
|
85
|
+
const safeContent = currentContent.replace(/"""/g, "'''");
|
|
86
|
+
return `You are updating the agent.md file for a Claude Gateway agent named "${name}".
|
|
87
|
+
|
|
88
|
+
Current agent.md content:
|
|
89
|
+
"""
|
|
90
|
+
${safeContent}
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
Update this agent.md to follow current best practices:
|
|
94
|
+
- Preserve the agent's role, purpose, and all existing rules
|
|
95
|
+
- REMOVE any "Acknowledge first" rule if present — this is now handled at infrastructure level
|
|
96
|
+
- Ensure ## Rules section includes this rule (add if missing, strengthen if weak):
|
|
97
|
+
"Report completion (mandatory): After finishing any task, ALWAYS send a reply summarising what
|
|
98
|
+
was done before the session ends. Never silently complete work without reporting the result back
|
|
99
|
+
to the user."
|
|
100
|
+
- Ensure an "## Emoji Usage" section exists with these guidelines:
|
|
101
|
+
- React to messages naturally — use the react tool. Max 1 reaction per message.
|
|
102
|
+
- Signature emoji: preserve any existing signature emoji setting.
|
|
103
|
+
- Remove any mention of "emojiReactionMode" if present
|
|
104
|
+
- Keep the file under 500 words
|
|
105
|
+
|
|
106
|
+
Output ONLY the updated agent.md content — no preamble, no explanation, no commentary.
|
|
107
|
+
Start directly with the first line of the agent.md content.`;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=create-agent-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-agent-prompts.js","sourceRoot":"","sources":["../../src/agent/create-agent-prompts.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAKH,sDA4CC;AAQD,kDA4BC;AAKD,8CAwBC;AAhHD;;GAEG;AACH,SAAgB,qBAAqB,CACnC,IAAY,EACZ,WAAmB,EACnB,OAAqC;IAErC,MAAM,aAAa,GAAG,OAAO,EAAE,cAAc;QAC3C,CAAC,CAAC,sCAAsC,OAAO,CAAC,cAAc,iEAAiE;QAC/H,CAAC,CAAC,EAAE,CAAC;IAEP,6DAA6D;IAC7D,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,OAAO;;;;EAIP,eAAe;;;;;;;;;;;;gDAY+B,IAAI;;;;;;;;yBAQ3B,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,cAAc,qDAAqD,CAAC,CAAC,CAAC,gBAAgB,GAAG,aAAa;;;;;;;wMAOgC,CAAC;AACzM,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,MAAc;IAChD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,gDAAgD;IAChD,MAAM,YAAY,GAAG,+BAA+B,CAAC;IAErD,MAAM,OAAO,GAA2E,EAAE,CAAC;IAC3F,IAAI,KAA6B,CAAC;IAElC,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC;QAChC,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAA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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AAOpD,OAAO,EAAE,WAAW,EAAkB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAmL5D,wBAAgB,eAAe,CAC7B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EACtC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EACtC,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,EAAE,GACrB,MAAM,CA2iDR"}
|