@capyclaw/publisher 0.1.3 → 0.1.4
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/package.json +3 -11
- package/server/archive.mjs +69 -35
- package/server/drop.mjs +9 -3
- package/server/impl.mjs +133 -97
- package/server/tools.mjs +1 -1
- package/node_modules/@capyclaw/foundation/README.md +0 -51
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +0 -86
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +0 -63
- package/node_modules/@capyclaw/foundation/abi/index.mjs +0 -35
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +0 -271
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +0 -345
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +0 -98
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +0 -255
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +0 -24
- package/node_modules/@capyclaw/foundation/abi/version.mjs +0 -82
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +0 -5
- package/node_modules/@capyclaw/foundation/kit/index.mjs +0 -6
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +0 -98
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +0 -35
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +0 -69
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +0 -55
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +0 -113
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +0 -68
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +0 -113
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +0 -77
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +0 -56
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +0 -50
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +0 -64
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +0 -42
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +0 -34
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +0 -85
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +0 -50
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +0 -160
- package/node_modules/@capyclaw/foundation/lib/host.mjs +0 -23
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +0 -185
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +0 -87
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +0 -60
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +0 -51
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +0 -188
- package/node_modules/@capyclaw/foundation/package.json +0 -53
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +0 -20
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +0 -100
- package/node_modules/@capyclaw/plugin-kit/README.md +0 -70
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +0 -103
- package/node_modules/@capyclaw/plugin-kit/package.json +0 -69
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +0 -56
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +0 -142
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +0 -129
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +0 -139
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +0 -219
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +0 -13
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +0 -13
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +0 -230
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +0 -128
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +0 -307
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +0 -45
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +0 -113
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +0 -150
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +0 -131
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +0 -82
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +0 -109
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +0 -17
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +0 -89
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +0 -57
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +0 -150
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +0 -82
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +0 -132
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +0 -130
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +0 -656
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +0 -181
- package/node_modules/@capyclaw/plugin-validator/bin/cli.mjs +0 -49
- package/node_modules/@capyclaw/plugin-validator/lib/index.mjs +0 -303
- package/node_modules/@capyclaw/plugin-validator/package.json +0 -28
- package/node_modules/@capyclaw/tool-host/README.md +0 -56
- package/node_modules/@capyclaw/tool-host/cordis.patch.yml +0 -4
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +0 -30
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +0 -16
- package/node_modules/@capyclaw/tool-host/package.json +0 -59
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +0 -166
- package/node_modules/@capyclaw/tool-host/src/index.mjs +0 -416
- package/node_modules/semver/LICENSE +0 -15
- package/node_modules/semver/README.md +0 -680
- package/node_modules/semver/bin/semver.js +0 -195
- package/node_modules/semver/classes/comparator.js +0 -143
- package/node_modules/semver/classes/index.js +0 -7
- package/node_modules/semver/classes/range.js +0 -577
- package/node_modules/semver/classes/semver.js +0 -350
- package/node_modules/semver/functions/clean.js +0 -8
- package/node_modules/semver/functions/cmp.js +0 -54
- package/node_modules/semver/functions/coerce.js +0 -62
- package/node_modules/semver/functions/compare-build.js +0 -9
- package/node_modules/semver/functions/compare-loose.js +0 -5
- package/node_modules/semver/functions/compare.js +0 -7
- package/node_modules/semver/functions/diff.js +0 -60
- package/node_modules/semver/functions/eq.js +0 -5
- package/node_modules/semver/functions/gt.js +0 -5
- package/node_modules/semver/functions/gte.js +0 -5
- package/node_modules/semver/functions/inc.js +0 -21
- package/node_modules/semver/functions/lt.js +0 -5
- package/node_modules/semver/functions/lte.js +0 -5
- package/node_modules/semver/functions/major.js +0 -5
- package/node_modules/semver/functions/minor.js +0 -5
- package/node_modules/semver/functions/neq.js +0 -5
- package/node_modules/semver/functions/parse.js +0 -18
- package/node_modules/semver/functions/patch.js +0 -5
- package/node_modules/semver/functions/prerelease.js +0 -8
- package/node_modules/semver/functions/rcompare.js +0 -5
- package/node_modules/semver/functions/rsort.js +0 -5
- package/node_modules/semver/functions/satisfies.js +0 -12
- package/node_modules/semver/functions/sort.js +0 -5
- package/node_modules/semver/functions/truncate.js +0 -48
- package/node_modules/semver/functions/valid.js +0 -8
- package/node_modules/semver/index.js +0 -93
- package/node_modules/semver/internal/constants.js +0 -67
- package/node_modules/semver/internal/debug.js +0 -11
- package/node_modules/semver/internal/identifiers.js +0 -29
- package/node_modules/semver/internal/lrucache.js +0 -42
- package/node_modules/semver/internal/parse-options.js +0 -17
- package/node_modules/semver/internal/re.js +0 -223
- package/node_modules/semver/internal/trim-comparator-whitespace.js +0 -438
- package/node_modules/semver/package.json +0 -78
- package/node_modules/semver/preload.js +0 -4
- package/node_modules/semver/range.bnf +0 -17
- package/node_modules/semver/ranges/gtr.js +0 -6
- package/node_modules/semver/ranges/intersects.js +0 -9
- package/node_modules/semver/ranges/ltr.js +0 -6
- package/node_modules/semver/ranges/max-satisfying.js +0 -27
- package/node_modules/semver/ranges/min-satisfying.js +0 -26
- package/node_modules/semver/ranges/min-version.js +0 -63
- package/node_modules/semver/ranges/outside.js +0 -82
- package/node_modules/semver/ranges/simplify.js +0 -49
- package/node_modules/semver/ranges/subset.js +0 -249
- package/node_modules/semver/ranges/to-comparators.js +0 -10
- package/node_modules/semver/ranges/valid.js +0 -13
- package/node_modules/yaml/LICENSE +0 -13
- package/node_modules/yaml/README.md +0 -172
- package/node_modules/yaml/bin.mjs +0 -11
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +0 -88
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -43
- package/node_modules/yaml/browser/dist/compose/compose-node.js +0 -109
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +0 -86
- package/node_modules/yaml/browser/dist/compose/composer.js +0 -219
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -115
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +0 -198
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +0 -49
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +0 -37
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +0 -207
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +0 -226
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +0 -146
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +0 -34
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +0 -26
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +0 -15
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +0 -13
- package/node_modules/yaml/browser/dist/doc/Document.js +0 -335
- package/node_modules/yaml/browser/dist/doc/anchors.js +0 -71
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -55
- package/node_modules/yaml/browser/dist/doc/createNode.js +0 -88
- package/node_modules/yaml/browser/dist/doc/directives.js +0 -176
- package/node_modules/yaml/browser/dist/errors.js +0 -57
- package/node_modules/yaml/browser/dist/index.js +0 -17
- package/node_modules/yaml/browser/dist/log.js +0 -11
- package/node_modules/yaml/browser/dist/nodes/Alias.js +0 -118
- package/node_modules/yaml/browser/dist/nodes/Collection.js +0 -147
- package/node_modules/yaml/browser/dist/nodes/Node.js +0 -38
- package/node_modules/yaml/browser/dist/nodes/Pair.js +0 -36
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +0 -24
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +0 -144
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +0 -113
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +0 -63
- package/node_modules/yaml/browser/dist/nodes/identity.js +0 -36
- package/node_modules/yaml/browser/dist/nodes/toJS.js +0 -37
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +0 -214
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +0 -61
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +0 -97
- package/node_modules/yaml/browser/dist/parse/cst.js +0 -98
- package/node_modules/yaml/browser/dist/parse/lexer.js +0 -721
- package/node_modules/yaml/browser/dist/parse/line-counter.js +0 -39
- package/node_modules/yaml/browser/dist/parse/parser.js +0 -975
- package/node_modules/yaml/browser/dist/public-api.js +0 -102
- package/node_modules/yaml/browser/dist/schema/Schema.js +0 -37
- package/node_modules/yaml/browser/dist/schema/common/map.js +0 -17
- package/node_modules/yaml/browser/dist/schema/common/null.js +0 -15
- package/node_modules/yaml/browser/dist/schema/common/seq.js +0 -17
- package/node_modules/yaml/browser/dist/schema/common/string.js +0 -14
- package/node_modules/yaml/browser/dist/schema/core/bool.js +0 -19
- package/node_modules/yaml/browser/dist/schema/core/float.js +0 -43
- package/node_modules/yaml/browser/dist/schema/core/int.js +0 -38
- package/node_modules/yaml/browser/dist/schema/core/schema.js +0 -23
- package/node_modules/yaml/browser/dist/schema/json/schema.js +0 -62
- package/node_modules/yaml/browser/dist/schema/tags.js +0 -96
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +0 -58
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +0 -26
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +0 -46
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +0 -71
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -67
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +0 -74
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +0 -78
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -39
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +0 -93
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +0 -101
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +0 -146
- package/node_modules/yaml/browser/dist/stringify/stringify.js +0 -129
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +0 -153
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +0 -20
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +0 -85
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +0 -25
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +0 -150
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +0 -336
- package/node_modules/yaml/browser/dist/util.js +0 -11
- package/node_modules/yaml/browser/dist/visit.js +0 -233
- package/node_modules/yaml/browser/index.js +0 -5
- package/node_modules/yaml/browser/package.json +0 -3
- package/node_modules/yaml/dist/cli.d.ts +0 -8
- package/node_modules/yaml/dist/cli.mjs +0 -201
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +0 -11
- package/node_modules/yaml/dist/compose/compose-collection.js +0 -90
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +0 -7
- package/node_modules/yaml/dist/compose/compose-doc.js +0 -45
- package/node_modules/yaml/dist/compose/compose-node.d.ts +0 -29
- package/node_modules/yaml/dist/compose/compose-node.js +0 -112
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +0 -5
- package/node_modules/yaml/dist/compose/compose-scalar.js +0 -88
- package/node_modules/yaml/dist/compose/composer.d.ts +0 -63
- package/node_modules/yaml/dist/compose/composer.js +0 -224
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +0 -6
- package/node_modules/yaml/dist/compose/resolve-block-map.js +0 -117
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +0 -11
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +0 -200
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +0 -6
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +0 -51
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +0 -6
- package/node_modules/yaml/dist/compose/resolve-end.js +0 -39
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +0 -7
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +0 -209
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +0 -10
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +0 -228
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +0 -23
- package/node_modules/yaml/dist/compose/resolve-props.js +0 -148
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +0 -2
- package/node_modules/yaml/dist/compose/util-contains-newline.js +0 -36
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +0 -2
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +0 -28
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +0 -3
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +0 -17
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +0 -4
- package/node_modules/yaml/dist/compose/util-map-includes.js +0 -15
- package/node_modules/yaml/dist/doc/Document.d.ts +0 -141
- package/node_modules/yaml/dist/doc/Document.js +0 -337
- package/node_modules/yaml/dist/doc/anchors.d.ts +0 -24
- package/node_modules/yaml/dist/doc/anchors.js +0 -76
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +0 -9
- package/node_modules/yaml/dist/doc/applyReviver.js +0 -57
- package/node_modules/yaml/dist/doc/createNode.d.ts +0 -17
- package/node_modules/yaml/dist/doc/createNode.js +0 -90
- package/node_modules/yaml/dist/doc/directives.d.ts +0 -49
- package/node_modules/yaml/dist/doc/directives.js +0 -178
- package/node_modules/yaml/dist/errors.d.ts +0 -21
- package/node_modules/yaml/dist/errors.js +0 -62
- package/node_modules/yaml/dist/index.d.ts +0 -25
- package/node_modules/yaml/dist/index.js +0 -50
- package/node_modules/yaml/dist/log.d.ts +0 -3
- package/node_modules/yaml/dist/log.js +0 -19
- package/node_modules/yaml/dist/nodes/Alias.d.ts +0 -29
- package/node_modules/yaml/dist/nodes/Alias.js +0 -120
- package/node_modules/yaml/dist/nodes/Collection.d.ts +0 -73
- package/node_modules/yaml/dist/nodes/Collection.js +0 -151
- package/node_modules/yaml/dist/nodes/Node.d.ts +0 -53
- package/node_modules/yaml/dist/nodes/Node.js +0 -40
- package/node_modules/yaml/dist/nodes/Pair.d.ts +0 -22
- package/node_modules/yaml/dist/nodes/Pair.js +0 -39
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +0 -47
- package/node_modules/yaml/dist/nodes/Scalar.js +0 -27
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +0 -53
- package/node_modules/yaml/dist/nodes/YAMLMap.js +0 -147
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +0 -60
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +0 -115
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +0 -4
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +0 -65
- package/node_modules/yaml/dist/nodes/identity.d.ts +0 -23
- package/node_modules/yaml/dist/nodes/identity.js +0 -53
- package/node_modules/yaml/dist/nodes/toJS.d.ts +0 -29
- package/node_modules/yaml/dist/nodes/toJS.js +0 -39
- package/node_modules/yaml/dist/options.d.ts +0 -350
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +0 -64
- package/node_modules/yaml/dist/parse/cst-scalar.js +0 -218
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +0 -8
- package/node_modules/yaml/dist/parse/cst-stringify.js +0 -63
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +0 -39
- package/node_modules/yaml/dist/parse/cst-visit.js +0 -99
- package/node_modules/yaml/dist/parse/cst.d.ts +0 -109
- package/node_modules/yaml/dist/parse/cst.js +0 -112
- package/node_modules/yaml/dist/parse/lexer.d.ts +0 -87
- package/node_modules/yaml/dist/parse/lexer.js +0 -723
- package/node_modules/yaml/dist/parse/line-counter.d.ts +0 -22
- package/node_modules/yaml/dist/parse/line-counter.js +0 -41
- package/node_modules/yaml/dist/parse/parser.d.ts +0 -84
- package/node_modules/yaml/dist/parse/parser.js +0 -980
- package/node_modules/yaml/dist/public-api.d.ts +0 -44
- package/node_modules/yaml/dist/public-api.js +0 -107
- package/node_modules/yaml/dist/schema/Schema.d.ts +0 -17
- package/node_modules/yaml/dist/schema/Schema.js +0 -39
- package/node_modules/yaml/dist/schema/common/map.d.ts +0 -2
- package/node_modules/yaml/dist/schema/common/map.js +0 -19
- package/node_modules/yaml/dist/schema/common/null.d.ts +0 -4
- package/node_modules/yaml/dist/schema/common/null.js +0 -17
- package/node_modules/yaml/dist/schema/common/seq.d.ts +0 -2
- package/node_modules/yaml/dist/schema/common/seq.js +0 -19
- package/node_modules/yaml/dist/schema/common/string.d.ts +0 -2
- package/node_modules/yaml/dist/schema/common/string.js +0 -16
- package/node_modules/yaml/dist/schema/core/bool.d.ts +0 -4
- package/node_modules/yaml/dist/schema/core/bool.js +0 -21
- package/node_modules/yaml/dist/schema/core/float.d.ts +0 -4
- package/node_modules/yaml/dist/schema/core/float.js +0 -47
- package/node_modules/yaml/dist/schema/core/int.d.ts +0 -4
- package/node_modules/yaml/dist/schema/core/int.js +0 -42
- package/node_modules/yaml/dist/schema/core/schema.d.ts +0 -1
- package/node_modules/yaml/dist/schema/core/schema.js +0 -25
- package/node_modules/yaml/dist/schema/json/schema.d.ts +0 -2
- package/node_modules/yaml/dist/schema/json/schema.js +0 -64
- package/node_modules/yaml/dist/schema/json-schema.d.ts +0 -69
- package/node_modules/yaml/dist/schema/tags.d.ts +0 -48
- package/node_modules/yaml/dist/schema/tags.js +0 -99
- package/node_modules/yaml/dist/schema/types.d.ts +0 -92
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +0 -2
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +0 -70
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +0 -7
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +0 -29
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +0 -4
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +0 -50
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +0 -5
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +0 -76
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +0 -9
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +0 -71
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +0 -22
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +0 -77
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +0 -10
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +0 -82
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +0 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +0 -41
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +0 -28
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +0 -96
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +0 -6
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +0 -105
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +0 -34
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +0 -151
- package/node_modules/yaml/dist/stringify/stringify.d.ts +0 -21
- package/node_modules/yaml/dist/stringify/stringify.js +0 -132
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +0 -17
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +0 -155
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +0 -10
- package/node_modules/yaml/dist/stringify/stringifyComment.js +0 -24
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +0 -4
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +0 -87
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +0 -2
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +0 -27
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +0 -3
- package/node_modules/yaml/dist/stringify/stringifyPair.js +0 -152
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +0 -9
- package/node_modules/yaml/dist/stringify/stringifyString.js +0 -338
- package/node_modules/yaml/dist/test-events.d.ts +0 -4
- package/node_modules/yaml/dist/test-events.js +0 -134
- package/node_modules/yaml/dist/util.d.ts +0 -16
- package/node_modules/yaml/dist/util.js +0 -28
- package/node_modules/yaml/dist/visit.d.ts +0 -102
- package/node_modules/yaml/dist/visit.js +0 -236
- package/node_modules/yaml/package.json +0 -97
- package/node_modules/yaml/util.js +0 -2
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
/** Descriptor loader: synchronous validation/mount, observable asynchronous readiness and cleanup. */
|
|
2
|
-
import { ABI_MAJOR, getInterfaceKind } from './kinds.mjs'
|
|
3
|
-
import { validateInterface } from './validate.mjs'
|
|
4
|
-
import { AbiError, ERROR_CODES, toAbiError } from './errors.mjs'
|
|
5
|
-
import { satisfies } from './version.mjs'
|
|
6
|
-
|
|
7
|
-
const thenable = (value) => value && typeof value.then === 'function'
|
|
8
|
-
|
|
9
|
-
/** Run in order, retaining immediate effects when all operations are synchronous. */
|
|
10
|
-
function sequence(items, operation) {
|
|
11
|
-
let pending
|
|
12
|
-
for (const item of items) {
|
|
13
|
-
if (pending) pending = pending.then(() => operation(item))
|
|
14
|
-
else {
|
|
15
|
-
const result = operation(item)
|
|
16
|
-
if (thenable(result)) pending = Promise.resolve(result)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return pending
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function createLoader({ adapters = {}, capabilities = {}, log = null, abiMajor = ABI_MAJOR } = {}) {
|
|
23
|
-
const capabilityMap = () => (typeof capabilities === 'function' ? capabilities() : capabilities)
|
|
24
|
-
const plugins = new Map()
|
|
25
|
-
const uniques = new Map()
|
|
26
|
-
const providers = new Map()
|
|
27
|
-
/* 失败按插件 name 键控:同一插件重试成功后清除旧失败,健康检查不再永久红。
|
|
28
|
-
* 旧实现是只增数组,一次瞬时失败就让 failures.length===0 的断言永远失败。 */
|
|
29
|
-
const failures = new Map()
|
|
30
|
-
let shuttingDown = false
|
|
31
|
-
let shutdown
|
|
32
|
-
|
|
33
|
-
function error(code, message, detail = {}) {
|
|
34
|
-
return new AbiError(code, message, detail)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function capture(reason, plugin, kind, phase) {
|
|
38
|
-
const normalized = toAbiError(reason, ERROR_CODES.E_ADAPTER_THREW, { plugin, kind, phase })
|
|
39
|
-
normalized.detail = { ...normalized.detail, plugin, kind, phase }
|
|
40
|
-
failures.set(plugin, normalized)
|
|
41
|
-
log?.error?.(`[foundation] ${normalized.message}`)
|
|
42
|
-
return normalized
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function adapterOf(kind) {
|
|
46
|
-
const adapter = adapters[kind]
|
|
47
|
-
if (!adapter || typeof adapter.compile !== 'function') {
|
|
48
|
-
throw error(ERROR_CODES.E_KIND_UNAVAILABLE, `接口 ${kind} 已定义但内核没有注册适配器`, { kind })
|
|
49
|
-
}
|
|
50
|
-
return adapter
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function capability(name) {
|
|
54
|
-
const native = capabilityMap()[name]
|
|
55
|
-
if (native) return native
|
|
56
|
-
const owners = providers.get(name)
|
|
57
|
-
return owners?.values().next().value?.version || null
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function capabilityView() {
|
|
61
|
-
const view = { ...capabilityMap() }
|
|
62
|
-
for (const name of providers.keys()) view[name] ??= capability(name)
|
|
63
|
-
return view
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function removeProvides(record) {
|
|
67
|
-
for (const offered of record.spec.provides) {
|
|
68
|
-
const owners = providers.get(offered.name)
|
|
69
|
-
owners?.delete(record)
|
|
70
|
-
if (!owners?.size) providers.delete(offered.name)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function publishProvides(record) {
|
|
75
|
-
for (const offered of record.spec.provides) {
|
|
76
|
-
if (!providers.has(offered.name)) providers.set(offered.name, new Map())
|
|
77
|
-
providers.get(offered.name).set(record, { version: offered.range })
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function releaseClaims(record) {
|
|
82
|
-
for (const key of record.claims) {
|
|
83
|
-
if (uniques.get(key) === record) uniques.delete(key)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function cleanup(record) {
|
|
88
|
-
if (record.cleanupStarted) return record.cleanupResult || record.cleanupTask
|
|
89
|
-
record.cleanupStarted = true
|
|
90
|
-
let settle
|
|
91
|
-
record.cleanupTask = new Promise((resolve) => { settle = resolve })
|
|
92
|
-
const clean = sequence([...record.entries].reverse(), (entry) => {
|
|
93
|
-
try {
|
|
94
|
-
const result = entry.instance.dispose?.()
|
|
95
|
-
if (thenable(result)) {
|
|
96
|
-
return Promise.resolve(result).catch((reason) => {
|
|
97
|
-
record.cleanupErrors.push(capture(reason, record.spec.name, entry.impl.kind, 'dispose'))
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
} catch (reason) {
|
|
101
|
-
record.cleanupErrors.push(capture(reason, record.spec.name, entry.impl.kind, 'dispose'))
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
const done = () => {
|
|
105
|
-
record.resourcesReleased = record.cleanupErrors.length === 0
|
|
106
|
-
if (record.resourcesReleased) releaseClaims(record)
|
|
107
|
-
record.cleanupResult = { ok: record.resourcesReleased, errors: [...record.cleanupErrors] }
|
|
108
|
-
settle(record.cleanupResult)
|
|
109
|
-
return record.cleanupResult
|
|
110
|
-
}
|
|
111
|
-
if (thenable(clean)) {
|
|
112
|
-
/* done 必达:即便清理序列意外 reject,也要结算 cleanupTask,避免挂起。 */
|
|
113
|
-
clean.then(done, done)
|
|
114
|
-
return record.cleanupTask
|
|
115
|
-
}
|
|
116
|
-
return done()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function disposeRecord(record) {
|
|
120
|
-
if (record.disposal) return record.disposal
|
|
121
|
-
let settle
|
|
122
|
-
// Publish the task before abort/cleanup callbacks; either can reenter disposal.
|
|
123
|
-
record.disposal = new Promise((resolve) => { settle = resolve })
|
|
124
|
-
record.stopRequested = true
|
|
125
|
-
record.controller.abort()
|
|
126
|
-
record.status = 'disposing'
|
|
127
|
-
removeProvides(record)
|
|
128
|
-
const finish = () => {
|
|
129
|
-
const result = cleanup(record)
|
|
130
|
-
const complete = (outcome) => {
|
|
131
|
-
record.status = outcome.ok ? 'disposed' : 'failed'
|
|
132
|
-
if (outcome.ok && plugins.get(record.spec.name) === record) plugins.delete(record.spec.name)
|
|
133
|
-
return outcome
|
|
134
|
-
}
|
|
135
|
-
return thenable(result) ? result.then(complete) : complete(result)
|
|
136
|
-
}
|
|
137
|
-
// An in-flight start must settle before stop, otherwise resources could reappear after unload.
|
|
138
|
-
const result = record.inStart ? record.startSettled.then(finish) : finish()
|
|
139
|
-
/* settle 必达:result 一旦 reject(如 startSettled 链意外抛错),旧 .then(settle)
|
|
140
|
-
* 不会执行 → disposal 永久挂起 + unhandledRejection。这里补 rejection 分支。 */
|
|
141
|
-
Promise.resolve(result).then(settle, (reason) => {
|
|
142
|
-
record.status = 'failed'
|
|
143
|
-
settle({ ok: false, errors: [toAbiError(reason, ERROR_CODES.E_ADAPTER_THREW, { plugin: record.spec.name, phase: 'dispose' })] })
|
|
144
|
-
})
|
|
145
|
-
return record.disposal
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function mount(spec, config = {}, context = {}) {
|
|
149
|
-
if (shuttingDown) throw error('E_KERNEL_CLOSED', '内核已关闭,不能挂载插件')
|
|
150
|
-
if (!spec || spec.kind !== 'plugin' || !Array.isArray(spec.implements)
|
|
151
|
-
|| !Array.isArray(spec.requires) || !Array.isArray(spec.provides)) {
|
|
152
|
-
throw error(ERROR_CODES.E_PLUGIN_SHAPE, 'mount 需要 definePlugin 产出的插件描述符')
|
|
153
|
-
}
|
|
154
|
-
if (spec.apiVersion !== abiMajor) {
|
|
155
|
-
throw error(ERROR_CODES.E_ABI_MISMATCH, `插件 ${spec.name} 声明 ABI v${spec.apiVersion},内核为 v${abiMajor}`)
|
|
156
|
-
}
|
|
157
|
-
const previous = plugins.get(spec.name)
|
|
158
|
-
if (previous && previous.status !== 'disposed' && previous.status !== 'failed') {
|
|
159
|
-
throw error(ERROR_CODES.E_DUP_PLUGIN, `插件 ${spec.name} 已挂载`)
|
|
160
|
-
}
|
|
161
|
-
if (previous) {
|
|
162
|
-
// 上一次卸载没走完(宿主没登记 disposer,或清理失败)时,残留记录会一直占着 name。
|
|
163
|
-
// 这里摘掉它并尽力回收,否则「关掉插件再启用」会永久失败在 E_DUP_PLUGIN。
|
|
164
|
-
plugins.delete(spec.name)
|
|
165
|
-
void previous.handle?.dispose?.()
|
|
166
|
-
}
|
|
167
|
-
const missing = spec.requires.filter((need) => need.name.startsWith('os.')
|
|
168
|
-
&& !satisfies(capabilityMap()[need.name] || '', need.range))
|
|
169
|
-
if (missing.length) {
|
|
170
|
-
throw error(ERROR_CODES.E_CAP_MISSING, `插件 ${spec.name} 需要的能力不可用:${missing.map((r) => r.raw).join(', ')}`,
|
|
171
|
-
{ plugin: spec.name, missing })
|
|
172
|
-
}
|
|
173
|
-
const claims = []
|
|
174
|
-
for (const impl of spec.implements) {
|
|
175
|
-
const { definition, errors } = validateInterface(impl)
|
|
176
|
-
if (!definition) throw error(ERROR_CODES.E_KIND_UNKNOWN, `未知接口种类 ${impl?.kind}`)
|
|
177
|
-
if (errors.length) throw error(ERROR_CODES.E_SCHEMA, `${impl.kind} 描述符非法:${errors.join(';')}`)
|
|
178
|
-
adapterOf(impl.kind)
|
|
179
|
-
if (definition.unique) {
|
|
180
|
-
const key = definition.uniqueBy ? `${impl.kind}:${impl[definition.uniqueBy]}` : impl.kind
|
|
181
|
-
if (uniques.has(key) || claims.includes(key)) {
|
|
182
|
-
throw error(ERROR_CODES.E_DUP_INTERFACE, `接口 ${key} 已被占用`, { key })
|
|
183
|
-
}
|
|
184
|
-
claims.push(key)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
for (const offered of spec.provides) {
|
|
188
|
-
if (offered.name.startsWith('os.') || Object.hasOwn(capabilityMap(), offered.name)) {
|
|
189
|
-
throw error('E_CAP_RESERVED', `应用不能提供宿主保留能力 ${offered.name}`)
|
|
190
|
-
}
|
|
191
|
-
const conflicting = [...plugins.values()].find((record) => !record.resourcesReleased && record.status !== 'disposed'
|
|
192
|
-
&& record.spec.provides.some((item) => item.name === offered.name && item.range !== offered.range))
|
|
193
|
-
if (conflicting) throw error('E_CAP_CONFLICT', `能力 ${offered.name} 的提供版本冲突`, { owner: conflicting.spec.name })
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const record = {
|
|
197
|
-
spec, claims, entries: [], controller: new AbortController(), status: 'starting',
|
|
198
|
-
stopRequested: false, inStart: false, cleanupStarted: false, cleanupErrors: [], startError: null,
|
|
199
|
-
}
|
|
200
|
-
for (const key of claims) uniques.set(key, record)
|
|
201
|
-
try {
|
|
202
|
-
for (const impl of spec.implements) {
|
|
203
|
-
const instance = adapterOf(impl.kind).compile(impl, {
|
|
204
|
-
spec, config, context, log, loader: api, signal: record.controller.signal,
|
|
205
|
-
})
|
|
206
|
-
if (thenable(instance)) throw error(ERROR_CODES.E_PLUGIN_SHAPE, 'compile 必须同步返回资源实例')
|
|
207
|
-
record.entries.push({ impl, instance: instance || {} })
|
|
208
|
-
}
|
|
209
|
-
} catch (reason) {
|
|
210
|
-
const normalized = toAbiError(reason, ERROR_CODES.E_ADAPTER_THREW, { plugin: spec.name, phase: 'compile' })
|
|
211
|
-
removeProvides(record)
|
|
212
|
-
record.status = 'failed'
|
|
213
|
-
record.startSettled = Promise.resolve()
|
|
214
|
-
record.ready = record.startSettled
|
|
215
|
-
// Reserve before invoking user cleanup: a disposer may initiate global shutdown.
|
|
216
|
-
plugins.set(spec.name, record)
|
|
217
|
-
const rollback = cleanup(record)
|
|
218
|
-
const finishRollback = (result) => {
|
|
219
|
-
if (result.ok && plugins.get(spec.name) === record) plugins.delete(spec.name)
|
|
220
|
-
}
|
|
221
|
-
if (thenable(rollback)) rollback.then(finishRollback)
|
|
222
|
-
else finishRollback(rollback)
|
|
223
|
-
throw normalized
|
|
224
|
-
}
|
|
225
|
-
plugins.set(spec.name, record)
|
|
226
|
-
// Sync-only interfaces are operational after compilation, preserving existing skill registration behavior.
|
|
227
|
-
const hasStart = record.entries.some((entry) => typeof entry.instance.start === 'function')
|
|
228
|
-
if (!hasStart) {
|
|
229
|
-
record.status = 'ready'
|
|
230
|
-
failures.delete(spec.name)
|
|
231
|
-
publishProvides(record)
|
|
232
|
-
}
|
|
233
|
-
record.startSettled = Promise.resolve().then(async () => {
|
|
234
|
-
if (record.stopRequested || !hasStart) return
|
|
235
|
-
record.inStart = true
|
|
236
|
-
try {
|
|
237
|
-
for (const entry of record.entries) {
|
|
238
|
-
if (record.stopRequested) break
|
|
239
|
-
if (typeof entry.instance.start === 'function') {
|
|
240
|
-
try {
|
|
241
|
-
await entry.instance.start({ signal: record.controller.signal })
|
|
242
|
-
} catch (reason) {
|
|
243
|
-
record.startError = capture(reason, spec.name, entry.impl.kind, 'start')
|
|
244
|
-
break
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} finally {
|
|
249
|
-
record.inStart = false
|
|
250
|
-
}
|
|
251
|
-
})
|
|
252
|
-
record.ready = record.startSettled.then(async () => {
|
|
253
|
-
if (record.stopRequested) return
|
|
254
|
-
if (record.startError) {
|
|
255
|
-
record.status = 'failed'
|
|
256
|
-
removeProvides(record)
|
|
257
|
-
await cleanup(record)
|
|
258
|
-
// 启动失败的记录必须让出 name,否则重试挂载永远撞 E_DUP_PLUGIN。
|
|
259
|
-
if (plugins.get(spec.name) === record) plugins.delete(spec.name)
|
|
260
|
-
} else {
|
|
261
|
-
record.status = 'ready'
|
|
262
|
-
failures.delete(spec.name)
|
|
263
|
-
publishProvides(record)
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
const handle = {
|
|
267
|
-
name: spec.name, spec, interfaces: record.entries.map((entry) => entry.impl.kind),
|
|
268
|
-
ready: record.ready,
|
|
269
|
-
get status() { return record.status },
|
|
270
|
-
async result() {
|
|
271
|
-
await record.ready
|
|
272
|
-
return { ok: record.status === 'ready', status: record.status, error: record.startError, cleanupErrors: [...record.cleanupErrors] }
|
|
273
|
-
},
|
|
274
|
-
async waitUntilReady() {
|
|
275
|
-
const result = await handle.result()
|
|
276
|
-
if (!result.ok) throw result.error || error('E_NOT_READY', `插件 ${spec.name} 未就绪(${result.status})`)
|
|
277
|
-
return handle
|
|
278
|
-
},
|
|
279
|
-
dispose: () => disposeRecord(record),
|
|
280
|
-
}
|
|
281
|
-
record.handle = handle
|
|
282
|
-
return handle
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function unresolved() {
|
|
286
|
-
const out = []
|
|
287
|
-
for (const { spec } of plugins.values()) {
|
|
288
|
-
for (const need of spec.requires) {
|
|
289
|
-
const actual = capability(need.name)
|
|
290
|
-
if (actual && satisfies(actual, need.range)) continue
|
|
291
|
-
out.push({ plugin: spec.name, capability: need.name, range: need.range,
|
|
292
|
-
actual, reason: actual ? 'incompatible' : 'missing' })
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return out
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function report() {
|
|
299
|
-
return {
|
|
300
|
-
abiVersion: abiMajor,
|
|
301
|
-
plugins: [...plugins.values()].map((record) => ({
|
|
302
|
-
name: record.spec.name, status: record.status,
|
|
303
|
-
interfaces: record.entries.map((entry) => entry.impl.kind),
|
|
304
|
-
requires: record.spec.requires.map((r) => r.raw), provides: record.spec.provides.map((p) => p.raw),
|
|
305
|
-
})),
|
|
306
|
-
capabilities: capabilityView(), unresolved: unresolved(),
|
|
307
|
-
failures: [...failures.values()].map((reason) => ({ code: reason.code, message: reason.message, detail: reason.detail })),
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function disposeAll() {
|
|
312
|
-
if (shutdown) return shutdown
|
|
313
|
-
shuttingDown = true
|
|
314
|
-
const records = [...plugins.values()].reverse()
|
|
315
|
-
// Stop every pending start now, not after a preceding plugin's async cleanup.
|
|
316
|
-
for (const record of records) {
|
|
317
|
-
record.stopRequested = true
|
|
318
|
-
record.controller.abort()
|
|
319
|
-
}
|
|
320
|
-
const pending = sequence(records, (record) => disposeRecord(record))
|
|
321
|
-
shutdown = Promise.resolve(pending).then(() => ({ ok: ![...plugins.values()].some((r) => r.cleanupErrors.length) }))
|
|
322
|
-
return shutdown
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* 显式强制释放出口(运维/HMR 用):dispose 失败时「保留所有权」是有意设计,
|
|
327
|
-
* 但一次清理失败会把 name/unique 永久锁死,重挂永远撞 E_DUP_INTERFACE。
|
|
328
|
-
* 这里提供一个人工出口:释放 name/unique/provides 占用,让重挂得以进行。
|
|
329
|
-
* 它**不假装资源已清理**——cleanupErrors 原样保留并返回,调用方须知情。
|
|
330
|
-
*/
|
|
331
|
-
function forceRelease(name) {
|
|
332
|
-
const record = plugins.get(name)
|
|
333
|
-
if (!record) return { ok: false, reason: 'no-record' }
|
|
334
|
-
releaseClaims(record)
|
|
335
|
-
removeProvides(record)
|
|
336
|
-
record.resourcesReleased = true
|
|
337
|
-
record.status = 'disposed'
|
|
338
|
-
plugins.delete(name)
|
|
339
|
-
failures.delete(name)
|
|
340
|
-
return { ok: true, forced: true, cleanupErrors: [...record.cleanupErrors] }
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const api = Object.freeze({ mount, report, capability, disposeAll, forceRelease, get size() { return plugins.size } })
|
|
344
|
-
return api
|
|
345
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 极简 schema 校验器:只覆盖 ABI 描述符需要的子集,不引入依赖。
|
|
3
|
-
*
|
|
4
|
-
* 支持的约束:type(含类型数组)/ required / properties / additionalProperties /
|
|
5
|
-
* items / minItems / enum / pattern / min / max / minLength / maxLength。
|
|
6
|
-
*
|
|
7
|
-
* 刻意不做的事:$ref、oneOf/anyOf、format、默认值填充。描述符是代码不是配置文件,
|
|
8
|
-
* 需要更强表达力时写 `extra()` 校验,而不是把 schema 语言做大。
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const TYPE_CHECKS = {
|
|
12
|
-
string: (v) => typeof v === 'string',
|
|
13
|
-
number: (v) => typeof v === 'number' && Number.isFinite(v),
|
|
14
|
-
integer: (v) => Number.isInteger(v),
|
|
15
|
-
boolean: (v) => typeof v === 'boolean',
|
|
16
|
-
object: (v) => v !== null && typeof v === 'object' && !Array.isArray(v),
|
|
17
|
-
array: (v) => Array.isArray(v),
|
|
18
|
-
function: (v) => typeof v === 'function',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function describe(value) {
|
|
22
|
-
if (value === null) return 'null'
|
|
23
|
-
if (Array.isArray(value)) return 'array'
|
|
24
|
-
return typeof value
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @param {unknown} value
|
|
29
|
-
* @param {object} schema
|
|
30
|
-
* @param {string} [path] 出错时的字段路径根
|
|
31
|
-
* @returns {string[]} 错误列表;空数组表示通过
|
|
32
|
-
*/
|
|
33
|
-
export function validateSchema(value, schema, path = '$') {
|
|
34
|
-
const errors = []
|
|
35
|
-
visit(value, schema, path, errors)
|
|
36
|
-
return errors
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function visit(value, schema, path, errors) {
|
|
40
|
-
if (!schema) return
|
|
41
|
-
|
|
42
|
-
if (schema.type !== undefined) {
|
|
43
|
-
const types = Array.isArray(schema.type) ? schema.type : [schema.type]
|
|
44
|
-
const known = types.filter((type) => TYPE_CHECKS[type])
|
|
45
|
-
if (known.length !== types.length) {
|
|
46
|
-
errors.push(`${path} 的 schema 声明了未知类型 ${types.join('|')}`)
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
if (!types.some((type) => TYPE_CHECKS[type](value))) {
|
|
50
|
-
errors.push(`${path} 应为 ${types.join('|')},实际 ${describe(value)}`)
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (typeof value === 'string') {
|
|
56
|
-
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
57
|
-
errors.push(`${path} 长度不得小于 ${schema.minLength}`)
|
|
58
|
-
}
|
|
59
|
-
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
60
|
-
errors.push(`${path} 长度不得大于 ${schema.maxLength}`)
|
|
61
|
-
}
|
|
62
|
-
if (schema.pattern && !new RegExp(schema.pattern).test(value)) {
|
|
63
|
-
errors.push(`${path} 不匹配 ${schema.pattern}`)
|
|
64
|
-
}
|
|
65
|
-
if (schema.enum && !schema.enum.includes(value)) {
|
|
66
|
-
errors.push(`${path} 必须是 ${schema.enum.join(' | ')} 之一`)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (typeof value === 'number') {
|
|
71
|
-
if (schema.min !== undefined && value < schema.min) errors.push(`${path} 不得小于 ${schema.min}`)
|
|
72
|
-
if (schema.max !== undefined && value > schema.max) errors.push(`${path} 不得大于 ${schema.max}`)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (Array.isArray(value)) {
|
|
76
|
-
if (schema.minItems !== undefined && value.length < schema.minItems) {
|
|
77
|
-
errors.push(`${path} 至少需要 ${schema.minItems} 项`)
|
|
78
|
-
}
|
|
79
|
-
if (schema.items) {
|
|
80
|
-
value.forEach((item, index) => visit(item, schema.items, `${path}[${index}]`, errors))
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
85
|
-
const props = schema.properties || {}
|
|
86
|
-
for (const key of schema.required || []) {
|
|
87
|
-
if (value[key] === undefined) errors.push(`${path}.${key} 必填`)
|
|
88
|
-
}
|
|
89
|
-
if (schema.additionalProperties === false) {
|
|
90
|
-
for (const key of Object.keys(value)) {
|
|
91
|
-
if (!(key in props)) errors.push(`${path}.${key} 未知字段`)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
for (const [key, sub] of Object.entries(props)) {
|
|
95
|
-
if (value[key] !== undefined) visit(value[key], sub, `${path}.${key}`, errors)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|