@sota-io/mcp 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CLAUDE.md +19 -4
  2. package/README.md +11 -4
  3. package/dist/auth/token-bridge.d.ts +16 -0
  4. package/dist/auth/token-bridge.d.ts.map +1 -1
  5. package/dist/auth/token-bridge.js +49 -9
  6. package/dist/auth/token-bridge.js.map +1 -1
  7. package/dist/auth/verify-jwt.js +6 -6
  8. package/dist/auth/verify-jwt.js.map +1 -1
  9. package/dist/http-app.d.ts +27 -0
  10. package/dist/http-app.d.ts.map +1 -0
  11. package/dist/http-app.js +324 -0
  12. package/dist/http-app.js.map +1 -0
  13. package/dist/http.d.ts +3 -15
  14. package/dist/http.d.ts.map +1 -1
  15. package/dist/http.js +13 -251
  16. package/dist/http.js.map +1 -1
  17. package/dist/index.js +11 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/lib/account.d.ts +63 -0
  20. package/dist/lib/account.d.ts.map +1 -0
  21. package/dist/lib/account.js +64 -0
  22. package/dist/lib/account.js.map +1 -0
  23. package/dist/lib/archive-builder.d.ts +39 -5
  24. package/dist/lib/archive-builder.d.ts.map +1 -1
  25. package/dist/lib/archive-builder.js +131 -37
  26. package/dist/lib/archive-builder.js.map +1 -1
  27. package/dist/lib/auth-config.d.ts +37 -0
  28. package/dist/lib/auth-config.d.ts.map +1 -0
  29. package/dist/lib/auth-config.js +95 -0
  30. package/dist/lib/auth-config.js.map +1 -0
  31. package/dist/lib/guide.d.ts +33 -0
  32. package/dist/lib/guide.d.ts.map +1 -0
  33. package/dist/lib/guide.js +82 -0
  34. package/dist/lib/guide.js.map +1 -0
  35. package/dist/lib/hosted-guard.d.ts +26 -0
  36. package/dist/lib/hosted-guard.d.ts.map +1 -0
  37. package/dist/lib/hosted-guard.js +48 -0
  38. package/dist/lib/hosted-guard.js.map +1 -0
  39. package/dist/lib/ignore.d.ts +16 -0
  40. package/dist/lib/ignore.d.ts.map +1 -0
  41. package/dist/lib/ignore.js +131 -0
  42. package/dist/lib/ignore.js.map +1 -0
  43. package/dist/lib/log.d.ts +17 -0
  44. package/dist/lib/log.d.ts.map +1 -0
  45. package/dist/lib/log.js +41 -0
  46. package/dist/lib/log.js.map +1 -0
  47. package/dist/lib/project-url.d.ts +14 -0
  48. package/dist/lib/project-url.d.ts.map +1 -0
  49. package/dist/lib/project-url.js +16 -0
  50. package/dist/lib/project-url.js.map +1 -0
  51. package/dist/lib/version.d.ts +22 -0
  52. package/dist/lib/version.d.ts.map +1 -0
  53. package/dist/lib/version.js +36 -0
  54. package/dist/lib/version.js.map +1 -0
  55. package/dist/oauth-proxy.d.ts +31 -0
  56. package/dist/oauth-proxy.d.ts.map +1 -0
  57. package/dist/oauth-proxy.js +212 -0
  58. package/dist/oauth-proxy.js.map +1 -0
  59. package/dist/tools/account.d.ts +10 -0
  60. package/dist/tools/account.d.ts.map +1 -0
  61. package/dist/tools/account.js +104 -0
  62. package/dist/tools/account.js.map +1 -0
  63. package/dist/tools/create-account.d.ts.map +1 -1
  64. package/dist/tools/create-account.js +23 -1
  65. package/dist/tools/create-account.js.map +1 -1
  66. package/dist/tools/deploy.d.ts +19 -1
  67. package/dist/tools/deploy.d.ts.map +1 -1
  68. package/dist/tools/deploy.js +129 -77
  69. package/dist/tools/deploy.js.map +1 -1
  70. package/dist/tools/env.js +2 -2
  71. package/dist/tools/env.js.map +1 -1
  72. package/dist/tools/logs.js +1 -1
  73. package/dist/tools/logs.js.map +1 -1
  74. package/dist/tools/projects.d.ts +8 -1
  75. package/dist/tools/projects.d.ts.map +1 -1
  76. package/dist/tools/projects.js +13 -5
  77. package/dist/tools/projects.js.map +1 -1
  78. package/dist/tools/status.d.ts.map +1 -1
  79. package/dist/tools/status.js +8 -3
  80. package/dist/tools/status.js.map +1 -1
  81. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ export interface IgnoreRules {
2
+ /** ".sotaignore", ".gitignore" or null when no file was used. */
3
+ source: string | null;
4
+ patterns: string[];
5
+ }
6
+ export declare const NO_RULES: IgnoreRules;
7
+ /** Kept when only the .gitignore fallback applies (base names). */
8
+ export declare const KEPT_FROM_GITIGNORE: ReadonlySet<string>;
9
+ export declare function loadIgnoreRules(root: string, opts: {
10
+ gitignoreFallback: boolean;
11
+ }): IgnoreRules;
12
+ /** relPath uses "/" and has no leading "./". */
13
+ export declare function isIgnored(relPath: string, isDir: boolean, patterns: readonly string[]): boolean;
14
+ /** isIgnored with the .gitignore-fallback exceptions. */
15
+ export declare function ignoredBy(rules: IgnoreRules, relPath: string, isDir: boolean): boolean;
16
+ //# sourceMappingURL=ignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../src/lib/ignore.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,EAAE,WAA4C,CAAC;AAEpE,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAgD,CAAC;AAcrG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CAQ/F;AAyBD,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAyB/F;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAQtF"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * .sotaignore / .gitignore for directory and git deploys (quick task
3
+ * 261125-mcg), with the CLI's pattern rules (cli/internal/archive/archive.go
4
+ * loadIgnorePatterns + shouldIgnore). Blank lines and # comments are skipped.
5
+ * A pattern matches a relative path when
6
+ * - it ends in "/" and names that directory or a path below it,
7
+ * - it equals the path or its base name,
8
+ * - it contains "*" and glob-matches the base name or the whole path
9
+ * ("*" and "?" do not cross "/"), or
10
+ * - it equals one path component.
11
+ * Additions to the CLI rules: a leading "/" anchors the pattern to the root
12
+ * (as in git); "!" lines are skipped (no re-include); a pattern that is not a
13
+ * valid glob is skipped (like Go's filepath.Match returning an error).
14
+ *
15
+ * Which file is read:
16
+ * - directory deploy: .sotaignore when it exists (an empty one means
17
+ * "nothing extra", it does NOT fall back to .gitignore); otherwise the
18
+ * .gitignore, but .env.production and .env.example are kept even when
19
+ * the .gitignore lists them (create-next-app's .gitignore has ".env*",
20
+ * and public build-time values such as NEXT_PUBLIC_* live there).
21
+ * - git_url deploy: only .sotaignore. A clone holds tracked files only,
22
+ * and tracked files that match the .gitignore (committed build output)
23
+ * have always been deployed.
24
+ */
25
+ import { existsSync, readFileSync } from 'fs';
26
+ import { join } from 'path';
27
+ export const NO_RULES = { source: null, patterns: [] };
28
+ /** Kept when only the .gitignore fallback applies (base names). */
29
+ export const KEPT_FROM_GITIGNORE = new Set(['.env.production', '.env.example']);
30
+ function readPatterns(path) {
31
+ if (!existsSync(path))
32
+ return null;
33
+ try {
34
+ return readFileSync(path, 'utf8')
35
+ .split(/\r?\n/)
36
+ .map((l) => l.trim())
37
+ .filter((l) => l !== '' && !l.startsWith('#') && !l.startsWith('!'));
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ export function loadIgnoreRules(root, opts) {
44
+ const sota = readPatterns(join(root, '.sotaignore'));
45
+ if (sota !== null)
46
+ return { source: '.sotaignore', patterns: sota };
47
+ if (opts.gitignoreFallback) {
48
+ const git = readPatterns(join(root, '.gitignore'));
49
+ if (git !== null)
50
+ return { source: '.gitignore', patterns: git };
51
+ }
52
+ return NO_RULES;
53
+ }
54
+ /** null when the pattern is not a valid glob. */
55
+ function globToRegExp(glob) {
56
+ let re = '';
57
+ for (let i = 0; i < glob.length; i++) {
58
+ const c = glob[i];
59
+ if (c === '*')
60
+ re += '[^/]*';
61
+ else if (c === '?')
62
+ re += '[^/]';
63
+ else if (c === '[') {
64
+ const end = glob.indexOf(']', i + 1);
65
+ if (end === -1)
66
+ return null; // unterminated class: invalid, like filepath.Match
67
+ let cls = glob.slice(i + 1, end);
68
+ if (cls.startsWith('!') || cls.startsWith('^'))
69
+ cls = `^${cls.slice(1)}`;
70
+ re += `[${cls.replace(/\\/g, '\\\\')}]`;
71
+ i = end;
72
+ }
73
+ else
74
+ re += c.replace(/[.+^${}()|\\]/g, '\\$&');
75
+ }
76
+ try {
77
+ return new RegExp(`^${re}$`);
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ /** relPath uses "/" and has no leading "./". */
84
+ export function isIgnored(relPath, isDir, patterns) {
85
+ const base = relPath.slice(relPath.lastIndexOf('/') + 1);
86
+ const parts = relPath.split('/');
87
+ for (const raw of patterns) {
88
+ const anchored = raw.startsWith('/');
89
+ const pattern = anchored ? raw.slice(1) : raw;
90
+ if (pattern === '')
91
+ continue;
92
+ if (pattern.endsWith('/')) {
93
+ const dir = pattern.slice(0, -1);
94
+ if (isDir && (relPath === dir || relPath.startsWith(`${dir}/`)))
95
+ return true;
96
+ if (!isDir && relPath.startsWith(`${dir}/`))
97
+ return true;
98
+ continue;
99
+ }
100
+ if (relPath === pattern)
101
+ return true;
102
+ const wild = pattern.includes('*') || pattern.includes('?') || pattern.includes('[');
103
+ const re = wild ? globToRegExp(pattern) : null;
104
+ if (anchored) {
105
+ if (re && re.test(relPath))
106
+ return true;
107
+ continue;
108
+ }
109
+ if (base === pattern)
110
+ return true;
111
+ if (re && (re.test(base) || re.test(relPath)))
112
+ return true;
113
+ if (parts.includes(pattern))
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+ /** isIgnored with the .gitignore-fallback exceptions. */
119
+ export function ignoredBy(rules, relPath, isDir) {
120
+ if (rules.patterns.length === 0)
121
+ return false;
122
+ if (!isIgnored(relPath, isDir, rules.patterns))
123
+ return false;
124
+ if (rules.source === '.gitignore' && !isDir) {
125
+ const base = relPath.slice(relPath.lastIndexOf('/') + 1);
126
+ if (KEPT_FROM_GITIGNORE.has(base))
127
+ return false;
128
+ }
129
+ return true;
130
+ }
131
+ //# sourceMappingURL=ignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/lib/ignore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,MAAM,CAAC,MAAM,QAAQ,GAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAEpE,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;AAErG,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC;aAC9B,KAAK,CAAC,OAAO,CAAC;aACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OA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AC7D,IAAI,KAAK,CAAC,MAAM,KAAK,YAAY,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACzD,IAAI,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Structured logging without personal data.
3
+ *
4
+ * Every log line of the hosted server goes through `logEvent`, which
5
+ * serialises the fields as one JSON object and then redacts anything that
6
+ * looks like an email address, including emails embedded in upstream error
7
+ * messages. Log user ids (JWT `sub`) to correlate requests, never emails.
8
+ */
9
+ export declare const EMAIL_REDACTED = "[email redacted]";
10
+ export declare function redactEmails(text: string): string;
11
+ export type LogLevel = 'info' | 'warn' | 'error';
12
+ /** Serialise `fields` as a single JSON line with emails redacted. */
13
+ export declare function formatLogLine(fields: Record<string, unknown>): string;
14
+ export declare function logEvent(level: LogLevel, fields: Record<string, unknown>): void;
15
+ /** Error message for a log field, with emails redacted. */
16
+ export declare function errorMessage(err: unknown): string;
17
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/lib/log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAQrE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAO/E;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEjD"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Structured logging without personal data.
3
+ *
4
+ * Every log line of the hosted server goes through `logEvent`, which
5
+ * serialises the fields as one JSON object and then redacts anything that
6
+ * looks like an email address, including emails embedded in upstream error
7
+ * messages. Log user ids (JWT `sub`) to correlate requests, never emails.
8
+ */
9
+ // Deliberately broad: a false positive only costs a redacted log fragment.
10
+ const EMAIL_RE = /[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g;
11
+ export const EMAIL_REDACTED = '[email redacted]';
12
+ export function redactEmails(text) {
13
+ return text.replace(EMAIL_RE, EMAIL_REDACTED);
14
+ }
15
+ /** Serialise `fields` as a single JSON line with emails redacted. */
16
+ export function formatLogLine(fields) {
17
+ let line;
18
+ try {
19
+ line = JSON.stringify(fields);
20
+ }
21
+ catch {
22
+ line = JSON.stringify({ event: 'log_serialisation_failed' });
23
+ }
24
+ return redactEmails(line);
25
+ }
26
+ export function logEvent(level, fields) {
27
+ const line = formatLogLine(fields);
28
+ /* eslint-disable no-console */
29
+ if (level === 'error')
30
+ console.error(line);
31
+ else if (level === 'warn')
32
+ console.warn(line);
33
+ else
34
+ console.log(line);
35
+ /* eslint-enable no-console */
36
+ }
37
+ /** Error message for a log field, with emails redacted. */
38
+ export function errorMessage(err) {
39
+ return redactEmails(err instanceof Error ? err.message : String(err));
40
+ }
41
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/lib/log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,MAAM,QAAQ,GAAG,oEAAoE,CAAC;AAEtF,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAEjD,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAChD,CAAC;AAID,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,MAA+B;IAC3D,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAe,EAAE,MAA+B;IACvE,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,+BAA+B;IAC/B,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACtC,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;QACzC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvB,8BAA8B;AAChC,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,OAAO,YAAY,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The public URL of a project, as the API returns it in `project.url`
3
+ * (ENT-MVP WP2). An Enterprise app lives at `https://<app>.<customer>.sota.io`
4
+ * and has no `<slug>.sota.io` host, so tools show this value instead of
5
+ * composing one from the slug.
6
+ *
7
+ * The slug-based fallback is only for an API from before the `url` field;
8
+ * such an API has no Enterprise projects, so the composed URL is right there.
9
+ */
10
+ export declare function projectUrl(project: {
11
+ slug: string;
12
+ url?: string | null;
13
+ }): string;
14
+ //# sourceMappingURL=project-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-url.d.ts","sourceRoot":"","sources":["../../src/lib/project-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAKjF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The public URL of a project, as the API returns it in `project.url`
3
+ * (ENT-MVP WP2). An Enterprise app lives at `https://<app>.<customer>.sota.io`
4
+ * and has no `<slug>.sota.io` host, so tools show this value instead of
5
+ * composing one from the slug.
6
+ *
7
+ * The slug-based fallback is only for an API from before the `url` field;
8
+ * such an API has no Enterprise projects, so the composed URL is right there.
9
+ */
10
+ export function projectUrl(project) {
11
+ if (typeof project.url === 'string' && project.url !== '') {
12
+ return project.url;
13
+ }
14
+ return `https://${project.slug}.sota.io`;
15
+ }
16
+ //# sourceMappingURL=project-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-url.js","sourceRoot":"","sources":["../../src/lib/project-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,OAA8C;IACvE,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,OAAO,CAAC,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,WAAW,OAAO,CAAC,IAAI,UAAU,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The package version, read from package.json at runtime.
3
+ *
4
+ * Both entry points (stdio `index.ts` and hosted `http.ts`) report this
5
+ * version, so /health and the MCP `initialize` handshake always match the
6
+ * code that is actually running. The compiled file lives at
7
+ * dist/lib/version.js, so ../../package.json is the package root in the
8
+ * npm tarball, in a local checkout and in the Docker image (/app).
9
+ */
10
+ export declare function readPackageVersion(): string;
11
+ export declare const PACKAGE_VERSION: string;
12
+ /**
13
+ * Commit and build time of the hosted image (DEVX-4). The Dockerfile turns
14
+ * the GIT_SHA and BUILD_TIME build args into environment variables of the
15
+ * runtime stage. Anything built without them (npm package, local checkout,
16
+ * a plain `docker compose build`) reports "unknown".
17
+ */
18
+ export declare const UNKNOWN_BUILD = "unknown";
19
+ export declare function readBuildValue(name: 'GIT_SHA' | 'BUILD_TIME', env?: NodeJS.ProcessEnv): string;
20
+ export declare const GIT_SHA: string;
21
+ export declare const BUILD_TIME: string;
22
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/lib/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,kBAAkB,IAAI,MAAM,CAU3C;AAED,eAAO,MAAM,eAAe,QAAuB,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAG3G;AAED,eAAO,MAAM,OAAO,QAA4B,CAAC;AACjD,eAAO,MAAM,UAAU,QAA+B,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The package version, read from package.json at runtime.
3
+ *
4
+ * Both entry points (stdio `index.ts` and hosted `http.ts`) report this
5
+ * version, so /health and the MCP `initialize` handshake always match the
6
+ * code that is actually running. The compiled file lives at
7
+ * dist/lib/version.js, so ../../package.json is the package root in the
8
+ * npm tarball, in a local checkout and in the Docker image (/app).
9
+ */
10
+ import { readFileSync } from 'node:fs';
11
+ export function readPackageVersion() {
12
+ try {
13
+ const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
14
+ if (typeof pkg.version === 'string' && pkg.version !== '')
15
+ return pkg.version;
16
+ }
17
+ catch {
18
+ // fall through: a missing package.json is a packaging bug, not a crash
19
+ }
20
+ return '0.0.0-unknown';
21
+ }
22
+ export const PACKAGE_VERSION = readPackageVersion();
23
+ /**
24
+ * Commit and build time of the hosted image (DEVX-4). The Dockerfile turns
25
+ * the GIT_SHA and BUILD_TIME build args into environment variables of the
26
+ * runtime stage. Anything built without them (npm package, local checkout,
27
+ * a plain `docker compose build`) reports "unknown".
28
+ */
29
+ export const UNKNOWN_BUILD = 'unknown';
30
+ export function readBuildValue(name, env = process.env) {
31
+ const value = (env[name] ?? '').trim();
32
+ return value === '' ? UNKNOWN_BUILD : value;
33
+ }
34
+ export const GIT_SHA = readBuildValue('GIT_SHA');
35
+ export const BUILD_TIME = readBuildValue('BUILD_TIME');
36
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/lib/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAE1F,CAAC;QACF,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,KAAK,EAAE;YAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;IACzE,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,MAAM,UAAU,cAAc,CAAC,IAA8B,EAAE,MAAyB,OAAO,CAAC,GAAG;IACjG,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * oauth-proxy.ts — Phase 65/Pattern-A precursor. Transparent reverse proxy
3
+ * in front of Supabase OAuth Server that strips `openid` from the scope
4
+ * parameter on /authorize requests, working around the Supabase OIDC bug
5
+ * (HTTP 500 "Error generating ID token" — error_id 019e41f7-…).
6
+ *
7
+ * Why this exists: removing `openid` from our /.well-known/oauth-protected-
8
+ * resource metadata's `scopes_supported` only works if the client
9
+ * (Claude.ai) actually respects the advertised list. RFC 9728 says it
10
+ * SHOULD, but if the client hardcodes openid it'll still trigger the bug.
11
+ * This proxy is a hard safety net — no matter what scope the client sends,
12
+ * Supabase never sees `openid` in the request.
13
+ *
14
+ * What the proxy does:
15
+ * GET /auth/v1/.well-known/oauth-authorization-server → rewritten metadata
16
+ * POST /auth/v1/oauth/clients/register → transparent forward
17
+ * GET /auth/v1/oauth/authorize?scope=… → strip openid → forward
18
+ * POST /auth/v1/oauth/token → transparent forward
19
+ * GET /auth/v1/oauth/userinfo → transparent forward
20
+ * GET /auth/v1/.well-known/jwks.json → transparent forward
21
+ * any other GET/POST under /auth/v1/ → transparent forward
22
+ *
23
+ * Redirects are followed by curl/SDK clients themselves; our proxy passes
24
+ * the Location header through unchanged (Supabase emits redirects to
25
+ * sota.io/oauth/authorize which is our consent UI and stays valid).
26
+ *
27
+ * Activation: registered on the same Express app as /mcp via mountOAuthProxy().
28
+ */
29
+ import type { Express } from 'express';
30
+ export declare function mountOAuthProxy(app: Express, publicOrigin: string): void;
31
+ //# sourceMappingURL=oauth-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-proxy.d.ts","sourceRoot":"","sources":["../src/oauth-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAqB,OAAO,EAAE,MAAM,SAAS,CAAC;AAmI1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAyExE"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * oauth-proxy.ts — Phase 65/Pattern-A precursor. Transparent reverse proxy
3
+ * in front of Supabase OAuth Server that strips `openid` from the scope
4
+ * parameter on /authorize requests, working around the Supabase OIDC bug
5
+ * (HTTP 500 "Error generating ID token" — error_id 019e41f7-…).
6
+ *
7
+ * Why this exists: removing `openid` from our /.well-known/oauth-protected-
8
+ * resource metadata's `scopes_supported` only works if the client
9
+ * (Claude.ai) actually respects the advertised list. RFC 9728 says it
10
+ * SHOULD, but if the client hardcodes openid it'll still trigger the bug.
11
+ * This proxy is a hard safety net — no matter what scope the client sends,
12
+ * Supabase never sees `openid` in the request.
13
+ *
14
+ * What the proxy does:
15
+ * GET /auth/v1/.well-known/oauth-authorization-server → rewritten metadata
16
+ * POST /auth/v1/oauth/clients/register → transparent forward
17
+ * GET /auth/v1/oauth/authorize?scope=… → strip openid → forward
18
+ * POST /auth/v1/oauth/token → transparent forward
19
+ * GET /auth/v1/oauth/userinfo → transparent forward
20
+ * GET /auth/v1/.well-known/jwks.json → transparent forward
21
+ * any other GET/POST under /auth/v1/ → transparent forward
22
+ *
23
+ * Redirects are followed by curl/SDK clients themselves; our proxy passes
24
+ * the Location header through unchanged (Supabase emits redirects to
25
+ * sota.io/oauth/authorize which is our consent UI and stays valid).
26
+ *
27
+ * Activation: registered on the same Express app as /mcp via mountOAuthProxy().
28
+ */
29
+ import { resolveAuthUpstream } from './lib/auth-config.js';
30
+ // AUTH_SERVER (compose: ${SUPABASE_URL}/auth/v1); default = prod
31
+ // https://auth.sota.io/auth/v1. Invalid values throw here = fail at startup.
32
+ const UPSTREAM = resolveAuthUpstream();
33
+ /**
34
+ * Strip `openid` from a space-separated scope string. Returns the cleaned
35
+ * value, or undefined when nothing remains (caller should omit the param).
36
+ */
37
+ function stripOpenidScope(raw) {
38
+ if (!raw)
39
+ return raw;
40
+ const cleaned = raw
41
+ .split(/\s+/)
42
+ .filter((s) => s.length > 0 && s.toLowerCase() !== 'openid')
43
+ .join(' ');
44
+ return cleaned.length === 0 ? undefined : cleaned;
45
+ }
46
+ /**
47
+ * Build a rewritten OIDC discovery document that points all endpoints at
48
+ * mcp.sota.io's proxy rather than auth.sota.io directly. This is the entry
49
+ * point that makes the proxy actually do anything — Claude.ai reads this
50
+ * once and uses these URLs for the rest of the flow.
51
+ */
52
+ function rewriteMetadata(upstreamMetadata, publicOrigin) {
53
+ const base = `${publicOrigin}/auth/v1`;
54
+ return {
55
+ ...upstreamMetadata,
56
+ issuer: upstreamMetadata.issuer, // keep Supabase's issuer so JWT validation still works
57
+ authorization_endpoint: `${base}/oauth/authorize`,
58
+ token_endpoint: `${base}/oauth/token`,
59
+ userinfo_endpoint: `${base}/oauth/userinfo`,
60
+ jwks_uri: `${base}/.well-known/jwks.json`,
61
+ registration_endpoint: `${base}/oauth/clients/register`,
62
+ // Crucially: drop openid from advertised scopes so well-behaved clients
63
+ // skip it. The /authorize strip-pass is the belt-and-braces backup.
64
+ scopes_supported: Array.isArray(upstreamMetadata.scopes_supported)
65
+ ? upstreamMetadata.scopes_supported.filter((s) => typeof s === 'string' && s.toLowerCase() !== 'openid')
66
+ : ['profile', 'email'],
67
+ };
68
+ }
69
+ /**
70
+ * Forward an HTTP request to Supabase OAuth Server transparently. Preserves
71
+ * method, headers (except Host), query string, and body. Returns the
72
+ * upstream response untouched.
73
+ *
74
+ * Express has already body-parsed POST JSON for us when content-type was
75
+ * application/json (set up at top of http.ts). For x-www-form-urlencoded
76
+ * we need to re-serialise from req.body. Other content types pass through
77
+ * as best we can — DCR and token endpoints use JSON / form-encoded only.
78
+ */
79
+ async function forward(req, targetPath, targetQuery) {
80
+ const url = `${UPSTREAM}${targetPath}${targetQuery ?? ''}`;
81
+ const isForm = typeof req.headers['content-type'] === 'string' &&
82
+ req.headers['content-type'].includes('application/x-www-form-urlencoded');
83
+ // Reconstruct body — express.json() leaves it as a parsed object, so we
84
+ // re-serialise based on the original content-type.
85
+ let body;
86
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
87
+ if (isForm) {
88
+ const params = new URLSearchParams();
89
+ for (const [k, v] of Object.entries(req.body ?? {})) {
90
+ if (typeof v === 'string')
91
+ params.append(k, v);
92
+ else if (Array.isArray(v))
93
+ v.forEach((x) => params.append(k, String(x)));
94
+ }
95
+ body = params.toString();
96
+ }
97
+ else if (req.body && typeof req.body === 'object') {
98
+ body = JSON.stringify(req.body);
99
+ }
100
+ else if (typeof req.body === 'string') {
101
+ body = req.body;
102
+ }
103
+ }
104
+ const headers = {};
105
+ for (const [k, v] of Object.entries(req.headers)) {
106
+ if (typeof v !== 'string')
107
+ continue;
108
+ // Strip hop-by-hop and host headers; the host gets recomputed by fetch.
109
+ if (['host', 'connection', 'content-length', 'accept-encoding'].includes(k.toLowerCase())) {
110
+ continue;
111
+ }
112
+ headers[k] = v;
113
+ }
114
+ const upstreamRes = await fetch(url, {
115
+ method: req.method,
116
+ headers,
117
+ body,
118
+ redirect: 'manual',
119
+ });
120
+ return upstreamRes;
121
+ }
122
+ async function streamUpstreamResponse(upstream, res) {
123
+ const r = upstream;
124
+ // Mirror headers EXCEPT hop-by-hop ones.
125
+ r.headers.forEach((value, key) => {
126
+ if (['content-encoding', 'transfer-encoding', 'connection'].includes(key.toLowerCase())) {
127
+ return;
128
+ }
129
+ res.setHeader(key, value);
130
+ });
131
+ res.status(r.status);
132
+ const buf = Buffer.from(await r.arrayBuffer());
133
+ res.end(buf);
134
+ }
135
+ export function mountOAuthProxy(app, publicOrigin) {
136
+ // 1) Rewritten metadata document.
137
+ app.get('/auth/v1/.well-known/oauth-authorization-server', async (_req, res) => {
138
+ try {
139
+ const upstream = await fetch(`${UPSTREAM}/.well-known/oauth-authorization-server`);
140
+ const json = (await upstream.json());
141
+ const rewritten = rewriteMetadata(json, publicOrigin);
142
+ res.json(rewritten);
143
+ }
144
+ catch (err) {
145
+ res.status(502).json({
146
+ error: 'metadata_fetch_failed',
147
+ message: err instanceof Error ? err.message : String(err),
148
+ });
149
+ }
150
+ });
151
+ // 2) /authorize — strip openid from the scope before forwarding.
152
+ app.get('/auth/v1/oauth/authorize', async (req, res) => {
153
+ try {
154
+ const params = new URLSearchParams();
155
+ for (const [k, v] of Object.entries(req.query)) {
156
+ if (typeof v === 'string')
157
+ params.set(k, v);
158
+ else if (Array.isArray(v) && typeof v[0] === 'string')
159
+ params.set(k, v[0]);
160
+ }
161
+ const cleanedScope = stripOpenidScope(params.get('scope') ?? undefined);
162
+ if (cleanedScope === undefined) {
163
+ params.delete('scope');
164
+ }
165
+ else {
166
+ params.set('scope', cleanedScope);
167
+ }
168
+ const upstream = await forward(req, '/oauth/authorize', '?' + params.toString());
169
+ if (!upstream) {
170
+ res.status(502).end();
171
+ return;
172
+ }
173
+ await streamUpstreamResponse(upstream, res);
174
+ }
175
+ catch (err) {
176
+ res.status(502).json({
177
+ error: 'proxy_error',
178
+ message: err instanceof Error ? err.message : String(err),
179
+ });
180
+ }
181
+ });
182
+ // 3) All other /auth/v1/* paths — transparent forward.
183
+ app.all('/auth/v1/*', async (req, res) => {
184
+ try {
185
+ // Some clients (and SDKs) send scope to other endpoints too; strip it
186
+ // defensively wherever it appears in a query string.
187
+ const url = new URL(`http://x${req.originalUrl}`);
188
+ if (url.searchParams.has('scope')) {
189
+ const cleaned = stripOpenidScope(url.searchParams.get('scope') ?? undefined);
190
+ if (cleaned === undefined)
191
+ url.searchParams.delete('scope');
192
+ else
193
+ url.searchParams.set('scope', cleaned);
194
+ }
195
+ const path = url.pathname.replace(/^\/auth\/v1/, '');
196
+ const query = url.search;
197
+ const upstream = await forward(req, path, query || undefined);
198
+ if (!upstream) {
199
+ res.status(502).end();
200
+ return;
201
+ }
202
+ await streamUpstreamResponse(upstream, res);
203
+ }
204
+ catch (err) {
205
+ res.status(502).json({
206
+ error: 'proxy_error',
207
+ message: err instanceof Error ? err.message : String(err),
208
+ });
209
+ }
210
+ });
211
+ }
212
+ //# sourceMappingURL=oauth-proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-proxy.js","sourceRoot":"","sources":["../src/oauth-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,iEAAiE;AACjE,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAC;AAEvC;;;GAGG;AACH,SAAS,gBAAgB,CAAC,GAAuB;IAC/C,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC;IACrB,MAAM,OAAO,GAAG,GAAG;SAChB,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC;SAC3D,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CACtB,gBAAyC,EACzC,YAAoB;IAEpB,MAAM,IAAI,GAAG,G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AAG,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;gBACtB,OAAO;YACT,CAAC;YACD,MAAM,sBAAsB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,aAAa;gBACpB,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { Account, AccountReader } from '../lib/account.js';
3
+ /** The Enterprise next steps for the human, with this account's links. */
4
+ export declare function enterpriseNextSteps(account: Account, appUrl?: string): string;
5
+ /** get-account output. */
6
+ export declare function renderAccount(account: Account | null): string;
7
+ export declare function registerAccountTool(server: McpServer, readAccount: AccountReader): void;
8
+ /** Static checklist prompt; needs no account and no API call. */
9
+ export declare function registerChecklistPrompt(server: McpServer): void;
10
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAsBhE,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAe7E;AAED,0BAA0B;AAC1B,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAwC7D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,QAyBhF;AAED,iEAAiE;AACjE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,QAoBxD"}