Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475// Client parsing decides whether prose becomes a billing-sensitive mutation; daemon E2E bypasses that classification.import assert from 'node:assert/strict';import { readFile } from 'node:fs/promises';import { stripTypeScriptTypes } from 'node:module';import test from 'node:test';
const source = stripTypeScriptTypes( ( await readFile(new URL('../src/lib/commands.ts', import.meta.url), 'utf8') ).replace(/^import .*;\n/gm, ''),);const commands = await import( `data:text/javascript;base64,${Buffer.from(source).toString('base64')}`);
const fast = { slash_name: '/fast', delivery: 'mutation', arguments: [] };const modelRead = { slash_name: '/model', delivery: 'read', arguments: [] };const modelEdit = { slash_name: '/model', delivery: 'mutation', arguments: [{ name: 'model', type: 'string', required: true }],};
test('bare /fast selects the no-argument mutation, but suffixes stay prompts', () => { assert.deepEqual(commands.parse([fast], '/fast'), { command: fast, rest: '', }); for (const line of ['/fast on', '/fast off', '/fast please toggle']) assert.equal(commands.parse([fast], line), null);});
test('/model read and edit parsing remain intact', () => { assert.deepEqual(commands.parse([modelRead, modelEdit], '/model'), { command: modelRead, rest: '', }); const parsed = commands.parse([modelRead, modelEdit], '/model gpt-5'); assert.deepEqual(parsed, { command: modelEdit, rest: 'gpt-5' }); assert.deepEqual(commands.form(modelEdit, parsed.rest), { model: 'gpt-5' });});
test('declared compaction uses receipt recovery and reports a saved selection on failure', async (t) => { const previous = globalThis.compactSession; t.after(() => { globalThis.compactSession = previous; }); let calls = 0; globalThis.compactSession = async (session, strategy) => { calls++; assert.equal(session, 'session'); assert.equal(strategy, 'rolling'); return { state: 'failed', selection_applied: true, failure: { detail: 'summary failed' }, }; }; const command = { slash_name: '/compact', delivery: 'mutation', arguments: [{ name: 'strategy', type: 'text', required: false }], operation: { operation_id: 'putCompaction', method: 'PUT', path_template: '/sessions/{session_id}/compactions/{action_id}', }, }; await assert.rejects( commands.invoke('session', command, 'rolling', 'input'), /summary failed.*selection was saved/, ); assert.equal(calls, 1);});