@blade-hq/agent-client 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -25
- package/dist/blade-client.d.ts +2 -14
- package/dist/index.d.ts +5 -2
- package/dist/index.js +212 -106
- package/dist/index.js.map +1 -1
- package/dist/resources/models.d.ts +15 -0
- package/dist/resources/sessions.d.ts +8 -1
- package/dist/session/agent-session.d.ts +10 -0
- package/dist/session/definition.d.ts +49 -0
- package/dist/shared/projection/helpers.d.ts +1 -1
- package/dist/types/rest.d.ts +378 -10
- package/dist/version.d.ts +4 -42
- package/node_modules/@ark/schema/LICENSE +7 -0
- package/node_modules/@ark/schema/README.md +18 -0
- package/node_modules/@ark/schema/out/config.d.ts +58 -0
- package/node_modules/@ark/schema/out/config.js +95 -0
- package/node_modules/@ark/schema/out/constraint.d.ts +67 -0
- package/node_modules/@ark/schema/out/constraint.js +136 -0
- package/node_modules/@ark/schema/out/generic.d.ts +73 -0
- package/node_modules/@ark/schema/out/generic.js +76 -0
- package/node_modules/@ark/schema/out/index.d.ts +47 -0
- package/node_modules/@ark/schema/out/index.js +47 -0
- package/node_modules/@ark/schema/out/intrinsic.d.ts +24 -0
- package/node_modules/@ark/schema/out/intrinsic.js +56 -0
- package/node_modules/@ark/schema/out/kinds.d.ts +73 -0
- package/node_modules/@ark/schema/out/kinds.js +71 -0
- package/node_modules/@ark/schema/out/module.d.ts +24 -0
- package/node_modules/@ark/schema/out/module.js +15 -0
- package/node_modules/@ark/schema/out/node.d.ts +154 -0
- package/node_modules/@ark/schema/out/node.js +438 -0
- package/node_modules/@ark/schema/out/parse.d.ts +52 -0
- package/node_modules/@ark/schema/out/parse.js +215 -0
- package/node_modules/@ark/schema/out/predicate.d.ts +52 -0
- package/node_modules/@ark/schema/out/predicate.js +63 -0
- package/node_modules/@ark/schema/out/refinements/after.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/after.js +35 -0
- package/node_modules/@ark/schema/out/refinements/before.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/before.js +41 -0
- package/node_modules/@ark/schema/out/refinements/divisor.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/divisor.js +58 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.d.ts +49 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.js +55 -0
- package/node_modules/@ark/schema/out/refinements/kinds.d.ts +34 -0
- package/node_modules/@ark/schema/out/refinements/kinds.js +25 -0
- package/node_modules/@ark/schema/out/refinements/max.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/max.js +45 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.js +49 -0
- package/node_modules/@ark/schema/out/refinements/min.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/min.js +39 -0
- package/node_modules/@ark/schema/out/refinements/minLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/minLength.js +47 -0
- package/node_modules/@ark/schema/out/refinements/pattern.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/pattern.js +52 -0
- package/node_modules/@ark/schema/out/refinements/range.d.ts +106 -0
- package/node_modules/@ark/schema/out/refinements/range.js +103 -0
- package/node_modules/@ark/schema/out/roots/alias.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/alias.js +115 -0
- package/node_modules/@ark/schema/out/roots/basis.d.ts +12 -0
- package/node_modules/@ark/schema/out/roots/basis.js +26 -0
- package/node_modules/@ark/schema/out/roots/domain.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/domain.js +72 -0
- package/node_modules/@ark/schema/out/roots/intersection.d.ts +98 -0
- package/node_modules/@ark/schema/out/roots/intersection.js +292 -0
- package/node_modules/@ark/schema/out/roots/morph.d.ts +62 -0
- package/node_modules/@ark/schema/out/roots/morph.js +159 -0
- package/node_modules/@ark/schema/out/roots/proto.d.ts +53 -0
- package/node_modules/@ark/schema/out/roots/proto.js +101 -0
- package/node_modules/@ark/schema/out/roots/root.d.ts +145 -0
- package/node_modules/@ark/schema/out/roots/root.js +455 -0
- package/node_modules/@ark/schema/out/roots/union.d.ts +99 -0
- package/node_modules/@ark/schema/out/roots/union.js +718 -0
- package/node_modules/@ark/schema/out/roots/unit.d.ts +41 -0
- package/node_modules/@ark/schema/out/roots/unit.js +86 -0
- package/node_modules/@ark/schema/out/roots/utils.d.ts +3 -0
- package/node_modules/@ark/schema/out/roots/utils.js +6 -0
- package/node_modules/@ark/schema/out/scope.d.ts +158 -0
- package/node_modules/@ark/schema/out/scope.js +481 -0
- package/node_modules/@ark/schema/out/shared/compile.d.ts +62 -0
- package/node_modules/@ark/schema/out/shared/compile.js +145 -0
- package/node_modules/@ark/schema/out/shared/declare.d.ts +80 -0
- package/node_modules/@ark/schema/out/shared/declare.js +1 -0
- package/node_modules/@ark/schema/out/shared/disjoint.d.ts +41 -0
- package/node_modules/@ark/schema/out/shared/disjoint.js +65 -0
- package/node_modules/@ark/schema/out/shared/errors.d.ts +145 -0
- package/node_modules/@ark/schema/out/shared/errors.js +252 -0
- package/node_modules/@ark/schema/out/shared/implement.d.ts +151 -0
- package/node_modules/@ark/schema/out/shared/implement.js +98 -0
- package/node_modules/@ark/schema/out/shared/intersections.d.ts +10 -0
- package/node_modules/@ark/schema/out/shared/intersections.js +132 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.d.ts +93 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.js +1 -0
- package/node_modules/@ark/schema/out/shared/registry.d.ts +7 -0
- package/node_modules/@ark/schema/out/shared/registry.js +10 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.d.ts +122 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.js +2 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.d.ts +139 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.js +40 -0
- package/node_modules/@ark/schema/out/shared/traversal.d.ts +117 -0
- package/node_modules/@ark/schema/out/shared/traversal.js +226 -0
- package/node_modules/@ark/schema/out/shared/utils.d.ts +34 -0
- package/node_modules/@ark/schema/out/shared/utils.js +8 -0
- package/node_modules/@ark/schema/out/structure/index.d.ts +46 -0
- package/node_modules/@ark/schema/out/structure/index.js +89 -0
- package/node_modules/@ark/schema/out/structure/optional.d.ts +49 -0
- package/node_modules/@ark/schema/out/structure/optional.js +127 -0
- package/node_modules/@ark/schema/out/structure/prop.d.ts +45 -0
- package/node_modules/@ark/schema/out/structure/prop.js +85 -0
- package/node_modules/@ark/schema/out/structure/required.d.ts +39 -0
- package/node_modules/@ark/schema/out/structure/required.js +38 -0
- package/node_modules/@ark/schema/out/structure/sequence.d.ts +110 -0
- package/node_modules/@ark/schema/out/structure/sequence.js +521 -0
- package/node_modules/@ark/schema/out/structure/shared.d.ts +4 -0
- package/node_modules/@ark/schema/out/structure/shared.js +4 -0
- package/node_modules/@ark/schema/out/structure/structure.d.ts +113 -0
- package/node_modules/@ark/schema/out/structure/structure.js +747 -0
- package/node_modules/@ark/schema/package.json +51 -0
- package/node_modules/@ark/util/LICENSE +7 -0
- package/node_modules/@ark/util/out/arrays.d.ts +166 -0
- package/node_modules/@ark/util/out/arrays.js +147 -0
- package/node_modules/@ark/util/out/clone.d.ts +4 -0
- package/node_modules/@ark/util/out/clone.js +33 -0
- package/node_modules/@ark/util/out/describe.d.ts +25 -0
- package/node_modules/@ark/util/out/describe.js +1 -0
- package/node_modules/@ark/util/out/domain.d.ts +48 -0
- package/node_modules/@ark/util/out/domain.js +25 -0
- package/node_modules/@ark/util/out/errors.d.ts +29 -0
- package/node_modules/@ark/util/out/errors.js +17 -0
- package/node_modules/@ark/util/out/flatMorph.d.ts +41 -0
- package/node_modules/@ark/util/out/flatMorph.js +24 -0
- package/node_modules/@ark/util/out/functions.d.ts +33 -0
- package/node_modules/@ark/util/out/functions.js +53 -0
- package/node_modules/@ark/util/out/generics.d.ts +59 -0
- package/node_modules/@ark/util/out/generics.js +5 -0
- package/node_modules/@ark/util/out/get.d.ts +9 -0
- package/node_modules/@ark/util/out/get.js +7 -0
- package/node_modules/@ark/util/out/hkt.d.ts +27 -0
- package/node_modules/@ark/util/out/hkt.js +5 -0
- package/node_modules/@ark/util/out/index.d.ts +24 -0
- package/node_modules/@ark/util/out/index.js +24 -0
- package/node_modules/@ark/util/out/intersections.d.ts +50 -0
- package/node_modules/@ark/util/out/intersections.js +1 -0
- package/node_modules/@ark/util/out/isomorphic.d.ts +5 -0
- package/node_modules/@ark/util/out/isomorphic.js +19 -0
- package/node_modules/@ark/util/out/keys.d.ts +18 -0
- package/node_modules/@ark/util/out/keys.js +1 -0
- package/node_modules/@ark/util/out/lazily.d.ts +1 -0
- package/node_modules/@ark/util/out/lazily.js +16 -0
- package/node_modules/@ark/util/out/numbers.d.ts +72 -0
- package/node_modules/@ark/util/out/numbers.js +138 -0
- package/node_modules/@ark/util/out/objectKinds.d.ts +205 -0
- package/node_modules/@ark/util/out/objectKinds.js +150 -0
- package/node_modules/@ark/util/out/path.d.ts +22 -0
- package/node_modules/@ark/util/out/path.js +65 -0
- package/node_modules/@ark/util/out/primitive.d.ts +16 -0
- package/node_modules/@ark/util/out/primitive.js +3 -0
- package/node_modules/@ark/util/out/records.d.ts +183 -0
- package/node_modules/@ark/util/out/records.js +63 -0
- package/node_modules/@ark/util/out/registry.d.ts +21 -0
- package/node_modules/@ark/util/out/registry.js +49 -0
- package/node_modules/@ark/util/out/scanner.d.ts +44 -0
- package/node_modules/@ark/util/out/scanner.js +87 -0
- package/node_modules/@ark/util/out/serialize.d.ts +34 -0
- package/node_modules/@ark/util/out/serialize.js +150 -0
- package/node_modules/@ark/util/out/strings.d.ts +33 -0
- package/node_modules/@ark/util/out/strings.js +59 -0
- package/node_modules/@ark/util/out/traits.d.ts +89 -0
- package/node_modules/@ark/util/out/traits.js +75 -0
- package/node_modules/@ark/util/out/unionToTuple.d.ts +14 -0
- package/node_modules/@ark/util/out/unionToTuple.js +1 -0
- package/node_modules/@ark/util/package.json +39 -0
- package/node_modules/@ark/util/tsconfig.base.json +18 -0
- package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
- package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/package.json +28 -0
- package/node_modules/arkregex/LICENSE +7 -0
- package/node_modules/arkregex/README.md +61 -0
- package/node_modules/arkregex/out/charset.d.ts +15 -0
- package/node_modules/arkregex/out/charset.js +1 -0
- package/node_modules/arkregex/out/escape.d.ts +29 -0
- package/node_modules/arkregex/out/escape.js +10 -0
- package/node_modules/arkregex/out/execArray.d.ts +23 -0
- package/node_modules/arkregex/out/execArray.js +1 -0
- package/node_modules/arkregex/out/group.d.ts +33 -0
- package/node_modules/arkregex/out/group.js +6 -0
- package/node_modules/arkregex/out/index.d.ts +1 -0
- package/node_modules/arkregex/out/index.js +1 -0
- package/node_modules/arkregex/out/parse.d.ts +10 -0
- package/node_modules/arkregex/out/parse.js +1 -0
- package/node_modules/arkregex/out/quantify.d.ts +43 -0
- package/node_modules/arkregex/out/quantify.js +2 -0
- package/node_modules/arkregex/out/regex.d.ts +38 -0
- package/node_modules/arkregex/out/regex.js +2 -0
- package/node_modules/arkregex/out/state.d.ts +359 -0
- package/node_modules/arkregex/out/state.js +2 -0
- package/node_modules/arkregex/package.json +42 -0
- package/node_modules/arktype/LICENSE +7 -0
- package/node_modules/arktype/README.md +157 -0
- package/node_modules/arktype/out/attributes.d.ts +104 -0
- package/node_modules/arktype/out/attributes.js +3 -0
- package/node_modules/arktype/out/config.d.ts +35 -0
- package/node_modules/arktype/out/config.js +3 -0
- package/node_modules/arktype/out/declare.d.ts +35 -0
- package/node_modules/arktype/out/declare.js +1 -0
- package/node_modules/arktype/out/fn.d.ts +61 -0
- package/node_modules/arktype/out/fn.js +54 -0
- package/node_modules/arktype/out/generic.d.ts +118 -0
- package/node_modules/arktype/out/generic.js +37 -0
- package/node_modules/arktype/out/index.d.ts +12 -0
- package/node_modules/arktype/out/index.js +9 -0
- package/node_modules/arktype/out/keywords/Array.d.ts +20 -0
- package/node_modules/arktype/out/keywords/Array.js +21 -0
- package/node_modules/arktype/out/keywords/FormData.d.ts +15 -0
- package/node_modules/arktype/out/keywords/FormData.js +40 -0
- package/node_modules/arktype/out/keywords/TypedArray.d.ts +19 -0
- package/node_modules/arktype/out/keywords/TypedArray.js +16 -0
- package/node_modules/arktype/out/keywords/builtins.d.ts +18 -0
- package/node_modules/arktype/out/keywords/builtins.js +11 -0
- package/node_modules/arktype/out/keywords/constructors.d.ts +31 -0
- package/node_modules/arktype/out/keywords/constructors.js +16 -0
- package/node_modules/arktype/out/keywords/keywords.d.ts +70 -0
- package/node_modules/arktype/out/keywords/keywords.js +48 -0
- package/node_modules/arktype/out/keywords/number.d.ts +23 -0
- package/node_modules/arktype/out/keywords/number.js +49 -0
- package/node_modules/arktype/out/keywords/string.d.ts +334 -0
- package/node_modules/arktype/out/keywords/string.js +463 -0
- package/node_modules/arktype/out/keywords/ts.d.ts +108 -0
- package/node_modules/arktype/out/keywords/ts.js +82 -0
- package/node_modules/arktype/out/match.d.ts +152 -0
- package/node_modules/arktype/out/match.js +95 -0
- package/node_modules/arktype/out/module.d.ts +22 -0
- package/node_modules/arktype/out/module.js +3 -0
- package/node_modules/arktype/out/nary.d.ts +473 -0
- package/node_modules/arktype/out/nary.js +1 -0
- package/node_modules/arktype/out/parser/ast/bounds.d.ts +18 -0
- package/node_modules/arktype/out/parser/ast/bounds.js +1 -0
- package/node_modules/arktype/out/parser/ast/default.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/default.js +1 -0
- package/node_modules/arktype/out/parser/ast/divisor.d.ts +9 -0
- package/node_modules/arktype/out/parser/ast/divisor.js +1 -0
- package/node_modules/arktype/out/parser/ast/generic.d.ts +17 -0
- package/node_modules/arktype/out/parser/ast/generic.js +1 -0
- package/node_modules/arktype/out/parser/ast/infer.d.ts +25 -0
- package/node_modules/arktype/out/parser/ast/infer.js +1 -0
- package/node_modules/arktype/out/parser/ast/keyof.d.ts +7 -0
- package/node_modules/arktype/out/parser/ast/keyof.js +1 -0
- package/node_modules/arktype/out/parser/ast/utils.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/utils.js +1 -0
- package/node_modules/arktype/out/parser/ast/validate.d.ts +30 -0
- package/node_modules/arktype/out/parser/ast/validate.js +3 -0
- package/node_modules/arktype/out/parser/definition.d.ts +30 -0
- package/node_modules/arktype/out/parser/definition.js +74 -0
- package/node_modules/arktype/out/parser/objectLiteral.d.ts +70 -0
- package/node_modules/arktype/out/parser/objectLiteral.js +113 -0
- package/node_modules/arktype/out/parser/property.d.ts +34 -0
- package/node_modules/arktype/out/parser/property.js +16 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.d.ts +42 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.js +153 -0
- package/node_modules/arktype/out/parser/reduce/shared.d.ts +39 -0
- package/node_modules/arktype/out/parser/reduce/shared.js +25 -0
- package/node_modules/arktype/out/parser/reduce/static.d.ts +186 -0
- package/node_modules/arktype/out/parser/reduce/static.js +1 -0
- package/node_modules/arktype/out/parser/shift/operand/date.d.ts +11 -0
- package/node_modules/arktype/out/parser/shift/operand/date.js +23 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.d.ts +57 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.js +78 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.d.ts +27 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.d.ts +43 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.js +59 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.js +91 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.d.ts +7 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.js +6 -0
- package/node_modules/arktype/out/parser/shift/operator/default.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/default.js +15 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.js +13 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.d.ts +14 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.js +28 -0
- package/node_modules/arktype/out/parser/shift/tokens.d.ts +33 -0
- package/node_modules/arktype/out/parser/shift/tokens.js +37 -0
- package/node_modules/arktype/out/parser/string.d.ts +30 -0
- package/node_modules/arktype/out/parser/string.js +42 -0
- package/node_modules/arktype/out/parser/tupleExpressions.d.ts +79 -0
- package/node_modules/arktype/out/parser/tupleExpressions.js +75 -0
- package/node_modules/arktype/out/parser/tupleLiteral.d.ts +95 -0
- package/node_modules/arktype/out/parser/tupleLiteral.js +128 -0
- package/node_modules/arktype/out/scope.d.ts +158 -0
- package/node_modules/arktype/out/scope.js +106 -0
- package/node_modules/arktype/out/type.d.ts +144 -0
- package/node_modules/arktype/out/type.js +55 -0
- package/node_modules/arktype/out/variants/array.d.ts +12 -0
- package/node_modules/arktype/out/variants/array.js +1 -0
- package/node_modules/arktype/out/variants/base.d.ts +542 -0
- package/node_modules/arktype/out/variants/base.js +1 -0
- package/node_modules/arktype/out/variants/date.d.ts +10 -0
- package/node_modules/arktype/out/variants/date.js +1 -0
- package/node_modules/arktype/out/variants/instantiate.d.ts +12 -0
- package/node_modules/arktype/out/variants/instantiate.js +1 -0
- package/node_modules/arktype/out/variants/number.d.ts +11 -0
- package/node_modules/arktype/out/variants/number.js +1 -0
- package/node_modules/arktype/out/variants/object.d.ts +107 -0
- package/node_modules/arktype/out/variants/object.js +1 -0
- package/node_modules/arktype/out/variants/string.d.ts +15 -0
- package/node_modules/arktype/out/variants/string.js +1 -0
- package/node_modules/arktype/package.json +57 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/engine.io-client/LICENSE +22 -0
- package/node_modules/engine.io-client/README.md +331 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
- package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/index.js +32 -0
- package/node_modules/engine.io-client/build/cjs/package.json +10 -0
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
- package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/cjs/util.js +65 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/index.js +15 -0
- package/node_modules/engine.io-client/build/esm/package.json +10 -0
- package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm/socket.js +727 -0
- package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm/transport.js +142 -0
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
- package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm/util.js +59 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
- package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.js +3064 -0
- package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
- package/node_modules/engine.io-client/package.json +95 -0
- package/node_modules/engine.io-parser/LICENSE +22 -0
- package/node_modules/engine.io-parser/Readme.md +158 -0
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
- package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
- package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/esm/index.js +156 -0
- package/node_modules/engine.io-parser/build/esm/package.json +8 -0
- package/node_modules/engine.io-parser/package.json +46 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/socket.io-client/LICENSE +21 -0
- package/node_modules/socket.io-client/README.md +29 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
- package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/cjs/index.js +76 -0
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
- package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/on.js +9 -0
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
- package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/cjs/url.js +69 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm/index.js +58 -0
- package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm/manager.js +367 -0
- package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/on.js +6 -0
- package/node_modules/socket.io-client/build/esm/package.json +5 -0
- package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm/socket.js +880 -0
- package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm/url.js +59 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
- package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
- package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
- package/node_modules/socket.io-client/package.json +101 -0
- package/node_modules/socket.io-parser/LICENSE +20 -0
- package/node_modules/socket.io-parser/Readme.md +81 -0
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/cjs/binary.js +87 -0
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/cjs/index.js +359 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
- package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm/index.js +348 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.js +353 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
- package/node_modules/socket.io-parser/package.json +44 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +13 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +18 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +550 -0
- package/node_modules/ws/lib/websocket.js +1388 -0
- package/node_modules/ws/package.json +69 -0
- package/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
- package/node_modules/xmlhttprequest-ssl/README.md +67 -0
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
- package/node_modules/xmlhttprequest-ssl/package.json +40 -0
- package/package.json +34 -4
- package/public-api.md +85 -23
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Blade Agent 的框架无关客户端。浏览器和 Node.js 都能用;用 Vue
|
|
|
6
6
|
|
|
7
7
|
1. **实时会话**(`AgentSession`):把 Socket.IO 协议、历史加载、流式合流、断线重连全部封装掉,你只面对"状态快照 + 动作 + 事件"。
|
|
8
8
|
2. **登录**:`client.auth.login()` 弹窗授权,用户点一下"许可授权"就拿到访问令牌,不用手工复制粘贴。
|
|
9
|
-
3. **REST
|
|
9
|
+
3. **REST**:类型化会话和模型目录(`client.sessions.*`、`client.models.list()`)。其他长尾接口对照 Swagger 用原生 `fetch` + `client.token` 调用。
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install @blade-hq/agent-client
|
|
@@ -91,6 +91,30 @@ const configured = await client.sessions.create({ intent: "数据分析", model:
|
|
|
91
91
|
|
|
92
92
|
两者都返回 [`AgentSession`](#agentsession)。
|
|
93
93
|
|
|
94
|
+
### 声明完整会话
|
|
95
|
+
|
|
96
|
+
自定义 Solution、Skill 和模型无需手写上传步骤:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const chat = await client.sessions.create({
|
|
100
|
+
solution: {
|
|
101
|
+
role: "resume-writer",
|
|
102
|
+
files: [
|
|
103
|
+
{ path: "solution.yaml", content: solutionYaml },
|
|
104
|
+
{ path: "roles/resume-writer/role.yaml", content: roleYaml },
|
|
105
|
+
{ path: "roles/resume-writer/AGENTS.md.j2", content: rolePrompt },
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
skills: [{
|
|
109
|
+
name: "my/resume",
|
|
110
|
+
files: [{ path: "SKILL.md", content: "# 简历制作" }],
|
|
111
|
+
}],
|
|
112
|
+
config: { model: "qwen3.5-122b-int4" },
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Solution 和 Skill 都声明为 `{ path, content }[]` 文本文件;SDK 负责准备资源、创建会话和安装 Skill,成功返回时 `chat` 已可使用。已有 Solution 改传 `solution: { id, role }`。模型值是 Server 模型目录中的 ID,LLM 地址与密钥应由 Server 管理。
|
|
117
|
+
|
|
94
118
|
> **`sessionId` 从哪来?** 三种,按需选:
|
|
95
119
|
> 1. **不用管它** —— 首次接入最省事:`client.sessions.create()` 直接建一个新会话,用不着 ID。React 的 `<ChatView />` 不传 `sessionId` 也一样。
|
|
96
120
|
> 2. **自己建、自己存**:`const { session_id } = await client.sessions.createSessionWithRequest({ intent: "季度报表分析" })`。把返回的 `session_id`(后端是蛇形命名)存进你的数据库或 URL,用户下次进来传给 `connect(sessionId)`(前端参数是驼峰),就能接着上次的对话。
|
|
@@ -116,6 +140,21 @@ await client.sessions.deleteFile(id, "notes.md")
|
|
|
116
140
|
client.buildAuthedUrl(`/api/sessions/${id}/files/report.pdf`) // 带鉴权的下载/预览地址
|
|
117
141
|
```
|
|
118
142
|
|
|
143
|
+
连接后的 `AgentSession` 提供最常用的短写法:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
await chat.listDir("输出")
|
|
147
|
+
await chat.countFiles() // 递归统计,不含目录
|
|
148
|
+
await chat.downloadFile("输出/简历.md", "简历.md") // 浏览器下载
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 模型目录
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
const { default: defaultModel, models } = await client.models.list()
|
|
155
|
+
// models: Array<{ id, label }>
|
|
156
|
+
```
|
|
157
|
+
|
|
119
158
|
## AgentSession
|
|
120
159
|
|
|
121
160
|
一个会话的实时状态机。**状态归属实例**:同一页面建多个会话互不干扰。
|
|
@@ -254,30 +293,13 @@ PATCH / query / FormData / AbortSignal 等完整 HTTP 语义(否则不够用
|
|
|
254
293
|
await client.headless.run("统计上月订单量", { schema })
|
|
255
294
|
```
|
|
256
295
|
|
|
257
|
-
##
|
|
258
|
-
|
|
259
|
-
本 SDK 与 Server 是配套的:`@blade-hq/agent-client` 2.x 需要 Server 1.1.1 及以上。
|
|
260
|
-
|
|
261
|
-
SDK 在首次建立会话前会查询 `GET /api/version`。版本不匹配时抛出
|
|
262
|
-
`VersionMismatchError`,报错文案里写清楚双方版本号和该升级哪一端,
|
|
263
|
-
而不是让你对着一个莫名其妙的运行时异常发呆:
|
|
264
|
-
|
|
265
|
-
```ts
|
|
266
|
-
import { VersionMismatchError } from "@blade-hq/agent-client"
|
|
267
|
-
|
|
268
|
-
try {
|
|
269
|
-
const chat = await client.sessions.create()
|
|
270
|
-
} catch (error) {
|
|
271
|
-
if (error instanceof VersionMismatchError) {
|
|
272
|
-
console.error(error.message) // 含双方版本号与建议动作
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
```
|
|
296
|
+
## 版本
|
|
276
297
|
|
|
277
|
-
|
|
278
|
-
|
|
298
|
+
Git Release Tag 是唯一版本来源:发布 `v1.2.0` 时,镜像和两个 NPM 包均为
|
|
299
|
+
`1.2.0`,SDK 在 Socket.IO 握手中也声明 `1.2.0`。应用代码不需要处理版本。
|
|
279
300
|
|
|
280
|
-
|
|
301
|
+
只有一个兼容性断点:Server `1.1.1` 及以上要求
|
|
302
|
+
`@blade-hq/agent-client` `1.1.1` 及以上;未声明 SDK 身份或版本的旧客户端也会被拒绝。
|
|
281
303
|
|
|
282
304
|
## 自己渲染消息
|
|
283
305
|
|
|
@@ -331,7 +353,6 @@ function Message({ message }: { message: ChatMessage }) {
|
|
|
331
353
|
| login() 报"弹窗被拦截" | 浏览器设置里允许该站点弹窗,或改用 PAT |
|
|
332
354
|
| login() 报 403 来源未允许 | 让管理员把你的页面 origin 加进后端 `BLADE_SDK_AUTH_ALLOWED_ORIGINS` |
|
|
333
355
|
| socket 一直 connecting | 检查 baseUrl 是否可达、跨域时后端是否允许你的 origin |
|
|
334
|
-
| VersionMismatchError | SDK 与 Server 版本不配套,按报错提示升级其中一端,见「版本握手」 |
|
|
335
356
|
| onCommand 收不到指令 | 确认技能工具返回值里写了 `_meta.bridge`,action 拼写与注册一致 |
|
|
336
357
|
|
|
337
358
|
更多接入教程(Vue 完整示例、GIS 协作闭环、AI 助手接入指南)见 [public-skills 文档站](https://github.com/blade-hq/public-skills)。
|
|
@@ -341,7 +362,9 @@ function Message({ message }: { message: ChatMessage }) {
|
|
|
341
362
|
完整签名见 [public-api.md](./public-api.md)(由 `scripts/public-api-report.mjs` 生成并在 CI 校验)。
|
|
342
363
|
|
|
343
364
|
- **客户端与登录**:`BladeClientOptions`、`LoginOptions`、`LoginResult`、`TokenStorageMode`、`UploadProgress`、`BladeApiError`、`AuthResource`、`ProvidersResponse`、`UserInfo`
|
|
344
|
-
-
|
|
365
|
+
- **SDK 身份**:`SDK_NAME`、`SDK_VERSION`
|
|
366
|
+
- **声明式会话**:`SessionDefinition`、`SolutionDefinition`、`SkillDefinition`、`SessionConfig`、`TextFile`、`SessionSetupError`、`SessionSetupStage`
|
|
367
|
+
- **模型目录**:`ModelsResource`、`ModelCatalog`、`ModelOption`
|
|
345
368
|
- **会话资源(REST)**:`SessionsResource`、`CreateSessionRequest`、`PaginatedSessionsResult`、`SessionHistory`、`SessionContextStats`、`ShareLinkResult`、`FileEntry`、`UploadFileEntry`、`UploadFilesOptions`、`SessionProfile`、`SessionDetail`、`SessionInfo`、`SessionStatus`、`SessionPortMapping`、`ModeId`、`TemplateId`、`PrimarySkillSnapshot`、`PrimarySkillParallelMode`
|
|
346
369
|
- **会话状态机**:`SessionHub`、`SessionState`、`SendOptions`、`ConnectionStatus`、`AskUserAnswerData`、`AgentLoopInfo`、`ActiveCompactionState`、`createInitialSessionState`、`AgentSessionEventName`
|
|
347
370
|
- **页面协作**:`EmbeddedChat`、`EmbeddedChatOptions`、`CommandHandler`、`CommandEnvelope`、`InboundAction`、`InboundEnvelope`、`isCommandEnvelope`、`isInboundEnvelope`
|
package/dist/blade-client.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type LoginOptions, type LoginResult, type TokenStorageMode } from "./au
|
|
|
2
2
|
import { type BladeFetchInit, type HttpMethod } from "./rest";
|
|
3
3
|
import { AuthResource } from "./resources/auth";
|
|
4
4
|
import { HeadlessResource } from "./resources/headless";
|
|
5
|
+
import { ModelsResource } from "./resources/models";
|
|
5
6
|
import { SessionsResource } from "./resources/sessions";
|
|
6
7
|
import { SessionHub } from "./session/hub";
|
|
7
8
|
import { type TypedSocket } from "./socket";
|
|
@@ -32,11 +33,10 @@ export declare class BladeClient {
|
|
|
32
33
|
readonly options: BladeClientOptions;
|
|
33
34
|
readonly auth: AuthResource;
|
|
34
35
|
readonly headless: HeadlessResource;
|
|
36
|
+
readonly models: ModelsResource;
|
|
35
37
|
readonly sessions: SessionsResource;
|
|
36
38
|
/** 实时会话中枢:client.sessions.connect() 内部使用,一般不直接访问。 */
|
|
37
39
|
readonly hub: SessionHub;
|
|
38
|
-
/** 版本握手结果缓存:每个 client 实例只探测一次,不逐请求重复。 */
|
|
39
|
-
private versionCheck;
|
|
40
40
|
constructor(options: BladeClientOptions);
|
|
41
41
|
/**
|
|
42
42
|
* 弹窗授权登录:用户在弹出的授权页点击"许可授权"后自动取得 PAT,
|
|
@@ -64,18 +64,6 @@ export declare class BladeClient {
|
|
|
64
64
|
* 安全约束:该令牌只应发往 baseUrl 同源接口,不要附加到第三方域名的请求上。
|
|
65
65
|
*/
|
|
66
66
|
get token(): string | null;
|
|
67
|
-
/**
|
|
68
|
-
* 版本握手:首次连接前查询 Server 版本,不匹配则抛 VersionMismatchError。
|
|
69
|
-
* 结果缓存在实例上,失败的探测不缓存以便重试。
|
|
70
|
-
*/
|
|
71
|
-
ensureVersionCompatible(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* 读取 /api/version。接口存在但 404/响应不合法 → null(按旧 Server 处理);
|
|
74
|
-
* 网络层不可达(后端没启动、端口不通、代理配错)→ 抛连接错误。
|
|
75
|
-
* 两者必须区分:把「后端没起」误报成「版本不匹配,请改用 agent-kit」
|
|
76
|
-
* 会把开发者引向完全错误的排查方向。
|
|
77
|
-
*/
|
|
78
|
-
private fetchServerVersion;
|
|
79
67
|
setBaseUrl(baseUrl: string): void;
|
|
80
68
|
/** 底层 Socket.IO 实例因后端地址变化而被替换时通知高级集成层。 */
|
|
81
69
|
onSocketReplaced(listener: () => void): () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ export { BladeClient } from "./blade-client";
|
|
|
2
2
|
export type { BladeClientOptions, UploadProgress } from "./blade-client";
|
|
3
3
|
export { BladeApiError } from "./rest";
|
|
4
4
|
export type { LoginOptions, LoginResult, TokenStorageMode } from "./auth-login";
|
|
5
|
-
export {
|
|
6
|
-
export type { ServerVersionInfo } from "./version";
|
|
5
|
+
export { SDK_NAME, SDK_VERSION } from "./version";
|
|
7
6
|
export { AgentSession } from "./session/agent-session";
|
|
8
7
|
export type { SendOptions } from "./session/agent-session";
|
|
9
8
|
export { SessionHub } from "./session/hub";
|
|
10
9
|
export type { AgentSessionEvents, AgentSessionEventName } from "./session/events";
|
|
10
|
+
export { SessionSetupError } from "./session/definition";
|
|
11
|
+
export type { SessionConfig, SessionDefinition, SessionSetupStage, SkillDefinition, TextFile, SolutionDefinition, } from "./session/definition";
|
|
11
12
|
export { createInitialSessionState } from "./session/state";
|
|
12
13
|
export type { AskUserAnswerData, AgentLoopInfo, ActiveCompactionState, ConnectionStatus, SessionState, } from "./session/state";
|
|
13
14
|
export { connectEmbedded } from "./commands/embedded";
|
|
@@ -17,6 +18,8 @@ export type { CommandEnvelope, InboundAction, InboundEnvelope } from "./commands
|
|
|
17
18
|
export { isCommandEnvelope, isInboundEnvelope } from "./commands/protocol";
|
|
18
19
|
export type { AuthResource, ProvidersResponse, UserInfo } from "./resources/auth";
|
|
19
20
|
export type { HeadlessResource } from "./resources/headless";
|
|
21
|
+
export { ModelsResource } from "./resources/models";
|
|
22
|
+
export type { ModelCatalog, ModelOption } from "./resources/models";
|
|
20
23
|
export type { SessionsResource } from "./resources/sessions";
|
|
21
24
|
export type { CreateSessionRequest, FileEntry, PaginatedSessionsResult, SessionContextStats, SessionHistory, ShareLinkResult, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
|
|
22
25
|
export type { ArchivedFileInfo, ArchivedToolCallInfo, ChatMessage, CompactionInfo, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolBridgeContent, ToolCallInfo, } from "./schemas/message";
|
package/dist/index.js
CHANGED
|
@@ -380,6 +380,31 @@ function ensureSocketConnected(socket, timeoutMs, detail) {
|
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
// src/resources/models.ts
|
|
384
|
+
var ModelsResource = class {
|
|
385
|
+
constructor(client) {
|
|
386
|
+
this.client = client;
|
|
387
|
+
}
|
|
388
|
+
client;
|
|
389
|
+
list() {
|
|
390
|
+
return this.client.json("GET", "/api/config/models");
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// src/session/definition.ts
|
|
395
|
+
var SessionSetupError = class extends Error {
|
|
396
|
+
constructor(message, stage, sessionId, options) {
|
|
397
|
+
super(message);
|
|
398
|
+
this.stage = stage;
|
|
399
|
+
this.sessionId = sessionId;
|
|
400
|
+
this.cause = options?.cause;
|
|
401
|
+
}
|
|
402
|
+
stage;
|
|
403
|
+
sessionId;
|
|
404
|
+
name = "SessionSetupError";
|
|
405
|
+
cause;
|
|
406
|
+
};
|
|
407
|
+
|
|
383
408
|
// src/shared/projection/helpers.ts
|
|
384
409
|
function upsertToolCall(state, toolCallId, toolName, displayName, args) {
|
|
385
410
|
if (!toolCallId) return;
|
|
@@ -447,7 +472,7 @@ function applyToolResult(state, toolCallId, result, status, durationMs, sourceLo
|
|
|
447
472
|
}
|
|
448
473
|
upsertToolResultBlock(state, toolCallId, finalResult, toolName, displayName);
|
|
449
474
|
}
|
|
450
|
-
function appendToolResultDelta(state, toolCallId, delta) {
|
|
475
|
+
function appendToolResultDelta(state, toolCallId, delta, reset = false) {
|
|
451
476
|
if (!toolCallId || !delta) return;
|
|
452
477
|
let toolName = "";
|
|
453
478
|
let displayName = "";
|
|
@@ -457,13 +482,13 @@ function appendToolResultDelta(state, toolCallId, delta) {
|
|
|
457
482
|
if (tc.id !== toolCallId) continue;
|
|
458
483
|
toolName = tc.tool_name;
|
|
459
484
|
displayName = tc.display_name;
|
|
460
|
-
if (typeof tc.result === "string") currentResult = tc.result;
|
|
485
|
+
if (!reset && typeof tc.result === "string") currentResult = tc.result;
|
|
461
486
|
state.toolCalls[i] = { ...tc, result: currentResult + delta };
|
|
462
487
|
break;
|
|
463
488
|
}
|
|
464
489
|
for (const block of state.blocks) {
|
|
465
490
|
if (block.type !== "tool_result" || block.tool_call_id !== toolCallId) continue;
|
|
466
|
-
if (typeof block.content === "string") currentResult = block.content;
|
|
491
|
+
if (!reset && typeof block.content === "string") currentResult = block.content;
|
|
467
492
|
break;
|
|
468
493
|
}
|
|
469
494
|
upsertToolResultBlock(state, toolCallId, currentResult + delta, toolName, displayName);
|
|
@@ -1200,7 +1225,8 @@ var ClientProjectionBuilder = class {
|
|
|
1200
1225
|
}
|
|
1201
1226
|
onToolResultDone(state, loopId, payload) {
|
|
1202
1227
|
const toolCallId = String(payload.tool_call_id ?? "");
|
|
1203
|
-
const
|
|
1228
|
+
const streamedResult = state.toolCalls.find((toolCall) => toolCall.id === toolCallId)?.result;
|
|
1229
|
+
const content = payload.content_from_deltas === true ? streamedResult ?? "" : payload.content ?? "";
|
|
1204
1230
|
const status = toolStatusFromResult(content);
|
|
1205
1231
|
const rawDuration = payload.duration_ms;
|
|
1206
1232
|
const durationMs = typeof rawDuration === "number" && rawDuration >= 0 ? Math.round(rawDuration) : null;
|
|
@@ -1215,7 +1241,8 @@ var ClientProjectionBuilder = class {
|
|
|
1215
1241
|
appendToolResultDelta(
|
|
1216
1242
|
state,
|
|
1217
1243
|
String(payload.tool_call_id ?? ""),
|
|
1218
|
-
String(payload.content ?? "")
|
|
1244
|
+
String(payload.content ?? ""),
|
|
1245
|
+
payload.content_reset === true
|
|
1219
1246
|
);
|
|
1220
1247
|
return this.syncPatch(state);
|
|
1221
1248
|
}
|
|
@@ -1736,10 +1763,94 @@ var SessionsResource = class {
|
|
|
1736
1763
|
}
|
|
1737
1764
|
/** 创建新会话并直接连接,返回可收发消息的 AgentSession。 */
|
|
1738
1765
|
async create(request = {}) {
|
|
1739
|
-
|
|
1766
|
+
if (isSessionDefinition(request)) {
|
|
1767
|
+
return this.createDeclared(request);
|
|
1768
|
+
}
|
|
1740
1769
|
const { session_id } = await this.createSessionWithRequest(request);
|
|
1741
1770
|
return this.connect(session_id);
|
|
1742
1771
|
}
|
|
1772
|
+
async createDeclared(definition) {
|
|
1773
|
+
const { intent, solution, skills = [], config } = definition;
|
|
1774
|
+
validateDefinition(definition);
|
|
1775
|
+
let solutionRequest = {};
|
|
1776
|
+
try {
|
|
1777
|
+
solutionRequest = solution ? await this.prepareSolution(solution) : {};
|
|
1778
|
+
} catch (error) {
|
|
1779
|
+
throw setupError("solution", "Solution \u51C6\u5907\u5931\u8D25", error);
|
|
1780
|
+
}
|
|
1781
|
+
let session_id;
|
|
1782
|
+
try {
|
|
1783
|
+
const created = await this.createSessionWithRequest({
|
|
1784
|
+
intent,
|
|
1785
|
+
...solutionRequest,
|
|
1786
|
+
model: config?.model,
|
|
1787
|
+
enable_thinking: config?.enableThinking,
|
|
1788
|
+
memory_enabled: config?.memoryEnabled,
|
|
1789
|
+
compaction_ratio: config?.compactionRatio,
|
|
1790
|
+
env: config?.env,
|
|
1791
|
+
disable_tools: config?.disableTools
|
|
1792
|
+
});
|
|
1793
|
+
session_id = created.session_id;
|
|
1794
|
+
} catch (error) {
|
|
1795
|
+
const assetId = solutionRequest.session_solution_asset_id;
|
|
1796
|
+
const assetCleaned = await this.cleanupSolutionAsset(assetId);
|
|
1797
|
+
const cleanupMessage = assetId ? assetCleaned ? "\uFF1B\u4E34\u65F6 Solution \u5DF2\u6E05\u7406" : `\uFF1B\u4E34\u65F6 Solution ${assetId} \u6E05\u7406\u5931\u8D25` : "";
|
|
1798
|
+
throw setupError("session", `\u4F1A\u8BDD\u521B\u5EFA\u5931\u8D25${cleanupMessage}`, error);
|
|
1799
|
+
}
|
|
1800
|
+
let installingSkill = "";
|
|
1801
|
+
try {
|
|
1802
|
+
for (const skill of skills) {
|
|
1803
|
+
installingSkill = skill.name;
|
|
1804
|
+
await this.client.json("POST", `/api/sessions/${encodeURIComponent(session_id)}/skills:upload`, {
|
|
1805
|
+
name: skill.name,
|
|
1806
|
+
files: skill.files
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
} catch (error) {
|
|
1810
|
+
const sessionCleaned = await this.deleteSession(session_id).then(
|
|
1811
|
+
() => true,
|
|
1812
|
+
() => false
|
|
1813
|
+
);
|
|
1814
|
+
const assetCleaned = await this.cleanupSolutionAsset(solutionRequest.session_solution_asset_id);
|
|
1815
|
+
const cleanupMessage = sessionCleaned ? "\u672A\u5B8C\u6210\u7684\u4F1A\u8BDD\u5DF2\u6E05\u7406" : `\u8BF7\u624B\u52A8\u5220\u9664\u4F1A\u8BDD ${session_id}`;
|
|
1816
|
+
const assetCleanupMessage = assetCleaned ? "" : "\uFF1B\u4E34\u65F6 Solution \u6E05\u7406\u5931\u8D25";
|
|
1817
|
+
throw setupError(
|
|
1818
|
+
"skill",
|
|
1819
|
+
`Skill "${installingSkill}" \u5B89\u88C5\u5931\u8D25\uFF1B${cleanupMessage}${assetCleanupMessage}`,
|
|
1820
|
+
error,
|
|
1821
|
+
session_id
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1824
|
+
await this.cleanupSolutionAsset(solutionRequest.session_solution_asset_id);
|
|
1825
|
+
try {
|
|
1826
|
+
return await this.connect(session_id);
|
|
1827
|
+
} catch (error) {
|
|
1828
|
+
throw setupError("connection", `\u4F1A\u8BDD\u8FDE\u63A5\u5931\u8D25\uFF1B\u53EF\u4F7F\u7528 sessionId ${session_id} \u91CD\u8BD5`, error, session_id);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
async prepareSolution(solution) {
|
|
1832
|
+
if ("id" in solution) {
|
|
1833
|
+
return { solution_id: solution.id, biz_role_id: solution.role ?? null };
|
|
1834
|
+
}
|
|
1835
|
+
const prepared = await this.client.json(
|
|
1836
|
+
"POST",
|
|
1837
|
+
"/api/session-assets/solutions",
|
|
1838
|
+
{ files: solution.files }
|
|
1839
|
+
);
|
|
1840
|
+
return {
|
|
1841
|
+
session_solution_asset_id: prepared.asset_id,
|
|
1842
|
+
biz_role_id: solution.role ?? null
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
async cleanupSolutionAsset(assetId) {
|
|
1846
|
+
if (!assetId) return true;
|
|
1847
|
+
try {
|
|
1848
|
+
await this.client.json("DELETE", `/api/session-assets/solutions/${encodeURIComponent(assetId)}`);
|
|
1849
|
+
return true;
|
|
1850
|
+
} catch {
|
|
1851
|
+
return false;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1743
1854
|
fetchSessionsPage({
|
|
1744
1855
|
limit,
|
|
1745
1856
|
offset,
|
|
@@ -1894,6 +2005,33 @@ var SessionsResource = class {
|
|
|
1894
2005
|
listDir(sessionId, dirPath) {
|
|
1895
2006
|
return this.client.json("GET", `/api/sessions/${sessionId}/ls/${encodeURIComponent(dirPath)}`);
|
|
1896
2007
|
}
|
|
2008
|
+
async countFiles(sessionId, dirPath = "") {
|
|
2009
|
+
const entries = await this.listDir(sessionId, dirPath);
|
|
2010
|
+
let count = 0;
|
|
2011
|
+
for (const entry of entries) {
|
|
2012
|
+
count += entry.is_dir ? await this.countFiles(sessionId, entry.path) : 1;
|
|
2013
|
+
}
|
|
2014
|
+
return count;
|
|
2015
|
+
}
|
|
2016
|
+
/** 在浏览器中下载一个会话文件。 */
|
|
2017
|
+
async downloadFile(sessionId, filePath, downloadName) {
|
|
2018
|
+
if (typeof document === "undefined") {
|
|
2019
|
+
throw new Error("downloadFile \u53EA\u80FD\u5728\u6D4F\u89C8\u5668\u4E2D\u4F7F\u7528");
|
|
2020
|
+
}
|
|
2021
|
+
const response = await this.client.fetch(
|
|
2022
|
+
"GET",
|
|
2023
|
+
`/api/sessions/${encodeURIComponent(sessionId)}/files/${encodeURIComponent(filePath)}`
|
|
2024
|
+
);
|
|
2025
|
+
const objectUrl = URL.createObjectURL(await response.blob());
|
|
2026
|
+
const anchor = document.createElement("a");
|
|
2027
|
+
anchor.href = objectUrl;
|
|
2028
|
+
anchor.download = downloadName || filePath.split("/").pop() || "download";
|
|
2029
|
+
anchor.style.display = "none";
|
|
2030
|
+
document.body.appendChild(anchor);
|
|
2031
|
+
anchor.click();
|
|
2032
|
+
anchor.remove();
|
|
2033
|
+
globalThis.setTimeout(() => URL.revokeObjectURL(objectUrl), 1e3);
|
|
2034
|
+
}
|
|
1897
2035
|
async uploadFiles(sessionId, dirPath, files, options = {}) {
|
|
1898
2036
|
const formData = new FormData();
|
|
1899
2037
|
const entries = Array.from(files).map(
|
|
@@ -1964,6 +2102,51 @@ var SessionsResource = class {
|
|
|
1964
2102
|
return res.json();
|
|
1965
2103
|
}
|
|
1966
2104
|
};
|
|
2105
|
+
function isSessionDefinition(request) {
|
|
2106
|
+
return "solution" in request || "skills" in request || "config" in request;
|
|
2107
|
+
}
|
|
2108
|
+
function validateDefinition(definition) {
|
|
2109
|
+
if (definition.solution) {
|
|
2110
|
+
if ("id" in definition.solution) {
|
|
2111
|
+
if (!definition.solution.id.trim()) {
|
|
2112
|
+
throw new SessionSetupError("Solution id \u4E0D\u80FD\u4E3A\u7A7A", "solution");
|
|
2113
|
+
}
|
|
2114
|
+
} else {
|
|
2115
|
+
validateTextFiles(definition.solution.files, "solution", "Solution");
|
|
2116
|
+
if (!definition.solution.files.some((file) => file.path === "solution.yaml")) {
|
|
2117
|
+
throw new SessionSetupError("Solution \u7F3A\u5C11\u6839\u76EE\u5F55 solution.yaml", "solution");
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
for (const skill of definition.skills ?? []) validateSkill(skill);
|
|
2122
|
+
}
|
|
2123
|
+
function validateSkill(skill) {
|
|
2124
|
+
if (!/^[a-z0-9-]+\/[a-z0-9-]+$/.test(skill.name)) {
|
|
2125
|
+
throw new SessionSetupError(`Skill name "${skill.name}" \u5FC5\u987B\u662F\u5C0F\u5199\u7684 \u7EC4\u7EC7/\u540D\u79F0`, "skill");
|
|
2126
|
+
}
|
|
2127
|
+
validateTextFiles(skill.files, "skill", `Skill "${skill.name}"`);
|
|
2128
|
+
if (!skill.files.some((file) => file.path === "SKILL.md")) {
|
|
2129
|
+
throw new SessionSetupError(`Skill "${skill.name}" \u7F3A\u5C11\u6839\u76EE\u5F55 SKILL.md`, "skill");
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
function validateTextFiles(files, stage, label) {
|
|
2133
|
+
if (files.length === 0) throw new SessionSetupError(`${label} files \u4E0D\u80FD\u4E3A\u7A7A`, stage);
|
|
2134
|
+
const paths = /* @__PURE__ */ new Set();
|
|
2135
|
+
for (const file of files) {
|
|
2136
|
+
const path = file.path;
|
|
2137
|
+
if (!path || path !== path.trim() || path.startsWith("/") || path.includes("\\") || path.split("/").some((part) => !part || part === "." || part === "..") || /^[a-zA-Z]:/.test(path)) {
|
|
2138
|
+
throw new SessionSetupError(`${label} \u6587\u4EF6\u8DEF\u5F84\u4E0D\u5B89\u5168\uFF1A"${path}"`, stage);
|
|
2139
|
+
}
|
|
2140
|
+
if (paths.has(path)) {
|
|
2141
|
+
throw new SessionSetupError(`${label} \u6587\u4EF6\u8DEF\u5F84\u91CD\u590D\uFF1A"${path}"`, stage);
|
|
2142
|
+
}
|
|
2143
|
+
paths.add(path);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function setupError(stage, message, cause, sessionId) {
|
|
2147
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
2148
|
+
return new SessionSetupError(`${message}\uFF1A${detail}`, stage, sessionId, { cause });
|
|
2149
|
+
}
|
|
1967
2150
|
function profileToCreateSessionRequest(profile) {
|
|
1968
2151
|
const solution = profile.solution;
|
|
1969
2152
|
return {
|
|
@@ -2708,6 +2891,9 @@ var AgentSession = class _AgentSession {
|
|
|
2708
2891
|
emitWithAck: async () => readonlyError(),
|
|
2709
2892
|
ensureConnected: readonlyError,
|
|
2710
2893
|
fetchTurns: async () => turns,
|
|
2894
|
+
listDir: async () => readonlyError(),
|
|
2895
|
+
countFiles: async () => readonlyError(),
|
|
2896
|
+
downloadFile: async () => readonlyError(),
|
|
2711
2897
|
onDispose: () => void 0
|
|
2712
2898
|
},
|
|
2713
2899
|
"connected"
|
|
@@ -2840,6 +3026,18 @@ var AgentSession = class _AgentSession {
|
|
|
2840
3026
|
insertText(text) {
|
|
2841
3027
|
this.emitter.emit("insertTextRequested", { text });
|
|
2842
3028
|
}
|
|
3029
|
+
/** 列出工作区的一层目录。 */
|
|
3030
|
+
listDir(dirPath = "") {
|
|
3031
|
+
return this.runtime.listDir(this.sessionId, dirPath);
|
|
3032
|
+
}
|
|
3033
|
+
/** 递归统计工作区文件数(不含目录)。 */
|
|
3034
|
+
countFiles(dirPath = "") {
|
|
3035
|
+
return this.runtime.countFiles(this.sessionId, dirPath);
|
|
3036
|
+
}
|
|
3037
|
+
/** 在浏览器中下载一个工作区文件。 */
|
|
3038
|
+
downloadFile(filePath, downloadName) {
|
|
3039
|
+
return this.runtime.downloadFile(this.sessionId, filePath, downloadName);
|
|
3040
|
+
}
|
|
2843
3041
|
/** 释放订阅与监听器。之后该实例不再接收任何事件。 */
|
|
2844
3042
|
dispose() {
|
|
2845
3043
|
if (this.disposed) return;
|
|
@@ -3287,7 +3485,6 @@ var SessionHub = class {
|
|
|
3287
3485
|
}
|
|
3288
3486
|
/** 取得(或复用)一个会话的 AgentSession,并完成历史加载 + 房间订阅。 */
|
|
3289
3487
|
async connect(sessionId) {
|
|
3290
|
-
await this.client.ensureVersionCompatible();
|
|
3291
3488
|
const existing = this.sessions.get(sessionId);
|
|
3292
3489
|
if (existing && !existing.isDisposed) {
|
|
3293
3490
|
return this.bootstrapPending.get(sessionId) ?? existing;
|
|
@@ -3365,6 +3562,9 @@ var SessionHub = class {
|
|
|
3365
3562
|
}),
|
|
3366
3563
|
ensureConnected: () => this.ensureConnected(),
|
|
3367
3564
|
fetchTurns: (sessionId) => this.client.sessions.getSessionTurns(sessionId),
|
|
3565
|
+
listDir: (sessionId, dirPath) => this.client.sessions.listDir(sessionId, dirPath),
|
|
3566
|
+
countFiles: (sessionId, dirPath) => this.client.sessions.countFiles(sessionId, dirPath),
|
|
3567
|
+
downloadFile: (sessionId, filePath, downloadName) => this.client.sessions.downloadFile(sessionId, filePath, downloadName),
|
|
3368
3568
|
onDispose: (session) => {
|
|
3369
3569
|
if (this.sessions.get(session.sessionId) === session) {
|
|
3370
3570
|
this.sessions.delete(session.sessionId);
|
|
@@ -3557,63 +3757,7 @@ function resolveAuthToken(options) {
|
|
|
3557
3757
|
|
|
3558
3758
|
// src/version.ts
|
|
3559
3759
|
var SDK_NAME = "agent-client";
|
|
3560
|
-
var SDK_VERSION = "
|
|
3561
|
-
var MIN_SERVER_VERSION = "1.1.1";
|
|
3562
|
-
var LEGACY_SDK = "@blade-hq/agent-kit@1.1.0";
|
|
3563
|
-
var VersionMismatchError = class extends Error {
|
|
3564
|
-
serverVersion;
|
|
3565
|
-
sdkVersion;
|
|
3566
|
-
hint;
|
|
3567
|
-
constructor(options) {
|
|
3568
|
-
super(
|
|
3569
|
-
`SDK \u4E0E Server \u7248\u672C\u4E0D\u5339\u914D\uFF08SDK ${SDK_NAME}@${SDK_VERSION}\uFF0CServer ${options.serverVersion ?? "\u7248\u672C\u672A\u77E5\uFF08\u4E0D\u652F\u6301 /api/version\uFF09"}\uFF09\uFF1A${options.hint}`
|
|
3570
|
-
);
|
|
3571
|
-
this.name = "VersionMismatchError";
|
|
3572
|
-
this.serverVersion = options.serverVersion;
|
|
3573
|
-
this.sdkVersion = SDK_VERSION;
|
|
3574
|
-
this.hint = options.hint;
|
|
3575
|
-
}
|
|
3576
|
-
};
|
|
3577
|
-
function parseCoreVersion(version) {
|
|
3578
|
-
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
|
|
3579
|
-
if (!match) return null;
|
|
3580
|
-
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
3581
|
-
}
|
|
3582
|
-
function isPrerelease(version) {
|
|
3583
|
-
const trimmed = version.trim();
|
|
3584
|
-
if (!parseCoreVersion(trimmed)) return true;
|
|
3585
|
-
return /[-+]/.test(trimmed);
|
|
3586
|
-
}
|
|
3587
|
-
function compareVersions(a, b) {
|
|
3588
|
-
const left = parseCoreVersion(a);
|
|
3589
|
-
const right = parseCoreVersion(b);
|
|
3590
|
-
if (!left || !right) return 0;
|
|
3591
|
-
for (let i = 0; i < 3; i++) {
|
|
3592
|
-
if (left[i] !== right[i]) return left[i] - right[i];
|
|
3593
|
-
}
|
|
3594
|
-
return 0;
|
|
3595
|
-
}
|
|
3596
|
-
function assertVersionCompatible(info) {
|
|
3597
|
-
if (info === null) {
|
|
3598
|
-
throw new VersionMismatchError({
|
|
3599
|
-
serverVersion: null,
|
|
3600
|
-
hint: `\u8BE5 Server \u4E0D\u63D0\u4F9B /api/version\uFF0C\u8BF4\u660E\u7248\u672C\u4F4E\u4E8E ${MIN_SERVER_VERSION}\u3002\u8BF7\u6539\u7528 ${LEGACY_SDK} \u63A5\u5165\uFF0C\u6216\u628A Server \u5347\u7EA7\u5230 ${MIN_SERVER_VERSION} \u53CA\u4EE5\u4E0A\u3002`
|
|
3601
|
-
});
|
|
3602
|
-
}
|
|
3603
|
-
if (!isPrerelease(info.version) && compareVersions(info.version, MIN_SERVER_VERSION) < 0) {
|
|
3604
|
-
throw new VersionMismatchError({
|
|
3605
|
-
serverVersion: info.version,
|
|
3606
|
-
hint: `\u672C SDK \u9700\u8981 Server ${MIN_SERVER_VERSION} \u53CA\u4EE5\u4E0A\u3002\u8BF7\u6539\u7528 ${LEGACY_SDK} \u63A5\u5165\u8BE5 Server\uFF0C\u6216\u628A Server \u5347\u7EA7\u5230 ${MIN_SERVER_VERSION} \u53CA\u4EE5\u4E0A\u3002`
|
|
3607
|
-
});
|
|
3608
|
-
}
|
|
3609
|
-
const minSdk = info.min_sdk;
|
|
3610
|
-
if (minSdk && !isPrerelease(SDK_VERSION) && compareVersions(SDK_VERSION, minSdk) < 0) {
|
|
3611
|
-
throw new VersionMismatchError({
|
|
3612
|
-
serverVersion: info.version,
|
|
3613
|
-
hint: `\u8BE5 Server \u8981\u6C42 SDK ${minSdk} \u53CA\u4EE5\u4E0A\uFF0C\u8BF7\u628A ${SDK_NAME} \u5347\u7EA7\u5230 ${minSdk} \u53CA\u4EE5\u4E0A\u3002`
|
|
3614
|
-
});
|
|
3615
|
-
}
|
|
3616
|
-
}
|
|
3760
|
+
var SDK_VERSION = true ? "1.1.3" : "1.1.1";
|
|
3617
3761
|
|
|
3618
3762
|
// src/socket.ts
|
|
3619
3763
|
function withSdkIdentity(auth) {
|
|
@@ -3641,11 +3785,10 @@ var BladeClient = class {
|
|
|
3641
3785
|
options;
|
|
3642
3786
|
auth;
|
|
3643
3787
|
headless;
|
|
3788
|
+
models;
|
|
3644
3789
|
sessions;
|
|
3645
3790
|
/** 实时会话中枢:client.sessions.connect() 内部使用,一般不直接访问。 */
|
|
3646
3791
|
hub;
|
|
3647
|
-
/** 版本握手结果缓存:每个 client 实例只探测一次,不逐请求重复。 */
|
|
3648
|
-
versionCheck = null;
|
|
3649
3792
|
constructor(options) {
|
|
3650
3793
|
this.options = {
|
|
3651
3794
|
...options,
|
|
@@ -3653,6 +3796,7 @@ var BladeClient = class {
|
|
|
3653
3796
|
};
|
|
3654
3797
|
this.auth = new AuthResource(this);
|
|
3655
3798
|
this.headless = new HeadlessResource(this);
|
|
3799
|
+
this.models = new ModelsResource(this);
|
|
3656
3800
|
this.sessions = new SessionsResource(this);
|
|
3657
3801
|
this.hub = new SessionHub(this);
|
|
3658
3802
|
if (this.options.token === void 0) {
|
|
@@ -3711,43 +3855,6 @@ var BladeClient = class {
|
|
|
3711
3855
|
get token() {
|
|
3712
3856
|
return this.resolveRestToken();
|
|
3713
3857
|
}
|
|
3714
|
-
/**
|
|
3715
|
-
* 版本握手:首次连接前查询 Server 版本,不匹配则抛 VersionMismatchError。
|
|
3716
|
-
* 结果缓存在实例上,失败的探测不缓存以便重试。
|
|
3717
|
-
*/
|
|
3718
|
-
async ensureVersionCompatible() {
|
|
3719
|
-
if (!this.versionCheck) {
|
|
3720
|
-
this.versionCheck = this.fetchServerVersion().then(assertVersionCompatible).catch((error) => {
|
|
3721
|
-
this.versionCheck = null;
|
|
3722
|
-
throw error;
|
|
3723
|
-
});
|
|
3724
|
-
}
|
|
3725
|
-
return this.versionCheck;
|
|
3726
|
-
}
|
|
3727
|
-
/**
|
|
3728
|
-
* 读取 /api/version。接口存在但 404/响应不合法 → null(按旧 Server 处理);
|
|
3729
|
-
* 网络层不可达(后端没启动、端口不通、代理配错)→ 抛连接错误。
|
|
3730
|
-
* 两者必须区分:把「后端没起」误报成「版本不匹配,请改用 agent-kit」
|
|
3731
|
-
* 会把开发者引向完全错误的排查方向。
|
|
3732
|
-
*/
|
|
3733
|
-
async fetchServerVersion() {
|
|
3734
|
-
let response;
|
|
3735
|
-
try {
|
|
3736
|
-
response = await this.fetch("GET", "/api/version", { expectOk: false });
|
|
3737
|
-
} catch (error) {
|
|
3738
|
-
throw new Error(
|
|
3739
|
-
`\u65E0\u6CD5\u8FDE\u63A5\u5230 Server\uFF08${this.options.baseUrl || "\u5F53\u524D\u57DF\u540D"}\uFF09\u3002\u8BF7\u786E\u8BA4\u540E\u7AEF\u5DF2\u542F\u52A8\u3001\u5730\u5740\u4E0E\u7AEF\u53E3\u6B63\u786E\u3002`,
|
|
3740
|
-
{ cause: error }
|
|
3741
|
-
);
|
|
3742
|
-
}
|
|
3743
|
-
if (!response.ok) return null;
|
|
3744
|
-
try {
|
|
3745
|
-
const info = await response.json();
|
|
3746
|
-
return typeof info?.version === "string" ? info : null;
|
|
3747
|
-
} catch {
|
|
3748
|
-
return null;
|
|
3749
|
-
}
|
|
3750
|
-
}
|
|
3751
3858
|
setBaseUrl(baseUrl) {
|
|
3752
3859
|
const nextBaseUrl = normalizeBaseUrl(baseUrl);
|
|
3753
3860
|
if (nextBaseUrl === this.options.baseUrl) {
|
|
@@ -3755,7 +3862,6 @@ var BladeClient = class {
|
|
|
3755
3862
|
}
|
|
3756
3863
|
this.hub.disposeAll();
|
|
3757
3864
|
this.options.baseUrl = nextBaseUrl;
|
|
3758
|
-
this.versionCheck = null;
|
|
3759
3865
|
if (this.socketInstance) {
|
|
3760
3866
|
this.socketInstance.removeAllListeners();
|
|
3761
3867
|
this.socketInstance.disconnect();
|
|
@@ -4154,15 +4260,15 @@ export {
|
|
|
4154
4260
|
BladeClient,
|
|
4155
4261
|
ClientProjectionBuilder,
|
|
4156
4262
|
LayoutType,
|
|
4157
|
-
|
|
4263
|
+
ModelsResource,
|
|
4158
4264
|
SDK_NAME,
|
|
4159
4265
|
SDK_VERSION,
|
|
4160
4266
|
SessionHub,
|
|
4161
4267
|
SessionInfo,
|
|
4268
|
+
SessionSetupError,
|
|
4162
4269
|
SessionStatus,
|
|
4163
4270
|
Task,
|
|
4164
4271
|
TaskStatus,
|
|
4165
|
-
VersionMismatchError,
|
|
4166
4272
|
buildMessageContent,
|
|
4167
4273
|
connectEmbedded,
|
|
4168
4274
|
contentPreview,
|