instar 1.2.10 → 1.2.12

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Codex driver for the hybrid wizard.
3
+ *
4
+ * Per-turn narrative: for each `narrative-then-prompt` state, instar
5
+ * spawns `codex exec` with a tightly-constrained prompt asking Codex
6
+ * to generate ONE warm 2-3 sentence intro paragraph. The structural
7
+ * prompt (the question text) is printed verbatim by instar from the
8
+ * state machine; Codex never sees it. This means Codex cannot reword
9
+ * the question, can't add or remove options, and can't decide to
10
+ * "execute the setup" — each per-turn invocation has nothing to
11
+ * execute and a single bounded text job.
12
+ *
13
+ * Action states call existing instar CLI commands directly. Telegram
14
+ * setup is a special action that spawns Codex as a full agentic
15
+ * session with Playwright access, pointed at a Telegram-specific
16
+ * prompt that aligns with Codex's execution-orientation (the
17
+ * conversational behavior is no longer expected here — Codex is
18
+ * driving the browser, that's its strength).
19
+ */
20
+ export interface CodexDriverOptions {
21
+ codexPath: string;
22
+ projectDir: string;
23
+ instarRoot: string;
24
+ /**
25
+ * When false, the driver suppresses narrative LLM calls and prints
26
+ * a deterministic fallback intro for each step. Used in tests and
27
+ * when the codex binary returns an auth error.
28
+ */
29
+ enableNarrative?: boolean;
30
+ }
31
+ /**
32
+ * Entry point — runs the wizard from the initial state to completion.
33
+ */
34
+ export declare function runCodexWizard(options: CodexDriverOptions): Promise<void>;
35
+ //# sourceMappingURL=codex-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-driver.d.ts","sourceRoot":"","sources":["../../../src/commands/setup-wizard/codex-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAgBH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA8VD;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/E"}
@@ -0,0 +1,355 @@
1
+ /**
2
+ * Codex driver for the hybrid wizard.
3
+ *
4
+ * Per-turn narrative: for each `narrative-then-prompt` state, instar
5
+ * spawns `codex exec` with a tightly-constrained prompt asking Codex
6
+ * to generate ONE warm 2-3 sentence intro paragraph. The structural
7
+ * prompt (the question text) is printed verbatim by instar from the
8
+ * state machine; Codex never sees it. This means Codex cannot reword
9
+ * the question, can't add or remove options, and can't decide to
10
+ * "execute the setup" — each per-turn invocation has nothing to
11
+ * execute and a single bounded text job.
12
+ *
13
+ * Action states call existing instar CLI commands directly. Telegram
14
+ * setup is a special action that spawns Codex as a full agentic
15
+ * session with Playwright access, pointed at a Telegram-specific
16
+ * prompt that aligns with Codex's execution-orientation (the
17
+ * conversational behavior is no longer expected here — Codex is
18
+ * driving the browser, that's its strength).
19
+ */
20
+ import { execFileSync, spawn, spawnSync } from 'node:child_process';
21
+ import path from 'node:path';
22
+ import readline from 'node:readline';
23
+ import pc from 'picocolors';
24
+ import { buildFreshProjectInstall, INITIAL_STATE, } from './state-machine.js';
25
+ import { WIZARD_CODEX_MODEL } from './model-constants.js';
26
+ /**
27
+ * Per-state narrative-prompt builders. Each returns the EXACT text we
28
+ * send to `codex exec`. The contract: ONE paragraph, no tools, no
29
+ * commands. Codex's `-s read-only` sandbox plus the prompt's
30
+ * constraints together prevent execution.
31
+ */
32
+ const NARRATIVE_PROMPTS = {
33
+ welcome: (_a, ctx) => `
34
+ You are a warm, friendly setup wizard greeting a new user installing
35
+ instar (a persistent AI-agent toolkit) in their project at ${path.basename(ctx.projectDir)}.
36
+
37
+ OUTPUT EXACTLY ONE warm 2-3 sentence paragraph welcoming them. Do NOT
38
+ include CLI commands, file paths, or technical jargon. Do NOT use ANY
39
+ tools or run ANY commands. Do NOT ask any questions — a separate
40
+ structured prompt will follow yours.
41
+
42
+ After your paragraph, exit. Output text only.
43
+ `.trim(),
44
+ 'agent-name': (a) => `
45
+ You are continuing the instar setup wizard. The user just accepted
46
+ the privacy notice. Now you're transitioning to the identity phase
47
+ where they'll pick a name for their agent.
48
+
49
+ OUTPUT EXACTLY ONE warm 2-3 sentence paragraph introducing the
50
+ "pick a name" step. Make it feel like the start of something — they're
51
+ naming a presence, not configuring a script. Hint that the name can
52
+ be anything (made-up word, real name, project-relevant).
53
+
54
+ Do NOT include CLI commands, file paths, or examples in code blocks.
55
+ Do NOT use ANY tools. Do NOT ask the question — a structured prompt
56
+ follows. Output text only and exit.
57
+
58
+ Their answers so far: name not yet given.
59
+ `.trim(),
60
+ 'agent-role': (a) => `
61
+ The user just told you their agent will be called "${a.agentName}".
62
+ Acknowledge the name in one short sentence (warmly), then introduce
63
+ the next step: a one-sentence description of what the agent should
64
+ focus on.
65
+
66
+ OUTPUT 1-2 sentences total. No CLI, no jargon, no tools, no question
67
+ (structured prompt follows). Output text only and exit.
68
+ `.trim(),
69
+ 'user-name': (a) => `
70
+ The user named their agent "${a.agentName}" and described its focus
71
+ as: "${a.agentRole}". Now you're asking what they'd like to be called.
72
+
73
+ OUTPUT ONE short sentence transitioning into "what should ${a.agentName}
74
+ call you?". Warm, not formal. No tools, no question (structured
75
+ prompt follows). Output text only and exit.
76
+ `.trim(),
77
+ autonomy: (a) => `
78
+ The user is "${a.userName}". Their agent "${a.agentName}" will focus on:
79
+ "${a.agentRole}". Next step: pick an autonomy level.
80
+
81
+ OUTPUT 2-3 short sentences introducing the autonomy choice. Explain
82
+ that this is a starting point — they can change it anytime later by
83
+ just chatting the agent ("be more proactive", "ask before acting").
84
+ Don't re-list the options (a structured prompt with the options
85
+ follows). No tools. Output text only and exit.
86
+ `.trim(),
87
+ messaging: (a) => `
88
+ The user "${a.userName}" has set up their agent "${a.agentName}" with
89
+ ${a.autonomy} autonomy. Now they need to pick how to talk to the agent
90
+ day-to-day.
91
+
92
+ OUTPUT 2-3 short sentences introducing the messaging-channel choice.
93
+ Hint that messaging is THE interface — the user shouldn't need to
94
+ return to a terminal after this. Don't re-list the options. No tools.
95
+ Output text only and exit.
96
+ `.trim(),
97
+ };
98
+ function narrativeFor(stateId, answers, ctx) {
99
+ const builder = NARRATIVE_PROMPTS[stateId];
100
+ return builder ? builder(answers, ctx) : null;
101
+ }
102
+ /**
103
+ * Default deterministic narrative for each state, used when the
104
+ * Codex call is suppressed or fails. Keeps the wizard usable even
105
+ * when narrative generation is unavailable.
106
+ */
107
+ const FALLBACK_NARRATIVES = {
108
+ welcome: 'Welcome to instar.',
109
+ 'agent-name': 'Let\'s start with a name for your agent.',
110
+ 'agent-role': 'Got it.',
111
+ 'user-name': 'And one more piece of identity:',
112
+ autonomy: 'A starting point — you can change this anytime.',
113
+ messaging: 'Messaging is the interface you\'ll use day-to-day.',
114
+ };
115
+ /**
116
+ * Run `codex exec` for one narrative-generation turn. Returns the
117
+ * text body of Codex's response (stdout), or null on failure /
118
+ * timeout. Bounded to a short per-turn timeout so a flaky network
119
+ * doesn't stall the wizard.
120
+ */
121
+ function runCodexNarrative(codexPath, prompt, options) {
122
+ try {
123
+ const result = spawnSync(codexPath, [
124
+ 'exec',
125
+ '-s', 'read-only',
126
+ '-m', WIZARD_CODEX_MODEL,
127
+ '--skip-git-repo-check',
128
+ '--ephemeral',
129
+ prompt,
130
+ ], {
131
+ cwd: options.instarRoot,
132
+ timeout: options.timeoutMs,
133
+ stdio: ['ignore', 'pipe', 'pipe'],
134
+ encoding: 'utf-8',
135
+ });
136
+ if (result.status !== 0)
137
+ return null;
138
+ // Strip any trailing trace blocks that codex exec prints. We want
139
+ // the last contiguous block of plain-English text.
140
+ const stdout = (result.stdout || '').trim();
141
+ // Heuristic: take everything after the last "--------" or "user\n" /
142
+ // "codex\n" marker if present (codex exec output sometimes prefixes
143
+ // session metadata).
144
+ const markers = ['\n--------\n', '\nuser\n', '\ncodex\n'];
145
+ let body = stdout;
146
+ for (const m of markers) {
147
+ const idx = body.lastIndexOf(m);
148
+ if (idx >= 0 && idx < body.length - 20)
149
+ body = body.slice(idx + m.length).trim();
150
+ }
151
+ return body || null;
152
+ }
153
+ catch {
154
+ return null;
155
+ }
156
+ }
157
+ /**
158
+ * Prompt the user with readline. Returns the trimmed answer (may be
159
+ * empty string for "user pressed enter").
160
+ */
161
+ async function askUser(promptText) {
162
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
163
+ return new Promise((resolve) => {
164
+ rl.question(promptText, (answer) => {
165
+ rl.close();
166
+ resolve(answer || '');
167
+ });
168
+ });
169
+ }
170
+ /**
171
+ * Render a state to the user: narrative paragraph (LLM-generated) +
172
+ * structural prompt (verbatim). Then read the answer.
173
+ */
174
+ async function renderNarrativeState(state, answers, options) {
175
+ // Generate narrative
176
+ let narrative = null;
177
+ if (options.enableNarrative !== false) {
178
+ const prompt = narrativeFor(state.id, answers, { projectDir: options.projectDir });
179
+ if (prompt) {
180
+ narrative = runCodexNarrative(options.codexPath, prompt, {
181
+ instarRoot: options.instarRoot,
182
+ timeoutMs: 30_000,
183
+ });
184
+ }
185
+ }
186
+ console.log();
187
+ console.log(pc.cyan(narrative ?? FALLBACK_NARRATIVES[state.id] ?? ''));
188
+ console.log();
189
+ console.log(state.prompt);
190
+ console.log();
191
+ const placeholderHint = state.input.kind === 'text' && state.input.placeholder
192
+ ? pc.dim(` (${state.input.placeholder})`)
193
+ : '';
194
+ if (placeholderHint)
195
+ console.log(placeholderHint);
196
+ return askUser(' > ');
197
+ }
198
+ /**
199
+ * Execute an action state — calls the appropriate instar CLI command
200
+ * or hands off to an agentic session.
201
+ */
202
+ async function runAction(action, answers, options) {
203
+ console.log();
204
+ console.log(pc.dim(` → ${action.description}...`));
205
+ switch (action.kind) {
206
+ case 'init': {
207
+ // We assume instar is on PATH (the bareword `npx instar` flow
208
+ // got us here). Use the installed binary.
209
+ try {
210
+ execFileSync('npx', [
211
+ 'instar',
212
+ 'init',
213
+ '--dir', options.projectDir,
214
+ '--framework', 'codex-cli',
215
+ ], { stdio: 'inherit' });
216
+ }
217
+ catch {
218
+ console.log(pc.yellow(' (init returned non-zero; continuing)'));
219
+ }
220
+ return {};
221
+ }
222
+ case 'add-user': {
223
+ const id = (answers.userName || 'user').toLowerCase().replace(/[^a-z0-9]/g, '');
224
+ const name = answers.userName || 'User';
225
+ try {
226
+ execFileSync('npx', ['instar', 'user', 'add', '-d', options.projectDir, '--id', id, '--name', name], { stdio: 'inherit' });
227
+ }
228
+ catch {
229
+ // non-fatal
230
+ }
231
+ return {};
232
+ }
233
+ case 'start-server': {
234
+ try {
235
+ execFileSync('npx', ['instar', 'server', 'start', '-d', options.projectDir], { stdio: 'inherit' });
236
+ return { serverStarted: true };
237
+ }
238
+ catch {
239
+ return { serverStarted: false };
240
+ }
241
+ }
242
+ case 'install-autostart': {
243
+ try {
244
+ execFileSync('npx', ['instar', 'autostart', 'install', '-d', options.projectDir], { stdio: 'inherit' });
245
+ }
246
+ catch {
247
+ // non-fatal
248
+ }
249
+ return {};
250
+ }
251
+ case 'setup-telegram-agentic': {
252
+ return await runTelegramSetup(options);
253
+ }
254
+ case 'setup-whatsapp-agentic':
255
+ case 'setup-slack-agentic': {
256
+ // Not yet ported to the hybrid wizard. Fall back to a clear
257
+ // pointer: setup completes, user can configure later via
258
+ // `instar add <channel>`.
259
+ console.log();
260
+ console.log(pc.yellow(' This channel will be configured after setup.'));
261
+ console.log(pc.dim(' (Hybrid wizard will gain agentic setup for it in a follow-up release.)'));
262
+ return {};
263
+ }
264
+ case 'send-greeting': {
265
+ // Lifeline topic greeting depends on Telegram being configured.
266
+ // Defer to existing helper if available; otherwise skip silently.
267
+ return {};
268
+ }
269
+ case 'github-backup': {
270
+ // Out of scope for v1.2.12 minimum. Future PR.
271
+ return {};
272
+ }
273
+ }
274
+ }
275
+ /**
276
+ * Telegram setup — the agentic phase. Spawns Codex with a tight
277
+ * Telegram-specific prompt and Playwright access. Codex's
278
+ * execution-orientation is an asset here.
279
+ */
280
+ async function runTelegramSetup(options) {
281
+ const skillPath = path.join(options.instarRoot, '.claude', 'skills', 'setup-wizard', 'SKILL.md');
282
+ // Inline Codex-specific Telegram-only prompt. The skill text isn't
283
+ // perfect for Codex but the Telegram-via-Playwright phase is
284
+ // primarily execution (open browser, click buttons, capture token),
285
+ // which Codex handles well.
286
+ const telegramPrompt = `
287
+ You are completing the Telegram messaging setup for an instar agent
288
+ already initialized at ${options.projectDir}.
289
+
290
+ Your task is OPERATIONAL and BOUNDED:
291
+ 1. Open Telegram Web in a browser via Playwright (if Playwright MCP
292
+ tools are available; otherwise fall back to printing manual steps).
293
+ 2. Help the user create a bot via BotFather.
294
+ 3. Capture the bot token and chat ID.
295
+ 4. Write them to .instar/config.json under messaging[].config.
296
+
297
+ When you have the token + chat ID and have written them, exit. Do NOT
298
+ proceed past Telegram setup — the rest of the wizard is owned by
299
+ instar's state machine.
300
+
301
+ If Playwright is not available, print clear manual steps (open
302
+ t.me/BotFather, type /newbot, etc.) and prompt the user for the token
303
+ and chat ID. Then write them to config.
304
+
305
+ Reference skill (for the wizard sections about Telegram if you need
306
+ detail): ${skillPath}
307
+ `.trim();
308
+ return new Promise((resolve) => {
309
+ const child = spawn(options.codexPath, [
310
+ 'exec',
311
+ '--dangerously-bypass-approvals-and-sandbox',
312
+ '-m', WIZARD_CODEX_MODEL,
313
+ telegramPrompt,
314
+ ], {
315
+ cwd: options.projectDir,
316
+ stdio: 'inherit',
317
+ });
318
+ child.on('close', () => resolve({ telegramConfigured: true }));
319
+ child.on('error', () => resolve({ telegramConfigured: false }));
320
+ });
321
+ }
322
+ /**
323
+ * Entry point — runs the wizard from the initial state to completion.
324
+ */
325
+ export async function runCodexWizard(options) {
326
+ const states = buildFreshProjectInstall();
327
+ const answers = {};
328
+ let currentId = INITIAL_STATE;
329
+ let safety = 30; // guard against infinite loops via bad transitions
330
+ while (safety-- > 0) {
331
+ const state = states[currentId];
332
+ if (!state) {
333
+ console.log(pc.red(` Wizard reached an unknown state: ${currentId}`));
334
+ return;
335
+ }
336
+ if (state.kind === 'terminal') {
337
+ console.log();
338
+ console.log(pc.green(state.farewell));
339
+ console.log();
340
+ return;
341
+ }
342
+ if (state.kind === 'action') {
343
+ const updates = await runAction(state.action, answers, options);
344
+ Object.assign(answers, updates);
345
+ currentId = state.next(answers);
346
+ continue;
347
+ }
348
+ // narrative-then-prompt
349
+ const answer = await renderNarrativeState(state, answers, options);
350
+ const { state: nextId, updates } = state.next(answer, answers);
351
+ Object.assign(answers, updates);
352
+ currentId = nextId;
353
+ }
354
+ }
355
+ //# sourceMappingURL=codex-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-driver.js","sourceRoot":"","sources":["../../../src/commands/setup-wizard/codex-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,aAAa,GAKd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAc1D;;;;;GAKG;AACH,MAAM,iBAAiB,GAA8E;IACnG,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;;6DAEqC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC;;;;;;;;CAQzF,CAAC,IAAI,EAAE;IAEN,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;CAetB,CAAC,IAAI,EAAE;IAEN,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;qDAC8B,CAAC,CAAC,SAAS;;;;;;;CAO/D,CAAC,IAAI,EAAE;IAEN,WAAW,EAAE,CA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ACpB,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YACtC,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO;QACT,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAChE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAChC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAChC,SAAS;QACX,CAAC;QAED,wBAAwB;QACxB,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACnE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/D,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAChC,SAAS,GAAG,MAAM,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Codex model used by the hybrid wizard's Codex driver.
3
+ *
4
+ * Codex CLI's bundled default (gpt-5.2-codex) was retired from
5
+ * ChatGPT-subscription accounts on 2026-04-14 and is API-only since.
6
+ * The wizard targets the subscription path by default, so we pin to a
7
+ * model empirically confirmed-working on ChatGPT auth (see
8
+ * src/providers/adapters/openai-codex/models.ts for the full
9
+ * availability matrix). gpt-5.3-codex is the "balanced" tier in that
10
+ * matrix.
11
+ */
12
+ export declare const WIZARD_CODEX_MODEL = "gpt-5.3-codex";
13
+ //# sourceMappingURL=model-constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-constants.d.ts","sourceRoot":"","sources":["../../../src/commands/setup-wizard/model-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Codex model used by the hybrid wizard's Codex driver.
3
+ *
4
+ * Codex CLI's bundled default (gpt-5.2-codex) was retired from
5
+ * ChatGPT-subscription accounts on 2026-04-14 and is API-only since.
6
+ * The wizard targets the subscription path by default, so we pin to a
7
+ * model empirically confirmed-working on ChatGPT auth (see
8
+ * src/providers/adapters/openai-codex/models.ts for the full
9
+ * availability matrix). gpt-5.3-codex is the "balanced" tier in that
10
+ * matrix.
11
+ */
12
+ export const WIZARD_CODEX_MODEL = 'gpt-5.3-codex';
13
+ //# sourceMappingURL=model-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-constants.js","sourceRoot":"","sources":["../../../src/commands/setup-wizard/model-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Wizard state machine — backbone of the conversational setup flow.
3
+ *
4
+ * This is the deterministic spine. Each state has a `prompt` (what the
5
+ * user is asked), a list of `choices` (when multi-choice) or `kind:
6
+ * 'text'` (free-text), and `nextState` derived from the user's answer.
7
+ * Side-effects (init, user add, server start, etc.) are emitted as
8
+ * `actions` the driver runs at appropriate transitions.
9
+ *
10
+ * Framework-specific drivers (codex-driver.ts) consume this state
11
+ * machine. The framework's LLM is invoked ONLY to generate narrative
12
+ * intro text for each state — not to drive transitions. Transitions
13
+ * are owned by instar.
14
+ *
15
+ * This is the "Structure > Willpower" answer to the v1.2.11 failure
16
+ * mode where Codex ignored the wizard SKILL.md's conversational
17
+ * contract and executed the entire setup non-interactively. With the
18
+ * state machine owning the flow, the framework cannot get out of hand
19
+ * — each per-turn LLM call has a single bounded text job.
20
+ */
21
+ export type Autonomy = 'guided' | 'proactive' | 'autonomous';
22
+ export type Messaging = 'telegram' | 'whatsapp' | 'slack' | 'skip';
23
+ export interface WizardAnswers {
24
+ agentName?: string;
25
+ agentRole?: string;
26
+ userName?: string;
27
+ autonomy?: Autonomy;
28
+ messaging?: Messaging;
29
+ telegramConfigured?: boolean;
30
+ whatsappConfigured?: boolean;
31
+ slackConfigured?: boolean;
32
+ githubBackupRepo?: string;
33
+ serverStarted?: boolean;
34
+ }
35
+ export type WizardActionKind = 'init' | 'add-user' | 'setup-telegram-agentic' | 'setup-whatsapp-agentic' | 'setup-slack-agentic' | 'github-backup' | 'start-server' | 'install-autostart' | 'send-greeting';
36
+ export interface WizardAction {
37
+ kind: WizardActionKind;
38
+ description: string;
39
+ }
40
+ export type StateKind = 'narrative-then-prompt' | 'action' | 'terminal';
41
+ export interface NarrativeState {
42
+ id: string;
43
+ kind: 'narrative-then-prompt';
44
+ /**
45
+ * The question text the user sees. Framework drivers should NOT
46
+ * regenerate this — it is the structural prompt, displayed verbatim.
47
+ * Narrative intro text is rendered separately by the driver via a
48
+ * per-turn LLM call.
49
+ */
50
+ prompt: string;
51
+ /** Optional preamble keys for the driver to look up narrative-prompt builders. */
52
+ narrativeContext: string;
53
+ input: {
54
+ kind: 'text';
55
+ placeholder?: string;
56
+ } | {
57
+ kind: 'choice';
58
+ choices: Array<{
59
+ value: string;
60
+ label: string;
61
+ }>;
62
+ };
63
+ /** Where to go next based on the user's answer. Driver invokes this. */
64
+ next: (answer: string, answers: WizardAnswers) => {
65
+ state: string;
66
+ updates: Partial<WizardAnswers>;
67
+ };
68
+ }
69
+ export interface ActionState {
70
+ id: string;
71
+ kind: 'action';
72
+ action: WizardAction;
73
+ /**
74
+ * Where to go after the action completes. Drivers are responsible
75
+ * for running the action and applying any answer updates.
76
+ */
77
+ next: (answers: WizardAnswers) => string;
78
+ }
79
+ export interface TerminalState {
80
+ id: string;
81
+ kind: 'terminal';
82
+ /** Final farewell text. */
83
+ farewell: string;
84
+ }
85
+ export type WizardState = NarrativeState | ActionState | TerminalState;
86
+ /**
87
+ * Normalize a user-typed answer for choice matching: accepts the
88
+ * 1-based numeric index OR the choice's `value` (case-insensitive
89
+ * prefix-match against the label).
90
+ */
91
+ export declare function resolveChoice(answer: string, choices: Array<{
92
+ value: string;
93
+ label: string;
94
+ }>): string | null;
95
+ /**
96
+ * Build the wizard state machine for a fresh project-bound install
97
+ * (the most common entry point — and the one observed broken in the
98
+ * v1.2.11 instar-codey log). Restore / multi-user / multi-machine
99
+ * scenarios are out of scope for the first hybrid-wizard PR; they
100
+ * stay on the existing SKILL.md path until ported.
101
+ */
102
+ export declare function buildFreshProjectInstall(): Record<string, WizardState>;
103
+ export declare const INITIAL_STATE = "welcome";
104
+ //# sourceMappingURL=state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.d.ts","sourceRoot":"","sources":["../../../src/commands/setup-wizard/state-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAA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