@docyrus/docyrus 0.0.13 → 0.0.14
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/main.js +99 -14
- package/main.js.map +2 -2
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -124678,7 +124678,7 @@ function buildInputSchema(args, env2, options2) {
|
|
|
124678
124678
|
// package.json
|
|
124679
124679
|
var package_default = {
|
|
124680
124680
|
name: "@docyrus/docyrus",
|
|
124681
|
-
version: "0.0.
|
|
124681
|
+
version: "0.0.14",
|
|
124682
124682
|
private: false,
|
|
124683
124683
|
description: "Docyrus API CLI",
|
|
124684
124684
|
main: "./main.js",
|
|
@@ -125214,6 +125214,49 @@ async function resolveTenantIdSelector(params) {
|
|
|
125214
125214
|
}
|
|
125215
125215
|
return selector;
|
|
125216
125216
|
}
|
|
125217
|
+
async function resolveClientId(params) {
|
|
125218
|
+
const envClientId = getOptionalEnvValue(params.env, "DOCYRUS_API_CLIENT_ID");
|
|
125219
|
+
const configuredClientId = await params.environmentConfigService.getDefaultClientId();
|
|
125220
|
+
const globalConfiguredClientId = configuredClientId ? void 0 : await params.globalEnvironmentConfigService?.getDefaultClientId();
|
|
125221
|
+
const resolvedClientId = params.requestedClientId || envClientId || configuredClientId || globalConfiguredClientId;
|
|
125222
|
+
return {
|
|
125223
|
+
configuredClientId,
|
|
125224
|
+
globalConfiguredClientId,
|
|
125225
|
+
resolvedClientId,
|
|
125226
|
+
clientId: resolvedClientId || (params.allowManualFallback ? "manual-token" : void 0)
|
|
125227
|
+
};
|
|
125228
|
+
}
|
|
125229
|
+
async function loginWithManualTokens(params) {
|
|
125230
|
+
const manualAccessToken = params.accessToken.trim();
|
|
125231
|
+
const manualRefreshToken = params.refreshToken?.trim();
|
|
125232
|
+
if (!manualAccessToken) {
|
|
125233
|
+
throw new UserInputError("accessToken is required.");
|
|
125234
|
+
}
|
|
125235
|
+
const resolvedClient = await resolveClientId({
|
|
125236
|
+
requestedClientId: params.clientId,
|
|
125237
|
+
env: params.env,
|
|
125238
|
+
environmentConfigService: params.dependencies.environmentConfigService,
|
|
125239
|
+
globalEnvironmentConfigService: params.dependencies.globalEnvironmentConfigService,
|
|
125240
|
+
allowManualFallback: true
|
|
125241
|
+
});
|
|
125242
|
+
if (!resolvedClient.clientId) {
|
|
125243
|
+
throw new UserInputError(
|
|
125244
|
+
"Client ID is required. Pass --clientId, set DOCYRUS_API_CLIENT_ID, or login once with --clientId to save it."
|
|
125245
|
+
);
|
|
125246
|
+
}
|
|
125247
|
+
const authSessionService = params.dependencies.createAuthSessionService(params.apiBaseUrl);
|
|
125248
|
+
const profile = await authSessionService.loginWithManualTokens({
|
|
125249
|
+
clientId: resolvedClient.clientId,
|
|
125250
|
+
accessToken: manualAccessToken,
|
|
125251
|
+
refreshToken: manualRefreshToken || void 0,
|
|
125252
|
+
scope: params.scope,
|
|
125253
|
+
tokenType: "Bearer"
|
|
125254
|
+
});
|
|
125255
|
+
if (resolvedClient.resolvedClientId) {
|
|
125256
|
+
await params.dependencies.environmentConfigService.setDefaultClientId(resolvedClient.resolvedClientId);
|
|
125257
|
+
}
|
|
125258
|
+
return profile;
|
|
125259
|
+
}
|
|
125217
125260
|
function createAuthCli(dependencies) {
|
|
125218
125261
|
const authCli = Cli_exports.create("auth", {
|
|
125219
125262
|
description: "Authentication commands",
|
|
@@ -125234,32 +125277,36 @@ function createAuthCli(dependencies) {
|
|
|
125234
125277
|
if (manualRefreshToken && !manualAccessToken) {
|
|
125235
125278
|
throw new UserInputError("refreshToken requires accessToken. Pass --accessToken when using --refreshToken.");
|
|
125236
125279
|
}
|
|
125237
|
-
const
|
|
125238
|
-
|
|
125239
|
-
|
|
125240
|
-
|
|
125241
|
-
|
|
125280
|
+
const resolvedClient = await resolveClientId({
|
|
125281
|
+
requestedClientId: context.options.clientId,
|
|
125282
|
+
env: context.env,
|
|
125283
|
+
environmentConfigService: dependencies.environmentConfigService,
|
|
125284
|
+
globalEnvironmentConfigService: dependencies.globalEnvironmentConfigService,
|
|
125285
|
+
allowManualFallback: Boolean(manualAccessToken)
|
|
125286
|
+
});
|
|
125287
|
+
const clientId = resolvedClient.clientId;
|
|
125242
125288
|
if (!clientId) {
|
|
125243
125289
|
throw new UserInputError(
|
|
125244
125290
|
"Client ID is required. Pass --clientId, set DOCYRUS_API_CLIENT_ID, or login once with --clientId to save it."
|
|
125245
125291
|
);
|
|
125246
125292
|
}
|
|
125247
|
-
const
|
|
125248
|
-
|
|
125249
|
-
clientId,
|
|
125293
|
+
const profile = manualAccessToken ? await loginWithManualTokens({
|
|
125294
|
+
apiBaseUrl,
|
|
125250
125295
|
accessToken: manualAccessToken,
|
|
125251
|
-
refreshToken: manualRefreshToken
|
|
125296
|
+
refreshToken: manualRefreshToken,
|
|
125297
|
+
clientId: context.options.clientId,
|
|
125252
125298
|
scope: context.options.scope,
|
|
125253
|
-
|
|
125254
|
-
|
|
125299
|
+
dependencies,
|
|
125300
|
+
env: context.env
|
|
125301
|
+
}) : await dependencies.createAuthSessionService(apiBaseUrl).loginWithDeviceFlow({
|
|
125255
125302
|
clientId,
|
|
125256
125303
|
scope: context.options.scope,
|
|
125257
125304
|
onVerification: (verification) => {
|
|
125258
125305
|
logVerificationHint(verification, context.agent, dependencies.onMessage);
|
|
125259
125306
|
}
|
|
125260
125307
|
});
|
|
125261
|
-
if (resolvedClientId) {
|
|
125262
|
-
await dependencies.environmentConfigService.setDefaultClientId(resolvedClientId);
|
|
125308
|
+
if (!manualAccessToken && resolvedClient.resolvedClientId) {
|
|
125309
|
+
await dependencies.environmentConfigService.setDefaultClientId(resolvedClient.resolvedClientId);
|
|
125263
125310
|
}
|
|
125264
125311
|
return await injectContext({
|
|
125265
125312
|
apiBaseUrl,
|
|
@@ -125279,6 +125326,43 @@ function createAuthCli(dependencies) {
|
|
|
125279
125326
|
});
|
|
125280
125327
|
}
|
|
125281
125328
|
});
|
|
125329
|
+
authCli.command("set-tokens", {
|
|
125330
|
+
description: "Set custom access and refresh tokens for the active environment",
|
|
125331
|
+
options: external_exports.object({
|
|
125332
|
+
clientId: external_exports.string().optional().describe("OAuth2 client id"),
|
|
125333
|
+
scope: external_exports.string().default(DEFAULT_LOGIN_SCOPES).describe("OAuth2 scopes"),
|
|
125334
|
+
accessToken: external_exports.string().min(1).describe("Custom access token"),
|
|
125335
|
+
refreshToken: external_exports.string().optional().describe("Custom refresh token")
|
|
125336
|
+
}),
|
|
125337
|
+
run: async (context) => {
|
|
125338
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
125339
|
+
const profile = await loginWithManualTokens({
|
|
125340
|
+
apiBaseUrl,
|
|
125341
|
+
accessToken: context.options.accessToken,
|
|
125342
|
+
refreshToken: context.options.refreshToken,
|
|
125343
|
+
clientId: context.options.clientId,
|
|
125344
|
+
scope: context.options.scope,
|
|
125345
|
+
dependencies,
|
|
125346
|
+
env: context.env
|
|
125347
|
+
});
|
|
125348
|
+
return await injectContext({
|
|
125349
|
+
apiBaseUrl,
|
|
125350
|
+
authStore: dependencies.authStore,
|
|
125351
|
+
payload: {
|
|
125352
|
+
authenticated: true,
|
|
125353
|
+
apiBaseUrl,
|
|
125354
|
+
userId: profile.userId,
|
|
125355
|
+
email: profile.email,
|
|
125356
|
+
tenantId: profile.tenantId,
|
|
125357
|
+
tenantName: profile.tenantName,
|
|
125358
|
+
tenantNo: profile.tenantNo,
|
|
125359
|
+
clientId: profile.clientId,
|
|
125360
|
+
scope: profile.scope,
|
|
125361
|
+
expiresAt: profile.expiresAt
|
|
125362
|
+
}
|
|
125363
|
+
});
|
|
125364
|
+
}
|
|
125365
|
+
});
|
|
125282
125366
|
const accountsCli = Cli_exports.create("accounts", {
|
|
125283
125367
|
description: "Account management",
|
|
125284
125368
|
env: EnvSchema
|
|
@@ -128602,6 +128686,7 @@ var ROOT_HELP_COMMANDS = [
|
|
|
128602
128686
|
{ command: "env", description: "Show active environment and list environments" },
|
|
128603
128687
|
{ command: "env use <id|name>", description: "Switch active environment" },
|
|
128604
128688
|
{ command: "auth login", description: "Authenticate with OAuth2 device flow" },
|
|
128689
|
+
{ command: "auth set-tokens --accessToken <token>", description: "Save custom access and refresh tokens" },
|
|
128605
128690
|
{ command: "auth accounts list", description: "List saved user accounts" },
|
|
128606
128691
|
{ command: "auth tenants use <uuid|tenantNo>", description: "Switch active tenant for selected user" },
|
|
128607
128692
|
{ command: 'ai "<prompt>"', description: "Send a prompt to the default Docyrus CLI agent" },
|