@openontology/opencode-palantir 0.1.2-next.7 → 0.1.2
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/index.js +43 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7291,6 +7291,19 @@ var ParseErrorCode;
|
|
|
7291
7291
|
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
7292
7292
|
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
7293
7293
|
|
|
7294
|
+
// src/palantir-mcp/types.ts
|
|
7295
|
+
function parseProfileId(value) {
|
|
7296
|
+
if (value === "pipelines_transforms")
|
|
7297
|
+
return value;
|
|
7298
|
+
if (value === "osdk_functions_ts")
|
|
7299
|
+
return value;
|
|
7300
|
+
if (value === "all")
|
|
7301
|
+
return value;
|
|
7302
|
+
if (value === "unknown")
|
|
7303
|
+
return value;
|
|
7304
|
+
return null;
|
|
7305
|
+
}
|
|
7306
|
+
|
|
7294
7307
|
// src/palantir-mcp/opencode-config.ts
|
|
7295
7308
|
var OPENCODE_JSONC_FILENAME = "opencode.jsonc";
|
|
7296
7309
|
var OPENCODE_JSON_FILENAME = "opencode.json";
|
|
@@ -7415,9 +7428,18 @@ function getString(obj, key) {
|
|
|
7415
7428
|
const v = obj[key];
|
|
7416
7429
|
return typeof v === "string" ? v : null;
|
|
7417
7430
|
}
|
|
7418
|
-
function
|
|
7419
|
-
|
|
7420
|
-
|
|
7431
|
+
function readProfileOverride(data) {
|
|
7432
|
+
const meta = data["palantir_mcp"];
|
|
7433
|
+
if (!isRecord(meta))
|
|
7434
|
+
return null;
|
|
7435
|
+
return parseProfileId(meta["profile"]);
|
|
7436
|
+
}
|
|
7437
|
+
function setProfileIfMissing(data, profile) {
|
|
7438
|
+
const meta = ensureObject(data, "palantir_mcp");
|
|
7439
|
+
const existing = meta["profile"];
|
|
7440
|
+
if (typeof existing === "string" && existing.length > 0)
|
|
7441
|
+
return;
|
|
7442
|
+
meta["profile"] = profile;
|
|
7421
7443
|
}
|
|
7422
7444
|
function ensureMcpServer(data, foundryApiUrl) {
|
|
7423
7445
|
const mcp = ensureObject(data, "mcp");
|
|
@@ -7469,14 +7491,13 @@ function ensureAgentBase(data, agentName) {
|
|
|
7469
7491
|
return created;
|
|
7470
7492
|
}
|
|
7471
7493
|
function ensureAgentDefaults(agent, agentName) {
|
|
7472
|
-
const defaultDescription = agentName === "foundry-librarian" ? "Foundry exploration and context gathering (parallel-friendly)" : "Foundry execution agent (uses only enabled palantir-mcp tools)";
|
|
7473
7494
|
const mode = agent["mode"];
|
|
7474
7495
|
if (typeof mode !== "string")
|
|
7475
7496
|
agent["mode"] = "subagent";
|
|
7476
7497
|
if (typeof agent["hidden"] !== "boolean")
|
|
7477
7498
|
agent["hidden"] = false;
|
|
7478
7499
|
if (typeof agent["description"] !== "string") {
|
|
7479
|
-
agent["description"] =
|
|
7500
|
+
agent["description"] = agentName === "foundry-librarian" ? "Foundry exploration and context gathering (parallel-friendly)" : "Foundry execution agent (uses only enabled palantir-mcp tools)";
|
|
7480
7501
|
}
|
|
7481
7502
|
if (typeof agent["prompt"] !== "string") {
|
|
7482
7503
|
agent["prompt"] = agentName === "foundry-librarian" ? [
|
|
@@ -7497,27 +7518,6 @@ function ensureAgentDefaults(agent, agentName) {
|
|
|
7497
7518
|
`);
|
|
7498
7519
|
}
|
|
7499
7520
|
}
|
|
7500
|
-
var GENERATED_NOTE_PREFIX = "Generated by opencode-palantir /setup-palantir-mcp.";
|
|
7501
|
-
function buildGeneratedNote(profile) {
|
|
7502
|
-
return `${GENERATED_NOTE_PREFIX} Profile: ${profile}. Edit palantir-mcp_* tool flags below to reject tools.`;
|
|
7503
|
-
}
|
|
7504
|
-
function stripGeneratedNote(description) {
|
|
7505
|
-
const idx = description.indexOf(GENERATED_NOTE_PREFIX);
|
|
7506
|
-
if (idx === -1)
|
|
7507
|
-
return description.trim();
|
|
7508
|
-
const before = description.slice(0, idx).trimEnd();
|
|
7509
|
-
return before.replace(/(?:\s*(?:\||-)\s*)$/, "").trimEnd();
|
|
7510
|
-
}
|
|
7511
|
-
function annotateAgentDescription(agent, agentName, profile, mode) {
|
|
7512
|
-
const defaultDescription = agentName === "foundry-librarian" ? "Foundry exploration and context gathering (parallel-friendly)" : "Foundry execution agent (uses only enabled palantir-mcp tools)";
|
|
7513
|
-
const raw = agent["description"];
|
|
7514
|
-
const description = typeof raw === "string" ? raw : defaultDescription;
|
|
7515
|
-
const shouldAnnotate = mode === "setup" || description.includes(GENERATED_NOTE_PREFIX) || description.trim() === defaultDescription;
|
|
7516
|
-
if (!shouldAnnotate)
|
|
7517
|
-
return;
|
|
7518
|
-
const base = stripGeneratedNote(description);
|
|
7519
|
-
agent["description"] = base ? `${base} | ${buildGeneratedNote(profile)}` : buildGeneratedNote(profile);
|
|
7520
|
-
}
|
|
7521
7521
|
function ensureDocsToolDefaults(tools, agentName) {
|
|
7522
7522
|
if (agentName === "foundry-librarian") {
|
|
7523
7523
|
if (tools["get_doc_page"] === undefined)
|
|
@@ -7567,17 +7567,15 @@ function patchConfigForSetup(input, opts) {
|
|
|
7567
7567
|
const data = { ...input };
|
|
7568
7568
|
if (data["$schema"] === undefined)
|
|
7569
7569
|
data["$schema"] = "https://opencode.ai/config.json";
|
|
7570
|
-
removeUnsupportedPalantirMeta(data);
|
|
7571
7570
|
ensureGlobalDeny(data);
|
|
7572
7571
|
ensureMcpServer(data, opts.foundryApiUrl);
|
|
7572
|
+
setProfileIfMissing(data, opts.profile);
|
|
7573
7573
|
const librarianAgent = ensureAgentBase(data, "foundry-librarian");
|
|
7574
7574
|
ensureAgentDefaults(librarianAgent, "foundry-librarian");
|
|
7575
|
-
annotateAgentDescription(librarianAgent, "foundry-librarian", opts.profile, "setup");
|
|
7576
7575
|
const librarianTools = ensureObject(librarianAgent, "tools");
|
|
7577
7576
|
ensureDocsToolDefaults(librarianTools, "foundry-librarian");
|
|
7578
7577
|
const foundryAgent = ensureAgentBase(data, "foundry");
|
|
7579
7578
|
ensureAgentDefaults(foundryAgent, "foundry");
|
|
7580
|
-
annotateAgentDescription(foundryAgent, "foundry", opts.profile, "setup");
|
|
7581
7579
|
const foundryTools = ensureObject(foundryAgent, "tools");
|
|
7582
7580
|
ensureDocsToolDefaults(foundryTools, "foundry");
|
|
7583
7581
|
const libApply = applyToolToggles(librarianTools, opts.toolNames, opts.allowlist.librarianAllow, "setup");
|
|
@@ -7602,16 +7600,14 @@ function patchConfigForRescan(input, opts) {
|
|
|
7602
7600
|
const data = { ...input };
|
|
7603
7601
|
if (data["$schema"] === undefined)
|
|
7604
7602
|
data["$schema"] = "https://opencode.ai/config.json";
|
|
7605
|
-
removeUnsupportedPalantirMeta(data);
|
|
7606
7603
|
ensureGlobalDeny(data);
|
|
7604
|
+
setProfileIfMissing(data, opts.profile);
|
|
7607
7605
|
const librarianAgent = ensureAgentBase(data, "foundry-librarian");
|
|
7608
7606
|
ensureAgentDefaults(librarianAgent, "foundry-librarian");
|
|
7609
|
-
annotateAgentDescription(librarianAgent, "foundry-librarian", opts.profile, "rescan");
|
|
7610
7607
|
const librarianTools = ensureObject(librarianAgent, "tools");
|
|
7611
7608
|
ensureDocsToolDefaults(librarianTools, "foundry-librarian");
|
|
7612
7609
|
const foundryAgent = ensureAgentBase(data, "foundry");
|
|
7613
7610
|
ensureAgentDefaults(foundryAgent, "foundry");
|
|
7614
|
-
annotateAgentDescription(foundryAgent, "foundry", opts.profile, "rescan");
|
|
7615
7611
|
const foundryTools = ensureObject(foundryAgent, "tools");
|
|
7616
7612
|
ensureDocsToolDefaults(foundryTools, "foundry");
|
|
7617
7613
|
const libApply = applyToolToggles(librarianTools, opts.toolNames, opts.allowlist.librarianAllow, "rescan");
|
|
@@ -7891,14 +7887,22 @@ function formatPatchSummary(patch) {
|
|
|
7891
7887
|
return lines.join(`
|
|
7892
7888
|
`);
|
|
7893
7889
|
}
|
|
7894
|
-
async function resolveProfile(worktree) {
|
|
7890
|
+
async function resolveProfile(worktree, baseConfig) {
|
|
7891
|
+
const override = readProfileOverride(baseConfig);
|
|
7892
|
+
if (override)
|
|
7893
|
+
return {
|
|
7894
|
+
profile: override,
|
|
7895
|
+
reasons: ["Using palantir_mcp.profile override"],
|
|
7896
|
+
usedOverride: true
|
|
7897
|
+
};
|
|
7895
7898
|
try {
|
|
7896
7899
|
const scan = await scanRepoForProfile(worktree);
|
|
7897
|
-
return { profile: scan.profile, reasons: scan.reasons };
|
|
7900
|
+
return { profile: scan.profile, reasons: scan.reasons, usedOverride: false };
|
|
7898
7901
|
} catch (err) {
|
|
7899
7902
|
return {
|
|
7900
7903
|
profile: "unknown",
|
|
7901
|
-
reasons: [`Repo scan failed; falling back to unknown: ${formatError3(err)}`]
|
|
7904
|
+
reasons: [`Repo scan failed; falling back to unknown: ${formatError3(err)}`],
|
|
7905
|
+
usedOverride: false
|
|
7902
7906
|
};
|
|
7903
7907
|
}
|
|
7904
7908
|
}
|
|
@@ -7923,10 +7927,7 @@ async function setupPalantirMcp(worktree, rawArgs) {
|
|
|
7923
7927
|
return [
|
|
7924
7928
|
"[ERROR] FOUNDRY_TOKEN is not set in your environment.",
|
|
7925
7929
|
"",
|
|
7926
|
-
"palantir-mcp tool discovery requires a token. Export FOUNDRY_TOKEN and retry."
|
|
7927
|
-
"",
|
|
7928
|
-
"Tip: if `echo $FOUNDRY_TOKEN` prints a value but this still errors, it is likely " + "not exported.",
|
|
7929
|
-
"Run `export FOUNDRY_TOKEN` (or set `export FOUNDRY_TOKEN=...` in your shell " + "secrets) and retry."
|
|
7930
|
+
"palantir-mcp tool discovery requires a token. Export FOUNDRY_TOKEN and retry."
|
|
7930
7931
|
].join(`
|
|
7931
7932
|
`);
|
|
7932
7933
|
}
|
|
@@ -7941,7 +7942,7 @@ async function setupPalantirMcp(worktree, rawArgs) {
|
|
|
7941
7942
|
const merged = readLegacy.ok ? mergeLegacyIntoJsonc(readLegacy.data, base) : { ...base };
|
|
7942
7943
|
const existingMcpUrlRaw = extractFoundryApiUrlFromMcpConfig(merged);
|
|
7943
7944
|
const existingMcpUrlNorm = existingMcpUrlRaw ? normalizeFoundryBaseUrl(existingMcpUrlRaw) : null;
|
|
7944
|
-
const { profile } = await resolveProfile(worktree);
|
|
7945
|
+
const { profile } = await resolveProfile(worktree, merged);
|
|
7945
7946
|
const discoveryUrl = existingMcpUrlNorm && "url" in existingMcpUrlNorm ? existingMcpUrlNorm.url : normalized.url;
|
|
7946
7947
|
let toolNames;
|
|
7947
7948
|
try {
|
|
@@ -7995,10 +7996,7 @@ async function rescanPalantirMcpTools(worktree) {
|
|
|
7995
7996
|
return [
|
|
7996
7997
|
"[ERROR] FOUNDRY_TOKEN is not set in your environment.",
|
|
7997
7998
|
"",
|
|
7998
|
-
"palantir-mcp tool discovery requires a token. Export FOUNDRY_TOKEN and retry."
|
|
7999
|
-
"",
|
|
8000
|
-
"Tip: if `echo $FOUNDRY_TOKEN` prints a value but this still errors, it is likely " + "not exported.",
|
|
8001
|
-
"Run `export FOUNDRY_TOKEN` (or set `export FOUNDRY_TOKEN=...` in your shell " + "secrets) and retry."
|
|
7999
|
+
"palantir-mcp tool discovery requires a token. Export FOUNDRY_TOKEN and retry."
|
|
8002
8000
|
].join(`
|
|
8003
8001
|
`);
|
|
8004
8002
|
}
|
|
@@ -8023,7 +8021,7 @@ async function rescanPalantirMcpTools(worktree) {
|
|
|
8023
8021
|
const normalized = normalizeFoundryBaseUrl(foundryUrlRaw);
|
|
8024
8022
|
if ("error" in normalized)
|
|
8025
8023
|
return `[ERROR] Invalid Foundry URL in config: ${normalized.error}`;
|
|
8026
|
-
const { profile } = await resolveProfile(worktree);
|
|
8024
|
+
const { profile } = await resolveProfile(worktree, baseData);
|
|
8027
8025
|
let toolNames;
|
|
8028
8026
|
try {
|
|
8029
8027
|
toolNames = await listPalantirMcpTools(normalized.url);
|