@agentprojectcontext/apx 1.31.2 → 1.32.2
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/package.json +6 -1
- package/skills/apc-context/SKILL.md +5 -2
- package/skills/apx/SKILL.md +3 -3
- package/skills/apx-agency-agents/SKILL.md +5 -5
- package/skills/apx-agent/SKILL.md +7 -7
- package/skills/apx-mcp/SKILL.md +6 -4
- package/skills/apx-mcp-builder/SKILL.md +4 -7
- package/skills/apx-project/SKILL.md +4 -5
- package/skills/apx-routine/SKILL.md +14 -12
- package/skills/apx-runtime/SKILL.md +5 -3
- package/skills/apx-sessions/SKILL.md +5 -5
- package/skills/apx-skill-builder/SKILL.md +10 -6
- package/skills/apx-task/SKILL.md +8 -8
- package/skills/apx-telegram/SKILL.md +23 -7
- package/skills/apx-voice/SKILL.md +8 -6
- package/src/core/{agent-system.js → agent/build-agent-system.js} +10 -12
- package/src/core/agent/constants.js +5 -0
- package/src/core/agent/index.js +0 -2
- package/src/core/{agent-memory.js → agent/memory.js} +2 -2
- package/src/core/agent/model-router.js +21 -43
- package/src/core/agent/prompt-builder.js +17 -63
- package/src/core/agent/prompts/action-discipline.md +17 -0
- package/src/core/agent/prompts/channels/code.md +8 -12
- package/src/core/agent/prompts/channels/desktop.md +6 -4
- package/src/core/agent/prompts/channels/routine.md +10 -1
- package/src/core/agent/prompts/channels/telegram.md +5 -0
- package/src/core/agent/prompts/channels/web_code.md +20 -0
- package/src/core/agent/prompts/modes/voice.md +2 -2
- package/src/core/agent/prompts/super-agent-base.md +2 -2
- package/src/core/agent/run-agent.js +66 -36
- package/src/core/agent/runtime-bridge.js +42 -0
- package/src/core/agent/self-memory.js +19 -9
- package/src/core/agent/skills/catalog.js +65 -0
- package/src/core/agent/skills/index.js +6 -0
- package/src/{host/daemon/skills-loader.js → core/agent/skills/loader.js} +3 -3
- package/src/core/agent/skills/rag.js +91 -0
- package/src/core/agent/skills/trigger.js +71 -0
- package/src/{host/daemon → core/agent}/super-agent.js +5 -5
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/add-project.js +3 -4
- package/src/core/agent/tools/handlers/ask-questions.js +115 -0
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/call-agent.js +2 -2
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/call-mcp.js +1 -2
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/call-runtime.js +10 -11
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/create-task.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/discover-tools.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/edit-file.js +1 -2
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/import-agent.js +4 -5
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-agents.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-skills.js +7 -2
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-tasks.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-vault-agents.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/load-skill.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/read-agent-memory.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/read-self-memory.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/remember.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/run-shell.js +1 -2
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/search-messages.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/search-sessions.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/send-telegram.js +0 -2
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/set-identity.js +1 -3
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/set-permission-mode.js +1 -3
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/tail-messages.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/transcribe-audio.js +1 -1
- package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/write-file.js +1 -2
- package/src/core/agent/tools/helpers.js +74 -0
- package/src/{host/daemon/super-agent-tools → core/agent/tools}/registry-bridge.js +3 -3
- package/src/{host/daemon/super-agent-tools/index.js → core/agent/tools/registry.js} +31 -32
- package/src/core/apc/agents-vault.js +37 -0
- package/src/core/{scaffold.js → apc/scaffold.js} +4 -5
- package/src/core/{config.js → config/index.js} +21 -27
- package/src/core/config/paths.js +32 -0
- package/src/core/constants/actors.js +8 -0
- package/src/core/constants/channels.js +19 -0
- package/src/core/constants/index.js +5 -0
- package/src/core/constants/permissions.js +17 -0
- package/src/core/constants/roles.js +9 -0
- package/src/core/engines/_streaming.js +63 -0
- package/src/core/engines/anthropic.js +11 -22
- package/src/core/engines/ollama.js +7 -16
- package/src/core/identity/index.js +8 -0
- package/src/core/{identity.js → identity/self.js} +5 -5
- package/src/core/{telegram-identity.js → identity/telegram.js} +1 -1
- package/src/core/logging.js +1 -1
- package/src/core/mascot.js +1 -1
- package/src/core/memory/active-threads.js +10 -10
- package/src/core/memory/broker.js +9 -9
- package/src/core/memory/compactor.js +2 -2
- package/src/core/memory/index.js +2 -2
- package/src/core/memory/indexer.js +1 -1
- package/src/core/{code-sessions-store.js → stores/code-sessions.js} +3 -7
- package/src/core/{messages-store.js → stores/messages.js} +6 -4
- package/src/core/stores/routine-memory.js +71 -0
- package/src/core/{routines-store.js → stores/routines.js} +1 -3
- package/src/core/stores/runtime-sessions.js +99 -0
- package/src/core/{tasks-store.js → stores/tasks.js} +3 -8
- package/src/core/update-check.js +1 -1
- package/src/core/util/ids.js +14 -0
- package/src/core/util/index.js +2 -0
- package/src/core/util/text-similarity.js +52 -0
- package/src/core/util/time.js +9 -0
- package/src/core/voice/tts.js +1 -1
- package/src/host/daemon/api/admin-config.js +4 -3
- package/src/host/daemon/api/admin.js +1 -1
- package/src/host/daemon/api/agents.js +4 -25
- package/src/host/daemon/api/artifacts.js +118 -1
- package/src/host/daemon/api/code.js +60 -16
- package/src/host/daemon/api/confirm.js +1 -1
- package/src/host/daemon/api/connections.js +2 -2
- package/src/host/daemon/api/conversations.js +2 -2
- package/src/host/daemon/api/deck.js +1 -1
- package/src/host/daemon/api/desktop.js +1 -1
- package/src/host/daemon/api/embeddings.js +4 -4
- package/src/host/daemon/api/engines.js +2 -2
- package/src/host/daemon/api/exec.js +3 -3
- package/src/host/daemon/api/identity.js +1 -1
- package/src/host/daemon/api/mcps.js +1 -1
- package/src/host/daemon/api/messages.js +1 -1
- package/src/host/daemon/api/runtimes.js +9 -8
- package/src/host/daemon/api/sessions-search.js +1 -1
- package/src/host/daemon/api/sessions.js +2 -2
- package/src/host/daemon/api/shared.js +5 -4
- package/src/host/daemon/api/skills.js +30 -0
- package/src/host/daemon/api/super-agent.js +29 -9
- package/src/host/daemon/api/tasks.js +2 -2
- package/src/host/daemon/api/telegram.js +1 -1
- package/src/host/daemon/api/tools.js +6 -6
- package/src/host/daemon/api/tts.js +2 -2
- package/src/host/daemon/api/voice.js +14 -12
- package/src/host/daemon/api.js +2 -0
- package/src/host/daemon/compact.js +1 -1
- package/src/host/daemon/db.js +4 -4
- package/src/host/daemon/desktop-ws.js +1 -1
- package/src/host/daemon/index.js +4 -4
- package/src/host/daemon/plugins/{desktop.js → desktop/index.js} +45 -6
- package/src/host/daemon/plugins/index.js +2 -2
- package/src/host/daemon/plugins/telegram/ask.js +309 -0
- package/src/host/daemon/plugins/{telegram.js → telegram/index.js} +390 -191
- package/src/host/daemon/plugins/telegram/media.js +162 -0
- package/src/host/daemon/projects-helpers.js +54 -0
- package/src/host/daemon/routines.js +28 -12
- package/src/host/daemon/smoke.js +2 -2
- package/src/host/daemon/token-store.js +1 -1
- package/src/host/daemon/transcription.js +2 -2
- package/src/host/daemon/wakeup.js +2 -2
- package/src/interfaces/cli/commands/agent.js +3 -3
- package/src/interfaces/cli/commands/artifact.js +99 -0
- package/src/interfaces/cli/commands/command.js +1 -1
- package/src/interfaces/cli/commands/config.js +3 -2
- package/src/interfaces/cli/commands/desktop.js +1 -1
- package/src/interfaces/cli/commands/exec.js +2 -1
- package/src/interfaces/cli/commands/identity.js +2 -2
- package/src/interfaces/cli/commands/init.js +1 -1
- package/src/interfaces/cli/commands/mcp.js +1 -1
- package/src/interfaces/cli/commands/memory.js +2 -2
- package/src/interfaces/cli/commands/model.js +16 -6
- package/src/interfaces/cli/commands/project.js +1 -1
- package/src/interfaces/cli/commands/routine.js +58 -0
- package/src/interfaces/cli/commands/search.js +1 -1
- package/src/interfaces/cli/commands/session.js +4 -4
- package/src/interfaces/cli/commands/setup.js +4 -3
- package/src/interfaces/cli/commands/skills.js +25 -4
- package/src/interfaces/cli/commands/status.js +1 -1
- package/src/interfaces/cli/commands/sys.js +11 -4
- package/src/interfaces/cli/commands/update.js +1 -1
- package/src/interfaces/cli/index.js +8 -4
- package/src/interfaces/cli/postinstall.js +2 -2
- package/src/interfaces/cli/terminal-chat/renderer.js +22 -2
- package/src/interfaces/mcp-server/index.js +1 -1
- package/src/interfaces/tui/component/prompt/index.tsx +3 -1
- package/src/interfaces/tui/context/sdk-apx.tsx +47 -7
- package/src/interfaces/tui/context/sync-apx.tsx +20 -2
- package/src/interfaces/tui/context/sync.tsx +2 -1
- package/src/interfaces/tui/routes/session/index.tsx +151 -136
- package/src/interfaces/tui/routes/session/sidebar-apx.tsx +37 -15
- package/src/interfaces/tui/run.ts +2 -0
- package/src/interfaces/web/dist/assets/index-34U_Mp1M.css +1 -0
- package/src/interfaces/web/dist/assets/index-BkybwwRn.js +570 -0
- package/src/interfaces/web/dist/assets/index-BkybwwRn.js.map +1 -0
- package/src/interfaces/web/dist/index.html +2 -2
- package/src/interfaces/web/package-lock.json +9 -9
- package/src/interfaces/web/src/App.tsx +51 -32
- package/src/interfaces/web/src/components/RobyBubble.tsx +12 -6
- package/src/interfaces/web/src/components/UiSelect.tsx +1 -1
- package/src/interfaces/web/src/components/chat/AskQuestionsCard.tsx +72 -0
- package/src/interfaces/web/src/components/chat/InlineAskPanel.tsx +399 -0
- package/src/interfaces/web/src/components/chat/MessageBubble.tsx +16 -3
- package/src/interfaces/web/src/components/chat/MessageList.tsx +2 -1
- package/src/interfaces/web/src/components/chat/SkillPicker.tsx +77 -0
- package/src/interfaces/web/src/components/code/CodeArtifactsTab.tsx +230 -0
- package/src/interfaces/web/src/components/code/CodeProjectPicker.tsx +1 -1
- package/src/interfaces/web/src/components/code/CodeSidePanel.tsx +40 -17
- package/src/interfaces/web/src/components/common/TabLayout.tsx +9 -5
- package/src/interfaces/web/src/components/common/TabNav.tsx +3 -3
- package/src/interfaces/web/src/components/layout/ProjectSidebar.tsx +4 -2
- package/src/interfaces/web/src/hooks/useChat.ts +47 -2
- package/src/interfaces/web/src/hooks/useNavCollapseCtx.tsx +59 -0
- package/src/interfaces/web/src/hooks/usePersonaName.ts +11 -0
- package/src/interfaces/web/src/i18n/en.ts +27 -7
- package/src/interfaces/web/src/i18n/es.ts +27 -7
- package/src/interfaces/web/src/lib/api/artifacts.ts +47 -0
- package/src/interfaces/web/src/lib/api/skills.ts +25 -0
- package/src/interfaces/web/src/lib/api.ts +2 -0
- package/src/interfaces/web/src/screens/modules/CodeScreen.tsx +41 -20
- package/src/interfaces/web/src/screens/modules/DeckScreen.tsx +5 -18
- package/src/interfaces/web/src/screens/modules/DesktopScreen.tsx +1 -8
- package/src/interfaces/web/src/screens/modules/VoiceScreen.tsx +39 -40
- package/src/interfaces/web/src/screens/project/ChatTab.tsx +27 -9
- package/src/skills/apc-context/SKILL.md +159 -0
- package/src/core/agent/ghost-guard.js +0 -24
- package/src/core/agent/prompts/channels/terminal.md +0 -16
- package/src/host/daemon/apc-runtime-context.js +0 -124
- package/src/host/daemon/super-agent-tools/helpers.js +0 -124
- package/src/host/daemon/super-agent-tools/tools/ask-questions.js +0 -32
- package/src/host/daemon/tool-call-parser.js +0 -2
- package/src/interfaces/web/dist/assets/index-BDUsA6L6.css +0 -1
- package/src/interfaces/web/dist/assets/index-BV615I9p.js +0 -548
- package/src/interfaces/web/dist/assets/index-BV615I9p.js.map +0 -1
- /package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-files.js +0 -0
- /package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-mcps.js +0 -0
- /package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/list-projects.js +0 -0
- /package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/read-file.js +0 -0
- /package/src/{host/daemon/super-agent-tools/tools → core/agent/tools/handlers}/search-files.js +0 -0
- /package/src/core/agent/{pseudo-tools.js → tools/pseudo-tools.js} +0 -0
- /package/src/core/agent/{tool-call-parser.js → tools/tool-call-parser.js} +0 -0
- /package/src/core/{parser.js → apc/parser.js} +0 -0
- /package/src/core/{apc-skill-sync.js → apc/skill-sync.js} +0 -0
- /package/src/core/{artifacts-store.js → stores/artifacts.js} +0 -0
- /package/src/{host/daemon → core/stores}/engine-sessions.js +0 -0
- /package/src/core/{session-store.js → stores/sessions.js} +0 -0
|
@@ -6,44 +6,23 @@
|
|
|
6
6
|
// PUT /projects/:pid/agents/:slug/memory
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
import { readAgents, readVaultAgents, readVaultAgent } from "
|
|
9
|
+
import { readAgents, readVaultAgents, readVaultAgent } from "#core/apc/parser.js";
|
|
10
10
|
import {
|
|
11
11
|
writeAgentFile,
|
|
12
12
|
writeVaultAgentFile,
|
|
13
13
|
removeVaultAgent,
|
|
14
14
|
restoreVaultAgent,
|
|
15
15
|
ensureAgentDir,
|
|
16
|
-
} from "
|
|
16
|
+
} from "#core/apc/scaffold.js";
|
|
17
17
|
import {
|
|
18
18
|
ensureAgentRuntimeDir,
|
|
19
19
|
readAgentMemory,
|
|
20
20
|
writeAgentMemory,
|
|
21
21
|
agentMemoryPath,
|
|
22
22
|
legacyAgentMemoryPath,
|
|
23
|
-
} from "
|
|
23
|
+
} from "#core/agent/memory.js";
|
|
24
24
|
import { agentToResponse } from "./shared.js";
|
|
25
|
-
|
|
26
|
-
// Lowercase the patch keys we accept on the vault and turn skills/tools into
|
|
27
|
-
// arrays. The writer takes either case but normalizes; passing this through
|
|
28
|
-
// it keeps the on-disk format consistent.
|
|
29
|
-
const VAULT_PATCH_FIELDS = ["role", "model", "language", "description", "skills", "tools", "is_master"];
|
|
30
|
-
function normalizeVaultPatch(input = {}) {
|
|
31
|
-
const out = {};
|
|
32
|
-
for (const k of VAULT_PATCH_FIELDS) {
|
|
33
|
-
const lower = k;
|
|
34
|
-
const title = k.charAt(0).toUpperCase() + k.slice(1);
|
|
35
|
-
const v = input[lower] ?? input[title];
|
|
36
|
-
if (v === undefined || v === null) continue;
|
|
37
|
-
if (k === "skills" || k === "tools") {
|
|
38
|
-
out[title] = Array.isArray(v)
|
|
39
|
-
? v.map(String).map((s) => s.trim()).filter(Boolean)
|
|
40
|
-
: String(v).split(",").map((s) => s.trim()).filter(Boolean);
|
|
41
|
-
} else {
|
|
42
|
-
out[title] = v;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
25
|
+
import { normalizeVaultPatch } from "#core/apc/agents-vault.js";
|
|
47
26
|
|
|
48
27
|
export function register(app, { projects, project }) {
|
|
49
28
|
// Vault = global agent templates. Two-layer: bundled defaults shipped with
|
|
@@ -2,13 +2,92 @@
|
|
|
2
2
|
// GET /projects/:pid/artifacts
|
|
3
3
|
// POST /projects/:pid/artifacts
|
|
4
4
|
// GET /projects/:pid/artifacts/:name
|
|
5
|
+
// POST /projects/:pid/artifacts/:name/run body: { args?: string[] }
|
|
5
6
|
// DELETE /projects/:pid/artifacts/:name
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import path from "node:path";
|
|
6
10
|
import {
|
|
11
|
+
artifactPath,
|
|
7
12
|
createArtifact,
|
|
8
13
|
listArtifacts,
|
|
9
14
|
readArtifact,
|
|
10
15
|
removeArtifact,
|
|
11
|
-
} from "
|
|
16
|
+
} from "#core/stores/artifacts.js";
|
|
17
|
+
|
|
18
|
+
// Same heuristic as `apx artifact run` (cli/commands/artifact.js): exec bit
|
|
19
|
+
// OR shebang counts as runnable. We auto-chmod when shebang-only so the
|
|
20
|
+
// web Run button "just works" the way it would from the terminal.
|
|
21
|
+
function detectRunnable(absPath) {
|
|
22
|
+
let stat;
|
|
23
|
+
try {
|
|
24
|
+
stat = fs.statSync(absPath);
|
|
25
|
+
} catch {
|
|
26
|
+
return { runnable: false, reason: "not_found" };
|
|
27
|
+
}
|
|
28
|
+
if (!stat.isFile()) return { runnable: false, reason: "not_a_file" };
|
|
29
|
+
const execBit = (stat.mode & 0o111) !== 0;
|
|
30
|
+
let hasShebang = false;
|
|
31
|
+
try {
|
|
32
|
+
const fd = fs.openSync(absPath, "r");
|
|
33
|
+
const buf = Buffer.alloc(2);
|
|
34
|
+
fs.readSync(fd, buf, 0, 2, 0);
|
|
35
|
+
fs.closeSync(fd);
|
|
36
|
+
hasShebang = buf.toString("utf8") === "#!";
|
|
37
|
+
} catch { /* leave hasShebang = false */ }
|
|
38
|
+
if (execBit) return { runnable: true, autoChmod: false };
|
|
39
|
+
if (hasShebang) return { runnable: true, autoChmod: true };
|
|
40
|
+
return { runnable: false, reason: "no_exec_no_shebang" };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cap stdout/stderr captured per run so a runaway script can't blow up the
|
|
44
|
+
// daemon. 256 KiB each — enough for typical script output, small enough to
|
|
45
|
+
// fit in one HTTP response without streaming.
|
|
46
|
+
const MAX_CAPTURE_BYTES = 256 * 1024;
|
|
47
|
+
// Hard timeout for synchronous web execution. Long-running scripts should
|
|
48
|
+
// be invoked from the terminal where the user has direct stdio.
|
|
49
|
+
const RUN_TIMEOUT_MS = 30_000;
|
|
50
|
+
|
|
51
|
+
function runArtifact({ absPath, cwd, args, timeoutMs = RUN_TIMEOUT_MS }) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const started = Date.now();
|
|
54
|
+
const child = spawn(absPath, Array.isArray(args) ? args : [], { cwd });
|
|
55
|
+
let stdout = "";
|
|
56
|
+
let stderr = "";
|
|
57
|
+
let truncated = false;
|
|
58
|
+
let timedOut = false;
|
|
59
|
+
const cap = (s, chunk) => {
|
|
60
|
+
if (s.length >= MAX_CAPTURE_BYTES) { truncated = true; return s; }
|
|
61
|
+
const next = s + chunk.toString("utf8");
|
|
62
|
+
if (next.length > MAX_CAPTURE_BYTES) { truncated = true; return next.slice(0, MAX_CAPTURE_BYTES); }
|
|
63
|
+
return next;
|
|
64
|
+
};
|
|
65
|
+
child.stdout.on("data", (c) => { stdout = cap(stdout, c); });
|
|
66
|
+
child.stderr.on("data", (c) => { stderr = cap(stderr, c); });
|
|
67
|
+
const killer = setTimeout(() => {
|
|
68
|
+
timedOut = true;
|
|
69
|
+
try { child.kill("SIGTERM"); } catch { /* ignore */ }
|
|
70
|
+
setTimeout(() => { try { child.kill("SIGKILL"); } catch { /* ignore */ } }, 1500);
|
|
71
|
+
}, timeoutMs);
|
|
72
|
+
child.on("error", (err) => {
|
|
73
|
+
clearTimeout(killer);
|
|
74
|
+
resolve({ ok: false, error: err.message, durationMs: Date.now() - started });
|
|
75
|
+
});
|
|
76
|
+
child.on("exit", (code, signal) => {
|
|
77
|
+
clearTimeout(killer);
|
|
78
|
+
resolve({
|
|
79
|
+
ok: !timedOut && code === 0,
|
|
80
|
+
exitCode: code,
|
|
81
|
+
signal,
|
|
82
|
+
timedOut,
|
|
83
|
+
truncated,
|
|
84
|
+
stdout,
|
|
85
|
+
stderr,
|
|
86
|
+
durationMs: Date.now() - started,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
12
91
|
|
|
13
92
|
export function register(app, { project }) {
|
|
14
93
|
app.get("/projects/:pid/artifacts", (req, res) => {
|
|
@@ -49,4 +128,42 @@ export function register(app, { project }) {
|
|
|
49
128
|
);
|
|
50
129
|
res.status(ok ? 204 : 404).end();
|
|
51
130
|
});
|
|
131
|
+
|
|
132
|
+
// Synchronous execute. Web's "Run" button hits this; the terminal CLI uses
|
|
133
|
+
// its own local spawn (stdio inherited) so it can run interactively. Output
|
|
134
|
+
// is captured up to MAX_CAPTURE_BYTES and the call is bounded by
|
|
135
|
+
// RUN_TIMEOUT_MS — anything longer should go through the terminal.
|
|
136
|
+
app.post("/projects/:pid/artifacts/:name/run", async (req, res) => {
|
|
137
|
+
const p = project(req, res);
|
|
138
|
+
if (!p) return;
|
|
139
|
+
const name = decodeURIComponent(req.params.name);
|
|
140
|
+
const absPath = artifactPath(p.storagePath, name);
|
|
141
|
+
if (!fs.existsSync(absPath)) {
|
|
142
|
+
return res.status(404).json({ error: `artifact "${name}" not found` });
|
|
143
|
+
}
|
|
144
|
+
const detection = detectRunnable(absPath);
|
|
145
|
+
if (!detection.runnable) {
|
|
146
|
+
return res.status(400).json({
|
|
147
|
+
error: `artifact "${name}" is not runnable`,
|
|
148
|
+
reason: detection.reason,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (detection.autoChmod) {
|
|
152
|
+
try {
|
|
153
|
+
const st = fs.statSync(absPath);
|
|
154
|
+
fs.chmodSync(absPath, st.mode | 0o111);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
return res.status(500).json({ error: `chmod failed: ${e.message}` });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const args = Array.isArray(req.body?.args)
|
|
160
|
+
? req.body.args.filter((a) => typeof a === "string")
|
|
161
|
+
: [];
|
|
162
|
+
const result = await runArtifact({
|
|
163
|
+
absPath,
|
|
164
|
+
cwd: path.dirname(absPath),
|
|
165
|
+
args,
|
|
166
|
+
});
|
|
167
|
+
res.json(result);
|
|
168
|
+
});
|
|
52
169
|
}
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
// stateful: the turn handler rebuilds `previousMessages` from the stored
|
|
13
13
|
// transcript, runs the super-agent on the `code` channel (with plan/build mode
|
|
14
14
|
// + per-mode tool gating), then persists the rich assistant turn.
|
|
15
|
-
import { runSuperAgent } from "
|
|
15
|
+
import { runSuperAgent } from "#core/agent/super-agent.js";
|
|
16
16
|
import { appendSuperAgentErrorTrace } from "./shared.js";
|
|
17
|
-
import { createWebConfirmAdapter } from "
|
|
17
|
+
import { createWebConfirmAdapter } from "#core/confirmation/adapters/web.js";
|
|
18
|
+
import { CHANNELS } from "#core/constants/channels.js";
|
|
18
19
|
import {
|
|
19
20
|
listCodeSessions,
|
|
20
21
|
getCodeSession,
|
|
@@ -22,9 +23,9 @@ import {
|
|
|
22
23
|
updateCodeSession,
|
|
23
24
|
removeCodeSession,
|
|
24
25
|
appendTurn,
|
|
25
|
-
} from "
|
|
26
|
-
import { captureBaseline, diffAgainstBaseline, initGitRepo } from "
|
|
27
|
-
import { loggerFor } from "
|
|
26
|
+
} from "#core/stores/code-sessions.js";
|
|
27
|
+
import { captureBaseline, diffAgainstBaseline, initGitRepo } from "#core/git-baseline.js";
|
|
28
|
+
import { loggerFor } from "#core/logging.js";
|
|
28
29
|
|
|
29
30
|
const log = loggerFor("code");
|
|
30
31
|
|
|
@@ -68,20 +69,63 @@ function modeGuidanceFor(mode) {
|
|
|
68
69
|
"confirmation and do not stop after one step — keep calling tools until the",
|
|
69
70
|
"entire task is done, then briefly summarize what you changed and why.",
|
|
70
71
|
"Prefer surgical edits over rewrites.",
|
|
72
|
+
"When the user asks for a reusable script, snippet, or 'artifact' (something",
|
|
73
|
+
"they want to keep and run later), put it under `artifacts/<name>` inside",
|
|
74
|
+
"the project — it then shows up in the Artifacts tab. Don't drop reusable",
|
|
75
|
+
"scripts at the project root.",
|
|
76
|
+
"If a parameter you need is missing (API key, app id, target URL, …), call",
|
|
77
|
+
"`ask_questions` ONCE with all your questions and stop — control returns",
|
|
78
|
+
"to the user. Do not call ask_questions again in the same turn; you'll just",
|
|
79
|
+
"get the same blank state back. Each question can be a string (free-text",
|
|
80
|
+
"answer) OR an object {question, options:[{label, description}], multiSelect}",
|
|
81
|
+
"for choices. Prefer 2–4 mutually-exclusive options when a question has a",
|
|
82
|
+
"natural shortlist (yes/no, which-of-these, …); leave options empty for",
|
|
83
|
+
"open-ended answers (API keys, names, free-form ideas).",
|
|
84
|
+
"If the previous assistant turn already asked these same questions and the",
|
|
85
|
+
"current user message is the compiled answers, DO NOT call ask_questions",
|
|
86
|
+
"again — process the answers and proceed with the task.",
|
|
71
87
|
].join(" ");
|
|
72
88
|
}
|
|
73
89
|
|
|
74
90
|
// Build the [{role, content}] history the super-agent expects from the stored
|
|
75
|
-
// rich transcript: flatten each turn's text parts
|
|
91
|
+
// rich transcript: flatten each turn's text parts. Tool parts are normally
|
|
92
|
+
// internal, but ask_questions is special — without surfacing it the model
|
|
93
|
+
// loses track that it ALREADY asked, sees the user's compiled-answer reply
|
|
94
|
+
// as a fresh request, and asks again forever. We render a one-line synthetic
|
|
95
|
+
// summary of each ask_questions call so the next turn's context shows
|
|
96
|
+
// "I asked X, the user replied Y" naturally.
|
|
97
|
+
function summarizeAskQuestionsPart(part) {
|
|
98
|
+
const raw = part?.args?.questions;
|
|
99
|
+
if (!Array.isArray(raw) || raw.length === 0) return null;
|
|
100
|
+
const lines = raw
|
|
101
|
+
.map((q) => {
|
|
102
|
+
if (typeof q === "string") return `- ${q}`;
|
|
103
|
+
if (!q || typeof q !== "object" || typeof q.question !== "string") return null;
|
|
104
|
+
const opts = Array.isArray(q.options) ? q.options : [];
|
|
105
|
+
const optStr = opts
|
|
106
|
+
.map((o) => (typeof o === "string" ? o : (o && typeof o.label === "string" ? o.label : "")))
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.join(", ");
|
|
109
|
+
return optStr ? `- ${q.question} (opciones: ${optStr})` : `- ${q.question}`;
|
|
110
|
+
})
|
|
111
|
+
.filter(Boolean);
|
|
112
|
+
if (lines.length === 0) return null;
|
|
113
|
+
return `[ask_questions]\n${lines.join("\n")}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
76
116
|
function historyFrom(session) {
|
|
77
|
-
return (session.messages || []).map((m) =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
117
|
+
return (session.messages || []).map((m) => {
|
|
118
|
+
const chunks = [];
|
|
119
|
+
for (const p of m.parts || []) {
|
|
120
|
+
if (!p) continue;
|
|
121
|
+
if (p.kind === "text" && p.text) chunks.push(p.text);
|
|
122
|
+
else if (p.kind === "tool" && p.tool === "ask_questions") {
|
|
123
|
+
const summary = summarizeAskQuestionsPart(p);
|
|
124
|
+
if (summary) chunks.push(summary);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { role: m.role, content: chunks.join("\n\n").trim() };
|
|
128
|
+
});
|
|
85
129
|
}
|
|
86
130
|
|
|
87
131
|
// Accumulate stream events into the rich ChatPart shape so the persisted
|
|
@@ -273,7 +317,7 @@ export function register(app, { projects, project, config, registries, plugins }
|
|
|
273
317
|
plugins,
|
|
274
318
|
registries,
|
|
275
319
|
prompt,
|
|
276
|
-
channel:
|
|
320
|
+
channel: CHANNELS.WEB_CODE,
|
|
277
321
|
channelMeta: {
|
|
278
322
|
projectId: String(p.id),
|
|
279
323
|
projectName: p.name,
|
|
@@ -337,7 +381,7 @@ export function register(app, { projects, project, config, registries, plugins }
|
|
|
337
381
|
});
|
|
338
382
|
appendSuperAgentErrorTrace(req, e, {
|
|
339
383
|
prompt,
|
|
340
|
-
channel:
|
|
384
|
+
channel: CHANNELS.WEB_CODE,
|
|
341
385
|
previousMessages,
|
|
342
386
|
model: session.model,
|
|
343
387
|
stream: true,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// Promise in the agent loop, unblocking it to continue with confirmed: true
|
|
9
9
|
// or to return a cancelled error.
|
|
10
10
|
|
|
11
|
-
import { getConfirmationStore } from "
|
|
11
|
+
import { getConfirmationStore } from "#core/confirmation/pending-store.js";
|
|
12
12
|
|
|
13
13
|
export function register(app) {
|
|
14
14
|
app.post("/super-agent/confirm/:correlationId", async (req, res) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// GET /projects/:pid/agents/:slug/connections
|
|
2
2
|
// Builds a per-peer summary of an agent's a2a traffic from the messages store.
|
|
3
|
-
import { readAgents } from "
|
|
4
|
-
import { readProjectMessages } from "
|
|
3
|
+
import { readAgents } from "#core/apc/parser.js";
|
|
4
|
+
import { readProjectMessages } from "#core/stores/messages.js";
|
|
5
5
|
|
|
6
6
|
export function register(app, { project }) {
|
|
7
7
|
app.get("/projects/:pid/agents/:slug/connections", (req, res) => {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// POST /projects/:pid/send (agent-to-agent)
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
import { readAgents } from "
|
|
10
|
-
import { callEngine } from "
|
|
9
|
+
import { readAgents } from "#core/apc/parser.js";
|
|
10
|
+
import { callEngine } from "#core/engines/index.js";
|
|
11
11
|
import { listConversations, readConversation } from "../conversations.js";
|
|
12
12
|
import { compactConversation } from "../compact.js";
|
|
13
13
|
import { nowIso } from "./shared.js";
|
|
@@ -226,7 +226,7 @@ export function register(app, ctx) {
|
|
|
226
226
|
// the override we're about to set; we mutate ONLY the override and
|
|
227
227
|
// leave everything else intact.
|
|
228
228
|
try {
|
|
229
|
-
const { readConfig, writeConfig } = await import("
|
|
229
|
+
const { readConfig, writeConfig } = await import("#core/config/index.js");
|
|
230
230
|
const fresh = readConfig();
|
|
231
231
|
fresh.deck = fresh.deck && typeof fresh.deck === "object" ? fresh.deck : {};
|
|
232
232
|
fresh.deck.widget_overrides =
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
// POST /embeddings/reindex → { ok, cleared, indexed } (rebuild the vector
|
|
9
9
|
// store under the current embedder — needed
|
|
10
10
|
// after switching provider/model)
|
|
11
|
-
import { readConfig } from "
|
|
11
|
+
import { readConfig } from "#core/config/index.js";
|
|
12
12
|
import {
|
|
13
13
|
listAvailableEmbedEngines,
|
|
14
14
|
embeddingsConfig,
|
|
15
15
|
resolveMode,
|
|
16
16
|
resolveChainOrder,
|
|
17
|
-
} from "
|
|
18
|
-
import { embedOne } from "
|
|
19
|
-
import { reindexMemory } from "
|
|
17
|
+
} from "#core/memory/embed-engines/index.js";
|
|
18
|
+
import { embedOne } from "#core/memory/embeddings.js";
|
|
19
|
+
import { reindexMemory } from "#core/memory/index.js";
|
|
20
20
|
|
|
21
21
|
export function register(app) {
|
|
22
22
|
app.get("/embeddings/providers", async (_req, res) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// GET /engines — list engine adapter ids known to core/engines.
|
|
2
2
|
// POST /engines/models — live model catalog from a provider.
|
|
3
3
|
// GET /engines/models — legacy (Ollama only, no auth).
|
|
4
|
-
import { ENGINE_IDS } from "
|
|
5
|
-
import { fetchJsonWithTimeout } from "
|
|
4
|
+
import { ENGINE_IDS } from "#core/engines/index.js";
|
|
5
|
+
import { fetchJsonWithTimeout } from "#core/engines/_health.js";
|
|
6
6
|
|
|
7
7
|
const DEFAULT_BASE = {
|
|
8
8
|
openai: "https://api.openai.com/v1",
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
//
|
|
5
5
|
// POST /projects/:pid/agents/:slug/exec one-shot, no history
|
|
6
6
|
// POST /projects/:pid/agents/:slug/chat append to (or start) a conversation
|
|
7
|
-
import { callEngine } from "
|
|
8
|
-
import { readAgents } from "
|
|
9
|
-
import { buildAgentSystem } from "
|
|
7
|
+
import { callEngine } from "#core/engines/index.js";
|
|
8
|
+
import { readAgents } from "#core/apc/parser.js";
|
|
9
|
+
import { buildAgentSystem } from "#core/agent/build-agent-system.js";
|
|
10
10
|
import {
|
|
11
11
|
startConversation,
|
|
12
12
|
appendTurn,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// GET /identity full identity.json
|
|
2
2
|
// PATCH /identity { agent_name?, owner_name?, personality?, owner_context?, language?, timezone? }
|
|
3
|
-
import { readIdentity, writeIdentity } from "
|
|
3
|
+
import { readIdentity, writeIdentity } from "#core/identity/index.js";
|
|
4
4
|
|
|
5
5
|
const ALLOWED_KEYS = new Set([
|
|
6
6
|
"agent_name",
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
readGlobalMessages,
|
|
10
10
|
readProjectMessages,
|
|
11
11
|
searchProjectMessages,
|
|
12
|
-
} from "
|
|
12
|
+
} from "#core/stores/messages.js";
|
|
13
13
|
|
|
14
14
|
export function register(app, { project }) {
|
|
15
15
|
app.get("/projects/:pid/messages", (req, res) => {
|
|
@@ -7,18 +7,19 @@
|
|
|
7
7
|
// GET /projects/:pid/sessions/:id/resume?summarize=true
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
|
-
import { readAgents } from "
|
|
11
|
-
import { readSessionFrontmatter } from "
|
|
12
|
-
import { buildAgentSystem } from "
|
|
10
|
+
import { readAgents } from "#core/apc/parser.js";
|
|
11
|
+
import { readSessionFrontmatter } from "#core/stores/sessions.js";
|
|
12
|
+
import { buildAgentSystem } from "#core/agent/build-agent-system.js";
|
|
13
|
+
import { CHANNELS } from "#core/constants/channels.js";
|
|
13
14
|
import { getRuntime, RUNTIME_IDS } from "../runtimes/index.js";
|
|
14
15
|
import { detectAll } from "../env-detect.js";
|
|
16
|
+
import { buildRuntimeBridgeHint as buildApfHint } from "#core/agent/runtime-bridge.js";
|
|
15
17
|
import {
|
|
16
|
-
buildApfHint,
|
|
17
18
|
createRuntimeSession,
|
|
18
19
|
closeRuntimeSession,
|
|
19
|
-
extractApfResult,
|
|
20
|
-
} from "
|
|
21
|
-
import { runSuperAgent, isSuperAgentEnabled } from "
|
|
20
|
+
extractRuntimeResult as extractApfResult,
|
|
21
|
+
} from "#core/stores/runtime-sessions.js";
|
|
22
|
+
import { runSuperAgent, isSuperAgentEnabled } from "#core/agent/super-agent.js";
|
|
22
23
|
|
|
23
24
|
export function register(app, { projects, registries, plugins, project, config }) {
|
|
24
25
|
app.get("/runtimes", (_req, res) =>
|
|
@@ -205,7 +206,7 @@ export function register(app, { projects, registries, plugins, project, config }
|
|
|
205
206
|
plugins,
|
|
206
207
|
registries,
|
|
207
208
|
prompt,
|
|
208
|
-
channel:
|
|
209
|
+
channel: CHANNELS.API,
|
|
209
210
|
contextNote: `Resume request for session ${id}.`,
|
|
210
211
|
});
|
|
211
212
|
out.summary = sa.text;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// then delegates to compactConversation.
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { readAgents } from "
|
|
7
|
+
import { readAgents } from "#core/apc/parser.js";
|
|
8
8
|
import { compactConversation } from "../compact.js";
|
|
9
9
|
|
|
10
10
|
export function register(app, { projects, config }) {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// GET /projects/:pid/sessions/:sid by filename (cross-agent lookup)
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { parseSessionFrontmatter, readAgents } from "
|
|
8
|
-
import { collectAllSessions } from "
|
|
7
|
+
import { parseSessionFrontmatter, readAgents } from "#core/apc/parser.js";
|
|
8
|
+
import { collectAllSessions } from "#interfaces/cli/commands/sessions.js";
|
|
9
9
|
import { nowIso } from "./shared.js";
|
|
10
10
|
|
|
11
11
|
export function register(app, { projects, project }) {
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
|
-
import { appendErrorTrace, previewText } from "
|
|
9
|
-
import { readAgents } from "
|
|
10
|
-
import { agentMemoryPath } from "
|
|
8
|
+
import { appendErrorTrace, previewText } from "#core/logging.js";
|
|
9
|
+
import { readAgents } from "#core/apc/parser.js";
|
|
10
|
+
import { agentMemoryPath } from "#core/agent/memory.js";
|
|
11
|
+
import { CHANNELS } from "#core/constants/channels.js";
|
|
11
12
|
|
|
12
13
|
export const nowIso = () =>
|
|
13
14
|
new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
@@ -141,7 +142,7 @@ export function resolveSuperAgentContext(req, project) {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
return {
|
|
144
|
-
channel:
|
|
145
|
+
channel: CHANNELS.API,
|
|
145
146
|
channelMeta: {
|
|
146
147
|
projectId: String(project.id),
|
|
147
148
|
projectName: project.name,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Lightweight `/skills` listing for UI surfaces (web composer picker,
|
|
2
|
+
// future palettes). Same data backing `list_skills` tool, but here without
|
|
3
|
+
// auth-binding to a project — anyone with a valid daemon token can ask
|
|
4
|
+
// "which skills are around right now?".
|
|
5
|
+
//
|
|
6
|
+
// Returns the catalog already condensed (slug + first-sentence description)
|
|
7
|
+
// so the picker doesn't have to repeat the cleanup work.
|
|
8
|
+
import { listSkills } from "#core/agent/skills/loader.js";
|
|
9
|
+
import { condenseSkillDescription } from "#core/agent/skills/catalog.js";
|
|
10
|
+
|
|
11
|
+
export function register(app /*, ctx */) {
|
|
12
|
+
app.get("/skills", (req, res) => {
|
|
13
|
+
const projectPath = typeof req.query?.project_path === "string"
|
|
14
|
+
? req.query.project_path
|
|
15
|
+
: undefined;
|
|
16
|
+
try {
|
|
17
|
+
const skills = listSkills({ projectPath });
|
|
18
|
+
res.json({
|
|
19
|
+
count: skills.length,
|
|
20
|
+
skills: skills.map(({ slug, source, description }) => ({
|
|
21
|
+
slug,
|
|
22
|
+
source,
|
|
23
|
+
description: condenseSkillDescription(description),
|
|
24
|
+
})),
|
|
25
|
+
});
|
|
26
|
+
} catch (e) {
|
|
27
|
+
res.status(500).json({ error: e.message });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
//
|
|
6
6
|
// POST /projects/:pid/super-agent/chat/stream NDJSON event stream
|
|
7
7
|
// POST /projects/:pid/super-agent/chat blocking JSON response
|
|
8
|
-
import { runSuperAgent } from "
|
|
8
|
+
import { runSuperAgent } from "#core/agent/super-agent.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveSuperAgentContext,
|
|
11
11
|
appendSuperAgentErrorTrace,
|
|
12
12
|
} from "./shared.js";
|
|
13
|
-
import { loggerFor } from "
|
|
14
|
-
import { appendGlobalMessage } from "
|
|
15
|
-
import { createWebConfirmAdapter } from "
|
|
13
|
+
import { loggerFor } from "#core/logging.js";
|
|
14
|
+
import { appendGlobalMessage } from "#core/stores/messages.js";
|
|
15
|
+
import { createWebConfirmAdapter } from "#core/confirmation/adapters/web.js";
|
|
16
|
+
import { tryResolveSkillCommand } from "#core/agent/skills/trigger.js";
|
|
17
|
+
import { suggestSkillForPrompt } from "#core/agent/skills/rag.js";
|
|
18
|
+
import { CHANNELS } from "#core/constants/channels.js";
|
|
16
19
|
|
|
17
20
|
const log = loggerFor("super-agent");
|
|
18
21
|
|
|
@@ -20,7 +23,7 @@ const log = loggerFor("super-agent");
|
|
|
20
23
|
// RAG index, search_messages, and the "active threads" awareness block. Only
|
|
21
24
|
// the human surfaces (web big chat + sidebar) — not generic "api"/automation
|
|
22
25
|
// callers. Best-effort: a logging failure never breaks the reply.
|
|
23
|
-
const WEB_LOGGED_CHANNELS = new Set([
|
|
26
|
+
const WEB_LOGGED_CHANNELS = new Set([CHANNELS.WEB, CHANNELS.WEB_SIDEBAR]);
|
|
24
27
|
function logWebTurn(channel, { prompt, replyText }) {
|
|
25
28
|
if (!WEB_LOGGED_CHANNELS.has(channel)) return;
|
|
26
29
|
try {
|
|
@@ -66,11 +69,24 @@ export function register(app, { projects, registries, plugins, project, config }
|
|
|
66
69
|
// Optional coding-surface knobs: the terminal Code TUI (apx code, Build
|
|
67
70
|
// mode) sends these so it runs to completion exactly like the web Code
|
|
68
71
|
// module. Plain chat callers omit them and keep the lightweight defaults.
|
|
69
|
-
const { prompt, previousMessages, model, maxIters, maxTokens, completionContract } =
|
|
72
|
+
const { prompt: rawPrompt, previousMessages, model, maxIters, maxTokens, completionContract } =
|
|
70
73
|
req.body || {};
|
|
71
|
-
if (!
|
|
74
|
+
if (!rawPrompt) return res.status(400).json({ error: "prompt required" });
|
|
72
75
|
const ctx = resolveSuperAgentContext(req, p);
|
|
73
76
|
|
|
77
|
+
// `/slug ...` shortcut: load the matching skill body into contextNote and
|
|
78
|
+
// strip the prefix from the user prompt. Falls through unchanged when the
|
|
79
|
+
// slug is unknown.
|
|
80
|
+
const slashed = tryResolveSkillCommand(rawPrompt, { projectPath: p.path });
|
|
81
|
+
const prompt = slashed.handled ? slashed.prompt : rawPrompt;
|
|
82
|
+
if (slashed.handled) {
|
|
83
|
+
ctx.contextNote = [ctx.contextNote, slashed.contextNote].filter(Boolean).join("\n\n");
|
|
84
|
+
} else {
|
|
85
|
+
// Semantic skill nudge — only when there was no explicit /slug.
|
|
86
|
+
const hint = await suggestSkillForPrompt(prompt, { projectPath: p.path });
|
|
87
|
+
if (hint) ctx.contextNote = [ctx.contextNote, hint].filter(Boolean).join("\n\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
74
90
|
res.setHeader("content-type", "application/x-ndjson; charset=utf-8");
|
|
75
91
|
res.setHeader("cache-control", "no-cache, no-transform");
|
|
76
92
|
res.setHeader("x-accel-buffering", "no");
|
|
@@ -151,7 +167,7 @@ export function register(app, { projects, registries, plugins, project, config }
|
|
|
151
167
|
registries,
|
|
152
168
|
prompt,
|
|
153
169
|
contextNote,
|
|
154
|
-
channel:
|
|
170
|
+
channel: CHANNELS.API,
|
|
155
171
|
overrideModel: model,
|
|
156
172
|
maxTokens:
|
|
157
173
|
max_tokens && Number.isFinite(Number(max_tokens))
|
|
@@ -174,7 +190,8 @@ export function register(app, { projects, registries, plugins, project, config }
|
|
|
174
190
|
app.post("/projects/:pid/super-agent/chat", async (req, res) => {
|
|
175
191
|
const p = project(req, res);
|
|
176
192
|
if (!p) return;
|
|
177
|
-
const { prompt, previousMessages, model
|
|
193
|
+
const { prompt, previousMessages, model, maxIters, maxTokens, completionContract } =
|
|
194
|
+
req.body || {};
|
|
178
195
|
if (!prompt) return res.status(400).json({ error: "prompt required" });
|
|
179
196
|
const ctx = resolveSuperAgentContext(req, p);
|
|
180
197
|
try {
|
|
@@ -189,6 +206,9 @@ export function register(app, { projects, registries, plugins, project, config }
|
|
|
189
206
|
contextNote: ctx.contextNote,
|
|
190
207
|
previousMessages: previousMessages || [],
|
|
191
208
|
overrideModel: model,
|
|
209
|
+
...(Number.isFinite(Number(maxIters)) ? { maxIters: Number(maxIters) } : {}),
|
|
210
|
+
...(Number.isFinite(Number(maxTokens)) ? { maxTokens: Number(maxTokens) } : {}),
|
|
211
|
+
...(completionContract ? { completionContract: true } : {}),
|
|
192
212
|
onEvent: wrapOnEventForLog(null, {
|
|
193
213
|
trace_id: req.apxTraceId,
|
|
194
214
|
channel: ctx.channel,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Per-project tasks (TODOs). Backed by core/tasks
|
|
1
|
+
// Per-project tasks (TODOs). Backed by core/stores/tasks.js (JSONL event log).
|
|
2
2
|
// GET /projects/:pid/tasks ?state=open|done|dropped|all&tag=X&agent=Y&due_before=ISO&limit=N
|
|
3
3
|
// POST /projects/:pid/tasks { title, body?, tags?, due?, agent?, source?, meta? }
|
|
4
4
|
// GET /projects/:pid/tasks/:id (id or prefix)
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
dropTask,
|
|
16
16
|
reopenTask,
|
|
17
17
|
countTasks,
|
|
18
|
-
} from "
|
|
18
|
+
} from "#core/stores/tasks.js";
|
|
19
19
|
|
|
20
20
|
export function register(app, { project, projects }) {
|
|
21
21
|
// Global tasks across every project.
|