@openontology/opencode-palantir 0.1.2 → 0.1.3
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 +45 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7291,19 +7291,6 @@ 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
|
-
|
|
7307
7294
|
// src/palantir-mcp/opencode-config.ts
|
|
7308
7295
|
var OPENCODE_JSONC_FILENAME = "opencode.jsonc";
|
|
7309
7296
|
var OPENCODE_JSON_FILENAME = "opencode.json";
|
|
@@ -7428,18 +7415,9 @@ function getString(obj, key) {
|
|
|
7428
7415
|
const v = obj[key];
|
|
7429
7416
|
return typeof v === "string" ? v : null;
|
|
7430
7417
|
}
|
|
7431
|
-
function
|
|
7432
|
-
|
|
7433
|
-
|
|
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;
|
|
7418
|
+
function removeUnsupportedPalantirMeta(data) {
|
|
7419
|
+
if (data["palantir_mcp"] !== undefined)
|
|
7420
|
+
delete data["palantir_mcp"];
|
|
7443
7421
|
}
|
|
7444
7422
|
function ensureMcpServer(data, foundryApiUrl) {
|
|
7445
7423
|
const mcp = ensureObject(data, "mcp");
|
|
@@ -7491,13 +7469,14 @@ function ensureAgentBase(data, agentName) {
|
|
|
7491
7469
|
return created;
|
|
7492
7470
|
}
|
|
7493
7471
|
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)";
|
|
7494
7473
|
const mode = agent["mode"];
|
|
7495
7474
|
if (typeof mode !== "string")
|
|
7496
7475
|
agent["mode"] = "subagent";
|
|
7497
7476
|
if (typeof agent["hidden"] !== "boolean")
|
|
7498
7477
|
agent["hidden"] = false;
|
|
7499
7478
|
if (typeof agent["description"] !== "string") {
|
|
7500
|
-
agent["description"] =
|
|
7479
|
+
agent["description"] = defaultDescription;
|
|
7501
7480
|
}
|
|
7502
7481
|
if (typeof agent["prompt"] !== "string") {
|
|
7503
7482
|
agent["prompt"] = agentName === "foundry-librarian" ? [
|
|
@@ -7518,6 +7497,27 @@ function ensureAgentDefaults(agent, agentName) {
|
|
|
7518
7497
|
`);
|
|
7519
7498
|
}
|
|
7520
7499
|
}
|
|
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,15 +7567,17 @@ 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);
|
|
7570
7571
|
ensureGlobalDeny(data);
|
|
7571
7572
|
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");
|
|
7575
7576
|
const librarianTools = ensureObject(librarianAgent, "tools");
|
|
7576
7577
|
ensureDocsToolDefaults(librarianTools, "foundry-librarian");
|
|
7577
7578
|
const foundryAgent = ensureAgentBase(data, "foundry");
|
|
7578
7579
|
ensureAgentDefaults(foundryAgent, "foundry");
|
|
7580
|
+
annotateAgentDescription(foundryAgent, "foundry", opts.profile, "setup");
|
|
7579
7581
|
const foundryTools = ensureObject(foundryAgent, "tools");
|
|
7580
7582
|
ensureDocsToolDefaults(foundryTools, "foundry");
|
|
7581
7583
|
const libApply = applyToolToggles(librarianTools, opts.toolNames, opts.allowlist.librarianAllow, "setup");
|
|
@@ -7600,14 +7602,16 @@ function patchConfigForRescan(input, opts) {
|
|
|
7600
7602
|
const data = { ...input };
|
|
7601
7603
|
if (data["$schema"] === undefined)
|
|
7602
7604
|
data["$schema"] = "https://opencode.ai/config.json";
|
|
7605
|
+
removeUnsupportedPalantirMeta(data);
|
|
7603
7606
|
ensureGlobalDeny(data);
|
|
7604
|
-
setProfileIfMissing(data, opts.profile);
|
|
7605
7607
|
const librarianAgent = ensureAgentBase(data, "foundry-librarian");
|
|
7606
7608
|
ensureAgentDefaults(librarianAgent, "foundry-librarian");
|
|
7609
|
+
annotateAgentDescription(librarianAgent, "foundry-librarian", opts.profile, "rescan");
|
|
7607
7610
|
const librarianTools = ensureObject(librarianAgent, "tools");
|
|
7608
7611
|
ensureDocsToolDefaults(librarianTools, "foundry-librarian");
|
|
7609
7612
|
const foundryAgent = ensureAgentBase(data, "foundry");
|
|
7610
7613
|
ensureAgentDefaults(foundryAgent, "foundry");
|
|
7614
|
+
annotateAgentDescription(foundryAgent, "foundry", opts.profile, "rescan");
|
|
7611
7615
|
const foundryTools = ensureObject(foundryAgent, "tools");
|
|
7612
7616
|
ensureDocsToolDefaults(foundryTools, "foundry");
|
|
7613
7617
|
const libApply = applyToolToggles(librarianTools, opts.toolNames, opts.allowlist.librarianAllow, "rescan");
|
|
@@ -7887,22 +7891,14 @@ function formatPatchSummary(patch) {
|
|
|
7887
7891
|
return lines.join(`
|
|
7888
7892
|
`);
|
|
7889
7893
|
}
|
|
7890
|
-
async function resolveProfile(worktree
|
|
7891
|
-
const override = readProfileOverride(baseConfig);
|
|
7892
|
-
if (override)
|
|
7893
|
-
return {
|
|
7894
|
-
profile: override,
|
|
7895
|
-
reasons: ["Using palantir_mcp.profile override"],
|
|
7896
|
-
usedOverride: true
|
|
7897
|
-
};
|
|
7894
|
+
async function resolveProfile(worktree) {
|
|
7898
7895
|
try {
|
|
7899
7896
|
const scan = await scanRepoForProfile(worktree);
|
|
7900
|
-
return { profile: scan.profile, reasons: scan.reasons
|
|
7897
|
+
return { profile: scan.profile, reasons: scan.reasons };
|
|
7901
7898
|
} catch (err) {
|
|
7902
7899
|
return {
|
|
7903
7900
|
profile: "unknown",
|
|
7904
|
-
reasons: [`Repo scan failed; falling back to unknown: ${formatError3(err)}`]
|
|
7905
|
-
usedOverride: false
|
|
7901
|
+
reasons: [`Repo scan failed; falling back to unknown: ${formatError3(err)}`]
|
|
7906
7902
|
};
|
|
7907
7903
|
}
|
|
7908
7904
|
}
|
|
@@ -7927,7 +7923,10 @@ async function setupPalantirMcp(worktree, rawArgs) {
|
|
|
7927
7923
|
return [
|
|
7928
7924
|
"[ERROR] FOUNDRY_TOKEN is not set in your environment.",
|
|
7929
7925
|
"",
|
|
7930
|
-
"palantir-mcp tool discovery requires a token. Export FOUNDRY_TOKEN and retry."
|
|
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."
|
|
7931
7930
|
].join(`
|
|
7932
7931
|
`);
|
|
7933
7932
|
}
|
|
@@ -7942,7 +7941,7 @@ async function setupPalantirMcp(worktree, rawArgs) {
|
|
|
7942
7941
|
const merged = readLegacy.ok ? mergeLegacyIntoJsonc(readLegacy.data, base) : { ...base };
|
|
7943
7942
|
const existingMcpUrlRaw = extractFoundryApiUrlFromMcpConfig(merged);
|
|
7944
7943
|
const existingMcpUrlNorm = existingMcpUrlRaw ? normalizeFoundryBaseUrl(existingMcpUrlRaw) : null;
|
|
7945
|
-
const { profile } = await resolveProfile(worktree
|
|
7944
|
+
const { profile } = await resolveProfile(worktree);
|
|
7946
7945
|
const discoveryUrl = existingMcpUrlNorm && "url" in existingMcpUrlNorm ? existingMcpUrlNorm.url : normalized.url;
|
|
7947
7946
|
let toolNames;
|
|
7948
7947
|
try {
|
|
@@ -7996,7 +7995,10 @@ async function rescanPalantirMcpTools(worktree) {
|
|
|
7996
7995
|
return [
|
|
7997
7996
|
"[ERROR] FOUNDRY_TOKEN is not set in your environment.",
|
|
7998
7997
|
"",
|
|
7999
|
-
"palantir-mcp tool discovery requires a token. Export FOUNDRY_TOKEN and retry."
|
|
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."
|
|
8000
8002
|
].join(`
|
|
8001
8003
|
`);
|
|
8002
8004
|
}
|
|
@@ -8021,7 +8023,7 @@ async function rescanPalantirMcpTools(worktree) {
|
|
|
8021
8023
|
const normalized = normalizeFoundryBaseUrl(foundryUrlRaw);
|
|
8022
8024
|
if ("error" in normalized)
|
|
8023
8025
|
return `[ERROR] Invalid Foundry URL in config: ${normalized.error}`;
|
|
8024
|
-
const { profile } = await resolveProfile(worktree
|
|
8026
|
+
const { profile } = await resolveProfile(worktree);
|
|
8025
8027
|
let toolNames;
|
|
8026
8028
|
try {
|
|
8027
8029
|
toolNames = await listPalantirMcpTools(normalized.url);
|