@vm0/cli 9.221.4 → 9.221.5
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/{agent-SRJW4DJV.js → agent-DYWIJQ2R.js} +4 -4
- package/{automation-THUDKXQR.js → automation-CZYPQV3U.js} +7 -9
- package/{automation-THUDKXQR.js.map → automation-CZYPQV3U.js.map} +1 -1
- package/{banking-ED4LTRY3.js → banking-NLYZOBEM.js} +2 -2
- package/{chat-WMXIEDEY.js → chat-5UZFU2YR.js} +2 -2
- package/{chunk-AYR37FIN.js → chunk-463VKP2V.js} +3 -3
- package/{chunk-3NMCKGNJ.js → chunk-65CYJRLA.js} +2 -2
- package/{chunk-J7RLLIWI.js → chunk-HQFETCZ6.js} +26 -2
- package/chunk-HQFETCZ6.js.map +1 -0
- package/{chunk-2K5GNYND.js → chunk-IFA2V7EW.js} +2 -2
- package/{chunk-RR5CO7IT.js → chunk-IMZDXXSW.js} +2 -2
- package/{chunk-4YUV2CMK.js → chunk-PB7YKTIG.js} +3 -3
- package/{chunk-QV73BJ3B.js → chunk-PCBM5SRN.js} +320 -134
- package/chunk-PCBM5SRN.js.map +1 -0
- package/{chunk-QCYPFXRV.js → chunk-PX6FH3KT.js} +2 -2
- package/{chunk-M5MXYLLZ.js → chunk-UZJLZXGK.js} +123 -291
- package/chunk-UZJLZXGK.js.map +1 -0
- package/{chunk-DAC5OAWI.js → chunk-ZQYA5M55.js} +3 -64
- package/{chunk-DAC5OAWI.js.map → chunk-ZQYA5M55.js.map} +1 -1
- package/{computer-use-WINYVPQS.js → computer-use-JWVNMBIM.js} +2 -2
- package/{connector-WBM4EKRR.js → connector-YJX3MZGN.js} +382 -395
- package/connector-YJX3MZGN.js.map +1 -0
- package/{credit-KJRMNSQ2.js → credit-FHOJ736M.js} +2 -2
- package/{developer-support-DMUPPQB2.js → developer-support-BJVUM5OZ.js} +2 -2
- package/{doctor-VGQ6YI6G.js → doctor-BDSKVS5W.js} +5 -5
- package/{generate-STQVPQZO.js → generate-EA5ZRXFE.js} +60 -81
- package/generate-EA5ZRXFE.js.map +1 -0
- package/{github-LSFYZXO3.js → github-NU7VA3WB.js} +2 -2
- package/{goal-BNN7NM52.js → goal-4H4GUEMC.js} +2 -2
- package/{host-4MVX223U.js → host-SCI3ZPFT.js} +2 -2
- package/index.js +13 -13
- package/{logs-2VYXOUSW.js → logs-EOG3DCHM.js} +6 -6
- package/{maps-AMT7SMTH.js → maps-E5GVYSKP.js} +2 -2
- package/{model-HRRTGQQW.js → model-XP7ACN22.js} +3 -3
- package/{model-provider-HRK3C42K.js → model-provider-TAGWSIEW.js} +3 -3
- package/{org-M6Z5HXLU.js → org-4CMXX52G.js} +2 -2
- package/package.json +1 -1
- package/{phone-XM2DDX3C.js → phone-T7VLFMEU.js} +2 -2
- package/{preference-OQ3NRFCT.js → preference-Q4ZCLD2L.js} +2 -2
- package/{resource-NR6R2I6J.js → resource-QKFJESUB.js} +2 -2
- package/{search-RVTPT6N3.js → search-5QGCMW7I.js} +6 -6
- package/{secret-JPLOSNN3.js → secret-LMPIFKPU.js} +3 -3
- package/{slack-ETMPZQYC.js → slack-FKENH3DZ.js} +2 -2
- package/{telegram-IOHI44M5.js → telegram-ZG24OBRU.js} +2 -2
- package/{variable-URYGYI2W.js → variable-BOATQUX3.js} +2 -2
- package/{web-OAVP3LA4.js → web-3ASTXCH7.js} +2 -2
- package/{whoami-5RMEOJGY.js → whoami-DHCS6YIJ.js} +4 -4
- package/{workflow-JJXIMM3C.js → workflow-T2TTFE6C.js} +4 -6
- package/{workflow-JJXIMM3C.js.map → workflow-T2TTFE6C.js.map} +1 -1
- package/zero.js +31 -31
- package/chunk-J7RLLIWI.js.map +0 -1
- package/chunk-M5MXYLLZ.js.map +0 -1
- package/chunk-QV73BJ3B.js.map +0 -1
- package/chunk-RGP625TN.js +0 -47
- package/chunk-RGP625TN.js.map +0 -1
- package/connector-WBM4EKRR.js.map +0 -1
- package/generate-STQVPQZO.js.map +0 -1
- /package/{agent-SRJW4DJV.js.map → agent-DYWIJQ2R.js.map} +0 -0
- /package/{banking-ED4LTRY3.js.map → banking-NLYZOBEM.js.map} +0 -0
- /package/{chat-WMXIEDEY.js.map → chat-5UZFU2YR.js.map} +0 -0
- /package/{chunk-AYR37FIN.js.map → chunk-463VKP2V.js.map} +0 -0
- /package/{chunk-3NMCKGNJ.js.map → chunk-65CYJRLA.js.map} +0 -0
- /package/{chunk-2K5GNYND.js.map → chunk-IFA2V7EW.js.map} +0 -0
- /package/{chunk-RR5CO7IT.js.map → chunk-IMZDXXSW.js.map} +0 -0
- /package/{chunk-4YUV2CMK.js.map → chunk-PB7YKTIG.js.map} +0 -0
- /package/{chunk-QCYPFXRV.js.map → chunk-PX6FH3KT.js.map} +0 -0
- /package/{computer-use-WINYVPQS.js.map → computer-use-JWVNMBIM.js.map} +0 -0
- /package/{credit-KJRMNSQ2.js.map → credit-FHOJ736M.js.map} +0 -0
- /package/{developer-support-DMUPPQB2.js.map → developer-support-BJVUM5OZ.js.map} +0 -0
- /package/{doctor-VGQ6YI6G.js.map → doctor-BDSKVS5W.js.map} +0 -0
- /package/{github-LSFYZXO3.js.map → github-NU7VA3WB.js.map} +0 -0
- /package/{goal-BNN7NM52.js.map → goal-4H4GUEMC.js.map} +0 -0
- /package/{host-4MVX223U.js.map → host-SCI3ZPFT.js.map} +0 -0
- /package/{logs-2VYXOUSW.js.map → logs-EOG3DCHM.js.map} +0 -0
- /package/{maps-AMT7SMTH.js.map → maps-E5GVYSKP.js.map} +0 -0
- /package/{model-HRRTGQQW.js.map → model-XP7ACN22.js.map} +0 -0
- /package/{model-provider-HRK3C42K.js.map → model-provider-TAGWSIEW.js.map} +0 -0
- /package/{org-M6Z5HXLU.js.map → org-4CMXX52G.js.map} +0 -0
- /package/{phone-XM2DDX3C.js.map → phone-T7VLFMEU.js.map} +0 -0
- /package/{preference-OQ3NRFCT.js.map → preference-Q4ZCLD2L.js.map} +0 -0
- /package/{resource-NR6R2I6J.js.map → resource-QKFJESUB.js.map} +0 -0
- /package/{search-RVTPT6N3.js.map → search-5QGCMW7I.js.map} +0 -0
- /package/{secret-JPLOSNN3.js.map → secret-LMPIFKPU.js.map} +0 -0
- /package/{slack-ETMPZQYC.js.map → slack-FKENH3DZ.js.map} +0 -0
- /package/{telegram-IOHI44M5.js.map → telegram-ZG24OBRU.js.map} +0 -0
- /package/{variable-URYGYI2W.js.map → variable-BOATQUX3.js.map} +0 -0
- /package/{web-OAVP3LA4.js.map → web-3ASTXCH7.js.map} +0 -0
- /package/{whoami-5RMEOJGY.js.map → whoami-DHCS6YIJ.js.map} +0 -0
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __createRequire } from "node:module";
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
|
-
import {
|
|
5
|
-
formatDateTime
|
|
6
|
-
} from "./chunk-RGP625TN.js";
|
|
7
4
|
import {
|
|
8
5
|
getPlatformOrigin
|
|
9
6
|
} from "./chunk-ZFETZTKV.js";
|
|
10
|
-
import {
|
|
11
|
-
getConfiguredConnectorAuthMethodIds,
|
|
12
|
-
getConnectorAuthMethod,
|
|
13
|
-
getConnectorAuthMethodScopeDiff,
|
|
14
|
-
getConnectorEnvBindingEntries,
|
|
15
|
-
hasRequiredConnectorAuthMethodScopes
|
|
16
|
-
} from "./chunk-DAC5OAWI.js";
|
|
17
7
|
import "./chunk-LTDQISD7.js";
|
|
18
8
|
import {
|
|
19
|
-
CONNECTOR_TYPES,
|
|
20
|
-
CONNECTOR_TYPE_KEYS,
|
|
21
9
|
connectZeroConnectorManualGrant,
|
|
10
|
+
connectorAuthMethodIdSchema,
|
|
22
11
|
connectorTypeSchema,
|
|
23
12
|
customConnectorProposalSchema,
|
|
24
13
|
getZeroAgent,
|
|
25
14
|
getZeroAgentCustomConnectors,
|
|
26
15
|
getZeroAgentUserConnectors,
|
|
27
|
-
getZeroConnector,
|
|
28
16
|
getZeroCustomConnector,
|
|
29
|
-
|
|
30
|
-
listZeroCustomConnectors
|
|
31
|
-
|
|
32
|
-
} from "./chunk-QV73BJ3B.js";
|
|
17
|
+
listZeroConnectorCatalogStatus,
|
|
18
|
+
listZeroCustomConnectors
|
|
19
|
+
} from "./chunk-PCBM5SRN.js";
|
|
33
20
|
import {
|
|
34
21
|
withErrorHandler
|
|
35
22
|
} from "./chunk-3F4RFLPX.js";
|
|
@@ -49,87 +36,293 @@ init_esm_shims();
|
|
|
49
36
|
|
|
50
37
|
// src/commands/zero/connector/connect.ts
|
|
51
38
|
init_esm_shims();
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
|
|
40
|
+
// src/commands/zero/connector/public-catalog.ts
|
|
41
|
+
init_esm_shims();
|
|
42
|
+
var TOKEN_BOUNDARY = /[_\-\s]+/;
|
|
43
|
+
var CASE_BOUNDARY = /(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/;
|
|
44
|
+
var MIN_SCORE = 10;
|
|
45
|
+
function tokenize(input) {
|
|
46
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
47
|
+
for (const chunk of input.split(TOKEN_BOUNDARY)) {
|
|
48
|
+
if (!chunk) continue;
|
|
49
|
+
for (const sub of chunk.split(CASE_BOUNDARY)) {
|
|
50
|
+
const lower = sub.toLowerCase();
|
|
51
|
+
if (lower) tokens.add(lower);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return tokens;
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
function publicStrings(connector) {
|
|
57
|
+
return [
|
|
58
|
+
connector.connectorRef,
|
|
59
|
+
connector.label,
|
|
60
|
+
connector.description,
|
|
61
|
+
connector.category,
|
|
62
|
+
...connector.tags,
|
|
63
|
+
...connector.generation,
|
|
64
|
+
...connector.authMethods.flatMap((authMethod) => {
|
|
65
|
+
return [
|
|
66
|
+
authMethod.id,
|
|
67
|
+
authMethod.label,
|
|
68
|
+
...authMethod.description ? [authMethod.description] : []
|
|
69
|
+
];
|
|
70
|
+
})
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
function best(candidates) {
|
|
74
|
+
return candidates.reduce((bestHit, hit) => {
|
|
75
|
+
if (!hit) return bestHit;
|
|
76
|
+
if (!bestHit || hit.score > bestHit.score) return hit;
|
|
77
|
+
return bestHit;
|
|
78
|
+
}, null);
|
|
79
|
+
}
|
|
80
|
+
function scoreExact(keywordLower, skipPrivateIdentifierMatches, connector) {
|
|
81
|
+
if (connector.connectorRef.toLowerCase() === keywordLower) {
|
|
82
|
+
return { score: 100, matchedField: "connectorRef" };
|
|
62
83
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
if (connector.label.toLowerCase() === keywordLower) {
|
|
85
|
+
return { score: 80, matchedField: "label" };
|
|
86
|
+
}
|
|
87
|
+
for (const tag of connector.tags) {
|
|
88
|
+
if (skipPrivateIdentifierMatches && tag.includes("_")) continue;
|
|
89
|
+
if (tag.toLowerCase() === keywordLower) {
|
|
90
|
+
return { score: 70, matchedField: `tag:${tag}` };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const generationType of connector.generation) {
|
|
94
|
+
if (generationType.toLowerCase() === keywordLower) {
|
|
95
|
+
return { score: 65, matchedField: `generation:${generationType}` };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const authMethod of connector.authMethods) {
|
|
99
|
+
if (authMethod.id.toLowerCase() === keywordLower) {
|
|
100
|
+
return { score: 60, matchedField: `auth-method:${authMethod.id}` };
|
|
101
|
+
}
|
|
102
|
+
if (authMethod.label.toLowerCase() === keywordLower) {
|
|
103
|
+
return { score: 60, matchedField: `auth-method:${authMethod.label}` };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (connector.category.toLowerCase() === keywordLower) {
|
|
107
|
+
return { score: 55, matchedField: "category" };
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
function scoreSubstring(keywordLower, skipPrivateIdentifierMatches, connector) {
|
|
112
|
+
const candidates = [];
|
|
113
|
+
if (connector.connectorRef.toLowerCase().includes(keywordLower)) {
|
|
114
|
+
candidates.push({ score: 50, matchedField: "connectorRef" });
|
|
115
|
+
}
|
|
116
|
+
if (connector.label.toLowerCase().includes(keywordLower)) {
|
|
117
|
+
candidates.push({ score: 50, matchedField: "label" });
|
|
118
|
+
}
|
|
119
|
+
for (const tag of connector.tags) {
|
|
120
|
+
if (skipPrivateIdentifierMatches && tag.includes("_")) continue;
|
|
121
|
+
if (tag.toLowerCase().includes(keywordLower)) {
|
|
122
|
+
candidates.push({ score: 25, matchedField: `tag:${tag}` });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const generationType of connector.generation) {
|
|
126
|
+
if (generationType.toLowerCase().includes(keywordLower)) {
|
|
127
|
+
candidates.push({
|
|
128
|
+
score: 25,
|
|
129
|
+
matchedField: `generation:${generationType}`
|
|
69
130
|
});
|
|
70
131
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
132
|
+
}
|
|
133
|
+
for (const authMethod of connector.authMethods) {
|
|
134
|
+
if (authMethod.id.toLowerCase().includes(keywordLower) || authMethod.label.toLowerCase().includes(keywordLower)) {
|
|
135
|
+
candidates.push({
|
|
136
|
+
score: 20,
|
|
137
|
+
matchedField: `auth-method:${authMethod.id}`
|
|
75
138
|
});
|
|
76
139
|
}
|
|
77
|
-
values[name] = rawValue.slice(separatorIndex + 1);
|
|
78
140
|
}
|
|
79
|
-
|
|
141
|
+
if (connector.category.toLowerCase().includes(keywordLower)) {
|
|
142
|
+
candidates.push({ score: 20, matchedField: "category" });
|
|
143
|
+
}
|
|
144
|
+
if (connector.description.toLowerCase().includes(keywordLower)) {
|
|
145
|
+
candidates.push({ score: 15, matchedField: "description" });
|
|
146
|
+
}
|
|
147
|
+
return best(candidates);
|
|
80
148
|
}
|
|
81
|
-
function
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
149
|
+
function scoreTokens(keywordTokens, connector) {
|
|
150
|
+
const candidateTokens = /* @__PURE__ */ new Set();
|
|
151
|
+
for (const source of publicStrings(connector)) {
|
|
152
|
+
for (const token of tokenize(source)) {
|
|
153
|
+
candidateTokens.add(token);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
let intersection = 0;
|
|
157
|
+
let firstCommon = "";
|
|
158
|
+
for (const token of keywordTokens) {
|
|
159
|
+
if (candidateTokens.has(token)) {
|
|
160
|
+
intersection++;
|
|
161
|
+
if (!firstCommon) firstCommon = token;
|
|
162
|
+
}
|
|
85
163
|
}
|
|
86
|
-
|
|
87
|
-
|
|
164
|
+
if (intersection === 0) return null;
|
|
165
|
+
return { score: 10 * intersection, matchedField: `token:${firstCommon}` };
|
|
166
|
+
}
|
|
167
|
+
function scoreConnector(keywordLower, keyword, keywordTokens, connector) {
|
|
168
|
+
const skipPrivateIdentifierMatches = /^[A-Za-z0-9_]+$/.test(keyword) && keyword.includes("_");
|
|
169
|
+
const tokenHit = skipPrivateIdentifierMatches ? null : scoreTokens(keywordTokens, connector);
|
|
170
|
+
const hit = best([
|
|
171
|
+
scoreExact(keywordLower, skipPrivateIdentifierMatches, connector),
|
|
172
|
+
scoreSubstring(keywordLower, skipPrivateIdentifierMatches, connector),
|
|
173
|
+
tokenHit
|
|
174
|
+
]);
|
|
175
|
+
if (!hit || hit.score < MIN_SCORE) return null;
|
|
176
|
+
return hit;
|
|
177
|
+
}
|
|
178
|
+
function searchPublicConnectorCatalog(connectors, keyword, limit) {
|
|
179
|
+
const trimmed = keyword.trim();
|
|
180
|
+
if (!trimmed) return { results: [], total: 0 };
|
|
181
|
+
const keywordLower = trimmed.toLowerCase();
|
|
182
|
+
const keywordTokens = tokenize(trimmed);
|
|
183
|
+
const hits = connectors.flatMap(
|
|
184
|
+
(connector) => {
|
|
185
|
+
const hit = scoreConnector(
|
|
186
|
+
keywordLower,
|
|
187
|
+
trimmed,
|
|
188
|
+
keywordTokens,
|
|
189
|
+
connector
|
|
190
|
+
);
|
|
191
|
+
if (!hit) return [];
|
|
192
|
+
return [
|
|
193
|
+
{
|
|
194
|
+
connector,
|
|
195
|
+
score: hit.score,
|
|
196
|
+
matchedField: hit.matchedField
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
hits.sort((a, b) => {
|
|
202
|
+
if (b.score !== a.score) return b.score - a.score;
|
|
203
|
+
return a.connector.connectorRef.localeCompare(b.connector.connectorRef);
|
|
88
204
|
});
|
|
205
|
+
return {
|
|
206
|
+
results: hits.slice(0, limit),
|
|
207
|
+
total: hits.length
|
|
208
|
+
};
|
|
89
209
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
return method === rawAuthMethod;
|
|
210
|
+
function findConnectorStatusItem(connectors, connectorRef) {
|
|
211
|
+
const exact = connectors.find((connector) => {
|
|
212
|
+
return connector.connectorRef === connectorRef;
|
|
94
213
|
});
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
214
|
+
if (exact) return exact;
|
|
215
|
+
const lower = connectorRef.toLowerCase();
|
|
216
|
+
return connectors.find((connector) => {
|
|
217
|
+
return connector.connectorRef.toLowerCase() === lower;
|
|
218
|
+
}) ?? null;
|
|
219
|
+
}
|
|
220
|
+
function availableConnectorRefs(connectors) {
|
|
221
|
+
return connectors.map((connector) => {
|
|
222
|
+
return connector.connectorRef;
|
|
223
|
+
}).join(", ");
|
|
224
|
+
}
|
|
225
|
+
function parseConnectorTypeForAction(connectorRef) {
|
|
226
|
+
const parsed = connectorTypeSchema.safeParse(connectorRef);
|
|
227
|
+
if (parsed.success) return parsed.data;
|
|
98
228
|
throw new Error(
|
|
99
|
-
|
|
229
|
+
`Connector ${connectorRef} cannot be used by this CLI action`,
|
|
100
230
|
{
|
|
101
231
|
cause: new Error(
|
|
102
|
-
|
|
232
|
+
"This action still uses the connector action API, which only accepts built-in connector refs."
|
|
103
233
|
)
|
|
104
234
|
}
|
|
105
235
|
);
|
|
106
236
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
237
|
+
function parseConnectorAuthMethodIdForAction(authMethodId) {
|
|
238
|
+
const parsed = connectorAuthMethodIdSchema.safeParse(authMethodId);
|
|
239
|
+
if (parsed.success) return parsed.data;
|
|
240
|
+
throw new Error(
|
|
241
|
+
`Auth method ${authMethodId} cannot be used by this CLI action`,
|
|
242
|
+
{
|
|
243
|
+
cause: new Error(
|
|
244
|
+
"This action still uses the connector action API, which only accepts built-in auth method ids."
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
);
|
|
111
248
|
}
|
|
112
|
-
function
|
|
249
|
+
function resolveManualGrantAuthMethod(connector, rawAuthMethod) {
|
|
113
250
|
if (rawAuthMethod) {
|
|
114
|
-
const authMethod2 =
|
|
115
|
-
|
|
251
|
+
const authMethod2 = connector.authMethods.find((method) => {
|
|
252
|
+
return method.id === rawAuthMethod;
|
|
253
|
+
});
|
|
254
|
+
if (!authMethod2) {
|
|
255
|
+
throw new Error(
|
|
256
|
+
`${connector.connectorRef} connector does not have ${rawAuthMethod} auth method`,
|
|
257
|
+
{
|
|
258
|
+
cause: new Error(
|
|
259
|
+
`Available auth methods: ${connector.authMethods.map((method) => {
|
|
260
|
+
return method.id;
|
|
261
|
+
}).join(", ")}`
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
if (authMethod2.grantKind === "manual") {
|
|
116
267
|
return authMethod2;
|
|
117
268
|
}
|
|
118
269
|
throw new Error(
|
|
119
|
-
`${
|
|
270
|
+
`${connector.connectorRef} ${authMethod2.id} auth method does not use a manual grant`
|
|
120
271
|
);
|
|
121
272
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
273
|
+
const manualAuthMethods = connector.authMethods.filter((method) => {
|
|
274
|
+
return method.grantKind === "manual";
|
|
275
|
+
});
|
|
276
|
+
const authMethod = manualAuthMethods[0];
|
|
277
|
+
if (manualAuthMethods.length === 1 && authMethod) {
|
|
125
278
|
return authMethod;
|
|
126
279
|
}
|
|
127
|
-
if (
|
|
128
|
-
throw new Error(
|
|
280
|
+
if (manualAuthMethods.length === 0) {
|
|
281
|
+
throw new Error(
|
|
282
|
+
`${connector.connectorRef} connector does not use a manual grant`
|
|
283
|
+
);
|
|
129
284
|
}
|
|
130
|
-
throw new Error(
|
|
131
|
-
|
|
132
|
-
|
|
285
|
+
throw new Error(
|
|
286
|
+
`${connector.connectorRef} connector has multiple manual grant auth methods`,
|
|
287
|
+
{
|
|
288
|
+
cause: new Error(
|
|
289
|
+
`Pass --auth-method ${manualAuthMethods.map((method) => {
|
|
290
|
+
return method.id;
|
|
291
|
+
}).join("|")}`
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/commands/zero/connector/connect.ts
|
|
298
|
+
function collectValue(value, previous) {
|
|
299
|
+
return [...previous, value];
|
|
300
|
+
}
|
|
301
|
+
function parseConnectorValues(rawValues) {
|
|
302
|
+
if (!rawValues || rawValues.length === 0) {
|
|
303
|
+
throw new Error("At least one --value NAME=VALUE is required", {
|
|
304
|
+
cause: new Error(
|
|
305
|
+
"Example: zero connector connect zendesk --value apiToken=token"
|
|
306
|
+
)
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const values = {};
|
|
310
|
+
for (const rawValue of rawValues) {
|
|
311
|
+
const separatorIndex = rawValue.indexOf("=");
|
|
312
|
+
if (separatorIndex <= 0) {
|
|
313
|
+
throw new Error("Invalid --value format", {
|
|
314
|
+
cause: new Error("Use --value NAME=VALUE")
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
const name = rawValue.slice(0, separatorIndex);
|
|
318
|
+
if (!name.trim()) {
|
|
319
|
+
throw new Error("Invalid --value format", {
|
|
320
|
+
cause: new Error("Field name cannot be empty")
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
values[name] = rawValue.slice(separatorIndex + 1);
|
|
324
|
+
}
|
|
325
|
+
return values;
|
|
133
326
|
}
|
|
134
327
|
var connectCommand = new Command().name("connect").description("Connect a connector with manual grant values").argument("<type>", "Connector type (e.g., zendesk)").option("--auth-method <method>", "Connector auth method to use").option(
|
|
135
328
|
"--value <name=value>",
|
|
@@ -138,23 +331,36 @@ var connectCommand = new Command().name("connect").description("Connect a connec
|
|
|
138
331
|
[]
|
|
139
332
|
).option("--json", "Print the connector response as JSON").action(
|
|
140
333
|
withErrorHandler(async (type, options) => {
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
334
|
+
const values = parseConnectorValues(options.value);
|
|
335
|
+
const catalog = await listZeroConnectorCatalogStatus();
|
|
336
|
+
const connectorMetadata = findConnectorStatusItem(
|
|
337
|
+
catalog.connectors,
|
|
338
|
+
type
|
|
339
|
+
);
|
|
340
|
+
if (!connectorMetadata) {
|
|
341
|
+
throw new Error(`Unknown or unavailable connector: ${type}`, {
|
|
342
|
+
cause: new Error(
|
|
343
|
+
`Available connectors: ${availableConnectorRefs(catalog.connectors)}`
|
|
344
|
+
)
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
const connectorType = parseConnectorTypeForAction(
|
|
348
|
+
connectorMetadata.connectorRef
|
|
349
|
+
);
|
|
350
|
+
const authMethod = resolveManualGrantAuthMethod(
|
|
351
|
+
connectorMetadata,
|
|
144
352
|
options.authMethod
|
|
145
353
|
);
|
|
146
354
|
const connector = await connectZeroConnectorManualGrant(
|
|
147
355
|
connectorType,
|
|
148
|
-
authMethod,
|
|
149
|
-
|
|
356
|
+
parseConnectorAuthMethodIdForAction(authMethod.id),
|
|
357
|
+
values
|
|
150
358
|
);
|
|
151
359
|
if (options.json) {
|
|
152
360
|
console.log(JSON.stringify(connector, null, 2));
|
|
153
361
|
return;
|
|
154
362
|
}
|
|
155
|
-
console.log(
|
|
156
|
-
source_default.green(`\u2713 ${CONNECTOR_TYPES[connectorType].label} connected`)
|
|
157
|
-
);
|
|
363
|
+
console.log(source_default.green(`\u2713 ${connectorMetadata.label} connected`));
|
|
158
364
|
console.log(source_default.dim(` Type: ${connector.type}`));
|
|
159
365
|
console.log(source_default.dim(` Auth Method: ${connector.authMethod}`));
|
|
160
366
|
console.log(source_default.dim(` Run: zero connector status ${connector.type}`));
|
|
@@ -183,22 +389,22 @@ async function resolveAgentContext(flagAgentId) {
|
|
|
183
389
|
// src/commands/zero/connector/connected-as.ts
|
|
184
390
|
init_esm_shims();
|
|
185
391
|
function renderIdentity(connector) {
|
|
186
|
-
if (connector.externalUsername)
|
|
187
|
-
|
|
392
|
+
if (connector.connection?.externalUsername) {
|
|
393
|
+
return `@${connector.connection.externalUsername}`;
|
|
394
|
+
}
|
|
395
|
+
if (connector.connection?.externalEmail)
|
|
396
|
+
return connector.connection.externalEmail;
|
|
188
397
|
return "-";
|
|
189
398
|
}
|
|
190
399
|
function renderConnectedAsCell(connector) {
|
|
191
|
-
if (!connector
|
|
400
|
+
if (!connector || connector.connectionStatus === "not-connected") {
|
|
401
|
+
return source_default.dim("(not connected)");
|
|
402
|
+
}
|
|
192
403
|
const identity = renderIdentity(connector);
|
|
193
404
|
if (connector.connectionStatus === "reconnect-required") {
|
|
194
405
|
return source_default.yellow(`${identity} (reconnect needed)`);
|
|
195
406
|
}
|
|
196
|
-
|
|
197
|
-
connector.type,
|
|
198
|
-
connector.authMethod,
|
|
199
|
-
connector.oauthScopes
|
|
200
|
-
);
|
|
201
|
-
if (scopeMismatch) {
|
|
407
|
+
if (connector.scopeMismatch || connector.connectionStatus === "scope-mismatch") {
|
|
202
408
|
return source_default.yellow(`${identity} (permissions update available)`);
|
|
203
409
|
}
|
|
204
410
|
return identity;
|
|
@@ -214,24 +420,15 @@ function padEndAnsi(s, width) {
|
|
|
214
420
|
}
|
|
215
421
|
|
|
216
422
|
// src/commands/zero/connector/list.ts
|
|
217
|
-
function isConnectorType(type) {
|
|
218
|
-
return type in CONNECTOR_TYPES;
|
|
219
|
-
}
|
|
220
423
|
var listCommand = new Command().name("list").alias("ls").description("List all connectors and their status").option("--agent <id>", "Show per-agent authorization column").action(
|
|
221
424
|
withErrorHandler(async (options) => {
|
|
222
|
-
const [{ connectors },
|
|
223
|
-
|
|
224
|
-
searchZeroConnectors(),
|
|
425
|
+
const [{ connectors }, agentCtx] = await Promise.all([
|
|
426
|
+
listZeroConnectorCatalogStatus(),
|
|
225
427
|
resolveAgentContext(options.agent)
|
|
226
428
|
]);
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
})
|
|
231
|
-
);
|
|
232
|
-
const allTypes = availableCatalog.connectors.map((connector) => {
|
|
233
|
-
return connector.id;
|
|
234
|
-
}).filter(isConnectorType);
|
|
429
|
+
const allTypes = connectors.map((connector) => {
|
|
430
|
+
return connector.connectorRef;
|
|
431
|
+
});
|
|
235
432
|
const typeWidth = Math.max(
|
|
236
433
|
4,
|
|
237
434
|
...allTypes.map((t) => {
|
|
@@ -239,8 +436,8 @@ var listCommand = new Command().name("list").alias("ls").description("List all c
|
|
|
239
436
|
})
|
|
240
437
|
);
|
|
241
438
|
const connectedAsHeader = "CONNECTED AS";
|
|
242
|
-
const connectedCells =
|
|
243
|
-
return renderConnectedAsCell(
|
|
439
|
+
const connectedCells = connectors.map((connector) => {
|
|
440
|
+
return renderConnectedAsCell(connector);
|
|
244
441
|
});
|
|
245
442
|
const connectedAsWidth = Math.max(
|
|
246
443
|
connectedAsHeader.length,
|
|
@@ -271,189 +468,18 @@ var listCommand = new Command().name("list").alias("ls").description("List all c
|
|
|
271
468
|
|
|
272
469
|
// src/commands/zero/connector/search.ts
|
|
273
470
|
init_esm_shims();
|
|
274
|
-
|
|
275
|
-
// ../../packages/connectors/src/connector-search.ts
|
|
276
|
-
init_esm_shims();
|
|
277
|
-
var TOKEN_BOUNDARY = /[_\-\s]+/;
|
|
278
|
-
var CASE_BOUNDARY = /(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/;
|
|
279
|
-
var MIN_SCORE = 10;
|
|
280
|
-
function tokenize(input) {
|
|
281
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
282
|
-
for (const chunk of input.split(TOKEN_BOUNDARY)) {
|
|
283
|
-
if (!chunk) continue;
|
|
284
|
-
for (const sub of chunk.split(CASE_BOUNDARY)) {
|
|
285
|
-
const lower = sub.toLowerCase();
|
|
286
|
-
if (lower) tokens.add(lower);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return tokens;
|
|
290
|
-
}
|
|
291
|
-
function connectorAccessEnvBindings(access) {
|
|
292
|
-
switch (access.kind) {
|
|
293
|
-
case "static":
|
|
294
|
-
case "refresh-token":
|
|
295
|
-
return access.envBindings;
|
|
296
|
-
case "none":
|
|
297
|
-
return {};
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function getManualGrantFields(method) {
|
|
301
|
-
return method.grant.kind === "manual" ? method.grant.fields : void 0;
|
|
302
|
-
}
|
|
303
|
-
function connectorEnvBindingValueRef(value) {
|
|
304
|
-
return typeof value === "string" ? value : value.valueRef;
|
|
305
|
-
}
|
|
306
|
-
function listSecretNames(config) {
|
|
307
|
-
const names = [];
|
|
308
|
-
for (const method of Object.values(config.authMethods)) {
|
|
309
|
-
for (const name of Object.keys(getManualGrantFields(method) ?? {})) {
|
|
310
|
-
names.push(name);
|
|
311
|
-
}
|
|
312
|
-
for (const valueRef of Object.values(
|
|
313
|
-
connectorAccessEnvBindings(method.access)
|
|
314
|
-
)) {
|
|
315
|
-
const ref = connectorEnvBindingValueRef(valueRef);
|
|
316
|
-
if (ref.startsWith("$secrets.")) {
|
|
317
|
-
names.push(ref.slice("$secrets.".length));
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return names;
|
|
322
|
-
}
|
|
323
|
-
function listEnvNames(type) {
|
|
324
|
-
return [
|
|
325
|
-
...new Set(
|
|
326
|
-
getConnectorEnvBindingEntries(type).map(({ envName }) => {
|
|
327
|
-
return envName;
|
|
328
|
-
})
|
|
329
|
-
)
|
|
330
|
-
];
|
|
331
|
-
}
|
|
332
|
-
function findExactMatch(keywordLower, type, config) {
|
|
333
|
-
if (type.toLowerCase() === keywordLower) {
|
|
334
|
-
return { score: 100, matchedField: "type" };
|
|
335
|
-
}
|
|
336
|
-
for (const envName of listEnvNames(type)) {
|
|
337
|
-
if (envName.toLowerCase() === keywordLower) {
|
|
338
|
-
return { score: 90, matchedField: `env:${envName}` };
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
if (config.label.toLowerCase() === keywordLower) {
|
|
342
|
-
return { score: 80, matchedField: "label" };
|
|
343
|
-
}
|
|
344
|
-
const tags = config.tags ?? [];
|
|
345
|
-
for (const tag of tags) {
|
|
346
|
-
if (tag === keywordLower) {
|
|
347
|
-
return { score: 70, matchedField: `tag:${tag}` };
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
function findSubstringMatch(keywordLower, type, config) {
|
|
353
|
-
if (type.toLowerCase().includes(keywordLower)) {
|
|
354
|
-
return { score: 50, matchedField: "type" };
|
|
355
|
-
}
|
|
356
|
-
if (config.label.toLowerCase().includes(keywordLower)) {
|
|
357
|
-
return { score: 50, matchedField: "label" };
|
|
358
|
-
}
|
|
359
|
-
for (const envName of listEnvNames(type)) {
|
|
360
|
-
if (envName.toLowerCase().includes(keywordLower)) {
|
|
361
|
-
return { score: 40, matchedField: `env:${envName}` };
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
for (const name of listSecretNames(config)) {
|
|
365
|
-
if (name.toLowerCase().includes(keywordLower)) {
|
|
366
|
-
return { score: 30, matchedField: `secret:${name}` };
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
const tags = config.tags ?? [];
|
|
370
|
-
for (const tag of tags) {
|
|
371
|
-
if (tag.includes(keywordLower)) {
|
|
372
|
-
return { score: 25, matchedField: `tag:${tag}` };
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
function collectCandidateTokens(type, config) {
|
|
378
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
379
|
-
const sources = [
|
|
380
|
-
type,
|
|
381
|
-
config.label,
|
|
382
|
-
...listEnvNames(type),
|
|
383
|
-
...listSecretNames(config),
|
|
384
|
-
...config.tags ?? []
|
|
385
|
-
];
|
|
386
|
-
for (const source of sources) {
|
|
387
|
-
for (const token of tokenize(source)) {
|
|
388
|
-
tokens.add(token);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return tokens;
|
|
392
|
-
}
|
|
393
|
-
function findTokenIntersection(keywordTokens, type, config) {
|
|
394
|
-
const candidateTokens = collectCandidateTokens(type, config);
|
|
395
|
-
let intersection = 0;
|
|
396
|
-
let firstCommon = "";
|
|
397
|
-
for (const token of keywordTokens) {
|
|
398
|
-
if (candidateTokens.has(token)) {
|
|
399
|
-
intersection++;
|
|
400
|
-
if (!firstCommon) firstCommon = token;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
if (intersection === 0) return null;
|
|
404
|
-
return { score: 10 * intersection, matchedField: `token:${firstCommon}` };
|
|
405
|
-
}
|
|
406
|
-
function scoreConnector(keywordLower, keywordTokens, type, config) {
|
|
407
|
-
const exact = findExactMatch(keywordLower, type, config);
|
|
408
|
-
if (exact) return exact;
|
|
409
|
-
const candidates = [];
|
|
410
|
-
const substring = findSubstringMatch(keywordLower, type, config);
|
|
411
|
-
if (substring) candidates.push(substring);
|
|
412
|
-
const token = findTokenIntersection(keywordTokens, type, config);
|
|
413
|
-
if (token) candidates.push(token);
|
|
414
|
-
if (candidates.length === 0) return null;
|
|
415
|
-
const best = candidates.reduce((a, b) => {
|
|
416
|
-
return a.score >= b.score ? a : b;
|
|
417
|
-
});
|
|
418
|
-
if (best.score < MIN_SCORE) return null;
|
|
419
|
-
return best;
|
|
420
|
-
}
|
|
421
|
-
function searchConnectors(keyword, limit, filter) {
|
|
422
|
-
const trimmed = keyword.trim();
|
|
423
|
-
if (!trimmed) return { results: [], total: 0 };
|
|
424
|
-
const keywordLower = trimmed.toLowerCase();
|
|
425
|
-
const keywordTokens = tokenize(trimmed);
|
|
426
|
-
const hits = [];
|
|
427
|
-
for (const type of CONNECTOR_TYPE_KEYS) {
|
|
428
|
-
if (filter && !filter(type)) continue;
|
|
429
|
-
const config = CONNECTOR_TYPES[type];
|
|
430
|
-
const hit = scoreConnector(keywordLower, keywordTokens, type, config);
|
|
431
|
-
if (!hit) continue;
|
|
432
|
-
hits.push({ type, score: hit.score, matchedField: hit.matchedField });
|
|
433
|
-
}
|
|
434
|
-
hits.sort((a, b) => {
|
|
435
|
-
if (b.score !== a.score) return b.score - a.score;
|
|
436
|
-
return a.type.localeCompare(b.type);
|
|
437
|
-
});
|
|
438
|
-
const capped = limit > 0 ? hits.slice(0, limit) : hits;
|
|
439
|
-
return { results: capped, total: hits.length };
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// src/commands/zero/connector/search.ts
|
|
443
471
|
var DEFAULT_LIMIT = 5;
|
|
444
472
|
var EXACT_MATCH_THRESHOLD = 80;
|
|
445
|
-
function isConnectorType2(type) {
|
|
446
|
-
return type in CONNECTOR_TYPES;
|
|
447
|
-
}
|
|
448
473
|
function parseLimit(raw) {
|
|
449
|
-
const
|
|
450
|
-
|
|
474
|
+
const trimmed = raw.trim();
|
|
475
|
+
const n = Number(trimmed);
|
|
476
|
+
if (!/^\d+$/.test(trimmed) || !Number.isSafeInteger(n) || n <= 0) {
|
|
451
477
|
throw new Error(`--limit must be a positive integer, got "${raw}".`);
|
|
452
478
|
}
|
|
453
479
|
return n;
|
|
454
480
|
}
|
|
455
481
|
var searchCommand = new Command().name("search").description(
|
|
456
|
-
"Search connectors by type, label,
|
|
482
|
+
"Search connectors by type, label, category, generation type, or tag"
|
|
457
483
|
).argument("<keyword>", "Search keyword (case-insensitive)").option("--agent <id>", "Show per-agent authorization column").option(
|
|
458
484
|
"--limit <n>",
|
|
459
485
|
`Maximum number of results to display (default ${DEFAULT_LIMIT})`,
|
|
@@ -466,27 +492,14 @@ var searchCommand = new Command().name("search").description(
|
|
|
466
492
|
if (!trimmed) {
|
|
467
493
|
throw new Error("Keyword cannot be empty.");
|
|
468
494
|
}
|
|
469
|
-
const [{ connectors },
|
|
470
|
-
|
|
471
|
-
searchZeroConnectors(),
|
|
495
|
+
const [{ connectors }, agentCtx] = await Promise.all([
|
|
496
|
+
listZeroConnectorCatalogStatus(),
|
|
472
497
|
resolveAgentContext(options.agent)
|
|
473
498
|
]);
|
|
474
|
-
const
|
|
475
|
-
connectors
|
|
476
|
-
return [c.type, c];
|
|
477
|
-
})
|
|
478
|
-
);
|
|
479
|
-
const availableTypes = new Set(
|
|
480
|
-
availableCatalog.connectors.map((connector) => {
|
|
481
|
-
return connector.id;
|
|
482
|
-
}).filter(isConnectorType2)
|
|
483
|
-
);
|
|
484
|
-
const { results, total } = searchConnectors(
|
|
499
|
+
const { results, total } = searchPublicConnectorCatalog(
|
|
500
|
+
connectors,
|
|
485
501
|
trimmed,
|
|
486
|
-
options.limit
|
|
487
|
-
(type) => {
|
|
488
|
-
return availableTypes.has(type);
|
|
489
|
-
}
|
|
502
|
+
options.limit
|
|
490
503
|
);
|
|
491
504
|
if (results.length === 0) {
|
|
492
505
|
console.log("No matches found.");
|
|
@@ -502,12 +515,12 @@ var searchCommand = new Command().name("search").description(
|
|
|
502
515
|
const typeHeader = "TYPE";
|
|
503
516
|
const connectedAsHeader = "CONNECTED AS";
|
|
504
517
|
const connectedCells = results.map((r) => {
|
|
505
|
-
return renderConnectedAsCell(
|
|
518
|
+
return renderConnectedAsCell(r.connector);
|
|
506
519
|
});
|
|
507
520
|
const typeWidth = Math.max(
|
|
508
521
|
typeHeader.length,
|
|
509
522
|
...results.map((r) => {
|
|
510
|
-
return r.
|
|
523
|
+
return r.connector.connectorRef.length;
|
|
511
524
|
})
|
|
512
525
|
);
|
|
513
526
|
const connectedAsWidth = Math.max(
|
|
@@ -527,12 +540,12 @@ var searchCommand = new Command().name("search").description(
|
|
|
527
540
|
for (let i = 0; i < results.length; i++) {
|
|
528
541
|
const result = results[i];
|
|
529
542
|
const parts = [
|
|
530
|
-
result.
|
|
543
|
+
result.connector.connectorRef.padEnd(typeWidth),
|
|
531
544
|
padEndAnsi(connectedCells[i], connectedAsWidth)
|
|
532
545
|
];
|
|
533
546
|
if (agentCtx) {
|
|
534
547
|
parts.push(
|
|
535
|
-
agentCtx.authorizedTypes.has(result.
|
|
548
|
+
agentCtx.authorizedTypes.has(result.connector.connectorRef) ? source_default.green("\u2713") : source_default.dim("-")
|
|
536
549
|
);
|
|
537
550
|
}
|
|
538
551
|
console.log(parts.join(" "));
|
|
@@ -544,149 +557,123 @@ var searchCommand = new Command().name("search").description(
|
|
|
544
557
|
// src/commands/zero/connector/status.ts
|
|
545
558
|
init_esm_shims();
|
|
546
559
|
var LABEL_WIDTH = 16;
|
|
547
|
-
function
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}).
|
|
560
|
+
function printConnectorDetails(connector) {
|
|
561
|
+
if (connector.connectionStatus === "not-connected") {
|
|
562
|
+
console.log(
|
|
563
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${source_default.dim("not connected")}`
|
|
564
|
+
);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
console.log(
|
|
568
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${connector.connectionStatus === "reconnect-required" ? source_default.yellow("reconnect needed") : source_default.green("connected")}`
|
|
556
569
|
);
|
|
557
|
-
|
|
558
|
-
function printConnectorDetails(type, connector) {
|
|
559
|
-
if (connector) {
|
|
570
|
+
if (connector.connection?.externalUsername) {
|
|
560
571
|
console.log(
|
|
561
|
-
`${"
|
|
572
|
+
`${"Account:".padEnd(LABEL_WIDTH)}@${connector.connection.externalUsername}`
|
|
562
573
|
);
|
|
574
|
+
} else if (connector.connection?.externalEmail) {
|
|
563
575
|
console.log(
|
|
564
|
-
`${"Account:".padEnd(LABEL_WIDTH)}
|
|
576
|
+
`${"Account:".padEnd(LABEL_WIDTH)}${connector.connection.externalEmail}`
|
|
565
577
|
);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
console.log(
|
|
569
|
-
`${"OAuth Scopes:".padEnd(LABEL_WIDTH)}${connector.oauthScopes.join(", ")}`
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
if (!hasRequiredConnectorAuthMethodScopes(
|
|
573
|
-
type,
|
|
574
|
-
connector.authMethod,
|
|
575
|
-
connector.oauthScopes
|
|
576
|
-
)) {
|
|
577
|
-
const diff = getConnectorAuthMethodScopeDiff(
|
|
578
|
-
type,
|
|
579
|
-
connector.authMethod,
|
|
580
|
-
connector.oauthScopes
|
|
581
|
-
);
|
|
582
|
-
console.log(
|
|
583
|
-
`${"Permissions:".padEnd(LABEL_WIDTH)}${source_default.yellow("update available")}`
|
|
584
|
-
);
|
|
585
|
-
if (diff.addedScopes.length > 0) {
|
|
586
|
-
console.log(
|
|
587
|
-
`${" Added:".padEnd(LABEL_WIDTH)}${diff.addedScopes.join(", ")}`
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
if (diff.removedScopes.length > 0) {
|
|
591
|
-
console.log(
|
|
592
|
-
`${" Removed:".padEnd(LABEL_WIDTH)}${diff.removedScopes.join(", ")}`
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
578
|
+
}
|
|
579
|
+
if (connector.connection?.authMethod) {
|
|
596
580
|
console.log(
|
|
597
|
-
`${"
|
|
581
|
+
`${"Auth Method:".padEnd(LABEL_WIDTH)}${connector.connection.authMethod}`
|
|
598
582
|
);
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
`${"Last Updated:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.updatedAt)}`
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
} else {
|
|
583
|
+
}
|
|
584
|
+
if (connector.scopeMismatch) {
|
|
605
585
|
console.log(
|
|
606
|
-
`${"
|
|
586
|
+
`${"Permissions:".padEnd(LABEL_WIDTH)}${source_default.yellow("update available")}`
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
if (connector.tokenExpiresAt) {
|
|
590
|
+
console.log(
|
|
591
|
+
`${"Token Expires:".padEnd(LABEL_WIDTH)}${connector.tokenExpiresAt}`
|
|
607
592
|
);
|
|
608
593
|
}
|
|
609
594
|
}
|
|
610
|
-
async function printAgentAction(
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
const
|
|
595
|
+
async function printAgentAction(connector, agentCtx) {
|
|
596
|
+
const connectorRef = connector.connectorRef;
|
|
597
|
+
const authorized = agentCtx.authorizedTypes.has(connectorRef);
|
|
598
|
+
const isConnected = connector.connected;
|
|
599
|
+
const needsReconnect = connector.connectionStatus === "reconnect-required";
|
|
614
600
|
const agentLabel = agentCtx.displayName === agentCtx.agentId ? agentCtx.agentId : `${agentCtx.displayName} (${agentCtx.agentId})`;
|
|
615
601
|
console.log();
|
|
616
602
|
if (needsReconnect) {
|
|
617
603
|
const origin = await getPlatformOrigin();
|
|
618
604
|
const url = `${origin}/connectors`;
|
|
619
605
|
console.log(
|
|
620
|
-
`The ${
|
|
606
|
+
`The ${connectorRef} connector is connected but needs to be reconnected before agent ${agentLabel} can use it.`
|
|
621
607
|
);
|
|
622
|
-
console.log(`Reconnect it at: [Reconnect ${
|
|
608
|
+
console.log(`Reconnect it at: [Reconnect ${connectorRef}](${url})`);
|
|
623
609
|
} else if (authorized && !isConnected) {
|
|
624
610
|
const origin = await getPlatformOrigin();
|
|
625
|
-
const url = `${origin}/connectors/${
|
|
611
|
+
const url = `${origin}/connectors/${connectorRef}/connect?agentId=${agentCtx.agentId}`;
|
|
626
612
|
console.log(
|
|
627
|
-
`The ${
|
|
613
|
+
`The ${connectorRef} connector is authorized for agent ${agentLabel}, but it is not connected.`
|
|
628
614
|
);
|
|
629
|
-
console.log(`Connect it at: [Connect ${
|
|
615
|
+
console.log(`Connect it at: [Connect ${connectorRef}](${url})`);
|
|
630
616
|
} else if (authorized) {
|
|
631
|
-
console.log(
|
|
617
|
+
console.log(
|
|
618
|
+
`The ${connectorRef} connector is authorized for agent ${agentLabel}.`
|
|
619
|
+
);
|
|
632
620
|
} else if (!isConnected) {
|
|
633
621
|
const origin = await getPlatformOrigin();
|
|
634
|
-
const url = `${origin}/connectors/${
|
|
622
|
+
const url = `${origin}/connectors/${connectorRef}/connect?agentId=${agentCtx.agentId}`;
|
|
623
|
+
console.log(
|
|
624
|
+
`The ${connectorRef} connector is not connected. Once connected, it will be authorized for agent ${agentLabel}.`
|
|
625
|
+
);
|
|
635
626
|
console.log(
|
|
636
|
-
`
|
|
627
|
+
`Connect and authorize it at: [Connect ${connectorRef}](${url})`
|
|
637
628
|
);
|
|
638
|
-
console.log(`Connect and authorize it at: [Connect ${type}](${url})`);
|
|
639
629
|
} else {
|
|
640
630
|
const origin = await getPlatformOrigin();
|
|
641
|
-
const url = `${origin}/connectors/${
|
|
631
|
+
const url = `${origin}/connectors/${connectorRef}/authorize?agentId=${agentCtx.agentId}`;
|
|
642
632
|
console.log(
|
|
643
|
-
`The ${
|
|
633
|
+
`The ${connectorRef} connector is not authorized for agent ${agentLabel}.`
|
|
644
634
|
);
|
|
645
|
-
console.log(`Authorize it at: [Authorize ${
|
|
635
|
+
console.log(`Authorize it at: [Authorize ${connectorRef}](${url})`);
|
|
646
636
|
}
|
|
647
637
|
}
|
|
648
|
-
async function printStandaloneAction(
|
|
649
|
-
|
|
638
|
+
async function printStandaloneAction(connector) {
|
|
639
|
+
const connectorRef = connector.connectorRef;
|
|
640
|
+
if (connector.connectionStatus === "connected" || connector.connectionStatus === "scope-mismatch") {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
650
643
|
const origin = await getPlatformOrigin();
|
|
651
644
|
console.log();
|
|
652
|
-
if (connector
|
|
645
|
+
if (connector.connectionStatus === "reconnect-required") {
|
|
653
646
|
const url = `${origin}/connectors`;
|
|
654
647
|
console.log(
|
|
655
|
-
`The ${
|
|
648
|
+
`The ${connectorRef} connector is connected but needs to be reconnected.`
|
|
656
649
|
);
|
|
657
|
-
console.log(`Reconnect it at: [Reconnect ${
|
|
650
|
+
console.log(`Reconnect it at: [Reconnect ${connectorRef}](${url})`);
|
|
658
651
|
} else {
|
|
659
|
-
const url = `${origin}/connectors/${
|
|
660
|
-
console.log(`Connect it at: [Connect ${
|
|
652
|
+
const url = `${origin}/connectors/${connectorRef}/connect`;
|
|
653
|
+
console.log(`Connect it at: [Connect ${connectorRef}](${url})`);
|
|
661
654
|
}
|
|
662
655
|
}
|
|
663
656
|
var statusCommand = new Command().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").option("--agent <id>", "Show authorization state for the given agent").action(
|
|
664
657
|
withErrorHandler(async (type, options) => {
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
const available2 = CONNECTOR_TYPE_KEYS.join(", ");
|
|
668
|
-
throw new Error(`Unknown connector type: ${type}`, {
|
|
669
|
-
cause: new Error(`Available connectors: ${available2}`)
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
|
-
const [connector, availableTypes, agentCtx] = await Promise.all([
|
|
673
|
-
getZeroConnector(parseResult.data),
|
|
674
|
-
availableConnectorTypes(),
|
|
658
|
+
const [catalog, agentCtx] = await Promise.all([
|
|
659
|
+
listZeroConnectorCatalogStatus(),
|
|
675
660
|
resolveAgentContext(options.agent)
|
|
676
661
|
]);
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
return;
|
|
662
|
+
const connector = findConnectorStatusItem(catalog.connectors, type);
|
|
663
|
+
if (!connector) {
|
|
664
|
+
throw new Error(`Unknown or unavailable connector: ${type}`, {
|
|
665
|
+
cause: new Error(
|
|
666
|
+
`Available connectors: ${availableConnectorRefs(catalog.connectors)}`
|
|
667
|
+
)
|
|
668
|
+
});
|
|
685
669
|
}
|
|
670
|
+
console.log(`Connector: ${source_default.cyan(connector.connectorRef)}`);
|
|
671
|
+
console.log();
|
|
672
|
+
printConnectorDetails(connector);
|
|
686
673
|
if (agentCtx) {
|
|
687
|
-
await printAgentAction(
|
|
674
|
+
await printAgentAction(connector, agentCtx);
|
|
688
675
|
} else {
|
|
689
|
-
await printStandaloneAction(
|
|
676
|
+
await printStandaloneAction(connector);
|
|
690
677
|
}
|
|
691
678
|
})
|
|
692
679
|
);
|
|
@@ -845,4 +832,4 @@ var zeroConnectorCommand = new Command().name("connector").description("Check th
|
|
|
845
832
|
export {
|
|
846
833
|
zeroConnectorCommand
|
|
847
834
|
};
|
|
848
|
-
//# sourceMappingURL=connector-
|
|
835
|
+
//# sourceMappingURL=connector-YJX3MZGN.js.map
|