comisai 1.0.19 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-entry.js +0 -0
- package/node_modules/@comis/agent/dist/context-engine/context-engine.js +43 -2
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +51 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +110 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +54 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +145 -0
- package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +17 -0
- package/node_modules/@comis/agent/dist/executor/error-classifier.d.ts +11 -1
- package/node_modules/@comis/agent/dist/executor/error-classifier.js +13 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +1 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +55 -0
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +106 -5
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +1 -0
- package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
- package/node_modules/@comis/agent/dist/executor/pi-executor.js +30 -3
- package/node_modules/@comis/agent/dist/executor/replay-drift-detector.d.ts +85 -0
- package/node_modules/@comis/agent/dist/executor/replay-drift-detector.js +92 -0
- package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.d.ts +34 -0
- package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.js +69 -0
- package/node_modules/@comis/agent/dist/executor/signed-replay-detector.d.ts +39 -0
- package/node_modules/@comis/agent/dist/executor/signed-replay-detector.js +72 -0
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/dist/cli.js +0 -0
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/config/git-manager.js +10 -4
- package/node_modules/@comis/core/dist/config/index.d.ts +1 -0
- package/node_modules/@comis/core/dist/config/index.js +2 -0
- package/node_modules/@comis/core/dist/config/managed-sections.d.ts +67 -0
- package/node_modules/@comis/core/dist/config/managed-sections.js +124 -0
- package/node_modules/@comis/core/dist/config/schema-agent.d.ts +28 -10
- package/node_modules/@comis/core/dist/config/schema-agent.js +6 -0
- package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +2 -2
- package/node_modules/@comis/core/dist/config/schema.d.ts +65 -64
- package/node_modules/@comis/core/dist/event-bus/events-messaging.d.ts +16 -0
- package/node_modules/@comis/core/dist/exports/config.d.ts +1 -1
- package/node_modules/@comis/core/dist/exports/config.js +1 -1
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/init-skill.py +0 -0
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +0 -0
- package/node_modules/@comis/daemon/dist/daemon.js +11 -4
- package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +20 -7
- package/node_modules/@comis/daemon/dist/rpc/session-handlers.js +27 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.d.ts +22 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +34 -8
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.js +14 -1
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/dist/logging/log-fields.d.ts +2 -2
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +23 -8
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +1 -1
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +18 -14
- package/node_modules/@comis/skills/dist/builtin/platform/unified-session-tool.js +1 -1
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.d.ts +1 -0
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +78 -5
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/package.json +1 -1
- package/package.json +24 -26
- package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.d.ts +0 -9
- package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.js +0 -17
- package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.d.ts +0 -13
- package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.js +0 -19
- package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.d.ts +0 -11
- package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.js +0 -32
- package/node_modules/@comis/agent/dist/safety/follow-through-detector.d.ts +0 -46
- package/node_modules/@comis/agent/dist/safety/follow-through-detector.js +0 -76
- package/node_modules/@comis/agent/dist/safety/post-compaction-safety.d.ts +0 -30
- package/node_modules/@comis/agent/dist/safety/post-compaction-safety.js +0 -51
- package/node_modules/@comis/agent/dist/safety/schema-normalizer.d.ts +0 -37
- package/node_modules/@comis/agent/dist/safety/schema-normalizer.js +0 -137
- package/node_modules/@comis/agent/dist/safety/schema-pruning.d.ts +0 -50
- package/node_modules/@comis/agent/dist/safety/schema-pruning.js +0 -112
- package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.d.ts +0 -43
- package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.js +0 -96
- package/node_modules/@comis/agent/dist/safety/tool-sanitizer.d.ts +0 -44
- package/node_modules/@comis/agent/dist/safety/tool-sanitizer.js +0 -94
- package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.d.ts +0 -28
- package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.js +0 -206
- package/node_modules/@comis/cli/dist/wizard/config-writer.d.ts +0 -25
- package/node_modules/@comis/cli/dist/wizard/config-writer.js +0 -144
- package/node_modules/@comis/cli/dist/wizard/flow-types.d.ts +0 -48
- package/node_modules/@comis/cli/dist/wizard/flow-types.js +0 -70
- package/node_modules/@comis/cli/dist/wizard/manual-flow.d.ts +0 -21
- package/node_modules/@comis/cli/dist/wizard/manual-flow.js +0 -345
- package/node_modules/@comis/cli/dist/wizard/quickstart-flow.d.ts +0 -21
- package/node_modules/@comis/cli/dist/wizard/quickstart-flow.js +0 -116
- package/node_modules/@comis/core/dist/config/schema-agent-model.d.ts +0 -135
- package/node_modules/@comis/core/dist/config/schema-agent-model.js +0 -114
- package/node_modules/@comis/core/dist/config/schema-agent-session.d.ts +0 -177
- package/node_modules/@comis/core/dist/config/schema-agent-session.js +0 -116
- package/node_modules/@comis/core/dist/config/schema-context-engine.d.ts +0 -92
- package/node_modules/@comis/core/dist/config/schema-context-engine.js +0 -92
- package/node_modules/@comis/core/dist/config/schema-context-guard.d.ts +0 -34
- package/node_modules/@comis/core/dist/config/schema-context-guard.js +0 -32
- package/node_modules/@comis/core/dist/config/schema-delivery-mirror.d.ts +0 -27
- package/node_modules/@comis/core/dist/config/schema-delivery-mirror.js +0 -26
- package/node_modules/@comis/core/dist/config/schema-delivery-queue.d.ts +0 -31
- package/node_modules/@comis/core/dist/config/schema-delivery-queue.js +0 -30
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.d.ts +0 -41
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.js +0 -31
- package/node_modules/@comis/core/dist/config/schema-monitoring.d.ts +0 -105
- package/node_modules/@comis/core/dist/config/schema-monitoring.js +0 -67
- package/node_modules/@comis/core/dist/ports/media-ports.d.ts +0 -278
- package/node_modules/@comis/core/dist/ports/media-ports.js +0 -1
- package/node_modules/@comis/core/dist/security/input-guard.d.ts +0 -46
- package/node_modules/@comis/core/dist/security/input-guard.js +0 -166
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.d.ts +0 -38
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.js +0 -94
- package/node_modules/@comis/daemon/dist/observability/delivery-context.d.ts +0 -37
- package/node_modules/@comis/daemon/dist/observability/delivery-context.js +0 -1
- package/node_modules/@comis/daemon/dist/observability/log-level-manager.d.ts +0 -23
- package/node_modules/@comis/daemon/dist/observability/log-level-manager.js +0 -34
- package/node_modules/@comis/daemon/dist/observability/log-transport.d.ts +0 -44
- package/node_modules/@comis/daemon/dist/observability/log-transport.js +0 -74
- package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.d.ts +0 -53
- package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.js +0 -68
- package/node_modules/@comis/daemon/dist/observability/types.d.ts +0 -6
- package/node_modules/@comis/daemon/dist/observability/types.js +0 -1
- package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.d.ts +0 -41
- package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.js +0 -84
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.d.ts +0 -24
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.js +0 -88
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.d.ts +0 -31
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.js +0 -132
- package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.d.ts +0 -38
- package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.js +0 -100
- package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.d.ts +0 -34
- package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.js +0 -52
- package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.d.ts +0 -41
- package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.js +0 -86
- package/node_modules/@comis/memory/dist/embedding-cache.d.ts +0 -36
- package/node_modules/@comis/memory/dist/embedding-cache.js +0 -94
- package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.d.ts +0 -17
- package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.js +0 -125
- package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.d.ts +0 -14
- package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.js +0 -92
- package/node_modules/@comis/skills/dist/bridge/tool-result-caps.d.ts +0 -14
- package/node_modules/@comis/skills/dist/bridge/tool-result-caps.js +0 -36
- package/node_modules/@comis/skills/dist/bridge/tool-search-hints.d.ts +0 -15
- package/node_modules/@comis/skills/dist/bridge/tool-search-hints.js +0 -68
- package/node_modules/@comis/skills/dist/bridge/tool-validators.d.ts +0 -11
- package/node_modules/@comis/skills/dist/bridge/tool-validators.js +0 -105
- package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.d.ts +0 -22
- package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.js +0 -95
- package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.d.ts +0 -24
- package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.js +0 -167
- package/node_modules/@comis/skills/dist/builtin/task-plan-tool.d.ts +0 -25
- package/node_modules/@comis/skills/dist/builtin/task-plan-tool.js +0 -67
- package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.d.ts +0 -75
- package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.js +0 -235
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
/**
|
|
3
|
-
* Manual wizard flow.
|
|
4
|
-
*
|
|
5
|
-
* Full-control wizard covering all 8 steps: provider, API key,
|
|
6
|
-
* agent name, model, channels, gateway, data directory, and review.
|
|
7
|
-
* Uses ModelCatalog from @comis/agent for dynamic model selection.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import * as p from "@clack/prompts";
|
|
12
|
-
import { randomBytes } from "node:crypto";
|
|
13
|
-
import * as os from "node:os";
|
|
14
|
-
import { ok, err } from "@comis/shared";
|
|
15
|
-
import { createModelCatalog } from "@comis/agent";
|
|
16
|
-
import { PROVIDERS, MIN_KEY_LENGTHS, CHANNEL_TYPES, } from "./flow-types.js";
|
|
17
|
-
import { writeWizardConfig, writeWizardEnv } from "./config-writer.js";
|
|
18
|
-
/**
|
|
19
|
-
* Run the Manual wizard flow.
|
|
20
|
-
*
|
|
21
|
-
* Presents all configuration options: provider, API key, agent name,
|
|
22
|
-
* model, channels, gateway, data directory, and a review step.
|
|
23
|
-
*
|
|
24
|
-
* @param configDir - Override config directory (default ~/.comis)
|
|
25
|
-
* @returns The wizard result or an error
|
|
26
|
-
*/
|
|
27
|
-
export async function runManualFlow(configDir) {
|
|
28
|
-
const targetDir = configDir ?? os.homedir() + "/.comis";
|
|
29
|
-
p.intro("Comis Manual Setup");
|
|
30
|
-
// Step 1: Provider
|
|
31
|
-
const provider = await p.select({
|
|
32
|
-
message: "Select your LLM provider:",
|
|
33
|
-
options: PROVIDERS,
|
|
34
|
-
});
|
|
35
|
-
if (p.isCancel(provider)) {
|
|
36
|
-
p.cancel("Setup cancelled.");
|
|
37
|
-
process.exit(0);
|
|
38
|
-
}
|
|
39
|
-
// Step 2: API key
|
|
40
|
-
let apiKey = "";
|
|
41
|
-
if (provider !== "ollama") {
|
|
42
|
-
const minLen = MIN_KEY_LENGTHS[provider] ?? 20;
|
|
43
|
-
const keyResult = await p.password({
|
|
44
|
-
message: `Enter your ${provider} API key:`,
|
|
45
|
-
validate: (value) => {
|
|
46
|
-
if (!value || value.length < minLen) {
|
|
47
|
-
return `API key must be at least ${minLen} characters`;
|
|
48
|
-
}
|
|
49
|
-
return undefined;
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
if (p.isCancel(keyResult)) {
|
|
53
|
-
p.cancel("Setup cancelled.");
|
|
54
|
-
process.exit(0);
|
|
55
|
-
}
|
|
56
|
-
apiKey = keyResult;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
p.log.info("Ollama runs locally -- no API key needed.");
|
|
60
|
-
}
|
|
61
|
-
// Step 3: Agent name
|
|
62
|
-
const agentName = await p.text({
|
|
63
|
-
message: "Name your agent:",
|
|
64
|
-
placeholder: "Comis",
|
|
65
|
-
defaultValue: "Comis",
|
|
66
|
-
validate: (value) => {
|
|
67
|
-
if (!value || !/^[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(value)) {
|
|
68
|
-
return "Name must be alphanumeric with optional hyphens (no leading hyphen)";
|
|
69
|
-
}
|
|
70
|
-
if (value.length > 64) {
|
|
71
|
-
return "Name must be at most 64 characters";
|
|
72
|
-
}
|
|
73
|
-
return undefined;
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
if (p.isCancel(agentName)) {
|
|
77
|
-
p.cancel("Setup cancelled.");
|
|
78
|
-
process.exit(0);
|
|
79
|
-
}
|
|
80
|
-
// Step 4: Model selection from ModelCatalog
|
|
81
|
-
let model;
|
|
82
|
-
try {
|
|
83
|
-
const catalog = createModelCatalog();
|
|
84
|
-
catalog.loadStatic();
|
|
85
|
-
const models = catalog.getByProvider(provider);
|
|
86
|
-
if (models.length > 0) {
|
|
87
|
-
const modelOptions = models.slice(0, 20).map((m) => ({
|
|
88
|
-
value: m.modelId,
|
|
89
|
-
label: m.displayName,
|
|
90
|
-
hint: m.contextWindow > 0 ? `${Math.round(m.contextWindow / 1000)}k ctx` : undefined,
|
|
91
|
-
}));
|
|
92
|
-
// Add custom option
|
|
93
|
-
modelOptions.push({ value: "__custom__", label: "Custom (enter manually)", hint: undefined });
|
|
94
|
-
const modelChoice = await p.select({
|
|
95
|
-
message: "Select a model:",
|
|
96
|
-
options: modelOptions,
|
|
97
|
-
});
|
|
98
|
-
if (p.isCancel(modelChoice)) {
|
|
99
|
-
p.cancel("Setup cancelled.");
|
|
100
|
-
process.exit(0);
|
|
101
|
-
}
|
|
102
|
-
if (modelChoice === "__custom__") {
|
|
103
|
-
const custom = await p.text({
|
|
104
|
-
message: "Enter custom model identifier:",
|
|
105
|
-
validate: (value) => !value || value.length === 0
|
|
106
|
-
? "Model identifier is required"
|
|
107
|
-
: undefined,
|
|
108
|
-
});
|
|
109
|
-
if (p.isCancel(custom)) {
|
|
110
|
-
p.cancel("Setup cancelled.");
|
|
111
|
-
process.exit(0);
|
|
112
|
-
}
|
|
113
|
-
model = custom;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
model = modelChoice;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
const custom = await p.text({
|
|
121
|
-
message: "Enter model identifier:",
|
|
122
|
-
placeholder: getDefaultModel(provider),
|
|
123
|
-
defaultValue: getDefaultModel(provider),
|
|
124
|
-
});
|
|
125
|
-
if (p.isCancel(custom)) {
|
|
126
|
-
p.cancel("Setup cancelled.");
|
|
127
|
-
process.exit(0);
|
|
128
|
-
}
|
|
129
|
-
model = custom;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
// Fallback if ModelCatalog fails
|
|
134
|
-
const custom = await p.text({
|
|
135
|
-
message: "Enter model identifier:",
|
|
136
|
-
placeholder: getDefaultModel(provider),
|
|
137
|
-
defaultValue: getDefaultModel(provider),
|
|
138
|
-
});
|
|
139
|
-
if (p.isCancel(custom)) {
|
|
140
|
-
p.cancel("Setup cancelled.");
|
|
141
|
-
process.exit(0);
|
|
142
|
-
}
|
|
143
|
-
model = custom;
|
|
144
|
-
}
|
|
145
|
-
// Step 5: Channels
|
|
146
|
-
const channels = [];
|
|
147
|
-
const setupChannels = await p.confirm({
|
|
148
|
-
message: "Would you like to configure messaging channels?",
|
|
149
|
-
initialValue: false,
|
|
150
|
-
});
|
|
151
|
-
if (p.isCancel(setupChannels)) {
|
|
152
|
-
p.cancel("Setup cancelled.");
|
|
153
|
-
process.exit(0);
|
|
154
|
-
}
|
|
155
|
-
if (setupChannels) {
|
|
156
|
-
const selectedTypes = await p.multiselect({
|
|
157
|
-
message: "Select channels to configure:",
|
|
158
|
-
options: CHANNEL_TYPES,
|
|
159
|
-
required: false,
|
|
160
|
-
});
|
|
161
|
-
if (p.isCancel(selectedTypes)) {
|
|
162
|
-
p.cancel("Setup cancelled.");
|
|
163
|
-
process.exit(0);
|
|
164
|
-
}
|
|
165
|
-
for (const channelType of selectedTypes) {
|
|
166
|
-
const setup = { type: channelType };
|
|
167
|
-
if (channelType === "telegram") {
|
|
168
|
-
const token = await p.password({
|
|
169
|
-
message: "Telegram bot token (from @BotFather):",
|
|
170
|
-
validate: (v) => !v || v.length < 10 ? "Token too short" : undefined,
|
|
171
|
-
});
|
|
172
|
-
if (p.isCancel(token)) {
|
|
173
|
-
p.cancel("Setup cancelled.");
|
|
174
|
-
process.exit(0);
|
|
175
|
-
}
|
|
176
|
-
setup.botToken = token;
|
|
177
|
-
}
|
|
178
|
-
else if (channelType === "discord") {
|
|
179
|
-
const token = await p.password({
|
|
180
|
-
message: "Discord bot token:",
|
|
181
|
-
validate: (v) => !v || v.length < 10 ? "Token too short" : undefined,
|
|
182
|
-
});
|
|
183
|
-
if (p.isCancel(token)) {
|
|
184
|
-
p.cancel("Setup cancelled.");
|
|
185
|
-
process.exit(0);
|
|
186
|
-
}
|
|
187
|
-
setup.botToken = token;
|
|
188
|
-
}
|
|
189
|
-
else if (channelType === "slack") {
|
|
190
|
-
const botToken = await p.password({
|
|
191
|
-
message: "Slack bot token (xoxb-...):",
|
|
192
|
-
validate: (v) => !v || v.length < 10 ? "Token too short" : undefined,
|
|
193
|
-
});
|
|
194
|
-
if (p.isCancel(botToken)) {
|
|
195
|
-
p.cancel("Setup cancelled.");
|
|
196
|
-
process.exit(0);
|
|
197
|
-
}
|
|
198
|
-
setup.botToken = botToken;
|
|
199
|
-
const appToken = await p.password({
|
|
200
|
-
message: "Slack app token (xapp-...):",
|
|
201
|
-
validate: (v) => !v || v.length < 10 ? "Token too short" : undefined,
|
|
202
|
-
});
|
|
203
|
-
if (p.isCancel(appToken)) {
|
|
204
|
-
p.cancel("Setup cancelled.");
|
|
205
|
-
process.exit(0);
|
|
206
|
-
}
|
|
207
|
-
setup.appToken = appToken;
|
|
208
|
-
}
|
|
209
|
-
else if (channelType === "whatsapp") {
|
|
210
|
-
p.log.info("WhatsApp uses QR code pairing -- no token needed during setup.");
|
|
211
|
-
}
|
|
212
|
-
else if (channelType === "signal") {
|
|
213
|
-
p.log.info("Signal requires signal-cli. Run 'comis signal-setup' after init.");
|
|
214
|
-
}
|
|
215
|
-
else if (channelType === "irc" || channelType === "line") {
|
|
216
|
-
p.log.info(`${channelType.toUpperCase()} adapter will use default configuration.`);
|
|
217
|
-
}
|
|
218
|
-
channels.push(setup);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
// Step 6: Gateway
|
|
222
|
-
let gatewayEnabled = false;
|
|
223
|
-
let gatewayHost = "127.0.0.1";
|
|
224
|
-
let gatewayPort = 3000;
|
|
225
|
-
let gatewayToken;
|
|
226
|
-
const enableGateway = await p.confirm({
|
|
227
|
-
message: "Enable the gateway HTTP server (web dashboard & API)?",
|
|
228
|
-
initialValue: true,
|
|
229
|
-
});
|
|
230
|
-
if (p.isCancel(enableGateway)) {
|
|
231
|
-
p.cancel("Setup cancelled.");
|
|
232
|
-
process.exit(0);
|
|
233
|
-
}
|
|
234
|
-
if (enableGateway) {
|
|
235
|
-
gatewayEnabled = true;
|
|
236
|
-
const host = await p.text({
|
|
237
|
-
message: "Gateway bind address:",
|
|
238
|
-
defaultValue: "127.0.0.1",
|
|
239
|
-
placeholder: "127.0.0.1",
|
|
240
|
-
});
|
|
241
|
-
if (p.isCancel(host)) {
|
|
242
|
-
p.cancel("Setup cancelled.");
|
|
243
|
-
process.exit(0);
|
|
244
|
-
}
|
|
245
|
-
gatewayHost = host;
|
|
246
|
-
const portStr = await p.text({
|
|
247
|
-
message: "Gateway port:",
|
|
248
|
-
defaultValue: "3000",
|
|
249
|
-
placeholder: "3000",
|
|
250
|
-
validate: (value) => {
|
|
251
|
-
const num = Number(value);
|
|
252
|
-
if (!Number.isInteger(num) || num < 1 || num > 65535) {
|
|
253
|
-
return "Port must be an integer between 1 and 65535";
|
|
254
|
-
}
|
|
255
|
-
return undefined;
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
if (p.isCancel(portStr)) {
|
|
259
|
-
p.cancel("Setup cancelled.");
|
|
260
|
-
process.exit(0);
|
|
261
|
-
}
|
|
262
|
-
gatewayPort = Number(portStr);
|
|
263
|
-
gatewayToken = randomBytes(32).toString("hex");
|
|
264
|
-
p.log.info("Generated gateway access token for authentication.");
|
|
265
|
-
}
|
|
266
|
-
// Step 7: Data directory
|
|
267
|
-
const dataDir = await p.text({
|
|
268
|
-
message: "Data directory for persistent storage:",
|
|
269
|
-
defaultValue: targetDir,
|
|
270
|
-
placeholder: targetDir,
|
|
271
|
-
validate: (value) => {
|
|
272
|
-
if (!value)
|
|
273
|
-
return "Path is required";
|
|
274
|
-
if (!value.startsWith("/") && !value.startsWith("./") && !value.startsWith("~/")) {
|
|
275
|
-
return "Please provide an absolute path, or relative with ./ or ~/";
|
|
276
|
-
}
|
|
277
|
-
return undefined;
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
if (p.isCancel(dataDir)) {
|
|
281
|
-
p.cancel("Setup cancelled.");
|
|
282
|
-
process.exit(0);
|
|
283
|
-
}
|
|
284
|
-
// Step 8: Review
|
|
285
|
-
const summary = [
|
|
286
|
-
` Provider: ${provider}`,
|
|
287
|
-
` API Key: ${apiKey ? "****" + apiKey.slice(-4) : "(none)"}`,
|
|
288
|
-
` Agent Name: ${agentName}`,
|
|
289
|
-
` Model: ${model}`,
|
|
290
|
-
` Channels: ${channels.length > 0 ? channels.map((c) => c.type).join(", ") : "(none)"}`,
|
|
291
|
-
` Gateway: ${gatewayEnabled ? `${gatewayHost}:${gatewayPort}` : "disabled"}`,
|
|
292
|
-
` Data Dir: ${dataDir}`,
|
|
293
|
-
].join("\n");
|
|
294
|
-
p.log.info("Configuration summary:\n" + summary);
|
|
295
|
-
const confirmed = await p.confirm({
|
|
296
|
-
message: "Save this configuration?",
|
|
297
|
-
initialValue: true,
|
|
298
|
-
});
|
|
299
|
-
if (p.isCancel(confirmed) || !confirmed) {
|
|
300
|
-
p.cancel("Setup cancelled. No files written.");
|
|
301
|
-
process.exit(0);
|
|
302
|
-
}
|
|
303
|
-
const wizardResult = {
|
|
304
|
-
provider,
|
|
305
|
-
apiKey,
|
|
306
|
-
agentName,
|
|
307
|
-
model,
|
|
308
|
-
channels,
|
|
309
|
-
gatewayEnabled,
|
|
310
|
-
gatewayHost,
|
|
311
|
-
gatewayPort,
|
|
312
|
-
gatewayToken,
|
|
313
|
-
dataDir,
|
|
314
|
-
};
|
|
315
|
-
// Write config files
|
|
316
|
-
const configResult = writeWizardConfig(wizardResult, targetDir);
|
|
317
|
-
if (!configResult.ok) {
|
|
318
|
-
p.log.error(`Failed to write config: ${configResult.error.message}`);
|
|
319
|
-
return err(configResult.error);
|
|
320
|
-
}
|
|
321
|
-
if (apiKey) {
|
|
322
|
-
const envResult = writeWizardEnv(wizardResult, targetDir);
|
|
323
|
-
if (!envResult.ok) {
|
|
324
|
-
p.log.error(`Failed to write .env: ${envResult.error.message}`);
|
|
325
|
-
return err(envResult.error);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
p.log.success(`Configuration saved to ${configResult.value}`);
|
|
329
|
-
if (gatewayEnabled && gatewayToken) {
|
|
330
|
-
p.log.warn(`Save your gateway token -- it will not be shown again:\n ${gatewayToken}`);
|
|
331
|
-
}
|
|
332
|
-
p.outro("Setup complete! Next: comis daemon start");
|
|
333
|
-
return ok(wizardResult);
|
|
334
|
-
}
|
|
335
|
-
/** Fallback default model per provider. */
|
|
336
|
-
function getDefaultModel(provider) {
|
|
337
|
-
const defaults = {
|
|
338
|
-
anthropic: "claude-sonnet-4-5-20250929",
|
|
339
|
-
openai: "gpt-4o",
|
|
340
|
-
google: "gemini-2.0-flash",
|
|
341
|
-
groq: "llama-3.3-70b-versatile",
|
|
342
|
-
ollama: "llama3",
|
|
343
|
-
};
|
|
344
|
-
return defaults[provider] ?? "default";
|
|
345
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QuickStart wizard flow.
|
|
3
|
-
*
|
|
4
|
-
* Collects provider, API key, and agent name in 3 prompts (skipping
|
|
5
|
-
* API key for Ollama). Uses ModelCatalog from @comis/agent for
|
|
6
|
-
* dynamic model selection instead of hardcoded lists.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import { type Result } from "@comis/shared";
|
|
11
|
-
import type { WizardResult } from "./flow-types.js";
|
|
12
|
-
/**
|
|
13
|
-
* Run the QuickStart wizard flow.
|
|
14
|
-
*
|
|
15
|
-
* Collects provider + API key + agent name, picks the first model
|
|
16
|
-
* from ModelCatalog for the provider, writes config and .env.
|
|
17
|
-
*
|
|
18
|
-
* @param configDir - Override config directory (default ~/.comis)
|
|
19
|
-
* @returns The wizard result or an error
|
|
20
|
-
*/
|
|
21
|
-
export declare function runQuickStartFlow(configDir?: string): Promise<Result<WizardResult, Error>>;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
/**
|
|
3
|
-
* QuickStart wizard flow.
|
|
4
|
-
*
|
|
5
|
-
* Collects provider, API key, and agent name in 3 prompts (skipping
|
|
6
|
-
* API key for Ollama). Uses ModelCatalog from @comis/agent for
|
|
7
|
-
* dynamic model selection instead of hardcoded lists.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import * as p from "@clack/prompts";
|
|
12
|
-
import * as os from "node:os";
|
|
13
|
-
import { ok, err } from "@comis/shared";
|
|
14
|
-
import { createModelCatalog } from "@comis/agent";
|
|
15
|
-
import { PROVIDERS, MIN_KEY_LENGTHS } from "./flow-types.js";
|
|
16
|
-
import { writeWizardConfig, writeWizardEnv } from "./config-writer.js";
|
|
17
|
-
/**
|
|
18
|
-
* Run the QuickStart wizard flow.
|
|
19
|
-
*
|
|
20
|
-
* Collects provider + API key + agent name, picks the first model
|
|
21
|
-
* from ModelCatalog for the provider, writes config and .env.
|
|
22
|
-
*
|
|
23
|
-
* @param configDir - Override config directory (default ~/.comis)
|
|
24
|
-
* @returns The wizard result or an error
|
|
25
|
-
*/
|
|
26
|
-
export async function runQuickStartFlow(configDir) {
|
|
27
|
-
const targetDir = configDir ?? os.homedir() + "/.comis";
|
|
28
|
-
p.intro("Comis Quick Setup");
|
|
29
|
-
const result = await p.group({
|
|
30
|
-
provider: () => p.select({
|
|
31
|
-
message: "Select your LLM provider:",
|
|
32
|
-
options: PROVIDERS,
|
|
33
|
-
}),
|
|
34
|
-
apiKey: ({ results }) => {
|
|
35
|
-
if (results.provider === "ollama") {
|
|
36
|
-
p.log.info("Ollama runs locally -- no API key needed.");
|
|
37
|
-
return Promise.resolve("");
|
|
38
|
-
}
|
|
39
|
-
const minLen = MIN_KEY_LENGTHS[results.provider] ?? 20;
|
|
40
|
-
return p.password({
|
|
41
|
-
message: `Enter your ${results.provider} API key:`,
|
|
42
|
-
validate: (value) => {
|
|
43
|
-
if (!value || value.length < minLen) {
|
|
44
|
-
return `API key must be at least ${minLen} characters`;
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
agentName: () => p.text({
|
|
51
|
-
message: "Name your agent:",
|
|
52
|
-
placeholder: "Comis",
|
|
53
|
-
defaultValue: "Comis",
|
|
54
|
-
validate: (value) => {
|
|
55
|
-
if (!value || !/^[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(value)) {
|
|
56
|
-
return "Name must be alphanumeric with optional hyphens (no leading hyphen)";
|
|
57
|
-
}
|
|
58
|
-
if (value.length > 64) {
|
|
59
|
-
return "Name must be at most 64 characters";
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
}, {
|
|
65
|
-
onCancel: () => {
|
|
66
|
-
p.cancel("Setup cancelled.");
|
|
67
|
-
process.exit(0);
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
// Use ModelCatalog for dynamic model selection
|
|
71
|
-
let model;
|
|
72
|
-
try {
|
|
73
|
-
const catalog = createModelCatalog();
|
|
74
|
-
catalog.loadStatic();
|
|
75
|
-
const models = catalog.getByProvider(result.provider);
|
|
76
|
-
model = models.length > 0 ? models[0].modelId : getDefaultModel(result.provider);
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
// Fallback if pi-ai loading fails
|
|
80
|
-
model = getDefaultModel(result.provider);
|
|
81
|
-
}
|
|
82
|
-
const wizardResult = {
|
|
83
|
-
provider: result.provider,
|
|
84
|
-
apiKey: result.apiKey,
|
|
85
|
-
agentName: result.agentName,
|
|
86
|
-
model,
|
|
87
|
-
dataDir: targetDir,
|
|
88
|
-
};
|
|
89
|
-
// Write config files
|
|
90
|
-
const configResult = writeWizardConfig(wizardResult, targetDir);
|
|
91
|
-
if (!configResult.ok) {
|
|
92
|
-
p.log.error(`Failed to write config: ${configResult.error.message}`);
|
|
93
|
-
return err(configResult.error);
|
|
94
|
-
}
|
|
95
|
-
if (wizardResult.apiKey) {
|
|
96
|
-
const envResult = writeWizardEnv(wizardResult, targetDir);
|
|
97
|
-
if (!envResult.ok) {
|
|
98
|
-
p.log.error(`Failed to write .env: ${envResult.error.message}`);
|
|
99
|
-
return err(envResult.error);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
p.log.success(`Configuration saved to ${configResult.value}`);
|
|
103
|
-
p.outro("Setup complete! Next: comis daemon start");
|
|
104
|
-
return ok(wizardResult);
|
|
105
|
-
}
|
|
106
|
-
/** Fallback default model per provider. */
|
|
107
|
-
function getDefaultModel(provider) {
|
|
108
|
-
const defaults = {
|
|
109
|
-
anthropic: "claude-sonnet-4-5-20250929",
|
|
110
|
-
openai: "gpt-4o",
|
|
111
|
-
google: "gemini-2.0-flash",
|
|
112
|
-
groq: "llama-3.3-70b-versatile",
|
|
113
|
-
ollama: "llama3",
|
|
114
|
-
};
|
|
115
|
-
return defaults[provider] ?? "default";
|
|
116
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Model selection configuration schemas.
|
|
4
|
-
*
|
|
5
|
-
* Owns budget limits, circuit breaker thresholds, model route overrides,
|
|
6
|
-
* fallback model entries, auth profile rotation, and failover configuration.
|
|
7
|
-
*/
|
|
8
|
-
export declare const BudgetConfigSchema: z.ZodObject<{
|
|
9
|
-
/** Max tokens per single execution */
|
|
10
|
-
perExecution: z.ZodDefault<z.ZodNumber>;
|
|
11
|
-
/** Max tokens per hour (rolling window) */
|
|
12
|
-
perHour: z.ZodDefault<z.ZodNumber>;
|
|
13
|
-
/** Max tokens per day (rolling window) */
|
|
14
|
-
perDay: z.ZodDefault<z.ZodNumber>;
|
|
15
|
-
}, z.core.$strict>;
|
|
16
|
-
export declare const CircuitBreakerConfigSchema: z.ZodObject<{
|
|
17
|
-
/** Number of consecutive failures before opening circuit */
|
|
18
|
-
failureThreshold: z.ZodDefault<z.ZodNumber>;
|
|
19
|
-
/** Milliseconds to wait before attempting recovery */
|
|
20
|
-
resetTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
21
|
-
/** Milliseconds for half-open probe timeout */
|
|
22
|
-
halfOpenTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
23
|
-
}, z.core.$strict>;
|
|
24
|
-
/**
|
|
25
|
-
* Per-agent model route overrides.
|
|
26
|
-
*
|
|
27
|
-
* Maps task types to specific model identifiers. The `default` key
|
|
28
|
-
* falls back to the agent's top-level `model` field when not set.
|
|
29
|
-
* Additional named routes (e.g. "summarization", "classification")
|
|
30
|
-
* allow task-specific model selection.
|
|
31
|
-
*
|
|
32
|
-
* Uses .catchall(z.string()) for extensibility -- any string key maps
|
|
33
|
-
* to a model identifier string.
|
|
34
|
-
*/
|
|
35
|
-
export declare const ModelRoutesSchema: z.ZodDefault<z.ZodObject<{
|
|
36
|
-
default: z.ZodOptional<z.ZodString>;
|
|
37
|
-
}, z.core.$catchall<z.ZodString>>>;
|
|
38
|
-
/**
|
|
39
|
-
* Schema for a single fallback model entry (provider + modelId pair).
|
|
40
|
-
*/
|
|
41
|
-
export declare const FallbackModelSchema: z.ZodObject<{
|
|
42
|
-
/** LLM provider (e.g. "anthropic", "openai") */
|
|
43
|
-
provider: z.ZodString;
|
|
44
|
-
/** Model identifier at the provider */
|
|
45
|
-
modelId: z.ZodString;
|
|
46
|
-
}, z.core.$strict>;
|
|
47
|
-
/**
|
|
48
|
-
* Schema for an auth profile entry (key name + provider association).
|
|
49
|
-
*
|
|
50
|
-
* Each profile maps a SecretManager key name to a provider, enabling
|
|
51
|
-
* multiple API keys per provider for rotation during rate limiting.
|
|
52
|
-
*/
|
|
53
|
-
export declare const AuthProfileSchema: z.ZodObject<{
|
|
54
|
-
/** Key name in SecretManager (e.g. "ANTHROPIC_API_KEY_2") */
|
|
55
|
-
keyName: z.ZodString;
|
|
56
|
-
/** Provider this key belongs to (e.g. "anthropic") */
|
|
57
|
-
provider: z.ZodString;
|
|
58
|
-
}, z.core.$strict>;
|
|
59
|
-
/**
|
|
60
|
-
* Model failover configuration schema.
|
|
61
|
-
*
|
|
62
|
-
* Controls automatic model failover behavior, auth profile rotation
|
|
63
|
-
* with exponential cooldowns, and model allowlisting.
|
|
64
|
-
*/
|
|
65
|
-
export declare const ModelFailoverConfigSchema: z.ZodObject<{
|
|
66
|
-
/** Ordered list of fallback models to try when primary fails */
|
|
67
|
-
fallbackModels: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
68
|
-
/** LLM provider (e.g. "anthropic", "openai") */
|
|
69
|
-
provider: z.ZodString;
|
|
70
|
-
/** Model identifier at the provider */
|
|
71
|
-
modelId: z.ZodString;
|
|
72
|
-
}, z.core.$strict>>>;
|
|
73
|
-
/** Per-provider API key profiles for auth rotation */
|
|
74
|
-
authProfiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
75
|
-
/** Key name in SecretManager (e.g. "ANTHROPIC_API_KEY_2") */
|
|
76
|
-
keyName: z.ZodString;
|
|
77
|
-
/** Provider this key belongs to (e.g. "anthropic") */
|
|
78
|
-
provider: z.ZodString;
|
|
79
|
-
}, z.core.$strict>>>;
|
|
80
|
-
/** Model allowlist (empty = allow all models) */
|
|
81
|
-
allowedModels: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
82
|
-
/** Maximum total attempts across all models/keys */
|
|
83
|
-
maxAttempts: z.ZodDefault<z.ZodNumber>;
|
|
84
|
-
/** Initial cooldown duration in milliseconds (1 min) */
|
|
85
|
-
cooldownInitialMs: z.ZodDefault<z.ZodNumber>;
|
|
86
|
-
/** Exponential cooldown multiplier */
|
|
87
|
-
cooldownMultiplier: z.ZodDefault<z.ZodNumber>;
|
|
88
|
-
/** Maximum cooldown duration in milliseconds (1 hr) */
|
|
89
|
-
cooldownCapMs: z.ZodDefault<z.ZodNumber>;
|
|
90
|
-
}, z.core.$strict>;
|
|
91
|
-
export declare const PromptTimeoutConfigSchema: z.ZodObject<{
|
|
92
|
-
/** Wall-clock timeout for primary prompt calls in milliseconds. Default: 180s. */
|
|
93
|
-
promptTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
94
|
-
/** Wall-clock timeout for retry prompt calls in milliseconds. Default: 60s. */
|
|
95
|
-
retryPromptTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
96
|
-
}, z.core.$strict>;
|
|
97
|
-
/**
|
|
98
|
-
* Valid operation type keys for model resolution.
|
|
99
|
-
*
|
|
100
|
-
* Named ModelOperationType (not OperationType) to avoid collision with
|
|
101
|
-
* the existing OperationType in packages/daemon/src/observability/latency-recorder.ts.
|
|
102
|
-
*/
|
|
103
|
-
export type ModelOperationType = "interactive" | "cron" | "heartbeat" | "subagent" | "compaction" | "taskExtraction" | "condensation";
|
|
104
|
-
/**
|
|
105
|
-
* Per-operation model override configuration.
|
|
106
|
-
*
|
|
107
|
-
* Each operation type has an optional model field (accepts "provider:modelId"
|
|
108
|
-
* format or "primary" keyword to opt out of tiering) and an optional timeout
|
|
109
|
-
* field (milliseconds, overrides per-operation defaults).
|
|
110
|
-
*
|
|
111
|
-
* When no fields are set (default: {}), the resolver uses provider-family
|
|
112
|
-
* smart defaults for automatic model tiering.
|
|
113
|
-
*/
|
|
114
|
-
export declare const OperationModelsSchema: z.ZodDefault<z.ZodObject<{
|
|
115
|
-
cron: z.ZodOptional<z.ZodString>;
|
|
116
|
-
cronTimeout: z.ZodOptional<z.ZodNumber>;
|
|
117
|
-
heartbeat: z.ZodOptional<z.ZodString>;
|
|
118
|
-
heartbeatTimeout: z.ZodOptional<z.ZodNumber>;
|
|
119
|
-
subagent: z.ZodOptional<z.ZodString>;
|
|
120
|
-
subagentTimeout: z.ZodOptional<z.ZodNumber>;
|
|
121
|
-
compaction: z.ZodOptional<z.ZodString>;
|
|
122
|
-
compactionTimeout: z.ZodOptional<z.ZodNumber>;
|
|
123
|
-
taskExtraction: z.ZodOptional<z.ZodString>;
|
|
124
|
-
taskExtractionTimeout: z.ZodOptional<z.ZodNumber>;
|
|
125
|
-
condensation: z.ZodOptional<z.ZodString>;
|
|
126
|
-
condensationTimeout: z.ZodOptional<z.ZodNumber>;
|
|
127
|
-
}, z.core.$strict>>;
|
|
128
|
-
export type BudgetConfig = z.infer<typeof BudgetConfigSchema>;
|
|
129
|
-
export type CircuitBreakerConfig = z.infer<typeof CircuitBreakerConfigSchema>;
|
|
130
|
-
export type ModelRoutes = z.infer<typeof ModelRoutesSchema>;
|
|
131
|
-
export type FallbackModel = z.infer<typeof FallbackModelSchema>;
|
|
132
|
-
export type AuthProfileEntry = z.infer<typeof AuthProfileSchema>;
|
|
133
|
-
export type ModelFailoverConfig = z.infer<typeof ModelFailoverConfigSchema>;
|
|
134
|
-
export type PromptTimeoutConfig = z.infer<typeof PromptTimeoutConfigSchema>;
|
|
135
|
-
export type OperationModels = z.infer<typeof OperationModelsSchema>;
|