@credibledata/cred-cli 0.0.105 → 0.0.107
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/README.md +12 -4
- package/dist/agent-contract.spec.js +21 -6
- package/dist/agent-contract.spec.js.map +1 -1
- package/dist/client/api.js +900 -521
- package/dist/client/api.js.map +1 -1
- package/dist/client-codeassist/api.js.map +1 -1
- package/dist/commands/misc/mcp.boot.harness.js +14 -0
- package/dist/commands/misc/mcp.boot.harness.js.map +1 -0
- package/dist/commands/misc/mcp.harness.js +9 -0
- package/dist/commands/misc/mcp.harness.js.map +1 -0
- package/dist/commands/misc/mcp.js +258 -0
- package/dist/commands/misc/mcp.js.map +1 -0
- package/dist/commands/misc/mcp.spec.js +213 -0
- package/dist/commands/misc/mcp.spec.js.map +1 -0
- package/dist/commands/misc/setup.js +72 -3
- package/dist/commands/misc/setup.js.map +1 -1
- package/dist/commands/misc/setup.spec.js +51 -6
- package/dist/commands/misc/setup.spec.js.map +1 -1
- package/dist/commands/misc/status.js +7 -1
- package/dist/commands/misc/status.js.map +1 -1
- package/dist/commands/misc/status.spec.js +34 -0
- package/dist/commands/misc/status.spec.js.map +1 -1
- package/dist/index.js +52 -11
- package/dist/index.js.map +1 -1
- package/dist/setup-core/briefing.d.ts +68 -0
- package/dist/setup-core/briefing.js +20 -11
- package/dist/setup-core/briefing.js.map +1 -1
- package/dist/setup-core/credstore.d.ts +229 -0
- package/dist/setup-core/environments.d.ts +112 -0
- package/dist/setup-core/flow.d.ts +171 -0
- package/dist/setup-core/flow.js +54 -28
- package/dist/setup-core/flow.js.map +1 -1
- package/dist/setup-core/flow.spec.js +135 -54
- package/dist/setup-core/flow.spec.js.map +1 -1
- package/dist/setup-core/folderconfig.d.ts +184 -0
- package/dist/setup-core/folderconfig.js +82 -21
- package/dist/setup-core/folderconfig.js.map +1 -1
- package/dist/setup-core/git.d.ts +57 -0
- package/dist/setup-core/git.js +37 -0
- package/dist/setup-core/git.js.map +1 -1
- package/dist/setup-core/host.d.ts +121 -0
- package/dist/setup-core/importconnections.d.ts +171 -0
- package/dist/setup-core/liveness.d.ts +17 -0
- package/dist/setup-core/localpublisherconfig.d.ts +10 -0
- package/dist/setup-core/mcpconfig.d.ts +132 -0
- package/dist/setup-core/mcpconfig.js +41 -17
- package/dist/setup-core/mcpconfig.js.map +1 -1
- package/dist/setup-core/mcpconfig.spec.js +17 -6
- package/dist/setup-core/mcpconfig.spec.js.map +1 -1
- package/dist/setup-core/packagemanifest.d.ts +28 -0
- package/dist/setup-core/ports.d.ts +95 -0
- package/dist/setup-core/ports.js +6 -5
- package/dist/setup-core/ports.js.map +1 -1
- package/dist/setup-core/publisherconfig.d.ts +163 -0
- package/dist/setup-core/publisherversion.d.ts +22 -0
- package/dist/setup-core/publisherversion.js +1 -1
- package/dist/setup-core/readylines.d.ts +109 -0
- package/dist/setup-core/refresh.d.ts +80 -0
- package/dist/setup-core/skills.d.ts +114 -0
- package/dist/setup-core/skills.js +34 -11
- package/dist/setup-core/skills.js.map +1 -1
- package/dist/setup-core/skills.spec.js +20 -0
- package/dist/setup-core/skills.spec.js.map +1 -1
- package/dist/setup-core/staleservers.d.ts +27 -0
- package/dist/setup-core/staleservers.js +97 -0
- package/dist/setup-core/staleservers.js.map +1 -0
- package/dist/setup-core/staleservers.spec.js +63 -0
- package/dist/setup-core/staleservers.spec.js.map +1 -0
- package/dist/setup-core/supervisor.d.ts +187 -0
- package/dist/setup-core/supervisor.js +1 -0
- package/dist/setup-core/supervisor.js.map +1 -1
- package/dist/setup-core/writefile.d.ts +27 -0
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folderconfig.js","sourceRoot":"","sources":["../../src/setup-core/folderconfig.ts"],"names":[],"mappings":";;;;;;AA0DA,4CAEC;AAkFD,4CAqBC;AAYD,8CAkBC;AAoBD,8CAkBC;AA6CD,0CAgBC;
|
|
1
|
+
{"version":3,"file":"folderconfig.js","sourceRoot":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CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CACpE;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,IAAI,IAAI,KAAK,QAAQ;QAAE,YAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,SAAiB,EAAE,KAAa;IAClD,OAAO,IAAI,UAAU,CAAC,IAAA,eAAS,EAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What git says about a directory: does it push anywhere, and is a path already
|
|
3
|
+
* ignored?
|
|
4
|
+
*
|
|
5
|
+
* Every function here answers with a plain value and never throws. Git not
|
|
6
|
+
* installed, not a repository, no remote — the caller's question still has a
|
|
7
|
+
* sensible answer, and none of these is a reason to fail setup.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Does this directory push anywhere, and where?
|
|
11
|
+
*
|
|
12
|
+
* One line of the agent briefing depends on the answer: whether `git push` means
|
|
13
|
+
* anything here. That used to be decided by the setup prompt — "did you clone
|
|
14
|
+
* this, or adopt it?" — which was a proxy for the question, and got it wrong in
|
|
15
|
+
* the commonest case. Someone who cloned their own repo by hand and ran setup
|
|
16
|
+
* inside it answered "this directory", and the briefing then told their agent the
|
|
17
|
+
* directory "is not wired to push anywhere". It is; the agent was misinformed by
|
|
18
|
+
* a file it is meant to trust.
|
|
19
|
+
*
|
|
20
|
+
* Asking git is exact rather than a proxy, needs no prompt, and stays right when
|
|
21
|
+
* a remote is added later and setup is re-run.
|
|
22
|
+
*
|
|
23
|
+
* Never throws. Not a repository, no remote, git not installed — all mean the
|
|
24
|
+
* same thing to the caller ("nothing to push to"), and none of them is a reason
|
|
25
|
+
* to fail setup.
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectGitRemote(directory: string): string | undefined;
|
|
28
|
+
/** Is `directory` inside a git working tree? */
|
|
29
|
+
export declare function isGitRepository(directory: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Would git ignore `relativePath` inside `directory`?
|
|
32
|
+
*
|
|
33
|
+
* Asked of git rather than by reading `.gitignore`, because the answer can come
|
|
34
|
+
* from a parent directory's file, `.git/info/exclude`, or the user's global
|
|
35
|
+
* excludes file — so a local read would report "not ignored" for a path that is,
|
|
36
|
+
* and setup would append a duplicate rule.
|
|
37
|
+
*
|
|
38
|
+
* `check-ignore` exits 1 for "not ignored", which {@link git} turns into
|
|
39
|
+
* undefined; only exit 0 with output means ignored.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isIgnoredByGit(directory: string, relativePath: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Where this repository keeps the exclude file git reads but never commits,
|
|
44
|
+
* or undefined outside a repository.
|
|
45
|
+
*
|
|
46
|
+
* Asked of git because the path moves: a linked worktree's `.git` is a file,
|
|
47
|
+
* and git reads `info/exclude` from the shared common directory.
|
|
48
|
+
*/
|
|
49
|
+
export declare function gitExcludePath(directory: string): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* `directory`'s path from the repository root, with a trailing slash, or ""
|
|
52
|
+
* at the root. Patterns in `info/exclude` are relative to the root, not to the
|
|
53
|
+
* directory that asked.
|
|
54
|
+
*/
|
|
55
|
+
export declare function gitPrefix(directory: string): string;
|
|
56
|
+
/** Does git track `relativePath` inside `directory`? */
|
|
57
|
+
export declare function isTrackedByGit(directory: string, relativePath: string): boolean;
|
package/dist/setup-core/git.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.detectGitRemote = detectGitRemote;
|
|
4
7
|
exports.isGitRepository = isGitRepository;
|
|
5
8
|
exports.isIgnoredByGit = isIgnoredByGit;
|
|
9
|
+
exports.gitExcludePath = gitExcludePath;
|
|
10
|
+
exports.gitPrefix = gitPrefix;
|
|
11
|
+
exports.isTrackedByGit = isTrackedByGit;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
6
13
|
const child_process_1 = require("child_process");
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
7
15
|
/**
|
|
8
16
|
* What git says about a directory: does it push anywhere, and is a path already
|
|
9
17
|
* ignored?
|
|
@@ -94,4 +102,33 @@ function isIgnoredByGit(directory, relativePath) {
|
|
|
94
102
|
const result = git(["check-ignore", "--no-index", "--", relativePath], directory);
|
|
95
103
|
return result !== undefined && result.length > 0;
|
|
96
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Where this repository keeps the exclude file git reads but never commits,
|
|
107
|
+
* or undefined outside a repository.
|
|
108
|
+
*
|
|
109
|
+
* Asked of git because the path moves: a linked worktree's `.git` is a file,
|
|
110
|
+
* and git reads `info/exclude` from the shared common directory.
|
|
111
|
+
*/
|
|
112
|
+
function gitExcludePath(directory) {
|
|
113
|
+
const relative = git(["rev-parse", "--git-path", "info/exclude"], directory);
|
|
114
|
+
// git computes a relative answer from the physical directory, so resolve
|
|
115
|
+
// it from there too: `..` from a path through a symlink lands elsewhere.
|
|
116
|
+
return relative === undefined
|
|
117
|
+
? undefined
|
|
118
|
+
: path_1.default.resolve(fs_1.default.realpathSync(directory), relative);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `directory`'s path from the repository root, with a trailing slash, or ""
|
|
122
|
+
* at the root. Patterns in `info/exclude` are relative to the root, not to the
|
|
123
|
+
* directory that asked.
|
|
124
|
+
*/
|
|
125
|
+
function gitPrefix(directory) {
|
|
126
|
+
var _a;
|
|
127
|
+
return (_a = git(["rev-parse", "--show-prefix"], directory)) !== null && _a !== void 0 ? _a : "";
|
|
128
|
+
}
|
|
129
|
+
/** Does git track `relativePath` inside `directory`? */
|
|
130
|
+
function isTrackedByGit(directory, relativePath) {
|
|
131
|
+
return (git(["ls-files", "--error-unmatch", "--", relativePath], directory) !==
|
|
132
|
+
undefined);
|
|
133
|
+
}
|
|
97
134
|
//# sourceMappingURL=git.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/setup-core/git.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/setup-core/git.ts"],"names":[],"mappings":";;;;;AA+BA,0CAGC;AA2CD,0CAEC;AAaD,wCASC;AASD,wCAOC;AAOD,8BAEC;AAGD,wCAQC;AAzID,4CAAoB;AACpB,iDAA6C;AAC7C,gDAAwB;AAExB;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,eAAe,CAAC,SAAiB;IAC9C,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,SAAiB;;IACvC,MAAM,KAAK,GAAG,CAAC,MAAA,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,mCAAI,EAAE,CAAC;SAC5C,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,OAAO,CAAC,CAAC;IACpB,IAAI,KAAK,CAAC,MAAM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E,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,SAAiB;;IACxC,OAAO,MAAA,GAAG,CAAC,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,SAAS,CAAC,mCAAI,EAAE,CAAC;AAC/D,CAAC;AAED,wDAAwD;AACxD,SAAgB,cAAc,CAC3B,SAAiB,EACjB,YAAoB;IAEpB,OAAO,CACJ,GAAG,CAAC,CAAC,UAAU,EAAE,iBAAiB,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,SAAS,CAAC;QACnE,SAAS,CACX,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one seam between the shared setup flow and whatever is driving it.
|
|
3
|
+
*
|
|
4
|
+
* setup-core decides *what* to ask and *what* to do with the answer. It never
|
|
5
|
+
* decides how the question is rendered, because the two front doors render
|
|
6
|
+
* differently: the CLI uses inquirer prompts and a terminal, the VS Code
|
|
7
|
+
* extension uses QuickPicks, a native folder picker, and `openExternal`.
|
|
8
|
+
*
|
|
9
|
+
* Everything the library needs from its host is here, and it is deliberately
|
|
10
|
+
* small — every method added is a method the extension has to implement too.
|
|
11
|
+
*/
|
|
12
|
+
export interface HostChoice<T> {
|
|
13
|
+
/** What the user reads. */
|
|
14
|
+
name: string;
|
|
15
|
+
value: T;
|
|
16
|
+
/** When set, the row is shown but not selectable, and this says why. */
|
|
17
|
+
disabled?: string;
|
|
18
|
+
}
|
|
19
|
+
export type LogLevel = "info" | "warn" | "error";
|
|
20
|
+
/**
|
|
21
|
+
* How a caller would have answered this question without a prompt.
|
|
22
|
+
*
|
|
23
|
+
* Every question the flow asks is one a flag can answer — a picker is the human
|
|
24
|
+
* front door to the same flag, never the only door. The hint names that flag so
|
|
25
|
+
* a host with no terminal (an agent's shell, CI) can refuse to prompt and say
|
|
26
|
+
* exactly what to pass instead; `options` lists what the picker would have
|
|
27
|
+
* shown, so the caller does not need a second command to find out.
|
|
28
|
+
*/
|
|
29
|
+
export interface PromptHint {
|
|
30
|
+
/** The flag that answers this question, e.g. `--environment <name>`. */
|
|
31
|
+
flag: string;
|
|
32
|
+
/** The values the picker would have offered, when known. */
|
|
33
|
+
options?: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A question that could not be asked because there is no one to answer it.
|
|
37
|
+
*
|
|
38
|
+
* Thrown by a host instead of prompting when stdin is not a terminal. The
|
|
39
|
+
* message is written for the caller that hit it — an agent reading stderr —
|
|
40
|
+
* so it names the flag and the options rather than describing the failure.
|
|
41
|
+
* Exit code 2 by convention: distinct from 1 (failed) so a script can tell
|
|
42
|
+
* "needs input" from "broke".
|
|
43
|
+
*/
|
|
44
|
+
export declare class NeedsInputError extends Error {
|
|
45
|
+
readonly question: string;
|
|
46
|
+
readonly hint: PromptHint;
|
|
47
|
+
readonly exitCode = 2;
|
|
48
|
+
constructor(question: string, hint: PromptHint);
|
|
49
|
+
}
|
|
50
|
+
export interface Host {
|
|
51
|
+
/**
|
|
52
|
+
* Choose one of `choices`. A lone enabled choice may be returned without
|
|
53
|
+
* asking, but a disabled row alongside it must still be shown — that row is
|
|
54
|
+
* how the user learns an option exists and why it is unavailable.
|
|
55
|
+
*
|
|
56
|
+
* A host that cannot prompt throws {@link NeedsInputError} built from `hint`.
|
|
57
|
+
*/
|
|
58
|
+
select<T>(message: string, choices: HostChoice<T>[], hint?: PromptHint): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Choose any number of `choices`; `[]` means the user declined. Unlike
|
|
61
|
+
* {@link select}, a lone choice is still asked — the callers of this are
|
|
62
|
+
* consent questions ("copy this credential?"), where silence is not a yes.
|
|
63
|
+
*/
|
|
64
|
+
selectMany<T>(message: string, choices: HostChoice<T>[], hint?: PromptHint): Promise<T[]>;
|
|
65
|
+
confirm(message: string, hint?: PromptHint): Promise<boolean>;
|
|
66
|
+
/** Progress and diagnostics. Not a return channel — outcomes are returned. */
|
|
67
|
+
log(level: LogLevel, message: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Relay output from a subprocess verbatim. The host must not add a level, a
|
|
70
|
+
* timestamp, or a prefix.
|
|
71
|
+
*
|
|
72
|
+
* Separate from {@link log} because the publisher's output is already
|
|
73
|
+
* formatted — it carries its own `info:` / `error:` level and its own
|
|
74
|
+
* colouring. Passing it through `log` produced lines reading
|
|
75
|
+
* `[14:05:18] INFO: info: ...`, two levels deep, on every line of a session.
|
|
76
|
+
* A host that has nowhere raw to write may fall back to `log`.
|
|
77
|
+
*/
|
|
78
|
+
write(chunk: string): void;
|
|
79
|
+
/** Open a URL where the user will see it. */
|
|
80
|
+
openUrl(url: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Call `handler` when the user asks to stop (Ctrl-C, SIGTERM, a cancel
|
|
83
|
+
* button) instead of letting the host's default end the process. Returns the
|
|
84
|
+
* unsubscribe.
|
|
85
|
+
*
|
|
86
|
+
* The supervisor subscribes from the moment it spawns the publisher until
|
|
87
|
+
* the publisher exits. Outside that window nothing is subscribed, so the
|
|
88
|
+
* host's default applies. Inside it, a stop has to reach the child: it runs
|
|
89
|
+
* in its own process group, where a terminal's Ctrl-C does not reach, and it
|
|
90
|
+
* holds a live token and both ports. A host without the method cannot be
|
|
91
|
+
* interrupted mid-session.
|
|
92
|
+
*/
|
|
93
|
+
onInterrupt?(handler: () => void): () => void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A setup failure the user can act on.
|
|
97
|
+
*
|
|
98
|
+
* Every message must name what went wrong AND what to do about it: the two
|
|
99
|
+
* front ends turn these into a terminal line and a clickable notification
|
|
100
|
+
* respectively, and neither can improve on a message that only says "failed".
|
|
101
|
+
*/
|
|
102
|
+
export declare class SetupError extends Error {
|
|
103
|
+
readonly fix?: string;
|
|
104
|
+
constructor(message: string, fix?: string);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A flag was given a value it does not accept. A usage error, so it exits 2
|
|
108
|
+
* like a prompt that could not be asked, not 1 like a run that failed.
|
|
109
|
+
*/
|
|
110
|
+
export declare class UsageError extends SetupError {
|
|
111
|
+
readonly exitCode = 2;
|
|
112
|
+
constructor(message: string, fix?: string);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A setup failure whose cause was already logged where it happened. The
|
|
116
|
+
* terminal exits 1 without printing it again; other front ends still have the
|
|
117
|
+
* message.
|
|
118
|
+
*/
|
|
119
|
+
export declare class ReportedSetupError extends SetupError {
|
|
120
|
+
constructor(message: string);
|
|
121
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Host } from "./host";
|
|
2
|
+
/**
|
|
3
|
+
* Adopting the connections from a local Publisher config.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this exists
|
|
6
|
+
*
|
|
7
|
+
* `cred init` takes someone from "I have a Credible environment with
|
|
8
|
+
* connections" to "I am authoring locally". It has nothing to say to the person
|
|
9
|
+
* running an open-source Malloy Publisher against their own warehouse, who has
|
|
10
|
+
* the connections but no Credible environment — the half of the journey that was
|
|
11
|
+
* missing. This is that half: their existing `publisher.config.json` already
|
|
12
|
+
* describes every warehouse they use.
|
|
13
|
+
*
|
|
14
|
+
* ## Why it is a translation and not a conversion
|
|
15
|
+
*
|
|
16
|
+
* Credible's `Connection` schema and the Publisher's are the same shape, field
|
|
17
|
+
* for field — Credible's dataplane spec is derived from it. So a connection
|
|
18
|
+
* lifted out of a local config is already a valid create payload, and this file
|
|
19
|
+
* does no field mapping. What it does is *decide which ones to offer* and hand
|
|
20
|
+
* the user something they can consent to.
|
|
21
|
+
*
|
|
22
|
+
* ## What is deliberately not offered
|
|
23
|
+
*
|
|
24
|
+
* - **`publisher` connections.** Those are proxies to somewhere else, and in a
|
|
25
|
+
* directory setup has already touched they are *ours* — re-importing one would
|
|
26
|
+
* point Credible at Credible.
|
|
27
|
+
* - **Any connection named `duckdb`**, which the Publisher reserves for the
|
|
28
|
+
* per-package sandbox: importing one would break every later `cred init`.
|
|
29
|
+
* - **`duckdb` connections that name a file on this machine**, which means
|
|
30
|
+
* nothing to Credible's cloud. Local files become part of the package instead,
|
|
31
|
+
* which is what `cred publish` is for. A duckdb connection whose attachments
|
|
32
|
+
* are all remote (a bucket, a warehouse) is portable and offered.
|
|
33
|
+
*
|
|
34
|
+
* Everything else is offered, and nothing is sent without an explicit yes: this
|
|
35
|
+
* step moves warehouse credentials off the user's machine, which is precisely
|
|
36
|
+
* what the open-source user chose the open-source publisher to avoid.
|
|
37
|
+
*/
|
|
38
|
+
/** A connection as a local `publisher.config.json` carries it. */
|
|
39
|
+
export interface LocalConnection {
|
|
40
|
+
name?: string;
|
|
41
|
+
type?: string;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
export interface ImportCandidate {
|
|
45
|
+
connection: LocalConnection;
|
|
46
|
+
name: string;
|
|
47
|
+
type: string;
|
|
48
|
+
/** Host, account or path — enough to recognise it, never a secret. */
|
|
49
|
+
describe: string;
|
|
50
|
+
}
|
|
51
|
+
export interface LocalPublisherConfig {
|
|
52
|
+
path: string;
|
|
53
|
+
candidates: ImportCandidate[];
|
|
54
|
+
/** Names skipped, with why, so the user is not left wondering. */
|
|
55
|
+
skipped: {
|
|
56
|
+
name: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
fix?: string;
|
|
59
|
+
}[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Read a `publisher.config.json` sitting in the modeling directory, if there is
|
|
63
|
+
* one.
|
|
64
|
+
*
|
|
65
|
+
* Only this directory — never `~/.credible/sessions/`, where setup writes its
|
|
66
|
+
* own. Ours carries a live Credible token and describes proxies back to
|
|
67
|
+
* Credible; importing it would be circular, and reading it here would put a
|
|
68
|
+
* credential on a path it does not need to be on.
|
|
69
|
+
*/
|
|
70
|
+
export declare function findLocalPublisherConfig(directory: string): LocalPublisherConfig | undefined;
|
|
71
|
+
/** Every `${NAME}` in `value` that the environment does not set. */
|
|
72
|
+
export declare function unsetVariables(value: unknown): string[];
|
|
73
|
+
/** `value` with every `${NAME}` replaced. Call {@link unsetVariables} first. */
|
|
74
|
+
export declare function substituteVariables(value: unknown): unknown;
|
|
75
|
+
/**
|
|
76
|
+
* Why {@link findLocalPublisherConfig} found nothing in `directory`, said so a
|
|
77
|
+
* person can fix it. A named `--connections` list that finds nothing is a
|
|
78
|
+
* failed instruction, and "not valid JSON" and "not there" have different
|
|
79
|
+
* fixes.
|
|
80
|
+
*/
|
|
81
|
+
export declare function localPublisherConfigProblem(directory: string): string;
|
|
82
|
+
export interface ImportOutcome {
|
|
83
|
+
created: string[];
|
|
84
|
+
rejected: {
|
|
85
|
+
name: string;
|
|
86
|
+
reason: string;
|
|
87
|
+
}[];
|
|
88
|
+
declined: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Which local connections to import, when the caller already knows.
|
|
92
|
+
*
|
|
93
|
+
* `"all"` and a list of names are the `--connections` flag; `"none"` skips the
|
|
94
|
+
* step. Naming a connection on the command line is the consent the interactive
|
|
95
|
+
* path collects with two questions, so an explicit selection asks nothing.
|
|
96
|
+
*/
|
|
97
|
+
export type ConnectionSelection = "all" | "none" | string[];
|
|
98
|
+
/**
|
|
99
|
+
* The flag an agent passes to `cred init` instead of answering the picker.
|
|
100
|
+
* Other front doors pass their own: `cred add connection
|
|
101
|
+
* --from-publisher-config` takes `--name`, not this.
|
|
102
|
+
*/
|
|
103
|
+
export declare const CONNECTIONS_FLAG = "--connections <all|none|name,name>";
|
|
104
|
+
/**
|
|
105
|
+
* The result of creating or testing one connection.
|
|
106
|
+
*
|
|
107
|
+
* The success arm declares `reason?: undefined` rather than omitting it. This
|
|
108
|
+
* package compiles with `strict: false`, where narrowing a union by a literal
|
|
109
|
+
* discriminant does not happen, so `result.reason` after `if (result.ok)` is an
|
|
110
|
+
* error on the arm that lacks the property. Declaring it as always-absent still
|
|
111
|
+
* says a success can never carry a reason, while letting the access typecheck.
|
|
112
|
+
*/
|
|
113
|
+
export type ConnectionCreateResult = {
|
|
114
|
+
ok: true;
|
|
115
|
+
reason?: undefined;
|
|
116
|
+
} | {
|
|
117
|
+
ok: false;
|
|
118
|
+
reason: string;
|
|
119
|
+
};
|
|
120
|
+
/** Create one connection, or say why it cannot be created. `dryRun` only tests. */
|
|
121
|
+
export type ConnectionCreator = (connection: LocalConnection, options: {
|
|
122
|
+
dryRun: boolean;
|
|
123
|
+
}) => Promise<ConnectionCreateResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Offer the local connections, preflight them, and create the ones the user
|
|
126
|
+
* accepts.
|
|
127
|
+
*
|
|
128
|
+
* Preflight is the reason this is worth building rather than telling people to
|
|
129
|
+
* run `cred add connection`. Credible tests a connection before saving it, and
|
|
130
|
+
* `dryRun` exposes that test on its own — so a warehouse only this laptop can
|
|
131
|
+
* reach (`localhost:5432`, a VPN-only host) is reported as unreachable *before*
|
|
132
|
+
* the user decides, instead of becoming a saved connection that fails later for
|
|
133
|
+
* everyone. The user then chooses knowing which of their connections actually
|
|
134
|
+
* survive the move.
|
|
135
|
+
*
|
|
136
|
+
* Two questions, deliberately not merged, each saying what it gates. The first
|
|
137
|
+
* is the picker: ticking a connection sends it, credentials included, to
|
|
138
|
+
* Credible for a reachability test that saves nothing. The second names the
|
|
139
|
+
* environment and asks whether to store them there, because agreeing to a test
|
|
140
|
+
* is not agreeing to keep a password. A `selection` passed in stands for both
|
|
141
|
+
* answers — the caller named the connections, which is the explicit form of the
|
|
142
|
+
* same consent — so the flag path asks nothing at all.
|
|
143
|
+
*
|
|
144
|
+
* A named selection is an instruction, so any connection in it that cannot be
|
|
145
|
+
* added fails the call: one that fails the test stops it before anything is
|
|
146
|
+
* created, and one that fails the create fails it after the others are added.
|
|
147
|
+
* `all` means "whichever work", so its unreachable ones are only reported.
|
|
148
|
+
*/
|
|
149
|
+
export declare function importLocalConnections(found: LocalPublisherConfig, host: Host, credibleEnvironment: string, create: ConnectionCreator, options?: {
|
|
150
|
+
selection?: ConnectionSelection;
|
|
151
|
+
/** The flag this front door takes for the selection. */
|
|
152
|
+
flag?: string;
|
|
153
|
+
/**
|
|
154
|
+
* The connection names the Credible environment already has, asked for
|
|
155
|
+
* only once there is a choice to check: a create under one of them is not
|
|
156
|
+
* refused by the server, and its test borrows the existing connection's
|
|
157
|
+
* secrets, so a clash could pass and replace it. Lazy so a question that
|
|
158
|
+
* cannot be asked still exits 2 before any network call.
|
|
159
|
+
*/
|
|
160
|
+
existingNames?: () => Promise<string[]>;
|
|
161
|
+
}): Promise<ImportOutcome>;
|
|
162
|
+
/** The question `--connections` answers. */
|
|
163
|
+
export declare const CONNECTIONS_QUESTION = "Which connections should Credible test? Ticking one sends it to Credible for a reachability test; nothing is saved yet.";
|
|
164
|
+
/**
|
|
165
|
+
* Refuse a `--connections` list that names a connection the file does not
|
|
166
|
+
* have, listing the ones it does. `--connections warehous` must never import
|
|
167
|
+
* nothing and report success. A name that is in the file but cannot be
|
|
168
|
+
* imported (a `duckdb` or `publisher` connection) is refused with that reason,
|
|
169
|
+
* not as missing.
|
|
170
|
+
*/
|
|
171
|
+
export declare function checkSelection(found: LocalPublisherConfig, selection: ConnectionSelection | undefined): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Is a local Publisher answering on this port?
|
|
3
|
+
*
|
|
4
|
+
* The question `cred status` answers for an agent that started `cred dev` in
|
|
5
|
+
* the background and needs to know when to start calling tools. A bound port
|
|
6
|
+
* is not the signal (see `readylines.ts`): the REST API answering is. One GET
|
|
7
|
+
* with a short deadline, because the caller is polling.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPublisherServing(uiPort: number, timeoutMs?: number): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* How many packages the local Publisher is serving, or null when it does not
|
|
12
|
+
* answer. Distinct from {@link isPublisherServing}: a server whose only package
|
|
13
|
+
* failed to compile answers every request and serves nothing — the
|
|
14
|
+
* `PUBLISHER_READY … packages=0 load_errors=1` case — and an agent that starts
|
|
15
|
+
* calling tools on `running` alone gets "no such package" for every one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function countServedPackages(uiPort: number, environment?: string, timeoutMs?: number): Promise<number | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parsed `<directory>/publisher.config.json` the user keeps there, or
|
|
3
|
+
* undefined when it is absent or not JSON.
|
|
4
|
+
*
|
|
5
|
+
* One reader for every place that looks at this file (the connections setup
|
|
6
|
+
* can import, the packages it lists, the retrieval block `cred dev` carries),
|
|
7
|
+
* so they agree on what "unreadable" means: nothing to read, and not an error.
|
|
8
|
+
* A caller that must say why asks for the reason itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readLocalPublisherConfig(directory: string): unknown;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Environment } from "./environments";
|
|
2
|
+
/**
|
|
3
|
+
* Writing `.mcp.json` — the file that points an agent at both the local
|
|
4
|
+
* Publisher and the Credible cloud tools.
|
|
5
|
+
*
|
|
6
|
+
* ## Why we write it and the server does not
|
|
7
|
+
*
|
|
8
|
+
* The Publisher server writes `.mcp.json` itself on boot, but deliberately skips
|
|
9
|
+
* when the working directory is inside a git working tree — which describes
|
|
10
|
+
* essentially every real modeling directory, since model code that matters to
|
|
11
|
+
* anyone is under version control. So the skip is the normal case, not the edge
|
|
12
|
+
* case, and setup owns the file.
|
|
13
|
+
*
|
|
14
|
+
* ## Why the local entry is a command and not a URL
|
|
15
|
+
*
|
|
16
|
+
* The local entry runs `cred mcp`, which finds this directory's Publisher,
|
|
17
|
+
* starts it with `cred dev` when it is not running, and forwards over stdio
|
|
18
|
+
* (`docs/cred-mcp-stdio-design.md`). It used to be the Publisher's URL. That
|
|
19
|
+
* port was open only while `cred dev` ran, so an agent started first had no
|
|
20
|
+
* `malloy` tools for its whole session, and the file kept pointing at the
|
|
21
|
+
* port after the server stopped.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MCP_CONFIG_FILENAME = ".mcp.json";
|
|
24
|
+
/** The name of the local Publisher entry. Matches what upstream writes. */
|
|
25
|
+
export declare const LOCAL_SERVER_NAME = "malloy";
|
|
26
|
+
/** The name of the Credible cloud entry: the analysis tools over the published model. */
|
|
27
|
+
export declare const REMOTE_SERVER_NAME = "credible";
|
|
28
|
+
/** Every key this writer owns, and therefore overwrites. */
|
|
29
|
+
export declare const OWNED_SERVER_NAMES: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Entries setup used to write and now removes.
|
|
32
|
+
*
|
|
33
|
+
* `credible-modeling` pointed at `/mcp/modeling` for `search_database_schema`
|
|
34
|
+
* over the indexed warehouse schema. Two reasons it is gone: the local
|
|
35
|
+
* publisher serves `search_database_schema` itself, walking the live schema
|
|
36
|
+
* through the proxy, so a modeling directory already has schema search; and the
|
|
37
|
+
* other tool on that mount, `search_modeling_suggestions`, has nothing useful
|
|
38
|
+
* to return today. What it cost was real — a third server whose tool names
|
|
39
|
+
* collide with both of the others, so every schema lookup became a choice the
|
|
40
|
+
* agent had to get right.
|
|
41
|
+
*
|
|
42
|
+
* Listed rather than simply deleted because a directory wired by an earlier
|
|
43
|
+
* build already carries the entry, and a name this writer no longer owns would
|
|
44
|
+
* be *preserved* forever. Removing it here means the next `cred init` or
|
|
45
|
+
* `cred dev` cleans it up. Only when its URL is the one we wrote (a path
|
|
46
|
+
* ending `/mcp/modeling`): a server of the user's own under the same name is
|
|
47
|
+
* theirs, and is kept.
|
|
48
|
+
*/
|
|
49
|
+
export declare const RETIRED_SERVER_NAMES: string[];
|
|
50
|
+
interface McpStdioServer {
|
|
51
|
+
type: "stdio";
|
|
52
|
+
command: string;
|
|
53
|
+
args: string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The local Publisher's MCP URL, for `cred status` and `cred mcp`.
|
|
57
|
+
*
|
|
58
|
+
* `127.0.0.1`, never `localhost`: `localhost` resolves to both loopback
|
|
59
|
+
* families while the server binds only one, so another local process can hold
|
|
60
|
+
* the same port on the other family and receive the traffic instead.
|
|
61
|
+
*/
|
|
62
|
+
export declare function localPublisherUrl(mcpPort: number): string;
|
|
63
|
+
/**
|
|
64
|
+
* The `.mcp.json` entry for the local Publisher.
|
|
65
|
+
*
|
|
66
|
+
* On native Windows an npm-installed `cred` is a `cred.cmd` shim, which an
|
|
67
|
+
* MCP client spawning without a shell cannot launch. `cmd /c` is the wrapper
|
|
68
|
+
* Claude Code's docs give for the same problem with `npx`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function localServerEntry(platform?: NodeJS.Platform): McpStdioServer;
|
|
71
|
+
/**
|
|
72
|
+
* The org-scoped remote MCP URL.
|
|
73
|
+
*
|
|
74
|
+
* `docs/mcp-global-endpoint-and-install-design.md` makes
|
|
75
|
+
* `https://mcp.credibledata.com/mcp` the canonical URL that docs lead with, and
|
|
76
|
+
* reframes the org-scoped host as a deliberate scope-down. Setup uses the
|
|
77
|
+
* scoped one *because* it already knows the organization: scoping down here
|
|
78
|
+
* removes the orientation tax that doc names as problem #1, where the agent
|
|
79
|
+
* burns two or three discovery calls before its first useful one.
|
|
80
|
+
*/
|
|
81
|
+
export declare function remoteCredibleUrl(deployment: Environment, organization: string): string;
|
|
82
|
+
export interface McpConfigResult {
|
|
83
|
+
/** Absolute path written. */
|
|
84
|
+
filePath: string;
|
|
85
|
+
/** True when the file changed on disk. */
|
|
86
|
+
changed: boolean;
|
|
87
|
+
/** Entries we left alone because someone else owns them. */
|
|
88
|
+
preserved: string[];
|
|
89
|
+
/**
|
|
90
|
+
* Entries an earlier build of setup wrote and this one removed. Reported so
|
|
91
|
+
* a user whose `.mcp.json` lost a server learns it was ours, not theirs.
|
|
92
|
+
*/
|
|
93
|
+
retired: string[];
|
|
94
|
+
/**
|
|
95
|
+
* Where a file we could not merge into was copied before being replaced, or
|
|
96
|
+
* undefined when nothing was displaced.
|
|
97
|
+
*
|
|
98
|
+
* Set only for a non-empty file that did not parse. The caller warns on it,
|
|
99
|
+
* because from the user's side the file may well have been working: an agent
|
|
100
|
+
* reading `.mcp.json` accepts a byte-order mark, and `JSON.parse` does not.
|
|
101
|
+
*/
|
|
102
|
+
displaced?: string;
|
|
103
|
+
/**
|
|
104
|
+
* True when the file holds nothing but our entries: no server of the user's
|
|
105
|
+
* and no other top-level key. Such a file is ours to keep out of git.
|
|
106
|
+
*/
|
|
107
|
+
onlyOurs: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Merge our two entries into `<directory>/.mcp.json`, preserving everything else.
|
|
111
|
+
*
|
|
112
|
+
* Merge rather than create-or-replace, for two reasons that pull in opposite
|
|
113
|
+
* directions and both matter:
|
|
114
|
+
*
|
|
115
|
+
* - a user's own MCP servers in this file must survive `cred init`, so we only
|
|
116
|
+
* ever touch the keys we own, plus the ones we used to own and now remove;
|
|
117
|
+
* - our own entries must be *overwritten*, not preserved, so a file an older
|
|
118
|
+
* build wrote (with the local entry as a URL) moves to the current shape.
|
|
119
|
+
*
|
|
120
|
+
* No token is ever written. The local server needs none, and the remote one is
|
|
121
|
+
* reached with the client's own OAuth.
|
|
122
|
+
*/
|
|
123
|
+
export declare function writeMcpConfig(options: {
|
|
124
|
+
directory: string;
|
|
125
|
+
deployment: Environment;
|
|
126
|
+
organization: string;
|
|
127
|
+
/** For tests; the entry differs on Windows. */
|
|
128
|
+
platform?: NodeJS.Platform;
|
|
129
|
+
}): McpConfigResult;
|
|
130
|
+
/** The indentation of the first indented line, or two spaces. */
|
|
131
|
+
export declare function detectIndent(text: string | undefined): string;
|
|
132
|
+
export {};
|