negotium 0.1.6 → 0.1.8
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 +2 -2
- package/dist/chunk-0ay6cjdy.js +1331 -0
- package/dist/chunk-0ay6cjdy.js.map +16 -0
- package/dist/chunk-1k7t7bnx.js +97 -0
- package/dist/chunk-1k7t7bnx.js.map +10 -0
- package/dist/chunk-5ahkew9c.js +806 -0
- package/dist/chunk-5ahkew9c.js.map +17 -0
- package/dist/chunk-6cpn7ht2.js +287 -0
- package/dist/chunk-6cpn7ht2.js.map +13 -0
- package/dist/chunk-6kctn20e.js +3529 -0
- package/dist/chunk-6kctn20e.js.map +20 -0
- package/dist/chunk-7xqj7aex.js +77 -0
- package/dist/chunk-7xqj7aex.js.map +11 -0
- package/dist/chunk-9p0ww3tk.js +41 -0
- package/dist/chunk-9p0ww3tk.js.map +10 -0
- package/dist/chunk-a92a7nrk.js +252 -0
- package/dist/chunk-a92a7nrk.js.map +10 -0
- package/dist/chunk-c500xe9z.js +33 -0
- package/dist/chunk-c500xe9z.js.map +10 -0
- package/dist/chunk-cds1qxsf.js +1644 -0
- package/dist/chunk-cds1qxsf.js.map +17 -0
- package/dist/chunk-e4407g8x.js +274 -0
- package/dist/chunk-e4407g8x.js.map +10 -0
- package/dist/chunk-e5pbggsh.js +363 -0
- package/dist/chunk-e5pbggsh.js.map +11 -0
- package/dist/chunk-edb07sjp.js +567 -0
- package/dist/chunk-edb07sjp.js.map +14 -0
- package/dist/chunk-exd0v74a.js +3012 -0
- package/dist/chunk-exd0v74a.js.map +32 -0
- package/dist/chunk-fgrme9tr.js +4398 -0
- package/dist/chunk-fgrme9tr.js.map +47 -0
- package/dist/chunk-fka9eqe1.js +581 -0
- package/dist/chunk-fka9eqe1.js.map +11 -0
- package/dist/chunk-g82jygez.js +108 -0
- package/dist/chunk-g82jygez.js.map +10 -0
- package/dist/chunk-ghs2j1fr.js +312 -0
- package/dist/chunk-ghs2j1fr.js.map +10 -0
- package/dist/chunk-gmy11efb.js +125 -0
- package/dist/chunk-gmy11efb.js.map +10 -0
- package/dist/chunk-gxma4c70.js +110 -0
- package/dist/chunk-gxma4c70.js.map +10 -0
- package/dist/chunk-hkdqhm34.js +61 -0
- package/dist/chunk-hkdqhm34.js.map +10 -0
- package/dist/chunk-hpa0cpzh.js +134 -0
- package/dist/chunk-hpa0cpzh.js.map +10 -0
- package/dist/chunk-hwy3n31w.js +21 -0
- package/dist/chunk-hwy3n31w.js.map +9 -0
- package/dist/chunk-j2behpy7.js +214 -0
- package/dist/chunk-j2behpy7.js.map +10 -0
- package/dist/chunk-jc0at0tc.js +102 -0
- package/dist/chunk-jc0at0tc.js.map +10 -0
- package/dist/chunk-jkqq5ef6.js +243 -0
- package/dist/chunk-jkqq5ef6.js.map +11 -0
- package/dist/chunk-jzkw2f01.js +51 -0
- package/dist/chunk-jzkw2f01.js.map +10 -0
- package/dist/chunk-jzz91jwh.js +70 -0
- package/dist/chunk-jzz91jwh.js.map +10 -0
- package/dist/chunk-k9z47mab.js +247 -0
- package/dist/chunk-k9z47mab.js.map +12 -0
- package/dist/chunk-n17yxpa8.js +23 -0
- package/dist/chunk-n17yxpa8.js.map +10 -0
- package/dist/chunk-naa09ags.js +2143 -0
- package/dist/chunk-naa09ags.js.map +15 -0
- package/dist/chunk-ns3ke88n.js +142 -0
- package/dist/chunk-ns3ke88n.js.map +10 -0
- package/dist/chunk-p3cr2ejg.js +1626 -0
- package/dist/chunk-p3cr2ejg.js.map +15 -0
- package/dist/chunk-q5bcpf23.js +2925 -0
- package/dist/chunk-q5bcpf23.js.map +20 -0
- package/dist/chunk-rafc55bs.js +424 -0
- package/dist/chunk-rafc55bs.js.map +11 -0
- package/dist/chunk-rbrxjvbj.js +2830 -0
- package/dist/chunk-rbrxjvbj.js.map +23 -0
- package/dist/chunk-sa874j5c.js +9 -0
- package/dist/chunk-sa874j5c.js.map +10 -0
- package/dist/chunk-sgsz2fpq.js +289 -0
- package/dist/chunk-sgsz2fpq.js.map +10 -0
- package/dist/chunk-sm6fh5c5.js +569 -0
- package/dist/chunk-sm6fh5c5.js.map +14 -0
- package/dist/chunk-t9zcg8f1.js +499 -0
- package/dist/chunk-t9zcg8f1.js.map +13 -0
- package/dist/chunk-vp2db42d.js +121 -0
- package/dist/chunk-vp2db42d.js.map +10 -0
- package/dist/chunk-w13jjf4a.js +46 -0
- package/dist/chunk-w13jjf4a.js.map +10 -0
- package/dist/chunk-x1arr7ze.js +63 -0
- package/dist/chunk-x1arr7ze.js.map +10 -0
- package/dist/chunk-xfq68rch.js +583 -0
- package/dist/chunk-xfq68rch.js.map +11 -0
- package/dist/main.js +132 -20
- package/dist/main.js.map +4 -4
- package/dist/runtime/scripts/faster-whisper-wrapper.py +87 -0
- package/dist/runtime/scripts/mcp-patchright-http.mjs +349 -0
- package/dist/runtime/src/agents/api-topic-agent-switch.ts +178 -0
- package/dist/runtime/src/agents/archiver.ts +396 -0
- package/dist/runtime/src/agents/auth-check.ts +64 -0
- package/dist/runtime/src/agents/claude-provider.ts +737 -0
- package/dist/runtime/src/agents/claude-registry.ts +115 -0
- package/dist/runtime/src/agents/codex-native-multi-agent.ts +177 -0
- package/dist/runtime/src/agents/codex-provider.ts +785 -0
- package/dist/runtime/src/agents/codex-registry.ts +115 -0
- package/dist/runtime/src/agents/codex-tree-kill.ts +365 -0
- package/dist/runtime/src/agents/contracts.ts +69 -0
- package/dist/runtime/src/agents/deep-map.ts +13 -0
- package/dist/runtime/src/agents/execution-host.ts +91 -0
- package/dist/runtime/src/agents/fixtures/claude-attachments.jsonl +2 -0
- package/dist/runtime/src/agents/fixtures/codex-shell.jsonl +5 -0
- package/dist/runtime/src/agents/fork.ts +65 -0
- package/dist/runtime/src/agents/hosted-agent.ts +48 -0
- package/dist/runtime/src/agents/idle-archiver.ts +128 -0
- package/dist/runtime/src/agents/index.ts +205 -0
- package/dist/runtime/src/agents/maestro-provider.ts +206 -0
- package/dist/runtime/src/agents/maestro-registry.ts +31 -0
- package/dist/runtime/src/agents/mcp-tools/ask-user.ts +280 -0
- package/dist/runtime/src/agents/mcp-tools/common.ts +21 -0
- package/dist/runtime/src/agents/mcp-tools/self-config.ts +220 -0
- package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +525 -0
- package/dist/runtime/src/agents/mcp-tools/visuals.ts +88 -0
- package/dist/runtime/src/agents/model-catalog.ts +151 -0
- package/dist/runtime/src/agents/registry.ts +24 -0
- package/dist/runtime/src/agents/rollout/claude.ts +331 -0
- package/dist/runtime/src/agents/rollout/codex.ts +569 -0
- package/dist/runtime/src/agents/rollout/shared.ts +205 -0
- package/dist/runtime/src/agents/self-config-core.ts +415 -0
- package/dist/runtime/src/agents/task-events.ts +44 -0
- package/dist/runtime/src/agents/tool-format.ts +352 -0
- package/dist/runtime/src/agents/topic-agent-switch.ts +193 -0
- package/dist/runtime/src/agents/topic-cleanup.ts +231 -0
- package/dist/runtime/src/agents/vault-tool-policy.ts +33 -0
- package/dist/runtime/src/application/execute-external-user-turn.ts +23 -0
- package/dist/runtime/src/application/submit-user-message.ts +47 -0
- package/dist/runtime/src/application/switch-topic-effort.ts +48 -0
- package/dist/runtime/src/application/switch-topic-model.ts +79 -0
- package/dist/runtime/src/application/topic-service.ts +139 -0
- package/dist/runtime/src/application/vault-command.ts +170 -0
- package/dist/runtime/src/bus.ts +319 -0
- package/dist/runtime/src/index.ts +333 -0
- package/dist/runtime/src/mcp/agent-health-server.ts +309 -0
- package/dist/runtime/src/mcp/background-bash-server.ts +346 -0
- package/dist/runtime/src/mcp/canonical-bridge-config.ts +84 -0
- package/dist/runtime/src/mcp/canonical-proxy-server.ts +171 -0
- package/dist/runtime/src/mcp/dm-ipc.ts +60 -0
- package/dist/runtime/src/mcp/mcp-helpers.ts +40 -0
- package/dist/runtime/src/mcp/paddleocr-server.ts +105 -0
- package/dist/runtime/src/mcp/peer-bridge.ts +114 -0
- package/dist/runtime/src/mcp/runtime-spec.ts +134 -0
- package/dist/runtime/src/mcp/session-comm/bridge-ipc-config.ts +27 -0
- package/dist/runtime/src/mcp/session-comm/peer-forward.ts +165 -0
- package/dist/runtime/src/mcp/session-comm/runtime.ts +115 -0
- package/dist/runtime/src/mcp/session-comm/server.ts +649 -0
- package/dist/runtime/src/mcp/session-comm/topic-config.ts +131 -0
- package/dist/runtime/src/mcp/session-comm/topics.ts +229 -0
- package/dist/runtime/src/mcp/stdio-protect.ts +84 -0
- package/dist/runtime/src/mcp/system-health-server.ts +130 -0
- package/dist/runtime/src/mcp/task-server.ts +173 -0
- package/dist/runtime/src/mcp/token-stats-server.ts +98 -0
- package/dist/runtime/src/mcp/vault-http.ts +219 -0
- package/dist/runtime/src/mcp/vault-run.ts +153 -0
- package/dist/runtime/src/mcp/vault-server.ts +104 -0
- package/dist/runtime/src/mcp/wiki-server.ts +755 -0
- package/dist/runtime/src/media/file-events.ts +33 -0
- package/dist/runtime/src/media/text-extractor.ts +312 -0
- package/dist/runtime/src/media/video.ts +92 -0
- package/dist/runtime/src/outbox/file-ops.ts +210 -0
- package/dist/runtime/src/outbox/index.ts +8 -0
- package/dist/runtime/src/outbox/utils.ts +51 -0
- package/dist/runtime/src/platform/background-bash/manager.ts +279 -0
- package/dist/runtime/src/platform/config.ts +371 -0
- package/dist/runtime/src/platform/constants.ts +18 -0
- package/dist/runtime/src/platform/debug-users.ts +14 -0
- package/dist/runtime/src/platform/delay.ts +1 -0
- package/dist/runtime/src/platform/error.ts +9 -0
- package/dist/runtime/src/platform/file-utils.ts +16 -0
- package/dist/runtime/src/platform/jsonl.ts +202 -0
- package/dist/runtime/src/platform/lifecycle.ts +174 -0
- package/dist/runtime/src/platform/logger.ts +31 -0
- package/dist/runtime/src/platform/maestro-bootstrap-env.ts +3 -0
- package/dist/runtime/src/platform/mcp-config.ts +865 -0
- package/dist/runtime/src/platform/modules.ts +145 -0
- package/dist/runtime/src/platform/node-plugins.ts +46 -0
- package/dist/runtime/src/platform/playwright/manager.ts +1233 -0
- package/dist/runtime/src/prompts/agents/wiki-archiver.md +261 -0
- package/dist/runtime/src/prompts/builders.ts +357 -0
- package/dist/runtime/src/prompts/sessions/channel-system.md +48 -0
- package/dist/runtime/src/prompts/sessions/manager-system.md +37 -0
- package/dist/runtime/src/prompts/sessions/topic-system.md +47 -0
- package/dist/runtime/src/prompts/sessions/visual-design.md +86 -0
- package/dist/runtime/src/query/active-rooms.ts +532 -0
- package/dist/runtime/src/query/control.ts +313 -0
- package/dist/runtime/src/query/index.ts +24 -0
- package/dist/runtime/src/query/session-inbox-cleanup.ts +44 -0
- package/dist/runtime/src/query/session-inbox-path.ts +42 -0
- package/dist/runtime/src/query/state.ts +94 -0
- package/dist/runtime/src/query/types.ts +83 -0
- package/dist/runtime/src/runtime/ask-callbacks.ts +153 -0
- package/dist/runtime/src/runtime/attachments.ts +151 -0
- package/dist/runtime/src/runtime/background-sessions.ts +83 -0
- package/dist/runtime/src/runtime/channel-context.ts +107 -0
- package/dist/runtime/src/runtime/errors.ts +69 -0
- package/dist/runtime/src/runtime/event-heartbeat.ts +77 -0
- package/dist/runtime/src/runtime/file-hooks.ts +81 -0
- package/dist/runtime/src/runtime/footer.ts +23 -0
- package/dist/runtime/src/runtime/inbox.ts +946 -0
- package/dist/runtime/src/runtime/tasks.ts +56 -0
- package/dist/runtime/src/runtime/topic-config.ts +29 -0
- package/dist/runtime/src/runtime/turn-runner.ts +2286 -0
- package/dist/runtime/src/runtime/usage-alert.ts +84 -0
- package/dist/runtime/src/runtime/visual-html.ts +109 -0
- package/dist/runtime/src/runtime/visual-store.ts +430 -0
- package/dist/runtime/src/runtime/visuals.ts +171 -0
- package/dist/runtime/src/security/sanitize.ts +27 -0
- package/dist/runtime/src/security/sensitive-path.ts +34 -0
- package/dist/runtime/src/storage/activity-log.ts +152 -0
- package/dist/runtime/src/storage/api-messages.ts +617 -0
- package/dist/runtime/src/storage/api-topic-brief.ts +127 -0
- package/dist/runtime/src/storage/api-topic-config.ts +192 -0
- package/dist/runtime/src/storage/api-topics.ts +844 -0
- package/dist/runtime/src/storage/app-settings.ts +44 -0
- package/dist/runtime/src/storage/browser-profiles.ts +133 -0
- package/dist/runtime/src/storage/conversations.ts +268 -0
- package/dist/runtime/src/storage/forum/agent-settings.ts +20 -0
- package/dist/runtime/src/storage/forum/index.ts +4 -0
- package/dist/runtime/src/storage/forum/repository.ts +283 -0
- package/dist/runtime/src/storage/forum/schema.ts +300 -0
- package/dist/runtime/src/storage/forum-db.ts +23 -0
- package/dist/runtime/src/storage/runtime-events.ts +130 -0
- package/dist/runtime/src/storage/runtime-leases.ts +189 -0
- package/dist/runtime/src/storage/runtime-process-leases.ts +216 -0
- package/dist/runtime/src/storage/runtime-topic-state.ts +148 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +300 -0
- package/dist/runtime/src/storage/self-schedules.ts +298 -0
- package/dist/runtime/src/storage/session-asks.ts +347 -0
- package/dist/runtime/src/storage/sqlite.ts +129 -0
- package/dist/runtime/src/storage/tasks.ts +179 -0
- package/dist/runtime/src/storage/token-stats.ts +144 -0
- package/dist/runtime/src/storage/topic-archive-state.ts +59 -0
- package/dist/runtime/src/storage/topic-archive.ts +74 -0
- package/dist/runtime/src/storage/topic-settings.ts +67 -0
- package/dist/runtime/src/storage/topic-transcript.ts +98 -0
- package/dist/runtime/src/storage/vault-crypto.ts +65 -0
- package/dist/runtime/src/storage/vault.ts +225 -0
- package/dist/runtime/src/storage/wiki-summary-names.ts +33 -0
- package/dist/runtime/src/storage/wiki.ts +85 -0
- package/dist/runtime/src/topics/create.ts +123 -0
- package/dist/runtime/src/topics/derive.ts +398 -0
- package/dist/runtime/src/topics/lifecycle.ts +311 -0
- package/dist/runtime/src/topics/links.ts +7 -0
- package/dist/runtime/src/topics/personal-general.ts +65 -0
- package/dist/runtime/src/topics/session.ts +381 -0
- package/dist/runtime/src/types/api.ts +497 -0
- package/dist/runtime/src/types.ts +255 -0
- package/dist/runtime/src/version.ts +1 -0
- package/dist/runtime/tsconfig.json +13 -0
- package/package.json +16 -3
- package/dist/main.d.ts +0 -3
- package/dist/main.d.ts.map +0 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @negotium/core public API.
|
|
3
|
+
*
|
|
4
|
+
* Hosts embed the runtime through this barrel: create/list topics, trigger
|
|
5
|
+
* turns, subscribe to the RuntimeBus, and mount MCP catalogs for agent turns.
|
|
6
|
+
* Deep imports are not part of the public contract.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import "#platform/maestro-bootstrap-env";
|
|
10
|
+
|
|
11
|
+
// ── Agents ──────────────────────────────────────────────────────────
|
|
12
|
+
export { checkAgentAuth } from "#agents/auth-check";
|
|
13
|
+
export { killOwnedCodexTreesForShutdown } from "#agents/codex-tree-kill";
|
|
14
|
+
export type { ForkHandle } from "#agents/fork";
|
|
15
|
+
export { cleanupAgentFork, forkAgentSession } from "#agents/fork";
|
|
16
|
+
export { runAgent, SUPPORTED_AGENTS } from "#agents/index";
|
|
17
|
+
export type { AnswerAskUserQuestionResult } from "#agents/mcp-tools/ask-user";
|
|
18
|
+
export {
|
|
19
|
+
answerPendingAskUserQuestion,
|
|
20
|
+
createAskUserToolDefinition,
|
|
21
|
+
} from "#agents/mcp-tools/ask-user";
|
|
22
|
+
export type { McpToolResult, SharedMcpTool } from "#agents/mcp-tools/common";
|
|
23
|
+
export { errorResult, textResult } from "#agents/mcp-tools/common";
|
|
24
|
+
export type { SelfConfigContext } from "#agents/mcp-tools/self-config";
|
|
25
|
+
export { createSelfConfigToolDefinitions } from "#agents/mcp-tools/self-config";
|
|
26
|
+
export {
|
|
27
|
+
createSpawnSubagentToolDefinition,
|
|
28
|
+
createSubagentManagementToolDefinitions,
|
|
29
|
+
sweepStaleSubagentCards,
|
|
30
|
+
} from "#agents/mcp-tools/spawn-subagent";
|
|
31
|
+
export { visualToolDefinitions } from "#agents/mcp-tools/visuals";
|
|
32
|
+
export {
|
|
33
|
+
AGENT_DISPLAY_NAME,
|
|
34
|
+
modelOwner,
|
|
35
|
+
resolveModelForAgent,
|
|
36
|
+
SELECTABLE_MODELS,
|
|
37
|
+
selectableModel,
|
|
38
|
+
} from "#agents/model-catalog";
|
|
39
|
+
export { getRegistry } from "#agents/registry";
|
|
40
|
+
export type {
|
|
41
|
+
PurgeSessionRef,
|
|
42
|
+
PurgeTopicLogsOptions,
|
|
43
|
+
RotateTopicLogsOptions,
|
|
44
|
+
RotateTopicLogsResult,
|
|
45
|
+
} from "#agents/topic-cleanup";
|
|
46
|
+
export { purgeTopicLogs, rotateTopicLogs } from "#agents/topic-cleanup";
|
|
47
|
+
// ── Application use cases ──────────────────────────────────────────
|
|
48
|
+
export type { ExecuteExternalUserTurnParams } from "#application/execute-external-user-turn";
|
|
49
|
+
export { executeExternalUserTurn } from "#application/execute-external-user-turn";
|
|
50
|
+
export type {
|
|
51
|
+
SubmitUserMessageParams,
|
|
52
|
+
SubmitUserMessageResult,
|
|
53
|
+
} from "#application/submit-user-message";
|
|
54
|
+
export { submitUserMessage } from "#application/submit-user-message";
|
|
55
|
+
export type {
|
|
56
|
+
SwitchTopicEffortParams,
|
|
57
|
+
SwitchTopicEffortResult,
|
|
58
|
+
} from "#application/switch-topic-effort";
|
|
59
|
+
export { switchTopicEffort } from "#application/switch-topic-effort";
|
|
60
|
+
export type {
|
|
61
|
+
SwitchTopicModelParams,
|
|
62
|
+
SwitchTopicModelResult,
|
|
63
|
+
} from "#application/switch-topic-model";
|
|
64
|
+
export { switchTopicModel } from "#application/switch-topic-model";
|
|
65
|
+
export type {
|
|
66
|
+
CompactUserTopicParams,
|
|
67
|
+
DeleteUserTopicParams,
|
|
68
|
+
DeriveUserTopicParams,
|
|
69
|
+
TopicServiceErrorCode,
|
|
70
|
+
TopicSessionParams,
|
|
71
|
+
} from "#application/topic-service";
|
|
72
|
+
export { TopicServiceError, topicService } from "#application/topic-service";
|
|
73
|
+
export {
|
|
74
|
+
deleteVaultEntry,
|
|
75
|
+
executeVaultCommand,
|
|
76
|
+
isVaultCommandLine,
|
|
77
|
+
listVaultEntries,
|
|
78
|
+
type SaveVaultEntryResult,
|
|
79
|
+
saveVaultEntry,
|
|
80
|
+
VAULT_COMMAND_HELP,
|
|
81
|
+
} from "#application/vault-command";
|
|
82
|
+
// ── Host boundary ───────────────────────────────────────────────────
|
|
83
|
+
export type { RuntimeBus, RuntimeBusEvent, RuntimeBusListener } from "#bus";
|
|
84
|
+
export { runtimeBus, setRuntimeBus, WsHub } from "#bus";
|
|
85
|
+
export type {
|
|
86
|
+
PeerRuntimeAskUserRequest,
|
|
87
|
+
PeerRuntimeBridge,
|
|
88
|
+
PeerRuntimeFileRequest,
|
|
89
|
+
PeerRuntimeSelfConfigRequest,
|
|
90
|
+
PeerRuntimeSpawnRequest,
|
|
91
|
+
PeerRuntimeVisualRequest,
|
|
92
|
+
PeerRuntimeVisualResult,
|
|
93
|
+
} from "#mcp/peer-bridge";
|
|
94
|
+
export {
|
|
95
|
+
dispatchPeerRuntimeAskUser,
|
|
96
|
+
dispatchPeerRuntimeFile,
|
|
97
|
+
dispatchPeerRuntimeSelfConfig,
|
|
98
|
+
dispatchPeerRuntimeSpawn,
|
|
99
|
+
dispatchPeerRuntimeVisual,
|
|
100
|
+
flushPeerRuntimeEvents,
|
|
101
|
+
registerPeerRuntimeBridge,
|
|
102
|
+
} from "#mcp/peer-bridge";
|
|
103
|
+
export type { RuntimeMcpContext } from "#mcp/runtime-spec";
|
|
104
|
+
export {
|
|
105
|
+
buildRuntimeMcpSpec,
|
|
106
|
+
getRuntimeMcpPort,
|
|
107
|
+
issueRuntimeMcpToken,
|
|
108
|
+
RUNTIME_MCP_BASE_PATH,
|
|
109
|
+
RUNTIME_MCP_KEY,
|
|
110
|
+
resolveRuntimeMcpToken,
|
|
111
|
+
setRuntimeMcpPort,
|
|
112
|
+
} from "#mcp/runtime-spec";
|
|
113
|
+
export {
|
|
114
|
+
deliverPeerReply,
|
|
115
|
+
type PeerForwardArgs,
|
|
116
|
+
type PeerForwardResult,
|
|
117
|
+
type PeerSessionBridge,
|
|
118
|
+
type RemoteReplyRoute,
|
|
119
|
+
registerPeerSessionBridge,
|
|
120
|
+
} from "#mcp/session-comm/peer-forward";
|
|
121
|
+
// ── Media ───────────────────────────────────────────────────────────
|
|
122
|
+
export { extractFileEvents, extractFileTagPaths, stripFileTags } from "#media/file-events";
|
|
123
|
+
export type { ExtractionResult, TranscribeAudioOptions } from "#media/text-extractor";
|
|
124
|
+
export { extractText, isTranscriptionConfigured, transcribeAudio } from "#media/text-extractor";
|
|
125
|
+
export { killAllBgBash } from "#platform/background-bash/manager";
|
|
126
|
+
// ── Platform ────────────────────────────────────────────────────────
|
|
127
|
+
export {
|
|
128
|
+
DATA_DIR,
|
|
129
|
+
LOG_DIR,
|
|
130
|
+
MAX_TELL_DEPTH,
|
|
131
|
+
NEGOTIUM_PORT,
|
|
132
|
+
NODE_CONTROL_TOKEN,
|
|
133
|
+
RUN_DIR,
|
|
134
|
+
resolveTopicWorkspaceDir,
|
|
135
|
+
SESSION_INBOX_DIR,
|
|
136
|
+
STATE_DIR,
|
|
137
|
+
WORKSPACE_DIR,
|
|
138
|
+
} from "#platform/config";
|
|
139
|
+
export { FROM_AUTO_CONTINUE } from "#platform/constants";
|
|
140
|
+
export { errMsg } from "#platform/error";
|
|
141
|
+
export { appendJsonlEntry } from "#platform/jsonl";
|
|
142
|
+
export { onShutdown, runShutdown } from "#platform/lifecycle";
|
|
143
|
+
export { logger } from "#platform/logger";
|
|
144
|
+
export type {
|
|
145
|
+
NodeMcpEntry,
|
|
146
|
+
RuntimeMcpBuildContext,
|
|
147
|
+
RuntimeMcpCatalogEntry,
|
|
148
|
+
RuntimeMcpScope,
|
|
149
|
+
} from "#platform/mcp-config";
|
|
150
|
+
// ── Runtime MCP wiring ──────────────────────────────────────────────
|
|
151
|
+
export {
|
|
152
|
+
buildStdioMcpServer,
|
|
153
|
+
consumePlaywrightUnavailable,
|
|
154
|
+
getMcpServersForQuery,
|
|
155
|
+
getNodeMcpServers,
|
|
156
|
+
markPlaywrightUnavailable,
|
|
157
|
+
OPTIONAL_FORUM_MCP_SERVERS,
|
|
158
|
+
registerRuntimeMcpServer,
|
|
159
|
+
setNodeMcpServers,
|
|
160
|
+
setPlaywrightUnavailableNotifier,
|
|
161
|
+
} from "#platform/mcp-config";
|
|
162
|
+
export type {
|
|
163
|
+
NegotiumNodeModule,
|
|
164
|
+
NegotiumNodeModuleContext,
|
|
165
|
+
NegotiumNodeModuleHandle,
|
|
166
|
+
StartedNegotiumNodeModules,
|
|
167
|
+
} from "#platform/modules";
|
|
168
|
+
export { startNegotiumNodeModules } from "#platform/modules";
|
|
169
|
+
export type { NodeRequestHandler } from "#platform/node-plugins";
|
|
170
|
+
export {
|
|
171
|
+
nodeRequestHandlerNames,
|
|
172
|
+
registerNodeRequestHandler,
|
|
173
|
+
runNodeRequestHandlers,
|
|
174
|
+
unregisterNodeRequestHandler,
|
|
175
|
+
} from "#platform/node-plugins";
|
|
176
|
+
export { killAllPlaywright } from "#platform/playwright/manager";
|
|
177
|
+
// ── Query control ───────────────────────────────────────────────────
|
|
178
|
+
export {
|
|
179
|
+
abortAllRooms,
|
|
180
|
+
abortRoom,
|
|
181
|
+
cancelDeferredInject,
|
|
182
|
+
getRoomQuery,
|
|
183
|
+
interSessionQueue,
|
|
184
|
+
isTopicRunning,
|
|
185
|
+
listRunningTopicIds,
|
|
186
|
+
listRunningTopicQueries,
|
|
187
|
+
} from "#query/active-rooms";
|
|
188
|
+
export { sessionInboxPath } from "#query/session-inbox-path";
|
|
189
|
+
export { AbortReason } from "#query/types";
|
|
190
|
+
export type { AskPending } from "#runtime/ask-callbacks";
|
|
191
|
+
// ── Runtime ─────────────────────────────────────────────────────────
|
|
192
|
+
export {
|
|
193
|
+
failInterruptedRemoteAskCallbacks,
|
|
194
|
+
registerAskCallback,
|
|
195
|
+
resolveAskCallback,
|
|
196
|
+
} from "#runtime/ask-callbacks";
|
|
197
|
+
export type { IngestAttachmentArgs, IngestedAttachment } from "#runtime/attachments";
|
|
198
|
+
export {
|
|
199
|
+
attachmentPromptLine,
|
|
200
|
+
composeAttachmentPrompt,
|
|
201
|
+
ingestAttachment,
|
|
202
|
+
} from "#runtime/attachments";
|
|
203
|
+
export type { BackgroundSessionProvider } from "#runtime/background-sessions";
|
|
204
|
+
export {
|
|
205
|
+
backgroundSessionProgress,
|
|
206
|
+
listBackgroundSessionsForUser,
|
|
207
|
+
registerBackgroundSessionProvider,
|
|
208
|
+
} from "#runtime/background-sessions";
|
|
209
|
+
export type { FileHooks, UploadAccess } from "#runtime/file-hooks";
|
|
210
|
+
export {
|
|
211
|
+
fileHooks,
|
|
212
|
+
resolveAttachmentByFileId,
|
|
213
|
+
resolveUploadedFilePathByFileId,
|
|
214
|
+
setFileHooks,
|
|
215
|
+
storeLocalFileAsUpload,
|
|
216
|
+
} from "#runtime/file-hooks";
|
|
217
|
+
export { renderTurnFooter } from "#runtime/footer";
|
|
218
|
+
export { flushSessionInbox, startSessionInboxWorker } from "#runtime/inbox";
|
|
219
|
+
export type { AiTurnSettlement, AiTurnTopic } from "#runtime/turn-runner";
|
|
220
|
+
export {
|
|
221
|
+
deliverAskCallbackToCaller,
|
|
222
|
+
resolveInitialTurnSessionId,
|
|
223
|
+
resolveTopicTurnExecution,
|
|
224
|
+
resolveTopicTurnSession,
|
|
225
|
+
startAiTurn,
|
|
226
|
+
startDurableTurnRequestWorker,
|
|
227
|
+
triggerTopicAiTurn,
|
|
228
|
+
} from "#runtime/turn-runner";
|
|
229
|
+
export { isSensitivePath } from "#security/sensitive-path";
|
|
230
|
+
export type { MessagePage } from "#storage/api-messages";
|
|
231
|
+
// ── Storage ─────────────────────────────────────────────────────────
|
|
232
|
+
export {
|
|
233
|
+
appendApiMessage,
|
|
234
|
+
getAllMessagesForTopic,
|
|
235
|
+
getApiMessage,
|
|
236
|
+
listApiMessages,
|
|
237
|
+
} from "#storage/api-messages";
|
|
238
|
+
export { getApiTopicConfig, setApiTopicConfig } from "#storage/api-topic-config";
|
|
239
|
+
export {
|
|
240
|
+
clearTopicSessionId,
|
|
241
|
+
findTopicTitleConflict,
|
|
242
|
+
getTopic,
|
|
243
|
+
getTopicByNameForUser,
|
|
244
|
+
getTopicSessionId,
|
|
245
|
+
isTopicShared,
|
|
246
|
+
isTopicVisible,
|
|
247
|
+
listTopics,
|
|
248
|
+
setTopicSessionId,
|
|
249
|
+
upsertTopic,
|
|
250
|
+
} from "#storage/api-topics";
|
|
251
|
+
export { getGlobalAiName } from "#storage/app-settings";
|
|
252
|
+
export { db } from "#storage/forum-db";
|
|
253
|
+
export type { StoredRuntimeEvent } from "#storage/runtime-events";
|
|
254
|
+
export {
|
|
255
|
+
latestRuntimeEventSeq,
|
|
256
|
+
listRecentRuntimeEventsForTopic,
|
|
257
|
+
listRuntimeEventsAfter,
|
|
258
|
+
} from "#storage/runtime-events";
|
|
259
|
+
export {
|
|
260
|
+
claimRuntimeTurnLease,
|
|
261
|
+
listRuntimeTurnLeases,
|
|
262
|
+
releaseRuntimeTurnLease,
|
|
263
|
+
} from "#storage/runtime-leases";
|
|
264
|
+
export type {
|
|
265
|
+
AcquireRuntimeProcessLeaseOptions,
|
|
266
|
+
RuntimeProcessLease,
|
|
267
|
+
RuntimeProcessLeaseHandle,
|
|
268
|
+
WaitForRequiredRuntimeProcessLeaseOptions,
|
|
269
|
+
WaitForRuntimeProcessLeaseOptions,
|
|
270
|
+
} from "#storage/runtime-process-leases";
|
|
271
|
+
export {
|
|
272
|
+
acquireRuntimeProcessLease,
|
|
273
|
+
getRuntimeProcessLease,
|
|
274
|
+
PROCESS_LEASE_HEARTBEAT_MS,
|
|
275
|
+
PROCESS_LEASE_STALE_MS,
|
|
276
|
+
waitForRequiredRuntimeProcessLease,
|
|
277
|
+
waitForRuntimeProcessLease,
|
|
278
|
+
} from "#storage/runtime-process-leases";
|
|
279
|
+
export { clearPendingAsk } from "#storage/session-asks";
|
|
280
|
+
export type { VaultEntry, VaultEntryWithValue } from "#storage/vault";
|
|
281
|
+
export {
|
|
282
|
+
normalizeVaultKey,
|
|
283
|
+
VAULT_DESCRIPTION_MAX_LENGTH,
|
|
284
|
+
VAULT_VALUE_MAX_BYTES,
|
|
285
|
+
VAULT_VALUE_MIN_BYTES,
|
|
286
|
+
validateVaultKey,
|
|
287
|
+
vaultDel,
|
|
288
|
+
vaultHasKey,
|
|
289
|
+
vaultList,
|
|
290
|
+
vaultListWithValues,
|
|
291
|
+
vaultSet,
|
|
292
|
+
} from "#storage/vault";
|
|
293
|
+
export type { RegisterTopicOptions } from "#topics/create";
|
|
294
|
+
// ── Topics ──────────────────────────────────────────────────────────
|
|
295
|
+
export { registerTopic, TopicValidationError } from "#topics/create";
|
|
296
|
+
export {
|
|
297
|
+
createDerivedTopic,
|
|
298
|
+
getTopics,
|
|
299
|
+
getVisibleTopics,
|
|
300
|
+
isParticipant,
|
|
301
|
+
TopicDeriveBusyError,
|
|
302
|
+
TopicTitleConflictError,
|
|
303
|
+
updateTopic,
|
|
304
|
+
} from "#topics/derive";
|
|
305
|
+
export type { DeleteTopicCascadeOptions } from "#topics/lifecycle";
|
|
306
|
+
export {
|
|
307
|
+
deleteTopicCascade,
|
|
308
|
+
TopicArchiveRequiredError,
|
|
309
|
+
TopicTurnStillActiveError,
|
|
310
|
+
} from "#topics/lifecycle";
|
|
311
|
+
export { ensurePersonalGeneral } from "#topics/personal-general";
|
|
312
|
+
export type {
|
|
313
|
+
CompactSummaryRequest,
|
|
314
|
+
CompactTopicSessionOptions,
|
|
315
|
+
RestartTopicSessionResult,
|
|
316
|
+
} from "#topics/session";
|
|
317
|
+
export { compactTopicSession, restartTopicSession } from "#topics/session";
|
|
318
|
+
export * from "#types";
|
|
319
|
+
// ── Types ───────────────────────────────────────────────────────────
|
|
320
|
+
export { EFFORT_VALUES } from "#types";
|
|
321
|
+
export type {
|
|
322
|
+
AiMode,
|
|
323
|
+
AttachmentDto,
|
|
324
|
+
BackgroundSessionDto,
|
|
325
|
+
MessageDto,
|
|
326
|
+
ResponsePolicy,
|
|
327
|
+
SubagentCardDto,
|
|
328
|
+
TopicAccessMode,
|
|
329
|
+
TopicDto,
|
|
330
|
+
TopicKind,
|
|
331
|
+
TopicVisibility,
|
|
332
|
+
} from "#types/api";
|
|
333
|
+
export { NEGOTIUM_VERSION } from "#version";
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Agent Health Check MCP Server
|
|
4
|
+
*
|
|
5
|
+
* 각 agent (claude, codex, maestro)와 model이 실제 API 호출 시
|
|
6
|
+
* 정상 동작하는지 검증합니다.
|
|
7
|
+
* API key 에러, rate limit, network error, timeout 등을 감지합니다.
|
|
8
|
+
*
|
|
9
|
+
* Scopes: forum, manager (general 방)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import "./stdio-protect";
|
|
13
|
+
import { spawn } from "node:child_process";
|
|
14
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
+
import { maestroProvider } from "maestro-agent-sdk";
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import { claudeRegistry } from "#agents/claude-registry";
|
|
20
|
+
import { codexRegistry } from "#agents/codex-registry";
|
|
21
|
+
import type { AgentRegistry } from "#agents/contracts";
|
|
22
|
+
import { maestroRegistry } from "#agents/maestro-registry";
|
|
23
|
+
import { ACTIVE_QUERY_STALE_MS, resolveDefaultModel, USERS_LOG_DIR } from "#platform/config";
|
|
24
|
+
import { errMsg } from "#platform/error";
|
|
25
|
+
import { readJsonFile } from "#platform/jsonl";
|
|
26
|
+
import type { AgentKind, QueryState } from "#types";
|
|
27
|
+
import { connectStdio, mcpOk, parseUserIdArg } from "./mcp-helpers";
|
|
28
|
+
|
|
29
|
+
const args = process.argv.slice(2);
|
|
30
|
+
const scopedUserId = parseUserIdArg(args);
|
|
31
|
+
|
|
32
|
+
// ────────────────────────────────────────────────────────
|
|
33
|
+
// Helpers
|
|
34
|
+
// ────────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
function spawnCapture(
|
|
37
|
+
cmd: string,
|
|
38
|
+
args: string[],
|
|
39
|
+
timeoutMs: number,
|
|
40
|
+
env?: Record<string, string>,
|
|
41
|
+
): Promise<{ stdout: string; stderr: string }> {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const child = spawn(cmd, args, {
|
|
44
|
+
env: env ?? process.env,
|
|
45
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
46
|
+
timeout: timeoutMs,
|
|
47
|
+
});
|
|
48
|
+
let stdout = "";
|
|
49
|
+
let stderr = "";
|
|
50
|
+
child.stdout.on("data", (d: Buffer) => {
|
|
51
|
+
stdout += d.toString();
|
|
52
|
+
});
|
|
53
|
+
child.stderr.on("data", (d: Buffer) => {
|
|
54
|
+
stderr += d.toString();
|
|
55
|
+
});
|
|
56
|
+
child.on("error", reject);
|
|
57
|
+
child.on("close", () => resolve({ stdout, stderr }));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resultOk(agent: string, model: string, latency: number, detail: string) {
|
|
62
|
+
return { agent, model, ok: true, latency, detail };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function resultFail(agent: string, model: string, latency: number, error: string) {
|
|
66
|
+
let category = "unknown";
|
|
67
|
+
const e = error.toLowerCase();
|
|
68
|
+
if (
|
|
69
|
+
e.includes("auth") ||
|
|
70
|
+
e.includes("key") ||
|
|
71
|
+
e.includes("credential") ||
|
|
72
|
+
e.includes("unauthorized")
|
|
73
|
+
)
|
|
74
|
+
category = "auth_error";
|
|
75
|
+
else if (
|
|
76
|
+
e.includes("rate") ||
|
|
77
|
+
e.includes("limit") ||
|
|
78
|
+
e.includes("busy") ||
|
|
79
|
+
e.includes("overloaded")
|
|
80
|
+
)
|
|
81
|
+
category = "rate_limit";
|
|
82
|
+
else if (
|
|
83
|
+
e.includes("network") ||
|
|
84
|
+
e.includes("refused") ||
|
|
85
|
+
e.includes("dns") ||
|
|
86
|
+
e.includes("timeout")
|
|
87
|
+
)
|
|
88
|
+
category = "network_error";
|
|
89
|
+
return { agent, model, ok: false, latency, error, category };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ────────────────────────────────────────────────────────
|
|
93
|
+
// Per-agent checkers
|
|
94
|
+
// ────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
async function checkClaude(model: string, timeoutMs: number) {
|
|
97
|
+
const start = performance.now();
|
|
98
|
+
try {
|
|
99
|
+
const args = ["-p", "say OK", "--model", model, "--max-turns", "1", "--output-format", "text"];
|
|
100
|
+
const { stdout, stderr } = await spawnCapture("claude", args, timeoutMs);
|
|
101
|
+
const elapsed = Math.round(performance.now() - start);
|
|
102
|
+
const text = (stdout + stderr).trim().slice(0, 200);
|
|
103
|
+
if (!text) return resultFail("claude", model, elapsed, "empty response");
|
|
104
|
+
return resultOk("claude", model, elapsed, text);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
return resultFail("claude", model, Math.round(performance.now() - start), errMsg(err));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function checkCodex(model: string, timeoutMs: number) {
|
|
111
|
+
const start = performance.now();
|
|
112
|
+
try {
|
|
113
|
+
const args = [
|
|
114
|
+
"exec",
|
|
115
|
+
"--model",
|
|
116
|
+
model,
|
|
117
|
+
"--skip-git-repo-check",
|
|
118
|
+
"--sandbox",
|
|
119
|
+
"danger-full-access",
|
|
120
|
+
"say OK",
|
|
121
|
+
];
|
|
122
|
+
const { stdout, stderr } = await spawnCapture("codex", args, timeoutMs, {
|
|
123
|
+
...process.env,
|
|
124
|
+
CODEX_NO_COLOR: "1",
|
|
125
|
+
});
|
|
126
|
+
const elapsed = Math.round(performance.now() - start);
|
|
127
|
+
const combined = (stdout + stderr).trim();
|
|
128
|
+
const match = combined.match(/\ncodex\s*\n(.+?)(?:\n(?:tokens|session|user|$))/);
|
|
129
|
+
const detail = match ? match[1].trim().slice(0, 200) : "OK";
|
|
130
|
+
return resultOk("codex", model, elapsed, detail);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
return resultFail("codex", model, Math.round(performance.now() - start), errMsg(err));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function checkMaestro(model: string, timeoutMs: number) {
|
|
137
|
+
const start = performance.now();
|
|
138
|
+
try {
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
const gen = (maestroProvider as any)({
|
|
141
|
+
model,
|
|
142
|
+
prompt: "say OK",
|
|
143
|
+
cwd: process.cwd(),
|
|
144
|
+
maxTurns: 1,
|
|
145
|
+
});
|
|
146
|
+
const deadline = Date.now() + timeoutMs;
|
|
147
|
+
let text = "";
|
|
148
|
+
for await (const event of gen) {
|
|
149
|
+
if (Date.now() > deadline) {
|
|
150
|
+
return resultFail("maestro", model, Math.round(performance.now() - start), "timeout");
|
|
151
|
+
}
|
|
152
|
+
if (event.type === "text" && (event as any).content) {
|
|
153
|
+
text = (event as any).content.slice(0, 200);
|
|
154
|
+
}
|
|
155
|
+
if (event.type === "error") {
|
|
156
|
+
return resultFail(
|
|
157
|
+
"maestro",
|
|
158
|
+
model,
|
|
159
|
+
Math.round(performance.now() - start),
|
|
160
|
+
(event as any).error || "unknown error",
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const elapsed = Math.round(performance.now() - start);
|
|
165
|
+
return resultOk("maestro", model, elapsed, text || "(empty response)");
|
|
166
|
+
} catch (err) {
|
|
167
|
+
return resultFail("maestro", model, Math.round(performance.now() - start), errMsg(err));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ────────────────────────────────────────────────────────
|
|
172
|
+
// Registry helpers
|
|
173
|
+
// ────────────────────────────────────────────────────────
|
|
174
|
+
|
|
175
|
+
function getDefaultModel(registry: AgentRegistry): string {
|
|
176
|
+
return resolveDefaultModel(registry.kind, registry.defaultModel);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
interface CheckResult {
|
|
180
|
+
agent: string;
|
|
181
|
+
model: string;
|
|
182
|
+
ok: boolean;
|
|
183
|
+
latency: number;
|
|
184
|
+
detail?: string;
|
|
185
|
+
error?: string;
|
|
186
|
+
category?: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type CheckerFn = (m: string, t: number) => Promise<CheckResult>;
|
|
190
|
+
|
|
191
|
+
const AGENTS: { kind: AgentKind; label: string; registry: AgentRegistry; checker: CheckerFn }[] = [
|
|
192
|
+
{ kind: "claude", label: "claude", registry: claudeRegistry, checker: checkClaude },
|
|
193
|
+
{ kind: "codex", label: "codex", registry: codexRegistry, checker: checkCodex },
|
|
194
|
+
{ kind: "maestro", label: "maestro", registry: maestroRegistry, checker: checkMaestro },
|
|
195
|
+
];
|
|
196
|
+
|
|
197
|
+
// ────────────────────────────────────────────────────────
|
|
198
|
+
// MCP Server
|
|
199
|
+
// ────────────────────────────────────────────────────────
|
|
200
|
+
|
|
201
|
+
const server = new McpServer({ name: "agent-health", version: "1.0.0" });
|
|
202
|
+
|
|
203
|
+
server.tool(
|
|
204
|
+
"check_agent",
|
|
205
|
+
"실제 API 호출로 특정 agent+model 조합이 정상 동작하는지 체크합니다. " +
|
|
206
|
+
"API key 에러, rate limit, network error 등을 감지하여 결과를 리포트합니다.",
|
|
207
|
+
{
|
|
208
|
+
agent: z.enum(["claude", "codex", "maestro"]).describe("체크할 agent"),
|
|
209
|
+
model: z.string().optional().describe("체크할 모델 (없으면 agent별 default 사용)"),
|
|
210
|
+
timeoutMs: z.number().default(30000).describe("타임아웃 (ms), 기본 30초"),
|
|
211
|
+
},
|
|
212
|
+
async ({ agent, model, timeoutMs }) => {
|
|
213
|
+
const entry = AGENTS.find((a) => a.kind === agent);
|
|
214
|
+
if (!entry) return mcpOk(`❌ Unknown agent: ${agent}`);
|
|
215
|
+
const m = model || getDefaultModel(entry.registry);
|
|
216
|
+
const result = await entry.checker(m, timeoutMs);
|
|
217
|
+
if (result.ok) {
|
|
218
|
+
return mcpOk(
|
|
219
|
+
`✅ OK ${result.agent} / ${result.model}\n latency: ${result.latency}ms\n detail: ${result.detail}`,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return mcpOk(
|
|
223
|
+
`❌ FAIL ${result.agent} / ${result.model} [${result.category}]\n latency: ${result.latency}ms\n error: ${result.error}`,
|
|
224
|
+
);
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
server.tool(
|
|
229
|
+
"check_all",
|
|
230
|
+
"모든 agent (claude, codex, maestro)를 기본 모델로 동시에 체크합니다. " +
|
|
231
|
+
"각 agent의 API 연결 상태를 한 번에 확인할 수 있습니다.",
|
|
232
|
+
{
|
|
233
|
+
timeoutMs: z.number().default(30000).describe("agent별 타임아웃 (ms), 기본 30초"),
|
|
234
|
+
},
|
|
235
|
+
async ({ timeoutMs }) => {
|
|
236
|
+
const results = await Promise.all(
|
|
237
|
+
AGENTS.map(async (entry) => {
|
|
238
|
+
const model = getDefaultModel(entry.registry);
|
|
239
|
+
return entry.checker(model, timeoutMs);
|
|
240
|
+
}),
|
|
241
|
+
);
|
|
242
|
+
const lines = results.map((r) => {
|
|
243
|
+
if (r.ok)
|
|
244
|
+
return `✅ ${r.agent.padEnd(8)} / ${r.model.padEnd(14)} ${r.latency}ms ${r.detail}`;
|
|
245
|
+
return `❌ ${r.agent.padEnd(8)} / ${r.model.padEnd(14)} ${r.latency}ms [${r.category}] ${r.error}`;
|
|
246
|
+
});
|
|
247
|
+
const allOk = results.every((r) => r.ok);
|
|
248
|
+
const summary = allOk ? "🎉 All agents healthy" : "⚠️ Some agents failed";
|
|
249
|
+
return mcpOk(
|
|
250
|
+
`Agent/Model Health Check\n━━━━━━━━━━━━━━━━━━━━━\n${lines.join("\n")}\n\n${summary}`,
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
server.tool(
|
|
256
|
+
"list_active_queries",
|
|
257
|
+
"현재 사용자 범위에서 실행 중인 토픽 쿼리 목록을 조회합니다. topicName, 시작 시간, 경과 시간, 작업 내용(앞 100자)을 반환합니다.",
|
|
258
|
+
{},
|
|
259
|
+
async () => {
|
|
260
|
+
const now = Date.now();
|
|
261
|
+
const entries: {
|
|
262
|
+
topicName: string;
|
|
263
|
+
since: string;
|
|
264
|
+
elapsedSec: number;
|
|
265
|
+
task?: string;
|
|
266
|
+
}[] = [];
|
|
267
|
+
|
|
268
|
+
if (!scopedUserId) return mcpOk("실행 중인 쿼리 조회 불가 (user context 없음)");
|
|
269
|
+
|
|
270
|
+
const stateDir = join(USERS_LOG_DIR, scopedUserId, "active-queries");
|
|
271
|
+
if (!existsSync(stateDir)) return mcpOk("실행 중인 쿼리 없음");
|
|
272
|
+
|
|
273
|
+
let files: string[];
|
|
274
|
+
try {
|
|
275
|
+
files = readdirSync(stateDir);
|
|
276
|
+
} catch {
|
|
277
|
+
return mcpOk("실행 중인 쿼리 없음");
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
for (const file of files) {
|
|
281
|
+
if (!file.endsWith(".json")) continue;
|
|
282
|
+
const filePath = join(stateDir, file);
|
|
283
|
+
const state = readJsonFile<QueryState>(filePath);
|
|
284
|
+
if (!state) continue;
|
|
285
|
+
const sinceMs = new Date(state.since).getTime();
|
|
286
|
+
if (now - sinceMs > ACTIVE_QUERY_STALE_MS) continue;
|
|
287
|
+
|
|
288
|
+
const base = file.slice(0, -5); // remove .json
|
|
289
|
+
const topicName = base;
|
|
290
|
+
|
|
291
|
+
entries.push({
|
|
292
|
+
topicName,
|
|
293
|
+
since: state.since,
|
|
294
|
+
elapsedSec: Math.round((now - sinceMs) / 1000),
|
|
295
|
+
task: state.task,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (entries.length === 0) return mcpOk("실행 중인 쿼리 없음");
|
|
300
|
+
|
|
301
|
+
const lines = entries.map((e) => {
|
|
302
|
+
const task = e.task ? ` "${e.task}"` : "";
|
|
303
|
+
return `• ${e.topicName} | ${e.elapsedSec}s 경과${task}`;
|
|
304
|
+
});
|
|
305
|
+
return mcpOk(`실행 중인 쿼리 (${entries.length}개)\n${lines.join("\n")}`);
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
await connectStdio(server);
|