pi-crew 0.1.37 → 0.1.39
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/AGENTS.md +1 -1
- package/CHANGELOG.md +27 -0
- package/README.md +5 -0
- package/agents/analyst.md +11 -11
- package/agents/critic.md +11 -11
- package/agents/executor.md +11 -11
- package/agents/explorer.md +11 -11
- package/agents/planner.md +11 -11
- package/agents/reviewer.md +11 -11
- package/agents/security-reviewer.md +11 -11
- package/agents/test-engineer.md +11 -11
- package/agents/verifier.md +11 -11
- package/agents/writer.md +11 -11
- package/docs/refactor-tasks-phase3.md +394 -394
- package/docs/refactor-tasks-phase4.md +564 -564
- package/docs/refactor-tasks-phase5.md +402 -402
- package/docs/refactor-tasks-phase6.md +662 -662
- package/docs/research-extension-examples.md +297 -297
- package/docs/research-extension-system.md +324 -324
- package/docs/research-optimization-plan.md +548 -548
- package/docs/research-pi-coding-agent.md +357 -357
- package/docs/research-source-pi-crew-reference.md +174 -174
- package/docs/resource-formats.md +10 -8
- package/docs/runtime-flow.md +148 -148
- package/docs/source-runtime-refactor-map.md +83 -83
- package/docs/usage.md +6 -0
- package/index.ts +6 -6
- package/package.json +3 -3
- package/schema.json +2 -2
- package/src/agents/agent-serializer.ts +34 -34
- package/src/config/config.ts +8 -4
- package/src/extension/cross-extension-rpc.ts +82 -82
- package/src/extension/import-index.ts +18 -2
- package/src/extension/register.ts +11 -1
- package/src/extension/registration/compaction-guard.ts +125 -125
- package/src/extension/registration/subagent-helpers.ts +30 -6
- package/src/extension/registration/subagent-tools.ts +8 -3
- package/src/extension/result-watcher.ts +98 -98
- package/src/extension/run-import.ts +12 -2
- package/src/extension/run-index.ts +12 -2
- package/src/extension/run-maintenance.ts +24 -24
- package/src/extension/team-tool/api.ts +54 -14
- package/src/extension/team-tool/cancel.ts +31 -31
- package/src/extension/team-tool/doctor.ts +179 -179
- package/src/extension/team-tool/inspect.ts +41 -41
- package/src/extension/team-tool/lifecycle-actions.ts +79 -79
- package/src/extension/team-tool/plan.ts +19 -19
- package/src/extension/team-tool/status.ts +73 -73
- package/src/observability/correlation.ts +35 -35
- package/src/observability/event-to-metric.ts +54 -54
- package/src/observability/exporters/adapter.ts +24 -24
- package/src/observability/exporters/otlp-exporter.ts +65 -65
- package/src/observability/exporters/prometheus-exporter.ts +47 -47
- package/src/observability/metric-registry.ts +72 -72
- package/src/observability/metric-retention.ts +46 -46
- package/src/observability/metric-sink.ts +51 -51
- package/src/observability/metrics-primitives.ts +166 -166
- package/src/prompt/prompt-runtime.ts +68 -68
- package/src/runtime/agent-control.ts +64 -64
- package/src/runtime/agent-memory.ts +72 -72
- package/src/runtime/agent-observability.ts +114 -113
- package/src/runtime/async-marker.ts +26 -26
- package/src/runtime/background-runner.ts +53 -53
- package/src/runtime/crash-recovery.ts +56 -56
- package/src/runtime/crew-agent-records.ts +54 -9
- package/src/runtime/crew-agent-runtime.ts +58 -58
- package/src/runtime/deadletter.ts +36 -36
- package/src/runtime/direct-run.ts +35 -35
- package/src/runtime/foreground-control.ts +82 -82
- package/src/runtime/green-contract.ts +46 -46
- package/src/runtime/group-join.ts +88 -88
- package/src/runtime/heartbeat-gradient.ts +28 -28
- package/src/runtime/heartbeat-watcher.ts +80 -80
- package/src/runtime/live-agent-control.ts +87 -78
- package/src/runtime/live-agent-manager.ts +85 -85
- package/src/runtime/live-control-realtime.ts +36 -36
- package/src/runtime/live-session-runtime.ts +299 -299
- package/src/runtime/manifest-cache.ts +248 -212
- package/src/runtime/model-fallback.ts +261 -261
- package/src/runtime/parallel-research.ts +44 -44
- package/src/runtime/parallel-utils.ts +99 -99
- package/src/runtime/pi-json-output.ts +111 -111
- package/src/runtime/policy-engine.ts +78 -78
- package/src/runtime/post-exit-stdio-guard.ts +86 -86
- package/src/runtime/process-status.ts +56 -56
- package/src/runtime/progress-event-coalescer.ts +43 -43
- package/src/runtime/recovery-recipes.ts +74 -74
- package/src/runtime/retry-executor.ts +59 -59
- package/src/runtime/role-permission.ts +39 -39
- package/src/runtime/session-usage.ts +79 -79
- package/src/runtime/sidechain-output.ts +28 -28
- package/src/runtime/subagent-manager.ts +80 -12
- package/src/runtime/task-display.ts +38 -38
- package/src/runtime/task-output-context.ts +127 -106
- package/src/runtime/task-runner/live-executor.ts +98 -98
- package/src/runtime/task-runner/progress.ts +111 -111
- package/src/runtime/task-runner/result-utils.ts +14 -14
- package/src/runtime/task-runner/state-helpers.ts +22 -22
- package/src/runtime/team-runner.ts +1 -1
- package/src/runtime/worker-heartbeat.ts +21 -21
- package/src/runtime/worker-startup.ts +57 -57
- package/src/schema/config-schema.ts +21 -21
- package/src/schema/team-tool-schema.ts +100 -100
- package/src/state/artifact-store.ts +122 -108
- package/src/state/contracts.ts +105 -105
- package/src/state/jsonl-writer.ts +77 -77
- package/src/state/mailbox.ts +67 -22
- package/src/state/state-store.ts +36 -5
- package/src/state/task-claims.ts +42 -42
- package/src/state/usage.ts +29 -29
- package/src/subagents/async-entry.ts +1 -1
- package/src/subagents/index.ts +3 -3
- package/src/subagents/live/control.ts +1 -1
- package/src/subagents/live/manager.ts +1 -1
- package/src/subagents/live/realtime.ts +1 -1
- package/src/subagents/live/session-runtime.ts +1 -1
- package/src/subagents/manager.ts +1 -1
- package/src/subagents/spawn.ts +1 -1
- package/src/teams/discover-teams.ts +27 -5
- package/src/teams/team-serializer.ts +38 -36
- package/src/types/diff.d.ts +18 -18
- package/src/ui/crew-footer.ts +101 -101
- package/src/ui/crew-select-list.ts +111 -111
- package/src/ui/dashboard-panes/metrics-pane.ts +34 -34
- package/src/ui/dynamic-border.ts +25 -25
- package/src/ui/layout-primitives.ts +106 -106
- package/src/ui/loaders.ts +158 -158
- package/src/ui/mascot.ts +441 -441
- package/src/ui/render-diff.ts +119 -119
- package/src/ui/run-dashboard.ts +5 -2
- package/src/ui/run-snapshot-cache.ts +19 -8
- package/src/ui/spinner.ts +17 -17
- package/src/ui/status-colors.ts +54 -54
- package/src/ui/syntax-highlight.ts +116 -116
- package/src/ui/transcript-viewer.ts +15 -1
- package/src/utils/completion-dedupe.ts +63 -63
- package/src/utils/file-coalescer.ts +84 -84
- package/src/utils/frontmatter.ts +36 -36
- package/src/utils/fs-watch.ts +31 -31
- package/src/utils/git.ts +262 -262
- package/src/utils/ids.ts +12 -12
- package/src/utils/names.ts +26 -26
- package/src/utils/paths.ts +3 -2
- package/src/utils/safe-paths.ts +34 -0
- package/src/utils/sleep.ts +32 -32
- package/src/utils/timings.ts +31 -31
- package/src/utils/visual.ts +159 -159
- package/src/workflows/discover-workflows.ts +30 -3
- package/src/workflows/validate-workflow.ts +40 -40
- package/src/worktree/branch-freshness.ts +45 -45
- package/teams/default.team.md +12 -12
- package/teams/fast-fix.team.md +11 -11
- package/teams/implementation.team.md +18 -18
- package/teams/parallel-research.team.md +14 -14
- package/teams/research.team.md +11 -11
- package/teams/review.team.md +12 -12
- package/workflows/default.workflow.md +29 -29
- package/workflows/fast-fix.workflow.md +22 -22
- package/workflows/implementation.workflow.md +38 -38
- package/workflows/parallel-research.workflow.md +46 -46
- package/workflows/research.workflow.md +22 -22
- package/workflows/review.workflow.md +30 -30
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import type { UsageState } from "../../state/types.ts";
|
|
2
|
-
import type { CrewAgentProgress } from "../crew-agent-runtime.ts";
|
|
3
|
-
import { emptyCrewAgentProgress } from "../crew-agent-records.ts";
|
|
4
|
-
import type { ProgressEventSummary } from "../progress-event-coalescer.ts";
|
|
5
|
-
import type { TeamTaskState } from "../../state/types.ts";
|
|
6
|
-
|
|
7
|
-
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
8
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function textFromContent(content: unknown): string[] {
|
|
12
|
-
if (typeof content === "string") return [content];
|
|
13
|
-
if (!Array.isArray(content)) return [];
|
|
14
|
-
const text: string[] = [];
|
|
15
|
-
for (const part of content) {
|
|
16
|
-
const obj = asRecord(part);
|
|
17
|
-
if (!obj) continue;
|
|
18
|
-
if (obj.type === "text" && typeof obj.text === "string") text.push(obj.text);
|
|
19
|
-
else if (typeof obj.content === "string") text.push(obj.content);
|
|
20
|
-
}
|
|
21
|
-
return text;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function eventText(event: unknown): string[] {
|
|
25
|
-
const obj = asRecord(event);
|
|
26
|
-
if (!obj) return [];
|
|
27
|
-
const text: string[] = [];
|
|
28
|
-
if (typeof obj.text === "string") text.push(obj.text);
|
|
29
|
-
if (typeof obj.output === "string") text.push(obj.output);
|
|
30
|
-
text.push(...textFromContent(obj.content));
|
|
31
|
-
const message = asRecord(obj.message);
|
|
32
|
-
if (message) text.push(...textFromContent(message.content));
|
|
33
|
-
return text.filter((entry) => entry.trim());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function numberField(obj: Record<string, unknown>, keys: string[]): number | undefined {
|
|
37
|
-
for (const key of keys) {
|
|
38
|
-
const value = obj[key];
|
|
39
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function eventUsage(event: unknown): { input?: number; output?: number; turns?: number } | undefined {
|
|
45
|
-
const obj = asRecord(event);
|
|
46
|
-
if (!obj) return undefined;
|
|
47
|
-
const direct = { input: numberField(obj, ["input", "inputTokens", "input_tokens"]), output: numberField(obj, ["output", "outputTokens", "output_tokens"]), turns: numberField(obj, ["turns", "turnCount", "turn_count"]) };
|
|
48
|
-
if (Object.values(direct).some((value) => value !== undefined)) return direct;
|
|
49
|
-
for (const key of ["usage", "tokenUsage", "tokens", "stats"]) {
|
|
50
|
-
const nested = eventUsage(obj[key]);
|
|
51
|
-
if (nested) return nested;
|
|
52
|
-
}
|
|
53
|
-
const message = asRecord(obj.message);
|
|
54
|
-
return message ? eventUsage(message.usage) : undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function previewArgs(args: unknown): string | undefined {
|
|
58
|
-
if (!args) return undefined;
|
|
59
|
-
try {
|
|
60
|
-
const text = typeof args === "string" ? args : JSON.stringify(args);
|
|
61
|
-
return text.length > 240 ? `${text.slice(0, 240)}…` : text;
|
|
62
|
-
} catch {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function applyUsageToProgress(progress: CrewAgentProgress | undefined, usage: UsageState | undefined): CrewAgentProgress | undefined {
|
|
68
|
-
if (!usage) return progress;
|
|
69
|
-
const base = progress ?? emptyCrewAgentProgress();
|
|
70
|
-
return { ...base, tokens: (usage.input ?? 0) + (usage.output ?? 0) + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0), turns: usage.turns ?? base.turns };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function shouldFlushProgressEvent(event: unknown): boolean {
|
|
74
|
-
const type = asRecord(event)?.type;
|
|
75
|
-
return type === "tool_execution_start" || type === "tool_execution_end" || type === "message_end" || type === "tool_result_end";
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function progressEventSummary(task: TeamTaskState, event: unknown): ProgressEventSummary {
|
|
79
|
-
const type = asRecord(event)?.type;
|
|
80
|
-
return { eventType: typeof type === "string" ? type : "event", currentTool: task.agentProgress?.currentTool, toolCount: task.agentProgress?.toolCount, tokens: task.agentProgress?.tokens, turns: task.agentProgress?.turns, activityState: task.agentProgress?.activityState, lastActivityAt: task.agentProgress?.lastActivityAt };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function applyAgentProgressEvent(progress: CrewAgentProgress, event: unknown, startedAt: string | undefined): CrewAgentProgress {
|
|
84
|
-
const obj = asRecord(event);
|
|
85
|
-
const now = new Date().toISOString();
|
|
86
|
-
const next: CrewAgentProgress = { ...progress, recentTools: [...progress.recentTools], recentOutput: [...progress.recentOutput], lastActivityAt: now, activityState: "active" };
|
|
87
|
-
if (startedAt) next.durationMs = Date.now() - new Date(startedAt).getTime();
|
|
88
|
-
if (obj?.type === "tool_execution_start") {
|
|
89
|
-
next.toolCount += 1;
|
|
90
|
-
next.currentTool = typeof obj.toolName === "string" ? obj.toolName : typeof obj.name === "string" ? obj.name : "tool";
|
|
91
|
-
next.currentToolArgs = previewArgs(obj.args);
|
|
92
|
-
next.currentToolStartedAt = now;
|
|
93
|
-
}
|
|
94
|
-
if (obj?.type === "tool_execution_end") {
|
|
95
|
-
if (next.currentTool) next.recentTools.push({ tool: next.currentTool, args: next.currentToolArgs, endedAt: now });
|
|
96
|
-
next.currentTool = undefined;
|
|
97
|
-
next.currentToolArgs = undefined;
|
|
98
|
-
next.currentToolStartedAt = undefined;
|
|
99
|
-
}
|
|
100
|
-
if ((obj?.type === "tool_execution_error" || obj?.type === "tool_execution_failed") && next.currentTool) next.failedTool = next.currentTool;
|
|
101
|
-
const usage = eventUsage(event);
|
|
102
|
-
if (usage) {
|
|
103
|
-
next.tokens = (usage.input ?? 0) + (usage.output ?? 0);
|
|
104
|
-
next.turns = usage.turns ?? next.turns;
|
|
105
|
-
}
|
|
106
|
-
const text = eventText(event);
|
|
107
|
-
if (text.length > 0) next.recentOutput.push(...text.flatMap((entry) => entry.split(/\r?\n/)).filter(Boolean).slice(-10));
|
|
108
|
-
if (next.recentTools.length > 25) next.recentTools.splice(0, next.recentTools.length - 25);
|
|
109
|
-
if (next.recentOutput.length > 50) next.recentOutput.splice(0, next.recentOutput.length - 50);
|
|
110
|
-
return next;
|
|
111
|
-
}
|
|
1
|
+
import type { UsageState } from "../../state/types.ts";
|
|
2
|
+
import type { CrewAgentProgress } from "../crew-agent-runtime.ts";
|
|
3
|
+
import { emptyCrewAgentProgress } from "../crew-agent-records.ts";
|
|
4
|
+
import type { ProgressEventSummary } from "../progress-event-coalescer.ts";
|
|
5
|
+
import type { TeamTaskState } from "../../state/types.ts";
|
|
6
|
+
|
|
7
|
+
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
8
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function textFromContent(content: unknown): string[] {
|
|
12
|
+
if (typeof content === "string") return [content];
|
|
13
|
+
if (!Array.isArray(content)) return [];
|
|
14
|
+
const text: string[] = [];
|
|
15
|
+
for (const part of content) {
|
|
16
|
+
const obj = asRecord(part);
|
|
17
|
+
if (!obj) continue;
|
|
18
|
+
if (obj.type === "text" && typeof obj.text === "string") text.push(obj.text);
|
|
19
|
+
else if (typeof obj.content === "string") text.push(obj.content);
|
|
20
|
+
}
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function eventText(event: unknown): string[] {
|
|
25
|
+
const obj = asRecord(event);
|
|
26
|
+
if (!obj) return [];
|
|
27
|
+
const text: string[] = [];
|
|
28
|
+
if (typeof obj.text === "string") text.push(obj.text);
|
|
29
|
+
if (typeof obj.output === "string") text.push(obj.output);
|
|
30
|
+
text.push(...textFromContent(obj.content));
|
|
31
|
+
const message = asRecord(obj.message);
|
|
32
|
+
if (message) text.push(...textFromContent(message.content));
|
|
33
|
+
return text.filter((entry) => entry.trim());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function numberField(obj: Record<string, unknown>, keys: string[]): number | undefined {
|
|
37
|
+
for (const key of keys) {
|
|
38
|
+
const value = obj[key];
|
|
39
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function eventUsage(event: unknown): { input?: number; output?: number; turns?: number } | undefined {
|
|
45
|
+
const obj = asRecord(event);
|
|
46
|
+
if (!obj) return undefined;
|
|
47
|
+
const direct = { input: numberField(obj, ["input", "inputTokens", "input_tokens"]), output: numberField(obj, ["output", "outputTokens", "output_tokens"]), turns: numberField(obj, ["turns", "turnCount", "turn_count"]) };
|
|
48
|
+
if (Object.values(direct).some((value) => value !== undefined)) return direct;
|
|
49
|
+
for (const key of ["usage", "tokenUsage", "tokens", "stats"]) {
|
|
50
|
+
const nested = eventUsage(obj[key]);
|
|
51
|
+
if (nested) return nested;
|
|
52
|
+
}
|
|
53
|
+
const message = asRecord(obj.message);
|
|
54
|
+
return message ? eventUsage(message.usage) : undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function previewArgs(args: unknown): string | undefined {
|
|
58
|
+
if (!args) return undefined;
|
|
59
|
+
try {
|
|
60
|
+
const text = typeof args === "string" ? args : JSON.stringify(args);
|
|
61
|
+
return text.length > 240 ? `${text.slice(0, 240)}…` : text;
|
|
62
|
+
} catch {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function applyUsageToProgress(progress: CrewAgentProgress | undefined, usage: UsageState | undefined): CrewAgentProgress | undefined {
|
|
68
|
+
if (!usage) return progress;
|
|
69
|
+
const base = progress ?? emptyCrewAgentProgress();
|
|
70
|
+
return { ...base, tokens: (usage.input ?? 0) + (usage.output ?? 0) + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0), turns: usage.turns ?? base.turns };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function shouldFlushProgressEvent(event: unknown): boolean {
|
|
74
|
+
const type = asRecord(event)?.type;
|
|
75
|
+
return type === "tool_execution_start" || type === "tool_execution_end" || type === "message_end" || type === "tool_result_end";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function progressEventSummary(task: TeamTaskState, event: unknown): ProgressEventSummary {
|
|
79
|
+
const type = asRecord(event)?.type;
|
|
80
|
+
return { eventType: typeof type === "string" ? type : "event", currentTool: task.agentProgress?.currentTool, toolCount: task.agentProgress?.toolCount, tokens: task.agentProgress?.tokens, turns: task.agentProgress?.turns, activityState: task.agentProgress?.activityState, lastActivityAt: task.agentProgress?.lastActivityAt };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function applyAgentProgressEvent(progress: CrewAgentProgress, event: unknown, startedAt: string | undefined): CrewAgentProgress {
|
|
84
|
+
const obj = asRecord(event);
|
|
85
|
+
const now = new Date().toISOString();
|
|
86
|
+
const next: CrewAgentProgress = { ...progress, recentTools: [...progress.recentTools], recentOutput: [...progress.recentOutput], lastActivityAt: now, activityState: "active" };
|
|
87
|
+
if (startedAt) next.durationMs = Date.now() - new Date(startedAt).getTime();
|
|
88
|
+
if (obj?.type === "tool_execution_start") {
|
|
89
|
+
next.toolCount += 1;
|
|
90
|
+
next.currentTool = typeof obj.toolName === "string" ? obj.toolName : typeof obj.name === "string" ? obj.name : "tool";
|
|
91
|
+
next.currentToolArgs = previewArgs(obj.args);
|
|
92
|
+
next.currentToolStartedAt = now;
|
|
93
|
+
}
|
|
94
|
+
if (obj?.type === "tool_execution_end") {
|
|
95
|
+
if (next.currentTool) next.recentTools.push({ tool: next.currentTool, args: next.currentToolArgs, endedAt: now });
|
|
96
|
+
next.currentTool = undefined;
|
|
97
|
+
next.currentToolArgs = undefined;
|
|
98
|
+
next.currentToolStartedAt = undefined;
|
|
99
|
+
}
|
|
100
|
+
if ((obj?.type === "tool_execution_error" || obj?.type === "tool_execution_failed") && next.currentTool) next.failedTool = next.currentTool;
|
|
101
|
+
const usage = eventUsage(event);
|
|
102
|
+
if (usage) {
|
|
103
|
+
next.tokens = (usage.input ?? 0) + (usage.output ?? 0);
|
|
104
|
+
next.turns = usage.turns ?? next.turns;
|
|
105
|
+
}
|
|
106
|
+
const text = eventText(event);
|
|
107
|
+
if (text.length > 0) next.recentOutput.push(...text.flatMap((entry) => entry.split(/\r?\n/)).filter(Boolean).slice(-10));
|
|
108
|
+
if (next.recentTools.length > 25) next.recentTools.splice(0, next.recentTools.length - 25);
|
|
109
|
+
if (next.recentOutput.length > 50) next.recentOutput.splice(0, next.recentOutput.length - 50);
|
|
110
|
+
return next;
|
|
111
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function cleanResultText(text: string | undefined): string | undefined {
|
|
2
|
-
const trimmed = text?.trim();
|
|
3
|
-
if (!trimmed) return undefined;
|
|
4
|
-
const doneIndex = trimmed.lastIndexOf("\nDONE\n");
|
|
5
|
-
if (doneIndex >= 0) return trimmed.slice(doneIndex + 1).trim();
|
|
6
|
-
if (trimmed === "DONE" || trimmed.startsWith("DONE\n")) return trimmed;
|
|
7
|
-
const fencedPromptIndex = trimmed.lastIndexOf("</file>");
|
|
8
|
-
if (fencedPromptIndex >= 0 && fencedPromptIndex < trimmed.length - 7) return trimmed.slice(fencedPromptIndex + 7).trim() || trimmed;
|
|
9
|
-
return trimmed;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function isFinalChildEvent(event: unknown): boolean {
|
|
13
|
-
return Boolean(event && typeof event === "object" && !Array.isArray(event) && (event as Record<string, unknown>).type === "message_end");
|
|
14
|
-
}
|
|
1
|
+
export function cleanResultText(text: string | undefined): string | undefined {
|
|
2
|
+
const trimmed = text?.trim();
|
|
3
|
+
if (!trimmed) return undefined;
|
|
4
|
+
const doneIndex = trimmed.lastIndexOf("\nDONE\n");
|
|
5
|
+
if (doneIndex >= 0) return trimmed.slice(doneIndex + 1).trim();
|
|
6
|
+
if (trimmed === "DONE" || trimmed.startsWith("DONE\n")) return trimmed;
|
|
7
|
+
const fencedPromptIndex = trimmed.lastIndexOf("</file>");
|
|
8
|
+
if (fencedPromptIndex >= 0 && fencedPromptIndex < trimmed.length - 7) return trimmed.slice(fencedPromptIndex + 7).trim() || trimmed;
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isFinalChildEvent(event: unknown): boolean {
|
|
13
|
+
return Boolean(event && typeof event === "object" && !Array.isArray(event) && (event as Record<string, unknown>).type === "message_end");
|
|
14
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { TaskCheckpointState, TeamRunManifest, TeamTaskState } from "../../state/types.ts";
|
|
2
|
-
import { loadRunManifestById, saveRunTasks } from "../../state/state-store.ts";
|
|
3
|
-
import { recordFromTask, upsertCrewAgent } from "../crew-agent-records.ts";
|
|
4
|
-
|
|
5
|
-
export function updateTask(tasks: TeamTaskState[], updated: TeamTaskState): TeamTaskState[] {
|
|
6
|
-
return tasks.map((task) => task.id === updated.id ? updated : task);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function persistSingleTaskUpdate(manifest: TeamRunManifest, fallbackTasks: TeamTaskState[], updated: TeamTaskState): TeamTaskState[] {
|
|
10
|
-
const latest = loadRunManifestById(manifest.cwd, manifest.runId)?.tasks ?? fallbackTasks;
|
|
11
|
-
const merged = updateTask(latest, updated);
|
|
12
|
-
saveRunTasks(manifest, merged);
|
|
13
|
-
return merged;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function checkpointTask(manifest: TeamRunManifest, tasks: TeamTaskState[], task: TeamTaskState, phase: TaskCheckpointState["phase"], childPid?: number): { task: TeamTaskState; tasks: TeamTaskState[] } {
|
|
17
|
-
const checkpoint: TaskCheckpointState = { phase, updatedAt: new Date().toISOString(), ...(childPid ? { childPid } : task.checkpoint?.childPid ? { childPid: task.checkpoint.childPid } : {}) };
|
|
18
|
-
const nextTask = { ...task, checkpoint };
|
|
19
|
-
const nextTasks = persistSingleTaskUpdate(manifest, updateTask(tasks, nextTask), nextTask);
|
|
20
|
-
upsertCrewAgent(manifest, recordFromTask(manifest, nextTask, "child-process"));
|
|
21
|
-
return { task: nextTask, tasks: nextTasks };
|
|
22
|
-
}
|
|
1
|
+
import type { TaskCheckpointState, TeamRunManifest, TeamTaskState } from "../../state/types.ts";
|
|
2
|
+
import { loadRunManifestById, saveRunTasks } from "../../state/state-store.ts";
|
|
3
|
+
import { recordFromTask, upsertCrewAgent } from "../crew-agent-records.ts";
|
|
4
|
+
|
|
5
|
+
export function updateTask(tasks: TeamTaskState[], updated: TeamTaskState): TeamTaskState[] {
|
|
6
|
+
return tasks.map((task) => task.id === updated.id ? updated : task);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function persistSingleTaskUpdate(manifest: TeamRunManifest, fallbackTasks: TeamTaskState[], updated: TeamTaskState): TeamTaskState[] {
|
|
10
|
+
const latest = loadRunManifestById(manifest.cwd, manifest.runId)?.tasks ?? fallbackTasks;
|
|
11
|
+
const merged = updateTask(latest, updated);
|
|
12
|
+
saveRunTasks(manifest, merged);
|
|
13
|
+
return merged;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function checkpointTask(manifest: TeamRunManifest, tasks: TeamTaskState[], task: TeamTaskState, phase: TaskCheckpointState["phase"], childPid?: number): { task: TeamTaskState; tasks: TeamTaskState[] } {
|
|
17
|
+
const checkpoint: TaskCheckpointState = { phase, updatedAt: new Date().toISOString(), ...(childPid ? { childPid } : task.checkpoint?.childPid ? { childPid: task.checkpoint.childPid } : {}) };
|
|
18
|
+
const nextTask = { ...task, checkpoint };
|
|
19
|
+
const nextTasks = persistSingleTaskUpdate(manifest, updateTask(tasks, nextTask), nextTask);
|
|
20
|
+
upsertCrewAgent(manifest, recordFromTask(manifest, nextTask, "child-process"));
|
|
21
|
+
return { task: nextTask, tasks: nextTasks };
|
|
22
|
+
}
|
|
@@ -529,7 +529,7 @@ export async function executeTeamRun(input: ExecuteTeamRunInput): Promise<{ mani
|
|
|
529
529
|
kind: "summary",
|
|
530
530
|
relativePath: `batches/${readyBatch.map((task) => task.id).join("+")}.md`,
|
|
531
531
|
producer: "team-runner",
|
|
532
|
-
content: aggregateTaskOutputs(completedBatch),
|
|
532
|
+
content: aggregateTaskOutputs(completedBatch, manifest),
|
|
533
533
|
});
|
|
534
534
|
const groupDelivery = deliverGroupJoin({ manifest, mode: resolveGroupJoinMode(input.runtimeConfig), batch: readyBatch, allTasks: tasks });
|
|
535
535
|
manifest = { ...manifest, artifacts: mergeArtifacts([...manifest.artifacts, batchArtifact, ...(groupDelivery?.artifact ? [groupDelivery.artifact] : [])]) };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export interface WorkerHeartbeatState {
|
|
2
|
-
workerId: string;
|
|
3
|
-
pid?: number;
|
|
4
|
-
lastSeenAt: string;
|
|
5
|
-
lastStdoutAt?: string;
|
|
6
|
-
lastEventAt?: string;
|
|
7
|
-
turnCount?: number;
|
|
8
|
-
alive?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function createWorkerHeartbeat(workerId: string, pid?: number, now = new Date()): WorkerHeartbeatState {
|
|
12
|
-
return { workerId, pid, lastSeenAt: now.toISOString(), alive: true };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function touchWorkerHeartbeat(heartbeat: WorkerHeartbeatState, updates: Partial<Omit<WorkerHeartbeatState, "workerId">> = {}, now = new Date()): WorkerHeartbeatState {
|
|
16
|
-
return { ...heartbeat, ...updates, lastSeenAt: now.toISOString() };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function isWorkerHeartbeatStale(heartbeat: WorkerHeartbeatState, staleMs: number, now = new Date()): boolean {
|
|
20
|
-
return now.getTime() - Date.parse(heartbeat.lastSeenAt) > staleMs;
|
|
21
|
-
}
|
|
1
|
+
export interface WorkerHeartbeatState {
|
|
2
|
+
workerId: string;
|
|
3
|
+
pid?: number;
|
|
4
|
+
lastSeenAt: string;
|
|
5
|
+
lastStdoutAt?: string;
|
|
6
|
+
lastEventAt?: string;
|
|
7
|
+
turnCount?: number;
|
|
8
|
+
alive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createWorkerHeartbeat(workerId: string, pid?: number, now = new Date()): WorkerHeartbeatState {
|
|
12
|
+
return { workerId, pid, lastSeenAt: now.toISOString(), alive: true };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function touchWorkerHeartbeat(heartbeat: WorkerHeartbeatState, updates: Partial<Omit<WorkerHeartbeatState, "workerId">> = {}, now = new Date()): WorkerHeartbeatState {
|
|
16
|
+
return { ...heartbeat, ...updates, lastSeenAt: now.toISOString() };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isWorkerHeartbeatStale(heartbeat: WorkerHeartbeatState, staleMs: number, now = new Date()): boolean {
|
|
20
|
+
return now.getTime() - Date.parse(heartbeat.lastSeenAt) > staleMs;
|
|
21
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
export type WorkerLifecycleState = "spawning" | "trust_required" | "ready_for_prompt" | "running" | "finished" | "failed";
|
|
2
|
-
export type StartupFailureClassification = "trust_required" | "prompt_misdelivery" | "prompt_acceptance_timeout" | "transport_dead" | "worker_crashed" | "unknown";
|
|
3
|
-
|
|
4
|
-
export interface WorkerStartupEvidence {
|
|
5
|
-
lastLifecycleState: WorkerLifecycleState;
|
|
6
|
-
command: string;
|
|
7
|
-
promptSentAt?: string;
|
|
8
|
-
promptAccepted: boolean;
|
|
9
|
-
trustPromptDetected: boolean;
|
|
10
|
-
transportHealthy: boolean;
|
|
11
|
-
childProcessAlive: boolean;
|
|
12
|
-
elapsedMs: number;
|
|
13
|
-
classification: StartupFailureClassification;
|
|
14
|
-
stderrPreview?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function detectTrustPrompt(text: string): boolean {
|
|
18
|
-
const lowered = text.toLowerCase();
|
|
19
|
-
return lowered.includes("do you trust") || lowered.includes("trust this") || lowered.includes("untrusted") || lowered.includes("workspace trust") || lowered.includes("allow this folder");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function classifyStartupFailure(evidence: Omit<WorkerStartupEvidence, "classification">): StartupFailureClassification {
|
|
23
|
-
if (!evidence.transportHealthy) return "transport_dead";
|
|
24
|
-
if (evidence.trustPromptDetected || evidence.lastLifecycleState === "trust_required") return "trust_required";
|
|
25
|
-
if (evidence.promptSentAt && !evidence.promptAccepted && evidence.childProcessAlive) return "prompt_acceptance_timeout";
|
|
26
|
-
if (evidence.promptSentAt && !evidence.promptAccepted && !evidence.childProcessAlive) return "worker_crashed";
|
|
27
|
-
if (evidence.stderrPreview?.toLowerCase().includes("command not found") || evidence.stderrPreview?.toLowerCase().includes("not recognized")) return "prompt_misdelivery";
|
|
28
|
-
if (!evidence.childProcessAlive && evidence.lastLifecycleState !== "finished") return "worker_crashed";
|
|
29
|
-
return "unknown";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function createStartupEvidence(input: {
|
|
33
|
-
command: string;
|
|
34
|
-
startedAt: Date;
|
|
35
|
-
finishedAt?: Date;
|
|
36
|
-
promptSentAt?: Date;
|
|
37
|
-
promptAccepted?: boolean;
|
|
38
|
-
stderr?: string;
|
|
39
|
-
error?: string;
|
|
40
|
-
exitCode?: number | null;
|
|
41
|
-
}): WorkerStartupEvidence {
|
|
42
|
-
const stderrPreview = (input.error || input.stderr || "").slice(0, 500) || undefined;
|
|
43
|
-
const trustPromptDetected = detectTrustPrompt(stderrPreview ?? "");
|
|
44
|
-
const childProcessAlive = input.exitCode === undefined || input.exitCode === null ? !input.finishedAt : false;
|
|
45
|
-
const base: Omit<WorkerStartupEvidence, "classification"> = {
|
|
46
|
-
lastLifecycleState: input.error || (input.exitCode !== undefined && input.exitCode !== null && input.exitCode !== 0) ? "failed" : input.finishedAt ? "finished" : "running",
|
|
47
|
-
command: input.command,
|
|
48
|
-
promptSentAt: input.promptSentAt?.toISOString(),
|
|
49
|
-
promptAccepted: input.promptAccepted ?? !input.error,
|
|
50
|
-
trustPromptDetected,
|
|
51
|
-
transportHealthy: !input.error || !/enoent|spawn|transport/i.test(input.error),
|
|
52
|
-
childProcessAlive,
|
|
53
|
-
elapsedMs: Math.max(0, (input.finishedAt ?? new Date()).getTime() - input.startedAt.getTime()),
|
|
54
|
-
stderrPreview,
|
|
55
|
-
};
|
|
56
|
-
return { ...base, classification: classifyStartupFailure(base) };
|
|
57
|
-
}
|
|
1
|
+
export type WorkerLifecycleState = "spawning" | "trust_required" | "ready_for_prompt" | "running" | "finished" | "failed";
|
|
2
|
+
export type StartupFailureClassification = "trust_required" | "prompt_misdelivery" | "prompt_acceptance_timeout" | "transport_dead" | "worker_crashed" | "unknown";
|
|
3
|
+
|
|
4
|
+
export interface WorkerStartupEvidence {
|
|
5
|
+
lastLifecycleState: WorkerLifecycleState;
|
|
6
|
+
command: string;
|
|
7
|
+
promptSentAt?: string;
|
|
8
|
+
promptAccepted: boolean;
|
|
9
|
+
trustPromptDetected: boolean;
|
|
10
|
+
transportHealthy: boolean;
|
|
11
|
+
childProcessAlive: boolean;
|
|
12
|
+
elapsedMs: number;
|
|
13
|
+
classification: StartupFailureClassification;
|
|
14
|
+
stderrPreview?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function detectTrustPrompt(text: string): boolean {
|
|
18
|
+
const lowered = text.toLowerCase();
|
|
19
|
+
return lowered.includes("do you trust") || lowered.includes("trust this") || lowered.includes("untrusted") || lowered.includes("workspace trust") || lowered.includes("allow this folder");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function classifyStartupFailure(evidence: Omit<WorkerStartupEvidence, "classification">): StartupFailureClassification {
|
|
23
|
+
if (!evidence.transportHealthy) return "transport_dead";
|
|
24
|
+
if (evidence.trustPromptDetected || evidence.lastLifecycleState === "trust_required") return "trust_required";
|
|
25
|
+
if (evidence.promptSentAt && !evidence.promptAccepted && evidence.childProcessAlive) return "prompt_acceptance_timeout";
|
|
26
|
+
if (evidence.promptSentAt && !evidence.promptAccepted && !evidence.childProcessAlive) return "worker_crashed";
|
|
27
|
+
if (evidence.stderrPreview?.toLowerCase().includes("command not found") || evidence.stderrPreview?.toLowerCase().includes("not recognized")) return "prompt_misdelivery";
|
|
28
|
+
if (!evidence.childProcessAlive && evidence.lastLifecycleState !== "finished") return "worker_crashed";
|
|
29
|
+
return "unknown";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createStartupEvidence(input: {
|
|
33
|
+
command: string;
|
|
34
|
+
startedAt: Date;
|
|
35
|
+
finishedAt?: Date;
|
|
36
|
+
promptSentAt?: Date;
|
|
37
|
+
promptAccepted?: boolean;
|
|
38
|
+
stderr?: string;
|
|
39
|
+
error?: string;
|
|
40
|
+
exitCode?: number | null;
|
|
41
|
+
}): WorkerStartupEvidence {
|
|
42
|
+
const stderrPreview = (input.error || input.stderr || "").slice(0, 500) || undefined;
|
|
43
|
+
const trustPromptDetected = detectTrustPrompt(stderrPreview ?? "");
|
|
44
|
+
const childProcessAlive = input.exitCode === undefined || input.exitCode === null ? !input.finishedAt : false;
|
|
45
|
+
const base: Omit<WorkerStartupEvidence, "classification"> = {
|
|
46
|
+
lastLifecycleState: input.error || (input.exitCode !== undefined && input.exitCode !== null && input.exitCode !== 0) ? "failed" : input.finishedAt ? "finished" : "running",
|
|
47
|
+
command: input.command,
|
|
48
|
+
promptSentAt: input.promptSentAt?.toISOString(),
|
|
49
|
+
promptAccepted: input.promptAccepted ?? !input.error,
|
|
50
|
+
trustPromptDetected,
|
|
51
|
+
transportHealthy: !input.error || !/enoent|spawn|transport/i.test(input.error),
|
|
52
|
+
childProcessAlive,
|
|
53
|
+
elapsedMs: Math.max(0, (input.finishedAt ?? new Date()).getTime() - input.startedAt.getTime()),
|
|
54
|
+
stderrPreview,
|
|
55
|
+
};
|
|
56
|
+
return { ...base, classification: classifyStartupFailure(base) };
|
|
57
|
+
}
|
|
@@ -14,7 +14,7 @@ export const PiTeamsAutonomousConfigSchema = Type.Object({
|
|
|
14
14
|
preferAsyncForLongTasks: Type.Optional(Type.Boolean()),
|
|
15
15
|
allowWorktreeSuggestion: Type.Optional(Type.Boolean()),
|
|
16
16
|
magicKeywords: Type.Optional(Type.Record(Type.String({ minLength: 1 }), Type.Array(Type.String({ minLength: 1 })))),
|
|
17
|
-
});
|
|
17
|
+
}, { additionalProperties: false });
|
|
18
18
|
|
|
19
19
|
export const PiTeamsLimitsConfigSchema = Type.Object({
|
|
20
20
|
maxConcurrentWorkers: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
@@ -25,7 +25,7 @@ export const PiTeamsLimitsConfigSchema = Type.Object({
|
|
|
25
25
|
maxRetriesPerTask: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
26
26
|
maxTasksPerRun: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
27
27
|
heartbeatStaleMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
28
|
-
});
|
|
28
|
+
}, { additionalProperties: false });
|
|
29
29
|
|
|
30
30
|
export const PiTeamsRuntimeConfigSchema = Type.Object({
|
|
31
31
|
mode: Type.Optional(Type.Union([Type.Literal("auto"), Type.Literal("scaffold"), Type.Literal("child-process"), Type.Literal("live-session")])),
|
|
@@ -36,18 +36,18 @@ export const PiTeamsRuntimeConfigSchema = Type.Object({
|
|
|
36
36
|
inheritContext: Type.Optional(Type.Boolean()),
|
|
37
37
|
promptMode: Type.Optional(Type.Union([Type.Literal("replace"), Type.Literal("append")])),
|
|
38
38
|
groupJoin: Type.Optional(Type.Union([Type.Literal("off"), Type.Literal("group"), Type.Literal("smart")])),
|
|
39
|
-
});
|
|
39
|
+
}, { additionalProperties: false });
|
|
40
40
|
|
|
41
41
|
export const PiTeamsControlConfigSchema = Type.Object({
|
|
42
42
|
enabled: Type.Optional(Type.Boolean()),
|
|
43
43
|
needsAttentionAfterMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
44
|
-
});
|
|
44
|
+
}, { additionalProperties: false });
|
|
45
45
|
|
|
46
46
|
export const PiTeamsWorktreeConfigSchema = Type.Object({
|
|
47
47
|
setupHook: Type.Optional(Type.String({ minLength: 1 })),
|
|
48
48
|
setupHookTimeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
49
49
|
linkNodeModules: Type.Optional(Type.Boolean()),
|
|
50
|
-
});
|
|
50
|
+
}, { additionalProperties: false });
|
|
51
51
|
|
|
52
52
|
export const AgentOverrideSchema = Type.Object({
|
|
53
53
|
disabled: Type.Optional(Type.Boolean()),
|
|
@@ -55,22 +55,22 @@ export const AgentOverrideSchema = Type.Object({
|
|
|
55
55
|
fallbackModels: Type.Optional(Type.Union([Type.Array(Type.String({ minLength: 1 })), Type.Literal(false)])),
|
|
56
56
|
thinking: Type.Optional(Type.Union([Type.String({ minLength: 1 }), Type.Literal(false)])),
|
|
57
57
|
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
58
|
-
});
|
|
58
|
+
}, { additionalProperties: false });
|
|
59
59
|
|
|
60
60
|
export const PiTeamsAgentsConfigSchema = Type.Object({
|
|
61
61
|
disableBuiltins: Type.Optional(Type.Boolean()),
|
|
62
62
|
overrides: Type.Optional(Type.Record(Type.String({ minLength: 1 }), AgentOverrideSchema)),
|
|
63
|
-
});
|
|
63
|
+
}, { additionalProperties: false });
|
|
64
64
|
|
|
65
65
|
export const PiTeamsToolsConfigSchema = Type.Object({
|
|
66
66
|
enableClaudeStyleAliases: Type.Optional(Type.Boolean()),
|
|
67
67
|
enableSteer: Type.Optional(Type.Boolean()),
|
|
68
68
|
terminateOnForeground: Type.Optional(Type.Boolean()),
|
|
69
|
-
});
|
|
69
|
+
}, { additionalProperties: false });
|
|
70
70
|
|
|
71
71
|
export const PiTeamsTelemetryConfigSchema = Type.Object({
|
|
72
72
|
enabled: Type.Optional(Type.Boolean()),
|
|
73
|
-
});
|
|
73
|
+
}, { additionalProperties: false });
|
|
74
74
|
|
|
75
75
|
export const PiTeamsNotificationsConfigSchema = Type.Object({
|
|
76
76
|
enabled: Type.Optional(Type.Boolean()),
|
|
@@ -79,13 +79,13 @@ export const PiTeamsNotificationsConfigSchema = Type.Object({
|
|
|
79
79
|
batchWindowMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
80
80
|
quietHours: Type.Optional(Type.String({ pattern: "^\\d{2}:\\d{2}-\\d{2}:\\d{2}$" })),
|
|
81
81
|
sinkRetentionDays: Type.Optional(Type.Integer({ minimum: 1, maximum: 90 })),
|
|
82
|
-
});
|
|
82
|
+
}, { additionalProperties: false });
|
|
83
83
|
|
|
84
84
|
export const PiTeamsObservabilityConfigSchema = Type.Object({
|
|
85
85
|
enabled: Type.Optional(Type.Boolean()),
|
|
86
86
|
pollIntervalMs: Type.Optional(Type.Integer({ minimum: 1000, maximum: 60000 })),
|
|
87
87
|
metricRetentionDays: Type.Optional(Type.Integer({ minimum: 1, maximum: 365 })),
|
|
88
|
-
});
|
|
88
|
+
}, { additionalProperties: false });
|
|
89
89
|
|
|
90
90
|
export const PiTeamsReliabilityConfigSchema = Type.Object({
|
|
91
91
|
autoRetry: Type.Optional(Type.Boolean()),
|
|
@@ -95,39 +95,39 @@ export const PiTeamsReliabilityConfigSchema = Type.Object({
|
|
|
95
95
|
jitterRatio: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
|
|
96
96
|
exponentialFactor: Type.Optional(Type.Number({ minimum: 1, maximum: 5 })),
|
|
97
97
|
retryableErrors: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
98
|
-
})),
|
|
98
|
+
}, { additionalProperties: false })),
|
|
99
99
|
autoRecover: Type.Optional(Type.Boolean()),
|
|
100
100
|
deadletterThreshold: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
101
|
-
});
|
|
101
|
+
}, { additionalProperties: false });
|
|
102
102
|
|
|
103
103
|
export const PiTeamsOtlpConfigSchema = Type.Object({
|
|
104
104
|
enabled: Type.Optional(Type.Boolean()),
|
|
105
105
|
endpoint: Type.Optional(Type.String({ minLength: 1 })),
|
|
106
106
|
headers: Type.Optional(Type.Record(Type.String({ minLength: 1 }), Type.String())),
|
|
107
107
|
intervalMs: Type.Optional(Type.Integer({ minimum: 5000 })),
|
|
108
|
-
});
|
|
108
|
+
}, { additionalProperties: false });
|
|
109
109
|
|
|
110
110
|
export const PiTeamsUiConfigSchema = Type.Object({
|
|
111
111
|
widgetPlacement: Type.Optional(Type.Union([Type.Literal("aboveEditor"), Type.Literal("belowEditor")])),
|
|
112
|
-
widgetMaxLines: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
112
|
+
widgetMaxLines: Type.Optional(Type.Integer({ minimum: 1, maximum: 50 })),
|
|
113
113
|
powerbar: Type.Optional(Type.Boolean()),
|
|
114
114
|
dashboardPlacement: Type.Optional(Type.Union([Type.Literal("center"), Type.Literal("right")])),
|
|
115
|
-
dashboardWidth: Type.Optional(Type.Integer({ minimum:
|
|
116
|
-
dashboardLiveRefreshMs: Type.Optional(Type.
|
|
115
|
+
dashboardWidth: Type.Optional(Type.Integer({ minimum: 32, maximum: 120 })),
|
|
116
|
+
dashboardLiveRefreshMs: Type.Optional(Type.Integer({ minimum: 250, maximum: 60000 })),
|
|
117
117
|
autoOpenDashboard: Type.Optional(Type.Boolean()),
|
|
118
118
|
autoOpenDashboardForForegroundRuns: Type.Optional(Type.Boolean()),
|
|
119
119
|
showModel: Type.Optional(Type.Boolean()),
|
|
120
120
|
showTokens: Type.Optional(Type.Boolean()),
|
|
121
121
|
showTools: Type.Optional(Type.Boolean()),
|
|
122
|
-
transcriptTailBytes: Type.Optional(Type.
|
|
122
|
+
transcriptTailBytes: Type.Optional(Type.Integer({ minimum: 1024, maximum: 50 * 1024 * 1024 })),
|
|
123
123
|
mascotStyle: Type.Optional(Type.Union([Type.Literal("cat"), Type.Literal("armin")])),
|
|
124
124
|
mascotEffect: Type.Optional(Type.Union([Type.Literal("random"), Type.Literal("none"), Type.Literal("typewriter"), Type.Literal("scanline"), Type.Literal("rain"), Type.Literal("fade"), Type.Literal("crt"), Type.Literal("glitch"), Type.Literal("dissolve")])),
|
|
125
|
-
});
|
|
125
|
+
}, { additionalProperties: false });
|
|
126
126
|
|
|
127
127
|
export const PiTeamsConfigSchema = Type.Object({
|
|
128
128
|
asyncByDefault: Type.Optional(Type.Boolean()),
|
|
129
129
|
executeWorkers: Type.Optional(Type.Boolean()),
|
|
130
|
-
notifierIntervalMs: Type.Optional(Type.
|
|
130
|
+
notifierIntervalMs: Type.Optional(Type.Number({ minimum: 1000 })),
|
|
131
131
|
requireCleanWorktreeLeader: Type.Optional(Type.Boolean()),
|
|
132
132
|
autonomous: Type.Optional(PiTeamsAutonomousConfigSchema),
|
|
133
133
|
limits: Type.Optional(PiTeamsLimitsConfigSchema),
|
|
@@ -142,4 +142,4 @@ export const PiTeamsConfigSchema = Type.Object({
|
|
|
142
142
|
reliability: Type.Optional(PiTeamsReliabilityConfigSchema),
|
|
143
143
|
otlp: Type.Optional(PiTeamsOtlpConfigSchema),
|
|
144
144
|
ui: Type.Optional(PiTeamsUiConfigSchema),
|
|
145
|
-
});
|
|
145
|
+
}, { additionalProperties: false });
|