@bolt-foundry/gambit-core 0.8.3 → 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 +38 -7
- package/cards/context.card.md +4 -4
- 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 +10 -2
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +4 -0
- 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 +0 -1
- package/esm/src/constants.d.ts.map +1 -1
- package/esm/src/constants.js +0 -4
- package/esm/src/loader.d.ts.map +1 -1
- package/esm/src/loader.js +159 -11
- package/esm/src/markdown.d.ts.map +1 -1
- package/esm/src/markdown.js +267 -41
- 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/runtime.d.ts +43 -3
- package/esm/src/runtime.d.ts.map +1 -1
- package/esm/src/runtime.js +4369 -406
- 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 +1 -0
- package/esm/src/state.d.ts.map +1 -1
- package/esm/src/types.d.ts +259 -3
- package/esm/src/types.d.ts.map +1 -1
- package/package.json +73 -1
- 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 +9 -1
- 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 +10 -2
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +12 -1
- 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 +0 -1
- package/script/src/constants.d.ts.map +1 -1
- package/script/src/constants.js +1 -5
- package/script/src/loader.d.ts.map +1 -1
- package/script/src/loader.js +158 -10
- package/script/src/markdown.d.ts.map +1 -1
- package/script/src/markdown.js +267 -41
- 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/runtime.d.ts +43 -3
- package/script/src/runtime.d.ts.map +1 -1
- package/script/src/runtime.js +4371 -405
- 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 +1 -0
- package/script/src/state.d.ts.map +1 -1
- package/script/src/types.d.ts +259 -3
- package/script/src/types.d.ts.map +1 -1
- 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/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/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
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
+
import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
3
|
+
/**
|
|
4
|
+
* Deno-native permission kinds supported by Gambit's permission contract.
|
|
5
|
+
*/
|
|
6
|
+
export const PERMISSION_KINDS = ["read", "write", "run", "net", "env"];
|
|
7
|
+
const DENY_SCOPE = { all: false, values: new Set() };
|
|
8
|
+
const DENY_RUN_SCOPE = {
|
|
9
|
+
all: false,
|
|
10
|
+
paths: new Set(),
|
|
11
|
+
commands: new Set(),
|
|
12
|
+
};
|
|
13
|
+
function cloneScope(scope) {
|
|
14
|
+
return {
|
|
15
|
+
all: scope.all,
|
|
16
|
+
values: new Set(scope.values),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function cloneRunScope(scope) {
|
|
20
|
+
return {
|
|
21
|
+
all: scope.all,
|
|
22
|
+
paths: new Set(scope.paths),
|
|
23
|
+
commands: new Set(scope.commands),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function cloneNormalizedPermissions(input) {
|
|
27
|
+
return {
|
|
28
|
+
baseDir: input.baseDir,
|
|
29
|
+
read: cloneScope(input.read),
|
|
30
|
+
write: cloneScope(input.write),
|
|
31
|
+
run: cloneRunScope(input.run),
|
|
32
|
+
net: cloneScope(input.net),
|
|
33
|
+
env: cloneScope(input.env),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function normalizeList(input, kind, baseDir, opts) {
|
|
37
|
+
if (input === true)
|
|
38
|
+
return { all: true, values: new Set() };
|
|
39
|
+
if (input === false || input === undefined || input === null) {
|
|
40
|
+
return cloneScope(DENY_SCOPE);
|
|
41
|
+
}
|
|
42
|
+
if (!Array.isArray(input)) {
|
|
43
|
+
throw new Error(`permissions.${kind} must be boolean or array`);
|
|
44
|
+
}
|
|
45
|
+
const values = new Set();
|
|
46
|
+
for (const entry of input) {
|
|
47
|
+
if (typeof entry !== "string") {
|
|
48
|
+
throw new Error(`permissions.${kind} entries must be strings`);
|
|
49
|
+
}
|
|
50
|
+
const trimmed = entry.trim();
|
|
51
|
+
if (!trimmed)
|
|
52
|
+
continue;
|
|
53
|
+
const normalized = opts?.resolvePaths
|
|
54
|
+
? path.resolve(baseDir, trimmed)
|
|
55
|
+
: trimmed;
|
|
56
|
+
values.add(normalized);
|
|
57
|
+
}
|
|
58
|
+
return { all: false, values };
|
|
59
|
+
}
|
|
60
|
+
function normalizeRun(input, baseDir) {
|
|
61
|
+
if (input === true) {
|
|
62
|
+
return {
|
|
63
|
+
all: true,
|
|
64
|
+
paths: new Set(),
|
|
65
|
+
commands: new Set(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (input === false || input === undefined || input === null) {
|
|
69
|
+
return cloneRunScope(DENY_RUN_SCOPE);
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(input)) {
|
|
72
|
+
const commands = new Set();
|
|
73
|
+
for (const entry of input) {
|
|
74
|
+
if (typeof entry !== "string") {
|
|
75
|
+
throw new Error("permissions.run entries must be strings");
|
|
76
|
+
}
|
|
77
|
+
const trimmed = entry.trim();
|
|
78
|
+
if (!trimmed)
|
|
79
|
+
continue;
|
|
80
|
+
commands.add(trimmed);
|
|
81
|
+
}
|
|
82
|
+
return { all: false, paths: new Set(), commands };
|
|
83
|
+
}
|
|
84
|
+
if (typeof input !== "object") {
|
|
85
|
+
throw new Error("permissions.run must be boolean, array, or object");
|
|
86
|
+
}
|
|
87
|
+
const record = input;
|
|
88
|
+
if (typeof record.paths === "boolean") {
|
|
89
|
+
throw new Error("permissions.run.paths must be an array in object form; use permissions.run=true for full run access");
|
|
90
|
+
}
|
|
91
|
+
if (typeof record.commands === "boolean") {
|
|
92
|
+
throw new Error("permissions.run.commands must be an array in object form; use permissions.run=true for full run access");
|
|
93
|
+
}
|
|
94
|
+
const pathsScope = normalizeList(record.paths, "run", baseDir, {
|
|
95
|
+
resolvePaths: true,
|
|
96
|
+
});
|
|
97
|
+
const commandsScope = normalizeList(record.commands, "run", baseDir, {
|
|
98
|
+
resolvePaths: false,
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
all: false,
|
|
102
|
+
paths: pathsScope.values,
|
|
103
|
+
commands: commandsScope.values,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function intersectScope(a, b) {
|
|
107
|
+
if (a.all)
|
|
108
|
+
return cloneScope(b);
|
|
109
|
+
if (b.all)
|
|
110
|
+
return cloneScope(a);
|
|
111
|
+
const values = new Set();
|
|
112
|
+
for (const value of a.values) {
|
|
113
|
+
if (b.values.has(value))
|
|
114
|
+
values.add(value);
|
|
115
|
+
}
|
|
116
|
+
return { all: false, values };
|
|
117
|
+
}
|
|
118
|
+
function intersectRun(a, b) {
|
|
119
|
+
if (a.all)
|
|
120
|
+
return cloneRunScope(b);
|
|
121
|
+
if (b.all)
|
|
122
|
+
return cloneRunScope(a);
|
|
123
|
+
const paths = new Set();
|
|
124
|
+
for (const value of a.paths) {
|
|
125
|
+
if (b.paths.has(value))
|
|
126
|
+
paths.add(value);
|
|
127
|
+
}
|
|
128
|
+
const commands = new Set();
|
|
129
|
+
for (const value of a.commands) {
|
|
130
|
+
if (b.commands.has(value))
|
|
131
|
+
commands.add(value);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
all: false,
|
|
135
|
+
paths,
|
|
136
|
+
commands,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns an allow-all permission set anchored to `baseDir`.
|
|
141
|
+
*/
|
|
142
|
+
export function allowAllPermissions(baseDir) {
|
|
143
|
+
return {
|
|
144
|
+
baseDir,
|
|
145
|
+
read: { all: true, values: new Set() },
|
|
146
|
+
write: { all: true, values: new Set() },
|
|
147
|
+
run: { all: true, paths: new Set(), commands: new Set() },
|
|
148
|
+
net: { all: true, values: new Set() },
|
|
149
|
+
env: { all: true, values: new Set() },
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function normalizePermissionSet(input, baseDir) {
|
|
153
|
+
return {
|
|
154
|
+
baseDir,
|
|
155
|
+
read: normalizeList(input.read, "read", baseDir, { resolvePaths: true }),
|
|
156
|
+
write: normalizeList(input.write, "write", baseDir, {
|
|
157
|
+
resolvePaths: true,
|
|
158
|
+
}),
|
|
159
|
+
run: normalizeRun(input.run, baseDir),
|
|
160
|
+
net: normalizeList(input.net, "net", baseDir),
|
|
161
|
+
env: normalizeList(input.env, "env", baseDir),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Normalizes a permission declaration to a serializable, deterministic shape.
|
|
166
|
+
*
|
|
167
|
+
* Relative path grants are resolved against `baseDir`.
|
|
168
|
+
*/
|
|
169
|
+
export function normalizePermissionDeclaration(input, baseDir) {
|
|
170
|
+
if (!input)
|
|
171
|
+
return undefined;
|
|
172
|
+
return serializePermissions(normalizePermissionSet(input, baseDir));
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Normalizes a declaration to the internal set form used during intersection.
|
|
176
|
+
*/
|
|
177
|
+
export function normalizePermissionDeclarationToSet(input, baseDir) {
|
|
178
|
+
if (!input)
|
|
179
|
+
return undefined;
|
|
180
|
+
return normalizePermissionSet(input, baseDir);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Serializes an internal normalized permission set for traces/persistence.
|
|
184
|
+
*/
|
|
185
|
+
export function serializePermissions(set) {
|
|
186
|
+
const serializeScope = (scope) => {
|
|
187
|
+
if (scope.all)
|
|
188
|
+
return true;
|
|
189
|
+
if (scope.values.size === 0)
|
|
190
|
+
return false;
|
|
191
|
+
return Array.from(scope.values).sort();
|
|
192
|
+
};
|
|
193
|
+
const serializeRunScope = (scope) => {
|
|
194
|
+
if (scope.all)
|
|
195
|
+
return true;
|
|
196
|
+
if (scope.paths.size === 0 && scope.commands.size === 0) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
paths: Array.from(scope.paths).sort(),
|
|
201
|
+
commands: Array.from(scope.commands).sort(),
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
read: serializeScope(set.read),
|
|
206
|
+
write: serializeScope(set.write),
|
|
207
|
+
run: serializeRunScope(set.run),
|
|
208
|
+
net: serializeScope(set.net),
|
|
209
|
+
env: serializeScope(set.env),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Computes the monotonic intersection between two permission sets.
|
|
214
|
+
*
|
|
215
|
+
* `baseDir` controls how relative checks (`canReadPath`/etc) are evaluated for
|
|
216
|
+
* the returned set.
|
|
217
|
+
*/
|
|
218
|
+
export function intersectPermissions(parent, next, baseDir) {
|
|
219
|
+
return {
|
|
220
|
+
baseDir,
|
|
221
|
+
read: intersectScope(parent.read, next.read),
|
|
222
|
+
write: intersectScope(parent.write, next.write),
|
|
223
|
+
run: intersectRun(parent.run, next.run),
|
|
224
|
+
net: intersectScope(parent.net, next.net),
|
|
225
|
+
env: intersectScope(parent.env, next.env),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Resolves effective permissions and emits a layer-by-layer permission trace.
|
|
230
|
+
*
|
|
231
|
+
* Layer precedence:
|
|
232
|
+
* 1. `parent` (or host allow-all for roots)
|
|
233
|
+
* 2. `workspace` (root only)
|
|
234
|
+
* 3. `declaration` (deck/card declaration)
|
|
235
|
+
* 4. `reference` (parent reference override)
|
|
236
|
+
* 5. `session` (root only)
|
|
237
|
+
*/
|
|
238
|
+
export function resolveEffectivePermissions(args) {
|
|
239
|
+
const layers = [];
|
|
240
|
+
let effective = args.parent
|
|
241
|
+
? {
|
|
242
|
+
...cloneNormalizedPermissions(args.parent),
|
|
243
|
+
// Rebase relative-path checks to the current invocation scope.
|
|
244
|
+
baseDir: args.baseDir,
|
|
245
|
+
}
|
|
246
|
+
: allowAllPermissions(args.baseDir);
|
|
247
|
+
if (args.parent) {
|
|
248
|
+
layers.push({
|
|
249
|
+
name: "parent",
|
|
250
|
+
baseDir: args.parent.baseDir,
|
|
251
|
+
requested: serializePermissions(args.parent),
|
|
252
|
+
effective: serializePermissions(effective),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
layers.push({
|
|
257
|
+
name: "host",
|
|
258
|
+
baseDir: args.baseDir,
|
|
259
|
+
requested: serializePermissions(effective),
|
|
260
|
+
effective: serializePermissions(effective),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
const applyLayer = (name, input) => {
|
|
264
|
+
if (!input)
|
|
265
|
+
return;
|
|
266
|
+
const requested = normalizePermissionSet(input.permissions, input.baseDir);
|
|
267
|
+
effective = intersectPermissions(effective, requested, args.baseDir);
|
|
268
|
+
layers.push({
|
|
269
|
+
name,
|
|
270
|
+
baseDir: input.baseDir,
|
|
271
|
+
requested: serializePermissions(requested),
|
|
272
|
+
effective: serializePermissions(effective),
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
if (!args.parent) {
|
|
276
|
+
applyLayer("workspace", args.workspace);
|
|
277
|
+
}
|
|
278
|
+
applyLayer("declaration", args.declaration);
|
|
279
|
+
applyLayer("reference", args.reference);
|
|
280
|
+
if (!args.parent) {
|
|
281
|
+
applyLayer("session", args.session);
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
effective,
|
|
285
|
+
trace: {
|
|
286
|
+
baseDir: args.baseDir,
|
|
287
|
+
effective: serializePermissions(effective),
|
|
288
|
+
layers,
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Checks whether `target` is covered by `scope`, treating each value as either
|
|
294
|
+
* an exact path grant or the root of an allowed directory tree.
|
|
295
|
+
*/
|
|
296
|
+
function matchScope(scope, target) {
|
|
297
|
+
if (scope.all)
|
|
298
|
+
return true;
|
|
299
|
+
const canonicalTarget = canonicalizePath(target);
|
|
300
|
+
if (!canonicalTarget)
|
|
301
|
+
return false;
|
|
302
|
+
for (const root of scope.values) {
|
|
303
|
+
const canonicalRoot = canonicalizePath(root);
|
|
304
|
+
if (!canonicalRoot)
|
|
305
|
+
continue;
|
|
306
|
+
if (pathWithinRoot(canonicalRoot, canonicalTarget))
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
function pathWithinRoot(root, target) {
|
|
312
|
+
if (root === target)
|
|
313
|
+
return true;
|
|
314
|
+
const rel = path.relative(root, target);
|
|
315
|
+
return rel.length > 0 && !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
316
|
+
}
|
|
317
|
+
function canonicalizePath(target) {
|
|
318
|
+
const resolved = path.resolve(target);
|
|
319
|
+
try {
|
|
320
|
+
return path.resolve(dntShim.Deno.realPathSync(resolved));
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
if (err instanceof dntShim.Deno.errors.NotFound) {
|
|
324
|
+
return canonicalizeMissingPath(resolved);
|
|
325
|
+
}
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function canonicalizeMissingPath(target) {
|
|
330
|
+
const suffix = [];
|
|
331
|
+
let probe = target;
|
|
332
|
+
while (true) {
|
|
333
|
+
try {
|
|
334
|
+
const canonicalBase = path.resolve(dntShim.Deno.realPathSync(probe));
|
|
335
|
+
if (suffix.length === 0)
|
|
336
|
+
return canonicalBase;
|
|
337
|
+
return path.resolve(canonicalBase, ...suffix.reverse());
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
if (err instanceof dntShim.Deno.errors.NotFound) {
|
|
341
|
+
const parent = path.dirname(probe);
|
|
342
|
+
if (parent === probe)
|
|
343
|
+
return undefined;
|
|
344
|
+
suffix.push(path.basename(probe));
|
|
345
|
+
probe = parent;
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Returns whether `targetPath` is readable under `set`.
|
|
354
|
+
*
|
|
355
|
+
* Relative paths are resolved against `set.baseDir`.
|
|
356
|
+
*/
|
|
357
|
+
export function canReadPath(set, targetPath) {
|
|
358
|
+
return matchScope(set.read, path.resolve(set.baseDir, targetPath));
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Returns whether `targetPath` is writable under `set`.
|
|
362
|
+
*
|
|
363
|
+
* Relative paths are resolved against `set.baseDir`.
|
|
364
|
+
*/
|
|
365
|
+
export function canWritePath(set, targetPath) {
|
|
366
|
+
return matchScope(set.write, path.resolve(set.baseDir, targetPath));
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Returns whether `targetPath` is executable via run-path grants.
|
|
370
|
+
*
|
|
371
|
+
* Relative paths are resolved against `set.baseDir`.
|
|
372
|
+
*/
|
|
373
|
+
export function canRunPath(set, targetPath) {
|
|
374
|
+
if (set.run.all)
|
|
375
|
+
return true;
|
|
376
|
+
const resolvedTarget = path.resolve(set.baseDir, targetPath);
|
|
377
|
+
const canonicalTarget = canonicalizePath(resolvedTarget);
|
|
378
|
+
if (!canonicalTarget)
|
|
379
|
+
return false;
|
|
380
|
+
// Run-path grants are exact binary grants; deny symlink-mediated execution.
|
|
381
|
+
if (canonicalTarget !== resolvedTarget)
|
|
382
|
+
return false;
|
|
383
|
+
for (const allowedPath of set.run.paths) {
|
|
384
|
+
const resolvedAllowed = path.resolve(set.baseDir, allowedPath);
|
|
385
|
+
if (resolvedAllowed !== resolvedTarget)
|
|
386
|
+
continue;
|
|
387
|
+
const canonicalAllowed = canonicalizePath(resolvedAllowed);
|
|
388
|
+
if (!canonicalAllowed)
|
|
389
|
+
continue;
|
|
390
|
+
if (canonicalAllowed !== resolvedAllowed)
|
|
391
|
+
continue;
|
|
392
|
+
if (canonicalAllowed === canonicalTarget)
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Returns whether `commandName` is executable via run-command grants.
|
|
399
|
+
*
|
|
400
|
+
* This check intentionally does not apply basename/path fallback semantics.
|
|
401
|
+
*/
|
|
402
|
+
export function canRunCommand(set, commandName) {
|
|
403
|
+
if (set.run.all)
|
|
404
|
+
return true;
|
|
405
|
+
return set.run.commands.has(commandName);
|
|
406
|
+
}
|
package/esm/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Guardrails, ModelProvider } from "./types.js";
|
|
1
|
+
import type { Guardrails, ModelProvider, ResponseItem } from "./types.js";
|
|
2
2
|
import type { SavedState } from "./state.js";
|
|
3
|
+
import type { NormalizedPermissionSet, PermissionDeclarationInput } from "./permissions.js";
|
|
3
4
|
export type GambitEndSignal = {
|
|
4
5
|
__gambitEnd: true;
|
|
5
6
|
payload?: unknown;
|
|
@@ -9,7 +10,19 @@ export type GambitEndSignal = {
|
|
|
9
10
|
meta?: Record<string, unknown>;
|
|
10
11
|
};
|
|
11
12
|
export declare function isGambitEndSignal(value: unknown): value is GambitEndSignal;
|
|
12
|
-
type
|
|
13
|
+
export type IntermediateOutputErrorContext = {
|
|
14
|
+
actionName?: string;
|
|
15
|
+
parentDeckPath?: string;
|
|
16
|
+
};
|
|
17
|
+
export type IntermediateOutputEmission = {
|
|
18
|
+
responseId: string;
|
|
19
|
+
actionCallId: string;
|
|
20
|
+
parentActionCallId?: string;
|
|
21
|
+
deckPath: string;
|
|
22
|
+
outputIndex: number;
|
|
23
|
+
item: ResponseItem;
|
|
24
|
+
};
|
|
25
|
+
export type RunOptions = {
|
|
13
26
|
path: string;
|
|
14
27
|
input: unknown;
|
|
15
28
|
inputProvided?: boolean;
|
|
@@ -30,7 +43,34 @@ type RunOptions = {
|
|
|
30
43
|
onStreamText?: (chunk: string) => void;
|
|
31
44
|
allowRootStringInput?: boolean;
|
|
32
45
|
responsesMode?: boolean;
|
|
46
|
+
workspacePermissions?: PermissionDeclarationInput;
|
|
47
|
+
workspacePermissionsBaseDir?: string;
|
|
48
|
+
sessionPermissions?: PermissionDeclarationInput;
|
|
49
|
+
sessionPermissionsBaseDir?: string;
|
|
50
|
+
parentPermissions?: NormalizedPermissionSet;
|
|
51
|
+
referencePermissions?: PermissionDeclarationInput;
|
|
52
|
+
referencePermissionsBaseDir?: string;
|
|
53
|
+
runDeadlineMs?: number;
|
|
54
|
+
workerSandbox?: boolean;
|
|
55
|
+
inOrchestrationWorker?: boolean;
|
|
56
|
+
signal?: AbortSignal;
|
|
57
|
+
intermediateOutputAllow?: boolean;
|
|
58
|
+
onIntermediateOutputItem?: (emission: IntermediateOutputEmission) => void;
|
|
59
|
+
intermediateOutputErrorContext?: IntermediateOutputErrorContext;
|
|
60
|
+
onCancel?: () => unknown | Promise<unknown>;
|
|
61
|
+
onTool?: (input: {
|
|
62
|
+
name: string;
|
|
63
|
+
args: Record<string, unknown>;
|
|
64
|
+
runId: string;
|
|
65
|
+
actionCallId: string;
|
|
66
|
+
parentActionCallId?: string;
|
|
67
|
+
deckPath: string;
|
|
68
|
+
}) => unknown | Promise<unknown>;
|
|
33
69
|
};
|
|
70
|
+
export declare class RunCanceledError extends Error {
|
|
71
|
+
code: string;
|
|
72
|
+
constructor(message?: string);
|
|
73
|
+
}
|
|
74
|
+
export declare function isRunCanceledError(err: unknown): boolean;
|
|
34
75
|
export declare function runDeck(opts: RunOptions): Promise<unknown>;
|
|
35
|
-
export {};
|
|
36
76
|
//# sourceMappingURL=runtime.d.ts.map
|
package/esm/src/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/src/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/src/runtime.ts"],"names":[],"mappings":"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"}
|