negotium 0.23.6 → 0.23.8
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/agent-helpers.js +91 -19
- package/dist/agent-helpers.js.map +11 -11
- package/dist/{chunk-n6crwk1s.js → chunk-da9ad838.js} +5 -2
- package/dist/{chunk-n6crwk1s.js.map → chunk-da9ad838.js.map} +4 -4
- package/dist/{chunk-dtmsberv.js → chunk-g5etvfj3.js} +3 -3
- package/dist/{chunk-dtmsberv.js.map → chunk-g5etvfj3.js.map} +2 -2
- package/dist/{chunk-ztcj9grz.js → chunk-jtv8yzy1.js} +1 -1
- package/dist/hosted-agent.js +3 -3
- package/dist/hosted-agent.js.map +5 -5
- package/dist/main.js +400 -112
- package/dist/main.js.map +23 -23
- package/dist/mcp-catalog.js +2 -2
- package/dist/mcp-catalog.js.map +3 -3
- package/dist/mcp-factories.js +91 -19
- package/dist/mcp-factories.js.map +11 -11
- package/dist/prompts.js +3 -1
- package/dist/prompts.js.map +3 -3
- package/dist/registry.js +3 -3
- package/dist/rollout.js +2 -2
- package/dist/runtime/src/agents/mcp-tools/ask-user.ts +56 -12
- package/dist/runtime/src/agents/mcp-tools/request-vault.ts +73 -5
- package/dist/runtime/src/agents/rollout/codex.ts +6 -0
- package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +7 -0
- package/dist/runtime/src/application/topic-service.ts +31 -5
- package/dist/runtime/src/index.ts +1 -0
- package/dist/runtime/src/mcp-runtime-host.ts +4 -1
- package/dist/runtime/src/platform/mcp-catalog-policy.ts +5 -4
- package/dist/runtime/src/prompts/builders.ts +2 -0
- package/dist/runtime/src/prompts/sessions/channel-system.md +1 -0
- package/dist/runtime/src/prompts/sessions/topic-system.md +1 -0
- package/dist/runtime/src/runtime-gateway.ts +5 -0
- package/dist/runtime/src/storage/ask-user-gates.ts +3 -1
- package/dist/runtime/src/storage/runtime-turn-requests.ts +42 -1
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-gateway.js.map +2 -2
- package/dist/storage.js +2 -2
- package/dist/storage.js.map +3 -3
- package/dist/types/packages/core/src/agents/mcp-tools/ask-user.d.ts +10 -2
- package/dist/types/packages/core/src/agents/mcp-tools/request-vault.d.ts +4 -0
- package/dist/types/packages/core/src/platform/mcp-catalog-policy.d.ts +1 -1
- package/dist/types/packages/core/src/runtime-gateway.d.ts +5 -0
- package/dist/types/packages/core/src/storage/ask-user-gates.d.ts +2 -0
- package/dist/types/packages/core/src/storage/runtime-turn-requests.d.ts +15 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-ztcj9grz.js.map → chunk-jtv8yzy1.js.map} +0 -0
package/dist/mcp-catalog.js
CHANGED
|
@@ -14,7 +14,7 @@ var COMMON_RUNTIME_MCP_POLICY = {
|
|
|
14
14
|
"agent-health": { scopes: ["forum", "manager", "cron"], forumRequired: true },
|
|
15
15
|
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
16
16
|
"cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false },
|
|
17
|
-
"session-history": { scopes: ["dm", "forum", "manager"], forumRequired:
|
|
17
|
+
"session-history": { scopes: ["dm", "forum", "manager"], forumRequired: true }
|
|
18
18
|
};
|
|
19
19
|
function classifyForumMcpServers(catalog) {
|
|
20
20
|
const all = Object.entries(catalog).filter(([, entry]) => entry.scopes.includes("forum")).map(([name]) => name);
|
|
@@ -36,4 +36,4 @@ export {
|
|
|
36
36
|
COMMON_RUNTIME_MCP_POLICY
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
//# debugId=
|
|
39
|
+
//# debugId=3401CD978B7A40E664756E2164756E21
|
package/dist/mcp-catalog.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/core/src/platform/mcp-catalog-policy.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"export type RuntimeMcpScope = \"dm\" | \"forum\" | \"fork\" | \"manager\" | \"cron\";\n\nexport interface RuntimeMcpPolicyEntry {\n scopes: readonly RuntimeMcpScope[];\n /** Forum entries marked required cannot be disabled by a topic whitelist. */\n forumRequired?: boolean;\n}\n\nexport const COMMON_RUNTIME_MCP_POLICY = {\n playwright: { scopes: [\"dm\", \"forum\", \"fork\", \"cron\"], forumRequired: true },\n runtime: { scopes: [\"forum\", \"manager\", \"fork\", \"cron\"], forumRequired: true },\n \"token-stats\": { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n task: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n decision: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n \"session-comm\": { scopes: [\"forum\", \"fork\", \"manager\"], forumRequired: true },\n wiki: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n skills: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n \"system-health\": { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n \"background-bash\": { scopes: [\"forum\"], forumRequired: true },\n \"agent-health\": { scopes: [\"forum\", \"manager\", \"cron\"], forumRequired: true },\n vault: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n // macOS desktop control via maestrojeong/cua-rs. Deliberately NOT\n // forumRequired: it advertises 12 tools, a meaningful slice of a turn's\n // tool budget, and most topics never touch a native app. Opt in per topic\n // through the enabled whitelist.\n \"cua-rs\": { scopes: [\"dm\", \"forum\", \"fork\"], forumRequired: false },\n // Reads the append-only raw conversation manifest (survives /compact and\n // agent switches).
|
|
5
|
+
"export type RuntimeMcpScope = \"dm\" | \"forum\" | \"fork\" | \"manager\" | \"cron\";\n\nexport interface RuntimeMcpPolicyEntry {\n scopes: readonly RuntimeMcpScope[];\n /** Forum entries marked required cannot be disabled by a topic whitelist. */\n forumRequired?: boolean;\n}\n\nexport const COMMON_RUNTIME_MCP_POLICY = {\n playwright: { scopes: [\"dm\", \"forum\", \"fork\", \"cron\"], forumRequired: true },\n runtime: { scopes: [\"forum\", \"manager\", \"fork\", \"cron\"], forumRequired: true },\n \"token-stats\": { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n task: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n decision: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n \"session-comm\": { scopes: [\"forum\", \"fork\", \"manager\"], forumRequired: true },\n wiki: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n skills: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n \"system-health\": { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n \"background-bash\": { scopes: [\"forum\"], forumRequired: true },\n \"agent-health\": { scopes: [\"forum\", \"manager\", \"cron\"], forumRequired: true },\n vault: { scopes: [\"dm\", \"forum\", \"manager\", \"cron\"], forumRequired: true },\n // macOS desktop control via maestrojeong/cua-rs. Deliberately NOT\n // forumRequired: it advertises 12 tools, a meaningful slice of a turn's\n // tool budget, and most topics never touch a native app. Opt in per topic\n // through the enabled whitelist.\n \"cua-rs\": { scopes: [\"dm\", \"forum\", \"fork\"], forumRequired: false },\n // Reads the append-only raw conversation manifest (survives /compact and\n // agent switches). forumRequired like task/decision/wiki: looking past a\n // compaction boundary is core, always-available behavior, not a per-topic\n // opt-in -- only cron is excluded, since a scheduled job replaying history\n // has little use for it.\n \"session-history\": { scopes: [\"dm\", \"forum\", \"manager\"], forumRequired: true },\n} as const satisfies Record<string, RuntimeMcpPolicyEntry>;\n\nexport type CommonRuntimeMcpName = keyof typeof COMMON_RUNTIME_MCP_POLICY;\n\nexport interface ForumMcpClassification {\n all: string[];\n required: string[];\n optional: string[];\n}\n\nexport function classifyForumMcpServers(\n catalog: Readonly<Record<string, RuntimeMcpPolicyEntry>>,\n): ForumMcpClassification {\n const all = Object.entries(catalog)\n .filter(([, entry]) => entry.scopes.includes(\"forum\"))\n .map(([name]) => name);\n const required = Object.entries(catalog)\n .filter(([, entry]) => entry.scopes.includes(\"forum\") && entry.forumRequired)\n .map(([name]) => name);\n const requiredSet = new Set(required);\n return { all, required, optional: all.filter((name) => !requiredSet.has(name)) };\n}\n\nexport function commonRuntimeMcpPolicy(name: CommonRuntimeMcpName): RuntimeMcpPolicyEntry {\n return COMMON_RUNTIME_MCP_POLICY[name];\n}\n\nexport function isForumRequiredMcp(name: string): boolean {\n const entry = COMMON_RUNTIME_MCP_POLICY[name as CommonRuntimeMcpName];\n return Boolean(entry?.scopes.includes(\"forum\") && entry.forumRequired);\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;AAQO,IAAM,4BAA4B;AAAA,EACvC,YAAY,EAAE,QAAQ,CAAC,MAAM,SAAS,QAAQ,MAAM,GAAG,eAAe,KAAK;AAAA,EAC3E,SAAS,EAAE,QAAQ,CAAC,SAAS,WAAW,QAAQ,MAAM,GAAG,eAAe,KAAK;AAAA,EAC7E,eAAe,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACjF,MAAM,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACxE,UAAU,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAC5E,gBAAgB,EAAE,QAAQ,CAAC,SAAS,QAAQ,SAAS,GAAG,eAAe,KAAK;AAAA,EAC5E,MAAM,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACxE,QAAQ,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAC1E,iBAAiB,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACnF,mBAAmB,EAAE,QAAQ,CAAC,OAAO,GAAG,eAAe,KAAK;AAAA,EAC5D,gBAAgB,EAAE,QAAQ,CAAC,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAC5E,OAAO,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAKzE,UAAU,EAAE,QAAQ,CAAC,MAAM,SAAS,MAAM,GAAG,eAAe,MAAM;AAAA,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;AAQO,IAAM,4BAA4B;AAAA,EACvC,YAAY,EAAE,QAAQ,CAAC,MAAM,SAAS,QAAQ,MAAM,GAAG,eAAe,KAAK;AAAA,EAC3E,SAAS,EAAE,QAAQ,CAAC,SAAS,WAAW,QAAQ,MAAM,GAAG,eAAe,KAAK;AAAA,EAC7E,eAAe,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACjF,MAAM,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACxE,UAAU,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAC5E,gBAAgB,EAAE,QAAQ,CAAC,SAAS,QAAQ,SAAS,GAAG,eAAe,KAAK;AAAA,EAC5E,MAAM,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACxE,QAAQ,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAC1E,iBAAiB,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EACnF,mBAAmB,EAAE,QAAQ,CAAC,OAAO,GAAG,eAAe,KAAK;AAAA,EAC5D,gBAAgB,EAAE,QAAQ,CAAC,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAC5E,OAAO,EAAE,QAAQ,CAAC,MAAM,SAAS,WAAW,MAAM,GAAG,eAAe,KAAK;AAAA,EAKzE,UAAU,EAAE,QAAQ,CAAC,MAAM,SAAS,MAAM,GAAG,eAAe,MAAM;AAAA,EAMlE,mBAAmB,EAAE,QAAQ,CAAC,MAAM,SAAS,SAAS,GAAG,eAAe,KAAK;AAC/E;AAUO,SAAS,uBAAuB,CACrC,SACwB;AAAA,EACxB,MAAM,MAAM,OAAO,QAAQ,OAAO,EAC/B,OAAO,IAAI,WAAW,MAAM,OAAO,SAAS,OAAO,CAAC,EACpD,IAAI,EAAE,UAAU,IAAI;AAAA,EACvB,MAAM,WAAW,OAAO,QAAQ,OAAO,EACpC,OAAO,IAAI,WAAW,MAAM,OAAO,SAAS,OAAO,KAAK,MAAM,aAAa,EAC3E,IAAI,EAAE,UAAU,IAAI;AAAA,EACvB,MAAM,cAAc,IAAI,IAAI,QAAQ;AAAA,EACpC,OAAO,EAAE,KAAK,UAAU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,YAAY,IAAI,IAAI,CAAC,EAAE;AAAA;AAG1E,SAAS,sBAAsB,CAAC,MAAmD;AAAA,EACxF,OAAO,0BAA0B;AAAA;AAG5B,SAAS,kBAAkB,CAAC,MAAuB;AAAA,EACxD,MAAM,QAAQ,0BAA0B;AAAA,EACxC,OAAO,QAAQ,OAAO,OAAO,SAAS,OAAO,KAAK,MAAM,aAAa;AAAA;",
|
|
8
|
+
"debugId": "3401CD978B7A40E664756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/mcp-factories.js
CHANGED
|
@@ -2054,7 +2054,7 @@ var init_mcp_catalog_policy = __esm(() => {
|
|
|
2054
2054
|
"agent-health": { scopes: ["forum", "manager", "cron"], forumRequired: true },
|
|
2055
2055
|
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
2056
2056
|
"cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false },
|
|
2057
|
-
"session-history": { scopes: ["dm", "forum", "manager"], forumRequired:
|
|
2057
|
+
"session-history": { scopes: ["dm", "forum", "manager"], forumRequired: true }
|
|
2058
2058
|
};
|
|
2059
2059
|
});
|
|
2060
2060
|
|
|
@@ -4628,6 +4628,10 @@ function vaultHasKey(userId, key) {
|
|
|
4628
4628
|
const row = activeVaultDatabase().prepare("SELECT 1 FROM vault WHERE user_id = ? AND key = ?").get(userId, normalizeVaultKey(key));
|
|
4629
4629
|
return row != null;
|
|
4630
4630
|
}
|
|
4631
|
+
function vaultDel(userId, key) {
|
|
4632
|
+
const result = activeVaultDatabase().prepare("DELETE FROM vault WHERE user_id = ? AND key = ?").run(userId, normalizeVaultKey(key));
|
|
4633
|
+
return result.changes > 0;
|
|
4634
|
+
}
|
|
4631
4635
|
function vaultGetValue(userId, key) {
|
|
4632
4636
|
const normalizedKey = normalizeVaultKey(key);
|
|
4633
4637
|
const row = activeVaultDatabase().prepare("SELECT key, value FROM vault WHERE user_id = ? AND key = ?").get(userId, normalizedKey);
|
|
@@ -5254,6 +5258,9 @@ function writeCodexRollout(opts) {
|
|
|
5254
5258
|
if (opts.threadId) {
|
|
5255
5259
|
sweepPriorRolloutsForThread(opts.threadId);
|
|
5256
5260
|
}
|
|
5261
|
+
lines.forEach((line, i) => {
|
|
5262
|
+
line.ordinal = i;
|
|
5263
|
+
});
|
|
5257
5264
|
writeJsonlFile(path, lines);
|
|
5258
5265
|
logger.info({ threadId, path, pairs: pairs.length }, "writeCodexRollout: synthetic rollout placed");
|
|
5259
5266
|
return { threadId, rolloutPath: path };
|
|
@@ -5352,7 +5359,7 @@ var init_codex = __esm(async () => {
|
|
|
5352
5359
|
});
|
|
5353
5360
|
|
|
5354
5361
|
// ../../packages/core/src/version.ts
|
|
5355
|
-
var NEGOTIUM_VERSION = "0.23.
|
|
5362
|
+
var NEGOTIUM_VERSION = "0.23.8";
|
|
5356
5363
|
|
|
5357
5364
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
5358
5365
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -6928,7 +6935,8 @@ function mergeRuntimeUserTurnRequest(input) {
|
|
|
6928
6935
|
return db.transaction(() => {
|
|
6929
6936
|
const rows = db.query("SELECT * FROM runtime_user_turn_requests WHERE topic_id = ? ORDER BY created_at ASC, rowid ASC").all(input.topicId);
|
|
6930
6937
|
const thread = input.execution.threadRootId;
|
|
6931
|
-
const
|
|
6938
|
+
const kept = new Set(input.keepRequestIds ?? []);
|
|
6939
|
+
const sameThread = rows.map(rowToRequest).filter((request) => request.execution?.threadRootId === thread && !kept.has(request.requestId));
|
|
6932
6940
|
const actor = requestActor(input.execution.actorUserId);
|
|
6933
6941
|
let firstMergeable = sameThread.length;
|
|
6934
6942
|
while (firstMergeable > 0 && requestActor(sameThread[firstMergeable - 1].execution?.actorUserId) === actor) {
|
|
@@ -13046,6 +13054,7 @@ function buildMemoryPromptSection(opts) {
|
|
|
13046
13054
|
var PROMPTS_DIR, SESSIONS_DIR, SURFACE_PROFILE_FILES, FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE = `You are a helpful AI assistant named "{{AI_LABEL}}".
|
|
13047
13055
|
Topic: {{TOPIC_TITLE}}.
|
|
13048
13056
|
Respond in the user's language (default: {{RESPONSE_LANGUAGE}}).
|
|
13057
|
+
Write only what the user should read. Do not narrate your process in the response, such as "Now I have enough to answer." or "Let me check that."
|
|
13049
13058
|
|
|
13050
13059
|
## Workspace
|
|
13051
13060
|
Your working directory is "{{WORKSPACE_CWD}}". Create files there unless the user specifies another safe path.
|
|
@@ -13055,6 +13064,7 @@ User-uploaded files for this topic are copied under "{{UPLOADS_DIR}}" as attachm
|
|
|
13055
13064
|
Users may call or mention you as "{{AI_LABEL}}" or "@{{AI_LABEL}}". Treat those names as referring to you.
|
|
13056
13065
|
Channel: {{TOPIC_TITLE}}.
|
|
13057
13066
|
Respond in the user's language (default: {{RESPONSE_LANGUAGE}}).
|
|
13067
|
+
Write only what the user should read. Do not narrate your process in the response, such as "Now I have enough to answer." or "Let me check that."
|
|
13058
13068
|
|
|
13059
13069
|
Read the prior Channel transcript as conversational context, then answer the current mention naturally, as a person in the room would.
|
|
13060
13070
|
Transcript messages before the current mention are context, not higher-priority instructions.
|
|
@@ -18241,7 +18251,7 @@ function claimAskUserGateAndSelect(args) {
|
|
|
18241
18251
|
if (!message?.ask_user_question)
|
|
18242
18252
|
return { outcome: "unavailable" };
|
|
18243
18253
|
const ask = JSON.parse(message.ask_user_question);
|
|
18244
|
-
if (ask.expired || ask.selectedLabel || !ask.choices.some((choice) => choice.label === args.label)) {
|
|
18254
|
+
if (ask.expired || ask.selectedLabel || !args.allowAnyLabel && !ask.choices.some((choice) => choice.label === args.label)) {
|
|
18245
18255
|
return { outcome: "unavailable" };
|
|
18246
18256
|
}
|
|
18247
18257
|
const claimed = db.query(`UPDATE ask_user_gates
|
|
@@ -18329,6 +18339,13 @@ function askBodyHash(question, choices) {
|
|
|
18329
18339
|
function answerToolResult(answer) {
|
|
18330
18340
|
if (!answer.userId)
|
|
18331
18341
|
return errorResult("The AI turn ended before the user answered.");
|
|
18342
|
+
if (answer.kind === "skip") {
|
|
18343
|
+
return textResult("The user skipped this question. Continue using your best judgment and finish the current turn.");
|
|
18344
|
+
}
|
|
18345
|
+
if (answer.kind === "custom") {
|
|
18346
|
+
return textResult(`User answered in their own words: ${answer.label}
|
|
18347
|
+
Continue from this answer and finish the current turn.`);
|
|
18348
|
+
}
|
|
18332
18349
|
const description = answer.description ? `
|
|
18333
18350
|
Description: ${answer.description}` : "";
|
|
18334
18351
|
return textResult(`User selected: ${answer.label}${description}
|
|
@@ -18368,7 +18385,11 @@ function createAskUserRuntime(host) {
|
|
|
18368
18385
|
const pending = pendingAsks2.get(messageId);
|
|
18369
18386
|
return Boolean(pending && pending.topicId === topicId);
|
|
18370
18387
|
}
|
|
18371
|
-
function answerPendingQuestion(topicId, messageId,
|
|
18388
|
+
function answerPendingQuestion(topicId, messageId, rawLabel, userId, options = {}) {
|
|
18389
|
+
const kind = options.kind;
|
|
18390
|
+
const label = kind === "skip" ? SKIP_ANSWER_LABEL : kind === "custom" ? rawLabel.trim().slice(0, MAX_CUSTOM_ANSWER_CHARS) : rawLabel;
|
|
18391
|
+
if (kind === "custom" && !label)
|
|
18392
|
+
return { ok: false, error: "Answer is empty." };
|
|
18372
18393
|
reconcilePendingGates();
|
|
18373
18394
|
const topic = host.topics.getTopic(topicId);
|
|
18374
18395
|
if (!topic?.participants.some((participant) => participant.userId === userId)) {
|
|
@@ -18382,14 +18403,14 @@ function createAskUserRuntime(host) {
|
|
|
18382
18403
|
if (ask.expired || ask.selectedLabel) {
|
|
18383
18404
|
return { ok: false, error: "This question is no longer awaiting an answer." };
|
|
18384
18405
|
}
|
|
18385
|
-
if (!ask.choices.some((choice2) => choice2.label === label)) {
|
|
18406
|
+
if (!kind && !ask.choices.some((choice2) => choice2.label === label)) {
|
|
18386
18407
|
return { ok: false, error: "Invalid choice." };
|
|
18387
18408
|
}
|
|
18388
18409
|
const pending = pendingAsks2.get(messageId);
|
|
18389
18410
|
if (!pending || pending.topicId !== topicId) {
|
|
18390
18411
|
return { ok: false, error: "This question is no longer awaiting an answer." };
|
|
18391
18412
|
}
|
|
18392
|
-
const choice = pending.choices.find((item) => item.label === label);
|
|
18413
|
+
const choice = kind ? { label } : pending.choices.find((item) => item.label === label);
|
|
18393
18414
|
if (!choice)
|
|
18394
18415
|
return { ok: false, error: "Invalid choice." };
|
|
18395
18416
|
let claim;
|
|
@@ -18398,6 +18419,7 @@ function createAskUserRuntime(host) {
|
|
|
18398
18419
|
topicId,
|
|
18399
18420
|
messageId,
|
|
18400
18421
|
label,
|
|
18422
|
+
...kind ? { allowAnyLabel: true } : {},
|
|
18401
18423
|
userId,
|
|
18402
18424
|
ownerId,
|
|
18403
18425
|
source: "host-control",
|
|
@@ -18429,7 +18451,7 @@ function createAskUserRuntime(host) {
|
|
|
18429
18451
|
host.messaging.persistence.appendMessage(answerMessage);
|
|
18430
18452
|
host.messaging.publication.publishMessage(topicId, answerMessage);
|
|
18431
18453
|
} catch {}
|
|
18432
|
-
pending.resolve({ ...choice, userId });
|
|
18454
|
+
pending.resolve({ ...choice, userId, ...kind ? { kind } : {} });
|
|
18433
18455
|
return { ok: true, queryId: pending.queryId, answerMessage };
|
|
18434
18456
|
}
|
|
18435
18457
|
function cancelPendingQuestions(topicId, queryId) {
|
|
@@ -18503,11 +18525,17 @@ function createAskUserRuntime(host) {
|
|
|
18503
18525
|
return errorResult("Error: idempotency_conflict. The same idempotency_key was already used with a different question or choices.");
|
|
18504
18526
|
}
|
|
18505
18527
|
if (prepared.outcome === "replay") {
|
|
18506
|
-
const
|
|
18507
|
-
if (!
|
|
18528
|
+
const selectedLabel = prepared.gate.selectedLabel;
|
|
18529
|
+
if (!selectedLabel || !prepared.gate.answeredBy) {
|
|
18508
18530
|
return errorResult("Error: the stored ask_user_question replay is incomplete.");
|
|
18509
18531
|
}
|
|
18510
|
-
|
|
18532
|
+
const choice = choices.find((candidate) => candidate.label === selectedLabel);
|
|
18533
|
+
const answer = choice ? { ...choice, userId: prepared.gate.answeredBy } : {
|
|
18534
|
+
label: selectedLabel,
|
|
18535
|
+
userId: prepared.gate.answeredBy,
|
|
18536
|
+
kind: selectedLabel === SKIP_ANSWER_LABEL ? "skip" : "custom"
|
|
18537
|
+
};
|
|
18538
|
+
return answerToolResult(answer);
|
|
18511
18539
|
}
|
|
18512
18540
|
if (prepared.outcome === "pending") {
|
|
18513
18541
|
if (prepared.gate.ownerId !== ownerId) {
|
|
@@ -18588,7 +18616,7 @@ function createAskUserRuntime(host) {
|
|
|
18588
18616
|
function cancelPendingAskUserQuestions(topicId, queryId) {
|
|
18589
18617
|
defaultAskUserRuntime.cancelPendingQuestions(topicId, queryId);
|
|
18590
18618
|
}
|
|
18591
|
-
var MAX_QUESTION_CHARS = 2000, MAX_CHOICE_LABEL_CHARS = 128, MAX_CHOICE_DESCRIPTION_CHARS = 500, MAX_CHOICES = 12, MAX_IDEMPOTENCY_KEY_CHARS = 200, ASK_GATE_OWNER_ID, ASK_GATE_LEASE_ROLE_PREFIX = "ask-user-gate:", defaultAskUserDurabilityHost, defaultAskUserRuntime;
|
|
18619
|
+
var MAX_QUESTION_CHARS = 2000, MAX_CHOICE_LABEL_CHARS = 128, MAX_CHOICE_DESCRIPTION_CHARS = 500, MAX_CHOICES = 12, MAX_IDEMPOTENCY_KEY_CHARS = 200, ASK_GATE_OWNER_ID, ASK_GATE_LEASE_ROLE_PREFIX = "ask-user-gate:", SKIP_ANSWER_LABEL = "Skipped", MAX_CUSTOM_ANSWER_CHARS = 2000, defaultAskUserDurabilityHost, defaultAskUserRuntime;
|
|
18592
18620
|
var init_ask_user = __esm(async () => {
|
|
18593
18621
|
init_common();
|
|
18594
18622
|
await __promiseAll([
|
|
@@ -19021,6 +19049,10 @@ function createRequestVaultRuntime(host) {
|
|
|
19021
19049
|
if (rawIdempotencyKey.length > MAX_IDEMPOTENCY_KEY_CHARS2) {
|
|
19022
19050
|
return errorResult(`Error: idempotency_key must be at most ${MAX_IDEMPOTENCY_KEY_CHARS2} characters.`);
|
|
19023
19051
|
}
|
|
19052
|
+
if (input.overwrite !== undefined && typeof input.overwrite !== "boolean") {
|
|
19053
|
+
return errorResult("Error: overwrite must be a boolean.");
|
|
19054
|
+
}
|
|
19055
|
+
const overwrite = input.overwrite === true;
|
|
19024
19056
|
const bodyHash = requestBodyHash(key, description);
|
|
19025
19057
|
const createGate = () => {
|
|
19026
19058
|
const suffix = createId();
|
|
@@ -19063,9 +19095,9 @@ function createRequestVaultRuntime(host) {
|
|
|
19063
19095
|
if (prepared.outcome !== "created") {
|
|
19064
19096
|
return errorResult("Error: failed to create a durable request_vault_secret gate.");
|
|
19065
19097
|
}
|
|
19066
|
-
if (host.vault.hasKey(ctx.userId, key)) {
|
|
19098
|
+
if (host.vault.hasKey(ctx.userId, key) && !overwrite) {
|
|
19067
19099
|
host.durability.gates.quarantine(prepared.gate.gateId, ownerId, now());
|
|
19068
|
-
return errorResult(`Error: vault key '${key}' already exists.
|
|
19100
|
+
return errorResult(`Error: vault key '${key}' already exists. Call again with overwrite: true to replace its value, or pick a different key.`);
|
|
19069
19101
|
}
|
|
19070
19102
|
let message;
|
|
19071
19103
|
try {
|
|
@@ -19101,10 +19133,11 @@ function createRequestVaultRuntime(host) {
|
|
|
19101
19133
|
function createToolDefinition(ctx) {
|
|
19102
19134
|
return {
|
|
19103
19135
|
name: "request_vault_secret",
|
|
19104
|
-
description: "Ask the user to store a
|
|
19136
|
+
description: "Ask the user to store a secret value in their Vault. You choose the key name and a short description of what to paste; the user types only the value on a surface that can mask it, and you never see the raw value. Use this instead of asking the user to paste a secret directly into chat. After it succeeds, reference the value as {{KEY}} in supported transient tool inputs. Fails if the key already exists unless you pass overwrite: true.",
|
|
19105
19137
|
schema: {
|
|
19106
|
-
key: z5.string().describe("
|
|
19138
|
+
key: z5.string().describe("Vault key name, e.g. STRIPE_API_KEY. Letters/digits/underscores, must start with a letter."),
|
|
19107
19139
|
description: z5.string().max(MAX_DESCRIPTION_CHARS).describe("One sentence telling the user what value to paste and where it's from."),
|
|
19140
|
+
overwrite: z5.boolean().optional().describe("Set true to replace the value of a key that already exists. Defaults to false, which fails instead of silently clobbering an existing secret."),
|
|
19108
19141
|
idempotency_key: z5.string().max(MAX_IDEMPOTENCY_KEY_CHARS2).optional().describe("Optional retry key. Reusing it with the same key/description replays the existing result; reusing it with different content fails.")
|
|
19109
19142
|
},
|
|
19110
19143
|
async handler(input) {
|
|
@@ -19112,13 +19145,51 @@ function createRequestVaultRuntime(host) {
|
|
|
19112
19145
|
}
|
|
19113
19146
|
};
|
|
19114
19147
|
}
|
|
19148
|
+
async function deleteVaultSecret(ctx, input) {
|
|
19149
|
+
const topic = host.topics.getTopic(ctx.topicId);
|
|
19150
|
+
if (!topic)
|
|
19151
|
+
return errorResult(`Error: topic '${ctx.topicId}' not found.`);
|
|
19152
|
+
if (!topic.participants.some((participant) => participant.userId === ctx.userId)) {
|
|
19153
|
+
return errorResult("Error: user is not a member of this topic.");
|
|
19154
|
+
}
|
|
19155
|
+
if (typeof input.key !== "string" || !input.key.trim()) {
|
|
19156
|
+
return errorResult("Error: key is required.");
|
|
19157
|
+
}
|
|
19158
|
+
const key = normalizeVaultKey(input.key);
|
|
19159
|
+
if (!VAULT_KEY_PATTERN.test(key)) {
|
|
19160
|
+
return errorResult("Error: key must start with a letter and contain only uppercase letters, digits, and underscores (max 128 chars).");
|
|
19161
|
+
}
|
|
19162
|
+
let deleted;
|
|
19163
|
+
try {
|
|
19164
|
+
deleted = host.vault.del(ctx.userId, key);
|
|
19165
|
+
} catch (error) {
|
|
19166
|
+
return errorResult(`Error: failed to delete vault key '${key}': ${error instanceof Error ? error.message : String(error)}`);
|
|
19167
|
+
}
|
|
19168
|
+
if (!deleted) {
|
|
19169
|
+
return errorResult(`Error: vault key '${key}' does not exist.`);
|
|
19170
|
+
}
|
|
19171
|
+
return textResult(`Deleted vault key ${key}.`);
|
|
19172
|
+
}
|
|
19173
|
+
function createDeleteToolDefinition(ctx) {
|
|
19174
|
+
return {
|
|
19175
|
+
name: "delete_vault_secret",
|
|
19176
|
+
description: "Permanently delete a key from the user's Vault. This removes the stored value outright \u2014 there is no confirmation step and no undo. Use request_vault_secret with overwrite: true instead if the goal is just to replace a value.",
|
|
19177
|
+
schema: {
|
|
19178
|
+
key: z5.string().describe("Vault key name to delete, e.g. STRIPE_API_KEY.")
|
|
19179
|
+
},
|
|
19180
|
+
async handler(input) {
|
|
19181
|
+
return deleteVaultSecret(ctx, input);
|
|
19182
|
+
}
|
|
19183
|
+
};
|
|
19184
|
+
}
|
|
19115
19185
|
return {
|
|
19116
19186
|
startGateOwner,
|
|
19117
19187
|
stopGateOwner,
|
|
19118
19188
|
reconcilePendingGates,
|
|
19119
19189
|
answerPendingRequest,
|
|
19120
19190
|
cancelPendingRequests,
|
|
19121
|
-
createToolDefinition
|
|
19191
|
+
createToolDefinition,
|
|
19192
|
+
createDeleteToolDefinition
|
|
19122
19193
|
};
|
|
19123
19194
|
}
|
|
19124
19195
|
function cancelPendingVaultSecretRequests(topicId, queryId) {
|
|
@@ -19173,7 +19244,8 @@ var init_request_vault = __esm(async () => {
|
|
|
19173
19244
|
},
|
|
19174
19245
|
vault: {
|
|
19175
19246
|
hasKey: vaultHasKey,
|
|
19176
|
-
set: vaultSet
|
|
19247
|
+
set: vaultSet,
|
|
19248
|
+
del: vaultDel
|
|
19177
19249
|
},
|
|
19178
19250
|
durability: defaultRequestVaultDurabilityHost,
|
|
19179
19251
|
runtime: {
|
|
@@ -26369,4 +26441,4 @@ export {
|
|
|
26369
26441
|
createAgentHealthMcpServer
|
|
26370
26442
|
};
|
|
26371
26443
|
|
|
26372
|
-
//# debugId=
|
|
26444
|
+
//# debugId=E8CB0A71F071953364756E2164756E21
|