@agent-watch-ai/edge 0.2.5 → 0.3.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 +512 -0
- package/README.md +217 -96
- package/SECURITY.md +69 -0
- package/dist/billing/session-billing.d.ts +19 -0
- package/dist/billing/session-billing.js +52 -0
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.js +20 -0
- package/dist/cli/constants/cli.constants.d.ts +50 -4
- package/dist/cli/constants/cli.constants.js +54 -5
- package/dist/cli/context.d.ts +33 -2
- package/dist/cli/context.js +84 -14
- package/dist/cli/doctor.js +309 -32
- package/dist/cli/hook-check.d.ts +23 -0
- package/dist/cli/hook-check.js +114 -0
- package/dist/cli/hook.js +118 -7
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/misc.d.ts +11 -0
- package/dist/cli/misc.js +80 -4
- package/dist/cli/npx-install.d.ts +37 -0
- package/dist/cli/npx-install.js +79 -0
- package/dist/cli/open-browser.d.ts +39 -0
- package/dist/cli/open-browser.js +62 -0
- package/dist/cli/setup.d.ts +17 -8
- package/dist/cli/setup.js +439 -98
- package/dist/cli/status.js +82 -13
- package/dist/cli/toggle.d.ts +9 -0
- package/dist/cli/toggle.js +113 -0
- package/dist/cli/types/cli.types.d.ts +37 -3
- package/dist/cli/ui.d.ts +7 -0
- package/dist/cli/ui.js +10 -1
- package/dist/cli/uninstall.js +39 -2
- package/dist/cli/update.d.ts +17 -0
- package/dist/cli/update.js +76 -0
- package/dist/cli.js +100 -13
- package/dist/config/config-store.d.ts +57 -0
- package/dist/config/config-store.js +250 -12
- package/dist/config/config.d.ts +53 -6
- package/dist/config/config.js +66 -6
- package/dist/config/constants/config.constants.d.ts +113 -6
- package/dist/config/constants/config.constants.js +126 -8
- package/dist/config/destination.d.ts +24 -0
- package/dist/config/destination.js +33 -0
- package/dist/config/index.d.ts +7 -4
- package/dist/config/index.js +5 -3
- package/dist/config/repo-config.d.ts +11 -7
- package/dist/config/repo-config.js +64 -15
- package/dist/config/root-config.d.ts +72 -0
- package/dist/config/root-config.js +170 -0
- package/dist/config/schemas/config.schema.d.ts +721 -84
- package/dist/config/schemas/config.schema.js +388 -15
- package/dist/config/types/config.types.d.ts +15 -1
- package/dist/config/types/destination.types.d.ts +8 -0
- package/dist/core/async.d.ts +36 -0
- package/dist/core/async.js +68 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/object.d.ts +5 -0
- package/dist/core/object.js +9 -4
- package/dist/core/pipe.d.ts +0 -13
- package/dist/core/pipe.js +1 -9
- package/dist/core/types/core.types.d.ts +9 -0
- package/dist/core/types/core.types.js +0 -3
- package/dist/core/which.d.ts +14 -0
- package/dist/core/which.js +43 -3
- package/dist/credentials/budget.d.ts +9 -0
- package/dist/credentials/budget.js +16 -0
- package/dist/credentials/command-runner.d.ts +16 -0
- package/dist/credentials/command-runner.js +37 -0
- package/dist/credentials/constants/credentials.constants.d.ts +111 -0
- package/dist/credentials/constants/credentials.constants.js +112 -0
- package/dist/credentials/credential-status.d.ts +14 -0
- package/dist/credentials/credential-status.js +34 -0
- package/dist/credentials/credentials.d.ts +72 -0
- package/dist/credentials/credentials.js +253 -0
- package/dist/credentials/device-api.d.ts +64 -0
- package/dist/credentials/device-api.js +150 -0
- package/dist/credentials/device-state.d.ts +31 -0
- package/dist/credentials/device-state.js +51 -0
- package/dist/credentials/identity.d.ts +62 -0
- package/dist/credentials/identity.js +90 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/migration.d.ts +46 -0
- package/dist/credentials/migration.js +164 -0
- package/dist/credentials/schemas/device-api.schema.d.ts +77 -0
- package/dist/credentials/schemas/device-api.schema.js +33 -0
- package/dist/credentials/schemas/device-state.schema.d.ts +51 -0
- package/dist/credentials/schemas/device-state.schema.js +20 -0
- package/dist/credentials/secret-store.d.ts +54 -0
- package/dist/credentials/secret-store.js +217 -0
- package/dist/credentials/sign-in.d.ts +18 -0
- package/dist/credentials/sign-in.js +86 -0
- package/dist/credentials/token-refresher.d.ts +39 -0
- package/dist/credentials/token-refresher.js +185 -0
- package/dist/credentials/types/credentials.types.d.ts +195 -0
- package/dist/credentials/types/credentials.types.js +1 -0
- package/dist/enforcement/constants/enforcement.constants.d.ts +47 -1
- package/dist/enforcement/constants/enforcement.constants.js +56 -0
- package/dist/enforcement/decision-cache.d.ts +20 -1
- package/dist/enforcement/decision-cache.js +65 -2
- package/dist/enforcement/decision-client.d.ts +9 -8
- package/dist/enforcement/decision-client.js +62 -16
- package/dist/enforcement/enforcement.d.ts +23 -2
- package/dist/enforcement/enforcement.js +103 -15
- package/dist/enforcement/index.d.ts +4 -3
- package/dist/enforcement/index.js +3 -2
- package/dist/enforcement/types/enforcement.types.d.ts +64 -0
- package/dist/enrollment/constants/enrollment.constants.d.ts +2 -6
- package/dist/enrollment/constants/enrollment.constants.js +2 -6
- package/dist/enrollment/enrollment.d.ts +16 -0
- package/dist/enrollment/enrollment.js +54 -0
- package/dist/enrollment/index.d.ts +3 -7
- package/dist/enrollment/index.js +1 -1
- package/dist/enrollment/types/enrollment.types.d.ts +9 -13
- package/dist/events/constants/enrich.constants.d.ts +15 -0
- package/dist/events/constants/enrich.constants.js +15 -0
- package/dist/events/constants/events.constants.d.ts +6 -2
- package/dist/events/constants/events.constants.js +5 -1
- package/dist/events/enrich.js +92 -10
- package/dist/events/event-id.d.ts +0 -8
- package/dist/events/event-id.js +0 -10
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/product-event.d.ts +9 -6
- package/dist/events/types/repo-snapshot.types.d.ts +7 -0
- package/dist/events/types/session-billing.types.d.ts +16 -0
- package/dist/events/types/session-billing.types.js +1 -0
- package/dist/feature/constants/feature.constants.d.ts +7 -0
- package/dist/feature/constants/feature.constants.js +7 -0
- package/dist/feature/index.d.ts +1 -1
- package/dist/feature/index.js +1 -1
- package/dist/feature/ticket-candidates.d.ts +14 -0
- package/dist/feature/ticket-candidates.js +26 -8
- package/dist/git/blob-hash.d.ts +21 -0
- package/dist/git/blob-hash.js +69 -0
- package/dist/git/checkout-root.d.ts +27 -0
- package/dist/git/checkout-root.js +75 -0
- package/dist/git/constants/git.constants.d.ts +160 -0
- package/dist/git/constants/git.constants.js +181 -0
- package/dist/git/fingerprint.d.ts +74 -0
- package/dist/git/fingerprint.js +219 -0
- package/dist/git/gate-checkout.d.ts +44 -0
- package/dist/git/gate-checkout.js +201 -0
- package/dist/git/git-context.d.ts +45 -0
- package/dist/git/git-context.js +61 -3
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +2 -1
- package/dist/git/manifest-repository.d.ts +13 -0
- package/dist/git/manifest-repository.js +92 -0
- package/dist/git/repo-snapshot.d.ts +29 -3
- package/dist/git/repo-snapshot.js +110 -7
- package/dist/git/repository-root.d.ts +39 -0
- package/dist/git/repository-root.js +131 -0
- package/dist/git/types/git.types.d.ts +55 -0
- package/dist/git/types/repository-root.types.d.ts +11 -0
- package/dist/git/types/repository-root.types.js +1 -0
- package/dist/git/types/snapshot.types.d.ts +9 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +7 -0
- package/dist/pipeline/constants/pipeline.constants.js +7 -0
- package/dist/pipeline/hook-pipeline.js +360 -32
- package/dist/pipeline/types/pipeline.types.d.ts +39 -4
- package/dist/privacy/constants/privacy.constants.js +15 -1
- package/dist/privacy/index.d.ts +1 -0
- package/dist/privacy/index.js +1 -0
- package/dist/privacy/product-capture.d.ts +12 -0
- package/dist/privacy/product-capture.js +73 -0
- package/dist/privacy/sanitizer.d.ts +21 -3
- package/dist/privacy/sanitizer.js +52 -8
- package/dist/process/ancestors.d.ts +39 -0
- package/dist/process/ancestors.js +121 -0
- package/dist/process/constants/process.constants.d.ts +34 -0
- package/dist/process/constants/process.constants.js +34 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +2 -0
- package/dist/process/types/process.types.d.ts +23 -0
- package/dist/process/types/process.types.js +1 -0
- package/dist/providers/antigravity/antigravity.adapter.d.ts +12 -1
- package/dist/providers/antigravity/antigravity.adapter.js +21 -3
- package/dist/providers/antigravity/antigravity.detect.d.ts +0 -9
- package/dist/providers/antigravity/antigravity.detect.js +1 -1
- package/dist/providers/antigravity/antigravity.provider.js +3 -2
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +2 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +2 -0
- package/dist/providers/claude/claude.adapter.d.ts +11 -1
- package/dist/providers/claude/claude.adapter.js +26 -5
- package/dist/providers/claude/claude.otel.d.ts +32 -18
- package/dist/providers/claude/claude.otel.js +81 -6
- package/dist/providers/claude/claude.provider.js +5 -2
- package/dist/providers/claude/constants/claude.constants.d.ts +2 -0
- package/dist/providers/claude/constants/claude.constants.js +2 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +4 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +8 -0
- package/dist/providers/codex/codex.adapter.d.ts +15 -1
- package/dist/providers/codex/codex.adapter.js +29 -5
- package/dist/providers/codex/codex.otel.d.ts +24 -2
- package/dist/providers/codex/codex.otel.js +147 -30
- package/dist/providers/codex/codex.provider.js +5 -2
- package/dist/providers/codex/constants/codex.constants.d.ts +2 -0
- package/dist/providers/codex/constants/codex.constants.js +16 -0
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +5 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +5 -0
- package/dist/providers/constants/provider.constants.d.ts +0 -3
- package/dist/providers/constants/provider.constants.js +0 -3
- package/dist/providers/cursor/constants/cursor.constants.d.ts +7 -0
- package/dist/providers/cursor/constants/cursor.constants.js +7 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
- package/dist/providers/cursor/cursor.adapter.js +52 -3
- package/dist/providers/cursor/cursor.detect.d.ts +0 -7
- package/dist/providers/cursor/cursor.detect.js +1 -1
- package/dist/providers/cursor/cursor.provider.js +5 -2
- package/dist/providers/gemini/constants/gemini.constants.d.ts +9 -0
- package/dist/providers/gemini/constants/gemini.constants.js +9 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +3 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +3 -0
- package/dist/providers/gemini/gemini.adapter.d.ts +14 -1
- package/dist/providers/gemini/gemini.adapter.js +25 -5
- package/dist/providers/gemini/gemini.detect.d.ts +0 -7
- package/dist/providers/gemini/gemini.detect.js +1 -1
- package/dist/providers/gemini/gemini.otel.d.ts +19 -20
- package/dist/providers/gemini/gemini.otel.js +121 -17
- package/dist/providers/gemini/gemini.provider.js +2 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/loaders.d.ts +10 -0
- package/dist/providers/loaders.js +40 -0
- package/dist/providers/provider.d.ts +11 -0
- package/dist/providers/provider.js +1 -1
- package/dist/providers/registry.d.ts +11 -8
- package/dist/providers/registry.js +11 -15
- package/dist/providers/shared/constants/hook-refusal.constants.d.ts +7 -0
- package/dist/providers/shared/constants/hook-refusal.constants.js +7 -0
- package/dist/providers/shared/constants/shell-directories.constants.d.ts +30 -0
- package/dist/providers/shared/constants/shell-directories.constants.js +39 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +18 -2
- package/dist/providers/shared/constants/tooling.constants.js +19 -3
- package/dist/providers/shared/event-builder.d.ts +12 -14
- package/dist/providers/shared/event-builder.js +20 -14
- package/dist/providers/shared/exporter-allowlist.d.ts +20 -0
- package/dist/providers/shared/exporter-allowlist.js +49 -0
- package/dist/providers/shared/hook-config.d.ts +2 -21
- package/dist/providers/shared/hook-config.js +5 -4
- package/dist/providers/shared/hook-refusal.d.ts +12 -0
- package/dist/providers/shared/hook-refusal.js +17 -1
- package/dist/providers/shared/install-record.d.ts +12 -2
- package/dist/providers/shared/install-record.js +5 -2
- package/dist/providers/shared/shell-directories.d.ts +24 -0
- package/dist/providers/shared/shell-directories.js +90 -0
- package/dist/providers/shared/tooling.d.ts +12 -1
- package/dist/providers/shared/tooling.js +18 -0
- package/dist/providers/shared/types/adapter.types.d.ts +1 -2
- package/dist/providers/types/provider.types.d.ts +57 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +32 -0
- package/dist/snapshot/constants/snapshot.constants.js +33 -0
- package/dist/snapshot/snapshot-event.js +52 -11
- package/dist/snapshot/snapshot-pipeline.js +1 -1
- package/dist/snapshot/types/snapshot.types.d.ts +2 -0
- package/dist/storage/atomic-file.d.ts +7 -0
- package/dist/storage/atomic-file.js +1 -1
- package/dist/storage/constants/storage.constants.d.ts +17 -0
- package/dist/storage/constants/storage.constants.js +17 -0
- package/dist/storage/disabled.d.ts +13 -0
- package/dist/storage/disabled.js +24 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/paths.js +3 -2
- package/dist/storage/schemas/storage.schema.d.ts +72 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/storage/sweep-marker.d.ts +19 -0
- package/dist/storage/sweep-marker.js +55 -0
- package/dist/storage/types/storage.types.d.ts +2 -0
- package/dist/storage/uninstalled.d.ts +58 -0
- package/dist/storage/uninstalled.js +107 -0
- package/dist/transport/auth-block.d.ts +66 -0
- package/dist/transport/auth-block.js +129 -0
- package/dist/transport/constants/transport.constants.d.ts +82 -3
- package/dist/transport/constants/transport.constants.js +83 -4
- package/dist/transport/cooldown.js +8 -1
- package/dist/transport/delivery.d.ts +14 -6
- package/dist/transport/delivery.js +80 -55
- package/dist/transport/http-transport.d.ts +1 -0
- package/dist/transport/http-transport.js +52 -10
- package/dist/transport/index.d.ts +6 -3
- package/dist/transport/index.js +3 -0
- package/dist/transport/queue-partition.d.ts +91 -0
- package/dist/transport/queue-partition.js +143 -0
- package/dist/transport/queue.d.ts +99 -20
- package/dist/transport/queue.js +210 -69
- package/dist/transport/response-body.d.ts +25 -0
- package/dist/transport/response-body.js +64 -0
- package/dist/transport/send.d.ts +11 -0
- package/dist/transport/send.js +17 -0
- package/dist/transport/types/delivery-flow.types.d.ts +19 -0
- package/dist/transport/types/delivery-flow.types.js +1 -0
- package/dist/transport/types/transport.types.d.ts +45 -0
- package/dist/turns/claude-transcript.d.ts +19 -1
- package/dist/turns/claude-transcript.js +46 -1
- package/dist/turns/codex-originator.d.ts +11 -0
- package/dist/turns/codex-originator.js +31 -0
- package/dist/turns/codex-transcript.d.ts +30 -0
- package/dist/turns/codex-transcript.js +88 -0
- package/dist/turns/constants/turns.constants.d.ts +141 -5
- package/dist/turns/constants/turns.constants.js +155 -5
- package/dist/turns/file-identity.d.ts +27 -0
- package/dist/turns/file-identity.js +48 -0
- package/dist/turns/gemini-transcript.d.ts +30 -0
- package/dist/turns/gemini-transcript.js +96 -0
- package/dist/turns/index.d.ts +3 -3
- package/dist/turns/index.js +1 -1
- package/dist/turns/inherited-checkout.d.ts +54 -0
- package/dist/turns/inherited-checkout.js +155 -0
- package/dist/turns/native-session-titles.d.ts +26 -0
- package/dist/turns/native-session-titles.js +102 -0
- package/dist/turns/transcript.d.ts +3 -2
- package/dist/turns/transcript.js +5 -1
- package/dist/turns/turn-state.d.ts +224 -3
- package/dist/turns/turn-state.js +456 -21
- package/dist/turns/turn-summary.d.ts +1 -14
- package/dist/turns/turn-summary.js +87 -51
- package/dist/turns/turn-tracker.d.ts +21 -2
- package/dist/turns/turn-tracker.js +379 -56
- package/dist/turns/types/transcript.types.d.ts +5 -0
- package/dist/turns/types/turn-state.types.d.ts +116 -5
- package/dist/turns/types/turn-summary.types.d.ts +64 -14
- package/dist/turns/types/turn-tracker.types.d.ts +27 -1
- package/dist/turns/work-checkout.d.ts +65 -0
- package/dist/turns/work-checkout.js +666 -0
- package/dist/untraced/constants/untraced.constants.d.ts +31 -0
- package/dist/untraced/constants/untraced.constants.js +63 -0
- package/dist/untraced/untraced.d.ts +35 -0
- package/dist/untraced/untraced.js +105 -0
- package/dist/update/constants/update.constants.d.ts +18 -0
- package/dist/update/constants/update.constants.js +20 -0
- package/dist/update/update-check.d.ts +52 -0
- package/dist/update/update-check.js +113 -0
- package/docs/AUDIT_PROMPT.md +129 -0
- package/docs/DATA_HANDLING.md +648 -0
- package/docs/ENTERPRISE_DEPLOYMENT.md +179 -0
- package/docs/PERFORMANCE.md +81 -0
- package/package.json +14 -4
- package/dist/enrollment/enrollment-provider.d.ts +0 -5
- package/dist/enrollment/manual-enrollment.d.ts +0 -32
- package/dist/enrollment/manual-enrollment.js +0 -72
- package/example/README.md +0 -43
- package/example/server.mjs +0 -240
- /package/dist/{enrollment/enrollment-provider.js → config/types/destination.types.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patterns the shell-directory reader uses. Every one of them is applied to a
|
|
3
|
+
* command held in memory inside one pipeline stage; see `shell-directories.ts`.
|
|
4
|
+
*/
|
|
5
|
+
/** A heredoc and its body: file content, not the command. */
|
|
6
|
+
export declare const RE_HEREDOC: RegExp;
|
|
7
|
+
/** What a heredoc is replaced with, so the command around it still reads. */
|
|
8
|
+
export declare const HEREDOC_PLACEHOLDER = "<<HEREDOC";
|
|
9
|
+
/** Command separators: each piece is read on its own, in order. */
|
|
10
|
+
export declare const RE_SHELL_SEPARATORS: RegExp;
|
|
11
|
+
/** `cd X` / `pushd X`: X is a directory, and later relative paths resolve against it. */
|
|
12
|
+
export declare const RE_CHANGE_DIRECTORY: RegExp;
|
|
13
|
+
/** Arguments that name a directory outright, relative or not. */
|
|
14
|
+
export declare const RE_DIRECTORY_ARGUMENTS: readonly RegExp[];
|
|
15
|
+
/** A quoted absolute or home-relative path anywhere in the command. */
|
|
16
|
+
export declare const RE_QUOTED_ABSOLUTE: RegExp;
|
|
17
|
+
/** A bare absolute or home-relative path, not glued to a longer word. */
|
|
18
|
+
export declare const RE_BARE_ABSOLUTE: RegExp;
|
|
19
|
+
/** A bare `./` or `../` path. */
|
|
20
|
+
export declare const RE_DOT_RELATIVE: RegExp;
|
|
21
|
+
/** `./x` or `../x`: relative on purpose, so resolved even outside a directory argument. */
|
|
22
|
+
export declare const RE_DOT_PREFIX: RegExp;
|
|
23
|
+
/** Home spelled the three ways a command spells it. */
|
|
24
|
+
export declare const RE_HOME_PREFIX: RegExp;
|
|
25
|
+
/** Anything the shell would still expand: not a path this reader can know. */
|
|
26
|
+
export declare const RE_UNEXPANDED: RegExp;
|
|
27
|
+
/** Surrounding quotes of one argument. */
|
|
28
|
+
export declare const RE_SURROUNDING_QUOTES: RegExp;
|
|
29
|
+
/** Directories one command may name before the rest are ignored: each one costs a walk of `stat`s. */
|
|
30
|
+
export declare const MAX_SHELL_DIRECTORIES = 32;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patterns the shell-directory reader uses. Every one of them is applied to a
|
|
3
|
+
* command held in memory inside one pipeline stage; see `shell-directories.ts`.
|
|
4
|
+
*/
|
|
5
|
+
/** A heredoc and its body: file content, not the command. */
|
|
6
|
+
export const RE_HEREDOC = /<<-?\s*(?:'([^'\n]+)'|"([^"\n]+)"|([\w.-]+))[^\n]*\n[\s\S]*?\n\s*\1\2\3\s*(?=\n|$)/g;
|
|
7
|
+
/** What a heredoc is replaced with, so the command around it still reads. */
|
|
8
|
+
export const HEREDOC_PLACEHOLDER = '<<HEREDOC';
|
|
9
|
+
/** Command separators: each piece is read on its own, in order. */
|
|
10
|
+
export const RE_SHELL_SEPARATORS = /&&|\|\||;|\n/;
|
|
11
|
+
/** One argument: double-quoted, single-quoted, or a bare word (a backslash-escaped space stays inside it). */
|
|
12
|
+
const ARG = String.raw `("[^"]+"|'[^']+'|(?:\\ |[^\s;&|()<>])+)`;
|
|
13
|
+
/** `cd X` / `pushd X`: X is a directory, and later relative paths resolve against it. */
|
|
14
|
+
export const RE_CHANGE_DIRECTORY = new RegExp(String.raw `(?:^|[\s(])(?:cd|pushd)\s+` + ARG, 'g');
|
|
15
|
+
/** Arguments that name a directory outright, relative or not. */
|
|
16
|
+
export const RE_DIRECTORY_ARGUMENTS = [
|
|
17
|
+
// Any global option may come first: `git --no-pager -C X`, `git -c k=v -C X`.
|
|
18
|
+
new RegExp(String.raw `\bgit\s+(?:(?:-c\s+\S+|--?[\w-]+(?:=\S+)?)\s+)*-C\s+` + ARG, 'g'),
|
|
19
|
+
new RegExp(String.raw `--(?:work-tree|git-dir)[= ]` + ARG, 'g'),
|
|
20
|
+
// Only -b, -B and --reason take a value; every other option is a flag, and
|
|
21
|
+
// the first bare word after them is the path.
|
|
22
|
+
new RegExp(String.raw `\bworktree\s+add\s+(?:(?:-[bB]|--reason)\s+(?:"[^"]*"|'[^']*'|\S+)\s+|-\S+\s+)*` + ARG, 'g')
|
|
23
|
+
];
|
|
24
|
+
/** A quoted absolute or home-relative path anywhere in the command. */
|
|
25
|
+
export const RE_QUOTED_ABSOLUTE = /(["'])((?:\/|~\/|\$HOME\/|\$\{HOME\}\/)[^"'\n]+)\1/g;
|
|
26
|
+
/** A bare absolute or home-relative path, not glued to a longer word. */
|
|
27
|
+
export const RE_BARE_ABSOLUTE = /(?<![\w/.$"'-])((?:\/|~\/|\$HOME\/|\$\{HOME\}\/)(?:\\ |[^\s"';|&()<>])+)/g;
|
|
28
|
+
/** A bare `./` or `../` path. */
|
|
29
|
+
export const RE_DOT_RELATIVE = /(?<![\w/.-])(\.\.?\/(?:\\ |[^\s"';|&()<>])+)/g;
|
|
30
|
+
/** `./x` or `../x`: relative on purpose, so resolved even outside a directory argument. */
|
|
31
|
+
export const RE_DOT_PREFIX = /^\.\.?\//;
|
|
32
|
+
/** Home spelled the three ways a command spells it. */
|
|
33
|
+
export const RE_HOME_PREFIX = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/;
|
|
34
|
+
/** Anything the shell would still expand: not a path this reader can know. */
|
|
35
|
+
export const RE_UNEXPANDED = /[$`*?[\]{}]/;
|
|
36
|
+
/** Surrounding quotes of one argument. */
|
|
37
|
+
export const RE_SURROUNDING_QUOTES = /^["']|["']$/g;
|
|
38
|
+
/** Directories one command may name before the rest are ignored: each one costs a walk of `stat`s. */
|
|
39
|
+
export const MAX_SHELL_DIRECTORIES = 32;
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
* Tool-name vocabularies, as O(1) sets.
|
|
3
3
|
*
|
|
4
4
|
* `run_command`, `edit_file` and `write_to_file` are Antigravity's names, read
|
|
5
|
-
* off the tool schemas in the `agy` binary.
|
|
6
|
-
*
|
|
5
|
+
* off the tool schemas in the `agy` binary. `run_shell_command` is Gemini CLI's
|
|
6
|
+
* (`SHELL_TOOL_NAME` in gemini-cli `packages/core/src/tools/definitions/base-declarations.ts`).
|
|
7
|
+
* Cursor's hooks call their shell tool `Shell` (cursor.com/docs/hooks), which
|
|
8
|
+
* `CURSOR_TOOL_KINDS` maps. A name no set lists falls through to 'other' ->
|
|
9
|
+
* tool.completed, which is accurate rather than guessed.
|
|
7
10
|
*/
|
|
8
11
|
export declare const SHELL_TOOLS: ReadonlySet<string>;
|
|
9
12
|
export declare const FILE_READ_TOOLS: ReadonlySet<string>;
|
|
@@ -23,3 +26,16 @@ export declare const FILE_PATH_KEYS: readonly ["file_path", "path", "notebook_pa
|
|
|
23
26
|
* Antigravity's name for it (`run_command`); everything else uses `command`.
|
|
24
27
|
*/
|
|
25
28
|
export declare const COMMAND_KEYS: readonly ["CommandLine", "command"];
|
|
29
|
+
/** Where Codex and Gemini put the command in a shell call's `tool_input`. */
|
|
30
|
+
export declare const SHELL_COMMAND_KEY = "command";
|
|
31
|
+
/**
|
|
32
|
+
* A block the agent's harness injected into the prompt, not something the
|
|
33
|
+
* developer typed. Claude Desktop prepends a `<system-reminder>` of ~2,000
|
|
34
|
+
* characters to a session's first prompt; sent as prompt text it would bury the
|
|
35
|
+
* person's words under the harness's. Only a closed block is a harness block:
|
|
36
|
+
* the text is stripped before any bound, so the harness's own are always whole,
|
|
37
|
+
* and an unclosed tag the person pasted keeps everything after it.
|
|
38
|
+
* ponytail: each unclosed tag scans to the end, quadratic only in a prompt
|
|
39
|
+
* stuffed with them; the agent bounds the prompt before the hook sees it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const RE_HARNESS_BLOCK: RegExp;
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
* Tool-name vocabularies, as O(1) sets.
|
|
3
3
|
*
|
|
4
4
|
* `run_command`, `edit_file` and `write_to_file` are Antigravity's names, read
|
|
5
|
-
* off the tool schemas in the `agy` binary.
|
|
6
|
-
*
|
|
5
|
+
* off the tool schemas in the `agy` binary. `run_shell_command` is Gemini CLI's
|
|
6
|
+
* (`SHELL_TOOL_NAME` in gemini-cli `packages/core/src/tools/definitions/base-declarations.ts`).
|
|
7
|
+
* Cursor's hooks call their shell tool `Shell` (cursor.com/docs/hooks), which
|
|
8
|
+
* `CURSOR_TOOL_KINDS` maps. A name no set lists falls through to 'other' ->
|
|
9
|
+
* tool.completed, which is accurate rather than guessed.
|
|
7
10
|
*/
|
|
8
|
-
export const SHELL_TOOLS = new Set(['Bash', 'shell', 'local_shell', 'exec_command', 'run_command']);
|
|
11
|
+
export const SHELL_TOOLS = new Set(['Bash', 'shell', 'local_shell', 'exec_command', 'run_command', 'run_shell_command']);
|
|
9
12
|
export const FILE_READ_TOOLS = new Set(['Read', 'read_file', 'view_image']);
|
|
10
13
|
export const FILE_EDIT_TOOLS = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit', 'apply_patch', 'edit_file', 'write_to_file']);
|
|
11
14
|
/** Prefix and separator of an MCP tool name. */
|
|
@@ -23,3 +26,16 @@ export const FILE_PATH_KEYS = ['file_path', 'path', 'notebook_path', 'filePath',
|
|
|
23
26
|
* Antigravity's name for it (`run_command`); everything else uses `command`.
|
|
24
27
|
*/
|
|
25
28
|
export const COMMAND_KEYS = ['CommandLine', 'command'];
|
|
29
|
+
/** Where Codex and Gemini put the command in a shell call's `tool_input`. */
|
|
30
|
+
export const SHELL_COMMAND_KEY = 'command';
|
|
31
|
+
/**
|
|
32
|
+
* A block the agent's harness injected into the prompt, not something the
|
|
33
|
+
* developer typed. Claude Desktop prepends a `<system-reminder>` of ~2,000
|
|
34
|
+
* characters to a session's first prompt; sent as prompt text it would bury the
|
|
35
|
+
* person's words under the harness's. Only a closed block is a harness block:
|
|
36
|
+
* the text is stripped before any bound, so the harness's own are always whole,
|
|
37
|
+
* and an unclosed tag the person pasted keeps everything after it.
|
|
38
|
+
* ponytail: each unclosed tag scans to the end, quadratic only in a prompt
|
|
39
|
+
* stuffed with them; the agent bounds the prompt before the hook sees it.
|
|
40
|
+
*/
|
|
41
|
+
export const RE_HARNESS_BLOCK = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
@@ -26,14 +26,6 @@ export declare function baseEvent(input: BaseEventInput): AgentWatchEvent;
|
|
|
26
26
|
* @returns A new event carrying both.
|
|
27
27
|
*/
|
|
28
28
|
export declare function withPatch(event: AgentWatchEvent, patch: EventPatch): AgentWatchEvent;
|
|
29
|
-
/**
|
|
30
|
-
* Merge two metadata bags, merging their `provider` blocks too.
|
|
31
|
-
*
|
|
32
|
-
* @param base - Metadata from the base event.
|
|
33
|
-
* @param extra - Metadata from the patch.
|
|
34
|
-
* @returns The merged bag, or undefined when both were empty.
|
|
35
|
-
*/
|
|
36
|
-
export declare function mergeMetadata(base: AgentWatchEvent['metadata'], extra: AgentWatchEvent['metadata']): AgentWatchEvent['metadata'];
|
|
37
29
|
/**
|
|
38
30
|
* Patch carrying provider-specific metadata only.
|
|
39
31
|
*
|
|
@@ -42,8 +34,16 @@ export declare function mergeMetadata(base: AgentWatchEvent['metadata'], extra:
|
|
|
42
34
|
*/
|
|
43
35
|
export declare function providerPatch(fields: UnknownRecord): EventPatch;
|
|
44
36
|
/**
|
|
45
|
-
* Patch for a
|
|
46
|
-
* effective config
|
|
37
|
+
* Patch for a submitted prompt: its length and SHA-256, the ticket keys it
|
|
38
|
+
* names, and its text only when the effective config opted in to `promptText`.
|
|
39
|
+
*
|
|
40
|
+
* The evidence hashes the prompt as the agent reported it, harness blocks and
|
|
41
|
+
* all, so its meaning does not change with the flag. The text and the keys drop
|
|
42
|
+
* the blocks the harness injected: they are not what the person asked for. The
|
|
43
|
+
* keys need no flag (AWT-326): they are the same class of data as a branch name.
|
|
44
|
+
* The text is neither bounded nor scrubbed here — enrichment scrubs the whole
|
|
45
|
+
* string and the turn record bounds it, in that order, so a secret straddling
|
|
46
|
+
* the bound is never cut short of its pattern.
|
|
47
47
|
*
|
|
48
48
|
* @param prompt - The prompt text as the agent reported it.
|
|
49
49
|
* @param capture - What the effective config allows.
|
|
@@ -51,14 +51,12 @@ export declare function providerPatch(fields: UnknownRecord): EventPatch;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function promptPatch(prompt: string, capture: CapturePolicy): EventPatch;
|
|
53
53
|
/**
|
|
54
|
-
* Patch for
|
|
55
|
-
* effective config permits it.
|
|
54
|
+
* Patch for an agent response: its length and SHA-256, never the text.
|
|
56
55
|
*
|
|
57
56
|
* @param response - The response text as the agent reported it.
|
|
58
|
-
* @param capture - What the effective config allows.
|
|
59
57
|
* @returns The patch.
|
|
60
58
|
*/
|
|
61
|
-
export declare function responsePatch(response: string
|
|
59
|
+
export declare function responsePatch(response: string): EventPatch;
|
|
62
60
|
/**
|
|
63
61
|
* Patch for a tool call: the canonical `tool` block plus whatever of its
|
|
64
62
|
* input, output and file path the effective config permits.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { compact } from '../../core/object.js';
|
|
2
2
|
import { EVENT_SCHEMA_VERSION } from '../../events/constants/events.constants.js';
|
|
3
3
|
import { deriveEventId } from '../../events/event-id.js';
|
|
4
|
+
import { ticketKeysInText } from '../../feature/ticket-candidates.js';
|
|
5
|
+
import { RE_HARNESS_BLOCK } from './constants/tooling.constants.js';
|
|
4
6
|
import { contentEvidence, extractCommand, extractFilePath } from './tooling.js';
|
|
5
7
|
/** Metadata key holding the provider's own, non-canonical fields. */
|
|
6
8
|
const PROVIDER_METADATA_KEY = 'provider';
|
|
@@ -68,7 +70,7 @@ export function withPatch(event, patch) {
|
|
|
68
70
|
* @param extra - Metadata from the patch.
|
|
69
71
|
* @returns The merged bag, or undefined when both were empty.
|
|
70
72
|
*/
|
|
71
|
-
|
|
73
|
+
function mergeMetadata(base, extra) {
|
|
72
74
|
if (!extra)
|
|
73
75
|
return base;
|
|
74
76
|
if (!base)
|
|
@@ -91,36 +93,40 @@ export function providerPatch(fields) {
|
|
|
91
93
|
return { metadata: { [PROVIDER_METADATA_KEY]: compact(fields) } };
|
|
92
94
|
}
|
|
93
95
|
/**
|
|
94
|
-
* Patch for a
|
|
95
|
-
* effective config
|
|
96
|
+
* Patch for a submitted prompt: its length and SHA-256, the ticket keys it
|
|
97
|
+
* names, and its text only when the effective config opted in to `promptText`.
|
|
98
|
+
*
|
|
99
|
+
* The evidence hashes the prompt as the agent reported it, harness blocks and
|
|
100
|
+
* all, so its meaning does not change with the flag. The text and the keys drop
|
|
101
|
+
* the blocks the harness injected: they are not what the person asked for. The
|
|
102
|
+
* keys need no flag (AWT-326): they are the same class of data as a branch name.
|
|
103
|
+
* The text is neither bounded nor scrubbed here — enrichment scrubs the whole
|
|
104
|
+
* string and the turn record bounds it, in that order, so a secret straddling
|
|
105
|
+
* the bound is never cut short of its pattern.
|
|
96
106
|
*
|
|
97
107
|
* @param prompt - The prompt text as the agent reported it.
|
|
98
108
|
* @param capture - What the effective config allows.
|
|
99
109
|
* @returns The patch.
|
|
100
110
|
*/
|
|
101
111
|
export function promptPatch(prompt, capture) {
|
|
112
|
+
const typed = prompt.replace(RE_HARNESS_BLOCK, '').trim();
|
|
113
|
+
const keys = ticketKeysInText(typed);
|
|
102
114
|
return {
|
|
103
115
|
metadata: compact({
|
|
104
116
|
prompt: contentEvidence(prompt),
|
|
105
|
-
promptText: capture.
|
|
117
|
+
promptText: capture.promptText && typed ? typed : undefined,
|
|
118
|
+
promptJiraIds: keys.length > 0 ? keys : undefined
|
|
106
119
|
})
|
|
107
120
|
};
|
|
108
121
|
}
|
|
109
122
|
/**
|
|
110
|
-
* Patch for
|
|
111
|
-
* effective config permits it.
|
|
123
|
+
* Patch for an agent response: its length and SHA-256, never the text.
|
|
112
124
|
*
|
|
113
125
|
* @param response - The response text as the agent reported it.
|
|
114
|
-
* @param capture - What the effective config allows.
|
|
115
126
|
* @returns The patch.
|
|
116
127
|
*/
|
|
117
|
-
export function responsePatch(response
|
|
118
|
-
return {
|
|
119
|
-
metadata: compact({
|
|
120
|
-
response: response ? contentEvidence(response) : undefined,
|
|
121
|
-
responseText: capture.responses && response ? response : undefined
|
|
122
|
-
})
|
|
123
|
-
};
|
|
128
|
+
export function responsePatch(response) {
|
|
129
|
+
return { metadata: compact({ response: response ? contentEvidence(response) : undefined }) };
|
|
124
130
|
}
|
|
125
131
|
/**
|
|
126
132
|
* Patch for a tool call: the canonical `tool` block plus whatever of its
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentProvider, ExporterSweep, SetupContext } from '../types/provider.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Remove every AgentWatch-owned native exporter that sends where the edge
|
|
4
|
+
* itself would not.
|
|
5
|
+
*
|
|
6
|
+
* The agents send native OTLP themselves, from their own config files, with the
|
|
7
|
+
* bearer setup wrote there (Codex, Gemini) or handed out (Claude). Refusing a
|
|
8
|
+
* URL in the edge's config does not reach those files, so an exporter written
|
|
9
|
+
* before a host was refused would keep sending to it until the next setup. Only
|
|
10
|
+
* what `exporterEndpoints` names is judged, and only `uninstall` removes it, so
|
|
11
|
+
* nothing the developer wrote is touched.
|
|
12
|
+
*
|
|
13
|
+
* Never throws for one agent's sake: a file that cannot be read or changed is
|
|
14
|
+
* reported and the next agent is still checked.
|
|
15
|
+
*
|
|
16
|
+
* @param context - Environment, paths, the machine config whose trust applies, and install state.
|
|
17
|
+
* @param candidates - The agents to check.
|
|
18
|
+
* @returns The refused exporters and the install state to persist.
|
|
19
|
+
*/
|
|
20
|
+
export declare function removeRefusedExporters(context: SetupContext, candidates: readonly AgentProvider[]): Promise<ExporterSweep>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { deliverableOrigin, isAllowedHost } from '../../config/schemas/config.schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Remove every AgentWatch-owned native exporter that sends where the edge
|
|
4
|
+
* itself would not.
|
|
5
|
+
*
|
|
6
|
+
* The agents send native OTLP themselves, from their own config files, with the
|
|
7
|
+
* bearer setup wrote there (Codex, Gemini) or handed out (Claude). Refusing a
|
|
8
|
+
* URL in the edge's config does not reach those files, so an exporter written
|
|
9
|
+
* before a host was refused would keep sending to it until the next setup. Only
|
|
10
|
+
* what `exporterEndpoints` names is judged, and only `uninstall` removes it, so
|
|
11
|
+
* nothing the developer wrote is touched.
|
|
12
|
+
*
|
|
13
|
+
* Never throws for one agent's sake: a file that cannot be read or changed is
|
|
14
|
+
* reported and the next agent is still checked.
|
|
15
|
+
*
|
|
16
|
+
* @param context - Environment, paths, the machine config whose trust applies, and install state.
|
|
17
|
+
* @param candidates - The agents to check.
|
|
18
|
+
* @returns The refused exporters and the install state to persist.
|
|
19
|
+
*/
|
|
20
|
+
export async function removeRefusedExporters(context, candidates) {
|
|
21
|
+
const trusted = new Set(context.config.customEndpoints);
|
|
22
|
+
let installState = context.installState;
|
|
23
|
+
const refused = [];
|
|
24
|
+
for (const provider of candidates) {
|
|
25
|
+
const telemetry = provider.nativeTelemetry;
|
|
26
|
+
if (!telemetry)
|
|
27
|
+
continue;
|
|
28
|
+
try {
|
|
29
|
+
const current = { ...context, installState };
|
|
30
|
+
const outside = (await telemetry.exporterEndpoints(current)).filter((url) => !isAllowedHost(url, trusted));
|
|
31
|
+
if (outside.length === 0)
|
|
32
|
+
continue;
|
|
33
|
+
const origins = [...new Set(outside.map((url) => deliverableOrigin(url) ?? 'a URL that is not https'))].join(', ');
|
|
34
|
+
const outcome = await telemetry.uninstall(current);
|
|
35
|
+
installState = outcome.installState ?? installState;
|
|
36
|
+
refused.push({
|
|
37
|
+
agent: provider.displayName,
|
|
38
|
+
removed: outcome.ok,
|
|
39
|
+
message: outcome.ok
|
|
40
|
+
? `${provider.displayName}: removed the AgentWatch exporter to ${origins}, not an Agent Watch host or trusted origin; if you trust it, run \`agentwatch setup --endpoint <url> --allow-custom-endpoint\``
|
|
41
|
+
: `${provider.displayName}: the AgentWatch exporter sends to ${origins}, not an Agent Watch host or trusted origin, and could not be removed: ${outcome.messages.join('; ')}`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
refused.push({ agent: provider.displayName, removed: false, message: `${provider.displayName}: could not check the native exporter: ${error.message}` });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { installState, refused };
|
|
49
|
+
}
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
import type { UnknownRecord } from '../../core/types/core.types.js';
|
|
2
2
|
import type { StripOptions, StripResult } from './types/hook-config.types.js';
|
|
3
3
|
export type { HookHandler, HookMatcherGroup, StripOptions, StripResult } from './types/hook-config.types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Whether one handler is an AgentWatch command.
|
|
6
|
-
*
|
|
7
|
-
* @param handler - Entry from an agent's hook list.
|
|
8
|
-
* @returns True when we own it.
|
|
9
|
-
*/
|
|
10
|
-
export declare function isOurHandler(handler: unknown): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Remove AgentWatch handlers from one event's entry list.
|
|
13
|
-
*
|
|
14
|
-
* Handlers, not whole groups: a user may have added their own handler into the
|
|
15
|
-
* group we created, and uninstalling AgentWatch must not take it with us. A
|
|
16
|
-
* group left with no handlers is dropped; anything we do not recognize is
|
|
17
|
-
* passed through untouched.
|
|
18
|
-
*
|
|
19
|
-
* @param entries - The event's entry list.
|
|
20
|
-
* @param options - Whether bare handlers are accepted alongside groups.
|
|
21
|
-
* @returns The entries to keep.
|
|
22
|
-
*/
|
|
23
|
-
export declare function withoutOurHandlers(entries: readonly unknown[], options?: StripOptions): unknown[];
|
|
24
4
|
/**
|
|
25
5
|
* Remove AgentWatch handlers from every event of a hook map.
|
|
26
6
|
*
|
|
@@ -76,5 +56,6 @@ export declare function withHooksBlock(config: UnknownRecord, hooks: UnknownReco
|
|
|
76
56
|
*
|
|
77
57
|
* @param targetPath - File to write.
|
|
78
58
|
* @param value - The whole config object.
|
|
59
|
+
* @param mode - Permissions for credential-bearing settings.
|
|
79
60
|
*/
|
|
80
|
-
export declare function writeJsonValidated(targetPath: string, value: UnknownRecord): Promise<void>;
|
|
61
|
+
export declare function writeJsonValidated(targetPath: string, value: UnknownRecord, mode?: number): Promise<void>;
|
|
@@ -7,7 +7,7 @@ import { isAgentWatchHookCommand } from '../provider.js';
|
|
|
7
7
|
* @param handler - Entry from an agent's hook list.
|
|
8
8
|
* @returns True when we own it.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
function isOurHandler(handler) {
|
|
11
11
|
const record = handler;
|
|
12
12
|
if (!isRecord(record) || typeof record.command !== 'string')
|
|
13
13
|
return false;
|
|
@@ -25,7 +25,7 @@ export function isOurHandler(handler) {
|
|
|
25
25
|
* @param options - Whether bare handlers are accepted alongside groups.
|
|
26
26
|
* @returns The entries to keep.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
function withoutOurHandlers(entries, options = {}) {
|
|
29
29
|
const kept = [];
|
|
30
30
|
for (const entry of entries) {
|
|
31
31
|
if (options.allowBareHandlers && isOurHandler(entry))
|
|
@@ -146,11 +146,12 @@ export function withHooksBlock(config, hooks, key = 'hooks') {
|
|
|
146
146
|
*
|
|
147
147
|
* @param targetPath - File to write.
|
|
148
148
|
* @param value - The whole config object.
|
|
149
|
+
* @param mode - Permissions for credential-bearing settings.
|
|
149
150
|
*/
|
|
150
|
-
export async function writeJsonValidated(targetPath, value) {
|
|
151
|
+
export async function writeJsonValidated(targetPath, value, mode) {
|
|
151
152
|
const serialized = `${JSON.stringify(value, null, 2)}\n`;
|
|
152
153
|
JSON.parse(serialized);
|
|
153
|
-
await writeFileAtomic(targetPath, serialized);
|
|
154
|
+
await writeFileAtomic(targetPath, serialized, mode);
|
|
154
155
|
}
|
|
155
156
|
/**
|
|
156
157
|
* Whether two entry lists are equivalent.
|
|
@@ -14,3 +14,15 @@ import type { ProviderHookResponse } from '../types/provider.types.js';
|
|
|
14
14
|
* @returns The response, or undefined when this hook cannot refuse anything.
|
|
15
15
|
*/
|
|
16
16
|
export declare function hookRefusal(payload: unknown, gateEvents: ReadonlySet<string>, body: UnknownRecord): ProviderHookResponse | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A line shown to the developer after a tool ran or as a session starts, and
|
|
19
|
+
* nothing for any other hook.
|
|
20
|
+
*
|
|
21
|
+
* Only `systemMessage` in a JSON reply: Claude Code injects plain stdout of some
|
|
22
|
+
* hooks into the model's context, and a notice is for the developer alone.
|
|
23
|
+
*
|
|
24
|
+
* @param payload - Raw hook payload.
|
|
25
|
+
* @param message - The sentence to show.
|
|
26
|
+
* @returns The response, or undefined when this is not a PostToolUse or SessionStart hook.
|
|
27
|
+
*/
|
|
28
|
+
export declare function hookNotice(payload: unknown, message: string): ProviderHookResponse | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asRecord } from '../../core/object.js';
|
|
2
|
-
import { PAYLOAD_HOOK_EVENT_KEY } from './constants/hook-refusal.constants.js';
|
|
2
|
+
import { NOTICE_EVENTS, PAYLOAD_HOOK_EVENT_KEY } from './constants/hook-refusal.constants.js';
|
|
3
3
|
/**
|
|
4
4
|
* A refusal for the hooks an agent lets a hook refuse, and nothing for the rest.
|
|
5
5
|
*
|
|
@@ -18,6 +18,22 @@ export function hookRefusal(payload, gateEvents, body) {
|
|
|
18
18
|
return undefined;
|
|
19
19
|
return { stdout: JSON.stringify(body), exitCode: 0 };
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A line shown to the developer after a tool ran or as a session starts, and
|
|
23
|
+
* nothing for any other hook.
|
|
24
|
+
*
|
|
25
|
+
* Only `systemMessage` in a JSON reply: Claude Code injects plain stdout of some
|
|
26
|
+
* hooks into the model's context, and a notice is for the developer alone.
|
|
27
|
+
*
|
|
28
|
+
* @param payload - Raw hook payload.
|
|
29
|
+
* @param message - The sentence to show.
|
|
30
|
+
* @returns The response, or undefined when this is not a PostToolUse or SessionStart hook.
|
|
31
|
+
*/
|
|
32
|
+
export function hookNotice(payload, message) {
|
|
33
|
+
if (!NOTICE_EVENTS.has(hookEventName(payload) ?? ''))
|
|
34
|
+
return undefined;
|
|
35
|
+
return { stdout: JSON.stringify({ systemMessage: message }), exitCode: 0 };
|
|
36
|
+
}
|
|
21
37
|
/**
|
|
22
38
|
* The hook the agent fired, as the agent names it.
|
|
23
39
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InstallState } from '../../storage/types/storage.types.js';
|
|
2
2
|
/** What one hook installation recorded about itself. */
|
|
3
|
-
|
|
3
|
+
interface HookInstallRecord {
|
|
4
4
|
readonly hookConfigPath: string;
|
|
5
5
|
readonly hookEvents: readonly string[];
|
|
6
6
|
readonly hookCommand: string;
|
|
@@ -46,11 +46,20 @@ export declare function withoutHookInstall(state: InstallState, agentId: string)
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function withoutAgent(state: InstallState, agentId: string): InstallState;
|
|
48
48
|
/** What one native-telemetry configuration recorded about itself. */
|
|
49
|
-
|
|
49
|
+
interface OtelInstallRecord {
|
|
50
50
|
readonly configPath: string;
|
|
51
51
|
/** Config keys AgentWatch now owns, and may therefore remove later. */
|
|
52
52
|
readonly ownedKeys: readonly string[];
|
|
53
53
|
readonly configuredAt: Date;
|
|
54
|
+
/**
|
|
55
|
+
* Permission bits the file had before this write tightened it.
|
|
56
|
+
*
|
|
57
|
+
* The agent's config file is not ours, and `writeFileAtomic` preserves the
|
|
58
|
+
* target's current mode by design — so tightening it once would otherwise
|
|
59
|
+
* keep it tightened forever, including after the token is gone. Recording
|
|
60
|
+
* the old bits is what makes the change reversible.
|
|
61
|
+
*/
|
|
62
|
+
readonly priorMode?: number;
|
|
54
63
|
}
|
|
55
64
|
/**
|
|
56
65
|
* Install state with one agent's native-telemetry configuration recorded.
|
|
@@ -73,3 +82,4 @@ export declare function withOtelInstall(state: InstallState, agentId: string, re
|
|
|
73
82
|
* @returns The next install state.
|
|
74
83
|
*/
|
|
75
84
|
export declare function withoutOtelInstall(state: InstallState, agentId: string): InstallState;
|
|
85
|
+
export {};
|
|
@@ -87,7 +87,10 @@ export function withOtelInstall(state, agentId, record) {
|
|
|
87
87
|
notes: previous?.notes ?? [],
|
|
88
88
|
otelConfiguredAt: record.configuredAt.toISOString(),
|
|
89
89
|
otelConfigPath: record.configPath,
|
|
90
|
-
otelOwnedKeys: [...new Set(record.ownedKeys)]
|
|
90
|
+
otelOwnedKeys: [...new Set(record.ownedKeys)],
|
|
91
|
+
// First tightening wins: a second configure must not record the 0600 we
|
|
92
|
+
// ourselves left behind as the file's original mode.
|
|
93
|
+
...(record.priorMode !== undefined && previous?.otelPriorMode === undefined ? { otelPriorMode: record.priorMode } : {})
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
};
|
|
@@ -107,7 +110,7 @@ export function withoutOtelInstall(state, agentId) {
|
|
|
107
110
|
...state,
|
|
108
111
|
agents: {
|
|
109
112
|
...state.agents,
|
|
110
|
-
[agentId]: { ...omitKeys(previous, new Set(['otelConfiguredAt'])), otelOwnedKeys: [] }
|
|
113
|
+
[agentId]: { ...omitKeys(previous, new Set(['otelConfiguredAt', 'otelPriorMode'])), otelOwnedKeys: [] }
|
|
111
114
|
}
|
|
112
115
|
};
|
|
113
116
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directories a shell command names, as absolute paths.
|
|
3
|
+
*
|
|
4
|
+
* Agents do their work through the shell far more than through file tools, and
|
|
5
|
+
* often in a checkout other than the folder they sit in: `cd ../worktree && git
|
|
6
|
+
* commit`. The command is the only place that says so. This reads it for
|
|
7
|
+
* directory names and nothing else — no verb decides anything; git later says
|
|
8
|
+
* which named checkout actually changed.
|
|
9
|
+
*
|
|
10
|
+
* Pure, and deliberately the only thing that ever sees the command: the caller
|
|
11
|
+
* holds the text in memory, passes it here, keeps the paths only long enough to
|
|
12
|
+
* turn them into checkout roots, and drops both. Nothing of it is stored.
|
|
13
|
+
*
|
|
14
|
+
* ponytail: a regex reader, not a shell parser. Variables, globs and
|
|
15
|
+
* subshell-computed paths are skipped rather than guessed, and a path that is
|
|
16
|
+
* only an argument (a script run from another repository) is nominated like any
|
|
17
|
+
* other; it can only win when nothing changed. The upgrade is a real tokenizer.
|
|
18
|
+
*
|
|
19
|
+
* @param command - The shell command, in memory.
|
|
20
|
+
* @param cwd - The directory the command runs in.
|
|
21
|
+
* @param home - Home directory, for `~/` and `$HOME/`; unknown means those are skipped.
|
|
22
|
+
* @returns Absolute paths, deduplicated, at most {@link MAX_SHELL_DIRECTORIES}.
|
|
23
|
+
*/
|
|
24
|
+
export declare function shellDirectories(command: string, cwd: string, home: string | undefined): string[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { HEREDOC_PLACEHOLDER, MAX_SHELL_DIRECTORIES, RE_BARE_ABSOLUTE, RE_CHANGE_DIRECTORY, RE_DIRECTORY_ARGUMENTS, RE_DOT_PREFIX, RE_DOT_RELATIVE, RE_HEREDOC, RE_HOME_PREFIX, RE_QUOTED_ABSOLUTE, RE_SHELL_SEPARATORS, RE_SURROUNDING_QUOTES, RE_UNEXPANDED } from './constants/shell-directories.constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* The directories a shell command names, as absolute paths.
|
|
5
|
+
*
|
|
6
|
+
* Agents do their work through the shell far more than through file tools, and
|
|
7
|
+
* often in a checkout other than the folder they sit in: `cd ../worktree && git
|
|
8
|
+
* commit`. The command is the only place that says so. This reads it for
|
|
9
|
+
* directory names and nothing else — no verb decides anything; git later says
|
|
10
|
+
* which named checkout actually changed.
|
|
11
|
+
*
|
|
12
|
+
* Pure, and deliberately the only thing that ever sees the command: the caller
|
|
13
|
+
* holds the text in memory, passes it here, keeps the paths only long enough to
|
|
14
|
+
* turn them into checkout roots, and drops both. Nothing of it is stored.
|
|
15
|
+
*
|
|
16
|
+
* ponytail: a regex reader, not a shell parser. Variables, globs and
|
|
17
|
+
* subshell-computed paths are skipped rather than guessed, and a path that is
|
|
18
|
+
* only an argument (a script run from another repository) is nominated like any
|
|
19
|
+
* other; it can only win when nothing changed. The upgrade is a real tokenizer.
|
|
20
|
+
*
|
|
21
|
+
* @param command - The shell command, in memory.
|
|
22
|
+
* @param cwd - The directory the command runs in.
|
|
23
|
+
* @param home - Home directory, for `~/` and `$HOME/`; unknown means those are skipped.
|
|
24
|
+
* @returns Absolute paths, deduplicated, at most {@link MAX_SHELL_DIRECTORIES}.
|
|
25
|
+
*/
|
|
26
|
+
export function shellDirectories(command, cwd, home) {
|
|
27
|
+
const found = new Set();
|
|
28
|
+
let base = cwd;
|
|
29
|
+
for (const piece of command.replace(RE_HEREDOC, HEREDOC_PLACEHOLDER).split(RE_SHELL_SEPARATORS)) {
|
|
30
|
+
for (const match of piece.matchAll(RE_CHANGE_DIRECTORY)) {
|
|
31
|
+
const directory = resolveArgument(match[1], base, home, true);
|
|
32
|
+
if (!directory)
|
|
33
|
+
continue;
|
|
34
|
+
found.add(directory);
|
|
35
|
+
// A lasting `cd` in one command moves every relative path after it.
|
|
36
|
+
base = directory;
|
|
37
|
+
}
|
|
38
|
+
for (const pattern of RE_DIRECTORY_ARGUMENTS) {
|
|
39
|
+
for (const match of piece.matchAll(pattern))
|
|
40
|
+
addResolved(found, resolveArgument(match[1], base, home, true));
|
|
41
|
+
}
|
|
42
|
+
for (const match of piece.matchAll(RE_QUOTED_ABSOLUTE))
|
|
43
|
+
addResolved(found, resolveArgument(match[0], base, home, false));
|
|
44
|
+
for (const match of piece.matchAll(RE_BARE_ABSOLUTE))
|
|
45
|
+
addResolved(found, resolveArgument(match[1], base, home, false));
|
|
46
|
+
for (const match of piece.matchAll(RE_DOT_RELATIVE))
|
|
47
|
+
addResolved(found, resolveArgument(match[1], base, home, false));
|
|
48
|
+
}
|
|
49
|
+
return [...found].slice(0, MAX_SHELL_DIRECTORIES);
|
|
50
|
+
}
|
|
51
|
+
function addResolved(found, directory) {
|
|
52
|
+
if (directory)
|
|
53
|
+
found.add(directory);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* One argument as an absolute path, when it can be known without a shell.
|
|
57
|
+
*
|
|
58
|
+
* @param raw - The argument as written.
|
|
59
|
+
* @param base - What a relative path is relative to.
|
|
60
|
+
* @param home - Home directory, when known.
|
|
61
|
+
* @param anyRelative - The argument is a directory by position (`cd X`), so a bare relative name counts.
|
|
62
|
+
* @returns The absolute path, or undefined.
|
|
63
|
+
*/
|
|
64
|
+
function resolveArgument(raw, base, home, anyRelative) {
|
|
65
|
+
const unquoted = raw?.replace(RE_SURROUNDING_QUOTES, '');
|
|
66
|
+
// Inside quotes a backslash is literal; only a bare word escapes its spaces.
|
|
67
|
+
const unescaped = raw !== undefined && unquoted === raw ? raw.replaceAll('\\ ', ' ') : unquoted;
|
|
68
|
+
if (!unquoted || unquoted.startsWith('-'))
|
|
69
|
+
return undefined;
|
|
70
|
+
const homed = expandHome(unescaped ?? '', home);
|
|
71
|
+
if (!homed || RE_UNEXPANDED.test(homed))
|
|
72
|
+
return undefined;
|
|
73
|
+
if (path.isAbsolute(homed))
|
|
74
|
+
return path.resolve(homed);
|
|
75
|
+
if (!anyRelative && !RE_DOT_PREFIX.test(homed))
|
|
76
|
+
return undefined;
|
|
77
|
+
return path.resolve(base, homed);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* `~`, `$HOME` and `${HOME}` at the start of a path, expanded.
|
|
81
|
+
*
|
|
82
|
+
* @param value - The unquoted argument.
|
|
83
|
+
* @param home - Home directory, when known.
|
|
84
|
+
* @returns The expanded path, or undefined when it needs a home nobody gave.
|
|
85
|
+
*/
|
|
86
|
+
function expandHome(value, home) {
|
|
87
|
+
if (!RE_HOME_PREFIX.test(value))
|
|
88
|
+
return value;
|
|
89
|
+
return home ? value.replace(RE_HOME_PREFIX, home) : undefined;
|
|
90
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CanonicalEventType, ContentEvidence } from '../../events/types/events.types.js';
|
|
2
|
-
import type { McpToolName, ToolKind } from '../types/provider.types.js';
|
|
2
|
+
import type { McpToolName, ShellCall, ToolKind } from '../types/provider.types.js';
|
|
3
3
|
export type { McpToolName, ToolKind } from '../types/provider.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* What kind of thing a tool call is, whatever the agent calls it.
|
|
@@ -56,3 +56,14 @@ export declare function extractFilePath(toolInput: unknown): string | undefined;
|
|
|
56
56
|
* @returns The command, or undefined when the input names none.
|
|
57
57
|
*/
|
|
58
58
|
export declare function extractCommand(toolInput: unknown): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* A shell call out of untrusted payload fields, type-checked.
|
|
61
|
+
*
|
|
62
|
+
* A working directory counts only when it is an absolute path: a relative one
|
|
63
|
+
* would have to be resolved against a guess.
|
|
64
|
+
*
|
|
65
|
+
* @param command - The command field as the payload carries it.
|
|
66
|
+
* @param workdir - The working-directory field as the payload carries it.
|
|
67
|
+
* @returns The call, or undefined when neither field is usable.
|
|
68
|
+
*/
|
|
69
|
+
export declare function shellCallOf(command: unknown, workdir: unknown): ShellCall | undefined;
|