@bolt-foundry/gambit-core 0.8.1 → 0.8.5-rc.10
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 +61 -34
- package/cards/context.card.md +5 -5
- package/cards/generate-test-input.card.md +12 -0
- package/decks/anthropic/agent-sdk/PROMPT.md +9 -0
- package/decks/openai/codex-sdk/PROMPT.md +9 -0
- package/decks/openai/codex-sdk/codex_client.ts +109 -0
- package/decks/openai/codex-sdk/codex_sdk_bridge.deck.ts +36 -0
- package/esm/cards/context.card.md +9 -0
- package/esm/cards/end.card.md +10 -0
- package/esm/cards/generate-test-input.card.md +12 -0
- package/esm/cards/respond.card.md +10 -0
- package/esm/decks/anthropic/agent-sdk/PROMPT.md +9 -0
- package/esm/decks/openai/codex-sdk/PROMPT.md +9 -0
- package/esm/decks/openai/codex-sdk/codex_client.ts +109 -0
- package/esm/decks/openai/codex-sdk/codex_sdk_bridge.deck.ts +36 -0
- package/{script/deps/jsr.io/@std/collections/1.1.4 → esm/deps/jsr.io/@std/collections/1.1.6}/deep_merge.d.ts +2 -2
- package/esm/deps/jsr.io/@std/collections/{1.1.4 → 1.1.6}/deep_merge.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/collections/{1.1.4 → 1.1.6}/deep_merge.js +29 -19
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +1 -1
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/yaml/1.0.11 → esm/deps/jsr.io/@std/yaml/1.0.12}/_loader_state.d.ts +0 -5
- package/esm/deps/jsr.io/@std/yaml/1.0.12/_loader_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_loader_state.js +216 -175
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/yaml/1.0.11 → esm/deps/jsr.io/@std/yaml/1.0.12}/_type/map.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/yaml/1.0.11 → esm/deps/jsr.io/@std/yaml/1.0.12}/_type/seq.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.js +0 -2
- 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.ts +40 -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.zod.ts +1 -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.ts +63 -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/conversation_tools.zod.ts +1 -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.ts +5 -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/tools.zod.ts +1 -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.ts +17 -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.zod.ts +1 -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.ts +63 -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/contexts/turn_tools.zod.ts +1 -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.ts +15 -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/grader_output.zod.ts +1 -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.ts +19 -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/graders/respond.zod.ts +1 -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.ts +6 -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_input_optional.zod.ts +1 -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.ts +5 -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/schemas/scenarios/plain_chat_output.zod.ts +1 -0
- package/esm/snippets/context.md +8 -0
- package/esm/snippets/end.md +10 -0
- package/esm/snippets/generate-test-input.md +12 -0
- package/esm/snippets/init.md +12 -0
- package/esm/snippets/respond.md +10 -0
- package/esm/snippets/scenario-participant.md +10 -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 -1
- package/esm/src/constants.d.ts.map +1 -1
- package/esm/src/constants.js +5 -4
- 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 +220 -13
- package/esm/src/markdown.d.ts.map +1 -1
- package/esm/src/markdown.js +322 -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 +44 -3
- package/esm/src/runtime.d.ts.map +1 -1
- package/esm/src/runtime.js +4629 -407
- 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 +405 -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/script/cards/context.card.md +9 -0
- package/script/cards/end.card.md +10 -0
- package/script/cards/generate-test-input.card.md +12 -0
- package/script/cards/respond.card.md +10 -0
- package/script/decks/anthropic/agent-sdk/PROMPT.md +9 -0
- package/script/decks/openai/codex-sdk/PROMPT.md +9 -0
- package/script/decks/openai/codex-sdk/codex_client.ts +109 -0
- package/script/decks/openai/codex-sdk/codex_sdk_bridge.deck.ts +36 -0
- package/{esm/deps/jsr.io/@std/collections/1.1.4 → script/deps/jsr.io/@std/collections/1.1.6}/deep_merge.d.ts +2 -2
- package/script/deps/jsr.io/@std/collections/{1.1.4 → 1.1.6}/deep_merge.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/collections/{1.1.4 → 1.1.6}/deep_merge.js +29 -19
- package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +1 -1
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/yaml/1.0.11 → script/deps/jsr.io/@std/yaml/1.0.12}/_loader_state.d.ts +0 -5
- package/script/deps/jsr.io/@std/yaml/1.0.12/_loader_state.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_loader_state.js +216 -175
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/yaml/1.0.11 → script/deps/jsr.io/@std/yaml/1.0.12}/_type/map.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/yaml/1.0.11 → script/deps/jsr.io/@std/yaml/1.0.12}/_type/seq.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.js +0 -2
- 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.ts +40 -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.zod.ts +1 -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.ts +63 -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/conversation_tools.zod.ts +1 -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.ts +5 -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/tools.zod.ts +1 -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.ts +17 -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.zod.ts +1 -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.ts +63 -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/contexts/turn_tools.zod.ts +1 -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.ts +15 -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/grader_output.zod.ts +1 -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.ts +19 -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/graders/respond.zod.ts +1 -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.ts +6 -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_input_optional.zod.ts +1 -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.ts +5 -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/schemas/scenarios/plain_chat_output.zod.ts +1 -0
- package/script/snippets/context.md +8 -0
- package/script/snippets/end.md +10 -0
- package/script/snippets/generate-test-input.md +12 -0
- package/script/snippets/init.md +12 -0
- package/script/snippets/respond.md +10 -0
- package/script/snippets/scenario-participant.md +10 -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 -1
- package/script/src/constants.d.ts.map +1 -1
- package/script/src/constants.js +6 -5
- 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 +219 -12
- package/script/src/markdown.d.ts.map +1 -1
- package/script/src/markdown.js +321 -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 +44 -3
- package/script/src/runtime.d.ts.map +1 -1
- package/script/src/runtime.js +4631 -406
- 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 +405 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +103 -0
- package/snippets/context.md +8 -0
- package/snippets/end.md +10 -0
- package/snippets/generate-test-input.md +12 -0
- package/snippets/init.md +12 -0
- package/snippets/respond.md +10 -0
- package/snippets/scenario-participant.md +10 -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/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts.map +0 -1
- 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/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts.map +0 -1
- 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/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.d.ts +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.js +0 -0
- /package/script/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.d.ts +0 -0
package/esm/src/markdown.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
2
|
import { extract } from "../deps/jsr.io/@std/front-matter/1.0.9/any.js";
|
|
3
3
|
import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
4
|
-
import { BUILTIN_TOOL_NAME_SET,
|
|
4
|
+
import { BUILTIN_TOOL_NAME_SET, GAMBIT_TOOL_CONTEXT, GAMBIT_TOOL_END, GAMBIT_TOOL_RESPOND, MAX_TOOL_NAME_LENGTH, RESERVED_TOOL_PREFIX, TOOL_NAME_PATTERN, } from "./constants.js";
|
|
5
5
|
import { isCardDefinition } from "./definitions.js";
|
|
6
6
|
import { loadCard } from "./loader.js";
|
|
7
|
+
import { normalizePermissionDeclaration, } from "./permissions.js";
|
|
7
8
|
import { mergeZodObjects } from "./schema.js";
|
|
8
9
|
import { resolveBuiltinSchemaPath } from "./builtins.js";
|
|
9
10
|
const logger = console;
|
|
@@ -15,8 +16,10 @@ const LEGACY_MARKER_WARNINGS = {
|
|
|
15
16
|
init: false,
|
|
16
17
|
end: false,
|
|
17
18
|
};
|
|
19
|
+
const LEGACY_SCHEMA_WARNINGS = new Set();
|
|
20
|
+
const LEGACY_FRAGMENT_WARNINGS = new Set();
|
|
18
21
|
const INIT_TEXT = `
|
|
19
|
-
You will automatically receive a \`${
|
|
22
|
+
You will automatically receive a \`${GAMBIT_TOOL_CONTEXT}\` tool result at the start that provides run/context info.
|
|
20
23
|
`.trim();
|
|
21
24
|
const RESPOND_TEXT = `
|
|
22
25
|
When you are done, call the \`${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 \`${GAMBIT_TOOL_RESPOND}\`.
|
|
@@ -30,10 +33,41 @@ function warnLegacyMarker(marker, replacement) {
|
|
|
30
33
|
LEGACY_MARKER_WARNINGS[marker] = true;
|
|
31
34
|
logger.warn(`[gambit] "gambit://${marker}" is deprecated; use ${replacement} instead.`);
|
|
32
35
|
}
|
|
36
|
+
function warnLegacySchema(resolvedPath, legacy, replacement) {
|
|
37
|
+
const key = `${resolvedPath}:${legacy}`;
|
|
38
|
+
if (LEGACY_SCHEMA_WARNINGS.has(key))
|
|
39
|
+
return;
|
|
40
|
+
LEGACY_SCHEMA_WARNINGS.add(key);
|
|
41
|
+
logger.warn(`[gambit] deck at ${resolvedPath} uses deprecated "${legacy}"; rename to "${replacement}"`);
|
|
42
|
+
}
|
|
43
|
+
function warnLegacyFragment(resolvedPath, legacy, replacement) {
|
|
44
|
+
const key = `${resolvedPath}:${legacy}`;
|
|
45
|
+
if (LEGACY_FRAGMENT_WARNINGS.has(key))
|
|
46
|
+
return;
|
|
47
|
+
LEGACY_FRAGMENT_WARNINGS.add(key);
|
|
48
|
+
logger.warn(`[gambit] card at ${resolvedPath} uses deprecated "${legacy}"; rename to "${replacement}"`);
|
|
49
|
+
}
|
|
33
50
|
function toFileUrl(p) {
|
|
34
51
|
const abs = path.resolve(p);
|
|
35
52
|
return path.toFileUrl(abs).href;
|
|
36
53
|
}
|
|
54
|
+
function startsWithFrontMatterDelimiter(raw) {
|
|
55
|
+
const normalized = raw.startsWith("\uFEFF") ? raw.slice(1) : raw;
|
|
56
|
+
const trimmed = normalized.trimStart();
|
|
57
|
+
return /^(\+\+\+|---)\s*(\r?\n|$)/.test(trimmed);
|
|
58
|
+
}
|
|
59
|
+
function parseFrontMatterOrRaw(raw, resolvedPath) {
|
|
60
|
+
try {
|
|
61
|
+
return extract(raw);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (!startsWithFrontMatterDelimiter(raw)) {
|
|
65
|
+
return { attrs: {}, body: raw };
|
|
66
|
+
}
|
|
67
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68
|
+
throw new Error(`Failed to parse front matter in ${resolvedPath}: ${message}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
37
71
|
async function maybeLoadSchema(schemaPath, basePath) {
|
|
38
72
|
if (!schemaPath || typeof schemaPath !== "string")
|
|
39
73
|
return undefined;
|
|
@@ -43,7 +77,7 @@ async function maybeLoadSchema(schemaPath, basePath) {
|
|
|
43
77
|
const mod = await import(toFileUrl(resolved));
|
|
44
78
|
return mod.default;
|
|
45
79
|
}
|
|
46
|
-
function normalizeDeckRefs(refs, basePath) {
|
|
80
|
+
function normalizeDeckRefs(refs, basePath, opts) {
|
|
47
81
|
if (!Array.isArray(refs))
|
|
48
82
|
return [];
|
|
49
83
|
return refs
|
|
@@ -55,13 +89,28 @@ function normalizeDeckRefs(refs, basePath) {
|
|
|
55
89
|
throw new Error("Deck reference must include a path");
|
|
56
90
|
}
|
|
57
91
|
const normalized = { ...rec };
|
|
58
|
-
normalized.path =
|
|
92
|
+
normalized.path = p.startsWith("gambit://")
|
|
93
|
+
? p
|
|
94
|
+
: path.resolve(path.dirname(basePath), p);
|
|
59
95
|
if (typeof rec.description !== "string")
|
|
60
96
|
delete normalized.description;
|
|
61
97
|
if (typeof rec.label !== "string")
|
|
62
98
|
delete normalized.label;
|
|
63
99
|
if (typeof rec.id !== "string")
|
|
64
100
|
delete normalized.id;
|
|
101
|
+
if (rec.permissions !== undefined) {
|
|
102
|
+
const parsed = normalizePermissionDeclaration(rec.permissions, path.dirname(basePath));
|
|
103
|
+
if (parsed)
|
|
104
|
+
normalized.permissions = parsed;
|
|
105
|
+
}
|
|
106
|
+
if (opts?.requireDescription) {
|
|
107
|
+
const desc = typeof rec.description === "string"
|
|
108
|
+
? rec.description.trim()
|
|
109
|
+
: "";
|
|
110
|
+
if (!desc) {
|
|
111
|
+
throw new Error(`Action deck must include a description (${basePath})`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
65
114
|
return normalized;
|
|
66
115
|
});
|
|
67
116
|
}
|
|
@@ -78,14 +127,194 @@ function mergeDeckRefs(...lists) {
|
|
|
78
127
|
}
|
|
79
128
|
return Array.from(merged.values());
|
|
80
129
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
130
|
+
function normalizeActionIntermediateOutputPolicy(raw, basePath) {
|
|
131
|
+
const invalid = () => {
|
|
132
|
+
throw new Error(`[gambit] Invalid intermediateOutput policy for action deck (${basePath}). Expected { emit: "allow" | "deny" }.`);
|
|
133
|
+
};
|
|
134
|
+
if (raw === undefined || raw === null) {
|
|
135
|
+
return { emit: "deny" };
|
|
136
|
+
}
|
|
137
|
+
if (typeof raw === "boolean") {
|
|
138
|
+
return { emit: raw ? "allow" : "deny" };
|
|
139
|
+
}
|
|
140
|
+
if (typeof raw === "string") {
|
|
141
|
+
const emit = raw.trim().toLowerCase();
|
|
142
|
+
if (emit === "allow" || emit === "deny")
|
|
143
|
+
return { emit };
|
|
144
|
+
invalid();
|
|
145
|
+
}
|
|
146
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
147
|
+
invalid();
|
|
148
|
+
const emitRaw = raw.emit;
|
|
149
|
+
if (emitRaw === undefined || emitRaw === null) {
|
|
150
|
+
return { emit: "deny" };
|
|
151
|
+
}
|
|
152
|
+
if (typeof emitRaw === "string") {
|
|
153
|
+
const emit = emitRaw.trim().toLowerCase();
|
|
154
|
+
if (emit === "allow" || emit === "deny")
|
|
155
|
+
return { emit };
|
|
156
|
+
}
|
|
157
|
+
invalid();
|
|
158
|
+
return { emit: "deny" };
|
|
159
|
+
}
|
|
160
|
+
function normalizeActionAsyncStartPolicy(raw, basePath) {
|
|
161
|
+
const invalid = () => {
|
|
162
|
+
throw new Error(`[gambit] Invalid asyncStart policy for action deck (${basePath}). Expected { mode: "allow" | "deny" }.`);
|
|
163
|
+
};
|
|
164
|
+
if (raw === undefined || raw === null) {
|
|
165
|
+
return { mode: "deny" };
|
|
166
|
+
}
|
|
167
|
+
if (typeof raw === "boolean") {
|
|
168
|
+
return { mode: raw ? "allow" : "deny" };
|
|
169
|
+
}
|
|
170
|
+
if (typeof raw === "string") {
|
|
171
|
+
const mode = raw.trim().toLowerCase();
|
|
172
|
+
if (mode === "allow" || mode === "deny")
|
|
173
|
+
return { mode };
|
|
174
|
+
invalid();
|
|
175
|
+
}
|
|
176
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
177
|
+
invalid();
|
|
178
|
+
const modeRaw = raw.mode;
|
|
179
|
+
if (modeRaw === undefined || modeRaw === null) {
|
|
180
|
+
return { mode: "deny" };
|
|
181
|
+
}
|
|
182
|
+
if (typeof modeRaw === "string") {
|
|
183
|
+
const mode = modeRaw.trim().toLowerCase();
|
|
184
|
+
if (mode === "allow" || mode === "deny")
|
|
185
|
+
return { mode };
|
|
186
|
+
}
|
|
187
|
+
invalid();
|
|
188
|
+
return { mode: "deny" };
|
|
189
|
+
}
|
|
190
|
+
async function normalizeActionDecks(entries, basePath, opts) {
|
|
191
|
+
if (!Array.isArray(entries))
|
|
192
|
+
return [];
|
|
193
|
+
const out = [];
|
|
194
|
+
for (const rawEntry of entries) {
|
|
195
|
+
if (!rawEntry || typeof rawEntry !== "object")
|
|
196
|
+
continue;
|
|
197
|
+
const rec = rawEntry;
|
|
198
|
+
const name = String(rec.name ?? "").trim();
|
|
84
199
|
if (!name) {
|
|
85
200
|
throw new Error(`Action deck must include a name (${basePath})`);
|
|
86
201
|
}
|
|
87
|
-
|
|
88
|
-
|
|
202
|
+
const desc = typeof rec.description === "string"
|
|
203
|
+
? rec.description.trim()
|
|
204
|
+
: "";
|
|
205
|
+
if (opts?.requireDescription && !desc) {
|
|
206
|
+
throw new Error(`Action deck must include a description (${basePath})`);
|
|
207
|
+
}
|
|
208
|
+
const rawPath = typeof rec.path === "string" ? rec.path.trim() : "";
|
|
209
|
+
const rawExecute = typeof rec.execute === "string"
|
|
210
|
+
? rec.execute.trim()
|
|
211
|
+
: "";
|
|
212
|
+
const hasPath = rawPath.length > 0;
|
|
213
|
+
const hasExecute = rawExecute.length > 0;
|
|
214
|
+
if (hasPath === hasExecute) {
|
|
215
|
+
throw new Error(`Action deck must include exactly one of path or execute (${basePath})`);
|
|
216
|
+
}
|
|
217
|
+
const actionContextSchema = await maybeLoadSchema(rec.contextSchema, basePath);
|
|
218
|
+
const actionResponseSchema = await maybeLoadSchema(rec.responseSchema, basePath);
|
|
219
|
+
if (hasExecute && (!actionContextSchema || !actionResponseSchema)) {
|
|
220
|
+
throw new Error(`Action execute target must include contextSchema and responseSchema (${basePath})`);
|
|
221
|
+
}
|
|
222
|
+
const selectedTarget = hasPath ? rawPath : rawExecute;
|
|
223
|
+
const normalizedPath = selectedTarget.startsWith("gambit://")
|
|
224
|
+
? selectedTarget
|
|
225
|
+
: path.resolve(path.dirname(basePath), selectedTarget);
|
|
226
|
+
const normalized = {
|
|
227
|
+
name,
|
|
228
|
+
path: normalizedPath,
|
|
229
|
+
description: desc || undefined,
|
|
230
|
+
label: typeof rec.label === "string" ? rec.label : undefined,
|
|
231
|
+
id: typeof rec.id === "string" ? rec.id : undefined,
|
|
232
|
+
execute: hasExecute ? normalizedPath : undefined,
|
|
233
|
+
contextSchema: actionContextSchema,
|
|
234
|
+
responseSchema: actionResponseSchema,
|
|
235
|
+
intermediateOutput: normalizeActionIntermediateOutputPolicy(rec.intermediateOutput, basePath),
|
|
236
|
+
asyncStart: normalizeActionAsyncStartPolicy(rec.asyncStart, basePath),
|
|
237
|
+
};
|
|
238
|
+
if (rec.permissions !== undefined) {
|
|
239
|
+
const parsed = normalizePermissionDeclaration(rec.permissions, path.dirname(basePath));
|
|
240
|
+
if (parsed)
|
|
241
|
+
normalized.permissions = parsed;
|
|
242
|
+
}
|
|
243
|
+
out.push(normalized);
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
async function normalizeExternalTools(refs, basePath) {
|
|
248
|
+
if (!Array.isArray(refs))
|
|
249
|
+
return [];
|
|
250
|
+
const out = [];
|
|
251
|
+
for (const entry of refs) {
|
|
252
|
+
if (!entry || typeof entry !== "object")
|
|
253
|
+
continue;
|
|
254
|
+
const rec = entry;
|
|
255
|
+
const name = String(rec.name ?? "").trim();
|
|
256
|
+
if (!name) {
|
|
257
|
+
throw new Error(`External tool must include a name (${basePath})`);
|
|
258
|
+
}
|
|
259
|
+
if (name.startsWith(RESERVED_TOOL_PREFIX)) {
|
|
260
|
+
throw new Error(`External tool name ${name} is reserved (prefix ${RESERVED_TOOL_PREFIX})`);
|
|
261
|
+
}
|
|
262
|
+
if (!TOOL_NAME_PATTERN.test(name) || name.length > MAX_TOOL_NAME_LENGTH) {
|
|
263
|
+
throw new Error(`External tool name ${name} must match ${TOOL_NAME_PATTERN} and be <= ${MAX_TOOL_NAME_LENGTH} characters`);
|
|
264
|
+
}
|
|
265
|
+
const inputSchema = await maybeLoadSchema(rec.inputSchema, basePath);
|
|
266
|
+
out.push({
|
|
267
|
+
name,
|
|
268
|
+
description: typeof rec.description === "string"
|
|
269
|
+
? rec.description
|
|
270
|
+
: undefined,
|
|
271
|
+
inputSchema,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
const CORE_RESPONSE_ITEM_TYPES = new Set([
|
|
277
|
+
"message",
|
|
278
|
+
"function_call",
|
|
279
|
+
"function_call_output",
|
|
280
|
+
"reasoning",
|
|
281
|
+
]);
|
|
282
|
+
async function normalizeResponseItemExtensions(refs, basePath) {
|
|
283
|
+
if (!Array.isArray(refs))
|
|
284
|
+
return [];
|
|
285
|
+
const out = [];
|
|
286
|
+
const seen = new Set();
|
|
287
|
+
for (const entry of refs) {
|
|
288
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
289
|
+
continue;
|
|
290
|
+
const rec = entry;
|
|
291
|
+
const type = String(rec.type ?? "").trim();
|
|
292
|
+
if (!type) {
|
|
293
|
+
throw new Error(`Response item extension must include a type (${basePath})`);
|
|
294
|
+
}
|
|
295
|
+
if (!type.includes(":")) {
|
|
296
|
+
throw new Error(`Response item extension type "${type}" must be namespaced (<namespace>:<type>) (${basePath})`);
|
|
297
|
+
}
|
|
298
|
+
if (CORE_RESPONSE_ITEM_TYPES.has(type)) {
|
|
299
|
+
throw new Error(`Response item extension type "${type}" conflicts with core OpenResponses item types (${basePath})`);
|
|
300
|
+
}
|
|
301
|
+
if (seen.has(type)) {
|
|
302
|
+
throw new Error(`Duplicate response item extension type "${type}" (${basePath})`);
|
|
303
|
+
}
|
|
304
|
+
seen.add(type);
|
|
305
|
+
const dataSchema = await maybeLoadSchema(rec.dataSchema, basePath);
|
|
306
|
+
if (!dataSchema) {
|
|
307
|
+
throw new Error(`Response item extension "${type}" must include dataSchema (${basePath})`);
|
|
308
|
+
}
|
|
309
|
+
out.push({
|
|
310
|
+
type: type,
|
|
311
|
+
dataSchema,
|
|
312
|
+
description: typeof rec.description === "string"
|
|
313
|
+
? rec.description
|
|
314
|
+
: undefined,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return out;
|
|
89
318
|
}
|
|
90
319
|
async function expandEmbedsInBody(args) {
|
|
91
320
|
const { body, resolvedPath, stack } = args;
|
|
@@ -101,17 +330,17 @@ async function expandEmbedsInBody(args) {
|
|
|
101
330
|
const target = match[1];
|
|
102
331
|
out += body.slice(lastIndex, matchIndex);
|
|
103
332
|
if (target === RESPOND_MARKER) {
|
|
104
|
-
warnLegacyMarker("respond", "gambit://
|
|
333
|
+
warnLegacyMarker("respond", "gambit://snippets/respond.md");
|
|
105
334
|
respond = true;
|
|
106
335
|
out += RESPOND_TEXT;
|
|
107
336
|
}
|
|
108
337
|
else if (target === INIT_MARKER) {
|
|
109
|
-
warnLegacyMarker("init", "gambit://
|
|
338
|
+
warnLegacyMarker("init", "gambit://snippets/context.md");
|
|
110
339
|
initHint = true;
|
|
111
340
|
out += INIT_TEXT;
|
|
112
341
|
}
|
|
113
342
|
else if (target === END_MARKER) {
|
|
114
|
-
warnLegacyMarker("end", "gambit://
|
|
343
|
+
warnLegacyMarker("end", "gambit://snippets/end.md");
|
|
115
344
|
endHint = true;
|
|
116
345
|
out += END_TEXT;
|
|
117
346
|
}
|
|
@@ -135,17 +364,7 @@ export async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
135
364
|
}
|
|
136
365
|
const nextStack = [...stack, resolved];
|
|
137
366
|
const raw = await dntShim.Deno.readTextFile(resolved);
|
|
138
|
-
|
|
139
|
-
let body;
|
|
140
|
-
try {
|
|
141
|
-
const parsed = extract(raw);
|
|
142
|
-
attrs = parsed.attrs;
|
|
143
|
-
body = parsed.body;
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
147
|
-
throw new Error(`Failed to parse front matter in ${resolved}: ${message}`);
|
|
148
|
-
}
|
|
367
|
+
const { attrs, body } = parseFrontMatterOrRaw(raw, resolved);
|
|
149
368
|
const candidate = attrs;
|
|
150
369
|
if (isCardDefinition(candidate)) {
|
|
151
370
|
// treat attrs as ts-shaped card
|
|
@@ -155,7 +374,7 @@ export async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
155
374
|
}
|
|
156
375
|
const hasNewActionField = attrs.actionDecks;
|
|
157
376
|
const legacyActions = attrs.actions;
|
|
158
|
-
const actionDecks = normalizeActionDecks(hasNewActionField ?? legacyActions, resolved);
|
|
377
|
+
const actionDecks = await normalizeActionDecks(hasNewActionField ?? legacyActions, resolved);
|
|
159
378
|
if (!hasNewActionField && legacyActions) {
|
|
160
379
|
logger.warn(`[gambit] card at ${resolved} uses deprecated "actions"; rename to "actionDecks"`);
|
|
161
380
|
}
|
|
@@ -168,8 +387,18 @@ export async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
168
387
|
throw new Error(`Action name ${a.name} must match ${TOOL_NAME_PATTERN} and be <= ${MAX_TOOL_NAME_LENGTH} characters`);
|
|
169
388
|
}
|
|
170
389
|
});
|
|
171
|
-
const
|
|
172
|
-
const
|
|
390
|
+
const legacyInputSchema = attrs.inputSchema;
|
|
391
|
+
const legacyOutputSchema = attrs.outputSchema;
|
|
392
|
+
const contextFragment = await maybeLoadSchema(attrs.contextFragment ??
|
|
393
|
+
legacyInputSchema, resolved);
|
|
394
|
+
const responseFragment = await maybeLoadSchema(attrs.responseFragment ??
|
|
395
|
+
legacyOutputSchema, resolved);
|
|
396
|
+
if (legacyInputSchema !== undefined) {
|
|
397
|
+
warnLegacyFragment(resolved, "inputSchema", "contextFragment");
|
|
398
|
+
}
|
|
399
|
+
if (legacyOutputSchema !== undefined) {
|
|
400
|
+
warnLegacyFragment(resolved, "outputSchema", "responseFragment");
|
|
401
|
+
}
|
|
173
402
|
const replaced = await expandEmbedsInBody({
|
|
174
403
|
body,
|
|
175
404
|
resolvedPath: resolved,
|
|
@@ -179,6 +408,7 @@ export async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
179
408
|
const embeddedCards = replaced.embeds;
|
|
180
409
|
const respondFlag = Boolean(attrs.respond);
|
|
181
410
|
const allowEndFlag = Boolean(attrs.allowEnd);
|
|
411
|
+
const permissions = normalizePermissionDeclaration(attrs.permissions, path.dirname(resolved));
|
|
182
412
|
return {
|
|
183
413
|
kind: "gambit.card",
|
|
184
414
|
path: resolved,
|
|
@@ -189,8 +419,11 @@ export async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
189
419
|
testDecks: normalizeDeckRefs(attrs.testDecks, resolved),
|
|
190
420
|
graderDecks: normalizeDeckRefs(attrs.graderDecks, resolved),
|
|
191
421
|
cards: embeddedCards,
|
|
192
|
-
|
|
193
|
-
|
|
422
|
+
permissions,
|
|
423
|
+
contextFragment,
|
|
424
|
+
responseFragment,
|
|
425
|
+
inputFragment: contextFragment,
|
|
426
|
+
outputFragment: responseFragment,
|
|
194
427
|
respond: respondFlag || replaced.respond,
|
|
195
428
|
};
|
|
196
429
|
}
|
|
@@ -199,26 +432,34 @@ export async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
199
432
|
? path.resolve(path.dirname(parentPath), filePath)
|
|
200
433
|
: path.resolve(filePath);
|
|
201
434
|
const raw = await dntShim.Deno.readTextFile(resolved);
|
|
202
|
-
|
|
203
|
-
let body;
|
|
204
|
-
try {
|
|
205
|
-
const parsed = extract(raw);
|
|
206
|
-
attrs = parsed.attrs;
|
|
207
|
-
body = parsed.body;
|
|
208
|
-
}
|
|
209
|
-
catch (err) {
|
|
210
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
211
|
-
throw new Error(`Failed to parse front matter in ${resolved}: ${message}`);
|
|
212
|
-
}
|
|
435
|
+
const { attrs, body } = parseFrontMatterOrRaw(raw, resolved);
|
|
213
436
|
const deckAttrs = attrs;
|
|
214
437
|
const deckMeta = (deckAttrs.deck ?? deckAttrs);
|
|
438
|
+
if (deckMeta.mcpServers !== undefined) {
|
|
439
|
+
throw new Error(`Deck-level [[mcpServers]] is unsupported in this phase (${resolved})`);
|
|
440
|
+
}
|
|
441
|
+
if (deckMeta.execute !== undefined) {
|
|
442
|
+
throw new Error(`Top-level execute in PROMPT.md is unsupported (${resolved})`);
|
|
443
|
+
}
|
|
215
444
|
const hasNewActionDecks = deckMeta.actionDecks;
|
|
216
|
-
const
|
|
217
|
-
const actionDecks = normalizeActionDecks(
|
|
218
|
-
|
|
219
|
-
|
|
445
|
+
const canonicalActions = deckMeta.actions;
|
|
446
|
+
const actionDecks = await normalizeActionDecks(canonicalActions, resolved, {
|
|
447
|
+
requireDescription: true,
|
|
448
|
+
});
|
|
449
|
+
const legacyActionDecks = await normalizeActionDecks(hasNewActionDecks, resolved);
|
|
450
|
+
if (hasNewActionDecks) {
|
|
451
|
+
logger.warn(`[gambit] deck at ${resolved} uses deprecated "actionDecks"; use "[[actions]]" instead.`);
|
|
220
452
|
}
|
|
221
|
-
|
|
453
|
+
if (deckMeta.testDecks) {
|
|
454
|
+
logger.warn(`[gambit] deck at ${resolved} uses deprecated "testDecks"; use "[[scenarios]]" instead.`);
|
|
455
|
+
}
|
|
456
|
+
if (deckMeta.graderDecks) {
|
|
457
|
+
logger.warn(`[gambit] deck at ${resolved} uses deprecated "graderDecks"; use "[[graders]]" instead.`);
|
|
458
|
+
}
|
|
459
|
+
const scenarioDecks = normalizeDeckRefs(deckMeta.scenarios, resolved);
|
|
460
|
+
const graderDecks = normalizeDeckRefs(deckMeta.graders, resolved);
|
|
461
|
+
const allActionDecks = [...actionDecks, ...legacyActionDecks];
|
|
462
|
+
allActionDecks.forEach((a) => {
|
|
222
463
|
if (a.name.startsWith(RESERVED_TOOL_PREFIX) &&
|
|
223
464
|
!BUILTIN_TOOL_NAME_SET.has(a.name)) {
|
|
224
465
|
throw new Error(`Action name ${a.name} is reserved`);
|
|
@@ -233,8 +474,18 @@ export async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
233
474
|
stack: [resolved],
|
|
234
475
|
});
|
|
235
476
|
const cards = replaced.embeds;
|
|
236
|
-
const
|
|
237
|
-
const
|
|
477
|
+
const legacyInputSchema = deckMeta.inputSchema;
|
|
478
|
+
const legacyOutputSchema = deckMeta.outputSchema;
|
|
479
|
+
const contextSchema = await maybeLoadSchema(deckMeta.contextSchema ??
|
|
480
|
+
legacyInputSchema, resolved);
|
|
481
|
+
const responseSchema = await maybeLoadSchema(deckMeta.responseSchema ??
|
|
482
|
+
legacyOutputSchema, resolved);
|
|
483
|
+
if (legacyInputSchema !== undefined) {
|
|
484
|
+
warnLegacySchema(resolved, "inputSchema", "contextSchema");
|
|
485
|
+
}
|
|
486
|
+
if (legacyOutputSchema !== undefined) {
|
|
487
|
+
warnLegacySchema(resolved, "outputSchema", "responseSchema");
|
|
488
|
+
}
|
|
238
489
|
const allCards = flattenCards(cards);
|
|
239
490
|
const cleanedBody = replaced.body;
|
|
240
491
|
const allowEnd = Boolean(deckMeta.allowEnd) ||
|
|
@@ -246,15 +497,17 @@ export async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
246
497
|
mergedActions[action.name] = action;
|
|
247
498
|
}
|
|
248
499
|
}
|
|
249
|
-
for (const action of
|
|
500
|
+
for (const action of allActionDecks) {
|
|
250
501
|
mergedActions[action.name] = action;
|
|
251
502
|
}
|
|
252
|
-
let
|
|
253
|
-
let
|
|
503
|
+
let mergedContextSchema = contextSchema;
|
|
504
|
+
let mergedResponseSchema = responseSchema;
|
|
254
505
|
for (const card of allCards) {
|
|
255
|
-
|
|
256
|
-
|
|
506
|
+
mergedContextSchema = mergeZodObjects(mergedContextSchema, card.contextFragment);
|
|
507
|
+
mergedResponseSchema = mergeZodObjects(mergedResponseSchema, card.responseFragment);
|
|
257
508
|
}
|
|
509
|
+
const mergedInputSchema = mergedContextSchema;
|
|
510
|
+
const mergedOutputSchema = mergedResponseSchema;
|
|
258
511
|
const normalizeHandler = (cfg, kind) => {
|
|
259
512
|
if (!cfg)
|
|
260
513
|
return undefined;
|
|
@@ -287,10 +540,19 @@ export async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
287
540
|
}
|
|
288
541
|
: undefined;
|
|
289
542
|
const mergedActionDecks = Object.values(mergedActions);
|
|
543
|
+
const tools = await normalizeExternalTools(deckMeta.tools, resolved);
|
|
544
|
+
const responseItemExtensions = await normalizeResponseItemExtensions(deckMeta.responseItemExtensions, resolved);
|
|
545
|
+
const actionNameSet = new Set(mergedActionDecks.map((action) => action.name));
|
|
546
|
+
for (const tool of tools) {
|
|
547
|
+
if (actionNameSet.has(tool.name)) {
|
|
548
|
+
logger.warn(`[gambit] tool ${tool.name} is shadowed by an action in ${resolved}`);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
290
551
|
const rootTestDecks = normalizeDeckRefs(deckMeta.testDecks, resolved);
|
|
291
552
|
const rootGraderDecks = normalizeDeckRefs(deckMeta.graderDecks, resolved);
|
|
292
553
|
const embeddedTestDecks = allCards.flatMap((card) => card.testDecks ?? []);
|
|
293
554
|
const embeddedGraderDecks = allCards.flatMap((card) => card.graderDecks ?? []);
|
|
555
|
+
const permissions = normalizePermissionDeclaration(deckMeta.permissions, path.dirname(resolved));
|
|
294
556
|
return {
|
|
295
557
|
kind: "gambit.deck",
|
|
296
558
|
path: resolved,
|
|
@@ -298,19 +560,26 @@ export async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
298
560
|
allowEnd,
|
|
299
561
|
actionDecks: mergedActionDecks,
|
|
300
562
|
actions: mergedActionDecks,
|
|
301
|
-
|
|
302
|
-
|
|
563
|
+
tools,
|
|
564
|
+
responseItemExtensions,
|
|
565
|
+
testDecks: mergeDeckRefs(scenarioDecks, rootTestDecks, embeddedTestDecks),
|
|
566
|
+
graderDecks: mergeDeckRefs(graderDecks, rootGraderDecks, embeddedGraderDecks),
|
|
303
567
|
cards: allCards,
|
|
304
568
|
label: deckMeta.label,
|
|
569
|
+
startMode: deckMeta.startMode,
|
|
305
570
|
modelParams: deckMeta.modelParams,
|
|
306
571
|
guardrails: deckMeta.guardrails,
|
|
572
|
+
contextSchema: mergedContextSchema,
|
|
573
|
+
responseSchema: mergedResponseSchema,
|
|
307
574
|
inputSchema: mergedInputSchema,
|
|
308
575
|
outputSchema: mergedOutputSchema,
|
|
576
|
+
executor: undefined,
|
|
309
577
|
handlers,
|
|
310
578
|
respond: Boolean(deckMeta.respond) ||
|
|
311
579
|
replaced.respond ||
|
|
312
580
|
allCards.some((c) => c.respond),
|
|
313
581
|
inlineEmbeds: true,
|
|
582
|
+
permissions,
|
|
314
583
|
};
|
|
315
584
|
}
|
|
316
585
|
export 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
|