@agent-watch-ai/edge 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +238 -7
- package/README.md +308 -8
- 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 +3 -2
- package/dist/billing/session-billing.js +8 -8
- 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 +479 -0
- package/dist/capture/constants/capture.constants.d.ts +70 -0
- package/dist/capture/constants/capture.constants.js +72 -0
- package/dist/capture/launched-runs.d.ts +16 -0
- package/dist/capture/launched-runs.js +151 -0
- package/dist/capture/node.cjs +697 -0
- package/dist/capture/node.d.cts +32 -0
- package/dist/capture/python/sitecustomize.py +823 -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/cli/constants/cli.constants.d.ts +2 -6
- package/dist/cli/constants/cli.constants.js +3 -7
- package/dist/cli/context.d.ts +19 -22
- package/dist/cli/context.js +23 -54
- package/dist/cli/doctor-run-capture.d.ts +13 -0
- package/dist/cli/doctor-run-capture.js +19 -0
- package/dist/cli/doctor.js +16 -67
- package/dist/cli/hook.d.ts +14 -0
- package/dist/cli/hook.js +40 -0
- 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/replay.d.ts +33 -0
- package/dist/cli/replay.js +193 -0
- package/dist/cli/setup.d.ts +10 -2
- package/dist/cli/setup.js +154 -26
- 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 +8 -22
- package/dist/cli.js +104 -17
- package/dist/config/config.d.ts +0 -2
- package/dist/config/config.js +0 -1
- package/dist/config/constants/config.constants.js +2 -0
- 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 +13 -0
- package/dist/config/schemas/config.schema.js +42 -6
- 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 +32 -0
- package/dist/credentials/cloud-claim.js +42 -0
- package/dist/credentials/constants/credentials.constants.d.ts +8 -1
- package/dist/credentials/constants/credentials.constants.js +9 -2
- package/dist/credentials/device-api.d.ts +15 -1
- package/dist/credentials/device-api.js +12 -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/events/constants/events.constants.d.ts +8 -2
- package/dist/events/constants/events.constants.js +7 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/product-event.d.ts +10 -4
- 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-snapshot.types.d.ts +1 -4
- package/dist/events/types/repo-tree.types.d.ts +25 -0
- package/dist/events/types/repo-tree.types.js +1 -0
- 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 +31 -11
- package/dist/git/constants/git.constants.js +36 -12
- package/dist/git/constants/tree.constants.d.ts +71 -0
- package/dist/git/constants/tree.constants.js +92 -0
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.d.ts +1 -0
- package/dist/git/git-context.js +8 -3
- 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 +47 -9
- package/dist/git/repo-tree.d.ts +69 -0
- package/dist/git/repo-tree.js +130 -0
- package/dist/git/types/git.types.d.ts +5 -2
- package/dist/git/types/snapshot.types.d.ts +14 -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 +112 -72
- package/dist/privacy/product-capture.js +36 -5
- 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 +17 -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 +29 -0
- package/dist/replay/checkout-resolver.js +69 -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 +58 -0
- package/dist/replay/replay-runner.js +529 -0
- package/dist/replay/replay-scan.d.ts +83 -0
- package/dist/replay/replay-scan.js +170 -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 +35 -0
- package/dist/replay/throttle.js +41 -0
- package/dist/replay/transcript-turns.d.ts +35 -0
- package/dist/replay/transcript-turns.js +215 -0
- package/dist/replay/turn-event.d.ts +38 -0
- package/dist/replay/turn-event.js +116 -0
- package/dist/replay/types/replay.types.d.ts +162 -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/snapshot/branch-selection.d.ts +40 -23
- package/dist/snapshot/branch-selection.js +74 -42
- package/dist/snapshot/budget.js +2 -2
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +10 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +10 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +37 -4
- package/dist/snapshot/constants/snapshot.constants.js +37 -4
- package/dist/snapshot/index.d.ts +6 -1
- package/dist/snapshot/index.js +3 -1
- package/dist/snapshot/snapshot-event.d.ts +7 -0
- package/dist/snapshot/snapshot-event.js +8 -5
- package/dist/snapshot/snapshot-pipeline.js +89 -26
- package/dist/snapshot/snapshot-state.js +24 -2
- package/dist/snapshot/tree-event.d.ts +14 -0
- package/dist/snapshot/tree-event.js +91 -0
- package/dist/snapshot/tree-pipeline.d.ts +12 -0
- package/dist/snapshot/tree-pipeline.js +172 -0
- package/dist/snapshot/types/snapshot.types.d.ts +62 -2
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/constants/transport.constants.d.ts +5 -0
- package/dist/transport/constants/transport.constants.js +5 -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/queue.js +40 -6
- 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 +13 -12
- package/dist/turns/constants/turns.constants.js +15 -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 +49 -7
- package/dist/turns/turn-state.js +78 -10
- package/dist/turns/turn-summary.js +10 -6
- package/dist/turns/turn-tracker.d.ts +9 -16
- package/dist/turns/turn-tracker.js +162 -86
- 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 +20 -6
- 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 +269 -32
- package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
- package/docs/PERFORMANCE.md +27 -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
|
@@ -1,37 +1,54 @@
|
|
|
1
1
|
import type { BranchRef } from '../git/types/snapshot.types.js';
|
|
2
|
-
import type { SelectionInput, SnapshotState } from './types/snapshot.types.js';
|
|
2
|
+
import type { SelectionInput, SnapshotCandidate, SnapshotState } from './types/snapshot.types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The branches the snapshot walks, newest commit first, and which of them are due.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* A branch already found on the trunk, at the same head and against the same
|
|
7
|
+
* base, is left out without a git process: merged stays merged, and that is
|
|
8
|
+
* what lets the walk pass the dozens of finished branches a busy repository
|
|
9
|
+
* keeps to reach the live ones behind them. Every other branch is a candidate,
|
|
10
|
+
* due when one of these holds — and each one is a bug if it is missing:
|
|
7
11
|
*
|
|
8
|
-
* - the branch is new — nothing has ever been
|
|
9
|
-
* - its head moved — the obvious one
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* - the branch is new — nothing has ever been checked about it;
|
|
13
|
+
* - its head moved — the obvious one, and how a merged branch with new work
|
|
14
|
+
* comes back;
|
|
15
|
+
* - the default branch changed since it was checked, because its delta and its
|
|
16
|
+
* verdict were computed against the wrong base and no head has to move for
|
|
17
|
+
* that to be true;
|
|
18
|
+
* - it was last sent longer ago than the heartbeat, which is the only thing
|
|
19
|
+
* that ever re-offers a finished branch to a tracker connected after the fact.
|
|
15
20
|
*
|
|
16
|
-
* @param input - The refs git reported and what was last
|
|
17
|
-
* @returns The
|
|
21
|
+
* @param input - The refs git reported and what was last recorded.
|
|
22
|
+
* @returns The candidates in walk order.
|
|
18
23
|
*/
|
|
19
|
-
export declare function
|
|
24
|
+
export declare function snapshotCandidates(input: SelectionInput): readonly SnapshotCandidate[];
|
|
25
|
+
/**
|
|
26
|
+
* Whether the walk would reach a due branch before the window is full.
|
|
27
|
+
*
|
|
28
|
+
* The cheap exit on an ordinary closing turn: the first ten live branches are
|
|
29
|
+
* all as they were sent, so no git process runs and nothing is queued.
|
|
30
|
+
*
|
|
31
|
+
* @param candidates - The walk, from {@link snapshotCandidates}.
|
|
32
|
+
* @returns True when something has to be checked.
|
|
33
|
+
*/
|
|
34
|
+
export declare function anyDue(candidates: readonly SnapshotCandidate[]): boolean;
|
|
20
35
|
/**
|
|
21
36
|
* The state to store once a snapshot has been queued.
|
|
22
37
|
*
|
|
23
|
-
* A branch is recorded
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* later.
|
|
38
|
+
* A branch is recorded only if it was actually checked. The cache is a record
|
|
39
|
+
* of what the platform has been told, not of what git said: a branch whose head
|
|
40
|
+
* moved and which then fell outside the budget must keep its *old* head here,
|
|
41
|
+
* or the next turn compares the new head against the new head, finds them
|
|
42
|
+
* equal, and the work disappears until the heartbeat six hours later.
|
|
29
43
|
*
|
|
30
|
-
* A branch
|
|
31
|
-
*
|
|
44
|
+
* A branch found on the trunk is recorded as merged: the platform has been told
|
|
45
|
+
* all there is, and the verdict is what keeps every later turn from checking it
|
|
46
|
+
* again. Each entry carries the base it was checked against, so a trunk change
|
|
47
|
+
* re-checks branch by branch and a budget cut part-way loses nothing.
|
|
32
48
|
*
|
|
33
49
|
* @param input - Refs, previous state and the send's own clock.
|
|
34
|
-
* @param sent - The branches this snapshot
|
|
50
|
+
* @param sent - The live branches this snapshot described.
|
|
51
|
+
* @param merged - The branches it found already on the trunk.
|
|
35
52
|
* @returns The state to write.
|
|
36
53
|
*/
|
|
37
|
-
export declare function nextSnapshotState(input: SelectionInput, sent: readonly BranchRef[]): SnapshotState;
|
|
54
|
+
export declare function nextSnapshotState(input: SelectionInput, sent: readonly BranchRef[], merged?: readonly BranchRef[]): SnapshotState;
|
|
@@ -1,69 +1,101 @@
|
|
|
1
|
-
import { SNAPSHOT_REFRESH_MS } from './constants/snapshot.constants.js';
|
|
1
|
+
import { SNAPSHOT_BRANCH_COUNT, SNAPSHOT_REFRESH_MS } from './constants/snapshot.constants.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The branches the snapshot walks, newest commit first, and which of them are due.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* A branch already found on the trunk, at the same head and against the same
|
|
6
|
+
* base, is left out without a git process: merged stays merged, and that is
|
|
7
|
+
* what lets the walk pass the dozens of finished branches a busy repository
|
|
8
|
+
* keeps to reach the live ones behind them. Every other branch is a candidate,
|
|
9
|
+
* due when one of these holds — and each one is a bug if it is missing:
|
|
6
10
|
*
|
|
7
|
-
* - the branch is new — nothing has ever been
|
|
8
|
-
* - its head moved — the obvious one
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* - the branch is new — nothing has ever been checked about it;
|
|
12
|
+
* - its head moved — the obvious one, and how a merged branch with new work
|
|
13
|
+
* comes back;
|
|
14
|
+
* - the default branch changed since it was checked, because its delta and its
|
|
15
|
+
* verdict were computed against the wrong base and no head has to move for
|
|
16
|
+
* that to be true;
|
|
17
|
+
* - it was last sent longer ago than the heartbeat, which is the only thing
|
|
18
|
+
* that ever re-offers a finished branch to a tracker connected after the fact.
|
|
14
19
|
*
|
|
15
|
-
* @param input - The refs git reported and what was last
|
|
16
|
-
* @returns The
|
|
20
|
+
* @param input - The refs git reported and what was last recorded.
|
|
21
|
+
* @returns The candidates in walk order.
|
|
17
22
|
*/
|
|
18
|
-
export function
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
if (rebased)
|
|
22
|
-
return true;
|
|
23
|
+
export function snapshotCandidates(input) {
|
|
24
|
+
const candidates = [];
|
|
25
|
+
for (const ref of input.refs) {
|
|
23
26
|
const entry = input.stored.branches[ref.name];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const current = entry !== undefined && entry.headSha === ref.headSha && entryBase(entry, input.stored) === input.defaultBranch;
|
|
28
|
+
if (current && entry.merged)
|
|
29
|
+
continue;
|
|
30
|
+
candidates.push({ ref, due: !current || input.now - entry.lastSentAt >= SNAPSHOT_REFRESH_MS });
|
|
31
|
+
}
|
|
32
|
+
return candidates;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether the walk would reach a due branch before the window is full.
|
|
36
|
+
*
|
|
37
|
+
* The cheap exit on an ordinary closing turn: the first ten live branches are
|
|
38
|
+
* all as they were sent, so no git process runs and nothing is queued.
|
|
39
|
+
*
|
|
40
|
+
* @param candidates - The walk, from {@link snapshotCandidates}.
|
|
41
|
+
* @returns True when something has to be checked.
|
|
42
|
+
*/
|
|
43
|
+
export function anyDue(candidates) {
|
|
44
|
+
const reached = candidates.slice(0, SNAPSHOT_BRANCH_COUNT);
|
|
45
|
+
return reached.some((candidate) => candidate.due);
|
|
30
46
|
}
|
|
31
47
|
/**
|
|
32
48
|
* The state to store once a snapshot has been queued.
|
|
33
49
|
*
|
|
34
|
-
* A branch is recorded
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* later.
|
|
50
|
+
* A branch is recorded only if it was actually checked. The cache is a record
|
|
51
|
+
* of what the platform has been told, not of what git said: a branch whose head
|
|
52
|
+
* moved and which then fell outside the budget must keep its *old* head here,
|
|
53
|
+
* or the next turn compares the new head against the new head, finds them
|
|
54
|
+
* equal, and the work disappears until the heartbeat six hours later.
|
|
40
55
|
*
|
|
41
|
-
* A branch
|
|
42
|
-
*
|
|
56
|
+
* A branch found on the trunk is recorded as merged: the platform has been told
|
|
57
|
+
* all there is, and the verdict is what keeps every later turn from checking it
|
|
58
|
+
* again. Each entry carries the base it was checked against, so a trunk change
|
|
59
|
+
* re-checks branch by branch and a budget cut part-way loses nothing.
|
|
43
60
|
*
|
|
44
61
|
* @param input - Refs, previous state and the send's own clock.
|
|
45
|
-
* @param sent - The branches this snapshot
|
|
62
|
+
* @param sent - The live branches this snapshot described.
|
|
63
|
+
* @param merged - The branches it found already on the trunk.
|
|
46
64
|
* @returns The state to write.
|
|
47
65
|
*/
|
|
48
|
-
export function nextSnapshotState(input, sent) {
|
|
66
|
+
export function nextSnapshotState(input, sent, merged = []) {
|
|
49
67
|
const sentNames = new Set(sent.map((ref) => ref.name));
|
|
68
|
+
const mergedNames = new Set(merged.map((ref) => ref.name));
|
|
50
69
|
const branches = {};
|
|
51
70
|
for (const ref of input.refs) {
|
|
52
71
|
if (sentNames.has(ref.name)) {
|
|
53
|
-
branches[ref.name] = { headSha: ref.headSha, lastSentAt: input.now };
|
|
72
|
+
branches[ref.name] = { headSha: ref.headSha, lastSentAt: input.now, base: input.defaultBranch };
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (mergedNames.has(ref.name)) {
|
|
76
|
+
branches[ref.name] = { headSha: ref.headSha, lastSentAt: input.now, base: input.defaultBranch, merged: true };
|
|
54
77
|
continue;
|
|
55
78
|
}
|
|
56
79
|
const previous = input.stored.branches[ref.name];
|
|
80
|
+
// An entry from before bases were per branch takes the repository's, so
|
|
81
|
+
// the recorded default branch below can move without re-dating it.
|
|
57
82
|
if (previous)
|
|
58
|
-
branches[ref.name] = previous;
|
|
83
|
+
branches[ref.name] = { ...previous, base: entryBase(previous, input.stored) };
|
|
59
84
|
}
|
|
60
|
-
// The
|
|
61
|
-
// it. Recording it early would end the `rebased` selection for branches whose
|
|
62
|
-
// deltas were never recomputed, and they would sit on the wrong base until
|
|
63
|
-
// their heads happened to move.
|
|
64
|
-
const described = input.refs.every((ref) => sentNames.has(ref.name));
|
|
85
|
+
// The tree is the tree flow's to write; a branch send carries it over untouched.
|
|
65
86
|
return {
|
|
66
|
-
defaultBranch:
|
|
67
|
-
branches
|
|
87
|
+
defaultBranch: input.defaultBranch,
|
|
88
|
+
branches,
|
|
89
|
+
...(input.stored.tree ? { tree: input.stored.tree } : {})
|
|
68
90
|
};
|
|
69
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The base an entry was checked against.
|
|
94
|
+
*
|
|
95
|
+
* @param entry - One stored branch.
|
|
96
|
+
* @param stored - Its state, whose default branch an older entry inherits.
|
|
97
|
+
* @returns The base name, or undefined when there was none.
|
|
98
|
+
*/
|
|
99
|
+
function entryBase(entry, stored) {
|
|
100
|
+
return entry.base ?? stored.defaultBranch;
|
|
101
|
+
}
|
package/dist/snapshot/budget.js
CHANGED
|
@@ -27,11 +27,11 @@ export function remainingMs(deadline, now = Date.now) {
|
|
|
27
27
|
* @returns A runner whose timeout is whatever is left, capped at the git default.
|
|
28
28
|
*/
|
|
29
29
|
export function budgetedRunner(run, deadline, now = Date.now) {
|
|
30
|
-
return async (args, cwd, timeoutMs, home) => {
|
|
30
|
+
return async (args, cwd, timeoutMs, home, maxBufferBytes) => {
|
|
31
31
|
const left = remainingMs(deadline, now);
|
|
32
32
|
if (left === 0)
|
|
33
33
|
return undefined;
|
|
34
|
-
return run(args, cwd, Math.min(timeoutMs || GIT_TIMEOUT_MS, left), home);
|
|
34
|
+
return run(args, cwd, Math.min(timeoutMs || GIT_TIMEOUT_MS, left), home, maxBufferBytes);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -7,5 +7,15 @@ export declare const STAGE_ENQUEUE = "enqueue";
|
|
|
7
7
|
/** Reasons a stage ends the flow early. */
|
|
8
8
|
export declare const STOP_NOT_A_REPOSITORY = "no branches: not a repository, or it has none";
|
|
9
9
|
export declare const STOP_NOTHING_CHANGED = "no branch moved and none is due a refresh";
|
|
10
|
+
export declare const STOP_ALL_ON_TRUNK = "every checked branch is already on the trunk";
|
|
10
11
|
export declare const STOP_BUDGET_SPENT = "snapshot budget spent";
|
|
11
12
|
export declare const STOP_NO_EVENT = "no snapshot event was built";
|
|
13
|
+
/** The tree flow's stages and stops. */
|
|
14
|
+
export declare const STAGE_TREE_DUE = "tree-due";
|
|
15
|
+
export declare const STAGE_TREE_RESOLVE = "tree-resolve";
|
|
16
|
+
export declare const STAGE_TREE_CHANGED = "tree-changed";
|
|
17
|
+
export declare const STAGE_TREE_COLLECT = "tree-collect";
|
|
18
|
+
export declare const STOP_TREE_SENT = "trunk tree already sent for this repository and identity";
|
|
19
|
+
export declare const STOP_TREE_NOT_DUE = "tree attempt failed within the last hour";
|
|
20
|
+
export declare const STOP_TREE_NO_TRUNK = "no default branch tree to list";
|
|
21
|
+
export declare const STOP_TREE_UNLISTED = "tree could not be listed";
|
|
@@ -7,5 +7,15 @@ export const STAGE_ENQUEUE = 'enqueue';
|
|
|
7
7
|
/** Reasons a stage ends the flow early. */
|
|
8
8
|
export const STOP_NOT_A_REPOSITORY = 'no branches: not a repository, or it has none';
|
|
9
9
|
export const STOP_NOTHING_CHANGED = 'no branch moved and none is due a refresh';
|
|
10
|
+
export const STOP_ALL_ON_TRUNK = 'every checked branch is already on the trunk';
|
|
10
11
|
export const STOP_BUDGET_SPENT = 'snapshot budget spent';
|
|
11
12
|
export const STOP_NO_EVENT = 'no snapshot event was built';
|
|
13
|
+
/** The tree flow's stages and stops. */
|
|
14
|
+
export const STAGE_TREE_DUE = 'tree-due';
|
|
15
|
+
export const STAGE_TREE_RESOLVE = 'tree-resolve';
|
|
16
|
+
export const STAGE_TREE_CHANGED = 'tree-changed';
|
|
17
|
+
export const STAGE_TREE_COLLECT = 'tree-collect';
|
|
18
|
+
export const STOP_TREE_SENT = 'trunk tree already sent for this repository and identity';
|
|
19
|
+
export const STOP_TREE_NOT_DUE = 'tree attempt failed within the last hour';
|
|
20
|
+
export const STOP_TREE_NO_TRUNK = 'no default branch tree to list';
|
|
21
|
+
export const STOP_TREE_UNLISTED = 'tree could not be listed';
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* How many branches one snapshot describes.
|
|
2
|
+
* How many live branches one snapshot describes.
|
|
3
3
|
*
|
|
4
|
-
* The ten most recently committed
|
|
5
|
-
* working on, few enough that the
|
|
6
|
-
*
|
|
4
|
+
* The ten most recently committed that are not already on the trunk: enough to
|
|
5
|
+
* cover what anyone is actually working on, few enough that the backend's
|
|
6
|
+
* per-branch transaction count stays bounded.
|
|
7
7
|
*/
|
|
8
8
|
export declare const SNAPSHOT_BRANCH_COUNT = 10;
|
|
9
|
+
/**
|
|
10
|
+
* How many branches the listing reads, newest commit first, to find those ten.
|
|
11
|
+
*
|
|
12
|
+
* Merged branches are passed over, so the ten live ones can sit deep: 46 down
|
|
13
|
+
* on agent-watch-core (294 local branches, October 2026). Still one process —
|
|
14
|
+
* all 294 list in ~40 ms — and the bound keeps the state file small.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SNAPSHOT_SCAN_COUNT = 100;
|
|
17
|
+
/**
|
|
18
|
+
* How many branches one snapshot may check with git.
|
|
19
|
+
*
|
|
20
|
+
* A check is the delta log plus, when it has commits, a merge-tree and a tree
|
|
21
|
+
* read: ~70 ms on agent-watch-core. Finding its ten live branches from an empty
|
|
22
|
+
* cache took 18 checks (27 more were passed for a gone upstream at no cost); the
|
|
23
|
+
* budget usually ends a first snapshot before this does, and verdicts are
|
|
24
|
+
* remembered, so the next turn continues where it stopped.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SNAPSHOT_MAX_CHECKS = 20;
|
|
27
|
+
/**
|
|
28
|
+
* Budget the checks leave for queueing the event and writing the state.
|
|
29
|
+
*
|
|
30
|
+
* Without it a walk that ran to the deadline would queue nothing and record
|
|
31
|
+
* nothing, and on a repository that always needs more than the budget no turn
|
|
32
|
+
* would ever make progress.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SNAPSHOT_WRITE_RESERVE_MS = 100;
|
|
9
35
|
/**
|
|
10
36
|
* How many of a branch's own commits travel with it.
|
|
11
37
|
*
|
|
@@ -86,3 +112,10 @@ export declare const SNAPSHOT_MAX_PATH_LENGTH = 1024;
|
|
|
86
112
|
export declare const SNAPSHOT_RE_CONTROL_CHARACTER: RegExp;
|
|
87
113
|
/** Hex characters kept from the repository digest that names a state file. */
|
|
88
114
|
export declare const SNAPSHOT_STATE_HASH_LENGTH = 32;
|
|
115
|
+
/**
|
|
116
|
+
* How long a repository waits between `repo.tree` checks: after a failed
|
|
117
|
+
* attempt (no trunk, listing failed, budget spent), and between comparisons of
|
|
118
|
+
* the trunk's tree oid with the one already sent. Bounds the git cost to one
|
|
119
|
+
* oid lookup an hour per repository.
|
|
120
|
+
*/
|
|
121
|
+
export declare const TREE_RETRY_INTERVAL_MS: number;
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* How many branches one snapshot describes.
|
|
2
|
+
* How many live branches one snapshot describes.
|
|
3
3
|
*
|
|
4
|
-
* The ten most recently committed
|
|
5
|
-
* working on, few enough that the
|
|
6
|
-
*
|
|
4
|
+
* The ten most recently committed that are not already on the trunk: enough to
|
|
5
|
+
* cover what anyone is actually working on, few enough that the backend's
|
|
6
|
+
* per-branch transaction count stays bounded.
|
|
7
7
|
*/
|
|
8
8
|
export const SNAPSHOT_BRANCH_COUNT = 10;
|
|
9
|
+
/**
|
|
10
|
+
* How many branches the listing reads, newest commit first, to find those ten.
|
|
11
|
+
*
|
|
12
|
+
* Merged branches are passed over, so the ten live ones can sit deep: 46 down
|
|
13
|
+
* on agent-watch-core (294 local branches, October 2026). Still one process —
|
|
14
|
+
* all 294 list in ~40 ms — and the bound keeps the state file small.
|
|
15
|
+
*/
|
|
16
|
+
export const SNAPSHOT_SCAN_COUNT = 100;
|
|
17
|
+
/**
|
|
18
|
+
* How many branches one snapshot may check with git.
|
|
19
|
+
*
|
|
20
|
+
* A check is the delta log plus, when it has commits, a merge-tree and a tree
|
|
21
|
+
* read: ~70 ms on agent-watch-core. Finding its ten live branches from an empty
|
|
22
|
+
* cache took 18 checks (27 more were passed for a gone upstream at no cost); the
|
|
23
|
+
* budget usually ends a first snapshot before this does, and verdicts are
|
|
24
|
+
* remembered, so the next turn continues where it stopped.
|
|
25
|
+
*/
|
|
26
|
+
export const SNAPSHOT_MAX_CHECKS = 20;
|
|
27
|
+
/**
|
|
28
|
+
* Budget the checks leave for queueing the event and writing the state.
|
|
29
|
+
*
|
|
30
|
+
* Without it a walk that ran to the deadline would queue nothing and record
|
|
31
|
+
* nothing, and on a repository that always needs more than the budget no turn
|
|
32
|
+
* would ever make progress.
|
|
33
|
+
*/
|
|
34
|
+
export const SNAPSHOT_WRITE_RESERVE_MS = 100;
|
|
9
35
|
/**
|
|
10
36
|
* How many of a branch's own commits travel with it.
|
|
11
37
|
*
|
|
@@ -87,3 +113,10 @@ export const SNAPSHOT_MAX_PATH_LENGTH = 1024;
|
|
|
87
113
|
export const SNAPSHOT_RE_CONTROL_CHARACTER = /[\x00-\x1f\x7f]/;
|
|
88
114
|
/** Hex characters kept from the repository digest that names a state file. */
|
|
89
115
|
export const SNAPSHOT_STATE_HASH_LENGTH = 32;
|
|
116
|
+
/**
|
|
117
|
+
* How long a repository waits between `repo.tree` checks: after a failed
|
|
118
|
+
* attempt (no trunk, listing failed, budget spent), and between comparisons of
|
|
119
|
+
* the trunk's tree oid with the one already sent. Bounds the git cost to one
|
|
120
|
+
* oid lookup an hour per repository.
|
|
121
|
+
*/
|
|
122
|
+
export const TREE_RETRY_INTERVAL_MS = 60 * 60 * 1000;
|
package/dist/snapshot/index.d.ts
CHANGED
|
@@ -6,11 +6,16 @@
|
|
|
6
6
|
* layer is an overlay on work items, and a team with no tracker connected has
|
|
7
7
|
* none — the branches on this machine are then the only evidence that a piece
|
|
8
8
|
* of work exists at all.
|
|
9
|
+
*
|
|
10
|
+
* The tree flow beside it sends the trunk's source paths and declaration names
|
|
11
|
+
* (`repo.tree`) per repository and identity, again when the trunk's tree changes, for a tenant whose code nothing may clone.
|
|
9
12
|
*/
|
|
10
13
|
export type { BuildSnapshotInput, SelectionInput, SnapshotFlowInput, SnapshotFlowState, SnapshotIdentity, SnapshotPipelineInput, SnapshotQueue, SnapshotState, SnapshotStateEntry, SnapshotStateReader } from './types/snapshot.types.js';
|
|
11
14
|
export { SNAPSHOT_BRANCH_COUNT, SNAPSHOT_BUDGET_MS, SNAPSHOT_COMMITS_PER_BRANCH, SNAPSHOT_REFRESH_MS } from './constants/snapshot.constants.js';
|
|
12
|
-
export { nextSnapshotState,
|
|
15
|
+
export { anyDue, nextSnapshotState, snapshotCandidates } from './branch-selection.js';
|
|
13
16
|
export { budgetedRunner, remainingMs, withinBudget } from './budget.js';
|
|
14
17
|
export { buildRepoSnapshot } from './snapshot-event.js';
|
|
15
18
|
export { runSnapshotPipeline } from './snapshot-pipeline.js';
|
|
19
|
+
export { buildRepoTree } from './tree-event.js';
|
|
20
|
+
export { runTreePipeline } from './tree-pipeline.js';
|
|
16
21
|
export { SnapshotStateStore, emptyState } from './snapshot-state.js';
|
package/dist/snapshot/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { SNAPSHOT_BRANCH_COUNT, SNAPSHOT_BUDGET_MS, SNAPSHOT_COMMITS_PER_BRANCH, SNAPSHOT_REFRESH_MS } from './constants/snapshot.constants.js';
|
|
2
|
-
export { nextSnapshotState,
|
|
2
|
+
export { anyDue, nextSnapshotState, snapshotCandidates } from './branch-selection.js';
|
|
3
3
|
export { budgetedRunner, remainingMs, withinBudget } from './budget.js';
|
|
4
4
|
export { buildRepoSnapshot } from './snapshot-event.js';
|
|
5
5
|
export { runSnapshotPipeline } from './snapshot-pipeline.js';
|
|
6
|
+
export { buildRepoTree } from './tree-event.js';
|
|
7
|
+
export { runTreePipeline } from './tree-pipeline.js';
|
|
6
8
|
export { SnapshotStateStore, emptyState } from './snapshot-state.js';
|
|
@@ -15,3 +15,10 @@ import type { BuildSnapshotInput } from './types/snapshot.types.js';
|
|
|
15
15
|
* @returns The snapshot event.
|
|
16
16
|
*/
|
|
17
17
|
export declare function buildRepoSnapshot(input: BuildSnapshotInput): RepoSnapshotEvent;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a path may be named at all: not over-long, no control characters, not a credential file.
|
|
20
|
+
*
|
|
21
|
+
* @param filePath - Repository-relative path.
|
|
22
|
+
* @returns True when the path may be sent.
|
|
23
|
+
*/
|
|
24
|
+
export declare function sendable(filePath: string): boolean;
|
|
@@ -49,11 +49,9 @@ export function buildRepoSnapshot(input) {
|
|
|
49
49
|
return compact({
|
|
50
50
|
name: branch.name,
|
|
51
51
|
head_sha: branch.headSha,
|
|
52
|
-
last_commit_at: branch.lastCommitAt,
|
|
53
52
|
commits: branch.commits.map((commit, index) => compact({
|
|
54
53
|
sha: commit.sha,
|
|
55
54
|
subject: commit.subject.slice(0, SNAPSHOT_MAX_SUBJECT_LENGTH),
|
|
56
|
-
authored_at: commit.authoredAt,
|
|
57
55
|
files: files[index]
|
|
58
56
|
}))
|
|
59
57
|
});
|
|
@@ -84,15 +82,20 @@ function branchFiles(commits) {
|
|
|
84
82
|
continue;
|
|
85
83
|
files -= 1;
|
|
86
84
|
bytes -= size;
|
|
87
|
-
kept.push(file);
|
|
85
|
+
kept.push({ path: file.path });
|
|
88
86
|
}
|
|
89
87
|
// Empty only when git listed nothing: a commit whose every file was withheld
|
|
90
88
|
// or capped did change something, and an empty list would say it had not.
|
|
91
89
|
return kept.length > 0 || commit.files?.length === 0 ? kept : undefined;
|
|
92
90
|
});
|
|
93
91
|
}
|
|
94
|
-
/**
|
|
95
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Whether a path may be named at all: not over-long, no control characters, not a credential file.
|
|
94
|
+
*
|
|
95
|
+
* @param filePath - Repository-relative path.
|
|
96
|
+
* @returns True when the path may be sent.
|
|
97
|
+
*/
|
|
98
|
+
export function sendable(filePath) {
|
|
96
99
|
return filePath.length <= SNAPSHOT_MAX_PATH_LENGTH && !SNAPSHOT_RE_CONTROL_CHARACTER.test(filePath) && !RE_SECRET_FILE.test(path.posix.basename(filePath));
|
|
97
100
|
}
|
|
98
101
|
/**
|