@veilio-inc/mcp 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # Veilio Community License
2
2
 
3
- _Version 1.0 · Effective 2026-08-08_
3
+ _Version 1.1 · Effective 2026-09-25_
4
4
 
5
5
  **Copyright © 2026 Veilio**
6
6
 
@@ -10,7 +10,8 @@ _Version 1.0 · Effective 2026-08-08_
10
10
  > The one thing you may not do without written permission is sell Veilio itself:
11
11
  > reselling it, white-labeling it, or running it as a hosted service for other
12
12
  > people. Contributions are welcome. For a commercial or redistribution license,
13
- > email `hello@veilio.dev`.
13
+ > email `hello@veilio.dev`. Veilio is not licensed for use in or from Russia or
14
+ > Belarus, or by sanctioned persons (Section 5A).
14
15
 
15
16
  ---
16
17
 
@@ -48,11 +49,17 @@ For the purposes of this License:
48
49
 
49
50
  **"Competing Product"** means a commercially offered product or service whose primary purpose and core functionality substantially overlap with the Software or Cloud Edition.
50
51
 
52
+ **"Applicable Sanctions"** means any economic, financial, trade or other restrictive measures applicable to Veilio or the relevant transaction under the laws of the European Union or the Republic of Poland, including applicable asset-freezing and prohibition-on-making-available measures, and any other sanctions or trade restrictions that are legally binding on Veilio.
53
+
54
+ **"Restricted Person"** means any natural or legal person, entity or body that: (a) is designated or otherwise subject to restrictive measures under Applicable Sanctions, (b) is directly or indirectly owned or controlled by such a person, entity or body, (c) acts on behalf of or at the direction of such a person, entity or body; or (d) is otherwise a person to whom Veilio is prohibited under Applicable Sanctions from providing the Software, funds or economic resources.
55
+
56
+ **"Restricted Territory"** means the Russian Federation and the Republic of Belarus.
57
+
51
58
  ---
52
59
 
53
60
  ## 3. Permissions
54
61
 
55
- Subject to the restrictions in this License, you are granted a worldwide, royalty-free, non-exclusive license to:
62
+ Subject to the restrictions in this License, including Section 5A, you are granted a worldwide, royalty-free, non-exclusive license to:
56
63
 
57
64
  * use the Software for personal purposes;
58
65
  * use the Software for internal commercial purposes;
@@ -114,6 +121,24 @@ Requests for written permission may be sent to `hello@veilio.dev`.
114
121
 
115
122
  ---
116
123
 
124
+ ## 5A. Restricted Territories and Sanctions
125
+
126
+ **5A.1.** No license or other right to the Software is granted to:
127
+
128
+ * persons or entities incorporated, registered, established or headquartered in a Restricted Territory;
129
+ * natural persons whose principal place of business or ordinary residence is in a Restricted Territory; or
130
+ * Restricted Persons.
131
+
132
+ **5A.2.** You must not access or use the Software from a Restricted Territory, make the Software available to any person located in a Restricted Territory, or use the Software directly or indirectly for the benefit of a Restricted Person or a person or entity incorporated, registered, established or headquartered in a Restricted Territory.
133
+
134
+ **5A.3.** By using the Software, you represent and warrant, both when you first use it and throughout your use of it, that you are not a Restricted Person and do not fall within any of the territorial restrictions set out in this Section.
135
+
136
+ **5A.4.** You must not use an intermediary, affiliate, nominee, proxy, VPN or other arrangement for the purpose of circumventing the restrictions set out in this Section or Applicable Sanctions.
137
+
138
+ **5A.5.** Any breach of this Section is a material violation of this License and terminates your rights under it (Section 14). Veilio does not grant written permission for exceptions to this Section.
139
+
140
+ ---
141
+
117
142
  ## 6. Cloud Edition
118
143
 
119
144
  The Cloud Edition is the official commercial hosted offering of the project.
@@ -218,7 +243,7 @@ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHORS
218
243
 
219
244
  ## 14. Termination
220
245
 
221
- Your rights under this License terminate automatically if you materially violate its terms.
246
+ Your rights under this License terminate automatically if you materially violate its terms. Any breach of Section 5A is a material violation.
222
247
 
223
248
  Upon termination, you must cease the activities that are prohibited by this License.
224
249
 
@@ -244,5 +269,5 @@ Each version will be identified by a version number. Unless explicitly stated ot
244
269
 
245
270
  **Project:** Veilio
246
271
  **Copyright:** © 2026 Veilio
247
- **License:** Veilio Community License, Version 1.0
272
+ **License:** Veilio Community License, Version 1.1
248
273
  **Contact:** `hello@veilio.dev`
package/README.md CHANGED
@@ -37,6 +37,8 @@ tools/call anonymize_file { "path": "src/gateway.ts" }
37
37
  | `scan_secrets` | Detect credentials without modifying anything, and without putting the values in context. |
38
38
  | `symbol_map_summary` | Placeholder counts by kind. Returns keys only, never real names. |
39
39
 
40
+ Setup for Claude Code, Claude Desktop, Xcode, Cursor and VS Code, plus troubleshooting: [docs/USING-THE-CLI-AND-MCP.md](../../docs/USING-THE-CLI-AND-MCP.md).
41
+
40
42
  ## Install
41
43
 
42
44
  ```jsonc
@@ -55,25 +57,35 @@ tools/call anonymize_file { "path": "src/gateway.ts" }
55
57
 
56
58
  ## Team namespace (Team plan and above)
57
59
 
58
- > **Not in `0.1.0`, which is what npm currently has** — and neither is the
59
- > `veilio login` it depends on. Both are merged here and ship with the next
60
- > release; until then, run both packages from a clone
61
- > (`npm run build:packages`).
62
-
63
60
  Sign in once with the `veilio` CLI — `veilio login` — and every anonymize
64
61
  result from this server states which namespace produced its placeholders:
65
62
 
66
63
  - **`team`** — resolved against the team's shared dictionary, fetched from
67
64
  Cloud once at startup and reused for the life of the process, so every
68
65
  teammate's agent produces the same placeholder for the same identifier.
69
- - **`local`** — resolved locally: never signed in, offline, or the plan
70
- doesn't include shared dictionaries. This is the normal, fully-functional
71
- state for anyone not on a paid team — the server never blocks on it, and
72
- the fallback is always stated, never silent.
66
+ - **`local`** — resolved locally: not signed in, no team key unlocked on this
67
+ machine, offline, or the plan doesn't include shared dictionaries. This is the
68
+ normal, fully-functional state for anyone not on a paid team — the server never
69
+ blocks on it, and the fallback is always stated, never silent.
73
70
 
74
71
  There is no separate sign-in for the MCP server; it reads the same credential
75
72
  file `veilio login` already wrote.
76
73
 
74
+ The merge happens **here, not in Cloud**: team maps arrive sealed under the team
75
+ key, which the server cannot read. So on a Team plan the namespace is `team` only
76
+ once `veilio team unlock` has opened that key on this machine — it is kept for
77
+ seven days, and a key rotation ends it sooner. Signed in with nothing unlocked,
78
+ the server reports `local`: there is nothing it could decrypt. A single map it
79
+ cannot open is skipped rather than fatal, but a failed read of the namespace as a
80
+ whole reports `local` too, because a namespace missing a teammate's newest map
81
+ would restore their placeholders wrong. An older self-hosted Cloud that still
82
+ merges server-side is honoured as it is, with no key needed here.
83
+
84
+ The account's custom rules are fetched at startup the same way and applied to
85
+ every anonymize call. Each result states their source: `from Cloud`, `cached`
86
+ (Cloud did not answer, so the last `veilio rules pull` is used, with its age),
87
+ or `none`.
88
+
77
89
  ## Design properties
78
90
 
79
91
  - **Zero runtime dependencies.** JSON-RPC framing is implemented directly. Pulling a transitive tree into the component that reads your source would undercut the product's own claim.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  // go to stderr, which MCP clients surface as server logs.
7
7
  import { FrameReader } from './server.js';
8
8
  import { primeNamespace } from './namespace.js';
9
+ import { primeRules } from './rules.js';
9
10
  export { FrameReader, handleFrame, handleMessage, SERVER_VERSION } from './server.js';
10
11
  export { TOOLS, callTool } from './tools.js';
11
12
  function parseCliContext(argv) {
@@ -31,7 +32,7 @@ async function start() {
31
32
  // for the rest of this process sees the answer already settled rather than
32
33
  // racing the first one in (contracts/shared-namespace.md R-007). Never
33
34
  // throws — see namespace.ts — so this can only delay startup, not fail it.
34
- await primeNamespace();
35
+ await Promise.all([primeNamespace(), primeRules()]);
35
36
  process.stdin.setEncoding('utf8');
36
37
  process.stdin.on('data', (chunk) => reader.push(chunk));
37
38
  process.stdin.on('end', () => process.exit(0));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,0BAA0B;AAC1B,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAE,WAAW,EAAwB,MAAM,aAAa,CAAA;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE5C,SAAS,eAAe,CAAC,IAAuB;IAC9C,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACvB,IAAI,OAAO,GAAkB,IAAI,CAAA;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YAC5E,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QACjB,CAAC;aAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YAClF,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA;AACzB,C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CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACvD,CAAC,CAAA;IACD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAEzC,2EAA2E;IAC3E,2EAA2E;IAC3E,uEAAuE;IACvE,2EAA2E;IAC3E,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IAEnD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AAC1D,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrF,KAAK,KAAK,EAAE,CAAA;AACd,CAAC"}
@@ -1,8 +1,25 @@
1
+ import { type TeamNamespaceResult } from '@veilio-inc/cli/team-namespace';
1
2
  export type NamespaceSource = 'team' | 'local';
2
3
  export interface ResolvedNamespace {
3
4
  source: NamespaceSource;
4
- /** Placeholder -> identifier. Empty for 'local' — there is nothing to merge. */
5
+ /** Placeholder -> identifier, WITHOUT the disputed placeholders - so this
6
+ * server never emits one. Empty for 'local'. */
5
7
  namespace: Record<string, string>;
8
+ /** A second number a team map kept for an identifier that already had one
9
+ * (spec 017): text sent with it must restore too (spec 028). */
10
+ aliases: Record<string, string>;
11
+ /** Placeholders the team's saved maps give DIFFERENT identifiers -> how many.
12
+ * Never emitted, never guessed back (spec 017). */
13
+ conflicts: Record<string, number>;
14
+ /** Highest number per placeholder base in any readable team map, conflicts
15
+ * included: new names are numbered above it. */
16
+ highest: Record<string, number>;
17
+ /** What the CLI's resolver found - including why it is 'local' when the team
18
+ * exists but its maps were not read (locked, unavailable). Never silent. */
19
+ found: TeamNamespaceResult;
20
+ /** False for an older instance's server-merged namespace: usable to anonymize,
21
+ * never to restore - it cannot tell a disputed placeholder (spec 028). */
22
+ conflictDetection: boolean;
6
23
  }
7
24
  /**
8
25
  * Resolve the namespace once and cache it for the rest of the process.
@@ -11,7 +28,20 @@ export interface ResolvedNamespace {
11
28
  * their own request. `home` is injectable for tests; production leaves it
12
29
  * undefined and `readCredential` falls back to the real home directory.
13
30
  */
14
- export declare function primeNamespace(home?: string): Promise<ResolvedNamespace>;
31
+ export declare function primeNamespace(home?: string, opts?: {
32
+ retryDelayMs?: number;
33
+ }): Promise<ResolvedNamespace>;
34
+ /**
35
+ * The cache must not outlive the reason it was cached (review): `veilio team
36
+ * unlock` run after this server started said "restore again" and every retry
37
+ * met the same cached `locked`. Called at the start of each tool call. Cheap
38
+ * and synchronous - a local file read - and never waits: when there is
39
+ * something new to fetch it starts the fetch and says 'loading'; the next call
40
+ * sees the result. A settled `team` or `local` is kept for the process.
41
+ */
42
+ export declare function refreshNamespaceIfStale(): 'unlocked' | 'retrying' | null;
43
+ /** Test support and callers that can wait: the in-flight (or last) resolution. */
44
+ export declare function namespaceSettled(): Promise<ResolvedNamespace>;
15
45
  /** The already-resolved namespace. `local` (with an empty namespace) until
16
46
  * `primeNamespace` has been called and settled — the safe default for any
17
47
  * caller that never primes, including every existing offline-only test. */
@@ -19,35 +49,29 @@ export declare function getNamespace(): ResolvedNamespace;
19
49
  /** Test-only: forget the cached result so the next `primeNamespace` refetches. */
20
50
  export declare function resetNamespaceCache(): void;
21
51
  /**
22
- * Overlay a team namespace onto a local map, safely.
23
- *
24
- * Both are `Record<placeholder, identifier>`, and that similarity is a trap: the
25
- * two placeholder spaces are numbered independently — the local map by this
26
- * project's own engine, the team's by `mergeTeamNamespace` walking every
27
- * member's own maps — so `__CLS__1` in one has no relation to `__CLS__1` in the
28
- * other beyond coincidence. A blind `{ ...local, ...team }` merge treats that
29
- * coincidence as identity: two different identifiers that happen to land on the
30
- * same key collide, `saveMap` then refuses the write as data loss (or, worse,
31
- * silently drops one identifier's real mapping if the guard is bypassed), and
32
- * text already restored under the shadowed placeholder now resolves to the
33
- * wrong name.
52
+ * The namespace line every anonymize result carries, with the reason when the
53
+ * team exists but was not used - so a fallback is never mistaken for agreement.
54
+ */
55
+ export declare function namespaceLine(resolved: ResolvedNamespace): string;
56
+ /**
57
+ * The map handed to the engine to anonymize: this project's store and the
58
+ * team's namespace, reconciled so that nothing emitted can mean something else
59
+ * to a teammate (spec 028 R5; this replaced spec 005's "the local placeholder
60
+ * wins", which after a lapse emitted staging's `createInvoice` as __FN__1 - the
61
+ * team's `chargeCustomer`).
34
62
  *
35
- * So this reconciles by IDENTIFIER, which is the thing two teammates actually
36
- * want to agree on, and it only ever ADDS to `local` — never overwrites an
37
- * existing key, never introduces a second placeholder for an identifier `local`
38
- * already has under a different one:
63
+ * The two placeholder spaces are numbered independently, so a shared key is
64
+ * coincidence, not identity:
39
65
  *
40
- * - an identifier already known locally (under any placeholder) keeps its
41
- * local placeholder — converging it to the team's would relabel every
42
- * already-anonymized reference to it, which is not this call's to decide
43
- * - a team entry whose placeholder KEY is already taken locally by a
44
- * DIFFERENT identifier is dropped rather than forced in; that one
45
- * identifier just doesn't converge with the team this round and gets a
46
- * fresh local placeholder from the engine instead, which is a safe
47
- * degradation, not a corruption
48
- * - everything else — a team identifier neither known locally nor colliding
49
- * on key — is added under the team's placeholder, which is the case two
50
- * fresh sessions (T044) actually converge through
66
+ * - An identifier the team knows takes the TEAM's placeholder. The project's
67
+ * own placeholder for it is left out (it stays in the store, for restoring
68
+ * text already sent) - one placeholder per identifier, always.
69
+ * - A placeholder the project's store and the team use for DIFFERENT
70
+ * identifiers is used for neither: the store must keep its meaning (text was
71
+ * sent with it; `saveMap` refuses to lose it), and emitting it would mean the
72
+ * team's identifier to every teammate. Both identifiers get fresh numbers.
73
+ * - Everything else - a local entry the team does not contradict, a team entry
74
+ * the store does not contradict - is used as it is.
51
75
  */
52
76
  export declare function mergeNamespace(local: Record<string, string>, team: Record<string, string>): Record<string, string>;
53
77
  //# sourceMappingURL=namespace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAA;AAE9C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AA0BD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQxE;AAED;;4EAE4E;AAC5E,wBAAgB,YAAY,IAAI,iBAAiB,CAEhD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUxB"}
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAwB,KAAK,mBAAmB,EAAE,M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,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBxB"}
package/dist/namespace.js CHANGED
@@ -15,30 +15,43 @@
15
15
  // whole JSON-RPC pipeline (server.ts, tools.ts) synchronous rather than
16
16
  // threading a Promise through 78 existing call sites for one network call that
17
17
  // happens once per process.
18
+ import { resolveTeamNamespace } from '@veilio-inc/cli/team-namespace';
18
19
  import { readCredential } from '@veilio-inc/cli/credential';
19
- import { listMaps } from '@veilio-inc/cli/cloud';
20
- const LOCAL = { source: 'local', namespace: {} };
20
+ import { readTeamUnlock } from '@veilio-inc/cli/team-unlock';
21
+ function localFrom(found) {
22
+ return {
23
+ source: 'local',
24
+ namespace: {},
25
+ aliases: {},
26
+ conflicts: {},
27
+ highest: {},
28
+ found,
29
+ conflictDetection: true,
30
+ };
31
+ }
32
+ const LOCAL = localFrom({ status: 'local' });
21
33
  let current = LOCAL;
22
34
  let priming = null;
23
- async function fetchNamespace(home) {
24
- const credential = readCredential(home);
25
- // Not signed in. No request — a signed-out terminal has nothing to ask Cloud.
26
- if (!credential)
27
- return LOCAL;
28
- try {
29
- const { teamNamespace } = await listMaps(credential);
30
- // No active team, or the plan lacks shared dictionaries — the server's
31
- // entitlement answer (getEffectiveAccess), not a decision made here.
32
- if (!teamNamespace)
33
- return LOCAL;
34
- return { source: 'team', namespace: teamNamespace };
35
- }
36
- catch {
37
- // Unreachable, revoked session, timed out — every network or auth failure
38
- // degrades the same way. A coding agent must keep working when Cloud is
39
- // down; the fallback itself is what gets reported, not this failure.
40
- return LOCAL;
35
+ /** The CLI's resolver, shaped for this server (spec 028: one resolver for both). */
36
+ async function fetchNamespace(home, opts) {
37
+ const found = await resolveTeamNamespace(home, opts);
38
+ if (found.status !== 'team')
39
+ return localFrom(found);
40
+ const { namespace, aliases, conflicts, highest } = found.analysis;
41
+ // A team with no maps yet has no namespace to share: 'local', as before. (A
42
+ // team whose maps exist but none opened is 'unavailable', from the resolver.)
43
+ if (Object.keys(namespace).length === 0 && Object.keys(conflicts).length === 0) {
44
+ return localFrom({ status: 'local' });
41
45
  }
46
+ return {
47
+ source: 'team',
48
+ namespace: Object.fromEntries(Object.entries(namespace).filter(([p]) => !(p in conflicts))),
49
+ aliases,
50
+ conflicts,
51
+ highest,
52
+ found,
53
+ conflictDetection: found.conflictDetection,
54
+ };
42
55
  }
43
56
  /**
44
57
  * Resolve the namespace once and cache it for the rest of the process.
@@ -47,15 +60,57 @@ async function fetchNamespace(home) {
47
60
  * their own request. `home` is injectable for tests; production leaves it
48
61
  * undefined and `readCredential` falls back to the real home directory.
49
62
  */
50
- export function primeNamespace(home) {
63
+ export function primeNamespace(home, opts = {}) {
64
+ primedWith = { home, opts };
65
+ lastAttemptAt = Date.now();
51
66
  if (!priming) {
52
- priming = fetchNamespace(home).then((resolved) => {
67
+ priming = fetchNamespace(home, { deadlineMs: STARTUP_DEADLINE_MS, ...opts }).then((resolved) => {
53
68
  current = resolved;
54
69
  return resolved;
55
70
  });
56
71
  }
57
72
  return priming;
58
73
  }
74
+ /** A hung instance must not hold the agent's first tool call for 30 s. */
75
+ const STARTUP_DEADLINE_MS = 10_000;
76
+ /** How often an 'unavailable' team is asked again, from a tool call. */
77
+ const UNAVAILABLE_RECHECK_MS = 30_000;
78
+ let primedWith = { opts: {} };
79
+ let lastAttemptAt = 0;
80
+ /**
81
+ * The cache must not outlive the reason it was cached (review): `veilio team
82
+ * unlock` run after this server started said "restore again" and every retry
83
+ * met the same cached `locked`. Called at the start of each tool call. Cheap
84
+ * and synchronous - a local file read - and never waits: when there is
85
+ * something new to fetch it starts the fetch and says 'loading'; the next call
86
+ * sees the result. A settled `team` or `local` is kept for the process.
87
+ */
88
+ export function refreshNamespaceIfStale() {
89
+ const status = current.found.status;
90
+ if (status !== 'locked' && status !== 'unavailable')
91
+ return null;
92
+ if (priming && !settledFlag)
93
+ return status === 'locked' ? 'unlocked' : 'retrying';
94
+ const now = Date.now();
95
+ const credential = status === 'locked' ? readCredential(primedWith.home) : null;
96
+ const due = status === 'locked'
97
+ ? credential !== null &&
98
+ readTeamUnlock({ instance: credential.instance, account: credential.account }, primedWith.home) !== null
99
+ : now - lastAttemptAt >= UNAVAILABLE_RECHECK_MS;
100
+ if (!due)
101
+ return null;
102
+ priming = null;
103
+ settledFlag = false;
104
+ void primeNamespace(primedWith.home, primedWith.opts).then(() => {
105
+ settledFlag = true;
106
+ });
107
+ return status === 'locked' ? 'unlocked' : 'retrying';
108
+ }
109
+ let settledFlag = true;
110
+ /** Test support and callers that can wait: the in-flight (or last) resolution. */
111
+ export function namespaceSettled() {
112
+ return priming ?? Promise.resolve(current);
113
+ }
59
114
  /** The already-resolved namespace. `local` (with an empty namespace) until
60
115
  * `primeNamespace` has been called and settled — the safe default for any
61
116
  * caller that never primes, including every existing offline-only test. */
@@ -66,48 +121,62 @@ export function getNamespace() {
66
121
  export function resetNamespaceCache() {
67
122
  current = LOCAL;
68
123
  priming = null;
124
+ settledFlag = true;
125
+ lastAttemptAt = 0;
126
+ primedWith = { opts: {} };
69
127
  }
70
128
  /**
71
- * Overlay a team namespace onto a local map, safely.
72
- *
73
- * Both are `Record<placeholder, identifier>`, and that similarity is a trap: the
74
- * two placeholder spaces are numbered independently — the local map by this
75
- * project's own engine, the team's by `mergeTeamNamespace` walking every
76
- * member's own maps — so `__CLS__1` in one has no relation to `__CLS__1` in the
77
- * other beyond coincidence. A blind `{ ...local, ...team }` merge treats that
78
- * coincidence as identity: two different identifiers that happen to land on the
79
- * same key collide, `saveMap` then refuses the write as data loss (or, worse,
80
- * silently drops one identifier's real mapping if the guard is bypassed), and
81
- * text already restored under the shadowed placeholder now resolves to the
82
- * wrong name.
129
+ * The namespace line every anonymize result carries, with the reason when the
130
+ * team exists but was not used - so a fallback is never mistaken for agreement.
131
+ */
132
+ export function namespaceLine(resolved) {
133
+ if (resolved.source === 'team')
134
+ return 'Namespace: team';
135
+ const { found } = resolved;
136
+ if (found.status === 'locked')
137
+ return 'Namespace: local (the team key is locked on this machine - run `veilio team unlock`)';
138
+ if (found.status === 'unavailable')
139
+ return `Namespace: local (could not read the team's maps: ${found.reason})`;
140
+ return 'Namespace: local';
141
+ }
142
+ /**
143
+ * The map handed to the engine to anonymize: this project's store and the
144
+ * team's namespace, reconciled so that nothing emitted can mean something else
145
+ * to a teammate (spec 028 R5; this replaced spec 005's "the local placeholder
146
+ * wins", which after a lapse emitted staging's `createInvoice` as __FN__1 - the
147
+ * team's `chargeCustomer`).
83
148
  *
84
- * So this reconciles by IDENTIFIER, which is the thing two teammates actually
85
- * want to agree on, and it only ever ADDS to `local` — never overwrites an
86
- * existing key, never introduces a second placeholder for an identifier `local`
87
- * already has under a different one:
149
+ * The two placeholder spaces are numbered independently, so a shared key is
150
+ * coincidence, not identity:
88
151
  *
89
- * - an identifier already known locally (under any placeholder) keeps its
90
- * local placeholder — converging it to the team's would relabel every
91
- * already-anonymized reference to it, which is not this call's to decide
92
- * - a team entry whose placeholder KEY is already taken locally by a
93
- * DIFFERENT identifier is dropped rather than forced in; that one
94
- * identifier just doesn't converge with the team this round and gets a
95
- * fresh local placeholder from the engine instead, which is a safe
96
- * degradation, not a corruption
97
- * - everything else — a team identifier neither known locally nor colliding
98
- * on key — is added under the team's placeholder, which is the case two
99
- * fresh sessions (T044) actually converge through
152
+ * - An identifier the team knows takes the TEAM's placeholder. The project's
153
+ * own placeholder for it is left out (it stays in the store, for restoring
154
+ * text already sent) - one placeholder per identifier, always.
155
+ * - A placeholder the project's store and the team use for DIFFERENT
156
+ * identifiers is used for neither: the store must keep its meaning (text was
157
+ * sent with it; `saveMap` refuses to lose it), and emitting it would mean the
158
+ * team's identifier to every teammate. Both identifiers get fresh numbers.
159
+ * - Everything else - a local entry the team does not contradict, a team entry
160
+ * the store does not contradict - is used as it is.
100
161
  */
101
162
  export function mergeNamespace(local, team) {
102
- const merged = { ...local };
103
- const knownIdentifiers = new Set(Object.values(local));
163
+ const merged = {};
164
+ const placed = new Set();
104
165
  for (const [placeholder, identifier] of Object.entries(team)) {
105
- if (knownIdentifiers.has(identifier))
166
+ if (placeholder in local && local[placeholder] !== identifier)
167
+ continue;
168
+ if (placed.has(identifier))
169
+ continue;
170
+ merged[placeholder] = identifier;
171
+ placed.add(identifier);
172
+ }
173
+ for (const [placeholder, identifier] of Object.entries(local)) {
174
+ if (placeholder in team && team[placeholder] !== identifier)
106
175
  continue;
107
- if (placeholder in merged)
176
+ if (placed.has(identifier))
108
177
  continue;
109
178
  merged[placeholder] = identifier;
110
- knownIdentifiers.add(identifier);
179
+ placed.add(identifier);
111
180
  }
112
181
  return merged;
113
182
  }
@@ -1 +1 @@
1
- {"version":3,"file":"namespace.js","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,iFAAiF;AACjF,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,8EAA8E;AAC9E,iEAAiE;AACjE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,wEAAwE;AACxE,+EAA+E;AAC/E,4BAA4B;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAUhD,MAAM,KAAK,GAAsB,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;AAEnE,IAAI,OAAO,GAAsB,KAAK,CAAA;AACtC,IAAI,OAAO,GAAsC,IAAI,CAAA;AAErD,KAAK,UAAU,cAAc,CAAC,IAAwB;IACpD,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;IACvC,8EAA8E;IAC9E,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAA;IAE7B,IAAI,CAAC;QACH,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAA;QACpD,uEAAuE;QACvE,qEAAqE;QACrE,IAAI,CAAC,aAA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,WAAW,CAAC,GAAG,UAAU,CAAA;QAChC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACxB,CAAC;IACD,KAAK,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9D,IAAI,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,UAAU;YAAE,SAAQ;QACrE,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,SAAQ;QACpC,MAAM,CAAC,WAAW,CAAC,GAAG,UAAU,CAAA;QAChC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACxB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { CustomRule } from '@veilio-inc/engine';
2
+ export interface ResolvedRules {
3
+ /** 'cloud' fetched now; 'cached' Cloud did not answer, so the last pull; 'none'. */
4
+ source: 'cloud' | 'cached' | 'none';
5
+ rules: CustomRule[];
6
+ /** When the cached rules were pulled. Only for 'cached'. */
7
+ pulledAt?: string;
8
+ }
9
+ /** Resolve once per process; concurrent callers share the one request. */
10
+ export declare function primeRules(home?: string): Promise<ResolvedRules>;
11
+ /** The resolved rules. 'none' until primed - the safe default for offline tests. */
12
+ export declare function getRules(): ResolvedRules;
13
+ /** Test-only. */
14
+ export declare function resetRulesCache(): void;
15
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACnC,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAiDD,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQhE;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,IAAI,aAAa,CAExC;AAED,iBAAiB;AACjB,wBAAgB,eAAe,IAAI,IAAI,CAGtC"}
package/dist/rules.js ADDED
@@ -0,0 +1,75 @@
1
+ // The account's custom rules - fetched once per MCP session, like the team
2
+ // namespace (see namespace.ts for why once, at startup, and never inside a
3
+ // tool call).
4
+ //
5
+ // Before this the server applied no custom rules at all, so an agent masked the
6
+ // same code differently from the web app (found on staging, 2026-09-26). The
7
+ // fallback is stated on every result, never silent: rules from Cloud, the
8
+ // cache `veilio rules pull` left, or none.
9
+ import { readCredential } from '@veilio-inc/cli/credential';
10
+ import { CloudError, listRules } from '@veilio-inc/cli/cloud';
11
+ import { mergeRules, readRules, removeRules, writeRules } from '@veilio-inc/cli/rules';
12
+ const NONE = { source: 'none', rules: [] };
13
+ let current = NONE;
14
+ let priming = null;
15
+ async function fetchRules(home) {
16
+ const credential = readCredential(home);
17
+ if (!credential)
18
+ return NONE;
19
+ try {
20
+ const fetched = await listRules(credential);
21
+ const rules = mergeRules(fetched.rules ?? [], fetched.teamRules ?? []);
22
+ // Refresh the CLI's cache too, so `veilio scrub` on this machine agrees
23
+ // with the agent. A failed write costs nothing here.
24
+ try {
25
+ writeRules({
26
+ instance: credential.instance,
27
+ account: credential.account,
28
+ pulledAt: new Date().toISOString(),
29
+ rules,
30
+ }, home);
31
+ }
32
+ catch {
33
+ // ignore
34
+ }
35
+ return { source: 'cloud', rules };
36
+ }
37
+ catch (err) {
38
+ // The plan no longer includes rules: stop applying the old ones, here and
39
+ // in the CLI, rather than letting a stale whitelist keep names readable.
40
+ if (err instanceof CloudError && err.kind === 'unentitled') {
41
+ try {
42
+ removeRules(home);
43
+ }
44
+ catch {
45
+ // ignore
46
+ }
47
+ return NONE;
48
+ }
49
+ const cached = readRules(credential, home);
50
+ if (cached && cached.rules.length > 0) {
51
+ return { source: 'cached', rules: cached.rules, pulledAt: cached.pulledAt };
52
+ }
53
+ return NONE;
54
+ }
55
+ }
56
+ /** Resolve once per process; concurrent callers share the one request. */
57
+ export function primeRules(home) {
58
+ if (!priming) {
59
+ priming = fetchRules(home).then((resolved) => {
60
+ current = resolved;
61
+ return resolved;
62
+ });
63
+ }
64
+ return priming;
65
+ }
66
+ /** The resolved rules. 'none' until primed - the safe default for offline tests. */
67
+ export function getRules() {
68
+ return current;
69
+ }
70
+ /** Test-only. */
71
+ export function resetRulesCache() {
72
+ current = NONE;
73
+ priming = null;
74
+ }
75
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,cAAc;AACd,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,0EAA0E;AAC1E,2CAA2C;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAWtF,MAAM,IAAI,GAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAEzD,IAAI,OAAO,GAAkB,IAAI,CAAA;AACjC,IAAI,OAAO,GAAkC,IAAI,CAAA;AAEjD,KAAK,UAAU,UAAU,CAAC,IAAwB;IAChD,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAA;IAE5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,CAAA;QAC3C,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AAE,EAAE;YAC3C,OAAO,GAAG,QAAQ,CAAA;YAClB,OAAO,QAAQ,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,QAAQ;IACtB,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,iBAAiB;AACjB,MAAM,UAAU,eAAe;IAC7B,OAAO,GAAG,IAAI,CAAA;IACd,OAAO,GAAG,IAAI,CAAA;AAChB,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ToolContext } from './tools.js';
2
- export declare const SERVER_VERSION = "0.1.0";
2
+ export declare const SERVER_VERSION: string;
3
3
  /** Protocol revisions this server implements. If the client asks for one of
4
4
  * these we echo it back; otherwise we answer with our newest and let the
5
5
  * client decide whether it can proceed. */
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,cAAc,UAAU,CAAA;AAErC;;4CAE4C;AAC5C,eAAO,MAAM,2BAA2B,UAA6C,CAAA;AAGrF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAA;IACd,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EA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,OAAO,CAAA;KAAE,CAAA;CAC1D;AAeD;4BAC4B;AAC5B,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAkExF;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAQlF;AAED;0EAC0E;AAC1E,qBAAa,WAAW;IAIpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,MAAM,CAAK;gBAGA,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI;IAG5D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAW1B"}
package/dist/server.js CHANGED
@@ -4,9 +4,12 @@
4
4
  // auditable, local, dependency-free code; pulling a transitive tree into the
5
5
  // component that reads your files to undercut that would be an odd trade for
6
6
  // ~150 lines of message plumbing.
7
+ import { createRequire } from 'node:module';
7
8
  import { PRODUCT_NAME } from '@veilio-inc/engine';
8
9
  import { callTool, TOOLS } from './tools.js';
9
- export const SERVER_VERSION = '0.1.0';
10
+ // Read from the package, not typed here - told to every MCP client, and a
11
+ // literal drifted from what npm published (found 2026-09-26).
12
+ export const SERVER_VERSION = createRequire(import.meta.url)('../package.json').version;
10
13
  /** Protocol revisions this server implements. If the client asks for one of
11
14
  * these we echo it back; otherwise we answer with our newest and let the
12
15
  * client decide whether it can proceed. */
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,K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A;CACzE;AAkMD,eAAO,MAAM,KAAK,EAAE,cAAc,EAyIjC,CAAA;AAED,eAAO,MAAM,aAAa,6BAAyC,CAAA;AAEnE;;wEAEwE;AACxE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,UAAU,CASZ"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAuDA,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAA;IACX,yEAAyE;IACzE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,UAAU,CAAA;CACzE;AA0QD,eAAO,MAAM,KAAK,EAAE,cAAc,EAiLjC,CAAA;AAED,eAAO,MAAM,aAAa,6BAAyC,CAAA;AAEnE;;wEAEwE;AACxE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,UAAU,CASZ"}
package/dist/tools.js CHANGED
@@ -17,9 +17,18 @@
17
17
  // model does not reach for it out of convenience and quietly defeat the purpose.
18
18
  import { readFileSync } from 'node:fs';
19
19
  import { isAbsolute, relative, resolve } from 'node:path';
20
- import { anonymize, detectSecrets, isPlaceholder, restore, summarizeSecrets, withAiPreamble, BIN_NAME, LANGUAGES, LANGUAGE_LABELS, PRODUCT_NAME, } from '@veilio-inc/engine';
20
+ import { anonymize, detectSecrets, isPlaceholder, restore, restoreLayers, disputedNote, locallyNumberedNote, summarizeSecrets, withAiPreamble, BIN_NAME, LANGUAGES, LANGUAGE_LABELS, PRODUCT_NAME, } from '@veilio-inc/engine';
21
21
  import { loadMap, resolveMapPath, saveMap } from '@veilio-inc/cli/store';
22
- import { getNamespace, mergeNamespace } from './namespace.js';
22
+ import { getNamespace, mergeNamespace, namespaceLine, refreshNamespaceIfStale, } from './namespace.js';
23
+ import { teamLayerNote } from '@veilio-inc/cli/team-namespace';
24
+ /** Said when a tool call has just started reloading the team's maps. */
25
+ function loadingNote(why) {
26
+ return why === 'unlocked'
27
+ ? "Note: the team key was unlocked - loading the team's maps now; call again in a moment to use them."
28
+ : "Note: asking Cloud for the team's maps again; call again in a moment to use them.";
29
+ }
30
+ import { getRules } from './rules.js';
31
+ import { describeAge } from '@veilio-inc/cli/rules';
23
32
  // ─── Helpers ─────────────────────────────────────────────────────────────────
24
33
  class ToolError extends Error {
25
34
  }
@@ -116,6 +125,51 @@ function restoreReportLines(report) {
116
125
  }
117
126
  return parts.length > 0 ? `\n\n${parts.join('\n\n')}` : '';
118
127
  }
128
+ function rulesLine(r) {
129
+ if (r.source === 'none')
130
+ return 'Custom rules: none';
131
+ const n = `${r.rules.length} custom rule${r.rules.length === 1 ? '' : 's'}`;
132
+ if (r.source === 'cloud')
133
+ return `Custom rules: ${n} from Cloud`;
134
+ return `Custom rules: ${n} cached, pulled ${describeAge(r.pulledAt ?? '')} - Cloud did not answer`;
135
+ }
136
+ const NUMBERED = /^(__[A-Z][A-Z0-9_]*__)(\d+)$/;
137
+ const FLOOR_MARKER = '\u0000floor:';
138
+ /**
139
+ * Anonymize with every NEW number above `floors[base]` (spec 017).
140
+ *
141
+ * The engine numbers above the highest number in the map it is given, so a
142
+ * marker entry at the floor moves the counter there. Markers hold a NUL no
143
+ * identifier contains, match nothing in the text, and are stripped from the
144
+ * returned map. Only added above the map's own highest, where they cannot
145
+ * overwrite a real entry. Same technique as the Cloud web app.
146
+ */
147
+ /** The team's highest number per base, raised to this project's own where higher. */
148
+ function floorsWith(highest, local) {
149
+ const floors = { ...highest };
150
+ for (const placeholder of Object.keys(local)) {
151
+ const m = NUMBERED.exec(placeholder);
152
+ if (m && Number(m[2]) > (floors[m[1]] ?? 0))
153
+ floors[m[1]] = Number(m[2]);
154
+ }
155
+ return floors;
156
+ }
157
+ function anonymizeAbove(source, options, floors) {
158
+ const inMap = {};
159
+ for (const p of Object.keys(options.existingMap)) {
160
+ const m = NUMBERED.exec(p);
161
+ if (m && Number(m[2]) > (inMap[m[1]] ?? 0))
162
+ inMap[m[1]] = Number(m[2]);
163
+ }
164
+ const seeded = { ...options.existingMap };
165
+ for (const [base, floor] of Object.entries(floors)) {
166
+ if (floor > (inMap[base] ?? 0))
167
+ seeded[`${base}${floor}`] = `${FLOOR_MARKER}${base}`;
168
+ }
169
+ const result = anonymize(source, { ...options, existingMap: seeded });
170
+ const map = Object.fromEntries(Object.entries(result.map).filter(([, identifier]) => !identifier.startsWith(FLOOR_MARKER)));
171
+ return { ...result, map };
172
+ }
119
173
  const LANGUAGE_ENUM = ['auto', ...LANGUAGES];
120
174
  const LANGUAGE_PROP = {
121
175
  type: 'string',
@@ -129,10 +183,16 @@ function runAnonymize(source, label, args, ctx) {
129
183
  // independently and a shared key is coincidence, not identity. See
130
184
  // mergeNamespace's own comment for why a naive `{ ...local, ...namespace }`
131
185
  // corrupts the store (spec 005 US4).
132
- const { source: namespaceSource, namespace } = getNamespace();
186
+ const refreshing = refreshNamespaceIfStale();
187
+ const resolved = getNamespace();
188
+ const { namespace, highest } = resolved;
133
189
  const existingMap = mergeNamespace(localMap, namespace);
134
190
  const language = (str(args, 'language') ?? 'auto');
135
- const result = anonymize(source, { existingMap, language, secrets: 'redact' });
191
+ const rules = getRules();
192
+ // New names go above the team's numbers AND this project's own: an entry
193
+ // mergeNamespace left out (a lapse-era number) stays in the store, and a new
194
+ // identifier must never be handed its number (spec 028 R5).
195
+ const result = anonymizeAbove(source, { existingMap, language, secrets: 'redact', rules: rules.rules }, floorsWith(highest, localMap));
136
196
  // Persist local-original, whatever this call genuinely minted, and only the
137
197
  // team-overlay entries this call actually USED — never the rest of the team
138
198
  // namespace. Persisting all of it would bake entries this project never
@@ -141,9 +201,14 @@ function runAnonymize(source, label, args, ctx) {
141
201
  // resolving through team placeholders while truthfully reporting `local`.
142
202
  // Persisting none of it, the other extreme, breaks `restore_text` for a
143
203
  // team placeholder that IS sitting in the output this call just returned.
144
- const toPersist = Object.fromEntries(Object.entries(result.map).filter(([placeholder]) => !(placeholder in namespace) ||
145
- placeholder in localMap ||
146
- appearsAsToken(result.anonymized, placeholder)));
204
+ // Every entry the store already held is kept - including one mergeNamespace
205
+ // left out of this call - because text was already sent with it.
206
+ const toPersist = {
207
+ ...localMap,
208
+ ...Object.fromEntries(Object.entries(result.map).filter(([placeholder]) => !(placeholder in namespace) ||
209
+ placeholder in localMap ||
210
+ appearsAsToken(result.anonymized, placeholder))),
211
+ };
147
212
  saveMap(mapPath, toPersist);
148
213
  const body = args.preamble === true ? withAiPreamble(result.anonymized, result.map) : result.anonymized;
149
214
  // The model reading this is about to reason over the masked text, and these
@@ -169,7 +234,11 @@ function runAnonymize(source, label, args, ctx) {
169
234
  `Placeholders in map: ${Object.keys(toPersist).length}`,
170
235
  // Never absent (FR-016, Constitution V): a result that cannot say where its
171
236
  // names came from is the silent fallback this line exists to rule out.
172
- `Namespace: ${namespaceSource}`,
237
+ namespaceLine(resolved),
238
+ ...(refreshing ? [loadingNote(refreshing)] : []),
239
+ // Stated every time, like the namespace: an agent whose masking ignored the
240
+ // team's rules must be able to tell.
241
+ rulesLine(rules),
173
242
  secretSummary(result.secrets),
174
243
  ...caveats,
175
244
  ].join('\n');
@@ -250,15 +319,52 @@ export const TOOLS = [
250
319
  },
251
320
  handler: (args, ctx) => {
252
321
  const text = str(args, 'text', true);
253
- const map = loadMap(resolveMapPath(ctx.mapPath, ctx.cwd));
254
- if (Object.keys(map).length === 0) {
322
+ const own = loadMap(resolveMapPath(ctx.mapPath, ctx.cwd));
323
+ // The one restore rule (spec 028), shared with the web app and the CLI:
324
+ // the team's maps - aliases included, disputed placeholders left out -
325
+ // then this project's map on top where it is in the team's numbering.
326
+ const refreshing = refreshNamespaceIfStale();
327
+ const resolved = getNamespace();
328
+ const team = resolved.source === 'team' && resolved.conflictDetection
329
+ ? {
330
+ namespace: resolved.namespace,
331
+ aliases: resolved.aliases,
332
+ conflicts: resolved.conflicts,
333
+ }
334
+ : null;
335
+ const unexplained = restore(text, own).report.unresolved;
336
+ const found = resolved.found;
337
+ const note = team ? null : teamLayerNote(found, unexplained);
338
+ if (Object.keys(own).length === 0 && !team && !note) {
255
339
  throw new ToolError(`no symbol map yet — run anonymize_file (or "${BIN_NAME} scrub") first`);
256
340
  }
257
- const result = restore(text, map);
341
+ const layers = restoreLayers({ own, team });
342
+ const disputed = layers.disputedIn(text);
343
+ const localOnly = layers.locallyNumberedIn(text);
344
+ const result = restore(text, layers.map);
345
+ // Measured against this project's map, not the whole team layer (review),
346
+ // and a placeholder left for a named reason is not "invented".
347
+ const report = {
348
+ ...result.report,
349
+ missing: result.report.missing.filter((p) => p in own),
350
+ unresolved: result.report.unresolved.filter((p) => !disputed.includes(p) && !localOnly.includes(p)),
351
+ };
352
+ const counted = new Set([...Object.keys(own), ...result.report.resolved]).size;
353
+ const warnings = [
354
+ ...(refreshing ? [loadingNote(refreshing)] : []),
355
+ ...(note ? [`WARNING: ${note}`] : []),
356
+ ...(disputed.length ? [`WARNING: ${disputedNote(disputed)}`] : []),
357
+ ...(localOnly.length ? [`WARNING: ${locallyNumberedNote(localOnly)}`] : []),
358
+ ];
359
+ // Unrestored team placeholders because the team's maps could not be used
360
+ // (locked, unreadable): not a success, whatever else restored (FR-005).
361
+ const failed = found.status === 'locked' || found.status === 'unavailable';
258
362
  return {
259
- text: `Restored ${result.report.resolved.length} of ${Object.keys(map).length} placeholders; ` +
363
+ isError: note !== null && failed,
364
+ text: `Restored ${result.report.resolved.length} of ${counted} placeholders; ` +
260
365
  `stripped ${result.strippedCount} AI artifact(s).` +
261
- `${restoreReportLines(result.report)}\n\n--- restored ---\n${result.restored}`,
366
+ `${restoreReportLines(report)}` +
367
+ `${warnings.length ? `\n\n${warnings.join('\n')}` : ''}\n\n--- restored ---\n${result.restored}`,
262
368
  };
263
369
  },
264
370
  },
package/dist/tools.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,oCAAoC;AACpC,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,aAAa;AACb,EAAE;AACF,8EAA8E;AAC9E,mEAAmE;AACnE,iFAAiF;AACjF,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,iFAAiF;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,GAGb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAsB7D,gFAAgF;AAEhF,MAAM,SAAU,SAAQ,KAAK;CAAG;AAIhC,SAAS,GAAG,CAAC,IAA6B,EAAE,GAAW,EAAE,QAAQ,GAAG,KAAK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;wEAEwE;AACxE,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,IAA6B,EAC7B,GAAgB;IAEhB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,IAAI,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACpE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,KAAK,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC/D,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veilio-inc/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "MCP server exposing the anonymizer to coding agents, so a model can work on masked code without the real identifiers ever entering its context.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,8 +27,8 @@
27
27
  ],
28
28
  "license": "SEE LICENSE IN LICENSE",
29
29
  "dependencies": {
30
- "@veilio-inc/engine": "^1.6.0",
31
- "@veilio-inc/cli": "^0.2.0"
30
+ "@veilio-inc/engine": "^1.7.0",
31
+ "@veilio-inc/cli": "^0.3.1"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsc",