@mnemonik/shared 7.111.2 → 7.111.4

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,25 @@
1
+ import type { HostName } from './hostAdapter.js';
2
+ export interface GrantClient {
3
+ clientId: string;
4
+ clientName?: string | null;
5
+ softwareId?: string | null;
6
+ }
7
+ export declare function hostForGrantClient(client: GrantClient): HostName | undefined;
8
+ /** The coding tools' own names, as a person reads them. */
9
+ export declare const CODING_TOOL_NAMES: Readonly<Record<HostName, string>>;
10
+ /**
11
+ * How each launch coding tool signs in to Mnemonik's MCP. `connect`:
12
+ * `mnemonik connect <tool>` drives the tool's own headless login (Codex:
13
+ * `codex mcp login mnemonik`), prints the approval link and waits, so an agent
14
+ * with a terminal runs it and hands the person the link. `in_tool`: only the
15
+ * person can, inside the coding tool (Claude Code refuses OAuth login on piped
16
+ * stdin; Cursor has no login command); `step` is that step in plain words.
17
+ */
18
+ export type CodingToolSignIn = {
19
+ kind: 'connect';
20
+ } | {
21
+ kind: 'in_tool';
22
+ step: string;
23
+ };
24
+ export declare const CODING_TOOL_SIGN_IN: Readonly<Record<'claude-code' | 'codex' | 'cursor', CodingToolSignIn>>;
25
+ //# sourceMappingURL=grantHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grantHost.d.ts","sourceRoot":"","sources":["../src/grantHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AA0BjD,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAM5E;AAED,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAMhE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACvF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CACxC,MAAM,CAAC,aAAa,GAAG,OAAO,GAAG,QAAQ,EAAE,gBAAgB,CAAC,CAW7D,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Which coding tool an MCP sign-in (an OAuth grant) belongs to. The one mapping
3
+ * read by the server's machine health, the console's device card and the CLI:
4
+ * the registered software id first, then the client name, then the host of a
5
+ * metadata-document client id. Display metadata is self-asserted, so this names
6
+ * a tool for reporting only; it is never evidence of account ownership.
7
+ */
8
+ const BY_NAME = {
9
+ 'claude code': 'claude-code',
10
+ 'claude-code': 'claude-code',
11
+ codex: 'codex',
12
+ 'codex cli': 'codex',
13
+ cursor: 'cursor',
14
+ grok: 'grok',
15
+ 'grok build': 'grok',
16
+ 'github copilot': 'vscode-copilot',
17
+ 'vs code copilot': 'vscode-copilot',
18
+ 'vscode-copilot': 'vscode-copilot',
19
+ };
20
+ const BY_CLIENT_HOST = {
21
+ 'claude.ai': 'claude-code',
22
+ 'chatgpt.com': 'codex',
23
+ };
24
+ export function hostForGrantClient(client) {
25
+ return (BY_NAME[client.softwareId?.toLowerCase() ?? ''] ??
26
+ BY_NAME[client.clientName?.toLowerCase() ?? ''] ??
27
+ BY_CLIENT_HOST[URL.canParse(client.clientId) ? new URL(client.clientId).hostname : '']);
28
+ }
29
+ /** The coding tools' own names, as a person reads them. */
30
+ export const CODING_TOOL_NAMES = {
31
+ 'claude-code': 'Claude Code',
32
+ codex: 'Codex',
33
+ cursor: 'Cursor',
34
+ grok: 'Grok',
35
+ 'vscode-copilot': 'VS Code Copilot',
36
+ };
37
+ export const CODING_TOOL_SIGN_IN = {
38
+ 'claude-code': {
39
+ kind: 'in_tool',
40
+ step: 'In Claude Code, type /mcp, choose mnemonik, then Authenticate.',
41
+ },
42
+ codex: { kind: 'connect' },
43
+ cursor: {
44
+ kind: 'in_tool',
45
+ step: 'In Cursor, open Cursor Settings, Customize, MCPs, then Authenticate.',
46
+ },
47
+ };
48
+ //# sourceMappingURL=grantHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grantHost.js","sourceRoot":"","sources":["../src/grantHost.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,GAAuC;IAClD,aAAa,EAAE,aAAa;IAC5B,aAAa,EAAE,aAAa;IAC5B,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,OAAO;IACpB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,MAAM;IACpB,gBAAgB,EAAE,gBAAgB;IAClC,iBAAiB,EAAE,gBAAgB;IACnC,gBAAgB,EAAE,gBAAgB;CACnC,CAAC;AACF,MAAM,cAAc,GAAuC;IACzD,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,OAAO;CACvB,CAAC;AAQF,MAAM,UAAU,kBAAkB,CAAC,MAAmB;IACpD,OAAO,CACL,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAC/C,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAC/C,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CACvF,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAAuC;IACnE,aAAa,EAAE,aAAa;IAC5B,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,gBAAgB,EAAE,iBAAiB;CACpC,CAAC;AAWF,MAAM,CAAC,MAAM,mBAAmB,GAE5B;IACF,aAAa,EAAE;QACb,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,gEAAgE;KACvE;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC1B,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,sEAAsE;KAC7E;CACF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export * from './repositoryRoot.js';
21
21
  export * from './protectedPaths.js';
22
22
  export * from './readiness.js';
23
23
  export * from './hostAdapter.js';
24
+ export * from './grantHost.js';
24
25
  export * from './hostBinary.js';
25
26
  export type { ServiceDefinition, SupervisorStatus, ServiceOperation, ServiceResult, } from './scannerSupervisor.js';
26
27
  export { apiOrigin } from './apiOrigin.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,W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,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAC/B,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAEhC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ export * from './repositoryRoot.js';
21
21
  export * from './protectedPaths.js';
22
22
  export * from './readiness.js';
23
23
  export * from './hostAdapter.js';
24
+ export * from './grantHost.js';
24
25
  export * from './hostBinary.js';
25
26
  export { apiOrigin } from './apiOrigin.js';
26
27
  export { WINDOWS_SERVICE_BUDGET_MS, SCANNER_STARTUP_BUDGET_MS, SCANNER_RAPID_FAILURE_LIMIT, SCANNER_HANDOFF_BUDGET_MS, SCANNER_RECEIPT_STALE_MS, SCANNER_MAC_COMMAND_BUDGET_MS, SCANNER_STOP_BUDGET_MS, SCANNER_REMOVAL_BUDGET_MS, scannerAttemptHealthy, } from './scannerSupervisor.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GAGrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GAKnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,mBAAmB,EACnB,YAAY,GAGb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,YAAY,EACZ,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,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ACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnemonik/shared",
3
- "version": "7.111.2",
3
+ "version": "7.111.4",
4
4
  "description": "Shared constants and utilities for Mnemonik packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "scripts": {
48
- "test": "tsx --test --test-concurrency=2 tests/repositoryFingerprint.test.ts tests/projectIdentity.test.ts tests/readiness.test.ts tests/hookRuntime.test.ts",
48
+ "test": "tsx --test --test-concurrency=2 tests/repositoryFingerprint.test.ts tests/projectIdentity.test.ts tests/readiness.test.ts tests/hookRuntime.test.ts tests/grantHost.test.ts",
49
49
  "build": "node ../../node_modules/@typescript/native/bin/tsc",
50
50
  "typecheck": "node ../../node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.test.json",
51
51
  "prepublishOnly": "npm run build"
@@ -0,0 +1,71 @@
1
+ import type { HostName } from './hostAdapter.js';
2
+
3
+ /**
4
+ * Which coding tool an MCP sign-in (an OAuth grant) belongs to. The one mapping
5
+ * read by the server's machine health, the console's device card and the CLI:
6
+ * the registered software id first, then the client name, then the host of a
7
+ * metadata-document client id. Display metadata is self-asserted, so this names
8
+ * a tool for reporting only; it is never evidence of account ownership.
9
+ */
10
+ const BY_NAME: Readonly<Record<string, HostName>> = {
11
+ 'claude code': 'claude-code',
12
+ 'claude-code': 'claude-code',
13
+ codex: 'codex',
14
+ 'codex cli': 'codex',
15
+ cursor: 'cursor',
16
+ grok: 'grok',
17
+ 'grok build': 'grok',
18
+ 'github copilot': 'vscode-copilot',
19
+ 'vs code copilot': 'vscode-copilot',
20
+ 'vscode-copilot': 'vscode-copilot',
21
+ };
22
+ const BY_CLIENT_HOST: Readonly<Record<string, HostName>> = {
23
+ 'claude.ai': 'claude-code',
24
+ 'chatgpt.com': 'codex',
25
+ };
26
+
27
+ export interface GrantClient {
28
+ clientId: string;
29
+ clientName?: string | null;
30
+ softwareId?: string | null;
31
+ }
32
+
33
+ export function hostForGrantClient(client: GrantClient): HostName | undefined {
34
+ return (
35
+ BY_NAME[client.softwareId?.toLowerCase() ?? ''] ??
36
+ BY_NAME[client.clientName?.toLowerCase() ?? ''] ??
37
+ BY_CLIENT_HOST[URL.canParse(client.clientId) ? new URL(client.clientId).hostname : '']
38
+ );
39
+ }
40
+
41
+ /** The coding tools' own names, as a person reads them. */
42
+ export const CODING_TOOL_NAMES: Readonly<Record<HostName, string>> = {
43
+ 'claude-code': 'Claude Code',
44
+ codex: 'Codex',
45
+ cursor: 'Cursor',
46
+ grok: 'Grok',
47
+ 'vscode-copilot': 'VS Code Copilot',
48
+ };
49
+
50
+ /**
51
+ * How each launch coding tool signs in to Mnemonik's MCP. `connect`:
52
+ * `mnemonik connect <tool>` drives the tool's own headless login (Codex:
53
+ * `codex mcp login mnemonik`), prints the approval link and waits, so an agent
54
+ * with a terminal runs it and hands the person the link. `in_tool`: only the
55
+ * person can, inside the coding tool (Claude Code refuses OAuth login on piped
56
+ * stdin; Cursor has no login command); `step` is that step in plain words.
57
+ */
58
+ export type CodingToolSignIn = { kind: 'connect' } | { kind: 'in_tool'; step: string };
59
+ export const CODING_TOOL_SIGN_IN: Readonly<
60
+ Record<'claude-code' | 'codex' | 'cursor', CodingToolSignIn>
61
+ > = {
62
+ 'claude-code': {
63
+ kind: 'in_tool',
64
+ step: 'In Claude Code, type /mcp, choose mnemonik, then Authenticate.',
65
+ },
66
+ codex: { kind: 'connect' },
67
+ cursor: {
68
+ kind: 'in_tool',
69
+ step: 'In Cursor, open Cursor Settings, Customize, MCPs, then Authenticate.',
70
+ },
71
+ };
package/src/index.ts CHANGED
@@ -81,6 +81,7 @@ export * from './protectedPaths.js';
81
81
  export * from './readiness.js';
82
82
 
83
83
  export * from './hostAdapter.js';
84
+ export * from './grantHost.js';
84
85
  export * from './hostBinary.js';
85
86
 
86
87
  export type {
@@ -0,0 +1,32 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import { CODING_TOOL_SIGN_IN, hostForGrantClient } from '../src/grantHost.js';
4
+
5
+ test('names the coding tool from software id, then client name, then client id host', () => {
6
+ assert.equal(
7
+ hostForGrantClient({ clientId: 'https://claude.ai/oauth/claude-code' }),
8
+ 'claude-code'
9
+ );
10
+ assert.equal(hostForGrantClient({ clientId: 'https://chatgpt.com/codex' }), 'codex');
11
+ assert.equal(hostForGrantClient({ clientId: 'x', clientName: 'Cursor' }), 'cursor');
12
+ assert.equal(hostForGrantClient({ clientId: 'x', clientName: 'Codex CLI' }), 'codex');
13
+ assert.equal(
14
+ hostForGrantClient({
15
+ clientId: 'https://claude.ai/x',
16
+ softwareId: 'cursor',
17
+ clientName: 'Codex',
18
+ }),
19
+ 'cursor'
20
+ );
21
+ assert.equal(hostForGrantClient({ clientId: 'mnemonik-cli' }), undefined);
22
+ assert.equal(
23
+ hostForGrantClient({ clientId: 'https://example.com/x', clientName: 'Other' }),
24
+ undefined
25
+ );
26
+ });
27
+
28
+ test('Codex signs in through mnemonik connect; Claude Code and Cursor only inside the tool', () => {
29
+ assert.deepEqual(CODING_TOOL_SIGN_IN.codex, { kind: 'connect' });
30
+ assert.equal(CODING_TOOL_SIGN_IN['claude-code'].kind, 'in_tool');
31
+ assert.equal(CODING_TOOL_SIGN_IN.cursor.kind, 'in_tool');
32
+ });