@bolt-foundry/gambit-core 0.8.1 → 0.8.5-rc.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/README.md +60 -34
- package/cards/context.card.md +5 -5
- package/cards/generate-test-input.card.md +12 -0
- package/{script/deps/jsr.io/@std/collections/1.1.4 → esm/deps/jsr.io/@std/collections/1.1.5}/deep_merge.d.ts +2 -2
- package/esm/deps/jsr.io/@std/collections/{1.1.4 → 1.1.5}/deep_merge.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/collections/{1.1.4 → 1.1.5}/deep_merge.js +29 -19
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +1 -1
- package/esm/mod.d.ts +20 -10
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +11 -5
- package/esm/schemas/graders/contexts/conversation.d.ts +22 -0
- package/esm/schemas/graders/contexts/conversation.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/conversation.js +17 -0
- package/esm/schemas/graders/contexts/conversation.zod.d.ts +3 -0
- package/esm/schemas/graders/contexts/conversation.zod.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/conversation.zod.js +2 -0
- package/esm/schemas/graders/contexts/conversation_tools.d.ts +31 -0
- package/esm/schemas/graders/contexts/conversation_tools.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/conversation_tools.js +25 -0
- package/esm/schemas/graders/contexts/conversation_tools.zod.d.ts +3 -0
- package/esm/schemas/graders/contexts/conversation_tools.zod.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/conversation_tools.zod.js +2 -0
- package/esm/schemas/graders/contexts/tools.d.ts +4 -0
- package/esm/schemas/graders/contexts/tools.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/tools.js +3 -0
- package/esm/schemas/graders/contexts/tools.zod.d.ts +3 -0
- package/esm/schemas/graders/contexts/tools.zod.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/tools.zod.js +2 -0
- package/esm/schemas/graders/contexts/turn.d.ts +10 -0
- package/esm/schemas/graders/contexts/turn.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/turn.js +8 -0
- package/esm/schemas/graders/contexts/turn.zod.d.ts +3 -0
- package/esm/schemas/graders/contexts/turn.zod.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/turn.zod.js +2 -0
- package/esm/schemas/graders/contexts/turn_tools.d.ts +32 -0
- package/esm/schemas/graders/contexts/turn_tools.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/turn_tools.js +28 -0
- package/esm/schemas/graders/contexts/turn_tools.zod.d.ts +3 -0
- package/esm/schemas/graders/contexts/turn_tools.zod.d.ts.map +1 -0
- package/esm/schemas/graders/contexts/turn_tools.zod.js +2 -0
- package/esm/schemas/graders/grader_output.d.ts +10 -0
- package/esm/schemas/graders/grader_output.d.ts.map +1 -0
- package/esm/schemas/graders/grader_output.js +8 -0
- package/esm/schemas/graders/grader_output.zod.d.ts +3 -0
- package/esm/schemas/graders/grader_output.zod.d.ts.map +1 -0
- package/esm/schemas/graders/grader_output.zod.js +2 -0
- package/esm/schemas/graders/respond.d.ts +12 -0
- package/esm/schemas/graders/respond.d.ts.map +1 -0
- package/esm/schemas/graders/respond.js +10 -0
- package/esm/schemas/graders/respond.zod.d.ts +3 -0
- package/esm/schemas/graders/respond.zod.d.ts.map +1 -0
- package/esm/schemas/graders/respond.zod.js +2 -0
- package/esm/schemas/scenarios/plain_chat_input_optional.d.ts +5 -0
- package/esm/schemas/scenarios/plain_chat_input_optional.d.ts.map +1 -0
- package/esm/schemas/scenarios/plain_chat_input_optional.js +5 -0
- package/esm/schemas/scenarios/plain_chat_input_optional.zod.d.ts +3 -0
- package/esm/schemas/scenarios/plain_chat_input_optional.zod.d.ts.map +1 -0
- package/esm/schemas/scenarios/plain_chat_input_optional.zod.js +2 -0
- package/esm/schemas/scenarios/plain_chat_output.d.ts +5 -0
- package/esm/schemas/scenarios/plain_chat_output.d.ts.map +1 -0
- package/esm/schemas/scenarios/plain_chat_output.js +4 -0
- package/esm/schemas/scenarios/plain_chat_output.zod.d.ts +3 -0
- package/esm/schemas/scenarios/plain_chat_output.zod.d.ts.map +1 -0
- package/esm/schemas/scenarios/plain_chat_output.zod.js +2 -0
- package/esm/src/builtins.d.ts +2 -0
- package/esm/src/builtins.d.ts.map +1 -1
- package/esm/src/builtins.js +45 -1
- package/esm/src/constants.d.ts +4 -0
- package/esm/src/constants.d.ts.map +1 -1
- package/esm/src/constants.js +5 -0
- package/esm/src/definitions.d.ts +5 -1
- package/esm/src/definitions.d.ts.map +1 -1
- package/esm/src/loader.d.ts.map +1 -1
- package/esm/src/loader.js +119 -13
- package/esm/src/markdown.d.ts.map +1 -1
- package/esm/src/markdown.js +222 -53
- package/esm/src/permissions.d.ts +143 -0
- package/esm/src/permissions.d.ts.map +1 -0
- package/esm/src/permissions.js +406 -0
- package/esm/src/render.d.ts.map +1 -1
- package/esm/src/render.js +22 -8
- package/esm/src/runtime.d.ts +28 -2
- package/esm/src/runtime.d.ts.map +1 -1
- package/esm/src/runtime.js +3051 -100
- package/esm/src/runtime_exec_host.d.ts +6 -0
- package/esm/src/runtime_exec_host.d.ts.map +1 -0
- package/esm/src/runtime_exec_host.js +17 -0
- package/esm/src/runtime_exec_host_contract.d.ts +23 -0
- package/esm/src/runtime_exec_host_contract.d.ts.map +1 -0
- package/esm/src/runtime_exec_host_contract.js +14 -0
- package/esm/src/runtime_exec_host_deno.d.ts +3 -0
- package/esm/src/runtime_exec_host_deno.d.ts.map +1 -0
- package/esm/src/runtime_exec_host_deno.js +35 -0
- package/esm/src/runtime_exec_host_unsupported.d.ts +3 -0
- package/esm/src/runtime_exec_host_unsupported.d.ts.map +1 -0
- package/esm/src/runtime_exec_host_unsupported.js +8 -0
- package/esm/src/runtime_worker_host.d.ts +6 -0
- package/esm/src/runtime_worker_host.d.ts.map +1 -0
- package/esm/src/runtime_worker_host.js +17 -0
- package/esm/src/runtime_worker_host_contract.d.ts +33 -0
- package/esm/src/runtime_worker_host_contract.d.ts.map +1 -0
- package/esm/src/runtime_worker_host_contract.js +14 -0
- package/esm/src/runtime_worker_host_deno.d.ts +3 -0
- package/esm/src/runtime_worker_host_deno.d.ts.map +1 -0
- package/esm/src/runtime_worker_host_deno.js +26 -0
- package/esm/src/runtime_worker_host_unsupported.d.ts +3 -0
- package/esm/src/runtime_worker_host_unsupported.d.ts.map +1 -0
- package/esm/src/runtime_worker_host_unsupported.js +8 -0
- package/esm/src/state.d.ts +4 -1
- package/esm/src/state.d.ts.map +1 -1
- package/esm/src/state.js +48 -2
- package/esm/src/types.d.ts +381 -1
- package/esm/src/types.d.ts.map +1 -1
- package/esm/src/types.js +102 -1
- package/package.json +73 -2
- package/schemas/graders/contexts/conversation.ts +32 -9
- package/schemas/graders/contexts/conversation.zod.ts +1 -0
- package/schemas/graders/contexts/conversation_tools.ts +63 -0
- package/schemas/graders/contexts/conversation_tools.zod.ts +1 -0
- package/schemas/graders/contexts/tools.ts +5 -0
- package/schemas/graders/contexts/tools.zod.ts +1 -0
- package/schemas/graders/contexts/turn.ts +8 -1
- package/schemas/graders/contexts/turn.zod.ts +1 -0
- package/schemas/graders/contexts/turn_tools.ts +63 -0
- package/schemas/graders/contexts/turn_tools.zod.ts +1 -0
- package/schemas/graders/grader_output.ts +15 -0
- package/schemas/graders/grader_output.zod.ts +1 -0
- package/schemas/graders/respond.ts +13 -3
- package/schemas/graders/respond.zod.ts +1 -0
- package/schemas/scenarios/plain_chat_input_optional.ts +6 -0
- package/schemas/scenarios/plain_chat_input_optional.zod.ts +1 -0
- package/schemas/scenarios/plain_chat_output.ts +5 -0
- package/schemas/scenarios/plain_chat_output.zod.ts +1 -0
- package/{esm/deps/jsr.io/@std/collections/1.1.4 → script/deps/jsr.io/@std/collections/1.1.5}/deep_merge.d.ts +2 -2
- package/script/deps/jsr.io/@std/collections/{1.1.4 → 1.1.5}/deep_merge.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/collections/{1.1.4 → 1.1.5}/deep_merge.js +29 -19
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +1 -1
- package/script/mod.d.ts +20 -10
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +25 -9
- package/script/schemas/graders/contexts/conversation.d.ts +22 -0
- package/script/schemas/graders/contexts/conversation.d.ts.map +1 -0
- package/script/schemas/graders/contexts/conversation.js +20 -0
- package/script/schemas/graders/contexts/conversation.zod.d.ts +3 -0
- package/script/schemas/graders/contexts/conversation.zod.d.ts.map +1 -0
- package/script/schemas/graders/contexts/conversation.zod.js +9 -0
- package/script/schemas/graders/contexts/conversation_tools.d.ts +31 -0
- package/script/schemas/graders/contexts/conversation_tools.d.ts.map +1 -0
- package/script/schemas/graders/contexts/conversation_tools.js +28 -0
- package/script/schemas/graders/contexts/conversation_tools.zod.d.ts +3 -0
- package/script/schemas/graders/contexts/conversation_tools.zod.d.ts.map +1 -0
- package/script/schemas/graders/contexts/conversation_tools.zod.js +9 -0
- package/script/schemas/graders/contexts/tools.d.ts +4 -0
- package/script/schemas/graders/contexts/tools.d.ts.map +1 -0
- package/script/schemas/graders/contexts/tools.js +12 -0
- package/script/schemas/graders/contexts/tools.zod.d.ts +3 -0
- package/script/schemas/graders/contexts/tools.zod.d.ts.map +1 -0
- package/script/schemas/graders/contexts/tools.zod.js +9 -0
- package/script/schemas/graders/contexts/turn.d.ts +10 -0
- package/script/schemas/graders/contexts/turn.d.ts.map +1 -0
- package/script/schemas/graders/contexts/turn.js +10 -0
- package/script/schemas/graders/contexts/turn.zod.d.ts +3 -0
- package/script/schemas/graders/contexts/turn.zod.d.ts.map +1 -0
- package/script/schemas/graders/contexts/turn.zod.js +9 -0
- package/script/schemas/graders/contexts/turn_tools.d.ts +32 -0
- package/script/schemas/graders/contexts/turn_tools.d.ts.map +1 -0
- package/script/schemas/graders/contexts/turn_tools.js +31 -0
- package/script/schemas/graders/contexts/turn_tools.zod.d.ts +3 -0
- package/script/schemas/graders/contexts/turn_tools.zod.d.ts.map +1 -0
- package/script/schemas/graders/contexts/turn_tools.zod.js +9 -0
- package/script/schemas/graders/grader_output.d.ts +10 -0
- package/script/schemas/graders/grader_output.d.ts.map +1 -0
- package/script/schemas/graders/grader_output.js +10 -0
- package/script/schemas/graders/grader_output.zod.d.ts +3 -0
- package/script/schemas/graders/grader_output.zod.d.ts.map +1 -0
- package/script/schemas/graders/grader_output.zod.js +9 -0
- package/script/schemas/graders/respond.d.ts +12 -0
- package/script/schemas/graders/respond.d.ts.map +1 -0
- package/script/schemas/graders/respond.js +12 -0
- package/script/schemas/graders/respond.zod.d.ts +3 -0
- package/script/schemas/graders/respond.zod.d.ts.map +1 -0
- package/script/schemas/graders/respond.zod.js +9 -0
- package/script/schemas/scenarios/plain_chat_input_optional.d.ts +5 -0
- package/script/schemas/scenarios/plain_chat_input_optional.d.ts.map +1 -0
- package/script/schemas/scenarios/plain_chat_input_optional.js +7 -0
- package/script/schemas/scenarios/plain_chat_input_optional.zod.d.ts +3 -0
- package/script/schemas/scenarios/plain_chat_input_optional.zod.d.ts.map +1 -0
- package/script/schemas/scenarios/plain_chat_input_optional.zod.js +9 -0
- package/script/schemas/scenarios/plain_chat_output.d.ts +5 -0
- package/script/schemas/scenarios/plain_chat_output.d.ts.map +1 -0
- package/script/schemas/scenarios/plain_chat_output.js +6 -0
- package/script/schemas/scenarios/plain_chat_output.zod.d.ts +3 -0
- package/script/schemas/scenarios/plain_chat_output.zod.d.ts.map +1 -0
- package/script/schemas/scenarios/plain_chat_output.zod.js +9 -0
- package/script/src/builtins.d.ts +2 -0
- package/script/src/builtins.d.ts.map +1 -1
- package/script/src/builtins.js +47 -1
- package/script/src/constants.d.ts +4 -0
- package/script/src/constants.d.ts.map +1 -1
- package/script/src/constants.js +6 -1
- package/script/src/definitions.d.ts +5 -1
- package/script/src/definitions.d.ts.map +1 -1
- package/script/src/loader.d.ts.map +1 -1
- package/script/src/loader.js +118 -12
- package/script/src/markdown.d.ts.map +1 -1
- package/script/src/markdown.js +221 -52
- package/script/src/permissions.d.ts +143 -0
- package/script/src/permissions.d.ts.map +1 -0
- package/script/src/permissions.js +453 -0
- package/script/src/render.d.ts.map +1 -1
- package/script/src/render.js +22 -8
- package/script/src/runtime.d.ts +28 -2
- package/script/src/runtime.d.ts.map +1 -1
- package/script/src/runtime.js +3053 -99
- package/script/src/runtime_exec_host.d.ts +6 -0
- package/script/src/runtime_exec_host.d.ts.map +1 -0
- package/script/src/runtime_exec_host.js +56 -0
- package/script/src/runtime_exec_host_contract.d.ts +23 -0
- package/script/src/runtime_exec_host_contract.d.ts.map +1 -0
- package/script/src/runtime_exec_host_contract.js +18 -0
- package/script/src/runtime_exec_host_deno.d.ts +3 -0
- package/script/src/runtime_exec_host_deno.d.ts.map +1 -0
- package/script/src/runtime_exec_host_deno.js +71 -0
- package/script/src/runtime_exec_host_unsupported.d.ts +3 -0
- package/script/src/runtime_exec_host_unsupported.d.ts.map +1 -0
- package/script/src/runtime_exec_host_unsupported.js +11 -0
- package/script/src/runtime_worker_host.d.ts +6 -0
- package/script/src/runtime_worker_host.d.ts.map +1 -0
- package/script/src/runtime_worker_host.js +56 -0
- package/script/src/runtime_worker_host_contract.d.ts +33 -0
- package/script/src/runtime_worker_host_contract.d.ts.map +1 -0
- package/script/src/runtime_worker_host_contract.js +18 -0
- package/script/src/runtime_worker_host_deno.d.ts +3 -0
- package/script/src/runtime_worker_host_deno.d.ts.map +1 -0
- package/script/src/runtime_worker_host_deno.js +62 -0
- package/script/src/runtime_worker_host_unsupported.d.ts +3 -0
- package/script/src/runtime_worker_host_unsupported.d.ts.map +1 -0
- package/script/src/runtime_worker_host_unsupported.js +11 -0
- package/script/src/state.d.ts +4 -1
- package/script/src/state.d.ts.map +1 -1
- package/script/src/state.js +48 -2
- package/script/src/types.d.ts +381 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +103 -0
- package/esm/deps/jsr.io/@std/collections/1.1.4/_utils.d.ts +0 -6
- package/esm/deps/jsr.io/@std/collections/1.1.4/_utils.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/collections/1.1.4/_utils.js +0 -18
- package/esm/src/openai_compat.d.ts +0 -63
- package/esm/src/openai_compat.d.ts.map +0 -1
- package/esm/src/openai_compat.js +0 -272
- package/esm/src/providers/openrouter.d.ts +0 -8
- package/esm/src/providers/openrouter.d.ts.map +0 -1
- package/esm/src/providers/openrouter.js +0 -168
- package/script/deps/jsr.io/@std/collections/1.1.4/_utils.d.ts +0 -6
- package/script/deps/jsr.io/@std/collections/1.1.4/_utils.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/collections/1.1.4/_utils.js +0 -21
- package/script/src/openai_compat.d.ts +0 -63
- package/script/src/openai_compat.d.ts.map +0 -1
- package/script/src/openai_compat.js +0 -276
- package/script/src/providers/openrouter.d.ts +0 -8
- package/script/src/providers/openrouter.d.ts.map +0 -1
- package/script/src/providers/openrouter.js +0 -207
package/script/src/markdown.js
CHANGED
|
@@ -42,6 +42,7 @@ const path = __importStar(require("../deps/jsr.io/@std/path/1.1.4/mod.js"));
|
|
|
42
42
|
const constants_js_1 = require("./constants.js");
|
|
43
43
|
const definitions_js_1 = require("./definitions.js");
|
|
44
44
|
const loader_js_1 = require("./loader.js");
|
|
45
|
+
const permissions_js_1 = require("./permissions.js");
|
|
45
46
|
const schema_js_1 = require("./schema.js");
|
|
46
47
|
const builtins_js_1 = require("./builtins.js");
|
|
47
48
|
const logger = console;
|
|
@@ -53,8 +54,10 @@ const LEGACY_MARKER_WARNINGS = {
|
|
|
53
54
|
init: false,
|
|
54
55
|
end: false,
|
|
55
56
|
};
|
|
57
|
+
const LEGACY_SCHEMA_WARNINGS = new Set();
|
|
58
|
+
const LEGACY_FRAGMENT_WARNINGS = new Set();
|
|
56
59
|
const INIT_TEXT = `
|
|
57
|
-
You will automatically receive a \`${constants_js_1.
|
|
60
|
+
You will automatically receive a \`${constants_js_1.GAMBIT_TOOL_CONTEXT}\` tool result at the start that provides run/context info.
|
|
58
61
|
`.trim();
|
|
59
62
|
const RESPOND_TEXT = `
|
|
60
63
|
When you are done, call the \`${constants_js_1.GAMBIT_TOOL_RESPOND}\` tool with a JSON object that includes your \`payload\` (validated output) and optional \`status\`/ \`message\`/ \`code\`/ \`meta\`. Do not end with normal assistant text; always finish by calling \`${constants_js_1.GAMBIT_TOOL_RESPOND}\`.
|
|
@@ -68,10 +71,41 @@ function warnLegacyMarker(marker, replacement) {
|
|
|
68
71
|
LEGACY_MARKER_WARNINGS[marker] = true;
|
|
69
72
|
logger.warn(`[gambit] "gambit://${marker}" is deprecated; use ${replacement} instead.`);
|
|
70
73
|
}
|
|
74
|
+
function warnLegacySchema(resolvedPath, legacy, replacement) {
|
|
75
|
+
const key = `${resolvedPath}:${legacy}`;
|
|
76
|
+
if (LEGACY_SCHEMA_WARNINGS.has(key))
|
|
77
|
+
return;
|
|
78
|
+
LEGACY_SCHEMA_WARNINGS.add(key);
|
|
79
|
+
logger.warn(`[gambit] deck at ${resolvedPath} uses deprecated "${legacy}"; rename to "${replacement}"`);
|
|
80
|
+
}
|
|
81
|
+
function warnLegacyFragment(resolvedPath, legacy, replacement) {
|
|
82
|
+
const key = `${resolvedPath}:${legacy}`;
|
|
83
|
+
if (LEGACY_FRAGMENT_WARNINGS.has(key))
|
|
84
|
+
return;
|
|
85
|
+
LEGACY_FRAGMENT_WARNINGS.add(key);
|
|
86
|
+
logger.warn(`[gambit] card at ${resolvedPath} uses deprecated "${legacy}"; rename to "${replacement}"`);
|
|
87
|
+
}
|
|
71
88
|
function toFileUrl(p) {
|
|
72
89
|
const abs = path.resolve(p);
|
|
73
90
|
return path.toFileUrl(abs).href;
|
|
74
91
|
}
|
|
92
|
+
function startsWithFrontMatterDelimiter(raw) {
|
|
93
|
+
const normalized = raw.startsWith("\uFEFF") ? raw.slice(1) : raw;
|
|
94
|
+
const trimmed = normalized.trimStart();
|
|
95
|
+
return /^(\+\+\+|---)\s*(\r?\n|$)/.test(trimmed);
|
|
96
|
+
}
|
|
97
|
+
function parseFrontMatterOrRaw(raw, resolvedPath) {
|
|
98
|
+
try {
|
|
99
|
+
return (0, any_js_1.extract)(raw);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (!startsWithFrontMatterDelimiter(raw)) {
|
|
103
|
+
return { attrs: {}, body: raw };
|
|
104
|
+
}
|
|
105
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
106
|
+
throw new Error(`Failed to parse front matter in ${resolvedPath}: ${message}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
75
109
|
async function maybeLoadSchema(schemaPath, basePath) {
|
|
76
110
|
if (!schemaPath || typeof schemaPath !== "string")
|
|
77
111
|
return undefined;
|
|
@@ -81,7 +115,7 @@ async function maybeLoadSchema(schemaPath, basePath) {
|
|
|
81
115
|
const mod = await Promise.resolve(`${toFileUrl(resolved)}`).then(s => __importStar(require(s)));
|
|
82
116
|
return mod.default;
|
|
83
117
|
}
|
|
84
|
-
function normalizeDeckRefs(refs, basePath) {
|
|
118
|
+
function normalizeDeckRefs(refs, basePath, opts) {
|
|
85
119
|
if (!Array.isArray(refs))
|
|
86
120
|
return [];
|
|
87
121
|
return refs
|
|
@@ -92,14 +126,32 @@ function normalizeDeckRefs(refs, basePath) {
|
|
|
92
126
|
if (!p) {
|
|
93
127
|
throw new Error("Deck reference must include a path");
|
|
94
128
|
}
|
|
129
|
+
if (opts?.requirePrompt && !p.endsWith("PROMPT.md")) {
|
|
130
|
+
throw new Error(`Deck reference must point to PROMPT.md (${basePath})`);
|
|
131
|
+
}
|
|
95
132
|
const normalized = { ...rec };
|
|
96
|
-
normalized.path =
|
|
133
|
+
normalized.path = p.startsWith("gambit://")
|
|
134
|
+
? p
|
|
135
|
+
: path.resolve(path.dirname(basePath), p);
|
|
97
136
|
if (typeof rec.description !== "string")
|
|
98
137
|
delete normalized.description;
|
|
99
138
|
if (typeof rec.label !== "string")
|
|
100
139
|
delete normalized.label;
|
|
101
140
|
if (typeof rec.id !== "string")
|
|
102
141
|
delete normalized.id;
|
|
142
|
+
if (rec.permissions !== undefined) {
|
|
143
|
+
const parsed = (0, permissions_js_1.normalizePermissionDeclaration)(rec.permissions, path.dirname(basePath));
|
|
144
|
+
if (parsed)
|
|
145
|
+
normalized.permissions = parsed;
|
|
146
|
+
}
|
|
147
|
+
if (opts?.requireDescription) {
|
|
148
|
+
const desc = typeof rec.description === "string"
|
|
149
|
+
? rec.description.trim()
|
|
150
|
+
: "";
|
|
151
|
+
if (!desc) {
|
|
152
|
+
throw new Error(`Action deck must include a description (${basePath})`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
103
155
|
return normalized;
|
|
104
156
|
});
|
|
105
157
|
}
|
|
@@ -116,14 +168,92 @@ function mergeDeckRefs(...lists) {
|
|
|
116
168
|
}
|
|
117
169
|
return Array.from(merged.values());
|
|
118
170
|
}
|
|
119
|
-
function normalizeActionDecks(entries, basePath) {
|
|
120
|
-
|
|
121
|
-
|
|
171
|
+
async function normalizeActionDecks(entries, basePath, opts) {
|
|
172
|
+
if (!Array.isArray(entries))
|
|
173
|
+
return [];
|
|
174
|
+
const out = [];
|
|
175
|
+
for (const rawEntry of entries) {
|
|
176
|
+
if (!rawEntry || typeof rawEntry !== "object")
|
|
177
|
+
continue;
|
|
178
|
+
const rec = rawEntry;
|
|
179
|
+
const name = String(rec.name ?? "").trim();
|
|
122
180
|
if (!name) {
|
|
123
181
|
throw new Error(`Action deck must include a name (${basePath})`);
|
|
124
182
|
}
|
|
125
|
-
|
|
126
|
-
|
|
183
|
+
const desc = typeof rec.description === "string"
|
|
184
|
+
? rec.description.trim()
|
|
185
|
+
: "";
|
|
186
|
+
if (opts?.requireDescription && !desc) {
|
|
187
|
+
throw new Error(`Action deck must include a description (${basePath})`);
|
|
188
|
+
}
|
|
189
|
+
const rawPath = typeof rec.path === "string" ? rec.path.trim() : "";
|
|
190
|
+
const rawExecute = typeof rec.execute === "string"
|
|
191
|
+
? rec.execute.trim()
|
|
192
|
+
: "";
|
|
193
|
+
const hasPath = rawPath.length > 0;
|
|
194
|
+
const hasExecute = rawExecute.length > 0;
|
|
195
|
+
if (hasPath === hasExecute) {
|
|
196
|
+
throw new Error(`Action deck must include exactly one of path or execute (${basePath})`);
|
|
197
|
+
}
|
|
198
|
+
if (hasPath && opts?.requirePrompt && !rawPath.endsWith("PROMPT.md")) {
|
|
199
|
+
throw new Error(`Deck reference must point to PROMPT.md (${basePath})`);
|
|
200
|
+
}
|
|
201
|
+
const actionContextSchema = await maybeLoadSchema(rec.contextSchema, basePath);
|
|
202
|
+
const actionResponseSchema = await maybeLoadSchema(rec.responseSchema, basePath);
|
|
203
|
+
if (hasExecute && (!actionContextSchema || !actionResponseSchema)) {
|
|
204
|
+
throw new Error(`Action execute target must include contextSchema and responseSchema (${basePath})`);
|
|
205
|
+
}
|
|
206
|
+
const selectedTarget = hasPath ? rawPath : rawExecute;
|
|
207
|
+
const normalizedPath = selectedTarget.startsWith("gambit://")
|
|
208
|
+
? selectedTarget
|
|
209
|
+
: path.resolve(path.dirname(basePath), selectedTarget);
|
|
210
|
+
const normalized = {
|
|
211
|
+
name,
|
|
212
|
+
path: normalizedPath,
|
|
213
|
+
description: desc || undefined,
|
|
214
|
+
label: typeof rec.label === "string" ? rec.label : undefined,
|
|
215
|
+
id: typeof rec.id === "string" ? rec.id : undefined,
|
|
216
|
+
execute: hasExecute ? normalizedPath : undefined,
|
|
217
|
+
contextSchema: actionContextSchema,
|
|
218
|
+
responseSchema: actionResponseSchema,
|
|
219
|
+
};
|
|
220
|
+
if (rec.permissions !== undefined) {
|
|
221
|
+
const parsed = (0, permissions_js_1.normalizePermissionDeclaration)(rec.permissions, path.dirname(basePath));
|
|
222
|
+
if (parsed)
|
|
223
|
+
normalized.permissions = parsed;
|
|
224
|
+
}
|
|
225
|
+
out.push(normalized);
|
|
226
|
+
}
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
async function normalizeExternalTools(refs, basePath) {
|
|
230
|
+
if (!Array.isArray(refs))
|
|
231
|
+
return [];
|
|
232
|
+
const out = [];
|
|
233
|
+
for (const entry of refs) {
|
|
234
|
+
if (!entry || typeof entry !== "object")
|
|
235
|
+
continue;
|
|
236
|
+
const rec = entry;
|
|
237
|
+
const name = String(rec.name ?? "").trim();
|
|
238
|
+
if (!name) {
|
|
239
|
+
throw new Error(`External tool must include a name (${basePath})`);
|
|
240
|
+
}
|
|
241
|
+
if (name.startsWith(constants_js_1.RESERVED_TOOL_PREFIX)) {
|
|
242
|
+
throw new Error(`External tool name ${name} is reserved (prefix ${constants_js_1.RESERVED_TOOL_PREFIX})`);
|
|
243
|
+
}
|
|
244
|
+
if (!constants_js_1.TOOL_NAME_PATTERN.test(name) || name.length > constants_js_1.MAX_TOOL_NAME_LENGTH) {
|
|
245
|
+
throw new Error(`External tool name ${name} must match ${constants_js_1.TOOL_NAME_PATTERN} and be <= ${constants_js_1.MAX_TOOL_NAME_LENGTH} characters`);
|
|
246
|
+
}
|
|
247
|
+
const inputSchema = await maybeLoadSchema(rec.inputSchema, basePath);
|
|
248
|
+
out.push({
|
|
249
|
+
name,
|
|
250
|
+
description: typeof rec.description === "string"
|
|
251
|
+
? rec.description
|
|
252
|
+
: undefined,
|
|
253
|
+
inputSchema,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return out;
|
|
127
257
|
}
|
|
128
258
|
async function expandEmbedsInBody(args) {
|
|
129
259
|
const { body, resolvedPath, stack } = args;
|
|
@@ -139,17 +269,17 @@ async function expandEmbedsInBody(args) {
|
|
|
139
269
|
const target = match[1];
|
|
140
270
|
out += body.slice(lastIndex, matchIndex);
|
|
141
271
|
if (target === RESPOND_MARKER) {
|
|
142
|
-
warnLegacyMarker("respond", "gambit://
|
|
272
|
+
warnLegacyMarker("respond", "gambit://snippets/respond.md");
|
|
143
273
|
respond = true;
|
|
144
274
|
out += RESPOND_TEXT;
|
|
145
275
|
}
|
|
146
276
|
else if (target === INIT_MARKER) {
|
|
147
|
-
warnLegacyMarker("init", "gambit://
|
|
277
|
+
warnLegacyMarker("init", "gambit://snippets/context.md");
|
|
148
278
|
initHint = true;
|
|
149
279
|
out += INIT_TEXT;
|
|
150
280
|
}
|
|
151
281
|
else if (target === END_MARKER) {
|
|
152
|
-
warnLegacyMarker("end", "gambit://
|
|
282
|
+
warnLegacyMarker("end", "gambit://snippets/end.md");
|
|
153
283
|
endHint = true;
|
|
154
284
|
out += END_TEXT;
|
|
155
285
|
}
|
|
@@ -173,17 +303,7 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
173
303
|
}
|
|
174
304
|
const nextStack = [...stack, resolved];
|
|
175
305
|
const raw = await dntShim.Deno.readTextFile(resolved);
|
|
176
|
-
|
|
177
|
-
let body;
|
|
178
|
-
try {
|
|
179
|
-
const parsed = (0, any_js_1.extract)(raw);
|
|
180
|
-
attrs = parsed.attrs;
|
|
181
|
-
body = parsed.body;
|
|
182
|
-
}
|
|
183
|
-
catch (err) {
|
|
184
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
185
|
-
throw new Error(`Failed to parse front matter in ${resolved}: ${message}`);
|
|
186
|
-
}
|
|
306
|
+
const { attrs, body } = parseFrontMatterOrRaw(raw, resolved);
|
|
187
307
|
const candidate = attrs;
|
|
188
308
|
if ((0, definitions_js_1.isCardDefinition)(candidate)) {
|
|
189
309
|
// treat attrs as ts-shaped card
|
|
@@ -193,7 +313,7 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
193
313
|
}
|
|
194
314
|
const hasNewActionField = attrs.actionDecks;
|
|
195
315
|
const legacyActions = attrs.actions;
|
|
196
|
-
const actionDecks = normalizeActionDecks(hasNewActionField ?? legacyActions, resolved);
|
|
316
|
+
const actionDecks = await normalizeActionDecks(hasNewActionField ?? legacyActions, resolved);
|
|
197
317
|
if (!hasNewActionField && legacyActions) {
|
|
198
318
|
logger.warn(`[gambit] card at ${resolved} uses deprecated "actions"; rename to "actionDecks"`);
|
|
199
319
|
}
|
|
@@ -206,8 +326,18 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
206
326
|
throw new Error(`Action name ${a.name} must match ${constants_js_1.TOOL_NAME_PATTERN} and be <= ${constants_js_1.MAX_TOOL_NAME_LENGTH} characters`);
|
|
207
327
|
}
|
|
208
328
|
});
|
|
209
|
-
const
|
|
210
|
-
const
|
|
329
|
+
const legacyInputSchema = attrs.inputSchema;
|
|
330
|
+
const legacyOutputSchema = attrs.outputSchema;
|
|
331
|
+
const contextFragment = await maybeLoadSchema(attrs.contextFragment ??
|
|
332
|
+
legacyInputSchema, resolved);
|
|
333
|
+
const responseFragment = await maybeLoadSchema(attrs.responseFragment ??
|
|
334
|
+
legacyOutputSchema, resolved);
|
|
335
|
+
if (legacyInputSchema !== undefined) {
|
|
336
|
+
warnLegacyFragment(resolved, "inputSchema", "contextFragment");
|
|
337
|
+
}
|
|
338
|
+
if (legacyOutputSchema !== undefined) {
|
|
339
|
+
warnLegacyFragment(resolved, "outputSchema", "responseFragment");
|
|
340
|
+
}
|
|
211
341
|
const replaced = await expandEmbedsInBody({
|
|
212
342
|
body,
|
|
213
343
|
resolvedPath: resolved,
|
|
@@ -217,6 +347,7 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
217
347
|
const embeddedCards = replaced.embeds;
|
|
218
348
|
const respondFlag = Boolean(attrs.respond);
|
|
219
349
|
const allowEndFlag = Boolean(attrs.allowEnd);
|
|
350
|
+
const permissions = (0, permissions_js_1.normalizePermissionDeclaration)(attrs.permissions, path.dirname(resolved));
|
|
220
351
|
return {
|
|
221
352
|
kind: "gambit.card",
|
|
222
353
|
path: resolved,
|
|
@@ -227,8 +358,11 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
227
358
|
testDecks: normalizeDeckRefs(attrs.testDecks, resolved),
|
|
228
359
|
graderDecks: normalizeDeckRefs(attrs.graderDecks, resolved),
|
|
229
360
|
cards: embeddedCards,
|
|
230
|
-
|
|
231
|
-
|
|
361
|
+
permissions,
|
|
362
|
+
contextFragment,
|
|
363
|
+
responseFragment,
|
|
364
|
+
inputFragment: contextFragment,
|
|
365
|
+
outputFragment: responseFragment,
|
|
232
366
|
respond: respondFlag || replaced.respond,
|
|
233
367
|
};
|
|
234
368
|
}
|
|
@@ -237,26 +371,35 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
237
371
|
? path.resolve(path.dirname(parentPath), filePath)
|
|
238
372
|
: path.resolve(filePath);
|
|
239
373
|
const raw = await dntShim.Deno.readTextFile(resolved);
|
|
240
|
-
|
|
241
|
-
let body;
|
|
242
|
-
try {
|
|
243
|
-
const parsed = (0, any_js_1.extract)(raw);
|
|
244
|
-
attrs = parsed.attrs;
|
|
245
|
-
body = parsed.body;
|
|
246
|
-
}
|
|
247
|
-
catch (err) {
|
|
248
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
249
|
-
throw new Error(`Failed to parse front matter in ${resolved}: ${message}`);
|
|
250
|
-
}
|
|
374
|
+
const { attrs, body } = parseFrontMatterOrRaw(raw, resolved);
|
|
251
375
|
const deckAttrs = attrs;
|
|
252
376
|
const deckMeta = (deckAttrs.deck ?? deckAttrs);
|
|
377
|
+
if (deckMeta.mcpServers !== undefined) {
|
|
378
|
+
throw new Error(`Deck-level [[mcpServers]] is unsupported in this phase (${resolved})`);
|
|
379
|
+
}
|
|
380
|
+
if (deckMeta.execute !== undefined) {
|
|
381
|
+
throw new Error(`Top-level execute in PROMPT.md is unsupported (${resolved})`);
|
|
382
|
+
}
|
|
253
383
|
const hasNewActionDecks = deckMeta.actionDecks;
|
|
254
|
-
const
|
|
255
|
-
const actionDecks = normalizeActionDecks(
|
|
256
|
-
|
|
257
|
-
|
|
384
|
+
const canonicalActions = deckMeta.actions;
|
|
385
|
+
const actionDecks = await normalizeActionDecks(canonicalActions, resolved, {
|
|
386
|
+
requirePrompt: true,
|
|
387
|
+
requireDescription: true,
|
|
388
|
+
});
|
|
389
|
+
const legacyActionDecks = await normalizeActionDecks(hasNewActionDecks, resolved);
|
|
390
|
+
if (hasNewActionDecks) {
|
|
391
|
+
logger.warn(`[gambit] deck at ${resolved} uses deprecated "actionDecks"; use "[[actions]]" instead.`);
|
|
258
392
|
}
|
|
259
|
-
|
|
393
|
+
if (deckMeta.testDecks) {
|
|
394
|
+
logger.warn(`[gambit] deck at ${resolved} uses deprecated "testDecks"; use "[[scenarios]]" instead.`);
|
|
395
|
+
}
|
|
396
|
+
if (deckMeta.graderDecks) {
|
|
397
|
+
logger.warn(`[gambit] deck at ${resolved} uses deprecated "graderDecks"; use "[[graders]]" instead.`);
|
|
398
|
+
}
|
|
399
|
+
const scenarioDecks = normalizeDeckRefs(deckMeta.scenarios, resolved, { requirePrompt: true });
|
|
400
|
+
const graderDecks = normalizeDeckRefs(deckMeta.graders, resolved, { requirePrompt: true });
|
|
401
|
+
const allActionDecks = [...actionDecks, ...legacyActionDecks];
|
|
402
|
+
allActionDecks.forEach((a) => {
|
|
260
403
|
if (a.name.startsWith(constants_js_1.RESERVED_TOOL_PREFIX) &&
|
|
261
404
|
!constants_js_1.BUILTIN_TOOL_NAME_SET.has(a.name)) {
|
|
262
405
|
throw new Error(`Action name ${a.name} is reserved`);
|
|
@@ -271,8 +414,18 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
271
414
|
stack: [resolved],
|
|
272
415
|
});
|
|
273
416
|
const cards = replaced.embeds;
|
|
274
|
-
const
|
|
275
|
-
const
|
|
417
|
+
const legacyInputSchema = deckMeta.inputSchema;
|
|
418
|
+
const legacyOutputSchema = deckMeta.outputSchema;
|
|
419
|
+
const contextSchema = await maybeLoadSchema(deckMeta.contextSchema ??
|
|
420
|
+
legacyInputSchema, resolved);
|
|
421
|
+
const responseSchema = await maybeLoadSchema(deckMeta.responseSchema ??
|
|
422
|
+
legacyOutputSchema, resolved);
|
|
423
|
+
if (legacyInputSchema !== undefined) {
|
|
424
|
+
warnLegacySchema(resolved, "inputSchema", "contextSchema");
|
|
425
|
+
}
|
|
426
|
+
if (legacyOutputSchema !== undefined) {
|
|
427
|
+
warnLegacySchema(resolved, "outputSchema", "responseSchema");
|
|
428
|
+
}
|
|
276
429
|
const allCards = flattenCards(cards);
|
|
277
430
|
const cleanedBody = replaced.body;
|
|
278
431
|
const allowEnd = Boolean(deckMeta.allowEnd) ||
|
|
@@ -284,15 +437,17 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
284
437
|
mergedActions[action.name] = action;
|
|
285
438
|
}
|
|
286
439
|
}
|
|
287
|
-
for (const action of
|
|
440
|
+
for (const action of allActionDecks) {
|
|
288
441
|
mergedActions[action.name] = action;
|
|
289
442
|
}
|
|
290
|
-
let
|
|
291
|
-
let
|
|
443
|
+
let mergedContextSchema = contextSchema;
|
|
444
|
+
let mergedResponseSchema = responseSchema;
|
|
292
445
|
for (const card of allCards) {
|
|
293
|
-
|
|
294
|
-
|
|
446
|
+
mergedContextSchema = (0, schema_js_1.mergeZodObjects)(mergedContextSchema, card.contextFragment);
|
|
447
|
+
mergedResponseSchema = (0, schema_js_1.mergeZodObjects)(mergedResponseSchema, card.responseFragment);
|
|
295
448
|
}
|
|
449
|
+
const mergedInputSchema = mergedContextSchema;
|
|
450
|
+
const mergedOutputSchema = mergedResponseSchema;
|
|
296
451
|
const normalizeHandler = (cfg, kind) => {
|
|
297
452
|
if (!cfg)
|
|
298
453
|
return undefined;
|
|
@@ -325,10 +480,18 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
325
480
|
}
|
|
326
481
|
: undefined;
|
|
327
482
|
const mergedActionDecks = Object.values(mergedActions);
|
|
483
|
+
const tools = await normalizeExternalTools(deckMeta.tools, resolved);
|
|
484
|
+
const actionNameSet = new Set(mergedActionDecks.map((action) => action.name));
|
|
485
|
+
for (const tool of tools) {
|
|
486
|
+
if (actionNameSet.has(tool.name)) {
|
|
487
|
+
logger.warn(`[gambit] tool ${tool.name} is shadowed by an action in ${resolved}`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
328
490
|
const rootTestDecks = normalizeDeckRefs(deckMeta.testDecks, resolved);
|
|
329
491
|
const rootGraderDecks = normalizeDeckRefs(deckMeta.graderDecks, resolved);
|
|
330
492
|
const embeddedTestDecks = allCards.flatMap((card) => card.testDecks ?? []);
|
|
331
493
|
const embeddedGraderDecks = allCards.flatMap((card) => card.graderDecks ?? []);
|
|
494
|
+
const permissions = (0, permissions_js_1.normalizePermissionDeclaration)(deckMeta.permissions, path.dirname(resolved));
|
|
332
495
|
return {
|
|
333
496
|
kind: "gambit.deck",
|
|
334
497
|
path: resolved,
|
|
@@ -336,19 +499,25 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
336
499
|
allowEnd,
|
|
337
500
|
actionDecks: mergedActionDecks,
|
|
338
501
|
actions: mergedActionDecks,
|
|
339
|
-
|
|
340
|
-
|
|
502
|
+
tools,
|
|
503
|
+
testDecks: mergeDeckRefs(scenarioDecks, rootTestDecks, embeddedTestDecks),
|
|
504
|
+
graderDecks: mergeDeckRefs(graderDecks, rootGraderDecks, embeddedGraderDecks),
|
|
341
505
|
cards: allCards,
|
|
342
506
|
label: deckMeta.label,
|
|
507
|
+
startMode: deckMeta.startMode,
|
|
343
508
|
modelParams: deckMeta.modelParams,
|
|
344
509
|
guardrails: deckMeta.guardrails,
|
|
510
|
+
contextSchema: mergedContextSchema,
|
|
511
|
+
responseSchema: mergedResponseSchema,
|
|
345
512
|
inputSchema: mergedInputSchema,
|
|
346
513
|
outputSchema: mergedOutputSchema,
|
|
514
|
+
executor: undefined,
|
|
347
515
|
handlers,
|
|
348
516
|
respond: Boolean(deckMeta.respond) ||
|
|
349
517
|
replaced.respond ||
|
|
350
518
|
allCards.some((c) => c.respond),
|
|
351
519
|
inlineEmbeds: true,
|
|
520
|
+
permissions,
|
|
352
521
|
};
|
|
353
522
|
}
|
|
354
523
|
function isMarkdownFile(filePath) {
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deno-native permission kinds supported by Gambit's permission contract.
|
|
3
|
+
*/
|
|
4
|
+
export declare const PERMISSION_KINDS: readonly ["read", "write", "run", "net", "env"];
|
|
5
|
+
export type PermissionKind = (typeof PERMISSION_KINDS)[number];
|
|
6
|
+
export type PathPermissionInput = boolean | Array<string>;
|
|
7
|
+
export type RunPermissionInput = boolean | Array<string> | {
|
|
8
|
+
paths?: Array<string>;
|
|
9
|
+
commands?: Array<string>;
|
|
10
|
+
};
|
|
11
|
+
export type PermissionDeclarationInput = Partial<{
|
|
12
|
+
read: PathPermissionInput;
|
|
13
|
+
write: PathPermissionInput;
|
|
14
|
+
run: RunPermissionInput;
|
|
15
|
+
net: PathPermissionInput;
|
|
16
|
+
env: PathPermissionInput;
|
|
17
|
+
}>;
|
|
18
|
+
export type SerializedRunPermission = false | true | {
|
|
19
|
+
paths: Array<string>;
|
|
20
|
+
commands: Array<string>;
|
|
21
|
+
};
|
|
22
|
+
export type SerializedPermissionSet = {
|
|
23
|
+
read: false | true | Array<string>;
|
|
24
|
+
write: false | true | Array<string>;
|
|
25
|
+
run: SerializedRunPermission;
|
|
26
|
+
net: false | true | Array<string>;
|
|
27
|
+
env: false | true | Array<string>;
|
|
28
|
+
};
|
|
29
|
+
export type PermissionDeclaration = SerializedPermissionSet;
|
|
30
|
+
type NormalizedScope = {
|
|
31
|
+
all: boolean;
|
|
32
|
+
values: Set<string>;
|
|
33
|
+
};
|
|
34
|
+
type NormalizedRunScope = {
|
|
35
|
+
all: boolean;
|
|
36
|
+
paths: Set<string>;
|
|
37
|
+
commands: Set<string>;
|
|
38
|
+
};
|
|
39
|
+
export type NormalizedPermissionSet = {
|
|
40
|
+
baseDir: string;
|
|
41
|
+
read: NormalizedScope;
|
|
42
|
+
write: NormalizedScope;
|
|
43
|
+
run: NormalizedRunScope;
|
|
44
|
+
net: NormalizedScope;
|
|
45
|
+
env: NormalizedScope;
|
|
46
|
+
};
|
|
47
|
+
export type PermissionLayerName = "parent" | "workspace" | "declaration" | "reference" | "session" | "host";
|
|
48
|
+
export type PermissionLayerTrace = {
|
|
49
|
+
name: PermissionLayerName;
|
|
50
|
+
baseDir: string;
|
|
51
|
+
requested: SerializedPermissionSet;
|
|
52
|
+
effective: SerializedPermissionSet;
|
|
53
|
+
};
|
|
54
|
+
export type PermissionTrace = {
|
|
55
|
+
baseDir: string;
|
|
56
|
+
effective: SerializedPermissionSet;
|
|
57
|
+
layers: Array<PermissionLayerTrace>;
|
|
58
|
+
};
|
|
59
|
+
export declare function cloneNormalizedPermissions(input: NormalizedPermissionSet): NormalizedPermissionSet;
|
|
60
|
+
/**
|
|
61
|
+
* Returns an allow-all permission set anchored to `baseDir`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function allowAllPermissions(baseDir: string): NormalizedPermissionSet;
|
|
64
|
+
/**
|
|
65
|
+
* Normalizes a permission declaration to a serializable, deterministic shape.
|
|
66
|
+
*
|
|
67
|
+
* Relative path grants are resolved against `baseDir`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function normalizePermissionDeclaration(input: PermissionDeclarationInput | undefined, baseDir: string): PermissionDeclaration | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Normalizes a declaration to the internal set form used during intersection.
|
|
72
|
+
*/
|
|
73
|
+
export declare function normalizePermissionDeclarationToSet(input: PermissionDeclarationInput | undefined, baseDir: string): NormalizedPermissionSet | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Serializes an internal normalized permission set for traces/persistence.
|
|
76
|
+
*/
|
|
77
|
+
export declare function serializePermissions(set: NormalizedPermissionSet): SerializedPermissionSet;
|
|
78
|
+
/**
|
|
79
|
+
* Computes the monotonic intersection between two permission sets.
|
|
80
|
+
*
|
|
81
|
+
* `baseDir` controls how relative checks (`canReadPath`/etc) are evaluated for
|
|
82
|
+
* the returned set.
|
|
83
|
+
*/
|
|
84
|
+
export declare function intersectPermissions(parent: NormalizedPermissionSet, next: NormalizedPermissionSet, baseDir: string): NormalizedPermissionSet;
|
|
85
|
+
/**
|
|
86
|
+
* Resolves effective permissions and emits a layer-by-layer permission trace.
|
|
87
|
+
*
|
|
88
|
+
* Layer precedence:
|
|
89
|
+
* 1. `parent` (or host allow-all for roots)
|
|
90
|
+
* 2. `workspace` (root only)
|
|
91
|
+
* 3. `declaration` (deck/card declaration)
|
|
92
|
+
* 4. `reference` (parent reference override)
|
|
93
|
+
* 5. `session` (root only)
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveEffectivePermissions(args: {
|
|
96
|
+
baseDir: string;
|
|
97
|
+
parent?: NormalizedPermissionSet;
|
|
98
|
+
workspace?: {
|
|
99
|
+
baseDir: string;
|
|
100
|
+
permissions: PermissionDeclarationInput;
|
|
101
|
+
};
|
|
102
|
+
declaration?: {
|
|
103
|
+
baseDir: string;
|
|
104
|
+
permissions: PermissionDeclarationInput;
|
|
105
|
+
};
|
|
106
|
+
reference?: {
|
|
107
|
+
baseDir: string;
|
|
108
|
+
permissions: PermissionDeclarationInput;
|
|
109
|
+
};
|
|
110
|
+
session?: {
|
|
111
|
+
baseDir: string;
|
|
112
|
+
permissions: PermissionDeclarationInput;
|
|
113
|
+
};
|
|
114
|
+
}): {
|
|
115
|
+
effective: NormalizedPermissionSet;
|
|
116
|
+
trace: PermissionTrace;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Returns whether `targetPath` is readable under `set`.
|
|
120
|
+
*
|
|
121
|
+
* Relative paths are resolved against `set.baseDir`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function canReadPath(set: NormalizedPermissionSet, targetPath: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Returns whether `targetPath` is writable under `set`.
|
|
126
|
+
*
|
|
127
|
+
* Relative paths are resolved against `set.baseDir`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function canWritePath(set: NormalizedPermissionSet, targetPath: string): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Returns whether `targetPath` is executable via run-path grants.
|
|
132
|
+
*
|
|
133
|
+
* Relative paths are resolved against `set.baseDir`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function canRunPath(set: NormalizedPermissionSet, targetPath: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Returns whether `commandName` is executable via run-command grants.
|
|
138
|
+
*
|
|
139
|
+
* This check intentionally does not apply basename/path fallback semantics.
|
|
140
|
+
*/
|
|
141
|
+
export declare function canRunCommand(set: NormalizedPermissionSet, commandName: string): boolean;
|
|
142
|
+
export {};
|
|
143
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/src/permissions.ts"],"names":[],"mappings":"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"}
|