@ogment-ai/cli 0.10.0 → 0.10.1
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 +1 -1
- package/dist/cli.js +326 -164
- package/dist/cli.js.map +1 -1
- package/package.json +8 -9
package/dist/cli.js
CHANGED
|
@@ -8004,10 +8004,10 @@ const defaultRecoveryByCode = {
|
|
|
8004
8004
|
when: "immediate"
|
|
8005
8005
|
},
|
|
8006
8006
|
[ERROR_CODE.authDevicePending]: {
|
|
8007
|
-
command: "ogment
|
|
8008
|
-
reason: "
|
|
8009
|
-
title: "
|
|
8010
|
-
when: "
|
|
8007
|
+
command: "ogment status",
|
|
8008
|
+
reason: "Approve this request in the browser, then continue in the terminal.",
|
|
8009
|
+
title: "Continue after approval",
|
|
8010
|
+
when: "after_approval"
|
|
8011
8011
|
},
|
|
8012
8012
|
[ERROR_CODE.authInvalidCredentials]: {
|
|
8013
8013
|
command: "ogment login",
|
|
@@ -8373,6 +8373,7 @@ const authStateFileSchema = object({
|
|
|
8373
8373
|
currentAuthRequest: object({
|
|
8374
8374
|
authRequestId: string().min(1),
|
|
8375
8375
|
expiresAt: string().min(1),
|
|
8376
|
+
requestOrigin: _enum(["existing", "new"]).optional(),
|
|
8376
8377
|
verificationUrl: string().min(1)
|
|
8377
8378
|
}).nullable().optional(),
|
|
8378
8379
|
installationId: uuid(),
|
|
@@ -8419,6 +8420,14 @@ const legacyAuthStateFileSchema = object({
|
|
|
8419
8420
|
const LOCK_RETRY_DELAY_MS = 10;
|
|
8420
8421
|
const LOCK_STALE_MS = 3e4;
|
|
8421
8422
|
const LOCK_TIMEOUT_MS = 2e3;
|
|
8423
|
+
const normalizeCurrentAuthRequest = (request) => {
|
|
8424
|
+
return {
|
|
8425
|
+
authRequestId: request.authRequestId,
|
|
8426
|
+
expiresAt: request.expiresAt,
|
|
8427
|
+
requestOrigin: request.requestOrigin ?? "existing",
|
|
8428
|
+
verificationUrl: request.verificationUrl
|
|
8429
|
+
};
|
|
8430
|
+
};
|
|
8422
8431
|
const sleepBlocking = (milliseconds) => {
|
|
8423
8432
|
const buffer = new SharedArrayBuffer(4);
|
|
8424
8433
|
const view = new Int32Array(buffer);
|
|
@@ -8429,7 +8438,7 @@ const normalizeAuthState = (value) => {
|
|
|
8429
8438
|
if (Result.isOk(parsedCurrentState)) return {
|
|
8430
8439
|
needsMigration: false,
|
|
8431
8440
|
state: {
|
|
8432
|
-
currentAuthRequest: parsedCurrentState.value.currentAuthRequest
|
|
8441
|
+
currentAuthRequest: parsedCurrentState.value.currentAuthRequest === null || parsedCurrentState.value.currentAuthRequest === void 0 ? null : normalizeCurrentAuthRequest(parsedCurrentState.value.currentAuthRequest),
|
|
8433
8442
|
installationId: parsedCurrentState.value.installationId,
|
|
8434
8443
|
session: parsedCurrentState.value.session ?? null,
|
|
8435
8444
|
version: 3
|
|
@@ -8439,7 +8448,10 @@ const normalizeAuthState = (value) => {
|
|
|
8439
8448
|
if (Result.isOk(parsedLegacyV2State)) return {
|
|
8440
8449
|
needsMigration: true,
|
|
8441
8450
|
state: {
|
|
8442
|
-
currentAuthRequest: parsedLegacyV2State.value.pendingAuthRequest
|
|
8451
|
+
currentAuthRequest: parsedLegacyV2State.value.pendingAuthRequest === null || parsedLegacyV2State.value.pendingAuthRequest === void 0 ? null : {
|
|
8452
|
+
...parsedLegacyV2State.value.pendingAuthRequest,
|
|
8453
|
+
requestOrigin: "existing"
|
|
8454
|
+
},
|
|
8443
8455
|
installationId: parsedLegacyV2State.value.installationId,
|
|
8444
8456
|
session: parsedLegacyV2State.value.session ?? null,
|
|
8445
8457
|
version: 3
|
|
@@ -8454,6 +8466,7 @@ const normalizeAuthState = (value) => {
|
|
|
8454
8466
|
currentAuthRequest: latestPendingRequest === void 0 ? null : {
|
|
8455
8467
|
authRequestId: latestPendingRequest.authRequestId,
|
|
8456
8468
|
expiresAt: latestPendingRequest.expiresAt,
|
|
8469
|
+
requestOrigin: "existing",
|
|
8457
8470
|
verificationUrl: latestPendingRequest.verificationUrl
|
|
8458
8471
|
},
|
|
8459
8472
|
installationId: parsedV1.value.installationId,
|
|
@@ -8728,6 +8741,7 @@ const createFileCredentialsStore = (deps) => {
|
|
|
8728
8741
|
currentAuthRequest: {
|
|
8729
8742
|
authRequestId: request.authRequestId,
|
|
8730
8743
|
expiresAt: request.expiresAt,
|
|
8744
|
+
requestOrigin: request.requestOrigin,
|
|
8731
8745
|
verificationUrl: request.verificationUrl
|
|
8732
8746
|
}
|
|
8733
8747
|
});
|
|
@@ -8751,7 +8765,7 @@ const DEFAULT_OGMENT_BASE_URL = "https://dashboard.ogment.ai";
|
|
|
8751
8765
|
*/
|
|
8752
8766
|
const SENTRY_DSN_BUILD = "https://4219ab98670b61086758b4d0e31ae318@o4507724844957696.ingest.us.sentry.io/4510992932405248";
|
|
8753
8767
|
const SENTRY_ENVIRONMENT_BUILD = "production";
|
|
8754
|
-
const SENTRY_RELEASE_BUILD = "cli-v0.10.
|
|
8768
|
+
const SENTRY_RELEASE_BUILD = "cli-v0.10.1+git:865c808dd";
|
|
8755
8769
|
const packageJsonSchema = object({ version: string().min(1) });
|
|
8756
8770
|
const hasCode = (value, code) => {
|
|
8757
8771
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -13866,7 +13880,7 @@ const resolvePrimaryCode = (error) => {
|
|
|
13866
13880
|
if (typeof error.httpStatus === "number") return toHttpCode(error.httpStatus);
|
|
13867
13881
|
if (typeof error.mcpCode === "number") return toMcpCode(error.mcpCode);
|
|
13868
13882
|
}
|
|
13869
|
-
return
|
|
13883
|
+
return meta.code;
|
|
13870
13884
|
};
|
|
13871
13885
|
const resolveRelatedCodes = (error, primaryCode) => {
|
|
13872
13886
|
if (error._tag !== "RemoteRequestError") return;
|
|
@@ -14106,9 +14120,9 @@ const cliOrgSchema = object({
|
|
|
14106
14120
|
servers: array(cliServerSchema)
|
|
14107
14121
|
}).strict();
|
|
14108
14122
|
const cliActingAgentSchema = object({
|
|
14109
|
-
agentId:
|
|
14123
|
+
agentId: uuid(),
|
|
14110
14124
|
agentName: string().min(1),
|
|
14111
|
-
boundInstallationId:
|
|
14125
|
+
boundInstallationId: uuid().nullable()
|
|
14112
14126
|
}).strict();
|
|
14113
14127
|
const cliMeDataSchema = object({
|
|
14114
14128
|
actingAgent: cliActingAgentSchema.nullable(),
|
|
@@ -14130,15 +14144,15 @@ const authStartDataSchema = object({
|
|
|
14130
14144
|
"reused_pending"
|
|
14131
14145
|
]),
|
|
14132
14146
|
expiresAt: isoTimestampSchema,
|
|
14133
|
-
verificationUrl:
|
|
14147
|
+
verificationUrl: url$4()
|
|
14134
14148
|
}).strict();
|
|
14135
14149
|
const authStartSchema = cliSuccessEnvelopeSchema(authStartDataSchema);
|
|
14136
14150
|
const authExchangePendingDataSchema = object({ status: literal("authorization_pending") }).strict();
|
|
14137
14151
|
const authExchangeApprovedDataSchema = object({
|
|
14138
|
-
agentId:
|
|
14152
|
+
agentId: uuid(),
|
|
14139
14153
|
agentName: string().min(1),
|
|
14140
14154
|
apiKey: string().min(1),
|
|
14141
|
-
credentialId:
|
|
14155
|
+
credentialId: uuid(),
|
|
14142
14156
|
status: literal("approved")
|
|
14143
14157
|
}).strict();
|
|
14144
14158
|
const authExchangeExpiredDataSchema = object({ status: literal("expired") }).strict();
|
|
@@ -14175,7 +14189,7 @@ const cliEndpoints = {
|
|
|
14175
14189
|
const cliCommandKindSchema = _enum([
|
|
14176
14190
|
"login",
|
|
14177
14191
|
"logout",
|
|
14178
|
-
"
|
|
14192
|
+
"logout_reset",
|
|
14179
14193
|
"catalog_summary",
|
|
14180
14194
|
"catalog_tool",
|
|
14181
14195
|
"catalog_tools",
|
|
@@ -14310,7 +14324,7 @@ const exitCodeForError = (error) => {
|
|
|
14310
14324
|
const { category, code } = appErrorMeta(error);
|
|
14311
14325
|
switch (category) {
|
|
14312
14326
|
case ERROR_CATEGORY.auth:
|
|
14313
|
-
if (code === ERROR_CODE.authRequired) return EXIT_CODE.authRequired;
|
|
14327
|
+
if (code === ERROR_CODE.authRequired || code === ERROR_CODE.authDevicePending) return EXIT_CODE.authRequired;
|
|
14314
14328
|
return EXIT_CODE.authFailed;
|
|
14315
14329
|
case ERROR_CATEGORY.notFound: return EXIT_CODE.notFound;
|
|
14316
14330
|
case ERROR_CATEGORY.rateLimit: return EXIT_CODE.rateLimit;
|
|
@@ -14333,8 +14347,8 @@ const runLoginCommand = async (context, options) => {
|
|
|
14333
14347
|
const runLogoutCommand = async (context) => {
|
|
14334
14348
|
return context.services.auth.logout();
|
|
14335
14349
|
};
|
|
14336
|
-
const
|
|
14337
|
-
return context.services.auth.
|
|
14350
|
+
const runLogoutResetCommand = async (context) => {
|
|
14351
|
+
return context.services.auth.logoutReset();
|
|
14338
14352
|
};
|
|
14339
14353
|
|
|
14340
14354
|
//#endregion
|
|
@@ -14701,7 +14715,7 @@ const runInvokeCommand = async (context, options, deps = {}) => {
|
|
|
14701
14715
|
//#endregion
|
|
14702
14716
|
//#region src/commands/status.ts
|
|
14703
14717
|
const runStatusCommand = async (options, deps) => {
|
|
14704
|
-
return deps.infoService.collect(options.apiKeyOverride, { includeDebug: options.debug });
|
|
14718
|
+
return deps.infoService.collect(options.apiKeyOverride, { includeDebug: options.debug ?? false });
|
|
14705
14719
|
};
|
|
14706
14720
|
|
|
14707
14721
|
//#endregion
|
|
@@ -14769,81 +14783,131 @@ const buildJsonSchemaExample = (schema) => {
|
|
|
14769
14783
|
|
|
14770
14784
|
//#endregion
|
|
14771
14785
|
//#region src/cli/commands.ts
|
|
14786
|
+
function catalogCommand() {
|
|
14787
|
+
return "ogment catalog";
|
|
14788
|
+
}
|
|
14789
|
+
function catalogServerCommand(serverId) {
|
|
14790
|
+
return `${catalogCommand()} ${serverId}`;
|
|
14791
|
+
}
|
|
14792
|
+
function catalogSummaryCommand(options) {
|
|
14793
|
+
return [
|
|
14794
|
+
catalogCommand(),
|
|
14795
|
+
...options.cursor === void 0 ? [] : [`--cursor ${options.cursor}`],
|
|
14796
|
+
...options.limit === void 0 ? [] : [`--limit ${options.limit}`]
|
|
14797
|
+
].join(" ");
|
|
14798
|
+
}
|
|
14799
|
+
function catalogToolCommand(serverId, toolName, options) {
|
|
14800
|
+
return [
|
|
14801
|
+
catalogCommand(),
|
|
14802
|
+
serverId,
|
|
14803
|
+
toolName,
|
|
14804
|
+
...options.example ? ["--example"] : []
|
|
14805
|
+
].join(" ");
|
|
14806
|
+
}
|
|
14807
|
+
function helpForScope(scope) {
|
|
14808
|
+
if (scope === null) return "ogment --help";
|
|
14809
|
+
return `ogment ${scope} --help`;
|
|
14810
|
+
}
|
|
14811
|
+
function loginCommand() {
|
|
14812
|
+
return "ogment login";
|
|
14813
|
+
}
|
|
14814
|
+
function logoutCommand() {
|
|
14815
|
+
return "ogment logout";
|
|
14816
|
+
}
|
|
14817
|
+
function logoutResetCommand() {
|
|
14818
|
+
return "ogment logout --reset";
|
|
14819
|
+
}
|
|
14820
|
+
function invokeCommand(serverId, toolName, orgSlug) {
|
|
14821
|
+
return [
|
|
14822
|
+
"ogment invoke",
|
|
14823
|
+
...orgSlug === void 0 ? [] : [`--org ${orgSlug}`],
|
|
14824
|
+
serverId,
|
|
14825
|
+
toolName
|
|
14826
|
+
].join(" ");
|
|
14827
|
+
}
|
|
14828
|
+
function invokeInlineJson(serverId, toolName, orgSlug) {
|
|
14829
|
+
return `${invokeCommand(serverId, toolName, orgSlug)} --input <json>`;
|
|
14830
|
+
}
|
|
14831
|
+
function invokeStdin(serverId, toolName, orgSlug) {
|
|
14832
|
+
return `${invokeCommand(serverId, toolName, orgSlug)} --input -`;
|
|
14833
|
+
}
|
|
14834
|
+
function invokeWithInputValue(serverId, toolName, value, orgSlug) {
|
|
14835
|
+
return `${invokeCommand(serverId, toolName, orgSlug)} --input ${value}`;
|
|
14836
|
+
}
|
|
14837
|
+
function rootCommand() {
|
|
14838
|
+
return "ogment";
|
|
14839
|
+
}
|
|
14840
|
+
const rootCommandReferences = [
|
|
14841
|
+
{
|
|
14842
|
+
quickCommand: catalogCommand(),
|
|
14843
|
+
surface: "catalog"
|
|
14844
|
+
},
|
|
14845
|
+
{
|
|
14846
|
+
quickCommand: catalogServerCommand("<server-id>"),
|
|
14847
|
+
surface: "catalog <server-id>"
|
|
14848
|
+
},
|
|
14849
|
+
{
|
|
14850
|
+
quickCommand: catalogToolCommand("<server-id>", "<tool-name>", { example: false }),
|
|
14851
|
+
surface: "catalog <server-id> <tool-name>"
|
|
14852
|
+
},
|
|
14853
|
+
{
|
|
14854
|
+
quickCommand: invokeWithInputValue("<server-id>", "<tool-name>", "'{}'"),
|
|
14855
|
+
surface: "invoke <server-id> <tool-name>"
|
|
14856
|
+
},
|
|
14857
|
+
{
|
|
14858
|
+
quickCommand: statusCommand(),
|
|
14859
|
+
surface: "status"
|
|
14860
|
+
},
|
|
14861
|
+
{
|
|
14862
|
+
quickCommand: loginCommand(),
|
|
14863
|
+
surface: "login"
|
|
14864
|
+
},
|
|
14865
|
+
{
|
|
14866
|
+
quickCommand: logoutCommand(),
|
|
14867
|
+
surface: "logout"
|
|
14868
|
+
},
|
|
14869
|
+
{
|
|
14870
|
+
quickCommand: logoutResetCommand(),
|
|
14871
|
+
surface: "logout --reset"
|
|
14872
|
+
}
|
|
14873
|
+
];
|
|
14874
|
+
function rootCommandsSurface() {
|
|
14875
|
+
return rootCommandReferences.map(({ surface }) => surface);
|
|
14876
|
+
}
|
|
14877
|
+
function rootQuickCommands() {
|
|
14878
|
+
return rootCommandReferences.map(({ quickCommand }) => quickCommand);
|
|
14879
|
+
}
|
|
14880
|
+
function rootHelp() {
|
|
14881
|
+
return `${rootCommand()} --help`;
|
|
14882
|
+
}
|
|
14883
|
+
function statusCommand() {
|
|
14884
|
+
return "ogment status";
|
|
14885
|
+
}
|
|
14772
14886
|
const cliCommands = {
|
|
14773
14887
|
catalog: {
|
|
14774
|
-
command:
|
|
14775
|
-
server:
|
|
14776
|
-
summary:
|
|
14777
|
-
|
|
14778
|
-
"ogment catalog",
|
|
14779
|
-
...options.cursor === void 0 ? [] : [`--cursor ${options.cursor}`],
|
|
14780
|
-
...options.limit === void 0 ? [] : [`--limit ${options.limit}`]
|
|
14781
|
-
].join(" ");
|
|
14782
|
-
},
|
|
14783
|
-
tool: (serverId, toolName, options) => {
|
|
14784
|
-
return [
|
|
14785
|
-
"ogment catalog",
|
|
14786
|
-
serverId,
|
|
14787
|
-
toolName,
|
|
14788
|
-
...options.example ? ["--example"] : []
|
|
14789
|
-
].join(" ");
|
|
14790
|
-
}
|
|
14888
|
+
command: catalogCommand,
|
|
14889
|
+
server: catalogServerCommand,
|
|
14890
|
+
summary: catalogSummaryCommand,
|
|
14891
|
+
tool: catalogToolCommand
|
|
14791
14892
|
},
|
|
14792
|
-
helpForScope
|
|
14793
|
-
|
|
14794
|
-
|
|
14893
|
+
helpForScope,
|
|
14894
|
+
login: { command: loginCommand },
|
|
14895
|
+
logout: {
|
|
14896
|
+
command: logoutCommand,
|
|
14897
|
+
reset: logoutResetCommand
|
|
14795
14898
|
},
|
|
14796
|
-
login: { command: () => "ogment login" },
|
|
14797
|
-
logout: { command: () => "ogment logout" },
|
|
14798
14899
|
invoke: {
|
|
14799
|
-
command:
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
toolName
|
|
14804
|
-
].join(" "),
|
|
14805
|
-
inlineJson: (serverId, toolName, orgSlug) => [
|
|
14806
|
-
"ogment invoke",
|
|
14807
|
-
...orgSlug === void 0 ? [] : [`--org ${orgSlug}`],
|
|
14808
|
-
serverId,
|
|
14809
|
-
toolName,
|
|
14810
|
-
"--input <json>"
|
|
14811
|
-
].join(" "),
|
|
14812
|
-
stdin: (serverId, toolName, orgSlug) => [
|
|
14813
|
-
"ogment invoke",
|
|
14814
|
-
...orgSlug === void 0 ? [] : [`--org ${orgSlug}`],
|
|
14815
|
-
serverId,
|
|
14816
|
-
toolName,
|
|
14817
|
-
"--input -"
|
|
14818
|
-
].join(" "),
|
|
14819
|
-
withInputValue: (serverId, toolName, value, orgSlug) => {
|
|
14820
|
-
return [
|
|
14821
|
-
"ogment invoke",
|
|
14822
|
-
...orgSlug === void 0 ? [] : [`--org ${orgSlug}`],
|
|
14823
|
-
serverId,
|
|
14824
|
-
toolName,
|
|
14825
|
-
`--input ${value}`
|
|
14826
|
-
].join(" ");
|
|
14827
|
-
}
|
|
14900
|
+
command: invokeCommand,
|
|
14901
|
+
inlineJson: invokeInlineJson,
|
|
14902
|
+
stdin: invokeStdin,
|
|
14903
|
+
withInputValue: invokeWithInputValue
|
|
14828
14904
|
},
|
|
14829
14905
|
root: {
|
|
14830
|
-
command:
|
|
14831
|
-
commandsSurface:
|
|
14832
|
-
|
|
14833
|
-
"login",
|
|
14834
|
-
"logout",
|
|
14835
|
-
"reset",
|
|
14836
|
-
"catalog",
|
|
14837
|
-
"catalog <server-id>",
|
|
14838
|
-
"catalog <server-id> <tool-name>",
|
|
14839
|
-
"invoke <server-id> <tool-name>",
|
|
14840
|
-
"status"
|
|
14841
|
-
];
|
|
14842
|
-
},
|
|
14843
|
-
help: () => "ogment --help"
|
|
14906
|
+
command: rootCommand,
|
|
14907
|
+
commandsSurface: rootCommandsSurface,
|
|
14908
|
+
help: rootHelp
|
|
14844
14909
|
},
|
|
14845
|
-
|
|
14846
|
-
status: { command: () => "ogment status" }
|
|
14910
|
+
status: { command: statusCommand }
|
|
14847
14911
|
};
|
|
14848
14912
|
|
|
14849
14913
|
//#endregion
|
|
@@ -14884,8 +14948,8 @@ const ensureSuccess = (result, runtime, context) => {
|
|
|
14884
14948
|
const nextActionsForLogin = (payload) => {
|
|
14885
14949
|
return [nextAction("inspect_status", "Inspect status", cliCommands.status.command(), `Verify the connected CLI state for ${payload.agentName}.`, "immediate"), nextAction("discover_servers", "Discover servers", cliCommands.catalog.command(), `Logged in as ${payload.agentName}; discover available servers.`, "after_auth")];
|
|
14886
14950
|
};
|
|
14887
|
-
const
|
|
14888
|
-
return [nextAction("
|
|
14951
|
+
const nextActionsForPendingAuth = (verification, command = cliCommands.status.command()) => {
|
|
14952
|
+
return [nextAction("continue_after_approval", "Continue in terminal", command, `Approve request ${verification.authRequestId} at ${verification.verificationUrl}, then continue in the terminal.`, "after_approval")];
|
|
14889
14953
|
};
|
|
14890
14954
|
const nextActionsForCatalogSummary = (payload, context) => {
|
|
14891
14955
|
const actions = [];
|
|
@@ -14914,9 +14978,58 @@ const nextActionsForInvoke = (payload) => {
|
|
|
14914
14978
|
return [nextAction("inspect_tool", "Inspect tool schema", cliCommands.catalog.tool(payload.serverId, payload.toolName, { example: false }), `Review ${payload.serverId}/${payload.toolName} schema for the next invocation.`, "after_invoke")];
|
|
14915
14979
|
};
|
|
14916
14980
|
const nextActionsForStatus = (payload) => {
|
|
14981
|
+
if (payload.auth.state === "pending_approval") return nextActionsForPendingAuth(payload.auth.pendingRequest);
|
|
14917
14982
|
if (!payload.auth.apiKeyPresent) return [nextAction("login", "Authenticate", cliCommands.login.command(), "Status detected no API key; authenticate first.", "immediate")];
|
|
14918
14983
|
return [nextAction("discover_servers", "Discover servers", cliCommands.catalog.command(), `Connectivity is ${payload.summary.status}; discover available servers.`, "after_status")];
|
|
14919
14984
|
};
|
|
14985
|
+
const pendingAuthDiagnostics = (verification) => {
|
|
14986
|
+
return {
|
|
14987
|
+
authRequestId: verification.authRequestId,
|
|
14988
|
+
expiresAt: verification.expiresAt,
|
|
14989
|
+
requestOrigin: verification.requestOrigin,
|
|
14990
|
+
verificationUrl: verification.verificationUrl
|
|
14991
|
+
};
|
|
14992
|
+
};
|
|
14993
|
+
const throwPendingAuthError = (runtime, command, verification, recoveryCommand) => {
|
|
14994
|
+
const error = new AuthError({
|
|
14995
|
+
code: ERROR_CODE.authDevicePending,
|
|
14996
|
+
message: "Approve this request, then continue in the terminal.",
|
|
14997
|
+
recovery: {
|
|
14998
|
+
command: recoveryCommand,
|
|
14999
|
+
reason: "Approve this request in the browser, then continue in the terminal.",
|
|
15000
|
+
title: "Continue after approval",
|
|
15001
|
+
when: "after_approval"
|
|
15002
|
+
}
|
|
15003
|
+
});
|
|
15004
|
+
runtime.output.error(error, {
|
|
15005
|
+
command,
|
|
15006
|
+
diagnostics: pendingAuthDiagnostics(verification),
|
|
15007
|
+
entity: {
|
|
15008
|
+
event: "auth.pending",
|
|
15009
|
+
verification: pendingAuthDiagnostics(verification)
|
|
15010
|
+
}
|
|
15011
|
+
});
|
|
15012
|
+
throw new CliExitError(exitCodeForError(error), error);
|
|
15013
|
+
};
|
|
15014
|
+
const completePendingAuthBeforeInvocation = async (runtime, command) => {
|
|
15015
|
+
const data = ensureSuccess(await runtime.context.services.auth.completePendingAuth(), runtime, { command });
|
|
15016
|
+
if (data.kind === "pending") {
|
|
15017
|
+
const resolvedApiKey = await runtime.context.services.auth.resolveApiKey(runtime.context.apiKeyOverride);
|
|
15018
|
+
if (Result.isOk(resolvedApiKey)) return { kind: "continue" };
|
|
15019
|
+
if (!(resolvedApiKey.error instanceof AuthError && resolvedApiKey.error.code === ERROR_CODE.authDevicePending)) {
|
|
15020
|
+
runtime.output.error(resolvedApiKey.error, {
|
|
15021
|
+
command,
|
|
15022
|
+
entity: null
|
|
15023
|
+
});
|
|
15024
|
+
throwCommandError(resolvedApiKey.error);
|
|
15025
|
+
}
|
|
15026
|
+
return {
|
|
15027
|
+
kind: "pending",
|
|
15028
|
+
verification: data.verification
|
|
15029
|
+
};
|
|
15030
|
+
}
|
|
15031
|
+
return { kind: "continue" };
|
|
15032
|
+
};
|
|
14920
15033
|
const runLoginFlow = async (runtime, options) => {
|
|
14921
15034
|
const invokedCommand = cliCommands.login.command();
|
|
14922
15035
|
const data = ensureSuccess(await runLoginCommand(runtime.context, options), runtime, { command: invokedCommand });
|
|
@@ -14932,10 +15045,12 @@ const runLoginFlow = async (runtime, options) => {
|
|
|
14932
15045
|
event: "login.pending",
|
|
14933
15046
|
verification: {
|
|
14934
15047
|
authRequestId: data.verification.authRequestId,
|
|
15048
|
+
expiresAt: data.verification.expiresAt,
|
|
15049
|
+
requestOrigin: data.verification.requestOrigin,
|
|
14935
15050
|
verificationUrl: data.verification.verificationUrl
|
|
14936
15051
|
}
|
|
14937
15052
|
},
|
|
14938
|
-
nextActions:
|
|
15053
|
+
nextActions: nextActionsForPendingAuth(data.verification)
|
|
14939
15054
|
});
|
|
14940
15055
|
return;
|
|
14941
15056
|
}
|
|
@@ -14968,28 +15083,26 @@ const executeLogoutInvocation = async (runtime) => {
|
|
|
14968
15083
|
command,
|
|
14969
15084
|
entity: {
|
|
14970
15085
|
event: "logout.completed",
|
|
14971
|
-
|
|
15086
|
+
outcome: data.outcome,
|
|
14972
15087
|
remoteSignedOut: data.remoteSignedOut
|
|
14973
15088
|
},
|
|
14974
15089
|
nextActions: [nextAction("login", "Authenticate again", cliCommands.login.command(), "Sign-out completed; run login when you want to reconnect this installation.", "after_logout")]
|
|
14975
15090
|
});
|
|
14976
15091
|
};
|
|
14977
|
-
const
|
|
14978
|
-
const command = cliCommands.reset
|
|
14979
|
-
const data = ensureSuccess(await
|
|
15092
|
+
const executeLogoutResetInvocation = async (runtime) => {
|
|
15093
|
+
const command = cliCommands.logout.reset();
|
|
15094
|
+
const data = ensureSuccess(await runLogoutResetCommand(runtime.context), runtime, { command });
|
|
14980
15095
|
const outputData = {
|
|
14981
15096
|
...data,
|
|
14982
|
-
event: "reset.completed"
|
|
15097
|
+
event: "logout.reset.completed"
|
|
14983
15098
|
};
|
|
14984
15099
|
runtime.output.success(outputData, {
|
|
14985
15100
|
command,
|
|
14986
15101
|
entity: {
|
|
14987
|
-
event: "reset.completed",
|
|
14988
|
-
|
|
14989
|
-
localStateCleared: data.localStateCleared,
|
|
14990
|
-
remoteReset: data.remoteReset
|
|
15102
|
+
event: "logout.reset.completed",
|
|
15103
|
+
outcome: data.outcome
|
|
14991
15104
|
},
|
|
14992
|
-
nextActions: [nextAction("login", "Authenticate this fresh install", cliCommands.login.command(), "
|
|
15105
|
+
nextActions: [nextAction("login", "Authenticate this fresh install", cliCommands.login.command(), "This installation is reset; run login to create or reconnect it.", "after_reset"), nextAction("inspect_status", "Inspect status", cliCommands.status.command(), "Inspect the fresh-install CLI state and diagnostics.", "after_reset")]
|
|
14993
15106
|
});
|
|
14994
15107
|
};
|
|
14995
15108
|
const executeCatalogInvocation = async (runtime, invocation) => {
|
|
@@ -15046,6 +15159,8 @@ const executeCatalogInvocation = async (runtime, invocation) => {
|
|
|
15046
15159
|
...plan.cursor === void 0 ? {} : { cursor: plan.cursor },
|
|
15047
15160
|
...plan.limit === void 0 ? {} : { limit: plan.limit }
|
|
15048
15161
|
});
|
|
15162
|
+
const pendingAuth = await completePendingAuthBeforeInvocation(runtime, command);
|
|
15163
|
+
if (pendingAuth.kind === "pending") throwPendingAuthError(runtime, command, pendingAuth.verification, command);
|
|
15049
15164
|
const data = ensureSuccess(await runCatalogCommand(runtime.context, {
|
|
15050
15165
|
...plan.cursor === void 0 ? {} : { cursor: plan.cursor },
|
|
15051
15166
|
includeDebug: runtime.output.debug,
|
|
@@ -15079,6 +15194,8 @@ const executeCatalogInvocation = async (runtime, invocation) => {
|
|
|
15079
15194
|
}
|
|
15080
15195
|
case "tools": {
|
|
15081
15196
|
const command = cliCommands.catalog.server(planResult.value.serverId);
|
|
15197
|
+
const pendingAuth = await completePendingAuthBeforeInvocation(runtime, command);
|
|
15198
|
+
if (pendingAuth.kind === "pending") throwPendingAuthError(runtime, command, pendingAuth.verification, command);
|
|
15082
15199
|
const data = ensureSuccess(await runCatalogToolsCommand(runtime.context, { serverId: planResult.value.serverId }), runtime, {
|
|
15083
15200
|
command,
|
|
15084
15201
|
entity: { serverId: planResult.value.serverId }
|
|
@@ -15095,6 +15212,8 @@ const executeCatalogInvocation = async (runtime, invocation) => {
|
|
|
15095
15212
|
}
|
|
15096
15213
|
case "tool": {
|
|
15097
15214
|
const command = cliCommands.catalog.tool(planResult.value.serverId, planResult.value.toolName, { example: planResult.value.example });
|
|
15215
|
+
const pendingAuth = await completePendingAuthBeforeInvocation(runtime, command);
|
|
15216
|
+
if (pendingAuth.kind === "pending") throwPendingAuthError(runtime, command, pendingAuth.verification, command);
|
|
15098
15217
|
const data = ensureSuccess(await runCatalogToolDetailsCommand(runtime.context, {
|
|
15099
15218
|
serverId: planResult.value.serverId,
|
|
15100
15219
|
toolName: planResult.value.toolName
|
|
@@ -15135,6 +15254,8 @@ const executeInvokeInvocation = async (runtime, invocation) => {
|
|
|
15135
15254
|
inputSource = "inline_json";
|
|
15136
15255
|
command = cliCommands.invoke.inlineJson(invocation.serverId, invocation.toolName, invocation.orgSlug);
|
|
15137
15256
|
}
|
|
15257
|
+
const pendingAuth = await completePendingAuthBeforeInvocation(runtime, command);
|
|
15258
|
+
if (pendingAuth.kind === "pending") throwPendingAuthError(runtime, command, pendingAuth.verification, command);
|
|
15138
15259
|
const data = ensureSuccess(await runInvokeCommand(runtime.context, {
|
|
15139
15260
|
input: invocation.input,
|
|
15140
15261
|
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
@@ -15162,19 +15283,42 @@ const executeInvokeInvocation = async (runtime, invocation) => {
|
|
|
15162
15283
|
};
|
|
15163
15284
|
const executeStatusInvocation = async (runtime) => {
|
|
15164
15285
|
const command = cliCommands.status.command();
|
|
15286
|
+
await completePendingAuthBeforeInvocation(runtime, command);
|
|
15165
15287
|
const data = await runStatusCommand({
|
|
15166
15288
|
apiKeyOverride: runtime.context.apiKeyOverride,
|
|
15167
15289
|
debug: runtime.output.debug
|
|
15168
15290
|
}, { infoService: runtime.infoService });
|
|
15169
15291
|
runtime.output.success(data, {
|
|
15170
15292
|
command,
|
|
15171
|
-
entity: {
|
|
15293
|
+
entity: {
|
|
15294
|
+
authState: data.auth.state,
|
|
15295
|
+
pendingAuth: data.auth.pendingRequest === null ? null : pendingAuthDiagnostics(data.auth.pendingRequest),
|
|
15296
|
+
summaryStatus: data.summary.status
|
|
15297
|
+
},
|
|
15172
15298
|
nextActions: nextActionsForStatus(data)
|
|
15173
15299
|
});
|
|
15174
15300
|
};
|
|
15175
|
-
const executeRootInvocation = (runtime) => {
|
|
15301
|
+
const executeRootInvocation = async (runtime) => {
|
|
15302
|
+
const command = cliCommands.root.command();
|
|
15303
|
+
const pendingAuth = await completePendingAuthBeforeInvocation(runtime, command);
|
|
15304
|
+
if (pendingAuth.kind === "pending") {
|
|
15305
|
+
const outputData = {
|
|
15306
|
+
event: "auth.pending",
|
|
15307
|
+
loggedIn: false,
|
|
15308
|
+
verification: pendingAuth.verification
|
|
15309
|
+
};
|
|
15310
|
+
runtime.output.success(outputData, {
|
|
15311
|
+
command,
|
|
15312
|
+
entity: {
|
|
15313
|
+
event: "auth.pending",
|
|
15314
|
+
verification: pendingAuthDiagnostics(pendingAuth.verification)
|
|
15315
|
+
},
|
|
15316
|
+
nextActions: nextActionsForPendingAuth(pendingAuth.verification, command)
|
|
15317
|
+
});
|
|
15318
|
+
return;
|
|
15319
|
+
}
|
|
15176
15320
|
runtime.output.success({ commands: cliCommands.root.commandsSurface() }, {
|
|
15177
|
-
command
|
|
15321
|
+
command,
|
|
15178
15322
|
entity: null,
|
|
15179
15323
|
nextActions: [nextAction("login", "Authenticate", cliCommands.login.command(), "Authenticate first so catalog and invoke commands can run.", "immediate"), nextAction("catalog", "Discover servers", cliCommands.catalog.command(), "List accessible servers and tool counts.", "after_auth")]
|
|
15180
15324
|
});
|
|
@@ -15187,8 +15331,8 @@ const executeInvocation = async (runtime, invocation) => {
|
|
|
15187
15331
|
case "logout":
|
|
15188
15332
|
await executeLogoutInvocation(runtime);
|
|
15189
15333
|
return;
|
|
15190
|
-
case "
|
|
15191
|
-
await
|
|
15334
|
+
case "logout_reset":
|
|
15335
|
+
await executeLogoutResetInvocation(runtime);
|
|
15192
15336
|
return;
|
|
15193
15337
|
case "catalog":
|
|
15194
15338
|
await executeCatalogInvocation(runtime, invocation);
|
|
@@ -15197,7 +15341,7 @@ const executeInvocation = async (runtime, invocation) => {
|
|
|
15197
15341
|
await executeInvokeInvocation(runtime, invocation);
|
|
15198
15342
|
return;
|
|
15199
15343
|
case "root":
|
|
15200
|
-
executeRootInvocation(runtime);
|
|
15344
|
+
await executeRootInvocation(runtime);
|
|
15201
15345
|
return;
|
|
15202
15346
|
case "status":
|
|
15203
15347
|
await executeStatusInvocation(runtime);
|
|
@@ -15261,7 +15405,7 @@ const nextActionForParseError = (scope, helpCommand) => {
|
|
|
15261
15405
|
};
|
|
15262
15406
|
};
|
|
15263
15407
|
const parseActionsForScope = (scope, helpAction) => {
|
|
15264
|
-
if (scope === "login" || scope === "logout"
|
|
15408
|
+
if (scope === "login" || scope === "logout") return [
|
|
15265
15409
|
{
|
|
15266
15410
|
command: cliCommands.login.command(),
|
|
15267
15411
|
id: "login",
|
|
@@ -60770,9 +60914,10 @@ const accountMeUrl = (baseUrl) => {
|
|
|
60770
60914
|
return toEndpointUrl(baseUrl, cliEndpoints.accountMe);
|
|
60771
60915
|
};
|
|
60772
60916
|
const toLoginPendingInfo = (request) => {
|
|
60773
|
-
if (request === null) return null;
|
|
60774
60917
|
return {
|
|
60775
60918
|
authRequestId: request.authRequestId,
|
|
60919
|
+
expiresAt: request.expiresAt,
|
|
60920
|
+
requestOrigin: request.requestOrigin,
|
|
60776
60921
|
verificationUrl: request.verificationUrl
|
|
60777
60922
|
};
|
|
60778
60923
|
};
|
|
@@ -60887,6 +61032,19 @@ const createAuthService = (deps) => {
|
|
|
60887
61032
|
if (Result.isError(clearResult)) return clearResult;
|
|
60888
61033
|
return Result.ok({ kind: "none" });
|
|
60889
61034
|
};
|
|
61035
|
+
const completePendingAuthSnapshot = async (snapshot) => {
|
|
61036
|
+
const exchangedCurrentAuthRequest = await exchangeCurrentAuthRequest(snapshot);
|
|
61037
|
+
if (Result.isError(exchangedCurrentAuthRequest)) return exchangedCurrentAuthRequest;
|
|
61038
|
+
if (exchangedCurrentAuthRequest.value.kind === "approved") return Result.ok({
|
|
61039
|
+
auth: exchangedCurrentAuthRequest.value.auth,
|
|
61040
|
+
kind: "authenticated"
|
|
61041
|
+
});
|
|
61042
|
+
if (exchangedCurrentAuthRequest.value.kind === "pending") return Result.ok({
|
|
61043
|
+
kind: "pending",
|
|
61044
|
+
verification: toLoginPendingInfo(exchangedCurrentAuthRequest.value.request)
|
|
61045
|
+
});
|
|
61046
|
+
return Result.ok({ kind: "none" });
|
|
61047
|
+
};
|
|
60890
61048
|
const startOrRecoverLogin = async (installationId, options) => {
|
|
60891
61049
|
const startPayload = await requestJson(deps.httpClient, authStartUrl(deps.baseUrl), authStartSchema, {
|
|
60892
61050
|
body: JSON.stringify({
|
|
@@ -60911,6 +61069,7 @@ const createAuthService = (deps) => {
|
|
|
60911
61069
|
const currentAuthRequest = {
|
|
60912
61070
|
authRequestId: startPayload.value.data.authRequestId,
|
|
60913
61071
|
expiresAt: startPayload.value.data.expiresAt,
|
|
61072
|
+
requestOrigin: startPayload.value.data.disposition === "created" ? "new" : "existing",
|
|
60914
61073
|
verificationUrl: startPayload.value.data.verificationUrl
|
|
60915
61074
|
};
|
|
60916
61075
|
const saveCurrentAuthRequestResult = deps.credentialsStore.saveCurrentAuthRequest(currentAuthRequest);
|
|
@@ -60929,18 +61088,20 @@ const createAuthService = (deps) => {
|
|
|
60929
61088
|
});
|
|
60930
61089
|
}
|
|
60931
61090
|
const verification = toLoginPendingInfo(currentAuthRequest);
|
|
60932
|
-
|
|
61091
|
+
options.onPending?.(verification);
|
|
60933
61092
|
return Result.ok({
|
|
60934
61093
|
agentName: null,
|
|
60935
61094
|
loggedIn: false,
|
|
60936
61095
|
outcome: "pending_approval",
|
|
60937
|
-
verification
|
|
60938
|
-
authRequestId: currentAuthRequest.authRequestId,
|
|
60939
|
-
verificationUrl: currentAuthRequest.verificationUrl
|
|
60940
|
-
}
|
|
61096
|
+
verification
|
|
60941
61097
|
});
|
|
60942
61098
|
};
|
|
60943
61099
|
return {
|
|
61100
|
+
completePendingAuth: async () => {
|
|
61101
|
+
const snapshot = loadLocalAuthSnapshot();
|
|
61102
|
+
if (Result.isError(snapshot)) return snapshot;
|
|
61103
|
+
return completePendingAuthSnapshot(snapshot.value);
|
|
61104
|
+
},
|
|
60944
61105
|
login: async (options) => {
|
|
60945
61106
|
const snapshot = loadLocalAuthSnapshot();
|
|
60946
61107
|
if (Result.isError(snapshot)) return snapshot;
|
|
@@ -60955,24 +61116,20 @@ const createAuthService = (deps) => {
|
|
|
60955
61116
|
const deleteResult = deps.credentialsStore.delete();
|
|
60956
61117
|
if (Result.isError(deleteResult)) return deleteResult;
|
|
60957
61118
|
}
|
|
60958
|
-
const
|
|
60959
|
-
if (Result.isError(
|
|
60960
|
-
if (
|
|
60961
|
-
agentName:
|
|
61119
|
+
const completedPendingAuth = await completePendingAuthSnapshot(snapshot.value);
|
|
61120
|
+
if (Result.isError(completedPendingAuth)) return completedPendingAuth;
|
|
61121
|
+
if (completedPendingAuth.value.kind === "authenticated") return Result.ok({
|
|
61122
|
+
agentName: completedPendingAuth.value.auth.agentName,
|
|
60962
61123
|
loggedIn: true,
|
|
60963
61124
|
outcome: "authenticated"
|
|
60964
61125
|
});
|
|
60965
|
-
if (
|
|
60966
|
-
|
|
60967
|
-
if (verification !== null) options.onPending?.(verification);
|
|
61126
|
+
if (completedPendingAuth.value.kind === "pending") {
|
|
61127
|
+
options.onPending?.(completedPendingAuth.value.verification);
|
|
60968
61128
|
return Result.ok({
|
|
60969
61129
|
agentName: null,
|
|
60970
61130
|
loggedIn: false,
|
|
60971
61131
|
outcome: "pending_approval",
|
|
60972
|
-
verification: verification
|
|
60973
|
-
authRequestId: exchangedCurrentAuthRequest.value.request.authRequestId,
|
|
60974
|
-
verificationUrl: exchangedCurrentAuthRequest.value.request.verificationUrl
|
|
60975
|
-
}
|
|
61132
|
+
verification: completedPendingAuth.value.verification
|
|
60976
61133
|
});
|
|
60977
61134
|
}
|
|
60978
61135
|
return startOrRecoverLogin(snapshot.value.installationId, options);
|
|
@@ -60981,7 +61138,7 @@ const createAuthService = (deps) => {
|
|
|
60981
61138
|
const snapshot = loadLocalAuthSnapshot();
|
|
60982
61139
|
if (Result.isError(snapshot)) return snapshot;
|
|
60983
61140
|
if (snapshot.value.session === null) return Result.ok({
|
|
60984
|
-
|
|
61141
|
+
outcome: "already_logged_out",
|
|
60985
61142
|
remoteSignedOut: false
|
|
60986
61143
|
});
|
|
60987
61144
|
const storedAuthorizationHeader = toStoredAuthorizationHeader(snapshot.value.session);
|
|
@@ -61007,11 +61164,11 @@ const createAuthService = (deps) => {
|
|
|
61007
61164
|
const deleteResult = deps.credentialsStore.delete();
|
|
61008
61165
|
if (Result.isError(deleteResult)) return deleteResult;
|
|
61009
61166
|
return Result.ok({
|
|
61010
|
-
|
|
61167
|
+
outcome: "logged_out",
|
|
61011
61168
|
remoteSignedOut
|
|
61012
61169
|
});
|
|
61013
61170
|
},
|
|
61014
|
-
|
|
61171
|
+
logoutReset: async () => {
|
|
61015
61172
|
const snapshot = loadLocalAuthSnapshot();
|
|
61016
61173
|
if (Result.isError(snapshot)) return snapshot;
|
|
61017
61174
|
const storedAuthorizationHeader = toStoredAuthorizationHeader(snapshot.value.session);
|
|
@@ -61035,14 +61192,9 @@ const createAuthService = (deps) => {
|
|
|
61035
61192
|
operation: "auth/reset"
|
|
61036
61193
|
});
|
|
61037
61194
|
const remoteReset = Result.isOk(remoteResetResult);
|
|
61038
|
-
const localStateCleared = snapshot.value.session !== null || snapshot.value.currentAuthRequest !== null;
|
|
61039
61195
|
const resetLocalStateResult = deps.credentialsStore.reset();
|
|
61040
61196
|
if (Result.isError(resetLocalStateResult)) return resetLocalStateResult;
|
|
61041
|
-
return Result.ok({
|
|
61042
|
-
installationReset: true,
|
|
61043
|
-
localStateCleared,
|
|
61044
|
-
remoteReset
|
|
61045
|
-
});
|
|
61197
|
+
return Result.ok({ outcome: remoteReset ? "installation_reset" : "local_only_reset_with_remote_warning" });
|
|
61046
61198
|
},
|
|
61047
61199
|
resolveApiKey: async (overrideApiKey) => {
|
|
61048
61200
|
const resolution = resolveApiKey({
|
|
@@ -61054,9 +61206,14 @@ const createAuthService = (deps) => {
|
|
|
61054
61206
|
if (resolution.source === "credentialsError" && resolution.loadError) return Result.err(resolution.loadError);
|
|
61055
61207
|
const snapshot = loadLocalAuthSnapshot();
|
|
61056
61208
|
if (Result.isError(snapshot)) return snapshot;
|
|
61057
|
-
const
|
|
61058
|
-
if (Result.isError(
|
|
61059
|
-
if (
|
|
61209
|
+
const completedPendingAuth = await completePendingAuthSnapshot(snapshot.value);
|
|
61210
|
+
if (Result.isError(completedPendingAuth)) return completedPendingAuth;
|
|
61211
|
+
if (completedPendingAuth.value.kind === "authenticated") return Result.ok(completedPendingAuth.value.auth.apiKey);
|
|
61212
|
+
if (completedPendingAuth.value.kind === "pending") return Result.err(new AuthError({
|
|
61213
|
+
code: ERROR_CODE.authDevicePending,
|
|
61214
|
+
message: "Approve this request, then continue in the terminal.",
|
|
61215
|
+
recovery: { command: "ogment status" }
|
|
61216
|
+
}));
|
|
61060
61217
|
return Result.err(new AuthError({
|
|
61061
61218
|
code: ERROR_CODE.authRequired,
|
|
61062
61219
|
message: "Not logged in. Run `ogment login` or set OGMENT_API_KEY.",
|
|
@@ -61080,14 +61237,14 @@ const nextActionByIssueCode = (includeDebug) => {
|
|
|
61080
61237
|
unreachable: includeDebug ? "Verify `OGMENT_BASE_URL` and network connectivity." : "Verify network connectivity."
|
|
61081
61238
|
};
|
|
61082
61239
|
};
|
|
61083
|
-
const toSummary = (issues, includeDebug) => {
|
|
61240
|
+
const toSummary = (issues, includeDebug, authState) => {
|
|
61084
61241
|
const issueActions = nextActionByIssueCode(includeDebug);
|
|
61085
61242
|
const nextActions = /* @__PURE__ */ new Set();
|
|
61086
61243
|
for (const issue of issues) {
|
|
61087
61244
|
const nextAction = issueActions[issue.code];
|
|
61088
61245
|
if (nextAction !== void 0) nextActions.add(nextAction);
|
|
61089
61246
|
}
|
|
61090
|
-
nextActions.add("Run `ogment catalog` to inspect available servers.");
|
|
61247
|
+
if (authState === "signed_in") nextActions.add("Run `ogment catalog` to inspect available servers.");
|
|
61091
61248
|
return {
|
|
61092
61249
|
issues: issues.map((issue) => issue.message),
|
|
61093
61250
|
nextActions: [...nextActions],
|
|
@@ -61104,6 +61261,11 @@ const emptyAccountErrorDetails = () => {
|
|
|
61104
61261
|
errorSource: null
|
|
61105
61262
|
};
|
|
61106
61263
|
};
|
|
61264
|
+
function resolveAuthState(selectedApiKey, pendingRequest) {
|
|
61265
|
+
if (selectedApiKey !== null) return "signed_in";
|
|
61266
|
+
if (pendingRequest !== null) return "pending_approval";
|
|
61267
|
+
return "signed_out";
|
|
61268
|
+
}
|
|
61107
61269
|
const createInfoService = (deps) => {
|
|
61108
61270
|
const detectEnvironment = deps.detectExecutionEnvironmentFn ?? detectExecutionEnvironment;
|
|
61109
61271
|
const existsSyncFn = deps.existsSyncFn ?? existsSync;
|
|
@@ -61116,8 +61278,11 @@ const createInfoService = (deps) => {
|
|
|
61116
61278
|
envApiKey: deps.envApiKey
|
|
61117
61279
|
});
|
|
61118
61280
|
const installationIdResult = deps.credentialsStore.getInstallationId();
|
|
61281
|
+
const currentAuthRequestResult = deps.credentialsStore.getCurrentAuthRequest();
|
|
61119
61282
|
const installationId = Result.isOk(installationIdResult) ? installationIdResult.value : null;
|
|
61283
|
+
const pendingRequest = Result.isOk(currentAuthRequestResult) ? currentAuthRequestResult.value : null;
|
|
61120
61284
|
const selectedApiKey = apiKeyResolution.apiKey;
|
|
61285
|
+
const authState = resolveAuthState(selectedApiKey, pendingRequest);
|
|
61121
61286
|
const credentialsFileExists = existsSyncFn(deps.credentialsPath);
|
|
61122
61287
|
const endpoint = `${deps.baseUrl}${cliEndpoints.accountMe}`;
|
|
61123
61288
|
const pingHeaders = typeof selectedApiKey === "string" ? { Authorization: `Bearer ${selectedApiKey}` } : void 0;
|
|
@@ -61192,7 +61357,7 @@ const createInfoService = (deps) => {
|
|
|
61192
61357
|
}
|
|
61193
61358
|
return {
|
|
61194
61359
|
actingAgent: null,
|
|
61195
|
-
..."code" in accountResult.error ? { errorCode:
|
|
61360
|
+
..."code" in accountResult.error ? { errorCode: accountResult.error.code } : { errorCode: null },
|
|
61196
61361
|
..."httpStatus" in accountResult.error ? { errorHttpStatus: typeof accountResult.error.httpStatus === "number" ? accountResult.error.httpStatus : null } : { errorHttpStatus: null },
|
|
61197
61362
|
..."mcpCode" in accountResult.error ? { errorMcpCode: typeof accountResult.error.mcpCode === "number" ? accountResult.error.mcpCode : null } : { errorMcpCode: null },
|
|
61198
61363
|
..."raw" in accountResult.error ? { errorRaw: accountResult.error.raw ?? null } : { errorRaw: null },
|
|
@@ -61213,7 +61378,11 @@ const createInfoService = (deps) => {
|
|
|
61213
61378
|
code: "unreachable",
|
|
61214
61379
|
message: `Could not reach ${deps.baseUrl}: ${ping.error ?? "unknown error"}`
|
|
61215
61380
|
});
|
|
61216
|
-
if (
|
|
61381
|
+
if (authState === "pending_approval") issues.push({
|
|
61382
|
+
code: "pending_approval",
|
|
61383
|
+
message: "CLI sign-in is waiting for browser approval for the current request."
|
|
61384
|
+
});
|
|
61385
|
+
if (apiKeyResolution.source === "none" && authState !== "pending_approval") issues.push({
|
|
61217
61386
|
code: "no_api_key",
|
|
61218
61387
|
message: "No API key found in --api-key, OGMENT_API_KEY, or local auth state."
|
|
61219
61388
|
});
|
|
@@ -61241,14 +61410,20 @@ const createInfoService = (deps) => {
|
|
|
61241
61410
|
code: "credentials_load_failed",
|
|
61242
61411
|
message: `Failed to load installation identity: ${installationIdResult.error.message}`
|
|
61243
61412
|
});
|
|
61413
|
+
if (Result.isError(currentAuthRequestResult)) issues.push({
|
|
61414
|
+
code: "credentials_load_failed",
|
|
61415
|
+
message: `Failed to load pending auth state: ${currentAuthRequestResult.error.message}`
|
|
61416
|
+
});
|
|
61244
61417
|
return {
|
|
61245
61418
|
auth: {
|
|
61419
|
+
state: authState,
|
|
61246
61420
|
apiKeyPresent: selectedApiKey !== null,
|
|
61247
61421
|
apiKeyPreview: selectedApiKey === null ? null : maskApiKey(selectedApiKey),
|
|
61248
61422
|
apiKeySource: apiKeyResolution.source,
|
|
61249
61423
|
credentialsFileExists,
|
|
61250
61424
|
credentialsFileLoadError: apiKeyResolution.loadError?.message ?? null,
|
|
61251
|
-
installationId
|
|
61425
|
+
installationId,
|
|
61426
|
+
pendingRequest
|
|
61252
61427
|
},
|
|
61253
61428
|
config: {
|
|
61254
61429
|
baseUrl: deps.baseUrl,
|
|
@@ -61263,16 +61438,7 @@ const createInfoService = (deps) => {
|
|
|
61263
61438
|
"~/.config/ogment/auth-state.json",
|
|
61264
61439
|
...includeDebug ? ["default base URL when OGMENT_BASE_URL is unset"] : []
|
|
61265
61440
|
],
|
|
61266
|
-
quickCommands:
|
|
61267
|
-
"ogment status",
|
|
61268
|
-
"ogment login",
|
|
61269
|
-
"ogment logout",
|
|
61270
|
-
"ogment reset",
|
|
61271
|
-
"ogment catalog",
|
|
61272
|
-
"ogment catalog <server-id>",
|
|
61273
|
-
"ogment catalog <server-id> <tool-name>",
|
|
61274
|
-
"ogment invoke <server-id> <tool-name> --input '{}'"
|
|
61275
|
-
]
|
|
61441
|
+
quickCommands: rootQuickCommands()
|
|
61276
61442
|
},
|
|
61277
61443
|
generatedAt: new Date(now()).toISOString(),
|
|
61278
61444
|
remote: {
|
|
@@ -61286,7 +61452,7 @@ const createInfoService = (deps) => {
|
|
|
61286
61452
|
platform: process.platform,
|
|
61287
61453
|
processArch: process.arch
|
|
61288
61454
|
},
|
|
61289
|
-
summary: toSummary(issues, includeDebug)
|
|
61455
|
+
summary: toSummary(issues, includeDebug, authState)
|
|
61290
61456
|
};
|
|
61291
61457
|
} };
|
|
61292
61458
|
};
|
|
@@ -72123,8 +72289,8 @@ const asGlobalOptions = (command) => {
|
|
|
72123
72289
|
const options = command.optsWithGlobals();
|
|
72124
72290
|
return {
|
|
72125
72291
|
apiKey: options.apiKey,
|
|
72126
|
-
debug:
|
|
72127
|
-
quiet:
|
|
72292
|
+
debug: options.debug,
|
|
72293
|
+
quiet: options.quiet
|
|
72128
72294
|
};
|
|
72129
72295
|
};
|
|
72130
72296
|
const mapGlobalOutputOptions = (options) => {
|
|
@@ -72194,11 +72360,8 @@ const createProgram = (runtime, parseState) => {
|
|
|
72194
72360
|
program.command("login").summary("Authenticate this CLI installation").description("Start or complete browser-based login for this installation").helpGroup("Authentication Commands:").action(() => {
|
|
72195
72361
|
setInvocation({ kind: "login" });
|
|
72196
72362
|
});
|
|
72197
|
-
program.command("logout").summary("Sign this CLI installation out").description("Sign out the current local CLI session").helpGroup("Authentication Commands:").action(() => {
|
|
72198
|
-
setInvocation({ kind: "logout" });
|
|
72199
|
-
});
|
|
72200
|
-
program.command("reset").summary("Reset this CLI installation").description("Wipe local state and create a fresh CLI installation identity").helpGroup("Authentication Commands:").action(() => {
|
|
72201
|
-
setInvocation({ kind: "reset" });
|
|
72363
|
+
program.command("logout").summary("Sign this CLI installation out").description("Sign out the current local CLI session").helpGroup("Authentication Commands:").option("--reset", "Forget this installation and rotate its local identity").action((options) => {
|
|
72364
|
+
setInvocation({ kind: options.reset === true ? "logout_reset" : "logout" });
|
|
72202
72365
|
});
|
|
72203
72366
|
program.command("catalog [serverId] [toolName]").summary("Discover servers and inspect tools").description("Discover servers and tools with progressive disclosure").helpGroup("Discovery Commands:").addOption(new Option("--cursor <cursor>", "Pagination cursor (catalog summary only)").conflicts("example")).addOption(new Option("--limit <limit>", "Maximum servers to return (catalog summary only)").argParser(parseCatalogLimitOption).conflicts("example")).addOption(new Option("--example", "Include a generated example input payload (tool details only)").conflicts(["cursor", "limit"])).action((serverId, toolName, options) => {
|
|
72204
72367
|
setInvocation({
|
|
@@ -72248,7 +72411,6 @@ const CLI_PACKAGE_NAME = "@ogment-ai/cli";
|
|
|
72248
72411
|
const PARSE_ERROR_SCOPE_COMMAND_PATHS = {
|
|
72249
72412
|
login: "ogment login <parse_error>",
|
|
72250
72413
|
logout: "ogment logout <parse_error>",
|
|
72251
|
-
reset: "ogment reset <parse_error>",
|
|
72252
72414
|
catalog: "ogment catalog <parse_error>",
|
|
72253
72415
|
invoke: "ogment invoke <parse_error>",
|
|
72254
72416
|
status: "ogment status <parse_error>"
|
|
@@ -72283,10 +72445,10 @@ const telemetryContextResolvers = {
|
|
|
72283
72445
|
inputMode: null
|
|
72284
72446
|
};
|
|
72285
72447
|
},
|
|
72286
|
-
|
|
72448
|
+
logout_reset: (_) => {
|
|
72287
72449
|
return {
|
|
72288
|
-
commandKind: "
|
|
72289
|
-
commandPath: "ogment reset",
|
|
72450
|
+
commandKind: "logout_reset",
|
|
72451
|
+
commandPath: "ogment logout --reset",
|
|
72290
72452
|
inputMode: null
|
|
72291
72453
|
};
|
|
72292
72454
|
},
|
|
@@ -72333,7 +72495,7 @@ const telemetryContextFromInvocation = (invocation) => {
|
|
|
72333
72495
|
switch (invocation.kind) {
|
|
72334
72496
|
case "login": return telemetryContextResolvers.login(invocation);
|
|
72335
72497
|
case "logout": return telemetryContextResolvers.logout(invocation);
|
|
72336
|
-
case "
|
|
72498
|
+
case "logout_reset": return telemetryContextResolvers.logout_reset(invocation);
|
|
72337
72499
|
case "catalog": return telemetryContextResolvers.catalog(invocation);
|
|
72338
72500
|
case "invoke": return telemetryContextResolvers.invoke(invocation);
|
|
72339
72501
|
case "root": return telemetryContextResolvers.root(invocation);
|
|
@@ -72417,7 +72579,7 @@ const commandContextFromInvocation = (invocation, apiKeyOverride) => {
|
|
|
72417
72579
|
switch (invocation.kind) {
|
|
72418
72580
|
case "login": return withBase("login", "login");
|
|
72419
72581
|
case "logout": return withBase("logout", "logout");
|
|
72420
|
-
case "
|
|
72582
|
+
case "logout_reset": return withBase("logout", "logout_reset", "--reset");
|
|
72421
72583
|
case "catalog":
|
|
72422
72584
|
if (invocation.toolName !== void 0) return withBase("catalog", "catalog", "tool");
|
|
72423
72585
|
if (invocation.serverId !== void 0) return withBase("catalog", "catalog", "server");
|
|
@@ -72575,4 +72737,4 @@ if (shouldExecuteCli(import.meta.url, process.argv[1])) await executeCli();
|
|
|
72575
72737
|
|
|
72576
72738
|
//#endregion
|
|
72577
72739
|
export { executeCli, runCli, shouldExecuteCli };
|
|
72578
|
-
//# debugId=
|
|
72740
|
+
//# debugId=fda73b83-a425-4a1b-a698-42d3d51d54f1
|