drafted 1.25.6 → 1.25.7
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/cli/drafted.mjs +46 -10
- package/package.json +1 -1
- package/src/shared/action-state.mjs +15 -0
package/cli/drafted.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import { DESIGN_SYSTEM_PROMPT, buildDesignPrompt } from './prompts.mjs';
|
|
|
19
19
|
import { scanRepoAgents, detectDefaultBranch, detectRemoteUrl, isGitUrl, cloneToTemp, classifySeed } from './repo-scan.mjs';
|
|
20
20
|
import { setupTrusted } from './skill-setup-trust.mjs';
|
|
21
21
|
import { openCommandFor } from './open-url.mjs';
|
|
22
|
+
import { actionState } from '../src/shared/action-state.mjs';
|
|
22
23
|
|
|
23
24
|
const __filename = fileURLToPath(import.meta.url);
|
|
24
25
|
const __dirname = dirname(__filename);
|
|
@@ -2250,16 +2251,6 @@ async function minionSetEnabled(id, enabled, format) {
|
|
|
2250
2251
|
// Approving stays a browser-only act in Drafted; nothing here can approve.
|
|
2251
2252
|
const actionCmd = program.command('action').description('Propose an outward effect for a person to approve, and read its decision');
|
|
2252
2253
|
|
|
2253
|
-
function actionState(actions) {
|
|
2254
|
-
const st = (actions || []).map((a) => a.status);
|
|
2255
|
-
if (!st.length) return 'unknown';
|
|
2256
|
-
if (st.every((s) => s === 'proposed')) return 'waiting';
|
|
2257
|
-
if (st.includes('rejected')) return 'rejected';
|
|
2258
|
-
if (st.includes('failed')) return 'failed';
|
|
2259
|
-
if (st.every((s) => s === 'executed')) return 'executed';
|
|
2260
|
-
return 'approved';
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
2254
|
async function actionApi(method, apiPath, org, body) {
|
|
2264
2255
|
requireLogin();
|
|
2265
2256
|
const server = getServerUrl().replace(/\/$/, '');
|
|
@@ -2338,6 +2329,51 @@ flowToolsCmd
|
|
|
2338
2329
|
else console.log(r.data.token);
|
|
2339
2330
|
});
|
|
2340
2331
|
|
|
2332
|
+
// ── Automations: start a skill flow in Drafted ──────────────────────────
|
|
2333
|
+
// The "local agent" trigger (U2): the same run as the Flows tab's Run now, at the
|
|
2334
|
+
// published version, as you. The request returns once the run finishes or parks
|
|
2335
|
+
// on an approval, so the status printed is where it stands, not "started".
|
|
2336
|
+
const automationCmd = program.command('automation').description('Run a skill\'s flows in Drafted');
|
|
2337
|
+
|
|
2338
|
+
automationCmd
|
|
2339
|
+
.command('run <skill> [flow]')
|
|
2340
|
+
.description('Run a flow (default: "default") of an org skill at its published version. --input becomes the run\'s untrusted trigger.json input.')
|
|
2341
|
+
.option('--project <id>', 'project the run happens in (defaults to your active project)')
|
|
2342
|
+
.option('--input <text>', 'input text for the run')
|
|
2343
|
+
.option('--input-file <path>', 'read the input from a file ("-" for stdin)')
|
|
2344
|
+
.option('--org <org>', 'org (id or slug) the skill belongs to')
|
|
2345
|
+
.option('--format <fmt>', 'output format: json or text', 'text')
|
|
2346
|
+
.action(async (skillSlug, flow, opts) => {
|
|
2347
|
+
const fail = (error) => {
|
|
2348
|
+
if (opts.format === 'json') console.log(JSON.stringify({ status: 'error', error }));
|
|
2349
|
+
else console.error(`error\t${error}`);
|
|
2350
|
+
process.exit(1);
|
|
2351
|
+
};
|
|
2352
|
+
const projectId = opts.project || getActiveProject()?.id;
|
|
2353
|
+
if (!projectId) fail('no project: pass --project or run `drafted use-project <id>` first');
|
|
2354
|
+
let input = opts.input;
|
|
2355
|
+
if (opts.inputFile) {
|
|
2356
|
+
try { input = readFileSync(opts.inputFile === '-' ? 0 : opts.inputFile, 'utf8'); } catch (err) { fail(`cannot read ${opts.inputFile}: ${err.message}`); }
|
|
2357
|
+
}
|
|
2358
|
+
const chain = flow || 'default';
|
|
2359
|
+
const found = await actionApi('GET', `/api/skills/slug/${encodeURIComponent(skillSlug)}?lookup=1`, opts.org);
|
|
2360
|
+
if (!found.ok) fail(found.data.error || `HTTP ${found.status}`);
|
|
2361
|
+
const skillId = found.data.id;
|
|
2362
|
+
const run = await actionApi('POST', `/api/skills/${encodeURIComponent(skillId)}/flows/${encodeURIComponent(chain)}/run`, opts.org, { projectId, input: input ?? '' });
|
|
2363
|
+
if (!run.ok) fail(run.data.error || `HTTP ${run.status}`);
|
|
2364
|
+
const list = await actionApi('GET', `/api/skills/${encodeURIComponent(skillId)}/automation-runs`, opts.org);
|
|
2365
|
+
const r = (list.ok && (list.data.runs || []).find((x) => x.id === run.data.runId)) || {};
|
|
2366
|
+
const out = {
|
|
2367
|
+
status: 'ok', runId: run.data.runId, version: run.data.version, flow: chain,
|
|
2368
|
+
state: r.status || 'unknown', error: r.error || null,
|
|
2369
|
+
steps: (r.steps || []).map((st) => ({ id: st.id, status: st.status, actionGroupId: st.actionGroupId || null })),
|
|
2370
|
+
};
|
|
2371
|
+
if (opts.format === 'json') { console.log(JSON.stringify(out)); return; }
|
|
2372
|
+
console.log(`${out.runId}\t${out.state}\tv${out.version}${out.error ? `\t${out.error}` : ''}`);
|
|
2373
|
+
for (const st of out.steps) console.log(` ${st.id}\t${st.status}${st.actionGroupId ? `\t${st.actionGroupId}` : ''}`);
|
|
2374
|
+
if (out.state === 'failed') process.exit(1);
|
|
2375
|
+
});
|
|
2376
|
+
|
|
2341
2377
|
const minionCmd = program.command('minion').description('Minion management (checklist-driven intake surfaces). Requires the agent allowlist.');
|
|
2342
2378
|
|
|
2343
2379
|
minionCmd
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drafted",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.7",
|
|
4
4
|
"description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The state of a proposed action group, from its actions' statuses: what an
|
|
3
|
+
* approval@1 step decides on. One implementation for every runner: Drafted's
|
|
4
|
+
* automation runner and the `drafted action status` command Causeway's
|
|
5
|
+
* approval@1 shim calls both import it (chain-spec/semantics.json holds the cases).
|
|
6
|
+
*/
|
|
7
|
+
export function actionState(actions) {
|
|
8
|
+
const st = (actions || []).map((a) => a.status);
|
|
9
|
+
if (!st.length) return 'unknown';
|
|
10
|
+
if (st.every((s) => s === 'proposed')) return 'waiting';
|
|
11
|
+
if (st.includes('rejected')) return 'rejected';
|
|
12
|
+
if (st.includes('failed')) return 'failed';
|
|
13
|
+
if (st.every((s) => s === 'executed')) return 'executed';
|
|
14
|
+
return 'approved';
|
|
15
|
+
}
|