pi-extensible-workflows 2.0.0 → 3.0.0

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/src/cli.js CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
7
7
  import { ProjectTrustStore, SessionManager, SettingsManager, createAgentSessionFromServices, createAgentSessionServices, getAgentDir, hasTrustRequiringProjectResources } from "@earendil-works/pi-coding-agent";
8
8
  import { Value } from "typebox/value";
9
9
  import { doctor, doctorExitCode, formatDoctorReport } from "./doctor.js";
10
- import workflowExtension, { formatWorkflowProgress, workflowCatalog } from "./index.js";
10
+ import workflowExtension, { formatWorkflowProgress, truncateWorkflowProgress, workflowCatalog } from "./index.js";
11
11
  import { runSessionInspector, transcriptFileLines } from "./session-inspector.js";
12
12
  function object(value) { return typeof value === "object" && value !== null && !Array.isArray(value); }
13
13
  function has(value, key) { return Object.prototype.hasOwnProperty.call(value, key); }
@@ -321,21 +321,27 @@ function writeLauncher(destination, workflowName, force) {
321
321
  rmSync(tempDir, { recursive: true, force: true });
322
322
  }
323
323
  }
324
+ function terminalProgressStyles(enabled) {
325
+ const style = (code) => enabled ? (text) => `\x1b[${String(code)}m${text}\x1b[0m` : (text) => text;
326
+ return { accent: style(36), success: style(32), error: style(31), warning: style(33), muted: style(90), dim: style(2), bold: style(1) };
327
+ }
324
328
  class CliProgress {
325
329
  stderr;
326
- tty;
327
330
  #lastStable = "";
328
331
  #lines = 0;
329
332
  #frame = 0;
330
333
  #run;
331
334
  #timer;
335
+ #interactive;
336
+ #styles;
332
337
  constructor(stderr, tty) {
333
338
  this.stderr = stderr;
334
- this.tty = tty;
339
+ this.#interactive = tty && process.env.NO_COLOR === undefined && process.env.TERM !== "dumb";
340
+ this.#styles = terminalProgressStyles(this.#interactive);
335
341
  }
336
342
  update(run) {
337
- const stable = formatWorkflowProgress(run, "◇");
338
- if (!this.tty) {
343
+ const stable = formatWorkflowProgress(run, "◇", this.#styles);
344
+ if (!this.#interactive) {
339
345
  if (stable !== this.#lastStable) {
340
346
  this.#lastStable = stable;
341
347
  this.stderr(`${stable}\n`);
@@ -352,7 +358,7 @@ class CliProgress {
352
358
  return;
353
359
  const spinner = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"][this.#frame++ % 10] ?? "◇";
354
360
  const width = process.stderr.columns || 80;
355
- const text = formatWorkflowProgress(this.#run, spinner).split("\n").map((line) => line.length <= width ? line : `${line.slice(0, Math.max(0, width - 1))}…`).join("\n");
361
+ const text = truncateWorkflowProgress(formatWorkflowProgress(this.#run, spinner, this.#styles), width).join("\n");
356
362
  this.stderr(`${this.#lines ? `\x1b[${String(this.#lines)}A` : ""}${this.#lines ? "" : "\x1b[?25l"}\x1b[0J${text}\n`);
357
363
  this.#lines = text.split("\n").length;
358
364
  }
@@ -361,7 +367,7 @@ class CliProgress {
361
367
  clearInterval(this.#timer);
362
368
  this.#timer = undefined;
363
369
  }
364
- if (this.tty && this.#lines) {
370
+ if (this.#interactive && this.#lines) {
365
371
  this.stderr(`\x1b[${String(this.#lines)}A\x1b[0J\x1b[?25h`);
366
372
  this.#lines = 0;
367
373
  }
@@ -0,0 +1,17 @@
1
+ import { RunStore } from "./persistence.js";
2
+ import type { AgentAttempt } from "./agent-execution.js";
3
+ import type { AgentIdentity, JsonValue, ShellIdentity, ShellOptions, ShellResult, WorkflowBridge, WorkflowExecution } from "./types.js";
4
+ export declare const RPC_LIMIT_BYTES: number;
5
+ export declare const HEARTBEAT_TIMEOUT_MS = 5000;
6
+ export declare function encoded(value: unknown): string;
7
+ export declare function agentIdentityPath(identity: AgentIdentity): string;
8
+ export declare function shellIdentityPath(identity: ShellIdentity): string;
9
+ export declare function readShellResult(value: unknown): ShellResult;
10
+ export declare function agentWorktree(identity: AgentIdentity): {
11
+ worktreeOwner?: string;
12
+ };
13
+ export declare function executeShellCommand(command: string, options: ShellOptions, signal: AbortSignal, cwd?: string): Promise<ShellResult>;
14
+ export declare function runWorkflow(script: string, args?: JsonValue, bridge?: WorkflowBridge, signal?: AbortSignal): WorkflowExecution;
15
+ export declare function persistActiveAgentAttempt(store: RunStore, id: string, active: Pick<AgentAttempt, "attempt" | "sessionId" | "sessionFile" | "setup">): Promise<void>;
16
+ export declare function persistAgentAttempts(store: RunStore, id: string, attempts: readonly AgentAttempt[]): Promise<void>;
17
+ export type { AgentIdentity, ShellIdentity, WorkflowBridge, WorkflowExecution } from "./types.js";