@agent-watch-ai/edge 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +288 -9
- package/README.md +307 -5
- package/dist/billing/billing-mode.d.ts +37 -5
- package/dist/billing/billing-mode.js +28 -19
- package/dist/billing/constants/billing.constants.d.ts +0 -2
- package/dist/billing/constants/billing.constants.js +0 -2
- package/dist/billing/index.d.ts +2 -1
- package/dist/billing/index.js +1 -1
- package/dist/billing/session-billing.d.ts +7 -3
- package/dist/billing/session-billing.js +34 -13
- package/dist/billing/types/billing.types.d.ts +7 -0
- package/dist/capture/capture-env.d.ts +147 -0
- package/dist/capture/capture-env.js +301 -0
- package/dist/capture/captured-step.d.ts +88 -0
- package/dist/capture/captured-step.js +503 -0
- package/dist/capture/constants/capture.constants.d.ts +85 -0
- package/dist/capture/constants/capture.constants.js +87 -0
- package/dist/capture/launched-runs.d.ts +43 -0
- package/dist/capture/launched-runs.js +157 -0
- package/dist/capture/node.cjs +697 -0
- package/dist/capture/node.d.cts +32 -0
- package/dist/capture/python/sitecustomize.py +832 -0
- package/dist/capture/schemas/capture.schema.d.ts +35 -0
- package/dist/capture/schemas/capture.schema.js +31 -0
- package/dist/capture/types/capture.types.d.ts +20 -0
- package/dist/capture/venv-loader.d.ts +68 -0
- package/dist/capture/venv-loader.js +189 -0
- package/dist/cli/constants/cli.constants.d.ts +23 -6
- package/dist/cli/constants/cli.constants.js +24 -7
- package/dist/cli/context.d.ts +19 -22
- package/dist/cli/context.js +23 -54
- package/dist/cli/doctor-run-capture.d.ts +21 -0
- package/dist/cli/doctor-run-capture.js +33 -0
- package/dist/cli/doctor.js +21 -68
- package/dist/cli/hook-check.d.ts +7 -2
- package/dist/cli/hook-check.js +30 -15
- package/dist/cli/hook.d.ts +14 -0
- package/dist/cli/hook.js +82 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/misc.js +10 -2
- package/dist/cli/npm-global.d.ts +24 -0
- package/dist/cli/npm-global.js +77 -0
- package/dist/cli/npx-install.js +22 -6
- package/dist/cli/replay.d.ts +33 -0
- package/dist/cli/replay.js +228 -0
- package/dist/cli/setup.d.ts +10 -2
- package/dist/cli/setup.js +200 -31
- package/dist/cli/status.js +45 -5
- package/dist/cli/toggle.js +10 -0
- package/dist/cli/types/cli.types.d.ts +15 -1
- package/dist/cli/uninstall.js +42 -23
- package/dist/cli/update.js +3 -2
- package/dist/cli.js +104 -17
- package/dist/config/config-store.d.ts +15 -4
- package/dist/config/config-store.js +31 -7
- package/dist/config/config.d.ts +0 -2
- package/dist/config/config.js +0 -1
- package/dist/config/constants/config.constants.d.ts +8 -1
- package/dist/config/constants/config.constants.js +10 -1
- package/dist/config/events-transport.d.ts +15 -0
- package/dist/config/events-transport.js +29 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/root-config.d.ts +12 -0
- package/dist/config/root-config.js +24 -0
- package/dist/config/schemas/config.schema.d.ts +15 -2
- package/dist/config/schemas/config.schema.js +52 -8
- package/dist/config/types/config.types.d.ts +7 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/version.d.ts +9 -0
- package/dist/core/version.js +14 -0
- package/dist/core/which.d.ts +11 -0
- package/dist/core/which.js +18 -0
- package/dist/credentials/cloud-claim.d.ts +34 -0
- package/dist/credentials/cloud-claim.js +61 -0
- package/dist/credentials/constants/credentials.constants.d.ts +16 -1
- package/dist/credentials/constants/credentials.constants.js +17 -2
- package/dist/credentials/credential-status.js +1 -1
- package/dist/credentials/credentials.d.ts +3 -3
- package/dist/credentials/credentials.js +26 -12
- package/dist/credentials/device-api.d.ts +15 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/identity.d.ts +2 -2
- package/dist/credentials/identity.js +2 -2
- package/dist/credentials/install-key.d.ts +31 -0
- package/dist/credentials/install-key.js +58 -0
- package/dist/credentials/migration.d.ts +9 -7
- package/dist/credentials/migration.js +58 -18
- package/dist/credentials/secret-store.d.ts +12 -0
- package/dist/credentials/secret-store.js +18 -1
- package/dist/credentials/sign-in.d.ts +27 -0
- package/dist/credentials/sign-in.js +31 -1
- package/dist/credentials/token-refresher.d.ts +5 -1
- package/dist/credentials/token-refresher.js +10 -2
- package/dist/enforcement/enforcement.js +1 -1
- package/dist/events/constants/events.constants.d.ts +5 -2
- package/dist/events/constants/events.constants.js +4 -1
- package/dist/events/enrich.d.ts +14 -0
- package/dist/events/enrich.js +1 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/product-event.d.ts +6 -3
- package/dist/events/types/events.types.d.ts +6 -0
- package/dist/events/types/replay-progress.types.d.ts +26 -0
- package/dist/events/types/replay-progress.types.js +1 -0
- package/dist/events/types/repo-tree.types.d.ts +2 -1
- package/dist/feature/ticket-candidates.d.ts +1 -1
- package/dist/git/checkout-root.d.ts +15 -0
- package/dist/git/checkout-root.js +18 -0
- package/dist/git/code-state.d.ts +2 -16
- package/dist/git/code-state.js +11 -12
- package/dist/git/constants/git.constants.d.ts +33 -11
- package/dist/git/constants/git.constants.js +45 -12
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.js +5 -1
- package/dist/git/index.d.ts +1 -2
- package/dist/git/index.js +1 -1
- package/dist/git/repo-snapshot.d.ts +13 -4
- package/dist/git/repo-snapshot.js +53 -9
- package/dist/git/types/snapshot.types.d.ts +6 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
- package/dist/pipeline/constants/pipeline.constants.js +3 -0
- package/dist/pipeline/hook-pipeline.js +82 -57
- package/dist/privacy/product-capture.js +2 -0
- package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.capture.js +5 -0
- package/dist/providers/antigravity/antigravity.detect.js +8 -22
- package/dist/providers/antigravity/antigravity.provider.js +10 -3
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
- package/dist/providers/claude/claude.adapter.js +9 -6
- package/dist/providers/claude/claude.detect.js +2 -17
- package/dist/providers/claude/claude.otel.d.ts +21 -3
- package/dist/providers/claude/claude.otel.js +216 -61
- package/dist/providers/claude/claude.provider.js +21 -1
- package/dist/providers/claude/claude.version.d.ts +9 -0
- package/dist/providers/claude/claude.version.js +28 -0
- package/dist/providers/claude/constants/claude.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.constants.js +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +45 -5
- package/dist/providers/claude/types/claude.types.d.ts +13 -0
- package/dist/providers/codex/codex.capture.d.ts +76 -0
- package/dist/providers/codex/codex.capture.js +454 -0
- package/dist/providers/codex/codex.detect.js +2 -4
- package/dist/providers/codex/codex.otel.d.ts +38 -2
- package/dist/providers/codex/codex.otel.js +50 -6
- package/dist/providers/codex/codex.provider.js +8 -0
- package/dist/providers/codex/codex.surface.d.ts +9 -0
- package/dist/{turns/codex-originator.js → providers/codex/codex.surface.js} +17 -3
- package/dist/providers/codex/codex.titles.d.ts +14 -0
- package/dist/providers/codex/codex.titles.js +35 -0
- package/dist/providers/codex/constants/codex.constants.d.ts +4 -0
- package/dist/providers/codex/constants/codex.constants.js +4 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +17 -4
- package/dist/providers/cursor/constants/cursor.constants.js +25 -5
- package/dist/providers/cursor/cursor-mcp-memo.d.ts +34 -0
- package/dist/providers/cursor/cursor-mcp-memo.js +94 -0
- package/dist/providers/cursor/cursor.adapter.js +20 -82
- package/dist/providers/cursor/cursor.capture.d.ts +1 -0
- package/dist/providers/cursor/cursor.capture.js +4 -0
- package/dist/providers/cursor/cursor.detect.d.ts +5 -1
- package/dist/providers/cursor/cursor.detect.js +11 -26
- package/dist/providers/cursor/cursor.hooks.js +2 -2
- package/dist/providers/cursor/cursor.provider.js +16 -7
- package/dist/providers/cursor/cursor.titles.d.ts +14 -0
- package/dist/providers/cursor/cursor.titles.js +20 -0
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +3 -3
- package/dist/providers/cursor/schemas/cursor.schema.js +5 -3
- package/dist/providers/gemini/constants/gemini.constants.d.ts +16 -0
- package/dist/providers/gemini/constants/gemini.constants.js +17 -0
- package/dist/providers/gemini/gemini.capture.d.ts +81 -0
- package/dist/providers/gemini/gemini.capture.js +210 -0
- package/dist/providers/gemini/gemini.detect.js +57 -24
- package/dist/providers/gemini/gemini.otel.d.ts +38 -2
- package/dist/providers/gemini/gemini.otel.js +56 -125
- package/dist/providers/gemini/gemini.provider.js +5 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/provider.d.ts +8 -0
- package/dist/providers/provider.js +9 -0
- package/dist/providers/registry.d.ts +14 -0
- package/dist/providers/registry.js +14 -0
- package/dist/providers/shared/constants/hook-config.constants.d.ts +2 -0
- package/dist/providers/shared/constants/hook-config.constants.js +2 -0
- package/dist/providers/shared/constants/terminal-capture.constants.d.ts +6 -0
- package/dist/providers/shared/constants/terminal-capture.constants.js +6 -0
- package/dist/providers/shared/editor-paths.d.ts +8 -0
- package/dist/providers/shared/editor-paths.js +18 -0
- package/dist/providers/shared/hook-config.d.ts +5 -0
- package/dist/providers/shared/hook-config.js +39 -1
- package/dist/providers/shared/hooks-marker.d.ts +14 -0
- package/dist/providers/shared/hooks-marker.js +23 -0
- package/dist/providers/shared/install-record.d.ts +29 -0
- package/dist/providers/shared/install-record.js +52 -0
- package/dist/providers/shared/session-title-store.d.ts +23 -0
- package/dist/providers/shared/session-title-store.js +50 -0
- package/dist/providers/shared/terminal-capture.d.ts +41 -0
- package/dist/providers/shared/terminal-capture.js +109 -0
- package/dist/providers/shared/tooling.d.ts +21 -0
- package/dist/providers/shared/tooling.js +36 -1
- package/dist/providers/types/provider.types.d.ts +57 -4
- package/dist/replay/checkout-resolver.d.ts +56 -0
- package/dist/replay/checkout-resolver.js +173 -0
- package/dist/replay/codex-turns.d.ts +24 -0
- package/dist/replay/codex-turns.js +221 -0
- package/dist/replay/constants/replay.constants.d.ts +99 -0
- package/dist/replay/constants/replay.constants.js +102 -0
- package/dist/replay/describe.d.ts +10 -0
- package/dist/replay/describe.js +31 -0
- package/dist/replay/gemini-turns.d.ts +36 -0
- package/dist/replay/gemini-turns.js +192 -0
- package/dist/replay/machine.d.ts +34 -0
- package/dist/replay/machine.js +68 -0
- package/dist/replay/progress-event.d.ts +21 -0
- package/dist/replay/progress-event.js +45 -0
- package/dist/replay/replay-runner.d.ts +60 -0
- package/dist/replay/replay-runner.js +581 -0
- package/dist/replay/replay-scan.d.ts +84 -0
- package/dist/replay/replay-scan.js +182 -0
- package/dist/replay/replay-state.d.ts +108 -0
- package/dist/replay/replay-state.js +199 -0
- package/dist/replay/resume.d.ts +18 -0
- package/dist/replay/resume.js +34 -0
- package/dist/replay/start.d.ts +23 -0
- package/dist/replay/start.js +39 -0
- package/dist/replay/throttle.d.ts +36 -0
- package/dist/replay/throttle.js +44 -0
- package/dist/replay/transcript-turns.d.ts +35 -0
- package/dist/replay/transcript-turns.js +241 -0
- package/dist/replay/turn-event.d.ts +40 -0
- package/dist/replay/turn-event.js +127 -0
- package/dist/replay/types/replay.types.d.ts +198 -0
- package/dist/replay/types/replay.types.js +1 -0
- package/dist/replay/window.d.ts +28 -0
- package/dist/replay/window.js +41 -0
- package/dist/replay/worktree-map.d.ts +42 -0
- package/dist/replay/worktree-map.js +134 -0
- package/dist/snapshot/branch-selection.d.ts +40 -23
- package/dist/snapshot/branch-selection.js +71 -41
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +3 -1
- package/dist/snapshot/constants/snapshot-stages.constants.js +3 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +34 -7
- package/dist/snapshot/constants/snapshot.constants.js +34 -7
- package/dist/snapshot/index.d.ts +2 -2
- package/dist/snapshot/index.js +1 -1
- package/dist/snapshot/snapshot-pipeline.js +100 -26
- package/dist/snapshot/snapshot-state.js +6 -2
- package/dist/snapshot/tree-pipeline.d.ts +1 -1
- package/dist/snapshot/tree-pipeline.js +34 -15
- package/dist/snapshot/types/snapshot.types.d.ts +22 -3
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/delivery-stats.d.ts +13 -1
- package/dist/transport/delivery-stats.js +18 -2
- package/dist/transport/delivery.d.ts +4 -3
- package/dist/transport/delivery.js +21 -7
- package/dist/transport/identity-delivery.d.ts +20 -0
- package/dist/transport/identity-delivery.js +41 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/types/delivery-flow.types.d.ts +7 -0
- package/dist/turns/claude-transcript.js +4 -12
- package/dist/turns/codex-transcript.d.ts +9 -0
- package/dist/turns/codex-transcript.js +27 -19
- package/dist/turns/constants/turns.constants.d.ts +29 -12
- package/dist/turns/constants/turns.constants.js +31 -19
- package/dist/turns/gemini-transcript.d.ts +19 -1
- package/dist/turns/gemini-transcript.js +29 -18
- package/dist/turns/index.d.ts +3 -4
- package/dist/turns/index.js +2 -3
- package/dist/turns/run-state.d.ts +71 -0
- package/dist/turns/run-state.js +114 -0
- package/dist/turns/tool-events.d.ts +11 -1
- package/dist/turns/tool-events.js +32 -9
- package/dist/turns/transcript.d.ts +15 -14
- package/dist/turns/transcript.js +23 -4
- package/dist/turns/turn-state.d.ts +82 -7
- package/dist/turns/turn-state.js +157 -10
- package/dist/turns/turn-summary.js +7 -2
- package/dist/turns/turn-tracker.d.ts +9 -16
- package/dist/turns/turn-tracker.js +163 -87
- package/dist/turns/types/transcript.types.d.ts +11 -1
- package/dist/turns/types/turn-provider.types.d.ts +33 -0
- package/dist/turns/types/turn-provider.types.js +1 -0
- package/dist/turns/types/turn-state.types.d.ts +9 -0
- package/dist/turns/types/turn-summary.types.d.ts +17 -1
- package/dist/turns/types/turn-tracker.types.d.ts +3 -1
- package/dist/turns/work-checkout.js +1 -2
- package/docs/AUDIT_PROMPT.md +10 -0
- package/docs/DATA_HANDLING.md +201 -13
- package/docs/ENTERPRISE_DEPLOYMENT.md +3 -3
- package/docs/PERFORMANCE.md +10 -0
- package/package.json +3 -2
- package/dist/events/canonical-event.d.ts +0 -10
- package/dist/events/canonical-event.js +0 -9
- package/dist/git/repository-root.d.ts +0 -39
- package/dist/git/repository-root.js +0 -131
- package/dist/git/types/repository-root.types.d.ts +0 -11
- package/dist/transport/transport.d.ts +0 -6
- package/dist/turns/codex-originator.d.ts +0 -11
- package/dist/turns/cursor-transcript.d.ts +0 -21
- package/dist/turns/cursor-transcript.js +0 -66
- package/dist/turns/native-session-titles.d.ts +0 -26
- package/dist/turns/native-session-titles.js +0 -102
- /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
- /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* One spool line. Strip, not passthrough: this schema is the guarantee that a
|
|
4
|
+
* body, a header or a key can never travel, whatever a file under the data dir
|
|
5
|
+
* says, because nothing past it reads anything it does not name.
|
|
6
|
+
*/
|
|
7
|
+
export declare const spoolRecordSchema: z.ZodObject<{
|
|
8
|
+
pid: z.ZodNumber;
|
|
9
|
+
started: z.ZodString;
|
|
10
|
+
ancestors: z.ZodArray<z.ZodObject<{
|
|
11
|
+
pid: z.ZodNumber;
|
|
12
|
+
started: z.ZodString;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
at: z.ZodString;
|
|
15
|
+
seq: z.ZodNumber;
|
|
16
|
+
script: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
provider: z.ZodEnum<{
|
|
18
|
+
anthropic: "anthropic";
|
|
19
|
+
openai: "openai";
|
|
20
|
+
google: "google";
|
|
21
|
+
vertex: "vertex";
|
|
22
|
+
bedrock: "bedrock";
|
|
23
|
+
}>;
|
|
24
|
+
model: z.ZodOptional<z.ZodString>;
|
|
25
|
+
request_id: z.ZodOptional<z.ZodString>;
|
|
26
|
+
status: z.ZodNumber;
|
|
27
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
cached_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
reasoning_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MAX_ID_LENGTH } from '../constants/capture.constants.js';
|
|
3
|
+
const tokens = z.number().int().nonnegative().optional();
|
|
4
|
+
/**
|
|
5
|
+
* One spool line. Strip, not passthrough: this schema is the guarantee that a
|
|
6
|
+
* body, a header or a key can never travel, whatever a file under the data dir
|
|
7
|
+
* says, because nothing past it reads anything it does not name.
|
|
8
|
+
*/
|
|
9
|
+
export const spoolRecordSchema = z.object({
|
|
10
|
+
pid: z.number().int().positive(),
|
|
11
|
+
started: z.string().min(1).max(64),
|
|
12
|
+
ancestors: z.array(z.object({ pid: z.number().int().positive(), started: z.string().min(1).max(64) })).max(64),
|
|
13
|
+
at: z.string().min(1).max(64),
|
|
14
|
+
seq: z.number().int().nonnegative(),
|
|
15
|
+
/** The file name the process runs: which run it is. Never sent. */
|
|
16
|
+
script: z.string().min(1).max(MAX_ID_LENGTH).optional().catch(undefined),
|
|
17
|
+
provider: z.enum(['anthropic', 'openai', 'google', 'vertex', 'bedrock']),
|
|
18
|
+
model: z.string().min(1).max(MAX_ID_LENGTH).optional(),
|
|
19
|
+
request_id: z.string().min(1).max(MAX_ID_LENGTH).optional(),
|
|
20
|
+
status: z.number().int(),
|
|
21
|
+
usage: z
|
|
22
|
+
.object({
|
|
23
|
+
input_tokens: tokens,
|
|
24
|
+
cached_input_tokens: tokens,
|
|
25
|
+
cache_creation_input_tokens: tokens,
|
|
26
|
+
output_tokens: tokens,
|
|
27
|
+
reasoning_output_tokens: tokens,
|
|
28
|
+
total_tokens: tokens
|
|
29
|
+
})
|
|
30
|
+
.optional()
|
|
31
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { LlmCallEvent } from '../../events/types/llm-call.types.js';
|
|
3
|
+
import type { spoolRecordSchema } from '../schemas/capture.schema.js';
|
|
4
|
+
/** One line a shim wrote: usage only. Untrusted until the schema has read it. */
|
|
5
|
+
export type SpoolRecord = z.infer<typeof spoolRecordSchema>;
|
|
6
|
+
/** A shell call the session ran: the turn it belongs to and what it is called. */
|
|
7
|
+
export interface LaunchedRun {
|
|
8
|
+
/** The agent that ran it; another agent's hook may be the one to attach its calls. */
|
|
9
|
+
readonly providerId: string;
|
|
10
|
+
readonly surface: string;
|
|
11
|
+
readonly turnId?: string;
|
|
12
|
+
readonly entry: string;
|
|
13
|
+
/** ISO time of the hook before the shell call, which is before the process. */
|
|
14
|
+
readonly at: string;
|
|
15
|
+
}
|
|
16
|
+
/** What the bridge's `llm.call` adds for a captured call; see its `run_entry` comment. */
|
|
17
|
+
export interface CapturedCallEvent extends LlmCallEvent {
|
|
18
|
+
readonly run_entry: string;
|
|
19
|
+
readonly platform?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The interpreters a shell command runs by path (`venv/bin/python -I x.py`, `cd app && .venv/bin/python3 x.py`),
|
|
3
|
+
* resolved against where each runs. A bare `python` is looked up on a PATH this hook cannot see, so it is left out.
|
|
4
|
+
*
|
|
5
|
+
* @param command - The shell command, read in memory only.
|
|
6
|
+
* @param directory - Where it runs.
|
|
7
|
+
* @returns Absolute interpreter paths, possibly none.
|
|
8
|
+
*/
|
|
9
|
+
export declare function pythonInterpreters(command: string, directory: string): string[];
|
|
10
|
+
/**
|
|
11
|
+
* The site-packages folders of the venv an interpreter belongs to, by its `pyvenv.cfg`
|
|
12
|
+
* beside it or one level up. Not resolved through links: a venv's `python` links to the
|
|
13
|
+
* system one, whose site-packages is never ours to write.
|
|
14
|
+
*
|
|
15
|
+
* @param interpreter - The interpreter's absolute path, as the command named it.
|
|
16
|
+
* @returns The folders, real and inside the venv; none for an interpreter outside one.
|
|
17
|
+
*/
|
|
18
|
+
export declare function venvSitePackages(interpreter: string): Promise<string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* The one line Python runs from the `.pth` at startup.
|
|
21
|
+
*
|
|
22
|
+
* It acts only when Python ignored the environment (`-I`, `-E`): otherwise PYTHONPATH loads
|
|
23
|
+
* the shim the usual way. And only when the process's environment names the capture folder
|
|
24
|
+
* in PYTHONPATH, which only an agent's environment does: `-I` stops Python from reading the
|
|
25
|
+
* variable, not the process from holding it. The developer running the same venv from their
|
|
26
|
+
* own terminal gets nothing. It loads nothing itself: a one-shot finder answers site's own
|
|
27
|
+
* `import sitecustomize`, which comes after every `.pth`, so the shim runs the developer's
|
|
28
|
+
* `sitecustomize` next on the full `sys.path`. Any fault is swallowed, since site prints a
|
|
29
|
+
* failing `.pth` line, or a failing `sitecustomize`, into the customer's stderr.
|
|
30
|
+
*
|
|
31
|
+
* ponytail: rides on `.pth` import lines. CPython's docs for 3.15 reportedly deprecate them
|
|
32
|
+
* (ignored from 3.18); 3.14 still runs them silently. When they go, a `-I` run on that
|
|
33
|
+
* Python is uncaptured again, and the upgrade is whatever startup hook replaces them.
|
|
34
|
+
*
|
|
35
|
+
* @param shimDir - The capture copy's python folder.
|
|
36
|
+
* @returns The file's contents, or undefined for a path that is not plain ASCII.
|
|
37
|
+
*/
|
|
38
|
+
export declare function venvLoader(shimDir: string): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Leave the loader in the venv of every interpreter a shell command runs by path, so a
|
|
41
|
+
* `python -I` run is captured too. Recorded first, so a file written is always one
|
|
42
|
+
* uninstall can find. Never throws: a venv it cannot write is skipped.
|
|
43
|
+
*
|
|
44
|
+
* @param command - The shell command, read in memory only.
|
|
45
|
+
* @param directory - Where it runs.
|
|
46
|
+
* @param dataDir - The data dir.
|
|
47
|
+
* @param shimDir - The capture copy's python folder.
|
|
48
|
+
* @returns The site-packages folders that now hold the loader.
|
|
49
|
+
*/
|
|
50
|
+
export declare function armVenvLoaders(command: string, directory: string, dataDir: string, shimDir: string): Promise<string[]>;
|
|
51
|
+
/**
|
|
52
|
+
* The site-packages folders Edge has left a loader in, as recorded.
|
|
53
|
+
*
|
|
54
|
+
* @param dataDir - The data dir.
|
|
55
|
+
* @returns The folders, whether or not the loader is still there.
|
|
56
|
+
*/
|
|
57
|
+
export declare function recordedVenvs(dataDir: string): Promise<string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Remove every loader Edge recorded, and its record. A file that no longer carries our
|
|
60
|
+
* mark is the developer's now and stays.
|
|
61
|
+
*
|
|
62
|
+
* @param dataDir - The data dir.
|
|
63
|
+
* @returns The folders a loader was removed from, and those whose loader could not be.
|
|
64
|
+
*/
|
|
65
|
+
export declare function removeVenvLoaders(dataDir: string): Promise<{
|
|
66
|
+
removed: string[];
|
|
67
|
+
left: string[];
|
|
68
|
+
}>;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { debugLog } from '../core/logger.js';
|
|
5
|
+
import { writeFileAtomic } from '../storage/atomic-file.js';
|
|
6
|
+
import { PYTHON_SHIM_FILE, RE_ASCII_PATH, RE_PYTHON, RE_SITE_PACKAGES_PARENT, VENV_CONFIG_FILE, VENV_LOADER_FILE, VENV_LOADER_MARK, VENV_LOADER_MODE, VENV_RECORDS_DIR } from './constants/capture.constants.js';
|
|
7
|
+
import { afterCds, segmentsOf, wordsOf } from './launched-runs.js';
|
|
8
|
+
/**
|
|
9
|
+
* The interpreters a shell command runs by path (`venv/bin/python -I x.py`, `cd app && .venv/bin/python3 x.py`),
|
|
10
|
+
* resolved against where each runs. A bare `python` is looked up on a PATH this hook cannot see, so it is left out.
|
|
11
|
+
*
|
|
12
|
+
* @param command - The shell command, read in memory only.
|
|
13
|
+
* @param directory - Where it runs.
|
|
14
|
+
* @returns Absolute interpreter paths, possibly none.
|
|
15
|
+
*/
|
|
16
|
+
export function pythonInterpreters(command, directory) {
|
|
17
|
+
const segments = segmentsOf(command);
|
|
18
|
+
const found = new Set();
|
|
19
|
+
for (const [index, segment] of segments.entries()) {
|
|
20
|
+
const program = wordsOf(segment)[0];
|
|
21
|
+
if (program === undefined || !program.includes('/') || !RE_PYTHON.test(path.basename(program)))
|
|
22
|
+
continue;
|
|
23
|
+
found.add(path.resolve(afterCds(segments, index, directory), program));
|
|
24
|
+
}
|
|
25
|
+
return [...found];
|
|
26
|
+
}
|
|
27
|
+
async function isFile(file) {
|
|
28
|
+
return (await fs.stat(file).catch(() => undefined))?.isFile() ?? false;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The site-packages folders of the venv an interpreter belongs to, by its `pyvenv.cfg`
|
|
32
|
+
* beside it or one level up. Not resolved through links: a venv's `python` links to the
|
|
33
|
+
* system one, whose site-packages is never ours to write.
|
|
34
|
+
*
|
|
35
|
+
* @param interpreter - The interpreter's absolute path, as the command named it.
|
|
36
|
+
* @returns The folders, real and inside the venv; none for an interpreter outside one.
|
|
37
|
+
*/
|
|
38
|
+
export async function venvSitePackages(interpreter) {
|
|
39
|
+
const bin = path.dirname(interpreter);
|
|
40
|
+
const candidates = [bin, path.dirname(bin)];
|
|
41
|
+
let root;
|
|
42
|
+
for (const candidate of candidates) {
|
|
43
|
+
if (await isFile(path.join(candidate, VENV_CONFIG_FILE))) {
|
|
44
|
+
root = candidate;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (root === undefined)
|
|
49
|
+
return [];
|
|
50
|
+
const realRoot = await fs.realpath(root);
|
|
51
|
+
const versions = await fs.readdir(path.join(root, 'lib')).catch(() => []);
|
|
52
|
+
const folders = [];
|
|
53
|
+
for (const version of versions) {
|
|
54
|
+
if (!RE_SITE_PACKAGES_PARENT.test(version))
|
|
55
|
+
continue;
|
|
56
|
+
const folder = path.join(root, 'lib', version, 'site-packages');
|
|
57
|
+
const real = await fs.realpath(folder).catch(() => undefined);
|
|
58
|
+
// Never outside the venv: a site-packages linked elsewhere is someone else's.
|
|
59
|
+
if (real !== undefined && real.startsWith(realRoot + path.sep) && (await fs.stat(real)).isDirectory())
|
|
60
|
+
folders.push(real);
|
|
61
|
+
}
|
|
62
|
+
return folders;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The one line Python runs from the `.pth` at startup.
|
|
66
|
+
*
|
|
67
|
+
* It acts only when Python ignored the environment (`-I`, `-E`): otherwise PYTHONPATH loads
|
|
68
|
+
* the shim the usual way. And only when the process's environment names the capture folder
|
|
69
|
+
* in PYTHONPATH, which only an agent's environment does: `-I` stops Python from reading the
|
|
70
|
+
* variable, not the process from holding it. The developer running the same venv from their
|
|
71
|
+
* own terminal gets nothing. It loads nothing itself: a one-shot finder answers site's own
|
|
72
|
+
* `import sitecustomize`, which comes after every `.pth`, so the shim runs the developer's
|
|
73
|
+
* `sitecustomize` next on the full `sys.path`. Any fault is swallowed, since site prints a
|
|
74
|
+
* failing `.pth` line, or a failing `sitecustomize`, into the customer's stderr.
|
|
75
|
+
*
|
|
76
|
+
* ponytail: rides on `.pth` import lines. CPython's docs for 3.15 reportedly deprecate them
|
|
77
|
+
* (ignored from 3.18); 3.14 still runs them silently. When they go, a `-I` run on that
|
|
78
|
+
* Python is uncaptured again, and the upgrade is whatever startup hook replaces them.
|
|
79
|
+
*
|
|
80
|
+
* @param shimDir - The capture copy's python folder.
|
|
81
|
+
* @returns The file's contents, or undefined for a path that is not plain ASCII.
|
|
82
|
+
*/
|
|
83
|
+
export function venvLoader(shimDir) {
|
|
84
|
+
// ponytail: a non-ASCII data dir gets no loader; JSON's \u escapes split astral characters in Python.
|
|
85
|
+
if (!RE_ASCII_PATH.test(shimDir))
|
|
86
|
+
return undefined;
|
|
87
|
+
const code = [
|
|
88
|
+
'try:',
|
|
89
|
+
` d = ${JSON.stringify(shimDir)}`,
|
|
90
|
+
` f = os.path.join(d, ${JSON.stringify(PYTHON_SHIM_FILE)})`,
|
|
91
|
+
" if sys.flags.ignore_environment and d in os.environ.get('PYTHONPATH', '').split(os.pathsep) and os.path.isfile(f):",
|
|
92
|
+
' import importlib.util',
|
|
93
|
+
' class AgentWatchCapture:',
|
|
94
|
+
' def find_spec(self, name, path=None, target=None):',
|
|
95
|
+
" if name != 'sitecustomize':",
|
|
96
|
+
' return None',
|
|
97
|
+
' try:',
|
|
98
|
+
' sys.meta_path.remove(self)',
|
|
99
|
+
" return importlib.util.spec_from_file_location('sitecustomize', f)",
|
|
100
|
+
' except Exception:',
|
|
101
|
+
' return None',
|
|
102
|
+
' sys.meta_path.insert(0, AgentWatchCapture())',
|
|
103
|
+
'except Exception:',
|
|
104
|
+
' pass',
|
|
105
|
+
''
|
|
106
|
+
].join('\n');
|
|
107
|
+
// Its own globals: site runs the line inside a function, whose locals a class's methods cannot see.
|
|
108
|
+
return `${VENV_LOADER_MARK}\nimport os, sys; exec(${JSON.stringify(code)}, {'os': os, 'sys': sys})\n`;
|
|
109
|
+
}
|
|
110
|
+
function recordFile(dataDir, folder) {
|
|
111
|
+
return path.join(dataDir, VENV_RECORDS_DIR, `${createHash('sha256').update(folder).digest('hex').slice(0, 16)}.txt`);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Leave the loader in the venv of every interpreter a shell command runs by path, so a
|
|
115
|
+
* `python -I` run is captured too. Recorded first, so a file written is always one
|
|
116
|
+
* uninstall can find. Never throws: a venv it cannot write is skipped.
|
|
117
|
+
*
|
|
118
|
+
* @param command - The shell command, read in memory only.
|
|
119
|
+
* @param directory - Where it runs.
|
|
120
|
+
* @param dataDir - The data dir.
|
|
121
|
+
* @param shimDir - The capture copy's python folder.
|
|
122
|
+
* @returns The site-packages folders that now hold the loader.
|
|
123
|
+
*/
|
|
124
|
+
export async function armVenvLoaders(command, directory, dataDir, shimDir) {
|
|
125
|
+
const contents = venvLoader(shimDir);
|
|
126
|
+
if (contents === undefined || !(await isFile(path.join(shimDir, PYTHON_SHIM_FILE))))
|
|
127
|
+
return [];
|
|
128
|
+
const armed = [];
|
|
129
|
+
for (const interpreter of pythonInterpreters(command, directory)) {
|
|
130
|
+
for (const folder of await venvSitePackages(interpreter).catch(() => [])) {
|
|
131
|
+
const file = path.join(folder, VENV_LOADER_FILE);
|
|
132
|
+
try {
|
|
133
|
+
const current = await fs.readFile(file, 'utf8').catch(() => undefined);
|
|
134
|
+
// A file of that name Edge did not write is the developer's: left, and not armed.
|
|
135
|
+
if (current !== undefined && !current.startsWith(VENV_LOADER_MARK))
|
|
136
|
+
continue;
|
|
137
|
+
const record = recordFile(dataDir, folder);
|
|
138
|
+
// Recorded even when the loader is already there: a purge can take the record and leave the file.
|
|
139
|
+
if (current !== contents || !(await isFile(record)))
|
|
140
|
+
await writeFileAtomic(record, folder, 0o600);
|
|
141
|
+
if (current !== contents)
|
|
142
|
+
await writeFileAtomic(file, contents, VENV_LOADER_MODE);
|
|
143
|
+
armed.push(folder);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// A fixed sentence: the error could quote a path.
|
|
147
|
+
debugLog('capture: could not write a venv loader; that venv is skipped');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return armed;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The site-packages folders Edge has left a loader in, as recorded.
|
|
155
|
+
*
|
|
156
|
+
* @param dataDir - The data dir.
|
|
157
|
+
* @returns The folders, whether or not the loader is still there.
|
|
158
|
+
*/
|
|
159
|
+
export async function recordedVenvs(dataDir) {
|
|
160
|
+
const dir = path.join(dataDir, VENV_RECORDS_DIR);
|
|
161
|
+
const names = await fs.readdir(dir).catch(() => []);
|
|
162
|
+
const folders = await Promise.all(names.map((name) => fs.readFile(path.join(dir, name), 'utf8').catch(() => '')));
|
|
163
|
+
return folders.filter((folder) => path.isAbsolute(folder));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Remove every loader Edge recorded, and its record. A file that no longer carries our
|
|
167
|
+
* mark is the developer's now and stays.
|
|
168
|
+
*
|
|
169
|
+
* @param dataDir - The data dir.
|
|
170
|
+
* @returns The folders a loader was removed from, and those whose loader could not be.
|
|
171
|
+
*/
|
|
172
|
+
export async function removeVenvLoaders(dataDir) {
|
|
173
|
+
const removed = [];
|
|
174
|
+
const left = [];
|
|
175
|
+
for (const folder of await recordedVenvs(dataDir)) {
|
|
176
|
+
const file = path.join(folder, VENV_LOADER_FILE);
|
|
177
|
+
const contents = await fs.readFile(file, 'utf8').catch(() => undefined);
|
|
178
|
+
const ours = contents?.startsWith(VENV_LOADER_MARK) === true;
|
|
179
|
+
// A loader it could not remove keeps its record, for the next uninstall.
|
|
180
|
+
if (ours && !(await fs.rm(file).then(() => true, () => false))) {
|
|
181
|
+
left.push(folder);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (ours)
|
|
185
|
+
removed.push(folder);
|
|
186
|
+
await fs.rm(recordFile(dataDir, folder), { force: true }).catch(() => undefined);
|
|
187
|
+
}
|
|
188
|
+
return { removed, left };
|
|
189
|
+
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* entirely.
|
|
7
7
|
*/
|
|
8
8
|
export declare const VALUE_FLAGS: ReadonlySet<string>;
|
|
9
|
+
/** The commands that take `--agent`; the help names the same three. Any other command refuses it. */
|
|
10
|
+
export declare const AGENT_COMMANDS: ReadonlySet<string>;
|
|
9
11
|
export declare const FLAG_PREFIX = "--";
|
|
10
12
|
/** `--enrollment-code -`: read the code from stdin. The only value the flag takes. */
|
|
11
13
|
export declare const ENROLLMENT_CODE_STDIN = "-";
|
|
@@ -42,11 +44,6 @@ export declare const MAX_STDIN_BYTES: number;
|
|
|
42
44
|
export declare const STDIN_TIMEOUT_MS = 5000;
|
|
43
45
|
/** Node major version the runtime requires. */
|
|
44
46
|
export declare const MIN_NODE_MAJOR = 20;
|
|
45
|
-
/**
|
|
46
|
-
* prompt_id (== OTel prompt.id) appeared in this Claude Code release; older
|
|
47
|
-
* versions fall back to session-scoped turn tracking with an empty turn_id.
|
|
48
|
-
*/
|
|
49
|
-
export declare const CLAUDE_MIN_VERSION_FOR_PROMPT_ID = "2.1.196";
|
|
50
47
|
/**
|
|
51
48
|
* Name of the one check an administrator's install script greps for: it carries
|
|
52
49
|
* all four backend states — accepted, credential rejected, unreachable, and not
|
|
@@ -57,8 +54,13 @@ export declare const BACKEND_CONNECTIVITY_CHECK = "backend connectivity";
|
|
|
57
54
|
export declare const BACKEND_PROBE_TIMEOUT_MS = 4000;
|
|
58
55
|
/** What the gateway answers an authenticated `{ events: [] }`: it checks the credential first. */
|
|
59
56
|
export declare const EMPTY_BATCH_REFUSED_STATUS = 422;
|
|
60
|
-
export declare const CLAUDE_VERSION_TIMEOUT_MS = 5000;
|
|
61
57
|
export declare const GIT_VERSION_TIMEOUT_MS = 2000;
|
|
58
|
+
/**
|
|
59
|
+
* The installed hook command's `--version` probe. A healthy one took up to
|
|
60
|
+
* 2.7 s on a loaded Mac, where `node -e 0` alone took about 1 s: only a hung
|
|
61
|
+
* install should fail it. Probed once per doctor run, not once per agent.
|
|
62
|
+
*/
|
|
63
|
+
export declare const HOOK_VERSION_TIMEOUT_MS = 10000;
|
|
62
64
|
/** Longer than the hook path's budget: status is not on anyone's critical path. */
|
|
63
65
|
export declare const STATUS_SEND_TIMEOUT_MS = 3000;
|
|
64
66
|
/** Backlog age past which `doctor` starts warning. */
|
|
@@ -106,3 +108,18 @@ export declare const BROWSER_OPENERS: Partial<Record<NodeJS.Platform, readonly s
|
|
|
106
108
|
export declare const DEFAULT_BROWSER_OPENER: readonly string[];
|
|
107
109
|
/** The only link schemes setup hands to a browser opener: the gateway chose the link. */
|
|
108
110
|
export declare const OPENABLE_PROTOCOLS: ReadonlySet<string>;
|
|
111
|
+
/** What npm 11 prints in place of anything that looks like a secret, a UUID included. */
|
|
112
|
+
export declare const NPM_REDACTION = "***";
|
|
113
|
+
/**
|
|
114
|
+
* A UUID, which npm masks in a path because it looks like a legacy npm token.
|
|
115
|
+
* npm also masks `npm_` tokens and URL passwords; those are not found again and
|
|
116
|
+
* get the manual message. Global flag: use with `replace` only, never `test`.
|
|
117
|
+
*/
|
|
118
|
+
export declare const RE_UUID: RegExp;
|
|
119
|
+
/** Both separators: on Windows npm may print either. */
|
|
120
|
+
export declare const RE_PATH_SEPARATORS: RegExp;
|
|
121
|
+
/**
|
|
122
|
+
* Set by npm in the environment of what `npx` runs: the global prefix in full,
|
|
123
|
+
* never masked the way npm's printed output is.
|
|
124
|
+
*/
|
|
125
|
+
export declare const NPM_GLOBAL_PREFIX_VAR = "npm_config_global_prefix";
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* itself into a boolean — which is how `--otel none` once ignored the selection
|
|
6
6
|
* entirely.
|
|
7
7
|
*/
|
|
8
|
-
export const VALUE_FLAGS = new Set(['agent', 'endpoint', 'token', 'enrollment-code', 'developer-email', 'developer-name', 'otel', 'root']);
|
|
8
|
+
export const VALUE_FLAGS = new Set(['agent', 'endpoint', 'token', 'enrollment-code', 'developer-email', 'developer-name', 'otel', 'root', 'replay-days']);
|
|
9
|
+
/** The commands that take `--agent`; the help names the same three. Any other command refuses it. */
|
|
10
|
+
export const AGENT_COMMANDS = new Set(['setup', 'uninstall', 'hook']);
|
|
9
11
|
export const FLAG_PREFIX = '--';
|
|
10
12
|
/** `--enrollment-code -`: read the code from stdin. The only value the flag takes. */
|
|
11
13
|
export const ENROLLMENT_CODE_STDIN = '-';
|
|
@@ -42,11 +44,6 @@ export const MAX_STDIN_BYTES = 10 * 1024 * 1024;
|
|
|
42
44
|
export const STDIN_TIMEOUT_MS = 5_000;
|
|
43
45
|
/** Node major version the runtime requires. */
|
|
44
46
|
export const MIN_NODE_MAJOR = 20;
|
|
45
|
-
/**
|
|
46
|
-
* prompt_id (== OTel prompt.id) appeared in this Claude Code release; older
|
|
47
|
-
* versions fall back to session-scoped turn tracking with an empty turn_id.
|
|
48
|
-
*/
|
|
49
|
-
export const CLAUDE_MIN_VERSION_FOR_PROMPT_ID = '2.1.196';
|
|
50
47
|
/**
|
|
51
48
|
* Name of the one check an administrator's install script greps for: it carries
|
|
52
49
|
* all four backend states — accepted, credential rejected, unreachable, and not
|
|
@@ -57,8 +54,13 @@ export const BACKEND_CONNECTIVITY_CHECK = 'backend connectivity';
|
|
|
57
54
|
export const BACKEND_PROBE_TIMEOUT_MS = 4_000;
|
|
58
55
|
/** What the gateway answers an authenticated `{ events: [] }`: it checks the credential first. */
|
|
59
56
|
export const EMPTY_BATCH_REFUSED_STATUS = 422;
|
|
60
|
-
export const CLAUDE_VERSION_TIMEOUT_MS = 5_000;
|
|
61
57
|
export const GIT_VERSION_TIMEOUT_MS = 2_000;
|
|
58
|
+
/**
|
|
59
|
+
* The installed hook command's `--version` probe. A healthy one took up to
|
|
60
|
+
* 2.7 s on a loaded Mac, where `node -e 0` alone took about 1 s: only a hung
|
|
61
|
+
* install should fail it. Probed once per doctor run, not once per agent.
|
|
62
|
+
*/
|
|
63
|
+
export const HOOK_VERSION_TIMEOUT_MS = 10_000;
|
|
62
64
|
/** Longer than the hook path's budget: status is not on anyone's critical path. */
|
|
63
65
|
export const STATUS_SEND_TIMEOUT_MS = 3_000;
|
|
64
66
|
/** Backlog age past which `doctor` starts warning. */
|
|
@@ -109,3 +111,18 @@ export const BROWSER_OPENERS = {
|
|
|
109
111
|
export const DEFAULT_BROWSER_OPENER = ['xdg-open'];
|
|
110
112
|
/** The only link schemes setup hands to a browser opener: the gateway chose the link. */
|
|
111
113
|
export const OPENABLE_PROTOCOLS = new Set(['http:', 'https:']);
|
|
114
|
+
/** What npm 11 prints in place of anything that looks like a secret, a UUID included. */
|
|
115
|
+
export const NPM_REDACTION = '***';
|
|
116
|
+
/**
|
|
117
|
+
* A UUID, which npm masks in a path because it looks like a legacy npm token.
|
|
118
|
+
* npm also masks `npm_` tokens and URL passwords; those are not found again and
|
|
119
|
+
* get the manual message. Global flag: use with `replace` only, never `test`.
|
|
120
|
+
*/
|
|
121
|
+
export const RE_UUID = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
122
|
+
/** Both separators: on Windows npm may print either. */
|
|
123
|
+
export const RE_PATH_SEPARATORS = /[\\/]/;
|
|
124
|
+
/**
|
|
125
|
+
* Set by npm in the environment of what `npx` runs: the global prefix in full,
|
|
126
|
+
* never masked the way npm's printed output is.
|
|
127
|
+
*/
|
|
128
|
+
export const NPM_GLOBAL_PREFIX_VAR = 'npm_config_global_prefix';
|
package/dist/cli/context.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Env } from '../core/types/core.types.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { EventQueue } from '../transport/queue.js';
|
|
2
|
+
import type { EventQueue } from '../transport/queue.js';
|
|
3
|
+
import type { IdentityDelivery } from '../transport/types/delivery-flow.types.js';
|
|
5
4
|
import type { EventTransport } from '../transport/types/transport.types.js';
|
|
6
5
|
import type { CliContext } from './types/cli.types.js';
|
|
7
6
|
export type { CliContext } from './types/cli.types.js';
|
|
@@ -12,9 +11,10 @@ export type { CliContext } from './types/cli.types.js';
|
|
|
12
11
|
* commands then work from this value instead of each reaching for the disk.
|
|
13
12
|
*
|
|
14
13
|
* @param env - Ambient environment.
|
|
14
|
+
* @param identityAt - A root to select explicitly, null for the machine, or the command cwd when omitted.
|
|
15
15
|
* @returns The context.
|
|
16
16
|
*/
|
|
17
|
-
export declare function buildCliContext(env: Env): Promise<CliContext>;
|
|
17
|
+
export declare function buildCliContext(env: Env, identityAt?: string | null): Promise<CliContext>;
|
|
18
18
|
/**
|
|
19
19
|
* The offline queue for this context.
|
|
20
20
|
*
|
|
@@ -28,31 +28,21 @@ export declare function buildCliContext(env: Env): Promise<CliContext>;
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function buildQueue(context: CliContext): Promise<EventQueue>;
|
|
30
30
|
/**
|
|
31
|
-
* Open
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @returns A queue handle; construction performs no filesystem writes.
|
|
35
|
-
*/
|
|
36
|
-
export declare function openIdentityQueue(context: CliContext): EventQueue;
|
|
37
|
-
/**
|
|
38
|
-
* The delivery-loss tally for this context.
|
|
39
|
-
*
|
|
40
|
-
* @param context - Resolved CLI context.
|
|
41
|
-
* @returns The tally.
|
|
42
|
-
*/
|
|
43
|
-
export declare function buildDeliveryStats(context: CliContext): DeliveryStats;
|
|
44
|
-
/**
|
|
45
|
-
* The standing credential refusal for this context.
|
|
31
|
+
* Open this context's identity delivery state (queue partition, loss tally,
|
|
32
|
+
* cooldown, auth block) without adopting or moving legacy records. Setup can
|
|
33
|
+
* inspect ownership and ask for consent without changing the queue.
|
|
46
34
|
*
|
|
47
|
-
* @param context - Resolved
|
|
48
|
-
* @returns The
|
|
35
|
+
* @param context - Resolved identity and storage paths.
|
|
36
|
+
* @returns The handles; construction performs no filesystem writes.
|
|
49
37
|
*/
|
|
50
|
-
export declare function
|
|
38
|
+
export declare function openIdentityDelivery(context: CliContext): IdentityDelivery;
|
|
51
39
|
/**
|
|
52
40
|
* The transport for this context, when a backend is configured.
|
|
53
41
|
*
|
|
54
42
|
* @param context - Resolved CLI context.
|
|
55
43
|
* @param timeoutMs - Override for the configured send timeout.
|
|
44
|
+
* @param bearer - What to authenticate with, from `resolveContextBearer`; none
|
|
45
|
+
* while a credential exists makes the transport defer every send.
|
|
56
46
|
* @returns The transport, or undefined before setup has run.
|
|
57
47
|
*/
|
|
58
48
|
export declare function buildTransport(context: CliContext, timeoutMs?: number, bearer?: string): EventTransport | undefined;
|
|
@@ -80,3 +70,10 @@ export declare function resolveContextBearer(context: CliContext, timeoutMs: num
|
|
|
80
70
|
* @returns The command line.
|
|
81
71
|
*/
|
|
82
72
|
export declare function buildHookCommand(env: Env, providerId: string, scriptPath?: string | undefined): string;
|
|
73
|
+
/**
|
|
74
|
+
* Quote a path for embedding in a shell-executed command.
|
|
75
|
+
*
|
|
76
|
+
* @param value - The path.
|
|
77
|
+
* @returns The value, quoted only when it needs to be.
|
|
78
|
+
*/
|
|
79
|
+
export declare function quoteArg(value: string): string;
|