@otakumesi/heph 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +536 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/hono.d.mts +30 -0
- package/dist/hono.d.mts.map +1 -0
- package/dist/hono.mjs +425 -0
- package/dist/hono.mjs.map +1 -0
- package/dist/index-CdsI9z7r.d.mts +1075 -0
- package/dist/index-CdsI9z7r.d.mts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/mcp.d.mts +2 -0
- package/dist/mcp.mjs +2 -0
- package/dist/skills-D1QE4Dtc.d.mts +13 -0
- package/dist/skills-D1QE4Dtc.d.mts.map +1 -0
- package/dist/skills-DLfYbSME.mjs +131 -0
- package/dist/skills-DLfYbSME.mjs.map +1 -0
- package/dist/skills.d.mts +2 -0
- package/dist/skills.mjs +2 -0
- package/dist/sqlite.d.mts +138 -0
- package/dist/sqlite.d.mts.map +1 -0
- package/dist/sqlite.mjs +1140 -0
- package/dist/sqlite.mjs.map +1 -0
- package/dist/src-DeheByi4.mjs +2677 -0
- package/dist/src-DeheByi4.mjs.map +1 -0
- package/dist/worker.d.mts +15 -0
- package/dist/worker.d.mts.map +1 -0
- package/dist/worker.mjs +18 -0
- package/dist/worker.mjs.map +1 -0
- package/package.json +67 -0
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { P as HephError, n as createHeph } from "./src-DeheByi4.mjs";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { createJiti } from "jiti";
|
|
7
|
+
//#region ../cli/src/index.ts
|
|
8
|
+
async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
9
|
+
const ctx = {
|
|
10
|
+
cwd: io.cwd ?? process.cwd(),
|
|
11
|
+
stdout: io.stdout ?? process.stdout,
|
|
12
|
+
stderr: io.stderr ?? process.stderr
|
|
13
|
+
};
|
|
14
|
+
try {
|
|
15
|
+
const parsed = parseArgs(argv);
|
|
16
|
+
const [command, subcommand, name] = parsed.positionals;
|
|
17
|
+
if (!command || command === "help" || parsed.flags.has("help")) {
|
|
18
|
+
printHelp(ctx);
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
if (command === "init") {
|
|
22
|
+
await initProject(ctx, parsed);
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
if (command === "add") {
|
|
26
|
+
await addScaffold(ctx, subcommand, name, parsed);
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
if (command === "inspect" && subcommand === "context") {
|
|
30
|
+
await inspectContext(ctx, parsed);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
if (command === "add" && subcommand === "skill") throw cliUsage("heph add skill is not part of the MVP. Skills are runtime bindings, not scaffolded components.");
|
|
34
|
+
throw cliUsage(`Unknown command: ${parsed.positionals.join(" ")}`);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
writeLine(ctx.stderr, formatCliError(error));
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function printHelp(ctx) {
|
|
41
|
+
writeLine(ctx.stdout, `heph
|
|
42
|
+
|
|
43
|
+
Usage:
|
|
44
|
+
heph init [dir] [--force]
|
|
45
|
+
heph add agent <id> [--dir <dir>] [--force]
|
|
46
|
+
heph add tool <id> [--dir <dir>] [--force]
|
|
47
|
+
heph add context-provider <id> [--dir <dir>] [--force]
|
|
48
|
+
heph add template <id> [--dir <dir>] [--force]
|
|
49
|
+
heph inspect context --agent <agent_spec_id> --input <text> [--config <path>] [--format json]
|
|
50
|
+
|
|
51
|
+
MVP note:
|
|
52
|
+
heph add skill is intentionally not available.`);
|
|
53
|
+
}
|
|
54
|
+
async function initProject(ctx, parsed) {
|
|
55
|
+
const targetArg = parsed.positionals[1] && !parsed.positionals[1].startsWith("-") ? parsed.positionals[1] : ".";
|
|
56
|
+
const targetDir = resolvePath(ctx.cwd, targetArg);
|
|
57
|
+
const force = parsed.flags.has("force");
|
|
58
|
+
const writes = [
|
|
59
|
+
["package.json", packageJsonTemplate(toPackageName(basename(targetDir) || "my-agent-app"))],
|
|
60
|
+
["tsconfig.json", tsconfigTemplate()],
|
|
61
|
+
[".env.example", envTemplate()],
|
|
62
|
+
["heph.config.ts", hephConfigTemplate()],
|
|
63
|
+
["src/runtime.ts", runtimeTemplate()],
|
|
64
|
+
["src/server.ts", serverTemplate()],
|
|
65
|
+
["src/worker.ts", workerTemplate()],
|
|
66
|
+
["src/agents/index.ts", agentsIndexTemplate()],
|
|
67
|
+
["src/agents/support-agent.agent.ts", supportAgentTemplate()],
|
|
68
|
+
["src/tools/index.ts", emptyIndexTemplate()],
|
|
69
|
+
["src/context/index.ts", emptyIndexTemplate()],
|
|
70
|
+
["src/context-templates/default.template.ts", defaultTemplateTemplate()],
|
|
71
|
+
["src/auth/index.ts", authIndexTemplate()],
|
|
72
|
+
["src/auth/auth.adapter.ts", authAdapterTemplate()],
|
|
73
|
+
["src/memory/index.ts", emptyIndexTemplate()],
|
|
74
|
+
["src/policies/index.ts", emptyIndexTemplate()],
|
|
75
|
+
["migrations/heph/.gitkeep", ""],
|
|
76
|
+
["var/.gitkeep", ""],
|
|
77
|
+
["AGENTS.md", agentsMdTemplate()]
|
|
78
|
+
];
|
|
79
|
+
for (const [relativePath, content] of writes) await writeProjectFile(join(targetDir, relativePath), content, force);
|
|
80
|
+
await upsertGitignore(targetDir, ["/var/*.db", "/var/*.db-*"]);
|
|
81
|
+
writeLine(ctx.stdout, `Initialized Heph app at ${targetDir}`);
|
|
82
|
+
}
|
|
83
|
+
async function addScaffold(ctx, kind, id, parsed) {
|
|
84
|
+
if (!kind || !id) throw cliUsage("Usage: heph add <agent|tool|context-provider|template> <id>");
|
|
85
|
+
const root = resolvePath(ctx.cwd, getStringFlag(parsed, "dir") ?? ".");
|
|
86
|
+
const force = parsed.flags.has("force");
|
|
87
|
+
const normalized = normalizeId(id);
|
|
88
|
+
if (kind === "agent") {
|
|
89
|
+
await writeProjectFile(join(root, "src/agents", `${normalized.kebab}.agent.ts`), agentTemplate(normalized), force);
|
|
90
|
+
await upsertAgentIndex(join(root, "src/agents/index.ts"), normalized);
|
|
91
|
+
writeLine(ctx.stdout, `Added agent ${id}`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (kind === "tool") {
|
|
95
|
+
await writeProjectFile(join(root, "src/tools", `${normalized.kebab}.tool.ts`), toolTemplate(normalized), force);
|
|
96
|
+
await appendExport(join(root, "src/tools/index.ts"), `export { ${componentVar(normalized, "Tool")} } from "./${normalized.kebab}.tool";\n`);
|
|
97
|
+
writeLine(ctx.stdout, `Added tool ${id}`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (kind === "context-provider") {
|
|
101
|
+
await writeProjectFile(join(root, "src/context", `${normalized.kebab}.context.ts`), contextProviderTemplate(normalized), force);
|
|
102
|
+
await appendExport(join(root, "src/context/index.ts"), `export { ${componentVar(normalized, "Context")} } from "./${normalized.kebab}.context";\n`);
|
|
103
|
+
writeLine(ctx.stdout, `Added context provider ${id}`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (kind === "template") {
|
|
107
|
+
await writeProjectFile(join(root, "src/context-templates", `${normalized.kebab}.template.ts`), contextTemplateTemplate(normalized), force);
|
|
108
|
+
writeLine(ctx.stdout, `Added context template ${id}`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (kind === "skill") throw cliUsage("heph add skill is not part of the MVP. Skills are runtime bindings, not scaffolded components.");
|
|
112
|
+
throw cliUsage(`Unknown scaffold type: ${kind}`);
|
|
113
|
+
}
|
|
114
|
+
async function inspectContext(ctx, parsed) {
|
|
115
|
+
const agentSpecId = getStringFlag(parsed, "agent") ?? getStringFlag(parsed, "spec");
|
|
116
|
+
const input = getStringFlag(parsed, "input") ?? parsed.positionals.slice(2).join(" ");
|
|
117
|
+
const format = getStringFlag(parsed, "format") ?? "text";
|
|
118
|
+
if (!agentSpecId) throw cliUsage("heph inspect context requires --agent <agent_spec_id>.");
|
|
119
|
+
if (!input) throw cliUsage("heph inspect context requires --input <text>.");
|
|
120
|
+
const loaded = await loadConfig(await resolveConfigPath(ctx.cwd, getStringFlag(parsed, "config")));
|
|
121
|
+
const heph = isHephRuntime(loaded) ? loaded : createHeph(loaded);
|
|
122
|
+
const auth = {
|
|
123
|
+
subject: "inspect",
|
|
124
|
+
actorType: "service"
|
|
125
|
+
};
|
|
126
|
+
const agent = await heph.agents.create({
|
|
127
|
+
spec: agentSpecId,
|
|
128
|
+
auth
|
|
129
|
+
});
|
|
130
|
+
const run = await heph.runs.create({
|
|
131
|
+
agentId: agent.id,
|
|
132
|
+
input,
|
|
133
|
+
auth,
|
|
134
|
+
enqueue: false
|
|
135
|
+
});
|
|
136
|
+
const rendered = await heph.renderRunContext(run.id);
|
|
137
|
+
if (format === "json") {
|
|
138
|
+
writeLine(ctx.stdout, JSON.stringify({
|
|
139
|
+
messages: rendered.messages,
|
|
140
|
+
manifest: rendered.manifest
|
|
141
|
+
}, null, 2));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
for (const message of rendered.messages) {
|
|
145
|
+
writeLine(ctx.stdout, `--- ${message.role} ---`);
|
|
146
|
+
writeLine(ctx.stdout, message.content);
|
|
147
|
+
}
|
|
148
|
+
writeLine(ctx.stdout, "--- context manifest ---");
|
|
149
|
+
writeLine(ctx.stdout, JSON.stringify(rendered.manifest, null, 2));
|
|
150
|
+
}
|
|
151
|
+
async function loadConfig(configPath) {
|
|
152
|
+
try {
|
|
153
|
+
const module = await createJiti(pathToFileURL(configPath).href, {
|
|
154
|
+
interopDefault: true,
|
|
155
|
+
moduleCache: false
|
|
156
|
+
}).import(configPath);
|
|
157
|
+
return module.default ?? module.heph ?? module.config ?? module;
|
|
158
|
+
} catch (cause) {
|
|
159
|
+
throw new HephError({
|
|
160
|
+
code: "HEPH9003",
|
|
161
|
+
title: "Failed to load Heph config",
|
|
162
|
+
message: `Failed to load Heph config at ${configPath}.`,
|
|
163
|
+
details: { configPath },
|
|
164
|
+
cause
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function resolveConfigPath(cwd, explicitPath) {
|
|
169
|
+
if (explicitPath) return resolvePath(cwd, explicitPath);
|
|
170
|
+
for (const candidate of [
|
|
171
|
+
"heph.config.ts",
|
|
172
|
+
"heph.config.mts",
|
|
173
|
+
"heph.config.mjs",
|
|
174
|
+
"heph.config.js"
|
|
175
|
+
]) {
|
|
176
|
+
const fullPath = join(cwd, candidate);
|
|
177
|
+
if (await exists(fullPath)) return fullPath;
|
|
178
|
+
}
|
|
179
|
+
throw cliUsage("Could not find heph.config.ts. Pass --config <path>.");
|
|
180
|
+
}
|
|
181
|
+
function isHephRuntime(value) {
|
|
182
|
+
return typeof value === "object" && value !== null && "agents" in value && "runs" in value && "renderRunContext" in value;
|
|
183
|
+
}
|
|
184
|
+
function parseArgs(argv) {
|
|
185
|
+
const positionals = [];
|
|
186
|
+
const flags = /* @__PURE__ */ new Map();
|
|
187
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
188
|
+
const arg = argv[index];
|
|
189
|
+
if (!arg) continue;
|
|
190
|
+
if (arg === "--") {
|
|
191
|
+
positionals.push(...argv.slice(index + 1));
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
if (arg.startsWith("--")) {
|
|
195
|
+
const [rawKey, inlineValue] = arg.slice(2).split("=", 2);
|
|
196
|
+
const key = rawKey;
|
|
197
|
+
if (!key) continue;
|
|
198
|
+
if (inlineValue !== void 0) {
|
|
199
|
+
flags.set(key, inlineValue);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const next = argv[index + 1];
|
|
203
|
+
if (next && !next.startsWith("--")) {
|
|
204
|
+
flags.set(key, next);
|
|
205
|
+
index += 1;
|
|
206
|
+
} else flags.set(key, true);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
positionals.push(arg);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
positionals,
|
|
213
|
+
flags
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function getStringFlag(parsed, key) {
|
|
217
|
+
const value = parsed.flags.get(key);
|
|
218
|
+
return typeof value === "string" ? value : void 0;
|
|
219
|
+
}
|
|
220
|
+
async function writeProjectFile(path, content, force) {
|
|
221
|
+
if (!force && await exists(path)) throw new HephError({
|
|
222
|
+
code: "HEPH9001",
|
|
223
|
+
title: "File already exists",
|
|
224
|
+
message: `${path} already exists. Re-run with --force to overwrite it.`,
|
|
225
|
+
details: { path }
|
|
226
|
+
});
|
|
227
|
+
await mkdir(dirname(path), { recursive: true });
|
|
228
|
+
await writeFile(path, content, "utf8");
|
|
229
|
+
}
|
|
230
|
+
async function appendExport(path, exportLine) {
|
|
231
|
+
await mkdir(dirname(path), { recursive: true });
|
|
232
|
+
const existing = await exists(path) ? await readFile(path, "utf8") : "";
|
|
233
|
+
if (existing.includes(exportLine.trim())) return;
|
|
234
|
+
await writeFile(path, `${existing.trimEnd()}\n${exportLine}`.trimStart(), "utf8");
|
|
235
|
+
}
|
|
236
|
+
async function upsertGitignore(root, entries) {
|
|
237
|
+
const path = join(root, ".gitignore");
|
|
238
|
+
const existing = await exists(path) ? await readFile(path, "utf8") : "";
|
|
239
|
+
const existingLines = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
|
|
240
|
+
const missing = entries.filter((entry) => !existingLines.has(entry));
|
|
241
|
+
if (missing.length === 0) return;
|
|
242
|
+
const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
|
|
243
|
+
const header = existingLines.has("# Heph local runtime data") ? "" : `${prefix}# Heph local runtime data\n`;
|
|
244
|
+
await mkdir(dirname(path), { recursive: true });
|
|
245
|
+
await writeFile(path, `${existing}${header}${missing.join("\n")}\n`, "utf8");
|
|
246
|
+
}
|
|
247
|
+
async function exists(path) {
|
|
248
|
+
try {
|
|
249
|
+
await stat(path);
|
|
250
|
+
return true;
|
|
251
|
+
} catch {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function resolvePath(cwd, path) {
|
|
256
|
+
return isAbsolute(path) ? path : resolve(cwd, path);
|
|
257
|
+
}
|
|
258
|
+
function cliUsage(message) {
|
|
259
|
+
return new HephError({
|
|
260
|
+
code: "HEPH9002",
|
|
261
|
+
title: "Invalid CLI usage",
|
|
262
|
+
message
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function formatCliError(error) {
|
|
266
|
+
if (error instanceof HephError) return `${error.code} ${error.title}: ${error.message}`;
|
|
267
|
+
if (error instanceof Error) return error.message;
|
|
268
|
+
return String(error);
|
|
269
|
+
}
|
|
270
|
+
function writeLine(stream, line) {
|
|
271
|
+
stream.write(`${line}\n`);
|
|
272
|
+
}
|
|
273
|
+
function normalizeId(id) {
|
|
274
|
+
const kebab = id.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
275
|
+
const pascal = kebab.split("-").filter(Boolean).map(capitalize).join("");
|
|
276
|
+
const camel = pascal ? `${pascal[0]?.toLowerCase() ?? ""}${pascal.slice(1)}` : "component";
|
|
277
|
+
if (!kebab) throw cliUsage(`Invalid id: ${id}`);
|
|
278
|
+
return {
|
|
279
|
+
raw: id,
|
|
280
|
+
kebab,
|
|
281
|
+
camel,
|
|
282
|
+
pascal
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function capitalize(value) {
|
|
286
|
+
return `${value[0]?.toUpperCase() ?? ""}${value.slice(1)}`;
|
|
287
|
+
}
|
|
288
|
+
function toPackageName(value) {
|
|
289
|
+
return value.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-|-$/g, "");
|
|
290
|
+
}
|
|
291
|
+
function packageJsonTemplate(projectName) {
|
|
292
|
+
return `${JSON.stringify({
|
|
293
|
+
name: projectName || "my-agent-app",
|
|
294
|
+
version: "0.0.1",
|
|
295
|
+
private: true,
|
|
296
|
+
type: "module",
|
|
297
|
+
scripts: { typecheck: "tsc --noEmit" },
|
|
298
|
+
dependencies: {
|
|
299
|
+
"@otakumesi/heph": "^0.0.1",
|
|
300
|
+
hono: "^4.10.7",
|
|
301
|
+
zod: "^4.1.12"
|
|
302
|
+
},
|
|
303
|
+
devDependencies: {
|
|
304
|
+
"@types/node": "^24.10.1",
|
|
305
|
+
typescript: "^5.9.3"
|
|
306
|
+
}
|
|
307
|
+
}, null, 2)}\n`;
|
|
308
|
+
}
|
|
309
|
+
function tsconfigTemplate() {
|
|
310
|
+
return `{
|
|
311
|
+
"compilerOptions": {
|
|
312
|
+
"target": "ES2022",
|
|
313
|
+
"module": "NodeNext",
|
|
314
|
+
"moduleResolution": "NodeNext",
|
|
315
|
+
"strict": true,
|
|
316
|
+
"skipLibCheck": true,
|
|
317
|
+
"verbatimModuleSyntax": true
|
|
318
|
+
},
|
|
319
|
+
"include": ["src/**/*.ts", "heph.config.ts"]
|
|
320
|
+
}
|
|
321
|
+
`;
|
|
322
|
+
}
|
|
323
|
+
function envTemplate() {
|
|
324
|
+
return `# Application-owned environment for your Heph app.
|
|
325
|
+
# Add model provider credentials and host-app secrets here.
|
|
326
|
+
HEPH_DATABASE_PATH=./var/heph.db
|
|
327
|
+
`;
|
|
328
|
+
}
|
|
329
|
+
function hephConfigTemplate() {
|
|
330
|
+
return `import type { CreateHephOptions } from "@otakumesi/heph";
|
|
331
|
+
import { agents } from "./src/agents/index.js";
|
|
332
|
+
|
|
333
|
+
const config = {
|
|
334
|
+
agents,
|
|
335
|
+
execution: {
|
|
336
|
+
mode: "single-process"
|
|
337
|
+
}
|
|
338
|
+
} satisfies CreateHephOptions;
|
|
339
|
+
|
|
340
|
+
export default config;
|
|
341
|
+
`;
|
|
342
|
+
}
|
|
343
|
+
function runtimeTemplate() {
|
|
344
|
+
return `import { createHeph } from "@otakumesi/heph";
|
|
345
|
+
import { createSQLiteAdapters } from "@otakumesi/heph/sqlite";
|
|
346
|
+
import config from "../heph.config.js";
|
|
347
|
+
|
|
348
|
+
const sqlite = createSQLiteAdapters({
|
|
349
|
+
databasePath: process.env.HEPH_DATABASE_PATH ?? "./var/heph.db",
|
|
350
|
+
migrations: {
|
|
351
|
+
mode: "apply",
|
|
352
|
+
outputDir: "migrations/heph"
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
export const heph = createHeph({
|
|
357
|
+
...config,
|
|
358
|
+
stores: sqlite.stores,
|
|
359
|
+
queue: sqlite.queue
|
|
360
|
+
});
|
|
361
|
+
`;
|
|
362
|
+
}
|
|
363
|
+
function serverTemplate() {
|
|
364
|
+
return `import { createDevAuth, createHephApp } from "@otakumesi/heph/hono";
|
|
365
|
+
import { heph } from "./runtime.js";
|
|
366
|
+
|
|
367
|
+
export default createHephApp({
|
|
368
|
+
heph,
|
|
369
|
+
getAuth: createDevAuth({
|
|
370
|
+
subject: "dev-user"
|
|
371
|
+
})
|
|
372
|
+
});
|
|
373
|
+
`;
|
|
374
|
+
}
|
|
375
|
+
function workerTemplate() {
|
|
376
|
+
return `import { createHephWorker } from "@otakumesi/heph/worker";
|
|
377
|
+
import { heph } from "./runtime.js";
|
|
378
|
+
|
|
379
|
+
export const worker = createHephWorker({ heph });
|
|
380
|
+
`;
|
|
381
|
+
}
|
|
382
|
+
function agentsIndexTemplate() {
|
|
383
|
+
return `import { supportAgent } from "./support-agent.agent.js";
|
|
384
|
+
|
|
385
|
+
export { supportAgent };
|
|
386
|
+
|
|
387
|
+
export const agents = [
|
|
388
|
+
supportAgent
|
|
389
|
+
];
|
|
390
|
+
`;
|
|
391
|
+
}
|
|
392
|
+
function supportAgentTemplate() {
|
|
393
|
+
return `import { defineAgent, memorySearch, recentMessages, threadState } from "@otakumesi/heph";
|
|
394
|
+
|
|
395
|
+
export const supportAgent = defineAgent({
|
|
396
|
+
id: "support-agent",
|
|
397
|
+
instructions: \`
|
|
398
|
+
You are a support agent for this application.
|
|
399
|
+
Use the provided context, bounded memory, and available tools.
|
|
400
|
+
\`,
|
|
401
|
+
contextProviders: [
|
|
402
|
+
threadState(),
|
|
403
|
+
recentMessages({ limit: 20 }),
|
|
404
|
+
memorySearch({ topK: 8 })
|
|
405
|
+
]
|
|
406
|
+
});
|
|
407
|
+
`;
|
|
408
|
+
}
|
|
409
|
+
function emptyIndexTemplate() {
|
|
410
|
+
return `export {};
|
|
411
|
+
`;
|
|
412
|
+
}
|
|
413
|
+
function defaultTemplateTemplate() {
|
|
414
|
+
return `import { defaultContextTemplate, defineContextTemplate } from "@otakumesi/heph";
|
|
415
|
+
|
|
416
|
+
// Application-owned and editable. Runtime-owned safety controls still live in Heph.
|
|
417
|
+
export const defaultTemplate = defineContextTemplate(defaultContextTemplate);
|
|
418
|
+
`;
|
|
419
|
+
}
|
|
420
|
+
function authIndexTemplate() {
|
|
421
|
+
return `export { devAuth } from "./auth.adapter.js";
|
|
422
|
+
`;
|
|
423
|
+
}
|
|
424
|
+
function authAdapterTemplate() {
|
|
425
|
+
return `import { createDevAuth } from "@otakumesi/heph/hono";
|
|
426
|
+
|
|
427
|
+
export const devAuth = createDevAuth({
|
|
428
|
+
subject: "dev-user"
|
|
429
|
+
});
|
|
430
|
+
`;
|
|
431
|
+
}
|
|
432
|
+
function agentsMdTemplate() {
|
|
433
|
+
return `# AGENTS.md
|
|
434
|
+
|
|
435
|
+
This is a Heph application.
|
|
436
|
+
|
|
437
|
+
- Generated files are application-owned and editable.
|
|
438
|
+
- Keep AgentSpec, Tool, ContextProvider, and ContextTemplate definitions in src/.
|
|
439
|
+
- Do not put login/signup flows into Heph core integration code.
|
|
440
|
+
- Do not execute Skill scripts.
|
|
441
|
+
`;
|
|
442
|
+
}
|
|
443
|
+
function agentTemplate(id) {
|
|
444
|
+
return `import { defineAgent, recentMessages, threadState } from "@otakumesi/heph";
|
|
445
|
+
|
|
446
|
+
export const ${componentVar(id, "Agent")} = defineAgent({
|
|
447
|
+
id: "${id.kebab}",
|
|
448
|
+
instructions: \`
|
|
449
|
+
Describe the ${id.raw} agent's role here.
|
|
450
|
+
\`,
|
|
451
|
+
contextProviders: [
|
|
452
|
+
threadState(),
|
|
453
|
+
recentMessages({ limit: 20 })
|
|
454
|
+
]
|
|
455
|
+
});
|
|
456
|
+
`;
|
|
457
|
+
}
|
|
458
|
+
async function upsertAgentIndex(path, id) {
|
|
459
|
+
await mkdir(dirname(path), { recursive: true });
|
|
460
|
+
const existing = await exists(path) ? await readFile(path, "utf8") : "";
|
|
461
|
+
const variable = componentVar(id, "Agent");
|
|
462
|
+
const importLine = `import { ${variable} } from "./${id.kebab}.agent.js";`;
|
|
463
|
+
const exportLine = `export { ${variable} };`;
|
|
464
|
+
let next = existing.trim();
|
|
465
|
+
if (!next) next = `${importLine}\n\n${exportLine}\n\nexport const agents = [\n ${variable}\n];`;
|
|
466
|
+
else {
|
|
467
|
+
if (!next.includes(importLine)) next = `${importLine}\n${next}`;
|
|
468
|
+
if (!next.includes(exportLine)) {
|
|
469
|
+
const exportConstIndex = next.indexOf("export const agents");
|
|
470
|
+
if (exportConstIndex >= 0) next = `${next.slice(0, exportConstIndex).trimEnd()}\n${exportLine}\n\n${next.slice(exportConstIndex)}`;
|
|
471
|
+
else next = `${next}\n${exportLine}`;
|
|
472
|
+
}
|
|
473
|
+
const agentsMatch = next.match(/export const agents = \[([\s\S]*?)\];/);
|
|
474
|
+
if (agentsMatch) {
|
|
475
|
+
const currentAgents = agentsMatch[1]?.split(",").map((part) => part.trim()).filter(Boolean).map((part) => part.replace(/\n/g, "").trim()) ?? [];
|
|
476
|
+
const allAgents = Array.from(new Set([...currentAgents, variable]));
|
|
477
|
+
next = next.replace(/export const agents = \[[\s\S]*?\];/, `export const agents = [\n ${allAgents.join(",\n ")}\n];`);
|
|
478
|
+
} else next = `${next}\n\nexport const agents = [\n ${variable}\n];`;
|
|
479
|
+
}
|
|
480
|
+
await writeFile(path, `${next.trimEnd()}\n`, "utf8");
|
|
481
|
+
}
|
|
482
|
+
function toolTemplate(id) {
|
|
483
|
+
return `import { defineTool } from "@otakumesi/heph";
|
|
484
|
+
import { z } from "zod";
|
|
485
|
+
|
|
486
|
+
export const ${componentVar(id, "Tool")} = defineTool({
|
|
487
|
+
id: "${id.kebab}",
|
|
488
|
+
description: "Describe what this tool does.",
|
|
489
|
+
inputSchema: z.object({
|
|
490
|
+
query: z.string()
|
|
491
|
+
}),
|
|
492
|
+
sideEffect: false,
|
|
493
|
+
async execute(input) {
|
|
494
|
+
return {
|
|
495
|
+
query: input.query,
|
|
496
|
+
result: null
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
`;
|
|
501
|
+
}
|
|
502
|
+
function contextProviderTemplate(id) {
|
|
503
|
+
return `import { defineContextProvider } from "@otakumesi/heph";
|
|
504
|
+
|
|
505
|
+
export const ${componentVar(id, "Context")} = defineContextProvider({
|
|
506
|
+
id: "${id.kebab}",
|
|
507
|
+
async load() {
|
|
508
|
+
return {
|
|
509
|
+
key: "domainContext",
|
|
510
|
+
type: "context_provider",
|
|
511
|
+
content: "Add ${id.raw} context here."
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
`;
|
|
516
|
+
}
|
|
517
|
+
function contextTemplateTemplate(id) {
|
|
518
|
+
return `import { defaultContextTemplate, defineContextTemplate } from "@otakumesi/heph";
|
|
519
|
+
|
|
520
|
+
export const ${componentVar(id, "Template")} = defineContextTemplate({
|
|
521
|
+
...defaultContextTemplate,
|
|
522
|
+
id: "${id.kebab}",
|
|
523
|
+
version: "0.0.1"
|
|
524
|
+
});
|
|
525
|
+
`;
|
|
526
|
+
}
|
|
527
|
+
function componentVar(id, suffix) {
|
|
528
|
+
return id.camel.toLowerCase().endsWith(suffix.toLowerCase()) ? id.camel : `${id.camel}${suffix}`;
|
|
529
|
+
}
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region src/cli.ts
|
|
532
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
533
|
+
//#endregion
|
|
534
|
+
export {};
|
|
535
|
+
|
|
536
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../../cli/src/index.ts","../src/cli.ts"],"sourcesContent":["import { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { createJiti } from \"jiti\";\nimport { HephError, createHeph } from \"@heph/core\";\nimport type { AuthContext, CreateHephOptions, HephRuntime } from \"@heph/core\";\n\nexport interface CliIo {\n cwd?: string;\n stdout?: Pick<NodeJS.WriteStream, \"write\">;\n stderr?: Pick<NodeJS.WriteStream, \"write\">;\n}\n\ninterface CliContext {\n cwd: string;\n stdout: Pick<NodeJS.WriteStream, \"write\">;\n stderr: Pick<NodeJS.WriteStream, \"write\">;\n}\n\ninterface ParsedArgs {\n positionals: string[];\n flags: Map<string, string | boolean>;\n}\n\nexport async function runCli(argv = process.argv.slice(2), io: CliIo = {}): Promise<number> {\n const ctx: CliContext = {\n cwd: io.cwd ?? process.cwd(),\n stdout: io.stdout ?? process.stdout,\n stderr: io.stderr ?? process.stderr\n };\n\n try {\n const parsed = parseArgs(argv);\n const [command, subcommand, name] = parsed.positionals;\n\n if (!command || command === \"help\" || parsed.flags.has(\"help\")) {\n printHelp(ctx);\n return 0;\n }\n\n if (command === \"init\") {\n await initProject(ctx, parsed);\n return 0;\n }\n\n if (command === \"add\") {\n await addScaffold(ctx, subcommand, name, parsed);\n return 0;\n }\n\n if (command === \"inspect\" && subcommand === \"context\") {\n await inspectContext(ctx, parsed);\n return 0;\n }\n\n if (command === \"add\" && subcommand === \"skill\") {\n throw cliUsage(\"heph add skill is not part of the MVP. Skills are runtime bindings, not scaffolded components.\");\n }\n\n throw cliUsage(`Unknown command: ${parsed.positionals.join(\" \")}`);\n } catch (error) {\n writeLine(ctx.stderr, formatCliError(error));\n return 1;\n }\n}\n\nfunction printHelp(ctx: CliContext): void {\n writeLine(\n ctx.stdout,\n `heph\n\nUsage:\n heph init [dir] [--force]\n heph add agent <id> [--dir <dir>] [--force]\n heph add tool <id> [--dir <dir>] [--force]\n heph add context-provider <id> [--dir <dir>] [--force]\n heph add template <id> [--dir <dir>] [--force]\n heph inspect context --agent <agent_spec_id> --input <text> [--config <path>] [--format json]\n\nMVP note:\n heph add skill is intentionally not available.`\n );\n}\n\nasync function initProject(ctx: CliContext, parsed: ParsedArgs): Promise<void> {\n const targetArg = parsed.positionals[1] && !parsed.positionals[1].startsWith(\"-\") ? parsed.positionals[1] : \".\";\n const targetDir = resolvePath(ctx.cwd, targetArg);\n const force = parsed.flags.has(\"force\");\n const projectName = toPackageName(basename(targetDir) || \"my-agent-app\");\n const writes: Array<[string, string]> = [\n [\"package.json\", packageJsonTemplate(projectName)],\n [\"tsconfig.json\", tsconfigTemplate()],\n [\".env.example\", envTemplate()],\n [\"heph.config.ts\", hephConfigTemplate()],\n [\"src/runtime.ts\", runtimeTemplate()],\n [\"src/server.ts\", serverTemplate()],\n [\"src/worker.ts\", workerTemplate()],\n [\"src/agents/index.ts\", agentsIndexTemplate()],\n [\"src/agents/support-agent.agent.ts\", supportAgentTemplate()],\n [\"src/tools/index.ts\", emptyIndexTemplate()],\n [\"src/context/index.ts\", emptyIndexTemplate()],\n [\"src/context-templates/default.template.ts\", defaultTemplateTemplate()],\n [\"src/auth/index.ts\", authIndexTemplate()],\n [\"src/auth/auth.adapter.ts\", authAdapterTemplate()],\n [\"src/memory/index.ts\", emptyIndexTemplate()],\n [\"src/policies/index.ts\", emptyIndexTemplate()],\n [\"migrations/heph/.gitkeep\", \"\"],\n [\"var/.gitkeep\", \"\"],\n [\"AGENTS.md\", agentsMdTemplate()]\n ];\n\n for (const [relativePath, content] of writes) {\n await writeProjectFile(join(targetDir, relativePath), content, force);\n }\n await upsertGitignore(targetDir, [\"/var/*.db\", \"/var/*.db-*\"]);\n\n writeLine(ctx.stdout, `Initialized Heph app at ${targetDir}`);\n}\n\nasync function addScaffold(\n ctx: CliContext,\n kind: string | undefined,\n id: string | undefined,\n parsed: ParsedArgs\n): Promise<void> {\n if (!kind || !id) {\n throw cliUsage(\"Usage: heph add <agent|tool|context-provider|template> <id>\");\n }\n\n const root = resolvePath(ctx.cwd, getStringFlag(parsed, \"dir\") ?? \".\");\n const force = parsed.flags.has(\"force\");\n const normalized = normalizeId(id);\n\n if (kind === \"agent\") {\n const file = join(root, \"src/agents\", `${normalized.kebab}.agent.ts`);\n await writeProjectFile(file, agentTemplate(normalized), force);\n await upsertAgentIndex(join(root, \"src/agents/index.ts\"), normalized);\n writeLine(ctx.stdout, `Added agent ${id}`);\n return;\n }\n\n if (kind === \"tool\") {\n const file = join(root, \"src/tools\", `${normalized.kebab}.tool.ts`);\n await writeProjectFile(file, toolTemplate(normalized), force);\n await appendExport(join(root, \"src/tools/index.ts\"), `export { ${componentVar(normalized, \"Tool\")} } from \"./${normalized.kebab}.tool\";\\n`);\n writeLine(ctx.stdout, `Added tool ${id}`);\n return;\n }\n\n if (kind === \"context-provider\") {\n const file = join(root, \"src/context\", `${normalized.kebab}.context.ts`);\n await writeProjectFile(file, contextProviderTemplate(normalized), force);\n await appendExport(join(root, \"src/context/index.ts\"), `export { ${componentVar(normalized, \"Context\")} } from \"./${normalized.kebab}.context\";\\n`);\n writeLine(ctx.stdout, `Added context provider ${id}`);\n return;\n }\n\n if (kind === \"template\") {\n const file = join(root, \"src/context-templates\", `${normalized.kebab}.template.ts`);\n await writeProjectFile(file, contextTemplateTemplate(normalized), force);\n writeLine(ctx.stdout, `Added context template ${id}`);\n return;\n }\n\n if (kind === \"skill\") {\n throw cliUsage(\"heph add skill is not part of the MVP. Skills are runtime bindings, not scaffolded components.\");\n }\n\n throw cliUsage(`Unknown scaffold type: ${kind}`);\n}\n\nasync function inspectContext(ctx: CliContext, parsed: ParsedArgs): Promise<void> {\n const agentSpecId = getStringFlag(parsed, \"agent\") ?? getStringFlag(parsed, \"spec\");\n const input = getStringFlag(parsed, \"input\") ?? parsed.positionals.slice(2).join(\" \");\n const format = getStringFlag(parsed, \"format\") ?? \"text\";\n\n if (!agentSpecId) {\n throw cliUsage(\"heph inspect context requires --agent <agent_spec_id>.\");\n }\n\n if (!input) {\n throw cliUsage(\"heph inspect context requires --input <text>.\");\n }\n\n const configPath = await resolveConfigPath(ctx.cwd, getStringFlag(parsed, \"config\"));\n const loaded = await loadConfig(configPath);\n const heph = isHephRuntime(loaded) ? loaded : createHeph(loaded as CreateHephOptions);\n const auth: AuthContext = {\n subject: \"inspect\",\n actorType: \"service\"\n };\n const agent = await heph.agents.create({\n spec: agentSpecId,\n auth\n });\n const run = await heph.runs.create({\n agentId: agent.id,\n input,\n auth,\n enqueue: false\n });\n const rendered = await heph.renderRunContext(run.id);\n\n if (format === \"json\") {\n writeLine(\n ctx.stdout,\n JSON.stringify(\n {\n messages: rendered.messages,\n manifest: rendered.manifest\n },\n null,\n 2\n )\n );\n return;\n }\n\n for (const message of rendered.messages) {\n writeLine(ctx.stdout, `--- ${message.role} ---`);\n writeLine(ctx.stdout, message.content);\n }\n\n writeLine(ctx.stdout, \"--- context manifest ---\");\n writeLine(ctx.stdout, JSON.stringify(rendered.manifest, null, 2));\n}\n\nasync function loadConfig(configPath: string): Promise<unknown> {\n try {\n const jiti = createJiti(pathToFileURL(configPath).href, {\n interopDefault: true,\n moduleCache: false\n });\n const module = await jiti.import<Record<string, unknown>>(configPath);\n return module.default ?? module.heph ?? module.config ?? module;\n } catch (cause) {\n throw new HephError({\n code: \"HEPH9003\",\n title: \"Failed to load Heph config\",\n message: `Failed to load Heph config at ${configPath}.`,\n details: {\n configPath\n },\n cause\n });\n }\n}\n\nasync function resolveConfigPath(cwd: string, explicitPath: string | undefined): Promise<string> {\n if (explicitPath) {\n return resolvePath(cwd, explicitPath);\n }\n\n for (const candidate of [\"heph.config.ts\", \"heph.config.mts\", \"heph.config.mjs\", \"heph.config.js\"]) {\n const fullPath = join(cwd, candidate);\n if (await exists(fullPath)) {\n return fullPath;\n }\n }\n\n throw cliUsage(\"Could not find heph.config.ts. Pass --config <path>.\");\n}\n\nfunction isHephRuntime(value: unknown): value is HephRuntime {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"agents\" in value &&\n \"runs\" in value &&\n \"renderRunContext\" in value\n );\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const positionals: string[] = [];\n const flags = new Map<string, string | boolean>();\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n\n if (!arg) {\n continue;\n }\n\n if (arg === \"--\") {\n positionals.push(...argv.slice(index + 1));\n break;\n }\n\n if (arg.startsWith(\"--\")) {\n const [rawKey, inlineValue] = arg.slice(2).split(\"=\", 2);\n const key = rawKey;\n\n if (!key) {\n continue;\n }\n\n if (inlineValue !== undefined) {\n flags.set(key, inlineValue);\n continue;\n }\n\n const next = argv[index + 1];\n if (next && !next.startsWith(\"--\")) {\n flags.set(key, next);\n index += 1;\n } else {\n flags.set(key, true);\n }\n continue;\n }\n\n positionals.push(arg);\n }\n\n return {\n positionals,\n flags\n };\n}\n\nfunction getStringFlag(parsed: ParsedArgs, key: string): string | undefined {\n const value = parsed.flags.get(key);\n return typeof value === \"string\" ? value : undefined;\n}\n\nasync function writeProjectFile(path: string, content: string, force: boolean): Promise<void> {\n if (!force && (await exists(path))) {\n throw new HephError({\n code: \"HEPH9001\",\n title: \"File already exists\",\n message: `${path} already exists. Re-run with --force to overwrite it.`,\n details: {\n path\n }\n });\n }\n\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, content, \"utf8\");\n}\n\nasync function appendExport(path: string, exportLine: string): Promise<void> {\n await mkdir(dirname(path), { recursive: true });\n const existing = (await exists(path)) ? await readFile(path, \"utf8\") : \"\";\n\n if (existing.includes(exportLine.trim())) {\n return;\n }\n\n await writeFile(path, `${existing.trimEnd()}\\n${exportLine}`.trimStart(), \"utf8\");\n}\n\nasync function upsertGitignore(root: string, entries: string[]): Promise<void> {\n const path = join(root, \".gitignore\");\n const existing = (await exists(path)) ? await readFile(path, \"utf8\") : \"\";\n const existingLines = new Set(existing.split(/\\r?\\n/).map((line) => line.trim()));\n const missing = entries.filter((entry) => !existingLines.has(entry));\n\n if (missing.length === 0) {\n return;\n }\n\n const prefix = existing && !existing.endsWith(\"\\n\") ? \"\\n\" : \"\";\n const header = existingLines.has(\"# Heph local runtime data\") ? \"\" : `${prefix}# Heph local runtime data\\n`;\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, `${existing}${header}${missing.join(\"\\n\")}\\n`, \"utf8\");\n}\n\nasync function exists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction resolvePath(cwd: string, path: string): string {\n return isAbsolute(path) ? path : resolve(cwd, path);\n}\n\nfunction cliUsage(message: string): HephError {\n return new HephError({\n code: \"HEPH9002\",\n title: \"Invalid CLI usage\",\n message\n });\n}\n\nfunction formatCliError(error: unknown): string {\n if (error instanceof HephError) {\n return `${error.code} ${error.title}: ${error.message}`;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n return String(error);\n}\n\nfunction writeLine(stream: Pick<NodeJS.WriteStream, \"write\">, line: string): void {\n stream.write(`${line}\\n`);\n}\n\nfunction normalizeId(id: string): { raw: string; kebab: string; camel: string; pascal: string } {\n const kebab = id\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .replace(/[^a-zA-Z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\")\n .toLowerCase();\n const words = kebab.split(\"-\").filter(Boolean);\n const pascal = words.map(capitalize).join(\"\");\n const camel = pascal ? `${pascal[0]?.toLowerCase() ?? \"\"}${pascal.slice(1)}` : \"component\";\n\n if (!kebab) {\n throw cliUsage(`Invalid id: ${id}`);\n }\n\n return {\n raw: id,\n kebab,\n camel,\n pascal\n };\n}\n\nfunction capitalize(value: string): string {\n return `${value[0]?.toUpperCase() ?? \"\"}${value.slice(1)}`;\n}\n\nfunction toPackageName(value: string): string {\n return value\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, \"-\")\n .replace(/^-|-$/g, \"\");\n}\n\nfunction packageJsonTemplate(projectName: string): string {\n return `${JSON.stringify(\n {\n name: projectName || \"my-agent-app\",\n version: \"0.0.1\",\n private: true,\n type: \"module\",\n scripts: {\n typecheck: \"tsc --noEmit\"\n },\n dependencies: {\n \"@otakumesi/heph\": \"^0.0.1\",\n hono: \"^4.10.7\",\n zod: \"^4.1.12\"\n },\n devDependencies: {\n \"@types/node\": \"^24.10.1\",\n typescript: \"^5.9.3\"\n }\n },\n null,\n 2\n )}\\n`;\n}\n\nfunction tsconfigTemplate(): string {\n return `{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"NodeNext\",\n \"moduleResolution\": \"NodeNext\",\n \"strict\": true,\n \"skipLibCheck\": true,\n \"verbatimModuleSyntax\": true\n },\n \"include\": [\"src/**/*.ts\", \"heph.config.ts\"]\n}\n`;\n}\n\nfunction envTemplate(): string {\n return `# Application-owned environment for your Heph app.\n# Add model provider credentials and host-app secrets here.\nHEPH_DATABASE_PATH=./var/heph.db\n`;\n}\n\nfunction hephConfigTemplate(): string {\n return `import type { CreateHephOptions } from \"@otakumesi/heph\";\nimport { agents } from \"./src/agents/index.js\";\n\nconst config = {\n agents,\n execution: {\n mode: \"single-process\"\n }\n} satisfies CreateHephOptions;\n\nexport default config;\n`;\n}\n\nfunction runtimeTemplate(): string {\n return `import { createHeph } from \"@otakumesi/heph\";\nimport { createSQLiteAdapters } from \"@otakumesi/heph/sqlite\";\nimport config from \"../heph.config.js\";\n\nconst sqlite = createSQLiteAdapters({\n databasePath: process.env.HEPH_DATABASE_PATH ?? \"./var/heph.db\",\n migrations: {\n mode: \"apply\",\n outputDir: \"migrations/heph\"\n }\n});\n\nexport const heph = createHeph({\n ...config,\n stores: sqlite.stores,\n queue: sqlite.queue\n});\n`;\n}\n\nfunction serverTemplate(): string {\n return `import { createDevAuth, createHephApp } from \"@otakumesi/heph/hono\";\nimport { heph } from \"./runtime.js\";\n\nexport default createHephApp({\n heph,\n getAuth: createDevAuth({\n subject: \"dev-user\"\n })\n});\n`;\n}\n\nfunction workerTemplate(): string {\n return `import { createHephWorker } from \"@otakumesi/heph/worker\";\nimport { heph } from \"./runtime.js\";\n\nexport const worker = createHephWorker({ heph });\n`;\n}\n\nfunction agentsIndexTemplate(): string {\n return `import { supportAgent } from \"./support-agent.agent.js\";\n\nexport { supportAgent };\n\nexport const agents = [\n supportAgent\n];\n`;\n}\n\nfunction supportAgentTemplate(): string {\n return `import { defineAgent, memorySearch, recentMessages, threadState } from \"@otakumesi/heph\";\n\nexport const supportAgent = defineAgent({\n id: \"support-agent\",\n instructions: \\`\nYou are a support agent for this application.\nUse the provided context, bounded memory, and available tools.\n\\`,\n contextProviders: [\n threadState(),\n recentMessages({ limit: 20 }),\n memorySearch({ topK: 8 })\n ]\n});\n`;\n}\n\nfunction emptyIndexTemplate(): string {\n return `export {};\n`;\n}\n\nfunction defaultTemplateTemplate(): string {\n return `import { defaultContextTemplate, defineContextTemplate } from \"@otakumesi/heph\";\n\n// Application-owned and editable. Runtime-owned safety controls still live in Heph.\nexport const defaultTemplate = defineContextTemplate(defaultContextTemplate);\n`;\n}\n\nfunction authIndexTemplate(): string {\n return `export { devAuth } from \"./auth.adapter.js\";\n`;\n}\n\nfunction authAdapterTemplate(): string {\n return `import { createDevAuth } from \"@otakumesi/heph/hono\";\n\nexport const devAuth = createDevAuth({\n subject: \"dev-user\"\n});\n`;\n}\n\nfunction agentsMdTemplate(): string {\n return `# AGENTS.md\n\nThis is a Heph application.\n\n- Generated files are application-owned and editable.\n- Keep AgentSpec, Tool, ContextProvider, and ContextTemplate definitions in src/.\n- Do not put login/signup flows into Heph core integration code.\n- Do not execute Skill scripts.\n`;\n}\n\nfunction agentTemplate(id: ReturnType<typeof normalizeId>): string {\n const variable = componentVar(id, \"Agent\");\n return `import { defineAgent, recentMessages, threadState } from \"@otakumesi/heph\";\n\nexport const ${variable} = defineAgent({\n id: \"${id.kebab}\",\n instructions: \\`\nDescribe the ${id.raw} agent's role here.\n\\`,\n contextProviders: [\n threadState(),\n recentMessages({ limit: 20 })\n ]\n});\n`;\n}\n\nasync function upsertAgentIndex(path: string, id: ReturnType<typeof normalizeId>): Promise<void> {\n await mkdir(dirname(path), { recursive: true });\n const existing = (await exists(path)) ? await readFile(path, \"utf8\") : \"\";\n const variable = componentVar(id, \"Agent\");\n const importLine = `import { ${variable} } from \"./${id.kebab}.agent.js\";`;\n const exportLine = `export { ${variable} };`;\n let next = existing.trim();\n\n if (!next) {\n next = `${importLine}\\n\\n${exportLine}\\n\\nexport const agents = [\\n ${variable}\\n];`;\n } else {\n if (!next.includes(importLine)) {\n next = `${importLine}\\n${next}`;\n }\n\n if (!next.includes(exportLine)) {\n const exportConstIndex = next.indexOf(\"export const agents\");\n if (exportConstIndex >= 0) {\n next = `${next.slice(0, exportConstIndex).trimEnd()}\\n${exportLine}\\n\\n${next.slice(exportConstIndex)}`;\n } else {\n next = `${next}\\n${exportLine}`;\n }\n }\n\n const agentsMatch = next.match(/export const agents = \\[([\\s\\S]*?)\\];/);\n if (agentsMatch) {\n const currentAgents = agentsMatch[1]\n ?.split(\",\")\n .map((part) => part.trim())\n .filter(Boolean)\n .map((part) => part.replace(/\\n/g, \"\").trim()) ?? [];\n const allAgents = Array.from(new Set([...currentAgents, variable]));\n next = next.replace(/export const agents = \\[[\\s\\S]*?\\];/, `export const agents = [\\n ${allAgents.join(\",\\n \")}\\n];`);\n } else {\n next = `${next}\\n\\nexport const agents = [\\n ${variable}\\n];`;\n }\n }\n\n await writeFile(path, `${next.trimEnd()}\\n`, \"utf8\");\n}\n\nfunction toolTemplate(id: ReturnType<typeof normalizeId>): string {\n const variable = componentVar(id, \"Tool\");\n return `import { defineTool } from \"@otakumesi/heph\";\nimport { z } from \"zod\";\n\nexport const ${variable} = defineTool({\n id: \"${id.kebab}\",\n description: \"Describe what this tool does.\",\n inputSchema: z.object({\n query: z.string()\n }),\n sideEffect: false,\n async execute(input) {\n return {\n query: input.query,\n result: null\n };\n }\n});\n`;\n}\n\nfunction contextProviderTemplate(id: ReturnType<typeof normalizeId>): string {\n const variable = componentVar(id, \"Context\");\n return `import { defineContextProvider } from \"@otakumesi/heph\";\n\nexport const ${variable} = defineContextProvider({\n id: \"${id.kebab}\",\n async load() {\n return {\n key: \"domainContext\",\n type: \"context_provider\",\n content: \"Add ${id.raw} context here.\"\n };\n }\n});\n`;\n}\n\nfunction contextTemplateTemplate(id: ReturnType<typeof normalizeId>): string {\n const variable = componentVar(id, \"Template\");\n return `import { defaultContextTemplate, defineContextTemplate } from \"@otakumesi/heph\";\n\nexport const ${variable} = defineContextTemplate({\n ...defaultContextTemplate,\n id: \"${id.kebab}\",\n version: \"0.0.1\"\n});\n`;\n}\n\nfunction componentVar(id: ReturnType<typeof normalizeId>, suffix: \"Agent\" | \"Tool\" | \"Context\" | \"Template\"): string {\n return id.camel.toLowerCase().endsWith(suffix.toLowerCase()) ? id.camel : `${id.camel}${suffix}`;\n}\n","#!/usr/bin/env node\nimport { runCli } from \"@heph/cli\";\n\nprocess.exitCode = await runCli(process.argv.slice(2));\n"],"mappings":";;;;;;;AAwBA,eAAsB,OAAO,OAAO,QAAQ,KAAK,MAAM,EAAE,EAAE,KAAY,EAAE,EAAmB;CAC1F,MAAM,MAAkB;EACtB,KAAK,GAAG,OAAO,QAAQ,KAAK;EAC5B,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,EAAE;GACtD,MAAM,YAAY,MAAM,KAAK,IAAI,IAAI,CAAC,GAAG,eAAe,SAAS,CAAC,CAAC;GACnE,OAAO,KAAK,QAAQ,uCAAuC,8BAA8B,UAAU,KAAK,QAAQ,CAAC,MAAM;SAEvH,OAAO,GAAG,KAAK,iCAAiC,SAAS;;CAI7D,MAAM,UAAU,MAAM,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;AAGtD,SAAS,aAAa,IAA4C;CAEhE,OAAO;;;eADU,aAAa,IAAI,OAIb,CAAC;SACf,GAAG,MAAM;;;;;;;;;;;;;;;AAgBlB,SAAS,wBAAwB,IAA4C;CAE3E,OAAO;;eADU,aAAa,IAAI,UAGb,CAAC;SACf,GAAG,MAAM;;;;;sBAKI,GAAG,IAAI;;;;;;AAO7B,SAAS,wBAAwB,IAA4C;CAE3E,OAAO;;eADU,aAAa,IAAI,WAGb,CAAC;;SAEf,GAAG,MAAM;;;;;AAMlB,SAAS,aAAa,IAAoC,QAA2D;CACnH,OAAO,GAAG,MAAM,aAAa,CAAC,SAAS,OAAO,aAAa,CAAC,GAAG,GAAG,QAAQ,GAAG,GAAG,QAAQ;;;;AC/sB1F,QAAQ,WAAW,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE,CAAC"}
|
package/dist/core.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as HephErrorOptions, $n as StateStore, $t as InboxEventStatus, A as CallToolInput, An as ResolvedMcpBinding, At as ContextBlockType, B as HephRuntime, Bn as SkillAgentPolicy, Bt as CreateMcpBindingStoreInput, C as RunExecutor, Cn as MemoryStore, Ct as ApprovalRequestId, D as AgentSpecResolverContext, Dn as MessageStore, Dt as AuthContext, E as AgentSpecResolver, En as MessageRole, Et as AuthAdapter, F as CreateAgentSessionInput, Fn as RunEventType, Ft as ContextSlot, G as createHeph, Gn as SkillBindingStatus, Gt as DeferredToolOperationId, H as StreamableHttpMcpToolExecutor, Hn as SkillBinding, Ht as CreateSkillBindingStoreInput, I as CreateHephOptions, In as RunId, It as ContextTemplateMessage, J as InProcessQueue, Jn as SkillManifest, Jt as DeferredToolResumePolicy, K as EnqueueOptions, Kn as SkillBindingStore, Kt as DeferredToolOperationStatus, L as CreateRunInput, Ln as RunInput, Lt as CreateAgentSessionStoreInput, M as CompleteDeferredToolResultResult, Mn as RunError, Mt as ContextManifestBlock, N as CreateAgentAndRunInput, Nn as RunEvent, Nt as ContextProviderContext, O as AppendAgentMessageInput, On as PutMemoryInput, Ot as CompleteDeferredToolOperationStoreInput, P as CreateAgentAndRunResult, Pn as RunEventId, Pt as ContextProviderDefinition, Q as HephErrorCode, Qn as SourceRef, Qt as InboxEventId, R as DeferToolResultInput, Rn as RunStatus, Rt as CreateApprovalRequestStoreInput, S as RunExecutionContext, Sn as MemoryScope, St as ApprovalRequest, T as AgentSpecRegistration, Tn as MessageId, Tt as ApprovalStore, U as ToolCallAttemptResult, Un as SkillBindingId, Ut as DecideApprovalRequestStoreInput, V as RemoveMcpBindingInput, Vn as SkillAllowReferences, Vt as CreateRunStoreInput, W as ToolCallResult, Wn as SkillBindingSource, Wt as DeferredToolOperation, X as QueueAdapter, Xn as SkillPackage, Xt as HephStores, Y as InProcessQueueOptions, Yn as SkillManifestEntry, Yt as EventLog, Z as HephError, Zn as SkillResourceRef, Zt as InboxEvent, _ as createMessageId, _n as McpToolCallContext, _t as AgentSessionId, a as block, an as LocalToolManifestTool, ar as ToolManifestTool, at as Tool, b as createSkillBindingId, bn as MemoryId, bt as AppendMessageInput, c as threadState, cn as McpBinding, ct as defineContextTemplate, d as createApprovalRequestId, dn as McpBindingResolverContext, dt as ContextRendererOptions, en as InboxStore, er as ToolConcurrencyKeyFn, et as isHephError, f as createDeferredToolOperationId, fn as McpBindingStatus, ft as defaultContextTemplate, g as createMemoryId, gn as McpResolvedCredentials, gt as AgentSession, h as createMcpBindingId, hn as McpCredentialResolverContext, ht as AgentDefinition, i as RecentMessagesOptions, in as JsonValue, ir as ToolManifestSource, it as ContextTemplate, j as CompleteDeferredToolResultInput, jn as Run, jt as ContextManifest, k as AppendAgentMessageResult, kn as RenderedContext, kt as ContextBlock, l as IdPrefix, ln as McpBindingId, lt as defineTool, m as createInboxEventId, mn as McpCatalogTool, mt as messagesToText, n as createInMemorySkillCatalog, nn as JsonPrimitive, nr as ToolExecutionContext, nt as AgentSpec, o as memorySearch, on as McpAgentPolicy, or as ToolManifestToolBase, ot as defineAgent, p as createId, pn as McpBindingStore, pt as estimateTokens, q as HephJob, qn as SkillCatalog, qt as DeferredToolOperationStore, r as MemorySearchOptions, rn as JsonSchema, rr as ToolManifest, rt as ContextProvider, s as recentMessages, sn as McpAllowTools, st as defineContextProvider, t as InMemoryHephStore, tn as JsonObject, tr as ToolDefinition, tt as toErrorDetails, u as createAgentSessionId, un as McpBindingResolver, ut as ContextRenderer, v as createRunEventId, vn as McpToolExecutor, vt as AgentSpecId, w as AddMcpBindingInput, wn as Message, wt as ApprovalRequestStatus, x as MinimalRunExecutor, xn as MemoryItem, xt as AppendRunEventInput, y as createRunId, yn as McpToolManifestTool, yt as AppendInboxEventInput, z as FailedToolCallResult, zn as SearchMemoryInput, zt as CreateDeferredToolOperationStoreInput } from "./index-CdsI9z7r.mjs";
|
|
2
|
+
export { AddMcpBindingInput, AgentDefinition, AgentSession, AgentSessionId, AgentSpec, AgentSpecId, AgentSpecRegistration, AgentSpecResolver, AgentSpecResolverContext, AppendAgentMessageInput, AppendAgentMessageResult, AppendInboxEventInput, AppendMessageInput, AppendRunEventInput, ApprovalRequest, ApprovalRequestId, ApprovalRequestStatus, ApprovalStore, AuthAdapter, AuthContext, CallToolInput, CompleteDeferredToolOperationStoreInput, CompleteDeferredToolResultInput, CompleteDeferredToolResultResult, ContextBlock, ContextBlockType, ContextManifest, ContextManifestBlock, ContextProvider, ContextProviderContext, ContextProviderDefinition, ContextRenderer, ContextRendererOptions, ContextSlot, ContextTemplate, ContextTemplateMessage, CreateAgentAndRunInput, CreateAgentAndRunResult, CreateAgentSessionInput, CreateAgentSessionStoreInput, CreateApprovalRequestStoreInput, CreateDeferredToolOperationStoreInput, CreateHephOptions, CreateMcpBindingStoreInput, CreateRunInput, CreateRunStoreInput, CreateSkillBindingStoreInput, DecideApprovalRequestStoreInput, DeferToolResultInput, DeferredToolOperation, DeferredToolOperationId, DeferredToolOperationStatus, DeferredToolOperationStore, DeferredToolResumePolicy, EnqueueOptions, EventLog, FailedToolCallResult, HephError, HephErrorCode, HephErrorOptions, HephJob, HephRuntime, HephStores, IdPrefix, InMemoryHephStore, InProcessQueue, InProcessQueueOptions, InboxEvent, InboxEventId, InboxEventStatus, InboxStore, JsonObject, JsonPrimitive, JsonSchema, JsonValue, LocalToolManifestTool, McpAgentPolicy, McpAllowTools, McpBinding, McpBindingId, McpBindingResolver, McpBindingResolverContext, McpBindingStatus, McpBindingStore, McpCatalogTool, McpCredentialResolverContext, McpResolvedCredentials, McpToolCallContext, McpToolExecutor, McpToolManifestTool, MemoryId, MemoryItem, MemoryScope, MemorySearchOptions, MemoryStore, Message, MessageId, MessageRole, MessageStore, MinimalRunExecutor, PutMemoryInput, QueueAdapter, RecentMessagesOptions, RemoveMcpBindingInput, RenderedContext, ResolvedMcpBinding, Run, RunError, RunEvent, RunEventId, RunEventType, RunExecutionContext, RunExecutor, RunId, RunInput, RunStatus, SearchMemoryInput, SkillAgentPolicy, SkillAllowReferences, SkillBinding, SkillBindingId, SkillBindingSource, SkillBindingStatus, SkillBindingStore, SkillCatalog, SkillManifest, SkillManifestEntry, SkillPackage, SkillResourceRef, SourceRef, StateStore, StreamableHttpMcpToolExecutor, Tool, ToolCallAttemptResult, ToolCallResult, ToolConcurrencyKeyFn, ToolDefinition, ToolExecutionContext, ToolManifest, ToolManifestSource, ToolManifestTool, ToolManifestToolBase, block, createAgentSessionId, createApprovalRequestId, createDeferredToolOperationId, createHeph, createId, createInMemorySkillCatalog, createInboxEventId, createMcpBindingId, createMemoryId, createMessageId, createRunEventId, createRunId, createSkillBindingId, defaultContextTemplate, defineAgent, defineContextProvider, defineContextTemplate, defineTool, estimateTokens, isHephError, memorySearch, messagesToText, recentMessages, threadState, toErrorDetails };
|
package/dist/core.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as ContextRenderer, C as ContextProvider, D as defineContextProvider, E as defineAgent, F as isHephError, I as toErrorDetails, M as estimateTokens, N as messagesToText, O as defineContextTemplate, P as HephError, S as AgentSpec, T as Tool, _ as createMessageId, a as InProcessQueue, b as createSkillBindingId, c as recentMessages, d as createApprovalRequestId, f as createDeferredToolOperationId, g as createMemoryId, h as createMcpBindingId, i as createInMemorySkillCatalog, j as defaultContextTemplate, k as defineTool, l as threadState, m as createInboxEventId, n as createHeph, o as block, p as createId, r as InMemoryHephStore, s as memorySearch, t as StreamableHttpMcpToolExecutor, u as createAgentSessionId, v as createRunEventId, w as ContextTemplate, x as MinimalRunExecutor, y as createRunId } from "./src-DeheByi4.mjs";
|
|
2
|
+
export { AgentSpec, ContextProvider, ContextRenderer, ContextTemplate, HephError, InMemoryHephStore, InProcessQueue, MinimalRunExecutor, StreamableHttpMcpToolExecutor, Tool, block, createAgentSessionId, createApprovalRequestId, createDeferredToolOperationId, createHeph, createId, createInMemorySkillCatalog, createInboxEventId, createMcpBindingId, createMemoryId, createMessageId, createRunEventId, createRunId, createSkillBindingId, defaultContextTemplate, defineAgent, defineContextProvider, defineContextTemplate, defineTool, estimateTokens, isHephError, memorySearch, messagesToText, recentMessages, threadState, toErrorDetails };
|
package/dist/hono.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { B as HephRuntime, Dt as AuthContext } from "./index-CdsI9z7r.mjs";
|
|
2
|
+
import { Context, Env, Hono } from "hono";
|
|
3
|
+
|
|
4
|
+
//#region ../server-hono/src/index.d.ts
|
|
5
|
+
type GetAuth<E extends Env = Env> = (c: Context<E>) => AuthContext | null | Promise<AuthContext | null>;
|
|
6
|
+
interface CreateHephRouterOptions<E extends Env = Env> {
|
|
7
|
+
heph: HephRuntime;
|
|
8
|
+
getAuth?: GetAuth<E>;
|
|
9
|
+
requireAuth?: boolean;
|
|
10
|
+
stream?: StreamOptions;
|
|
11
|
+
}
|
|
12
|
+
interface CreateHephAppOptions<E extends Env = Env> extends CreateHephRouterOptions<E> {}
|
|
13
|
+
interface DevAuthOptions {
|
|
14
|
+
subject?: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
tenantId?: string;
|
|
17
|
+
roles?: string[];
|
|
18
|
+
scopes?: string[];
|
|
19
|
+
cookieName?: string;
|
|
20
|
+
}
|
|
21
|
+
interface StreamOptions {
|
|
22
|
+
pollIntervalMs?: number;
|
|
23
|
+
closeOnTerminal?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare function createHephApp<E extends Env = Env>(options: CreateHephAppOptions<E>): Hono<E>;
|
|
26
|
+
declare function createHephRouter<E extends Env = Env>(options: CreateHephRouterOptions<E>): Hono<E>;
|
|
27
|
+
declare function createDevAuth(options?: DevAuthOptions): GetAuth;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { CreateHephAppOptions, CreateHephRouterOptions, DevAuthOptions, GetAuth, StreamOptions, createDevAuth, createHephApp, createHephRouter };
|
|
30
|
+
//# sourceMappingURL=hono.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono.d.mts","names":[],"sources":["../../server-hono/src/index.ts"],"mappings":";;;;KAMY,OAAA,WAAkB,GAAA,GAAM,GAAA,KAAQ,CAAA,EAAG,OAAA,CAAQ,CAAA,MAAO,WAAA,UAAqB,OAAA,CAAQ,WAAA;AAAA,UAE1E,uBAAA,WAAkC,GAAA,GAAM,GAAA;EACvD,IAAA,EAAM,WAAA;EACN,OAAA,GAAU,OAAA,CAAQ,CAAA;EAClB,WAAA;EACA,MAAA,GAAS,aAAA;AAAA;AAAA,UAGM,oBAAA,WAA+B,GAAA,GAAM,GAAA,UAAa,uBAAA,CAAwB,CAAA;AAAA,UAE1E,cAAA;EACf,OAAA;EACA,MAAA;EACA,QAAA;EACA,KAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,UAGe,aAAA;EACf,cAAA;EACA,eAAA;AAAA;AAAA,iBA8Bc,aAAA,WAAwB,GAAA,GAAM,GAAA,CAAA,CAAK,OAAA,EAAS,oBAAA,CAAqB,CAAA,IAAK,IAAA,CAAK,CAAA;AAAA,iBAM3E,gBAAA,WAA2B,GAAA,GAAM,GAAA,CAAA,CAAK,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAK,IAAA,CAAK,CAAA;AAAA,iBAuNjF,aAAA,CAAc,OAAA,GAAS,cAAA,GAAsB,OAAA"}
|