@mmerterden/multi-agent-pipeline 23.7.0 → 24.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -1
- package/README.md +59 -24
- package/README.tr.md +43 -8
- package/SECURITY.md +3 -3
- package/docs/architecture.md +41 -4
- package/docs/ecosystem.md +15 -13
- package/docs/facts.json +5 -4
- package/docs/features.md +67 -15
- package/install/_codex-agents.mjs +13 -8
- package/install/_common.mjs +24 -0
- package/install/_dev-only-files.mjs +5 -0
- package/install/_mcp-register.mjs +6 -2
- package/install/_rewrite-tree.mjs +197 -0
- package/install/codex.mjs +96 -180
- package/install/copilot.mjs +24 -54
- package/install/index.mjs +29 -11
- package/install/templates/codex-instructions.md +21 -5
- package/install/templates/copilot-instructions.md +21 -14
- package/manifest.json +2083 -0
- package/package.json +8 -2
- package/pipeline/commands/multi-agent/SKILL.md +5 -4
- package/pipeline/commands/multi-agent/analysis/SKILL.md +5 -1
- package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
- package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
- package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
- package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
- package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
- package/pipeline/contract/CHANGELOG.md +15 -0
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/fixtures/runs-awaiting-question.json +6 -1
- package/pipeline/contract/fixtures/runs-empty.json +1 -1
- package/pipeline/contract/fixtures/runs-failed.json +21 -1
- package/pipeline/contract/fixtures/runs-old-schema.json +18 -3
- package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +31 -1
- package/pipeline/contract/fixtures/runs-pr-opened.json +31 -1
- package/pipeline/contract/fixtures/runs-running.json +16 -1
- package/pipeline/contract/manifest.json +14 -14
- package/pipeline/contract/types/index.d.ts +20 -1
- package/pipeline/lib/_jira-auth.sh +50 -78
- package/pipeline/lib/_service-account.sh +191 -0
- package/pipeline/lib/credential-inventory.sh +49 -37
- package/pipeline/lib/credential-store.sh +48 -3
- package/pipeline/lib/fetch-confluence.sh +76 -92
- package/pipeline/lib/fetch-crashlytics.sh +30 -59
- package/pipeline/lib/fetch-figma-annotations.sh +9 -9
- package/pipeline/lib/fetch-fortify.sh +77 -81
- package/pipeline/lib/fetch-graylog.sh +38 -77
- package/pipeline/lib/figma-mcp-refresh.sh +23 -4
- package/pipeline/lib/figma-screenshot.sh +7 -8
- package/pipeline/lib/figma-token.sh +39 -46
- package/pipeline/lib/host.mjs +138 -0
- package/pipeline/lib/host.sh +48 -0
- package/pipeline/lib/issue-fetcher.sh +25 -41
- package/pipeline/lib/jira-publish.sh +23 -21
- package/pipeline/lib/local-model.mjs +93 -0
- package/pipeline/lib/md2confluence-v3.py +37 -30
- package/pipeline/lib/model-dispatch.sh +41 -4
- package/pipeline/lib/model-resolve.mjs +58 -0
- package/pipeline/lib/post-pr-review.sh +38 -53
- package/pipeline/lib/reviewer-families.mjs +70 -0
- package/pipeline/lib/service-account.mjs +2131 -0
- package/pipeline/lib/service-account.sh +35 -0
- package/pipeline/lib/usage-token.mjs +64 -24
- package/pipeline/lib/usage-vocab.mjs +1 -1
- package/pipeline/lib/user-facing.mjs +11 -3
- package/pipeline/lib/vercel-deploy.sh +17 -26
- package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
- package/pipeline/multi-agent-refs/analysis/render.md +12 -1
- package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
- package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
- package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
- package/pipeline/multi-agent-refs/channels/generator.md +10 -2
- package/pipeline/multi-agent-refs/channels/menu.md +3 -1
- package/pipeline/multi-agent-refs/channels/preview.md +3 -1
- package/pipeline/multi-agent-refs/channels/reference.md +16 -2
- package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
- package/pipeline/multi-agent-refs/cross-cli-contract.md +35 -27
- package/pipeline/multi-agent-refs/features/doctor.md +37 -11
- package/pipeline/multi-agent-refs/features/free-models.md +3 -3
- package/pipeline/multi-agent-refs/features/local-model.md +87 -0
- package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
- package/pipeline/multi-agent-refs/features/product-context.md +6 -5
- package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
- package/pipeline/multi-agent-refs/help/en.md +36 -1
- package/pipeline/multi-agent-refs/help/tr.md +34 -1
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +2 -1
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
- package/pipeline/multi-agent-refs/phases/modes.md +20 -1
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -0
- package/pipeline/multi-agent-refs/phases/phase-4-commit.md +1 -0
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +13 -11
- package/pipeline/multi-agent-refs/phases.md +4 -3
- package/pipeline/multi-agent-refs/review/panel.md +30 -18
- package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
- package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
- package/pipeline/multi-agent-refs/sync/overview.md +11 -5
- package/pipeline/multi-agent-refs/tracker-contract.md +64 -20
- package/pipeline/office/index.html +77 -4
- package/pipeline/schemas/activity.schema.json +63 -4
- package/pipeline/schemas/autopilot-config.schema.json +29 -4
- package/pipeline/schemas/hosts.json +512 -0
- package/pipeline/schemas/hosts.schema.json +310 -0
- package/pipeline/schemas/launch.json +22 -2
- package/pipeline/schemas/launch.schema.json +2 -1
- package/pipeline/schemas/now-lines.json +103 -0
- package/pipeline/schemas/now-lines.schema.json +42 -0
- package/pipeline/schemas/phases.json +19 -1
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +331 -4
- package/pipeline/schemas/runs-index.schema.json +22 -1
- package/pipeline/scripts/_autopilot-config.mjs +67 -4
- package/pipeline/scripts/_autopilot-item.mjs +67 -0
- package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
- package/pipeline/scripts/_contract-core.mjs +1 -1
- package/pipeline/scripts/_cost.mjs +75 -3
- package/pipeline/scripts/activity-snapshot.mjs +27 -1
- package/pipeline/scripts/analysis-sources.mjs +22 -5
- package/pipeline/scripts/analysis-unattended.mjs +360 -0
- package/pipeline/scripts/anonymize-findings.mjs +3 -7
- package/pipeline/scripts/autopilot-arming.mjs +19 -10
- package/pipeline/scripts/autopilot-intake.mjs +124 -27
- package/pipeline/scripts/autopilot-menubar.swift +7 -0
- package/pipeline/scripts/autopilot-runner.mjs +77 -48
- package/pipeline/scripts/autopilot-status.sh +32 -9
- package/pipeline/scripts/bulk-read.sh +37 -5
- package/pipeline/scripts/confluence-readback.mjs +15 -7
- package/pipeline/scripts/cost-table.json +65 -25
- package/pipeline/scripts/doctor.mjs +119 -32
- package/pipeline/scripts/entry-mode.mjs +101 -0
- package/pipeline/scripts/estimate.mjs +30 -16
- package/pipeline/scripts/feedback-send.mjs +11 -8
- package/pipeline/scripts/gen-facts.mjs +7 -9
- package/pipeline/scripts/jira-attach.sh +23 -28
- package/pipeline/scripts/jira-search.sh +5 -21
- package/pipeline/scripts/launch-request.mjs +15 -9
- package/pipeline/scripts/migrate-prefs.mjs +56 -0
- package/pipeline/scripts/phase-tracker.sh +226 -50
- package/pipeline/scripts/priority-review.mjs +14 -7
- package/pipeline/scripts/product-context.mjs +26 -7
- package/pipeline/scripts/prune-logs.sh +4 -2
- package/pipeline/scripts/render-work-summary.sh +51 -1
- package/pipeline/scripts/report-file.mjs +285 -0
- package/pipeline/scripts/rework-escalation.mjs +19 -4
- package/pipeline/scripts/runs-index.mjs +2 -1
- package/pipeline/scripts/service-read.mjs +19 -17
- package/pipeline/scripts/skill-siblings.mjs +17 -1
- package/pipeline/scripts/status-overview.mjs +20 -10
- package/pipeline/scripts/uninstall.mjs +145 -57
- package/pipeline/scripts/usage-register.mjs +34 -11
- package/pipeline/scripts/usage-report.mjs +31 -26
- package/pipeline/scripts/validate-triage.mjs +11 -1
- package/pipeline/scripts/work-items.mjs +25 -28
- package/pipeline/scripts/write-store-config.mjs +37 -11
- package/pipeline/skills/.skill-manifest.json +4 -4
- package/pipeline/skills/.skills-index.json +1 -1
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +11 -3
- package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
- package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
- package/pipeline/lib/credential-resolve.mjs +0 -75
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"contractVersion": "1.
|
|
2
|
+
"contractVersion": "1.6.0",
|
|
3
3
|
"logsRoot": "/Users/example/.claude/logs/multi-agent",
|
|
4
4
|
"count": 1,
|
|
5
5
|
"runs": [
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"now": null,
|
|
41
41
|
"subs": 0,
|
|
42
42
|
"subList": [],
|
|
43
|
+
"tokens": {
|
|
44
|
+
"in": 1200,
|
|
45
|
+
"out": 340,
|
|
46
|
+
"cached": 900
|
|
47
|
+
},
|
|
43
48
|
"progress": 1,
|
|
44
49
|
"tasks": []
|
|
45
50
|
},
|
|
@@ -53,6 +58,11 @@
|
|
|
53
58
|
"now": null,
|
|
54
59
|
"subs": 0,
|
|
55
60
|
"subList": [],
|
|
61
|
+
"tokens": {
|
|
62
|
+
"in": 1200,
|
|
63
|
+
"out": 340,
|
|
64
|
+
"cached": 900
|
|
65
|
+
},
|
|
56
66
|
"progress": 1,
|
|
57
67
|
"tasks": []
|
|
58
68
|
},
|
|
@@ -77,6 +87,11 @@
|
|
|
77
87
|
"status": "in_progress"
|
|
78
88
|
}
|
|
79
89
|
],
|
|
90
|
+
"tokens": {
|
|
91
|
+
"in": 0,
|
|
92
|
+
"out": 0,
|
|
93
|
+
"cached": 0
|
|
94
|
+
},
|
|
80
95
|
"progress": 0.5,
|
|
81
96
|
"tasks": [
|
|
82
97
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"contractVersion": "2.
|
|
2
|
+
"contractVersion": "2.4.0",
|
|
3
3
|
"supportedMajors": [2, 1],
|
|
4
4
|
"description": "The pipeline's client contract: every surface a client reads or writes, the CLI invocation and the HTTP route that carry it, and the schema its JSON follows. Schemas are not copied here; schemasDir points at the one tree the producers validate against. Paths in cli are relative to the pipeline directory (installed: ~/.claude).",
|
|
5
5
|
"schemasDir": "../schemas",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"query": ["group", "redact"],
|
|
96
96
|
"cli": ["node", "scripts/runs-index.mjs", "--json", "[--group <group>]", "[--redact]"],
|
|
97
97
|
"schema": "runs-index.schema.json",
|
|
98
|
-
"version": "1.
|
|
98
|
+
"version": "1.6.0",
|
|
99
99
|
"remote": "read",
|
|
100
100
|
"risk": "read"
|
|
101
101
|
},
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"query": ["redact"],
|
|
107
107
|
"cli": ["node", "scripts/runs-index.mjs", "--json", "--task-id", "{id}", "[--redact]"],
|
|
108
108
|
"schema": "runs-index.schema.json",
|
|
109
|
-
"version": "1.
|
|
109
|
+
"version": "1.6.0",
|
|
110
110
|
"remote": "read",
|
|
111
111
|
"risk": "read"
|
|
112
112
|
},
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"query": ["redact"],
|
|
181
181
|
"cli": ["node", "scripts/launch-request.mjs", "spec"],
|
|
182
182
|
"schema": "launch.schema.json",
|
|
183
|
-
"version": "1.
|
|
183
|
+
"version": "1.3.0",
|
|
184
184
|
"remote": "read",
|
|
185
185
|
"risk": "read"
|
|
186
186
|
},
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"body": "repo-request.schema.json",
|
|
205
205
|
"cli": ["node", "scripts/launch-request.mjs", "register-repo", "<path>"],
|
|
206
206
|
"schema": "repo-change.schema.json",
|
|
207
|
-
"version": "1.
|
|
207
|
+
"version": "1.5.0",
|
|
208
208
|
"note": "Two steps: the preview names the repository, the confirmation stores it in launch-repos.json. Only a git checkout that is neither the home directory nor the root is accepted.",
|
|
209
209
|
"remote": "local-only",
|
|
210
210
|
"risk": "high"
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
"path": "/v1/repos/{id}",
|
|
216
216
|
"query": ["confirm"],
|
|
217
217
|
"schema": "repo-change.schema.json",
|
|
218
|
-
"version": "1.
|
|
218
|
+
"version": "1.5.0",
|
|
219
219
|
"note": "Two steps: without confirm the preview and a token; with ?confirm=<token> the registered entry is removed. Configured autopilot repositories are not touched.",
|
|
220
220
|
"remote": "local-only",
|
|
221
221
|
"risk": "high"
|
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
"query": [],
|
|
398
398
|
"cli": ["node", "scripts/activity-snapshot.mjs", "--json"],
|
|
399
399
|
"schema": "activity.schema.json",
|
|
400
|
-
"version": "1.
|
|
400
|
+
"version": "1.5.0",
|
|
401
401
|
"note": "Derived from disk on every call; no field is machine-local, so redact changes nothing.",
|
|
402
402
|
"remote": "read",
|
|
403
403
|
"risk": "read"
|
|
@@ -409,7 +409,7 @@
|
|
|
409
409
|
"query": [],
|
|
410
410
|
"cli": ["node", "scripts/activity-snapshot.mjs", "--json"],
|
|
411
411
|
"schema": "activity.schema.json",
|
|
412
|
-
"version": "1.
|
|
412
|
+
"version": "1.5.0",
|
|
413
413
|
"note": "text/event-stream: an `activity` event carrying the document whenever it changes (checked every 2 seconds), a comment line as heartbeat. At most 4 streams at once (429 too-many-streams).",
|
|
414
414
|
"remote": "read",
|
|
415
415
|
"risk": "read"
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
"[--limit <n>]"
|
|
430
430
|
],
|
|
431
431
|
"schema": "activity-chat.schema.json",
|
|
432
|
-
"version": "1.
|
|
432
|
+
"version": "1.5.0",
|
|
433
433
|
"note": "agentId main is the session itself. Refused (403) to any Origin but the server's own page, even an allowed one. limit is 1 to 500, 200 by default; before is the offset the previous page returned.",
|
|
434
434
|
"remote": "read",
|
|
435
435
|
"risk": "read"
|
|
@@ -441,7 +441,7 @@
|
|
|
441
441
|
"query": [],
|
|
442
442
|
"cli": ["node", "scripts/routine-registry.mjs", "list", "--json"],
|
|
443
443
|
"schema": "routines.schema.json",
|
|
444
|
-
"version": "1.
|
|
444
|
+
"version": "1.5.0",
|
|
445
445
|
"remote": "read",
|
|
446
446
|
"risk": "read"
|
|
447
447
|
},
|
|
@@ -452,7 +452,7 @@
|
|
|
452
452
|
"query": ["confirm"],
|
|
453
453
|
"cli": ["node", "scripts/routine-registry.mjs", "remove", "--name", "{name}"],
|
|
454
454
|
"schema": "routine-delete.schema.json",
|
|
455
|
-
"version": "1.
|
|
455
|
+
"version": "1.5.0",
|
|
456
456
|
"note": "Two steps: without confirm the preview and a token; with ?confirm=<token> the removal. A shipped command is refused (409 not-removable). An unattended server refuses both steps with 409 unattended-refused.",
|
|
457
457
|
"remote": "local-only",
|
|
458
458
|
"risk": "high"
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
"query": [],
|
|
465
465
|
"cli": ["node", "scripts/routine-share.mjs", "browse"],
|
|
466
466
|
"schema": "shared-routines.schema.json",
|
|
467
|
-
"version": "1.
|
|
467
|
+
"version": "1.5.0",
|
|
468
468
|
"note": "The routines other site members shared that this machine may see, without bodies, read with the machine's usage token by routine-share.mjs. When sharing cannot answer the body says why (available false, reason) instead of an error. Local only: it spends this machine's token.",
|
|
469
469
|
"remote": "local-only",
|
|
470
470
|
"risk": "read"
|
|
@@ -476,7 +476,7 @@
|
|
|
476
476
|
"query": [],
|
|
477
477
|
"cli": ["node", "scripts/routine-share.mjs", "fetch", "--id", "{id}"],
|
|
478
478
|
"schema": "shared-routine.schema.json",
|
|
479
|
-
"version": "1.
|
|
479
|
+
"version": "1.5.0",
|
|
480
480
|
"note": "One shared routine with its body, version and payload digest, after the body was checked against its sha256; description and argumentHint are the values an import writes, unscrubbed. An unknown id is 404 not-found; a refusal from the sharing server is 502 upstream-failed.",
|
|
481
481
|
"remote": "local-only",
|
|
482
482
|
"risk": "read"
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
"{name}"
|
|
500
500
|
],
|
|
501
501
|
"schema": "shared-routine-import.schema.json",
|
|
502
|
-
"version": "1.
|
|
502
|
+
"version": "1.5.0",
|
|
503
503
|
"note": "Two steps. {} or {as} previews the full body, its sha256, the description, descriptionTr and argument hint as they become frontmatter, the payload digest over all of them and the local name, and returns a token bound to that routine, sha256, digest and name; a taken name is 409 name-taken, answered with another as; an as that is not a valid local name (the reserved shared included) is 400 invalid-body; a shared routine that would fail the import checks (name, description, descriptionTr, argumentHint, body, sha256) is 502 upstream-failed naming the field. {confirmToken, sha256, digest} installs the routine only when both are the previewed ones (else 409 confirm-mismatch) and the routine still matches them and still passes the import checks (else 409 state-moved). The frontmatter is rebuilt locally and the routine is never run. An unattended server refuses both steps with 409 unattended-refused.",
|
|
504
504
|
"remote": "local-only",
|
|
505
505
|
"risk": "high"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by pipeline/contract/build.mjs from pipeline/schemas/*.schema.json.
|
|
2
2
|
// Do not edit: change the schema and run `node pipeline/contract/build.mjs --write`.
|
|
3
3
|
|
|
4
|
-
export type ContractVersion = "2.
|
|
4
|
+
export type ContractVersion = "2.4.0";
|
|
5
5
|
export type SurfaceId = "runs" | "run" | "commands" | "skills" | "questions" | "issues" | "worktrees" | "launch-spec" | "repos" | "repo-add" | "repo-remove" | "launch" | "answer" | "run-log" | "resume" | "kill" | "gc" | "autopilot" | "autopilot-off" | "autopilot-on" | "steer" | "activity" | "activity-stream" | "agent-chat" | "routines" | "routine-delete" | "routines-shared" | "routine-shared" | "routine-shared-import" | "jobs" | "job-start" | "stack" | "stack-set" | "ledger" | "system" | "prune-logs" | "disk-clean" | "settings" | "settings-set" | "learning-curve" | "credentials" | "memory" | "server-room" | "mcp-health" | "archive" | "run-results" | "run-evidence" | "review-verdict" | "issue-maturity" | "prs" | "prs-reach" | "tools" | "tool-call" | "service-confluence" | "service-crashlytics" | "service-figma" | "permissions";
|
|
6
6
|
|
|
7
7
|
/** What `runs-index.mjs --json` prints: every run under the log root and the unattended log root (one record per task id), grouped per status/SKILL.md 3b. Fields are only ever added - a decoder ignores keys it does not know. `--redact` drops every x-sensitivity local field (and `logsRoot`) and scrubs the free text in the title, `now`, sub-step names, task subjects and the pending question. */
|
|
@@ -123,6 +123,12 @@ export interface RunsIndexPhase {
|
|
|
123
123
|
name: string;
|
|
124
124
|
status: string;
|
|
125
125
|
}>;
|
|
126
|
+
/** What this one phase spent, from its own tracker counters. The run's total is the `tokens` beside it on the run record. Added in 1.6.0. */
|
|
127
|
+
tokens: {
|
|
128
|
+
in: number;
|
|
129
|
+
out: number;
|
|
130
|
+
cached: number;
|
|
131
|
+
};
|
|
126
132
|
/** 1 for a completed or skipped phase, 0 for a pending one; otherwise completed tasks over tasks, and null when the phase has no tasks. Added in 1.2.0. */
|
|
127
133
|
progress?: number | null;
|
|
128
134
|
/** The host's native task list for this phase (TaskCreate/TaskUpdate, update_plan steps, card rows) as `phase-tracker.sh task` mirrored it; empty when there are none. subject and activeForm are scrubbed under --redact. Added in 1.2.0. */
|
|
@@ -308,6 +314,7 @@ export interface LaunchHost {
|
|
|
308
314
|
bin?: string;
|
|
309
315
|
cwd?: string;
|
|
310
316
|
note: string;
|
|
317
|
+
/** The launch shape per declared mode of schemas/phases.json that a client may start without a terminal conversation. autopilot runs the pipeline and stops at a pull request; analysis-autopilot runs the analysis command and stops at a document. */
|
|
311
318
|
modes?: {
|
|
312
319
|
[key: string]: LaunchShape;
|
|
313
320
|
};
|
|
@@ -715,6 +722,18 @@ export interface ActivityTable {
|
|
|
715
722
|
status: string;
|
|
716
723
|
startedAt: string | null;
|
|
717
724
|
completedAt: string | null;
|
|
725
|
+
/** The model that spent this phase's tokens, as the tracker recorded it; null until one is set. */
|
|
726
|
+
model: string | null;
|
|
727
|
+
/** What the phase is doing, for a running or failed phase only. Falls back to the name of the in-progress sub-step, and is null when neither exists. */
|
|
728
|
+
now: string | null;
|
|
729
|
+
/** Input plus output tokens for this phase; null when none were recorded. */
|
|
730
|
+
tokens: number | null;
|
|
731
|
+
/** The phase's own steps, as the card and the subject counter use them. */
|
|
732
|
+
subs: Array<{
|
|
733
|
+
id: string;
|
|
734
|
+
name: string;
|
|
735
|
+
status: "pending" | "in_progress" | "completed";
|
|
736
|
+
}>;
|
|
718
737
|
}>;
|
|
719
738
|
startedAt: string | null;
|
|
720
739
|
elapsedSeconds: number | null;
|
|
@@ -8,106 +8,78 @@
|
|
|
8
8
|
# and a third writer was about to make it three. Duplicated auth does not stay
|
|
9
9
|
# duplicated: it drifts, and the copy that drifts is the one nobody is looking at.
|
|
10
10
|
#
|
|
11
|
-
# Today only `analysis-jira-write.sh` sources this. The two older callers still
|
|
12
|
-
# carry their own resolution - `issue-fetcher.sh` resolves per-account token keys
|
|
13
|
-
# this helper does not model yet - so this is where new callers go, not a
|
|
14
|
-
# consolidation that has already happened.
|
|
15
11
|
# Worse, the part most worth getting right is the part most easily retyped badly -
|
|
16
|
-
# the token goes to curl through a
|
|
17
|
-
#
|
|
18
|
-
#
|
|
12
|
+
# the token goes to curl through a config file so it never reaches argv, a log,
|
|
13
|
+
# or `ps`. A second-hand copy of that idiom is a leak waiting for the first
|
|
14
|
+
# person who simplifies it.
|
|
15
|
+
#
|
|
16
|
+
# Host and token are now one answer rather than two lookups: `service-account.sh`
|
|
17
|
+
# decides which account covers the host being called and hands out that account's
|
|
18
|
+
# token for that host only. The token never reaches a shell variable here -
|
|
19
|
+
# `jira_api` asks for a curl config per call - so a stray `set -x` or an error
|
|
20
|
+
# trace has nothing to print.
|
|
19
21
|
#
|
|
20
22
|
# Sourced, never executed. The leading underscore marks it: it is a library for
|
|
21
23
|
# the scripts beside it, not a command.
|
|
22
24
|
#
|
|
23
25
|
# . "$(dirname "$0")/_jira-auth.sh"
|
|
24
|
-
# jira_auth_resolve || exit 4 # sets JIRA_API_HOST
|
|
26
|
+
# jira_auth_resolve || exit 4 # sets JIRA_API_HOST
|
|
25
27
|
# jira_api GET /rest/api/2/myself
|
|
26
28
|
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
29
|
+
# What the caller may still say, and what each now means to the resolver:
|
|
30
|
+
# $JIRA_HOST, $ACCOUNT_JIRA_HOST the destination; an account must cover it
|
|
31
|
+
# $JIRA_TOKEN a credential from the environment
|
|
32
|
+
# $JIRA_TOKEN_KEY, $ACCOUNT_JIRA_TOKEN_KEY a store item name; the account
|
|
33
|
+
# holding it answers
|
|
32
34
|
#
|
|
33
|
-
# Exit contract: `jira_auth_resolve` returns 0 when
|
|
34
|
-
# did not, having already said which on
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
# a
|
|
35
|
+
# Exit contract: `jira_auth_resolve` returns 0 when the host and an account for
|
|
36
|
+
# it both resolved, and 4 when either did not, having already said which on
|
|
37
|
+
# stderr. 4 is the code both original callers used for "could not resolve", so
|
|
38
|
+
# nothing downstream changes meaning. jq is no longer involved, so the old 3
|
|
39
|
+
# ("a value had to come from prefs and jq is not installed") can no longer
|
|
40
|
+
# happen; a caller testing for it will simply never see it.
|
|
38
41
|
|
|
39
42
|
# shellcheck shell=bash
|
|
40
43
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
JIRA_AUTH_PREFS="${JIRA_AUTH_PREFS:-${MULTI_AGENT_PREFS:-$HOME/.claude/multi-agent-preferences.json}}"
|
|
44
|
-
|
|
45
|
-
_jira_auth_pref() { # _jira_auth_pref <jq path> -> value or empty
|
|
46
|
-
[ -f "$JIRA_AUTH_PREFS" ] || { printf ''; return 0; }
|
|
47
|
-
# Without jq this printed empty and returned 0, so "no jq" and "key not set"
|
|
48
|
-
# were the same answer and the caller went on to authenticate with nothing -
|
|
49
|
-
# surfacing much later as a 401 that blames the credential.
|
|
50
|
-
if ! command -v jq >/dev/null 2>&1; then
|
|
51
|
-
echo "jq not found - cannot read $JIRA_AUTH_PREFS (install: brew install jq)" >&2
|
|
52
|
-
printf ''
|
|
53
|
-
return 3
|
|
54
|
-
fi
|
|
55
|
-
jq -r "$1 // empty" "$JIRA_AUTH_PREFS" 2>/dev/null || printf ''
|
|
56
|
-
}
|
|
44
|
+
# shellcheck source=_service-account.sh
|
|
45
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_service-account.sh"
|
|
57
46
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
47
|
+
# The selectors the environment asked for, as resolver arguments.
|
|
48
|
+
_jira_auth_selectors() {
|
|
49
|
+
local host="${JIRA_HOST:-${ACCOUNT_JIRA_HOST:-}}"
|
|
50
|
+
local item="${JIRA_TOKEN_KEY:-${ACCOUNT_JIRA_TOKEN_KEY:-}}"
|
|
51
|
+
[ -n "$host" ] && printf '%s\n%s\n' "--host" "$host"
|
|
52
|
+
[ -n "$item" ] && printf '%s\n%s\n' "--item" "$item"
|
|
53
|
+
return 0
|
|
65
54
|
}
|
|
66
55
|
|
|
67
56
|
jira_auth_resolve() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
local -a sel=()
|
|
58
|
+
while IFS= read -r line; do [ -n "$line" ] && sel+=("$line"); done < <(_jira_auth_selectors)
|
|
59
|
+
|
|
60
|
+
JIRA_API_HOST="$(sa_host jira "${sel[@]+"${sel[@]}"}")" || {
|
|
61
|
+
echo "ERR: no Jira account for this run: $(sa_explain)" >&2
|
|
62
|
+
return 4
|
|
63
|
+
}
|
|
72
64
|
if [ -z "$JIRA_API_HOST" ]; then
|
|
73
|
-
echo "ERR:
|
|
65
|
+
echo "ERR: the Jira account names no host; run /multi-agent:setup" >&2
|
|
74
66
|
return 4
|
|
75
67
|
fi
|
|
76
|
-
|
|
77
|
-
JIRA_API_HOST="${JIRA_API_HOST#https://}"
|
|
78
|
-
JIRA_API_HOST="${JIRA_API_HOST#http://}"
|
|
79
|
-
JIRA_API_HOST="${JIRA_API_HOST%/}"
|
|
80
|
-
|
|
81
|
-
JIRA_API_TOKEN="${JIRA_TOKEN:-}"
|
|
82
|
-
if [ -z "$JIRA_API_TOKEN" ]; then
|
|
83
|
-
local key store
|
|
84
|
-
key="${JIRA_TOKEN_KEY:-${ACCOUNT_JIRA_TOKEN_KEY:-}}"
|
|
85
|
-
[ -n "$key" ] || key="$(_jira_auth_pref '.global.keychainMapping.jira')" || return $?
|
|
86
|
-
if [ -z "$key" ]; then
|
|
87
|
-
echo "ERR: no Jira token: set JIRA_TOKEN or map prefs .global.keychainMapping.jira" >&2
|
|
88
|
-
return 4
|
|
89
|
-
fi
|
|
90
|
-
store="$(_jira_auth_store)" || {
|
|
91
|
-
echo "ERR: credential-store.sh not found next to lib/ or in ~/.claude/lib" >&2
|
|
92
|
-
return 4
|
|
93
|
-
}
|
|
94
|
-
JIRA_API_TOKEN="$(bash "$store" get "$key" 2>/dev/null || printf '')"
|
|
95
|
-
if [ -z "$JIRA_API_TOKEN" ]; then
|
|
96
|
-
echo "ERR: Jira token not in the credential store under: $key" >&2
|
|
97
|
-
return 4
|
|
98
|
-
fi
|
|
99
|
-
fi
|
|
68
|
+
JIRA_AUTH_SELECTORS=("${sel[@]+"${sel[@]}"}")
|
|
100
69
|
return 0
|
|
101
70
|
}
|
|
102
71
|
|
|
103
|
-
# The token reaches curl only through a -K config on process substitution: never
|
|
104
|
-
# argv, never a log, never `ps`. Every caller goes through here so that stays
|
|
105
|
-
# true in one place instead of three.
|
|
106
|
-
_jira_auth_cfg() { printf 'header = "Authorization: Bearer %s"\n' "$1"; }
|
|
107
|
-
|
|
108
72
|
jira_api() { # jira_api <METHOD> <path> [curl args...]
|
|
109
|
-
local method="$1" path="$2"
|
|
110
|
-
|
|
73
|
+
local method="$1" path="$2" cfg
|
|
74
|
+
shift 2
|
|
75
|
+
cfg="$(sa_cfg jira "https://$JIRA_API_HOST$path" bearer \
|
|
76
|
+
"${JIRA_AUTH_SELECTORS[@]+"${JIRA_AUTH_SELECTORS[@]}"}")" || {
|
|
77
|
+
echo "ERR: $(sa_explain)" >&2
|
|
78
|
+
return 4
|
|
79
|
+
}
|
|
80
|
+
# The URL and the scheme lock live in the config, so they cannot be separated
|
|
81
|
+
# from the header between the check and the request.
|
|
82
|
+
curl -sS -m 30 --config "$cfg" \
|
|
111
83
|
-H "Content-Type: application/json" \
|
|
112
|
-
-X "$method" "
|
|
84
|
+
-X "$method" "$@"
|
|
113
85
|
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# shellcheck shell=bash
|
|
2
|
+
# _service-account.sh - what a shell fetcher needs from the account resolver.
|
|
3
|
+
#
|
|
4
|
+
# Sourced, not executed. Every fetcher in the pipeline does the same four
|
|
5
|
+
# things: find the resolver, ask which host an account is for, get a curl
|
|
6
|
+
# config that carries the credential to that host and nowhere else, and say
|
|
7
|
+
# something useful when the answer is no. Written once here, those four are the
|
|
8
|
+
# same everywhere; written per fetcher they drifted, and a fetcher that builds
|
|
9
|
+
# its own `-H "Authorization: ..."` is a fetcher that can send it to a redirect.
|
|
10
|
+
#
|
|
11
|
+
# The credential never reaches argv, an environment variable, or a log: it is
|
|
12
|
+
# written to a config file only curl reads, with the mode set before anything
|
|
13
|
+
# is in it, and removed when the shell exits.
|
|
14
|
+
#
|
|
15
|
+
# Usage:
|
|
16
|
+
# . "$(dirname "$0")/_service-account.sh" # or the installed lib path
|
|
17
|
+
# cfg="$(sa_cfg jira "$url" bearer)" || exit $?
|
|
18
|
+
# curl --config "$cfg" ...
|
|
19
|
+
#
|
|
20
|
+
# sa_host jira # the host of the chosen account
|
|
21
|
+
# sa_base jira # scheme and host, port kept
|
|
22
|
+
# sa_reason # the last refusal, as JSON
|
|
23
|
+
|
|
24
|
+
SA_TRAP_SET=""
|
|
25
|
+
|
|
26
|
+
# One directory, created when this file is sourced, removed when the sourcing
|
|
27
|
+
# shell exits.
|
|
28
|
+
#
|
|
29
|
+
# It is made here rather than inside sa_cfg because sa_cfg is called from a
|
|
30
|
+
# command substitution, which is a subshell: a file registered for cleanup
|
|
31
|
+
# there is removed the moment that subshell ends, which is before the caller
|
|
32
|
+
# has read the path it just printed. A directory created in the parent is
|
|
33
|
+
# inherited by every subshell, and the parent's trap outlives all of them.
|
|
34
|
+
SA_TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/sa.XXXXXX")"
|
|
35
|
+
chmod 700 "$SA_TMPDIR"
|
|
36
|
+
|
|
37
|
+
# The last refusal is kept in a file, not a variable.
|
|
38
|
+
#
|
|
39
|
+
# Every caller reaches the resolver through a command substitution - that is
|
|
40
|
+
# what `cfg="$(sa_cfg ...)"` is - and a variable assigned inside one is assigned
|
|
41
|
+
# in a subshell that ends before the caller reads it. A refusal stored that way
|
|
42
|
+
# is gone by the time the caller asks why, and the caller reports whatever its
|
|
43
|
+
# default branch says instead of what actually happened. A file written in the
|
|
44
|
+
# subshell is there in the parent.
|
|
45
|
+
SA_ERROR_FILE="$SA_TMPDIR/last-refusal"
|
|
46
|
+
: >"$SA_ERROR_FILE"
|
|
47
|
+
|
|
48
|
+
sa_sweep() { [ -n "${SA_TMPDIR:-}" ] && rm -rf "$SA_TMPDIR"; return 0; }
|
|
49
|
+
|
|
50
|
+
if [ -z "$SA_TRAP_SET" ]; then
|
|
51
|
+
SA_EXISTING_TRAP="$(trap -p EXIT | sed -E "s/^trap -- '(.*)' EXIT$/\1/")"
|
|
52
|
+
if [ -n "$SA_EXISTING_TRAP" ]; then
|
|
53
|
+
# shellcheck disable=SC2064
|
|
54
|
+
trap "sa_sweep; $SA_EXISTING_TRAP" EXIT
|
|
55
|
+
else
|
|
56
|
+
trap sa_sweep EXIT
|
|
57
|
+
fi
|
|
58
|
+
SA_TRAP_SET=1
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
# errexit is the caller's setting, not ours: a helper that turns it on for a
|
|
62
|
+
# script that ran without it changes how every later line of that script fails.
|
|
63
|
+
sa_begin() { case $- in *e*) SA_ERREXIT=1 ;; *) SA_ERREXIT="" ;; esac; set +e; }
|
|
64
|
+
sa_end() { [ -n "${SA_ERREXIT:-}" ] && set -e; return 0; }
|
|
65
|
+
|
|
66
|
+
# The resolver beside this file, or the installed one.
|
|
67
|
+
sa_locate() {
|
|
68
|
+
local here
|
|
69
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
70
|
+
if [ -x "$here/service-account.sh" ]; then
|
|
71
|
+
printf '%s' "$here/service-account.sh"
|
|
72
|
+
return 0
|
|
73
|
+
fi
|
|
74
|
+
if [ -x "$HOME/.claude/lib/service-account.sh" ]; then
|
|
75
|
+
printf '%s' "$HOME/.claude/lib/service-account.sh"
|
|
76
|
+
return 0
|
|
77
|
+
fi
|
|
78
|
+
return 1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Run the resolver, keeping its refusal for sa_reason and passing its status on.
|
|
82
|
+
sa_run() {
|
|
83
|
+
local script status out err
|
|
84
|
+
script="$(sa_locate)" || {
|
|
85
|
+
printf '%s' '{"ok":false,"reason":"store-unavailable","message":"The account resolver is not installed.","remedy":"Run the installer, then /multi-agent:doctor."}' >"$SA_ERROR_FILE"
|
|
86
|
+
return 2
|
|
87
|
+
}
|
|
88
|
+
err="$(mktemp "$SA_TMPDIR/err.XXXXXX")"
|
|
89
|
+
sa_begin
|
|
90
|
+
out="$(bash "$script" "$@" 2>"$err")"
|
|
91
|
+
status=$?
|
|
92
|
+
sa_end
|
|
93
|
+
cat "$err" >"$SA_ERROR_FILE"
|
|
94
|
+
rm -f "$err"
|
|
95
|
+
[ "$status" -eq 0 ] && printf '%s' "$out"
|
|
96
|
+
return "$status"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# The refusal the last call produced, as the one JSON line every caller reads.
|
|
100
|
+
sa_reason() { cat "$SA_ERROR_FILE" 2>/dev/null; printf '\n'; }
|
|
101
|
+
|
|
102
|
+
# The machine-readable reason of the last refusal, for a fetcher that maps the
|
|
103
|
+
# resolver's vocabulary onto an exit contract its own callers already read.
|
|
104
|
+
sa_code() {
|
|
105
|
+
# shellcheck disable=SC2016 # the JSON reader is node source, not shell
|
|
106
|
+
node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{process.stdout.write(JSON.parse(s).reason||"")}catch{process.stdout.write("")}})' <"$SA_ERROR_FILE" 2>/dev/null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# One field of the last refusal, for a fetcher whose own contract turns on
|
|
110
|
+
# something the resolver knows and it does not.
|
|
111
|
+
sa_field() {
|
|
112
|
+
# shellcheck disable=SC2016 # the JSON reader is node source, not shell
|
|
113
|
+
FIELD="$1" node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const v=JSON.parse(s)[process.env.FIELD];process.stdout.write(v===undefined||v===null?"":String(v))}catch{process.stdout.write("")}})' <"$SA_ERROR_FILE" 2>/dev/null
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# A human-readable line for a refusal, for a fetcher that reports rather than exits.
|
|
117
|
+
sa_explain() {
|
|
118
|
+
# shellcheck disable=SC2016 # the JSON reader is node source, not shell
|
|
119
|
+
node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const j=JSON.parse(s);process.stdout.write(`${j.message||"refused"} ${j.remedy||""}`.trim()+"\n");}catch{process.stdout.write("the account resolver refused this request\n");}})' <"$SA_ERROR_FILE" 2>/dev/null ||
|
|
120
|
+
printf 'the account resolver refused this request\n'
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# The host the chosen account is for, so a caller can build its own URL.
|
|
124
|
+
#
|
|
125
|
+
# The reader runs on the answer rather than in the pipeline, so a refusal keeps
|
|
126
|
+
# its own exit status instead of being replaced by the reader's parse error.
|
|
127
|
+
sa_host() {
|
|
128
|
+
local service="$1" out status
|
|
129
|
+
shift
|
|
130
|
+
sa_begin
|
|
131
|
+
out="$(sa_run select --service "$service" "$@")"
|
|
132
|
+
status=$?
|
|
133
|
+
sa_end
|
|
134
|
+
[ "$status" -eq 0 ] || return "$status"
|
|
135
|
+
# shellcheck disable=SC2016 # the JSON reader is node source, not shell
|
|
136
|
+
printf '%s' "$out" |
|
|
137
|
+
node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const a=JSON.parse(s);process.stdout.write((a.account.hosts||[])[0]||"");})' 2>/dev/null
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# The scheme-and-host the chosen account is for, as a URL to build paths on.
|
|
141
|
+
#
|
|
142
|
+
# Separate from sa_host because a host is a name and an account may be reached
|
|
143
|
+
# on a port: `hosts` carries the name alone, and a caller that writes
|
|
144
|
+
# `https://$(sa_host ...)` loses the port with no sign that it did.
|
|
145
|
+
sa_base() {
|
|
146
|
+
local service="$1" out status
|
|
147
|
+
shift
|
|
148
|
+
sa_begin
|
|
149
|
+
out="$(sa_run select --service "$service" "$@")"
|
|
150
|
+
status=$?
|
|
151
|
+
sa_end
|
|
152
|
+
[ "$status" -eq 0 ] || return "$status"
|
|
153
|
+
# shellcheck disable=SC2016 # the JSON reader is node source, not shell
|
|
154
|
+
printf '%s' "$out" |
|
|
155
|
+
node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const a=JSON.parse(s).account;const h=(a.hosts||[])[0]||"";process.stdout.write(a.baseUrl||(h?`https://${h}`:""));})' 2>/dev/null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
# A curl config carrying the credential to this URL, as a file only curl reads.
|
|
159
|
+
#
|
|
160
|
+
# Prints the path. The file lives in a directory removed when the sourcing
|
|
161
|
+
# shell exits, so a caller that dies between writing and using it leaves no
|
|
162
|
+
# credential behind.
|
|
163
|
+
sa_cfg() {
|
|
164
|
+
local service="$1" url="$2" scheme="${3:-bearer}"
|
|
165
|
+
shift 3 2>/dev/null || shift $#
|
|
166
|
+
local file status
|
|
167
|
+
file="$(mktemp "$SA_TMPDIR/cfg.XXXXXX")" || return 2
|
|
168
|
+
chmod 600 "$file"
|
|
169
|
+
sa_begin
|
|
170
|
+
# The newline is added here because command substitution inside sa_run strips
|
|
171
|
+
# the one the config ends with. curl reads a last line without it, but a file
|
|
172
|
+
# whose shape depends on how it was captured is one nobody can reason about.
|
|
173
|
+
{ sa_run curl-config --service "$service" --url "$url" --scheme "$scheme" "$@" && printf '\n'; } >"$file"
|
|
174
|
+
status=$?
|
|
175
|
+
sa_end
|
|
176
|
+
if [ "$status" -ne 0 ]; then
|
|
177
|
+
rm -f "$file"
|
|
178
|
+
return "$status"
|
|
179
|
+
fi
|
|
180
|
+
printf '%s' "$file"
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# The raw secret, for the few callers that cannot use a curl config.
|
|
184
|
+
#
|
|
185
|
+
# Prefer sa_cfg. A value in a shell variable is one `set -x`, one error trace
|
|
186
|
+
# and one `ps` away from being somewhere nobody meant it to be.
|
|
187
|
+
sa_token() {
|
|
188
|
+
local service="$1" url="$2"
|
|
189
|
+
shift 2
|
|
190
|
+
sa_run token --service "$service" --url "$url" "$@"
|
|
191
|
+
}
|