@pipeshub-ai/mcp 2.1.0 → 2.3.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.
- package/README.md +92 -2
- package/bin/mcp-server.js +976 -169
- package/bin/mcp-server.js.map +28 -15
- package/bin/pipeshub.js +946 -0
- package/bin/pipeshub.js.map +14 -0
- package/esm/cli/client.d.ts +54 -0
- package/esm/cli/client.d.ts.map +1 -0
- package/esm/cli/client.js +230 -0
- package/esm/cli/client.js.map +1 -0
- package/esm/cli/commands.d.ts +30 -0
- package/esm/cli/commands.d.ts.map +1 -0
- package/esm/cli/commands.js +321 -0
- package/esm/cli/commands.js.map +1 -0
- package/esm/cli/config.d.ts +73 -0
- package/esm/cli/config.d.ts.map +1 -0
- package/esm/cli/config.js +218 -0
- package/esm/cli/config.js.map +1 -0
- package/esm/cli/init-qm.d.ts +11 -0
- package/esm/cli/init-qm.d.ts.map +1 -0
- package/esm/cli/init-qm.js +170 -0
- package/esm/cli/init-qm.js.map +1 -0
- package/esm/cli/pipeshub.d.ts +2 -0
- package/esm/cli/pipeshub.d.ts.map +1 -0
- package/esm/cli/pipeshub.js +296 -0
- package/esm/cli/pipeshub.js.map +1 -0
- package/esm/funcs/connectorGetRecordContent.d.ts +43 -0
- package/esm/funcs/connectorGetRecordContent.d.ts.map +1 -0
- package/esm/funcs/connectorGetRecordContent.js +114 -0
- package/esm/funcs/connectorGetRecordContent.js.map +1 -0
- package/esm/funcs/connectorLookupRecordByIdentifier.d.ts +68 -0
- package/esm/funcs/connectorLookupRecordByIdentifier.d.ts.map +1 -0
- package/esm/funcs/connectorLookupRecordByIdentifier.js +138 -0
- package/esm/funcs/connectorLookupRecordByIdentifier.js.map +1 -0
- package/esm/funcs/connectorNavigateKnowledgeGraph.d.ts +75 -0
- package/esm/funcs/connectorNavigateKnowledgeGraph.d.ts.map +1 -0
- package/esm/funcs/connectorNavigateKnowledgeGraph.js +152 -0
- package/esm/funcs/connectorNavigateKnowledgeGraph.js.map +1 -0
- package/esm/funcs/conversationsStreamConversation.js +1 -1
- package/esm/funcs/conversationsStreamConversation.js.map +1 -1
- package/esm/funcs/userGroupsGetAllUserGroups.js +1 -1
- package/esm/funcs/userGroupsGetAllUserGroups.js.map +1 -1
- package/esm/hooks/registration.d.ts.map +1 -1
- package/esm/hooks/registration.js +2 -1
- package/esm/hooks/registration.js.map +1 -1
- package/esm/hooks/request-context.d.ts +10 -0
- package/esm/hooks/request-context.d.ts.map +1 -0
- package/esm/hooks/request-context.js +38 -0
- package/esm/hooks/request-context.js.map +1 -0
- package/esm/hooks/requestid.d.ts +5 -0
- package/esm/hooks/requestid.d.ts.map +1 -0
- package/esm/hooks/requestid.js +58 -0
- package/esm/hooks/requestid.js.map +1 -0
- package/esm/lib/base64.d.ts +1 -1
- package/esm/lib/base64.d.ts.map +1 -1
- package/esm/lib/base64.js +6 -3
- package/esm/lib/base64.js.map +1 -1
- package/esm/lib/bytes-to-base64.d.ts +16 -0
- package/esm/lib/bytes-to-base64.d.ts.map +1 -0
- package/esm/lib/bytes-to-base64.js +23 -0
- package/esm/lib/bytes-to-base64.js.map +1 -0
- package/esm/mcp-server/instructions.d.ts +1 -1
- package/esm/mcp-server/instructions.d.ts.map +1 -1
- package/esm/mcp-server/instructions.js +62 -9
- package/esm/mcp-server/instructions.js.map +1 -1
- package/esm/mcp-server/server.d.ts.map +1 -1
- package/esm/mcp-server/server.js +10 -3
- package/esm/mcp-server/server.js.map +1 -1
- package/esm/mcp-server/shared.d.ts +2 -2
- package/esm/mcp-server/shared.d.ts.map +1 -1
- package/esm/mcp-server/shared.js +7 -3
- package/esm/mcp-server/shared.js.map +1 -1
- package/esm/mcp-server/tools/_agui.d.ts +34 -0
- package/esm/mcp-server/tools/_agui.d.ts.map +1 -0
- package/esm/mcp-server/tools/_agui.js +91 -0
- package/esm/mcp-server/tools/_agui.js.map +1 -0
- package/esm/mcp-server/tools/_helpers.d.ts.map +1 -1
- package/esm/mcp-server/tools/_helpers.js +13 -6
- package/esm/mcp-server/tools/_helpers.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubChat.d.ts +0 -3
- package/esm/mcp-server/tools/pipeshubChat.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubChat.js +75 -92
- package/esm/mcp-server/tools/pipeshubChat.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubGetRecordContent.d.ts +125 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.d.ts.map +1 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.js +214 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.js.map +1 -0
- package/esm/mcp-server/tools/pipeshubSearch.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubSearch.js +22 -5
- package/esm/mcp-server/tools/pipeshubSearch.js.map +1 -1
- package/esm/mcp-server/tools.d.ts.map +1 -1
- package/esm/mcp-server/tools.js +13 -1
- package/esm/mcp-server/tools.js.map +1 -1
- package/esm/models/availablemodelsresponse.d.ts +1 -1
- package/esm/models/conversation.d.ts +1 -1
- package/esm/models/getrecordcontentop.d.ts +6 -0
- package/esm/models/getrecordcontentop.d.ts.map +1 -0
- package/esm/models/getrecordcontentop.js +5 -0
- package/esm/models/getrecordcontentop.js.map +1 -0
- package/esm/models/lookuprecordbyidentifierop.d.ts +7 -0
- package/esm/models/lookuprecordbyidentifierop.d.ts.map +1 -0
- package/esm/models/lookuprecordbyidentifierop.js +14 -0
- package/esm/models/lookuprecordbyidentifierop.js.map +1 -0
- package/esm/models/navigateknowledgegraphop.d.ts +14 -0
- package/esm/models/navigateknowledgegraphop.d.ts.map +1 -0
- package/esm/models/navigateknowledgegraphop.js +25 -0
- package/esm/models/navigateknowledgegraphop.js.map +1 -0
- package/esm/models/userteamsresponse.d.ts +1 -1
- package/esm/tool-names.d.ts.map +1 -1
- package/esm/tool-names.js +6 -2
- package/esm/tool-names.js.map +1 -1
- package/package.json +4 -2
- package/qm/README.md +247 -0
- package/qm/SECURITY.md +134 -0
- package/qm/TROUBLESHOOTING.md +218 -0
- package/qm/qm.config.fragment.jsonc +42 -0
- package/qm/sandbox/Dockerfile +22 -0
- package/qm/sandbox/skills/pipeshub/SKILL.md +69 -0
- package/qm/sandbox/tools/pipeshub/tool.json +36 -0
- package/src/cli/client.ts +272 -0
- package/src/cli/commands.ts +403 -0
- package/src/cli/config.ts +229 -0
- package/src/cli/init-qm.ts +215 -0
- package/src/cli/pipeshub.ts +333 -0
- package/src/funcs/connectorGetRecordContent.ts +179 -0
- package/src/funcs/connectorLookupRecordByIdentifier.ts +200 -0
- package/src/funcs/connectorNavigateKnowledgeGraph.ts +215 -0
- package/src/funcs/conversationsStreamConversation.ts +1 -1
- package/src/funcs/userGroupsGetAllUserGroups.ts +1 -1
- package/src/hooks/registration.ts +2 -1
- package/src/hooks/request-context.ts +47 -0
- package/src/hooks/requestid.ts +62 -0
- package/src/lib/base64.ts +6 -3
- package/src/lib/bytes-to-base64.ts +24 -0
- package/src/mcp-server/instructions.ts +62 -9
- package/src/mcp-server/server.ts +11 -3
- package/src/mcp-server/shared.ts +7 -3
- package/src/mcp-server/tools/_agui.ts +138 -0
- package/src/mcp-server/tools/_helpers.ts +13 -6
- package/src/mcp-server/tools/pipeshubChat.ts +78 -91
- package/src/mcp-server/tools/pipeshubGetRecordContent.ts +251 -0
- package/src/mcp-server/tools/pipeshubSearch.ts +22 -5
- package/src/mcp-server/tools.ts +14 -1
- package/src/models/getrecordcontentop.ts +11 -0
- package/src/models/lookuprecordbyidentifierop.ts +26 -0
- package/src/models/navigateknowledgegraphop.ts +56 -0
- package/src/tool-names.ts +6 -2
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// `pipeshub init-qm <dir>` — scaffold the QM deployment-layer bundle into an
|
|
2
|
+
// operator's deployment directory.
|
|
3
|
+
//
|
|
4
|
+
// Why this exists rather than "copy the folder from the repo": the bundle and
|
|
5
|
+
// the CLI it describes are one contract. Copying by hand lets an operator end
|
|
6
|
+
// up with a tool.json written for a different version of the binary that is
|
|
7
|
+
// actually installed, and that mismatch is silent — an approval rule naming a
|
|
8
|
+
// subcommand that no longer exists compiles to a pattern matching nothing.
|
|
9
|
+
// Scaffolding from the installed package makes the two versions the same by
|
|
10
|
+
// construction, and stamps the version into the Dockerfile's pin.
|
|
11
|
+
import { copyFile, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
12
|
+
import { dirname, join, resolve } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { CliError, EXIT } from "./config.js";
|
|
15
|
+
/**
|
|
16
|
+
* Walk up from this module to the package root. The CLI runs from two possible
|
|
17
|
+
* layouts — `bin/pipeshub.js` (bundled) and `esm/cli/pipeshub.js` (tsc) — so a
|
|
18
|
+
* fixed number of `..` would be wrong for one of them.
|
|
19
|
+
*/
|
|
20
|
+
async function packageRoot() {
|
|
21
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
for (let i = 0; i < 6; i++) {
|
|
23
|
+
try {
|
|
24
|
+
const raw = await readFile(join(dir, "package.json"), "utf8");
|
|
25
|
+
const pkg = JSON.parse(raw);
|
|
26
|
+
if (pkg.name === "@pipeshub-ai/mcp")
|
|
27
|
+
return dir;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// keep walking
|
|
31
|
+
}
|
|
32
|
+
const parent = dirname(dir);
|
|
33
|
+
if (parent === dir)
|
|
34
|
+
break;
|
|
35
|
+
dir = parent;
|
|
36
|
+
}
|
|
37
|
+
throw new CliError("could not locate the installed package root — reinstall @pipeshub-ai/mcp");
|
|
38
|
+
}
|
|
39
|
+
async function packageVersion(root) {
|
|
40
|
+
const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
41
|
+
return pkg.version ?? "latest";
|
|
42
|
+
}
|
|
43
|
+
async function exists(p) {
|
|
44
|
+
try {
|
|
45
|
+
await stat(p);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Copy a directory tree, reporting what was written and what was left alone. */
|
|
53
|
+
async function copyTree(from, to, force, written, skipped) {
|
|
54
|
+
await mkdir(to, { recursive: true });
|
|
55
|
+
for (const entry of await readdir(from, { withFileTypes: true })) {
|
|
56
|
+
const src = join(from, entry.name);
|
|
57
|
+
const dst = join(to, entry.name);
|
|
58
|
+
if (entry.isDirectory()) {
|
|
59
|
+
await copyTree(src, dst, force, written, skipped);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (!force && await exists(dst)) {
|
|
63
|
+
skipped.push(dst);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
await copyFile(src, dst);
|
|
67
|
+
written.push(dst);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const DOCKERFILE_NOTE = (version) => `
|
|
71
|
+
# --- PipesHub ---------------------------------------------------------------
|
|
72
|
+
# Installs the \`pipeshub\` binary. Pin the version: the sandbox image and the
|
|
73
|
+
# PipesHub instance's MCP tool surface need to stay compatible, and an unpinned
|
|
74
|
+
# install turns a remote release into a silent change in agent behaviour.
|
|
75
|
+
RUN npm install -g "@pipeshub-ai/mcp@${version}" \\
|
|
76
|
+
&& pipeshub --help >/dev/null
|
|
77
|
+
# ----------------------------------------------------------------------------
|
|
78
|
+
`;
|
|
79
|
+
export async function initQm(targetDir, force) {
|
|
80
|
+
const root = await packageRoot();
|
|
81
|
+
const bundle = join(root, "qm");
|
|
82
|
+
if (!await exists(join(bundle, "sandbox"))) {
|
|
83
|
+
throw new CliError(`the QM bundle is missing from the installed package (looked in ${bundle}). `
|
|
84
|
+
+ "This build was packaged without it.");
|
|
85
|
+
}
|
|
86
|
+
const version = await packageVersion(root);
|
|
87
|
+
const dest = resolve(targetDir);
|
|
88
|
+
const written = [];
|
|
89
|
+
const skipped = [];
|
|
90
|
+
// Tools and skills copy cleanly — they are ours and live in their own
|
|
91
|
+
// subdirectories, so merging with an existing sandbox/ cannot collide with
|
|
92
|
+
// anything the operator wrote.
|
|
93
|
+
for (const sub of ["tools/pipeshub", "skills/pipeshub"]) {
|
|
94
|
+
await copyTree(join(bundle, "sandbox", sub), join(dest, "sandbox", sub), force, written, skipped);
|
|
95
|
+
}
|
|
96
|
+
// The Dockerfile is shared with whatever else the operator installs, so it is
|
|
97
|
+
// never overwritten. Create it if absent, append our block if it exists and
|
|
98
|
+
// has no PipesHub block yet, and otherwise leave it entirely alone.
|
|
99
|
+
const dockerfile = join(dest, "sandbox", "Dockerfile");
|
|
100
|
+
let dockerfileAction;
|
|
101
|
+
if (!await exists(dockerfile)) {
|
|
102
|
+
await copyFile(join(bundle, "sandbox", "Dockerfile"), dockerfile);
|
|
103
|
+
// Restamp the pin so it matches the version actually installed.
|
|
104
|
+
const body = await readFile(dockerfile, "utf8");
|
|
105
|
+
await writeFile(dockerfile, body.replace(/ARG PIPESHUB_CLI_VERSION=.*/, `ARG PIPESHUB_CLI_VERSION=${version}`), "utf8");
|
|
106
|
+
written.push(dockerfile);
|
|
107
|
+
dockerfileAction = "created";
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const body = await readFile(dockerfile, "utf8");
|
|
111
|
+
if (body.includes("@pipeshub-ai/mcp")) {
|
|
112
|
+
dockerfileAction = "manual";
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
await writeFile(dockerfile, body.replace(/\n*$/, "\n") + DOCKERFILE_NOTE(version), "utf8");
|
|
116
|
+
dockerfileAction = "appended";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Do not swallow this. The fragment carries the `sandbox.env` block the
|
|
120
|
+
// operator must merge in, so reporting a successful init without it leaves
|
|
121
|
+
// them with a scaffold that cannot reach PipesHub and no sign of why.
|
|
122
|
+
const fragmentPath = join(bundle, "qm.config.fragment.jsonc");
|
|
123
|
+
let configFragment;
|
|
124
|
+
try {
|
|
125
|
+
configFragment = await readFile(fragmentPath, "utf8");
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
throw new CliError(`the QM bundle is incomplete — could not read ${fragmentPath} `
|
|
129
|
+
+ `(${e.message}). Reinstall @pipeshub-ai/mcp.`);
|
|
130
|
+
}
|
|
131
|
+
return { written, skipped, dockerfileAction, version, configFragment };
|
|
132
|
+
}
|
|
133
|
+
export function renderInitReport(dest, r) {
|
|
134
|
+
const lines = [];
|
|
135
|
+
lines.push(`Scaffolded the PipesHub bundle into ${dest}`);
|
|
136
|
+
lines.push(`CLI version pinned: ${r.version}`);
|
|
137
|
+
lines.push("");
|
|
138
|
+
for (const f of r.written)
|
|
139
|
+
lines.push(` wrote ${f}`);
|
|
140
|
+
for (const f of r.skipped)
|
|
141
|
+
lines.push(` kept ${f} (already existed — use --force to replace)`);
|
|
142
|
+
lines.push("");
|
|
143
|
+
if (r.dockerfileAction === "appended") {
|
|
144
|
+
lines.push("Appended the install block to your existing sandbox/Dockerfile.");
|
|
145
|
+
}
|
|
146
|
+
else if (r.dockerfileAction === "manual") {
|
|
147
|
+
lines.push("Your sandbox/Dockerfile already mentions @pipeshub-ai/mcp, so it was left"
|
|
148
|
+
+ " untouched. Check the pinned version matches " + r.version + ".");
|
|
149
|
+
}
|
|
150
|
+
lines.push("");
|
|
151
|
+
lines.push("Two things left to do:");
|
|
152
|
+
lines.push("");
|
|
153
|
+
lines.push("1. Set your PipesHub origin in qm.config.jsonc. It must be a PUBLIC");
|
|
154
|
+
lines.push(" HTTPS address — QM sandboxes do not run on your machine, so");
|
|
155
|
+
lines.push(" localhost and LAN addresses are unreachable from them:");
|
|
156
|
+
lines.push("");
|
|
157
|
+
lines.push(' "sandbox": {');
|
|
158
|
+
lines.push(' "env": { "PIPESHUB_BASE_URL": "https://pipeshub.your-company.com" }');
|
|
159
|
+
lines.push(" }");
|
|
160
|
+
lines.push("");
|
|
161
|
+
lines.push(" Do NOT put anyone's token in sandbox.secretEnv — that is org-wide and");
|
|
162
|
+
lines.push(" would hand one person's credential to everybody. Each person adds");
|
|
163
|
+
lines.push(" their own to their own keychain (service: pipeshub, kind: env).");
|
|
164
|
+
lines.push("");
|
|
165
|
+
lines.push("2. Set `egress` in sandbox/tools/pipeshub/tool.json to your hostname,");
|
|
166
|
+
lines.push(" then run: qm check && qm sandbox publish && qm up");
|
|
167
|
+
return lines.join("\n");
|
|
168
|
+
}
|
|
169
|
+
export const INIT_QM_EXIT = EXIT.OK;
|
|
170
|
+
//# sourceMappingURL=init-qm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-qm.js","sourceRoot":"","sources":["../../src/cli/init-qm.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,mCAAmC;AACnC,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,kEAAkE;AAElE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;GAIG;AACH,KAAK,UAAU,WAAW;IACxB,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;YAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,K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,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACrC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IAClF,KAAK,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;IAC7E,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IACxE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAChC,KAAK,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;IACzF,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IACvF,KAAK,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;IACjF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAC;IACpF,KAAK,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeshub.d.ts","sourceRoot":"","sources":["../../src/cli/pipeshub.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// `pipeshub` — a thin CLI over the PipesHub MCP endpoint, built for agent use.
|
|
2
|
+
//
|
|
3
|
+
// Design constraints worth stating at the top, because they are easy to erode:
|
|
4
|
+
//
|
|
5
|
+
// - There is NO way to supply a credential on the command line. No
|
|
6
|
+
// `auth set`, no `auth import`, no `--token`, no `--print-token`. The
|
|
7
|
+
// keychain is the only credential path. A flag that accepts a token would
|
|
8
|
+
// end up in shell history, process listings, and eventually a transcript.
|
|
9
|
+
// - The token is never printed, in any command, in any mode.
|
|
10
|
+
// - Exit codes are contractual: agents branch on them.
|
|
11
|
+
import { CliError, EXIT, resolveOrigin, resolveToken, } from "./config.js";
|
|
12
|
+
import { newRequestId } from "./client.js";
|
|
13
|
+
import { initQm, renderInitReport } from "./init-qm.js";
|
|
14
|
+
import { ask, authStatus, connectHelp, directoryWhoami, get, search, sources, } from "./commands.js";
|
|
15
|
+
const USAGE = `pipeshub — query your organization's PipesHub context layer
|
|
16
|
+
|
|
17
|
+
USAGE
|
|
18
|
+
pipeshub <command> [options]
|
|
19
|
+
|
|
20
|
+
COMMANDS
|
|
21
|
+
auth status show connection, user, org, scopes, expiry
|
|
22
|
+
auth connect-help print the keychain setup steps
|
|
23
|
+
init-qm <dir> scaffold the QM deployment-layer bundle (admin)
|
|
24
|
+
sources list searchable sources (ids for --app)
|
|
25
|
+
search <query> locate records
|
|
26
|
+
ask <question> ask a grounded question; returns citations
|
|
27
|
+
get <recordId> fetch a record's content
|
|
28
|
+
directory whoami the identity behind the current token
|
|
29
|
+
|
|
30
|
+
OPTIONS
|
|
31
|
+
--json JSON output (default)
|
|
32
|
+
--text human-readable output where available
|
|
33
|
+
--limit <n> search: max results (default 10)
|
|
34
|
+
--app <id> search: restrict to a source id (repeatable)
|
|
35
|
+
--conversation <id> ask: continue an existing conversation
|
|
36
|
+
--mode <internal|web> ask: retrieval strategy (default internal)
|
|
37
|
+
--as <format> get: server-side conversion, e.g. pdf
|
|
38
|
+
--out <path> get: write to a file instead of stdout
|
|
39
|
+
--max-chars <n> cap snippet/content length (default 2000)
|
|
40
|
+
--insecure-http allow cleartext to a host outside the private allowlist
|
|
41
|
+
--force init-qm: overwrite files that already exist
|
|
42
|
+
|
|
43
|
+
ENVIRONMENT
|
|
44
|
+
PIPESHUB_TOKEN preferred; PIPESHUB_MCP_TOKEN also accepted
|
|
45
|
+
PIPESHUB_BASE_URL origin, e.g. https://pipeshub.example.com
|
|
46
|
+
PIPESHUB_MCP_URL also accepted (its /mcp path is stripped)
|
|
47
|
+
|
|
48
|
+
EXIT CODES
|
|
49
|
+
0 ok · 2 usage · 3 not authenticated · 4 forbidden · 5 rate limited
|
|
50
|
+
6 no results (also: an 'ask' answer with no citations)
|
|
51
|
+
|
|
52
|
+
Credentials come from your QM keychain. This CLI cannot accept one as an
|
|
53
|
+
argument, by design. Run 'pipeshub auth connect-help' for setup steps.`;
|
|
54
|
+
function parseFlags(argv) {
|
|
55
|
+
const flags = {
|
|
56
|
+
json: true,
|
|
57
|
+
limit: 10,
|
|
58
|
+
apps: [],
|
|
59
|
+
conversation: null,
|
|
60
|
+
mode: "internal",
|
|
61
|
+
as: null,
|
|
62
|
+
out: null,
|
|
63
|
+
maxChars: 2000,
|
|
64
|
+
insecureHttp: false,
|
|
65
|
+
force: false,
|
|
66
|
+
};
|
|
67
|
+
const positional = [];
|
|
68
|
+
const needValue = (name, value) => {
|
|
69
|
+
if (value === undefined) {
|
|
70
|
+
throw new CliError(`${name} requires a value`, EXIT.USAGE);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
};
|
|
74
|
+
for (let i = 0; i < argv.length; i++) {
|
|
75
|
+
const a = argv[i];
|
|
76
|
+
if (a === undefined)
|
|
77
|
+
continue;
|
|
78
|
+
switch (a) {
|
|
79
|
+
case "--json":
|
|
80
|
+
flags.json = true;
|
|
81
|
+
break;
|
|
82
|
+
case "--text":
|
|
83
|
+
flags.json = false;
|
|
84
|
+
break;
|
|
85
|
+
case "--insecure-http":
|
|
86
|
+
flags.insecureHttp = true;
|
|
87
|
+
break;
|
|
88
|
+
case "--force":
|
|
89
|
+
flags.force = true;
|
|
90
|
+
break;
|
|
91
|
+
case "--limit":
|
|
92
|
+
flags.limit = Number(needValue(a, argv[++i]));
|
|
93
|
+
break;
|
|
94
|
+
case "--app":
|
|
95
|
+
flags.apps.push(needValue(a, argv[++i]));
|
|
96
|
+
break;
|
|
97
|
+
case "--conversation":
|
|
98
|
+
flags.conversation = needValue(a, argv[++i]);
|
|
99
|
+
break;
|
|
100
|
+
case "--mode":
|
|
101
|
+
flags.mode = needValue(a, argv[++i]);
|
|
102
|
+
break;
|
|
103
|
+
case "--as":
|
|
104
|
+
flags.as = needValue(a, argv[++i]);
|
|
105
|
+
break;
|
|
106
|
+
case "--out":
|
|
107
|
+
flags.out = needValue(a, argv[++i]);
|
|
108
|
+
break;
|
|
109
|
+
case "--max-chars":
|
|
110
|
+
flags.maxChars = Number(needValue(a, argv[++i]));
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
if (a.startsWith("--")) {
|
|
114
|
+
// Fail loudly rather than ignoring a flag the caller believed in.
|
|
115
|
+
throw new CliError(`unknown option: ${a}`, EXIT.USAGE);
|
|
116
|
+
}
|
|
117
|
+
positional.push(a);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!Number.isFinite(flags.limit) || flags.limit <= 0) {
|
|
121
|
+
throw new CliError("--limit must be a positive number", EXIT.USAGE);
|
|
122
|
+
}
|
|
123
|
+
if (!Number.isFinite(flags.maxChars) || flags.maxChars <= 0) {
|
|
124
|
+
throw new CliError("--max-chars must be a positive number", EXIT.USAGE);
|
|
125
|
+
}
|
|
126
|
+
return { positional, flags };
|
|
127
|
+
}
|
|
128
|
+
/** `--mode internal|web` → the tool's `chatMode` vocabulary. */
|
|
129
|
+
function resolveChatMode(mode) {
|
|
130
|
+
if (mode === "internal" || mode === "internal_search")
|
|
131
|
+
return "internal_search";
|
|
132
|
+
if (mode === "web" || mode === "web_search")
|
|
133
|
+
return "web_search";
|
|
134
|
+
throw new CliError(`--mode must be "internal" or "web" (got "${mode}"). The other chatMode `
|
|
135
|
+
+ "values the API accepts (quick, verification, deep) are only valid for "
|
|
136
|
+
+ "agent conversations, which v1 does not expose.", EXIT.USAGE);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Write and wait for the bytes to actually reach the pipe.
|
|
140
|
+
*
|
|
141
|
+
* `process.stdout` is asynchronous when it is a pipe — which is the normal
|
|
142
|
+
* case here, since the caller is an agent capturing output. `process.exit()`
|
|
143
|
+
* does not flush it, so a payload larger than the pipe buffer is silently cut
|
|
144
|
+
* off (measured: a 2,000,015-byte write delivered 1,048,576 bytes) while the
|
|
145
|
+
* exit code still reports success. The consumer then parses truncated JSON.
|
|
146
|
+
*
|
|
147
|
+
* The `write` callback fires once the chunk has been handed to the underlying
|
|
148
|
+
* resource, so exiting after it is safe — and unlike setting `process.exitCode`
|
|
149
|
+
* and returning, it does not wait on undici's keep-alive sockets.
|
|
150
|
+
*/
|
|
151
|
+
function writeFlushed(stream, text) {
|
|
152
|
+
return new Promise((resolve) => {
|
|
153
|
+
stream.write(text, () => resolve());
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function emit(outcome, json) {
|
|
157
|
+
if (!json && outcome.text !== undefined) {
|
|
158
|
+
return writeFlushed(process.stdout, outcome.text + "\n");
|
|
159
|
+
}
|
|
160
|
+
return writeFlushed(process.stdout, JSON.stringify(outcome.payload, null, 2) + "\n");
|
|
161
|
+
}
|
|
162
|
+
async function run(argv) {
|
|
163
|
+
if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h" || argv[0] === "help") {
|
|
164
|
+
await writeFlushed(process.stdout, USAGE + "\n");
|
|
165
|
+
return EXIT.OK;
|
|
166
|
+
}
|
|
167
|
+
const { positional, flags } = parseFlags(argv);
|
|
168
|
+
const command = positional[0] ?? "";
|
|
169
|
+
const sub = positional[1] ?? "";
|
|
170
|
+
// Refuse the credential-mutating shapes explicitly, so the failure explains
|
|
171
|
+
// itself instead of looking like a typo. These names must never work.
|
|
172
|
+
if (command === "auth" && ["set", "import", "login", "add"].includes(sub)) {
|
|
173
|
+
await writeFlushed(process.stderr, `pipeshub auth ${sub} does not exist, deliberately.\n`
|
|
174
|
+
+ "Credentials come from your QM keychain — run "
|
|
175
|
+
+ "'pipeshub auth connect-help' for the steps.\n");
|
|
176
|
+
return EXIT.USAGE;
|
|
177
|
+
}
|
|
178
|
+
const requestId = newRequestId();
|
|
179
|
+
const token = resolveToken();
|
|
180
|
+
const origin = resolveOrigin();
|
|
181
|
+
// connect-help must work with no credential at all — it is the thing you run
|
|
182
|
+
// precisely when you have none.
|
|
183
|
+
if (command === "auth" && sub === "connect-help") {
|
|
184
|
+
const outcome = connectHelp({
|
|
185
|
+
origin: origin ?? "",
|
|
186
|
+
token: "",
|
|
187
|
+
insecureHttp: flags.insecureHttp,
|
|
188
|
+
requestId,
|
|
189
|
+
json: flags.json,
|
|
190
|
+
maxChars: flags.maxChars,
|
|
191
|
+
});
|
|
192
|
+
await emit(outcome, flags.json);
|
|
193
|
+
return outcome.exit;
|
|
194
|
+
}
|
|
195
|
+
// Scaffolding is an admin task performed before any credential exists, so it
|
|
196
|
+
// runs before the token and base-URL checks.
|
|
197
|
+
if (command === "init-qm") {
|
|
198
|
+
const dir = positional[1] ?? "";
|
|
199
|
+
if (dir === "") {
|
|
200
|
+
throw new CliError("init-qm requires a target directory", EXIT.USAGE);
|
|
201
|
+
}
|
|
202
|
+
const result = await initQm(dir, flags.force);
|
|
203
|
+
const report = renderInitReport(dir, result);
|
|
204
|
+
if (flags.json) {
|
|
205
|
+
await writeFlushed(process.stdout, JSON.stringify({
|
|
206
|
+
requestId,
|
|
207
|
+
target: dir,
|
|
208
|
+
version: result.version,
|
|
209
|
+
written: result.written,
|
|
210
|
+
skipped: result.skipped,
|
|
211
|
+
dockerfile: result.dockerfileAction,
|
|
212
|
+
}, null, 2) + "\n");
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
await writeFlushed(process.stdout, report + "\n");
|
|
216
|
+
}
|
|
217
|
+
return EXIT.OK;
|
|
218
|
+
}
|
|
219
|
+
if (origin === null) {
|
|
220
|
+
// Report the missing credential too when both are absent. Otherwise a
|
|
221
|
+
// person whose actual problem is "I never added my token" is told about an
|
|
222
|
+
// admin-level setting, and goes looking in the wrong place.
|
|
223
|
+
const alsoNoToken = token === null
|
|
224
|
+
? " Your PipesHub credential is also missing ($PIPESHUB_TOKEN is unset)."
|
|
225
|
+
: "";
|
|
226
|
+
throw new CliError("PIPESHUB_BASE_URL is not set — an admin sets it once for the deployment."
|
|
227
|
+
+ alsoNoToken
|
|
228
|
+
+ " Run 'pipeshub auth connect-help' for the steps.", EXIT.USAGE);
|
|
229
|
+
}
|
|
230
|
+
if (token === null) {
|
|
231
|
+
throw new CliError("No PipesHub credential found ($PIPESHUB_TOKEN is unset). "
|
|
232
|
+
+ "Run 'pipeshub auth connect-help' for setup steps.", EXIT.UNAUTHENTICATED);
|
|
233
|
+
}
|
|
234
|
+
const ctx = {
|
|
235
|
+
origin,
|
|
236
|
+
token,
|
|
237
|
+
insecureHttp: flags.insecureHttp,
|
|
238
|
+
requestId,
|
|
239
|
+
json: flags.json,
|
|
240
|
+
maxChars: flags.maxChars,
|
|
241
|
+
};
|
|
242
|
+
let outcome;
|
|
243
|
+
switch (command) {
|
|
244
|
+
case "auth":
|
|
245
|
+
if (sub !== "status") {
|
|
246
|
+
throw new CliError(`unknown subcommand: auth ${sub || "(none)"}`, EXIT.USAGE);
|
|
247
|
+
}
|
|
248
|
+
outcome = await authStatus(ctx);
|
|
249
|
+
break;
|
|
250
|
+
case "sources":
|
|
251
|
+
outcome = await sources(ctx);
|
|
252
|
+
break;
|
|
253
|
+
case "search": {
|
|
254
|
+
const query = positional.slice(1).join(" ").trim();
|
|
255
|
+
if (query === "")
|
|
256
|
+
throw new CliError("search requires a query", EXIT.USAGE);
|
|
257
|
+
outcome = await search(ctx, query, flags.limit, flags.apps);
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
case "ask": {
|
|
261
|
+
const query = positional.slice(1).join(" ").trim();
|
|
262
|
+
if (query === "")
|
|
263
|
+
throw new CliError("ask requires a question", EXIT.USAGE);
|
|
264
|
+
outcome = await ask(ctx, query, flags.conversation, resolveChatMode(flags.mode));
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
case "get": {
|
|
268
|
+
const recordId = positional[1] ?? "";
|
|
269
|
+
if (recordId === "")
|
|
270
|
+
throw new CliError("get requires a recordId", EXIT.USAGE);
|
|
271
|
+
outcome = await get(ctx, recordId, flags.as, flags.out);
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
case "directory":
|
|
275
|
+
if (sub !== "whoami") {
|
|
276
|
+
throw new CliError("v1 supports 'directory whoami' only. 'groups' needs usergroup:read, "
|
|
277
|
+
+ "which is not in the stock MCP_SCOPES and cannot be minted on a "
|
|
278
|
+
+ "default instance; 'teams' needs team:read, which the agent "
|
|
279
|
+
+ "preset excludes.", EXIT.USAGE);
|
|
280
|
+
}
|
|
281
|
+
outcome = await directoryWhoami(ctx);
|
|
282
|
+
break;
|
|
283
|
+
default:
|
|
284
|
+
throw new CliError(`unknown command: ${command}`, EXIT.USAGE);
|
|
285
|
+
}
|
|
286
|
+
await emit(outcome, flags.json);
|
|
287
|
+
return outcome.exit;
|
|
288
|
+
}
|
|
289
|
+
const code = await run(process.argv.slice(2)).catch(async (e) => {
|
|
290
|
+
const err = e;
|
|
291
|
+
const exit = typeof err.code === "number" ? err.code : EXIT.ERROR;
|
|
292
|
+
await writeFlushed(process.stderr, `pipeshub: ${err.message}\n`);
|
|
293
|
+
return exit;
|
|
294
|
+
});
|
|
295
|
+
process.exit(code);
|
|
296
|
+
//# sourceMappingURL=pipeshub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeshub.js","sourceRoot":"","sources":["../../src/cli/pipeshub.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,+EAA+E;AAC/E,EAAE;AACF,qEAAqE;AACrE,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,+D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E,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACxD,MAAM;QACR,CAAC;QACD,KAAK,WAAW;YACd,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACrB,MAAM,IAAI,QAAQ,CAChB,sEAAsE;sBAClE,iEAAiE;sBACjE,6DAA6D;sBAC7D,kBAAkB,EACtB,IAAI,CAAC,KAAK,CACX,CAAC;YACJ,CAAC;YACD,OAAO,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;YACrC,MAAM;QACR;YACE,MAAM,IAAI,QAAQ,CAAC,oBAAoB,OAAO,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC;AAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAU,EAAE,EAAE;IACvE,MAAM,GAAG,GAAG,CAAa,CAAC;IAC1B,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IAClE,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PipeshubCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
4
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
5
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
6
|
+
import { GetRecordContentRequest } from "../models/getrecordcontentop.js";
|
|
7
|
+
import { APIPromise } from "../types/async.js";
|
|
8
|
+
import { Result } from "../types/fp.js";
|
|
9
|
+
/**
|
|
10
|
+
* Get a record's full parsed content and metadata
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Retrieve the full parsed content and metadata of a single record —
|
|
14
|
+
* the same content PipesHub's own RAG/chat pipeline uses to answer
|
|
15
|
+
* questions, returned directly instead of via chat.
|
|
16
|
+
*
|
|
17
|
+
* **When to use this vs. the other record endpoints:**
|
|
18
|
+
* - `GET /knowledgeBase/record/{recordId}` returns metadata only
|
|
19
|
+
* (name, type, indexing status, size) — no content.
|
|
20
|
+
* - `GET /knowledgeBase/stream/record/{recordId}` returns the original,
|
|
21
|
+
* unparsed file bytes — use it to download/open the source file.
|
|
22
|
+
* - **This endpoint** returns the record's full parsed content as a
|
|
23
|
+
* single plain-text `content` string (a metadata header, then the
|
|
24
|
+
* block/table text in reading order) — use it when you need the
|
|
25
|
+
* record's actual textual/tabular content without downloading and
|
|
26
|
+
* re-parsing the original file yourself.
|
|
27
|
+
*
|
|
28
|
+
* **Typical flow:** obtain a `recordId` from a `pipeshub_search` hit or
|
|
29
|
+
* a chat citation's `recordId`, then call this endpoint to read the
|
|
30
|
+
* full content when the search snippet or citation excerpt isn't
|
|
31
|
+
* enough to answer the question.
|
|
32
|
+
*
|
|
33
|
+
* **Permission scoping:**
|
|
34
|
+
*
|
|
35
|
+
* The requesting user/token must have access to the record; access is
|
|
36
|
+
* verified via the knowledge graph before content is returned — a
|
|
37
|
+
* caller with a valid scope but no access to this specific record gets
|
|
38
|
+
* a `403`.
|
|
39
|
+
*
|
|
40
|
+
* If set, this operation will use either {@link Security.bearerAuth} or {@link Security.oauth2} from the global security.
|
|
41
|
+
*/
|
|
42
|
+
export declare function connectorGetRecordContent(client$: PipeshubCore, request: GetRecordContentRequest, options?: RequestOptions): APIPromise<Result<Response, APIError | SDKValidationError | UnexpectedClientError | InvalidRequestError | RequestAbortedError | RequestTimeoutError | ConnectionError>>;
|
|
43
|
+
//# sourceMappingURL=connectorGetRecordContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorGetRecordContent.d.ts","sourceRoot":"","sources":["../../src/funcs/connectorGetRecordContent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAW,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,uBAAuB,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CACX,MAAM,CACJ,QAAQ,EACN,QAAQ,GACR,kBAAkB,GAClB,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,CAClB,CACF,CAMA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from Speakeasy-generated connectorGetRecordContent.
|
|
3
|
+
*/
|
|
4
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
5
|
+
import { compactMap } from "../lib/primitives.js";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
8
|
+
import { pathToFunc } from "../lib/url.js";
|
|
9
|
+
import { GetRecordContentRequest$zodSchema, } from "../models/getrecordcontentop.js";
|
|
10
|
+
import { APIPromise } from "../types/async.js";
|
|
11
|
+
/**
|
|
12
|
+
* Get a record's full parsed content and metadata
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Retrieve the full parsed content and metadata of a single record —
|
|
16
|
+
* the same content PipesHub's own RAG/chat pipeline uses to answer
|
|
17
|
+
* questions, returned directly instead of via chat.
|
|
18
|
+
*
|
|
19
|
+
* **When to use this vs. the other record endpoints:**
|
|
20
|
+
* - `GET /knowledgeBase/record/{recordId}` returns metadata only
|
|
21
|
+
* (name, type, indexing status, size) — no content.
|
|
22
|
+
* - `GET /knowledgeBase/stream/record/{recordId}` returns the original,
|
|
23
|
+
* unparsed file bytes — use it to download/open the source file.
|
|
24
|
+
* - **This endpoint** returns the record's full parsed content as a
|
|
25
|
+
* single plain-text `content` string (a metadata header, then the
|
|
26
|
+
* block/table text in reading order) — use it when you need the
|
|
27
|
+
* record's actual textual/tabular content without downloading and
|
|
28
|
+
* re-parsing the original file yourself.
|
|
29
|
+
*
|
|
30
|
+
* **Typical flow:** obtain a `recordId` from a `pipeshub_search` hit or
|
|
31
|
+
* a chat citation's `recordId`, then call this endpoint to read the
|
|
32
|
+
* full content when the search snippet or citation excerpt isn't
|
|
33
|
+
* enough to answer the question.
|
|
34
|
+
*
|
|
35
|
+
* **Permission scoping:**
|
|
36
|
+
*
|
|
37
|
+
* The requesting user/token must have access to the record; access is
|
|
38
|
+
* verified via the knowledge graph before content is returned — a
|
|
39
|
+
* caller with a valid scope but no access to this specific record gets
|
|
40
|
+
* a `403`.
|
|
41
|
+
*
|
|
42
|
+
* If set, this operation will use either {@link Security.bearerAuth} or {@link Security.oauth2} from the global security.
|
|
43
|
+
*/
|
|
44
|
+
export function connectorGetRecordContent(client$, request, options) {
|
|
45
|
+
return new APIPromise($do(client$, request, options));
|
|
46
|
+
}
|
|
47
|
+
async function $do(client$, request, options) {
|
|
48
|
+
const parsed$ = safeParse(request, (value$) => GetRecordContentRequest$zodSchema.parse(value$), "Input validation failed");
|
|
49
|
+
if (!parsed$.ok) {
|
|
50
|
+
return [parsed$, { status: "invalid" }];
|
|
51
|
+
}
|
|
52
|
+
const payload$ = parsed$.value;
|
|
53
|
+
const body$ = null;
|
|
54
|
+
const pathParams$ = {
|
|
55
|
+
recordId: encodeSimple("recordId", payload$.recordId, {
|
|
56
|
+
explode: false,
|
|
57
|
+
charEncoding: "percent",
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
const path$ = pathToFunc("/connectors/record/{recordId}/content")(pathParams$);
|
|
61
|
+
const headers$ = new Headers(compactMap({
|
|
62
|
+
Accept: "application/json",
|
|
63
|
+
}));
|
|
64
|
+
const securityInput = await extractSecurity(client$._options.security);
|
|
65
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
66
|
+
const context = {
|
|
67
|
+
options: client$._options,
|
|
68
|
+
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
69
|
+
operationID: "getRecordContent",
|
|
70
|
+
oAuth2Scopes: ["connector:read"],
|
|
71
|
+
resolvedSecurity: requestSecurity,
|
|
72
|
+
securitySource: client$._options.security,
|
|
73
|
+
retryConfig: options?.retries
|
|
74
|
+
|| client$._options.retryConfig
|
|
75
|
+
|| { strategy: "none" },
|
|
76
|
+
retryCodes: options?.retryCodes || [
|
|
77
|
+
"429",
|
|
78
|
+
"500",
|
|
79
|
+
"502",
|
|
80
|
+
"503",
|
|
81
|
+
"504",
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
const requestRes = client$._createRequest(context, {
|
|
85
|
+
security: requestSecurity,
|
|
86
|
+
method: "GET",
|
|
87
|
+
baseURL: options?.serverURL,
|
|
88
|
+
path: path$,
|
|
89
|
+
headers: headers$,
|
|
90
|
+
body: body$,
|
|
91
|
+
userAgent: client$._options.userAgent,
|
|
92
|
+
timeoutMs: options?.timeoutMs || client$._options.timeoutMs
|
|
93
|
+
|| -1,
|
|
94
|
+
}, options);
|
|
95
|
+
if (!requestRes.ok) {
|
|
96
|
+
return [requestRes, { status: "invalid" }];
|
|
97
|
+
}
|
|
98
|
+
const req$ = requestRes.value;
|
|
99
|
+
const doResult = await client$._do(req$, {
|
|
100
|
+
context,
|
|
101
|
+
errorCodes: [],
|
|
102
|
+
retryConfig: context.retryConfig,
|
|
103
|
+
retryCodes: context.retryCodes,
|
|
104
|
+
});
|
|
105
|
+
if (!doResult.ok) {
|
|
106
|
+
return [doResult, { status: "request-error", request: req$ }];
|
|
107
|
+
}
|
|
108
|
+
return [doResult, {
|
|
109
|
+
status: "complete",
|
|
110
|
+
"request": req$,
|
|
111
|
+
response: doResult.value,
|
|
112
|
+
}];
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=connectorGetRecordContent.js.map
|