@ogment-ai/cli 0.9.1-next.0 → 0.9.1-next.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/dist/cli.js +493 -507
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8017,7 +8017,7 @@ const defaultRecoveryByCode = {
|
|
|
8017
8017
|
},
|
|
8018
8018
|
[ERROR_CODE.authRequired]: {
|
|
8019
8019
|
command: "ogment auth login",
|
|
8020
|
-
reason: "Authentication is required before catalog or
|
|
8020
|
+
reason: "Authentication is required before catalog, search, or execute commands can run.",
|
|
8021
8021
|
title: "Authenticate",
|
|
8022
8022
|
when: "immediate"
|
|
8023
8023
|
},
|
|
@@ -8053,14 +8053,14 @@ const defaultRecoveryByCode = {
|
|
|
8053
8053
|
},
|
|
8054
8054
|
[ERROR_CODE.toolInputSchemaViolation]: {
|
|
8055
8055
|
command: "ogment catalog",
|
|
8056
|
-
reason: "Tool contract did not validate; inspect available servers
|
|
8056
|
+
reason: "Tool contract did not validate; inspect available servers before retrying search or execute.",
|
|
8057
8057
|
title: "Inspect catalog",
|
|
8058
8058
|
when: "immediate"
|
|
8059
8059
|
},
|
|
8060
8060
|
[ERROR_CODE.toolNotFound]: {
|
|
8061
8061
|
command: "ogment catalog",
|
|
8062
|
-
reason: "Requested tool could not be found; rediscover servers
|
|
8063
|
-
title: "Rediscover
|
|
8062
|
+
reason: "Requested server or tool context could not be found; rediscover available servers.",
|
|
8063
|
+
title: "Rediscover servers",
|
|
8064
8064
|
when: "immediate"
|
|
8065
8065
|
},
|
|
8066
8066
|
[ERROR_CODE.transportRequestFailed]: {
|
|
@@ -8363,7 +8363,7 @@ const parseJsonValue = (raw, context) => {
|
|
|
8363
8363
|
}
|
|
8364
8364
|
});
|
|
8365
8365
|
};
|
|
8366
|
-
const isRecord$
|
|
8366
|
+
const isRecord$1 = (value) => {
|
|
8367
8367
|
return typeof value === "object" && value !== null;
|
|
8368
8368
|
};
|
|
8369
8369
|
|
|
@@ -13738,8 +13738,11 @@ const cacheSchema = object({
|
|
|
13738
13738
|
latestVersion: string().optional()
|
|
13739
13739
|
});
|
|
13740
13740
|
const isPrereleaseVersion = (version) => {
|
|
13741
|
-
|
|
13742
|
-
|
|
13741
|
+
return (import_semver.default.parse(version)?.prerelease.length ?? 0) > 0;
|
|
13742
|
+
};
|
|
13743
|
+
const normalizeLatestVersionCandidate = (version) => {
|
|
13744
|
+
if (version === void 0 || isPrereleaseVersion(version)) return;
|
|
13745
|
+
return version;
|
|
13743
13746
|
};
|
|
13744
13747
|
const isTruthyEnvValue = (value) => {
|
|
13745
13748
|
if (value === void 0) return false;
|
|
@@ -13807,18 +13810,19 @@ const maybeGetAvailableCliUpdate = async (options, deps = {}) => {
|
|
|
13807
13810
|
const cachePath = cachePathFromConfigDir(options.configDir ?? defaultConfigDir());
|
|
13808
13811
|
let latestVersion;
|
|
13809
13812
|
const existingCache = readCache(cachePath);
|
|
13813
|
+
const cachedLatestVersion = normalizeLatestVersionCandidate(existingCache?.latestVersion);
|
|
13810
13814
|
const nowMs = now().getTime();
|
|
13811
13815
|
if (existingCache === void 0 || nowMs - existingCache.lastCheckedAtMs >= UPDATE_CHECK_INTERVAL_MS) {
|
|
13812
13816
|
try {
|
|
13813
|
-
latestVersion = await fetchWithTimeout(options.packageName, fetchLatestVersion);
|
|
13817
|
+
latestVersion = normalizeLatestVersionCandidate(await fetchWithTimeout(options.packageName, fetchLatestVersion)) ?? cachedLatestVersion;
|
|
13814
13818
|
} catch {
|
|
13815
|
-
latestVersion =
|
|
13819
|
+
latestVersion = cachedLatestVersion;
|
|
13816
13820
|
}
|
|
13817
13821
|
writeCache(cachePath, {
|
|
13818
13822
|
...latestVersion === void 0 ? {} : { latestVersion },
|
|
13819
13823
|
lastCheckedAtMs: nowMs
|
|
13820
13824
|
});
|
|
13821
|
-
} else latestVersion =
|
|
13825
|
+
} else latestVersion = cachedLatestVersion;
|
|
13822
13826
|
if (latestVersion !== void 0 && isNewerVersion(latestVersion, options.currentVersion)) return {
|
|
13823
13827
|
currentVersion: options.currentVersion,
|
|
13824
13828
|
latestVersion,
|
|
@@ -13850,7 +13854,7 @@ const parseRemoteErrorDetails = (payload) => {
|
|
|
13850
13854
|
}
|
|
13851
13855
|
return { message: trimmed };
|
|
13852
13856
|
}
|
|
13853
|
-
if (!isRecord$
|
|
13857
|
+
if (!isRecord$1(payload)) return {};
|
|
13854
13858
|
const directCode = payload["code"];
|
|
13855
13859
|
const directMessage = payload["message"];
|
|
13856
13860
|
if (typeof directCode === "number" || typeof directMessage === "string") return {
|
|
@@ -13859,7 +13863,7 @@ const parseRemoteErrorDetails = (payload) => {
|
|
|
13859
13863
|
...Object.hasOwn(payload, "data") ? { data: toJsonValue(payload["data"]) } : {}
|
|
13860
13864
|
};
|
|
13861
13865
|
const nestedError = payload["error"];
|
|
13862
|
-
if (!isRecord$
|
|
13866
|
+
if (!isRecord$1(nestedError)) return {};
|
|
13863
13867
|
return {
|
|
13864
13868
|
...typeof nestedError["code"] === "number" ? { mcpCode: nestedError["code"] } : {},
|
|
13865
13869
|
...typeof nestedError["message"] === "string" ? { message: nestedError["message"] } : {},
|
|
@@ -13950,17 +13954,6 @@ const presentRuntimeErrorPayload = (error, options) => {
|
|
|
13950
13954
|
title: appErrorTitle(error)
|
|
13951
13955
|
};
|
|
13952
13956
|
};
|
|
13953
|
-
const presentCatalogFailureError = (error, options) => {
|
|
13954
|
-
const payload = presentRuntimeErrorPayload(error, options);
|
|
13955
|
-
return {
|
|
13956
|
-
code: payload.code,
|
|
13957
|
-
detail: payload.detail,
|
|
13958
|
-
diagnostics: payload.diagnostics,
|
|
13959
|
-
...payload.related_codes === void 0 ? {} : { related_codes: payload.related_codes },
|
|
13960
|
-
retryable: payload.retryable,
|
|
13961
|
-
title: payload.title
|
|
13962
|
-
};
|
|
13963
|
-
};
|
|
13964
13957
|
|
|
13965
13958
|
//#endregion
|
|
13966
13959
|
//#region src/output/envelope.ts
|
|
@@ -14224,12 +14217,13 @@ const cliCommandKindSchema = _enum([
|
|
|
14224
14217
|
"auth_login",
|
|
14225
14218
|
"auth_logout",
|
|
14226
14219
|
"auth_status",
|
|
14220
|
+
"catalog_detail",
|
|
14227
14221
|
"catalog_summary",
|
|
14228
|
-
"
|
|
14229
|
-
"
|
|
14230
|
-
"invoke",
|
|
14222
|
+
"catalog_tool_detail",
|
|
14223
|
+
"execute",
|
|
14231
14224
|
"parse_error",
|
|
14232
14225
|
"root",
|
|
14226
|
+
"search",
|
|
14233
14227
|
"runtime_error",
|
|
14234
14228
|
"status"
|
|
14235
14229
|
]);
|
|
@@ -14396,6 +14390,16 @@ const runAuthLogoutCommand = async (context) => {
|
|
|
14396
14390
|
|
|
14397
14391
|
//#endregion
|
|
14398
14392
|
//#region src/commands/server-context.ts
|
|
14393
|
+
const commandNameForSelectorKind = (selectorKind) => {
|
|
14394
|
+
return selectorKind;
|
|
14395
|
+
};
|
|
14396
|
+
const selectorRecoveryCommand = (selectorKind, selector, orgSlug, toolName) => {
|
|
14397
|
+
switch (selectorKind) {
|
|
14398
|
+
case "catalog": return toolName === void 0 ? `ogment catalog ${orgSlug}/${selector}` : `ogment catalog ${orgSlug}/${selector} ${toolName}`;
|
|
14399
|
+
case "search": return `ogment search --org ${orgSlug} ${selector} --code 'return input'`;
|
|
14400
|
+
case "execute": return `ogment execute --org ${orgSlug} ${selector} --code 'return input' --input '{}'`;
|
|
14401
|
+
}
|
|
14402
|
+
};
|
|
14399
14403
|
const formatCandidateSelectors = (profile, path) => {
|
|
14400
14404
|
return profile.orgs.flatMap((org) => {
|
|
14401
14405
|
return org.servers.filter((server) => server.path === path).map((server) => `${org.orgSlug}/${server.path}`);
|
|
@@ -14462,8 +14466,9 @@ const findServerByPath = (profile, selector, options) => {
|
|
|
14462
14466
|
const [firstCandidate] = sortedCandidates;
|
|
14463
14467
|
if (firstCandidate !== void 0) {
|
|
14464
14468
|
const firstCandidateParsed = parseQualifiedSelector(firstCandidate);
|
|
14465
|
-
const
|
|
14466
|
-
const
|
|
14469
|
+
const commandName = commandNameForSelectorKind(options.selectorKind);
|
|
14470
|
+
const message = `Server "${selector}" is ambiguous across organizations (${sortedCandidates.join(", ")}). Re-run \`ogment ${commandName}\` with --org <org-slug> or use a qualified selector like "${firstCandidate}".`;
|
|
14471
|
+
const recoveryCommand = firstCandidateParsed === null ? `ogment ${commandName} --help` : selectorRecoveryCommand(options.selectorKind, selector, firstCandidateParsed.orgSlug, options.toolName);
|
|
14467
14472
|
return Result.err(new ValidationError({
|
|
14468
14473
|
message,
|
|
14469
14474
|
recovery: { command: recoveryCommand }
|
|
@@ -14483,96 +14488,75 @@ const findServerByPath = (profile, selector, options) => {
|
|
|
14483
14488
|
|
|
14484
14489
|
//#endregion
|
|
14485
14490
|
//#region src/commands/catalog.ts
|
|
14486
|
-
const toServerSummary = (target
|
|
14491
|
+
const toServerSummary = (target) => {
|
|
14487
14492
|
return {
|
|
14488
14493
|
capabilities: [],
|
|
14489
14494
|
description: target.server.description,
|
|
14490
14495
|
name: target.server.name,
|
|
14491
14496
|
orgSlug: target.orgSlug,
|
|
14492
14497
|
serverId: target.server.path,
|
|
14493
|
-
toolCount,
|
|
14494
14498
|
version: null
|
|
14495
14499
|
};
|
|
14496
14500
|
};
|
|
14497
|
-
const
|
|
14498
|
-
return
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
};
|
|
14503
|
-
});
|
|
14504
|
-
};
|
|
14505
|
-
const listServerTools = async (context, apiKey, server) => {
|
|
14506
|
-
return context.services.mcp.listTools({
|
|
14507
|
-
orgSlug: server.orgSlug,
|
|
14508
|
-
serverPath: server.server.path
|
|
14509
|
-
}, apiKey);
|
|
14501
|
+
const toToolSummary = (tool) => {
|
|
14502
|
+
return {
|
|
14503
|
+
description: tool.description ?? null,
|
|
14504
|
+
name: tool.name
|
|
14505
|
+
};
|
|
14510
14506
|
};
|
|
14511
|
-
const
|
|
14512
|
-
const toCatalogServerFailure = (server, error, includeDebug) => {
|
|
14507
|
+
const toToolDetail = (tool) => {
|
|
14513
14508
|
return {
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14509
|
+
description: tool.description ?? null,
|
|
14510
|
+
inputSchema: toJsonValue(tool.inputSchema),
|
|
14511
|
+
name: tool.name,
|
|
14512
|
+
outputSchema: tool.outputSchema === void 0 ? null : toJsonValue(tool.outputSchema)
|
|
14517
14513
|
};
|
|
14518
14514
|
};
|
|
14519
|
-
const
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14515
|
+
const detailCommandForServer = (serverId, orgSlug) => {
|
|
14516
|
+
return `ogment catalog ${orgSlug === void 0 ? serverId : `${orgSlug}/${serverId}`}`;
|
|
14517
|
+
};
|
|
14518
|
+
const resolveCatalogServerTarget = async (context, options) => {
|
|
14519
|
+
const stateResult = await resolveServerState(context);
|
|
14520
|
+
if (Result.isError(stateResult)) return stateResult;
|
|
14521
|
+
const serverResult = findServerByPath(stateResult.value.profile, options.serverId, {
|
|
14522
|
+
...options.orgSlug === void 0 ? {} : { orgSlug: options.orgSlug },
|
|
14523
|
+
selectorKind: "catalog",
|
|
14524
|
+
..."toolName" in options ? { toolName: options.toolName } : {}
|
|
14525
|
+
});
|
|
14526
|
+
if (Result.isError(serverResult)) return serverResult;
|
|
14527
|
+
return Result.ok({
|
|
14528
|
+
apiKey: stateResult.value.apiKey,
|
|
14529
|
+
target: {
|
|
14530
|
+
orgSlug: serverResult.value.orgSlug,
|
|
14531
|
+
server: {
|
|
14532
|
+
description: serverResult.value.server.description,
|
|
14533
|
+
name: serverResult.value.server.name,
|
|
14534
|
+
path: serverResult.value.server.path
|
|
14535
|
+
}
|
|
14536
|
+
}
|
|
14537
|
+
});
|
|
14538
|
+
};
|
|
14539
|
+
const listCodeModeTools = async (context, apiKey, target) => {
|
|
14540
|
+
return context.services.codemode.listTools({
|
|
14541
|
+
orgSlug: target.orgSlug,
|
|
14542
|
+
serverPath: target.server.path
|
|
14543
|
+
}, apiKey);
|
|
14537
14544
|
};
|
|
14538
14545
|
const runCatalogCommand = async (context, options) => {
|
|
14539
14546
|
const stateResult = await resolveServerState(context);
|
|
14540
14547
|
if (Result.isError(stateResult)) return stateResult;
|
|
14541
|
-
|
|
14542
|
-
|
|
14548
|
+
const targetOrgs = options.orgSlug === void 0 ? stateResult.value.profile.orgs : stateResult.value.profile.orgs.filter((org) => org.orgSlug === options.orgSlug);
|
|
14549
|
+
if (options.orgSlug !== void 0 && targetOrgs.length === 0) return Result.err(new ValidationError({
|
|
14550
|
+
code: ERROR_CODE.validationInvalidInput,
|
|
14551
|
+
message: `Organization "${options.orgSlug}" not found`,
|
|
14552
|
+
recovery: { command: "ogment catalog" }
|
|
14553
|
+
}));
|
|
14554
|
+
const summaries = targetOrgs.flatMap((org) => {
|
|
14555
|
+
return org.servers.map((server) => toServerSummary({
|
|
14543
14556
|
orgSlug: org.orgSlug,
|
|
14544
14557
|
server
|
|
14545
14558
|
}));
|
|
14546
14559
|
});
|
|
14547
|
-
if (options.serverId !== void 0) {
|
|
14548
|
-
const serverResult = findServerByPath(stateResult.value.profile, options.serverId, { selectorKind: "catalog" });
|
|
14549
|
-
if (Result.isError(serverResult)) return serverResult;
|
|
14550
|
-
targetServers = [{
|
|
14551
|
-
orgSlug: serverResult.value.orgSlug,
|
|
14552
|
-
server: serverResult.value.server
|
|
14553
|
-
}];
|
|
14554
|
-
}
|
|
14555
|
-
const serverSummaries = await mapWithConcurrency(targetServers, TOOL_COUNT_CONCURRENCY, async (server) => {
|
|
14556
|
-
return {
|
|
14557
|
-
server,
|
|
14558
|
-
toolsResult: await listServerTools(context, stateResult.value.apiKey, server)
|
|
14559
|
-
};
|
|
14560
|
-
});
|
|
14561
|
-
const summaries = [];
|
|
14562
|
-
const failures = [];
|
|
14563
|
-
for (const serverSummary of serverSummaries) {
|
|
14564
|
-
if (Result.isError(serverSummary.toolsResult)) {
|
|
14565
|
-
if (options.serverId !== void 0) return serverSummary.toolsResult;
|
|
14566
|
-
failures.push(toCatalogServerFailure(serverSummary.server, serverSummary.toolsResult.error, options.includeDebug === true));
|
|
14567
|
-
continue;
|
|
14568
|
-
}
|
|
14569
|
-
summaries.push(toServerSummary(serverSummary.server, serverSummary.toolsResult.value.length));
|
|
14570
|
-
}
|
|
14571
|
-
if (options.serverId !== void 0) return Result.ok({
|
|
14572
|
-
failures: [],
|
|
14573
|
-
nextCursor: null,
|
|
14574
|
-
servers: summaries
|
|
14575
|
-
});
|
|
14576
14560
|
const limit = Math.max(1, options.limit ?? 20);
|
|
14577
14561
|
let startIndex = 0;
|
|
14578
14562
|
if (options.cursor !== void 0) {
|
|
@@ -14587,81 +14571,52 @@ const runCatalogCommand = async (context, options) => {
|
|
|
14587
14571
|
const servers = summaries.slice(startIndex, startIndex + limit);
|
|
14588
14572
|
const nextCursor = startIndex + limit < summaries.length ? servers.at(-1)?.serverId ?? null : null;
|
|
14589
14573
|
return Result.ok({
|
|
14590
|
-
failures,
|
|
14574
|
+
failures: [],
|
|
14591
14575
|
nextCursor,
|
|
14592
14576
|
servers
|
|
14593
14577
|
});
|
|
14594
14578
|
};
|
|
14595
|
-
const
|
|
14596
|
-
const
|
|
14597
|
-
if (Result.isError(
|
|
14598
|
-
const
|
|
14599
|
-
if (Result.isError(serverResult)) return serverResult;
|
|
14600
|
-
const targetServer = {
|
|
14601
|
-
orgSlug: serverResult.value.orgSlug,
|
|
14602
|
-
server: serverResult.value.server
|
|
14603
|
-
};
|
|
14604
|
-
const toolsResult = await listServerTools(context, stateResult.value.apiKey, targetServer);
|
|
14579
|
+
const runCatalogServerDetailCommand = async (context, options) => {
|
|
14580
|
+
const targetResult = await resolveCatalogServerTarget(context, options);
|
|
14581
|
+
if (Result.isError(targetResult)) return targetResult;
|
|
14582
|
+
const toolsResult = await listCodeModeTools(context, targetResult.value.apiKey, targetResult.value.target);
|
|
14605
14583
|
if (Result.isError(toolsResult)) return toolsResult;
|
|
14606
14584
|
return Result.ok({
|
|
14607
|
-
server: toServerSummary(
|
|
14608
|
-
tools:
|
|
14585
|
+
server: toServerSummary(targetResult.value.target),
|
|
14586
|
+
tools: toolsResult.value.map((tool) => toToolSummary(tool))
|
|
14609
14587
|
});
|
|
14610
14588
|
};
|
|
14611
|
-
const
|
|
14612
|
-
const
|
|
14613
|
-
if (Result.isError(
|
|
14614
|
-
const
|
|
14615
|
-
if (Result.isError(serverResult)) return serverResult;
|
|
14616
|
-
const targetServer = {
|
|
14617
|
-
orgSlug: serverResult.value.orgSlug,
|
|
14618
|
-
server: serverResult.value.server
|
|
14619
|
-
};
|
|
14620
|
-
const toolsResult = await listServerTools(context, stateResult.value.apiKey, targetServer);
|
|
14589
|
+
const runCatalogToolDetailCommand = async (context, options) => {
|
|
14590
|
+
const targetResult = await resolveCatalogServerTarget(context, options);
|
|
14591
|
+
if (Result.isError(targetResult)) return targetResult;
|
|
14592
|
+
const toolsResult = await listCodeModeTools(context, targetResult.value.apiKey, targetResult.value.target);
|
|
14621
14593
|
if (Result.isError(toolsResult)) return toolsResult;
|
|
14622
|
-
const tool = toolsResult.value.find((
|
|
14594
|
+
const tool = toolsResult.value.find((candidate) => {
|
|
14595
|
+
return candidate.name === options.toolName;
|
|
14596
|
+
});
|
|
14623
14597
|
if (tool === void 0) return Result.err(new NotFoundError({
|
|
14624
|
-
message: `
|
|
14625
|
-
|
|
14598
|
+
message: `Codemode tool "${options.toolName}" not found on server "${options.serverId}"`,
|
|
14599
|
+
recovery: { command: detailCommandForServer(targetResult.value.target.server.path, targetResult.value.target.orgSlug) },
|
|
14600
|
+
resource: `${options.serverId}/${options.toolName}`
|
|
14626
14601
|
}));
|
|
14627
14602
|
return Result.ok({
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
name: tool.name,
|
|
14631
|
-
outputSchema: tool.outputSchema ?? null,
|
|
14632
|
-
server: toServerSummary(targetServer, toolsResult.value.length)
|
|
14603
|
+
server: toServerSummary(targetResult.value.target),
|
|
14604
|
+
tool: toToolDetail(tool)
|
|
14633
14605
|
});
|
|
14634
14606
|
};
|
|
14635
14607
|
|
|
14636
14608
|
//#endregion
|
|
14637
|
-
//#region src/commands/
|
|
14638
|
-
const
|
|
14609
|
+
//#region src/commands/codemode.ts
|
|
14610
|
+
const mapSourceFileReadError = (inputFile, optionName, cause) => {
|
|
14639
14611
|
const code = cause instanceof Error && "code" in cause && typeof cause.code === "string" ? cause.code : void 0;
|
|
14640
|
-
if (code === "ENOENT") return new ValidationError({ message:
|
|
14641
|
-
if (code === "EACCES" || code === "EPERM") return new ValidationError({ message:
|
|
14642
|
-
if (code === "EISDIR") return new ValidationError({ message:
|
|
14612
|
+
if (code === "ENOENT") return new ValidationError({ message: `${optionName} file not found: ${inputFile}` });
|
|
14613
|
+
if (code === "EACCES" || code === "EPERM") return new ValidationError({ message: `${optionName} file is not readable: ${inputFile}` });
|
|
14614
|
+
if (code === "EISDIR") return new ValidationError({ message: `${optionName} path must be a file: ${inputFile}` });
|
|
14643
14615
|
return new UnexpectedError({
|
|
14644
14616
|
cause,
|
|
14645
|
-
message: `Failed to read
|
|
14617
|
+
message: `Failed to read ${optionName} file: ${inputFile}`
|
|
14646
14618
|
});
|
|
14647
14619
|
};
|
|
14648
|
-
const parseInputObject = (raw, context) => {
|
|
14649
|
-
const parsed = parseJsonValue(raw, context);
|
|
14650
|
-
if (Result.isError(parsed)) return parsed;
|
|
14651
|
-
const parsedValue = parsed.value;
|
|
14652
|
-
if (!isJsonObject(parsedValue)) return Result.err(new ValidationError({ message: "Invoke input must be a JSON object" }));
|
|
14653
|
-
return Result.ok(parsedValue);
|
|
14654
|
-
};
|
|
14655
|
-
const toToolCallStructuredContent = (result) => {
|
|
14656
|
-
if (result.structuredContent !== void 0) return toJsonValue(result.structuredContent);
|
|
14657
|
-
const firstContent = (Array.isArray(result.content) ? result.content : [])[0];
|
|
14658
|
-
if (firstContent !== void 0 && firstContent.type === "text" && typeof firstContent.text === "string") {
|
|
14659
|
-
const parsedText = parseJsonValue(firstContent.text, "MCP text content");
|
|
14660
|
-
if (Result.isError(parsedText)) return firstContent.text;
|
|
14661
|
-
return parsedText.value;
|
|
14662
|
-
}
|
|
14663
|
-
return toJsonValue(result);
|
|
14664
|
-
};
|
|
14665
14620
|
const readStdin = async () => {
|
|
14666
14621
|
return Result.tryPromise({
|
|
14667
14622
|
catch: (cause) => new UnexpectedError({
|
|
@@ -14685,73 +14640,111 @@ const readStdin = async () => {
|
|
|
14685
14640
|
}
|
|
14686
14641
|
});
|
|
14687
14642
|
};
|
|
14688
|
-
const
|
|
14689
|
-
if (
|
|
14690
|
-
if (
|
|
14691
|
-
const
|
|
14692
|
-
if (Result.isError(stdinResult)) return stdinResult;
|
|
14693
|
-
return parseInputObject(stdinResult.value, "--input (-)");
|
|
14694
|
-
}
|
|
14695
|
-
if (options.input.startsWith("@")) {
|
|
14696
|
-
const inputFile = options.input.slice(1);
|
|
14643
|
+
const readSourceValue = async (value, optionName, deps) => {
|
|
14644
|
+
if (value === "-") return (deps.readStdin ?? readStdin)();
|
|
14645
|
+
if (value.startsWith("@")) {
|
|
14646
|
+
const inputFile = value.slice(1);
|
|
14697
14647
|
if (inputFile.length === 0) return Result.err(new ValidationError({
|
|
14698
|
-
details:
|
|
14699
|
-
message:
|
|
14648
|
+
details: value,
|
|
14649
|
+
message: `Invalid ${optionName} value. Use @<path>, -, or an inline value.`
|
|
14700
14650
|
}));
|
|
14701
|
-
|
|
14702
|
-
catch: (cause) =>
|
|
14651
|
+
return Result.tryPromise({
|
|
14652
|
+
catch: (cause) => mapSourceFileReadError(inputFile, optionName, cause),
|
|
14703
14653
|
try: async () => readFile$1(inputFile, "utf8")
|
|
14704
14654
|
});
|
|
14705
|
-
if (Result.isError(fileReadResult)) return fileReadResult;
|
|
14706
|
-
return parseInputObject(fileReadResult.value, "--input (@file)");
|
|
14707
14655
|
}
|
|
14708
|
-
return
|
|
14656
|
+
return Result.ok(value);
|
|
14709
14657
|
};
|
|
14710
|
-
const
|
|
14711
|
-
const
|
|
14712
|
-
if (Result.isError(
|
|
14658
|
+
const parseInputObject = (raw, context) => {
|
|
14659
|
+
const parsed = parseJsonValue(raw, context);
|
|
14660
|
+
if (Result.isError(parsed)) return parsed;
|
|
14661
|
+
if (!isJsonObject(parsed.value)) return Result.err(new ValidationError({ message: "Execute input must be a JSON object" }));
|
|
14662
|
+
return Result.ok(parsed.value);
|
|
14663
|
+
};
|
|
14664
|
+
const parseExecuteInput = async (input, deps) => {
|
|
14665
|
+
if (input === void 0) return Result.ok(void 0);
|
|
14666
|
+
const sourceResult = await readSourceValue(input, "--input", deps);
|
|
14667
|
+
if (Result.isError(sourceResult)) return sourceResult;
|
|
14668
|
+
const sourceContext = input === "-" ? "--input (-)" : input.startsWith("@") ? "--input (@file)" : "--input";
|
|
14669
|
+
return parseInputObject(sourceResult.value, sourceContext);
|
|
14670
|
+
};
|
|
14671
|
+
const toToolCallStructuredContent = (result) => {
|
|
14672
|
+
if (result.structuredContent !== void 0) return toJsonValue(result.structuredContent);
|
|
14673
|
+
const firstContent = (Array.isArray(result.content) ? result.content : [])[0];
|
|
14674
|
+
if (firstContent !== void 0 && firstContent.type === "text" && typeof firstContent.text === "string") {
|
|
14675
|
+
const parsedText = parseJsonValue(firstContent.text, "MCP text content");
|
|
14676
|
+
if (Result.isError(parsedText)) return firstContent.text;
|
|
14677
|
+
return parsedText.value;
|
|
14678
|
+
}
|
|
14679
|
+
return toJsonValue(result);
|
|
14680
|
+
};
|
|
14681
|
+
const resolveServerTarget = async (context, options, selectorKind) => {
|
|
14713
14682
|
const stateResult = await resolveServerState(context);
|
|
14714
14683
|
if (Result.isError(stateResult)) return stateResult;
|
|
14715
14684
|
const serverResult = findServerByPath(stateResult.value.profile, options.serverId, {
|
|
14716
14685
|
...options.orgSlug === void 0 ? {} : { orgSlug: options.orgSlug },
|
|
14717
|
-
selectorKind
|
|
14718
|
-
toolName: options.toolName
|
|
14686
|
+
selectorKind
|
|
14719
14687
|
});
|
|
14720
14688
|
if (Result.isError(serverResult)) return serverResult;
|
|
14721
|
-
|
|
14689
|
+
return Result.ok({
|
|
14690
|
+
apiKey: stateResult.value.apiKey,
|
|
14722
14691
|
orgSlug: serverResult.value.orgSlug,
|
|
14723
14692
|
serverPath: serverResult.value.server.path
|
|
14724
|
-
};
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14693
|
+
});
|
|
14694
|
+
};
|
|
14695
|
+
const codemodeErrorFromToolResult = (result) => {
|
|
14696
|
+
if (!result.isError) return null;
|
|
14697
|
+
const structuredContent = toToolCallStructuredContent(result);
|
|
14698
|
+
const details = parseRemoteErrorDetails(structuredContent);
|
|
14699
|
+
return new RemoteRequestError({
|
|
14700
|
+
...details.mcpCode === void 0 ? {} : { mcpCode: details.mcpCode },
|
|
14701
|
+
...details.data === void 0 ? {} : { mcpData: details.data },
|
|
14702
|
+
message: details.message ?? "Codemode tool call returned an error result",
|
|
14703
|
+
operation: "tools/call",
|
|
14704
|
+
raw: structuredContent,
|
|
14705
|
+
retryable: false,
|
|
14706
|
+
source: "mcp_jsonrpc"
|
|
14707
|
+
});
|
|
14708
|
+
};
|
|
14709
|
+
const runSearchCommand = async (context, options, deps = {}) => {
|
|
14710
|
+
const codeResult = await readSourceValue(options.code, "--code", deps);
|
|
14711
|
+
if (Result.isError(codeResult)) return codeResult;
|
|
14712
|
+
const targetResult = await resolveServerTarget(context, options, "search");
|
|
14713
|
+
if (Result.isError(targetResult)) return targetResult;
|
|
14714
|
+
const callResult = await context.services.codemode.callTool({
|
|
14715
|
+
orgSlug: targetResult.value.orgSlug,
|
|
14716
|
+
serverPath: targetResult.value.serverPath
|
|
14717
|
+
}, targetResult.value.apiKey, "search", { code: codeResult.value });
|
|
14718
|
+
if (Result.isError(callResult)) return callResult;
|
|
14719
|
+
const toolError = codemodeErrorFromToolResult(callResult.value);
|
|
14720
|
+
if (toolError !== null) return Result.err(toolError);
|
|
14721
|
+
return Result.ok({
|
|
14722
|
+
result: toToolCallStructuredContent(callResult.value),
|
|
14723
|
+
serverId: options.serverId
|
|
14724
|
+
});
|
|
14725
|
+
};
|
|
14726
|
+
const runExecuteCommand = async (context, options, deps = {}) => {
|
|
14727
|
+
const [codeResult, inputResult, targetResult] = await Promise.all([
|
|
14728
|
+
readSourceValue(options.code, "--code", deps),
|
|
14729
|
+
parseExecuteInput(options.input, deps),
|
|
14730
|
+
resolveServerTarget(context, options, "execute")
|
|
14731
|
+
]);
|
|
14732
|
+
if (Result.isError(codeResult)) return codeResult;
|
|
14733
|
+
if (Result.isError(inputResult)) return inputResult;
|
|
14734
|
+
if (Result.isError(targetResult)) return targetResult;
|
|
14735
|
+
const callResult = await context.services.codemode.callTool({
|
|
14736
|
+
orgSlug: targetResult.value.orgSlug,
|
|
14737
|
+
serverPath: targetResult.value.serverPath
|
|
14738
|
+
}, targetResult.value.apiKey, "execute", {
|
|
14739
|
+
code: codeResult.value,
|
|
14740
|
+
...inputResult.value === void 0 ? {} : { input: inputResult.value }
|
|
14741
|
+
});
|
|
14742
|
+
if (Result.isError(callResult)) return callResult;
|
|
14743
|
+
const toolError = codemodeErrorFromToolResult(callResult.value);
|
|
14744
|
+
if (toolError !== null) return Result.err(toolError);
|
|
14751
14745
|
return Result.ok({
|
|
14752
|
-
result:
|
|
14753
|
-
serverId: options.serverId
|
|
14754
|
-
toolName: options.toolName
|
|
14746
|
+
result: toToolCallStructuredContent(callResult.value),
|
|
14747
|
+
serverId: options.serverId
|
|
14755
14748
|
});
|
|
14756
14749
|
};
|
|
14757
14750
|
|
|
@@ -14761,71 +14754,11 @@ const runStatusCommand = async (options, deps) => {
|
|
|
14761
14754
|
return deps.infoService.collect(options.apiKeyOverride, { includeDebug: options.debug });
|
|
14762
14755
|
};
|
|
14763
14756
|
|
|
14764
|
-
//#endregion
|
|
14765
|
-
//#region src/shared/schema-example.ts
|
|
14766
|
-
const MAX_EXAMPLE_DEPTH = 6;
|
|
14767
|
-
const EXAMPLE_PLACEHOLDER = " ... ";
|
|
14768
|
-
const isRecord$1 = (value) => {
|
|
14769
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14770
|
-
};
|
|
14771
|
-
const asStringArray = (value) => {
|
|
14772
|
-
if (!Array.isArray(value)) return [];
|
|
14773
|
-
return value.filter((item) => typeof item === "string");
|
|
14774
|
-
};
|
|
14775
|
-
const firstKnown = (value) => {
|
|
14776
|
-
if (Array.isArray(value) && value.length > 0) return value[0];
|
|
14777
|
-
};
|
|
14778
|
-
const deriveType = (schema) => {
|
|
14779
|
-
const typeValue = schema["type"];
|
|
14780
|
-
if (typeof typeValue === "string") return typeValue;
|
|
14781
|
-
if (Array.isArray(typeValue)) return typeValue.find((entry) => typeof entry === "string");
|
|
14782
|
-
if (isRecord$1(schema["properties"])) return "object";
|
|
14783
|
-
if (schema["items"] !== void 0) return "array";
|
|
14784
|
-
};
|
|
14785
|
-
const baseScalarExample = (_typeName) => {
|
|
14786
|
-
switch (_typeName) {
|
|
14787
|
-
case "string": return EXAMPLE_PLACEHOLDER;
|
|
14788
|
-
case "integer": return EXAMPLE_PLACEHOLDER;
|
|
14789
|
-
case "number": return EXAMPLE_PLACEHOLDER;
|
|
14790
|
-
case "boolean": return EXAMPLE_PLACEHOLDER;
|
|
14791
|
-
case "null": return EXAMPLE_PLACEHOLDER;
|
|
14792
|
-
default: return EXAMPLE_PLACEHOLDER;
|
|
14793
|
-
}
|
|
14794
|
-
};
|
|
14795
|
-
const buildExample = (value, depth) => {
|
|
14796
|
-
if (!isRecord$1(value)) return {};
|
|
14797
|
-
if (depth > MAX_EXAMPLE_DEPTH) return {};
|
|
14798
|
-
const oneOfCandidate = firstKnown(value["oneOf"]);
|
|
14799
|
-
if (oneOfCandidate !== void 0) return buildExample(oneOfCandidate, depth + 1);
|
|
14800
|
-
const anyOfCandidate = firstKnown(value["anyOf"]);
|
|
14801
|
-
if (anyOfCandidate !== void 0) return buildExample(anyOfCandidate, depth + 1);
|
|
14802
|
-
const allOfCandidate = firstKnown(value["allOf"]);
|
|
14803
|
-
if (allOfCandidate !== void 0) return buildExample(allOfCandidate, depth + 1);
|
|
14804
|
-
const typeName = deriveType(value);
|
|
14805
|
-
if (typeName === "object") {
|
|
14806
|
-
const result = {};
|
|
14807
|
-
const properties = isRecord$1(value["properties"]) ? value["properties"] : {};
|
|
14808
|
-
const required = asStringArray(value["required"]);
|
|
14809
|
-
for (const propertyName of required) {
|
|
14810
|
-
const propertySchema = properties[propertyName];
|
|
14811
|
-
if (propertySchema !== void 0) result[propertyName] = buildExample(propertySchema, depth + 1);
|
|
14812
|
-
}
|
|
14813
|
-
if (required.length === 0 && isRecord$1(value["additionalProperties"])) result["example"] = buildExample(value["additionalProperties"], depth + 1);
|
|
14814
|
-
return result;
|
|
14815
|
-
}
|
|
14816
|
-
if (typeName === "array") {
|
|
14817
|
-
if (value["items"] === void 0) return [EXAMPLE_PLACEHOLDER];
|
|
14818
|
-
return [buildExample(value["items"], depth + 1)];
|
|
14819
|
-
}
|
|
14820
|
-
if (typeName === void 0) return depth === 0 ? {} : EXAMPLE_PLACEHOLDER;
|
|
14821
|
-
return baseScalarExample(typeName);
|
|
14822
|
-
};
|
|
14823
|
-
const buildJsonSchemaExample = (schema) => {
|
|
14824
|
-
return buildExample(schema, 0);
|
|
14825
|
-
};
|
|
14826
|
-
|
|
14827
14757
|
//#endregion
|
|
14828
14758
|
//#region src/cli/commands.ts
|
|
14759
|
+
const withOrg = (orgSlug) => {
|
|
14760
|
+
return orgSlug === void 0 ? [] : [`--org ${orgSlug}`];
|
|
14761
|
+
};
|
|
14829
14762
|
const cliCommands = {
|
|
14830
14763
|
auth: {
|
|
14831
14764
|
help: () => "ogment auth --help",
|
|
@@ -14835,58 +14768,62 @@ const cliCommands = {
|
|
|
14835
14768
|
status: () => "ogment auth status"
|
|
14836
14769
|
},
|
|
14837
14770
|
catalog: {
|
|
14838
|
-
command: () =>
|
|
14839
|
-
|
|
14771
|
+
command: (serverId, toolName, orgSlug) => [
|
|
14772
|
+
"ogment catalog",
|
|
14773
|
+
...withOrg(orgSlug),
|
|
14774
|
+
...serverId === void 0 ? [] : [serverId],
|
|
14775
|
+
...toolName === void 0 ? [] : [toolName]
|
|
14776
|
+
].join(" "),
|
|
14777
|
+
detail: (serverId, orgSlug) => [
|
|
14778
|
+
"ogment catalog",
|
|
14779
|
+
...withOrg(orgSlug),
|
|
14780
|
+
serverId
|
|
14781
|
+
].join(" "),
|
|
14840
14782
|
summary: (options) => {
|
|
14841
14783
|
return [
|
|
14842
14784
|
"ogment catalog",
|
|
14785
|
+
...withOrg(options.orgSlug),
|
|
14843
14786
|
...options.cursor === void 0 ? [] : [`--cursor ${options.cursor}`],
|
|
14844
14787
|
...options.limit === void 0 ? [] : [`--limit ${options.limit}`]
|
|
14845
14788
|
].join(" ");
|
|
14846
14789
|
},
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
serverId,
|
|
14851
|
-
toolName,
|
|
14852
|
-
...options.example ? ["--example"] : []
|
|
14853
|
-
].join(" ");
|
|
14854
|
-
}
|
|
14855
|
-
},
|
|
14856
|
-
helpForScope: (scope) => {
|
|
14857
|
-
if (scope === null) return "ogment --help";
|
|
14858
|
-
return `ogment ${scope} --help`;
|
|
14859
|
-
},
|
|
14860
|
-
invoke: {
|
|
14861
|
-
command: (serverId, toolName, orgSlug) => [
|
|
14862
|
-
"ogment invoke",
|
|
14863
|
-
...orgSlug === void 0 ? [] : [`--org ${orgSlug}`],
|
|
14790
|
+
toolDetail: (serverId, toolName, orgSlug) => [
|
|
14791
|
+
"ogment catalog",
|
|
14792
|
+
...withOrg(orgSlug),
|
|
14864
14793
|
serverId,
|
|
14865
14794
|
toolName
|
|
14795
|
+
].join(" ")
|
|
14796
|
+
},
|
|
14797
|
+
execute: {
|
|
14798
|
+
command: (serverId, orgSlug) => [
|
|
14799
|
+
"ogment execute",
|
|
14800
|
+
...withOrg(orgSlug),
|
|
14801
|
+
serverId
|
|
14866
14802
|
].join(" "),
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14803
|
+
help: () => "ogment execute --help",
|
|
14804
|
+
inlineCode: (serverId, orgSlug) => [
|
|
14805
|
+
"ogment execute",
|
|
14806
|
+
...withOrg(orgSlug),
|
|
14870
14807
|
serverId,
|
|
14871
|
-
|
|
14872
|
-
"--input <json>"
|
|
14808
|
+
"--code <javascript>"
|
|
14873
14809
|
].join(" "),
|
|
14874
|
-
|
|
14875
|
-
"ogment
|
|
14876
|
-
...orgSlug
|
|
14810
|
+
stdinCode: (serverId, orgSlug) => [
|
|
14811
|
+
"ogment execute",
|
|
14812
|
+
...withOrg(orgSlug),
|
|
14877
14813
|
serverId,
|
|
14878
|
-
|
|
14879
|
-
"--input -"
|
|
14814
|
+
"--code -"
|
|
14880
14815
|
].join(" "),
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14816
|
+
withCodeAndInputValue: (serverId, code, input, orgSlug) => [
|
|
14817
|
+
"ogment execute",
|
|
14818
|
+
...withOrg(orgSlug),
|
|
14819
|
+
serverId,
|
|
14820
|
+
`--code ${code}`,
|
|
14821
|
+
...input === void 0 ? [] : [`--input ${input}`]
|
|
14822
|
+
].join(" ")
|
|
14823
|
+
},
|
|
14824
|
+
helpForScope: (scope) => {
|
|
14825
|
+
if (scope === null) return "ogment --help";
|
|
14826
|
+
return `ogment ${scope} --help`;
|
|
14890
14827
|
},
|
|
14891
14828
|
root: {
|
|
14892
14829
|
command: () => "ogment",
|
|
@@ -14896,14 +14833,39 @@ const cliCommands = {
|
|
|
14896
14833
|
"auth status",
|
|
14897
14834
|
"auth logout",
|
|
14898
14835
|
"catalog",
|
|
14899
|
-
"
|
|
14900
|
-
"
|
|
14901
|
-
"invoke <server-id> <tool-name>",
|
|
14836
|
+
"search <server-id>",
|
|
14837
|
+
"execute <server-id>",
|
|
14902
14838
|
"status"
|
|
14903
14839
|
];
|
|
14904
14840
|
},
|
|
14905
14841
|
help: () => "ogment --help"
|
|
14906
14842
|
},
|
|
14843
|
+
search: {
|
|
14844
|
+
command: (serverId, orgSlug) => [
|
|
14845
|
+
"ogment search",
|
|
14846
|
+
...withOrg(orgSlug),
|
|
14847
|
+
serverId
|
|
14848
|
+
].join(" "),
|
|
14849
|
+
help: () => "ogment search --help",
|
|
14850
|
+
inspectAllTools: (serverId, orgSlug) => [
|
|
14851
|
+
"ogment search",
|
|
14852
|
+
...withOrg(orgSlug),
|
|
14853
|
+
serverId,
|
|
14854
|
+
"--code 'return input'"
|
|
14855
|
+
].join(" "),
|
|
14856
|
+
stdinCode: (serverId, orgSlug) => [
|
|
14857
|
+
"ogment search",
|
|
14858
|
+
...withOrg(orgSlug),
|
|
14859
|
+
serverId,
|
|
14860
|
+
"--code -"
|
|
14861
|
+
].join(" "),
|
|
14862
|
+
withCodeValue: (serverId, code, orgSlug) => [
|
|
14863
|
+
"ogment search",
|
|
14864
|
+
...withOrg(orgSlug),
|
|
14865
|
+
serverId,
|
|
14866
|
+
`--code ${code}`
|
|
14867
|
+
].join(" ")
|
|
14868
|
+
},
|
|
14907
14869
|
status: { command: () => "ogment status" }
|
|
14908
14870
|
};
|
|
14909
14871
|
|
|
@@ -14954,34 +14916,45 @@ const nextActionsForAuthStatus = (payload) => {
|
|
|
14954
14916
|
};
|
|
14955
14917
|
const nextActionsForCatalogSummary = (payload, context) => {
|
|
14956
14918
|
const actions = [];
|
|
14957
|
-
const targetServer = payload.servers
|
|
14958
|
-
if (targetServer !== void 0) actions.push(nextAction("
|
|
14919
|
+
const targetServer = payload.servers[0];
|
|
14920
|
+
if (targetServer !== void 0) actions.push(nextAction("inspect_server", "Inspect server", cliCommands.catalog.detail(targetServer.serverId, targetServer.orgSlug), `Inspect Codemode tools exposed on ${targetServer.serverId}.`, "if_servers_available"));
|
|
14959
14921
|
if (context.nextCursor !== null) actions.push(nextAction("next_catalog_page", "Load next page", cliCommands.catalog.summary({
|
|
14960
14922
|
cursor: context.nextCursor,
|
|
14961
|
-
...context.limit === null ? {} : { limit: context.limit }
|
|
14923
|
+
...context.limit === null ? {} : { limit: context.limit },
|
|
14924
|
+
...context.orgSlug === null ? {} : { orgSlug: context.orgSlug }
|
|
14962
14925
|
}), `More servers are available after cursor ${context.nextCursor}.`, "if_more_servers"));
|
|
14963
14926
|
return actions;
|
|
14964
14927
|
};
|
|
14965
|
-
const
|
|
14966
|
-
const
|
|
14967
|
-
if (
|
|
14968
|
-
return [
|
|
14928
|
+
const nextActionsForCatalogServerDetail = (payload) => {
|
|
14929
|
+
const searchTool = payload.tools.find((tool) => tool.name === "search");
|
|
14930
|
+
if (searchTool !== void 0) return [nextAction("inspect_tool", "Inspect tool details", cliCommands.catalog.toolDetail(payload.server.serverId, searchTool.name, payload.server.orgSlug), `Inspect schema for ${payload.server.serverId}/${searchTool.name} before invoking.`, "if_tools_available")];
|
|
14931
|
+
return [];
|
|
14969
14932
|
};
|
|
14970
|
-
const
|
|
14971
|
-
|
|
14972
|
-
return
|
|
14933
|
+
const nextActionsForCatalogToolDetail = (payload) => {
|
|
14934
|
+
if (payload.tool.name === "search") return [nextAction("run_search", "Run search", cliCommands.search.inspectAllTools(payload.server.serverId, payload.server.orgSlug), `Use Codemode search on ${payload.server.serverId} after reviewing the tool contract.`, "after_tool_inspection")];
|
|
14935
|
+
return [nextAction("run_execute", "Run execute", cliCommands.execute.inlineCode(payload.server.serverId, payload.server.orgSlug), `Use Codemode execute on ${payload.server.serverId} after reviewing the tool contract.`, "after_tool_inspection")];
|
|
14973
14936
|
};
|
|
14974
|
-
const
|
|
14975
|
-
|
|
14976
|
-
return [nextAction("invoke_tool", "Invoke this tool", cliCommands.invoke.withInputValue(payload.server.serverId, payload.name, inputArgument), `Replace every ... placeholder with real JSON values, then invoke ${payload.server.serverId} ${payload.name}.`, "after_tool_inspection")];
|
|
14937
|
+
const nextActionsForSearch = (payload) => {
|
|
14938
|
+
return [nextAction("execute_help", "Inspect execute usage", cliCommands.execute.help(), `Run Codemode execute against ${payload.serverId} after choosing a workflow.`, "after_search")];
|
|
14977
14939
|
};
|
|
14978
|
-
const
|
|
14979
|
-
return [nextAction("
|
|
14940
|
+
const nextActionsForExecute = (payload) => {
|
|
14941
|
+
return [nextAction("search_tools", "Search tools again", cliCommands.search.inspectAllTools(payload.serverId), `Reinspect tool definitions on ${payload.serverId} before the next execution.`, "after_execute")];
|
|
14980
14942
|
};
|
|
14981
14943
|
const nextActionsForStatus = (payload) => {
|
|
14982
14944
|
if (!payload.auth.apiKeyPresent) return [nextAction("login", "Authenticate", cliCommands.auth.login(), "Status detected no API key; authenticate first.", "immediate")];
|
|
14983
14945
|
return [nextAction("discover_servers", "Discover servers", cliCommands.catalog.command(), `Connectivity is ${payload.summary.status}; discover available servers.`, "after_status")];
|
|
14984
14946
|
};
|
|
14947
|
+
const codeSourceFromValue = (value) => {
|
|
14948
|
+
if (value === "-") return "stdin";
|
|
14949
|
+
if (value.startsWith("@")) return "file";
|
|
14950
|
+
return "inline";
|
|
14951
|
+
};
|
|
14952
|
+
const inputSourceFromValue = (value) => {
|
|
14953
|
+
if (value === void 0) return "none";
|
|
14954
|
+
if (value === "-") return "stdin";
|
|
14955
|
+
if (value.startsWith("@")) return "file";
|
|
14956
|
+
return "inline_json";
|
|
14957
|
+
};
|
|
14985
14958
|
const runLoginFlow = async (runtime, options) => {
|
|
14986
14959
|
const { commandOptions, invokedCommand, mode } = options.mode === "apiKey" ? {
|
|
14987
14960
|
commandOptions: options,
|
|
@@ -15063,175 +15036,149 @@ const executeAuthLogoutInvocation = async (runtime) => {
|
|
|
15063
15036
|
localCredentialsDeleted: data.localCredentialsDeleted,
|
|
15064
15037
|
revoked: data.revoked
|
|
15065
15038
|
},
|
|
15066
|
-
nextActions: [nextAction("login", "Authenticate again", cliCommands.auth.login(), "Logout completed; authenticate again before further
|
|
15039
|
+
nextActions: [nextAction("login", "Authenticate again", cliCommands.auth.login(), "Logout completed; authenticate again before further Codemode commands.", "after_logout")]
|
|
15067
15040
|
});
|
|
15068
15041
|
};
|
|
15069
15042
|
const executeCatalogInvocation = async (runtime, invocation) => {
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
if (invocation.example) return Result.err(new ValidationError({
|
|
15076
|
-
details: "--example without <server-id> <tool-name>",
|
|
15077
|
-
message: "Invalid catalog options. --example requires <server-id> <tool-name>.",
|
|
15078
|
-
recovery: { command: cliCommands.catalog.command() }
|
|
15079
|
-
}));
|
|
15080
|
-
return Result.ok({
|
|
15081
|
-
cursor: invocation.cursor,
|
|
15082
|
-
kind: "summary",
|
|
15083
|
-
limit: invocation.limit
|
|
15084
|
-
});
|
|
15085
|
-
}
|
|
15086
|
-
if (invocation.toolName === void 0) {
|
|
15087
|
-
if (invocation.cursor !== void 0 || invocation.limit !== void 0) return Result.err(new ValidationError({
|
|
15088
|
-
details: formatPaginationDetails(),
|
|
15089
|
-
message: "Invalid catalog options. --cursor and --limit are only valid for `ogment catalog`.",
|
|
15090
|
-
recovery: { command: cliCommands.catalog.command() }
|
|
15091
|
-
}));
|
|
15092
|
-
if (invocation.example) return Result.err(new ValidationError({
|
|
15093
|
-
details: `--example without tool name for ${invocation.serverId}`,
|
|
15094
|
-
message: "Invalid catalog options. --example requires <tool-name>.",
|
|
15095
|
-
recovery: { command: cliCommands.catalog.server(invocation.serverId) }
|
|
15096
|
-
}));
|
|
15097
|
-
return Result.ok({
|
|
15098
|
-
kind: "tools",
|
|
15099
|
-
serverId: invocation.serverId
|
|
15100
|
-
});
|
|
15101
|
-
}
|
|
15102
|
-
if (invocation.cursor !== void 0 || invocation.limit !== void 0) return Result.err(new ValidationError({
|
|
15103
|
-
details: formatPaginationDetails(),
|
|
15104
|
-
message: "Invalid catalog options. --cursor and --limit are only valid for `ogment catalog`.",
|
|
15105
|
-
recovery: { command: cliCommands.catalog.tool(invocation.serverId, invocation.toolName, { example: invocation.example }) }
|
|
15106
|
-
}));
|
|
15107
|
-
return Result.ok({
|
|
15108
|
-
example: invocation.example,
|
|
15109
|
-
kind: "tool",
|
|
15043
|
+
if (invocation.toolName !== void 0 && invocation.serverId !== void 0) {
|
|
15044
|
+
const command = cliCommands.catalog.toolDetail(invocation.serverId, invocation.toolName, invocation.orgSlug);
|
|
15045
|
+
const data = ensureSuccess(await runCatalogToolDetailCommand(runtime.context, {
|
|
15046
|
+
includeDebug: runtime.output.debug,
|
|
15047
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15110
15048
|
serverId: invocation.serverId,
|
|
15111
15049
|
toolName: invocation.toolName
|
|
15050
|
+
}), runtime, {
|
|
15051
|
+
command,
|
|
15052
|
+
entity: {
|
|
15053
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15054
|
+
serverId: invocation.serverId,
|
|
15055
|
+
toolName: invocation.toolName
|
|
15056
|
+
}
|
|
15112
15057
|
});
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
}
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
entity: {
|
|
15163
|
-
serverId: data.server.serverId,
|
|
15164
|
-
toolCount: data.tools.length
|
|
15165
|
-
},
|
|
15166
|
-
nextActions: nextActionsForCatalogTools(data)
|
|
15167
|
-
});
|
|
15168
|
-
return;
|
|
15058
|
+
runtime.output.success(data, {
|
|
15059
|
+
command,
|
|
15060
|
+
entity: {
|
|
15061
|
+
orgSlug: data.server.orgSlug,
|
|
15062
|
+
serverId: data.server.serverId,
|
|
15063
|
+
toolName: data.tool.name
|
|
15064
|
+
},
|
|
15065
|
+
nextActions: nextActionsForCatalogToolDetail(data)
|
|
15066
|
+
});
|
|
15067
|
+
return;
|
|
15068
|
+
}
|
|
15069
|
+
if (invocation.serverId !== void 0) {
|
|
15070
|
+
const command = cliCommands.catalog.detail(invocation.serverId, invocation.orgSlug);
|
|
15071
|
+
const data = ensureSuccess(await runCatalogServerDetailCommand(runtime.context, {
|
|
15072
|
+
includeDebug: runtime.output.debug,
|
|
15073
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15074
|
+
serverId: invocation.serverId
|
|
15075
|
+
}), runtime, {
|
|
15076
|
+
command,
|
|
15077
|
+
entity: {
|
|
15078
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15079
|
+
serverId: invocation.serverId
|
|
15080
|
+
}
|
|
15081
|
+
});
|
|
15082
|
+
runtime.output.success(data, {
|
|
15083
|
+
command,
|
|
15084
|
+
entity: {
|
|
15085
|
+
orgSlug: data.server.orgSlug,
|
|
15086
|
+
serverId: data.server.serverId
|
|
15087
|
+
},
|
|
15088
|
+
nextActions: nextActionsForCatalogServerDetail(data)
|
|
15089
|
+
});
|
|
15090
|
+
return;
|
|
15091
|
+
}
|
|
15092
|
+
const command = cliCommands.catalog.summary({
|
|
15093
|
+
...invocation.cursor === void 0 ? {} : { cursor: invocation.cursor },
|
|
15094
|
+
...invocation.limit === void 0 ? {} : { limit: invocation.limit },
|
|
15095
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug }
|
|
15096
|
+
});
|
|
15097
|
+
const data = ensureSuccess(await runCatalogCommand(runtime.context, {
|
|
15098
|
+
...invocation.cursor === void 0 ? {} : { cursor: invocation.cursor },
|
|
15099
|
+
...invocation.limit === void 0 ? {} : { limit: invocation.limit },
|
|
15100
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug }
|
|
15101
|
+
}), runtime, {
|
|
15102
|
+
command,
|
|
15103
|
+
entity: {
|
|
15104
|
+
cursor: invocation.cursor ?? null,
|
|
15105
|
+
limit: invocation.limit ?? null,
|
|
15106
|
+
orgSlug: invocation.orgSlug ?? null
|
|
15169
15107
|
}
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15108
|
+
});
|
|
15109
|
+
const outputData = {
|
|
15110
|
+
failures: data.failures,
|
|
15111
|
+
servers: data.servers
|
|
15112
|
+
};
|
|
15113
|
+
runtime.output.success(outputData, {
|
|
15114
|
+
command,
|
|
15115
|
+
entity: {
|
|
15116
|
+
cursor: invocation.cursor ?? null,
|
|
15117
|
+
failedServerCount: data.failures.length,
|
|
15118
|
+
limit: invocation.limit ?? null,
|
|
15119
|
+
orgSlug: invocation.orgSlug ?? null,
|
|
15120
|
+
serverCount: data.servers.length
|
|
15121
|
+
},
|
|
15122
|
+
nextActions: nextActionsForCatalogSummary(outputData, {
|
|
15123
|
+
limit: invocation.limit ?? null,
|
|
15124
|
+
nextCursor: data.nextCursor,
|
|
15125
|
+
orgSlug: invocation.orgSlug ?? null
|
|
15126
|
+
}),
|
|
15127
|
+
pagination: { nextCursor: data.nextCursor }
|
|
15128
|
+
});
|
|
15129
|
+
};
|
|
15130
|
+
const executeSearchInvocation = async (runtime, invocation) => {
|
|
15131
|
+
const codeSource = codeSourceFromValue(invocation.code);
|
|
15132
|
+
const command = codeSource === "stdin" ? cliCommands.search.stdinCode(invocation.serverId, invocation.orgSlug) : cliCommands.search.withCodeValue(invocation.serverId, invocation.code, invocation.orgSlug);
|
|
15133
|
+
const data = ensureSuccess(await runSearchCommand(runtime.context, {
|
|
15134
|
+
code: invocation.code,
|
|
15135
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15136
|
+
serverId: invocation.serverId
|
|
15137
|
+
}), runtime, {
|
|
15138
|
+
command,
|
|
15139
|
+
entity: {
|
|
15140
|
+
codeSource,
|
|
15141
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15142
|
+
serverId: invocation.serverId
|
|
15196
15143
|
}
|
|
15197
|
-
}
|
|
15144
|
+
});
|
|
15145
|
+
runtime.output.success(data, {
|
|
15146
|
+
command,
|
|
15147
|
+
entity: {
|
|
15148
|
+
codeSource,
|
|
15149
|
+
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15150
|
+
serverId: data.serverId
|
|
15151
|
+
},
|
|
15152
|
+
nextActions: nextActionsForSearch(data)
|
|
15153
|
+
});
|
|
15198
15154
|
};
|
|
15199
|
-
const
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
} else if (invocation.input.startsWith("@")) {
|
|
15206
|
-
inputSource = "file";
|
|
15207
|
-
command = cliCommands.invoke.withInputValue(invocation.serverId, invocation.toolName, invocation.input, invocation.orgSlug);
|
|
15208
|
-
} else {
|
|
15209
|
-
inputSource = "inline_json";
|
|
15210
|
-
command = cliCommands.invoke.inlineJson(invocation.serverId, invocation.toolName, invocation.orgSlug);
|
|
15211
|
-
}
|
|
15212
|
-
const data = ensureSuccess(await runInvokeCommand(runtime.context, {
|
|
15155
|
+
const executeExecuteInvocation = async (runtime, invocation) => {
|
|
15156
|
+
const codeSource = codeSourceFromValue(invocation.code);
|
|
15157
|
+
const inputSource = inputSourceFromValue(invocation.input);
|
|
15158
|
+
const command = codeSource === "stdin" ? cliCommands.execute.stdinCode(invocation.serverId, invocation.orgSlug) : cliCommands.execute.withCodeAndInputValue(invocation.serverId, invocation.code, invocation.input, invocation.orgSlug);
|
|
15159
|
+
const data = ensureSuccess(await runExecuteCommand(runtime.context, {
|
|
15160
|
+
code: invocation.code,
|
|
15213
15161
|
input: invocation.input,
|
|
15214
15162
|
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15215
|
-
serverId: invocation.serverId
|
|
15216
|
-
toolName: invocation.toolName
|
|
15163
|
+
serverId: invocation.serverId
|
|
15217
15164
|
}), runtime, {
|
|
15218
15165
|
command,
|
|
15219
15166
|
entity: {
|
|
15167
|
+
codeSource,
|
|
15220
15168
|
inputSource,
|
|
15221
15169
|
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15222
|
-
serverId: invocation.serverId
|
|
15223
|
-
toolName: invocation.toolName
|
|
15170
|
+
serverId: invocation.serverId
|
|
15224
15171
|
}
|
|
15225
15172
|
});
|
|
15226
15173
|
runtime.output.success(data, {
|
|
15227
15174
|
command,
|
|
15228
15175
|
entity: {
|
|
15176
|
+
codeSource,
|
|
15229
15177
|
inputSource,
|
|
15230
15178
|
...invocation.orgSlug === void 0 ? {} : { orgSlug: invocation.orgSlug },
|
|
15231
|
-
serverId: data.serverId
|
|
15232
|
-
toolName: data.toolName
|
|
15179
|
+
serverId: data.serverId
|
|
15233
15180
|
},
|
|
15234
|
-
nextActions:
|
|
15181
|
+
nextActions: nextActionsForExecute(data)
|
|
15235
15182
|
});
|
|
15236
15183
|
};
|
|
15237
15184
|
const executeStatusInvocation = async (runtime) => {
|
|
@@ -15250,7 +15197,7 @@ const executeRootInvocation = (runtime) => {
|
|
|
15250
15197
|
runtime.output.success({ commands: cliCommands.root.commandsSurface() }, {
|
|
15251
15198
|
command: cliCommands.root.command(),
|
|
15252
15199
|
entity: null,
|
|
15253
|
-
nextActions: [nextAction("login", "Authenticate", cliCommands.auth.login(), "Authenticate first so catalog and
|
|
15200
|
+
nextActions: [nextAction("login", "Authenticate", cliCommands.auth.login(), "Authenticate first so catalog, search, and execute commands can run.", "immediate"), nextAction("catalog", "Discover servers", cliCommands.catalog.command(), "List accessible servers before running Codemode search or execute.", "after_auth")]
|
|
15254
15201
|
});
|
|
15255
15202
|
};
|
|
15256
15203
|
const executeInvocation = async (runtime, invocation) => {
|
|
@@ -15267,12 +15214,15 @@ const executeInvocation = async (runtime, invocation) => {
|
|
|
15267
15214
|
case "catalog":
|
|
15268
15215
|
await executeCatalogInvocation(runtime, invocation);
|
|
15269
15216
|
return;
|
|
15270
|
-
case "
|
|
15271
|
-
await
|
|
15217
|
+
case "execute":
|
|
15218
|
+
await executeExecuteInvocation(runtime, invocation);
|
|
15272
15219
|
return;
|
|
15273
15220
|
case "root":
|
|
15274
15221
|
executeRootInvocation(runtime);
|
|
15275
15222
|
return;
|
|
15223
|
+
case "search":
|
|
15224
|
+
await executeSearchInvocation(runtime, invocation);
|
|
15225
|
+
return;
|
|
15276
15226
|
case "status":
|
|
15277
15227
|
await executeStatusInvocation(runtime);
|
|
15278
15228
|
return;
|
|
@@ -15355,15 +15305,22 @@ const parseActionsForScope = (scope, helpAction) => {
|
|
|
15355
15305
|
if (scope === "catalog") return [{
|
|
15356
15306
|
command: cliCommands.catalog.command(),
|
|
15357
15307
|
id: "catalog_summary",
|
|
15358
|
-
reason: "List available servers
|
|
15308
|
+
reason: "List available servers before selecting a Codemode target.",
|
|
15359
15309
|
title: "Catalog servers",
|
|
15360
15310
|
when: "immediate"
|
|
15361
15311
|
}, helpAction];
|
|
15362
|
-
if (scope === "
|
|
15312
|
+
if (scope === "search") return [{
|
|
15363
15313
|
command: cliCommands.catalog.command(),
|
|
15364
|
-
id: "
|
|
15365
|
-
reason: "Discover servers
|
|
15366
|
-
title: "Discover
|
|
15314
|
+
id: "search_prepare",
|
|
15315
|
+
reason: "Discover servers before running Codemode search.",
|
|
15316
|
+
title: "Discover servers",
|
|
15317
|
+
when: "immediate"
|
|
15318
|
+
}, helpAction];
|
|
15319
|
+
if (scope === "execute") return [{
|
|
15320
|
+
command: cliCommands.catalog.command(),
|
|
15321
|
+
id: "execute_prepare",
|
|
15322
|
+
reason: "Discover servers before running Codemode execute.",
|
|
15323
|
+
title: "Discover servers",
|
|
15367
15324
|
when: "immediate"
|
|
15368
15325
|
}, helpAction];
|
|
15369
15326
|
if (scope === null) return [helpAction];
|
|
@@ -61236,9 +61193,8 @@ const createInfoService = (deps) => {
|
|
|
61236
61193
|
"ogment status",
|
|
61237
61194
|
"ogment auth login",
|
|
61238
61195
|
"ogment catalog",
|
|
61239
|
-
"ogment
|
|
61240
|
-
"ogment
|
|
61241
|
-
"ogment invoke <server-id> <tool-name> --input '{}'"
|
|
61196
|
+
"ogment search <server-id> --code 'return input'",
|
|
61197
|
+
"ogment execute <server-id> --code 'return input' --input '{}'"
|
|
61242
61198
|
]
|
|
61243
61199
|
},
|
|
61244
61200
|
generatedAt: new Date(now()).toISOString(),
|
|
@@ -71947,6 +71903,11 @@ const createRemoteRequestErrorFromMcpCause = (options) => {
|
|
|
71947
71903
|
const MCP_CONNECT_TIMEOUT_MS = 1e4;
|
|
71948
71904
|
const MCP_DISCOVERY_TIMEOUT_MS = 1e4;
|
|
71949
71905
|
const MCP_INVOKE_TIMEOUT_MS = 45e3;
|
|
71906
|
+
const normalizePathPrefix = (value) => {
|
|
71907
|
+
const candidate = value?.trim() || "/api/v1/mcp";
|
|
71908
|
+
if (candidate.startsWith("/")) return candidate;
|
|
71909
|
+
return `/${candidate}`;
|
|
71910
|
+
};
|
|
71950
71911
|
const defaultCreateClient = (version) => {
|
|
71951
71912
|
return new Client({
|
|
71952
71913
|
name: APP_NAME,
|
|
@@ -71959,8 +71920,9 @@ const defaultCreateTransport = (url, apiKey) => {
|
|
|
71959
71920
|
const createMcpService = (deps) => {
|
|
71960
71921
|
const createClient = deps.createClient ?? (() => defaultCreateClient(deps.version));
|
|
71961
71922
|
const createTransport = deps.createTransport ?? defaultCreateTransport;
|
|
71923
|
+
const pathPrefix = normalizePathPrefix(deps.pathPrefix);
|
|
71962
71924
|
const withClient = async (target, apiKey, handler) => {
|
|
71963
|
-
const endpoint = `${deps.baseUrl}
|
|
71925
|
+
const endpoint = `${deps.baseUrl}${pathPrefix}/${target.orgSlug}/${target.serverPath}`;
|
|
71964
71926
|
const transport = createTransport(new URL(endpoint), apiKey);
|
|
71965
71927
|
const client = createClient();
|
|
71966
71928
|
const connectResult = await Result.tryPromise({
|
|
@@ -72043,6 +72005,11 @@ const createRuntime = () => {
|
|
|
72043
72005
|
executionEnvironment,
|
|
72044
72006
|
httpClient
|
|
72045
72007
|
}),
|
|
72008
|
+
codemode: createMcpService({
|
|
72009
|
+
baseUrl: runtimeConfig.baseUrl,
|
|
72010
|
+
pathPrefix: "/code",
|
|
72011
|
+
version: runtimeConfig.version
|
|
72012
|
+
}),
|
|
72046
72013
|
mcp: createMcpService({
|
|
72047
72014
|
baseUrl: runtimeConfig.baseUrl,
|
|
72048
72015
|
version: runtimeConfig.version
|
|
@@ -72149,8 +72116,11 @@ const createProgram = (runtime, parseState) => {
|
|
|
72149
72116
|
"",
|
|
72150
72117
|
"Examples:",
|
|
72151
72118
|
" $ ogment auth login",
|
|
72152
|
-
" $ ogment catalog
|
|
72153
|
-
" $ ogment
|
|
72119
|
+
" $ ogment catalog",
|
|
72120
|
+
" $ ogment catalog billing",
|
|
72121
|
+
" $ ogment catalog billing execute",
|
|
72122
|
+
" $ ogment search billing --code 'return input'",
|
|
72123
|
+
" $ ogment execute billing --code 'return input' --input '{}'",
|
|
72154
72124
|
"",
|
|
72155
72125
|
"Run `ogment help <command>` for command-specific usage."
|
|
72156
72126
|
].join("\n");
|
|
@@ -72182,23 +72152,32 @@ const createProgram = (runtime, parseState) => {
|
|
|
72182
72152
|
authCommand.command("logout").summary("Delete local credentials and revoke token").description("Revoke token and delete local credentials").action(() => {
|
|
72183
72153
|
setInvocation({ kind: "auth_logout" });
|
|
72184
72154
|
});
|
|
72185
|
-
program.command("catalog
|
|
72155
|
+
program.command("catalog").summary("Discover servers or inspect Codemode tools").description("Discover servers or inspect Codemode tools on a server").helpGroup("Discovery Commands:").argument("[serverId]", "Server id").argument("[toolName]", "Codemode tool name").addOption(new Option("--org <orgSlug>", "Organization slug").hideHelp()).addOption(new Option("--cursor <cursor>", "Pagination cursor for server discovery")).addOption(new Option("--limit <limit>", "Maximum servers to return").argParser(parseCatalogLimitOption)).action((serverId, toolName, options) => {
|
|
72156
|
+
if (serverId !== void 0 && (options.cursor !== void 0 || options.limit !== void 0)) throw new InvalidArgumentError("--cursor and --limit are only supported for `ogment catalog`.");
|
|
72186
72157
|
setInvocation({
|
|
72187
|
-
example: options.example === true,
|
|
72188
72158
|
kind: "catalog",
|
|
72189
72159
|
...options.cursor === void 0 ? {} : { cursor: options.cursor },
|
|
72190
72160
|
...options.limit === void 0 ? {} : { limit: options.limit },
|
|
72161
|
+
...options.org === void 0 ? {} : { orgSlug: options.org },
|
|
72191
72162
|
...serverId === void 0 ? {} : { serverId },
|
|
72192
72163
|
...toolName === void 0 ? {} : { toolName }
|
|
72193
72164
|
});
|
|
72194
72165
|
});
|
|
72195
|
-
program.command("
|
|
72166
|
+
program.command("search").summary("Search tools on a server via Codemode").description("Run Codemode search JavaScript against a server tool catalog").helpGroup("Execution Commands:").argument("<serverId>", "Server id").addOption(new Option("--org <orgSlug>", "Organization slug").hideHelp()).requiredOption("--code <value>", "JavaScript source: inline code, @path, or - for stdin").action((serverId, options) => {
|
|
72196
72167
|
setInvocation({
|
|
72168
|
+
code: options.code,
|
|
72169
|
+
kind: "search",
|
|
72170
|
+
...options.org === void 0 ? {} : { orgSlug: options.org },
|
|
72171
|
+
serverId
|
|
72172
|
+
});
|
|
72173
|
+
});
|
|
72174
|
+
program.command("execute").summary("Execute Codemode JavaScript on a server").description("Run Codemode execute JavaScript with optional JSON input").helpGroup("Execution Commands:").argument("<serverId>", "Server id").addOption(new Option("--org <orgSlug>", "Organization slug").hideHelp()).requiredOption("--code <value>", "JavaScript source: inline code, @path, or - for stdin").option("--input <value>", "Input payload: inline JSON object, @path, or - for stdin").action((serverId, options) => {
|
|
72175
|
+
setInvocation({
|
|
72176
|
+
code: options.code,
|
|
72177
|
+
kind: "execute",
|
|
72197
72178
|
input: options.input,
|
|
72198
|
-
kind: "invoke",
|
|
72199
72179
|
...options.org === void 0 ? {} : { orgSlug: options.org },
|
|
72200
|
-
serverId
|
|
72201
|
-
toolName
|
|
72180
|
+
serverId
|
|
72202
72181
|
});
|
|
72203
72182
|
});
|
|
72204
72183
|
program.command("status").summary("Show runtime diagnostics").description("Show runtime configuration and connectivity diagnostics").helpGroup("Diagnostics Commands:").action(() => {
|
|
@@ -72230,7 +72209,8 @@ const CLI_PACKAGE_NAME = "@ogment-ai/cli";
|
|
|
72230
72209
|
const PARSE_ERROR_SCOPE_COMMAND_PATHS = {
|
|
72231
72210
|
auth: "ogment auth <parse_error>",
|
|
72232
72211
|
catalog: "ogment catalog <parse_error>",
|
|
72233
|
-
|
|
72212
|
+
execute: "ogment execute <parse_error>",
|
|
72213
|
+
search: "ogment search <parse_error>"
|
|
72234
72214
|
};
|
|
72235
72215
|
const isParseErrorTelemetryScope = (value) => {
|
|
72236
72216
|
return value in PARSE_ERROR_SCOPE_COMMAND_PATHS;
|
|
@@ -72241,7 +72221,7 @@ const parseErrorCommandPath = (scope) => {
|
|
|
72241
72221
|
if (rootScope === void 0 || !isParseErrorTelemetryScope(rootScope)) return PARSE_ERROR_COMMAND_PATH;
|
|
72242
72222
|
return PARSE_ERROR_SCOPE_COMMAND_PATHS[rootScope];
|
|
72243
72223
|
};
|
|
72244
|
-
const
|
|
72224
|
+
const telemetryInputModeFromExecute = (input) => {
|
|
72245
72225
|
if (input === void 0) return "none";
|
|
72246
72226
|
if (input === "-") return "stdin";
|
|
72247
72227
|
if (input.startsWith("@")) return "file";
|
|
@@ -72270,27 +72250,34 @@ const telemetryContextResolvers = {
|
|
|
72270
72250
|
};
|
|
72271
72251
|
},
|
|
72272
72252
|
catalog: (invocation) => {
|
|
72273
|
-
if (invocation.serverId
|
|
72274
|
-
commandKind: "
|
|
72275
|
-
commandPath: "ogment catalog",
|
|
72253
|
+
if (invocation.toolName !== void 0 && invocation.serverId !== void 0) return {
|
|
72254
|
+
commandKind: "catalog_tool_detail",
|
|
72255
|
+
commandPath: "ogment catalog <server-id> <tool-name>",
|
|
72276
72256
|
inputMode: null
|
|
72277
72257
|
};
|
|
72278
|
-
if (invocation.
|
|
72279
|
-
commandKind: "
|
|
72258
|
+
if (invocation.serverId !== void 0) return {
|
|
72259
|
+
commandKind: "catalog_detail",
|
|
72280
72260
|
commandPath: "ogment catalog <server-id>",
|
|
72281
72261
|
inputMode: null
|
|
72282
72262
|
};
|
|
72283
72263
|
return {
|
|
72284
|
-
commandKind: "
|
|
72285
|
-
commandPath: "ogment catalog
|
|
72264
|
+
commandKind: "catalog_summary",
|
|
72265
|
+
commandPath: "ogment catalog",
|
|
72286
72266
|
inputMode: null
|
|
72287
72267
|
};
|
|
72288
72268
|
},
|
|
72289
|
-
|
|
72269
|
+
execute: (invocation) => {
|
|
72270
|
+
return {
|
|
72271
|
+
commandKind: "execute",
|
|
72272
|
+
commandPath: "ogment execute <server-id>",
|
|
72273
|
+
inputMode: telemetryInputModeFromExecute(invocation.input)
|
|
72274
|
+
};
|
|
72275
|
+
},
|
|
72276
|
+
search: (_) => {
|
|
72290
72277
|
return {
|
|
72291
|
-
commandKind: "
|
|
72292
|
-
commandPath: "ogment
|
|
72293
|
-
inputMode:
|
|
72278
|
+
commandKind: "search",
|
|
72279
|
+
commandPath: "ogment search <server-id>",
|
|
72280
|
+
inputMode: null
|
|
72294
72281
|
};
|
|
72295
72282
|
},
|
|
72296
72283
|
root: (_) => {
|
|
@@ -72314,8 +72301,9 @@ const telemetryContextFromInvocation = (invocation) => {
|
|
|
72314
72301
|
case "auth_logout": return telemetryContextResolvers.auth_logout(invocation);
|
|
72315
72302
|
case "auth_status": return telemetryContextResolvers.auth_status(invocation);
|
|
72316
72303
|
case "catalog": return telemetryContextResolvers.catalog(invocation);
|
|
72317
|
-
case "
|
|
72304
|
+
case "execute": return telemetryContextResolvers.execute(invocation);
|
|
72318
72305
|
case "root": return telemetryContextResolvers.root(invocation);
|
|
72306
|
+
case "search": return telemetryContextResolvers.search(invocation);
|
|
72319
72307
|
case "status": return telemetryContextResolvers.status(invocation);
|
|
72320
72308
|
}
|
|
72321
72309
|
};
|
|
@@ -72399,12 +72387,10 @@ const commandContextFromInvocation = (invocation, apiKeyOverride) => {
|
|
|
72399
72387
|
case "auth_login": return withBase("auth", "auth_login", "login");
|
|
72400
72388
|
case "auth_logout": return withBase("auth", "auth_logout", "logout");
|
|
72401
72389
|
case "auth_status": return withBase("auth", "auth_status", "status");
|
|
72402
|
-
case "catalog":
|
|
72403
|
-
|
|
72404
|
-
if (invocation.serverId !== void 0) return withBase("catalog", "catalog", "server");
|
|
72405
|
-
return withBase("catalog", "catalog", "summary");
|
|
72406
|
-
case "invoke": return withBase("invoke", "invoke");
|
|
72390
|
+
case "catalog": return withBase("catalog", "catalog", "summary");
|
|
72391
|
+
case "execute": return withBase("execute", "execute");
|
|
72407
72392
|
case "root": return withBase("ogment", "root");
|
|
72393
|
+
case "search": return withBase("search", "search");
|
|
72408
72394
|
case "status": return withBase("status", "status");
|
|
72409
72395
|
default: return assertNever(invocation);
|
|
72410
72396
|
}
|
|
@@ -72556,4 +72542,4 @@ if (shouldExecuteCli(import.meta.url, process.argv[1])) await executeCli();
|
|
|
72556
72542
|
|
|
72557
72543
|
//#endregion
|
|
72558
72544
|
export { executeCli, runCli, shouldExecuteCli };
|
|
72559
|
-
//# debugId=
|
|
72545
|
+
//# debugId=b6726b83-6d8e-48e3-ae38-e730da1c0495
|