@nanonets/graft 0.10.1 → 0.12.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/README.md +32 -11
- package/dist/ai/crux.d.ts.map +1 -1
- package/dist/ai/crux.js +7 -6
- package/dist/ai/crux.js.map +1 -1
- package/dist/ai/failure.d.ts +49 -0
- package/dist/ai/failure.d.ts.map +1 -0
- package/dist/ai/failure.js +74 -0
- package/dist/ai/failure.js.map +1 -0
- package/dist/ai/llm/anthropic.d.ts.map +1 -1
- package/dist/ai/llm/anthropic.js +4 -1
- package/dist/ai/llm/anthropic.js.map +1 -1
- package/dist/ai/llm/claude-cli.d.ts +60 -0
- package/dist/ai/llm/claude-cli.d.ts.map +1 -0
- package/dist/ai/llm/claude-cli.js +417 -0
- package/dist/ai/llm/claude-cli.js.map +1 -0
- package/dist/ai/llm/openai.d.ts.map +1 -1
- package/dist/ai/llm/openai.js +2 -0
- package/dist/ai/llm/openai.js.map +1 -1
- package/dist/ai/llm/types.d.ts +9 -0
- package/dist/ai/llm/types.d.ts.map +1 -1
- package/dist/ai/llm/types.js +12 -1
- package/dist/ai/llm/types.js.map +1 -1
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +39 -45
- package/dist/ask/ask.js.map +1 -1
- package/dist/ask/fuse.d.ts +83 -46
- package/dist/ask/fuse.d.ts.map +1 -1
- package/dist/ask/fuse.js +165 -67
- package/dist/ask/fuse.js.map +1 -1
- package/dist/blast/blast-cli.d.ts +30 -0
- package/dist/blast/blast-cli.d.ts.map +1 -0
- package/dist/blast/blast-cli.js +163 -0
- package/dist/blast/blast-cli.js.map +1 -0
- package/dist/blast/blast.d.ts +119 -0
- package/dist/blast/blast.d.ts.map +1 -0
- package/dist/blast/blast.js +383 -0
- package/dist/blast/blast.js.map +1 -0
- package/dist/blast/diff.d.ts +53 -0
- package/dist/blast/diff.d.ts.map +1 -0
- package/dist/blast/diff.js +193 -0
- package/dist/blast/diff.js.map +1 -0
- package/dist/blast/modules.d.ts +33 -0
- package/dist/blast/modules.d.ts.map +1 -0
- package/dist/blast/modules.js +83 -0
- package/dist/blast/modules.js.map +1 -0
- package/dist/blast/name.d.ts +61 -0
- package/dist/blast/name.d.ts.map +1 -0
- package/dist/blast/name.js +233 -0
- package/dist/blast/name.js.map +1 -0
- package/dist/blast/render.d.ts +37 -0
- package/dist/blast/render.d.ts.map +1 -0
- package/dist/blast/render.js +300 -0
- package/dist/blast/render.js.map +1 -0
- package/dist/blast/viz.d.ts +17 -0
- package/dist/blast/viz.d.ts.map +1 -0
- package/dist/blast/viz.js +324 -0
- package/dist/blast/viz.js.map +1 -0
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +18 -2
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/shim-template.d.ts.map +1 -1
- package/dist/claude/shim-template.js +45 -15
- package/dist/claude/shim-template.js.map +1 -1
- package/dist/claude/state.d.ts +5 -0
- package/dist/claude/state.d.ts.map +1 -1
- package/dist/claude/state.js.map +1 -1
- package/dist/cli-picker.d.ts +44 -5
- package/dist/cli-picker.d.ts.map +1 -1
- package/dist/cli-picker.js +73 -26
- package/dist/cli-picker.js.map +1 -1
- package/dist/cli.js +270 -14
- package/dist/cli.js.map +1 -1
- package/dist/context/build.d.ts +8 -0
- package/dist/context/build.d.ts.map +1 -1
- package/dist/context/build.js +57 -9
- package/dist/context/build.js.map +1 -1
- package/dist/context/check.d.ts.map +1 -1
- package/dist/context/check.js +7 -6
- package/dist/context/check.js.map +1 -1
- package/dist/context/node-file.d.ts.map +1 -1
- package/dist/context/node-file.js +9 -2
- package/dist/context/node-file.js.map +1 -1
- package/dist/graph/bindings.d.ts.map +1 -1
- package/dist/graph/bindings.js +171 -8
- package/dist/graph/bindings.js.map +1 -1
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +36 -16
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/check.d.ts +4 -0
- package/dist/graph/check.d.ts.map +1 -1
- package/dist/graph/check.js +8 -1
- package/dist/graph/check.js.map +1 -1
- package/dist/graph/container.d.ts +63 -0
- package/dist/graph/container.d.ts.map +1 -0
- package/dist/graph/container.js +185 -0
- package/dist/graph/container.js.map +1 -0
- package/dist/graph/enrich.d.ts +18 -0
- package/dist/graph/enrich.d.ts.map +1 -1
- package/dist/graph/enrich.js +55 -2
- package/dist/graph/enrich.js.map +1 -1
- package/dist/graph/extract.d.ts +3 -1
- package/dist/graph/extract.d.ts.map +1 -1
- package/dist/graph/extract.js +215 -8
- package/dist/graph/extract.js.map +1 -1
- package/dist/graph/generic.d.ts +34 -1
- package/dist/graph/generic.d.ts.map +1 -1
- package/dist/graph/generic.js +152 -3
- package/dist/graph/generic.js.map +1 -1
- package/dist/graph/queries/clojure.scm +58 -0
- package/dist/graph/resolve.d.ts.map +1 -1
- package/dist/graph/resolve.js +132 -2
- package/dist/graph/resolve.js.map +1 -1
- package/dist/graph/scopes.d.ts +2 -2
- package/dist/graph/scopes.d.ts.map +1 -1
- package/dist/graph/scopes.js +8 -6
- package/dist/graph/scopes.js.map +1 -1
- package/dist/graph/source-files.d.ts +13 -4
- package/dist/graph/source-files.d.ts.map +1 -1
- package/dist/graph/source-files.js +35 -12
- package/dist/graph/source-files.js.map +1 -1
- package/dist/graph/types.d.ts +1 -1
- package/dist/graph/types.d.ts.map +1 -1
- package/dist/graph/workspace-cli.d.ts +2 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -1
- package/dist/graph/workspace-cli.js +10 -4
- package/dist/graph/workspace-cli.js.map +1 -1
- package/dist/graph/workspace.d.ts +11 -6
- package/dist/graph/workspace.d.ts.map +1 -1
- package/dist/graph/workspace.js +24 -13
- package/dist/graph/workspace.js.map +1 -1
- package/dist/graph/write.d.ts.map +1 -1
- package/dist/graph/write.js +25 -2
- package/dist/graph/write.js.map +1 -1
- package/dist/hosts/antigravity.d.ts +7 -0
- package/dist/hosts/antigravity.d.ts.map +1 -0
- package/dist/hosts/antigravity.js +42 -0
- package/dist/hosts/antigravity.js.map +1 -0
- package/dist/hosts/init.d.ts.map +1 -1
- package/dist/hosts/init.js +6 -1
- package/dist/hosts/init.js.map +1 -1
- package/dist/hosts/mcp-config.d.ts.map +1 -1
- package/dist/hosts/mcp-config.js +7 -0
- package/dist/hosts/mcp-config.js.map +1 -1
- package/dist/hosts/plan.d.ts +1 -1
- package/dist/hosts/plan.d.ts.map +1 -1
- package/dist/hosts/plan.js +2 -0
- package/dist/hosts/plan.js.map +1 -1
- package/dist/hosts/registry.d.ts.map +1 -1
- package/dist/hosts/registry.js +13 -0
- package/dist/hosts/registry.js.map +1 -1
- package/dist/ingest/fs.d.ts +9 -2
- package/dist/ingest/fs.d.ts.map +1 -1
- package/dist/ingest/fs.js +100 -16
- package/dist/ingest/fs.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +45 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/telemetry/contract.d.ts +90 -0
- package/dist/telemetry/contract.d.ts.map +1 -0
- package/dist/telemetry/contract.js +203 -0
- package/dist/telemetry/contract.js.map +1 -0
- package/dist/telemetry/flush.d.ts +21 -0
- package/dist/telemetry/flush.d.ts.map +1 -0
- package/dist/telemetry/flush.js +84 -0
- package/dist/telemetry/flush.js.map +1 -0
- package/dist/telemetry/gate.d.ts +16 -0
- package/dist/telemetry/gate.d.ts.map +1 -0
- package/dist/telemetry/gate.js +64 -0
- package/dist/telemetry/gate.js.map +1 -0
- package/dist/telemetry/identity.d.ts +33 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +80 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +16 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/key.d.ts +21 -0
- package/dist/telemetry/key.d.ts.map +1 -0
- package/dist/telemetry/key.js +49 -0
- package/dist/telemetry/key.js.map +1 -0
- package/dist/telemetry/notice.d.ts +19 -0
- package/dist/telemetry/notice.d.ts.map +1 -0
- package/dist/telemetry/notice.js +90 -0
- package/dist/telemetry/notice.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +162 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/send.d.ts +19 -0
- package/dist/telemetry/send.d.ts.map +1 -0
- package/dist/telemetry/send.js +84 -0
- package/dist/telemetry/send.js.map +1 -0
- package/dist/telemetry/sessions.d.ts +8 -0
- package/dist/telemetry/sessions.d.ts.map +1 -0
- package/dist/telemetry/sessions.js +81 -0
- package/dist/telemetry/sessions.js.map +1 -0
- package/dist/telemetry/track.d.ts +43 -0
- package/dist/telemetry/track.d.ts.map +1 -0
- package/dist/telemetry/track.js +108 -0
- package/dist/telemetry/track.js.map +1 -0
- package/dist/upkeep-run.d.ts +15 -0
- package/dist/upkeep-run.d.ts.map +1 -0
- package/dist/upkeep-run.js +60 -0
- package/dist/upkeep-run.js.map +1 -0
- package/dist/upkeep.d.ts +114 -0
- package/dist/upkeep.d.ts.map +1 -0
- package/dist/upkeep.js +232 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/util/num.d.ts +3 -0
- package/dist/util/num.d.ts.map +1 -0
- package/dist/util/num.js +20 -0
- package/dist/util/num.js.map +1 -0
- package/dist/util/state.d.ts +11 -4
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js +9 -0
- package/dist/util/state.js.map +1 -1
- package/dist/viewer/app.js +1 -1
- package/dist/viewer/index.html +1 -0
- package/dist/viewer/style.css +23 -2
- package/dist/viz/assemble.d.ts +33 -0
- package/dist/viz/assemble.d.ts.map +1 -1
- package/dist/viz/assemble.js.map +1 -1
- package/dist/viz/export.d.ts +39 -0
- package/dist/viz/export.d.ts.map +1 -0
- package/dist/viz/export.js +98 -0
- package/dist/viz/export.js.map +1 -0
- package/package.json +6 -5
- package/scripts/stamp-telemetry-key.mjs +53 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Machine-global telemetry state. Shares `~/.graft/` with `update-check.json`. */
|
|
2
|
+
export interface TelemetryState {
|
|
3
|
+
installId: string;
|
|
4
|
+
/** The user's choice. Absent means "never chosen" → the default (on) applies. */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
/** ISO stamp of the one-time first-run notice, so it prints exactly once. */
|
|
7
|
+
noticeShownAt?: string;
|
|
8
|
+
/** Epoch ms of the last flush ATTEMPT, mirroring `UpdateCache.checkedAt`. */
|
|
9
|
+
flushedAt?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function statePath(home?: string): string;
|
|
12
|
+
export declare function readState(home?: string): TelemetryState | null;
|
|
13
|
+
/** Read-modify-write. Not atomic across processes; a lost update costs at most a
|
|
14
|
+
* duplicated notice or an extra flush attempt, never corruption. */
|
|
15
|
+
export declare function patchState(patch: Partial<TelemetryState>, home?: string): TelemetryState;
|
|
16
|
+
export interface Install {
|
|
17
|
+
id: string;
|
|
18
|
+
/** True when this call minted the id, i.e. this is the machine's first run. */
|
|
19
|
+
firstRun: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** The install id, minted on first call. */
|
|
22
|
+
export declare function installId(home?: string): Install;
|
|
23
|
+
/**
|
|
24
|
+
* The repo id, in `graft/.cache/` rather than `.graft/config.json`.
|
|
25
|
+
*
|
|
26
|
+
* `.graft/config.json` would have been the tidier home, but writing it runs
|
|
27
|
+
* `ensureBuildConfigIgnored`, which appends to the repo's `.gitignore`. Minting
|
|
28
|
+
* an id during a read-only `graft ask` must not modify a file the user has
|
|
29
|
+
* committed. `graft/.cache/` is already derived, already git-ignored, and
|
|
30
|
+
* already where every other per-repo sidecar lives.
|
|
31
|
+
*/
|
|
32
|
+
export declare function repoId(repo: string): string;
|
|
33
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AA0BA,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE1D;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAE9D;AAED;qEACqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAIxF;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,4CAA4C;AAC5C,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAahD;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO3C"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two identifiers, and why neither of them identifies anyone.
|
|
3
|
+
*
|
|
4
|
+
* • install id — one per machine, in `~/.graft/telemetry.json`, beside the
|
|
5
|
+
* update-check cache that already lives there. Lets us count people rather
|
|
6
|
+
* than events, so a dev running forty queries is one user and not forty.
|
|
7
|
+
* • repo id — one per checkout, in `graft/.cache/`. Activation and retention
|
|
8
|
+
* for graft are per-repo facts ("did this repo ever get past build?"), and
|
|
9
|
+
* the install id alone cannot express them.
|
|
10
|
+
*
|
|
11
|
+
* Both are `randomUUID()`. Not a machine id, not a hash of the git remote, not
|
|
12
|
+
* derived from anything real — a coin flip, written down. A hash would at least
|
|
13
|
+
* be guessable by us (we could hash a public repo URL and look for it); a random
|
|
14
|
+
* UUID cannot be reversed or confirmed even in principle. Deleting `~/.graft/`
|
|
15
|
+
* or `graft/` deletes them, and the user simply looks like someone new.
|
|
16
|
+
*
|
|
17
|
+
* Every function here is fail-soft: an unwritable home is a very common state
|
|
18
|
+
* (a locked-down CI image, a read-only container) and it must cost the caller
|
|
19
|
+
* nothing. A failed persist yields an ephemeral id for this process — still
|
|
20
|
+
* anonymous, just not stable — and never a throw.
|
|
21
|
+
*/
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
import { randomUUID } from 'node:crypto';
|
|
25
|
+
import { cacheDir, readJson, writeJsonAtomic } from '../util/state.js';
|
|
26
|
+
export function statePath(home = homedir()) {
|
|
27
|
+
return join(home, '.graft', 'telemetry.json');
|
|
28
|
+
}
|
|
29
|
+
export function readState(home) {
|
|
30
|
+
return readJson(statePath(home));
|
|
31
|
+
}
|
|
32
|
+
/** Read-modify-write. Not atomic across processes; a lost update costs at most a
|
|
33
|
+
* duplicated notice or an extra flush attempt, never corruption. */
|
|
34
|
+
export function patchState(patch, home) {
|
|
35
|
+
const next = { ...(readState(home) ?? { installId: randomUUID() }), ...patch };
|
|
36
|
+
try {
|
|
37
|
+
writeJsonAtomic(statePath(home), next);
|
|
38
|
+
}
|
|
39
|
+
catch { /* unwritable home — in-memory only */ }
|
|
40
|
+
return next;
|
|
41
|
+
}
|
|
42
|
+
/** The install id, minted on first call. */
|
|
43
|
+
export function installId(home) {
|
|
44
|
+
const existing = readState(home);
|
|
45
|
+
if (existing?.installId)
|
|
46
|
+
return { id: existing.installId, firstRun: false };
|
|
47
|
+
const id = randomUUID();
|
|
48
|
+
try {
|
|
49
|
+
writeJsonAtomic(statePath(home), { ...(existing ?? {}), installId: id });
|
|
50
|
+
return { id, firstRun: true };
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Unwritable home: use the id for this process rather than failing closed.
|
|
54
|
+
// Reported as firstRun:false so a machine that can never persist doesn't
|
|
55
|
+
// send a first_run event on every single command.
|
|
56
|
+
return { id, firstRun: false };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The repo id, in `graft/.cache/` rather than `.graft/config.json`.
|
|
61
|
+
*
|
|
62
|
+
* `.graft/config.json` would have been the tidier home, but writing it runs
|
|
63
|
+
* `ensureBuildConfigIgnored`, which appends to the repo's `.gitignore`. Minting
|
|
64
|
+
* an id during a read-only `graft ask` must not modify a file the user has
|
|
65
|
+
* committed. `graft/.cache/` is already derived, already git-ignored, and
|
|
66
|
+
* already where every other per-repo sidecar lives.
|
|
67
|
+
*/
|
|
68
|
+
export function repoId(repo) {
|
|
69
|
+
const path = join(cacheDir(repo), 'telemetry-repo-id.json');
|
|
70
|
+
const existing = readJson(path);
|
|
71
|
+
if (existing?.repoId)
|
|
72
|
+
return existing.repoId;
|
|
73
|
+
const id = randomUUID();
|
|
74
|
+
try {
|
|
75
|
+
writeJsonAtomic(path, { repoId: id });
|
|
76
|
+
}
|
|
77
|
+
catch { /* unwritable — ephemeral */ }
|
|
78
|
+
return id;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAavE,MAAM,UAAU,SAAS,CAAC,OAAe,OAAO,EAAE;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;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,wBAAwB,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAsB,IAAI,CAAC,CAAC;IACrD,IAAI,QAAQ,EAAE,MAAM;QAAE,OAAO,QAAQ,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,IAAI,CAAC;QAAC,eAAe,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,4BAA4B,CAAC,CAAC;IACrF,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anonymous adoption telemetry. `TELEMETRY.md` is the public contract;
|
|
3
|
+
* `contract.ts` is the same list enforced in code.
|
|
4
|
+
*
|
|
5
|
+
* The whole subsystem is inert unless four things are true at once: the build
|
|
6
|
+
* carries a key (published releases only), `DO_NOT_TRACK` is unset, this is not
|
|
7
|
+
* CI, and the user has not disabled it. See `gate.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export { EVENTS, COMMON_KEYS, isTrackedCommand, errorCode, filesBucket, durationBucket, countBucket, savedTokensBucket, langsValue } from './contract.js';
|
|
10
|
+
export type { AgentHost, Surface, TrackedCommand, BuildStage, ErrorCode } from './contract.js';
|
|
11
|
+
export { track, trackFirstRunIfNew, detectHost } from './track.js';
|
|
12
|
+
export type { QueuedEvent, TrackContext } from './track.js';
|
|
13
|
+
export { telemetryOn, offReason, explainOff } from './gate.js';
|
|
14
|
+
export { maybeFlushInBackground, runFlush } from './flush.js';
|
|
15
|
+
export { firstRunNotice, formatStatus, formatDebug, NOTICE, TELEMETRY_DOC_URL } from './notice.js';
|
|
16
|
+
export { patchState, readState } from './identity.js';
|
|
17
|
+
export { flushClosedSessions } from './sessions.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1J,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anonymous adoption telemetry. `TELEMETRY.md` is the public contract;
|
|
3
|
+
* `contract.ts` is the same list enforced in code.
|
|
4
|
+
*
|
|
5
|
+
* The whole subsystem is inert unless four things are true at once: the build
|
|
6
|
+
* carries a key (published releases only), `DO_NOT_TRACK` is unset, this is not
|
|
7
|
+
* CI, and the user has not disabled it. See `gate.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export { EVENTS, COMMON_KEYS, isTrackedCommand, errorCode, filesBucket, durationBucket, countBucket, savedTokensBucket, langsValue } from './contract.js';
|
|
10
|
+
export { track, trackFirstRunIfNew, detectHost } from './track.js';
|
|
11
|
+
export { telemetryOn, offReason, explainOff } from './gate.js';
|
|
12
|
+
export { maybeFlushInBackground, runFlush } from './flush.js';
|
|
13
|
+
export { firstRunNotice, formatStatus, formatDebug, NOTICE, TELEMETRY_DOC_URL } from './notice.js';
|
|
14
|
+
export { patchState, readState } from './identity.js';
|
|
15
|
+
export { flushClosedSessions } from './sessions.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1J,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PostHog project key, and the reason forks stay silent.
|
|
3
|
+
*
|
|
4
|
+
* `BAKED_KEY` is empty in the repository and is rewritten in place by
|
|
5
|
+
* `scripts/stamp-telemetry-key.mjs`, which runs from `prepublishOnly`. So the
|
|
6
|
+
* key exists only in the published tarball: a clone, a fork, and a plain
|
|
7
|
+
* `npm run build` all compile to `''`, and every send path short-circuits. A
|
|
8
|
+
* contributor cannot accidentally send us their own usage, and a fork cannot
|
|
9
|
+
* send us anything at all.
|
|
10
|
+
*
|
|
11
|
+
* `GRAFT_POSTHOG_KEY` overrides it at runtime so a maintainer can exercise the
|
|
12
|
+
* real path locally without publishing.
|
|
13
|
+
*
|
|
14
|
+
* Public project keys are write-only ingestion keys — they authorise capture and
|
|
15
|
+
* nothing else — which is why one may sit in a published artifact at all. It is
|
|
16
|
+
* still not committed here: an empty default is what makes "forks never send"
|
|
17
|
+
* true by construction rather than by policy.
|
|
18
|
+
*/
|
|
19
|
+
export declare function posthogKey(): string;
|
|
20
|
+
export declare function posthogHost(): string;
|
|
21
|
+
//# sourceMappingURL=key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/telemetry/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4BH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PostHog project key, and the reason forks stay silent.
|
|
3
|
+
*
|
|
4
|
+
* `BAKED_KEY` is empty in the repository and is rewritten in place by
|
|
5
|
+
* `scripts/stamp-telemetry-key.mjs`, which runs from `prepublishOnly`. So the
|
|
6
|
+
* key exists only in the published tarball: a clone, a fork, and a plain
|
|
7
|
+
* `npm run build` all compile to `''`, and every send path short-circuits. A
|
|
8
|
+
* contributor cannot accidentally send us their own usage, and a fork cannot
|
|
9
|
+
* send us anything at all.
|
|
10
|
+
*
|
|
11
|
+
* `GRAFT_POSTHOG_KEY` overrides it at runtime so a maintainer can exercise the
|
|
12
|
+
* real path locally without publishing.
|
|
13
|
+
*
|
|
14
|
+
* Public project keys are write-only ingestion keys — they authorise capture and
|
|
15
|
+
* nothing else — which is why one may sit in a published artifact at all. It is
|
|
16
|
+
* still not committed here: an empty default is what makes "forks never send"
|
|
17
|
+
* true by construction rather than by policy.
|
|
18
|
+
*/
|
|
19
|
+
/** Rewritten at publish time. Do not hand-edit — see the module comment. */
|
|
20
|
+
const BAKED_KEY = '';
|
|
21
|
+
/**
|
|
22
|
+
* Nanonets' own PostHog host, not `us.i.posthog.com`.
|
|
23
|
+
*
|
|
24
|
+
* Every Nanonets product ingests through a nanonets.com proxy rather than
|
|
25
|
+
* PostHog directly, on one shared project token, so pointing graft at PostHog
|
|
26
|
+
* Cloud would put its events in a project nobody looks at.
|
|
27
|
+
*
|
|
28
|
+
* `events.` rather than `e.` because graft is server-side, and this is the host
|
|
29
|
+
* the other server-side integration already uses (the agents-platform Go
|
|
30
|
+
* backend sets `POSTHOG_HOST=https://events.nanonets.com`). The one documented
|
|
31
|
+
* objection to it — 400 `invalid_payload` — was gzip-compressed ingest from
|
|
32
|
+
* `posthog-js` in a browser, fixed there with `disable_compression: true`. We
|
|
33
|
+
* send plain uncompressed JSON from Node, so that failure mode cannot apply.
|
|
34
|
+
*
|
|
35
|
+
* Probed directly, that host answers 401 to a well-formed batch with a bad key,
|
|
36
|
+
* so it serves `/batch/` and parses the body — see the note in send.ts.
|
|
37
|
+
*
|
|
38
|
+
* The HOST is safe to commit; the KEY is not, and stays empty here. That
|
|
39
|
+
* asymmetry is the point: with no key, a fork built from this source sends
|
|
40
|
+
* nothing no matter where the host points.
|
|
41
|
+
*/
|
|
42
|
+
const BAKED_HOST = 'https://events.nanonets.com';
|
|
43
|
+
export function posthogKey() {
|
|
44
|
+
return process.env.GRAFT_POSTHOG_KEY || BAKED_KEY;
|
|
45
|
+
}
|
|
46
|
+
export function posthogHost() {
|
|
47
|
+
return (process.env.GRAFT_POSTHOG_HOST || BAKED_HOST).replace(/\/+$/, '');
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../src/telemetry/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,4EAA4E;AAC5E,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,GAAG,6BAA6B,CAAC;AAEjD,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,UAAU,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const TELEMETRY_DOC_URL = "https://github.com/NanoNets/context-graph-engine/blob/main/TELEMETRY.md";
|
|
2
|
+
export declare const NOTICE: string;
|
|
3
|
+
/**
|
|
4
|
+
* The notice text the first time it is due, then null forever after. Marks it as
|
|
5
|
+
* shown before returning, so two concurrent commands print it at most twice
|
|
6
|
+
* rather than every time.
|
|
7
|
+
*/
|
|
8
|
+
export declare function firstRunNotice(home?: string, env?: NodeJS.ProcessEnv): string | null;
|
|
9
|
+
/** `graft telemetry status`. `env` is a test seam, as elsewhere in this module —
|
|
10
|
+
* a real run must be gated on the real `DO_NOT_TRACK` and CI variables. */
|
|
11
|
+
export declare function formatStatus(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
12
|
+
/**
|
|
13
|
+
* `graft telemetry debug` — Next.js's `NEXT_TELEMETRY_DEBUG` and Astro's
|
|
14
|
+
* `DEBUG=astro:telemetry` in command form. Prints the pending queue and the
|
|
15
|
+
* literal JSON body a flush would POST, and sends nothing. The point is that a
|
|
16
|
+
* user never has to take our word for the contract.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatDebug(home?: string): string;
|
|
19
|
+
//# sourceMappingURL=notice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../src/telemetry/notice.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,4EAA4E,CAAC;AAE3G,eAAO,MAAM,MAAM,QAGP,CAAC;AAEb;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CASpF;AAED;4EAC4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAoB3E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBjD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one-time disclosure, and the `graft telemetry` command's output.
|
|
3
|
+
*
|
|
4
|
+
* The notice is the whole reason this design is defensible. Every telemetry
|
|
5
|
+
* backlash in the tools we looked at — the GitHub CLI's silent 2.91.0 rollout,
|
|
6
|
+
* Gatsby's on-by-default addition, the .NET SDK's opt-out that distributors now
|
|
7
|
+
* patch out — was about a tool that started sending without saying so. Homebrew
|
|
8
|
+
* does exactly what is done here and is uncontroversial: print once, in plain
|
|
9
|
+
* language, before anything leaves, and say how to turn it off in the same
|
|
10
|
+
* breath.
|
|
11
|
+
*
|
|
12
|
+
* Once per MACHINE, not per repo: a dev with twelve checkouts should read this
|
|
13
|
+
* one time. `graft init`'s picker is the other disclosure surface, for the users
|
|
14
|
+
* who see it — this catches everyone else.
|
|
15
|
+
*/
|
|
16
|
+
import { patchState, readState } from './identity.js';
|
|
17
|
+
import { explainOff, offReason } from './gate.js';
|
|
18
|
+
import { peek } from './queue.js';
|
|
19
|
+
import { buildBatch } from './send.js';
|
|
20
|
+
import { posthogHost } from './key.js';
|
|
21
|
+
export const TELEMETRY_DOC_URL = 'https://github.com/NanoNets/context-graph-engine/blob/main/TELEMETRY.md';
|
|
22
|
+
export const NOTICE = [
|
|
23
|
+
'· graft collects anonymous usage stats (no code, no file paths, no queries).',
|
|
24
|
+
` What exactly: ${TELEMETRY_DOC_URL} — turn it off with \`graft telemetry disable\`.`,
|
|
25
|
+
].join('\n');
|
|
26
|
+
/**
|
|
27
|
+
* The notice text the first time it is due, then null forever after. Marks it as
|
|
28
|
+
* shown before returning, so two concurrent commands print it at most twice
|
|
29
|
+
* rather than every time.
|
|
30
|
+
*/
|
|
31
|
+
export function firstRunNotice(home, env) {
|
|
32
|
+
try {
|
|
33
|
+
if (offReason(home, env) !== null)
|
|
34
|
+
return null; // nothing to disclose if nothing can be sent
|
|
35
|
+
if (readState(home)?.noticeShownAt)
|
|
36
|
+
return null;
|
|
37
|
+
patchState({ noticeShownAt: new Date().toISOString() }, home);
|
|
38
|
+
return NOTICE;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** `graft telemetry status`. `env` is a test seam, as elsewhere in this module —
|
|
45
|
+
* a real run must be gated on the real `DO_NOT_TRACK` and CI variables. */
|
|
46
|
+
export function formatStatus(home, env) {
|
|
47
|
+
const reason = offReason(home, env);
|
|
48
|
+
const pending = peek(home).length;
|
|
49
|
+
const lines = [
|
|
50
|
+
reason === null
|
|
51
|
+
? 'telemetry: on — anonymous, aggregate-only'
|
|
52
|
+
: `telemetry: ${explainOff(reason)}`,
|
|
53
|
+
` contract: ${TELEMETRY_DOC_URL}`,
|
|
54
|
+
];
|
|
55
|
+
if (reason === null || reason === 'disabled') {
|
|
56
|
+
lines.push(` endpoint: ${posthogHost()}`);
|
|
57
|
+
lines.push(` queued: ${pending} event${pending === 1 ? '' : 's'} waiting for the next daily flush`);
|
|
58
|
+
}
|
|
59
|
+
lines.push(reason === 'disabled'
|
|
60
|
+
? ' enable: graft telemetry enable'
|
|
61
|
+
: ' disable: graft telemetry disable (or set DO_NOT_TRACK=1)');
|
|
62
|
+
lines.push(' inspect: graft telemetry debug (prints the exact batch, sends nothing)');
|
|
63
|
+
return lines.join('\n');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `graft telemetry debug` — Next.js's `NEXT_TELEMETRY_DEBUG` and Astro's
|
|
67
|
+
* `DEBUG=astro:telemetry` in command form. Prints the pending queue and the
|
|
68
|
+
* literal JSON body a flush would POST, and sends nothing. The point is that a
|
|
69
|
+
* user never has to take our word for the contract.
|
|
70
|
+
*/
|
|
71
|
+
export function formatDebug(home) {
|
|
72
|
+
const events = peek(home);
|
|
73
|
+
if (events.length === 0) {
|
|
74
|
+
return [
|
|
75
|
+
'telemetry: nothing queued.',
|
|
76
|
+
' Run a graft command first — events are written locally and flushed once a day.',
|
|
77
|
+
].join('\n');
|
|
78
|
+
}
|
|
79
|
+
// A literal placeholder, never the key itself. This output is written to be
|
|
80
|
+
// pasted into an issue; the project key is not the user's to share and is not
|
|
81
|
+
// needed to audit what graft sends.
|
|
82
|
+
const body = { api_key: '<omitted — graft\'s own ingestion key>', ...buildBatch(events) };
|
|
83
|
+
return [
|
|
84
|
+
`telemetry: ${events.length} event(s) queued. This is the exact body a flush would POST`,
|
|
85
|
+
`to ${posthogHost()}/batch/ — running this command sends nothing.`,
|
|
86
|
+
'',
|
|
87
|
+
JSON.stringify(body, null, 2),
|
|
88
|
+
].join('\n');
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice.js","sourceRoot":"","sources":["../../src/telemetry/notice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAA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AAM,KAAK,UAAU,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,gBAAgB,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,gBAAgB,OAAO,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mCAAmC,CAAC,CAAC;IAC1G,CAAC;IACD,KAAK,CAAC,IAAI,CACR,MAAM,KAAK,UAAU;QACnB,CAAC,CAAC,qCAAqC;QACvC,CAAC,CAAC,+DAA+D,CACpE,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;IAC3F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACL,4BAA4B;YAC5B,kFAAkF;SACnF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IACD,4EAA4E;IAC5E,8EAA8E;IAC9E,oCAAoC;IACpC,MAAM,IAAI,GAAG,EAAE,OAAO,EAAE,wCAAwC,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1F,OAAO;QACL,cAAc,MAAM,CAAC,MAAM,6DAA6D;QACxF,MAAM,WAAW,EAAE,+CAA+C;QAClE,EAAE;QACF,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ceiling on the queue. An unflushable machine — permanently offline, or a
|
|
3
|
+
* key that never works — must not grow a file in someone's home forever.
|
|
4
|
+
*
|
|
5
|
+
* Bytes are the bound, because size is the only thing cheap enough to check on
|
|
6
|
+
* every append (one `statSync`); counting lines would mean reading the whole
|
|
7
|
+
* file each time. {@link TRIM_TO_EVENTS} is not a second ceiling — it is how
|
|
8
|
+
* FAR a trim cuts back, so a queue of unusually small events sheds a worthwhile
|
|
9
|
+
* amount rather than one line at a time. Between trims the file can hold more
|
|
10
|
+
* than that many events, and can exceed the byte bound by one append.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MAX_QUEUE_BYTES: number;
|
|
13
|
+
export declare const TRIM_TO_EVENTS = 500;
|
|
14
|
+
export declare function queuePath(home?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Append one event. Never throws — a full disk or a read-only home must not fail
|
|
17
|
+
* the command the user actually ran.
|
|
18
|
+
*/
|
|
19
|
+
export declare function enqueue(event: unknown, home?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Take everything pending, leaving an empty queue behind.
|
|
22
|
+
*
|
|
23
|
+
* The rename is what makes this safe against a concurrent append: from the
|
|
24
|
+
* instant it returns, other processes are writing to a brand-new file. Malformed
|
|
25
|
+
* lines are skipped rather than poisoning the batch — a torn write from a crash
|
|
26
|
+
* mid-append should cost one event, not the whole queue.
|
|
27
|
+
*/
|
|
28
|
+
export declare function drain(home?: string): unknown[];
|
|
29
|
+
/** Read without draining, for `graft telemetry debug`. */
|
|
30
|
+
export declare function peek(home?: string): unknown[];
|
|
31
|
+
/** Put a failed batch back, so a flush that could not reach the network does not
|
|
32
|
+
* silently discard a week of events. Oldest-first, ahead of anything queued
|
|
33
|
+
* since the drain. */
|
|
34
|
+
export declare function requeue(events: unknown[], home?: string): void;
|
|
35
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/telemetry/queue.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,QAAa,CAAC;AAC1C,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAO3D;AA6BD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAa9C;AAED,0DAA0D;AAC1D,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAS7C;AAED;;uBAEuB;AACvB,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAS9D"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The local event queue: one NDJSON line per event in `~/.graft/`.
|
|
3
|
+
*
|
|
4
|
+
* The queue exists because graft is a CLI, not an app. Every other tool we
|
|
5
|
+
* studied sends from a process that is already running and can afford to wait;
|
|
6
|
+
* `graft ask` lives for two seconds and its whole value proposition is being
|
|
7
|
+
* faster than reading files. So nothing is ever sent inline — events are
|
|
8
|
+
* appended here, and a detached child (`graft _telemetry-flush`, once a day)
|
|
9
|
+
* does the network. A user who is offline for a week loses nothing; a user on a
|
|
10
|
+
* hostile network never notices, because no command ever waits on a socket.
|
|
11
|
+
*
|
|
12
|
+
* Concurrency: appends are a single `appendFileSync` of one short line to a file
|
|
13
|
+
* opened `O_APPEND`, which POSIX makes atomic below PIPE_BUF (4 KB — an event is
|
|
14
|
+
* ~300 bytes). Two graft processes interleaving cannot produce a torn line.
|
|
15
|
+
*
|
|
16
|
+
* Draining renames the file first and reads the renamed copy, so events appended
|
|
17
|
+
* during a flush land in a fresh queue instead of being dropped by the truncate.
|
|
18
|
+
*/
|
|
19
|
+
import { homedir } from 'node:os';
|
|
20
|
+
import { join, dirname } from 'node:path';
|
|
21
|
+
import { appendFileSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
22
|
+
/**
|
|
23
|
+
* The ceiling on the queue. An unflushable machine — permanently offline, or a
|
|
24
|
+
* key that never works — must not grow a file in someone's home forever.
|
|
25
|
+
*
|
|
26
|
+
* Bytes are the bound, because size is the only thing cheap enough to check on
|
|
27
|
+
* every append (one `statSync`); counting lines would mean reading the whole
|
|
28
|
+
* file each time. {@link TRIM_TO_EVENTS} is not a second ceiling — it is how
|
|
29
|
+
* FAR a trim cuts back, so a queue of unusually small events sheds a worthwhile
|
|
30
|
+
* amount rather than one line at a time. Between trims the file can hold more
|
|
31
|
+
* than that many events, and can exceed the byte bound by one append.
|
|
32
|
+
*/
|
|
33
|
+
export const MAX_QUEUE_BYTES = 256 * 1024;
|
|
34
|
+
export const TRIM_TO_EVENTS = 500;
|
|
35
|
+
export function queuePath(home = homedir()) {
|
|
36
|
+
return join(home, '.graft', 'telemetry-queue.ndjson');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Append one event. Never throws — a full disk or a read-only home must not fail
|
|
40
|
+
* the command the user actually ran.
|
|
41
|
+
*/
|
|
42
|
+
export function enqueue(event, home) {
|
|
43
|
+
const path = queuePath(home);
|
|
44
|
+
try {
|
|
45
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
46
|
+
appendFileSync(path, JSON.stringify(event) + '\n');
|
|
47
|
+
trim(path);
|
|
48
|
+
}
|
|
49
|
+
catch { /* unwritable home, full disk — telemetry is never worth an error */ }
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Enforce the cap by dropping the OLDEST events. Newest-wins because the recent
|
|
53
|
+
* ones describe the version the user is on now; a year-old queue from 0.9
|
|
54
|
+
* answers nothing. Only rewrites when actually over, so the common path is one
|
|
55
|
+
* `statSync`.
|
|
56
|
+
*/
|
|
57
|
+
function trim(path) {
|
|
58
|
+
let size;
|
|
59
|
+
try {
|
|
60
|
+
size = statSync(path).size;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (size <= MAX_QUEUE_BYTES)
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
const lines = readFileSync(path, 'utf8').split('\n').filter(Boolean);
|
|
69
|
+
// Walk backwards from the newest, taking lines while both budgets hold, so
|
|
70
|
+
// the file left behind always satisfies the byte bound — a count-only trim
|
|
71
|
+
// would leave 500 large events well over it.
|
|
72
|
+
const kept = [];
|
|
73
|
+
let bytes = 0;
|
|
74
|
+
for (let i = lines.length - 1; i >= 0 && kept.length < TRIM_TO_EVENTS; i--) {
|
|
75
|
+
bytes += Buffer.byteLength(lines[i]) + 1;
|
|
76
|
+
if (bytes > MAX_QUEUE_BYTES)
|
|
77
|
+
break;
|
|
78
|
+
kept.push(lines[i]);
|
|
79
|
+
}
|
|
80
|
+
kept.reverse();
|
|
81
|
+
writeFileSync(path, kept.length ? kept.join('\n') + '\n' : '');
|
|
82
|
+
}
|
|
83
|
+
catch { /* leave it; the next drain clears it anyway */ }
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Take everything pending, leaving an empty queue behind.
|
|
87
|
+
*
|
|
88
|
+
* The rename is what makes this safe against a concurrent append: from the
|
|
89
|
+
* instant it returns, other processes are writing to a brand-new file. Malformed
|
|
90
|
+
* lines are skipped rather than poisoning the batch — a torn write from a crash
|
|
91
|
+
* mid-append should cost one event, not the whole queue.
|
|
92
|
+
*/
|
|
93
|
+
export function drain(home) {
|
|
94
|
+
const path = queuePath(home);
|
|
95
|
+
const taken = `${path}.${process.pid}.sending`;
|
|
96
|
+
try {
|
|
97
|
+
renameSync(path, taken);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return [];
|
|
101
|
+
} // nothing queued
|
|
102
|
+
let text = '';
|
|
103
|
+
try {
|
|
104
|
+
text = readFileSync(taken, 'utf8');
|
|
105
|
+
}
|
|
106
|
+
catch { /* fall through to cleanup */ }
|
|
107
|
+
try {
|
|
108
|
+
rmSync(taken, { force: true });
|
|
109
|
+
}
|
|
110
|
+
catch { /* best effort */ }
|
|
111
|
+
const out = [];
|
|
112
|
+
for (const line of text.split('\n')) {
|
|
113
|
+
if (!line.trim())
|
|
114
|
+
continue;
|
|
115
|
+
try {
|
|
116
|
+
out.push(JSON.parse(line));
|
|
117
|
+
}
|
|
118
|
+
catch { /* torn line — skip just this one */ }
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
/** Read without draining, for `graft telemetry debug`. */
|
|
123
|
+
export function peek(home) {
|
|
124
|
+
const out = [];
|
|
125
|
+
let text = '';
|
|
126
|
+
try {
|
|
127
|
+
text = readFileSync(queuePath(home), 'utf8');
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
for (const line of text.split('\n')) {
|
|
133
|
+
if (!line.trim())
|
|
134
|
+
continue;
|
|
135
|
+
try {
|
|
136
|
+
out.push(JSON.parse(line));
|
|
137
|
+
}
|
|
138
|
+
catch { /* skip */ }
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
/** Put a failed batch back, so a flush that could not reach the network does not
|
|
143
|
+
* silently discard a week of events. Oldest-first, ahead of anything queued
|
|
144
|
+
* since the drain. */
|
|
145
|
+
export function requeue(events, home) {
|
|
146
|
+
if (events.length === 0)
|
|
147
|
+
return;
|
|
148
|
+
const path = queuePath(home);
|
|
149
|
+
try {
|
|
150
|
+
const pending = (() => { try {
|
|
151
|
+
return readFileSync(path, 'utf8');
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return '';
|
|
155
|
+
} })();
|
|
156
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
157
|
+
writeFileSync(path, events.map((e) => JSON.stringify(e)).join('\n') + '\n' + pending);
|
|
158
|
+
trim(path);
|
|
159
|
+
}
|
|
160
|
+
catch { /* best effort */ }
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/telemetry/queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/G;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,MAAM,UAAU,SAAS,CAAC,OAAe,OAAO,EAAE;IAChD,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,wBAAwB,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,IAAa;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC;QACH,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,CAAC;IAAC,MAAM,CAAC,CAAC,oEAAoE,CAAC,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,SAAS,IAAI,CAAC,IAAY;IACxB,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QAAC,IAAI,GAAG,QAAQ,CAAC,I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AAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;uBAEuB;AACvB,MAAM,UAAU,OAAO,CAAC,MAAiB,EAAE,IAAa;IACtD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;YAAC,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,EAAE,CAAC;QAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC;QACtF,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,CAAC;IAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface SendResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
status?: number;
|
|
4
|
+
/** Why it failed, for `graft telemetry debug` only — never itself reported. */
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The events as PostHog wants them — everything the wire body contains EXCEPT
|
|
9
|
+
* the project key.
|
|
10
|
+
*
|
|
11
|
+
* The key is deliberately not in here. `graft telemetry debug` prints this
|
|
12
|
+
* object so a user can audit exactly what graft sends, and a command that exists
|
|
13
|
+
* to be pasted into a bug report must not also paste our ingestion key into it.
|
|
14
|
+
* `sendBatch` adds the key at the moment of the request and nowhere else, which
|
|
15
|
+
* keeps the key entirely out of every code path that can reach a terminal.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildBatch(events: unknown[]): Record<string, unknown>;
|
|
18
|
+
export declare function sendBatch(events: unknown[]): Promise<SendResult>;
|
|
19
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/telemetry/send.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBrE;AAkBD,wBAAsB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAmBtE"}
|