@burtson-labs/host-kit 0.4.1 → 0.4.3

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.
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Grant scope — what a permission choice actually authorizes.
3
+ *
4
+ * The bug this module exists to kill: the card and the stored rule disagreed.
5
+ * Picking "always" on
6
+ *
7
+ * npx create-vite my-app --template react
8
+ *
9
+ * showed that command on the card and then persisted `run_command:npx` to
10
+ * `.bandit/settings.json` — every future `npx <anything>`, forever. And "allow
11
+ * session" called `store.grant(toolName)` with no argument at all, so
12
+ * approving `git status` authorized `rm -rf /` for the rest of the session.
13
+ *
14
+ * Both hosts now compute the rule HERE, render it on the card, and store
15
+ * exactly the string they rendered. If the two ever drift again, they drift
16
+ * together and one test catches it.
17
+ *
18
+ * Scope model:
19
+ *
20
+ * - `once` Nothing stored.
21
+ * - `turn` Nothing stored; the host remembers it for the current turn only.
22
+ * Covers the "model emitted six edits in one iteration" case
23
+ * without buying anything beyond it.
24
+ * - `session` A deliberately broader rule, held in memory until the session
25
+ * ends. Broad enough to stop prompt-spam mid-task.
26
+ * - `always` The same rule, written to `.bandit/settings.json`.
27
+ *
28
+ * `session` and `always` share one rule so the user learns a single mental
29
+ * model and the only difference is how long it lasts.
30
+ */
31
+ import type { PermissionPolicy } from './permissions';
32
+ export type GrantScope = 'once' | 'turn' | 'session' | 'always';
33
+ export interface GrantRule {
34
+ /** The policy pattern to store, or null when the scope stores nothing. */
35
+ rule: string | null;
36
+ /** One-line plain-English blast radius, rendered under the option. */
37
+ describes: string;
38
+ }
39
+ /**
40
+ * Reduce a command line to the part worth granting on: the binary plus the
41
+ * subcommand that says what kind of operation it is.
42
+ *
43
+ * git status → git status
44
+ * git push origin main → git push
45
+ * npx create-vite my-app --template react → npx create-vite
46
+ * npm test -- --watch → npm test
47
+ * npm run build → npm run build (dispatcher)
48
+ * tsc --noEmit → tsc
49
+ *
50
+ * Two tokens by default. A third only after a dispatcher, because otherwise
51
+ * ordinary arguments creep in: `git push origin main` would sign as `git push
52
+ * origin`, which is both too narrow to be useful (a different remote re-prompts)
53
+ * and misleading about what it covers. Remote names, branch names, and script
54
+ * names are plain words — there is no lexical way to tell them from
55
+ * subcommands, so the rule is positional rather than clever.
56
+ */
57
+ export declare function commandSignature(full: string): string;
58
+ export interface GrantScopeInput {
59
+ toolName: string;
60
+ params: Record<string, string>;
61
+ /** The narrow primary the host already computes (path / cmd / url / query). */
62
+ primary: string;
63
+ /** For run_command, the full `cmd + args` line shown on the card. */
64
+ primaryFull?: string;
65
+ }
66
+ /**
67
+ * Compute the rule a given scope would store. The host renders `describes` on
68
+ * the option and stores `rule` verbatim if the user picks it.
69
+ */
70
+ export declare function grantRuleFor(input: GrantScopeInput, scope: GrantScope): GrantRule;
71
+ /**
72
+ * Does this policy already authorize the call a rule would cover? Used to skip
73
+ * a redundant card when a queued parallel call arrives after its sibling was
74
+ * granted.
75
+ */
76
+ export declare function policyIncludes(policy: PermissionPolicy, rule: string): boolean;
77
+ //# sourceMappingURL=grantScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grantScope.d.ts","sourceRoot":"","sources":["../src/grantScope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;CACnB;AA6BD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWrD;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,CA6DjF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9E"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commandSignature = commandSignature;
4
+ exports.grantRuleFor = grantRuleFor;
5
+ exports.policyIncludes = policyIncludes;
6
+ const EDIT_TOOLS = new Set(['apply_edit', 'replace_range', 'write_file', 'apply_patch']);
7
+ /**
8
+ * Tokens that make a command line specific to one run rather than to a kind of
9
+ * work — paths, filenames, URLs, versions, flags with values. A grant should
10
+ * generalize over these, not pin to them, or "always allow `npm test`" fails to
11
+ * match `npm test -- --watch` and the user gets prompted again immediately.
12
+ */
13
+ function isVariableToken(token) {
14
+ return token.startsWith('-')
15
+ || token.includes('/')
16
+ || token.includes('.')
17
+ || token.includes('=')
18
+ || token.includes('@')
19
+ || /^\d/.test(token)
20
+ || /^https?:/i.test(token);
21
+ }
22
+ /**
23
+ * Subcommands that don't do anything themselves — they dispatch to whatever the
24
+ * NEXT token names. `npm run` is not an operation; `npm run build` is. Granting
25
+ * at `npm run` would authorize every script in package.json, which is the same
26
+ * class of over-grant this module exists to prevent, so these get one extra
27
+ * token of specificity.
28
+ */
29
+ const DISPATCHER_SUBCOMMANDS = new Set(['run', 'exec', 'compose', 'global']);
30
+ /**
31
+ * Reduce a command line to the part worth granting on: the binary plus the
32
+ * subcommand that says what kind of operation it is.
33
+ *
34
+ * git status → git status
35
+ * git push origin main → git push
36
+ * npx create-vite my-app --template react → npx create-vite
37
+ * npm test -- --watch → npm test
38
+ * npm run build → npm run build (dispatcher)
39
+ * tsc --noEmit → tsc
40
+ *
41
+ * Two tokens by default. A third only after a dispatcher, because otherwise
42
+ * ordinary arguments creep in: `git push origin main` would sign as `git push
43
+ * origin`, which is both too narrow to be useful (a different remote re-prompts)
44
+ * and misleading about what it covers. Remote names, branch names, and script
45
+ * names are plain words — there is no lexical way to tell them from
46
+ * subcommands, so the rule is positional rather than clever.
47
+ */
48
+ function commandSignature(full) {
49
+ const argv = full.trim().split(/\s+/).filter(Boolean);
50
+ if (argv.length === 0)
51
+ return '';
52
+ const out = [argv[0].split('/').pop() ?? argv[0]];
53
+ if (argv.length > 1 && !isVariableToken(argv[1])) {
54
+ out.push(argv[1]);
55
+ if (DISPATCHER_SUBCOMMANDS.has(argv[1]) && argv.length > 2 && !isVariableToken(argv[2])) {
56
+ out.push(argv[2]);
57
+ }
58
+ }
59
+ return out.join(' ');
60
+ }
61
+ /**
62
+ * Compute the rule a given scope would store. The host renders `describes` on
63
+ * the option and stores `rule` verbatim if the user picks it.
64
+ */
65
+ function grantRuleFor(input, scope) {
66
+ const { toolName, primary, primaryFull } = input;
67
+ if (scope === 'once') {
68
+ return { rule: null, describes: 'this call only' };
69
+ }
70
+ if (scope === 'turn') {
71
+ return { rule: null, describes: 'every call like this until the agent finishes this turn' };
72
+ }
73
+ const persisted = scope === 'always';
74
+ const lifetime = persisted ? 'saved to .bandit/settings.json' : 'until this session ends';
75
+ if (toolName === 'run_command' || toolName === 'watch_command') {
76
+ const line = (primaryFull ?? primary ?? '').trim();
77
+ const signature = commandSignature(line);
78
+ if (!signature) {
79
+ return { rule: toolName, describes: `any ${toolName} call — ${lifetime}` };
80
+ }
81
+ // `<signature>*` rather than `<signature> *` so the rule matches the bare
82
+ // command as well as suffixed forms — `git status` and `git status --short`
83
+ // both, not just the latter. The glob engine escapes `*` inside `{a,b}`
84
+ // alternation, so the exact-or-suffixed form can't be expressed precisely;
85
+ // the residual looseness (`git status` also matching a hypothetical `git
86
+ // statuses`) is harmless, and the critical-tier floor in `decidePermission`
87
+ // is what stops a signature from ever spanning into destructive territory.
88
+ const rule = `${toolName}:${signature}*`;
89
+ return { rule, describes: `any \`${signature} …\` command — ${lifetime}` };
90
+ }
91
+ if (EDIT_TOOLS.has(toolName)) {
92
+ // Session and always diverge here, and the split matters.
93
+ //
94
+ // SESSION is tool-broad on purpose: the motivating case is one refactor
95
+ // touching many files, where re-prompting per path is pure friction. The
96
+ // blast radius is bounded by the session and by the workspace, and every
97
+ // change is visible in `git diff`.
98
+ //
99
+ // ALWAYS is path-narrow. A persisted tool-broad edit rule would authorize
100
+ // writing any file in the project, in every future session, from a single
101
+ // click on one file's card — strictly worse than the behavior this module
102
+ // replaced. "Always" should mean "always for this", not "always for
103
+ // everything of this kind".
104
+ //
105
+ // Paths outside the workspace never reach either branch: they classify
106
+ // `critical` and the floor sends them back to the card every time.
107
+ if (persisted) {
108
+ return primary
109
+ ? { rule: `${toolName}:${primary}`, describes: `\`${toolName}\` on \`${primary}\` — ${lifetime}` }
110
+ : { rule: toolName, describes: `any \`${toolName}\` call — ${lifetime}` };
111
+ }
112
+ return {
113
+ rule: toolName,
114
+ describes: `any \`${toolName}\` on files in this project — ${lifetime}`
115
+ };
116
+ }
117
+ if (!primary) {
118
+ return { rule: toolName, describes: `any \`${toolName}\` call — ${lifetime}` };
119
+ }
120
+ return { rule: `${toolName}:${primary}`, describes: `\`${toolName}\` on \`${primary}\` — ${lifetime}` };
121
+ }
122
+ /**
123
+ * Does this policy already authorize the call a rule would cover? Used to skip
124
+ * a redundant card when a queued parallel call arrives after its sibling was
125
+ * granted.
126
+ */
127
+ function policyIncludes(policy, rule) {
128
+ return policy.allow.includes(rule);
129
+ }
130
+ //# sourceMappingURL=grantScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grantScope.js","sourceRoot":"","sources":["../src/grantScope.ts"],"names":[],"mappings":";;AAsFA,4CAWC;AAe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B,cAAc,CAAC,MAAwB,EAAE,IAAY;IACnE,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
package/dist/hooks.d.ts CHANGED
@@ -26,6 +26,9 @@ export interface PermissionsBlock {
26
26
  allow?: string[];
27
27
  deny?: string[];
28
28
  ask?: string[];
29
+ /** `ask` (default) | `auto` | `dangerous` — see permissionMode.ts. Invalid
30
+ * values fall back to `ask` with a warning rather than failing the load. */
31
+ mode?: string;
29
32
  }
30
33
  export interface HookSettings {
31
34
  hooks?: Partial<Record<HookEvent, HookRule[]>>;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC/C,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B;kDAC8C;IAC9C,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,qBAAqB,CAAA;KAAE,CAAC;CAC9C;AAID,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAA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,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC/C,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B;kDAC8C;IAC9C,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,qBAAqB,CAAA;KAAE,CAAC;CAC9C;AAID,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CA6CtG;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBjF;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,UAAU,EAAE,CAAC,CAYvB"}
package/dist/hooks.js CHANGED
@@ -83,6 +83,10 @@ async function loadHookSettings(cwd, opts) {
83
83
  merged.permissions.allow = [...(merged.permissions.allow ?? []), ...(parsed.permissions.allow ?? [])];
84
84
  merged.permissions.deny = [...(merged.permissions.deny ?? []), ...(parsed.permissions.deny ?? [])];
85
85
  merged.permissions.ask = [...(merged.permissions.ask ?? []), ...(parsed.permissions.ask ?? [])];
86
+ // Scalar, so last file wins — workspace overrides global, .local
87
+ // overrides workspace. Matches how the guard's scalars merge.
88
+ if (parsed.permissions.mode)
89
+ merged.permissions.mode = parsed.permissions.mode;
86
90
  }
87
91
  if (parsed.security?.guard) {
88
92
  const g = parsed.security.guard;
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCH,4CA0CC;AAOD,8CAiBC;AAcD,4BAiBC;AA/HD,kDAAoC;AACpC,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAyBzB,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAE3B,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,IAA2B;IAC7E,0EAA0E;IAC1E,yEAAyE;IACzE,4EAA4E;IAC5E,4EAA4E;IAC5E,0EAA0E;IAC1E,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC;QACpE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,uBAAuB,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,6BAA6B,CAAC;KACjD,CAAC;IACF,MAAM,MAAM,GAAiB,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC;IAC1F,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,CAAC;YAC/C,IAAI,MAAM,CAAC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AAC,CAAC,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;YACtB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;YACrB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,9 @@ export { loadApprovedMcpFingerprints, approveMcpFingerprint, revokeMcpFingerprin
7
7
  export { loadMcpToolCache, saveMcpToolEntry, pruneMcpToolCache, mcpToolCachePath } from './mcpToolCache';
8
8
  export { loadHookSettings, persistAllowEntry, runHooks, type HookEvent, type HookRule, type HookSettings, type HookContext, type HookResult, type PermissionsBlock } from './hooks';
9
9
  export { evaluateSecurityGuard, type SecurityGuardSettings, type SecurityGuardContext, type SecurityGuardDecision } from './securityGuard';
10
+ export { classifyRisk, type RiskTier, type RiskAssessment, type RiskContext } from './riskTiers';
11
+ export { grantRuleFor, commandSignature, policyIncludes, type GrantScope, type GrantRule, type GrantScopeInput } from './grantScope';
12
+ export { resolvePermissionMode, shouldAutoApprove, decidePermission, isPermissionMode, AutoApprovalLedger, PERMISSION_MODES, type PermissionMode, type ResolvedMode, type ResolveModeInput, type AutoDecision, type AutoApprovalRecord, type PermissionDecisionInput, type PermissionOutcome } from './permissionMode';
10
13
  export { expandMentions, type ExpandedPrompt } from './mentions';
11
14
  export { TodoStore, buildTodoWriteTool, buildWebFetchTool, buildWebSearchTool, type WebSearchToolOptions, buildRememberTool } from './tools/extraTools';
12
15
  export { buildTaskTool, buildCheckTaskTool, buildListTasksTool, type TaskToolOptions } from './tools/taskTool';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAA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B,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACxB,MA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AkB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildTaskTool = exports.buildRememberTool = exports.buildWebSearchTool = exports.buildWebFetchTool = exports.buildTodoWriteTool = exports.TodoStore = exports.expandMentions = exports.evaluateSecurityGuard = exports.runHooks = exports.persistAllowEntry = exports.loadHookSettings = exports.mcpToolCachePath = exports.pruneMcpToolCache = exports.saveMcpToolEntry = exports.loadMcpToolCache = exports.mcpTrustPath = exports.revokeMcpFingerprint = exports.approveMcpFingerprint = exports.loadApprovedMcpFingerprints = exports.buildCustomServerConfig = exports.looksLikeGmailCredentialsPath = exports.buildGmailServerConfig = exports.looksLikeGitLabToken = exports.buildGitLabServerConfig = exports.looksLikeSlackTeamId = exports.looksLikeSlackToken = exports.buildSlackServerConfig = exports.looksLikeGitHubToken = exports.buildGitHubServerConfig = exports.addMcpServerToConfig = exports.persistMcpActivation = exports.globalMcpServersPath = exports.registerMcpServersFromDisk = exports.loadMcpServersConfig = exports.buildReadMemoryTool = exports.BANDIT_MEMORY_INDEX_FILE = exports.BANDIT_MEMORY_DIR = exports.BANDIT_DIR = exports.MEMORY_INDEX_FILE = exports.MEMORY_DIR = exports.MAX_MEMORY_FILE_BYTES = exports.MAX_INDEX_BYTES = exports.migrateMemoryToBanditDir = exports.writeMemoryTopic = exports.renderMemoryIndexBlock = exports.loadMemoryIndex = exports.consolidateMemory = exports.appendMemory = exports.loadCombinedMemory = exports.loadMemory = void 0;
4
- exports.CheckpointStore = exports.isChatCapable = exports.suggestOllamaMatch = exports.listInstalledOllamaModels = exports.formatTurnTraceMarkdown = exports.summarizeTurnTrace = exports.parseTurnLog = exports.readTurnTraceById = exports.readTurnTrace = exports.listTurnTraces = exports.listTurnTraceFiles = exports.previewText = exports.openTurnLog = exports.SessionPermissionStore = exports.mergePolicies = exports.emptyPolicy = exports.evaluatePermission = exports.InMemoryBackgroundTaskStore = exports.buildInsightsAiCallback = exports.buildAiInput = exports.writeInsightsReport = exports.renderInsightsHtml = exports.computeInsights = exports.parseTestOutput = exports.buildTestCommand = exports.detectTestFramework = exports.buildTestRunTool = exports.buildListTasksTool = exports.buildCheckTaskTool = void 0;
3
+ exports.decidePermission = exports.shouldAutoApprove = exports.resolvePermissionMode = exports.policyIncludes = exports.commandSignature = exports.grantRuleFor = exports.classifyRisk = exports.evaluateSecurityGuard = exports.runHooks = exports.persistAllowEntry = exports.loadHookSettings = exports.mcpToolCachePath = exports.pruneMcpToolCache = exports.saveMcpToolEntry = exports.loadMcpToolCache = exports.mcpTrustPath = exports.revokeMcpFingerprint = exports.approveMcpFingerprint = exports.loadApprovedMcpFingerprints = exports.buildCustomServerConfig = exports.looksLikeGmailCredentialsPath = exports.buildGmailServerConfig = exports.looksLikeGitLabToken = exports.buildGitLabServerConfig = exports.looksLikeSlackTeamId = exports.looksLikeSlackToken = exports.buildSlackServerConfig = exports.looksLikeGitHubToken = exports.buildGitHubServerConfig = exports.addMcpServerToConfig = exports.persistMcpActivation = exports.globalMcpServersPath = exports.registerMcpServersFromDisk = exports.loadMcpServersConfig = exports.buildReadMemoryTool = exports.BANDIT_MEMORY_INDEX_FILE = exports.BANDIT_MEMORY_DIR = exports.BANDIT_DIR = exports.MEMORY_INDEX_FILE = exports.MEMORY_DIR = exports.MAX_MEMORY_FILE_BYTES = exports.MAX_INDEX_BYTES = exports.migrateMemoryToBanditDir = exports.writeMemoryTopic = exports.renderMemoryIndexBlock = exports.loadMemoryIndex = exports.consolidateMemory = exports.appendMemory = exports.loadCombinedMemory = exports.loadMemory = void 0;
4
+ exports.CheckpointStore = exports.isChatCapable = exports.suggestOllamaMatch = exports.listInstalledOllamaModels = exports.formatTurnTraceMarkdown = exports.summarizeTurnTrace = exports.parseTurnLog = exports.readTurnTraceById = exports.readTurnTrace = exports.listTurnTraces = exports.listTurnTraceFiles = exports.previewText = exports.openTurnLog = exports.SessionPermissionStore = exports.mergePolicies = exports.emptyPolicy = exports.evaluatePermission = exports.InMemoryBackgroundTaskStore = exports.buildInsightsAiCallback = exports.buildAiInput = exports.writeInsightsReport = exports.renderInsightsHtml = exports.computeInsights = exports.parseTestOutput = exports.buildTestCommand = exports.detectTestFramework = exports.buildTestRunTool = exports.buildListTasksTool = exports.buildCheckTaskTool = exports.buildTaskTool = exports.buildRememberTool = exports.buildWebSearchTool = exports.buildWebFetchTool = exports.buildTodoWriteTool = exports.TodoStore = exports.expandMentions = exports.PERMISSION_MODES = exports.AutoApprovalLedger = exports.isPermissionMode = void 0;
5
5
  var memory_1 = require("./memory");
6
6
  Object.defineProperty(exports, "loadMemory", { enumerable: true, get: function () { return memory_1.loadMemory; } });
7
7
  Object.defineProperty(exports, "loadCombinedMemory", { enumerable: true, get: function () { return memory_1.loadCombinedMemory; } });
@@ -54,6 +54,19 @@ Object.defineProperty(exports, "persistAllowEntry", { enumerable: true, get: fun
54
54
  Object.defineProperty(exports, "runHooks", { enumerable: true, get: function () { return hooks_1.runHooks; } });
55
55
  var securityGuard_1 = require("./securityGuard");
56
56
  Object.defineProperty(exports, "evaluateSecurityGuard", { enumerable: true, get: function () { return securityGuard_1.evaluateSecurityGuard; } });
57
+ var riskTiers_1 = require("./riskTiers");
58
+ Object.defineProperty(exports, "classifyRisk", { enumerable: true, get: function () { return riskTiers_1.classifyRisk; } });
59
+ var grantScope_1 = require("./grantScope");
60
+ Object.defineProperty(exports, "grantRuleFor", { enumerable: true, get: function () { return grantScope_1.grantRuleFor; } });
61
+ Object.defineProperty(exports, "commandSignature", { enumerable: true, get: function () { return grantScope_1.commandSignature; } });
62
+ Object.defineProperty(exports, "policyIncludes", { enumerable: true, get: function () { return grantScope_1.policyIncludes; } });
63
+ var permissionMode_1 = require("./permissionMode");
64
+ Object.defineProperty(exports, "resolvePermissionMode", { enumerable: true, get: function () { return permissionMode_1.resolvePermissionMode; } });
65
+ Object.defineProperty(exports, "shouldAutoApprove", { enumerable: true, get: function () { return permissionMode_1.shouldAutoApprove; } });
66
+ Object.defineProperty(exports, "decidePermission", { enumerable: true, get: function () { return permissionMode_1.decidePermission; } });
67
+ Object.defineProperty(exports, "isPermissionMode", { enumerable: true, get: function () { return permissionMode_1.isPermissionMode; } });
68
+ Object.defineProperty(exports, "AutoApprovalLedger", { enumerable: true, get: function () { return permissionMode_1.AutoApprovalLedger; } });
69
+ Object.defineProperty(exports, "PERMISSION_MODES", { enumerable: true, get: function () { return permissionMode_1.PERMISSION_MODES; } });
57
70
  var mentions_1 = require("./mentions");
58
71
  Object.defineProperty(exports, "expandMentions", { enumerable: true, get: function () { return mentions_1.expandMentions; } });
59
72
  var extraTools_1 = require("./tools/extraTools");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mCAQkB;AAPhB,oGAAA,UAAU,OAAA;AACV,4GAAA,kBAAkB,OAAA;AAClB,sGAAA,YAAY,OAAA;AACZ,2GAAA,iBAAiB,OAAA;AAKnB,6CAeuB;AAdrB,8GAAA,eAAe,OAAA;AACf,qHAAA,sBAAsB,OAAA;AACtB,+GAAA,gBAAgB,OAAA;AAChB,uHAAA,wBAAwB,OAAA;AACxB,8GAAA,eAAe,OAAA;AACf,oHAAA,qBAAqB,OAAA;AACrB,yGAAA,UAAU,OAAA;AACV,gHAAA,iBAAiB,OAAA;AACjB,yGAAA,UAAU,OAAA;AACV,gHAAA,iBAAiB,OAAA;AACjB,uHAAA,wBAAwB,OAAA;AAK1B,yDAA6D;AAApD,qHAAA,mBAAmB,OAAA;AAC5B,6BAMe;AALb,2GAAA,oBAAoB,OAAA;AACpB,iHAAA,0BAA0B,OAAA;AAC1B,2GAAA,oBAAoB,OAAA;AACpB,2GAAA,oBAAoB,OAAA;AACpB,2GAAA,oBAAoB,OAAA;AAEtB,iDAWyB;AAVvB,wHAAA,uBAAuB,OAAA;AACvB,qHAAA,oBAAoB,OAAA;AACpB,uHAAA,sBAAsB,OAAA;AACtB,oHAAA,mBAAmB,OAAA;AACnB,qHAAA,oBAAoB,OAAA;AACpB,wHAAA,uBAAuB,OAAA;AACvB,qHAAA,oBAAoB,OAAA;AACpB,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B,uCAaoB;AAZlB,2GAAA,eAAe,OAAA;AACf,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,wGAAA,YAAY,OAAA;AACZ,mHAAA,uBAAuB,OAAA;AASzB,qDAM2B;AALzB,8HAAA,2BAA2B,OAAA;AAM7B,6CAOuB;AANrB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,qHAAA,sBAAsB,OAAA;AAIxB,qCAgBmB;AAfjB,sGAAA,WAAW,OAAA;AACX,sGAAA,WAAW,OAAA;AACX,6GAAA,kBAAkB,OAAA;AAClB,yGAAA,cAAc,OAAA;AACd,wGAAA,aAAa,OAAA;AACb,4GAAA,iBAAiB,OAAA;AACjB,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA;AAClB,kHAAA,uBAAuB,OAAA;AAQzB,+CAKwB;AAJtB,yHAAA,yBAAyB,OAAA;AACzB,kHAAA,kBAAkB,OAAA;AAClB,6GAAA,aAAa,OAAA;AAGf,6CAKuB;AAJrB,8GAAA,eAAe,OAAA"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Permission mode — how much Bandit is allowed to do without stopping to ask.
3
+ *
4
+ * ask (default) Every non-allowlisted call prompts. Today's behavior.
5
+ * auto `routine` calls run unprompted; `elevated` and `critical` still
6
+ * prompt. This is the mode meant for "let it work while I watch."
7
+ * dangerous Everything runs unprompted. For CI and sandboxes.
8
+ *
9
+ * The floor: **`critical` never auto-approves in `auto` mode.** Deletes,
10
+ * writes outside the workspace, force-push, global installs, credential paths
11
+ * and egress always require an explicit answer. That is the whole reason `auto`
12
+ * is a different mode from `dangerous` rather than a softer setting on the same
13
+ * dial — a mode whose exceptions are configurable is a bypass with extra steps.
14
+ *
15
+ * `dangerous` has no floor, by design and by name. If someone needs an
16
+ * unattended full-access run, they should have to type a word that tells them
17
+ * what they are doing; the failure mode we are avoiding is a user reaching for
18
+ * "auto" in a blog post and getting "no confirmation for anything."
19
+ */
20
+ import type { RiskAssessment, RiskTier } from './riskTiers';
21
+ export type PermissionMode = 'ask' | 'auto' | 'dangerous';
22
+ export declare const PERMISSION_MODES: readonly PermissionMode[];
23
+ export declare function isPermissionMode(value: unknown): value is PermissionMode;
24
+ export interface ResolveModeInput {
25
+ /** `permissions.mode` from .bandit/settings.json. */
26
+ settingsMode?: string;
27
+ /** Runtime override — a `--auto` flag or a `/auto` toggle. Wins over config. */
28
+ override?: PermissionMode;
29
+ /** Process env. Injectable for tests. */
30
+ env?: Record<string, string | undefined>;
31
+ }
32
+ export interface ResolvedMode {
33
+ mode: PermissionMode;
34
+ /** Where the mode came from, for the status line and `/permissions`. */
35
+ source: 'override' | 'env' | 'settings' | 'default';
36
+ /** Set when a deprecated input was used; hosts print this once at startup. */
37
+ deprecation?: string;
38
+ }
39
+ /**
40
+ * Resolve the effective mode. Precedence: runtime override > env > settings >
41
+ * default.
42
+ *
43
+ * `BANDIT_AUTO_APPROVE=1` predates this module and meant "skip the permission
44
+ * policy entirely" — a full bypass. It keeps that meaning and maps to
45
+ * `dangerous`, with a deprecation notice. Quietly re-pointing it at `auto`
46
+ * would have been the friendlier-looking choice and the wrong one: every
47
+ * existing CI job using it would start prompting for `elevated` calls, and a
48
+ * non-interactive prompt denies, so pipelines would fail in a way that looks
49
+ * like a Bandit bug rather than a config change.
50
+ */
51
+ export declare function resolvePermissionMode(input?: ResolveModeInput): ResolvedMode;
52
+ export interface AutoDecision {
53
+ /** True when the mode lets this call run without prompting. */
54
+ autoApprove: boolean;
55
+ /** Why, for the ledger and the transcript line. */
56
+ reason: string;
57
+ }
58
+ /**
59
+ * Should this call skip the prompt under the given mode?
60
+ *
61
+ * Callers must still run the security guard and PreToolUse hooks first — this
62
+ * function answers only "does the mode waive the user prompt", never "is this
63
+ * call safe."
64
+ */
65
+ export declare function shouldAutoApprove(mode: PermissionMode, risk: RiskAssessment): AutoDecision;
66
+ export interface PermissionDecisionInput {
67
+ mode: PermissionMode;
68
+ risk: RiskAssessment;
69
+ /** What the allow/deny/ask policy said, before mode and tier are applied. */
70
+ policyDecision: 'allow' | 'ask' | 'deny';
71
+ }
72
+ export interface PermissionOutcome {
73
+ action: 'allow' | 'ask' | 'deny';
74
+ /** Why — surfaced in the transcript, the turn log, and the ledger. */
75
+ reason: string;
76
+ /** True when the critical floor overrode a policy that said `allow`. */
77
+ flooredByRisk?: boolean;
78
+ }
79
+ /**
80
+ * The single precedence chain both hosts use. Previously each host open-coded
81
+ * this order and they had already drifted (the extension gained a turn-local
82
+ * auto-grant the CLI never had, the CLI gained an env short-circuit the
83
+ * extension never had). One function, one order, one set of tests:
84
+ *
85
+ * 1. `deny` from policy — nothing overrides an explicit deny.
86
+ * 2. **The critical floor.** A `critical` call always asks, even when a
87
+ * stored rule says allow. This is what stops a saved grant from widening
88
+ * into destruction: approving `git push origin main` for the session
89
+ * stores `run_command:git push*`, which as a bare glob would also cover
90
+ * `git push --force`. It doesn't, because force-push classifies critical
91
+ * and lands here. Same protection covers a hand-written `run_command:git *`
92
+ * in settings.json, which had this hole before the floor existed.
93
+ * 3. `dangerous` mode — no floor, by name and by design.
94
+ * 4. `auto` mode — routine runs unattended.
95
+ * 5. Otherwise the policy decides.
96
+ *
97
+ * The security guard and PreToolUse hooks run BEFORE this, in the host. This
98
+ * function answers "does the user have to be asked", not "is this call safe".
99
+ */
100
+ export declare function decidePermission(input: PermissionDecisionInput): PermissionOutcome;
101
+ /** A single auto-approved call, for the session ledger. */
102
+ export interface AutoApprovalRecord {
103
+ tool: string;
104
+ target: string;
105
+ tier: RiskTier;
106
+ rule: string;
107
+ at: number;
108
+ }
109
+ /**
110
+ * In-memory record of what auto mode did this session.
111
+ *
112
+ * Auto-approval without a record is indistinguishable from a bypass — the user
113
+ * has no way to answer "what did it do while I wasn't looking?". `/permissions`
114
+ * renders this.
115
+ */
116
+ export declare class AutoApprovalLedger {
117
+ private readonly entries;
118
+ private readonly limit;
119
+ constructor(limit?: number);
120
+ record(entry: AutoApprovalRecord): void;
121
+ all(): readonly AutoApprovalRecord[];
122
+ size(): number;
123
+ /** Counts per tool, most-used first — the useful shape for a summary line. */
124
+ summary(): Array<{
125
+ tool: string;
126
+ count: number;
127
+ }>;
128
+ clear(): void;
129
+ }
130
+ //# sourceMappingURL=permissionMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionMode.d.ts","sourceRoot":"","sources":["../src/permissionMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAA0C,CAAC;AAEjG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,wEAAwE;IACxE,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;IACpD,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,GAAE,gBAAqB,GAAG,YAAY,CA+ChF;AAED,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAC;IACrB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;CAChB;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