@kynver-app/runtime 0.1.3 → 0.1.5

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/dist/cli.js CHANGED
@@ -645,6 +645,16 @@ import path7 from "node:path";
645
645
  // src/prompt.ts
646
646
  function buildPrompt(input) {
647
647
  const ownership = input.ownedPaths.length ? `Owned paths: ${input.ownedPaths.join(", ")}. Do not edit outside these paths without stopping and reporting why.` : "Owned paths: unrestricted for this worker, but keep edits tightly scoped.";
648
+ const progressLines = [
649
+ "Structured plan progress (required when planId is set):",
650
+ "- Harness checkpoints only: `kynver plan progress --plan <planId> --row <rowKey> --role implementer --status running|partial|blocked` (the by-id harness route rejects `done` and confirm events).",
651
+ "- When a slice is finished, emit `partial` with evidence (`--evidence pr:<url>`, `--evidence path:<file>`, or `--evidence command:<cmd>`). Do not propose or confirm row `done` from the worker CLI.",
652
+ "- Propose/confirm row `done` is MCP/session only: chat agents use `agent_os_plan_progress_event_append` on the slug route (implementer proposes with `proposed: true`; report_reviewer/deep_reviewer confirm with `proposed: false`).",
653
+ "- When blocked on operator/Ghost/runtime review, create a linked review task (MCP `agent_os_plan_review_task_create` or API) and pass `--review-task <taskId>`.",
654
+ "- Before the completion report: mark completion-report rows partial with evidence; do not skip report review.",
655
+ "- After implementation: wait for report_reviewer then deep_reviewer confirmation (via MCP/session agents) before follow-up rows close.",
656
+ input.planId ? `Active planId: ${input.planId}${input.taskId ? ` \xB7 taskId: ${input.taskId}` : ""}` : "No planId on this worker \u2014 still emit progress when you touch plan-scoped work."
657
+ ];
648
658
  return [
649
659
  "You are running under the Kynver AgentOS runtime.",
650
660
  "Immediately state your plan before editing.",
@@ -654,6 +664,8 @@ function buildPrompt(input) {
654
664
  "After each major step, append one JSON line to the heartbeat file with fields: ts, phase, summary, changedFiles, blocker.",
655
665
  "Final response must include files changed, verification commands, and unresolved risks.",
656
666
  "",
667
+ ...progressLines,
668
+ "",
657
669
  "Task:",
658
670
  input.task
659
671
  ].join("\n");
@@ -1488,6 +1500,102 @@ async function runDaemon(args) {
1488
1500
  console.error(JSON.stringify({ event: "daemon_stop", runId, agentOsId }));
1489
1501
  }
1490
1502
 
1503
+ // src/plan-progress.ts
1504
+ function parseEvidenceArg(raw) {
1505
+ const idx = raw.indexOf(":");
1506
+ if (idx <= 0) throw new Error(`invalid --evidence ${raw} (expected type:value)`);
1507
+ return { type: raw.slice(0, idx), value: raw.slice(idx + 1) };
1508
+ }
1509
+ async function emitPlanProgress(args) {
1510
+ const planId = required(args.plan ? String(args.plan) : void 0, "plan");
1511
+ const agentOsId = (args.agentOsId ? String(args.agentOsId) : loadUserConfig().agentOsId) || "";
1512
+ if (!agentOsId) {
1513
+ console.error("requires --agent-os-id or agentOsId in ~/.kynver/config.json");
1514
+ process.exit(1);
1515
+ }
1516
+ const roleLane = required(args.role ? String(args.role) : void 0, "role");
1517
+ const status = required(args.status ? String(args.status) : void 0, "status");
1518
+ const evidence = [];
1519
+ const rawEvidence = args.evidence;
1520
+ if (Array.isArray(rawEvidence)) {
1521
+ for (const item of rawEvidence) evidence.push(parseEvidenceArg(String(item)));
1522
+ } else if (typeof rawEvidence === "string") {
1523
+ evidence.push(parseEvidenceArg(rawEvidence));
1524
+ }
1525
+ const base = resolveBaseUrl(args.baseUrl ? String(args.baseUrl) : void 0);
1526
+ const secret = resolveCallbackSecret(args.secret ? String(args.secret) : void 0);
1527
+ const url = `${base}/api/agent-os/by-id/${encodeURIComponent(agentOsId)}/plans/${encodeURIComponent(planId)}/progress-events`;
1528
+ const cfg = loadUserConfig();
1529
+ const provider = cfg.workerProvider ? `provider:${cfg.workerProvider}` : void 0;
1530
+ const body = {
1531
+ rowKey: args.row ? String(args.row) : void 0,
1532
+ rowId: args.rowId ? String(args.rowId) : void 0,
1533
+ taskId: args.task ? String(args.task) : void 0,
1534
+ reviewTaskId: args.reviewTask ? String(args.reviewTask) : void 0,
1535
+ roleLane,
1536
+ status,
1537
+ note: args.note ? String(args.note) : void 0,
1538
+ remainingWork: args.remaining ? String(args.remaining) : void 0,
1539
+ evidence: evidence.length ? evidence : void 0,
1540
+ proposed: args.proposed === true || args.proposed === "true",
1541
+ executorRef: args.executorRef ? String(args.executorRef) : provider
1542
+ };
1543
+ const res = await fetch(url, {
1544
+ method: "POST",
1545
+ headers: {
1546
+ "Content-Type": "application/json",
1547
+ "X-OpenClaw-Cron-Secret": secret
1548
+ },
1549
+ body: JSON.stringify(body)
1550
+ });
1551
+ const text = await res.text();
1552
+ let parsed = null;
1553
+ try {
1554
+ parsed = JSON.parse(text);
1555
+ } catch {
1556
+ parsed = text;
1557
+ }
1558
+ if (!res.ok) {
1559
+ console.error(JSON.stringify({ httpStatus: res.status, response: parsed }, null, 2));
1560
+ process.exit(1);
1561
+ }
1562
+ console.log(JSON.stringify(parsed, null, 2));
1563
+ }
1564
+ async function verifyPlan(args) {
1565
+ const planId = required(args.plan ? String(args.plan) : void 0, "plan");
1566
+ const slug = loadUserConfig().agentOsSlug;
1567
+ if (!slug) {
1568
+ console.error("requires agentOsSlug in ~/.kynver/config.json for verify (session route)");
1569
+ process.exit(1);
1570
+ }
1571
+ const base = resolveBaseUrl(args.baseUrl ? String(args.baseUrl) : void 0);
1572
+ const apiKey = process.env.KYNVER_API_KEY;
1573
+ const headers = { "Content-Type": "application/json" };
1574
+ if (apiKey) headers.Authorization = `Bearer ${apiKey}`;
1575
+ const url = `${base}/api/agent-os/${encodeURIComponent(slug)}/plans/${encodeURIComponent(planId)}/verify`;
1576
+ const res = await fetch(url, {
1577
+ method: "POST",
1578
+ headers,
1579
+ body: JSON.stringify({
1580
+ worktreePath: args.worktree ? String(args.worktree) : void 0,
1581
+ taskId: args.task ? String(args.task) : void 0,
1582
+ humanOverride: args.humanOverride === true || args.humanOverride === "true"
1583
+ })
1584
+ });
1585
+ const text = await res.text();
1586
+ let parsed = null;
1587
+ try {
1588
+ parsed = JSON.parse(text);
1589
+ } catch {
1590
+ parsed = text;
1591
+ }
1592
+ if (!res.ok) {
1593
+ console.error(JSON.stringify({ httpStatus: res.status, response: parsed }, null, 2));
1594
+ process.exit(1);
1595
+ }
1596
+ console.log(JSON.stringify(parsed, null, 2));
1597
+ }
1598
+
1491
1599
  // src/cli.ts
1492
1600
  function isHelpFlag(arg) {
1493
1601
  return arg === "help" || arg === "--help" || arg === "-h";
@@ -1514,7 +1622,9 @@ function usage(code = 0) {
1514
1622
  " kynver worker status --run RUN_ID --name worker",
1515
1623
  " kynver worker tail --run RUN_ID --name worker [--lines 40] [--raw]",
1516
1624
  " kynver worker stop --run RUN_ID --name worker",
1517
- " kynver worker complete --run RUN_ID --name worker [--agent-os-id AOS_ID] [--task-id TASK_ID] [--base-url URL] [--secret SECRET]"
1625
+ " kynver worker complete --run RUN_ID --name worker [--agent-os-id AOS_ID] [--task-id TASK_ID] [--base-url URL] [--secret SECRET]",
1626
+ " kynver plan progress --plan PLAN_ID --row ROW_KEY --role ROLE --status STATUS [--task TASK_ID] [--note NOTE] [--evidence type:value] [--agent-os-id AOS_ID]",
1627
+ " kynver plan verify --plan PLAN_ID [--worktree PATH] [--task TASK_ID] [--human-override]"
1518
1628
  ].join("\n")
1519
1629
  );
1520
1630
  process.exit(code);
@@ -1524,7 +1634,7 @@ async function main(argv = process.argv.slice(2)) {
1524
1634
  const scope = argv.shift();
1525
1635
  let action;
1526
1636
  let rest;
1527
- if (scope === "run" || scope === "worker") {
1637
+ if (scope === "run" || scope === "worker" || scope === "plan") {
1528
1638
  action = argv.shift();
1529
1639
  rest = argv;
1530
1640
  } else {
@@ -1537,6 +1647,8 @@ async function main(argv = process.argv.slice(2)) {
1537
1647
  if (scope === "login") return void await runLogin(args);
1538
1648
  if (scope === "setup") return void await runSetup(args);
1539
1649
  if (scope === "daemon") return void await runDaemon(args);
1650
+ if (scope === "plan" && action === "progress") return void await emitPlanProgress(args);
1651
+ if (scope === "plan" && action === "verify") return void await verifyPlan(args);
1540
1652
  if (scope === "run" && action === "create") return createRun(args);
1541
1653
  if (scope === "run" && action === "list") return listRuns();
1542
1654
  if (scope === "run" && action === "status") return runStatus(args);