acpus 0.5.2 → 0.6.0-alpha.1
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/README.md +19 -5
- package/dist/.tsbuildinfo +1 -0
- package/dist/agent-progress-format.d.ts +7 -0
- package/dist/agent-progress-format.d.ts.map +1 -0
- package/dist/agent-progress-format.js +102 -0
- package/dist/agent-progress-format.js.map +1 -0
- package/dist/authoring/core.d.ts +2 -0
- package/dist/authoring/core.d.ts.map +1 -0
- package/dist/authoring/core.js +2 -0
- package/dist/authoring/core.js.map +1 -0
- package/dist/authoring/expression.d.ts +2 -0
- package/dist/authoring/expression.d.ts.map +1 -0
- package/dist/authoring/expression.js +2 -0
- package/dist/authoring/expression.js.map +1 -0
- package/dist/authoring/tasks/git.d.ts +2 -0
- package/dist/authoring/tasks/git.d.ts.map +1 -0
- package/dist/authoring/tasks/git.js +2 -0
- package/dist/authoring/tasks/git.js.map +1 -0
- package/dist/catalog.d.ts +18 -24
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +164 -174
- package/dist/catalog.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/daemon.d.ts +14 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +89 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/doctor.d.ts +11 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +26 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hooks.d.ts +11 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +64 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/json.d.ts +7 -0
- package/dist/commands/json.d.ts.map +1 -0
- package/dist/commands/json.js +43 -0
- package/dist/commands/json.js.map +1 -0
- package/dist/commands/runs-picker.d.ts +21 -0
- package/dist/commands/runs-picker.d.ts.map +1 -0
- package/dist/commands/runs-picker.js +76 -0
- package/dist/commands/runs-picker.js.map +1 -0
- package/dist/commands/runs.d.ts +12 -0
- package/dist/commands/runs.d.ts.map +1 -0
- package/dist/commands/runs.js +285 -0
- package/dist/commands/runs.js.map +1 -0
- package/dist/commands/skill.d.ts +11 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +221 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/web.d.ts +24 -0
- package/dist/commands/web.d.ts.map +1 -0
- package/dist/commands/web.js +57 -0
- package/dist/commands/web.js.map +1 -0
- package/dist/commands/workflow.d.ts +11 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +324 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/daemon-entry.d.ts +3 -0
- package/dist/daemon-entry.d.ts.map +1 -0
- package/dist/daemon-entry.js +26 -0
- package/dist/daemon-entry.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/output.d.ts +91 -11
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +203 -44
- package/dist/output.js.map +1 -1
- package/dist/program.d.ts +9 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +85 -0
- package/dist/program.js.map +1 -0
- package/dist/run-status-surface.d.ts +12 -0
- package/dist/run-status-surface.d.ts.map +1 -0
- package/dist/run-status-surface.js +324 -0
- package/dist/run-status-surface.js.map +1 -0
- package/dist/workflow-preparation.d.ts +3 -0
- package/dist/workflow-preparation.d.ts.map +1 -0
- package/dist/workflow-preparation.js +34 -0
- package/dist/workflow-preparation.js.map +1 -0
- package/package.json +35 -35
- package/skills/acpus/SKILL.md +120 -0
- package/skills/acpus/eval/evaluations.md +47 -0
- package/skills/acpus/examples/hooks.example.json +17 -0
- package/skills/acpus/examples/workflows/adversarial-review/workflow.ts +248 -0
- package/skills/acpus/examples/workflows/change-approval/workflow.ts +121 -0
- package/skills/acpus/examples/workflows/issue-triage/tasks.ts +14 -0
- package/skills/acpus/examples/workflows/issue-triage/workflow.ts +146 -0
- package/skills/acpus/examples/workflows/multi-aspect-brainstorm/workflow.ts +304 -0
- package/skills/acpus/examples/workflows/worktree-tournament/workflow.ts +194 -0
- package/skills/acpus/references/authoring.md +205 -0
- package/skills/acpus/references/cli-operations.md +94 -0
- package/skills/acpus/references/hooks-json.md +81 -0
- package/skills/acpus/references/runtime-recovery.md +97 -0
- package/dist/agent-activity.d.ts +0 -3
- package/dist/agent-activity.d.ts.map +0 -1
- package/dist/agent-activity.js +0 -50
- package/dist/agent-activity.js.map +0 -1
- package/dist/agent-overrides.d.ts +0 -3
- package/dist/agent-overrides.d.ts.map +0 -1
- package/dist/agent-overrides.js +0 -39
- package/dist/agent-overrides.js.map +0 -1
- package/dist/follow.d.ts +0 -23
- package/dist/follow.d.ts.map +0 -1
- package/dist/follow.js +0 -164
- package/dist/follow.js.map +0 -1
- package/dist/hooks.d.ts +0 -4
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -159
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -592
- package/dist/index.js.map +0 -1
- package/dist/io.d.ts +0 -3
- package/dist/io.d.ts.map +0 -1
- package/dist/io.js +0 -27
- package/dist/io.js.map +0 -1
- package/dist/observations.d.ts +0 -39
- package/dist/observations.d.ts.map +0 -1
- package/dist/observations.js +0 -83
- package/dist/observations.js.map +0 -1
- package/dist/runs-show.d.ts +0 -40
- package/dist/runs-show.d.ts.map +0 -1
- package/dist/runs-show.js +0 -296
- package/dist/runs-show.js.map +0 -1
- package/dist/supervisor-client.d.ts +0 -9
- package/dist/supervisor-client.d.ts.map +0 -1
- package/dist/supervisor-client.js +0 -8
- package/dist/supervisor-client.js.map +0 -1
- package/dist/supervisor.d.ts +0 -18
- package/dist/supervisor.d.ts.map +0 -1
- package/dist/supervisor.js +0 -24
- package/dist/supervisor.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# CLI Operations
|
|
2
|
+
|
|
3
|
+
## Discover commands
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
acpus --help
|
|
7
|
+
acpus workflow --help
|
|
8
|
+
acpus runs --help
|
|
9
|
+
acpus hooks --help
|
|
10
|
+
acpus <cmd> --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Prefer command help for exact options. The skill should describe operating strategy, not mirror the whole CLI surface.
|
|
14
|
+
|
|
15
|
+
`doctor` is read-only and should not create runtime state in an uninitialized workspace.
|
|
16
|
+
|
|
17
|
+
## Operating defaults
|
|
18
|
+
|
|
19
|
+
- Run `acpus doctor` when the workspace health is uncertain.
|
|
20
|
+
- Use `acpus workflow check <workflow.ts-or-catalog>` before `run`.
|
|
21
|
+
- Use `acpus workflow list` and `acpus workflow show <name>` for catalog discovery.
|
|
22
|
+
- Use `acpus runs inspect [run-id]` before any retry, fork, signal, pause, resume, cancel, or delete.
|
|
23
|
+
- Use `--json` only when structured parsing is needed. Text output is usually better for human diagnosis.
|
|
24
|
+
|
|
25
|
+
`workflow check` prepares the workflow in memory and reports diagnostics, digests, and workflow summary data. It does not admit a runtime run and does not write durable preflight artifacts.
|
|
26
|
+
|
|
27
|
+
Agent nodes and agent declarations are validated by `workflow check`, but check does not invoke `acpx`, start an agent session, run Task or Signal nodes, admit a run, or count as an Agent workflow execution.
|
|
28
|
+
|
|
29
|
+
Failure phases:
|
|
30
|
+
|
|
31
|
+
- `usage`: invalid CLI input, invalid JSON, mutually exclusive options.
|
|
32
|
+
- `check`: TypeScript or Acpus authoring-rule diagnostics.
|
|
33
|
+
- `compile`: module read/import/default-export/build failures.
|
|
34
|
+
- `validate`: frozen IR structural diagnostics.
|
|
35
|
+
|
|
36
|
+
Use `--json` when the exact phase matters. For example, invalid `--agents` overrides are reported in the JSON `phase` field before any runtime admission.
|
|
37
|
+
|
|
38
|
+
## Workflow run
|
|
39
|
+
|
|
40
|
+
Foreground `--json` emits newline-delimited JSON: admitted record, observation records, terminal summary. Text mode shows bounded compact observations and a final summary.
|
|
41
|
+
|
|
42
|
+
`Ctrl-C` during a foreground run detaches observation; it should not cancel the daemon-owned run. Use the printed run id and `acpus runs cancel <run-id>` only when cancellation is intended.
|
|
43
|
+
|
|
44
|
+
For workflows that must receive a Signal, `--background` is usually the cleanest operator loop:
|
|
45
|
+
|
|
46
|
+
1. Run once with `acpus workflow run <workflow.ts> --background --input '<json>'`.
|
|
47
|
+
2. Poll with `acpus runs inspect <run-id>` until the signal row is awaiting.
|
|
48
|
+
3. Send a schema-valid payload to the dynamic signal target, for example `acpus runs signal <run-id> --target approval~abc123 --payload '{"approved":true,"notes":"ok"}'`.
|
|
49
|
+
4. Inspect again for the terminal state. A denial payload is still valid signal handling and may intentionally drive a downstream assert failure.
|
|
50
|
+
|
|
51
|
+
## Catalog entries
|
|
52
|
+
|
|
53
|
+
Catalog packages live under project `.acpus/workflows/<name>/workflow.ts` or global `$HOME/.acpus/workflows/<name>/workflow.ts`. Discovery inspects only first-level directories. If project and global entries share a name, pass `--project` or `--global`.
|
|
54
|
+
|
|
55
|
+
## Run inspection
|
|
56
|
+
|
|
57
|
+
In interactive text terminals, omitting the run id opens the run picker. Read-only run inspection should not start or wake the daemon. It reports durable status plus derived execution state such as active, inactive, stale, terminal, or unknown.
|
|
58
|
+
|
|
59
|
+
Compact text node rows use static ids and dynamic node keys. When a signal is awaiting input, text output should include the rendered prompt, expected payload guidance, and a copyable `runs signal` command.
|
|
60
|
+
|
|
61
|
+
Terminal text inspection includes the final workflow output when present. This is useful for operator handoffs.
|
|
62
|
+
|
|
63
|
+
Text inspection is intentionally compact. For composite-heavy runs, JSON inspection exposes the full dynamic frame/node metadata and Agent telemetry that text mode may omit.
|
|
64
|
+
|
|
65
|
+
## Agent overrides
|
|
66
|
+
|
|
67
|
+
Agent overrides are JSON objects keyed by declared top-level agent names:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
acpus workflow run review.workflow.ts \
|
|
71
|
+
--agents '{"reviewer":{"use":"codex","model":"opus"}}'
|
|
72
|
+
|
|
73
|
+
acpus runs fork <run-id> \
|
|
74
|
+
--agents '{"reviewer":{"command":"my-acp-server --stdio"}}'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Overrides reject unknown agent names, simultaneous `use` and `command`, `policy`, broad `options`, raw IR `kind`, and fields outside the allowlist.
|
|
78
|
+
|
|
79
|
+
If `use` or `command` changes identity, inherited `model` and `agentMode` are cleared unless replacements are supplied. `permissionMode` remains inherited across identity changes.
|
|
80
|
+
|
|
81
|
+
## Runtime controls
|
|
82
|
+
|
|
83
|
+
Controls route through the workspace daemon and wait only until the control is confirmed applied, failed, or the fixed client wait expires. They do not wait for the entire run to become terminal after the control effect.
|
|
84
|
+
|
|
85
|
+
`runs delete` is not a control command. It hard-deletes durable run state and
|
|
86
|
+
run-local artifacts without starting the daemon, rejects active live runs, and
|
|
87
|
+
opens a multi-select picker with an all-deletable option when no run id is
|
|
88
|
+
provided.
|
|
89
|
+
|
|
90
|
+
No `--no-wait` or custom timeout options are part of the next command surface.
|
|
91
|
+
|
|
92
|
+
## Hooks
|
|
93
|
+
|
|
94
|
+
Use hooks JSON files. See `references/hooks-json.md`.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Runtime Hooks JSON
|
|
2
|
+
|
|
3
|
+
Runtime hooks run configured shell commands as side effects when durable runtime events are committed. Hooks observe progress and write hook history; they must not change workflow state or outputs.
|
|
4
|
+
|
|
5
|
+
## Locations
|
|
6
|
+
|
|
7
|
+
- Project: `.acpus/hooks.json`
|
|
8
|
+
- Global: `$HOME/.acpus/hooks.json`
|
|
9
|
+
|
|
10
|
+
Project and global hook entries are merged by direct union. Both run when both match.
|
|
11
|
+
|
|
12
|
+
## Shape
|
|
13
|
+
|
|
14
|
+
A hooks file is an event map. Do not wrap it in a top-level `hooks` field.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"run.completed": [
|
|
19
|
+
{
|
|
20
|
+
"id": "record-completion",
|
|
21
|
+
"command": "mkdir -p .acpus/.local/hook-samples && cat > .acpus/.local/hook-samples/last-run-completed.json",
|
|
22
|
+
"timeout": "10s"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"node.failed": [
|
|
26
|
+
{
|
|
27
|
+
"id": "record-failed-agent",
|
|
28
|
+
"match": { "kind": "agent" },
|
|
29
|
+
"command": "mkdir -p .acpus/.local/hook-samples && cat > .acpus/.local/hook-samples/last-agent-failure.json"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Supported events:
|
|
36
|
+
|
|
37
|
+
- `run.started`
|
|
38
|
+
- `run.completed`
|
|
39
|
+
- `run.failed`
|
|
40
|
+
- `run.canceled`
|
|
41
|
+
- `run.awaiting`
|
|
42
|
+
- `node.started`
|
|
43
|
+
- `node.completed`
|
|
44
|
+
- `node.failed`
|
|
45
|
+
|
|
46
|
+
Each hook entry must contain a non-empty `command`. It may contain `id`, `timeout`, and `match`.
|
|
47
|
+
|
|
48
|
+
## Matching
|
|
49
|
+
|
|
50
|
+
`match` fields are JavaScript regular expression strings. Multiple match fields combine with AND semantics.
|
|
51
|
+
|
|
52
|
+
- `match.workflow` matches the frozen workflow name.
|
|
53
|
+
- `match.nodeId`, `match.nodeKey`, and `match.kind` apply to `node.*` events and `run.awaiting`.
|
|
54
|
+
- Exact matches should be anchored when precision matters, for example `{ "kind": "^agent$" }`.
|
|
55
|
+
|
|
56
|
+
`id` is display and journal metadata only. Duplicate ids do not override or suppress entries.
|
|
57
|
+
|
|
58
|
+
## Runtime behavior
|
|
59
|
+
|
|
60
|
+
- Hook commands receive JSON context on stdin, not workflow state through environment variables.
|
|
61
|
+
- Hooks trigger only for newly committed `run_events` rows, not from inspect commands, projection rebuilds, read APIs, or idempotent duplicate controls that commit no new row.
|
|
62
|
+
- Hook failure, timeout, output, or journal failure must not change workflow status, output, IR, runtime scope, or public run event payloads.
|
|
63
|
+
- Invalid hook configuration fails daemon startup with an invalid hooks config error instead of silently disabling hooks.
|
|
64
|
+
- Default hook timeout is 30 seconds.
|
|
65
|
+
- Hook journal rows are terminal only: `completed`, `failed`, or `timed_out`.
|
|
66
|
+
- `runs inspect` shows hook history only for terminal runs and omits the `Hooks:` section when no hook history exists.
|
|
67
|
+
|
|
68
|
+
## CLI
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
acpus hooks validate
|
|
72
|
+
acpus hooks validate --project
|
|
73
|
+
acpus hooks validate --global
|
|
74
|
+
acpus hooks list
|
|
75
|
+
acpus hooks list --project
|
|
76
|
+
acpus hooks list --global
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Reject simultaneous `--project` and `--global`.
|
|
80
|
+
|
|
81
|
+
The CLI validates only the project and global hook locations; it does not accept an arbitrary `--path`. For scratch validation without touching project hooks, set `HOME` to a scratch directory containing `.acpus/hooks.json` and run `acpus hooks validate --global`.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Runtime Recovery
|
|
2
|
+
|
|
3
|
+
## Triage checklist
|
|
4
|
+
|
|
5
|
+
1. Inspect first:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
acpus runs inspect <run-id>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2. Identify:
|
|
12
|
+
- durable run status and derived execution state
|
|
13
|
+
- failed, timed-out, canceled, paused, or awaiting node/frame
|
|
14
|
+
- dynamic `nodeKey` or `frameKey` when targeting a control
|
|
15
|
+
- rendered signal prompt and expected payload, if awaiting
|
|
16
|
+
- agent attempt metadata and artifact refs, if available
|
|
17
|
+
- whether the workflow source changed after admission
|
|
18
|
+
|
|
19
|
+
3. Choose the smallest safe action.
|
|
20
|
+
|
|
21
|
+
## Phase-based fixes
|
|
22
|
+
|
|
23
|
+
| Symptom | Likely phase | Fix |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| invalid JSON input or invalid CLI option | `usage` | Fix command syntax before preparing. |
|
|
26
|
+
| TypeScript diagnostics, Expr in JS truthiness, task capture, output admissibility | `check` | Edit workflow TypeScript, then run `workflow check` again. |
|
|
27
|
+
| module import failed, default export invalid, build callback throws | `compile` | Fix module exports/imports or build-time code. |
|
|
28
|
+
| unknown IR fields, malformed task target, invalid schema/expression IR | `validate` | Fix authoring shape or Acpus package mismatch. |
|
|
29
|
+
| task command failed, agent failed, signal timed out, assert false | `run` | Inspect artifacts; retry/fork/signal depending on cause. |
|
|
30
|
+
| control target not found, run terminal, conflict | `control` | Re-inspect and target the dynamic nodeKey/frameKey or static alias that currently exists. |
|
|
31
|
+
|
|
32
|
+
## Retry vs fork
|
|
33
|
+
|
|
34
|
+
Use retry when the frozen admitted workflow is still the right plan and the failure is transient or localized:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
acpus runs retry <run-id>
|
|
38
|
+
acpus runs retry <run-id> --target <nodeKey-or-frameKey-or-static-alias>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Targeted retry can reopen a failed dynamic leaf, composite/control frame, or a static alias that resolves unambiguously to one failed dynamic target.
|
|
42
|
+
|
|
43
|
+
Use fork when the workflow source, input, or agent mapping must change:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
acpus runs fork <run-id> --workflow fixed.workflow.ts
|
|
47
|
+
acpus runs fork <run-id> --input '{"repoPath":"/repo","ready":true}'
|
|
48
|
+
acpus runs fork <run-id> --agents '{"reviewer":{"use":"codex"}}'
|
|
49
|
+
acpus runs fork <run-id> --target <target> --workflow fixed.workflow.ts --unsafe-reuse
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Fork creates a new run from frozen source run data and may freeze replacement prepared workflow/input/agents. It should not read live workflow source except where the CLI explicitly prepares a replacement `--workflow`.
|
|
53
|
+
|
|
54
|
+
Use `--unsafe-reuse` when the user clearly wants to reuse earlier completed nodes and accepts the side effects of doing so. Typical cases include a failed node inside one loop iteration where rerunning the whole loop is undesirable, or a fork that changes agent definitions mid-run while keeping already-completed prerequisites.
|
|
55
|
+
|
|
56
|
+
## Signal
|
|
57
|
+
|
|
58
|
+
Inspect output usually gives a copyable command. General form:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
acpus runs signal <run-id> --target <signal-nodeKey-or-static-alias> --payload '<json-or-string>'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Rules:
|
|
65
|
+
|
|
66
|
+
- Schema-backed signals expect JSON that validates against the signal output schema.
|
|
67
|
+
- Schema-less signals receive raw string payloads.
|
|
68
|
+
- Static signal aliases are accepted only when they resolve to exactly one open signal wait.
|
|
69
|
+
- A dynamic `nodeKey` target is safest when fanout/loop instances create multiple waits.
|
|
70
|
+
- Invalid schema-backed payloads are rejected without consuming the wait. The control may surface as `RUN_NOT_CONTROLLABLE` with a schema path message; re-inspect and send a corrected payload to the same awaiting dynamic target.
|
|
71
|
+
|
|
72
|
+
## Pause, resume, and cancel
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
acpus runs pause <run-id>
|
|
76
|
+
acpus runs resume <run-id>
|
|
77
|
+
acpus runs cancel <run-id>
|
|
78
|
+
acpus runs cancel <run-id> --target <nodeKey-or-frameKey-or-static-alias>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Pause records a durable pause gate and best-effort aborts active attempts so eligible work can resume later. Resume clears that gate and re-drives runnable work. Cancel terminalizes the run or the selected scheduler subtree.
|
|
82
|
+
|
|
83
|
+
Ask before canceling unless the user already clearly requested cancellation.
|
|
84
|
+
|
|
85
|
+
## Stale non-terminal execution
|
|
86
|
+
|
|
87
|
+
`runs inspect` may report non-terminal execution as stale based on daemon heartbeat or lease evidence. Do not mutate state just because a run is stale. Re-inspect, run `acpus doctor`, and choose a control only when the user asks to recover or continue.
|
|
88
|
+
|
|
89
|
+
## Artifact reading
|
|
90
|
+
|
|
91
|
+
Prefer artifact references and metadata from `runs inspect --json`. Do not guess at run-local paths unless the inspection output exposes them. Typical run-local data is under `.acpus/.local/runs/<run-id>/`; durable runtime state is under `.acpus/.local/state/runtime.db`.
|
|
92
|
+
|
|
93
|
+
Do not edit SQLite state or run-local frozen files by hand. Use CLI controls.
|
|
94
|
+
|
|
95
|
+
## Agent telemetry
|
|
96
|
+
|
|
97
|
+
`runs inspect --json` exposes Agent attempt metadata under `run.dynamic.executionMetadata[]` entries with `kind: "agent_attempt"`. These entries can include session name, turn count, stop reason, workflow Agent tool-call telemetry, and artifact references for prompt, response, parsed JSON, and telemetry. JSON inspection can be large for composite-heavy runs; use it with `jq` to query exact telemetry or dynamic node keys you need.
|
package/dist/agent-activity.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-activity.d.ts","sourceRoot":"","sources":["../src/agent-activity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2C,MAAM,gBAAgB,CAAC;AAE9F,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBpH"}
|
package/dist/agent-activity.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export function summarizeAgentActivity(agentTelemetry, nowMs) {
|
|
2
|
-
const attempt = agentTelemetry?.attempts.find((item) => item.attempt === agentTelemetry.currentAttempt)
|
|
3
|
-
?? agentTelemetry?.attempts[agentTelemetry.attempts.length - 1];
|
|
4
|
-
if (!attempt)
|
|
5
|
-
return undefined;
|
|
6
|
-
const parts = [`updated=${formatAge(nowMs - Date.parse(attempt.updatedAt))} ago`, `tool_calls=${attempt.tools.totalToolCallCount}`];
|
|
7
|
-
const recent = attempt.tools.recentCalls.slice(0, 3).map(formatToolName).filter(Boolean);
|
|
8
|
-
if (recent.length > 0)
|
|
9
|
-
parts.push(`recent=${recent.join(", ")}`);
|
|
10
|
-
if (attempt.tools.droppedToolCallCount > 0)
|
|
11
|
-
parts.push(`dropped=${attempt.tools.droppedToolCallCount}`);
|
|
12
|
-
if (attempt.context) {
|
|
13
|
-
const ctxDisplay = formatContextUsage(attempt.context.used, attempt.context.size);
|
|
14
|
-
if (ctxDisplay)
|
|
15
|
-
parts.push(`context=${ctxDisplay}`);
|
|
16
|
-
}
|
|
17
|
-
const tokenDisplay = formatTokenUsage(attempt.tokenUsage);
|
|
18
|
-
if (tokenDisplay)
|
|
19
|
-
parts.push(`tokens=${tokenDisplay}`);
|
|
20
|
-
return parts.join("; ");
|
|
21
|
-
}
|
|
22
|
-
function formatContextUsage(used, size) {
|
|
23
|
-
if (used === 0)
|
|
24
|
-
return undefined;
|
|
25
|
-
return `${formatContextNumber(used)}/${formatContextNumber(size)}`;
|
|
26
|
-
}
|
|
27
|
-
function formatContextNumber(value) {
|
|
28
|
-
return value < 1000 ? String(value) : `${Math.floor(value / 1000)}k`;
|
|
29
|
-
}
|
|
30
|
-
function formatTokenUsage(usage) {
|
|
31
|
-
return usage?.totalTokens !== undefined ? formatContextNumber(usage.totalTokens) : undefined;
|
|
32
|
-
}
|
|
33
|
-
function formatToolName(tool) {
|
|
34
|
-
const raw = tool.title ?? tool.toolName ?? tool.kind ?? tool.toolCallId;
|
|
35
|
-
return raw.replace(/\s+/g, " ").trim();
|
|
36
|
-
}
|
|
37
|
-
function formatAge(deltaMs) {
|
|
38
|
-
const safeMs = Number.isFinite(deltaMs) ? Math.max(0, deltaMs) : 0;
|
|
39
|
-
const seconds = Math.floor(safeMs / 1000);
|
|
40
|
-
if (seconds < 60)
|
|
41
|
-
return `${seconds}s`;
|
|
42
|
-
const minutes = Math.floor(seconds / 60);
|
|
43
|
-
if (minutes < 60)
|
|
44
|
-
return `${minutes}m`;
|
|
45
|
-
const hours = Math.floor(minutes / 60);
|
|
46
|
-
if (hours < 48)
|
|
47
|
-
return `${hours}h`;
|
|
48
|
-
return `${Math.floor(hours / 24)}d`;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=agent-activity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-activity.js","sourceRoot":"","sources":["../src/agent-activity.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,cAA0C,EAAE,KAAa;IAC9F,MAAM,OAAO,GAAG,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,cAAc,CAAC,cAAc,CAAC;WAClG,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/B,MAAM,KAAK,GAAG,CAAC,WAAW,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,cAAc,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACpI,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjE,IAAI,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACxG,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,OAAO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M,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,OAAO,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACzC,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,OAAO,GAAG,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACvC,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IACnC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC;AACtC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-overrides.d.ts","sourceRoot":"","sources":["../src/agent-overrides.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAI1E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,SAAgB,GAAG,cAAc,GAAG,SAAS,CAuBnH"}
|
package/dist/agent-overrides.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
-
import { extname, resolve } from "node:path";
|
|
3
|
-
import { parse as parseYaml } from "yaml";
|
|
4
|
-
import { validateAgentOverrides } from "@acpus/core";
|
|
5
|
-
const SUPPORTED_FILE_EXTENSIONS = new Set([".json", ".yaml", ".yml"]);
|
|
6
|
-
export function parseAgentOverridesInput(value, cwd = process.cwd()) {
|
|
7
|
-
if (value === undefined)
|
|
8
|
-
return undefined;
|
|
9
|
-
const possiblePath = resolve(cwd, value);
|
|
10
|
-
if (existsSync(possiblePath)) {
|
|
11
|
-
const stat = statSync(possiblePath);
|
|
12
|
-
if (stat.isDirectory()) {
|
|
13
|
-
throw new Error("--agents must be a JSON/YAML file or inline JSON/YAML object, not a directory.");
|
|
14
|
-
}
|
|
15
|
-
const extension = extname(possiblePath).toLowerCase();
|
|
16
|
-
if (!SUPPORTED_FILE_EXTENSIONS.has(extension)) {
|
|
17
|
-
throw new Error("--agents file must use .json, .yaml, or .yml.");
|
|
18
|
-
}
|
|
19
|
-
const contents = readFileSync(possiblePath, "utf8");
|
|
20
|
-
const parsed = extension === ".json" ? JSON.parse(contents) : parseYaml(contents);
|
|
21
|
-
return validateAgentOverrides(parsed, "--agents");
|
|
22
|
-
}
|
|
23
|
-
if (looksLikePath(value)) {
|
|
24
|
-
throw new Error(`--agents file not found: ${value}`);
|
|
25
|
-
}
|
|
26
|
-
return validateAgentOverrides(parseYaml(value), "--agents");
|
|
27
|
-
}
|
|
28
|
-
function looksLikePath(value) {
|
|
29
|
-
const trimmed = value.trim();
|
|
30
|
-
if (trimmed.startsWith("{") || trimmed.includes("\n") || /^[A-Za-z0-9_.-]+\s*:/.test(trimmed)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return trimmed.startsWith(".")
|
|
34
|
-
|| trimmed.startsWith("/")
|
|
35
|
-
|| trimmed.startsWith("~")
|
|
36
|
-
|| trimmed.includes("/")
|
|
37
|
-
|| SUPPORTED_FILE_EXTENSIONS.has(extname(trimmed).toLowerCase());
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=agent-overrides.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-overrides.js","sourceRoot":"","sources":["../src/agent-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAA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AAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,sBAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9F,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;WACzB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;WACvB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;WACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;WACrB,yBAAyB,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/follow.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FollowLoop — polls a running Run and emits observations to stdout.
|
|
3
|
-
*
|
|
4
|
-
* Used by `acpus workflows run <spec>` (foreground follow mode) and
|
|
5
|
-
* `acpus workflows run <spec> --json`.
|
|
6
|
-
* Tracks node state changes and deduplicates: only emits when a node is first
|
|
7
|
-
* observed or when its state changes.
|
|
8
|
-
*
|
|
9
|
-
* Ctrl-C detaches (exit 0) without cancelling the Run.
|
|
10
|
-
*/
|
|
11
|
-
import type { RunSupervisorClient, RunStatus } from "@acpus/runtime";
|
|
12
|
-
export interface FollowOptions {
|
|
13
|
-
/** Emit JSONL observations instead of human-readable glyphs */
|
|
14
|
-
json?: boolean;
|
|
15
|
-
/** Polling interval in milliseconds (default 10000 = 10s). Parsed from --poll duration string. */
|
|
16
|
-
intervalMs?: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Run a follow loop until the Run reaches a terminal state.
|
|
20
|
-
* Returns the terminal RunStatus for exit-code mapping.
|
|
21
|
-
*/
|
|
22
|
-
export declare function followRun(client: RunSupervisorClient, runId: string, options?: FollowOptions): Promise<RunStatus>;
|
|
23
|
-
//# sourceMappingURL=follow.d.ts.map
|
package/dist/follow.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../src/follow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAkB,mBAAmB,EAAgC,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAInH,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kGAAkG;IAClG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,SAAS,CAAC,CA+GpB"}
|
package/dist/follow.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FollowLoop — polls a running Run and emits observations to stdout.
|
|
3
|
-
*
|
|
4
|
-
* Used by `acpus workflows run <spec>` (foreground follow mode) and
|
|
5
|
-
* `acpus workflows run <spec> --json`.
|
|
6
|
-
* Tracks node state changes and deduplicates: only emits when a node is first
|
|
7
|
-
* observed or when its state changes.
|
|
8
|
-
*
|
|
9
|
-
* Ctrl-C detaches (exit 0) without cancelling the Run.
|
|
10
|
-
*/
|
|
11
|
-
import { formatObservation, formatTerminalSummary } from "./observations.js";
|
|
12
|
-
import { computeRunDurationMs, shouldShowNode } from "./runs-show.js";
|
|
13
|
-
/**
|
|
14
|
-
* Run a follow loop until the Run reaches a terminal state.
|
|
15
|
-
* Returns the terminal RunStatus for exit-code mapping.
|
|
16
|
-
*/
|
|
17
|
-
export async function followRun(client, runId, options = {}) {
|
|
18
|
-
const intervalMs = options.intervalMs ?? 10_000;
|
|
19
|
-
// Pin the supervisor alive while following
|
|
20
|
-
client.clientKind = "follow";
|
|
21
|
-
const lastObserved = new Map();
|
|
22
|
-
let lastRunStatus;
|
|
23
|
-
let runName = "";
|
|
24
|
-
// Activity dedup: maps nodeKey → last emitted activity string
|
|
25
|
-
const lastActivity = new Map();
|
|
26
|
-
// Register Ctrl-C handler: detach (exit 0) without cancelling
|
|
27
|
-
let detached = false;
|
|
28
|
-
const onSigint = () => {
|
|
29
|
-
detached = true;
|
|
30
|
-
process.off("SIGINT", onSigint);
|
|
31
|
-
// Don't call process.exit(0) here — it skips the finally block and
|
|
32
|
-
// prevents cleanup. Instead, set the flag and let the loop exit naturally.
|
|
33
|
-
};
|
|
34
|
-
process.on("SIGINT", onSigint);
|
|
35
|
-
try {
|
|
36
|
-
for (;;) {
|
|
37
|
-
if (detached) {
|
|
38
|
-
// Ctrl-C detach: the Run continues in the background supervisor.
|
|
39
|
-
// Return a non-terminal status so the caller maps to exit 0.
|
|
40
|
-
return "running";
|
|
41
|
-
}
|
|
42
|
-
let run;
|
|
43
|
-
let nodes;
|
|
44
|
-
try {
|
|
45
|
-
[run, nodes] = await Promise.all([
|
|
46
|
-
client.getRun(runId),
|
|
47
|
-
client.getNodeStates(runId)
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
// Transient fetch error — retry after interval
|
|
52
|
-
if (!options.json) {
|
|
53
|
-
process.stderr.write(`⚠ poll error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
54
|
-
}
|
|
55
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
runName = run.workflowName;
|
|
59
|
-
// Emit Run-level observation on first poll or status change.
|
|
60
|
-
// Terminal states are handled by formatTerminalSummary below; skip here
|
|
61
|
-
// to avoid duplicate "Run ... completed" lines with different glyphs.
|
|
62
|
-
if (lastRunStatus === undefined || run.status !== lastRunStatus) {
|
|
63
|
-
if (!isTerminal(run.status)) {
|
|
64
|
-
const event = {
|
|
65
|
-
type: "run",
|
|
66
|
-
runId,
|
|
67
|
-
status: run.status,
|
|
68
|
-
workflowName: run.workflowName,
|
|
69
|
-
workflowRef: run.workflowRef,
|
|
70
|
-
createdAt: run.createdAt,
|
|
71
|
-
};
|
|
72
|
-
emit(formatObservation(event, runName, options.json));
|
|
73
|
-
}
|
|
74
|
-
lastRunStatus = run.status;
|
|
75
|
-
}
|
|
76
|
-
const visibleNodes = nodes.filter((node) => shouldShowNode(node, nodes));
|
|
77
|
-
// Emit Node-level observations for new/changed nodes
|
|
78
|
-
for (const node of visibleNodes) {
|
|
79
|
-
const prev = lastObserved.get(node.nodeKey);
|
|
80
|
-
if (!prev || prev.state !== node.state) {
|
|
81
|
-
// State change — always emit
|
|
82
|
-
const event = buildNodeEvent(node);
|
|
83
|
-
emit(formatObservation(event, undefined, options.json));
|
|
84
|
-
// Update activity dedup for running agents
|
|
85
|
-
if (node.kind === "run.agent" && node.state === "running" && node.agentTelemetry) {
|
|
86
|
-
lastActivity.set(node.nodeKey, summarizeActivity(node.agentTelemetry));
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
lastActivity.delete(node.nodeKey);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (node.kind === "run.agent" && node.state === "running" && node.agentTelemetry) {
|
|
93
|
-
// No state change, but check if activity content changed (dedup)
|
|
94
|
-
const currentActivity = summarizeActivity(node.agentTelemetry);
|
|
95
|
-
const prevActivity = lastActivity.get(node.nodeKey);
|
|
96
|
-
if (currentActivity !== prevActivity) {
|
|
97
|
-
const event = buildNodeEvent(node);
|
|
98
|
-
emit(formatObservation(event, undefined, options.json));
|
|
99
|
-
lastActivity.set(node.nodeKey, currentActivity);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
lastObserved.set(node.nodeKey, node);
|
|
103
|
-
}
|
|
104
|
-
// Check if Run is terminal
|
|
105
|
-
if (isTerminal(run.status)) {
|
|
106
|
-
const runDuration = computeRunDurationMs(run);
|
|
107
|
-
const summary = formatTerminalSummary(runId, run.status, runName, options.json, {
|
|
108
|
-
runDuration,
|
|
109
|
-
output: run.status === "completed" ? run.output : undefined,
|
|
110
|
-
});
|
|
111
|
-
emit(summary);
|
|
112
|
-
return run.status;
|
|
113
|
-
}
|
|
114
|
-
// Wait before next poll
|
|
115
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
finally {
|
|
119
|
-
process.off("SIGINT", onSigint);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function emit(line) {
|
|
123
|
-
process.stdout.write(line + "\n");
|
|
124
|
-
}
|
|
125
|
-
function isTerminal(status) {
|
|
126
|
-
return status === "completed" || status === "failed" || status === "cancelled" || status === "paused";
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Build an ObservationEvent for a node with all available fields.
|
|
130
|
-
*/
|
|
131
|
-
function buildNodeEvent(node) {
|
|
132
|
-
const event = {
|
|
133
|
-
type: "node",
|
|
134
|
-
nodeKey: node.nodeKey,
|
|
135
|
-
state: node.state,
|
|
136
|
-
kind: node.kind,
|
|
137
|
-
startedAt: node.startedAt,
|
|
138
|
-
completedAt: node.completedAt,
|
|
139
|
-
error: node.error,
|
|
140
|
-
attempt: node.attempt,
|
|
141
|
-
};
|
|
142
|
-
// Attach rich fields for JSON mode
|
|
143
|
-
if (node.agentTelemetry)
|
|
144
|
-
event.agentTelemetry = node.agentTelemetry;
|
|
145
|
-
if (node.artifactRefs)
|
|
146
|
-
event.artifactRefs = node.artifactRefs;
|
|
147
|
-
if (node.state === "completed" && node.output !== undefined && typeof node.output === "object" && node.output !== null) {
|
|
148
|
-
event.output = node.output;
|
|
149
|
-
}
|
|
150
|
-
return event;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Derive a concise activity fingerprint string from agent telemetry for dedup.
|
|
154
|
-
* Uses the same summary format as the human-readable output.
|
|
155
|
-
*/
|
|
156
|
-
function summarizeActivity(telemetry) {
|
|
157
|
-
const attempt = telemetry.attempts.find((a) => a.attempt === telemetry.currentAttempt)
|
|
158
|
-
?? telemetry.attempts[telemetry.attempts.length - 1];
|
|
159
|
-
if (!attempt)
|
|
160
|
-
return "";
|
|
161
|
-
// Key fields that change over time — compare these for dedup
|
|
162
|
-
return `${attempt.updatedAt}|${attempt.tools.totalToolCallCount}|${attempt.tools.recentCalls.map(c => c.toolCallId).join(",")}`;
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=follow.js.map
|
package/dist/follow.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../src/follow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAyB,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAStE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA2B,EAC3B,KAAa,EACb,OAAO,GAAkB,EAAE;IAE3B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,CAAC;IAEhD,2CAA2C;IAC3C,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC;IAE7B,MAAM,YAAY,GAAG,IAAI,GAAG,EAA8B,CAAC;IAC3D,IAAI,aAAoC,CAAC;IACzC,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,8DAA8D;IAC9D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE/C,8DAA8D;IAC9D,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