@testsprite/testsprite-cli 0.15.0 → 0.17.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.
Files changed (207) hide show
  1. package/README.md +53 -141
  2. package/dist/commands/agent.d.ts +12 -4
  3. package/dist/commands/agent.js +55 -65
  4. package/dist/commands/auth.d.ts +6 -10
  5. package/dist/commands/auth.js +44 -56
  6. package/dist/commands/ci.d.ts +23 -100
  7. package/dist/commands/ci.js +297 -489
  8. package/dist/commands/completion.js +2 -1
  9. package/dist/commands/conversation.d.ts +27 -0
  10. package/dist/commands/conversation.js +702 -0
  11. package/dist/commands/doctor.d.ts +5 -1
  12. package/dist/commands/doctor.js +130 -34
  13. package/dist/commands/init.d.ts +4 -45
  14. package/dist/commands/init.js +116 -68
  15. package/dist/commands/project-env.d.ts +62 -2
  16. package/dist/commands/project-env.js +426 -53
  17. package/dist/commands/project-sign-in.d.ts +0 -48
  18. package/dist/commands/project-sign-in.js +1 -224
  19. package/dist/commands/project.d.ts +15 -186
  20. package/dist/commands/project.js +93 -921
  21. package/dist/commands/result.d.ts +10 -0
  22. package/dist/commands/result.js +215 -0
  23. package/dist/commands/schedule.d.ts +0 -29
  24. package/dist/commands/schedule.js +47 -97
  25. package/dist/commands/test.d.ts +315 -1824
  26. package/dist/commands/test.js +1962 -13733
  27. package/dist/commands/testlist.d.ts +128 -5
  28. package/dist/commands/testlist.js +269 -329
  29. package/dist/commands/tunnel.d.ts +2 -2
  30. package/dist/commands/tunnel.js +43 -41
  31. package/dist/commands/usage.d.ts +12 -45
  32. package/dist/commands/usage.js +51 -131
  33. package/dist/index.js +189 -108
  34. package/dist/lib/agent-detect.js +9 -5
  35. package/dist/lib/agent-targets.d.ts +21 -2
  36. package/dist/lib/agent-targets.js +88 -11
  37. package/dist/lib/args.d.ts +13 -0
  38. package/dist/lib/args.js +49 -0
  39. package/dist/lib/basic-auth.d.ts +3 -0
  40. package/dist/lib/basic-auth.js +15 -0
  41. package/dist/lib/billing-refusal.js +4 -3
  42. package/dist/lib/ci-linkage.d.ts +4 -82
  43. package/dist/lib/ci-linkage.js +4 -157
  44. package/dist/lib/ci-run.js +1 -1
  45. package/dist/lib/client-factory.d.ts +10 -2
  46. package/dist/lib/client-factory.js +38 -26
  47. package/dist/lib/commit-signal.d.ts +65 -0
  48. package/dist/lib/commit-signal.js +305 -0
  49. package/dist/lib/concurrency-limiter.d.ts +6 -0
  50. package/dist/lib/concurrency-limiter.js +29 -0
  51. package/dist/lib/config.js +10 -5
  52. package/dist/lib/conflict-reason.d.ts +31 -4
  53. package/dist/lib/conflict-reason.js +38 -4
  54. package/dist/lib/conversation/answers.d.ts +9 -0
  55. package/dist/lib/conversation/answers.js +49 -0
  56. package/dist/lib/conversation/api.d.ts +71 -0
  57. package/dist/lib/conversation/api.js +150 -0
  58. package/dist/lib/conversation/change.d.ts +31 -0
  59. package/dist/lib/conversation/change.js +124 -0
  60. package/dist/lib/conversation/context.d.ts +19 -0
  61. package/dist/lib/conversation/context.js +70 -0
  62. package/dist/lib/conversation/environment.d.ts +15 -0
  63. package/dist/lib/conversation/environment.js +33 -0
  64. package/dist/lib/conversation/follow.d.ts +24 -0
  65. package/dist/lib/conversation/follow.js +42 -0
  66. package/dist/lib/conversation/render.d.ts +33 -0
  67. package/dist/lib/conversation/render.js +315 -0
  68. package/dist/lib/conversation/title.d.ts +2 -0
  69. package/dist/lib/conversation/title.js +18 -0
  70. package/dist/lib/conversation/types.d.ts +156 -0
  71. package/dist/lib/conversation/types.js +6 -0
  72. package/dist/lib/credentials.js +67 -11
  73. package/dist/lib/cron.d.ts +1 -1
  74. package/dist/lib/cron.js +2 -2
  75. package/dist/lib/dispatch-stop.d.ts +20 -0
  76. package/dist/lib/dispatch-stop.js +30 -0
  77. package/dist/lib/download.d.ts +71 -0
  78. package/dist/lib/download.js +274 -0
  79. package/dist/lib/dry-run/fetch.d.ts +10 -0
  80. package/dist/lib/dry-run/fetch.js +20 -0
  81. package/dist/lib/dry-run/samples.d.ts +6 -34
  82. package/dist/lib/dry-run/samples.js +389 -751
  83. package/dist/lib/environment-tunnel.d.ts +16 -26
  84. package/dist/lib/environment-tunnel.js +161 -157
  85. package/dist/lib/errors.d.ts +20 -4
  86. package/dist/lib/errors.js +36 -16
  87. package/dist/lib/facade.d.ts +7 -29
  88. package/dist/lib/facade.js +7 -36
  89. package/dist/lib/failing-fe-resolver.d.ts +13 -58
  90. package/dist/lib/failing-fe-resolver.js +47 -132
  91. package/dist/lib/first-suite-hint.d.ts +16 -22
  92. package/dist/lib/first-suite-hint.js +38 -47
  93. package/dist/lib/gh-output.d.ts +76 -21
  94. package/dist/lib/gh-output.js +171 -90
  95. package/dist/lib/git-utils.d.ts +56 -0
  96. package/dist/lib/git-utils.js +212 -0
  97. package/dist/lib/github-context.d.ts +2 -0
  98. package/dist/lib/github-context.js +40 -8
  99. package/dist/lib/history-retention.d.ts +6 -2
  100. package/dist/lib/history-retention.js +10 -7
  101. package/dist/lib/http.d.ts +58 -134
  102. package/dist/lib/http.js +352 -271
  103. package/dist/lib/interrupt.d.ts +14 -8
  104. package/dist/lib/interrupt.js +28 -10
  105. package/dist/lib/junit-report.d.ts +60 -4
  106. package/dist/lib/junit-report.js +209 -32
  107. package/dist/lib/local-target.d.ts +3 -3
  108. package/dist/lib/local-target.js +3 -3
  109. package/dist/lib/output.d.ts +0 -29
  110. package/dist/lib/output.js +10 -33
  111. package/dist/lib/pagination.d.ts +2 -5
  112. package/dist/lib/pagination.js +2 -5
  113. package/dist/lib/presigned-url.d.ts +22 -0
  114. package/dist/lib/presigned-url.js +90 -0
  115. package/dist/lib/prompt.js +36 -2
  116. package/dist/lib/proxy.js +2 -1
  117. package/dist/lib/redact.d.ts +2 -2
  118. package/dist/lib/redact.js +3 -4
  119. package/dist/lib/removed-commands.d.ts +18 -0
  120. package/dist/lib/removed-commands.js +154 -0
  121. package/dist/lib/render-error.d.ts +31 -6
  122. package/dist/lib/render-error.js +88 -25
  123. package/dist/lib/response-schemas.d.ts +38 -30
  124. package/dist/lib/response-schemas.js +210 -207
  125. package/dist/lib/result/api.d.ts +24 -0
  126. package/dist/lib/result/api.js +28 -0
  127. package/dist/lib/result/evidence.d.ts +71 -0
  128. package/dist/lib/result/evidence.js +420 -0
  129. package/dist/lib/result/render.d.ts +20 -0
  130. package/dist/lib/result/render.js +194 -0
  131. package/dist/lib/result/types.d.ts +122 -0
  132. package/dist/lib/result/types.js +19 -0
  133. package/dist/lib/run-output.d.ts +275 -0
  134. package/dist/lib/run-output.js +227 -0
  135. package/dist/lib/run-render.d.ts +101 -0
  136. package/dist/lib/run-render.js +183 -0
  137. package/dist/lib/run-wait.d.ts +192 -0
  138. package/dist/lib/run-wait.js +452 -0
  139. package/dist/lib/runs.types.d.ts +134 -367
  140. package/dist/lib/runs.types.js +0 -14
  141. package/dist/lib/secret-file.d.ts +1 -1
  142. package/dist/lib/secret-file.js +11 -2
  143. package/dist/lib/skill-nudge.d.ts +7 -27
  144. package/dist/lib/skill-nudge.js +9 -37
  145. package/dist/lib/target-path.d.ts +15 -0
  146. package/dist/lib/target-path.js +35 -0
  147. package/dist/lib/target-url-advisory.d.ts +19 -0
  148. package/dist/lib/target-url-advisory.js +31 -0
  149. package/dist/lib/target-url-preflight.d.ts +9 -0
  150. package/dist/lib/target-url-preflight.js +214 -106
  151. package/dist/lib/target-url.d.ts +1 -1
  152. package/dist/lib/target-url.js +6 -16
  153. package/dist/lib/telemetry.d.ts +32 -12
  154. package/dist/lib/telemetry.js +39 -8
  155. package/dist/lib/terminal-text.d.ts +41 -0
  156. package/dist/lib/terminal-text.js +127 -0
  157. package/dist/lib/testlist.types.d.ts +16 -8
  158. package/dist/lib/testlist.types.js +1 -1
  159. package/dist/lib/text-equality.d.ts +2 -0
  160. package/dist/lib/text-equality.js +5 -0
  161. package/dist/lib/text-file.d.ts +16 -0
  162. package/dist/lib/text-file.js +41 -0
  163. package/dist/lib/text-table.d.ts +46 -0
  164. package/dist/lib/text-table.js +72 -4
  165. package/dist/lib/ticker.d.ts +9 -2
  166. package/dist/lib/ticker.js +16 -3
  167. package/dist/lib/transport-failure.d.ts +22 -0
  168. package/dist/lib/transport-failure.js +126 -0
  169. package/dist/lib/tunnel-session.d.ts +7 -1
  170. package/dist/lib/tunnel-session.js +22 -9
  171. package/dist/lib/update-check.js +3 -2
  172. package/dist/lib/url-template.d.ts +43 -0
  173. package/dist/lib/url-template.js +151 -0
  174. package/dist/lib/validate.d.ts +0 -64
  175. package/dist/lib/validate.js +2 -131
  176. package/dist/lib/version-notice.js +4 -3
  177. package/dist/lib/wait-exit.d.ts +37 -2
  178. package/dist/lib/wait-exit.js +88 -30
  179. package/dist/lib/workspace-status.js +10 -2
  180. package/dist/version.d.ts +1 -1
  181. package/dist/version.js +1 -1
  182. package/package.json +3 -4
  183. package/skills/testsprite-ci.skill.md +48 -18
  184. package/skills/testsprite-onboard.skill.md +66 -151
  185. package/skills/testsprite-verify.codex.md +54 -56
  186. package/skills/testsprite-verify.skill.md +194 -358
  187. package/dist/lib/browser.d.ts +0 -6
  188. package/dist/lib/browser.js +0 -54
  189. package/dist/lib/bundle.d.ts +0 -234
  190. package/dist/lib/bundle.js +0 -781
  191. package/dist/lib/deprecate.d.ts +0 -10
  192. package/dist/lib/deprecate.js +0 -13
  193. package/dist/lib/flaky.d.ts +0 -91
  194. package/dist/lib/flaky.js +0 -71
  195. package/dist/lib/plan-poll.d.ts +0 -171
  196. package/dist/lib/plan-poll.js +0 -441
  197. package/dist/lib/plans.types.d.ts +0 -130
  198. package/dist/lib/plans.types.js +0 -31
  199. package/dist/lib/poll.d.ts +0 -100
  200. package/dist/lib/poll.js +0 -290
  201. package/dist/lib/rate-throttle.d.ts +0 -49
  202. package/dist/lib/rate-throttle.js +0 -75
  203. package/dist/lib/run-progress.d.ts +0 -41
  204. package/dist/lib/run-progress.js +0 -56
  205. package/dist/lib/v3-advisory.d.ts +0 -55
  206. package/dist/lib/v3-advisory.js +0 -74
  207. package/schemas/plan.schema.json +0 -61
@@ -1,9 +1,3 @@
1
- /**
2
- * Types for M3.3 piece-3 — `test run` / `test wait` commands.
3
- * Extended by M3.4 piece-3 — `test rerun` command.
4
- * Extended by M3.4 piece-5 — `test result --history` command.
5
-
6
- */
7
1
  /** Terminal states from the RunStatus union. */
8
2
  export const TERMINAL_RUN_STATUSES = new Set([
9
3
  'passed',
@@ -14,12 +8,4 @@ export const TERMINAL_RUN_STATUSES = new Set([
14
8
  export function isTerminalStatus(status) {
15
9
  return TERMINAL_RUN_STATUSES.has(status);
16
10
  }
17
- /** The valid RUN_SOURCES values as an array for CLI flag validation. */
18
- export const RUN_SOURCES = [
19
- 'cli',
20
- 'portal',
21
- 'mcp',
22
- 'schedule',
23
- 'github_action',
24
- ];
25
11
  //# sourceMappingURL=runs.types.js.map
@@ -2,7 +2,7 @@
2
2
  * Read a secret from `path`, surfacing every filesystem failure as a typed
3
3
  * `VALIDATION_ERROR` (exit 5) attributed to `flag`.
4
4
  *
5
- * The returned value is trimmed, matching what the unguarded call sites did.
5
+ * Most flags trim the returned value. A credential file preserves spaces in a raw Basic pair.
6
6
  * Trimming also drops a leading UTF-8 BOM: `U+FEFF` is ECMAScript whitespace,
7
7
  * so a file written by PowerShell 5.1's default `Set-Content -Encoding utf8`
8
8
  * no longer smuggles an invisible character into the secret.
@@ -27,11 +27,12 @@
27
27
  import { closeSync, constants, fstatSync, openSync, readFileSync, statSync } from 'node:fs';
28
28
  import { isAbsolute, resolve } from 'node:path';
29
29
  import { localValidationError } from './errors.js';
30
+ import { decodeWithBom } from './text-file.js';
30
31
  /**
31
32
  * Read a secret from `path`, surfacing every filesystem failure as a typed
32
33
  * `VALIDATION_ERROR` (exit 5) attributed to `flag`.
33
34
  *
34
- * The returned value is trimmed, matching what the unguarded call sites did.
35
+ * Most flags trim the returned value. A credential file preserves spaces in a raw Basic pair.
35
36
  * Trimming also drops a leading UTF-8 BOM: `U+FEFF` is ECMAScript whitespace,
36
37
  * so a file written by PowerShell 5.1's default `Set-Content -Encoding utf8`
37
38
  * no longer smuggles an invisible character into the secret.
@@ -95,8 +96,16 @@ export function readSecretFileGuarded(flag, path) {
95
96
  throw localValidationError(flag, `not a regular file: ${path}`);
96
97
  }
97
98
  try {
99
+ // Decoded through decodeWithBom so a UTF-16LE/BE secret file (PowerShell
100
+ // 5.1 `Set-Content -Encoding unicode`) yields the real secret instead of
101
+ // mojibake; decodeWithBom also strips a UTF-8 BOM.
98
102
  // eslint-disable-next-line security/detect-non-literal-fs-filename -- `fd` is the open file descriptor from openSync() above, not a path string; the rule's non-literal-argument check does not distinguish the two, but there is no path re-resolution here for anything to race against.
99
- return readFileSync(fd, 'utf8').trim();
103
+ const value = decodeWithBom(readFileSync(fd));
104
+ // A Basic username or password can start or end in a space. Drop only
105
+ // the file's BOM and one terminating line ending for static credentials.
106
+ return flag === 'credential-file'
107
+ ? value.replace(/^\uFEFF/, '').replace(/\r?\n$/, '')
108
+ : value.trim();
100
109
  }
101
110
  catch (err) {
102
111
  throw secretFileError(flag, path, err, 'read');
@@ -2,19 +2,16 @@ import { type AgentTarget } from './agent-targets.js';
2
2
  import type { OutputMode } from './output.js';
3
3
  /**
4
4
  * Full command paths (group + leaf) that signal the caller is actively driving
5
- * the verification loop — running or authoring tests, or checking auth in
6
- * preflight. The skill nudge fires ONLY for these.
5
+ * the verification loop — running tests, or checking auth in preflight. The
6
+ * skill nudge fires ONLY for these.
7
7
  *
8
8
  * Deliberately excluded:
9
- * - `setup` / `init` / `agent install` — they ARE the fix; nudging is circular.
10
- * - read-only inspection (`test list/get/result/...`, `project list/get`) —
9
+ * - `setup` / `agent install` — they ARE the fix; nudging is circular.
10
+ * - read-only inspection (`test list/get`, `result list/get`, `project list/get`) —
11
11
  * keeps an agent that is merely browsing from being nagged.
12
- * - `auth configure` / `auth remove` (and the deprecated `auth logout`) —
13
- * credential management, not the loop.
12
+ * - `auth remove` — credential management, not the loop.
14
13
  *
15
- * Match the strings emitted by `commandPathOf` in `src/index.ts`. `auth status`
16
- * is the primary identity command; `auth whoami` is its deprecated alias and is
17
- * listed too so the warning fires regardless of which name the caller uses.
14
+ * Match the strings emitted by `commandPathOf` in `src/index.ts`.
18
15
  */
19
16
  export declare const SKILL_NUDGE_COMMANDS: ReadonlySet<string>;
20
17
  /**
@@ -22,23 +19,6 @@ export declare const SKILL_NUDGE_COMMANDS: ReadonlySet<string>;
22
19
  * the CLI by hand without wiring a coding agent.
23
20
  */
24
21
  export declare const SKILL_NUDGE_OPT_OUT_ENV = "TESTSPRITE_NO_SKILL_WARNING";
25
- /**
26
- * True when this invocation is `test create --plan-template`, a
27
- * pure-local/informational flag (prints the plan-file skeleton and exits)
28
- * that must be treated like `setup` / `agent install`: exempt from BOTH the
29
- * missing-skill nudge above AND the update-registry check
30
- * (`src/lib/update-check.ts`'s `maybeNotifyUpdate`, which hits the network
31
- * and writes `~/.testsprite/update-check.json` — both contradict "no
32
- * network" for this flag). Neither allowlist (`SKILL_NUDGE_COMMANDS` here,
33
- * the unconditional call site in `src/index.ts`) tracks individual flags,
34
- * only whole commands, so `src/index.ts`'s `preAction` hook filters this one
35
- * case via this pure, independently-testable helper instead of teaching
36
- * either module about flags. Exported from `skill-nudge.ts` (rather than
37
- * `src/index.ts`, which executes `program.parse()` at import time and so
38
- * cannot be safely imported by a unit test) purely so it has a home that
39
- * supports direct unit testing.
40
- */
41
- export declare function isPlanTemplateInvocation(commandPath: string, planTemplate: boolean | undefined): boolean;
42
22
  export interface SkillPresenceDeps {
43
23
  existsSync?: (p: string) => boolean;
44
24
  readFileSync?: (p: string) => string;
@@ -65,7 +45,7 @@ export interface SkillPresenceDeps {
65
45
  */
66
46
  export declare function isVerifySkillInstalled(dir: string, deps?: SkillPresenceDeps): boolean;
67
47
  export interface SkillNudgeContext {
68
- /** Full command path, e.g. "test run" / "auth whoami". */
48
+ /** Full command path, e.g. "run" / "auth status". */
69
49
  commandPath: string;
70
50
  output: OutputMode;
71
51
  dryRun: boolean;
@@ -3,54 +3,26 @@ import { join } from 'node:path';
3
3
  import { MANAGED_SECTION_BEGIN, MANAGED_SECTION_END, TARGETS, } from './agent-targets.js';
4
4
  import { detectCallerFromEnv } from './agent-detect.js';
5
5
  import { defaultCredentialsPath, readProfile } from './credentials.js';
6
+ import { terminalSafeWriter } from './terminal-text.js';
6
7
  /**
7
8
  * Full command paths (group + leaf) that signal the caller is actively driving
8
- * the verification loop — running or authoring tests, or checking auth in
9
- * preflight. The skill nudge fires ONLY for these.
9
+ * the verification loop — running tests, or checking auth in preflight. The
10
+ * skill nudge fires ONLY for these.
10
11
  *
11
12
  * Deliberately excluded:
12
- * - `setup` / `init` / `agent install` — they ARE the fix; nudging is circular.
13
- * - read-only inspection (`test list/get/result/...`, `project list/get`) —
13
+ * - `setup` / `agent install` — they ARE the fix; nudging is circular.
14
+ * - read-only inspection (`test list/get`, `result list/get`, `project list/get`) —
14
15
  * keeps an agent that is merely browsing from being nagged.
15
- * - `auth configure` / `auth remove` (and the deprecated `auth logout`) —
16
- * credential management, not the loop.
16
+ * - `auth remove` — credential management, not the loop.
17
17
  *
18
- * Match the strings emitted by `commandPathOf` in `src/index.ts`. `auth status`
19
- * is the primary identity command; `auth whoami` is its deprecated alias and is
20
- * listed too so the warning fires regardless of which name the caller uses.
18
+ * Match the strings emitted by `commandPathOf` in `src/index.ts`.
21
19
  */
22
- export const SKILL_NUDGE_COMMANDS = new Set([
23
- 'test run',
24
- 'test rerun',
25
- 'test create',
26
- 'test create-batch',
27
- 'auth status',
28
- 'auth whoami',
29
- ]);
20
+ export const SKILL_NUDGE_COMMANDS = new Set(['run', 'auth status']);
30
21
  /**
31
22
  * Env var that silences the warning. For CI, or users who deliberately drive
32
23
  * the CLI by hand without wiring a coding agent.
33
24
  */
34
25
  export const SKILL_NUDGE_OPT_OUT_ENV = 'TESTSPRITE_NO_SKILL_WARNING';
35
- /**
36
- * True when this invocation is `test create --plan-template`, a
37
- * pure-local/informational flag (prints the plan-file skeleton and exits)
38
- * that must be treated like `setup` / `agent install`: exempt from BOTH the
39
- * missing-skill nudge above AND the update-registry check
40
- * (`src/lib/update-check.ts`'s `maybeNotifyUpdate`, which hits the network
41
- * and writes `~/.testsprite/update-check.json` — both contradict "no
42
- * network" for this flag). Neither allowlist (`SKILL_NUDGE_COMMANDS` here,
43
- * the unconditional call site in `src/index.ts`) tracks individual flags,
44
- * only whole commands, so `src/index.ts`'s `preAction` hook filters this one
45
- * case via this pure, independently-testable helper instead of teaching
46
- * either module about flags. Exported from `skill-nudge.ts` (rather than
47
- * `src/index.ts`, which executes `program.parse()` at import time and so
48
- * cannot be safely imported by a unit test) purely so it has a home that
49
- * supports direct unit testing.
50
- */
51
- export function isPlanTemplateInvocation(commandPath, planTemplate) {
52
- return commandPath === 'test create' && planTemplate === true;
53
- }
54
26
  /**
55
27
  * True if the `testsprite-verify` skill is installed in `dir` — for any
56
28
  * supported agent, or only for `deps.requiredTargets` when given. own-file
@@ -117,7 +89,7 @@ function hasCompleteManagedSection(content) {
117
89
  * `--debug` callers receive the swallowed reason on stderr.
118
90
  */
119
91
  export function maybeEmitSkillNudge(ctx) {
120
- const write = ctx.stderr ?? ((line) => process.stderr.write(`${line}\n`));
92
+ const write = terminalSafeWriter(ctx.stderr);
121
93
  try {
122
94
  if (ctx.output !== 'text')
123
95
  return;
@@ -0,0 +1,15 @@
1
+ export interface TargetPathFs {
2
+ lstat(p: string): Promise<{
3
+ isFile: boolean;
4
+ isSymbolicLink: boolean;
5
+ } | null>;
6
+ }
7
+ /**
8
+ * Inspect existing components before creating a target. Symlinks are refused
9
+ * unless the caller supplies a policy that validates their destination.
10
+ * Returns null at the first missing component. A race between inspection and
11
+ * writing remains, as with the agent installer's original path guard.
12
+ */
13
+ export declare function inspectTargetPath(agentFs: TargetPathFs, root: string, relPath: string, allowSymlink?: (target: string) => Promise<void>): Promise<{
14
+ isFile: boolean;
15
+ } | null>;
@@ -0,0 +1,35 @@
1
+ import path from 'node:path';
2
+ import { CLIError } from './errors.js';
3
+ /**
4
+ * Inspect existing components before creating a target. Symlinks are refused
5
+ * unless the caller supplies a policy that validates their destination.
6
+ * Returns null at the first missing component. A race between inspection and
7
+ * writing remains, as with the agent installer's original path guard.
8
+ */
9
+ export async function inspectTargetPath(agentFs, root, relPath, allowSymlink) {
10
+ const segments = relPath.split(process.platform === 'win32' ? /[/\\]+/ : /\/+/).filter(Boolean);
11
+ let current = root;
12
+ let finalIsFile = false;
13
+ for (const [i, seg] of segments.entries()) {
14
+ current = path.join(current, seg);
15
+ const ls = await agentFs.lstat(current);
16
+ if (ls === null) {
17
+ // This component and everything below it does not exist yet.
18
+ return null;
19
+ }
20
+ if (ls.isSymbolicLink && allowSymlink) {
21
+ await allowSymlink(current);
22
+ }
23
+ else if (ls.isSymbolicLink) {
24
+ const shown = segments.slice(0, i + 1).join('/');
25
+ throw new CLIError(`refusing to write through a symlink: "${shown}" — installing here could place files outside --dir. Remove the symlink or choose a different --dir.`, 5);
26
+ }
27
+ if (i < segments.length - 1 && ls.isFile) {
28
+ const shown = segments.slice(0, i + 1).join('/');
29
+ throw new CLIError(`cannot create ${relPath}: "${shown}" exists and is not a directory.`, 5);
30
+ }
31
+ finalIsFile = ls.isFile;
32
+ }
33
+ return { isFile: finalIsFile };
34
+ }
35
+ //# sourceMappingURL=target-path.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Point-of-use advisory for `run --target-url`. Response-driven: it
3
+ * compares what the caller asked for against the target the trigger response
4
+ * reports, and speaks up only when they differ — the backend is the ground
5
+ * truth for which origin a run used, so the CLI never infers it.
6
+ *
7
+ * Deliberately cause-agnostic in its wording: a mismatch is reported purely
8
+ * from the observed response, regardless of why the backend didn't apply the
9
+ * override.
10
+ */
11
+ export declare function targetUrlAdvisoryText(requested: string, applied: string): string;
12
+ /**
13
+ * Compare the requested `--target-url` against what the trigger response
14
+ * reports and write the advisory when they differ. No-op when they match
15
+ * (the override was applied, or the caller didn't supply one — callers are
16
+ * expected to gate the `requested` argument on `opts.targetUrl !== undefined`
17
+ * themselves so this stays a pure comparison).
18
+ */
19
+ export declare function emitTargetUrlMismatchAdvisory(stderr: (line: string) => void, requested: string, applied: string): void;
@@ -0,0 +1,31 @@
1
+ import { terminalSafeLine } from './terminal-text.js';
2
+ /**
3
+ * Point-of-use advisory for `run --target-url`. Response-driven: it
4
+ * compares what the caller asked for against the target the trigger response
5
+ * reports, and speaks up only when they differ — the backend is the ground
6
+ * truth for which origin a run used, so the CLI never infers it.
7
+ *
8
+ * Deliberately cause-agnostic in its wording: a mismatch is reported purely
9
+ * from the observed response, regardless of why the backend didn't apply the
10
+ * override.
11
+ */
12
+ export function targetUrlAdvisoryText(requested, applied) {
13
+ const appliedClause = applied.length > 0
14
+ ? `the run will use ${terminalSafeLine(applied)} instead`
15
+ : 'the run reports no target URL for it';
16
+ return (`[advisory] --target-url ${terminalSafeLine(requested)} was not applied to this run — ${appliedClause}. ` +
17
+ `The run used its own configured environment.`);
18
+ }
19
+ /**
20
+ * Compare the requested `--target-url` against what the trigger response
21
+ * reports and write the advisory when they differ. No-op when they match
22
+ * (the override was applied, or the caller didn't supply one — callers are
23
+ * expected to gate the `requested` argument on `opts.targetUrl !== undefined`
24
+ * themselves so this stays a pure comparison).
25
+ */
26
+ export function emitTargetUrlMismatchAdvisory(stderr, requested, applied) {
27
+ if (applied === requested)
28
+ return;
29
+ stderr(targetUrlAdvisoryText(requested, applied));
30
+ }
31
+ //# sourceMappingURL=target-url-advisory.js.map
@@ -41,6 +41,13 @@
41
41
  * string; the resolved-address check only covers *this* URL's host),
42
42
  * so following it would hand an attacker-controlled Location header a
43
43
  * live SSRF primitive running on the caller's machine or CI runner.
44
+ *
45
+ * One redirect is refused: Vercel Deployment Protection's login wall. Its
46
+ * Location is parsed as a string and never fetched, so the guarantee above
47
+ * holds. Unlike the app's own login page, no test credential gets past
48
+ * Vercel's wall. The honest limitation above (the probe runs here, not on
49
+ * the Lambda) does not apply either: Vercel sends every visitor without a
50
+ * Vercel session there, the Lambda included.
44
51
  */
45
52
  import { type ShutdownHandle } from './interrupt.js';
46
53
  export interface TargetUrlPreflightDeps {
@@ -63,6 +70,7 @@ export interface TargetUrlPreflightDeps {
63
70
  */
64
71
  proxyActive?: boolean;
65
72
  }
73
+ /** A `refuse` verdict's `refusal` names why; it becomes `details.reason` on the thrown error. */
66
74
  export type TargetUrlPreflightOutcome = {
67
75
  verdict: 'ok';
68
76
  } | {
@@ -70,6 +78,7 @@ export type TargetUrlPreflightOutcome = {
70
78
  reason: string;
71
79
  } | {
72
80
  verdict: 'refuse';
81
+ refusal: 'target-unreachable' | 'target-protected';
73
82
  reason: string;
74
83
  };
75
84
  /**