comisai 1.0.19 → 1.0.22

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.
Files changed (147) hide show
  1. package/dist/cli-entry.js +0 -0
  2. package/node_modules/@comis/agent/dist/context-engine/context-engine.js +43 -2
  3. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +51 -0
  4. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +110 -0
  5. package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +54 -0
  6. package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +145 -0
  7. package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +17 -0
  8. package/node_modules/@comis/agent/dist/executor/error-classifier.d.ts +11 -1
  9. package/node_modules/@comis/agent/dist/executor/error-classifier.js +13 -0
  10. package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +1 -0
  11. package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +55 -0
  12. package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +106 -5
  13. package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +1 -0
  14. package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
  15. package/node_modules/@comis/agent/dist/executor/replay-drift-detector.d.ts +85 -0
  16. package/node_modules/@comis/agent/dist/executor/replay-drift-detector.js +92 -0
  17. package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.d.ts +34 -0
  18. package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.js +69 -0
  19. package/node_modules/@comis/agent/dist/executor/signed-replay-detector.d.ts +39 -0
  20. package/node_modules/@comis/agent/dist/executor/signed-replay-detector.js +72 -0
  21. package/node_modules/@comis/agent/package.json +1 -1
  22. package/node_modules/@comis/channels/package.json +1 -1
  23. package/node_modules/@comis/cli/dist/cli.js +0 -0
  24. package/node_modules/@comis/cli/package.json +1 -1
  25. package/node_modules/@comis/core/dist/config/git-manager.js +10 -4
  26. package/node_modules/@comis/core/dist/config/index.d.ts +1 -0
  27. package/node_modules/@comis/core/dist/config/index.js +2 -0
  28. package/node_modules/@comis/core/dist/config/managed-sections.d.ts +67 -0
  29. package/node_modules/@comis/core/dist/config/managed-sections.js +124 -0
  30. package/node_modules/@comis/core/dist/config/schema-agent.d.ts +28 -10
  31. package/node_modules/@comis/core/dist/config/schema-agent.js +6 -0
  32. package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +2 -2
  33. package/node_modules/@comis/core/dist/config/schema.d.ts +65 -64
  34. package/node_modules/@comis/core/dist/event-bus/events-messaging.d.ts +16 -0
  35. package/node_modules/@comis/core/dist/exports/config.d.ts +1 -1
  36. package/node_modules/@comis/core/dist/exports/config.js +1 -1
  37. package/node_modules/@comis/core/package.json +1 -1
  38. package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/init-skill.py +0 -0
  39. package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +0 -0
  40. package/node_modules/@comis/daemon/dist/daemon.js +0 -0
  41. package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +20 -7
  42. package/node_modules/@comis/daemon/dist/rpc/session-handlers.js +27 -1
  43. package/node_modules/@comis/daemon/package.json +1 -1
  44. package/node_modules/@comis/gateway/package.json +1 -1
  45. package/node_modules/@comis/infra/package.json +1 -1
  46. package/node_modules/@comis/memory/package.json +1 -1
  47. package/node_modules/@comis/scheduler/package.json +1 -1
  48. package/node_modules/@comis/shared/package.json +1 -1
  49. package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +23 -8
  50. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +1 -1
  51. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +18 -14
  52. package/node_modules/@comis/skills/dist/builtin/platform/unified-session-tool.js +1 -1
  53. package/node_modules/@comis/skills/package.json +1 -1
  54. package/node_modules/@comis/web/package.json +1 -1
  55. package/package.json +24 -26
  56. package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.d.ts +0 -9
  57. package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.js +0 -17
  58. package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.d.ts +0 -13
  59. package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.js +0 -19
  60. package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.d.ts +0 -11
  61. package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.js +0 -32
  62. package/node_modules/@comis/agent/dist/safety/follow-through-detector.d.ts +0 -46
  63. package/node_modules/@comis/agent/dist/safety/follow-through-detector.js +0 -76
  64. package/node_modules/@comis/agent/dist/safety/post-compaction-safety.d.ts +0 -30
  65. package/node_modules/@comis/agent/dist/safety/post-compaction-safety.js +0 -51
  66. package/node_modules/@comis/agent/dist/safety/schema-normalizer.d.ts +0 -37
  67. package/node_modules/@comis/agent/dist/safety/schema-normalizer.js +0 -137
  68. package/node_modules/@comis/agent/dist/safety/schema-pruning.d.ts +0 -50
  69. package/node_modules/@comis/agent/dist/safety/schema-pruning.js +0 -112
  70. package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.d.ts +0 -43
  71. package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.js +0 -96
  72. package/node_modules/@comis/agent/dist/safety/tool-sanitizer.d.ts +0 -44
  73. package/node_modules/@comis/agent/dist/safety/tool-sanitizer.js +0 -94
  74. package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.d.ts +0 -28
  75. package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.js +0 -206
  76. package/node_modules/@comis/cli/dist/wizard/config-writer.d.ts +0 -25
  77. package/node_modules/@comis/cli/dist/wizard/config-writer.js +0 -144
  78. package/node_modules/@comis/cli/dist/wizard/flow-types.d.ts +0 -48
  79. package/node_modules/@comis/cli/dist/wizard/flow-types.js +0 -70
  80. package/node_modules/@comis/cli/dist/wizard/manual-flow.d.ts +0 -21
  81. package/node_modules/@comis/cli/dist/wizard/manual-flow.js +0 -345
  82. package/node_modules/@comis/cli/dist/wizard/quickstart-flow.d.ts +0 -21
  83. package/node_modules/@comis/cli/dist/wizard/quickstart-flow.js +0 -116
  84. package/node_modules/@comis/core/dist/config/schema-agent-model.d.ts +0 -135
  85. package/node_modules/@comis/core/dist/config/schema-agent-model.js +0 -114
  86. package/node_modules/@comis/core/dist/config/schema-agent-session.d.ts +0 -177
  87. package/node_modules/@comis/core/dist/config/schema-agent-session.js +0 -116
  88. package/node_modules/@comis/core/dist/config/schema-context-engine.d.ts +0 -92
  89. package/node_modules/@comis/core/dist/config/schema-context-engine.js +0 -92
  90. package/node_modules/@comis/core/dist/config/schema-context-guard.d.ts +0 -34
  91. package/node_modules/@comis/core/dist/config/schema-context-guard.js +0 -32
  92. package/node_modules/@comis/core/dist/config/schema-delivery-mirror.d.ts +0 -27
  93. package/node_modules/@comis/core/dist/config/schema-delivery-mirror.js +0 -26
  94. package/node_modules/@comis/core/dist/config/schema-delivery-queue.d.ts +0 -31
  95. package/node_modules/@comis/core/dist/config/schema-delivery-queue.js +0 -30
  96. package/node_modules/@comis/core/dist/config/schema-delivery-timing.d.ts +0 -41
  97. package/node_modules/@comis/core/dist/config/schema-delivery-timing.js +0 -31
  98. package/node_modules/@comis/core/dist/config/schema-monitoring.d.ts +0 -105
  99. package/node_modules/@comis/core/dist/config/schema-monitoring.js +0 -67
  100. package/node_modules/@comis/core/dist/ports/media-ports.d.ts +0 -278
  101. package/node_modules/@comis/core/dist/ports/media-ports.js +0 -1
  102. package/node_modules/@comis/core/dist/security/input-guard.d.ts +0 -46
  103. package/node_modules/@comis/core/dist/security/input-guard.js +0 -166
  104. package/node_modules/@comis/core/dist/security/scoped-secret-manager.d.ts +0 -38
  105. package/node_modules/@comis/core/dist/security/scoped-secret-manager.js +0 -94
  106. package/node_modules/@comis/daemon/dist/observability/delivery-context.d.ts +0 -37
  107. package/node_modules/@comis/daemon/dist/observability/delivery-context.js +0 -1
  108. package/node_modules/@comis/daemon/dist/observability/log-level-manager.d.ts +0 -23
  109. package/node_modules/@comis/daemon/dist/observability/log-level-manager.js +0 -34
  110. package/node_modules/@comis/daemon/dist/observability/log-transport.d.ts +0 -44
  111. package/node_modules/@comis/daemon/dist/observability/log-transport.js +0 -74
  112. package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.d.ts +0 -53
  113. package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.js +0 -68
  114. package/node_modules/@comis/daemon/dist/observability/types.d.ts +0 -6
  115. package/node_modules/@comis/daemon/dist/observability/types.js +0 -1
  116. package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.d.ts +0 -41
  117. package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.js +0 -84
  118. package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.d.ts +0 -24
  119. package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.js +0 -88
  120. package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.d.ts +0 -31
  121. package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.js +0 -132
  122. package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.d.ts +0 -38
  123. package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.js +0 -100
  124. package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.d.ts +0 -34
  125. package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.js +0 -52
  126. package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.d.ts +0 -41
  127. package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.js +0 -86
  128. package/node_modules/@comis/memory/dist/embedding-cache.d.ts +0 -36
  129. package/node_modules/@comis/memory/dist/embedding-cache.js +0 -94
  130. package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.d.ts +0 -17
  131. package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.js +0 -125
  132. package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.d.ts +0 -14
  133. package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.js +0 -92
  134. package/node_modules/@comis/skills/dist/bridge/tool-result-caps.d.ts +0 -14
  135. package/node_modules/@comis/skills/dist/bridge/tool-result-caps.js +0 -36
  136. package/node_modules/@comis/skills/dist/bridge/tool-search-hints.d.ts +0 -15
  137. package/node_modules/@comis/skills/dist/bridge/tool-search-hints.js +0 -68
  138. package/node_modules/@comis/skills/dist/bridge/tool-validators.d.ts +0 -11
  139. package/node_modules/@comis/skills/dist/bridge/tool-validators.js +0 -105
  140. package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.d.ts +0 -22
  141. package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.js +0 -95
  142. package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.d.ts +0 -24
  143. package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.js +0 -167
  144. package/node_modules/@comis/skills/dist/builtin/task-plan-tool.d.ts +0 -25
  145. package/node_modules/@comis/skills/dist/builtin/task-plan-tool.js +0 -67
  146. package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.d.ts +0 -75
  147. package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.js +0 -235
@@ -1,48 +0,0 @@
1
- /**
2
- * Shared types and constants for the init wizard flows.
3
- *
4
- * Provides the WizardResult, ChannelSetup, and ProviderChoice types
5
- * used by both QuickStart and Manual flows, plus constant arrays
6
- * for providers, channel types, and minimum key lengths.
7
- *
8
- * @module
9
- */
10
- /** Result collected from any wizard flow. */
11
- export interface WizardResult {
12
- provider: string;
13
- agentName: string;
14
- apiKey?: string;
15
- model?: string;
16
- channels?: ChannelSetup[];
17
- gatewayEnabled?: boolean;
18
- gatewayHost?: string;
19
- gatewayPort?: number;
20
- gatewayToken?: string;
21
- dataDir?: string;
22
- }
23
- /** Channel configuration collected during the wizard. */
24
- export interface ChannelSetup {
25
- type: "telegram" | "discord" | "slack" | "whatsapp" | "signal" | "irc" | "line";
26
- botToken?: string;
27
- apiKey?: string;
28
- appToken?: string;
29
- }
30
- /** A provider option for Clack select prompts. */
31
- export interface ProviderChoice {
32
- value: string;
33
- label: string;
34
- hint?: string;
35
- }
36
- /** Provider options for Clack select prompts. */
37
- export declare const PROVIDERS: ProviderChoice[];
38
- /** Minimum API key lengths per provider (0 = no key needed). */
39
- export declare const MIN_KEY_LENGTHS: Record<string, number>;
40
- /** Map provider name to the environment variable key for the API key. */
41
- export declare const PROVIDER_ENV_KEYS: Record<string, string>;
42
- /** Map channel type to required credential environment variable names. */
43
- export declare const CHANNEL_ENV_KEYS: Record<string, string[]>;
44
- /** All supported channel types for Clack multiselect. */
45
- export declare const CHANNEL_TYPES: {
46
- value: ChannelSetup["type"];
47
- label: string;
48
- }[];
@@ -1,70 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- /**
3
- * Shared types and constants for the init wizard flows.
4
- *
5
- * Provides the WizardResult, ChannelSetup, and ProviderChoice types
6
- * used by both QuickStart and Manual flows, plus constant arrays
7
- * for providers, channel types, and minimum key lengths.
8
- *
9
- * @module
10
- */
11
- // ---------- Constants ----------
12
- /** Provider options for Clack select prompts. */
13
- export const PROVIDERS = [
14
- { value: "anthropic", label: "Anthropic (Claude)", hint: "Recommended" },
15
- { value: "openai", label: "OpenAI (GPT)" },
16
- { value: "google", label: "Google (Gemini)" },
17
- { value: "groq", label: "Groq", hint: "Fast inference" },
18
- { value: "mistral", label: "Mistral" },
19
- { value: "deepseek", label: "DeepSeek" },
20
- { value: "xai", label: "xAI (Grok)" },
21
- { value: "together", label: "Together AI" },
22
- { value: "cerebras", label: "Cerebras", hint: "Fast inference" },
23
- { value: "openrouter", label: "OpenRouter", hint: "Multi-provider gateway" },
24
- { value: "ollama", label: "Ollama (local)", hint: "No API key needed" },
25
- ];
26
- /** Minimum API key lengths per provider (0 = no key needed). */
27
- export const MIN_KEY_LENGTHS = {
28
- anthropic: 20,
29
- openai: 20,
30
- google: 20,
31
- groq: 20,
32
- mistral: 20,
33
- deepseek: 20,
34
- xai: 20,
35
- together: 20,
36
- cerebras: 20,
37
- openrouter: 20,
38
- ollama: 0,
39
- };
40
- /** Map provider name to the environment variable key for the API key. */
41
- export const PROVIDER_ENV_KEYS = {
42
- anthropic: "ANTHROPIC_API_KEY",
43
- openai: "OPENAI_API_KEY",
44
- google: "GOOGLE_API_KEY",
45
- groq: "GROQ_API_KEY",
46
- mistral: "MISTRAL_API_KEY",
47
- deepseek: "DEEPSEEK_API_KEY",
48
- xai: "XAI_API_KEY",
49
- together: "TOGETHER_API_KEY",
50
- cerebras: "CEREBRAS_API_KEY",
51
- openrouter: "OPENROUTER_API_KEY",
52
- };
53
- /** Map channel type to required credential environment variable names. */
54
- export const CHANNEL_ENV_KEYS = {
55
- telegram: ["TELEGRAM_BOT_TOKEN"],
56
- discord: ["DISCORD_BOT_TOKEN"],
57
- slack: ["SLACK_BOT_TOKEN", "SLACK_SIGNING_SECRET"],
58
- whatsapp: ["WHATSAPP_ACCESS_TOKEN", "WHATSAPP_VERIFY_TOKEN"],
59
- line: ["LINE_CHANNEL_ACCESS_TOKEN", "LINE_CHANNEL_SECRET"],
60
- };
61
- /** All supported channel types for Clack multiselect. */
62
- export const CHANNEL_TYPES = [
63
- { value: "telegram", label: "Telegram" },
64
- { value: "discord", label: "Discord" },
65
- { value: "slack", label: "Slack" },
66
- { value: "whatsapp", label: "WhatsApp" },
67
- { value: "signal", label: "Signal" },
68
- { value: "irc", label: "IRC" },
69
- { value: "line", label: "LINE" },
70
- ];
@@ -1,21 +0,0 @@
1
- /**
2
- * Manual wizard flow.
3
- *
4
- * Full-control wizard covering all 8 steps: provider, API key,
5
- * agent name, model, channels, gateway, data directory, and review.
6
- * Uses ModelCatalog from @comis/agent for dynamic model selection.
7
- *
8
- * @module
9
- */
10
- import { type Result } from "@comis/shared";
11
- import type { WizardResult } from "./flow-types.js";
12
- /**
13
- * Run the Manual wizard flow.
14
- *
15
- * Presents all configuration options: provider, API key, agent name,
16
- * model, channels, gateway, data directory, and a review step.
17
- *
18
- * @param configDir - Override config directory (default ~/.comis)
19
- * @returns The wizard result or an error
20
- */
21
- export declare function runManualFlow(configDir?: string): Promise<Result<WizardResult, Error>>;
@@ -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
- }