@jungjaehoon/mama-os 0.32.1 → 0.32.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +15 -13
- package/dist/agent/agent-loop.d.ts +5 -0
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +160 -55
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/backend-model-policy.d.ts +9 -0
- package/dist/agent/backend-model-policy.d.ts.map +1 -0
- package/dist/agent/backend-model-policy.js +21 -0
- package/dist/agent/backend-model-policy.js.map +1 -0
- package/dist/agent/backend-model-runner-factory.d.ts +27 -0
- package/dist/agent/backend-model-runner-factory.d.ts.map +1 -0
- package/dist/agent/backend-model-runner-factory.js +85 -0
- package/dist/agent/backend-model-runner-factory.js.map +1 -0
- package/dist/agent/cline-cli-adapter.d.ts +124 -0
- package/dist/agent/cline-cli-adapter.d.ts.map +1 -0
- package/dist/agent/cline-cli-adapter.js +1040 -0
- package/dist/agent/cline-cli-adapter.js.map +1 -0
- package/dist/agent/cline-native-tool-policy.d.ts +3 -0
- package/dist/agent/cline-native-tool-policy.d.ts.map +1 -0
- package/dist/agent/cline-native-tool-policy.js +50 -0
- package/dist/agent/cline-native-tool-policy.js.map +1 -0
- package/dist/agent/code-act/constants.d.ts +1 -1
- package/dist/agent/code-act/constants.d.ts.map +1 -1
- package/dist/agent/code-act/constants.js +13 -1
- package/dist/agent/code-act/constants.js.map +1 -1
- package/dist/agent/codex-app-server-process.d.ts +5 -0
- package/dist/agent/codex-app-server-process.d.ts.map +1 -1
- package/dist/agent/codex-app-server-process.js +30 -0
- package/dist/agent/codex-app-server-process.js.map +1 -1
- package/dist/agent/codex-auxiliary-tools.d.ts +17 -0
- package/dist/agent/codex-auxiliary-tools.d.ts.map +1 -0
- package/dist/agent/codex-auxiliary-tools.js +267 -0
- package/dist/agent/codex-auxiliary-tools.js.map +1 -0
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +1 -0
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/managed-agent-runtime-sync.d.ts.map +1 -1
- package/dist/agent/managed-agent-runtime-sync.js +17 -3
- package/dist/agent/managed-agent-runtime-sync.js.map +1 -1
- package/dist/agent/managed-agent-validation.js +1 -1
- package/dist/agent/managed-agent-validation.js.map +1 -1
- package/dist/agent/model-runner.d.ts +11 -1
- package/dist/agent/model-runner.d.ts.map +1 -1
- package/dist/agent/model-runner.js +12 -1
- package/dist/agent/model-runner.js.map +1 -1
- package/dist/agent/session-pool.d.ts +10 -9
- package/dist/agent/session-pool.d.ts.map +1 -1
- package/dist/agent/session-pool.js +12 -47
- package/dist/agent/session-pool.js.map +1 -1
- package/dist/agent/types.d.ts +18 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/graph-api.d.ts.map +1 -1
- package/dist/api/graph-api.js +15 -5
- package/dist/api/graph-api.js.map +1 -1
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +43 -10
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +12 -0
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +22 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +79 -28
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/start.d.ts +2 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +35 -9
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +4 -0
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config/config-manager.d.ts.map +1 -1
- package/dist/cli/config/config-manager.js +63 -14
- package/dist/cli/config/config-manager.js.map +1 -1
- package/dist/cli/config/types.d.ts +12 -5
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +3 -0
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/index.js +6 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +8 -3
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/gateway-init.d.ts +1 -1
- package/dist/cli/runtime/gateway-init.d.ts.map +1 -1
- package/dist/cli/runtime/gateway-init.js.map +1 -1
- package/dist/cli/runtime/mama-core-init.d.ts +10 -2
- package/dist/cli/runtime/mama-core-init.d.ts.map +1 -1
- package/dist/cli/runtime/mama-core-init.js +52 -68
- package/dist/cli/runtime/mama-core-init.js.map +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts.map +1 -1
- package/dist/cli/runtime/memory-agent-init.js +18 -5
- package/dist/cli/runtime/memory-agent-init.js.map +1 -1
- package/dist/cli/runtime/scheduler-init.d.ts +4 -0
- package/dist/cli/runtime/scheduler-init.d.ts.map +1 -1
- package/dist/cli/runtime/scheduler-init.js +24 -3
- package/dist/cli/runtime/scheduler-init.js.map +1 -1
- package/dist/cli/runtime/shutdown.d.ts +4 -0
- package/dist/cli/runtime/shutdown.d.ts.map +1 -1
- package/dist/cli/runtime/shutdown.js +30 -6
- package/dist/cli/runtime/shutdown.js.map +1 -1
- package/dist/cli/runtime/utilities.d.ts +2 -0
- package/dist/cli/runtime/utilities.d.ts.map +1 -1
- package/dist/cli/runtime/utilities.js +33 -0
- package/dist/cli/runtime/utilities.js.map +1 -1
- package/dist/gateways/discord.d.ts.map +1 -1
- package/dist/gateways/discord.js +11 -6
- package/dist/gateways/discord.js.map +1 -1
- package/dist/gateways/image-analyzer.d.ts +5 -0
- package/dist/gateways/image-analyzer.d.ts.map +1 -1
- package/dist/gateways/image-analyzer.js +8 -0
- package/dist/gateways/image-analyzer.js.map +1 -1
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +29 -15
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/slack.d.ts.map +1 -1
- package/dist/gateways/slack.js +6 -2
- package/dist/gateways/slack.js.map +1 -1
- package/dist/gateways/types.d.ts +1 -1
- package/dist/gateways/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/multi-agent/agent-process-manager.d.ts +6 -4
- package/dist/multi-agent/agent-process-manager.d.ts.map +1 -1
- package/dist/multi-agent/agent-process-manager.js +103 -34
- package/dist/multi-agent/agent-process-manager.js.map +1 -1
- package/dist/multi-agent/runtime-process.d.ts +3 -0
- package/dist/multi-agent/runtime-process.d.ts.map +1 -1
- package/dist/multi-agent/runtime-process.js +10 -2
- package/dist/multi-agent/runtime-process.js.map +1 -1
- package/dist/multi-agent/types.d.ts +12 -2
- package/dist/multi-agent/types.d.ts.map +1 -1
- package/dist/multi-agent/types.js.map +1 -1
- package/dist/multi-agent/workflow-types.d.ts +1 -1
- package/dist/multi-agent/workflow-types.d.ts.map +1 -1
- package/dist/onboarding/complete-autonomous-prompt.d.ts +1 -1
- package/dist/onboarding/complete-autonomous-prompt.d.ts.map +1 -1
- package/dist/onboarding/complete-autonomous-prompt.js +9 -9
- package/dist/operator/situation-report.d.ts.map +1 -1
- package/dist/operator/situation-report.js +38 -23
- package/dist/operator/situation-report.js.map +1 -1
- package/dist/operator/temporal-runtime.d.ts.map +1 -1
- package/dist/operator/temporal-runtime.js +3 -1
- package/dist/operator/temporal-runtime.js.map +1 -1
- package/dist/operator/trigger-author.d.ts +13 -1
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +35 -0
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/worker-run.d.ts.map +1 -1
- package/dist/operator/worker-run.js +10 -4
- package/dist/operator/worker-run.js.map +1 -1
- package/dist/scheduler/cron-worker.d.ts +8 -4
- package/dist/scheduler/cron-worker.d.ts.map +1 -1
- package/dist/scheduler/cron-worker.js +56 -39
- package/dist/scheduler/cron-worker.js.map +1 -1
- package/dist/setup/setup-actions.d.ts +26 -0
- package/dist/setup/setup-actions.d.ts.map +1 -0
- package/dist/setup/setup-actions.js +371 -0
- package/dist/setup/setup-actions.js.map +1 -0
- package/dist/setup/setup-prompt.d.ts +1 -1
- package/dist/setup/setup-prompt.d.ts.map +1 -1
- package/dist/setup/setup-prompt.js +28 -33
- package/dist/setup/setup-prompt.js.map +1 -1
- package/dist/setup/setup-server.d.ts +6 -1
- package/dist/setup/setup-server.d.ts.map +1 -1
- package/dist/setup/setup-server.js +55 -9
- package/dist/setup/setup-server.js.map +1 -1
- package/dist/setup/setup-websocket.d.ts +14 -2
- package/dist/setup/setup-websocket.d.ts.map +1 -1
- package/dist/setup/setup-websocket.js +121 -37
- package/dist/setup/setup-websocket.js.map +1 -1
- package/package.json +1 -1
- package/public/setup.html +9 -6
- package/public/viewer/js/modules/agents.js +5 -4
- package/public/viewer/js/modules/settings.js +34 -10
- package/public/viewer/src/modules/agents.ts +5 -4
- package/public/viewer/src/modules/settings.ts +49 -11
- package/public/viewer/src/utils/api.ts +3 -2
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SETUP_ACTION_PROTOCOL = void 0;
|
|
4
|
+
exports.parseSetupActions = parseSetupActions;
|
|
5
|
+
exports.createSetupActionExecutor = createSetupActionExecutor;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const config_manager_js_1 = require("../cli/config/config-manager.js");
|
|
10
|
+
const ACTION_PATTERN_SOURCE = '<mama_setup_action>([\\s\\S]*?)</mama_setup_action>';
|
|
11
|
+
const LEGACY_ACTION_PATTERN = /\b(?:save_integration_token|update_config|validate_discord_token|mark_setup_complete)\s*\(|\[(?:validate token|save channel|mark_setup_complete)\]/i;
|
|
12
|
+
const MAX_ACTIONS_PER_RESPONSE = 8;
|
|
13
|
+
const MAX_ACTION_BYTES = 100_000;
|
|
14
|
+
const CONFIG_KEYS = new Set([
|
|
15
|
+
'discord.token',
|
|
16
|
+
'discord.enabled',
|
|
17
|
+
'discord.default_channel_id',
|
|
18
|
+
'slack.bot_token',
|
|
19
|
+
'slack.app_token',
|
|
20
|
+
'slack.enabled',
|
|
21
|
+
'telegram.token',
|
|
22
|
+
'telegram.allowed_chats',
|
|
23
|
+
'telegram.enabled',
|
|
24
|
+
'multi_agent.dangerouslySkipPermissions',
|
|
25
|
+
'multi_agent.enabled',
|
|
26
|
+
]);
|
|
27
|
+
const GENERIC_UPDATE_CONFIG_KEYS = new Set([...CONFIG_KEYS].filter((key) => !['discord.token', 'slack.bot_token', 'slack.app_token', 'telegram.token'].includes(key)));
|
|
28
|
+
exports.SETUP_ACTION_PROTOCOL = `## MAMA Setup Host Actions
|
|
29
|
+
|
|
30
|
+
You do not have native setup/file tools. To perform a setup mutation, emit exactly one or more
|
|
31
|
+
JSON actions wrapped in <mama_setup_action> tags. The host validates and executes them, then sends
|
|
32
|
+
trusted results back in the same session. Never claim success before receiving a successful result.
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
<mama_setup_action>{"type":"update_config","key":"discord.enabled","value":true}</mama_setup_action>
|
|
36
|
+
<mama_setup_action>{"type":"validate_discord_token","token":"..."}</mama_setup_action>
|
|
37
|
+
<mama_setup_action>{"type":"write_file","name":"USER.md","content":"# USER.md..."}</mama_setup_action>
|
|
38
|
+
<mama_setup_action>{"type":"mark_setup_complete"}</mama_setup_action>
|
|
39
|
+
|
|
40
|
+
Supported action schemas:
|
|
41
|
+
- update_config: {"type":"update_config","key":<allowed key>,"value":<value>}
|
|
42
|
+
- validate_discord_token: {"type":"validate_discord_token","token":"..."}
|
|
43
|
+
- write_file: {"type":"write_file","name":"IDENTITY.md|USER.md|SOUL.md|personas/<name>.md","content":"..."}
|
|
44
|
+
- save_integration_token:
|
|
45
|
+
- Discord: {"type":"save_integration_token","platform":"discord","token":"..."}
|
|
46
|
+
- Slack: {"type":"save_integration_token","platform":"slack","bot_token":"xoxb-...","app_token":"xapp-..."}
|
|
47
|
+
- Telegram: {"type":"save_integration_token","platform":"telegram","token":"...","allowed_chats":["123"]}
|
|
48
|
+
- Agent team: {"type":"save_integration_token","platform":"multi_agent","enabled":true}
|
|
49
|
+
- present_discovery_summary, present_security_warning, demonstrate_capability: {"type":"<name>", ...}
|
|
50
|
+
- complete_onboarding: {"type":"complete_onboarding","confirmed":true}
|
|
51
|
+
- mark_setup_complete: {"type":"mark_setup_complete"}
|
|
52
|
+
|
|
53
|
+
Allowed update_config keys: discord.enabled, discord.default_channel_id,
|
|
54
|
+
slack.enabled, telegram.allowed_chats,
|
|
55
|
+
telegram.enabled, multi_agent.dangerouslySkipPermissions,
|
|
56
|
+
multi_agent.enabled. Emit related updates in one response; the host saves the batch atomically.
|
|
57
|
+
|
|
58
|
+
write_file accepts IDENTITY.md, USER.md, SOUL.md, or personas/<name>.md. Every path is resolved by
|
|
59
|
+
the host under ~/.mama; never use the process working directory. Tokens inside action tags are
|
|
60
|
+
removed from browser-visible output.`;
|
|
61
|
+
function requiredString(action, key) {
|
|
62
|
+
const value = action[key];
|
|
63
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
64
|
+
throw new Error(`${key} must be a non-empty string`);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
function setConfigValue(config, key, value) {
|
|
69
|
+
if (!CONFIG_KEYS.has(key))
|
|
70
|
+
throw new Error(`Unsupported setup config key: ${key}`);
|
|
71
|
+
const [section, field] = key.split('.');
|
|
72
|
+
const root = config;
|
|
73
|
+
const current = root[section];
|
|
74
|
+
const target = typeof current === 'object' && current !== null
|
|
75
|
+
? current
|
|
76
|
+
: {};
|
|
77
|
+
target[field] = value;
|
|
78
|
+
root[section] = target;
|
|
79
|
+
}
|
|
80
|
+
function replaceConfigContents(target, source) {
|
|
81
|
+
const targetRecord = target;
|
|
82
|
+
for (const key of Object.keys(targetRecord))
|
|
83
|
+
delete targetRecord[key];
|
|
84
|
+
Object.assign(targetRecord, structuredClone(source));
|
|
85
|
+
}
|
|
86
|
+
function validateConfigValue(key, value) {
|
|
87
|
+
if (key.endsWith('.enabled') || key === 'multi_agent.dangerouslySkipPermissions') {
|
|
88
|
+
if (typeof value !== 'boolean')
|
|
89
|
+
throw new Error(`${key} must be boolean`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (key === 'telegram.allowed_chats') {
|
|
93
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
|
|
94
|
+
throw new Error(`${key} must be a string array`);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
99
|
+
throw new Error(`${key} must be a non-empty string`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function resolveSetupFile(mamaHome, name) {
|
|
103
|
+
const normalized = name.replaceAll('\\', '/');
|
|
104
|
+
const allowedRootFile = ['IDENTITY.md', 'USER.md', 'SOUL.md'].includes(normalized);
|
|
105
|
+
const allowedPersona = /^personas\/[A-Za-z0-9_.-]+\.md$/.test(normalized);
|
|
106
|
+
if (!allowedRootFile && !allowedPersona)
|
|
107
|
+
throw new Error('Unsupported setup file name');
|
|
108
|
+
const target = (0, node_path_1.resolve)(mamaHome, normalized);
|
|
109
|
+
const rel = (0, node_path_1.relative)(mamaHome, target);
|
|
110
|
+
if (rel.startsWith('..'))
|
|
111
|
+
throw new Error('Setup file escaped ~/.mama');
|
|
112
|
+
return target;
|
|
113
|
+
}
|
|
114
|
+
function writeSetupFile(mamaHome, name, content) {
|
|
115
|
+
if (Buffer.byteLength(content) > MAX_ACTION_BYTES)
|
|
116
|
+
throw new Error('Setup file exceeds size limit');
|
|
117
|
+
const target = resolveSetupFile(mamaHome, name);
|
|
118
|
+
writeAtomicSetupFile(mamaHome, target, content);
|
|
119
|
+
return target;
|
|
120
|
+
}
|
|
121
|
+
function writeAtomicSetupFile(mamaHome, target, content) {
|
|
122
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(target), { recursive: true });
|
|
123
|
+
const canonicalParent = (0, node_fs_1.realpathSync)((0, node_path_1.dirname)(target));
|
|
124
|
+
if ((0, node_path_1.relative)(mamaHome, canonicalParent).startsWith('..')) {
|
|
125
|
+
throw new Error('Setup file parent escaped ~/.mama');
|
|
126
|
+
}
|
|
127
|
+
if ((0, node_fs_1.existsSync)(target) && (0, node_fs_1.lstatSync)(target).isSymbolicLink()) {
|
|
128
|
+
throw new Error('Setup file target cannot be a symlink');
|
|
129
|
+
}
|
|
130
|
+
const temporary = (0, node_path_1.join)(canonicalParent, `.${(0, node_path_1.basename)(target)}.${(0, node_crypto_1.randomUUID)()}.tmp`);
|
|
131
|
+
try {
|
|
132
|
+
(0, node_fs_1.writeFileSync)(temporary, content, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
133
|
+
(0, node_fs_1.renameSync)(temporary, target);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if ((0, node_fs_1.existsSync)(temporary))
|
|
137
|
+
(0, node_fs_1.unlinkSync)(temporary);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function assertCompletedPersonaFile(mamaHome, file) {
|
|
142
|
+
const path = (0, node_path_1.join)(mamaHome, file);
|
|
143
|
+
if (!(0, node_fs_1.existsSync)(path) || (0, node_fs_1.lstatSync)(path).isSymbolicLink() || !(0, node_fs_1.lstatSync)(path).isFile()) {
|
|
144
|
+
throw new Error(`Cannot complete onboarding before ${file} is written safely`);
|
|
145
|
+
}
|
|
146
|
+
if ((0, node_path_1.relative)(mamaHome, (0, node_fs_1.realpathSync)(path)).startsWith('..')) {
|
|
147
|
+
throw new Error(`Cannot complete onboarding with ${file} outside ~/.mama`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function parseSetupActions(text) {
|
|
151
|
+
const actionPattern = new RegExp(ACTION_PATTERN_SOURCE, 'g');
|
|
152
|
+
const actions = [];
|
|
153
|
+
let match;
|
|
154
|
+
while ((match = actionPattern.exec(text)) !== null) {
|
|
155
|
+
if (actions.length >= MAX_ACTIONS_PER_RESPONSE) {
|
|
156
|
+
throw new Error('Setup response exceeded its action limit');
|
|
157
|
+
}
|
|
158
|
+
if (Buffer.byteLength(match[1]) > MAX_ACTION_BYTES) {
|
|
159
|
+
throw new Error('Setup action exceeded its size limit');
|
|
160
|
+
}
|
|
161
|
+
let parsed;
|
|
162
|
+
try {
|
|
163
|
+
parsed = JSON.parse(match[1]);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
throw new Error('Setup action must contain valid JSON');
|
|
167
|
+
}
|
|
168
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
169
|
+
throw new Error('Setup action must be a JSON object');
|
|
170
|
+
}
|
|
171
|
+
actions.push(parsed);
|
|
172
|
+
}
|
|
173
|
+
const visibleText = text.replace(new RegExp(ACTION_PATTERN_SOURCE, 'g'), '').trim();
|
|
174
|
+
if (LEGACY_ACTION_PATTERN.test(visibleText)) {
|
|
175
|
+
throw new Error('Setup response used unsupported legacy action syntax');
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
visibleText,
|
|
179
|
+
actions,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function createSetupActionExecutor(options = {}) {
|
|
183
|
+
const loadConfig = options.loadConfig ?? config_manager_js_1.getConfig;
|
|
184
|
+
const persistConfig = options.persistConfig ?? config_manager_js_1.saveConfig;
|
|
185
|
+
const mamaHome = (0, node_path_1.resolve)(options.mamaHome ?? (0, config_manager_js_1.expandPath)('~/.mama'));
|
|
186
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
187
|
+
const now = options.now ?? (() => new Date());
|
|
188
|
+
(0, node_fs_1.mkdirSync)(mamaHome, { recursive: true });
|
|
189
|
+
const canonicalMamaHome = (0, node_fs_1.realpathSync)(mamaHome);
|
|
190
|
+
const validateDiscordToken = async (token) => {
|
|
191
|
+
const response = await fetchImpl('https://discord.com/api/v10/users/@me', {
|
|
192
|
+
headers: { Authorization: `Bot ${token}` },
|
|
193
|
+
signal: AbortSignal.timeout(10_000),
|
|
194
|
+
});
|
|
195
|
+
if (!response.ok)
|
|
196
|
+
return { valid: false };
|
|
197
|
+
const body = (await response.json());
|
|
198
|
+
return { valid: true, clientId: typeof body.id === 'string' ? body.id : undefined };
|
|
199
|
+
};
|
|
200
|
+
const validateSlackTokens = async (botToken, appToken) => {
|
|
201
|
+
const botResponse = await fetchImpl('https://slack.com/api/auth.test', {
|
|
202
|
+
method: 'POST',
|
|
203
|
+
headers: { Authorization: `Bearer ${botToken}` },
|
|
204
|
+
signal: AbortSignal.timeout(10_000),
|
|
205
|
+
});
|
|
206
|
+
if (!botResponse.ok || (await botResponse.json()).ok !== true) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
const appResponse = await fetchImpl('https://slack.com/api/apps.connections.open', {
|
|
210
|
+
method: 'POST',
|
|
211
|
+
headers: { Authorization: `Bearer ${appToken}` },
|
|
212
|
+
signal: AbortSignal.timeout(10_000),
|
|
213
|
+
});
|
|
214
|
+
return appResponse.ok && (await appResponse.json()).ok === true;
|
|
215
|
+
};
|
|
216
|
+
const validateTelegramToken = async (token) => {
|
|
217
|
+
const response = await fetchImpl(`https://api.telegram.org/bot${token}/getMe`, {
|
|
218
|
+
signal: AbortSignal.timeout(10_000),
|
|
219
|
+
});
|
|
220
|
+
return response.ok && (await response.json()).ok === true;
|
|
221
|
+
};
|
|
222
|
+
const executeOne = async (action, workingConfig, markConfigDirty) => {
|
|
223
|
+
let type = 'unknown';
|
|
224
|
+
try {
|
|
225
|
+
type = requiredString(action, 'type');
|
|
226
|
+
if (type === 'update_config') {
|
|
227
|
+
const key = requiredString(action, 'key');
|
|
228
|
+
if (!GENERIC_UPDATE_CONFIG_KEYS.has(key)) {
|
|
229
|
+
throw new Error(`Unsupported setup config key: ${key}`);
|
|
230
|
+
}
|
|
231
|
+
validateConfigValue(key, action.value);
|
|
232
|
+
setConfigValue(workingConfig, key, action.value);
|
|
233
|
+
markConfigDirty();
|
|
234
|
+
return { type, ok: true, data: { key } };
|
|
235
|
+
}
|
|
236
|
+
if (type === 'validate_discord_token') {
|
|
237
|
+
const token = requiredString(action, 'token');
|
|
238
|
+
const validation = await validateDiscordToken(token);
|
|
239
|
+
return {
|
|
240
|
+
type,
|
|
241
|
+
ok: true,
|
|
242
|
+
data: { valid: validation.valid, client_id: validation.clientId },
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (type === 'write_file') {
|
|
246
|
+
const name = requiredString(action, 'name');
|
|
247
|
+
const content = requiredString(action, 'content');
|
|
248
|
+
const path = writeSetupFile(canonicalMamaHome, name, content);
|
|
249
|
+
return { type, ok: true, data: { file: (0, node_path_1.basename)(path) } };
|
|
250
|
+
}
|
|
251
|
+
if (type === 'save_integration_token') {
|
|
252
|
+
const platform = requiredString(action, 'platform');
|
|
253
|
+
if (platform === 'discord') {
|
|
254
|
+
const token = requiredString(action, 'token');
|
|
255
|
+
const validation = await validateDiscordToken(token);
|
|
256
|
+
if (!validation.valid)
|
|
257
|
+
throw new Error('Discord token validation failed');
|
|
258
|
+
setConfigValue(workingConfig, 'discord.token', token);
|
|
259
|
+
setConfigValue(workingConfig, 'discord.enabled', true);
|
|
260
|
+
}
|
|
261
|
+
else if (platform === 'slack') {
|
|
262
|
+
const botToken = requiredString(action, 'bot_token');
|
|
263
|
+
const appToken = requiredString(action, 'app_token');
|
|
264
|
+
if (!(await validateSlackTokens(botToken, appToken))) {
|
|
265
|
+
throw new Error('Slack token validation failed');
|
|
266
|
+
}
|
|
267
|
+
setConfigValue(workingConfig, 'slack.bot_token', botToken);
|
|
268
|
+
setConfigValue(workingConfig, 'slack.app_token', appToken);
|
|
269
|
+
setConfigValue(workingConfig, 'slack.enabled', true);
|
|
270
|
+
}
|
|
271
|
+
else if (platform === 'telegram') {
|
|
272
|
+
const token = requiredString(action, 'token');
|
|
273
|
+
if (!(await validateTelegramToken(token))) {
|
|
274
|
+
throw new Error('Telegram token validation failed');
|
|
275
|
+
}
|
|
276
|
+
setConfigValue(workingConfig, 'telegram.token', token);
|
|
277
|
+
const allowedChats = action.allowed_chats;
|
|
278
|
+
if (allowedChats !== undefined &&
|
|
279
|
+
(!Array.isArray(allowedChats) || allowedChats.some((item) => typeof item !== 'string'))) {
|
|
280
|
+
throw new Error('allowed_chats must be a string array');
|
|
281
|
+
}
|
|
282
|
+
if (allowedChats)
|
|
283
|
+
setConfigValue(workingConfig, 'telegram.allowed_chats', allowedChats);
|
|
284
|
+
setConfigValue(workingConfig, 'telegram.enabled', true);
|
|
285
|
+
}
|
|
286
|
+
else if (platform === 'multi_agent') {
|
|
287
|
+
if (typeof action.enabled !== 'boolean')
|
|
288
|
+
throw new Error('enabled must be boolean');
|
|
289
|
+
setConfigValue(workingConfig, 'multi_agent.enabled', action.enabled);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
throw new Error(`Unsupported integration platform: ${platform}`);
|
|
293
|
+
}
|
|
294
|
+
markConfigDirty();
|
|
295
|
+
return { type, ok: true, data: { platform } };
|
|
296
|
+
}
|
|
297
|
+
if (type === 'present_discovery_summary' ||
|
|
298
|
+
type === 'present_security_warning' ||
|
|
299
|
+
type === 'demonstrate_capability') {
|
|
300
|
+
return { type, ok: true };
|
|
301
|
+
}
|
|
302
|
+
if (type === 'complete_onboarding') {
|
|
303
|
+
if (action.confirmed !== true)
|
|
304
|
+
throw new Error('Onboarding must be confirmed');
|
|
305
|
+
for (const file of ['IDENTITY.md', 'USER.md', 'SOUL.md']) {
|
|
306
|
+
assertCompletedPersonaFile(canonicalMamaHome, file);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
else if (type !== 'mark_setup_complete') {
|
|
310
|
+
throw new Error(`Unsupported setup action: ${type}`);
|
|
311
|
+
}
|
|
312
|
+
writeAtomicSetupFile(canonicalMamaHome, (0, node_path_1.join)(canonicalMamaHome, 'setup-complete.json'), `${JSON.stringify({ completed_at: now().toISOString() })}\n`);
|
|
313
|
+
return { type, ok: true, data: { completed: true } };
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
return {
|
|
317
|
+
type,
|
|
318
|
+
ok: false,
|
|
319
|
+
error: error instanceof Error ? error.message : String(error),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const executor = {
|
|
324
|
+
async execute(action) {
|
|
325
|
+
return (await executor.executeBatch([action]))[0];
|
|
326
|
+
},
|
|
327
|
+
async executeBatch(actions) {
|
|
328
|
+
const sharedConfig = loadConfig();
|
|
329
|
+
const workingConfig = structuredClone(sharedConfig);
|
|
330
|
+
let configDirty = false;
|
|
331
|
+
const results = [];
|
|
332
|
+
for (const action of actions) {
|
|
333
|
+
const result = await executeOne(action, workingConfig, () => {
|
|
334
|
+
configDirty = true;
|
|
335
|
+
});
|
|
336
|
+
results.push(result);
|
|
337
|
+
if (!result.ok) {
|
|
338
|
+
return results.map((prior) => configDirty &&
|
|
339
|
+
prior.ok &&
|
|
340
|
+
(prior.type === 'update_config' || prior.type === 'save_integration_token')
|
|
341
|
+
? {
|
|
342
|
+
...prior,
|
|
343
|
+
ok: false,
|
|
344
|
+
data: { ...prior.data, rolled_back: true },
|
|
345
|
+
error: 'Config batch was rolled back because a later action failed',
|
|
346
|
+
}
|
|
347
|
+
: prior);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (configDirty) {
|
|
351
|
+
try {
|
|
352
|
+
await persistConfig(workingConfig);
|
|
353
|
+
replaceConfigContents(sharedConfig, workingConfig);
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
return results.map((result) => result.ok &&
|
|
357
|
+
(result.type === 'update_config' || result.type === 'save_integration_token')
|
|
358
|
+
? {
|
|
359
|
+
...result,
|
|
360
|
+
ok: false,
|
|
361
|
+
error: error instanceof Error ? error.message : String(error),
|
|
362
|
+
}
|
|
363
|
+
: result);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return results;
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
return executor;
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=setup-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-actions.js","sourceRoot":"","sources":["../../src/setup/setup-actions.ts"],"names":[],"mappings":";;;AA8LA,8CA8BC;AAED,8DA0MC;AAxaD,qCAQiB;AACjB,6CAAyC;AACzC,yCAAuE;AAGvE,uEAAoF;AAEpF,MAAM,qBAAqB,GAAG,qDAAqD,CAAC;AACpF,MAAM,qBAAqB,GACzB,qJAAqJ,CAAC;AACxJ,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACjC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,eAAe;IACf,iBAAiB;IACjB,4BAA4B;IAC5B,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,wBAAwB;IACxB,kBAAkB;IAClB,wCAAwC;IACxC,qBAAqB;CACtB,CAAC,CAAC;AACH,MAAM,0BAA0B,GAAG,IAAI,GAAG,CACxC,CAAC,GAAG,WAAW,CAAC,CAAC,MAAM,CACrB,CAAC,GAAG,EAAE,EAAE,CACN,CAAC,CAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAC3F,CACF,CAAC;AAEW,QAAA,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,KAAK,CAAC;yBAC9D;wBACH,CAAC,CAAC,MAAM,CACX,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SETUP_SYSTEM_PROMPT = "You are MAMA Setup Assistant. Help users configure MAMA Standalone step by step.\n\n## Your Role\n\nGuide users through setting up MAMA Standalone by:\n1. Understanding what platform they want to use (Discord, Slack, etc.)\n2. Walking them through creating bots on those platforms\n3. Collecting tokens/credentials\n4. Validating and saving configuration\n5. Confirming setup is complete\n\n## Available Tools\n\nYou have these tools to configure MAMA:\n\n**update_config**: Update config.yaml settings\n- Use this when you have validated a token or credential\n- Parameters: key (string), value (any)\n\n**validate_discord_token**: Check if a Discord bot token is valid\n- Use this before saving a Discord token\n- Parameters: token (string)\n- Returns: { valid: boolean, client_id?: string }\n\n**mark_setup_complete**: Signal that setup is finished\n- Use this only when all required configuration is done\n- No parameters\n\n## Setup Flow\n\n### Discord Setup\n\n1. Ask if they want to set up Discord bot\n2. Guide them:\n - Go to https://discord.com/developers/applications\n - Click \"New Application\"\n - Give it a name (e.g., \"MAMA Bot\")\n - Go to \"Bot\" tab\n - Click \"Reset Token\" and copy it\n3. Ask them to paste the token\n4. Validate the token using validate_discord_token\n5. If valid, save it:\n ```\n
|
|
1
|
+
export declare const SETUP_SYSTEM_PROMPT = "You are MAMA Setup Assistant. Help users configure MAMA Standalone step by step.\n\n## Your Role\n\nGuide users through setting up MAMA Standalone by:\n1. Understanding what platform they want to use (Discord, Slack, etc.)\n2. Walking them through creating bots on those platforms\n3. Collecting tokens/credentials\n4. Validating and saving configuration\n5. Confirming setup is complete\n\n## Available Tools\n\nYou have these tools to configure MAMA:\n\n**update_config**: Update config.yaml settings through the MAMA setup host-action protocol\n- Use this when you have validated a token or credential\n- Parameters: key (string), value (any)\n\n**validate_discord_token**: Check if a Discord bot token is valid through the host-action protocol\n- Use this before saving a Discord token\n- Parameters: token (string)\n- Returns: { valid: boolean, client_id?: string }\n\n**mark_setup_complete**: Signal that setup is finished through the host-action protocol\n- Use this only when all required configuration is done\n- No parameters\n\n## Setup Flow\n\n### Discord Setup\n\n1. Ask if they want to set up Discord bot\n2. Guide them:\n - Go to https://discord.com/developers/applications\n - Click \"New Application\"\n - Give it a name (e.g., \"MAMA Bot\")\n - Go to \"Bot\" tab\n - Click \"Reset Token\" and copy it\n3. Ask them to paste the token\n4. Validate the token using a tagged `validate_discord_token` host action and wait for its trusted result\n5. If valid, save it:\n ```\n <mama_setup_action>{\"type\":\"save_integration_token\",\"platform\":\"discord\",\"token\":\"DISCORD_BOT_TOKEN\"}</mama_setup_action>\n ```\n6. Generate invite link: https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=8&scope=bot\n7. Ask them to invite the bot to their server\n8. Ask for the channel ID where they want MAMA to respond\n9. Save channel ID:\n ```\n <mama_setup_action>{\"type\":\"update_config\",\"key\":\"discord.default_channel_id\",\"value\":\"CHANNEL_ID_HERE\"}</mama_setup_action>\n ```\n\n### Slack Setup\n\n1. Ask if they want to set up Slack bot\n2. Guide them:\n - Go to https://api.slack.com/apps\n - Click \"Create New App\" \u2192 \"From scratch\"\n - Give it a name and select workspace\n - Go to \"OAuth & Permissions\"\n - Add scopes: chat:write, channels:history, groups:history\n - Install to workspace\n - Copy Bot User OAuth Token\n - Copy App-Level Token\n3. Save tokens:\n ```\n <mama_setup_action>{\"type\":\"save_integration_token\",\"platform\":\"slack\",\"bot_token\":\"xoxb-...\",\"app_token\":\"xapp-...\"}</mama_setup_action>\n ```\n\n### Agent Backend Setup\n\nThe wizard runs on the backend that was already authenticated and selected before it started.\nDo not mutate `agent.backend` or `agent.model` here. To change providers, tell the user to finish\nthis setup, authenticate the target CLI, and run `mama init --force --backend claude|codex|cline`.\n\n### Security & Permission Settings\n\nAsk users about agent permission settings:\n\n**Agent Autonomy (dangerouslySkipPermissions)**\n\nThis controls whether agents can execute tools (file writes, bash commands, git operations) without asking for permission.\n\n**Options:**\n- **true** (default): Agents run autonomously without approval prompts. Required for headless/daemon operation.\n- **false**: Agents ask for permission before executing each tool.\n\n\u26A0\uFE0F **Warning**: Setting this to `true` gives agents full system access. Only enable in trusted environments.\n\nTo configure:\n```\n<mama_setup_action>{\"type\":\"update_config\",\"key\":\"multi_agent.dangerouslySkipPermissions\",\"value\":true}</mama_setup_action>\n```\n\n**IMPORTANT**: This setting also requires `MAMA_TRUSTED_ENV=true` environment variable.\n- For systemd service: Add `Environment=MAMA_TRUSTED_ENV=true` to the service file\n- For manual start: Run with `MAMA_TRUSTED_ENV=true mama start`\n\nIf they want autonomous agents, save the config and remind them about the environment variable.\n\n### Completion\n\nAfter setup is done:\n1. Summarize what was configured\n2. Tell them to run: mama start\n3. Explain how to use MAMA (mention bot in Discord/Slack)\n4. Emit `<mama_setup_action>{\"type\":\"mark_setup_complete\"}</mama_setup_action>` and wait for its trusted result\n\n## Important Rules\n\n- Be friendly and encouraging\n- Provide clickable links\n- Ask for one thing at a time\n- Validate inputs before saving\n- Explain each step clearly\n- If they make a mistake, help them fix it\n- If token is invalid, ask them to double-check and try again\n- Never save invalid credentials\n\n## Example Interaction\n\nUser: \"I want to set up Discord\"\n\nYou: \"Great! Let's set up a Discord bot for MAMA. \n\nFirst, you'll need to create a Discord application:\n1. Go to https://discord.com/developers/applications\n2. Click 'New Application'\n3. Give it a name like 'MAMA Bot'\n4. Go to the 'Bot' tab\n5. Click 'Reset Token' and copy the token\n\nOnce you have the token, paste it here.\"\n\nUser: \"DISCORD_BOT_TOKEN\"\n\nYou: <mama_setup_action>{\"type\":\"save_integration_token\",\"platform\":\"discord\",\"token\":\"DISCORD_BOT_TOKEN\"}</mama_setup_action>\n\nHost: Trusted MAMA setup host action results: [{\"type\":\"save_integration_token\",\"ok\":true,\"data\":{\"platform\":\"discord\"}}]\n\nYou: \"\u2713 Token is valid and the host saved it to your configuration.\n\nNow let's invite the bot to your server:\nhttps://discord.com/oauth2/authorize?client_id=YOUR_BOT_CLIENT_ID&permissions=8&scope=bot\n\nClick that link and select your server. After that, tell me the channel ID where you want MAMA to respond.\"\n\nUser: \"1234567890123456789\"\n\nYou: <mama_setup_action>{\"type\":\"update_config\",\"key\":\"discord.default_channel_id\",\"value\":\"1234567890123456789\"}</mama_setup_action>\n\nHost: Trusted MAMA setup host action results: [{\"type\":\"update_config\",\"ok\":true,\"data\":{\"key\":\"discord.default_channel_id\"}}]\n\nYou: <mama_setup_action>{\"type\":\"mark_setup_complete\"}</mama_setup_action>\n\nHost: Trusted MAMA setup host action results: [{\"type\":\"mark_setup_complete\",\"ok\":true,\"data\":{\"completed\":true}}]\n\nYou: \"Perfect! Your Discord bot is now configured.\n\nTo start MAMA, run:\n`mama start`\n\nThen go to Discord and mention @MAMA to start chatting!\"\n\n## Tone\n\n- Friendly but professional\n- Match the user's language (will be specified in system prompt)\n- Use emojis sparingly (\u2713, \uD83C\uDF89 for success moments)\n- Keep responses concise but complete\n";
|
|
2
2
|
//# sourceMappingURL=setup-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-prompt.d.ts","sourceRoot":"","sources":["../../src/setup/setup-prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"setup-prompt.d.ts","sourceRoot":"","sources":["../../src/setup/setup-prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,+6MA2K/B,CAAC"}
|
|
@@ -16,16 +16,16 @@ Guide users through setting up MAMA Standalone by:
|
|
|
16
16
|
|
|
17
17
|
You have these tools to configure MAMA:
|
|
18
18
|
|
|
19
|
-
**update_config**: Update config.yaml settings
|
|
19
|
+
**update_config**: Update config.yaml settings through the MAMA setup host-action protocol
|
|
20
20
|
- Use this when you have validated a token or credential
|
|
21
21
|
- Parameters: key (string), value (any)
|
|
22
22
|
|
|
23
|
-
**validate_discord_token**: Check if a Discord bot token is valid
|
|
23
|
+
**validate_discord_token**: Check if a Discord bot token is valid through the host-action protocol
|
|
24
24
|
- Use this before saving a Discord token
|
|
25
25
|
- Parameters: token (string)
|
|
26
26
|
- Returns: { valid: boolean, client_id?: string }
|
|
27
27
|
|
|
28
|
-
**mark_setup_complete**: Signal that setup is finished
|
|
28
|
+
**mark_setup_complete**: Signal that setup is finished through the host-action protocol
|
|
29
29
|
- Use this only when all required configuration is done
|
|
30
30
|
- No parameters
|
|
31
31
|
|
|
@@ -41,18 +41,17 @@ You have these tools to configure MAMA:
|
|
|
41
41
|
- Go to "Bot" tab
|
|
42
42
|
- Click "Reset Token" and copy it
|
|
43
43
|
3. Ask them to paste the token
|
|
44
|
-
4. Validate the token using validate_discord_token
|
|
44
|
+
4. Validate the token using a tagged \`validate_discord_token\` host action and wait for its trusted result
|
|
45
45
|
5. If valid, save it:
|
|
46
46
|
\`\`\`
|
|
47
|
-
|
|
48
|
-
update_config("discord.enabled", true)
|
|
47
|
+
<mama_setup_action>{"type":"save_integration_token","platform":"discord","token":"DISCORD_BOT_TOKEN"}</mama_setup_action>
|
|
49
48
|
\`\`\`
|
|
50
49
|
6. Generate invite link: https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=8&scope=bot
|
|
51
50
|
7. Ask them to invite the bot to their server
|
|
52
51
|
8. Ask for the channel ID where they want MAMA to respond
|
|
53
52
|
9. Save channel ID:
|
|
54
53
|
\`\`\`
|
|
55
|
-
update_config
|
|
54
|
+
<mama_setup_action>{"type":"update_config","key":"discord.default_channel_id","value":"CHANNEL_ID_HERE"}</mama_setup_action>
|
|
56
55
|
\`\`\`
|
|
57
56
|
|
|
58
57
|
### Slack Setup
|
|
@@ -69,28 +68,14 @@ You have these tools to configure MAMA:
|
|
|
69
68
|
- Copy App-Level Token
|
|
70
69
|
3. Save tokens:
|
|
71
70
|
\`\`\`
|
|
72
|
-
|
|
73
|
-
update_config("slack.app_token", "xapp-...")
|
|
74
|
-
update_config("slack.enabled", true)
|
|
71
|
+
<mama_setup_action>{"type":"save_integration_token","platform":"slack","bot_token":"xoxb-...","app_token":"xapp-..."}</mama_setup_action>
|
|
75
72
|
\`\`\`
|
|
76
73
|
|
|
77
74
|
### Agent Backend Setup
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- **claude** (default): Uses Claude CLI. Requires Claude Code subscription.
|
|
83
|
-
- **codex**: Uses OpenAI Codex app-server. Requires a Codex subscription and codex login.
|
|
84
|
-
|
|
85
|
-
To configure:
|
|
86
|
-
\`\`\`
|
|
87
|
-
update_config("agent.backend", "claude") // or "codex"
|
|
88
|
-
update_config("agent.model", "claude-sonnet-4-6") // for claude
|
|
89
|
-
update_config("agent.model", "gpt-5.4") // for codex
|
|
90
|
-
\`\`\`
|
|
91
|
-
|
|
92
|
-
**Important:**
|
|
93
|
-
- If using \`codex\`, authenticate first with \`codex login\`; MAMA manages its isolated runtime home.
|
|
76
|
+
The wizard runs on the backend that was already authenticated and selected before it started.
|
|
77
|
+
Do not mutate \`agent.backend\` or \`agent.model\` here. To change providers, tell the user to finish
|
|
78
|
+
this setup, authenticate the target CLI, and run \`mama init --force --backend claude|codex|cline\`.
|
|
94
79
|
|
|
95
80
|
### Security & Permission Settings
|
|
96
81
|
|
|
@@ -108,7 +93,7 @@ This controls whether agents can execute tools (file writes, bash commands, git
|
|
|
108
93
|
|
|
109
94
|
To configure:
|
|
110
95
|
\`\`\`
|
|
111
|
-
update_config
|
|
96
|
+
<mama_setup_action>{"type":"update_config","key":"multi_agent.dangerouslySkipPermissions","value":true}</mama_setup_action>
|
|
112
97
|
\`\`\`
|
|
113
98
|
|
|
114
99
|
**IMPORTANT**: This setting also requires \`MAMA_TRUSTED_ENV=true\` environment variable.
|
|
@@ -123,7 +108,7 @@ After setup is done:
|
|
|
123
108
|
1. Summarize what was configured
|
|
124
109
|
2. Tell them to run: mama start
|
|
125
110
|
3. Explain how to use MAMA (mention bot in Discord/Slack)
|
|
126
|
-
4.
|
|
111
|
+
4. Emit \`<mama_setup_action>{"type":"mark_setup_complete"}</mama_setup_action>\` and wait for its trusted result
|
|
127
112
|
|
|
128
113
|
## Important Rules
|
|
129
114
|
|
|
@@ -151,9 +136,13 @@ First, you'll need to create a Discord application:
|
|
|
151
136
|
|
|
152
137
|
Once you have the token, paste it here."
|
|
153
138
|
|
|
154
|
-
User: "
|
|
139
|
+
User: "DISCORD_BOT_TOKEN"
|
|
155
140
|
|
|
156
|
-
You:
|
|
141
|
+
You: <mama_setup_action>{"type":"save_integration_token","platform":"discord","token":"DISCORD_BOT_TOKEN"}</mama_setup_action>
|
|
142
|
+
|
|
143
|
+
Host: Trusted MAMA setup host action results: [{"type":"save_integration_token","ok":true,"data":{"platform":"discord"}}]
|
|
144
|
+
|
|
145
|
+
You: "✓ Token is valid and the host saved it to your configuration.
|
|
157
146
|
|
|
158
147
|
Now let's invite the bot to your server:
|
|
159
148
|
https://discord.com/oauth2/authorize?client_id=YOUR_BOT_CLIENT_ID&permissions=8&scope=bot
|
|
@@ -162,14 +151,20 @@ Click that link and select your server. After that, tell me the channel ID where
|
|
|
162
151
|
|
|
163
152
|
User: "1234567890123456789"
|
|
164
153
|
|
|
165
|
-
You:
|
|
154
|
+
You: <mama_setup_action>{"type":"update_config","key":"discord.default_channel_id","value":"1234567890123456789"}</mama_setup_action>
|
|
155
|
+
|
|
156
|
+
Host: Trusted MAMA setup host action results: [{"type":"update_config","ok":true,"data":{"key":"discord.default_channel_id"}}]
|
|
157
|
+
|
|
158
|
+
You: <mama_setup_action>{"type":"mark_setup_complete"}</mama_setup_action>
|
|
159
|
+
|
|
160
|
+
Host: Trusted MAMA setup host action results: [{"type":"mark_setup_complete","ok":true,"data":{"completed":true}}]
|
|
161
|
+
|
|
162
|
+
You: "Perfect! Your Discord bot is now configured.
|
|
166
163
|
|
|
167
164
|
To start MAMA, run:
|
|
168
165
|
\`mama start\`
|
|
169
166
|
|
|
170
|
-
Then go to Discord and mention @MAMA to start chatting!
|
|
171
|
-
|
|
172
|
-
[mark_setup_complete]"
|
|
167
|
+
Then go to Discord and mention @MAMA to start chatting!"
|
|
173
168
|
|
|
174
169
|
## Tone
|
|
175
170
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-prompt.js","sourceRoot":"","sources":["../../src/setup/setup-prompt.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"setup-prompt.js","sourceRoot":"","sources":["../../src/setup/setup-prompt.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2KlC,CAAC"}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* Setup Server - HTTP + WebSocket server for interactive setup wizard
|
|
3
3
|
*/
|
|
4
4
|
export interface SetupServer {
|
|
5
|
-
close: (
|
|
5
|
+
close: () => Promise<void>;
|
|
6
6
|
}
|
|
7
|
+
export interface SetupNonceStore {
|
|
8
|
+
issue(): string | null;
|
|
9
|
+
consume(candidate: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function createSetupNonceStore(now?: () => number): SetupNonceStore;
|
|
7
12
|
export declare function startSetupServer(port?: number): Promise<SetupServer>;
|
|
8
13
|
//# sourceMappingURL=setup-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-server.d.ts","sourceRoot":"","sources":["../../src/setup/setup-server.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"setup-server.d.ts","sourceRoot":"","sources":["../../src/setup/setup-server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAKD,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CACrC;AAED,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,MAAiB,GAAG,eAAe,CAuBnF;AAED,wBAAsB,gBAAgB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CA+GhF"}
|