@openclaw/lobster 2026.7.1-beta.2 → 2026.7.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -23
- package/node_modules/@clawdbot/lobster/README.md +10 -0
- package/node_modules/@clawdbot/lobster/dist/src/cli.js +23 -7
- package/node_modules/@clawdbot/lobster/dist/src/cli.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/commands/stdlib/ask.js +28 -5
- package/node_modules/@clawdbot/lobster/dist/src/commands/stdlib/ask.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/commands/stdlib/llm_invoke.js +20 -5
- package/node_modules/@clawdbot/lobster/dist/src/commands/stdlib/llm_invoke.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/commands/stdlib/state.js +3 -3
- package/node_modules/@clawdbot/lobster/dist/src/commands/stdlib/state.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/core/cost_tracker.js +52 -6
- package/node_modules/@clawdbot/lobster/dist/src/core/cost_tracker.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/core/retry.js +7 -3
- package/node_modules/@clawdbot/lobster/dist/src/core/retry.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/core/tool_runtime.js +17 -8
- package/node_modules/@clawdbot/lobster/dist/src/core/tool_runtime.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/input_request.js +430 -0
- package/node_modules/@clawdbot/lobster/dist/src/input_request.js.map +1 -0
- package/node_modules/@clawdbot/lobster/dist/src/pipeline_resume_state.js +50 -4
- package/node_modules/@clawdbot/lobster/dist/src/pipeline_resume_state.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/runtime.js +160 -10
- package/node_modules/@clawdbot/lobster/dist/src/runtime.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/sdk/Lobster.js +105 -12
- package/node_modules/@clawdbot/lobster/dist/src/sdk/Lobster.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/sdk/primitives/diff.js +7 -6
- package/node_modules/@clawdbot/lobster/dist/src/sdk/primitives/diff.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/sdk/primitives/state.js +43 -2
- package/node_modules/@clawdbot/lobster/dist/src/sdk/primitives/state.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/sdk/runtime.js +82 -90
- package/node_modules/@clawdbot/lobster/dist/src/sdk/runtime.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/state/store.js +166 -8
- package/node_modules/@clawdbot/lobster/dist/src/state/store.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/src/workflows/file.js +216 -28
- package/node_modules/@clawdbot/lobster/dist/src/workflows/file.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/approval_id.test.js +13 -0
- package/node_modules/@clawdbot/lobster/dist/test/approval_id.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/cost_tracker.test.js +108 -3
- package/node_modules/@clawdbot/lobster/dist/test/cost_tracker.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/for_each.test.js +17 -0
- package/node_modules/@clawdbot/lobster/dist/test/for_each.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/llm_task_invoke.test.js +70 -1
- package/node_modules/@clawdbot/lobster/dist/test/llm_task_invoke.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/parallel.test.js +13 -0
- package/node_modules/@clawdbot/lobster/dist/test/parallel.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/request_input.test.js +946 -0
- package/node_modules/@clawdbot/lobster/dist/test/request_input.test.js.map +1 -0
- package/node_modules/@clawdbot/lobster/dist/test/sdk_lobster.test.js +118 -0
- package/node_modules/@clawdbot/lobster/dist/test/sdk_lobster.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/state.test.js +268 -1
- package/node_modules/@clawdbot/lobster/dist/test/state.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/step_retry.test.js +46 -2
- package/node_modules/@clawdbot/lobster/dist/test/step_retry.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/dist/test/workflow_file.test.js +503 -0
- package/node_modules/@clawdbot/lobster/dist/test/workflow_file.test.js.map +1 -1
- package/node_modules/@clawdbot/lobster/package.json +15 -9
- package/node_modules/typebox/build/compile/validator.d.mts +2 -7
- package/node_modules/typebox/build/compile/validator.mjs +6 -36
- package/node_modules/typebox/build/error/errors.d.mts +1 -7
- package/node_modules/typebox/build/format/_idna.mjs +36 -6
- package/node_modules/typebox/build/format/_puny.mjs +4 -1
- package/node_modules/typebox/build/format/uuid.d.mts +2 -2
- package/node_modules/typebox/build/format/uuid.mjs +3 -3
- package/node_modules/typebox/build/guard/emit.d.mts +0 -4
- package/node_modules/typebox/build/guard/emit.mjs +0 -8
- package/node_modules/typebox/build/guard/guard.d.mts +4 -8
- package/node_modules/typebox/build/guard/guard.mjs +5 -13
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
- package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/types/index.mjs +0 -1
- package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
- package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
- package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
- package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
- package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
- package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
- package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
- package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
- package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
- package/node_modules/typebox/build/type/action/index.d.mts +7 -4
- package/node_modules/typebox/build/type/action/index.mjs +7 -4
- package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
- package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
- package/node_modules/typebox/build/type/action/module.d.mts +8 -7
- package/node_modules/typebox/build/type/action/module.mjs +7 -6
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
- package/node_modules/typebox/build/type/action/with.d.mts +11 -0
- package/node_modules/typebox/build/type/action/with.mjs +11 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/index.mjs +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
- package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
- package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
- package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
- package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
- package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
- package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
- package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
- package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
- package/node_modules/typebox/build/type/extends/object.mjs +25 -3
- package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
- package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/record.mjs +23 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
- package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
- package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
- package/node_modules/typebox/build/type/extends/union.mjs +2 -2
- package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
- package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
- package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
- package/node_modules/typebox/build/type/script/parser.mjs +22 -22
- package/node_modules/typebox/build/type/script/script.d.mts +3 -4
- package/node_modules/typebox/build/type/script/script.mjs +3 -2
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
- package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
- package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
- package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
- package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
- package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
- package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
- package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
- package/node_modules/typebox/build/type/types/call.d.mts +3 -3
- package/node_modules/typebox/build/type/types/call.mjs +3 -2
- package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
- package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
- package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
- package/node_modules/typebox/build/type/types/enum.mjs +5 -0
- package/node_modules/typebox/build/type/types/index.d.mts +1 -4
- package/node_modules/typebox/build/type/types/index.mjs +1 -4
- package/node_modules/typebox/build/type/types/number.d.mts +1 -1
- package/node_modules/typebox/build/type/types/number.mjs +1 -1
- package/node_modules/typebox/build/type/types/record.d.mts +13 -7
- package/node_modules/typebox/build/type/types/record.mjs +15 -9
- package/node_modules/typebox/build/type/types/static.d.mts +2 -5
- package/node_modules/typebox/build/typebox.d.mts +4 -8
- package/node_modules/typebox/build/typebox.mjs +4 -8
- package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
- package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
- package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
- package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
- package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
- package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
- package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/index.d.mts +0 -1
- package/node_modules/typebox/build/value/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
- package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
- package/node_modules/typebox/build/value/value.d.mts +0 -1
- package/node_modules/typebox/build/value/value.mjs +0 -1
- package/node_modules/typebox/package.json +25 -25
- package/node_modules/typebox/readme.md +97 -80
- package/npm-shrinkwrap.json +12 -12
- package/package.json +6 -6
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
- package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
- package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
- package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
- package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
- package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
- package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
- package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
- package/node_modules/typebox/build/type/action/options.d.mts +0 -11
- package/node_modules/typebox/build/type/action/options.mjs +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/base.d.mts +0 -50
- package/node_modules/typebox/build/type/types/base.mjs +0 -84
- package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
- package/node_modules/typebox/build/type/types/promise.mjs +0 -29
- package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
- package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
- package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
- package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
- package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
- package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
- package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
- package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { stableStringify } from "./state/store.js";
|
|
2
|
+
import { compileCached } from "./validation.js";
|
|
3
|
+
const MAX_REPLAY_ITEMS = 1000;
|
|
4
|
+
const MAX_REPLAY_BYTES = 1024 * 1024;
|
|
5
|
+
const MAX_REQUEST_HISTORY = 100;
|
|
6
|
+
export class InputRequestSuspension extends Error {
|
|
7
|
+
stageIndex;
|
|
8
|
+
request;
|
|
9
|
+
constructor(stageIndex, request) {
|
|
10
|
+
super("Input request suspended");
|
|
11
|
+
this.name = "InputRequestSuspension";
|
|
12
|
+
this.stageIndex = stageIndex;
|
|
13
|
+
this.request = request;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class RequestInputResumeError extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "RequestInputResumeError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function createInputTracker(input) {
|
|
23
|
+
const knownItems = Array.isArray(input) ? input : null;
|
|
24
|
+
let iterator = null;
|
|
25
|
+
let completed = false;
|
|
26
|
+
let closed = false;
|
|
27
|
+
let replayEnabled = true;
|
|
28
|
+
let replaySnapshotItems = [];
|
|
29
|
+
let replaySnapshotIndex = 0;
|
|
30
|
+
let replaySnapshotError = null;
|
|
31
|
+
let replaySnapshotBytes = 0;
|
|
32
|
+
const iterable = {
|
|
33
|
+
async *[Symbol.asyncIterator]() {
|
|
34
|
+
const iter = getIterator();
|
|
35
|
+
let hasPrimaryError = false;
|
|
36
|
+
let yieldedIndex = 0;
|
|
37
|
+
try {
|
|
38
|
+
while (true) {
|
|
39
|
+
const next = await iter.next();
|
|
40
|
+
if (next.done) {
|
|
41
|
+
completed = true;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (knownItems) {
|
|
45
|
+
snapshotKnownItemsThrough(yieldedIndex);
|
|
46
|
+
yieldedIndex += 1;
|
|
47
|
+
}
|
|
48
|
+
yield next.value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
hasPrimaryError = true;
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await closeTrackedIterator({ suppressErrors: hasPrimaryError });
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
iterable,
|
|
62
|
+
getReplayItems(hasSuspendedState) {
|
|
63
|
+
if (!replayEnabled) {
|
|
64
|
+
throw new Error("requestInput replay is no longer available after command output");
|
|
65
|
+
}
|
|
66
|
+
if (!knownItems) {
|
|
67
|
+
if (hasSuspendedState)
|
|
68
|
+
return [];
|
|
69
|
+
throw new Error("requestInput requires suspendedState when command input is streaming");
|
|
70
|
+
}
|
|
71
|
+
snapshotKnownItemsThrough(knownItems.length - 1);
|
|
72
|
+
if (replaySnapshotError)
|
|
73
|
+
throw replaySnapshotError;
|
|
74
|
+
return snapshotArray(replaySnapshotItems, "requestInput replay input");
|
|
75
|
+
},
|
|
76
|
+
disableReplay() {
|
|
77
|
+
replayEnabled = false;
|
|
78
|
+
},
|
|
79
|
+
async close(options = {}) {
|
|
80
|
+
await closeTrackedIterator({ suppressErrors: options.suppressErrors === true });
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
function getIterator() {
|
|
84
|
+
iterator ??= toAsyncIterator(input);
|
|
85
|
+
return iterator;
|
|
86
|
+
}
|
|
87
|
+
async function closeTrackedIterator({ suppressErrors }) {
|
|
88
|
+
if (!iterator || completed || closed)
|
|
89
|
+
return;
|
|
90
|
+
closed = true;
|
|
91
|
+
await closeIterator(iterator, { suppressErrors });
|
|
92
|
+
}
|
|
93
|
+
function snapshotKnownItemsThrough(index) {
|
|
94
|
+
if (!knownItems || replaySnapshotError)
|
|
95
|
+
return;
|
|
96
|
+
while (replaySnapshotIndex <= index && replaySnapshotIndex < knownItems.length) {
|
|
97
|
+
try {
|
|
98
|
+
const snapshot = snapshotJson(knownItems[replaySnapshotIndex], "requestInput replay input");
|
|
99
|
+
replaySnapshotBytes += Buffer.byteLength(JSON.stringify(snapshot), "utf8");
|
|
100
|
+
if (replaySnapshotItems.length + 1 > MAX_REPLAY_ITEMS ||
|
|
101
|
+
replaySnapshotBytes > MAX_REPLAY_BYTES) {
|
|
102
|
+
throw new Error("requestInput replay limit exceeded");
|
|
103
|
+
}
|
|
104
|
+
replaySnapshotItems.push(snapshot);
|
|
105
|
+
replaySnapshotIndex += 1;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
replaySnapshotError = err instanceof Error ? err : new Error(String(err));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function createStageRequestInput({ ctx, stageIndex, mode, inputTracker, isCommandActive, getInactiveReason, isOutputStarted, resume, }) {
|
|
115
|
+
let requestIndex = 0;
|
|
116
|
+
const history = [...(resume?.state.history ?? [])];
|
|
117
|
+
const requestInput = async function requestInput(params) {
|
|
118
|
+
if (!isCommandActive()) {
|
|
119
|
+
throw new Error(getInactiveReason?.() ?? "requestInput cannot run after the command has completed");
|
|
120
|
+
}
|
|
121
|
+
const metadata = snapshotRequestMetadata(params);
|
|
122
|
+
const requestedSuspendedState = params.suspendedState === undefined
|
|
123
|
+
? undefined
|
|
124
|
+
: snapshotJson(params.suspendedState, "requestInput suspendedState");
|
|
125
|
+
const historical = history[requestIndex];
|
|
126
|
+
if (historical) {
|
|
127
|
+
assertMetadataMatches(historical.requestIndex, historical.metadata, requestIndex, metadata);
|
|
128
|
+
assertSuspendedStateMatches(historical.suspendedState, requestedSuspendedState);
|
|
129
|
+
const response = snapshotJson(historical.response, "requestInput response");
|
|
130
|
+
validateRequestInputResponse(metadata.responseSchema, response, "requestInput");
|
|
131
|
+
requestIndex += 1;
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
if (resume && !resume.consumed) {
|
|
135
|
+
assertMetadataMatches(resume.state.pending.requestIndex, resume.state.pending.metadata, requestIndex, metadata);
|
|
136
|
+
assertSuspendedStateMatches(resume.state.pending.suspendedState, requestedSuspendedState);
|
|
137
|
+
const response = snapshotJson(resume.response, "requestInput response");
|
|
138
|
+
validateRequestInputResponse(metadata.responseSchema, response, "requestInput");
|
|
139
|
+
const historyResponse = snapshotJson(response, "requestInput response");
|
|
140
|
+
await resume.onConsumed?.();
|
|
141
|
+
resume.consumed = true;
|
|
142
|
+
history.push({
|
|
143
|
+
requestIndex,
|
|
144
|
+
metadata,
|
|
145
|
+
...(requestedSuspendedState !== undefined
|
|
146
|
+
? { suspendedState: requestedSuspendedState }
|
|
147
|
+
: null),
|
|
148
|
+
response: historyResponse,
|
|
149
|
+
});
|
|
150
|
+
requestIndex += 1;
|
|
151
|
+
return response;
|
|
152
|
+
}
|
|
153
|
+
if (mode === "human" && isInteractive(ctx.stdin)) {
|
|
154
|
+
return requestInputInteractively(ctx, metadata);
|
|
155
|
+
}
|
|
156
|
+
if (isOutputStarted()) {
|
|
157
|
+
throw new Error("requestInput cannot suspend after this command has produced output");
|
|
158
|
+
}
|
|
159
|
+
if (history.length >= MAX_REQUEST_HISTORY) {
|
|
160
|
+
throw new Error("requestInput replay history limit exceeded");
|
|
161
|
+
}
|
|
162
|
+
const items = inputTracker.getReplayItems(requestedSuspendedState !== undefined);
|
|
163
|
+
const pending = {
|
|
164
|
+
requestIndex,
|
|
165
|
+
metadata,
|
|
166
|
+
...(requestedSuspendedState !== undefined
|
|
167
|
+
? { suspendedState: requestedSuspendedState }
|
|
168
|
+
: null),
|
|
169
|
+
};
|
|
170
|
+
throw new InputRequestSuspension(stageIndex, {
|
|
171
|
+
type: "input_request",
|
|
172
|
+
prompt: metadata.prompt,
|
|
173
|
+
responseSchema: metadata.responseSchema,
|
|
174
|
+
...(metadata.defaults !== undefined ? { defaults: metadata.defaults } : null),
|
|
175
|
+
...(metadata.subject !== undefined ? { subject: metadata.subject } : null),
|
|
176
|
+
items,
|
|
177
|
+
commandInput: {
|
|
178
|
+
pending,
|
|
179
|
+
history,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
requestInput.getSuspendedState = function getSuspendedState() {
|
|
184
|
+
if (requestIndex < history.length) {
|
|
185
|
+
return snapshotOptionalState(history[requestIndex].suspendedState);
|
|
186
|
+
}
|
|
187
|
+
if (resume && !resume.consumed && resume.state.pending.requestIndex === requestIndex) {
|
|
188
|
+
return snapshotOptionalState(resume.state.pending.suspendedState);
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
};
|
|
192
|
+
return requestInput;
|
|
193
|
+
}
|
|
194
|
+
export function assertRequestInputResumeConsumed(resume) {
|
|
195
|
+
if (resume && !resume.consumed) {
|
|
196
|
+
throw new RequestInputResumeError("resume input response was not consumed by requestInput");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export function snapshotRequestMetadata(params) {
|
|
200
|
+
validateRequestInputParams(params);
|
|
201
|
+
const responseSchema = snapshotJson(params.responseSchema, "requestInput responseSchema");
|
|
202
|
+
const defaults = params.defaults === undefined
|
|
203
|
+
? undefined
|
|
204
|
+
: snapshotJson(params.defaults, "requestInput defaults");
|
|
205
|
+
const subject = params.subject === undefined ? undefined : snapshotJson(params.subject, "requestInput subject");
|
|
206
|
+
const unsigned = {
|
|
207
|
+
prompt: params.prompt,
|
|
208
|
+
responseSchema,
|
|
209
|
+
...(defaults !== undefined ? { defaults } : null),
|
|
210
|
+
...(subject !== undefined ? { subject } : null),
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
...unsigned,
|
|
214
|
+
signature: stableStringify(unsigned),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
export function validateCommandInputState(value) {
|
|
218
|
+
if (!value || typeof value !== "object")
|
|
219
|
+
throw new Error("Invalid pipeline resume state");
|
|
220
|
+
const data = value;
|
|
221
|
+
validatePending(data.pending);
|
|
222
|
+
if (!Array.isArray(data.history))
|
|
223
|
+
throw new Error("Invalid pipeline resume state");
|
|
224
|
+
if (data.history.length !== data.pending.requestIndex) {
|
|
225
|
+
throw new Error("Invalid pipeline resume state");
|
|
226
|
+
}
|
|
227
|
+
data.history.forEach(validateHistoryEntry);
|
|
228
|
+
return data;
|
|
229
|
+
}
|
|
230
|
+
export function validateRequestInputResponse(schema, response, label) {
|
|
231
|
+
let validator;
|
|
232
|
+
try {
|
|
233
|
+
validator = compileCached(schema);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
throw new Error(`${label} response schema is invalid`);
|
|
237
|
+
}
|
|
238
|
+
if (validator(response))
|
|
239
|
+
return;
|
|
240
|
+
const first = validator.errors?.[0];
|
|
241
|
+
const pathValue = first?.instancePath || "/";
|
|
242
|
+
const reason = first?.message ? ` ${first.message}` : "";
|
|
243
|
+
throw new Error(`${label} response failed schema validation at ${pathValue}:${reason}`);
|
|
244
|
+
}
|
|
245
|
+
function validateRequestInputParams(params) {
|
|
246
|
+
if (!params || typeof params !== "object") {
|
|
247
|
+
throw new Error("requestInput params must be an object");
|
|
248
|
+
}
|
|
249
|
+
if (typeof params.prompt !== "string" || params.prompt.length === 0) {
|
|
250
|
+
throw new Error("requestInput prompt is required");
|
|
251
|
+
}
|
|
252
|
+
if (params.responseSchema === undefined) {
|
|
253
|
+
throw new Error("requestInput responseSchema is required");
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
compileCached(params.responseSchema);
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
throw new Error("requestInput response schema is invalid");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function validatePending(value) {
|
|
263
|
+
if (!value || typeof value !== "object")
|
|
264
|
+
throw new Error("Invalid pipeline resume state");
|
|
265
|
+
const data = value;
|
|
266
|
+
if (typeof data.requestIndex !== "number" ||
|
|
267
|
+
!Number.isInteger(data.requestIndex) ||
|
|
268
|
+
data.requestIndex < 0) {
|
|
269
|
+
throw new Error("Invalid pipeline resume state");
|
|
270
|
+
}
|
|
271
|
+
validateStoredMetadata(data.metadata);
|
|
272
|
+
if (data.suspendedState !== undefined) {
|
|
273
|
+
snapshotJson(data.suspendedState, "requestInput suspendedState");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function validateHistoryEntry(value, index) {
|
|
277
|
+
if (!value || typeof value !== "object")
|
|
278
|
+
throw new Error("Invalid pipeline resume state");
|
|
279
|
+
const data = value;
|
|
280
|
+
if (data.requestIndex !== index)
|
|
281
|
+
throw new Error("Invalid pipeline resume state");
|
|
282
|
+
validateStoredMetadata(data.metadata);
|
|
283
|
+
if (data.suspendedState !== undefined) {
|
|
284
|
+
snapshotJson(data.suspendedState, "requestInput suspendedState");
|
|
285
|
+
}
|
|
286
|
+
if (data.response === undefined)
|
|
287
|
+
throw new Error("Invalid pipeline resume state");
|
|
288
|
+
snapshotJson(data.response, "requestInput response");
|
|
289
|
+
}
|
|
290
|
+
function validateStoredMetadata(value) {
|
|
291
|
+
if (!value || typeof value !== "object")
|
|
292
|
+
throw new Error("Invalid pipeline resume state");
|
|
293
|
+
const data = value;
|
|
294
|
+
if (typeof data.prompt !== "string" || data.prompt.length === 0) {
|
|
295
|
+
throw new Error("Invalid pipeline resume state");
|
|
296
|
+
}
|
|
297
|
+
if (typeof data.signature !== "string" || data.signature.length === 0) {
|
|
298
|
+
throw new Error("Invalid pipeline resume state");
|
|
299
|
+
}
|
|
300
|
+
if (data.responseSchema === undefined)
|
|
301
|
+
throw new Error("Invalid pipeline resume state");
|
|
302
|
+
const actual = snapshotRequestMetadata({
|
|
303
|
+
prompt: data.prompt,
|
|
304
|
+
responseSchema: data.responseSchema,
|
|
305
|
+
...(data.defaults !== undefined ? { defaults: data.defaults } : null),
|
|
306
|
+
...(data.subject !== undefined ? { subject: data.subject } : null),
|
|
307
|
+
});
|
|
308
|
+
if (actual.signature !== data.signature)
|
|
309
|
+
throw new Error("Invalid pipeline resume state");
|
|
310
|
+
}
|
|
311
|
+
function assertMetadataMatches(storedIndex, stored, actualIndex, actual) {
|
|
312
|
+
if (storedIndex !== actualIndex ||
|
|
313
|
+
stored.prompt !== actual.prompt ||
|
|
314
|
+
stored.signature !== actual.signature) {
|
|
315
|
+
throw new RequestInputResumeError("requestInput resume request does not match suspended request");
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function assertSuspendedStateMatches(stored, actual) {
|
|
319
|
+
if (stableStringify(stored) !== stableStringify(actual)) {
|
|
320
|
+
throw new RequestInputResumeError("requestInput resume state does not match suspended request");
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function snapshotOptionalState(state) {
|
|
324
|
+
return state === undefined ? undefined : snapshotJson(state, "requestInput suspendedState");
|
|
325
|
+
}
|
|
326
|
+
function snapshotArray(items, label) {
|
|
327
|
+
if (items.length > MAX_REPLAY_ITEMS)
|
|
328
|
+
throw new Error("requestInput replay item limit exceeded");
|
|
329
|
+
let totalBytes = 0;
|
|
330
|
+
return items.map((item) => {
|
|
331
|
+
const snapshot = snapshotJson(item, label);
|
|
332
|
+
totalBytes += Buffer.byteLength(JSON.stringify(snapshot), "utf8");
|
|
333
|
+
if (totalBytes > MAX_REPLAY_BYTES) {
|
|
334
|
+
throw new Error("requestInput replay byte limit exceeded");
|
|
335
|
+
}
|
|
336
|
+
return snapshot;
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function snapshotJson(value, label) {
|
|
340
|
+
assertJsonSerializable(value, label, new WeakSet());
|
|
341
|
+
const text = JSON.stringify(value);
|
|
342
|
+
if (text === undefined)
|
|
343
|
+
throw new Error(`${label} must be JSON-serializable`);
|
|
344
|
+
return JSON.parse(text);
|
|
345
|
+
}
|
|
346
|
+
function assertJsonSerializable(value, label, seen) {
|
|
347
|
+
if (value === null)
|
|
348
|
+
return;
|
|
349
|
+
const type = typeof value;
|
|
350
|
+
if (type === "string" || type === "boolean")
|
|
351
|
+
return;
|
|
352
|
+
if (type === "number") {
|
|
353
|
+
if (!Number.isFinite(value))
|
|
354
|
+
throw new Error(`${label} must be JSON-serializable`);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (type === "undefined" || type === "function" || type === "symbol" || type === "bigint") {
|
|
358
|
+
throw new Error(`${label} must be JSON-serializable`);
|
|
359
|
+
}
|
|
360
|
+
const object = value;
|
|
361
|
+
if (seen.has(object))
|
|
362
|
+
throw new Error(`${label} must be JSON-serializable`);
|
|
363
|
+
const prototype = Object.getPrototypeOf(object);
|
|
364
|
+
if (prototype !== Object.prototype && prototype !== null && !Array.isArray(value)) {
|
|
365
|
+
throw new Error(`${label} must be JSON-serializable`);
|
|
366
|
+
}
|
|
367
|
+
seen.add(object);
|
|
368
|
+
if (Array.isArray(value)) {
|
|
369
|
+
for (let index = 0; index < value.length; index++) {
|
|
370
|
+
if (!(index in value))
|
|
371
|
+
throw new Error(`${label} must be JSON-serializable`);
|
|
372
|
+
assertJsonSerializable(value[index], label, seen);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
for (const key of Object.keys(value)) {
|
|
377
|
+
assertJsonSerializable(value[key], label, seen);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
seen.delete(object);
|
|
381
|
+
}
|
|
382
|
+
async function requestInputInteractively(ctx, metadata) {
|
|
383
|
+
ctx.stdout.write(`${metadata.prompt}\n> `);
|
|
384
|
+
const { readLineFromStream } = await import("./read_line.js");
|
|
385
|
+
const raw = await readLineFromStream(ctx.stdin, { timeoutMs: 0 });
|
|
386
|
+
let response;
|
|
387
|
+
try {
|
|
388
|
+
response = JSON.parse(String(raw ?? "").trim());
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
throw new Error("requestInput response must be valid JSON");
|
|
392
|
+
}
|
|
393
|
+
validateRequestInputResponse(metadata.responseSchema, response, "requestInput");
|
|
394
|
+
return snapshotJson(response, "requestInput response");
|
|
395
|
+
}
|
|
396
|
+
function isInteractive(stdin) {
|
|
397
|
+
return Boolean(stdin?.isTTY);
|
|
398
|
+
}
|
|
399
|
+
async function closeIterator(iterator, { suppressErrors }) {
|
|
400
|
+
if (typeof iterator.return !== "function")
|
|
401
|
+
return;
|
|
402
|
+
try {
|
|
403
|
+
await iterator.return();
|
|
404
|
+
}
|
|
405
|
+
catch (err) {
|
|
406
|
+
if (!suppressErrors)
|
|
407
|
+
throw err;
|
|
408
|
+
// Cleanup must not mask the original command error or suspension.
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function toAsyncIterator(input) {
|
|
412
|
+
if (typeof input[Symbol.asyncIterator] === "function") {
|
|
413
|
+
return input[Symbol.asyncIterator]();
|
|
414
|
+
}
|
|
415
|
+
if (typeof input[Symbol.iterator] === "function") {
|
|
416
|
+
const iterator = input[Symbol.iterator]();
|
|
417
|
+
return {
|
|
418
|
+
async next() {
|
|
419
|
+
return iterator.next();
|
|
420
|
+
},
|
|
421
|
+
async return() {
|
|
422
|
+
if (typeof iterator.return === "function")
|
|
423
|
+
iterator.return();
|
|
424
|
+
return { done: true, value: undefined };
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
throw new Error("input is not iterable");
|
|
429
|
+
}
|
|
430
|
+
//# sourceMappingURL=input_request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input_request.js","sourceRoot":"","sources":["../../src/input_request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAqDhD,MAAM,gBAAgB,GAAG,IAA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QAAQ,CAAC,KAAK,UAAU,EAAE,CAAC;QAC1D,MAAM,QAAQ,GAAI,KAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjE,OAAO;YACL,KAAK,CAAC,IAAI;gBACR,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;YACD,KAAK,CAAC,MAAM;gBACV,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU;oBAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC7D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;YAC1C,CAAC;SACF,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { encodeToken } from "./token.js";
|
|
3
3
|
import { cleanupApprovalIndexByStateKey, createApprovalIndex, deleteStateJson, readStateJson, writeStateJson, } from "./state/store.js";
|
|
4
4
|
import { compileCached } from "./validation.js";
|
|
5
|
+
import { validateCommandInputState } from "./input_request.js";
|
|
5
6
|
export function extractPipelineHalt(output) {
|
|
6
7
|
const halted = output.halted && output.items.length === 1
|
|
7
8
|
? output.items[0]
|
|
@@ -45,19 +46,24 @@ export async function finalizePipelineToolRun(params) {
|
|
|
45
46
|
requiresApproval: {
|
|
46
47
|
...approval,
|
|
47
48
|
resumeToken,
|
|
48
|
-
approvalId,
|
|
49
|
+
...(approvalId ? { approvalId } : null),
|
|
49
50
|
},
|
|
50
51
|
requiresInput: null,
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
if (inputRequest) {
|
|
55
|
+
const resumeMode = inputRequest.commandInput ? "same_stage" : "next_stage";
|
|
54
56
|
const nextStateKey = await savePipelineResumeState(params.env, {
|
|
55
57
|
pipeline: params.pipeline,
|
|
56
|
-
resumeAtIndex:
|
|
57
|
-
|
|
58
|
+
resumeAtIndex: resumeMode === "same_stage"
|
|
59
|
+
? (params.output.haltedAt?.index ?? -1)
|
|
60
|
+
: (params.output.haltedAt?.index ?? -1) + 1,
|
|
61
|
+
items: resumeMode === "same_stage" ? (inputRequest.items ?? []) : [],
|
|
58
62
|
haltType: "input_request",
|
|
63
|
+
resumeMode,
|
|
59
64
|
inputSchema: inputRequest.responseSchema,
|
|
60
65
|
prompt: inputRequest.prompt,
|
|
66
|
+
...(inputRequest.commandInput ? { commandInput: inputRequest.commandInput } : null),
|
|
61
67
|
createdAt: new Date().toISOString(),
|
|
62
68
|
});
|
|
63
69
|
if (params.previousStateKey) {
|
|
@@ -108,14 +114,39 @@ export async function loadPipelineResumeState(env, stateKey) {
|
|
|
108
114
|
const data = stored;
|
|
109
115
|
if (!Array.isArray(data.pipeline))
|
|
110
116
|
throw new Error("Invalid pipeline resume state");
|
|
111
|
-
|
|
117
|
+
validatePipelineShape(data.pipeline);
|
|
118
|
+
if (typeof data.resumeAtIndex !== "number" ||
|
|
119
|
+
!Number.isInteger(data.resumeAtIndex) ||
|
|
120
|
+
data.resumeAtIndex < 0 ||
|
|
121
|
+
data.resumeAtIndex > data.pipeline.length) {
|
|
112
122
|
throw new Error("Invalid pipeline resume state");
|
|
123
|
+
}
|
|
113
124
|
if (!Array.isArray(data.items))
|
|
114
125
|
throw new Error("Invalid pipeline resume state");
|
|
115
126
|
if (data.haltType !== undefined &&
|
|
116
127
|
!["approval_request", "input_request"].includes(data.haltType)) {
|
|
117
128
|
throw new Error("Invalid pipeline resume state");
|
|
118
129
|
}
|
|
130
|
+
if (data.resumeMode !== undefined && !["next_stage", "same_stage"].includes(data.resumeMode)) {
|
|
131
|
+
throw new Error("Invalid pipeline resume state");
|
|
132
|
+
}
|
|
133
|
+
if (data.haltType === "input_request") {
|
|
134
|
+
if (data.inputSchema === undefined || typeof data.prompt !== "string") {
|
|
135
|
+
throw new Error("Invalid pipeline resume state");
|
|
136
|
+
}
|
|
137
|
+
if (data.resumeMode === "same_stage") {
|
|
138
|
+
if (data.resumeAtIndex >= data.pipeline.length) {
|
|
139
|
+
throw new Error("Invalid pipeline resume state");
|
|
140
|
+
}
|
|
141
|
+
data.commandInput = validateCommandInputState(data.commandInput);
|
|
142
|
+
}
|
|
143
|
+
else if (data.commandInput !== undefined) {
|
|
144
|
+
throw new Error("Invalid pipeline resume state");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (data.resumeMode === "same_stage" || data.commandInput !== undefined) {
|
|
148
|
+
throw new Error("Invalid pipeline resume state");
|
|
149
|
+
}
|
|
119
150
|
return data;
|
|
120
151
|
}
|
|
121
152
|
export function validatePipelineInputResponse(schema, response) {
|
|
@@ -137,4 +168,19 @@ export function validatePipelineInputResponse(schema, response) {
|
|
|
137
168
|
const reason = first?.message ? ` ${first.message}` : "";
|
|
138
169
|
throw new Error(`pipeline input response failed schema validation at ${pathValue}:${reason}`);
|
|
139
170
|
}
|
|
171
|
+
function validatePipelineShape(pipeline) {
|
|
172
|
+
for (const stage of pipeline) {
|
|
173
|
+
if (!stage || typeof stage !== "object")
|
|
174
|
+
throw new Error("Invalid pipeline resume state");
|
|
175
|
+
const data = stage;
|
|
176
|
+
if (typeof data.name !== "string" || data.name.length === 0) {
|
|
177
|
+
throw new Error("Invalid pipeline resume state");
|
|
178
|
+
}
|
|
179
|
+
if (!data.args || typeof data.args !== "object" || Array.isArray(data.args)) {
|
|
180
|
+
throw new Error("Invalid pipeline resume state");
|
|
181
|
+
}
|
|
182
|
+
if (typeof data.raw !== "string")
|
|
183
|
+
throw new Error("Invalid pipeline resume state");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
140
186
|
//# sourceMappingURL=pipeline_resume_state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline_resume_state.js","sourceRoot":"","sources":["../../src/pipeline_resume_state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EA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