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
package/docs/runtime-flow.md
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
# pi-crew Runtime Flow
|
|
2
|
-
|
|
3
|
-
This document is a compact map of the runtime paths used by `pi-crew`.
|
|
4
|
-
|
|
5
|
-
## Main sequence
|
|
6
|
-
|
|
7
|
-
```text
|
|
8
|
-
User / model
|
|
9
|
-
│ calls team({ action: "run", ... }) or /team-run
|
|
10
|
-
▼
|
|
11
|
-
handleTeamTool()
|
|
12
|
-
│ validates schema and routes action
|
|
13
|
-
▼
|
|
14
|
-
handleRun()
|
|
15
|
-
├─ discoverTeams/discoverWorkflows/discoverAgents
|
|
16
|
-
├─ validateWorkflowForTeam
|
|
17
|
-
├─ expandParallelResearchWorkflow when applicable
|
|
18
|
-
├─ createRunManifest + tasks.json + goal artifact
|
|
19
|
-
├─ if async=true ─────────────────────────────────────────────┐
|
|
20
|
-
│ spawnBackgroundTeamRun() │
|
|
21
|
-
│ ├─ resolve jiti-register.mjs │
|
|
22
|
-
│ ├─ fail-fast if jiti missing │
|
|
23
|
-
│ ├─ node --import jiti-register.mjs background-runner.ts │
|
|
24
|
-
│ └─ parent schedules early-exit guard │
|
|
25
|
-
│ ▼
|
|
26
|
-
│ background-runner.ts
|
|
27
|
-
│ ├─ append async.started
|
|
28
|
-
│ ├─ write async.pid startup marker
|
|
29
|
-
│ ├─ rediscover team/workflow/agents
|
|
30
|
-
│ └─ executeTeamRun()
|
|
31
|
-
│
|
|
32
|
-
└─ if foreground/default
|
|
33
|
-
├─ startForegroundRun schedules session-bound run, or
|
|
34
|
-
└─ executeTeamRun inline for scaffold/non-scheduled paths
|
|
35
|
-
|
|
36
|
-
executeTeamRun()
|
|
37
|
-
├─ write run.running
|
|
38
|
-
├─ materialize queued/running agent records lazily
|
|
39
|
-
├─ build task graph index
|
|
40
|
-
├─ while queued tasks exist
|
|
41
|
-
│ ├─ taskGraphSnapshot
|
|
42
|
-
│ ├─ resolveBatchConcurrency
|
|
43
|
-
│ ├─ getReadyTasks
|
|
44
|
-
│ ├─ append task.progress batch event
|
|
45
|
-
│ ├─ mapConcurrent ready batch
|
|
46
|
-
│ │ └─ runTeamTask()
|
|
47
|
-
│ │ ├─ prepare workspace/worktree
|
|
48
|
-
│ │ ├─ build task packet
|
|
49
|
-
│ │ ├─ render prompt + dependency context
|
|
50
|
-
│ │ ├─ choose model candidates from Pi config
|
|
51
|
-
│ │ ├─ spawn child Pi process
|
|
52
|
-
│ │ ├─ ChildPiLineObserver parses stdout/stderr
|
|
53
|
-
│ │ ├─ append per-agent events/output
|
|
54
|
-
│ │ ├─ update agent progress/task state
|
|
55
|
-
│ │ ├─ parse final JSONL/session usage
|
|
56
|
-
│ │ └─ write result/log/transcript/metadata artifacts
|
|
57
|
-
│ ├─ merge task updates monotonically
|
|
58
|
-
│ ├─ optional adaptive plan injection
|
|
59
|
-
│ ├─ save tasks/agents/progress
|
|
60
|
-
│ └─ write batch artifact
|
|
61
|
-
├─ policy closeout
|
|
62
|
-
└─ run.completed / run.failed / run.blocked / run.cancelled
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Action router
|
|
66
|
-
|
|
67
|
-
| Action | Handler | Purpose |
|
|
68
|
-
|---|---|---|
|
|
69
|
-
| `run` | `team-tool/run.ts` | Create and execute a run, foreground or async. |
|
|
70
|
-
| `status` | `team-tool.ts` | Show manifest/tasks/agents/events and mark stale async runs failed. |
|
|
71
|
-
| `summary` | `session-summary.ts`/summary handler | Write/read run summary artifact. |
|
|
72
|
-
| `events` | `team-tool.ts` | Tail durable run events. |
|
|
73
|
-
| `artifacts` | `team-tool.ts` | List run artifacts. |
|
|
74
|
-
| `resume` | `team-tool.ts` | Requeue failed/cancelled/skipped/running tasks. |
|
|
75
|
-
| `cancel` | `team-tool.ts` | Mark queued/running tasks cancelled and request foreground interrupt. |
|
|
76
|
-
| `forget` | `run-maintenance.ts` | Delete run state/artifacts with confirmation. |
|
|
77
|
-
| `prune` | `run-maintenance.ts` | Remove old finished runs with confirmation. |
|
|
78
|
-
| `export` | `run-export.ts` | Create portable run bundle. |
|
|
79
|
-
| `import` / `imports` | `run-import.ts` / `import-index.ts` | Store/list imported bundles. |
|
|
80
|
-
| `config` | `config.ts` + config action | Show/update user/project config. |
|
|
81
|
-
| `doctor` | `team-tool/doctor.ts` | Platform/resource/runtime diagnostics. |
|
|
82
|
-
| `validate` | `validate-resources.ts` | Validate agents/teams/workflows. |
|
|
83
|
-
| `recommend` | `team-recommendation.ts` | Suggest team/workflow/action for a goal. |
|
|
84
|
-
| management | `management.ts` | Create/update/delete/rename teams, agents, workflows. |
|
|
85
|
-
| API | `team-tool/api.ts` | File-backed observability/control/mailbox API. |
|
|
86
|
-
|
|
87
|
-
## Worker modes
|
|
88
|
-
|
|
89
|
-
| Mode | Behavior |
|
|
90
|
-
|---|---|
|
|
91
|
-
| `child-process` | Default. Launches real child `pi` processes per task. |
|
|
92
|
-
| `scaffold` | Explicit dry-run. No child Pi worker execution. |
|
|
93
|
-
| `live-session` | Experimental/gated in-process/live agent path. |
|
|
94
|
-
| `auto` | Resolves to child-process unless config/env requests otherwise. |
|
|
95
|
-
|
|
96
|
-
## Important files
|
|
97
|
-
|
|
98
|
-
```text
|
|
99
|
-
src/extension/register.ts Pi extension entry/wiring
|
|
100
|
-
src/extension/team-tool/run.ts run creation and foreground/async split
|
|
101
|
-
src/runtime/background-runner.ts detached async entrypoint
|
|
102
|
-
src/runtime/async-runner.ts background spawn command/options
|
|
103
|
-
src/runtime/team-runner.ts workflow/task graph scheduler
|
|
104
|
-
src/runtime/task-runner.ts single task execution
|
|
105
|
-
src/runtime/child-pi.ts child Pi process and output observer
|
|
106
|
-
src/runtime/model-fallback.ts configured model candidates/routing
|
|
107
|
-
src/runtime/concurrency.ts batch concurrency decisions
|
|
108
|
-
src/runtime/process-status.ts pid/liveness/stale detection
|
|
109
|
-
src/state/state-store.ts manifest/tasks persistence
|
|
110
|
-
src/state/event-log.ts JSONL run events
|
|
111
|
-
src/runtime/crew-agent-records.ts aggregate + per-agent status files
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Environment variables
|
|
115
|
-
|
|
116
|
-
| Env | Effect |
|
|
117
|
-
|---|---|
|
|
118
|
-
| `PI_CREW_EXECUTE_WORKERS=0` | Disable real workers, use scaffold behavior. |
|
|
119
|
-
| `PI_TEAMS_EXECUTE_WORKERS=0` | Legacy alias for worker disable. |
|
|
120
|
-
| `PI_CREW_ENABLE_EXPERIMENTAL_LIVE_SESSION=1` | Allow experimental live-session runtime. |
|
|
121
|
-
| `PI_CREW_MOCK_LIVE_SESSION=success` | Test hook for live-session mock. |
|
|
122
|
-
| `PI_TEAMS_MOCK_CHILD_PI` | Test hook for mocked child Pi execution. |
|
|
123
|
-
| `PI_CREW_DEPTH`, `PI_CREW_MAX_DEPTH` | Canonical subagent recursion guard. |
|
|
124
|
-
| `PI_TEAMS_DEPTH`, `PI_TEAMS_MAX_DEPTH` | Legacy recursion guard aliases. |
|
|
125
|
-
| `PI_TEAMS_HOME` | Override user config/state home in tests. |
|
|
126
|
-
| `PI_TEAMS_PI_BIN` | Override child `pi` executable. |
|
|
127
|
-
| `PI_CODING_AGENT_DIR` | Override Pi settings/models directory for model discovery. |
|
|
128
|
-
| `PI_CREW_ASYNC_EARLY_EXIT_GUARD=0` | Disable 3s background early-exit guard. |
|
|
129
|
-
|
|
130
|
-
## State transition summary
|
|
131
|
-
|
|
132
|
-
```text
|
|
133
|
-
queued/planning/running ── completed
|
|
134
|
-
├─ failed
|
|
135
|
-
├─ blocked
|
|
136
|
-
└─ cancelled
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Task states follow the same durable contract plus `skipped`. Terminal states are monotonic during parallel merge.
|
|
140
|
-
|
|
141
|
-
## Observability tips
|
|
142
|
-
|
|
143
|
-
- Use `/team-dashboard` for a UI overview.
|
|
144
|
-
- Use `team status runId=...` for canonical state and stale async detection.
|
|
145
|
-
- Read `background.log` for early import/spawn errors.
|
|
146
|
-
- Read `events.jsonl` for event chronology.
|
|
147
|
-
- Read `agents/{taskId}/status.json` for per-agent model/progress/tool status.
|
|
148
|
-
- Read `artifacts/{runId}/transcripts/{taskId}.jsonl` for raw child Pi transcript.
|
|
1
|
+
# pi-crew Runtime Flow
|
|
2
|
+
|
|
3
|
+
This document is a compact map of the runtime paths used by `pi-crew`.
|
|
4
|
+
|
|
5
|
+
## Main sequence
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
User / model
|
|
9
|
+
│ calls team({ action: "run", ... }) or /team-run
|
|
10
|
+
▼
|
|
11
|
+
handleTeamTool()
|
|
12
|
+
│ validates schema and routes action
|
|
13
|
+
▼
|
|
14
|
+
handleRun()
|
|
15
|
+
├─ discoverTeams/discoverWorkflows/discoverAgents
|
|
16
|
+
├─ validateWorkflowForTeam
|
|
17
|
+
├─ expandParallelResearchWorkflow when applicable
|
|
18
|
+
├─ createRunManifest + tasks.json + goal artifact
|
|
19
|
+
├─ if async=true ─────────────────────────────────────────────┐
|
|
20
|
+
│ spawnBackgroundTeamRun() │
|
|
21
|
+
│ ├─ resolve jiti-register.mjs │
|
|
22
|
+
│ ├─ fail-fast if jiti missing │
|
|
23
|
+
│ ├─ node --import jiti-register.mjs background-runner.ts │
|
|
24
|
+
│ └─ parent schedules early-exit guard │
|
|
25
|
+
│ ▼
|
|
26
|
+
│ background-runner.ts
|
|
27
|
+
│ ├─ append async.started
|
|
28
|
+
│ ├─ write async.pid startup marker
|
|
29
|
+
│ ├─ rediscover team/workflow/agents
|
|
30
|
+
│ └─ executeTeamRun()
|
|
31
|
+
│
|
|
32
|
+
└─ if foreground/default
|
|
33
|
+
├─ startForegroundRun schedules session-bound run, or
|
|
34
|
+
└─ executeTeamRun inline for scaffold/non-scheduled paths
|
|
35
|
+
|
|
36
|
+
executeTeamRun()
|
|
37
|
+
├─ write run.running
|
|
38
|
+
├─ materialize queued/running agent records lazily
|
|
39
|
+
├─ build task graph index
|
|
40
|
+
├─ while queued tasks exist
|
|
41
|
+
│ ├─ taskGraphSnapshot
|
|
42
|
+
│ ├─ resolveBatchConcurrency
|
|
43
|
+
│ ├─ getReadyTasks
|
|
44
|
+
│ ├─ append task.progress batch event
|
|
45
|
+
│ ├─ mapConcurrent ready batch
|
|
46
|
+
│ │ └─ runTeamTask()
|
|
47
|
+
│ │ ├─ prepare workspace/worktree
|
|
48
|
+
│ │ ├─ build task packet
|
|
49
|
+
│ │ ├─ render prompt + dependency context
|
|
50
|
+
│ │ ├─ choose model candidates from Pi config
|
|
51
|
+
│ │ ├─ spawn child Pi process
|
|
52
|
+
│ │ ├─ ChildPiLineObserver parses stdout/stderr
|
|
53
|
+
│ │ ├─ append per-agent events/output
|
|
54
|
+
│ │ ├─ update agent progress/task state
|
|
55
|
+
│ │ ├─ parse final JSONL/session usage
|
|
56
|
+
│ │ └─ write result/log/transcript/metadata artifacts
|
|
57
|
+
│ ├─ merge task updates monotonically
|
|
58
|
+
│ ├─ optional adaptive plan injection
|
|
59
|
+
│ ├─ save tasks/agents/progress
|
|
60
|
+
│ └─ write batch artifact
|
|
61
|
+
├─ policy closeout
|
|
62
|
+
└─ run.completed / run.failed / run.blocked / run.cancelled
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Action router
|
|
66
|
+
|
|
67
|
+
| Action | Handler | Purpose |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `run` | `team-tool/run.ts` | Create and execute a run, foreground or async. |
|
|
70
|
+
| `status` | `team-tool.ts` | Show manifest/tasks/agents/events and mark stale async runs failed. |
|
|
71
|
+
| `summary` | `session-summary.ts`/summary handler | Write/read run summary artifact. |
|
|
72
|
+
| `events` | `team-tool.ts` | Tail durable run events. |
|
|
73
|
+
| `artifacts` | `team-tool.ts` | List run artifacts. |
|
|
74
|
+
| `resume` | `team-tool.ts` | Requeue failed/cancelled/skipped/running tasks. |
|
|
75
|
+
| `cancel` | `team-tool.ts` | Mark queued/running tasks cancelled and request foreground interrupt. |
|
|
76
|
+
| `forget` | `run-maintenance.ts` | Delete run state/artifacts with confirmation. |
|
|
77
|
+
| `prune` | `run-maintenance.ts` | Remove old finished runs with confirmation. |
|
|
78
|
+
| `export` | `run-export.ts` | Create portable run bundle. |
|
|
79
|
+
| `import` / `imports` | `run-import.ts` / `import-index.ts` | Store/list imported bundles. |
|
|
80
|
+
| `config` | `config.ts` + config action | Show/update user/project config. |
|
|
81
|
+
| `doctor` | `team-tool/doctor.ts` | Platform/resource/runtime diagnostics. |
|
|
82
|
+
| `validate` | `validate-resources.ts` | Validate agents/teams/workflows. |
|
|
83
|
+
| `recommend` | `team-recommendation.ts` | Suggest team/workflow/action for a goal. |
|
|
84
|
+
| management | `management.ts` | Create/update/delete/rename teams, agents, workflows. |
|
|
85
|
+
| API | `team-tool/api.ts` | File-backed observability/control/mailbox API. |
|
|
86
|
+
|
|
87
|
+
## Worker modes
|
|
88
|
+
|
|
89
|
+
| Mode | Behavior |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `child-process` | Default. Launches real child `pi` processes per task. |
|
|
92
|
+
| `scaffold` | Explicit dry-run. No child Pi worker execution. |
|
|
93
|
+
| `live-session` | Experimental/gated in-process/live agent path. |
|
|
94
|
+
| `auto` | Resolves to child-process unless config/env requests otherwise. |
|
|
95
|
+
|
|
96
|
+
## Important files
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
src/extension/register.ts Pi extension entry/wiring
|
|
100
|
+
src/extension/team-tool/run.ts run creation and foreground/async split
|
|
101
|
+
src/runtime/background-runner.ts detached async entrypoint
|
|
102
|
+
src/runtime/async-runner.ts background spawn command/options
|
|
103
|
+
src/runtime/team-runner.ts workflow/task graph scheduler
|
|
104
|
+
src/runtime/task-runner.ts single task execution
|
|
105
|
+
src/runtime/child-pi.ts child Pi process and output observer
|
|
106
|
+
src/runtime/model-fallback.ts configured model candidates/routing
|
|
107
|
+
src/runtime/concurrency.ts batch concurrency decisions
|
|
108
|
+
src/runtime/process-status.ts pid/liveness/stale detection
|
|
109
|
+
src/state/state-store.ts manifest/tasks persistence
|
|
110
|
+
src/state/event-log.ts JSONL run events
|
|
111
|
+
src/runtime/crew-agent-records.ts aggregate + per-agent status files
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Environment variables
|
|
115
|
+
|
|
116
|
+
| Env | Effect |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `PI_CREW_EXECUTE_WORKERS=0` | Disable real workers, use scaffold behavior. |
|
|
119
|
+
| `PI_TEAMS_EXECUTE_WORKERS=0` | Legacy alias for worker disable. |
|
|
120
|
+
| `PI_CREW_ENABLE_EXPERIMENTAL_LIVE_SESSION=1` | Allow experimental live-session runtime. |
|
|
121
|
+
| `PI_CREW_MOCK_LIVE_SESSION=success` | Test hook for live-session mock. |
|
|
122
|
+
| `PI_TEAMS_MOCK_CHILD_PI` | Test hook for mocked child Pi execution. |
|
|
123
|
+
| `PI_CREW_DEPTH`, `PI_CREW_MAX_DEPTH` | Canonical subagent recursion guard. |
|
|
124
|
+
| `PI_TEAMS_DEPTH`, `PI_TEAMS_MAX_DEPTH` | Legacy recursion guard aliases. |
|
|
125
|
+
| `PI_TEAMS_HOME` | Override user config/state home in tests. |
|
|
126
|
+
| `PI_TEAMS_PI_BIN` | Override child `pi` executable. |
|
|
127
|
+
| `PI_CODING_AGENT_DIR` | Override Pi settings/models directory for model discovery. |
|
|
128
|
+
| `PI_CREW_ASYNC_EARLY_EXIT_GUARD=0` | Disable 3s background early-exit guard. |
|
|
129
|
+
|
|
130
|
+
## State transition summary
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
queued/planning/running ── completed
|
|
134
|
+
├─ failed
|
|
135
|
+
├─ blocked
|
|
136
|
+
└─ cancelled
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Task states follow the same durable contract plus `skipped`. Terminal states are monotonic during parallel merge.
|
|
140
|
+
|
|
141
|
+
## Observability tips
|
|
142
|
+
|
|
143
|
+
- Use `/team-dashboard` for a UI overview.
|
|
144
|
+
- Use `team status runId=...` for canonical state and stale async detection.
|
|
145
|
+
- Read `background.log` for early import/spawn errors.
|
|
146
|
+
- Read `events.jsonl` for event chronology.
|
|
147
|
+
- Read `agents/{taskId}/status.json` for per-agent model/progress/tool status.
|
|
148
|
+
- Read `artifacts/{runId}/transcripts/{taskId}.jsonl` for raw child Pi transcript.
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
# pi-crew runtime refactor source map
|
|
2
|
-
|
|
3
|
-
This document records the source projects used as the baseline for the pi-crew subagent/runtime refactor. The goal is to avoid ad-hoc fixes in critical process orchestration paths and instead align pi-crew with proven Pi extension patterns.
|
|
4
|
-
|
|
5
|
-
## Source/pi-subagents
|
|
6
|
-
|
|
7
|
-
Primary source for child-process worker execution.
|
|
8
|
-
|
|
9
|
-
- `pi-spawn.ts`: robust Pi CLI resolution on Windows and package installs.
|
|
10
|
-
- `async-execution.ts`: detached async runner with `windowsHide: true` to avoid blank console windows.
|
|
11
|
-
- `subagent-runner.ts`: streaming child Pi process runner, output capture, result extraction.
|
|
12
|
-
- `post-exit-stdio-guard.ts`: guards for child processes that exit before stdio fully closes.
|
|
13
|
-
- `result-watcher.ts` and `async-job-tracker.ts`: durable async job/result observation patterns.
|
|
14
|
-
- `model-fallback.ts`: model fallback policy independent of hardcoded provider assumptions.
|
|
15
|
-
- `subagent-control.ts`, `run-status.ts`: status and control semantics.
|
|
16
|
-
|
|
17
|
-
pi-crew alignment:
|
|
18
|
-
|
|
19
|
-
- Background runner and child worker spawn options now explicitly set `windowsHide: true`.
|
|
20
|
-
- Parallel research no longer gates all shard workers behind a single discover worker.
|
|
21
|
-
- Further work should consolidate `child-pi.ts`, `async-runner.ts`, and `subagent-manager.ts` into a durable-first subagent runtime module.
|
|
22
|
-
|
|
23
|
-
## Source/pi-subagents2
|
|
24
|
-
|
|
25
|
-
Primary source for higher-level agent management and UI patterns.
|
|
26
|
-
|
|
27
|
-
- `src/agent-manager.ts`: agent lifecycle registry boundaries.
|
|
28
|
-
- `src/agent-runner.ts`: invocation/run abstraction separate from UI registration.
|
|
29
|
-
- `src/model-resolver.ts`: cleaner model resolution responsibility.
|
|
30
|
-
- `src/output-file.ts`: output file abstraction.
|
|
31
|
-
- `src/ui/agent-widget.ts`, `src/ui/conversation-viewer.ts`: compact live status and transcript viewing.
|
|
32
|
-
|
|
33
|
-
pi-crew alignment:
|
|
34
|
-
|
|
35
|
-
- Keep `Agent`/`crew_agent` tools as thin adapters over a durable manager.
|
|
36
|
-
- Avoid storing essential run mapping in memory only.
|
|
37
|
-
- Keep UI active-only and file-backed.
|
|
38
|
-
|
|
39
|
-
## Source/pi-mono
|
|
40
|
-
|
|
41
|
-
Primary source for Pi extension API/lifecycle constraints.
|
|
42
|
-
|
|
43
|
-
- `packages/coding-agent/src/core/extensions/types.ts`: extension context/tool contracts.
|
|
44
|
-
- `packages/coding-agent/src/core/extensions/runner.ts`: extension execution boundaries.
|
|
45
|
-
- `packages/coding-agent/src/core/model-registry.ts`: available model discovery.
|
|
46
|
-
- `packages/coding-agent/src/modes/interactive/interactive-mode.ts`: session lifecycle/UI behavior.
|
|
47
|
-
|
|
48
|
-
pi-crew alignment:
|
|
49
|
-
|
|
50
|
-
- Treat session-bound foreground workers differently from explicit async background workers.
|
|
51
|
-
- Do not assume hardcoded providers/models.
|
|
52
|
-
- Use Pi-native UI calls without modal auto-open by default.
|
|
53
|
-
|
|
54
|
-
## Source/pi-powerbar, pi-plan, pi-diff-review, pi-extensions*
|
|
55
|
-
|
|
56
|
-
Sources for UI and small-extension patterns.
|
|
57
|
-
|
|
58
|
-
- `pi-powerbar/src/powerbar/*`: low-noise status segment publishing.
|
|
59
|
-
- `pi-plan/src/plan-action-ui.ts`: action-oriented UI without persistent heavy overlays.
|
|
60
|
-
- `pi-diff-review/src/*`: command/tool registration and review UX patterns.
|
|
61
|
-
- `pi-extensions2/files-widget/*`: file-backed UI composition and navigation.
|
|
62
|
-
|
|
63
|
-
pi-crew alignment:
|
|
64
|
-
|
|
65
|
-
- Keep persistent widget active-only.
|
|
66
|
-
- Prefer manual dashboard/transcript commands for history.
|
|
67
|
-
- Avoid expensive render scans and auto-opening focus-capturing overlays.
|
|
68
|
-
|
|
69
|
-
## Current refactor checkpoints
|
|
70
|
-
|
|
71
|
-
- [x] Hide Windows console windows for background runner and child Pi workers.
|
|
72
|
-
- [x] Make parallel research shard workers start in parallel instead of depending on a single discover worker.
|
|
73
|
-
- [x] Keep direct-agent reconstruction gated by `workflow === "direct-agent"` only.
|
|
74
|
-
- [x] Persist subagent records and recover terminal results after restart.
|
|
75
|
-
- [x] Fail fast for unrecoverable persisted records without `runId` instead of hanging.
|
|
76
|
-
- [x] Persist direct-agent model override into task state for background/resume reconstruction.
|
|
77
|
-
|
|
78
|
-
## Remaining larger subsystem work
|
|
79
|
-
|
|
80
|
-
- Consolidate subagent runtime into `src/subagents/*` or equivalent durable-first module.
|
|
81
|
-
- Move model routing transparency into persisted task/subagent records: requested model, selected model, fallback chain, fallback reason.
|
|
82
|
-
- Add real integration smoke scripts for Windows process visibility, async restart recovery, and multi-shard fanout.
|
|
83
|
-
- Add adaptive planner repair/retry for invalid JSON instead of immediate block when safe.
|
|
1
|
+
# pi-crew runtime refactor source map
|
|
2
|
+
|
|
3
|
+
This document records the source projects used as the baseline for the pi-crew subagent/runtime refactor. The goal is to avoid ad-hoc fixes in critical process orchestration paths and instead align pi-crew with proven Pi extension patterns.
|
|
4
|
+
|
|
5
|
+
## Source/pi-subagents
|
|
6
|
+
|
|
7
|
+
Primary source for child-process worker execution.
|
|
8
|
+
|
|
9
|
+
- `pi-spawn.ts`: robust Pi CLI resolution on Windows and package installs.
|
|
10
|
+
- `async-execution.ts`: detached async runner with `windowsHide: true` to avoid blank console windows.
|
|
11
|
+
- `subagent-runner.ts`: streaming child Pi process runner, output capture, result extraction.
|
|
12
|
+
- `post-exit-stdio-guard.ts`: guards for child processes that exit before stdio fully closes.
|
|
13
|
+
- `result-watcher.ts` and `async-job-tracker.ts`: durable async job/result observation patterns.
|
|
14
|
+
- `model-fallback.ts`: model fallback policy independent of hardcoded provider assumptions.
|
|
15
|
+
- `subagent-control.ts`, `run-status.ts`: status and control semantics.
|
|
16
|
+
|
|
17
|
+
pi-crew alignment:
|
|
18
|
+
|
|
19
|
+
- Background runner and child worker spawn options now explicitly set `windowsHide: true`.
|
|
20
|
+
- Parallel research no longer gates all shard workers behind a single discover worker.
|
|
21
|
+
- Further work should consolidate `child-pi.ts`, `async-runner.ts`, and `subagent-manager.ts` into a durable-first subagent runtime module.
|
|
22
|
+
|
|
23
|
+
## Source/pi-subagents2
|
|
24
|
+
|
|
25
|
+
Primary source for higher-level agent management and UI patterns.
|
|
26
|
+
|
|
27
|
+
- `src/agent-manager.ts`: agent lifecycle registry boundaries.
|
|
28
|
+
- `src/agent-runner.ts`: invocation/run abstraction separate from UI registration.
|
|
29
|
+
- `src/model-resolver.ts`: cleaner model resolution responsibility.
|
|
30
|
+
- `src/output-file.ts`: output file abstraction.
|
|
31
|
+
- `src/ui/agent-widget.ts`, `src/ui/conversation-viewer.ts`: compact live status and transcript viewing.
|
|
32
|
+
|
|
33
|
+
pi-crew alignment:
|
|
34
|
+
|
|
35
|
+
- Keep `Agent`/`crew_agent` tools as thin adapters over a durable manager.
|
|
36
|
+
- Avoid storing essential run mapping in memory only.
|
|
37
|
+
- Keep UI active-only and file-backed.
|
|
38
|
+
|
|
39
|
+
## Source/pi-mono
|
|
40
|
+
|
|
41
|
+
Primary source for Pi extension API/lifecycle constraints.
|
|
42
|
+
|
|
43
|
+
- `packages/coding-agent/src/core/extensions/types.ts`: extension context/tool contracts.
|
|
44
|
+
- `packages/coding-agent/src/core/extensions/runner.ts`: extension execution boundaries.
|
|
45
|
+
- `packages/coding-agent/src/core/model-registry.ts`: available model discovery.
|
|
46
|
+
- `packages/coding-agent/src/modes/interactive/interactive-mode.ts`: session lifecycle/UI behavior.
|
|
47
|
+
|
|
48
|
+
pi-crew alignment:
|
|
49
|
+
|
|
50
|
+
- Treat session-bound foreground workers differently from explicit async background workers.
|
|
51
|
+
- Do not assume hardcoded providers/models.
|
|
52
|
+
- Use Pi-native UI calls without modal auto-open by default.
|
|
53
|
+
|
|
54
|
+
## Source/pi-powerbar, pi-plan, pi-diff-review, pi-extensions*
|
|
55
|
+
|
|
56
|
+
Sources for UI and small-extension patterns.
|
|
57
|
+
|
|
58
|
+
- `pi-powerbar/src/powerbar/*`: low-noise status segment publishing.
|
|
59
|
+
- `pi-plan/src/plan-action-ui.ts`: action-oriented UI without persistent heavy overlays.
|
|
60
|
+
- `pi-diff-review/src/*`: command/tool registration and review UX patterns.
|
|
61
|
+
- `pi-extensions2/files-widget/*`: file-backed UI composition and navigation.
|
|
62
|
+
|
|
63
|
+
pi-crew alignment:
|
|
64
|
+
|
|
65
|
+
- Keep persistent widget active-only.
|
|
66
|
+
- Prefer manual dashboard/transcript commands for history.
|
|
67
|
+
- Avoid expensive render scans and auto-opening focus-capturing overlays.
|
|
68
|
+
|
|
69
|
+
## Current refactor checkpoints
|
|
70
|
+
|
|
71
|
+
- [x] Hide Windows console windows for background runner and child Pi workers.
|
|
72
|
+
- [x] Make parallel research shard workers start in parallel instead of depending on a single discover worker.
|
|
73
|
+
- [x] Keep direct-agent reconstruction gated by `workflow === "direct-agent"` only.
|
|
74
|
+
- [x] Persist subagent records and recover terminal results after restart.
|
|
75
|
+
- [x] Fail fast for unrecoverable persisted records without `runId` instead of hanging.
|
|
76
|
+
- [x] Persist direct-agent model override into task state for background/resume reconstruction.
|
|
77
|
+
|
|
78
|
+
## Remaining larger subsystem work
|
|
79
|
+
|
|
80
|
+
- Consolidate subagent runtime into `src/subagents/*` or equivalent durable-first module.
|
|
81
|
+
- Move model routing transparency into persisted task/subagent records: requested model, selected model, fallback chain, fallback reason.
|
|
82
|
+
- Add real integration smoke scripts for Windows process visibility, async restart recovery, and multi-shard fanout.
|
|
83
|
+
- Add adaptive planner repair/retry for invalid JSON instead of immediate block when safe.
|
package/docs/usage.md
CHANGED
|
@@ -107,6 +107,12 @@ Check status:
|
|
|
107
107
|
}
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
Background `Agent`/`crew_agent` subagents wake the parent Pi session when they complete, so the parent can call `get_subagent_result`/`crew_agent_result` and continue without waiting for another user prompt.
|
|
111
|
+
|
|
112
|
+
## State and API safety
|
|
113
|
+
|
|
114
|
+
State paths are validated before read/write operations. Run ids, imported bundles, artifact and transcript references, mailbox files, and agent control/log files must stay inside their expected `.crew` roots and symlink escapes are rejected. Read-only mailbox APIs return default state without creating mailbox files when no messages exist.
|
|
115
|
+
|
|
110
116
|
## Worktree mode
|
|
111
117
|
|
|
112
118
|
```json
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
-
import { registerPiTeams } from "./src/extension/register.ts";
|
|
3
|
-
|
|
4
|
-
export default function (pi: ExtensionAPI): void {
|
|
5
|
-
registerPiTeams(pi);
|
|
6
|
-
}
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { registerPiTeams } from "./src/extension/register.ts";
|
|
3
|
+
|
|
4
|
+
export default function (pi: ExtensionAPI): void {
|
|
5
|
+
registerPiTeams(pi);
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-crew",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.39",
|
|
4
4
|
"description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
|
|
5
5
|
"author": "baphuongna",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"ci": "npm run typecheck && npm test && npm pack --dry-run",
|
|
48
48
|
"typecheck": "tsc --noEmit && node --experimental-strip-types -e \"await import('./index.ts'); console.log('strip-types import ok')\"",
|
|
49
49
|
"test": "npm run test:unit && npm run test:integration",
|
|
50
|
-
"test:unit": "node --experimental-strip-types --test --test-timeout=30000 test/unit/*.test.ts",
|
|
51
|
-
"test:integration": "node --experimental-strip-types --test --test-timeout=120000 test/integration/*.test.ts",
|
|
50
|
+
"test:unit": "node --experimental-strip-types --test --test-concurrency=1 --test-timeout=30000 test/unit/*.test.ts",
|
|
51
|
+
"test:integration": "node --experimental-strip-types --test --test-concurrency=1 --test-timeout=120000 test/integration/*.test.ts",
|
|
52
52
|
"smoke:pi": "pi install ."
|
|
53
53
|
},
|
|
54
54
|
"exports": {
|
package/schema.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"executeWorkers": {
|
|
13
13
|
"type": "boolean",
|
|
14
|
-
"description": "Allow real child Pi workers
|
|
14
|
+
"description": "Allow real child Pi workers. Defaults to true; set false or use PI_CREW_EXECUTE_WORKERS=0/PI_TEAMS_EXECUTE_WORKERS=0 to force scaffold mode."
|
|
15
15
|
},
|
|
16
16
|
"notifierIntervalMs": {
|
|
17
17
|
"type": "number",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"showModel": { "type": "boolean", "default": true, "description": "Show worker model attempts in dashboard agent rows." },
|
|
129
129
|
"showTokens": { "type": "boolean", "description": "Show token usage in dashboard agent rows." },
|
|
130
130
|
"showTools": { "type": "boolean", "description": "Show tool activity in dashboard agent rows." },
|
|
131
|
-
"transcriptTailBytes": { "type": "integer", "minimum": 1024, "default": 262144, "description": "Maximum transcript bytes to parse by default; use viewer hotkey f to load full content." },
|
|
131
|
+
"transcriptTailBytes": { "type": "integer", "minimum": 1024, "maximum": 52428800, "default": 262144, "description": "Maximum transcript bytes to parse by default; use viewer hotkey f to load full content." },
|
|
132
132
|
"mascotStyle": { "type": "string", "enum": ["cat", "armin"] },
|
|
133
133
|
"mascotEffect": { "type": "string", "enum": ["random", "none", "typewriter", "scanline", "rain", "fade", "crt", "glitch", "dissolve"] }
|
|
134
134
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import type { AgentConfig } from "./agent-config.ts";
|
|
2
|
-
|
|
3
|
-
function line(key: string, value: string | boolean | string[] | undefined): string | undefined {
|
|
4
|
-
if (value === undefined) return undefined;
|
|
5
|
-
if (Array.isArray(value)) return `${key}: ${value.join(", ")}`;
|
|
6
|
-
return `${key}: ${String(value)}`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function serializeAgent(agent: AgentConfig): string {
|
|
10
|
-
const lines = [
|
|
11
|
-
"---",
|
|
12
|
-
`name: ${agent.name}`,
|
|
13
|
-
`description: ${agent.description}`,
|
|
14
|
-
line("model", agent.model),
|
|
15
|
-
line("fallbackModels", agent.fallbackModels),
|
|
16
|
-
line("thinking", agent.thinking),
|
|
17
|
-
line("tools", agent.tools),
|
|
18
|
-
agent.extensions !== undefined ? line("extensions", agent.extensions) ?? "extensions:" : undefined,
|
|
19
|
-
line("skills", agent.skills),
|
|
20
|
-
line("systemPromptMode", agent.systemPromptMode),
|
|
21
|
-
line("inheritProjectContext", agent.inheritProjectContext),
|
|
22
|
-
line("inheritSkills", agent.inheritSkills),
|
|
23
|
-
line("triggers", agent.routing?.triggers),
|
|
24
|
-
line("useWhen", agent.routing?.useWhen),
|
|
25
|
-
line("avoidWhen", agent.routing?.avoidWhen),
|
|
26
|
-
line("cost", agent.routing?.cost),
|
|
27
|
-
line("category", agent.routing?.category),
|
|
28
|
-
"---",
|
|
29
|
-
"",
|
|
30
|
-
agent.systemPrompt.trim(),
|
|
31
|
-
"",
|
|
32
|
-
].filter((entry): entry is string => entry !== undefined);
|
|
33
|
-
return lines.join("\n");
|
|
34
|
-
}
|
|
1
|
+
import type { AgentConfig } from "./agent-config.ts";
|
|
2
|
+
|
|
3
|
+
function line(key: string, value: string | boolean | string[] | undefined): string | undefined {
|
|
4
|
+
if (value === undefined) return undefined;
|
|
5
|
+
if (Array.isArray(value)) return `${key}: ${value.join(", ")}`;
|
|
6
|
+
return `${key}: ${String(value)}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function serializeAgent(agent: AgentConfig): string {
|
|
10
|
+
const lines = [
|
|
11
|
+
"---",
|
|
12
|
+
`name: ${agent.name}`,
|
|
13
|
+
`description: ${agent.description}`,
|
|
14
|
+
line("model", agent.model),
|
|
15
|
+
line("fallbackModels", agent.fallbackModels),
|
|
16
|
+
line("thinking", agent.thinking),
|
|
17
|
+
line("tools", agent.tools),
|
|
18
|
+
agent.extensions !== undefined ? line("extensions", agent.extensions) ?? "extensions:" : undefined,
|
|
19
|
+
line("skills", agent.skills),
|
|
20
|
+
line("systemPromptMode", agent.systemPromptMode),
|
|
21
|
+
line("inheritProjectContext", agent.inheritProjectContext),
|
|
22
|
+
line("inheritSkills", agent.inheritSkills),
|
|
23
|
+
line("triggers", agent.routing?.triggers),
|
|
24
|
+
line("useWhen", agent.routing?.useWhen),
|
|
25
|
+
line("avoidWhen", agent.routing?.avoidWhen),
|
|
26
|
+
line("cost", agent.routing?.cost),
|
|
27
|
+
line("category", agent.routing?.category),
|
|
28
|
+
"---",
|
|
29
|
+
"",
|
|
30
|
+
agent.systemPrompt.trim(),
|
|
31
|
+
"",
|
|
32
|
+
].filter((entry): entry is string => entry !== undefined);
|
|
33
|
+
return lines.join("\n");
|
|
34
|
+
}
|
package/src/config/config.ts
CHANGED
|
@@ -319,8 +319,12 @@ function parseWithSchema<T extends TSchema>(schema: T, value: unknown): Static<T
|
|
|
319
319
|
return Value.Decode(schema, value);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
function parseIntegerInRange(value: unknown, minimum = 1, maximum = Number.MAX_SAFE_INTEGER): number | undefined {
|
|
323
|
+
return parseWithSchema(Type.Integer({ minimum, maximum }), value);
|
|
324
|
+
}
|
|
325
|
+
|
|
322
326
|
function parsePositiveInteger(value: unknown, max = Number.MAX_SAFE_INTEGER): number | undefined {
|
|
323
|
-
return
|
|
327
|
+
return parseIntegerInRange(value, 1, max);
|
|
324
328
|
}
|
|
325
329
|
|
|
326
330
|
function parseProfile(value: unknown): PiTeamsAutonomyProfile | undefined {
|
|
@@ -462,14 +466,14 @@ function parseUiConfig(value: unknown): CrewUiConfig | undefined {
|
|
|
462
466
|
widgetMaxLines: parsePositiveInteger(obj.widgetMaxLines, 50),
|
|
463
467
|
powerbar: parseWithSchema(Type.Boolean(), obj.powerbar),
|
|
464
468
|
dashboardPlacement: rawDashboardPlacement,
|
|
465
|
-
dashboardWidth:
|
|
466
|
-
dashboardLiveRefreshMs:
|
|
469
|
+
dashboardWidth: parseIntegerInRange(obj.dashboardWidth, 32, 120),
|
|
470
|
+
dashboardLiveRefreshMs: parseIntegerInRange(obj.dashboardLiveRefreshMs, 250, 60_000),
|
|
467
471
|
autoOpenDashboard: parseWithSchema(Type.Boolean(), obj.autoOpenDashboard),
|
|
468
472
|
autoOpenDashboardForForegroundRuns: parseWithSchema(Type.Boolean(), obj.autoOpenDashboardForForegroundRuns),
|
|
469
473
|
showModel: parseWithSchema(Type.Boolean(), obj.showModel),
|
|
470
474
|
showTokens: parseWithSchema(Type.Boolean(), obj.showTokens),
|
|
471
475
|
showTools: parseWithSchema(Type.Boolean(), obj.showTools),
|
|
472
|
-
transcriptTailBytes:
|
|
476
|
+
transcriptTailBytes: parseIntegerInRange(obj.transcriptTailBytes, 1024, 50 * 1024 * 1024),
|
|
473
477
|
mascotStyle: parseWithSchema(Type.Union([Type.Literal("cat"), Type.Literal("armin")]), obj.mascotStyle),
|
|
474
478
|
mascotEffect: parseWithSchema(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")]), obj.mascotEffect),
|
|
475
479
|
};
|