@bolt-foundry/gambit-core 0.5.3-dev
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/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts +6 -0
- package/esm/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.1.3/_utils.js +18 -0
- package/esm/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts +322 -0
- package/esm/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.1.3/deep_merge.js +95 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts +11 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/_formats.js +28 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts +5 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/_shared.js +8 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts +32 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/any.js +48 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts +30 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/json.js +35 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts +30 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/toml.js +36 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts +7 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/types.js +3 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts +33 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +39 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/_os.d.ts +2 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/_os.js +12 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/os.d.ts +3 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/os.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/os.js +5 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.js +7 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts +4 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.js +40 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.js +23 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts +40 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.js +46 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.js +8 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts +4 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.js +19 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.js +9 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts +35 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.js +235 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.js +8 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.js +77 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.js +9 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.js +19 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.js +15 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/basename.d.ts +27 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/basename.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/basename.js +35 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/common.d.ts +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/common.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/common.js +33 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/constants.d.ts +15 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/constants.js +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/dirname.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/dirname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/dirname.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/extname.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/extname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/extname.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/format.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/format.js +27 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts +77 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.js +83 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.js +42 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/join.d.ts +23 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/join.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/join.js +29 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.js +34 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/mod.d.ts +213 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/mod.js +216 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/normalize.d.ts +26 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/normalize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/normalize.js +32 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts +29 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.js +35 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/parse.d.ts +35 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/parse.js +39 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts +2 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.js +8 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts +39 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.js +52 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts +13 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.js +14 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts +30 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.js +64 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts +37 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.js +93 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts +24 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts +16 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.js +21 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts +72 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.js +82 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.js +23 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts +31 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.js +45 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts +20 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.js +40 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts +37 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.js +58 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts +20 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.js +32 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts +25 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.js +115 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts +20 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.js +106 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.js +59 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.js +27 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts +16 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.js +20 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/relative.d.ts +24 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/relative.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/relative.js +30 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/resolve.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/resolve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/resolve.js +30 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts +21 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.js +29 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/types.d.ts +38 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/types.js +3 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts +4 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.js +15 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts +22 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.js +47 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts +13 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.js +14 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.js +113 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.js +82 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts +24 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.js +28 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts +18 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.js +30 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts +71 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.js +82 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.js +38 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts +18 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.js +77 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts +21 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.js +41 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts +19 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.js +135 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts +20 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.js +32 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts +25 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.js +176 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts +23 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.js +131 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.js +154 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.js +34 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts +17 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.js +49 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +753 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/parse.js +25 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts +33 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_chars.js +48 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts +66 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.js +1427 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts +44 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_schema.js +117 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/binary.js +103 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/bool.js +32 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/float.js +96 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/int.js +159 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/map.js +14 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/merge.js +10 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/nil.js +22 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/omap.js +29 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.js +19 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.js +30 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/seq.js +10 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/set.js +14 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/str.js +9 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.js +81 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.js +20 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts +32 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_type.js +6 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts +4 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/_utils.js +13 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts +76 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.10/parse.js +93 -0
- package/esm/mod.d.ts +51 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +20 -0
- package/esm/package.json +3 -0
- package/esm/src/constants.d.ts +15 -0
- package/esm/src/constants.d.ts.map +1 -0
- package/esm/src/constants.js +20 -0
- package/esm/src/definitions.d.ts +11 -0
- package/esm/src/definitions.d.ts.map +1 -0
- package/esm/src/definitions.js +14 -0
- package/esm/src/loader.d.ts +4 -0
- package/esm/src/loader.d.ts.map +1 -0
- package/esm/src/loader.js +179 -0
- package/esm/src/markdown.d.ts +5 -0
- package/esm/src/markdown.d.ts.map +1 -0
- package/esm/src/markdown.js +307 -0
- package/esm/src/openai_compat.d.ts +63 -0
- package/esm/src/openai_compat.d.ts.map +1 -0
- package/esm/src/openai_compat.js +272 -0
- package/esm/src/providers/openrouter.d.ts +8 -0
- package/esm/src/providers/openrouter.d.ts.map +1 -0
- package/esm/src/providers/openrouter.js +168 -0
- package/esm/src/render.d.ts +51 -0
- package/esm/src/render.d.ts.map +1 -0
- package/esm/src/render.js +188 -0
- package/esm/src/runtime.d.ts +35 -0
- package/esm/src/runtime.d.ts.map +1 -0
- package/esm/src/runtime.js +1368 -0
- package/esm/src/schema.d.ts +8 -0
- package/esm/src/schema.d.ts.map +1 -0
- package/esm/src/schema.js +45 -0
- package/esm/src/state.d.ts +34 -0
- package/esm/src/state.d.ts.map +1 -0
- package/esm/src/state.js +22 -0
- package/esm/src/types.d.ts +318 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +1 -0
- package/package.json +32 -0
- package/script/_dnt.polyfills.d.ts +12 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +16 -0
- package/script/_dnt.shims.d.ts +6 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +65 -0
- package/script/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts +6 -0
- package/script/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/collections/1.1.3/_utils.js +21 -0
- package/script/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts +322 -0
- package/script/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/collections/1.1.3/deep_merge.js +98 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts +11 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/_formats.js +31 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts +5 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/_shared.js +11 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts +32 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/any.js +51 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts +30 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/json.js +38 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts +30 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/toml.js +39 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts +7 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/types.js +4 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts +33 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +42 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/_os.d.ts +2 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/_os.js +38 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/os.d.ts +3 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/os.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/os.js +8 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/assert_path.js +10 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts +4 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/basename.js +45 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/common.js +26 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts +40 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/constants.js +49 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/dirname.js +11 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts +4 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/format.js +23 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.js +12 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts +35 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.js +238 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize.js +11 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.js +80 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/relative.js +12 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.js +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.js +18 -0
- package/script/deps/jsr.io/@std/path/1.1.4/basename.d.ts +27 -0
- package/script/deps/jsr.io/@std/path/1.1.4/basename.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/basename.js +38 -0
- package/script/deps/jsr.io/@std/path/1.1.4/common.d.ts +28 -0
- package/script/deps/jsr.io/@std/path/1.1.4/common.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/common.js +36 -0
- package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts +15 -0
- package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/constants.js +20 -0
- package/script/deps/jsr.io/@std/path/1.1.4/dirname.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/dirname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/dirname.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/extname.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/extname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/extname.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/format.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/format.js +30 -0
- package/script/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/from_file_url.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts +77 -0
- package/script/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.js +86 -0
- package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/is_glob.js +45 -0
- package/script/deps/jsr.io/@std/path/1.1.4/join.d.ts +23 -0
- package/script/deps/jsr.io/@std/path/1.1.4/join.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/join.js +32 -0
- package/script/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts +28 -0
- package/script/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/join_globs.js +37 -0
- package/script/deps/jsr.io/@std/path/1.1.4/mod.d.ts +213 -0
- package/script/deps/jsr.io/@std/path/1.1.4/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/mod.js +232 -0
- package/script/deps/jsr.io/@std/path/1.1.4/normalize.d.ts +26 -0
- package/script/deps/jsr.io/@std/path/1.1.4/normalize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/normalize.js +35 -0
- package/script/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts +29 -0
- package/script/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/normalize_glob.js +38 -0
- package/script/deps/jsr.io/@std/path/1.1.4/parse.d.ts +35 -0
- package/script/deps/jsr.io/@std/path/1.1.4/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/parse.js +42 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts +2 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/_util.js +11 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts +39 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/basename.js +55 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts +13 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.js +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts +30 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/dirname.js +67 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts +37 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/extname.js +96 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts +24 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/format.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts +16 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.js +24 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts +72 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.js +85 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.js +26 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/join.js +48 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts +20 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/join_globs.js +43 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts +37 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize.js +61 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts +20 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.js +35 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts +25 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/parse.js +118 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts +20 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/relative.js +109 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.js +85 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.js +30 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts +16 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.js +23 -0
- package/script/deps/jsr.io/@std/path/1.1.4/relative.d.ts +24 -0
- package/script/deps/jsr.io/@std/path/1.1.4/relative.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/relative.js +33 -0
- package/script/deps/jsr.io/@std/path/1.1.4/resolve.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/resolve.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/resolve.js +33 -0
- package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts +21 -0
- package/script/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.js +32 -0
- package/script/deps/jsr.io/@std/path/1.1.4/types.d.ts +38 -0
- package/script/deps/jsr.io/@std/path/1.1.4/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/types.js +4 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts +4 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/_util.js +20 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts +22 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/basename.js +50 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts +13 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.js +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/dirname.js +116 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/extname.js +85 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts +24 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/format.js +31 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts +18 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.js +33 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts +71 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.js +85 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.js +41 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts +18 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/join.js +80 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts +21 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/join_globs.js +44 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts +19 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize.js +138 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts +20 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.js +35 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts +25 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/parse.js +179 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts +23 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/relative.js +134 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.js +180 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.js +37 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts +17 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.js +52 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +781 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/parse.js +28 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts +33 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_chars.js +55 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts +66 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.js +1431 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts +44 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_schema.js +121 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/binary.js +106 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/bool.js +35 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/float.js +99 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/int.js +162 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/map.js +17 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/merge.js +13 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/nil.js +25 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/omap.js +32 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.js +22 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.js +33 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/seq.js +13 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/set.js +17 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/str.js +12 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.js +84 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts +3 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.js +23 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts +32 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_type.js +7 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts +4 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/_utils.js +18 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts +76 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/yaml/1.0.10/parse.js +97 -0
- package/script/mod.d.ts +51 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +30 -0
- package/script/package.json +3 -0
- package/script/src/constants.d.ts +15 -0
- package/script/src/constants.d.ts.map +1 -0
- package/script/src/constants.js +23 -0
- package/script/src/definitions.d.ts +11 -0
- package/script/src/definitions.d.ts.map +1 -0
- package/script/src/definitions.js +20 -0
- package/script/src/loader.d.ts +4 -0
- package/script/src/loader.d.ts.map +1 -0
- package/script/src/loader.js +206 -0
- package/script/src/markdown.d.ts +5 -0
- package/script/src/markdown.d.ts.map +1 -0
- package/script/src/markdown.js +335 -0
- package/script/src/openai_compat.d.ts +63 -0
- package/script/src/openai_compat.d.ts.map +1 -0
- package/script/src/openai_compat.js +276 -0
- package/script/src/providers/openrouter.d.ts +8 -0
- package/script/src/providers/openrouter.d.ts.map +1 -0
- package/script/src/providers/openrouter.js +197 -0
- package/script/src/render.d.ts +51 -0
- package/script/src/render.d.ts.map +1 -0
- package/script/src/render.js +192 -0
- package/script/src/runtime.d.ts +35 -0
- package/script/src/runtime.d.ts.map +1 -0
- package/script/src/runtime.js +1395 -0
- package/script/src/schema.d.ts +8 -0
- package/script/src/schema.d.ts.map +1 -0
- package/script/src/schema.js +51 -0
- package/script/src/state.d.ts +34 -0
- package/script/src/state.d.ts.map +1 -0
- package/script/src/state.js +49 -0
- package/script/src/types.d.ts +318 -0
- package/script/src/types.d.ts.map +1 -0
- package/script/src/types.js +2 -0
|
@@ -0,0 +1,1368 @@
|
|
|
1
|
+
import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
2
|
+
import { DEFAULT_GUARDRAILS, DEFAULT_STATUS_DELAY_MS, GAMBIT_TOOL_COMPLETE, GAMBIT_TOOL_END, GAMBIT_TOOL_INIT, GAMBIT_TOOL_RESPOND, } from "./constants.js";
|
|
3
|
+
import { loadDeck } from "./loader.js";
|
|
4
|
+
import { assertZodSchema, toJsonSchema, validateWithSchema } from "./schema.js";
|
|
5
|
+
export function isGambitEndSignal(value) {
|
|
6
|
+
return Boolean(value &&
|
|
7
|
+
typeof value === "object" &&
|
|
8
|
+
value.__gambitEnd === true);
|
|
9
|
+
}
|
|
10
|
+
const logger = console;
|
|
11
|
+
function randomId(prefix) {
|
|
12
|
+
const suffix = crypto.randomUUID().replace(/-/g, "").slice(0, 24);
|
|
13
|
+
// Keep IDs short enough for OpenAI/OpenRouter tool_call id limits (~40 chars).
|
|
14
|
+
return `${prefix}-${suffix}`;
|
|
15
|
+
}
|
|
16
|
+
export async function runDeck(opts) {
|
|
17
|
+
const guardrails = {
|
|
18
|
+
...DEFAULT_GUARDRAILS,
|
|
19
|
+
...opts.guardrails,
|
|
20
|
+
};
|
|
21
|
+
const depth = opts.depth ?? 0;
|
|
22
|
+
const inferredRoot = opts.isRoot ??
|
|
23
|
+
(!opts.parentActionCallId && depth === 0);
|
|
24
|
+
if (depth >= guardrails.maxDepth) {
|
|
25
|
+
throw new Error(`Max depth ${guardrails.maxDepth} exceeded`);
|
|
26
|
+
}
|
|
27
|
+
const runId = opts.runId ?? opts.state?.runId ?? randomId("run");
|
|
28
|
+
const deck = await loadDeck(opts.path);
|
|
29
|
+
const deckGuardrails = deck.guardrails ?? {};
|
|
30
|
+
const effectiveGuardrails = {
|
|
31
|
+
...guardrails,
|
|
32
|
+
...deckGuardrails,
|
|
33
|
+
};
|
|
34
|
+
const isRoot = Boolean(inferredRoot);
|
|
35
|
+
ensureSchemaPresence(deck, isRoot);
|
|
36
|
+
const resolvedInput = resolveInput({
|
|
37
|
+
deck,
|
|
38
|
+
input: opts.input,
|
|
39
|
+
state: opts.state,
|
|
40
|
+
isRoot,
|
|
41
|
+
initialUserMessage: opts.initialUserMessage,
|
|
42
|
+
});
|
|
43
|
+
const validatedInput = validateInput(deck, resolvedInput, isRoot, opts.allowRootStringInput ?? false);
|
|
44
|
+
const shouldEmitRun = opts.depth === undefined || opts.depth === 0;
|
|
45
|
+
if (shouldEmitRun) {
|
|
46
|
+
opts.trace?.({
|
|
47
|
+
type: "run.start",
|
|
48
|
+
runId,
|
|
49
|
+
deckPath: deck.path,
|
|
50
|
+
input: validatedInput,
|
|
51
|
+
initialUserMessage: opts
|
|
52
|
+
.initialUserMessage,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
if (deck.modelParams?.model || deck.modelParams?.temperature !== undefined) {
|
|
57
|
+
return await runLlmDeck({
|
|
58
|
+
deck,
|
|
59
|
+
guardrails: effectiveGuardrails,
|
|
60
|
+
depth,
|
|
61
|
+
runId,
|
|
62
|
+
parentActionCallId: opts.parentActionCallId,
|
|
63
|
+
modelProvider: opts.modelProvider,
|
|
64
|
+
input: validatedInput,
|
|
65
|
+
inputProvided: opts.inputProvided ?? true,
|
|
66
|
+
initialUserMessage: opts.initialUserMessage,
|
|
67
|
+
defaultModel: opts.defaultModel,
|
|
68
|
+
modelOverride: opts.modelOverride,
|
|
69
|
+
trace: opts.trace,
|
|
70
|
+
stream: opts.stream,
|
|
71
|
+
state: opts.state,
|
|
72
|
+
onStateUpdate: opts.onStateUpdate,
|
|
73
|
+
onStreamText: opts.onStreamText,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (!deck.executor) {
|
|
77
|
+
throw new Error(`Deck ${deck.path} has no model and no executor (add run or execute to the deck definition)`);
|
|
78
|
+
}
|
|
79
|
+
return await runComputeDeck({
|
|
80
|
+
deck,
|
|
81
|
+
guardrails: effectiveGuardrails,
|
|
82
|
+
depth,
|
|
83
|
+
runId,
|
|
84
|
+
parentActionCallId: opts.parentActionCallId,
|
|
85
|
+
modelProvider: opts.modelProvider,
|
|
86
|
+
input: validatedInput,
|
|
87
|
+
defaultModel: opts.defaultModel,
|
|
88
|
+
modelOverride: opts.modelOverride,
|
|
89
|
+
trace: opts.trace,
|
|
90
|
+
stream: opts.stream,
|
|
91
|
+
onStreamText: opts.onStreamText,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
if (shouldEmitRun) {
|
|
96
|
+
opts.trace?.({ type: "run.end", runId });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function toProviderParams(params) {
|
|
101
|
+
if (!params)
|
|
102
|
+
return undefined;
|
|
103
|
+
const { model: _model, temperature, top_p, frequency_penalty, presence_penalty, max_tokens, } = params;
|
|
104
|
+
const out = {};
|
|
105
|
+
if (temperature !== undefined)
|
|
106
|
+
out.temperature = temperature;
|
|
107
|
+
if (top_p !== undefined)
|
|
108
|
+
out.top_p = top_p;
|
|
109
|
+
if (frequency_penalty !== undefined) {
|
|
110
|
+
out.frequency_penalty = frequency_penalty;
|
|
111
|
+
}
|
|
112
|
+
if (presence_penalty !== undefined)
|
|
113
|
+
out.presence_penalty = presence_penalty;
|
|
114
|
+
if (max_tokens !== undefined)
|
|
115
|
+
out.max_tokens = max_tokens;
|
|
116
|
+
return Object.keys(out).length ? out : undefined;
|
|
117
|
+
}
|
|
118
|
+
function ensureSchemaPresence(deck, isRoot) {
|
|
119
|
+
if (!isRoot) {
|
|
120
|
+
if (!deck.inputSchema || !deck.outputSchema) {
|
|
121
|
+
throw new Error(`Deck ${deck.path} must declare inputSchema and outputSchema (non-root)`);
|
|
122
|
+
}
|
|
123
|
+
assertZodSchema(deck.inputSchema, "inputSchema");
|
|
124
|
+
assertZodSchema(deck.outputSchema, "outputSchema");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function resolveInput(args) {
|
|
128
|
+
if (args.input !== undefined)
|
|
129
|
+
return args.input;
|
|
130
|
+
if (!args.isRoot)
|
|
131
|
+
return args.input;
|
|
132
|
+
const persisted = extractInitInput(args.state);
|
|
133
|
+
if (persisted !== undefined)
|
|
134
|
+
return persisted;
|
|
135
|
+
if (args.initialUserMessage !== undefined) {
|
|
136
|
+
const schema = args.deck.inputSchema;
|
|
137
|
+
if (schema?.safeParse) {
|
|
138
|
+
const candidates = [undefined, {}, ""];
|
|
139
|
+
for (const candidate of candidates) {
|
|
140
|
+
try {
|
|
141
|
+
const result = schema.safeParse(candidate);
|
|
142
|
+
if (result?.success)
|
|
143
|
+
return candidate;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// ignore and try next candidate
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return "";
|
|
151
|
+
}
|
|
152
|
+
return args.input;
|
|
153
|
+
}
|
|
154
|
+
function extractInitInput(state) {
|
|
155
|
+
if (!state?.messages)
|
|
156
|
+
return undefined;
|
|
157
|
+
for (let i = state.messages.length - 1; i >= 0; i--) {
|
|
158
|
+
const msg = state.messages[i];
|
|
159
|
+
if (msg.role === "tool" && msg.name === GAMBIT_TOOL_INIT) {
|
|
160
|
+
const content = msg.content;
|
|
161
|
+
if (typeof content !== "string")
|
|
162
|
+
return undefined;
|
|
163
|
+
try {
|
|
164
|
+
return JSON.parse(content);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return content;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
function validateInput(deck, input, isRoot, allowRootStringInput) {
|
|
174
|
+
if (deck.inputSchema) {
|
|
175
|
+
if (isRoot && typeof input === "string" && allowRootStringInput) {
|
|
176
|
+
try {
|
|
177
|
+
return validateWithSchema(deck.inputSchema, input);
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return input;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return validateWithSchema(deck.inputSchema, input);
|
|
184
|
+
}
|
|
185
|
+
if (isRoot) {
|
|
186
|
+
if (input === undefined)
|
|
187
|
+
return "";
|
|
188
|
+
if (typeof input === "string")
|
|
189
|
+
return input;
|
|
190
|
+
return input;
|
|
191
|
+
}
|
|
192
|
+
throw new Error(`Deck ${deck.path} requires inputSchema (non-root)`);
|
|
193
|
+
}
|
|
194
|
+
function validateOutput(deck, output, isRoot) {
|
|
195
|
+
if (deck.outputSchema) {
|
|
196
|
+
return validateWithSchema(deck.outputSchema, output);
|
|
197
|
+
}
|
|
198
|
+
if (isRoot) {
|
|
199
|
+
if (typeof output === "string")
|
|
200
|
+
return output;
|
|
201
|
+
return JSON.stringify(output);
|
|
202
|
+
}
|
|
203
|
+
throw new Error(`Deck ${deck.path} requires outputSchema (non-root)`);
|
|
204
|
+
}
|
|
205
|
+
async function runComputeDeck(ctx) {
|
|
206
|
+
const { deck, runId } = ctx;
|
|
207
|
+
const actionCallId = randomId("action");
|
|
208
|
+
const execContext = {
|
|
209
|
+
runId,
|
|
210
|
+
actionCallId,
|
|
211
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
212
|
+
depth: ctx.depth,
|
|
213
|
+
input: ctx.input,
|
|
214
|
+
label: deck.label,
|
|
215
|
+
log: (entry) => {
|
|
216
|
+
if (!ctx.trace)
|
|
217
|
+
return;
|
|
218
|
+
const raw = typeof entry === "string" ? { message: entry } : entry;
|
|
219
|
+
if (!raw)
|
|
220
|
+
return;
|
|
221
|
+
const message = typeof raw.message === "string"
|
|
222
|
+
? raw.message
|
|
223
|
+
: raw.message !== undefined
|
|
224
|
+
? String(raw.message)
|
|
225
|
+
: typeof entry === "string"
|
|
226
|
+
? entry
|
|
227
|
+
: "";
|
|
228
|
+
const title = typeof raw.title === "string" ? raw.title : undefined;
|
|
229
|
+
const body = raw.body ?? raw.message ?? message;
|
|
230
|
+
ctx.trace({
|
|
231
|
+
type: "log",
|
|
232
|
+
runId,
|
|
233
|
+
deckPath: deck.path,
|
|
234
|
+
actionCallId,
|
|
235
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
236
|
+
level: raw.level ?? "info",
|
|
237
|
+
title: title ?? (message || undefined),
|
|
238
|
+
message,
|
|
239
|
+
body,
|
|
240
|
+
meta: raw.meta,
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
spawnAndWait: async (opts) => {
|
|
244
|
+
const childPath = path.isAbsolute(opts.path)
|
|
245
|
+
? opts.path
|
|
246
|
+
: path.resolve(path.dirname(deck.path), opts.path);
|
|
247
|
+
return await runDeck({
|
|
248
|
+
path: childPath,
|
|
249
|
+
input: opts.input,
|
|
250
|
+
modelProvider: ctx.modelProvider,
|
|
251
|
+
isRoot: false,
|
|
252
|
+
guardrails: ctx.guardrails,
|
|
253
|
+
depth: ctx.depth + 1,
|
|
254
|
+
parentActionCallId: actionCallId,
|
|
255
|
+
runId,
|
|
256
|
+
defaultModel: ctx.defaultModel,
|
|
257
|
+
modelOverride: ctx.modelOverride,
|
|
258
|
+
trace: ctx.trace,
|
|
259
|
+
stream: ctx.stream,
|
|
260
|
+
state: ctx.state,
|
|
261
|
+
onStateUpdate: ctx.onStateUpdate,
|
|
262
|
+
onStreamText: ctx.onStreamText,
|
|
263
|
+
initialUserMessage: undefined,
|
|
264
|
+
inputProvided: true,
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
fail: (opts) => {
|
|
268
|
+
throw new Error(opts.message);
|
|
269
|
+
},
|
|
270
|
+
return: (payload) => Promise.resolve(payload),
|
|
271
|
+
};
|
|
272
|
+
const raw = await deck.executor(execContext);
|
|
273
|
+
return validateOutput(deck, raw, ctx.depth === 0);
|
|
274
|
+
}
|
|
275
|
+
async function runLlmDeck(ctx) {
|
|
276
|
+
const { deck, guardrails, depth, modelProvider, input, runId, inputProvided, initialUserMessage, } = ctx;
|
|
277
|
+
const actionCallId = randomId("action");
|
|
278
|
+
const start = performance.now();
|
|
279
|
+
const respondEnabled = Boolean(deck.respond);
|
|
280
|
+
const systemPrompt = buildSystemPrompt(deck);
|
|
281
|
+
const refToolCallId = randomId("call");
|
|
282
|
+
const messages = ctx.state?.messages
|
|
283
|
+
? ctx.state.messages.map(sanitizeMessage)
|
|
284
|
+
: [];
|
|
285
|
+
const resumed = messages.length > 0;
|
|
286
|
+
const sendInit = Boolean(inputProvided) && input !== undefined && !resumed;
|
|
287
|
+
const idleController = createIdleController({
|
|
288
|
+
cfg: deck.handlers?.onIdle,
|
|
289
|
+
deck,
|
|
290
|
+
guardrails,
|
|
291
|
+
depth,
|
|
292
|
+
runId,
|
|
293
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
294
|
+
modelProvider,
|
|
295
|
+
defaultModel: ctx.defaultModel,
|
|
296
|
+
modelOverride: ctx.modelOverride,
|
|
297
|
+
trace: ctx.trace,
|
|
298
|
+
stream: ctx.stream,
|
|
299
|
+
onStreamText: ctx.onStreamText,
|
|
300
|
+
pushMessages: (msgs) => messages.push(...msgs.map(sanitizeMessage)),
|
|
301
|
+
});
|
|
302
|
+
let streamingBuffer = "";
|
|
303
|
+
let streamingCommitted = false;
|
|
304
|
+
const wrappedOnStreamText = (chunk) => {
|
|
305
|
+
if (!chunk)
|
|
306
|
+
return;
|
|
307
|
+
idleController.touch();
|
|
308
|
+
streamingBuffer += chunk;
|
|
309
|
+
ctx.onStreamText?.(chunk);
|
|
310
|
+
};
|
|
311
|
+
if (!resumed) {
|
|
312
|
+
messages.push(sanitizeMessage({ role: "system", content: systemPrompt }));
|
|
313
|
+
if (sendInit) {
|
|
314
|
+
ctx.trace?.({
|
|
315
|
+
type: "tool.call",
|
|
316
|
+
runId,
|
|
317
|
+
actionCallId: refToolCallId,
|
|
318
|
+
name: GAMBIT_TOOL_INIT,
|
|
319
|
+
args: {},
|
|
320
|
+
parentActionCallId: actionCallId,
|
|
321
|
+
});
|
|
322
|
+
messages.push(sanitizeMessage({
|
|
323
|
+
role: "assistant",
|
|
324
|
+
content: null,
|
|
325
|
+
tool_calls: [{
|
|
326
|
+
id: refToolCallId,
|
|
327
|
+
type: "function",
|
|
328
|
+
function: {
|
|
329
|
+
name: GAMBIT_TOOL_INIT,
|
|
330
|
+
arguments: "{}",
|
|
331
|
+
},
|
|
332
|
+
}],
|
|
333
|
+
}), sanitizeMessage({
|
|
334
|
+
role: "tool",
|
|
335
|
+
name: GAMBIT_TOOL_INIT,
|
|
336
|
+
tool_call_id: refToolCallId,
|
|
337
|
+
content: JSON.stringify(input),
|
|
338
|
+
}));
|
|
339
|
+
ctx.trace?.({
|
|
340
|
+
type: "tool.result",
|
|
341
|
+
runId,
|
|
342
|
+
actionCallId: refToolCallId,
|
|
343
|
+
name: GAMBIT_TOOL_INIT,
|
|
344
|
+
result: input,
|
|
345
|
+
parentActionCallId: actionCallId,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (initialUserMessage !== undefined) {
|
|
350
|
+
const userMessage = sanitizeMessage({
|
|
351
|
+
role: "user",
|
|
352
|
+
content: formatInputForUser(initialUserMessage),
|
|
353
|
+
});
|
|
354
|
+
messages.push(userMessage);
|
|
355
|
+
ctx.trace?.({
|
|
356
|
+
type: "message.user",
|
|
357
|
+
runId,
|
|
358
|
+
actionCallId,
|
|
359
|
+
deckPath: deck.path,
|
|
360
|
+
message: userMessage,
|
|
361
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
idleController.touch();
|
|
365
|
+
const tools = await buildToolDefs(deck);
|
|
366
|
+
ctx.trace?.({
|
|
367
|
+
type: "deck.start",
|
|
368
|
+
runId,
|
|
369
|
+
deckPath: deck.path,
|
|
370
|
+
actionCallId,
|
|
371
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
372
|
+
});
|
|
373
|
+
let passes = 0;
|
|
374
|
+
try {
|
|
375
|
+
while (passes < guardrails.maxPasses) {
|
|
376
|
+
passes++;
|
|
377
|
+
if (performance.now() - start > guardrails.timeoutMs) {
|
|
378
|
+
throw new Error("Timeout exceeded");
|
|
379
|
+
}
|
|
380
|
+
streamingBuffer = "";
|
|
381
|
+
streamingCommitted = false;
|
|
382
|
+
const model = ctx.modelOverride ??
|
|
383
|
+
deck.modelParams?.model ??
|
|
384
|
+
ctx.defaultModel ??
|
|
385
|
+
(() => {
|
|
386
|
+
throw new Error(`No model configured for deck ${deck.path} and no --model provided`);
|
|
387
|
+
})();
|
|
388
|
+
const stateMessages = ctx.state?.messages?.length;
|
|
389
|
+
ctx.trace?.({
|
|
390
|
+
type: "model.call",
|
|
391
|
+
runId,
|
|
392
|
+
actionCallId,
|
|
393
|
+
deckPath: deck.path,
|
|
394
|
+
model,
|
|
395
|
+
stream: ctx.stream,
|
|
396
|
+
messageCount: messages.length,
|
|
397
|
+
toolCount: tools.length,
|
|
398
|
+
messages: messages.map(sanitizeMessage),
|
|
399
|
+
tools,
|
|
400
|
+
stateMessages,
|
|
401
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
402
|
+
});
|
|
403
|
+
const result = await modelProvider.chat({
|
|
404
|
+
model,
|
|
405
|
+
messages,
|
|
406
|
+
tools,
|
|
407
|
+
stream: ctx.stream,
|
|
408
|
+
state: ctx.state,
|
|
409
|
+
params: toProviderParams(deck.modelParams),
|
|
410
|
+
onStreamText: (ctx.onStreamText || deck.handlers?.onIdle)
|
|
411
|
+
? wrappedOnStreamText
|
|
412
|
+
: undefined,
|
|
413
|
+
});
|
|
414
|
+
idleController.touch();
|
|
415
|
+
const message = result.message;
|
|
416
|
+
ctx.trace?.({
|
|
417
|
+
type: "model.result",
|
|
418
|
+
runId,
|
|
419
|
+
actionCallId,
|
|
420
|
+
deckPath: deck.path,
|
|
421
|
+
model,
|
|
422
|
+
finishReason: result.finishReason,
|
|
423
|
+
message: sanitizeMessage(message),
|
|
424
|
+
toolCalls: result.toolCalls,
|
|
425
|
+
stateMessages: result.updatedState?.messages?.length,
|
|
426
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
427
|
+
});
|
|
428
|
+
const computeState = (updated) => {
|
|
429
|
+
const base = updated ??
|
|
430
|
+
{ runId, messages: messages.map(sanitizeMessage) };
|
|
431
|
+
const mergedMessages = base.messages && base.messages.length > 0
|
|
432
|
+
? base.messages.map(sanitizeMessage)
|
|
433
|
+
: messages.map(sanitizeMessage);
|
|
434
|
+
const priorRefs = updated?.messageRefs ?? ctx.state?.messageRefs ?? [];
|
|
435
|
+
const messageRefs = mergedMessages.map((m, idx) => priorRefs[idx] ?? { id: randomId("msg"), role: m.role });
|
|
436
|
+
const feedback = updated?.feedback ?? ctx.state?.feedback;
|
|
437
|
+
const traces = updated?.traces ?? ctx.state?.traces;
|
|
438
|
+
return {
|
|
439
|
+
...base,
|
|
440
|
+
runId,
|
|
441
|
+
messages: mergedMessages,
|
|
442
|
+
messageRefs,
|
|
443
|
+
feedback,
|
|
444
|
+
traces,
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
if (result.toolCalls && result.toolCalls.length > 0) {
|
|
448
|
+
let responded = false;
|
|
449
|
+
let respondValue;
|
|
450
|
+
let endSignal;
|
|
451
|
+
const appendedMessages = [];
|
|
452
|
+
if (!streamingCommitted && streamingBuffer) {
|
|
453
|
+
messages.push(sanitizeMessage({ role: "assistant", content: streamingBuffer }));
|
|
454
|
+
streamingCommitted = true;
|
|
455
|
+
}
|
|
456
|
+
for (const call of result.toolCalls) {
|
|
457
|
+
if (respondEnabled && call.name === GAMBIT_TOOL_RESPOND) {
|
|
458
|
+
const status = typeof call.args?.status === "number"
|
|
459
|
+
? call.args.status
|
|
460
|
+
: undefined;
|
|
461
|
+
const message = typeof call.args?.message === "string"
|
|
462
|
+
? call.args.message
|
|
463
|
+
: undefined;
|
|
464
|
+
const code = typeof call.args?.code === "string"
|
|
465
|
+
? call.args.code
|
|
466
|
+
: undefined;
|
|
467
|
+
const meta = (call.args?.meta &&
|
|
468
|
+
typeof call.args.meta === "object" &&
|
|
469
|
+
call.args.meta !== null)
|
|
470
|
+
? call.args.meta
|
|
471
|
+
: undefined;
|
|
472
|
+
const rawPayload = call.args?.payload ?? call.args;
|
|
473
|
+
const validatedPayload = validateOutput(deck, rawPayload, depth === 0);
|
|
474
|
+
const respondEnvelope = {
|
|
475
|
+
payload: validatedPayload,
|
|
476
|
+
};
|
|
477
|
+
if (status !== undefined)
|
|
478
|
+
respondEnvelope.status = status;
|
|
479
|
+
if (message !== undefined)
|
|
480
|
+
respondEnvelope.message = message;
|
|
481
|
+
if (code !== undefined)
|
|
482
|
+
respondEnvelope.code = code;
|
|
483
|
+
if (meta !== undefined)
|
|
484
|
+
respondEnvelope.meta = meta;
|
|
485
|
+
ctx.trace?.({
|
|
486
|
+
type: "tool.call",
|
|
487
|
+
runId,
|
|
488
|
+
actionCallId: call.id,
|
|
489
|
+
name: call.name,
|
|
490
|
+
args: call.args,
|
|
491
|
+
parentActionCallId: actionCallId,
|
|
492
|
+
});
|
|
493
|
+
const toolContent = JSON.stringify(call.args ?? {});
|
|
494
|
+
appendedMessages.push({
|
|
495
|
+
role: "assistant",
|
|
496
|
+
content: null,
|
|
497
|
+
tool_calls: [{
|
|
498
|
+
id: call.id,
|
|
499
|
+
type: "function",
|
|
500
|
+
function: {
|
|
501
|
+
name: call.name,
|
|
502
|
+
arguments: JSON.stringify(call.args ?? {}),
|
|
503
|
+
},
|
|
504
|
+
}],
|
|
505
|
+
});
|
|
506
|
+
appendedMessages.push({
|
|
507
|
+
role: "tool",
|
|
508
|
+
tool_call_id: call.id,
|
|
509
|
+
name: call.name,
|
|
510
|
+
content: toolContent,
|
|
511
|
+
});
|
|
512
|
+
respondValue = respondEnvelope;
|
|
513
|
+
responded = true;
|
|
514
|
+
ctx.trace?.({
|
|
515
|
+
type: "tool.result",
|
|
516
|
+
runId,
|
|
517
|
+
actionCallId: call.id,
|
|
518
|
+
name: call.name,
|
|
519
|
+
result: respondEnvelope,
|
|
520
|
+
parentActionCallId: actionCallId,
|
|
521
|
+
});
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (deck.allowEnd && call.name === GAMBIT_TOOL_END) {
|
|
525
|
+
const status = typeof call.args?.status === "number"
|
|
526
|
+
? call.args.status
|
|
527
|
+
: undefined;
|
|
528
|
+
const messageText = typeof call.args?.message === "string"
|
|
529
|
+
? call.args.message
|
|
530
|
+
: undefined;
|
|
531
|
+
const code = typeof call.args?.code === "string"
|
|
532
|
+
? call.args.code
|
|
533
|
+
: undefined;
|
|
534
|
+
const meta = (call.args?.meta &&
|
|
535
|
+
typeof call.args.meta === "object" &&
|
|
536
|
+
call.args.meta !== null)
|
|
537
|
+
? call.args.meta
|
|
538
|
+
: undefined;
|
|
539
|
+
const payload = call.args?.payload;
|
|
540
|
+
ctx.trace?.({
|
|
541
|
+
type: "tool.call",
|
|
542
|
+
runId,
|
|
543
|
+
actionCallId: call.id,
|
|
544
|
+
name: call.name,
|
|
545
|
+
args: call.args,
|
|
546
|
+
parentActionCallId: actionCallId,
|
|
547
|
+
});
|
|
548
|
+
const toolContent = JSON.stringify(call.args ?? {});
|
|
549
|
+
appendedMessages.push({
|
|
550
|
+
role: "assistant",
|
|
551
|
+
content: null,
|
|
552
|
+
tool_calls: [{
|
|
553
|
+
id: call.id,
|
|
554
|
+
type: "function",
|
|
555
|
+
function: {
|
|
556
|
+
name: call.name,
|
|
557
|
+
arguments: JSON.stringify(call.args ?? {}),
|
|
558
|
+
},
|
|
559
|
+
}],
|
|
560
|
+
});
|
|
561
|
+
appendedMessages.push({
|
|
562
|
+
role: "tool",
|
|
563
|
+
tool_call_id: call.id,
|
|
564
|
+
name: call.name,
|
|
565
|
+
content: toolContent,
|
|
566
|
+
});
|
|
567
|
+
const signal = { __gambitEnd: true };
|
|
568
|
+
if (status !== undefined)
|
|
569
|
+
signal.status = status;
|
|
570
|
+
if (messageText !== undefined)
|
|
571
|
+
signal.message = messageText;
|
|
572
|
+
if (code !== undefined)
|
|
573
|
+
signal.code = code;
|
|
574
|
+
if (meta !== undefined)
|
|
575
|
+
signal.meta = meta;
|
|
576
|
+
if (payload !== undefined)
|
|
577
|
+
signal.payload = payload;
|
|
578
|
+
endSignal = signal;
|
|
579
|
+
ctx.trace?.({
|
|
580
|
+
type: "tool.result",
|
|
581
|
+
runId,
|
|
582
|
+
actionCallId: call.id,
|
|
583
|
+
name: call.name,
|
|
584
|
+
result: signal,
|
|
585
|
+
parentActionCallId: actionCallId,
|
|
586
|
+
});
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
ctx.trace?.({
|
|
590
|
+
type: "action.start",
|
|
591
|
+
runId,
|
|
592
|
+
actionCallId: call.id,
|
|
593
|
+
name: call.name,
|
|
594
|
+
path: call.name,
|
|
595
|
+
parentActionCallId: actionCallId,
|
|
596
|
+
});
|
|
597
|
+
ctx.trace?.({
|
|
598
|
+
type: "tool.call",
|
|
599
|
+
runId,
|
|
600
|
+
actionCallId: call.id,
|
|
601
|
+
name: call.name,
|
|
602
|
+
args: call.args,
|
|
603
|
+
parentActionCallId: actionCallId,
|
|
604
|
+
});
|
|
605
|
+
const toolResult = await handleToolCall(call, {
|
|
606
|
+
parentDeck: deck,
|
|
607
|
+
modelProvider,
|
|
608
|
+
guardrails,
|
|
609
|
+
depth,
|
|
610
|
+
runId,
|
|
611
|
+
parentActionCallId: actionCallId,
|
|
612
|
+
defaultModel: ctx.defaultModel,
|
|
613
|
+
modelOverride: ctx.modelOverride,
|
|
614
|
+
trace: ctx.trace,
|
|
615
|
+
onStreamText: (ctx.onStreamText || deck.handlers?.onIdle)
|
|
616
|
+
? wrappedOnStreamText
|
|
617
|
+
: undefined,
|
|
618
|
+
runStartedAt: start,
|
|
619
|
+
inputProvided: true,
|
|
620
|
+
idle: idleController,
|
|
621
|
+
});
|
|
622
|
+
ctx.trace?.({
|
|
623
|
+
type: "tool.result",
|
|
624
|
+
runId,
|
|
625
|
+
actionCallId: call.id,
|
|
626
|
+
name: call.name,
|
|
627
|
+
result: toolResult.toolContent,
|
|
628
|
+
parentActionCallId: actionCallId,
|
|
629
|
+
});
|
|
630
|
+
appendedMessages.push({
|
|
631
|
+
role: "assistant",
|
|
632
|
+
content: null,
|
|
633
|
+
tool_calls: [{
|
|
634
|
+
id: call.id,
|
|
635
|
+
type: "function",
|
|
636
|
+
function: {
|
|
637
|
+
name: call.name,
|
|
638
|
+
arguments: JSON.stringify(call.args),
|
|
639
|
+
},
|
|
640
|
+
}],
|
|
641
|
+
});
|
|
642
|
+
appendedMessages.push({
|
|
643
|
+
role: "tool",
|
|
644
|
+
tool_call_id: call.id,
|
|
645
|
+
name: call.name,
|
|
646
|
+
content: toolResult.toolContent,
|
|
647
|
+
});
|
|
648
|
+
if (toolResult.extraMessages?.length) {
|
|
649
|
+
appendedMessages.push(...toolResult.extraMessages);
|
|
650
|
+
}
|
|
651
|
+
ctx.trace?.({
|
|
652
|
+
type: "action.end",
|
|
653
|
+
runId,
|
|
654
|
+
actionCallId: call.id,
|
|
655
|
+
name: call.name,
|
|
656
|
+
path: call.name,
|
|
657
|
+
parentActionCallId: actionCallId,
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
if (appendedMessages.length) {
|
|
661
|
+
messages.push(...appendedMessages.map(sanitizeMessage));
|
|
662
|
+
idleController.touch();
|
|
663
|
+
}
|
|
664
|
+
if (ctx.onStateUpdate) {
|
|
665
|
+
const state = computeState(result.updatedState);
|
|
666
|
+
ctx.onStateUpdate(state);
|
|
667
|
+
}
|
|
668
|
+
if (endSignal) {
|
|
669
|
+
ctx.trace?.({
|
|
670
|
+
type: "deck.end",
|
|
671
|
+
runId,
|
|
672
|
+
deckPath: deck.path,
|
|
673
|
+
actionCallId,
|
|
674
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
675
|
+
});
|
|
676
|
+
return endSignal;
|
|
677
|
+
}
|
|
678
|
+
if (responded) {
|
|
679
|
+
ctx.trace?.({
|
|
680
|
+
type: "deck.end",
|
|
681
|
+
runId,
|
|
682
|
+
deckPath: deck.path,
|
|
683
|
+
actionCallId,
|
|
684
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
685
|
+
});
|
|
686
|
+
return respondValue;
|
|
687
|
+
}
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (result.finishReason === "tool_calls") {
|
|
691
|
+
throw new Error("Model requested tool_calls but provided none");
|
|
692
|
+
}
|
|
693
|
+
if (result.finishReason === "length" &&
|
|
694
|
+
(message.content === null || message.content === undefined)) {
|
|
695
|
+
throw new Error("Model stopped early (length) with no content");
|
|
696
|
+
}
|
|
697
|
+
if (message.content !== null && message.content !== undefined) {
|
|
698
|
+
messages.push(sanitizeMessage(message));
|
|
699
|
+
if (ctx.onStateUpdate) {
|
|
700
|
+
const state = computeState(result.updatedState);
|
|
701
|
+
ctx.onStateUpdate(state);
|
|
702
|
+
}
|
|
703
|
+
if (ctx.parentActionCallId !== undefined &&
|
|
704
|
+
(!result.toolCalls || result.toolCalls.length === 0)) {
|
|
705
|
+
ctx.trace?.({
|
|
706
|
+
type: "monolog",
|
|
707
|
+
runId,
|
|
708
|
+
deckPath: deck.path,
|
|
709
|
+
actionCallId,
|
|
710
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
711
|
+
content: message
|
|
712
|
+
.content,
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
if (!respondEnabled) {
|
|
716
|
+
const validated = validateOutput(deck, message.content, depth === 0);
|
|
717
|
+
ctx.trace?.({
|
|
718
|
+
type: "deck.end",
|
|
719
|
+
runId,
|
|
720
|
+
deckPath: deck.path,
|
|
721
|
+
actionCallId,
|
|
722
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
723
|
+
});
|
|
724
|
+
return validated;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (respondEnabled && result.finishReason === "stop") {
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
if (passes >= guardrails.maxPasses) {
|
|
731
|
+
throw new Error("Max passes exceeded without completing");
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
finally {
|
|
736
|
+
idleController.stop();
|
|
737
|
+
}
|
|
738
|
+
throw new Error("Model did not complete within guardrails");
|
|
739
|
+
}
|
|
740
|
+
async function handleToolCall(call, ctx) {
|
|
741
|
+
const action = ctx.parentDeck.actionDecks.find((a) => a.name === call.name);
|
|
742
|
+
const source = {
|
|
743
|
+
deckPath: ctx.parentDeck.path,
|
|
744
|
+
actionName: action?.name ?? call.name,
|
|
745
|
+
};
|
|
746
|
+
if (!action) {
|
|
747
|
+
return {
|
|
748
|
+
toolContent: JSON.stringify({
|
|
749
|
+
runId: ctx.runId,
|
|
750
|
+
actionCallId: call.id,
|
|
751
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
752
|
+
source,
|
|
753
|
+
status: 404,
|
|
754
|
+
message: "unknown action",
|
|
755
|
+
}),
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
const baseComplete = (payload) => JSON.stringify({
|
|
759
|
+
runId: ctx.runId,
|
|
760
|
+
actionCallId: call.id,
|
|
761
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
762
|
+
source,
|
|
763
|
+
status: payload.status,
|
|
764
|
+
payload: payload.payload,
|
|
765
|
+
message: payload.message,
|
|
766
|
+
code: payload.code,
|
|
767
|
+
meta: payload.meta,
|
|
768
|
+
});
|
|
769
|
+
const extraMessages = [];
|
|
770
|
+
const started = performance.now();
|
|
771
|
+
const busyCfg = ctx.parentDeck.handlers?.onBusy ??
|
|
772
|
+
ctx.parentDeck.handlers?.onInterval;
|
|
773
|
+
const busyDelay = busyCfg?.delayMs ?? DEFAULT_STATUS_DELAY_MS;
|
|
774
|
+
const busyRepeat = busyCfg?.repeatMs;
|
|
775
|
+
let busyTimer;
|
|
776
|
+
let busyFired = false;
|
|
777
|
+
let busyStopped = false;
|
|
778
|
+
let nextBusyAt = busyCfg?.path ? performance.now() + busyDelay : 0;
|
|
779
|
+
ctx.idle?.pause();
|
|
780
|
+
const childPromise = (async () => {
|
|
781
|
+
try {
|
|
782
|
+
const result = await runDeck({
|
|
783
|
+
path: action.path,
|
|
784
|
+
input: call.args,
|
|
785
|
+
modelProvider: ctx.modelProvider,
|
|
786
|
+
isRoot: false,
|
|
787
|
+
guardrails: ctx.guardrails,
|
|
788
|
+
depth: ctx.depth + 1,
|
|
789
|
+
parentActionCallId: call.id,
|
|
790
|
+
runId: ctx.runId,
|
|
791
|
+
defaultModel: ctx.defaultModel,
|
|
792
|
+
modelOverride: ctx.modelOverride,
|
|
793
|
+
trace: ctx.trace,
|
|
794
|
+
stream: ctx.stream,
|
|
795
|
+
onStreamText: ctx.onStreamText,
|
|
796
|
+
initialUserMessage: undefined,
|
|
797
|
+
});
|
|
798
|
+
return { ok: true, result };
|
|
799
|
+
}
|
|
800
|
+
catch (err) {
|
|
801
|
+
return { ok: false, error: err };
|
|
802
|
+
}
|
|
803
|
+
finally {
|
|
804
|
+
// Keep busy timers alive until the caller explicitly stops them
|
|
805
|
+
}
|
|
806
|
+
})();
|
|
807
|
+
const triggerBusy = async (elapsed) => {
|
|
808
|
+
if (busyStopped)
|
|
809
|
+
return;
|
|
810
|
+
busyFired = true;
|
|
811
|
+
try {
|
|
812
|
+
const envelope = await runBusyHandler({
|
|
813
|
+
parentDeck: ctx.parentDeck,
|
|
814
|
+
action,
|
|
815
|
+
call,
|
|
816
|
+
runId: ctx.runId,
|
|
817
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
818
|
+
handlerPath: busyCfg.path,
|
|
819
|
+
modelProvider: ctx.modelProvider,
|
|
820
|
+
guardrails: ctx.guardrails,
|
|
821
|
+
depth: ctx.depth,
|
|
822
|
+
defaultModel: ctx.defaultModel,
|
|
823
|
+
modelOverride: ctx.modelOverride,
|
|
824
|
+
elapsedMs: elapsed,
|
|
825
|
+
trace: ctx.trace,
|
|
826
|
+
stream: ctx.stream,
|
|
827
|
+
onStreamText: ctx.onStreamText,
|
|
828
|
+
initialUserMessage: undefined,
|
|
829
|
+
});
|
|
830
|
+
if (envelope.length) {
|
|
831
|
+
extraMessages.push(...envelope.map(sanitizeMessage));
|
|
832
|
+
}
|
|
833
|
+
ctx.idle?.touch();
|
|
834
|
+
}
|
|
835
|
+
catch {
|
|
836
|
+
// ignore handler errors
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
const scheduleNextBusy = () => {
|
|
840
|
+
if (!busyCfg?.path || busyStopped)
|
|
841
|
+
return;
|
|
842
|
+
const now = performance.now();
|
|
843
|
+
const delay = Math.max(0, nextBusyAt - now);
|
|
844
|
+
busyTimer = setTimeout(async () => {
|
|
845
|
+
if (busyStopped)
|
|
846
|
+
return;
|
|
847
|
+
const elapsed = performance.now() - started;
|
|
848
|
+
await triggerBusy(elapsed);
|
|
849
|
+
if (busyRepeat && busyRepeat > 0) {
|
|
850
|
+
nextBusyAt += busyRepeat;
|
|
851
|
+
scheduleNextBusy();
|
|
852
|
+
}
|
|
853
|
+
}, delay);
|
|
854
|
+
};
|
|
855
|
+
if (busyCfg?.path) {
|
|
856
|
+
scheduleNextBusy();
|
|
857
|
+
}
|
|
858
|
+
const stopBusy = () => {
|
|
859
|
+
busyStopped = true;
|
|
860
|
+
if (busyTimer !== undefined) {
|
|
861
|
+
clearTimeout(busyTimer);
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
const childResult = await childPromise;
|
|
865
|
+
ctx.idle?.resume();
|
|
866
|
+
if (!childResult.ok) {
|
|
867
|
+
const handled = await maybeHandleError({
|
|
868
|
+
err: childResult.error,
|
|
869
|
+
call,
|
|
870
|
+
ctx,
|
|
871
|
+
action,
|
|
872
|
+
});
|
|
873
|
+
if (handled) {
|
|
874
|
+
if (handled.extraMessages) {
|
|
875
|
+
extraMessages.push(...handled.extraMessages);
|
|
876
|
+
}
|
|
877
|
+
stopBusy();
|
|
878
|
+
ctx.idle?.touch();
|
|
879
|
+
const content = handled.toolContent;
|
|
880
|
+
return { toolContent: content, extraMessages };
|
|
881
|
+
}
|
|
882
|
+
stopBusy();
|
|
883
|
+
throw childResult.error;
|
|
884
|
+
}
|
|
885
|
+
const normalized = normalizeChildResult(childResult.result);
|
|
886
|
+
const toolContent = baseComplete(normalized);
|
|
887
|
+
if (busyCfg?.path) {
|
|
888
|
+
const elapsedFromAction = performance.now() - started;
|
|
889
|
+
if (!busyFired && elapsedFromAction >= busyDelay) {
|
|
890
|
+
try {
|
|
891
|
+
const envelope = await runBusyHandler({
|
|
892
|
+
parentDeck: ctx.parentDeck,
|
|
893
|
+
action,
|
|
894
|
+
call,
|
|
895
|
+
runId: ctx.runId,
|
|
896
|
+
parentActionCallId: ctx.parentActionCallId,
|
|
897
|
+
handlerPath: busyCfg.path,
|
|
898
|
+
modelProvider: ctx.modelProvider,
|
|
899
|
+
guardrails: ctx.guardrails,
|
|
900
|
+
depth: ctx.depth,
|
|
901
|
+
defaultModel: ctx.defaultModel,
|
|
902
|
+
modelOverride: ctx.modelOverride,
|
|
903
|
+
elapsedMs: elapsedFromAction,
|
|
904
|
+
trace: ctx.trace,
|
|
905
|
+
stream: ctx.stream,
|
|
906
|
+
onStreamText: ctx.onStreamText,
|
|
907
|
+
initialUserMessage: undefined,
|
|
908
|
+
});
|
|
909
|
+
if (envelope.length) {
|
|
910
|
+
extraMessages.push(...envelope.map(sanitizeMessage));
|
|
911
|
+
}
|
|
912
|
+
ctx.idle?.touch();
|
|
913
|
+
}
|
|
914
|
+
catch {
|
|
915
|
+
// ignore handler errors
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
const completeEventId = randomId("event");
|
|
920
|
+
extraMessages.push({
|
|
921
|
+
role: "assistant",
|
|
922
|
+
content: null,
|
|
923
|
+
tool_calls: [{
|
|
924
|
+
id: completeEventId,
|
|
925
|
+
type: "function",
|
|
926
|
+
function: {
|
|
927
|
+
name: GAMBIT_TOOL_COMPLETE,
|
|
928
|
+
arguments: toolContent,
|
|
929
|
+
},
|
|
930
|
+
}],
|
|
931
|
+
}, {
|
|
932
|
+
role: "tool",
|
|
933
|
+
tool_call_id: completeEventId,
|
|
934
|
+
name: GAMBIT_TOOL_COMPLETE,
|
|
935
|
+
content: toolContent,
|
|
936
|
+
});
|
|
937
|
+
stopBusy();
|
|
938
|
+
ctx.idle?.touch();
|
|
939
|
+
return { toolContent, extraMessages };
|
|
940
|
+
}
|
|
941
|
+
function normalizeChildResult(result) {
|
|
942
|
+
if (result && typeof result === "object") {
|
|
943
|
+
const rec = result;
|
|
944
|
+
const status = typeof rec.status === "number" ? rec.status : undefined;
|
|
945
|
+
const message = typeof rec.message === "string" ? rec.message : undefined;
|
|
946
|
+
const code = typeof rec.code === "string" ? rec.code : undefined;
|
|
947
|
+
const meta = (rec.meta && typeof rec.meta === "object")
|
|
948
|
+
? rec.meta
|
|
949
|
+
: undefined;
|
|
950
|
+
const payload = rec.payload ?? result;
|
|
951
|
+
return { status, payload, message, code, meta };
|
|
952
|
+
}
|
|
953
|
+
return { payload: result };
|
|
954
|
+
}
|
|
955
|
+
async function runBusyHandler(args) {
|
|
956
|
+
try {
|
|
957
|
+
const input = {
|
|
958
|
+
kind: "busy",
|
|
959
|
+
label: args.action.label ?? args.parentDeck.label,
|
|
960
|
+
source: { deckPath: args.parentDeck.path, actionName: args.action.name },
|
|
961
|
+
trigger: {
|
|
962
|
+
reason: "timeout",
|
|
963
|
+
elapsedMs: Math.floor(args.elapsedMs),
|
|
964
|
+
},
|
|
965
|
+
childInput: args.call.args,
|
|
966
|
+
};
|
|
967
|
+
const handlerOutput = await runDeck({
|
|
968
|
+
path: args.handlerPath,
|
|
969
|
+
input,
|
|
970
|
+
modelProvider: args.modelProvider,
|
|
971
|
+
isRoot: false,
|
|
972
|
+
guardrails: args.guardrails,
|
|
973
|
+
depth: args.depth + 1,
|
|
974
|
+
parentActionCallId: args.call.id,
|
|
975
|
+
runId: args.runId,
|
|
976
|
+
defaultModel: args.defaultModel,
|
|
977
|
+
modelOverride: args.modelOverride,
|
|
978
|
+
trace: args.trace,
|
|
979
|
+
stream: args.stream,
|
|
980
|
+
onStreamText: args.onStreamText,
|
|
981
|
+
initialUserMessage: args.initialUserMessage,
|
|
982
|
+
inputProvided: true,
|
|
983
|
+
});
|
|
984
|
+
const elapsedMs = Math.floor(args.elapsedMs);
|
|
985
|
+
let message;
|
|
986
|
+
if (typeof handlerOutput === "string") {
|
|
987
|
+
message = handlerOutput;
|
|
988
|
+
}
|
|
989
|
+
else if (handlerOutput && typeof handlerOutput === "object") {
|
|
990
|
+
if (typeof handlerOutput.message === "string") {
|
|
991
|
+
message = handlerOutput.message;
|
|
992
|
+
}
|
|
993
|
+
else {
|
|
994
|
+
message = JSON.stringify(handlerOutput);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
if (!message)
|
|
998
|
+
return [];
|
|
999
|
+
if (args.onStreamText) {
|
|
1000
|
+
args.onStreamText(`${message}\n`);
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
logger.log(message);
|
|
1004
|
+
}
|
|
1005
|
+
return [{
|
|
1006
|
+
role: "assistant",
|
|
1007
|
+
content: `${message} (elapsed ${elapsedMs}ms)`,
|
|
1008
|
+
}];
|
|
1009
|
+
}
|
|
1010
|
+
catch {
|
|
1011
|
+
return [];
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
function createIdleController(args) {
|
|
1015
|
+
if (!args.cfg?.path) {
|
|
1016
|
+
return {
|
|
1017
|
+
touch: () => { },
|
|
1018
|
+
pause: () => { },
|
|
1019
|
+
resume: () => { },
|
|
1020
|
+
stop: () => { },
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
const delayMs = args.cfg.delayMs ?? DEFAULT_STATUS_DELAY_MS;
|
|
1024
|
+
const repeatMs = args.cfg.repeatMs;
|
|
1025
|
+
let timer;
|
|
1026
|
+
let paused = false;
|
|
1027
|
+
let stopped = false;
|
|
1028
|
+
let lastTouched = performance.now();
|
|
1029
|
+
const clear = () => {
|
|
1030
|
+
if (timer !== undefined)
|
|
1031
|
+
clearTimeout(timer);
|
|
1032
|
+
timer = undefined;
|
|
1033
|
+
};
|
|
1034
|
+
const schedule = () => {
|
|
1035
|
+
if (stopped || paused)
|
|
1036
|
+
return;
|
|
1037
|
+
clear();
|
|
1038
|
+
const now = performance.now();
|
|
1039
|
+
const remaining = Math.max(0, delayMs - (now - lastTouched));
|
|
1040
|
+
timer = setTimeout(async () => {
|
|
1041
|
+
if (stopped || paused)
|
|
1042
|
+
return;
|
|
1043
|
+
const elapsed = performance.now() - lastTouched;
|
|
1044
|
+
try {
|
|
1045
|
+
const envelope = await runIdleHandler({
|
|
1046
|
+
deck: args.deck,
|
|
1047
|
+
handlerPath: args.cfg.path,
|
|
1048
|
+
runId: args.runId,
|
|
1049
|
+
parentActionCallId: args.parentActionCallId,
|
|
1050
|
+
modelProvider: args.modelProvider,
|
|
1051
|
+
guardrails: args.guardrails,
|
|
1052
|
+
depth: args.depth,
|
|
1053
|
+
defaultModel: args.defaultModel,
|
|
1054
|
+
modelOverride: args.modelOverride,
|
|
1055
|
+
elapsedMs: elapsed,
|
|
1056
|
+
trace: args.trace,
|
|
1057
|
+
stream: args.stream,
|
|
1058
|
+
onStreamText: args.onStreamText,
|
|
1059
|
+
});
|
|
1060
|
+
if (envelope.length)
|
|
1061
|
+
args.pushMessages(envelope.map(sanitizeMessage));
|
|
1062
|
+
}
|
|
1063
|
+
catch {
|
|
1064
|
+
// ignore idle handler errors
|
|
1065
|
+
}
|
|
1066
|
+
if (repeatMs && repeatMs > 0) {
|
|
1067
|
+
lastTouched = performance.now();
|
|
1068
|
+
schedule();
|
|
1069
|
+
}
|
|
1070
|
+
}, remaining);
|
|
1071
|
+
};
|
|
1072
|
+
const touch = () => {
|
|
1073
|
+
if (stopped)
|
|
1074
|
+
return;
|
|
1075
|
+
lastTouched = performance.now();
|
|
1076
|
+
schedule();
|
|
1077
|
+
};
|
|
1078
|
+
const pause = () => {
|
|
1079
|
+
paused = true;
|
|
1080
|
+
clear();
|
|
1081
|
+
};
|
|
1082
|
+
const resume = () => {
|
|
1083
|
+
if (stopped)
|
|
1084
|
+
return;
|
|
1085
|
+
if (!paused)
|
|
1086
|
+
return;
|
|
1087
|
+
paused = false;
|
|
1088
|
+
schedule();
|
|
1089
|
+
};
|
|
1090
|
+
const stop = () => {
|
|
1091
|
+
stopped = true;
|
|
1092
|
+
clear();
|
|
1093
|
+
};
|
|
1094
|
+
return { touch, pause, resume, stop };
|
|
1095
|
+
}
|
|
1096
|
+
async function runIdleHandler(args) {
|
|
1097
|
+
try {
|
|
1098
|
+
const input = {
|
|
1099
|
+
kind: "idle",
|
|
1100
|
+
label: args.deck.label,
|
|
1101
|
+
source: { deckPath: args.deck.path },
|
|
1102
|
+
trigger: {
|
|
1103
|
+
reason: "idle_timeout",
|
|
1104
|
+
elapsedMs: Math.floor(args.elapsedMs),
|
|
1105
|
+
},
|
|
1106
|
+
};
|
|
1107
|
+
const handlerOutput = await runDeck({
|
|
1108
|
+
path: args.handlerPath,
|
|
1109
|
+
input,
|
|
1110
|
+
modelProvider: args.modelProvider,
|
|
1111
|
+
isRoot: false,
|
|
1112
|
+
guardrails: args.guardrails,
|
|
1113
|
+
depth: args.depth + 1,
|
|
1114
|
+
parentActionCallId: args.parentActionCallId,
|
|
1115
|
+
runId: args.runId,
|
|
1116
|
+
defaultModel: args.defaultModel,
|
|
1117
|
+
modelOverride: args.modelOverride,
|
|
1118
|
+
trace: args.trace,
|
|
1119
|
+
stream: args.stream,
|
|
1120
|
+
onStreamText: args.onStreamText,
|
|
1121
|
+
initialUserMessage: undefined,
|
|
1122
|
+
inputProvided: true,
|
|
1123
|
+
});
|
|
1124
|
+
const elapsedMs = Math.floor(args.elapsedMs);
|
|
1125
|
+
let message;
|
|
1126
|
+
if (typeof handlerOutput === "string") {
|
|
1127
|
+
message = handlerOutput;
|
|
1128
|
+
}
|
|
1129
|
+
else if (handlerOutput && typeof handlerOutput === "object") {
|
|
1130
|
+
if (typeof handlerOutput.message === "string") {
|
|
1131
|
+
message = handlerOutput.message;
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
message = JSON.stringify(handlerOutput);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (!message)
|
|
1138
|
+
return [];
|
|
1139
|
+
if (args.onStreamText) {
|
|
1140
|
+
args.onStreamText(`${message}\n`);
|
|
1141
|
+
}
|
|
1142
|
+
else {
|
|
1143
|
+
logger.log(message);
|
|
1144
|
+
}
|
|
1145
|
+
return [{
|
|
1146
|
+
role: "assistant",
|
|
1147
|
+
content: `${message} (idle for ${elapsedMs}ms)`,
|
|
1148
|
+
}];
|
|
1149
|
+
}
|
|
1150
|
+
catch {
|
|
1151
|
+
return [];
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
async function maybeHandleError(args) {
|
|
1155
|
+
const handlerPath = args.ctx.parentDeck.handlers?.onError?.path;
|
|
1156
|
+
if (!handlerPath)
|
|
1157
|
+
return undefined;
|
|
1158
|
+
const message = args.err instanceof Error
|
|
1159
|
+
? args.err.message
|
|
1160
|
+
: String(args.err);
|
|
1161
|
+
const envelopeInput = {
|
|
1162
|
+
kind: "error",
|
|
1163
|
+
label: args.action.label ?? args.ctx.parentDeck.label,
|
|
1164
|
+
source: {
|
|
1165
|
+
deckPath: args.ctx.parentDeck.path,
|
|
1166
|
+
actionName: args.action.name,
|
|
1167
|
+
},
|
|
1168
|
+
error: { message },
|
|
1169
|
+
childInput: args.call.args,
|
|
1170
|
+
};
|
|
1171
|
+
try {
|
|
1172
|
+
const handlerOutput = await runDeck({
|
|
1173
|
+
path: handlerPath,
|
|
1174
|
+
input: envelopeInput,
|
|
1175
|
+
modelProvider: args.ctx.modelProvider,
|
|
1176
|
+
isRoot: false,
|
|
1177
|
+
guardrails: args.ctx.guardrails,
|
|
1178
|
+
depth: args.ctx.depth + 1,
|
|
1179
|
+
parentActionCallId: args.call.id,
|
|
1180
|
+
runId: args.ctx.runId,
|
|
1181
|
+
defaultModel: args.ctx.defaultModel,
|
|
1182
|
+
modelOverride: args.ctx.modelOverride,
|
|
1183
|
+
trace: args.ctx.trace,
|
|
1184
|
+
stream: args.ctx.stream,
|
|
1185
|
+
onStreamText: args.ctx.onStreamText,
|
|
1186
|
+
initialUserMessage: undefined,
|
|
1187
|
+
inputProvided: true,
|
|
1188
|
+
});
|
|
1189
|
+
const parsed = typeof handlerOutput === "object" && handlerOutput !== null
|
|
1190
|
+
? handlerOutput
|
|
1191
|
+
: undefined;
|
|
1192
|
+
const status = typeof parsed?.status === "number" ? parsed.status : 500;
|
|
1193
|
+
const code = typeof parsed?.code === "string" ? parsed.code : undefined;
|
|
1194
|
+
const messageOverride = typeof parsed?.message === "string"
|
|
1195
|
+
? parsed.message
|
|
1196
|
+
: undefined;
|
|
1197
|
+
const meta = (parsed?.meta && typeof parsed.meta === "object")
|
|
1198
|
+
? parsed.meta
|
|
1199
|
+
: undefined;
|
|
1200
|
+
const payload = parsed?.payload ?? handlerOutput;
|
|
1201
|
+
const content = JSON.stringify({
|
|
1202
|
+
runId: args.ctx.runId,
|
|
1203
|
+
actionCallId: args.call.id,
|
|
1204
|
+
parentActionCallId: args.ctx.parentActionCallId,
|
|
1205
|
+
source: {
|
|
1206
|
+
deckPath: args.ctx.parentDeck.path,
|
|
1207
|
+
actionName: args.action.name,
|
|
1208
|
+
},
|
|
1209
|
+
status,
|
|
1210
|
+
payload,
|
|
1211
|
+
message: messageOverride ?? message,
|
|
1212
|
+
code,
|
|
1213
|
+
meta,
|
|
1214
|
+
});
|
|
1215
|
+
const callId = randomId("event");
|
|
1216
|
+
const extraMessages = [
|
|
1217
|
+
{
|
|
1218
|
+
role: "assistant",
|
|
1219
|
+
content: null,
|
|
1220
|
+
tool_calls: [{
|
|
1221
|
+
id: callId,
|
|
1222
|
+
type: "function",
|
|
1223
|
+
function: {
|
|
1224
|
+
name: GAMBIT_TOOL_COMPLETE,
|
|
1225
|
+
arguments: content,
|
|
1226
|
+
},
|
|
1227
|
+
}],
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
role: "tool",
|
|
1231
|
+
tool_call_id: callId,
|
|
1232
|
+
name: GAMBIT_TOOL_COMPLETE,
|
|
1233
|
+
content,
|
|
1234
|
+
},
|
|
1235
|
+
];
|
|
1236
|
+
return { toolContent: content, extraMessages };
|
|
1237
|
+
}
|
|
1238
|
+
catch {
|
|
1239
|
+
// Fallback when the handler itself fails: still return a structured error envelope
|
|
1240
|
+
// so the assistant can continue gracefully.
|
|
1241
|
+
const status = 500;
|
|
1242
|
+
const messageOverride = `Handled error: ${message}`;
|
|
1243
|
+
const code = "HANDLER_FALLBACK";
|
|
1244
|
+
const content = JSON.stringify({
|
|
1245
|
+
runId: args.ctx.runId,
|
|
1246
|
+
actionCallId: args.call.id,
|
|
1247
|
+
parentActionCallId: args.ctx.parentActionCallId,
|
|
1248
|
+
source: {
|
|
1249
|
+
deckPath: args.ctx.parentDeck.path,
|
|
1250
|
+
actionName: args.action.name,
|
|
1251
|
+
},
|
|
1252
|
+
status,
|
|
1253
|
+
payload: envelopeInput,
|
|
1254
|
+
message: messageOverride,
|
|
1255
|
+
code,
|
|
1256
|
+
meta: { handlerFailed: true },
|
|
1257
|
+
});
|
|
1258
|
+
const callId = randomId("event");
|
|
1259
|
+
const extraMessages = [
|
|
1260
|
+
{
|
|
1261
|
+
role: "assistant",
|
|
1262
|
+
content: null,
|
|
1263
|
+
tool_calls: [{
|
|
1264
|
+
id: callId,
|
|
1265
|
+
type: "function",
|
|
1266
|
+
function: {
|
|
1267
|
+
name: GAMBIT_TOOL_COMPLETE,
|
|
1268
|
+
arguments: content,
|
|
1269
|
+
},
|
|
1270
|
+
}],
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
role: "tool",
|
|
1274
|
+
tool_call_id: callId,
|
|
1275
|
+
name: GAMBIT_TOOL_COMPLETE,
|
|
1276
|
+
content,
|
|
1277
|
+
},
|
|
1278
|
+
];
|
|
1279
|
+
return { toolContent: content, extraMessages };
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
function buildSystemPrompt(deck) {
|
|
1283
|
+
const parts = [];
|
|
1284
|
+
const prompt = deck.body ?? deck.prompt;
|
|
1285
|
+
if (prompt)
|
|
1286
|
+
parts.push(prompt.trim());
|
|
1287
|
+
if (!deck.inlineEmbeds) {
|
|
1288
|
+
for (const card of deck.cards) {
|
|
1289
|
+
if (card.body)
|
|
1290
|
+
parts.push(card.body.trim());
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
return parts.join("\n\n").trim();
|
|
1294
|
+
}
|
|
1295
|
+
function formatInputForUser(input) {
|
|
1296
|
+
if (typeof input === "string")
|
|
1297
|
+
return input;
|
|
1298
|
+
try {
|
|
1299
|
+
return JSON.stringify(input, null, 2);
|
|
1300
|
+
}
|
|
1301
|
+
catch {
|
|
1302
|
+
return String(input);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
function sanitizeMessage(msg) {
|
|
1306
|
+
const toolCalls = msg.tool_calls && msg.tool_calls.length > 0
|
|
1307
|
+
? msg.tool_calls
|
|
1308
|
+
: undefined;
|
|
1309
|
+
return { ...msg, tool_calls: toolCalls };
|
|
1310
|
+
}
|
|
1311
|
+
async function buildToolDefs(deck) {
|
|
1312
|
+
const defs = [];
|
|
1313
|
+
if (deck.allowEnd) {
|
|
1314
|
+
defs.push({
|
|
1315
|
+
type: "function",
|
|
1316
|
+
function: {
|
|
1317
|
+
name: GAMBIT_TOOL_END,
|
|
1318
|
+
description: "End the current run once all goals are complete.",
|
|
1319
|
+
parameters: {
|
|
1320
|
+
type: "object",
|
|
1321
|
+
properties: {
|
|
1322
|
+
status: { type: "number" },
|
|
1323
|
+
payload: {},
|
|
1324
|
+
message: { type: "string" },
|
|
1325
|
+
code: { type: "string" },
|
|
1326
|
+
meta: { type: "object" },
|
|
1327
|
+
},
|
|
1328
|
+
additionalProperties: true,
|
|
1329
|
+
},
|
|
1330
|
+
},
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
if (deck.respond) {
|
|
1334
|
+
defs.push({
|
|
1335
|
+
type: "function",
|
|
1336
|
+
function: {
|
|
1337
|
+
name: GAMBIT_TOOL_RESPOND,
|
|
1338
|
+
description: "Finish the current deck with a structured response.",
|
|
1339
|
+
parameters: {
|
|
1340
|
+
type: "object",
|
|
1341
|
+
properties: {
|
|
1342
|
+
status: { type: "number" },
|
|
1343
|
+
payload: {},
|
|
1344
|
+
message: { type: "string" },
|
|
1345
|
+
code: { type: "string" },
|
|
1346
|
+
meta: { type: "object" },
|
|
1347
|
+
},
|
|
1348
|
+
additionalProperties: true,
|
|
1349
|
+
},
|
|
1350
|
+
},
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
for (const action of deck.actionDecks) {
|
|
1354
|
+
const child = await loadDeck(action.path, deck.path);
|
|
1355
|
+
ensureSchemaPresence(child, false);
|
|
1356
|
+
const schema = child.inputSchema;
|
|
1357
|
+
const params = toJsonSchema(schema);
|
|
1358
|
+
defs.push({
|
|
1359
|
+
type: "function",
|
|
1360
|
+
function: {
|
|
1361
|
+
name: action.name,
|
|
1362
|
+
description: action.description,
|
|
1363
|
+
parameters: params,
|
|
1364
|
+
},
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
return defs;
|
|
1368
|
+
}
|