@agentprojectcontext/apx 1.77.2 → 1.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -9
- package/package.json +12 -12
- package/src/core/agent/build-agent-system.js +3 -2
- package/src/core/agent/constants.js +3 -2
- package/src/core/agent/loop/greeting-guard.js +55 -0
- package/src/core/agent/loop/side-effects.js +52 -0
- package/src/core/agent/prompt-builder.js +49 -8
- package/src/core/agent/run-agent.js +13 -48
- package/src/core/agent/security.js +1 -1
- package/src/core/agent/self-memory.js +4 -2
- package/src/core/agent/skills/index-store.js +2 -2
- package/src/core/agent/skills/loader.js +3 -22
- package/src/core/agent/super-agent.js +0 -2
- package/src/core/agent/tools/handlers/call-runtime.js +4 -4
- package/src/core/agent/tools/handlers/search-sessions.js +1 -1
- package/src/core/agent/tools/handlers/set-permission-mode.js +11 -4
- package/src/core/agent/tools/names.js +58 -0
- package/src/core/apc/context-copy.js +1 -1
- package/src/core/apc/frontmatter.js +85 -0
- package/src/core/apc/parser.js +9 -21
- package/src/core/apc/paths.js +8 -8
- package/src/core/apc/scaffold.js +5 -4
- package/src/core/channels/telegram/config.js +201 -0
- package/src/core/config/index.js +25 -183
- package/src/core/config/paths.js +54 -1
- package/src/core/confirmation/adapters/web.js +1 -1
- package/src/core/deck/manifest.js +12 -12
- package/src/core/desktop/autostart.js +3 -2
- package/src/core/desktop/process.js +4 -4
- package/src/core/engines/presets.js +2 -2
- package/src/core/http-tools/browser.js +1 -1
- package/src/core/http-tools/catalog.js +551 -0
- package/src/core/http-tools/fetch.js +1 -1
- package/src/core/http-tools/glob.js +3 -3
- package/src/core/http-tools/grep.js +2 -9
- package/src/core/http-tools/inline-handlers.js +59 -0
- package/src/core/http-tools/registry.js +31 -615
- package/src/core/http-tools/search.js +2 -2
- package/src/core/identity/self.js +6 -7
- package/src/core/identity/telegram.js +3 -3
- package/src/core/logging.js +6 -5
- package/src/core/mcp/sources.js +12 -16
- package/src/core/memory/indexer.js +2 -5
- package/src/core/profiles/lifecycle.js +0 -2
- package/src/core/profiles/store.js +2 -7
- package/src/core/routines/runner.js +1 -1
- package/src/core/runtime-skills/apx-agency-agents/SKILL.md +2 -2
- package/src/core/runtime-skills/apx-profile/SKILL.md +3 -3
- package/src/core/runtime-skills/apx-project/SKILL.md +1 -1
- package/src/core/runtime-skills/apx-task/SKILL.md +8 -8
- package/src/core/runtime-skills/apx-telegram/SKILL.md +4 -4
- package/src/core/runtime-skills/apx-voice/SKILL.md +4 -4
- package/src/core/runtimes/detect.js +2 -2
- package/src/core/sessions/index.js +800 -0
- package/src/core/stores/code-sessions.js +3 -14
- package/src/core/stores/engine-sessions.js +0 -4
- package/src/core/stores/messages.js +0 -5
- package/src/core/stores/organization.js +9 -11
- package/src/core/stores/routines.js +6 -11
- package/src/core/stores/runtime-callbacks.js +2 -1
- package/src/core/util/json-file.js +128 -0
- package/src/core/vars/sources.js +14 -21
- package/src/core/voice/stt-models.js +1 -1
- package/src/core/voice/tts.js +5 -4
- package/src/host/daemon/api/admin-config.js +5 -5
- package/src/host/daemon/api/admin.js +8 -7
- package/src/host/daemon/api/agents.js +16 -16
- package/src/host/daemon/api/artifact-preview.js +8 -8
- package/src/host/daemon/api/artifacts.js +7 -7
- package/src/host/daemon/api/code.js +8 -8
- package/src/host/daemon/api/config.js +6 -6
- package/src/host/daemon/api/confirm.js +2 -2
- package/src/host/daemon/api/connections.js +2 -2
- package/src/host/daemon/api/conversations.js +12 -12
- package/src/host/daemon/api/deck.js +6 -6
- package/src/host/daemon/api/desktop.js +8 -8
- package/src/host/daemon/api/embeddings.js +4 -4
- package/src/host/daemon/api/engines.js +8 -7
- package/src/host/daemon/api/exec.js +5 -4
- package/src/host/daemon/api/files-project.js +6 -6
- package/src/host/daemon/api/health.js +2 -2
- package/src/host/daemon/api/identity.js +3 -3
- package/src/host/daemon/api/inbox.js +2 -2
- package/src/host/daemon/api/integrations.js +23 -19
- package/src/host/daemon/api/mcps.js +16 -12
- package/src/host/daemon/api/messages.js +5 -5
- package/src/host/daemon/api/organization.js +8 -8
- package/src/host/daemon/api/pairing.js +10 -7
- package/src/host/daemon/api/plugins.js +3 -3
- package/src/host/daemon/api/prefix.js +20 -0
- package/src/host/daemon/api/profiles.js +9 -9
- package/src/host/daemon/api/projects.js +5 -5
- package/src/host/daemon/api/routines.js +8 -8
- package/src/host/daemon/api/run.js +2 -2
- package/src/host/daemon/api/runtimes.js +6 -6
- package/src/host/daemon/api/sessions-search.js +18 -11
- package/src/host/daemon/api/sessions.js +6 -6
- package/src/host/daemon/api/shared.js +59 -13
- package/src/host/daemon/api/skills.js +12 -12
- package/src/host/daemon/api/super-agent.js +4 -4
- package/src/host/daemon/api/tasks.js +11 -11
- package/src/host/daemon/api/telegram.js +19 -20
- package/src/host/daemon/api/tools.js +7 -7
- package/src/host/daemon/api/top-level.js +7 -7
- package/src/host/daemon/api/transcribe.js +6 -6
- package/src/host/daemon/api/tts.js +3 -3
- package/src/host/daemon/api/vars.js +11 -8
- package/src/host/daemon/api/voice.js +6 -6
- package/src/host/daemon/api/web.js +28 -32
- package/src/host/daemon/api.js +77 -48
- package/src/host/daemon/db.js +1 -1
- package/src/host/daemon/desktop-ws.js +7 -3
- package/src/host/daemon/index.js +11 -5
- package/src/host/daemon/plugins/desktop/index.js +1 -1
- package/src/host/daemon/plugins/telegram/index.js +1 -1
- package/src/host/daemon/stt-venv.js +20 -81
- package/src/host/daemon/wakeup.js +1 -1
- package/src/interfaces/acp/index.js +3 -3
- package/src/interfaces/acp/session.js +2 -2
- package/src/interfaces/cli/commands/a2a.js +2 -2
- package/src/interfaces/cli/commands/agent.js +3 -3
- package/src/interfaces/cli/commands/artifact.js +13 -13
- package/src/interfaces/cli/commands/chat.js +3 -3
- package/src/interfaces/cli/commands/command.js +2 -2
- package/src/interfaces/cli/commands/config.js +4 -4
- package/src/interfaces/cli/commands/daemon.js +17 -18
- package/src/interfaces/cli/commands/desktop.js +7 -14
- package/src/interfaces/cli/commands/exec.js +2 -2
- package/src/interfaces/cli/commands/log.js +3 -4
- package/src/interfaces/cli/commands/mcp.js +9 -9
- package/src/interfaces/cli/commands/memory.js +2 -2
- package/src/interfaces/cli/commands/messages.js +5 -5
- package/src/interfaces/cli/commands/model.js +0 -18
- package/src/interfaces/cli/commands/obsidian.js +5 -5
- package/src/interfaces/cli/commands/org.js +5 -5
- package/src/interfaces/cli/commands/pair.js +6 -6
- package/src/interfaces/cli/commands/plugins.js +2 -2
- package/src/interfaces/cli/commands/profile.js +10 -10
- package/src/interfaces/cli/commands/project-config.js +6 -6
- package/src/interfaces/cli/commands/project.js +10 -10
- package/src/interfaces/cli/commands/routine.js +8 -9
- package/src/interfaces/cli/commands/runtime.js +2 -2
- package/src/interfaces/cli/commands/search.js +0 -1
- package/src/interfaces/cli/commands/session.js +12 -40
- package/src/interfaces/cli/commands/sessions.js +21 -798
- package/src/interfaces/cli/commands/setup.js +16 -6
- package/src/interfaces/cli/commands/skills.js +1 -2
- package/src/interfaces/cli/commands/status.js +3 -3
- package/src/interfaces/cli/commands/task.js +8 -8
- package/src/interfaces/cli/commands/telegram.js +21 -21
- package/src/interfaces/cli/commands/voice.js +6 -6
- package/src/interfaces/cli/help/index.js +2245 -0
- package/src/interfaces/cli/http.js +9 -4
- package/src/interfaces/cli/index.js +14 -2857
- package/src/interfaces/cli/routes/acp.js +13 -0
- package/src/interfaces/cli/routes/agent.js +27 -0
- package/src/interfaces/cli/routes/artifact.js +28 -0
- package/src/interfaces/cli/routes/chat.js +11 -0
- package/src/interfaces/cli/routes/code.js +11 -0
- package/src/interfaces/cli/routes/command.js +21 -0
- package/src/interfaces/cli/routes/config.js +16 -0
- package/src/interfaces/cli/routes/connections.js +11 -0
- package/src/interfaces/cli/routes/conversations.js +21 -0
- package/src/interfaces/cli/routes/daemon.js +19 -0
- package/src/interfaces/cli/routes/desktop.js +20 -0
- package/src/interfaces/cli/routes/env.js +13 -0
- package/src/interfaces/cli/routes/exec.js +11 -0
- package/src/interfaces/cli/routes/identity.js +11 -0
- package/src/interfaces/cli/routes/index.js +71 -0
- package/src/interfaces/cli/routes/init.js +11 -0
- package/src/interfaces/cli/routes/log.js +20 -0
- package/src/interfaces/cli/routes/mcp.js +22 -0
- package/src/interfaces/cli/routes/memory.js +11 -0
- package/src/interfaces/cli/routes/messages.js +16 -0
- package/src/interfaces/cli/routes/model.js +11 -0
- package/src/interfaces/cli/routes/obsidian.js +17 -0
- package/src/interfaces/cli/routes/org.js +34 -0
- package/src/interfaces/cli/routes/overlay.js +10 -0
- package/src/interfaces/cli/routes/pair.js +17 -0
- package/src/interfaces/cli/routes/panel.js +16 -0
- package/src/interfaces/cli/routes/permission.js +11 -0
- package/src/interfaces/cli/routes/plugins.js +21 -0
- package/src/interfaces/cli/routes/profile.js +27 -0
- package/src/interfaces/cli/routes/project.js +41 -0
- package/src/interfaces/cli/routes/restart.js +15 -0
- package/src/interfaces/cli/routes/routine.js +28 -0
- package/src/interfaces/cli/routes/run.js +11 -0
- package/src/interfaces/cli/routes/search.js +11 -0
- package/src/interfaces/cli/routes/send.js +11 -0
- package/src/interfaces/cli/routes/session.js +26 -0
- package/src/interfaces/cli/routes/sessions.js +15 -0
- package/src/interfaces/cli/routes/setup.js +18 -0
- package/src/interfaces/cli/routes/skills.js +20 -0
- package/src/interfaces/cli/routes/status.js +12 -0
- package/src/interfaces/cli/routes/task.js +26 -0
- package/src/interfaces/cli/routes/telegram.js +39 -0
- package/src/interfaces/cli/routes/update.js +24 -0
- package/src/interfaces/cli/routes/voice.js +17 -0
- package/src/interfaces/desktop/main.js +6 -7
- package/src/interfaces/desktop/renderer.js +0 -5
- package/src/interfaces/mcp-server/index.js +15 -14
- package/src/interfaces/tui/_shims/globals.d.ts +8 -0
- package/src/interfaces/tui/tsconfig.json +4 -1
- package/src/interfaces/web/README.md +6 -6
- package/src/interfaces/web/dist/assets/index-CBR_-QyA.js +824 -0
- package/src/interfaces/web/dist/assets/index-CBR_-QyA.js.map +1 -0
- package/src/interfaces/web/dist/index.html +1 -1
- package/src/interfaces/web/src/components/AddProjectDialog.tsx +1 -1
- package/src/interfaces/web/src/components/agents/AgentFormFields.tsx +1 -1
- package/src/interfaces/web/src/components/chat/ChatList.tsx +2 -2
- package/src/interfaces/web/src/components/chat/SkillPicker.tsx +1 -1
- package/src/interfaces/web/src/components/code/CodeFileTree.tsx +1 -1
- package/src/interfaces/web/src/components/code/CodeTerminal.tsx +1 -1
- package/src/interfaces/web/src/components/desktop/DesktopStatusCard.tsx +1 -1
- package/src/interfaces/web/src/components/files/FileBrowser.tsx +2 -2
- package/src/interfaces/web/src/components/memory/MemoryBrowser.tsx +2 -2
- package/src/interfaces/web/src/components/routines/ExecutionsList.tsx +1 -1
- package/src/interfaces/web/src/components/routines/RoutineEditor.tsx +2 -2
- package/src/interfaces/web/src/components/settings/DesktopSettingsPanel.tsx +1 -1
- package/src/interfaces/web/src/components/settings/MemoryPanel.tsx +1 -1
- package/src/interfaces/web/src/components/settings/SkillsInspectorPanel.tsx +1 -1
- package/src/interfaces/web/src/components/settings/SkillsManager.tsx +2 -2
- package/src/interfaces/web/src/components/tasks/TaskDetailPanel.tsx +1 -1
- package/src/interfaces/web/src/hooks/useDaemonStatus.ts +1 -1
- package/src/interfaces/web/src/hooks/useDevices.ts +1 -1
- package/src/interfaces/web/src/hooks/useEngines.ts +1 -1
- package/src/interfaces/web/src/hooks/useGlobalConfig.ts +2 -2
- package/src/interfaces/web/src/hooks/useIdentity.ts +1 -1
- package/src/interfaces/web/src/hooks/useInbox.ts +1 -1
- package/src/interfaces/web/src/hooks/useProfiles.ts +3 -3
- package/src/interfaces/web/src/hooks/useProjects.ts +1 -1
- package/src/interfaces/web/src/hooks/useTelegram.ts +3 -3
- package/src/interfaces/web/src/hooks/useTokenBootstrap.ts +30 -7
- package/src/interfaces/web/src/lib/api/admin.ts +11 -11
- package/src/interfaces/web/src/lib/api/agents.ts +14 -14
- package/src/interfaces/web/src/lib/api/artifacts.ts +11 -11
- package/src/interfaces/web/src/lib/api/code.ts +1 -1
- package/src/interfaces/web/src/lib/api/conversations.ts +8 -8
- package/src/interfaces/web/src/lib/api/deck.ts +3 -3
- package/src/interfaces/web/src/lib/api/desktop.ts +8 -8
- package/src/interfaces/web/src/lib/api/embeddings.ts +3 -3
- package/src/interfaces/web/src/lib/api/engines.ts +3 -3
- package/src/interfaces/web/src/lib/api/filesystem.ts +2 -2
- package/src/interfaces/web/src/lib/api/health.ts +1 -1
- package/src/interfaces/web/src/lib/api/identity.ts +2 -2
- package/src/interfaces/web/src/lib/api/inbox.ts +1 -1
- package/src/interfaces/web/src/lib/api/integrations.ts +8 -8
- package/src/interfaces/web/src/lib/api/mcps.ts +6 -6
- package/src/interfaces/web/src/lib/api/messages.ts +3 -3
- package/src/interfaces/web/src/lib/api/organization.ts +7 -7
- package/src/interfaces/web/src/lib/api/profiles.ts +8 -8
- package/src/interfaces/web/src/lib/api/projectFiles.ts +5 -5
- package/src/interfaces/web/src/lib/api/projects.ts +12 -12
- package/src/interfaces/web/src/lib/api/routines.ts +7 -7
- package/src/interfaces/web/src/lib/api/sessions.ts +2 -2
- package/src/interfaces/web/src/lib/api/skills.ts +11 -11
- package/src/interfaces/web/src/lib/api/super_agent.ts +3 -3
- package/src/interfaces/web/src/lib/api/tasks.ts +12 -12
- package/src/interfaces/web/src/lib/api/telegram.ts +14 -14
- package/src/interfaces/web/src/lib/api/tools.ts +1 -1
- package/src/interfaces/web/src/lib/api/vars.ts +4 -4
- package/src/interfaces/web/src/lib/api/voice.ts +6 -6
- package/src/interfaces/web/src/screens/base/AgentDefaultsTab.tsx +1 -1
- package/src/interfaces/web/src/screens/base/GlobalTasksTab.tsx +1 -1
- package/src/interfaces/web/src/screens/base/LogsTab.tsx +3 -3
- package/src/interfaces/web/src/screens/base/SessionsTab.tsx +1 -1
- package/src/interfaces/web/src/screens/modules/CodeScreen.tsx +1 -1
- package/src/interfaces/web/src/screens/modules/DeckScreen.tsx +1 -1
- package/src/interfaces/web/src/screens/modules/DesktopScreen.tsx +1 -1
- package/src/interfaces/web/src/screens/modules/VoiceScreen.tsx +1 -1
- package/src/interfaces/web/src/screens/project/AgentDetailScreen.tsx +8 -8
- package/src/interfaces/web/src/screens/project/AgentsTab.tsx +2 -2
- package/src/interfaces/web/src/screens/project/ChatTab.tsx +3 -3
- package/src/interfaces/web/src/screens/project/ConfigTab.tsx +1 -1
- package/src/interfaces/web/src/screens/project/McpsTab.tsx +3 -3
- package/src/interfaces/web/src/screens/project/Overview.tsx +6 -6
- package/src/interfaces/web/src/screens/project/RoutinesTab.tsx +2 -2
- package/src/interfaces/web/src/screens/project/StructureTab.tsx +1 -1
- package/src/interfaces/web/src/screens/project/TasksTab.tsx +1 -1
- package/src/interfaces/web/src/screens/project/VarsTab.tsx +1 -1
- package/src/interfaces/web/vite.config.ts +13 -18
- package/src/interfaces/web/dist/assets/index-BWWpTTSd.js +0 -824
- package/src/interfaces/web/dist/assets/index-BWWpTTSd.js.map +0 -1
- package/src/skills/apc-context/SKILL.md +0 -159
- /package/src/{host/daemon → core}/runtimes/_spawn.js +0 -0
- /package/src/{host/daemon → core}/runtimes/aider.js +0 -0
- /package/src/{host/daemon → core}/runtimes/antigravity.js +0 -0
- /package/src/{host/daemon → core}/runtimes/claude-code.js +0 -0
- /package/src/{host/daemon → core}/runtimes/codex.js +0 -0
- /package/src/{host/daemon → core}/runtimes/cursor-agent.js +0 -0
- /package/src/{host/daemon → core}/runtimes/gemini-cli.js +0 -0
- /package/src/{host/daemon → core}/runtimes/index.js +0 -0
- /package/src/{host/daemon → core}/runtimes/opencode.js +0 -0
- /package/src/{host/daemon → core}/runtimes/qwen-code.js +0 -0
package/src/core/config/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { APX_HOME, CONFIG_PATH } from "./paths.js";
|
|
8
|
-
import { PERMISSION_MODES
|
|
8
|
+
import { PERMISSION_MODES } from "../constants/permissions.js";
|
|
9
9
|
import { agentsMdFile, apcProjectFile } from "../apc/paths.js";
|
|
10
10
|
|
|
11
11
|
export {
|
|
@@ -62,6 +62,10 @@ const DEFAULT_CONFIG = {
|
|
|
62
62
|
// snappier but more "want me to continue?" hand-backs. 0/unset → built-in
|
|
63
63
|
// default (TELEGRAM_TOOL_ITERS in src/core/agent/constants.js).
|
|
64
64
|
telegram_max_iters: 0,
|
|
65
|
+
// Char cap for a FOREIGN project's AGENTS.md in the prompt. 0 = no cap.
|
|
66
|
+
// The project APX runs inside is never capped regardless of this value —
|
|
67
|
+
// a project must always read its own contract whole.
|
|
68
|
+
project_agents_max_chars: 24000,
|
|
65
69
|
// Model fallback: ordered list. Each item carries its own provider
|
|
66
70
|
// prefix; the array order IS the attempt order. The router tries the
|
|
67
71
|
// primary (super_agent.model) first, then walks this list, skipping
|
|
@@ -522,186 +526,24 @@ export function removeProject(cfg, idOrPath) {
|
|
|
522
526
|
if (cfg.projects.length !== before) writeConfig(cfg);
|
|
523
527
|
return { removed: before - cfg.projects.length };
|
|
524
528
|
}
|
|
525
|
-
// ── Telegram channels (multi-channel mode) ──────────────────────────────────
|
|
526
|
-
// Each entry in cfg.telegram.channels[] is { name, bot_token, chat_id,
|
|
527
|
-
// route_to_agent, project, respond_with_engine, poll_interval_ms }.
|
|
528
|
-
// These helpers keep the array shape stable for the CLI and the daemon API.
|
|
529
|
-
|
|
530
|
-
const CHANNEL_FIELDS = [
|
|
531
|
-
"name",
|
|
532
|
-
"bot_token",
|
|
533
|
-
"chat_id",
|
|
534
|
-
"route_to_agent",
|
|
535
|
-
"project",
|
|
536
|
-
"respond_with_engine",
|
|
537
|
-
"poll_interval_ms",
|
|
538
|
-
"owner_user_id",
|
|
539
|
-
];
|
|
540
|
-
|
|
541
|
-
function ensureChannelsArray(cfg) {
|
|
542
|
-
cfg.telegram = cfg.telegram || {};
|
|
543
|
-
if (!Array.isArray(cfg.telegram.channels)) cfg.telegram.channels = [];
|
|
544
|
-
return cfg.telegram.channels;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
export function listTelegramChannels(cfg) {
|
|
548
|
-
return ensureChannelsArray(cfg).slice();
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
export function findTelegramChannel(cfg, name) {
|
|
552
|
-
return ensureChannelsArray(cfg).find((c) => c.name === name) || null;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// Create-or-patch a channel by name. `patch` is a partial channel object;
|
|
556
|
-
// unknown keys are dropped. Returns { created, channel }.
|
|
557
|
-
export function upsertTelegramChannel(cfg, name, patch = {}) {
|
|
558
|
-
if (!name || typeof name !== "string")
|
|
559
|
-
throw new Error("upsertTelegramChannel: name required");
|
|
560
|
-
const channels = ensureChannelsArray(cfg);
|
|
561
|
-
let entry = channels.find((c) => c.name === name);
|
|
562
|
-
const created = !entry;
|
|
563
|
-
if (!entry) {
|
|
564
|
-
entry = { name };
|
|
565
|
-
channels.push(entry);
|
|
566
|
-
}
|
|
567
|
-
for (const k of CHANNEL_FIELDS) {
|
|
568
|
-
if (k === "name") continue;
|
|
569
|
-
if (patch[k] !== undefined) entry[k] = patch[k];
|
|
570
|
-
}
|
|
571
|
-
// Default respond_with_engine to true on create.
|
|
572
|
-
if (created && entry.respond_with_engine === undefined) {
|
|
573
|
-
entry.respond_with_engine = true;
|
|
574
|
-
}
|
|
575
|
-
writeConfig(cfg);
|
|
576
|
-
return { created, channel: entry };
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
export function removeTelegramChannel(cfg, name) {
|
|
580
|
-
const channels = ensureChannelsArray(cfg);
|
|
581
|
-
const before = channels.length;
|
|
582
|
-
cfg.telegram.channels = channels.filter((c) => c.name !== name);
|
|
583
|
-
const removed = before - cfg.telegram.channels.length;
|
|
584
|
-
if (removed > 0) {
|
|
585
|
-
// Explicit user-initiated removal — bypass the credential-loss guard
|
|
586
|
-
// so the write goes through even when this empties the array.
|
|
587
|
-
cfg._allowClear = true;
|
|
588
|
-
writeConfig(cfg);
|
|
589
|
-
}
|
|
590
|
-
return { removed };
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
// Clear specific optional fields on a channel (project, route_to_agent, …).
|
|
594
|
-
// Returns { channel } or null when no such channel.
|
|
595
|
-
export function unsetTelegramChannelFields(cfg, name, fields = []) {
|
|
596
|
-
const ch = findTelegramChannel(cfg, name);
|
|
597
|
-
if (!ch) return null;
|
|
598
|
-
let mutated = false;
|
|
599
|
-
for (const f of fields) {
|
|
600
|
-
if (!CHANNEL_FIELDS.includes(f) || f === "name") continue;
|
|
601
|
-
if (f in ch) {
|
|
602
|
-
delete ch[f];
|
|
603
|
-
mutated = true;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
if (mutated) writeConfig(cfg);
|
|
607
|
-
return { channel: ch };
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// ── Telegram contacts (global roster, keyed by user_id) ─────────────────────
|
|
611
|
-
// Identity of a person is global; the per-channel owner_user_id only marks who
|
|
612
|
-
// owns a given channel. Role lives on the contact (global), per the chosen
|
|
613
|
-
// design — owner_user_id overrides it to "owner" for that channel only.
|
|
614
|
-
|
|
615
|
-
const CONTACT_FIELDS = [
|
|
616
|
-
"user_id",
|
|
617
|
-
"name",
|
|
618
|
-
"username",
|
|
619
|
-
"role",
|
|
620
|
-
"note",
|
|
621
|
-
"first_seen",
|
|
622
|
-
"last_seen",
|
|
623
|
-
];
|
|
624
|
-
|
|
625
|
-
function ensureContactsArray(cfg) {
|
|
626
|
-
cfg.telegram = cfg.telegram || {};
|
|
627
|
-
if (!Array.isArray(cfg.telegram.contacts)) cfg.telegram.contacts = [];
|
|
628
|
-
return cfg.telegram.contacts;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
export function listContacts(cfg) {
|
|
632
|
-
return ensureContactsArray(cfg).slice();
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
export function findContact(cfg, userId) {
|
|
636
|
-
if (userId == null) return null;
|
|
637
|
-
return (
|
|
638
|
-
ensureContactsArray(cfg).find((c) => String(c.user_id) === String(userId)) ||
|
|
639
|
-
null
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// Create-or-patch a contact by user_id. Unknown keys are dropped.
|
|
644
|
-
export function upsertContact(cfg, userId, patch = {}, { persist = true } = {}) {
|
|
645
|
-
if (userId == null) throw new Error("upsertContact: user_id required");
|
|
646
|
-
const contacts = ensureContactsArray(cfg);
|
|
647
|
-
let entry = contacts.find((c) => String(c.user_id) === String(userId));
|
|
648
|
-
const created = !entry;
|
|
649
|
-
if (!entry) {
|
|
650
|
-
entry = { user_id: userId };
|
|
651
|
-
contacts.push(entry);
|
|
652
|
-
}
|
|
653
|
-
for (const k of CONTACT_FIELDS) {
|
|
654
|
-
if (k === "user_id") continue;
|
|
655
|
-
if (patch[k] !== undefined) entry[k] = patch[k];
|
|
656
|
-
}
|
|
657
|
-
if (persist) writeConfig(cfg);
|
|
658
|
-
return { created, contact: entry };
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
export function setContactRole(cfg, userId, role) {
|
|
662
|
-
const { contact } = upsertContact(cfg, userId, { role });
|
|
663
|
-
return contact;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
export function removeContact(cfg, userId) {
|
|
667
|
-
const contacts = ensureContactsArray(cfg);
|
|
668
|
-
const before = contacts.length;
|
|
669
|
-
cfg.telegram.contacts = contacts.filter(
|
|
670
|
-
(c) => String(c.user_id) !== String(userId)
|
|
671
|
-
);
|
|
672
|
-
const removed = before - cfg.telegram.contacts.length;
|
|
673
|
-
if (removed > 0) writeConfig(cfg);
|
|
674
|
-
return { removed };
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
export function setChannelOwner(cfg, channelName, userId) {
|
|
678
|
-
return upsertTelegramChannel(cfg, channelName, { owner_user_id: userId });
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// ── Telegram roles (role → capability map) ──────────────────────────────────
|
|
682
|
-
|
|
683
|
-
export function listRoles(cfg) {
|
|
684
|
-
cfg.telegram = cfg.telegram || {};
|
|
685
|
-
return { ...(cfg.telegram.roles || {}) };
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
export function setRole(cfg, name, def) {
|
|
689
|
-
if (!name || typeof name !== "string") throw new Error("setRole: name required");
|
|
690
|
-
cfg.telegram = cfg.telegram || {};
|
|
691
|
-
cfg.telegram.roles = cfg.telegram.roles || {};
|
|
692
|
-
cfg.telegram.roles[name] = def;
|
|
693
|
-
writeConfig(cfg);
|
|
694
|
-
return cfg.telegram.roles[name];
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
export function removeRole(cfg, name) {
|
|
698
|
-
cfg.telegram = cfg.telegram || {};
|
|
699
|
-
if (!cfg.telegram.roles || !(name in cfg.telegram.roles)) return { removed: 0 };
|
|
700
|
-
if (name === "owner" || name === "guest") {
|
|
701
|
-
throw new Error(`role "${name}" is built-in and cannot be removed`);
|
|
702
|
-
}
|
|
703
|
-
delete cfg.telegram.roles[name];
|
|
704
|
-
writeConfig(cfg);
|
|
705
|
-
return { removed: 1 };
|
|
706
|
-
}
|
|
707
529
|
|
|
530
|
+
// ── Telegram identity ───────────────────────────────────────────────────────
|
|
531
|
+
// Moved to core/channels/telegram/config.js — it is channel domain, not config
|
|
532
|
+
// plumbing. Re-exported here so the CLI, the daemon API and the plugin keep
|
|
533
|
+
// their existing import paths.
|
|
534
|
+
export {
|
|
535
|
+
listTelegramChannels,
|
|
536
|
+
findTelegramChannel,
|
|
537
|
+
upsertTelegramChannel,
|
|
538
|
+
removeTelegramChannel,
|
|
539
|
+
unsetTelegramChannelFields,
|
|
540
|
+
listContacts,
|
|
541
|
+
findContact,
|
|
542
|
+
upsertContact,
|
|
543
|
+
setContactRole,
|
|
544
|
+
removeContact,
|
|
545
|
+
setChannelOwner,
|
|
546
|
+
listRoles,
|
|
547
|
+
setRole,
|
|
548
|
+
removeRole,
|
|
549
|
+
} from "../channels/telegram/config.js";
|
package/src/core/config/paths.js
CHANGED
|
@@ -4,7 +4,19 @@ import fs from "node:fs";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Where APX keeps everything. `APX_HOME` in the environment relocates it —
|
|
9
|
+
* useful for sandboxes and required by tests that need an isolated home.
|
|
10
|
+
*
|
|
11
|
+
* Resolve lazily when a caller can be reached after the environment changes
|
|
12
|
+
* (tests stub os.homedir mid-run); the eager `APX_HOME` constant below is the
|
|
13
|
+
* common case and stays for the ~30 call sites that read it at import time.
|
|
14
|
+
*/
|
|
15
|
+
export function apxHome() {
|
|
16
|
+
return process.env.APX_HOME || path.join(os.homedir(), ".apx");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const APX_HOME = apxHome();
|
|
8
20
|
export const CONFIG_PATH = path.join(APX_HOME, "config.json");
|
|
9
21
|
export const PID_PATH = path.join(APX_HOME, "daemon.pid");
|
|
10
22
|
export const LOG_PATH = path.join(APX_HOME, "daemon.log");
|
|
@@ -21,6 +33,47 @@ export const PROJECT_STORE_ROOT = path.join(APX_HOME, "projects");
|
|
|
21
33
|
export const DEFAULT_PROJECT_ID = "default";
|
|
22
34
|
export const DEFAULT_PROJECT_STORE = path.join(PROJECT_STORE_ROOT, DEFAULT_PROJECT_ID);
|
|
23
35
|
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Everything else under ~/.apx.
|
|
38
|
+
//
|
|
39
|
+
// These used to be rebuilt from os.homedir() at ~30 call sites, several of them
|
|
40
|
+
// duplicated across modules that then drifted: the TTS scratch dir existed in
|
|
41
|
+
// core/voice/tts.js *and* api/voice.js, the desktop log in core/desktop/
|
|
42
|
+
// process.js *and* cli/commands/desktop.js, the log paths in core/logging.js
|
|
43
|
+
// *and* cli/commands/log.js. One definition each, imported everywhere.
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
/** The super-agent's own notebook (see core/agent/self-memory.js). */
|
|
47
|
+
export const SELF_MEMORY_PATH = path.join(APX_HOME, "memory.md");
|
|
48
|
+
/** Who the super-agent is: name, personality, owner. */
|
|
49
|
+
export const IDENTITY_PATH = path.join(APX_HOME, "identity.json");
|
|
50
|
+
|
|
51
|
+
/** User-installed skills and the RAG index built over them. */
|
|
52
|
+
export const SKILLS_DIR = path.join(APX_HOME, "skills");
|
|
53
|
+
export const SKILLS_INDEX_PATH = path.join(SKILLS_DIR, ".index.json");
|
|
54
|
+
|
|
55
|
+
/** Agent vault — reusable agent definitions, not tied to one project. */
|
|
56
|
+
export const AGENT_VAULT_DIR = path.join(APX_HOME, "agents");
|
|
57
|
+
|
|
58
|
+
/** Unified log tree. Everything writes here so one tail follows the system. */
|
|
59
|
+
export const LOG_DIR = path.join(APX_HOME, "logs");
|
|
60
|
+
export const APX_LOG_PATH = path.join(LOG_DIR, "apx.log");
|
|
61
|
+
export const ERROR_TRACE_PATH = path.join(LOG_DIR, "errors.jsonl");
|
|
62
|
+
|
|
63
|
+
/** Desktop capsule (Electron) runtime state. */
|
|
64
|
+
export const DESKTOP_PID_PATH = path.join(APX_HOME, "desktop.pid");
|
|
65
|
+
export const DESKTOP_LOG_PATH = path.join(APX_HOME, "desktop.log");
|
|
66
|
+
export const DESKTOP_AUTOSTART_LOG_PATH = path.join(APX_HOME, "desktop-autostart.log");
|
|
67
|
+
|
|
68
|
+
/** Scratch space. Safe to delete between runs. */
|
|
69
|
+
export const TMP_DIR = path.join(APX_HOME, "tmp");
|
|
70
|
+
export const TTS_TMP_DIR = path.join(TMP_DIR, "tts");
|
|
71
|
+
export const RECORDINGS_TMP_DIR = path.join(TMP_DIR, "recordings");
|
|
72
|
+
|
|
73
|
+
/** Managed runtimes we install on the user's behalf. */
|
|
74
|
+
export const RUNTIME_DIR = path.join(APX_HOME, "runtime");
|
|
75
|
+
export const WHISPER_VENV_DIR = path.join(RUNTIME_DIR, "whisper-venv");
|
|
76
|
+
|
|
24
77
|
export function projectStorageRoot(apxId) {
|
|
25
78
|
return path.join(PROJECT_STORE_ROOT, apxId);
|
|
26
79
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// dialog. The dialog is keyed by correlationId.
|
|
12
12
|
//
|
|
13
13
|
// 3. The user responds → frontend POSTs to
|
|
14
|
-
// POST /super-agent/confirm/:correlationId { confirmed: boolean }
|
|
14
|
+
// POST /api/super-agent/confirm/:correlationId { confirmed: boolean }
|
|
15
15
|
//
|
|
16
16
|
// 4. The API handler (api/confirm.js) calls pendingStore.resolve(correlationId,
|
|
17
17
|
// value). This finds the in-memory resolve callback and calls it, unblocking
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// APX Deck manifest — the data model the companion clients (deck, desktop
|
|
2
2
|
// capsule) read on boot. Pure data + decoration; no HTTP or filesystem.
|
|
3
|
-
// host/daemon/api/deck.js wraps this for the /deck/manifest endpoint.
|
|
3
|
+
// host/daemon/api/deck.js wraps this for the /api/deck/manifest endpoint.
|
|
4
4
|
|
|
5
5
|
export const CORE_WIDGETS = [
|
|
6
6
|
{
|
|
@@ -75,19 +75,19 @@ export const SAFE_ACTIONS = [
|
|
|
75
75
|
id: "apx.copy_context",
|
|
76
76
|
title: "Copiar contexto APX",
|
|
77
77
|
risk: "safe",
|
|
78
|
-
endpoint: "/projects/:pid/agents",
|
|
78
|
+
endpoint: "/api/projects/:pid/agents",
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
id: "apx.voice_turn",
|
|
82
82
|
title: "Hablar con APX",
|
|
83
83
|
risk: "safe",
|
|
84
|
-
endpoint: "/voice/turn",
|
|
84
|
+
endpoint: "/api/voice/turn",
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
id: "apx.super_agent",
|
|
88
88
|
title: "Pedir acción a APX",
|
|
89
89
|
risk: "confirm",
|
|
90
|
-
endpoint: "/projects/:pid/super-agent/chat",
|
|
90
|
+
endpoint: "/api/projects/:pid/super-agent/chat",
|
|
91
91
|
},
|
|
92
92
|
];
|
|
93
93
|
|
|
@@ -131,7 +131,7 @@ export function decorateExternalWidgets(pluginStatus = {}, overrides = {}) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
* Build the full /deck/manifest response body.
|
|
134
|
+
* Build the full /api/deck/manifest response body.
|
|
135
135
|
*
|
|
136
136
|
* Inputs are *resolved* runtime values, not the live managers — caller is
|
|
137
137
|
* responsible for catching errors in projects.list()/plugins.status() and
|
|
@@ -167,13 +167,13 @@ export function buildDeckManifest({
|
|
|
167
167
|
projects: projectList,
|
|
168
168
|
plugins: pluginStatus,
|
|
169
169
|
endpoints: {
|
|
170
|
-
health: "/health",
|
|
171
|
-
projects: "/projects",
|
|
172
|
-
plugins: "/plugins",
|
|
173
|
-
voice_turn: "/voice/turn",
|
|
174
|
-
transcribe_chunk: "/transcribe/chunk",
|
|
175
|
-
super_agent_chat: "/projects/:pid/super-agent/chat",
|
|
176
|
-
super_agent_stream: "/projects/:pid/super-agent/chat/stream",
|
|
170
|
+
health: "/api/health",
|
|
171
|
+
projects: "/api/projects",
|
|
172
|
+
plugins: "/api/plugins",
|
|
173
|
+
voice_turn: "/api/voice/turn",
|
|
174
|
+
transcribe_chunk: "/api/transcribe/chunk",
|
|
175
|
+
super_agent_chat: "/api/projects/:pid/super-agent/chat",
|
|
176
|
+
super_agent_stream: "/api/projects/:pid/super-agent/chat/stream",
|
|
177
177
|
},
|
|
178
178
|
},
|
|
179
179
|
safety: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Per-user "launch APX Desktop at login" wiring. Used by BOTH the CLI
|
|
2
2
|
// (`apx desktop install` / `uninstall`) and the daemon's
|
|
3
|
-
// /desktop/autostart endpoint so the web admin can toggle the same setting
|
|
3
|
+
// /api/desktop/autostart endpoint so the web admin can toggle the same setting
|
|
4
4
|
// without shelling out.
|
|
5
5
|
//
|
|
6
6
|
// Per-user, never sudo, fully reversible. Three platforms supported:
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import fs from "node:fs";
|
|
17
17
|
import os from "node:os";
|
|
18
18
|
import path from "node:path";
|
|
19
|
+
import { DESKTOP_AUTOSTART_LOG_PATH } from "#core/config/paths.js";
|
|
19
20
|
import { execFileSync } from "node:child_process";
|
|
20
21
|
import { fileURLToPath } from "node:url";
|
|
21
22
|
import { augmentedPath } from "#core/util/path-env.js";
|
|
@@ -28,7 +29,7 @@ export const MAC_PLIST_PATH = path.join(os.homedir(), "Library", "LaunchAg
|
|
|
28
29
|
export const LINUX_DESKTOP_PATH = path.join(os.homedir(), ".config", "autostart", "apx-desktop.desktop");
|
|
29
30
|
export const WIN_RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
30
31
|
export const WIN_RUN_NAME = "APXDesktop";
|
|
31
|
-
const AUTOSTART_LOG_PATH =
|
|
32
|
+
const AUTOSTART_LOG_PATH = DESKTOP_AUTOSTART_LOG_PATH;
|
|
32
33
|
|
|
33
34
|
// ── runner resolution ────────────────────────────────────────────────────
|
|
34
35
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Desktop (Electron floating window) process control — shared by the CLI
|
|
2
|
-
// (`apx desktop start/stop/restart`) and the daemon's /desktop/{start,stop}
|
|
2
|
+
// (`apx desktop start/stop/restart`) and the daemon's /api/desktop/{start,stop}
|
|
3
3
|
// HTTP endpoints, so both spawn/kill the window the exact same way.
|
|
4
4
|
//
|
|
5
5
|
// The window is a detached Electron process (it must survive the spawner so a
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
"use strict";
|
|
10
10
|
import fs from "node:fs";
|
|
11
|
-
import os from "node:os";
|
|
12
11
|
import path from "node:path";
|
|
12
|
+
import { DESKTOP_LOG_PATH, DESKTOP_PID_PATH } from "#core/config/paths.js";
|
|
13
13
|
import { spawn, execFileSync } from "node:child_process";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
@@ -19,8 +19,8 @@ const __dirname = path.dirname(__filename);
|
|
|
19
19
|
// src/core/desktop/ → repo root is three levels up.
|
|
20
20
|
const ROOT = path.resolve(__dirname, "..", "..", "..");
|
|
21
21
|
export const DESKTOP_MAIN = path.resolve(__dirname, "..", "..", "interfaces", "desktop", "main.js");
|
|
22
|
-
export const DESKTOP_PID =
|
|
23
|
-
const DESKTOP_LOG =
|
|
22
|
+
export const DESKTOP_PID = DESKTOP_PID_PATH;
|
|
23
|
+
const DESKTOP_LOG = DESKTOP_LOG_PATH;
|
|
24
24
|
|
|
25
25
|
// ── PID file ────────────────────────────────────────────────────────────────
|
|
26
26
|
export function readPid() {
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
// Who consumes this:
|
|
5
5
|
// • CLI — `apx setup` builds its provider/model menus from here
|
|
6
6
|
// (src/interfaces/cli/commands/setup.js).
|
|
7
|
-
// • Web — the admin panel fetches it via `GET /engines/presets` and hydrates
|
|
7
|
+
// • Web — the admin panel fetches it via `GET /api/engines/presets` and hydrates
|
|
8
8
|
// its provider forms (src/interfaces/web/.../providers/typeStyles.ts).
|
|
9
9
|
//
|
|
10
10
|
// This is the OFFLINE / no-key fallback list. When the user has an api_key
|
|
11
|
-
// configured, the daemon's `POST /engines/models` returns the provider's LIVE
|
|
11
|
+
// configured, the daemon's `POST /api/engines/models` returns the provider's LIVE
|
|
12
12
|
// catalog instead (see ./catalog.js). The model field is ALWAYS free-text, so
|
|
13
13
|
// any id can be typed even if it is not listed here.
|
|
14
14
|
//
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// browser_* tool is actually called. HTTP-only fetching lives in fetch.js
|
|
10
10
|
// (no Chromium needed).
|
|
11
11
|
//
|
|
12
|
-
// Endpoints (mounted at /tools/browser by api.js):
|
|
12
|
+
// Endpoints (mounted at /api/tools/browser by api.js):
|
|
13
13
|
// POST /navigate { url, launch_options?, allow_dangerous? }
|
|
14
14
|
// POST /screenshot { selector?, full_page?, width?, height?, encoded? }
|
|
15
15
|
// POST /click { selector }
|