@apralabs/apra-fleet 0.4.4 → 0.4.5
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 +49 -4
- package/dist/agents/backlog-groomer.md +5 -0
- package/dist/agents/ci-watcher.md +5 -0
- package/dist/agents/deployer.md +20 -2
- package/dist/agents/doer.md +38 -2
- package/dist/agents/harvester.md +12 -9
- package/dist/agents/integ-test-runner.md +5 -0
- package/dist/agents/kb-reconciler.md +6 -0
- package/dist/agents/plan-reviewer.md +5 -0
- package/dist/agents/planner.md +5 -0
- package/dist/agents/regression-test-runner.md +5 -0
- package/dist/agents/reviewer.md +67 -15
- package/dist/agents/schemas/deployer-output.json +5 -0
- package/dist/agents/schemas/doer-output.json +78 -2
- package/dist/agents/schemas/reviewer-output.json +104 -2
- package/dist/cli/auth.js +5 -1
- package/dist/cli/beads-pin.js +6 -7
- package/dist/cli/claude-mod.d.ts +75 -0
- package/dist/cli/claude-mod.js +288 -0
- package/dist/cli/dolt-install.d.ts +1 -1
- package/dist/cli/dolt-install.js +5 -1
- package/dist/cli/fleet-se-guard.d.ts +8 -0
- package/dist/cli/fleet-se-guard.js +19 -3
- package/dist/cli/install-guard.d.ts +9 -0
- package/dist/cli/install-guard.js +24 -0
- package/dist/cli/install.d.ts +12 -0
- package/dist/cli/install.js +180 -20
- package/dist/cli/kb-profile.d.ts +16 -0
- package/dist/cli/kb-profile.js +81 -0
- package/dist/cli/start.js +3 -0
- package/dist/cli/uninstall.js +13 -3
- package/dist/cli/update.d.ts +4 -0
- package/dist/cli/update.js +19 -3
- package/dist/commands/kb-server.d.ts +10 -1
- package/dist/commands/kb-server.js +285 -11
- package/dist/index.js +22 -1
- package/dist/os/git-executable.d.ts +57 -0
- package/dist/os/git-executable.js +85 -0
- package/dist/os/go-concurrency.d.ts +44 -0
- package/dist/os/go-concurrency.js +53 -0
- package/dist/os/index.d.ts +1 -0
- package/dist/os/index.js +1 -0
- package/dist/os/linux.d.ts +2 -0
- package/dist/os/linux.js +10 -1
- package/dist/os/os-commands.d.ts +25 -0
- package/dist/os/os-commands.js +2 -0
- package/dist/os/windows-executable.d.ts +53 -0
- package/dist/os/windows-executable.js +185 -0
- package/dist/os/windows-gitbash.d.ts +23 -14
- package/dist/os/windows-gitbash.js +40 -16
- package/dist/os/windows.d.ts +2 -0
- package/dist/os/windows.js +37 -6
- package/dist/paths.d.ts +10 -1
- package/dist/paths.js +19 -2
- package/dist/services/agy-project.d.ts +7 -1
- package/dist/services/agy-project.js +7 -2
- package/dist/services/auth-socket.d.ts +18 -0
- package/dist/services/auth-socket.js +30 -4
- package/dist/services/credential-store.d.ts +33 -0
- package/dist/services/credential-store.js +79 -2
- package/dist/services/http-transport.d.ts +29 -0
- package/dist/services/http-transport.js +166 -37
- package/dist/services/kb-tool-profile.d.ts +36 -0
- package/dist/services/kb-tool-profile.js +88 -0
- package/dist/services/knowledge/bible-blob-id.js +10 -1
- package/dist/services/knowledge/bible-import.d.ts +108 -0
- package/dist/services/knowledge/bible-import.js +137 -4
- package/dist/services/knowledge/file-hash.js +6 -5
- package/dist/services/knowledge/http-provider.d.ts +303 -20
- package/dist/services/knowledge/http-provider.js +795 -125
- package/dist/services/knowledge/kb-config.d.ts +65 -1
- package/dist/services/knowledge/kb-config.js +143 -3
- package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
- package/dist/services/knowledge/kb-http-auth-state.js +40 -0
- package/dist/services/knowledge/kb-providers.d.ts +9 -2
- package/dist/services/knowledge/kb-providers.js +67 -37
- package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
- package/dist/services/knowledge/kb-self.d.ts +122 -9
- package/dist/services/knowledge/kb-self.js +196 -36
- package/dist/services/knowledge/member-bible-view.js +16 -3
- package/dist/services/knowledge/path-validation.d.ts +7 -0
- package/dist/services/knowledge/path-validation.js +11 -0
- package/dist/services/knowledge/project-slug.js +3 -2
- package/dist/services/knowledge/repository-header.d.ts +77 -0
- package/dist/services/knowledge/repository-header.js +233 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
- package/dist/services/knowledge/require-sqlite-project.js +1 -1
- package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
- package/dist/services/knowledge/sqlite-provider.js +416 -4
- package/dist/services/knowledge/types.d.ts +15 -2
- package/dist/services/member-busy.d.ts +12 -0
- package/dist/services/member-busy.js +20 -0
- package/dist/services/member-config-io.d.ts +3 -2
- package/dist/services/member-config-io.js +7 -4
- package/dist/services/member-fleet-install.js +1 -0
- package/dist/services/member-tool-allowlist.d.ts +1 -1
- package/dist/services/member-tool-allowlist.js +8 -4
- package/dist/services/port-holder.js +2 -1
- package/dist/services/service-manager/types.d.ts +17 -1
- package/dist/services/service-manager/windows.d.ts +7 -2
- package/dist/services/service-manager/windows.js +28 -11
- package/dist/services/service-notice.d.ts +7 -0
- package/dist/services/service-notice.js +19 -0
- package/dist/services/session-registry.d.ts +13 -0
- package/dist/services/session-registry.js +13 -0
- package/dist/services/session-roots.d.ts +67 -0
- package/dist/services/session-roots.js +126 -0
- package/dist/services/statusline.d.ts +21 -0
- package/dist/services/statusline.js +97 -1
- package/dist/services/supervisor-service-cleanup.js +2 -1
- package/dist/services/tool-registry.js +108 -20
- package/dist/services/tool-scope.d.ts +34 -1
- package/dist/services/tool-scope.js +27 -2
- package/dist/services/vcs/azure-devops.js +10 -0
- package/dist/services/vcs/bitbucket.d.ts +22 -1
- package/dist/services/vcs/bitbucket.js +163 -17
- package/dist/services/vcs/types.d.ts +25 -2
- package/dist/services/watch/project-resolver.js +2 -1
- package/dist/skills/pm/cost.md +5 -1
- package/dist/skills/pm/index.md +9 -9
- package/dist/skills/pm/sprint.md +2 -1
- package/dist/tools/check-status.d.ts +51 -0
- package/dist/tools/check-status.js +124 -12
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
- package/dist/tools/code-intelligence-gitnexus.js +166 -9
- package/dist/tools/code-intelligence-readiness.d.ts +58 -1
- package/dist/tools/code-intelligence-readiness.js +93 -8
- package/dist/tools/code-intelligence-reindex.d.ts +25 -1
- package/dist/tools/code-intelligence-reindex.js +76 -4
- package/dist/tools/code-intelligence.d.ts +1 -1
- package/dist/tools/code-intelligence.js +1 -1
- package/dist/tools/execute-command.js +14 -8
- package/dist/tools/execute-prompt.js +6 -2
- package/dist/tools/fleet-snapshot.d.ts +21 -0
- package/dist/tools/fleet-snapshot.js +78 -0
- package/dist/tools/kb-bible-commit.d.ts +25 -11
- package/dist/tools/kb-bible-commit.js +142 -33
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-context.js +47 -27
- package/dist/tools/kb-demote.d.ts +27 -0
- package/dist/tools/kb-demote.js +37 -0
- package/dist/tools/kb-export.d.ts +35 -3
- package/dist/tools/kb-export.js +56 -13
- package/dist/tools/kb-feedback.d.ts +2 -0
- package/dist/tools/kb-feedback.js +17 -7
- package/dist/tools/kb-harvest.js +28 -9
- package/dist/tools/kb-import.d.ts +18 -2
- package/dist/tools/kb-import.js +24 -9
- package/dist/tools/kb-invalidate.d.ts +11 -3
- package/dist/tools/kb-invalidate.js +80 -7
- package/dist/tools/kb-list.js +38 -10
- package/dist/tools/kb-promote.js +6 -4
- package/dist/tools/kb-query.d.ts +3 -0
- package/dist/tools/kb-query.js +181 -37
- package/dist/tools/kb-session-prime.d.ts +4 -4
- package/dist/tools/kb-session-prime.js +89 -9
- package/dist/tools/kb-setup.d.ts +20 -0
- package/dist/tools/kb-setup.js +149 -11
- package/dist/tools/list-members.js +1 -1
- package/dist/tools/member-detail.js +7 -3
- package/dist/tools/provision-vcs-auth.d.ts +28 -3
- package/dist/tools/provision-vcs-auth.js +53 -7
- package/dist/tools/receive-files.js +7 -4
- package/dist/tools/send-files.js +5 -4
- package/dist/tools/send-message.d.ts +3 -0
- package/dist/tools/send-message.js +15 -2
- package/dist/tools/stop-prompt.js +3 -1
- package/dist/tools/vcs-credential-exec.d.ts +45 -3
- package/dist/tools/vcs-credential-exec.js +90 -11
- package/dist/utils/process-utils.js +5 -1
- package/dist/utils/redact-known-secrets.d.ts +17 -0
- package/dist/utils/redact-known-secrets.js +70 -0
- package/dist/utils/skill-matrix.js +1 -1
- package/dist/utils/vcs-provider-detect.js +2 -2
- package/dist/workflows/auto-sprint.js +245 -9
- package/package.json +10 -7
- package/packages/apra-fleet-client/package.json +1 -1
- package/packages/apra-fleet-client/src/client/api.mjs +172 -19
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
- package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
- package/packages/apra-fleet-se/bin/cli.mjs +104 -31
- package/packages/apra-fleet-se/bin/serve.mjs +46 -8
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
- package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
- package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
- package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
- package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
- package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
- package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
- package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
- package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
- package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
- package/packages/apra-fleet-workflow/package.json +2 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
- package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
- package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
- package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
- package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
- package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
- package/skills/fleet/auth-bitbucket.md +47 -20
- package/skills/fleet/onboarding.md +1 -1
- package/skills/fleet/skill-matrix.md +3 -3
- package/version.json +1 -1
|
@@ -28,6 +28,15 @@ import { z } from 'zod';
|
|
|
28
28
|
* 4. redacts any occurrence of the token from stdout/stderr before
|
|
29
29
|
* returning, the same defence execute-command.ts's redactOutput applies.
|
|
30
30
|
*
|
|
31
|
+
* The same helper stdout also carries a `username=` line (the basic-auth
|
|
32
|
+
* user provision_vcs_auth wrote -- for Bitbucket, the fixed token username
|
|
33
|
+
* x-bitbucket-api-token-auth, never an email),
|
|
34
|
+
* so `{{vcs_username}}` / `{{vcs_username_inline}}` get the identical
|
|
35
|
+
* two-dialect treatment for a command that needs the helper's git username
|
|
36
|
+
* (apra-fleet-qeq1.1; Bitbucket REST itself now takes a Bearer token). The username is
|
|
37
|
+
* one half of a credential pair, so it is redacted on the same footing as
|
|
38
|
+
* the token -- under its own marker so a reader can tell the two apart.
|
|
39
|
+
*
|
|
31
40
|
* The plaintext token therefore appears in no field of any result an
|
|
32
41
|
* orchestrator-side caller can read. readMemberVcsCredentialToken is
|
|
33
42
|
* deliberately left in place; retiring it is a separate task.
|
|
@@ -56,6 +65,30 @@ export declare const VCS_TOKEN_PLACEHOLDER = "{{vcs_token}}";
|
|
|
56
65
|
* refusals. The contract is documented, not enforced (apra-fleet-3swo.7.16).
|
|
57
66
|
*/
|
|
58
67
|
export declare const VCS_TOKEN_INLINE_PLACEHOLDER = "{{vcs_token_inline}}";
|
|
68
|
+
/**
|
|
69
|
+
* The git USERNAME half of the same credential (the helper's username=
|
|
70
|
+
* line). Reference this one BARE, exactly like
|
|
71
|
+
* {{vcs_token}}: the substituted value arrives already shell-escaped AND
|
|
72
|
+
* quoted for the member's shell.
|
|
73
|
+
*
|
|
74
|
+
* The value is read from the `username=` line of the SAME credential-helper
|
|
75
|
+
* stdout the token comes from -- provision_vcs_auth wrote it there (see
|
|
76
|
+
* src/services/vcs/bitbucket.ts, which always writes the fixed token
|
|
77
|
+
* username x-bitbucket-api-token-auth; Bitbucket REST itself is called with
|
|
78
|
+
* a Bearer token, so this placeholder is not needed for it). No
|
|
79
|
+
* extra member round trip is involved.
|
|
80
|
+
*/
|
|
81
|
+
export declare const VCS_USERNAME_PLACEHOLDER = "{{vcs_username}}";
|
|
82
|
+
/**
|
|
83
|
+
* The inside-your-own-single-quotes form of {{vcs_username}}, the exact
|
|
84
|
+
* counterpart of {{vcs_token_inline}} (e.g.
|
|
85
|
+
* `-u '{{vcs_username_inline}}:{{vcs_token_inline}}'`): escaped for the
|
|
86
|
+
* INTERIOR of a single-quoted string in the member's shell dialect, with no
|
|
87
|
+
* quotes of its own. As with the token pair, placement is documented rather
|
|
88
|
+
* than enforced -- whether an occurrence really sits inside the caller's
|
|
89
|
+
* open quotes is not decidable from the command string alone.
|
|
90
|
+
*/
|
|
91
|
+
export declare const VCS_USERNAME_INLINE_PLACEHOLDER = "{{vcs_username_inline}}";
|
|
59
92
|
export declare const vcsCredentialExecSchema: z.ZodObject<{
|
|
60
93
|
command: z.ZodString;
|
|
61
94
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -89,6 +122,13 @@ export type VcsCredentialExecReason =
|
|
|
89
122
|
| 'credential_read_failed'
|
|
90
123
|
/** The helper ran but printed no usable password= line. */
|
|
91
124
|
| 'credential_empty'
|
|
125
|
+
/**
|
|
126
|
+
* `command` referenced {{vcs_username}}/{{vcs_username_inline}} but the
|
|
127
|
+
* helper printed no usable username= line. Only reachable for a command
|
|
128
|
+
* that actually asks for the username -- a token-only command never
|
|
129
|
+
* consults it.
|
|
130
|
+
*/
|
|
131
|
+
| 'username_empty'
|
|
92
132
|
/** Dispatching the credential-requiring command threw. */
|
|
93
133
|
| 'dispatch_failed';
|
|
94
134
|
interface VcsCredentialExecFields {
|
|
@@ -103,9 +143,11 @@ interface VcsCredentialExecFields {
|
|
|
103
143
|
/** Command stderr with every occurrence of the credential redacted. */
|
|
104
144
|
stderr: string;
|
|
105
145
|
/**
|
|
106
|
-
* How many times
|
|
107
|
-
*
|
|
108
|
-
*
|
|
146
|
+
* How many times credential material had to be redacted out of
|
|
147
|
+
* stdout+stderr -- the token, plus the git username when the
|
|
148
|
+
* command substituted one. Normally 0; a nonzero count means the
|
|
149
|
+
* dispatched command echoed its own credential back and the redaction
|
|
150
|
+
* earned its keep.
|
|
109
151
|
*/
|
|
110
152
|
tokenRedactions: number;
|
|
111
153
|
/** Credential label used, or null for the unlabelled helper. */
|
|
@@ -34,6 +34,15 @@ import { logLine } from '../utils/log-helpers.js';
|
|
|
34
34
|
* 4. redacts any occurrence of the token from stdout/stderr before
|
|
35
35
|
* returning, the same defence execute-command.ts's redactOutput applies.
|
|
36
36
|
*
|
|
37
|
+
* The same helper stdout also carries a `username=` line (the basic-auth
|
|
38
|
+
* user provision_vcs_auth wrote -- for Bitbucket, the fixed token username
|
|
39
|
+
* x-bitbucket-api-token-auth, never an email),
|
|
40
|
+
* so `{{vcs_username}}` / `{{vcs_username_inline}}` get the identical
|
|
41
|
+
* two-dialect treatment for a command that needs the helper's git username
|
|
42
|
+
* (apra-fleet-qeq1.1; Bitbucket REST itself now takes a Bearer token). The username is
|
|
43
|
+
* one half of a credential pair, so it is redacted on the same footing as
|
|
44
|
+
* the token -- under its own marker so a reader can tell the two apart.
|
|
45
|
+
*
|
|
37
46
|
* The plaintext token therefore appears in no field of any result an
|
|
38
47
|
* orchestrator-side caller can read. readMemberVcsCredentialToken is
|
|
39
48
|
* deliberately left in place; retiring it is a separate task.
|
|
@@ -62,6 +71,30 @@ export const VCS_TOKEN_PLACEHOLDER = '{{vcs_token}}';
|
|
|
62
71
|
* refusals. The contract is documented, not enforced (apra-fleet-3swo.7.16).
|
|
63
72
|
*/
|
|
64
73
|
export const VCS_TOKEN_INLINE_PLACEHOLDER = '{{vcs_token_inline}}';
|
|
74
|
+
/**
|
|
75
|
+
* The git USERNAME half of the same credential (the helper's username=
|
|
76
|
+
* line). Reference this one BARE, exactly like
|
|
77
|
+
* {{vcs_token}}: the substituted value arrives already shell-escaped AND
|
|
78
|
+
* quoted for the member's shell.
|
|
79
|
+
*
|
|
80
|
+
* The value is read from the `username=` line of the SAME credential-helper
|
|
81
|
+
* stdout the token comes from -- provision_vcs_auth wrote it there (see
|
|
82
|
+
* src/services/vcs/bitbucket.ts, which always writes the fixed token
|
|
83
|
+
* username x-bitbucket-api-token-auth; Bitbucket REST itself is called with
|
|
84
|
+
* a Bearer token, so this placeholder is not needed for it). No
|
|
85
|
+
* extra member round trip is involved.
|
|
86
|
+
*/
|
|
87
|
+
export const VCS_USERNAME_PLACEHOLDER = '{{vcs_username}}';
|
|
88
|
+
/**
|
|
89
|
+
* The inside-your-own-single-quotes form of {{vcs_username}}, the exact
|
|
90
|
+
* counterpart of {{vcs_token_inline}} (e.g.
|
|
91
|
+
* `-u '{{vcs_username_inline}}:{{vcs_token_inline}}'`): escaped for the
|
|
92
|
+
* INTERIOR of a single-quoted string in the member's shell dialect, with no
|
|
93
|
+
* quotes of its own. As with the token pair, placement is documented rather
|
|
94
|
+
* than enforced -- whether an occurrence really sits inside the caller's
|
|
95
|
+
* open quotes is not decidable from the command string alone.
|
|
96
|
+
*/
|
|
97
|
+
export const VCS_USERNAME_INLINE_PLACEHOLDER = '{{vcs_username_inline}}';
|
|
65
98
|
export const vcsCredentialExecSchema = z.object({
|
|
66
99
|
...memberIdentifier,
|
|
67
100
|
command: z.string().min(1).describe('The credential-requiring command to run on the member. MUST contain at least one of two '
|
|
@@ -71,6 +104,12 @@ export const vcsCredentialExecSchema = z.object({
|
|
|
71
104
|
+ 'server substitutes it with the value escaped for the interior of a single-quoted string, with '
|
|
72
105
|
+ 'no quotes of its own (use this one when the token must be interpolated into a larger quoted '
|
|
73
106
|
+ 'value, e.g. an Authorization header). Both may appear in the same command. '
|
|
107
|
+
+ 'Bitbucket REST uses the token as a Bearer value (-H \'Authorization: Bearer '
|
|
108
|
+
+ '{{vcs_token_inline}}\'), with no username and no email. The optional username '
|
|
109
|
+
+ 'placeholders {{vcs_username}} (bare) and {{vcs_username_inline}} (inside your own single '
|
|
110
|
+
+ 'quotes) substitute the credential helper\'s git username under the same two dialects (for '
|
|
111
|
+
+ 'Bitbucket always x-bitbucket-api-token-auth, a git-only username, never a REST login); they '
|
|
112
|
+
+ 'may not appear alone -- a token placeholder is still required. '
|
|
74
113
|
+ 'The plaintext credential never leaves the server and never appears in this tool\'s result.'),
|
|
75
114
|
label: z.string().regex(/^[a-zA-Z0-9._-]{1,64}$/).optional().describe('Credential label the helper was deployed under by provision_vcs_auth (defaults to the '
|
|
76
115
|
+ 'provider name there, e.g. "github" or "azure-devops"). Omit to use the unlabelled helper.'),
|
|
@@ -78,7 +117,12 @@ export const vcsCredentialExecSchema = z.object({
|
|
|
78
117
|
+ 'On expiry the command\'s remote process tree is killed and the result is reason dispatch_failed '
|
|
79
118
|
+ 'with a "Command timed out" message.'),
|
|
80
119
|
});
|
|
81
|
-
const
|
|
120
|
+
const TOKEN_REDACTION = '[REDACTED:vcs_token]';
|
|
121
|
+
/**
|
|
122
|
+
* Distinct from TOKEN_REDACTION on purpose: a reader of a redacted stream
|
|
123
|
+
* needs to know WHICH half of the basic-auth pair was scrubbed out of it.
|
|
124
|
+
*/
|
|
125
|
+
const USERNAME_REDACTION = '[REDACTED:vcs_username]';
|
|
82
126
|
function execResult(text, fields) {
|
|
83
127
|
return {
|
|
84
128
|
text,
|
|
@@ -96,11 +140,11 @@ function execResult(text, fields) {
|
|
|
96
140
|
};
|
|
97
141
|
}
|
|
98
142
|
/** Replace every occurrence of `secret` in `output`, and report how many. */
|
|
99
|
-
function
|
|
143
|
+
function redactSecret(output, secret, marker) {
|
|
100
144
|
if (!secret)
|
|
101
145
|
return { text: output, count: 0 };
|
|
102
146
|
const parts = output.split(secret);
|
|
103
|
-
return { text: parts.join(
|
|
147
|
+
return { text: parts.join(marker), count: parts.length - 1 };
|
|
104
148
|
}
|
|
105
149
|
export async function vcsCredentialExec(input) {
|
|
106
150
|
const agentOrError = resolveMember(input.member_id, input.member_name);
|
|
@@ -117,6 +161,9 @@ export async function vcsCredentialExec(input) {
|
|
|
117
161
|
// credential handoff rather than a second, unguarded execute_command.
|
|
118
162
|
const hasBare = input.command.includes(VCS_TOKEN_PLACEHOLDER);
|
|
119
163
|
const hasInline = input.command.includes(VCS_TOKEN_INLINE_PLACEHOLDER);
|
|
164
|
+
// A token placeholder stays mandatory even for a basic-auth command: the
|
|
165
|
+
// username alone is not a credential, so a username-only command is still
|
|
166
|
+
// an unguarded execute_command and is still refused here.
|
|
120
167
|
if (!hasBare && !hasInline) {
|
|
121
168
|
return execResult(`[FAIL] command must contain ${VCS_TOKEN_PLACEHOLDER} or ${VCS_TOKEN_INLINE_PLACEHOLDER} -- use execute_command for a command that needs no credential.`, { ...who, reason: 'placeholder_missing' });
|
|
122
169
|
}
|
|
@@ -134,9 +181,16 @@ export async function vcsCredentialExec(input) {
|
|
|
134
181
|
catch (err) {
|
|
135
182
|
return execResult(`[FAIL] Cannot read a VCS credential on "${agent.friendlyName}" (os=${agentOs} shell=${agentShell ?? 'default'}): ${err.message}`, { ...who, reason: 'unsupported_member_os' });
|
|
136
183
|
}
|
|
184
|
+
// Only a command that actually references a username placeholder consults
|
|
185
|
+
// the username= line, so every existing token-only call site (GitHub,
|
|
186
|
+
// Azure DevOps) keeps its exact previous behaviour and cannot reach the
|
|
187
|
+
// username_empty failure.
|
|
188
|
+
const needsUsername = input.command.includes(VCS_USERNAME_PLACEHOLDER)
|
|
189
|
+
|| input.command.includes(VCS_USERNAME_INLINE_PLACEHOLDER);
|
|
137
190
|
// STEP 1 -- read the credential SERVER-SIDE. This result is consumed
|
|
138
191
|
// in-process and is never placed in the payload returned below.
|
|
139
192
|
let token = '';
|
|
193
|
+
let username = '';
|
|
140
194
|
try {
|
|
141
195
|
const readRes = await strategy.execCommand(read.command, 15000);
|
|
142
196
|
if (readRes.code !== 0) {
|
|
@@ -144,6 +198,8 @@ export async function vcsCredentialExec(input) {
|
|
|
144
198
|
}
|
|
145
199
|
const m = /^password=(.*)$/m.exec(readRes.stdout || '');
|
|
146
200
|
token = m ? m[1].trim() : '';
|
|
201
|
+
const u = /^username=(.*)$/m.exec(readRes.stdout || '');
|
|
202
|
+
username = u ? u[1].trim() : '';
|
|
147
203
|
}
|
|
148
204
|
catch (err) {
|
|
149
205
|
return execResult(`[FAIL] Failed to read the VCS credential for "${agent.friendlyName}" from '${read.path}': ${err.message}`, { ...who, reason: 'credential_read_failed' });
|
|
@@ -151,19 +207,42 @@ export async function vcsCredentialExec(input) {
|
|
|
151
207
|
if (!token) {
|
|
152
208
|
return execResult(`[FAIL] The VCS credential for "${agent.friendlyName}" was empty or unreadable (expected a 'password=' line from '${read.path}'). Re-run provision_vcs_auth.`, { ...who, reason: 'credential_empty' });
|
|
153
209
|
}
|
|
210
|
+
// Substituting an empty username would silently dispatch ':<token>' and
|
|
211
|
+
// surface much later as a confusing 401, so this is a typed refusal that
|
|
212
|
+
// never dispatches anything.
|
|
213
|
+
if (needsUsername && !username) {
|
|
214
|
+
return execResult(`[FAIL] The VCS credential for "${agent.friendlyName}" carries no git username (expected a 'username=' line from '${read.path}'), but the command references ${VCS_USERNAME_PLACEHOLDER}. Re-run provision_vcs_auth for a provider that records one.`, { ...who, reason: 'username_empty' });
|
|
215
|
+
}
|
|
154
216
|
// STEP 2 -- substitute, escaped for the member's OWN shell. A Windows
|
|
155
217
|
// member registered with shell=gitbash runs bash, so it needs POSIX
|
|
156
218
|
// escaping even though its OS is windows; isPosixShell owns that decision
|
|
157
219
|
// for every consumer. The bare placeholder gets the fully-quoted form; the
|
|
158
220
|
// inline placeholder gets the SAME dialect's interior-only escaping, with
|
|
159
221
|
// no wrapping quotes of its own, so it composes inside the caller's
|
|
160
|
-
// already-open single quotes instead of double-escaping.
|
|
222
|
+
// already-open single quotes instead of double-escaping. The username pair
|
|
223
|
+
// reuses the SAME two escapers under the SAME isPosixShell branch rather
|
|
224
|
+
// than adding a second dialect decision.
|
|
161
225
|
const posix = isPosixShell(agentOs, agentShell);
|
|
162
|
-
const
|
|
163
|
-
const
|
|
226
|
+
const quote = (v) => (posix ? escapeShellArg(v) : escapePowerShellArg(v));
|
|
227
|
+
const inner = (v) => (posix ? escapeShellArgInner(v) : escapePowerShellArgInner(v));
|
|
164
228
|
const finalCommand = input.command
|
|
165
|
-
.replaceAll(VCS_TOKEN_PLACEHOLDER,
|
|
166
|
-
.replaceAll(VCS_TOKEN_INLINE_PLACEHOLDER,
|
|
229
|
+
.replaceAll(VCS_TOKEN_PLACEHOLDER, quote(token))
|
|
230
|
+
.replaceAll(VCS_TOKEN_INLINE_PLACEHOLDER, inner(token))
|
|
231
|
+
.replaceAll(VCS_USERNAME_PLACEHOLDER, quote(username))
|
|
232
|
+
.replaceAll(VCS_USERNAME_INLINE_PLACEHOLDER, inner(username));
|
|
233
|
+
/**
|
|
234
|
+
* Scrub both halves of the credential. The username is only scrubbed when
|
|
235
|
+
* this command actually substituted one -- a token-only command must not
|
|
236
|
+
* start redacting an unrelated string (a GitHub helper's username is the
|
|
237
|
+
* very common literal 'x-access-token') out of its own output.
|
|
238
|
+
*/
|
|
239
|
+
const redactCredentials = (output) => {
|
|
240
|
+
const t = redactSecret(output, token, TOKEN_REDACTION);
|
|
241
|
+
if (!needsUsername)
|
|
242
|
+
return t;
|
|
243
|
+
const u = redactSecret(t.text, username, USERNAME_REDACTION);
|
|
244
|
+
return { text: u.text, count: t.count + u.count };
|
|
245
|
+
};
|
|
167
246
|
// STEP 3 -- dispatch. Only the log-safe form (placeholder still in place) is
|
|
168
247
|
// ever logged; `finalCommand` is never written anywhere.
|
|
169
248
|
logLine('vcs_credential_exec', `label=${input.label ?? '(default)'} command=${input.command.slice(0, 120)}`, agent);
|
|
@@ -183,14 +262,14 @@ export async function vcsCredentialExec(input) {
|
|
|
183
262
|
catch (err) {
|
|
184
263
|
// The thrown message can quote the command that failed, so it is redacted
|
|
185
264
|
// on the same footing as stdout/stderr.
|
|
186
|
-
const redactedErr =
|
|
265
|
+
const redactedErr = redactCredentials(String(err?.message ?? err));
|
|
187
266
|
return execResult(`[FAIL] Command dispatch failed on "${agent.friendlyName}": ${redactedErr.text}`, { ...who, reason: 'dispatch_failed', stderr: redactedErr.text, tokenRedactions: redactedErr.count });
|
|
188
267
|
}
|
|
189
268
|
// STEP 4 -- defence in depth: the command itself may echo the credential
|
|
190
269
|
// back (a curl -v, a git error quoting the remote URL), so scrub both
|
|
191
270
|
// streams before anything is returned.
|
|
192
|
-
const outRedacted =
|
|
193
|
-
const errRedacted =
|
|
271
|
+
const outRedacted = redactCredentials(stdout);
|
|
272
|
+
const errRedacted = redactCredentials(stderr);
|
|
194
273
|
return execResult(`[OK] Ran credential-requiring command on "${agent.friendlyName}" (exit ${code}).`, {
|
|
195
274
|
...who,
|
|
196
275
|
reason: 'ok',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { windowsExecutable } from '../os/windows-executable.js';
|
|
3
4
|
export function isPidAlive(pid) {
|
|
4
5
|
try {
|
|
5
6
|
process.kill(pid, 0);
|
|
@@ -19,9 +20,12 @@ export function processCommandLine(pid) {
|
|
|
19
20
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
20
21
|
return null;
|
|
21
22
|
const opts = { encoding: 'utf8', stdio: 'pipe', windowsHide: true, timeout: 10_000 };
|
|
23
|
+
// powershell.exe is resolved to an absolute path (never the cwd). A missing
|
|
24
|
+
// PowerShell lands in the catch like any other unreadable command line:
|
|
25
|
+
// callers (isApraFleetProcess) then fall back to the tasklist image name.
|
|
22
26
|
try {
|
|
23
27
|
const out = process.platform === 'win32'
|
|
24
|
-
? execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
|
|
28
|
+
? execFileSync(windowsExecutable('powershell.exe'), ['-NoProfile', '-NonInteractive', '-Command',
|
|
25
29
|
`(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").CommandLine`], opts)
|
|
26
30
|
: execFileSync('ps', ['-p', String(pid), '-o', 'command='], opts);
|
|
27
31
|
const trimmed = String(out).trim();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redact known credential values from free text before it is returned to a
|
|
3
|
+
* caller or logged.
|
|
4
|
+
*
|
|
5
|
+
* Replaces every occurrence of each secret value in its raw form, URL-encoded
|
|
6
|
+
* form, base64 of `user:secret` (for every username supplied), and every
|
|
7
|
+
* shell-escaped form the OS command builders (src/os/*) write it in, with
|
|
8
|
+
* ****. Those escaped forms are built with the SAME escapers the builders use
|
|
9
|
+
* (src/utils/shell-escape.ts), never re-implemented here, so a form actually
|
|
10
|
+
* sent to a member is always a form this module masks. Also redacts any `Authorization` header value (Bearer/Basic) and
|
|
11
|
+
* GitHub-shaped token literals (ghp_/ghs_/... and github_pat_...), which covers
|
|
12
|
+
* a token minted inside a provider's deploy that this module never sees.
|
|
13
|
+
*
|
|
14
|
+
* Out of scope: fragment-aware redaction of wrapped/truncated console output.
|
|
15
|
+
*/
|
|
16
|
+
export declare function redactKnownSecrets(text: string, secrets: Array<string | undefined | null>, usernames?: string[]): string;
|
|
17
|
+
//# sourceMappingURL=redact-known-secrets.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redact known credential values from free text before it is returned to a
|
|
3
|
+
* caller or logged.
|
|
4
|
+
*
|
|
5
|
+
* Replaces every occurrence of each secret value in its raw form, URL-encoded
|
|
6
|
+
* form, base64 of `user:secret` (for every username supplied), and every
|
|
7
|
+
* shell-escaped form the OS command builders (src/os/*) write it in, with
|
|
8
|
+
* ****. Those escaped forms are built with the SAME escapers the builders use
|
|
9
|
+
* (src/utils/shell-escape.ts), never re-implemented here, so a form actually
|
|
10
|
+
* sent to a member is always a form this module masks. Also redacts any `Authorization` header value (Bearer/Basic) and
|
|
11
|
+
* GitHub-shaped token literals (ghp_/ghs_/... and github_pat_...), which covers
|
|
12
|
+
* a token minted inside a provider's deploy that this module never sees.
|
|
13
|
+
*
|
|
14
|
+
* Out of scope: fragment-aware redaction of wrapped/truncated console output.
|
|
15
|
+
*/
|
|
16
|
+
import { escapeBatchMetachars, escapeDoubleQuoted, escapeForDoubleQuotes, escapePowerShellArgInner, escapeShellArgInner, escapeWindowsArg, } from './shell-escape.js';
|
|
17
|
+
const MASK = '****';
|
|
18
|
+
/** Secrets shorter than this are not redacted by value (would mangle text). */
|
|
19
|
+
const MIN_SECRET_LENGTH = 4;
|
|
20
|
+
function escapeRegExp(s) {
|
|
21
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
22
|
+
}
|
|
23
|
+
function forms(secret, usernames) {
|
|
24
|
+
const out = new Set();
|
|
25
|
+
const add = (v) => { if (v && v.length >= MIN_SECRET_LENGTH)
|
|
26
|
+
out.add(v); };
|
|
27
|
+
add(secret);
|
|
28
|
+
add(encodeURIComponent(secret));
|
|
29
|
+
// POSIX single quotes (escapeShellArg: httpGetStatusWithBearer, git-bash helper).
|
|
30
|
+
add(escapeShellArgInner(secret));
|
|
31
|
+
// POSIX double quotes (linux/macos gitCredentialHelperWrite, ghAuthLogin).
|
|
32
|
+
add(escapeDoubleQuoted(secret));
|
|
33
|
+
add(escapeForDoubleQuotes(secret, false));
|
|
34
|
+
// PowerShell single quotes (windows httpGetStatusWithBearer) and double quotes.
|
|
35
|
+
add(escapePowerShellArgInner(secret));
|
|
36
|
+
add(escapeForDoubleQuotes(secret, true));
|
|
37
|
+
// .bat helper content (windows / git-bash gitCredentialHelperWrite) and its
|
|
38
|
+
// PowerShell / POSIX single-quoted carriers.
|
|
39
|
+
add(escapeBatchMetachars(secret));
|
|
40
|
+
add(escapePowerShellArgInner(escapeBatchMetachars(secret)));
|
|
41
|
+
add(escapeShellArgInner(escapeBatchMetachars(secret)));
|
|
42
|
+
// cmd.exe double quotes (windows ghAuthLogin) inside PowerShell single quotes.
|
|
43
|
+
add(escapeWindowsArg(secret));
|
|
44
|
+
add(escapePowerShellArgInner(escapeWindowsArg(secret)));
|
|
45
|
+
for (const u of usernames) {
|
|
46
|
+
add(Buffer.from(`${u}:${secret}`).toString('base64'));
|
|
47
|
+
add(Buffer.from(`:${secret}`).toString('base64'));
|
|
48
|
+
}
|
|
49
|
+
add(Buffer.from(`:${secret}`).toString('base64'));
|
|
50
|
+
add(Buffer.from(secret).toString('base64'));
|
|
51
|
+
return [...out];
|
|
52
|
+
}
|
|
53
|
+
export function redactKnownSecrets(text, secrets, usernames = []) {
|
|
54
|
+
let out = text;
|
|
55
|
+
const all = new Set();
|
|
56
|
+
for (const s of secrets) {
|
|
57
|
+
if (typeof s === 'string' && s.length >= MIN_SECRET_LENGTH)
|
|
58
|
+
for (const f of forms(s, usernames))
|
|
59
|
+
all.add(f);
|
|
60
|
+
}
|
|
61
|
+
// Longest first so a raw value never leaves a partial of a longer form.
|
|
62
|
+
for (const f of [...all].sort((a, b) => b.length - a.length)) {
|
|
63
|
+
out = out.replace(new RegExp(escapeRegExp(f), 'g'), MASK);
|
|
64
|
+
}
|
|
65
|
+
out = out.replace(/(\bAuthorization\s*[:=]\s*['"]?\s*)(Bearer|Basic|token)(\s+)[^\s'"]+/gi, `$1$2$3${MASK}`);
|
|
66
|
+
out = out.replace(/\b(Bearer|Basic)(\s+)[A-Za-z0-9._~+/=-]{8,}/g, `$1$2${MASK}`);
|
|
67
|
+
out = out.replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, MASK);
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=redact-known-secrets.js.map
|
|
@@ -21,7 +21,7 @@ export function getRequiredSkills(tags, vcs, project) {
|
|
|
21
21
|
// Bitbucket tag rules
|
|
22
22
|
if (vcsNorm === 'bitbucket') {
|
|
23
23
|
if (tagNorm === 'devops' || tagNorm === 'code-review') {
|
|
24
|
-
skills.add('bitbucket
|
|
24
|
+
skills.add('bitbucket');
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
// Azure DevOps tag rules (future skills -- added as placeholders)
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
*/
|
|
48
48
|
/** github.com and its ssh alias. Anchored -- see the header note on GHE. */
|
|
49
49
|
const GITHUB_HOST_RE = /^(?:www\.|ssh\.)?github\.com$/i;
|
|
50
|
-
/** bitbucket.org and its
|
|
51
|
-
const BITBUCKET_HOST_RE = /^(?:www\.|altssh\.)?bitbucket\.org$/i;
|
|
50
|
+
/** bitbucket.org and its SSH hosts (altssh, ssh). */
|
|
51
|
+
const BITBUCKET_HOST_RE = /^(?:www\.|altssh\.|ssh\.)?bitbucket\.org$/i;
|
|
52
52
|
/** dev.azure.com, its v3 ssh host, and the legacy <org>.visualstudio.com.
|
|
53
53
|
* Kept identical to azure-devops.mjs's HOST_RE. */
|
|
54
54
|
const AZURE_DEVOPS_HOST_RE = /^(?:dev\.azure\.com|ssh\.dev\.azure\.com|(?:[a-z0-9-]+\.)*visualstudio\.com)$/i;
|