@indigoai-us/hq-cli 5.101.7 → 5.103.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.
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Typed client for hq-pro's integration-factory routes.
3
+ *
4
+ * One function per endpoint, each a thin `vaultApiFetch` + `raiseForResponse`
5
+ * pair. The wire shapes below MIRROR hq-pro (`src/vault-service/handlers/
6
+ * integrations-admin.ts`) rather than importing from it — hq-cli takes no
7
+ * cross-repo source dependency — so every field a newer backend might not emit
8
+ * is optional and read defensively.
9
+ */
10
+ import { vaultApiFetch } from "../utils/vault-api.js";
11
+ import { raiseForResponse, } from "./integrations-core.js";
12
+ export async function listCatalog(token, companyUid, opts = {}) {
13
+ const query = {
14
+ companyUid,
15
+ limit: String(opts.limit ?? 60),
16
+ };
17
+ // hq-pro bounds the query itself; normalize whitespace here so an
18
+ // accidentally padded shell argument doesn't read as a different search.
19
+ const q = (opts.query ?? "").replace(/\s+/g, " ").trim();
20
+ if (q)
21
+ query.query = q;
22
+ const res = await vaultApiFetch({
23
+ token,
24
+ path: "/v1/integrations/factory/catalog",
25
+ query,
26
+ });
27
+ if (!res.ok)
28
+ await raiseForResponse(res, "Failed to browse the app catalog");
29
+ const body = (await res.json());
30
+ return body.entries ?? [];
31
+ }
32
+ export async function pullBlueprint(token, companyUid, input) {
33
+ const res = await vaultApiFetch({
34
+ token,
35
+ path: "/v1/integrations/factory/blueprint",
36
+ method: "POST",
37
+ body: { companyUid, ...input },
38
+ });
39
+ if (!res.ok)
40
+ await raiseForResponse(res, "Failed to inspect the app");
41
+ const body = (await res.json());
42
+ return body.blueprint;
43
+ }
44
+ export async function discoverDocs(token, companyUid, docsUrl) {
45
+ const res = await vaultApiFetch({
46
+ token,
47
+ path: "/v1/integrations/factory/discover-docs",
48
+ method: "POST",
49
+ body: { companyUid, docsUrl },
50
+ });
51
+ if (!res.ok)
52
+ await raiseForResponse(res, "Failed to read that documentation page");
53
+ return (await res.json());
54
+ }
55
+ export async function installIntegration(token, companyUid, input) {
56
+ const res = await vaultApiFetch({
57
+ token,
58
+ path: "/v1/integrations/factory/install",
59
+ method: "POST",
60
+ body: { companyUid, ...input },
61
+ });
62
+ if (!res.ok)
63
+ await raiseForResponse(res, "Failed to connect the app");
64
+ return (await res.json());
65
+ }
66
+ export async function uninstallIntegration(token, companyUid, installationId) {
67
+ const res = await vaultApiFetch({
68
+ token,
69
+ path: "/v1/integrations/factory/uninstall",
70
+ method: "POST",
71
+ body: { companyUid, installationId },
72
+ });
73
+ if (!res.ok)
74
+ await raiseForResponse(res, "Failed to disconnect the app");
75
+ return (await res.json());
76
+ }
77
+ export async function startOAuth(token, companyUid, input) {
78
+ const res = await vaultApiFetch({
79
+ token,
80
+ path: "/v1/integrations/factory/oauth/start",
81
+ method: "POST",
82
+ body: { companyUid, ...input },
83
+ });
84
+ if (!res.ok)
85
+ await raiseForResponse(res, "Failed to start sign-in");
86
+ return (await res.json());
87
+ }
88
+ export async function completeOAuth(token, companyUid, input) {
89
+ const res = await vaultApiFetch({
90
+ token,
91
+ path: "/v1/integrations/factory/oauth/complete",
92
+ method: "POST",
93
+ body: { companyUid, ...input },
94
+ });
95
+ if (!res.ok)
96
+ await raiseForResponse(res, "Failed to finish sign-in");
97
+ return (await res.json());
98
+ }
99
+ /* ------------------------------------------------------------------ */
100
+ /* Governance: write policy + per-tool grants */
101
+ /* ------------------------------------------------------------------ */
102
+ export async function updateGovernance(token, companyUid, input) {
103
+ const res = await vaultApiFetch({
104
+ token,
105
+ path: "/v1/integrations/admin",
106
+ method: "PATCH",
107
+ body: { companyUid, ...input },
108
+ });
109
+ if (!res.ok)
110
+ await raiseForResponse(res, "Failed to update the app's settings");
111
+ return (await res.json());
112
+ }
113
+ export async function getConnectionAccess(token, companyUid, connectionId) {
114
+ const res = await vaultApiFetch({
115
+ token,
116
+ path: "/v1/integrations/factory/access",
117
+ query: { companyUid, connectionId },
118
+ });
119
+ if (!res.ok)
120
+ await raiseForResponse(res, "Failed to read who can use this app");
121
+ return (await res.json());
122
+ }
123
+ export async function mutateConnectionAccess(token, companyUid, action, input) {
124
+ const res = await vaultApiFetch({
125
+ token,
126
+ path: `/v1/integrations/factory/access/${action}`,
127
+ method: "POST",
128
+ body: { companyUid, ...input },
129
+ });
130
+ if (!res.ok) {
131
+ await raiseForResponse(res, action === "grant" ? "Failed to share the app" : "Failed to remove access");
132
+ }
133
+ return (await res.json());
134
+ }
135
+ //# sourceMappingURL=integrations-api.js.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `hq integrations catalog | inspect | discover | connect | reconnect`.
3
+ *
4
+ * The add half of the lifecycle: find an app, look at what it exposes, and
5
+ * connect it. Connecting is the interesting one — an app authenticates in one
6
+ * of three ways and hq-cli should not make the caller work out which:
7
+ *
8
+ * none the MCP endpoint is anonymously callable → install directly
9
+ * key the endpoint wants a bearer token → take it from --token /
10
+ * --token-stdin / a hidden prompt, never from argv history
11
+ * oauth the endpoint speaks OAuth 2.1 → run the RFC 8252 loopback flow
12
+ *
13
+ * Detection is server-authoritative and lazy. Rather than guessing from
14
+ * catalog metadata (which can be stale), the command attempts the direct
15
+ * install and treats hq-pro's `INTEGRATION_FACTORY_OAUTH_REQUIRED` as the
16
+ * signal to switch into the browser flow. That way a catalog row that says
17
+ * "key" but is really OAuth-protected still connects on the first try.
18
+ */
19
+ import { Command } from "commander";
20
+ /**
21
+ * Validate `--auth` against the supported enum, rejecting an unknown value
22
+ * before anything is installed. A finite provider/runtime option must never be
23
+ * narrowed by a truthy cast — an unrecognised mode has to fail loudly rather
24
+ * than fall through to a default.
25
+ */
26
+ export declare function assertAuthMode(value: string | undefined): void;
27
+ /** Single-quote a value for a copy-pasteable shell command. */
28
+ export declare function shellQuote(value: string): string;
29
+ export declare function registerConnectCommands(integrations: Command): void;
30
+ //# sourceMappingURL=integrations-connect.d.ts.map