@workerstack/clients 0.0.0-stage → 1.0.0-rc.24
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/LICENSE +21 -0
- package/README.md +619 -2
- package/bin/honey-clients.js +94 -0
- package/dist/cli.d.ts +102 -0
- package/dist/cli.js +190 -0
- package/dist/emit/cli/channels.d.ts +73 -0
- package/dist/emit/cli/channels.js +197 -0
- package/dist/emit/cli/commands.d.ts +27 -0
- package/dist/emit/cli/commands.js +187 -0
- package/dist/emit/cli/discovery.d.ts +35 -0
- package/dist/emit/cli/discovery.js +202 -0
- package/dist/emit/cli/flags.d.ts +59 -0
- package/dist/emit/cli/flags.js +186 -0
- package/dist/emit/cli/index.d.ts +1 -0
- package/dist/emit/cli/index.js +1 -0
- package/dist/emit/cli/install.d.ts +37 -0
- package/dist/emit/cli/install.js +88 -0
- package/dist/emit/cli/layout.d.ts +23 -0
- package/dist/emit/cli/layout.js +118 -0
- package/dist/emit/cli/module.d.ts +30 -0
- package/dist/emit/cli/module.js +186 -0
- package/dist/emit/cli/release.d.ts +40 -0
- package/dist/emit/cli/release.js +183 -0
- package/dist/emit/cli/skills.d.ts +11 -0
- package/dist/emit/cli/skills.js +56 -0
- package/dist/emit/csharp/errors.d.ts +7 -0
- package/dist/emit/csharp/errors.js +69 -0
- package/dist/emit/csharp/index.d.ts +1 -0
- package/dist/emit/csharp/index.js +1 -0
- package/dist/emit/csharp/json.d.ts +13 -0
- package/dist/emit/csharp/json.js +113 -0
- package/dist/emit/csharp/realtime.d.ts +10 -0
- package/dist/emit/csharp/realtime.js +33 -0
- package/dist/emit/csharp/sdk-answer.d.ts +48 -0
- package/dist/emit/csharp/sdk-answer.js +85 -0
- package/dist/emit/csharp/sdk-body.d.ts +10 -0
- package/dist/emit/csharp/sdk-body.js +87 -0
- package/dist/emit/csharp/sdk-client.d.ts +32 -0
- package/dist/emit/csharp/sdk-client.js +177 -0
- package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
- package/dist/emit/csharp/sdk-csproj.js +136 -0
- package/dist/emit/csharp/sdk-doc.d.ts +12 -0
- package/dist/emit/csharp/sdk-doc.js +35 -0
- package/dist/emit/csharp/sdk-method.d.ts +26 -0
- package/dist/emit/csharp/sdk-method.js +187 -0
- package/dist/emit/csharp/sdk-plan.d.ts +38 -0
- package/dist/emit/csharp/sdk-plan.js +1 -0
- package/dist/emit/csharp/sdk.d.ts +40 -0
- package/dist/emit/csharp/sdk.js +105 -0
- package/dist/emit/csharp/sse.d.ts +18 -0
- package/dist/emit/csharp/sse.js +29 -0
- package/dist/emit/csharp/transport.d.ts +11 -0
- package/dist/emit/csharp/transport.js +67 -0
- package/dist/emit/csharp/types-enum.d.ts +19 -0
- package/dist/emit/csharp/types-enum.js +63 -0
- package/dist/emit/csharp/types-names.d.ts +33 -0
- package/dist/emit/csharp/types-names.js +182 -0
- package/dist/emit/csharp/types-record.d.ts +25 -0
- package/dist/emit/csharp/types-record.js +65 -0
- package/dist/emit/csharp/types-union.d.ts +27 -0
- package/dist/emit/csharp/types-union.js +113 -0
- package/dist/emit/csharp/types.d.ts +36 -0
- package/dist/emit/csharp/types.js +126 -0
- package/dist/emit/csharp/ws.d.ts +20 -0
- package/dist/emit/csharp/ws.js +14 -0
- package/dist/emit/go/errors.d.ts +7 -0
- package/dist/emit/go/errors.js +44 -0
- package/dist/emit/go/http.d.ts +11 -0
- package/dist/emit/go/http.js +50 -0
- package/dist/emit/go/index.d.ts +1 -0
- package/dist/emit/go/index.js +1 -0
- package/dist/emit/go/module-path.d.ts +2 -0
- package/dist/emit/go/module-path.js +27 -0
- package/dist/emit/go/sdk-answer.d.ts +28 -0
- package/dist/emit/go/sdk-answer.js +41 -0
- package/dist/emit/go/sdk-body.d.ts +24 -0
- package/dist/emit/go/sdk-body.js +76 -0
- package/dist/emit/go/sdk-client.d.ts +29 -0
- package/dist/emit/go/sdk-client.js +141 -0
- package/dist/emit/go/sdk-method.d.ts +68 -0
- package/dist/emit/go/sdk-method.js +172 -0
- package/dist/emit/go/sdk-mirror.d.ts +23 -0
- package/dist/emit/go/sdk-mirror.js +97 -0
- package/dist/emit/go/sdk-opts.d.ts +55 -0
- package/dist/emit/go/sdk-opts.js +100 -0
- package/dist/emit/go/sdk.d.ts +26 -0
- package/dist/emit/go/sdk.js +111 -0
- package/dist/emit/go/sse.d.ts +16 -0
- package/dist/emit/go/sse.js +26 -0
- package/dist/emit/go/types-codec.d.ts +15 -0
- package/dist/emit/go/types-codec.js +171 -0
- package/dist/emit/go/types-names.d.ts +14 -0
- package/dist/emit/go/types-names.js +64 -0
- package/dist/emit/go/types-struct.d.ts +29 -0
- package/dist/emit/go/types-struct.js +65 -0
- package/dist/emit/go/types-union.d.ts +17 -0
- package/dist/emit/go/types-union.js +84 -0
- package/dist/emit/go/types.d.ts +32 -0
- package/dist/emit/go/types.js +177 -0
- package/dist/emit/go/ws.d.ts +12 -0
- package/dist/emit/go/ws.js +70 -0
- package/dist/emit/java/gradle.d.ts +57 -0
- package/dist/emit/java/gradle.js +221 -0
- package/dist/emit/java/index.d.ts +2 -0
- package/dist/emit/java/index.js +2 -0
- package/dist/emit/java/json.d.ts +13 -0
- package/dist/emit/java/json.js +84 -0
- package/dist/emit/java/layout-ast.d.ts +146 -0
- package/dist/emit/java/layout-ast.js +102 -0
- package/dist/emit/java/layout-decl.d.ts +20 -0
- package/dist/emit/java/layout-decl.js +155 -0
- package/dist/emit/java/layout-doc.d.ts +55 -0
- package/dist/emit/java/layout-doc.js +166 -0
- package/dist/emit/java/layout-dot.d.ts +18 -0
- package/dist/emit/java/layout-dot.js +127 -0
- package/dist/emit/java/layout-strings.d.ts +8 -0
- package/dist/emit/java/layout-strings.js +76 -0
- package/dist/emit/java/layout-types.d.ts +11 -0
- package/dist/emit/java/layout-types.js +95 -0
- package/dist/emit/java/layout-visitor.d.ts +38 -0
- package/dist/emit/java/layout-visitor.js +232 -0
- package/dist/emit/java/layout.d.ts +61 -0
- package/dist/emit/java/layout.js +121 -0
- package/dist/emit/java/models-enum.d.ts +17 -0
- package/dist/emit/java/models-enum.js +51 -0
- package/dist/emit/java/models-names.d.ts +29 -0
- package/dist/emit/java/models-names.js +97 -0
- package/dist/emit/java/models-record.d.ts +24 -0
- package/dist/emit/java/models-record.js +79 -0
- package/dist/emit/java/models-union.d.ts +27 -0
- package/dist/emit/java/models-union.js +86 -0
- package/dist/emit/java/models.d.ts +28 -0
- package/dist/emit/java/models.js +118 -0
- package/dist/emit/java/realtime.d.ts +50 -0
- package/dist/emit/java/realtime.js +69 -0
- package/dist/emit/java/sdk-client.d.ts +66 -0
- package/dist/emit/java/sdk-client.js +207 -0
- package/dist/emit/java/sdk-decl.d.ts +11 -0
- package/dist/emit/java/sdk-decl.js +63 -0
- package/dist/emit/java/sdk-errors.d.ts +13 -0
- package/dist/emit/java/sdk-errors.js +141 -0
- package/dist/emit/java/sdk-headers.d.ts +12 -0
- package/dist/emit/java/sdk-headers.js +74 -0
- package/dist/emit/java/sdk-mirror.d.ts +14 -0
- package/dist/emit/java/sdk-mirror.js +107 -0
- package/dist/emit/java/sdk-models.d.ts +16 -0
- package/dist/emit/java/sdk-models.js +68 -0
- package/dist/emit/java/sdk-op.d.ts +57 -0
- package/dist/emit/java/sdk-op.js +216 -0
- package/dist/emit/java/sdk-params.d.ts +38 -0
- package/dist/emit/java/sdk-params.js +133 -0
- package/dist/emit/java/sdk-plan.d.ts +52 -0
- package/dist/emit/java/sdk-plan.js +1 -0
- package/dist/emit/java/sdk-record.d.ts +16 -0
- package/dist/emit/java/sdk-record.js +99 -0
- package/dist/emit/java/sdk.d.ts +49 -0
- package/dist/emit/java/sdk.js +216 -0
- package/dist/emit/java/sse.d.ts +35 -0
- package/dist/emit/java/sse.js +57 -0
- package/dist/emit/java/ws.d.ts +27 -0
- package/dist/emit/java/ws.js +31 -0
- package/dist/emit/mcp/annotations.d.ts +15 -0
- package/dist/emit/mcp/annotations.js +15 -0
- package/dist/emit/mcp/files.d.ts +18 -0
- package/dist/emit/mcp/files.js +42 -0
- package/dist/emit/mcp/index.d.ts +3 -0
- package/dist/emit/mcp/index.js +3 -0
- package/dist/emit/mcp/literal.d.ts +2 -0
- package/dist/emit/mcp/literal.js +33 -0
- package/dist/emit/mcp/mounted.d.ts +21 -0
- package/dist/emit/mcp/mounted.js +89 -0
- package/dist/emit/mcp/output-schema.d.ts +18 -0
- package/dist/emit/mcp/output-schema.js +38 -0
- package/dist/emit/mcp/registry.d.ts +23 -0
- package/dist/emit/mcp/registry.js +83 -0
- package/dist/emit/mcp/runtime.d.ts +10 -0
- package/dist/emit/mcp/runtime.js +47 -0
- package/dist/emit/mcp/schema.d.ts +19 -0
- package/dist/emit/mcp/schema.js +88 -0
- package/dist/emit/mcp/server.d.ts +30 -0
- package/dist/emit/mcp/server.js +246 -0
- package/dist/emit/mcp/tools.d.ts +51 -0
- package/dist/emit/mcp/tools.js +153 -0
- package/dist/emit/python/errors.d.ts +8 -0
- package/dist/emit/python/errors.js +68 -0
- package/dist/emit/python/index.d.ts +1 -0
- package/dist/emit/python/index.js +1 -0
- package/dist/emit/python/realtime.d.ts +10 -0
- package/dist/emit/python/realtime.js +33 -0
- package/dist/emit/python/sdk-answer.d.ts +49 -0
- package/dist/emit/python/sdk-answer.js +89 -0
- package/dist/emit/python/sdk-body.d.ts +11 -0
- package/dist/emit/python/sdk-body.js +40 -0
- package/dist/emit/python/sdk-client.d.ts +36 -0
- package/dist/emit/python/sdk-client.js +163 -0
- package/dist/emit/python/sdk-doc.d.ts +9 -0
- package/dist/emit/python/sdk-doc.js +32 -0
- package/dist/emit/python/sdk-imports.d.ts +14 -0
- package/dist/emit/python/sdk-imports.js +38 -0
- package/dist/emit/python/sdk-method.d.ts +29 -0
- package/dist/emit/python/sdk-method.js +183 -0
- package/dist/emit/python/sdk-plan.d.ts +33 -0
- package/dist/emit/python/sdk-plan.js +1 -0
- package/dist/emit/python/sdk-pyproject.d.ts +27 -0
- package/dist/emit/python/sdk-pyproject.js +103 -0
- package/dist/emit/python/sdk.d.ts +22 -0
- package/dist/emit/python/sdk.js +154 -0
- package/dist/emit/python/sse.d.ts +12 -0
- package/dist/emit/python/sse.js +23 -0
- package/dist/emit/python/transport.d.ts +15 -0
- package/dist/emit/python/transport.js +60 -0
- package/dist/emit/python/types-dict.d.ts +31 -0
- package/dist/emit/python/types-dict.js +45 -0
- package/dist/emit/python/types-names.d.ts +16 -0
- package/dist/emit/python/types-names.js +52 -0
- package/dist/emit/python/types-union.d.ts +32 -0
- package/dist/emit/python/types-union.js +46 -0
- package/dist/emit/python/types.d.ts +36 -0
- package/dist/emit/python/types.js +128 -0
- package/dist/emit/python/ws.d.ts +14 -0
- package/dist/emit/python/ws.js +16 -0
- package/dist/emit/rust/errors.d.ts +7 -0
- package/dist/emit/rust/errors.js +107 -0
- package/dist/emit/rust/http.d.ts +13 -0
- package/dist/emit/rust/http.js +67 -0
- package/dist/emit/rust/index.d.ts +1 -0
- package/dist/emit/rust/index.js +1 -0
- package/dist/emit/rust/realtime.d.ts +11 -0
- package/dist/emit/rust/realtime.js +29 -0
- package/dist/emit/rust/sdk-body.d.ts +19 -0
- package/dist/emit/rust/sdk-body.js +53 -0
- package/dist/emit/rust/sdk-cargo.d.ts +43 -0
- package/dist/emit/rust/sdk-cargo.js +178 -0
- package/dist/emit/rust/sdk-client.d.ts +25 -0
- package/dist/emit/rust/sdk-client.js +108 -0
- package/dist/emit/rust/sdk-method.d.ts +15 -0
- package/dist/emit/rust/sdk-method.js +119 -0
- package/dist/emit/rust/sdk-opts.d.ts +58 -0
- package/dist/emit/rust/sdk-opts.js +117 -0
- package/dist/emit/rust/sdk-plan.d.ts +33 -0
- package/dist/emit/rust/sdk-plan.js +1 -0
- package/dist/emit/rust/sdk.d.ts +23 -0
- package/dist/emit/rust/sdk.js +111 -0
- package/dist/emit/rust/sse.d.ts +19 -0
- package/dist/emit/rust/sse.js +20 -0
- package/dist/emit/rust/types-enum.d.ts +13 -0
- package/dist/emit/rust/types-enum.js +62 -0
- package/dist/emit/rust/types-names.d.ts +19 -0
- package/dist/emit/rust/types-names.js +66 -0
- package/dist/emit/rust/types-struct.d.ts +21 -0
- package/dist/emit/rust/types-struct.js +59 -0
- package/dist/emit/rust/types-union.d.ts +24 -0
- package/dist/emit/rust/types-union.js +97 -0
- package/dist/emit/rust/types.d.ts +34 -0
- package/dist/emit/rust/types.js +105 -0
- package/dist/emit/rust/ws.d.ts +21 -0
- package/dist/emit/rust/ws.js +20 -0
- package/dist/emit/shared/escape.d.ts +55 -0
- package/dist/emit/shared/escape.js +144 -0
- package/dist/emit/shared/format.d.ts +24 -0
- package/dist/emit/shared/format.js +23 -0
- package/dist/emit/shared/gofmt.d.ts +3 -0
- package/dist/emit/shared/gofmt.js +26 -0
- package/dist/emit/shared/lang.d.ts +60 -0
- package/dist/emit/shared/lang.js +233 -0
- package/dist/emit/shared/literals.d.ts +4 -0
- package/dist/emit/shared/literals.js +31 -0
- package/dist/emit/shared/metadata.d.ts +106 -0
- package/dist/emit/shared/metadata.js +130 -0
- package/dist/emit/shared/mirror.d.ts +22 -0
- package/dist/emit/shared/mirror.js +26 -0
- package/dist/emit/shared/ruff.d.ts +3 -0
- package/dist/emit/shared/ruff.js +31 -0
- package/dist/emit/shared/rustfmt.d.ts +3 -0
- package/dist/emit/shared/rustfmt.js +32 -0
- package/dist/emit/shared/status-keys.d.ts +7 -0
- package/dist/emit/shared/status-keys.js +67 -0
- package/dist/emit/shared/type-emitter.d.ts +19 -0
- package/dist/emit/shared/type-emitter.js +100 -0
- package/dist/emit/ts/app-client.d.ts +4 -0
- package/dist/emit/ts/app-client.js +68 -0
- package/dist/emit/ts/http.d.ts +20 -0
- package/dist/emit/ts/http.js +74 -0
- package/dist/emit/ts/package.d.ts +36 -0
- package/dist/emit/ts/package.js +126 -0
- package/dist/emit/ts/route-tree.d.ts +68 -0
- package/dist/emit/ts/route-tree.js +240 -0
- package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
- package/dist/emit/ts/sdk-types-preamble.js +123 -0
- package/dist/emit/ts/sdk-types.d.ts +13 -0
- package/dist/emit/ts/sdk-types.js +213 -0
- package/dist/emit/ts/sdk.d.ts +21 -0
- package/dist/emit/ts/sdk.js +173 -0
- package/dist/emit/ts/service-map.d.ts +40 -0
- package/dist/emit/ts/service-map.js +171 -0
- package/dist/emit/ts/tanstack-query.d.ts +12 -0
- package/dist/emit/ts/tanstack-query.js +156 -0
- package/dist/emit/ts/type-gen.d.ts +26 -0
- package/dist/emit/ts/type-gen.js +255 -0
- package/dist/emit/ts/webhooks.d.ts +19 -0
- package/dist/emit/ts/webhooks.js +81 -0
- package/dist/extract/chain.d.ts +34 -0
- package/dist/extract/chain.js +84 -0
- package/dist/extract/extract.d.ts +41 -0
- package/dist/extract/extract.js +191 -0
- package/dist/extract/serialize.d.ts +34 -0
- package/dist/extract/serialize.js +295 -0
- package/dist/extract/walk.d.ts +47 -0
- package/dist/extract/walk.js +109 -0
- package/dist/gen/args.d.ts +28 -0
- package/dist/gen/args.js +133 -0
- package/dist/gen/formatters.d.ts +62 -0
- package/dist/gen/formatters.js +146 -0
- package/dist/gen/process.d.ts +13 -0
- package/dist/gen/process.js +35 -0
- package/dist/gen/shipped.d.ts +17 -0
- package/dist/gen/shipped.js +55 -0
- package/dist/gen/targets.d.ts +93 -0
- package/dist/gen/targets.js +171 -0
- package/dist/gen/write.d.ts +33 -0
- package/dist/gen/write.js +118 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +15 -0
- package/dist/ir/build.d.ts +37 -0
- package/dist/ir/build.js +152 -0
- package/dist/ir/load.d.ts +11 -0
- package/dist/ir/load.js +112 -0
- package/dist/ir/model.d.ts +206 -0
- package/dist/ir/model.js +5 -0
- package/dist/ir/resolve-refs.d.ts +11 -0
- package/dist/ir/resolve-refs.js +66 -0
- package/dist/ir/resource-tree.d.ts +9 -0
- package/dist/ir/resource-tree.js +53 -0
- package/dist/ir/route-tree-intern.d.ts +18 -0
- package/dist/ir/route-tree-intern.js +174 -0
- package/dist/ir/schema.d.ts +11 -0
- package/dist/ir/schema.js +192 -0
- package/dist/ir/sdk-model.d.ts +86 -0
- package/dist/ir/sdk-model.js +204 -0
- package/dist/ir/slots.d.ts +42 -0
- package/dist/ir/slots.js +245 -0
- package/dist/runtime/cli/body.go +176 -0
- package/dist/runtime/cli/config.go +243 -0
- package/dist/runtime/cli/discovery.go +147 -0
- package/dist/runtime/cli/format.go +174 -0
- package/dist/runtime/cli/log.go +117 -0
- package/dist/runtime/cli/output.go +247 -0
- package/dist/runtime/cli/params.go +197 -0
- package/dist/runtime/cli/run.go +226 -0
- package/dist/runtime/cli/socket.go +60 -0
- package/dist/runtime/cli/stream.go +217 -0
- package/dist/runtime/cli/target.go +117 -0
- package/dist/runtime/csharp/Adapters.cs +183 -0
- package/dist/runtime/csharp/Auth.cs +56 -0
- package/dist/runtime/csharp/Body.cs +135 -0
- package/dist/runtime/csharp/Config.cs +161 -0
- package/dist/runtime/csharp/Envelope.cs +149 -0
- package/dist/runtime/csharp/Errors.cs +194 -0
- package/dist/runtime/csharp/Events.cs +155 -0
- package/dist/runtime/csharp/Exchange.cs +247 -0
- package/dist/runtime/csharp/Handler.cs +103 -0
- package/dist/runtime/csharp/Hooks.cs +128 -0
- package/dist/runtime/csharp/Invalidation.cs +102 -0
- package/dist/runtime/csharp/Json.cs +144 -0
- package/dist/runtime/csharp/Log.cs +48 -0
- package/dist/runtime/csharp/Operation.cs +33 -0
- package/dist/runtime/csharp/Path.cs +65 -0
- package/dist/runtime/csharp/Query.cs +72 -0
- package/dist/runtime/csharp/Realtime.cs +118 -0
- package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
- package/dist/runtime/csharp/Redirect.cs +53 -0
- package/dist/runtime/csharp/Result.cs +57 -0
- package/dist/runtime/csharp/Sse.cs +122 -0
- package/dist/runtime/csharp/Stale.cs +151 -0
- package/dist/runtime/csharp/Transport.cs +143 -0
- package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
- package/dist/runtime/csharp/TransportSse.cs +54 -0
- package/dist/runtime/csharp/TransportWs.cs +40 -0
- package/dist/runtime/csharp/Wire.cs +109 -0
- package/dist/runtime/csharp/Ws.cs +300 -0
- package/dist/runtime/csharp/WsDial.cs +127 -0
- package/dist/runtime/go/auth.go +127 -0
- package/dist/runtime/go/body.go +129 -0
- package/dist/runtime/go/config.go +75 -0
- package/dist/runtime/go/errors.go +185 -0
- package/dist/runtime/go/export.go +37 -0
- package/dist/runtime/go/hooks.go +53 -0
- package/dist/runtime/go/invalidation.go +112 -0
- package/dist/runtime/go/log.go +92 -0
- package/dist/runtime/go/nullable.go +64 -0
- package/dist/runtime/go/options.go +118 -0
- package/dist/runtime/go/path.go +156 -0
- package/dist/runtime/go/query.go +147 -0
- package/dist/runtime/go/realtime.go +239 -0
- package/dist/runtime/go/realtime_loop.go +208 -0
- package/dist/runtime/go/redirect.go +124 -0
- package/dist/runtime/go/request.go +222 -0
- package/dist/runtime/go/result.go +86 -0
- package/dist/runtime/go/sse.go +186 -0
- package/dist/runtime/go/stale.go +229 -0
- package/dist/runtime/go/stream.go +105 -0
- package/dist/runtime/go/transport.go +242 -0
- package/dist/runtime/go/transport_longpoll.go +121 -0
- package/dist/runtime/go/transport_sse.go +175 -0
- package/dist/runtime/go/ws.go +205 -0
- package/dist/runtime/java/Answer.java +107 -0
- package/dist/runtime/java/ApiException.java +110 -0
- package/dist/runtime/java/BinaryBody.java +36 -0
- package/dist/runtime/java/Body.java +105 -0
- package/dist/runtime/java/Call.java +23 -0
- package/dist/runtime/java/CallLog.java +51 -0
- package/dist/runtime/java/ClientConfig.java +233 -0
- package/dist/runtime/java/ConnectionState.java +12 -0
- package/dist/runtime/java/Credential.java +58 -0
- package/dist/runtime/java/Deadline.java +38 -0
- package/dist/runtime/java/Decode.java +181 -0
- package/dist/runtime/java/Envelope.java +141 -0
- package/dist/runtime/java/ErrorEnvelope.java +23 -0
- package/dist/runtime/java/EventStream.java +129 -0
- package/dist/runtime/java/Exchange.java +62 -0
- package/dist/runtime/java/FilePart.java +5 -0
- package/dist/runtime/java/Flight.java +306 -0
- package/dist/runtime/java/HoneyException.java +14 -0
- package/dist/runtime/java/Hooks.java +47 -0
- package/dist/runtime/java/Hops.java +133 -0
- package/dist/runtime/java/InvalidationConfig.java +73 -0
- package/dist/runtime/java/Json.java +23 -0
- package/dist/runtime/java/Keepalive.java +60 -0
- package/dist/runtime/java/LogEntry.java +14 -0
- package/dist/runtime/java/LongPollAdapter.java +68 -0
- package/dist/runtime/java/Operation.java +21 -0
- package/dist/runtime/java/Opt.java +121 -0
- package/dist/runtime/java/Pump.java +160 -0
- package/dist/runtime/java/RawResponse.java +48 -0
- package/dist/runtime/java/Realtime.java +152 -0
- package/dist/runtime/java/RealtimeLoop.java +371 -0
- package/dist/runtime/java/RedirectPolicy.java +13 -0
- package/dist/runtime/java/Redirects.java +126 -0
- package/dist/runtime/java/RequestContext.java +78 -0
- package/dist/runtime/java/RequestHook.java +9 -0
- package/dist/runtime/java/RequestOptions.java +91 -0
- package/dist/runtime/java/ResponseContext.java +70 -0
- package/dist/runtime/java/ResponseHook.java +12 -0
- package/dist/runtime/java/Result.java +32 -0
- package/dist/runtime/java/ResumableConnection.java +165 -0
- package/dist/runtime/java/SdkException.java +11 -0
- package/dist/runtime/java/Socket.java +301 -0
- package/dist/runtime/java/Sse.java +171 -0
- package/dist/runtime/java/SseAdapter.java +61 -0
- package/dist/runtime/java/SseEvent.java +10 -0
- package/dist/runtime/java/StaleMeta.java +16 -0
- package/dist/runtime/java/StaleTracker.java +287 -0
- package/dist/runtime/java/Transport.java +16 -0
- package/dist/runtime/java/TransportAdapter.java +14 -0
- package/dist/runtime/java/TransportConnection.java +15 -0
- package/dist/runtime/java/TransportKind.java +12 -0
- package/dist/runtime/java/TransportMessage.java +9 -0
- package/dist/runtime/java/TransportOptions.java +138 -0
- package/dist/runtime/java/TypedWebSocket.java +83 -0
- package/dist/runtime/java/UrlPath.java +49 -0
- package/dist/runtime/java/UrlQuery.java +99 -0
- package/dist/runtime/java/WsAdapter.java +52 -0
- package/dist/runtime/java/WsClose.java +47 -0
- package/dist/runtime/java/WsDial.java +148 -0
- package/dist/runtime/java/WsMessage.java +18 -0
- package/dist/runtime/mcp/call.ts +167 -0
- package/dist/runtime/mcp/files.ts +183 -0
- package/dist/runtime/mcp/guard.ts +176 -0
- package/dist/runtime/mcp/http.ts +159 -0
- package/dist/runtime/mcp/jsonrpc.ts +50 -0
- package/dist/runtime/mcp/listen.ts +76 -0
- package/dist/runtime/mcp/mount.ts +123 -0
- package/dist/runtime/mcp/protocol.ts +219 -0
- package/dist/runtime/mcp/reader.ts +57 -0
- package/dist/runtime/mcp/result.ts +85 -0
- package/dist/runtime/mcp/stdio.ts +79 -0
- package/dist/runtime/mcp/stream.ts +62 -0
- package/dist/runtime/python/__init__.py +2 -0
- package/dist/runtime/python/auth.py +67 -0
- package/dist/runtime/python/body.py +83 -0
- package/dist/runtime/python/config.py +139 -0
- package/dist/runtime/python/errors.py +213 -0
- package/dist/runtime/python/events.py +152 -0
- package/dist/runtime/python/exchange.py +298 -0
- package/dist/runtime/python/hooks.py +86 -0
- package/dist/runtime/python/invalidation.py +57 -0
- package/dist/runtime/python/log.py +60 -0
- package/dist/runtime/python/operation.py +25 -0
- package/dist/runtime/python/path.py +41 -0
- package/dist/runtime/python/query.py +48 -0
- package/dist/runtime/python/realtime.py +244 -0
- package/dist/runtime/python/redirect.py +93 -0
- package/dist/runtime/python/result.py +58 -0
- package/dist/runtime/python/send_async.py +189 -0
- package/dist/runtime/python/send_sync.py +105 -0
- package/dist/runtime/python/sse.py +81 -0
- package/dist/runtime/python/stale.py +94 -0
- package/dist/runtime/python/transport.py +157 -0
- package/dist/runtime/python/transport_longpoll.py +60 -0
- package/dist/runtime/python/transport_sse.py +60 -0
- package/dist/runtime/python/transport_ws.py +57 -0
- package/dist/runtime/python/ws.py +276 -0
- package/dist/runtime/rust/Cargo.lock +1763 -0
- package/dist/runtime/rust/answer.rs +120 -0
- package/dist/runtime/rust/auth.rs +80 -0
- package/dist/runtime/rust/body.rs +150 -0
- package/dist/runtime/rust/call.rs +200 -0
- package/dist/runtime/rust/config.rs +254 -0
- package/dist/runtime/rust/envelope.rs +84 -0
- package/dist/runtime/rust/errors.rs +235 -0
- package/dist/runtime/rust/events.rs +177 -0
- package/dist/runtime/rust/exchange.rs +287 -0
- package/dist/runtime/rust/hooks.rs +63 -0
- package/dist/runtime/rust/invalidation.rs +84 -0
- package/dist/runtime/rust/log.rs +88 -0
- package/dist/runtime/rust/nullable.rs +13 -0
- package/dist/runtime/rust/path.rs +83 -0
- package/dist/runtime/rust/query.rs +84 -0
- package/dist/runtime/rust/realtime.rs +182 -0
- package/dist/runtime/rust/realtime_loop.rs +177 -0
- package/dist/runtime/rust/redirect.rs +121 -0
- package/dist/runtime/rust/request.rs +178 -0
- package/dist/runtime/rust/result.rs +101 -0
- package/dist/runtime/rust/sse.rs +104 -0
- package/dist/runtime/rust/stale.rs +209 -0
- package/dist/runtime/rust/transport.rs +221 -0
- package/dist/runtime/rust/transport_longpoll.rs +108 -0
- package/dist/runtime/rust/transport_sse.rs +91 -0
- package/dist/runtime/rust/transport_ws.rs +75 -0
- package/dist/runtime/rust/ws.rs +322 -0
- package/dist/runtime/ts/app-types.ts +200 -0
- package/dist/runtime/ts/app.ts +104 -0
- package/dist/runtime/ts/config.ts +124 -0
- package/dist/runtime/ts/defaults.ts +48 -0
- package/dist/runtime/ts/error.ts +113 -0
- package/dist/runtime/ts/hooks.ts +92 -0
- package/dist/runtime/ts/http.ts +228 -0
- package/dist/runtime/ts/media-type.ts +36 -0
- package/dist/runtime/ts/path.ts +152 -0
- package/dist/runtime/ts/realtime-connection.ts +296 -0
- package/dist/runtime/ts/realtime-transports.ts +149 -0
- package/dist/runtime/ts/realtime.ts +293 -0
- package/dist/runtime/ts/redirect-policy.ts +17 -0
- package/dist/runtime/ts/redirects.ts +74 -0
- package/dist/runtime/ts/request.ts +239 -0
- package/dist/runtime/ts/response.ts +219 -0
- package/dist/runtime/ts/sdk-realtime.ts +10 -0
- package/dist/runtime/ts/sdk-sse.ts +55 -0
- package/dist/runtime/ts/sdk-ws.ts +21 -0
- package/dist/runtime/ts/sdk.ts +242 -0
- package/dist/runtime/ts/sse.ts +175 -0
- package/dist/runtime/ts/stale.ts +137 -0
- package/dist/runtime/ts/stream.ts +87 -0
- package/dist/runtime/ts/webhook.ts +116 -0
- package/dist/runtime/ts/ws.ts +155 -0
- package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
- package/dist/runtime/ts-tanstack-query/query.ts +261 -0
- package/package.json +135 -5
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { goString, invisible } from "../shared/escape.js";
|
|
2
|
+
import { NameScope, words } from "../shared/lang.js";
|
|
3
|
+
/** The flags every command has, and those later phases give it: a parameter never takes one of these names. */
|
|
4
|
+
export const GLOBAL_FLAGS = [
|
|
5
|
+
"api-key",
|
|
6
|
+
"base-url",
|
|
7
|
+
"config",
|
|
8
|
+
"data",
|
|
9
|
+
"format",
|
|
10
|
+
"header",
|
|
11
|
+
"help",
|
|
12
|
+
"include",
|
|
13
|
+
"json",
|
|
14
|
+
"last-event-id",
|
|
15
|
+
"max-reconnects",
|
|
16
|
+
"output",
|
|
17
|
+
"quiet",
|
|
18
|
+
"raw",
|
|
19
|
+
"reconnect-token",
|
|
20
|
+
"redirect",
|
|
21
|
+
"take",
|
|
22
|
+
"timeout",
|
|
23
|
+
"verbose",
|
|
24
|
+
"version",
|
|
25
|
+
];
|
|
26
|
+
const JSON_KIND = { enum: [], kind: "json", list: false };
|
|
27
|
+
/**
|
|
28
|
+
* Spec text as a terminal shows it in help: line ends as `\n`, and every other control character (C0 but tab, DEL, C1,
|
|
29
|
+
* the BOM, the line and paragraph separators, the bidi controls) dropped, so no spec can move the cursor, recolor a
|
|
30
|
+
* user's terminal or reorder what it shows.
|
|
31
|
+
*/
|
|
32
|
+
export const helpText = (text) => [...text.replace(/\r\n?/g, "\n")].filter((ch) => !hidden(ch.codePointAt(0))).join("");
|
|
33
|
+
/** Whether a code point is one help drops: a C0 control but tab and line feed, DEL, C1, the BOM, U+2028, U+2029, bidi. */
|
|
34
|
+
const hidden = (cp) => (cp < 0x20 && cp !== 0x09 && cp !== 0x0a) ||
|
|
35
|
+
cp === 0x7f ||
|
|
36
|
+
cp === 0xfeff ||
|
|
37
|
+
cp === 0x2028 ||
|
|
38
|
+
cp === 0x2029 ||
|
|
39
|
+
invisible(cp);
|
|
40
|
+
/** A name as a flag spells it: its words, lowercase, joined by `-`. */
|
|
41
|
+
export const kebab = (raw) => words(raw)
|
|
42
|
+
.map((word) => word.toLowerCase())
|
|
43
|
+
.join("-") || "value";
|
|
44
|
+
/** `schema` followed through refs and nullables, by the component schemas. */
|
|
45
|
+
function resolved(schema, schemas) {
|
|
46
|
+
if (schema.kind === "ref" && schemas[schema.name] !== undefined)
|
|
47
|
+
return resolved(schemas[schema.name], schemas);
|
|
48
|
+
if (schema.kind === "nullable")
|
|
49
|
+
return resolved(schema.inner, schemas);
|
|
50
|
+
return schema;
|
|
51
|
+
}
|
|
52
|
+
/** A scalar's kind: a null type reads as a string. */
|
|
53
|
+
function scalarKind(schema) {
|
|
54
|
+
if (schema.kind === "scalar") {
|
|
55
|
+
const kind = schema.type === "null" ? "string" : schema.type;
|
|
56
|
+
return { enum: (schema.enum ?? []).map(String), kind, list: false };
|
|
57
|
+
}
|
|
58
|
+
if (schema.kind === "const")
|
|
59
|
+
return { enum: [String(schema.value)], kind: schema.type ?? typeof schema.value, list: false };
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** The flag kind of a value of `schema`: a scalar, a list of scalars, else JSON. */
|
|
63
|
+
export function kindOf(schema, schemas) {
|
|
64
|
+
const at = resolved(schema, schemas);
|
|
65
|
+
const scalar = scalarKind(at);
|
|
66
|
+
if (scalar !== null)
|
|
67
|
+
return scalar;
|
|
68
|
+
const item = at.kind === "array" ? scalarKind(resolved(at.items, schemas)) : null;
|
|
69
|
+
return item === null ? JSON_KIND : { ...item, list: true };
|
|
70
|
+
}
|
|
71
|
+
/** One flag's declaration: `p.Flag(name, kind, list, required, usage, enum...)`. */
|
|
72
|
+
function flagLine(name, kind, required, usage) {
|
|
73
|
+
const args = [goString(name), goString(kind.kind), String(kind.list), String(required), goString(helpText(usage))];
|
|
74
|
+
return `\tp.Flag(${[...args, ...kind.enum.map(goString)].join(", ")})`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A flag's help with its schema default as cobra shows its own: `(default 20)`, `(default "asc")`, `(default true)`; a
|
|
78
|
+
* string quoted with its controls dropped, as spec text is; nothing for a list, an object or no default. Display only:
|
|
79
|
+
* the CLI sends only what is given.
|
|
80
|
+
*/
|
|
81
|
+
function withDefault(usage, value) {
|
|
82
|
+
const shown = typeof value === "string"
|
|
83
|
+
? JSON.stringify(helpText(value))
|
|
84
|
+
: typeof value === "number" || typeof value === "boolean"
|
|
85
|
+
? String(value)
|
|
86
|
+
: undefined;
|
|
87
|
+
return shown === undefined ? usage : [usage, `(default ${shown})`].filter((part) => part !== "").join(" ");
|
|
88
|
+
}
|
|
89
|
+
const STRING = { enum: [], kind: "string", list: false };
|
|
90
|
+
/** Each parameter flag `op` takes, path ones first, and each scalar body field's, claimed in one scope beside the global flags. */
|
|
91
|
+
export function commandFlags(op, plan, schemas) {
|
|
92
|
+
const scope = new NameScope(GLOBAL_FLAGS);
|
|
93
|
+
const lines = [];
|
|
94
|
+
const opts = [];
|
|
95
|
+
const usage = [];
|
|
96
|
+
if (plan.pathParams.length > 0) {
|
|
97
|
+
const names = plan.pathParams.map((name) => scope.claim(kebab(name)));
|
|
98
|
+
lines.push(`\tp.Path(${names.map(goString).join(", ")})`);
|
|
99
|
+
usage.push(...names.map((name, i) => ({ kind: STRING, name, param: plan.pathParams[i], positional: true, required: true })));
|
|
100
|
+
}
|
|
101
|
+
/* each param the SDK gives an Opts field, by the plan: a stream's channel param (Last-Event-ID) has none */
|
|
102
|
+
const params = (specs, fields) => {
|
|
103
|
+
for (const [param, field] of Object.entries(fields)) {
|
|
104
|
+
const spec = specs.find((each) => each.name === param);
|
|
105
|
+
const name = scope.claim(kebab(spec.name));
|
|
106
|
+
const kind = kindOf(spec.schema, schemas);
|
|
107
|
+
usage.push({ kind, name, param: spec.name, positional: false, required: spec.required === true });
|
|
108
|
+
lines.push(flagLine(name, kind, spec.required === true, withDefault(spec.description ?? "", spec.default)));
|
|
109
|
+
opts.push(`\tif err := cli.Set(&opts.${field}, p.Values(${goString(name)})); err != nil {`, "\t\treturn err", "\t}");
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
params(op.query, plan.query);
|
|
113
|
+
params(op.headers, plan.headers);
|
|
114
|
+
if (op.stream !== null)
|
|
115
|
+
streamFlags(op.stream, lines, opts);
|
|
116
|
+
if (op.body?.kind === "multipart") {
|
|
117
|
+
const parts = partFlags(op, plan, { declare: lines, schemas, scope });
|
|
118
|
+
for (const part of parts) {
|
|
119
|
+
const kind = part.file ? { ...STRING, kind: "path" } : part.kind;
|
|
120
|
+
usage.push({ kind: { ...kind, list: part.list }, name: part.flag, positional: false, required: false });
|
|
121
|
+
}
|
|
122
|
+
return { declare: lines, fields: [], opts, parts, usage };
|
|
123
|
+
}
|
|
124
|
+
const fields = bodyFields(op, schemas, scope, lines);
|
|
125
|
+
if (op.body !== undefined)
|
|
126
|
+
usage.push({ kind: { ...STRING, kind: op.body.kind }, name: "data", positional: false, required: op.body.required });
|
|
127
|
+
return { declare: lines, fields, opts, parts: [], usage };
|
|
128
|
+
}
|
|
129
|
+
/** A stream's cursor flags, each `[flag, its Opts field, usage]`: the names GLOBAL_FLAGS keeps from a parameter. */
|
|
130
|
+
const LAST_EVENT_ID = ["last-event-id", "LastEventID", "resume after this event id"];
|
|
131
|
+
const RECONNECT_TOKEN = ["reconnect-token", "ReconnectToken", "resume with this reconnect token"];
|
|
132
|
+
const CURSOR = { realtime: [LAST_EVENT_ID, RECONNECT_TOKEN], sse: [LAST_EVENT_ID], ws: [RECONNECT_TOKEN] };
|
|
133
|
+
/** A stream command's own flags: --take, a realtime one's --max-reconnects, and its cursor flags, each set into its Opts field. */
|
|
134
|
+
function streamFlags(stream, lines, opts) {
|
|
135
|
+
lines.push("\tp.Take()");
|
|
136
|
+
if (stream === "realtime") {
|
|
137
|
+
lines.push("\tp.MaxReconnects()");
|
|
138
|
+
opts.push("\treconnects, err := p.Reconnects()", "\tif err != nil {", "\t\treturn err", "\t}", "\topts.MaxReconnectAttempts = reconnects");
|
|
139
|
+
}
|
|
140
|
+
for (const [flag, field, usage] of CURSOR[stream]) {
|
|
141
|
+
lines.push(flagLine(flag, { enum: [], kind: "string", list: false }, false, usage));
|
|
142
|
+
opts.push(`\tif err := cli.Set(&opts.${field}, p.Values(${goString(flag)})); err != nil {`, "\t\treturn err", "\t}");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** A multipart body's flags, each declared into `lines` by its part's name: a text part typed by its schema, a file part a path. */
|
|
146
|
+
function partFlags(op, plan, at) {
|
|
147
|
+
const { declare: lines, schemas, scope } = at;
|
|
148
|
+
const body = op.body;
|
|
149
|
+
return plan.parts.map((part) => {
|
|
150
|
+
const flag = scope.claim(kebab(part.part));
|
|
151
|
+
if (part.file) {
|
|
152
|
+
lines.push(`\tp.FileFlag(${goString(flag)}, ${part.list}, ${goString(`the ${part.part} part's file, or - for stdin`)})`);
|
|
153
|
+
return { field: part.field, file: true, flag, list: part.list };
|
|
154
|
+
}
|
|
155
|
+
const spec = body.parts.find((each) => each.name === part.part);
|
|
156
|
+
const kind = { ...kindOf(spec.schema, schemas), list: part.list };
|
|
157
|
+
lines.push(flagLine(flag, kind, false, `the ${part.part} part`));
|
|
158
|
+
return { field: part.field, file: false, flag, kind, list: part.list };
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/** The body's `--data`, then a flag per scalar field of a JSON or form object body, each declared into `lines`. */
|
|
162
|
+
function bodyFields(op, schemas, scope, lines) {
|
|
163
|
+
const body = op.body;
|
|
164
|
+
if (body === undefined)
|
|
165
|
+
return [];
|
|
166
|
+
lines.push(`\tp.Data(${goString(DATA_USAGE[body.kind])})`);
|
|
167
|
+
const object = body.kind === "json" || body.kind === "form" ? resolved(body.schema, schemas) : null;
|
|
168
|
+
if (object?.kind !== "object")
|
|
169
|
+
return [];
|
|
170
|
+
return object.fields.flatMap((field) => {
|
|
171
|
+
const kind = kindOf(field.schema, schemas);
|
|
172
|
+
if (kind.kind === "json")
|
|
173
|
+
return [];
|
|
174
|
+
const name = scope.claim(kebab(field.name));
|
|
175
|
+
lines.push(flagLine(name, kind, false, field.description ?? `the body's ${field.name}`));
|
|
176
|
+
return [[name, field.name]];
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/** What `--data` holds, by body kind. */
|
|
180
|
+
const DATA_USAGE = {
|
|
181
|
+
binary: "the body's bytes",
|
|
182
|
+
form: "the form body as a query string (a=1&b=2)",
|
|
183
|
+
json: "the JSON body",
|
|
184
|
+
multipart: "the multipart body",
|
|
185
|
+
text: "the text body",
|
|
186
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type GeneratedGoCli, generateGoCli, type GoCliOptions } from "./module.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateGoCli } from "./module.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's install scripts (bit 17 phase g, D8 of the release program): `install.sh` (Linux and macOS) and
|
|
3
|
+
* `install.ps1` (Windows), written by installgen from the layout `release.ts` publishes. Each reads the latest tag
|
|
4
|
+
* from the release's `version.txt` (a version by `<PREFIX>_VERSION` over it), downloads this platform's archive
|
|
5
|
+
* `<bin>_<os>_<arch>` and `checksums.txt` from the repository's GitHub Releases, checks `checksums.txt` with cosign
|
|
6
|
+
* against the repository's release workflow on that exact tag when cosign is on PATH (`<PREFIX>_INSTALL_VERIFY=require`
|
|
7
|
+
* refuses without it), checks the archive's sha256 against it, and installs the binary to `<PREFIX>_INSTALL_DIR`,
|
|
8
|
+
* `~/.local/bin` by default. installgen holds the scripts' hardening and their tests; this file holds the layout.
|
|
9
|
+
* Beside the scripts goes `installgen.config.mts`, the same config as a file, which the release workflow's
|
|
10
|
+
* `installgen check` reads to prove a release serves every file the scripts fetch: both are written from one
|
|
11
|
+
* `layout`, and a test holds the file's scripts byte for byte to the emitted ones. Without a repository there is
|
|
12
|
+
* nowhere to download from, so there are no scripts and no config.
|
|
13
|
+
*/
|
|
14
|
+
import { type InstallgenConfig } from "@lovrozagar/installgen";
|
|
15
|
+
/** The options the scripts are written from: the binary, its repository, the variables' prefix, the scripts' URL. */
|
|
16
|
+
export type InstallApp = {
|
|
17
|
+
readonly bin: string;
|
|
18
|
+
readonly repo: string;
|
|
19
|
+
readonly prefix: string;
|
|
20
|
+
readonly installUrl: string;
|
|
21
|
+
};
|
|
22
|
+
/** The issuer of the OIDC token a GitHub Actions run signs with. */
|
|
23
|
+
export declare const ISSUER = "https://token.actions.githubusercontent.com";
|
|
24
|
+
/** The installgen release the scripts are written by, and the release workflow's `npx` runs `check` with. */
|
|
25
|
+
export declare const INSTALLGEN_VERSION = "0.3.0";
|
|
26
|
+
/** The name `installgen` finds its config by, in the module's root, where the release workflow runs it. */
|
|
27
|
+
export declare const INSTALLGEN_CONFIG = "installgen.config.mts";
|
|
28
|
+
/** installgen's config for `app`, its files under `base` (the repository's GitHub Releases outside a test). */
|
|
29
|
+
export declare function installerConfig(app: InstallApp, base?: string): InstallgenConfig;
|
|
30
|
+
/**
|
|
31
|
+
* `installgen.config.mts` for `app`: `installerConfig`'s config as a module installgen loads with no local install
|
|
32
|
+
* (its one import is type-only, which Node 22.18+ strips), so `npx @lovrozagar/installgen@<version> check` runs in the
|
|
33
|
+
* module's root.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installgenConfigFile(app: InstallApp): string;
|
|
36
|
+
/** `install.sh`, `install.ps1` and `installgen.config.mts` for `app`, by file name. */
|
|
37
|
+
export declare function installFiles(app: InstallApp): Record<string, string>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's install scripts (bit 17 phase g, D8 of the release program): `install.sh` (Linux and macOS) and
|
|
3
|
+
* `install.ps1` (Windows), written by installgen from the layout `release.ts` publishes. Each reads the latest tag
|
|
4
|
+
* from the release's `version.txt` (a version by `<PREFIX>_VERSION` over it), downloads this platform's archive
|
|
5
|
+
* `<bin>_<os>_<arch>` and `checksums.txt` from the repository's GitHub Releases, checks `checksums.txt` with cosign
|
|
6
|
+
* against the repository's release workflow on that exact tag when cosign is on PATH (`<PREFIX>_INSTALL_VERIFY=require`
|
|
7
|
+
* refuses without it), checks the archive's sha256 against it, and installs the binary to `<PREFIX>_INSTALL_DIR`,
|
|
8
|
+
* `~/.local/bin` by default. installgen holds the scripts' hardening and their tests; this file holds the layout.
|
|
9
|
+
* Beside the scripts goes `installgen.config.mts`, the same config as a file, which the release workflow's
|
|
10
|
+
* `installgen check` reads to prove a release serves every file the scripts fetch: both are written from one
|
|
11
|
+
* `layout`, and a test holds the file's scripts byte for byte to the emitted ones. Without a repository there is
|
|
12
|
+
* nowhere to download from, so there are no scripts and no config.
|
|
13
|
+
*/
|
|
14
|
+
import { generateInstallers } from "@lovrozagar/installgen";
|
|
15
|
+
/** The issuer of the OIDC token a GitHub Actions run signs with. */
|
|
16
|
+
export const ISSUER = "https://token.actions.githubusercontent.com";
|
|
17
|
+
/** The installgen release the scripts are written by, and the release workflow's `npx` runs `check` with. */
|
|
18
|
+
export const INSTALLGEN_VERSION = "0.3.0";
|
|
19
|
+
/** The name `installgen` finds its config by, in the module's root, where the release workflow runs it. */
|
|
20
|
+
export const INSTALLGEN_CONFIG = "installgen.config.mts";
|
|
21
|
+
/**
|
|
22
|
+
* The layout both configs spell: every plain value, and the fixed pieces of each path around its tokens. The pieces
|
|
23
|
+
* hold only the binary name and the repository, each refused at generate unless it matches its grammar (lowercase
|
|
24
|
+
* words joined by `-`; GitHub's owner/name), so the config file writes them into its template literals as they are.
|
|
25
|
+
*/
|
|
26
|
+
function layout(app, base) {
|
|
27
|
+
return {
|
|
28
|
+
asset: [`download/`, `/${app.bin}_`, `_`],
|
|
29
|
+
checksums: [`download/`, `/checksums.txt`],
|
|
30
|
+
identity: [`https://github.com/${app.repo}/.github/workflows/release.yml@refs/tags/`],
|
|
31
|
+
plain: {
|
|
32
|
+
baseUrl: base,
|
|
33
|
+
envPrefix: app.prefix,
|
|
34
|
+
installDir: "~/.local/bin",
|
|
35
|
+
latestPath: "latest/download/version.txt",
|
|
36
|
+
message: `Run \`${app.bin} --help\` to get started.`,
|
|
37
|
+
name: app.bin,
|
|
38
|
+
scriptUrls: { ps1: `${app.installUrl}/install.ps1`, sh: `${app.installUrl}/install.sh` },
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** installgen's config for `app`, its files under `base` (the repository's GitHub Releases outside a test). */
|
|
43
|
+
export function installerConfig(app, base = `https://github.com/${app.repo}/releases`) {
|
|
44
|
+
const { asset, checksums, identity, plain } = layout(app, base);
|
|
45
|
+
return {
|
|
46
|
+
...plain,
|
|
47
|
+
assetPath: ({ arch, os, tag }) => `${asset[0]}${tag}${asset[1]}${os}${asset[2]}${arch}${os === "windows" ? ".zip" : ".tar.gz"}`,
|
|
48
|
+
checksumsPath: ({ tag }) => `${checksums[0]}${tag}${checksums[1]}`,
|
|
49
|
+
signature: { identity: ({ tag }) => `${identity[0]}${tag}`, issuer: ISSUER },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `installgen.config.mts` for `app`: `installerConfig`'s config as a module installgen loads with no local install
|
|
54
|
+
* (its one import is type-only, which Node 22.18+ strips), so `npx @lovrozagar/installgen@<version> check` runs in the
|
|
55
|
+
* module's root.
|
|
56
|
+
*/
|
|
57
|
+
export function installgenConfigFile(app) {
|
|
58
|
+
const { asset, checksums, identity, plain } = layout(app, `https://github.com/${app.repo}/releases`);
|
|
59
|
+
const value = (key) => `\t${key}: ${JSON.stringify(plain[key])},\n`;
|
|
60
|
+
return `// Code generated by honey. DO NOT EDIT.
|
|
61
|
+
// installgen's config for ${app.bin}'s install scripts, as honey wrote them: the release workflow runs
|
|
62
|
+
// \`npx @lovrozagar/installgen@${INSTALLGEN_VERSION} check\` with it to prove a release serves every file they fetch.
|
|
63
|
+
import type { InstallgenConfig } from "@lovrozagar/installgen"
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
assetPath: ({ arch, os, tag }) =>
|
|
67
|
+
\`${asset[0]}\${tag}${asset[1]}\${os}${asset[2]}\${arch}\${os === "windows" ? ".zip" : ".tar.gz"}\`,
|
|
68
|
+
${value("baseUrl")} checksumsPath: ({ tag }) => \`${checksums[0]}\${tag}${checksums[1]}\`,
|
|
69
|
+
${value("envPrefix")}${value("installDir")}${value("latestPath")}${value("message")}${value("name")}${value("scriptUrls")} signature: {
|
|
70
|
+
identity: ({ tag }) => \`${identity[0]}\${tag}\`,
|
|
71
|
+
issuer: ${JSON.stringify(ISSUER)},
|
|
72
|
+
},
|
|
73
|
+
} satisfies InstallgenConfig
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
/** `install.sh`, `install.ps1` and `installgen.config.mts` for `app`, by file name. */
|
|
77
|
+
export function installFiles(app) {
|
|
78
|
+
const { ps1, sh } = generateInstallers(installerConfig(app));
|
|
79
|
+
/* every platform is configured, so installgen writes both */
|
|
80
|
+
const scripts = [
|
|
81
|
+
["install.ps1", ps1],
|
|
82
|
+
["install.sh", sh],
|
|
83
|
+
];
|
|
84
|
+
return {
|
|
85
|
+
...Object.fromEntries(scripts.filter((entry) => entry[1] !== undefined)),
|
|
86
|
+
[INSTALLGEN_CONFIG]: installgenConfigFile(app),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generated CLI's `cmd` package as files (bit 17): `root.go` (the root, its top-level commands added), `client.go`
|
|
3
|
+
* (the SDK client the run's settings configure, and an answer outside 2xx as the runtime's APIError), and a
|
|
4
|
+
* `<name>_cmds.go` per top-level command holding it and every command below it. Each file imports, in gofmt's groups,
|
|
5
|
+
* only the packages its code names, literals and comments aside.
|
|
6
|
+
*/
|
|
7
|
+
import type { IR } from "../../ir/model.ts";
|
|
8
|
+
import { type CommandNode } from "./commands.ts";
|
|
9
|
+
import { type Entry } from "./discovery.ts";
|
|
10
|
+
/** The CLI's name, description and environment prefix, and its module. */
|
|
11
|
+
export type CliApp = {
|
|
12
|
+
/** the base URL the root command is built with; none when the document declares no server */
|
|
13
|
+
readonly baseUrl?: string;
|
|
14
|
+
readonly binaryName: string;
|
|
15
|
+
readonly short: string;
|
|
16
|
+
readonly envPrefix: string;
|
|
17
|
+
readonly modulePath: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Every file under cmd/: root.go, client.go, discovery.go (`entries`, as `commands` and `schema` print them), and
|
|
21
|
+
* `<name>_cmds.go` for each top-level command (a group and all below).
|
|
22
|
+
*/
|
|
23
|
+
export declare function cmdFiles(app: CliApp, ir: IR, nodes: readonly CommandNode[], entries: readonly Entry[]): Record<string, string>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { NOT_CODE } from "../go/sdk.js";
|
|
2
|
+
import { goString } from "../shared/escape.js";
|
|
3
|
+
import { compareCodeUnits, NameScope, snakeWords } from "../shared/lang.js";
|
|
4
|
+
import { groupFuncs } from "./commands.js";
|
|
5
|
+
import { discoveryBody } from "./discovery.js";
|
|
6
|
+
import { helpText } from "./flags.js";
|
|
7
|
+
/* the marker gopls and linters read, apart from the package doc by a blank line */
|
|
8
|
+
const MARKER = "// Code generated by honey. DO NOT EDIT.";
|
|
9
|
+
/** What a cmd file imports, by the packages its code names: the runtime always. */
|
|
10
|
+
const importsOf = (text) => {
|
|
11
|
+
const code = text.replace(NOT_CODE, "");
|
|
12
|
+
return ["cli", ...["cobra", "errors", "http", "json", "sdk"].filter((name) => new RegExp(`\\b${name}\\.`).test(code))];
|
|
13
|
+
};
|
|
14
|
+
/** Each package a cmd file may import, by name, in its import group: the standard library, cobra, the module's own. */
|
|
15
|
+
const PACKAGES = {
|
|
16
|
+
cli: [2, (module) => `${module}/internal/cli`],
|
|
17
|
+
cobra: [1, () => "github.com/spf13/cobra"],
|
|
18
|
+
errors: [0, () => "errors"],
|
|
19
|
+
http: [0, () => "net/http"],
|
|
20
|
+
json: [0, () => "encoding/json"],
|
|
21
|
+
sdk: [2, (module) => `${module}/internal/sdk`],
|
|
22
|
+
};
|
|
23
|
+
/** A cmd file: the marker, its package and doc, its imports in gofmt's groups, then `body`. */
|
|
24
|
+
function cmdFile(module, body, doc = "") {
|
|
25
|
+
const groups = [[], [], []];
|
|
26
|
+
for (const name of importsOf(body)) {
|
|
27
|
+
const [group, path] = PACKAGES[name];
|
|
28
|
+
groups[group]?.push(`\t"${path(module)}"`);
|
|
29
|
+
}
|
|
30
|
+
const block = groups
|
|
31
|
+
.filter((lines) => lines.length > 0)
|
|
32
|
+
.map((lines) => lines.sort(compareCodeUnits).join("\n"))
|
|
33
|
+
.join("\n\n");
|
|
34
|
+
return `${MARKER}\n\n${doc}package cmd\n\nimport (\n${block}\n)\n\n${body}\n`;
|
|
35
|
+
}
|
|
36
|
+
/** cmd/root.go: the root command, named by the binary, its skill given, its top-level commands its API ones. */
|
|
37
|
+
function rootBody(app, ir, nodes) {
|
|
38
|
+
const fields = [
|
|
39
|
+
`Name: ${goString(app.binaryName)}`,
|
|
40
|
+
`Short: ${goString(helpText(app.short))}`,
|
|
41
|
+
`EnvPrefix: ${goString(app.envPrefix)}`,
|
|
42
|
+
...(app.baseUrl === undefined ? [] : [`Server: ${goString(app.baseUrl)}`]),
|
|
43
|
+
"Discovery: discovery",
|
|
44
|
+
"Skill: skill",
|
|
45
|
+
];
|
|
46
|
+
const api = nodes.map((node) => `, ${node.fn}()`).join("");
|
|
47
|
+
return [
|
|
48
|
+
`// Root is the ${app.binaryName} command, skill the agent skill it ships; every other command hangs under it.`,
|
|
49
|
+
"func Root(skill string) *cobra.Command {",
|
|
50
|
+
`\treturn cli.Root(cli.App{${fields.join(", ")}}${api})`,
|
|
51
|
+
"}",
|
|
52
|
+
].join("\n");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* cmd/client.go: the SDK client the run's settings configure, its requests and responses logged under --verbose, and
|
|
56
|
+
* an answer outside 2xx as the runtime's APIError. An API that declares no server needs a base URL set.
|
|
57
|
+
*/
|
|
58
|
+
function clientBody(app, ir) {
|
|
59
|
+
const env = `$${app.envPrefix}_BASE_URL`;
|
|
60
|
+
const noServer = app.baseUrl !== undefined
|
|
61
|
+
? []
|
|
62
|
+
: [
|
|
63
|
+
'\tif s.BaseURL == "" {',
|
|
64
|
+
`\t\treturn nil, cli.Usage(${goString(`no base URL: set --base-url, ${env} or base_url in the config file`)})`,
|
|
65
|
+
"\t}",
|
|
66
|
+
];
|
|
67
|
+
return [
|
|
68
|
+
"// newClient is the API client the run's settings configure.",
|
|
69
|
+
"func newClient(c *cobra.Command) (*sdk.Client, error) {",
|
|
70
|
+
"\ts, err := cli.Settings(c)",
|
|
71
|
+
"\tif err != nil {",
|
|
72
|
+
"\t\treturn nil, err",
|
|
73
|
+
"\t}",
|
|
74
|
+
...noServer,
|
|
75
|
+
"\ts.Announce()",
|
|
76
|
+
"\treturn sdk.NewClient(sdk.Config{",
|
|
77
|
+
"\t\tBaseURL: s.BaseURL, BearerToken: s.APIKey, Headers: s.Headers, Timeout: s.Timeout,",
|
|
78
|
+
"\t\tRedirect: sdk.RedirectPolicy(s.Redirect),",
|
|
79
|
+
"\t\tOnRequest: []func(*sdk.RequestContext) error{func(rc *sdk.RequestContext) error {",
|
|
80
|
+
"\t\t\ts.LogRequest(rc.Method, rc.URL, rc.Headers)",
|
|
81
|
+
"\t\t\treturn nil",
|
|
82
|
+
"\t\t}},",
|
|
83
|
+
"\t\tOnResponse: []func(*sdk.ResponseContext) error{func(rc *sdk.ResponseContext) error {",
|
|
84
|
+
"\t\t\ts.LogResponse(rc.Status, rc.Headers)",
|
|
85
|
+
"\t\t\treturn nil",
|
|
86
|
+
"\t\t}},",
|
|
87
|
+
"\t}), nil",
|
|
88
|
+
"}",
|
|
89
|
+
"",
|
|
90
|
+
"// failed is err as the CLI reports it: an answer outside 2xx with its status, error key and message.",
|
|
91
|
+
"func failed(err error) error {",
|
|
92
|
+
"\tvar answer *sdk.ClientError",
|
|
93
|
+
"\tif errors.As(err, &answer) {",
|
|
94
|
+
"\t\treturn &cli.APIError{Status: answer.StatusCode, Key: string(answer.Key), Message: answer.Message, Err: err}",
|
|
95
|
+
"\t}",
|
|
96
|
+
"\treturn err",
|
|
97
|
+
"}",
|
|
98
|
+
].join("\n");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Every file under cmd/: root.go, client.go, discovery.go (`entries`, as `commands` and `schema` print them), and
|
|
102
|
+
* `<name>_cmds.go` for each top-level command (a group and all below).
|
|
103
|
+
*/
|
|
104
|
+
export function cmdFiles(app, ir, nodes, entries) {
|
|
105
|
+
const stems = new NameScope(["client", "root"]);
|
|
106
|
+
const files = {
|
|
107
|
+
"cmd/client.go": cmdFile(app.modulePath, clientBody(app, ir)),
|
|
108
|
+
"cmd/discovery.go": cmdFile(app.modulePath, discoveryBody(entries)),
|
|
109
|
+
"cmd/root.go": cmdFile(app.modulePath, rootBody(app, ir, nodes), `// Package cmd holds the ${app.binaryName} commands.\n`),
|
|
110
|
+
};
|
|
111
|
+
for (const node of nodes) {
|
|
112
|
+
const body = groupFuncs(node, [], ir)
|
|
113
|
+
.map((lines) => lines.join("\n"))
|
|
114
|
+
.join("\n\n");
|
|
115
|
+
files[`cmd/${stems.claim(snakeWords(node.name))}_cmds.go`] = cmdFile(app.modulePath, body);
|
|
116
|
+
}
|
|
117
|
+
return files;
|
|
118
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PackageIdentity } from "../shared/metadata.ts";
|
|
2
|
+
import { type ReleaseOptions } from "./release.ts";
|
|
3
|
+
export type GoCliOptions = ReleaseOptions & {
|
|
4
|
+
/** the binary and root command name: lowercase words joined by `-`, at most 64 characters; the title's, else `api` */
|
|
5
|
+
readonly binaryName?: string;
|
|
6
|
+
/** the module path go.mod declares, a domain first; `example.com/<binaryName>` by default */
|
|
7
|
+
readonly modulePath?: string;
|
|
8
|
+
/** the module's version, semver: from v2 on, its major suffix (`/v2`) ends the module path */
|
|
9
|
+
readonly version?: string;
|
|
10
|
+
/** the environment variables' prefix: uppercase words joined by `_`; the binary name's by default */
|
|
11
|
+
readonly envPrefix?: string;
|
|
12
|
+
/** the GitHub repository the release is published to, `owner/name`; none by default (then no install scripts) */
|
|
13
|
+
readonly repo?: string;
|
|
14
|
+
/**
|
|
15
|
+
* the base URL the binary calls by default, absolute; the document's first server by default. A document
|
|
16
|
+
* served under a path (a gateway's `servers: [{ url: "/api" }]`) names no host a CLI can call, so it needs this.
|
|
17
|
+
*/
|
|
18
|
+
readonly baseUrl?: string;
|
|
19
|
+
};
|
|
20
|
+
export type GeneratedGoCli = {
|
|
21
|
+
readonly files: Readonly<Record<string, string>>;
|
|
22
|
+
/** the module as the Go proxy serves it (`go install <module>@<version>`), by its path and version, if any */
|
|
23
|
+
readonly packages: readonly PackageIdentity[];
|
|
24
|
+
};
|
|
25
|
+
/** The runtime files a CLI ships, read from `runtime/cli/` and nowhere else; SOCKET only beside the WebSocket library. */
|
|
26
|
+
export declare const CLI_RUNTIME: readonly string[];
|
|
27
|
+
/** The binary name a title gives: its letters and digits, lowercased, joined by `-`; `api` when it has none. */
|
|
28
|
+
export declare const binaryNameOf: (title: string | undefined) => string;
|
|
29
|
+
/** The CLI module for `document`, by file name. */
|
|
30
|
+
export declare function generateGoCli(document: Record<string, unknown>, options?: GoCliOptions): GeneratedGoCli;
|