@getmarrow/mcp 3.9.101 → 3.9.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +63 -29
  2. package/dist/cli.js +64 -1005
  3. package/dist/cli.js.map +1 -1
  4. package/dist/codex-plugin-pins.d.ts +19 -0
  5. package/dist/codex-plugin-pins.d.ts.map +1 -0
  6. package/dist/codex-plugin-pins.js +43 -0
  7. package/dist/codex-plugin-pins.js.map +1 -0
  8. package/dist/codex-plugins.d.ts +34 -0
  9. package/dist/codex-plugins.d.ts.map +1 -0
  10. package/dist/codex-plugins.js +240 -0
  11. package/dist/codex-plugins.js.map +1 -0
  12. package/dist/env.d.ts +2 -0
  13. package/dist/env.d.ts.map +1 -1
  14. package/dist/env.js +229 -39
  15. package/dist/env.js.map +1 -1
  16. package/dist/hook-contract.d.ts +41 -3
  17. package/dist/hook-contract.d.ts.map +1 -1
  18. package/dist/hook-contract.js +126 -18
  19. package/dist/hook-contract.js.map +1 -1
  20. package/dist/hook-pre-action.d.ts +48 -2
  21. package/dist/hook-pre-action.d.ts.map +1 -1
  22. package/dist/hook-pre-action.js +199 -23
  23. package/dist/hook-pre-action.js.map +1 -1
  24. package/dist/hook-tool-policy.d.ts +3 -3
  25. package/dist/hook-tool-policy.d.ts.map +1 -1
  26. package/dist/hook-tool-policy.js +6 -22
  27. package/dist/hook-tool-policy.js.map +1 -1
  28. package/dist/hook.d.ts +2 -2
  29. package/dist/hook.d.ts.map +1 -1
  30. package/dist/hook.js +13 -6
  31. package/dist/hook.js.map +1 -1
  32. package/dist/host-approval-state.d.ts +9 -0
  33. package/dist/host-approval-state.d.ts.map +1 -1
  34. package/dist/host-approval-state.js +4 -0
  35. package/dist/host-approval-state.js.map +1 -1
  36. package/dist/host-approval.d.ts +6 -0
  37. package/dist/host-approval.d.ts.map +1 -1
  38. package/dist/host-approval.js +3 -1
  39. package/dist/host-approval.js.map +1 -1
  40. package/dist/host-session.d.ts +11 -0
  41. package/dist/host-session.d.ts.map +1 -1
  42. package/dist/host-session.js +49 -0
  43. package/dist/host-session.js.map +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +27 -19
  46. package/dist/index.js.map +1 -1
  47. package/dist/normalized-action.d.ts +29 -6
  48. package/dist/normalized-action.d.ts.map +1 -1
  49. package/dist/normalized-action.js +497 -103
  50. package/dist/normalized-action.js.map +1 -1
  51. package/dist/own-server-identity.d.ts +123 -0
  52. package/dist/own-server-identity.d.ts.map +1 -0
  53. package/dist/own-server-identity.js +1052 -0
  54. package/dist/own-server-identity.js.map +1 -0
  55. package/dist/own-tool.d.ts +87 -0
  56. package/dist/own-tool.d.ts.map +1 -0
  57. package/dist/own-tool.js +169 -0
  58. package/dist/own-tool.js.map +1 -0
  59. package/dist/redact.d.ts +23 -0
  60. package/dist/redact.d.ts.map +1 -1
  61. package/dist/redact.js +181 -8
  62. package/dist/redact.js.map +1 -1
  63. package/dist/seatbelt/classifier-pin.d.ts +15 -0
  64. package/dist/seatbelt/classifier-pin.d.ts.map +1 -0
  65. package/dist/seatbelt/classifier-pin.js +26 -0
  66. package/dist/seatbelt/classifier-pin.js.map +1 -0
  67. package/dist/seatbelt/guards.d.ts +10 -0
  68. package/dist/seatbelt/guards.d.ts.map +1 -0
  69. package/dist/seatbelt/guards.js +509 -0
  70. package/dist/seatbelt/guards.js.map +1 -0
  71. package/dist/seatbelt/hook.d.ts +72 -0
  72. package/dist/seatbelt/hook.d.ts.map +1 -0
  73. package/dist/seatbelt/hook.js +362 -0
  74. package/dist/seatbelt/hook.js.map +1 -0
  75. package/dist/seatbelt/longopts.d.ts +68 -0
  76. package/dist/seatbelt/longopts.d.ts.map +1 -0
  77. package/dist/seatbelt/longopts.js +377 -0
  78. package/dist/seatbelt/longopts.js.map +1 -0
  79. package/dist/seatbelt/mapper.d.ts +83 -0
  80. package/dist/seatbelt/mapper.d.ts.map +1 -0
  81. package/dist/seatbelt/mapper.js +10248 -0
  82. package/dist/seatbelt/mapper.js.map +1 -0
  83. package/dist/seatbelt/record.d.ts +94 -0
  84. package/dist/seatbelt/record.d.ts.map +1 -0
  85. package/dist/seatbelt/record.js +776 -0
  86. package/dist/seatbelt/record.js.map +1 -0
  87. package/dist/seatbelt/tables.d.ts +82 -0
  88. package/dist/seatbelt/tables.d.ts.map +1 -0
  89. package/dist/seatbelt/tables.js +359 -0
  90. package/dist/seatbelt/tables.js.map +1 -0
  91. package/dist/seatbelt-deploy.d.ts +100 -0
  92. package/dist/seatbelt-deploy.d.ts.map +1 -0
  93. package/dist/seatbelt-deploy.js +393 -0
  94. package/dist/seatbelt-deploy.js.map +1 -0
  95. package/dist/seatbelt-fs.d.ts +30 -0
  96. package/dist/seatbelt-fs.d.ts.map +1 -0
  97. package/dist/seatbelt-fs.js +94 -0
  98. package/dist/seatbelt-fs.js.map +1 -0
  99. package/dist/seatbelt-git.d.ts +212 -0
  100. package/dist/seatbelt-git.d.ts.map +1 -0
  101. package/dist/seatbelt-git.js +844 -0
  102. package/dist/seatbelt-git.js.map +1 -0
  103. package/dist/seatbelt-mode.d.ts +77 -0
  104. package/dist/seatbelt-mode.d.ts.map +1 -0
  105. package/dist/seatbelt-mode.js +496 -0
  106. package/dist/seatbelt-mode.js.map +1 -0
  107. package/dist/seatbelt-path.d.ts +123 -0
  108. package/dist/seatbelt-path.d.ts.map +1 -0
  109. package/dist/seatbelt-path.js +482 -0
  110. package/dist/seatbelt-path.js.map +1 -0
  111. package/dist/seatbelt-scripts.d.ts +109 -0
  112. package/dist/seatbelt-scripts.d.ts.map +1 -0
  113. package/dist/seatbelt-scripts.js +1060 -0
  114. package/dist/seatbelt-scripts.js.map +1 -0
  115. package/dist/tool-catalog.d.ts +6852 -0
  116. package/dist/tool-catalog.d.ts.map +1 -0
  117. package/dist/tool-catalog.js +999 -0
  118. package/dist/tool-catalog.js.map +1 -0
  119. package/dist/types.d.ts +2 -1
  120. package/dist/types.d.ts.map +1 -1
  121. package/package.json +2 -1
  122. package/server.json +10 -3
  123. package/vendor/classifier/MANIFEST.json +25 -0
  124. package/vendor/classifier/classifier.js +1356 -0
  125. package/vendor/classifier/policy-baseline.js +187 -0
  126. package/vendor/classifier/redact.js +59 -0
  127. package/vendor/classifier/shell-parse.js +455 -0
@@ -0,0 +1,72 @@
1
+ import type { SeatbeltDecision, SeatbeltFs as MapperFs, SeatbeltGit } from './mapper';
2
+ import type { SeatbeltFs } from '../seatbelt-fs';
3
+ /**
4
+ * Compiled-in rollout table. Not env, not a file: changing a value is a one-line, reviewed code
5
+ * change. `keyless: 'off'` makes every keyless machine `claimed_no_key` (3.9.103 holds plus the
6
+ * floor). `account_floor: 'on'` enforces the S0-S5 floor before the server flow.
7
+ */
8
+ export declare const SEATBELT_ROLLOUT: {
9
+ readonly keyless: 'on' | 'off';
10
+ readonly account_floor: 'watch' | 'on';
11
+ };
12
+ /** One wall-clock budget for the whole seatbelt path (mode resolution and mapper). Over it: stop. */
13
+ export declare const HOOK_BUDGET_MS = 300;
14
+ export declare const CLAIMED_NO_KEY_TEXT = "Marrow is linked to an account but has no working key; owner: run `npx -y @getmarrow/install@latest doctor`.";
15
+ /**
16
+ * `claimed_no_key` with no account evidence and no rejected key: a fallback because the machine's
17
+ * setup could not be confirmed (an evidence dir others can write, an unreadable probe, a home
18
+ * mismatch, strict mode). Same holds as CLAIMED_NO_KEY_TEXT, but it never claims an account exists.
19
+ */
20
+ export declare const SETUP_UNCONFIRMED_TEXT = "Marrow has no working key on this machine and its keyless mode is off here (strict mode, or a home folder it cannot trust); owner: run `npx -y @getmarrow/install@latest doctor`.";
21
+ export declare function seatbeltStopText(category: string, rule: string, reason: string, mode: 'seatbelt' | 'claimed_no_key' | 'account', accountLinked?: boolean): string;
22
+ /** §4.2: an S0-S5 floor stop is lifted only by an enforced server allow (a verified permit); an advisory allow never lifts it. */
23
+ export declare function accountFloorStops(rollout: 'watch' | 'on', floor: Pick<SeatbeltDecision, 'decision'> | null, server: 'enforced_allow' | 'advisory_allow' | 'deny' | 'none'): boolean;
24
+ /** The mapper's file view over the host. Missing: null. A failure the mapper must not guess about throws (it stops on fs_error). */
25
+ export declare function hostMapperFs(fs3: SeatbeltFs): MapperFs;
26
+ /**
27
+ * The git view the mapper gets (r4 contract). `currentBranch` is read at every call, never cached;
28
+ * anything unclear is null. `getAll` throws when the config cannot be read in full.
29
+ */
30
+ export declare function hostSeatbeltGit(fs3: SeatbeltFs, home: string, env: NodeJS.ProcessEnv): SeatbeltGit;
31
+ export interface SeatbeltHookEvent {
32
+ tool_name: unknown;
33
+ tool_input: unknown;
34
+ /** The event's cwd as the harness sent it; anything but an absolute path means the workspace is unknown. */
35
+ cwd: unknown;
36
+ /** The harness adapter cut the input: the action is not known in full. */
37
+ truncated: boolean;
38
+ /** The harness session id; used only for the receipt's keyed session_key. */
39
+ session?: unknown;
40
+ }
41
+ export interface KeylessOutcome {
42
+ mode: 'seatbelt' | 'claimed_no_key';
43
+ /** The agent text of a stop; null when the seatbelt passes the action. */
44
+ stopText: string | null;
45
+ /** True only with account evidence or a rejected key: then the text may say the machine is linked to an account. */
46
+ accountLinked: boolean;
47
+ /**
48
+ * The mapper recognised the tool (audit H1). False: the seatbelt passed nothing it can vouch for, so
49
+ * the hook gives master's answer for that host instead of the seatbelt pass.
50
+ */
51
+ recognized: boolean;
52
+ }
53
+ /** The keyless branch of the hook: mode (U4), then the mapper (U2) with the U3 resolvers. Never throws. */
54
+ export declare function keylessSeatbelt(harness: string, event: SeatbeltHookEvent): KeylessOutcome;
55
+ /**
56
+ * The account floor. `watch`: computed after the answer, for the record only; it never throws and
57
+ * never writes output. `on` (not active): run before the server flow; a returned text is a stop.
58
+ */
59
+ export declare function accountFloor(harness: string, event: SeatbeltHookEvent, deadlineAt: number): string | null;
60
+ /**
61
+ * I3: how the mapper reads an action for the outage hold (Marrow unreachable). `high`: an S0-S5/S-x hit
62
+ * or a program on the outage list (git push, publish, deploy, remote delete), a dynamic subcommand of a
63
+ * listed program included. `not_high`: the mapper read all of it and found neither. `unknown`: it could
64
+ * not (budget, error, unparsed or dynamic text, truncated input, a tool it does not recognise); the hook
65
+ * then keeps the client classifier's answer. `shell`: the event ran a shell command. Never throws;
66
+ * writes no receipt or output.
67
+ */
68
+ export declare function outageRisk(event: SeatbeltHookEvent, deadlineAt: number): {
69
+ shell: boolean;
70
+ risk: 'high' | 'not_high' | 'unknown';
71
+ };
72
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/seatbelt/hook.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAe,UAAU,IAAI,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,KAAK,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;CAGrG,CAAC;AAEH,qGAAqG;AACrG,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,eAAO,MAAM,mBAAmB,iHAAiH,CAAC;AAClJ;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,sLAAsL,CAAC;AAmB1N,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,gBAAgB,GAAG,SAAS,EAAE,aAAa,UAAO,GAAG,MAAM,CAO9J;AAED,kIAAkI;AAClI,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG,IAAI,EAChD,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,MAAM,GAAG,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MED_TEXT = exports.CLAIMED_NO_KEY_TEXT = exports.HOOK_BUDGET_MS = exports.SEATBELT_ROLLOUT = void 0;
4
+ exports.seatbeltStopText = seatbeltStopText;
5
+ exports.accountFloorStops = accountFloorStops;
6
+ exports.hostMapperFs = hostMapperFs;
7
+ exports.hostSeatbeltGit = hostSeatbeltGit;
8
+ exports.keylessSeatbelt = keylessSeatbelt;
9
+ exports.accountFloor = accountFloor;
10
+ exports.outageRisk = outageRisk;
11
+ /**
12
+ * Compiled-in rollout table. Not env, not a file: changing a value is a one-line, reviewed code
13
+ * change. `keyless: 'off'` makes every keyless machine `claimed_no_key` (3.9.103 holds plus the
14
+ * floor). `account_floor: 'on'` enforces the S0-S5 floor before the server flow.
15
+ */
16
+ exports.SEATBELT_ROLLOUT = Object.freeze({
17
+ keyless: 'on',
18
+ account_floor: 'watch',
19
+ });
20
+ /** One wall-clock budget for the whole seatbelt path (mode resolution and mapper). Over it: stop. */
21
+ exports.HOOK_BUDGET_MS = 300;
22
+ exports.CLAIMED_NO_KEY_TEXT = 'Marrow is linked to an account but has no working key; owner: run `npx -y @getmarrow/install@latest doctor`.';
23
+ /**
24
+ * `claimed_no_key` with no account evidence and no rejected key: a fallback because the machine's
25
+ * setup could not be confirmed (an evidence dir others can write, an unreadable probe, a home
26
+ * mismatch, strict mode). Same holds as CLAIMED_NO_KEY_TEXT, but it never claims an account exists.
27
+ */
28
+ exports.SETUP_UNCONFIRMED_TEXT = 'Marrow has no working key on this machine and its keyless mode is off here (strict mode, or a home folder it cannot trust); owner: run `npx -y @getmarrow/install@latest doctor`.';
29
+ const LABELS = {
30
+ S0: 'a change to Marrow seatbelt settings or an owner-only command',
31
+ S1: 'force-push or delete of a protected branch',
32
+ S2: 'production deploy',
33
+ S3: 'package publish',
34
+ S4: 'credential or secret access',
35
+ S5: 'recursive delete outside the workspace',
36
+ Sx: 'obfuscated execution',
37
+ hook: 'a safety check that could not finish',
38
+ };
39
+ const CODE = /^[A-Za-z0-9_.:-]{1,64}$/;
40
+ function codes(list) {
41
+ return Array.isArray(list) ? list.filter((item) => typeof item === 'string' && CODE.test(item)).slice(0, 16) : [];
42
+ }
43
+ function seatbeltStopText(category, rule, reason, mode, accountLinked = true) {
44
+ const label = LABELS[category] || LABELS.hook;
45
+ const head = `MARROW SEATBELT stopped this action: ${label} (${CODE.test(rule) ? rule : 'unknown'}, ${CODE.test(reason) ? reason : 'unknown'}). This needs the machine owner. Do not retry it another way or edit Marrow settings.`;
46
+ if (mode === 'account')
47
+ return `${head} Tell the owner: run it yourself in your own terminal.`;
48
+ return mode === 'seatbelt'
49
+ ? `${head} Tell the owner: run it yourself in your own terminal, or link a Marrow account with "npx -y @getmarrow/install@latest activate" (it needs MARROW_API_KEY set first) so these become approval prompts.`
50
+ : `${head} ${accountLinked ? exports.CLAIMED_NO_KEY_TEXT : exports.SETUP_UNCONFIRMED_TEXT}`;
51
+ }
52
+ /** §4.2: an S0-S5 floor stop is lifted only by an enforced server allow (a verified permit); an advisory allow never lifts it. */
53
+ function accountFloorStops(rollout, floor, server) {
54
+ if (rollout !== 'on' || !floor || floor.decision !== 'stop')
55
+ return false;
56
+ return server !== 'enforced_allow';
57
+ }
58
+ /** The event as the receipt writer may use it: to derive enums and keyed hashes only, never stored. */
59
+ function recordContext(event, home) {
60
+ return { tool_name: event.tool_name, tool_input: event.tool_input, cwd: event.cwd, session: event.session, truncated: event.truncated, home };
61
+ }
62
+ function record(entry, event, home) {
63
+ try {
64
+ require('./record').recordSeatbeltDecision(entry, recordContext(event, home));
65
+ }
66
+ catch { /* the record hook never changes a decision */ }
67
+ }
68
+ function gone(error) {
69
+ const code = error?.code;
70
+ return code === 'ENOENT' || code === 'ENOTDIR';
71
+ }
72
+ function unreadable(error) {
73
+ const code = error?.code;
74
+ return code === 'EACCES' || code === 'EPERM';
75
+ }
76
+ /** The mapper's file view over the host. Missing: null. A failure the mapper must not guess about throws (it stops on fs_error). */
77
+ function hostMapperFs(fs3) {
78
+ const fs = require('node:fs');
79
+ const realpath = (p) => {
80
+ try {
81
+ return fs.realpathSync(p);
82
+ }
83
+ catch (error) {
84
+ if (gone(error))
85
+ return null;
86
+ throw error;
87
+ }
88
+ };
89
+ return {
90
+ realpath,
91
+ readFile(p, maxBytes) {
92
+ const real = realpath(p);
93
+ if (real === null)
94
+ return null;
95
+ try {
96
+ return fs3.readFile(real, maxBytes);
97
+ }
98
+ catch (error) {
99
+ if (gone(error) || unreadable(error))
100
+ return null;
101
+ throw error;
102
+ }
103
+ },
104
+ readdir(p) {
105
+ try {
106
+ return fs.readdirSync(p);
107
+ }
108
+ catch (error) {
109
+ if (gone(error) || unreadable(error))
110
+ return null;
111
+ throw error;
112
+ }
113
+ },
114
+ };
115
+ }
116
+ const BRANCH_NAME = /^[A-Za-z0-9._/+@-]+$/;
117
+ /**
118
+ * The git view the mapper gets (r4 contract). `currentBranch` is read at every call, never cached;
119
+ * anything unclear is null. `getAll` throws when the config cannot be read in full.
120
+ */
121
+ function hostSeatbeltGit(fs3, home, env) {
122
+ const G = require('../seatbelt-git');
123
+ const P = require('../seatbelt-path');
124
+ const gitEnv = () => Object.keys(env).some((name) => name.startsWith('GIT_'));
125
+ const configEnv = { ...env };
126
+ // git reads $HOME; when it is the trusted home under another spelling (a symlink) it is the same files.
127
+ if (typeof env.HOME === 'string' && env.HOME !== home) {
128
+ const real = P.realPath(fs3, env.HOME, { followFinal: true });
129
+ if (real.status === 'resolved' && real.exists && real.path === home)
130
+ configEnv.HOME = home;
131
+ }
132
+ // The work tree that holds the `.git` entry nearest to cwd; null when none; 'unknown' when unclear.
133
+ const worktree = (cwd) => {
134
+ const real = P.realPath(fs3, cwd, { followFinal: true });
135
+ if (real.status !== 'resolved' || !real.exists)
136
+ return 'unknown';
137
+ let dir = real.path;
138
+ for (;;) {
139
+ const entry = fs3.lstat(dir === '/' ? '/.git' : `${dir}/.git`);
140
+ if (entry && (entry.type === 'dir' || entry.type === 'file'))
141
+ return dir;
142
+ if (entry)
143
+ return 'unknown';
144
+ if (dir === '/')
145
+ return null;
146
+ dir = dir.slice(0, dir.lastIndexOf('/')) || '/';
147
+ }
148
+ };
149
+ const dirsOf = (cwd) => {
150
+ const dirs = G.discoverGitDirs(fs3, cwd, configEnv);
151
+ if (dirs === 'unknown')
152
+ throw new Error('git_dirs_unknown');
153
+ return dirs;
154
+ };
155
+ const refExists = (commonDir, branch) => {
156
+ const loose = fs3.lstat(`${commonDir}/refs/heads/${branch}`);
157
+ if (loose && loose.type === 'file')
158
+ return true;
159
+ if (loose)
160
+ return false;
161
+ const packedEntry = fs3.lstat(`${commonDir}/packed-refs`);
162
+ if (!packedEntry)
163
+ return false;
164
+ if (packedEntry.type !== 'file')
165
+ return false;
166
+ const packed = fs3.readFile(`${commonDir}/packed-refs`, G.MAX_GIT_CONFIG_BYTES);
167
+ return packed !== null && packed.split('\n').some((line) => line.endsWith(` refs/heads/${branch}`));
168
+ };
169
+ return {
170
+ toplevel(cwd) {
171
+ if (gitEnv())
172
+ throw new Error('git_env');
173
+ const top = worktree(cwd);
174
+ if (top === 'unknown')
175
+ throw new Error('git_toplevel_unknown');
176
+ return top;
177
+ },
178
+ getAll(cwd, key) {
179
+ const dirs = dirsOf(cwd);
180
+ const config = G.loadGitConfig(fs3, { home, dirs, env: configEnv });
181
+ if (config.incomplete)
182
+ throw new Error('git_config_unreadable');
183
+ return G.gitConfigValues(config, key);
184
+ },
185
+ currentBranch(cwd) {
186
+ if (gitEnv())
187
+ return null;
188
+ try {
189
+ const top = worktree(cwd);
190
+ if (top === null || top === 'unknown')
191
+ return null;
192
+ const dirs = G.discoverGitDirs(fs3, cwd, configEnv);
193
+ if (dirs === null || dirs === 'unknown')
194
+ return null;
195
+ for (const marker of ['rebase-merge', 'rebase-apply', 'BISECT_LOG'])
196
+ if (fs3.lstat(`${dirs.gitDir}/${marker}`))
197
+ return null;
198
+ const head = G.readGitHead(fs3, dirs);
199
+ if (head.kind !== 'branch')
200
+ return null;
201
+ const name = head.branch;
202
+ if (!BRANCH_NAME.test(name) || name.startsWith('-') || name.startsWith('/') || name.endsWith('/')
203
+ || name.includes('..') || name.includes('//') || name.endsWith('.lock'))
204
+ return null;
205
+ return refExists(dirs.commonDir, name) ? name : null;
206
+ }
207
+ catch {
208
+ return null;
209
+ }
210
+ },
211
+ remoteHead(cwd, remote) {
212
+ const dirs = dirsOf(cwd);
213
+ if (!dirs)
214
+ return null;
215
+ const head = G.readRemoteDefaultBranch(fs3, dirs, remote);
216
+ if (head === 'unknown')
217
+ throw new Error('remote_head_unknown');
218
+ return head;
219
+ },
220
+ };
221
+ }
222
+ const TEMP_ROOTS = /^\/(?:tmp|var\/tmp|private\/tmp|var\/folders|private\/var\/folders)(?:\/|$)/;
223
+ /** $TMPDIR only when it resolves under a system temp root: the environment can only narrow the workspace. */
224
+ function trustedTmpdir() {
225
+ try {
226
+ const real = require('node:fs').realpathSync(require('node:os').tmpdir());
227
+ return TEMP_ROOTS.test(real) && real !== '/' ? real : undefined;
228
+ }
229
+ catch {
230
+ return undefined;
231
+ }
232
+ }
233
+ function mapperEnv(home, cwd, budgetMs) {
234
+ const fs3 = require('../seatbelt-fs').nodeSeatbeltFs();
235
+ return {
236
+ cwd: typeof cwd === 'string' && cwd.startsWith('/') ? cwd : null,
237
+ home,
238
+ tmpdir: trustedTmpdir(),
239
+ platform: process.platform,
240
+ fs: hostMapperFs(fs3),
241
+ git: hostSeatbeltGit(fs3, home, process.env),
242
+ budgetMs: Math.max(0, budgetMs),
243
+ };
244
+ }
245
+ function evaluate(event, home, budgetMs) {
246
+ const { evaluateSeatbelt } = require('./mapper');
247
+ return evaluateSeatbelt({ tool_name: String(event.tool_name || ''), tool_input: event.tool_input }, mapperEnv(home, event.cwd, budgetMs));
248
+ }
249
+ function passwdHome() {
250
+ try {
251
+ const home = require('node:os').userInfo().homedir;
252
+ return typeof home === 'string' && home.startsWith('/') ? home : null;
253
+ }
254
+ catch {
255
+ return null;
256
+ }
257
+ }
258
+ /** The keyless branch of the hook: mode (U4), then the mapper (U2) with the U3 resolvers. Never throws. */
259
+ function keylessSeatbelt(harness, event) {
260
+ const started = Date.now();
261
+ let mode = 'claimed_no_key';
262
+ let accountLinked = false;
263
+ let trustedHome;
264
+ const stop = (reason) => {
265
+ record({ v: 1, mode, enforcement: 'enforce', harness, decision: 'stop', category: 'hook', rule: 'U5.fail_closed', reasons: [reason], flags: [], parse: 'unparsed', latency_ms: Date.now() - started }, event, trustedHome);
266
+ return { mode, accountLinked, recognized: true, stopText: seatbeltStopText('hook', 'U5.fail_closed', reason, mode, accountLinked) };
267
+ };
268
+ try {
269
+ const { resolveSeatbeltModeOnHost } = require('../seatbelt-mode');
270
+ const resolution = resolveSeatbeltModeOnHost();
271
+ mode = resolution.mode === 'seatbelt' && exports.SEATBELT_ROLLOUT.keyless === 'on' ? 'seatbelt' : 'claimed_no_key';
272
+ accountLinked = resolution.reasons.includes('account_evidence') || resolution.reasons.includes('key_rejected');
273
+ if (event.truncated)
274
+ return stop('input_truncated');
275
+ const home = resolution.homes[0] || passwdHome() || '/nonexistent-home';
276
+ trustedHome = home;
277
+ const decision = evaluate(event, home, exports.HOOK_BUDGET_MS - (Date.now() - started));
278
+ if (Date.now() - started > exports.HOOK_BUDGET_MS)
279
+ return stop('hook_budget');
280
+ const reasons = codes(decision.reasons);
281
+ record({
282
+ v: 1, mode, enforcement: 'enforce', harness, decision: decision.decision === 'pass' ? 'pass' : 'stop',
283
+ category: CODE.test(decision.category) ? decision.category : 'unknown', rule: CODE.test(decision.rule) ? decision.rule : 'unknown',
284
+ reasons, flags: codes(decision.flags), parse: CODE.test(decision.parse) ? decision.parse : 'unknown', latency_ms: Date.now() - started,
285
+ }, event, home);
286
+ if (decision.decision === 'pass')
287
+ return { mode, accountLinked, recognized: decision.recognized === true, stopText: null };
288
+ return { mode, accountLinked, recognized: true, stopText: seatbeltStopText(decision.category, decision.rule, reasons[0] || 'unspecified', mode, accountLinked) };
289
+ }
290
+ catch {
291
+ return stop('hook_error');
292
+ }
293
+ }
294
+ /**
295
+ * The account floor. `watch`: computed after the answer, for the record only; it never throws and
296
+ * never writes output. `on` (not active): run before the server flow; a returned text is a stop.
297
+ */
298
+ function accountFloor(harness, event, deadlineAt) {
299
+ const started = Date.now();
300
+ try {
301
+ const budget = Math.min(exports.HOOK_BUDGET_MS, (Number.isFinite(deadlineAt) ? deadlineAt : Number.POSITIVE_INFINITY) - started - 200);
302
+ const enforcement = exports.SEATBELT_ROLLOUT.account_floor === 'on' ? 'enforce' : 'watch';
303
+ if (!(budget >= 20)) {
304
+ record({ v: 1, mode: 'account', enforcement, harness, decision: 'skipped', category: 'none', rule: 'none', reasons: ['floor_no_budget'], flags: [], parse: 'ok', latency_ms: 0 }, event);
305
+ return enforcement === 'enforce' ? seatbeltStopText('hook', 'U5.fail_closed', 'hook_budget', 'account') : null;
306
+ }
307
+ const decision = event.truncated ? null : evaluate(event, passwdHome() || '/nonexistent-home', budget);
308
+ const stopped = decision === null || decision.decision === 'stop' || Date.now() - started > budget;
309
+ record({
310
+ v: 1, mode: 'account', enforcement, harness, decision: stopped ? 'stop' : 'pass',
311
+ category: decision && CODE.test(decision.category) ? decision.category : 'hook', rule: decision && CODE.test(decision.rule) ? decision.rule : 'U5.fail_closed',
312
+ reasons: decision ? codes(decision.reasons) : ['input_truncated'], flags: decision ? codes(decision.flags) : [],
313
+ parse: decision && CODE.test(decision.parse) ? decision.parse : 'unparsed', latency_ms: Date.now() - started,
314
+ }, event);
315
+ if (!accountFloorStops(exports.SEATBELT_ROLLOUT.account_floor, { decision: stopped ? 'stop' : 'pass' }, 'none'))
316
+ return null;
317
+ return decision && decision.decision === 'stop'
318
+ ? seatbeltStopText(decision.category, decision.rule, codes(decision.reasons)[0] || 'unspecified', 'account')
319
+ : seatbeltStopText('hook', 'U5.fail_closed', decision ? 'hook_budget' : 'input_truncated', 'account');
320
+ }
321
+ catch {
322
+ return exports.SEATBELT_ROLLOUT.account_floor === 'on' ? seatbeltStopText('hook', 'U5.fail_closed', 'hook_error', 'account') : null;
323
+ }
324
+ }
325
+ // Hits that only mean the mapper could not finish (load, an internal error): not a reading of the action.
326
+ const UNFINISHED_HIT = /^(?:budget_[a-z_]+|mapper_error|fs_error)$/;
327
+ /**
328
+ * I3: how the mapper reads an action for the outage hold (Marrow unreachable). `high`: an S0-S5/S-x hit
329
+ * or a program on the outage list (git push, publish, deploy, remote delete), a dynamic subcommand of a
330
+ * listed program included. `not_high`: the mapper read all of it and found neither. `unknown`: it could
331
+ * not (budget, error, unparsed or dynamic text, truncated input, a tool it does not recognise); the hook
332
+ * then keeps the client classifier's answer. `shell`: the event ran a shell command. Never throws;
333
+ * writes no receipt or output.
334
+ */
335
+ function outageRisk(event, deadlineAt) {
336
+ const started = Date.now();
337
+ try {
338
+ const budget = Math.min(exports.HOOK_BUDGET_MS, (Number.isFinite(deadlineAt) ? deadlineAt : Number.POSITIVE_INFINITY) - started - 200);
339
+ if (!(budget >= 20) || event.truncated)
340
+ return { shell: false, risk: 'unknown' };
341
+ const decision = evaluate(event, passwdHome() || '/nonexistent-home', budget);
342
+ const shell = decision.shell === true;
343
+ if (Date.now() - started > budget)
344
+ return { shell, risk: 'unknown' };
345
+ // T-3: a command that only prints its help or version is never held in an outage.
346
+ if (decision.outageHelpOnly === true && decision.parse === 'ok' && decision.recognized === true)
347
+ return { shell, risk: 'not_high' };
348
+ // A real hit or a listed program is high even where the rest of the text could not be read; a listed
349
+ // program whose subcommand word is dynamic (`unknown`) may be the listed one, so it is high too.
350
+ if (decision.hits.some((h) => !UNFINISHED_HIT.test(h.reason)))
351
+ return { shell, risk: 'high' };
352
+ if (decision.risk.length)
353
+ return { shell, risk: 'high' };
354
+ if (decision.decision === 'stop' || decision.parse !== 'ok' || decision.recognized !== true)
355
+ return { shell, risk: 'unknown' };
356
+ return { shell, risk: 'not_high' };
357
+ }
358
+ catch {
359
+ return { shell: false, risk: 'unknown' };
360
+ }
361
+ }
362
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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K,GAAG,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC;QACtC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,GAAG,MAAM;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACrE,kFAAkF;QAClF,IAAI,QAAQ,CAAC,cAAc,KAAK,IAAI,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,KAAK,IAAI;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QACpI,qGAAqG;QACrG,iGAAiG;QACjG,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC9F,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACzD,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,KAAK,IAAI;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC/H,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC3C,CAAC;AACH,CAAC"}
@@ -0,0 +1,68 @@
1
+ /** n: no value. v: a value, `--name=value` or the next word. o: an optional value, `--name=value` only. a: any of these (long lists whose modes do not matter). */
2
+ export type LongMode = 'n' | 'v' | 'o' | 'a';
3
+ export type LongList = ReadonlyMap<string, LongMode>;
4
+ /** A word of a command line; a null text is a word the mapper cannot read. */
5
+ export interface OptWord {
6
+ readonly text: string | null;
7
+ }
8
+ /**
9
+ * Builds a list from text. Tokens are separated by spaces: `name` (no value), `name=` (a value), `name[=]` (an
10
+ * optional value), `name~` (any form). A leading `[no-]` adds the `no-name` form (no value).
11
+ */
12
+ export declare function longList(text: string): LongList;
13
+ /**
14
+ * The indexes of the long options in `words` that are not on `list` (exact name; `=value` only where the option
15
+ * takes one); empty when every long option is on it. A bare `--` ends the options when `honourEnd` is set. A value
16
+ * word that belongs to a listed option (`--name value`) is skipped. `dashes` is 2 for `--name`; find writes its
17
+ * options as `-name` (1), where `=` is never part of an option. A word with no readable text is not a long option here
18
+ * (each parser already treats it on its own).
19
+ */
20
+ export declare function unknownLongAll(words: readonly OptWord[], list: LongList, dashes?: 1 | 2, honourEnd?: boolean): number[];
21
+ /** The index of the first long option that is not on `list` (see unknownLongAll), or -1. */
22
+ export declare function unknownLong(words: readonly OptWord[], list: LongList, dashes?: 1 | 2, honourEnd?: boolean): number;
23
+ /** True for a word that is exactly `--name` of a listed option that takes its value as the next word. */
24
+ export declare function takesNextWord(text: string, list: LongList): boolean;
25
+ /** The text after `=` of a `--name=value` word, or null when there is none. */
26
+ export declare function longValue(text: string): string | null;
27
+ export declare const NO_LONG: LongList;
28
+ export declare const CP_LONG: LongList;
29
+ export declare const MV_LONG: LongList;
30
+ export declare const LN_LONG: LongList;
31
+ export declare const INSTALL_LONG: LongList;
32
+ export declare const TAR_LONG: LongList;
33
+ export declare const SED_LONG: LongList;
34
+ export declare const CURL_LONG: LongList;
35
+ export declare const WGET_LONG: LongList;
36
+ export declare const RSYNC_LONG: LongList;
37
+ export declare const SCP_LONG: LongList;
38
+ export declare const CAT_LONG: LongList;
39
+ export declare const HEAD_LONG: LongList;
40
+ export declare const TAIL_LONG: LongList;
41
+ export declare const WC_LONG: LongList;
42
+ export declare const STAT_LONG: LongList;
43
+ export declare const LS_LONG: LongList;
44
+ export declare const DU_LONG: LongList;
45
+ export declare const DIFF_LONG: LongList;
46
+ export declare const CMP_LONG: LongList;
47
+ export declare const FILE_LONG: LongList;
48
+ export declare const GREP_LONG: LongList;
49
+ export declare const CHECKSUM_LONG: LongList;
50
+ export declare const JQ_LONG: LongList;
51
+ export declare const YQ_LONG: LongList;
52
+ export declare const BAT_LONG: LongList;
53
+ export declare const LESS_LONG: LongList;
54
+ export declare const MORE_LONG: LongList;
55
+ export declare const RG_LONG: LongList;
56
+ export declare const TREE_LONG: LongList;
57
+ export declare const PRETTIER_LONG: LongList;
58
+ export declare const ZIP_LONG: LongList;
59
+ export declare const ENV_LONG: LongList;
60
+ export declare const SUDO_LONG: LongList;
61
+ export declare const DOAS_LONG: LongList;
62
+ export declare const GIT_READ_LONG: LongList;
63
+ export declare const GIT_GLOBAL_LONG: LongList;
64
+ export declare const GIT_RESET_LONG: LongList;
65
+ export declare const GIT_RM_LONG: LongList;
66
+ export declare const GIT_RESTORE_LONG: LongList;
67
+ export declare const FIND_LONG: LongList;
68
+ //# sourceMappingURL=longopts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"longopts.d.ts","sourceRoot":"","sources":["../../src/seatbelt/longopts.ts"],"names":[],"mappings":"AAkBA,mKAAmK;AACnK,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC7C,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAErD,8EAA8E;AAC9E,MAAM,WAAW,OAAO;IAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AAEzD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAe/C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAE,CAAC,GAAG,CAAK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