@zachwill/pi-orchestrate 0.8.0 → 0.9.2
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/extension/catalog.ts +70 -75
- package/extension/contract.ts +73 -7
- package/extension/delivery.ts +65 -17
- package/extension/domain.ts +83 -58
- package/extension/host.ts +316 -30
- package/extension/index.ts +28 -31
- package/extension/presentation.ts +48 -98
- package/extension/runtime.ts +1690 -884
- package/extension/tools.ts +236 -270
- package/extension/tui.ts +50 -0
- package/extension/worker-session.ts +514 -188
- package/extension/worker-settlement.ts +105 -44
- package/package.json +1 -1
- package/extension/scheduler.ts +0 -85
package/extension/tui.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { truncateToWidth, type Component } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
export class WidthBoundComponent implements Component {
|
|
4
|
+
constructor(
|
|
5
|
+
private readonly child: Component,
|
|
6
|
+
private readonly maxLines?: number,
|
|
7
|
+
) {}
|
|
8
|
+
|
|
9
|
+
render(width: number): string[] {
|
|
10
|
+
const bounded = Math.max(1, Math.floor(width));
|
|
11
|
+
const lines = this.child.render(bounded);
|
|
12
|
+
return (this.maxLines === undefined ? lines : lines.slice(0, this.maxLines))
|
|
13
|
+
.map((line) => truncateToWidth(line, bounded, "…"));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
invalidate(): void { this.child.invalidate(); }
|
|
17
|
+
dispose(): void { disposeComponent(this.child); }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function disposeComponent(component: Component): void {
|
|
21
|
+
(component as Component & { dispose?: () => void }).dispose?.();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resultAppearance(
|
|
25
|
+
status: "completed" | "ready" | "failed" | "aborted",
|
|
26
|
+
readyQualifier: string,
|
|
27
|
+
failedQualifier = "failed",
|
|
28
|
+
): {
|
|
29
|
+
readonly color: "success" | "error" | "warning";
|
|
30
|
+
readonly icon: "✓" | "✗" | "■";
|
|
31
|
+
readonly qualifier?: string;
|
|
32
|
+
} {
|
|
33
|
+
if (status === "failed") {
|
|
34
|
+
return { color: "error", icon: "✗", qualifier: failedQualifier };
|
|
35
|
+
}
|
|
36
|
+
if (status === "aborted") {
|
|
37
|
+
return { color: "warning", icon: "■", qualifier: "aborted" };
|
|
38
|
+
}
|
|
39
|
+
if (status === "ready") {
|
|
40
|
+
return { color: "success", icon: "✓", qualifier: readyQualifier };
|
|
41
|
+
}
|
|
42
|
+
return { color: "success", icon: "✓" };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function formatElapsed(milliseconds: number): string {
|
|
46
|
+
const seconds = Math.floor(milliseconds / 1000);
|
|
47
|
+
if (seconds < 60) return `${seconds}s`;
|
|
48
|
+
const minutes = Math.floor(seconds / 60);
|
|
49
|
+
return seconds % 60 === 0 ? `${minutes}m` : `${minutes}m ${seconds % 60}s`;
|
|
50
|
+
}
|