@openlife/cli 1.7.13 → 1.8.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.
Files changed (35) hide show
  1. package/INSTALL.md +29 -1
  2. package/dist/cli/ChatTui.js +32 -0
  3. package/dist/cli/InstallModules.js +17 -2
  4. package/dist/cli/InstallWizardV2.js +110 -0
  5. package/dist/cli/install/Multiselect.js +285 -0
  6. package/dist/cli/install/OAuthRunner.js +170 -0
  7. package/dist/cli/install/Phases.js +864 -0
  8. package/dist/cli/install/ProvidersCatalog.js +320 -0
  9. package/dist/cli/install/WizardIO.js +271 -0
  10. package/dist/cli/install/types.js +17 -0
  11. package/dist/index.js +170 -35
  12. package/dist/orchestrator/ConsequenceForecaster.js +24 -1
  13. package/dist/orchestrator/DreamGoalStore.js +130 -0
  14. package/dist/orchestrator/Gatekeeper.js +14 -0
  15. package/dist/orchestrator/Gateway.js +194 -15
  16. package/dist/orchestrator/ModelManager.js +7 -1
  17. package/dist/orchestrator/OrchestrationLoop.js +12 -0
  18. package/dist/orchestrator/ParallelOrchestrationLoop.js +12 -2
  19. package/dist/orchestrator/RuntimePolicy.js +4 -1
  20. package/dist/orchestrator/ServiceCompletionPolicy.js +15 -0
  21. package/dist/orchestrator/SynthesizerAgent.js +20 -1
  22. package/dist/orchestrator/TaskExecutor.js +53 -0
  23. package/dist/orchestrator/capability/CapabilityGenesisEngine.js +66 -11
  24. package/dist/test_capability_genesis_engine.js +1 -1
  25. package/dist/test_chat_smoke_command.js +59 -0
  26. package/dist/test_dream_goal_commands.js +76 -0
  27. package/dist/test_gateway_telegram_formatting.js +74 -0
  28. package/dist/test_install_wizard_v2.js +193 -0
  29. package/dist/test_on_demand_voice_reply.js +65 -0
  30. package/dist/test_remaining_sprints_contracts.js +103 -0
  31. package/dist/test_runtime_policy.js +25 -6
  32. package/dist/test_service_completion_policy.js +7 -0
  33. package/dist/test_subsystems_routing_governance.js +13 -3
  34. package/dist/test_task_executor_gemini_api.js +68 -0
  35. package/package.json +5 -3
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const child_process = __importStar(require("child_process"));
38
+ const path = __importStar(require("path"));
39
+ const InstallModules_1 = require("./cli/InstallModules");
40
+ function runCli(args) {
41
+ return child_process.spawnSync(process.execPath, [path.join(__dirname, 'index.js'), ...args], {
42
+ cwd: path.join(__dirname, '..'),
43
+ encoding: 'utf-8',
44
+ env: { ...process.env, OPENLIFE_DISABLE_CHAT_TUI: '1' },
45
+ timeout: 5000,
46
+ });
47
+ }
48
+ function main() {
49
+ const cli = runCli(['chat', '--test']);
50
+ assert.strictEqual(cli.status, 0, `chat --test should exit 0, stderr=${cli.stderr}, stdout=${cli.stdout}`);
51
+ assert.match(cli.stdout, /OPENLIFE_CHAT_SMOKE_OK/, 'chat --test should print stable smoke marker');
52
+ assert.match(cli.stdout, /sessionId=/, 'chat --test should surface session context');
53
+ assert.match(cli.stdout, /model=/, 'chat --test should surface active model context');
54
+ const smoke = (0, InstallModules_1.chatSmoke)(path.join(__dirname, '..'));
55
+ assert.strictEqual(smoke.ok, true, smoke.detail);
56
+ assert.match(smoke.detail, /OPENLIFE_CHAT_SMOKE_OK/, 'installer chatSmoke should call the real chat test path');
57
+ console.log('TEST_CHAT_SMOKE_COMMAND_OK');
58
+ }
59
+ main();
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const fs = __importStar(require("fs"));
38
+ const os = __importStar(require("os"));
39
+ const path = __importStar(require("path"));
40
+ const DreamGoalStore_1 = require("./orchestrator/DreamGoalStore");
41
+ const Gateway_1 = require("./orchestrator/Gateway");
42
+ async function main() {
43
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openlife-dream-goal-'));
44
+ process.env.OPENLIFE_STATE_DIR = path.join(root, '.openlife');
45
+ process.env.OPENLIFE_TELEGRAM_ALLOWED_USER_ID = '';
46
+ process.env.OPENLIFE_TTS_ENABLED = 'off';
47
+ const store = new DreamGoalStore_1.DreamGoalStore(process.env.OPENLIFE_STATE_DIR);
48
+ const dream = store.setDream('Construir o OpenLife como sistema operacional de agentes autônomos.');
49
+ assert.equal(dream.kind, 'dream');
50
+ assert.ok(dream.value.includes('sistema operacional'));
51
+ assert.ok(fs.existsSync(path.join(process.env.OPENLIFE_STATE_DIR, 'dream-goal.json')));
52
+ const goal = store.setGoal('Implementar /dream e /goal no Telegram.');
53
+ assert.equal(goal.kind, 'goal');
54
+ assert.ok(goal.value.includes('/dream'));
55
+ const summary = store.summary();
56
+ assert.ok(summary.includes('Dream atual'));
57
+ assert.ok(summary.includes('Goal atual'));
58
+ const gateway = new Gateway_1.Gateway();
59
+ const dreamResp = await gateway.processTextForTest('1344110010', '/dream Criar um AIOBUILDER que transforma sonhos em planos executáveis.');
60
+ assert.match(dreamResp, /Dream registrado/i);
61
+ assert.match(dreamResp, /AIOBUILDER/);
62
+ const goalResp = await gateway.processTextForTest('1344110010', '/goal Entregar comandos slash persistentes no OpenLife.');
63
+ assert.match(goalResp, /Goal registrado/i);
64
+ assert.match(goalResp, /comandos slash/);
65
+ const statusResp = await gateway.processTextForTest('1344110010', '/goal');
66
+ assert.match(statusResp, /Goal atual/i);
67
+ assert.match(statusResp, /comandos slash/);
68
+ const dreamStatus = await gateway.processTextForTest('1344110010', '/dream');
69
+ assert.match(dreamStatus, /Dream atual/i);
70
+ assert.match(dreamStatus, /AIOBUILDER/);
71
+ console.log('DREAM_GOAL_COMMANDS_OK');
72
+ }
73
+ main().catch((err) => {
74
+ console.error(err);
75
+ process.exit(1);
76
+ });
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const Gateway_1 = require("./orchestrator/Gateway");
38
+ async function main() {
39
+ process.env.OPENLIFE_TELEGRAM_ALLOWED_USER_ID = '';
40
+ process.env.OPENLIFE_ENABLE_TTS = 'false';
41
+ process.env.OPENLIFE_REASONING_MODE = 'off';
42
+ const gateway = new Gateway_1.Gateway();
43
+ gateway.classifier = {
44
+ classify: async (_text) => ({ intent: 'KNOWLEDGE_RETRIEVAL', budget: 0.1 })
45
+ };
46
+ gateway.gatekeeper = {
47
+ routeTask: async (_task, _text, _userId) => [
48
+ '### Síntese para Operação',
49
+ '',
50
+ '| Comando | Foco Principal | Quando usar |',
51
+ '| :--- | :--- | :--- |',
52
+ '| `/goal` | Execução (O quê) | Para tarefas práticas, correções de bugs ou implementação de recursos definidos. |',
53
+ '| `/dream` | Visão (Como) | Para buscar arquiteturas otimizadas, sugestões de design ou refatorações complexas. |',
54
+ '',
55
+ '---'
56
+ ].join('\n')
57
+ };
58
+ const result = await gateway.processTextForTestDetailed('1344110010', 'compare /goal e /dream');
59
+ const finalText = result.finalText;
60
+ assert.ok(!finalText.includes('| Comando |'), `SHOULD_NOT_LEAK_TABLE_HEADER_${finalText}`);
61
+ assert.ok(!/^\s*\|\s*:?-{3,}/m.test(finalText), `SHOULD_NOT_LEAK_SEPARATOR_${finalText}`);
62
+ assert.ok(!finalText.includes('###'), `SHOULD_NOT_LEAK_MARKDOWN_HEADING_${finalText}`);
63
+ assert.ok(!/^\s*---\s*$/m.test(finalText), `SHOULD_NOT_LEAK_HORIZONTAL_RULE_${finalText}`);
64
+ assert.ok(finalText.includes('Síntese para Operação'), `SHOULD_KEEP_HEADING_TEXT_${finalText}`);
65
+ assert.ok(finalText.includes('• /goal'), `SHOULD_CONVERT_GOAL_ROW_TO_BULLET_${finalText}`);
66
+ assert.ok(finalText.includes('Foco Principal: Execução (O quê)'), `SHOULD_LABEL_GOAL_FOCUS_${finalText}`);
67
+ assert.ok(finalText.includes('Quando usar: Para tarefas práticas'), `SHOULD_LABEL_GOAL_WHEN_${finalText}`);
68
+ assert.ok(finalText.includes('• /dream'), `SHOULD_CONVERT_DREAM_ROW_TO_BULLET_${finalText}`);
69
+ console.log('TEST_GATEWAY_TELEGRAM_FORMATTING_OK');
70
+ }
71
+ main().catch((err) => {
72
+ console.error('TEST_GATEWAY_TELEGRAM_FORMATTING_FAIL:', err?.message || err);
73
+ process.exit(1);
74
+ });
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ // src/test_install_wizard_v2.ts
3
+ // Smoke + invariant tests for the v1.8.0 Install Wizard 2.0.
4
+ //
5
+ // Covers:
6
+ // 1. ProvidersCatalog consistency — every ProviderId has a catalog row.
7
+ // 2. OAuth policy — Anthropic OAuth is blocked, Codex/Gemini/Grok allowed.
8
+ // 3. Phase registry — all phases have unique ids and required fields.
9
+ // 4. CannedIO driver — wizard can walk through happy-path with canned answers
10
+ // without throwing (early phases only — won't touch the filesystem).
11
+ //
12
+ // Pattern follows existing src/test_install_wizard.ts (canned-answer driver).
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ const fs = __importStar(require("fs"));
48
+ const os = __importStar(require("os"));
49
+ const path = __importStar(require("path"));
50
+ const ProvidersCatalog_1 = require("./cli/install/ProvidersCatalog");
51
+ const types_1 = require("./cli/install/types");
52
+ const Phases_1 = require("./cli/install/Phases");
53
+ const WizardIO_1 = require("./cli/install/WizardIO");
54
+ const OAuthRunner_1 = require("./cli/install/OAuthRunner");
55
+ let failed = 0;
56
+ let passed = 0;
57
+ function check(name, cond, detail) {
58
+ if (cond) {
59
+ passed++;
60
+ console.log(` ✓ ${name}`);
61
+ }
62
+ else {
63
+ failed++;
64
+ console.error(` ✗ ${name}${detail ? ` — ${detail}` : ''}`);
65
+ }
66
+ }
67
+ async function main() {
68
+ console.log('test_install_wizard_v2: starting');
69
+ // ── 1. ProvidersCatalog consistency ─────────────────────────────────
70
+ console.log('\n[1] ProvidersCatalog consistency');
71
+ check('catalog has at least 25 entries', ProvidersCatalog_1.PROVIDERS_CATALOG.length >= 25, `actual=${ProvidersCatalog_1.PROVIDERS_CATALOG.length}`);
72
+ // All entries have required fields
73
+ for (const p of ProvidersCatalog_1.PROVIDERS_CATALOG) {
74
+ check(`${p.id} has label`, p.label.length > 0);
75
+ check(`${p.id} has tier`, !!p.tier);
76
+ check(`${p.id} has tags`, p.tags.length > 0);
77
+ }
78
+ // No duplicate IDs
79
+ const seen = new Set();
80
+ let dupes = 0;
81
+ for (const p of ProvidersCatalog_1.PROVIDERS_CATALOG) {
82
+ if (seen.has(p.id))
83
+ dupes++;
84
+ seen.add(p.id);
85
+ }
86
+ check('no duplicate provider ids', dupes === 0, `dupes=${dupes}`);
87
+ // ── 2. OAuth policy enforcement ─────────────────────────────────────
88
+ console.log('\n[2] OAuth policy');
89
+ const oauthList = types_1.OAUTH_ENABLED_PROVIDERS;
90
+ check('OAUTH_ENABLED_PROVIDERS has openai-cli', oauthList.includes('openai-cli'));
91
+ check('OAUTH_ENABLED_PROVIDERS has gemini-cli', oauthList.includes('gemini-cli'));
92
+ check('OAUTH_ENABLED_PROVIDERS has xai (Grok)', oauthList.includes('xai'));
93
+ check('OAUTH_ENABLED_PROVIDERS excludes anthropic', !oauthList.includes('anthropic'), 'Anthropic OAuth must be policy-blocked');
94
+ // OAuth runner refuses Anthropic
95
+ const antResult = await (0, OAuthRunner_1.runOAuth)('anthropic', { dryRun: true });
96
+ check('runOAuth("anthropic") returns ok=false', antResult.ok === false, `detail=${antResult.detail}`);
97
+ check('runOAuth("anthropic") detail mentions POLICY_BLOCK', /POLICY_BLOCK/.test(antResult.detail));
98
+ // OAuth runner accepts Codex dry-run
99
+ const codexResult = await (0, OAuthRunner_1.runOAuth)('openai-cli', { dryRun: true });
100
+ check('runOAuth("openai-cli", dryRun) returns ok=true', codexResult.ok === true);
101
+ const geminiResult = await (0, OAuthRunner_1.runOAuth)('gemini-cli', { dryRun: true });
102
+ check('runOAuth("gemini-cli", dryRun) returns ok=true', geminiResult.ok === true);
103
+ // ── 3. Phase registry ───────────────────────────────────────────────
104
+ console.log('\n[3] Phase registry');
105
+ check('ALL_PHASES has at least 20 phases', Phases_1.ALL_PHASES.length >= 20, `actual=${Phases_1.ALL_PHASES.length}`);
106
+ const phaseIds = new Set();
107
+ let phaseDupes = 0;
108
+ for (const ph of Phases_1.ALL_PHASES) {
109
+ if (phaseIds.has(ph.id))
110
+ phaseDupes++;
111
+ phaseIds.add(ph.id);
112
+ check(`phase "${ph.id}" has label`, ph.label.length > 0);
113
+ check(`phase "${ph.id}" has run fn`, typeof ph.run === 'function');
114
+ }
115
+ check('no duplicate phase ids', phaseDupes === 0, `dupes=${phaseDupes}`);
116
+ // The first 3 phases (banner, existing-install, product-select) MUST be unconditional.
117
+ const banner = Phases_1.ALL_PHASES.find(p => p.id === '00-banner');
118
+ check('00-banner has no `when` condition', banner !== undefined && !banner.when);
119
+ const existing = Phases_1.ALL_PHASES.find(p => p.id === '01-existing-install');
120
+ check('01-existing-install has no `when` condition', existing !== undefined && !existing.when);
121
+ const productSel = Phases_1.ALL_PHASES.find(p => p.id === '02-product-select');
122
+ check('02-product-select has no `when` condition', productSel !== undefined && !productSel.when);
123
+ // Core / agent phases must have `when` conditions
124
+ const coreEnter = Phases_1.ALL_PHASES.find(p => p.id === '10-core-enter');
125
+ check('10-core-enter has `when` condition', coreEnter !== undefined && typeof coreEnter.when === 'function');
126
+ const agentEnter = Phases_1.ALL_PHASES.find(p => p.id === '20-agent-enter');
127
+ check('20-agent-enter has `when` condition', agentEnter !== undefined && typeof agentEnter.when === 'function');
128
+ // ── 4. Catalog ↔ OAuth consistency ──────────────────────────────────
129
+ console.log('\n[4] Catalog ↔ OAuth consistency');
130
+ for (const id of types_1.OAUTH_ENABLED_PROVIDERS) {
131
+ try {
132
+ const p = (0, ProvidersCatalog_1.getProvider)(id);
133
+ check(`OAuth provider "${id}" has oauthCli`, !!p.oauthCli, `oauthCli="${p.oauthCli}"`);
134
+ }
135
+ catch (err) {
136
+ check(`OAuth provider "${id}" exists in catalog`, false, err instanceof Error ? err.message : String(err));
137
+ }
138
+ }
139
+ // Every catalog entry with oauthCli set should appear in OAUTH_ENABLED_PROVIDERS
140
+ for (const p of (0, ProvidersCatalog_1.oauthProviders)()) {
141
+ check(`catalog OAuth "${p.id}" in OAUTH_ENABLED_PROVIDERS`, types_1.OAUTH_ENABLED_PROVIDERS.includes(p.id), `catalog declares oauthCli=${p.oauthCli} but type not allow-listed`);
142
+ }
143
+ // ── 5. CannedIO smoke (banner + existing-install only, no FS writes) ─
144
+ // Use a clean tmp dir so phase 01 hits the "no previous install" branch
145
+ // and doesn't prompt for abort/reinstall/repair.
146
+ console.log('\n[5] CannedIO smoke');
147
+ const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'openlife-test-v2-'));
148
+ try {
149
+ const io = new WizardIO_1.CannedIO([
150
+ /* phase 00-banner: pause */ true,
151
+ /* phase 01-existing-install: pause */ true,
152
+ ]);
153
+ const phase00 = Phases_1.ALL_PHASES[0];
154
+ const phase01 = Phases_1.ALL_PHASES[1];
155
+ const ctx = {
156
+ root: tmpRoot,
157
+ products: [],
158
+ coreHosts: [],
159
+ coreProviders: [],
160
+ coreApiKeys: {},
161
+ agentAuthDecisions: [],
162
+ agentOAuthResults: [],
163
+ agentApiKeys: {},
164
+ warnings: [],
165
+ };
166
+ await phase00.run(ctx, io);
167
+ await phase01.run(ctx, io);
168
+ check('CannedIO drove first 2 phases without throwing', true);
169
+ check('CannedIO transcript captured output', io.transcript.length > 0);
170
+ check('ctx not aborted on clean tmpdir', !ctx.aborted);
171
+ }
172
+ catch (err) {
173
+ check('CannedIO drove first 2 phases without throwing', false, err instanceof Error ? err.message : String(err));
174
+ }
175
+ finally {
176
+ try {
177
+ fs.rmSync(tmpRoot, { recursive: true, force: true });
178
+ }
179
+ catch { /* ignore */ }
180
+ }
181
+ // ── Done ────────────────────────────────────────────────────────────
182
+ console.log('');
183
+ console.log(`Results: ${passed} passed, ${failed} failed`);
184
+ if (failed > 0) {
185
+ console.error('TEST_INSTALL_WIZARD_V2_FAIL');
186
+ process.exit(1);
187
+ }
188
+ console.log('✅ test_install_wizard_v2: all checks passed');
189
+ }
190
+ main().catch((err) => {
191
+ console.error('TEST_INSTALL_WIZARD_V2_UNCAUGHT', err);
192
+ process.exit(1);
193
+ });
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const Gateway_1 = require("./orchestrator/Gateway");
38
+ async function main() {
39
+ process.env.OPENLIFE_TELEGRAM_ALLOWED_USER_ID = '';
40
+ process.env.OPENLIFE_ENABLE_TTS = 'false';
41
+ const gateway = new Gateway_1.Gateway();
42
+ gateway.classifier = { classify: async () => ({ intent: 'KNOWLEDGE_RETRIEVAL', budgetLimit: 0.01 }) };
43
+ gateway.gatekeeper = { routeTask: async (_task, input) => `Resposta final para: ${input}` };
44
+ gateway.voiceManager = { generateSpeech: async (_text) => '/tmp/openlife-on-demand-voice-test.mp3' };
45
+ const result = await gateway.processTextForTestDetailed('1344110010', '/voice explique o AIOBUILDER em uma frase');
46
+ assert.equal(result.events.some((e) => e.kind === 'voice'), true);
47
+ assert.equal(result.finalText.includes('Resposta final para: explique o AIOBUILDER em uma frase'), true);
48
+ assert.equal(result.finalText.includes('/voice'), false);
49
+ const noVoice = await gateway.processTextForTestDetailed('1344110010', 'explique o AIOBUILDER em uma frase');
50
+ assert.equal(noVoice.events.some((e) => e.kind === 'voice'), false);
51
+ assert.equal(noVoice.events.some((e) => e.kind === 'edit'), true);
52
+ const fallbackGateway = new Gateway_1.Gateway();
53
+ fallbackGateway.classifier = gateway.classifier;
54
+ fallbackGateway.gatekeeper = gateway.gatekeeper;
55
+ fallbackGateway.voiceManager = { generateSpeech: async () => { throw new Error('NO_TTS_PROVIDER'); } };
56
+ const fallback = await fallbackGateway.processTextForTestDetailed('1344110010', 'responda por voz: diga olá');
57
+ assert.equal(fallback.events.some((e) => e.kind === 'voice'), false);
58
+ assert.match(fallback.finalText, /Não consegui gerar a voz/);
59
+ assert.match(fallback.finalText, /OPENAI_API_KEY|ELEVENLABS_API_KEY/);
60
+ console.log('ON_DEMAND_VOICE_REPLY_OK');
61
+ }
62
+ main().catch((err) => {
63
+ console.error(err);
64
+ process.exit(1);
65
+ });
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const fs = __importStar(require("fs"));
37
+ const os = __importStar(require("os"));
38
+ const path = __importStar(require("path"));
39
+ const ServiceCompletionPolicy_1 = require("./orchestrator/ServiceCompletionPolicy");
40
+ const ExecutionState_1 = require("./orchestrator/ExecutionState");
41
+ const Gateway_1 = require("./orchestrator/Gateway");
42
+ const CapabilityGenesisEngine_1 = require("./orchestrator/capability/CapabilityGenesisEngine");
43
+ const CapabilityPackState_1 = require("./orchestrator/capability/CapabilityPackState");
44
+ const ConsequenceForecaster_1 = require("./orchestrator/ConsequenceForecaster");
45
+ function assert(condition, message) {
46
+ if (!condition)
47
+ throw new Error(message);
48
+ }
49
+ async function main() {
50
+ // Sprint 2 — ServiceEvidence must be typed; generic artifacts/attempts alone are not enough.
51
+ const policy = new ServiceCompletionPolicy_1.ServiceCompletionPolicy();
52
+ const weak = (0, ExecutionState_1.createExecutionState)('weak', 'operate service', 'u1');
53
+ weak.plan = ['provision', 'integrate', 'validate'];
54
+ weak.successCriteria = policy.enforceCriteria(['resultado']);
55
+ weak.attempts.push({ role: 'executor', summary: 'exec ok', status: 'success', at: new Date().toISOString(), artifactPath: '.artifacts/a.txt' });
56
+ weak.attempts.push({ role: 'reviewer', summary: 'review ok', status: 'success', at: new Date().toISOString() });
57
+ weak.artifacts.push('.artifacts/a.txt');
58
+ assert(policy.evaluate(weak).complete === false, 'generic artifacts must not complete service without typed evidence');
59
+ const strong = (0, ExecutionState_1.createExecutionState)('strong', 'operate service', 'u1');
60
+ strong.plan = ['provision', 'integrate', 'validate'];
61
+ strong.successCriteria = policy.enforceCriteria(['resultado']);
62
+ strong.attempts = weak.attempts;
63
+ strong.artifacts = ['.artifacts/provision.txt', '.artifacts/e2e.txt'];
64
+ strong.serviceEvidence = [
65
+ { type: 'provisioning', status: 'passed', summary: 'runtime provisioned', artifactPath: '.artifacts/provision.txt', at: new Date().toISOString() },
66
+ { type: 'integration', status: 'passed', summary: 'modules integrated', artifactPath: '.artifacts/integration.txt', at: new Date().toISOString() },
67
+ { type: 'e2e', status: 'passed', summary: 'end-to-end passed', artifactPath: '.artifacts/e2e.txt', at: new Date().toISOString() },
68
+ { type: 'observability', status: 'passed', summary: 'logs/metrics captured', artifactPath: '.artifacts/observability.txt', at: new Date().toISOString() },
69
+ { type: 'operation', status: 'passed', summary: 'real operation command documented', artifactPath: '.artifacts/operation.txt', command: 'openlife service run svc', at: new Date().toISOString() },
70
+ ];
71
+ assert(policy.evaluate(strong).complete === true, 'typed service evidence should complete service');
72
+ // Sprint 3 — Telegram conflict classification must be deterministic and non-secret.
73
+ const conflict = Gateway_1.Gateway.classifyTelegramLaunchError(new Error('409: Conflict: terminated by other getUpdates request'));
74
+ assert('error' in conflict && conflict.error === 'telegram_polling_conflict', '409 must classify as polling conflict');
75
+ assert('recoveryOptions' in conflict && conflict.recoveryOptions.includes('stop_conflicting_instance'), '409 recovery must offer stop_conflicting_instance');
76
+ // Sprint 4 — Capability Genesis must create skill+squad+agent+workflow+checklist+governance+index by default.
77
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'openlife-remaining-sprints-'));
78
+ const catalogRoot = path.join(tmp, '.catalog', 'capabilities');
79
+ const stateStore = new CapabilityPackState_1.CapabilityPackStateStore({ stateDir: path.join(tmp, '.openlife', 'capability-state') });
80
+ const engine = new CapabilityGenesisEngine_1.CapabilityGenesisEngine({ catalogRoot, stateStore });
81
+ const generated = engine.generate({ description: 'customer support escalation capability', packId: 'customer-support-escalation', mode: 'professional', actor: 'tester' });
82
+ assert(generated.ok === true, 'capability genesis should succeed');
83
+ if (!generated.ok)
84
+ throw new Error('unreachable');
85
+ for (const rel of ['skills/customer-support-escalation.md', 'squads/customer-support-escalation-squad/SQUAD.md', 'agents/customer-support-escalation-agent.md', 'workflows/customer-support-escalation.yaml', 'checklists/customer-support-escalation-checklist.md', 'governance/customer-support-escalation-policy.json', 'INDEX.md']) {
86
+ assert(fs.existsSync(path.join(generated.packDir, rel)), `missing generated asset: ${rel}`);
87
+ }
88
+ assert(generated.pack.agents?.length === 1, 'manifest must include agent ref');
89
+ assert(generated.pack.checklists?.length === 1, 'manifest must include checklist ref');
90
+ assert(generated.pack.policies?.length === 1, 'manifest must include governance policy ref');
91
+ // Sprint 5 — consequence forecast must expose value scoring and now/24h/7d/30d horizons.
92
+ const basePolicy = { executionMode: 'balanced', swarmMode: 'none', maxBranches: 1, rationale: 'test' };
93
+ const forecast = new ConsequenceForecaster_1.ConsequenceForecaster().forecast('deploy production change safely', 'high', basePolicy, ['codex']);
94
+ assert(Array.isArray(forecast.valueScores) && forecast.valueScores.length >= 4, 'forecast must include value scores');
95
+ for (const h of ['now', '24h', '7d', '30d']) {
96
+ assert(forecast.horizons?.[h]?.impact, `missing horizon ${h}`);
97
+ }
98
+ console.log('TEST_REMAINING_SPRINTS_CONTRACTS_OK');
99
+ }
100
+ main().catch((error) => {
101
+ console.error(error.message || error);
102
+ process.exit(1);
103
+ });
@@ -10,12 +10,31 @@ async function main() {
10
10
  runtime.recordResult('gemini', false, 'quota exhausted');
11
11
  runtime.recordResult('claude', false, 'auth expired');
12
12
  runtime.recordResult('codex', true, 'ok');
13
- const research = runtime.decide('RESEARCH_ANALYSIS');
14
- assert(!research.preferred.includes('gemini'), 'gemini should enter cooldown after quota failure');
15
- assert(research.preferred.includes('codex'), 'research should fallback to codex when gemini is unhealthy');
16
- const engineering = runtime.decide('ENGINEERING_BUILD');
17
- assert(!engineering.preferred.includes('claude'), 'claude should enter cooldown after auth failure');
18
- assert(engineering.preferred[0] === 'codex', 'codex should become preferred when secondary executors cool down');
13
+ // Pass explicit executors so the test is deterministic regardless of the
14
+ // repo's models.json (otherwise getStrictModelExecutors() reads cwd's
15
+ // models.json and biases `base` to a single executor when the chain has
16
+ // length 1 — which is the case in this repo today). The test exercises
17
+ // the health/cooldown filter, not chain-detection from disk.
18
+ //
19
+ // Also unset GEMINI_API_KEY in this process so the runtime's gemini-api
20
+ // bypass (which keeps gemini preferred when the key is exported even if
21
+ // cooling down) doesn't mask the cooldown assertion. CI/local env may
22
+ // export it for other tests; we restore it after.
23
+ const previousGeminiKey = process.env.GEMINI_API_KEY;
24
+ delete process.env.GEMINI_API_KEY;
25
+ try {
26
+ const baseExecutors = ['gemini', 'claude', 'codex'];
27
+ const research = runtime.decide('RESEARCH_ANALYSIS', [...baseExecutors]);
28
+ assert(!research.preferred.includes('gemini'), 'gemini should enter cooldown after quota failure');
29
+ assert(research.preferred.includes('codex'), 'research should fallback to codex when gemini is unhealthy');
30
+ const engineering = runtime.decide('ENGINEERING_BUILD', [...baseExecutors]);
31
+ assert(!engineering.preferred.includes('claude'), 'claude should enter cooldown after auth failure');
32
+ assert(engineering.preferred[0] === 'codex', 'codex should become preferred when secondary executors cool down');
33
+ }
34
+ finally {
35
+ if (previousGeminiKey !== undefined)
36
+ process.env.GEMINI_API_KEY = previousGeminiKey;
37
+ }
19
38
  const snapshot = runtime.saveSnapshot();
20
39
  assert(!!snapshot, 'runtime policy snapshot should be saved');
21
40
  console.log('TEST_RUNTIME_POLICY_OK');
@@ -22,6 +22,13 @@ async function main() {
22
22
  complete.attempts.push({ role: 'executor', summary: 'exec ok', status: 'success', at: new Date().toISOString(), artifactPath: '.artifacts/a.txt' });
23
23
  complete.attempts.push({ role: 'reviewer', summary: 'review ok', status: 'success', at: new Date().toISOString() });
24
24
  complete.artifacts.push('.artifacts/a.txt');
25
+ complete.serviceEvidence = [
26
+ { type: 'provisioning', status: 'passed', summary: 'provisioned', at: new Date().toISOString(), artifactPath: '.artifacts/provision.txt' },
27
+ { type: 'integration', status: 'passed', summary: 'integrated', at: new Date().toISOString(), artifactPath: '.artifacts/integration.txt' },
28
+ { type: 'e2e', status: 'passed', summary: 'e2e passed', at: new Date().toISOString(), artifactPath: '.artifacts/e2e.txt' },
29
+ { type: 'observability', status: 'passed', summary: 'observability captured', at: new Date().toISOString(), artifactPath: '.artifacts/observability.txt' },
30
+ { type: 'operation', status: 'passed', summary: 'operation documented', at: new Date().toISOString(), artifactPath: '.artifacts/operation.txt', command: 'openlife service run t2' },
31
+ ];
25
32
  const reportComplete = policy.evaluate(complete);
26
33
  assert(reportComplete.complete === true, 'should pass complete service report');
27
34
  console.log('TEST_SERVICE_COMPLETION_POLICY_OK');