@phins/engine 0.0.0-stage → 0.1.2
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 +202 -0
- package/NOTICE +29 -0
- package/PROVENANCE.md +28 -0
- package/README.md +10 -2
- package/THIRD_PARTY.md +40 -0
- package/notices/bun-LICENSE.md +74 -0
- package/notices/dependency-licenses.json +2314 -0
- package/notices/drizzle-LICENSE +201 -0
- package/notices/fff-LICENSE +21 -0
- package/notices/node-forge-LICENSE +331 -0
- package/notices/opentui-spinner-MIT.txt +27 -0
- package/notices/packages__http-recorder__LICENSE +21 -0
- package/notices/remeda-LICENSE +21 -0
- package/notices/runtime-sources.json +7081 -0
- package/notices/seq-queue-LICENSE +22 -0
- package/notices/supplemental-notices.json +61 -0
- package/notices/third-party-source-LICENSE +21 -0
- package/package.json +54 -4
- package/src/agents/commands.ts +67 -0
- package/src/agents/context/builtins.ts +47 -0
- package/src/agents/context/instructions.ts +92 -0
- package/src/agents/context/registry.ts +53 -0
- package/src/agents/context/system.ts +329 -0
- package/src/agents/questions.ts +219 -0
- package/src/agents/references/guidance.ts +71 -0
- package/src/agents/references/registry.ts +122 -0
- package/src/agents/registry.ts +108 -0
- package/src/agents/resources/client.ts +185 -0
- package/src/agents/resources/contract.ts +71 -0
- package/src/agents/resources/error.ts +7 -0
- package/src/agents/skills/discovery.ts +167 -0
- package/src/agents/skills/guidance.ts +76 -0
- package/src/agents/skills/registry.ts +131 -0
- package/src/contracts/agents/agent.ts +36 -0
- package/src/contracts/agents/command.ts +14 -0
- package/src/contracts/agents/question-compat.ts +66 -0
- package/src/contracts/agents/question.ts +79 -0
- package/src/contracts/agents/reference.ts +36 -0
- package/src/contracts/agents/skill.ts +54 -0
- package/src/contracts/events/durable-manifest.ts +10 -0
- package/src/contracts/events/event.ts +125 -0
- package/src/contracts/events/filesystem.ts +13 -0
- package/src/contracts/events/installation.ts +20 -0
- package/src/contracts/events/legacy.ts +18 -0
- package/src/contracts/events/manifest.ts +82 -0
- package/src/contracts/events/mcp.ts +21 -0
- package/src/contracts/events/server.ts +8 -0
- package/src/contracts/events/session-compaction.ts +13 -0
- package/src/contracts/events/session-status.ts +50 -0
- package/src/contracts/events/session.ts +734 -0
- package/src/contracts/events/tui.ts +58 -0
- package/src/contracts/events/vcs.ts +13 -0
- package/src/contracts/events/workspace.ts +32 -0
- package/src/contracts/events/worktree.ts +21 -0
- package/src/contracts/execution/terminal-ticket.ts +9 -0
- package/src/contracts/execution/terminal.ts +55 -0
- package/src/contracts/execution/verification-receipt.ts +281 -0
- package/src/contracts/extensions/connection.ts +22 -0
- package/src/contracts/extensions/integration-id.ts +7 -0
- package/src/contracts/extensions/integration.ts +128 -0
- package/src/contracts/extensions/plugin.ts +15 -0
- package/src/contracts/identifier.ts +30 -0
- package/src/contracts/inference/catalog.ts +6 -0
- package/src/contracts/inference/llm.ts +23 -0
- package/src/contracts/inference/model.ts +103 -0
- package/src/contracts/inference/models-dev.ts +9 -0
- package/src/contracts/inference/provider.ts +69 -0
- package/src/contracts/schema.ts +30 -0
- package/src/contracts/security/credential.ts +34 -0
- package/src/contracts/security/permission-compat.ts +71 -0
- package/src/contracts/security/permission-saved.ts +20 -0
- package/src/contracts/security/permission.ts +64 -0
- package/src/contracts/session/compat.ts +676 -0
- package/src/contracts/session/delivery.ts +6 -0
- package/src/contracts/session/id.ts +20 -0
- package/src/contracts/session/info.ts +52 -0
- package/src/contracts/session/input-origin.ts +43 -0
- package/src/contracts/session/input.ts +24 -0
- package/src/contracts/session/live.ts +43 -0
- package/src/contracts/session/message-id.ts +11 -0
- package/src/contracts/session/message.ts +206 -0
- package/src/contracts/session/prompt.ts +56 -0
- package/src/contracts/session/revert.ts +23 -0
- package/src/contracts/session/run-state.ts +109 -0
- package/src/contracts/session/todo.ts +24 -0
- package/src/contracts/workspace/file-diff.ts +12 -0
- package/src/contracts/workspace/filesystem.ts +39 -0
- package/src/contracts/workspace/location.ts +30 -0
- package/src/contracts/workspace/project-copy.ts +29 -0
- package/src/contracts/workspace/project-directories.ts +11 -0
- package/src/contracts/workspace/project-id.ts +8 -0
- package/src/contracts/workspace/project.ts +41 -0
- package/src/contracts/workspace/workspace-id.ts +19 -0
- package/src/contracts/workspace/workspace.ts +9 -0
- package/src/execution/commands/executor.ts +44 -0
- package/src/execution/commands/provider.ts +54 -0
- package/src/execution/commands/runner.ts +26 -0
- package/src/execution/control/command.ts +55 -0
- package/src/execution/control/grant.ts +123 -0
- package/src/execution/control/promotion.ts +113 -0
- package/src/execution/control/receiver.ts +153 -0
- package/src/execution/control/restoration.ts +264 -0
- package/src/execution/identity.ts +432 -0
- package/src/execution/process/runner.ts +243 -0
- package/src/execution/process/sessions.ts +239 -0
- package/src/execution/process/spawner.ts +508 -0
- package/src/execution/sandbox.ts +143 -0
- package/src/execution/shell.ts +226 -0
- package/src/execution/terminal/native.ts +26 -0
- package/src/execution/terminal/protocol.ts +37 -0
- package/src/execution/terminal/schema.ts +1 -0
- package/src/execution/terminal/service.ts +318 -0
- package/src/execution/terminal/ticket.ts +57 -0
- package/src/execution/terminal/types.ts +25 -0
- package/src/extensions/agents.ts +211 -0
- package/src/extensions/api/agent.ts +14 -0
- package/src/extensions/api/catalog.ts +29 -0
- package/src/extensions/api/command.ts +13 -0
- package/src/extensions/api/context.ts +27 -0
- package/src/extensions/api/integration.ts +63 -0
- package/src/extensions/api/plugin.ts +17 -0
- package/src/extensions/api/reference.ts +12 -0
- package/src/extensions/api/registration.ts +16 -0
- package/src/extensions/api/skill.ts +11 -0
- package/src/extensions/api/tool.ts +58 -0
- package/src/extensions/api.ts +6 -0
- package/src/extensions/definition.ts +13 -0
- package/src/extensions/host.ts +225 -0
- package/src/extensions/integrations/service.ts +517 -0
- package/src/extensions/internal.ts +117 -0
- package/src/extensions/mcp/local.ts +352 -0
- package/src/extensions/mcp/schema.ts +21 -0
- package/src/extensions/mcp/tool-names.ts +26 -0
- package/src/extensions/mcp/tool.ts +149 -0
- package/src/extensions/models-dev.ts +135 -0
- package/src/extensions/options.ts +1 -0
- package/src/extensions/service.ts +152 -0
- package/src/extensions/skills/customize-phins.md +106 -0
- package/src/extensions/skills.ts +31 -0
- package/src/extensions/tools.ts +88 -0
- package/src/inference/api.ts +34 -0
- package/src/inference/cache-policy.ts +111 -0
- package/src/inference/catalog/discovery.ts +163 -0
- package/src/inference/catalog/metadata.ts +249 -0
- package/src/inference/catalog/model.ts +41 -0
- package/src/inference/catalog/provider.ts +25 -0
- package/src/inference/catalog/registry.ts +437 -0
- package/src/inference/errors.ts +32 -0
- package/src/inference/protocols/openai-chat.ts +497 -0
- package/src/inference/protocols/openai-compatible-chat.ts +24 -0
- package/src/inference/protocols/shared.ts +483 -0
- package/src/inference/protocols/utils/lifecycle.ts +102 -0
- package/src/inference/protocols/utils/openai-options.ts +93 -0
- package/src/inference/protocols/utils/tool-stream.ts +214 -0
- package/src/inference/provider.ts +37 -0
- package/src/inference/request/api.ts +27 -0
- package/src/inference/request/auth-options.ts +57 -0
- package/src/inference/request/auth.ts +161 -0
- package/src/inference/request/client.ts +490 -0
- package/src/inference/request/endpoint.ts +55 -0
- package/src/inference/request/execution-boundary.ts +41 -0
- package/src/inference/request/executor.ts +478 -0
- package/src/inference/request/framing.ts +27 -0
- package/src/inference/request/protocol.ts +90 -0
- package/src/inference/request/spending.ts +159 -0
- package/src/inference/requests.ts +193 -0
- package/src/inference/schema/errors.ts +194 -0
- package/src/inference/schema/events.ts +372 -0
- package/src/inference/schema/ids.ts +43 -0
- package/src/inference/schema/messages.ts +312 -0
- package/src/inference/schema/options.ts +247 -0
- package/src/inference/schema.ts +5 -0
- package/src/inference/tools/definition.ts +253 -0
- package/src/inference/tools/dispatcher.ts +83 -0
- package/src/inference/tools/failure.ts +19 -0
- package/src/inference/transports/http.ts +115 -0
- package/src/inference/transports/transport.ts +34 -0
- package/src/inference/transports/websocket.ts +322 -0
- package/src/runtime/effect/keyed-mutex.ts +45 -0
- package/src/runtime/effect/platform.ts +12 -0
- package/src/runtime/effect/service-access.ts +43 -0
- package/src/runtime/effect/service-graph.ts +102 -0
- package/src/runtime/events/bus.ts +1222 -0
- package/src/runtime/events/session-deltas.ts +128 -0
- package/src/runtime/events/verification-publisher.ts +9 -0
- package/src/runtime/flags.ts +78 -0
- package/src/runtime/markdown.d.ts +4 -0
- package/src/runtime/paths.ts +87 -0
- package/src/runtime/services.ts +240 -0
- package/src/runtime/state.ts +128 -0
- package/src/runtime/vendor.d.ts +25 -0
- package/src/runtime/version.ts +8 -0
- package/src/security/credentials.ts +137 -0
- package/src/security/launcher-policy.ts +68 -0
- package/src/security/permissions/delegation.ts +32 -0
- package/src/security/permissions/origin.ts +70 -0
- package/src/security/permissions/saved.ts +78 -0
- package/src/security/permissions/service.ts +533 -0
- package/src/security/policy.ts +46 -0
- package/src/sessions/actions/administration.ts +109 -0
- package/src/sessions/actions/command-template.ts +23 -0
- package/src/sessions/actions/commands.ts +258 -0
- package/src/sessions/actions/errors.ts +16 -0
- package/src/sessions/actions/operations.ts +271 -0
- package/src/sessions/actions/revert.ts +121 -0
- package/src/sessions/context/checkpoint.ts +330 -0
- package/src/sessions/context/compaction.ts +268 -0
- package/src/sessions/context/epoch.ts +173 -0
- package/src/sessions/context/selection.ts +30 -0
- package/src/sessions/errors.ts +38 -0
- package/src/sessions/identifiers.ts +25 -0
- package/src/sessions/info.ts +90 -0
- package/src/sessions/input/inbox.ts +514 -0
- package/src/sessions/input/origin.ts +131 -0
- package/src/sessions/input/turns.ts +125 -0
- package/src/sessions/messages/history.ts +101 -0
- package/src/sessions/messages/service.ts +2 -0
- package/src/sessions/messages/updater.ts +420 -0
- package/src/sessions/projector.ts +699 -0
- package/src/sessions/run/budget.ts +62 -0
- package/src/sessions/run/chat-scope.ts +62 -0
- package/src/sessions/run/coding-workflow.ts +82 -0
- package/src/sessions/run/coordinator.ts +192 -0
- package/src/sessions/run/events.ts +572 -0
- package/src/sessions/run/execution.ts +57 -0
- package/src/sessions/run/inference.ts +1466 -0
- package/src/sessions/run/lifecycle.ts +316 -0
- package/src/sessions/run/local-executor.ts +307 -0
- package/src/sessions/run/loop.ts +33 -0
- package/src/sessions/run/messages.ts +161 -0
- package/src/sessions/run/model.ts +232 -0
- package/src/sessions/run/state.ts +288 -0
- package/src/sessions/run/subtasks.ts +190 -0
- package/src/sessions/runtime.ts +40 -0
- package/src/sessions/service.ts +686 -0
- package/src/sessions/store.ts +129 -0
- package/src/sessions/tasks.ts +78 -0
- package/src/sessions/title.ts +23 -0
- package/src/sessions/usage/contribution-value.ts +48 -0
- package/src/sessions/usage/contribution.ts +511 -0
- package/src/sessions/usage/cost.ts +21 -0
- package/src/sessions/verification/history.ts +79 -0
- package/src/sessions/verification/recovery.ts +971 -0
- package/src/sessions/verification/service.ts +671 -0
- package/src/settings/agents.ts +23 -0
- package/src/settings/attachments.ts +15 -0
- package/src/settings/commands.ts +12 -0
- package/src/settings/compaction.ts +15 -0
- package/src/settings/config.ts +234 -0
- package/src/settings/experimental.ts +18 -0
- package/src/settings/formatters.ts +12 -0
- package/src/settings/markdown.ts +36 -0
- package/src/settings/mcp.ts +39 -0
- package/src/settings/plugins/agent.ts +108 -0
- package/src/settings/plugins/command.ts +82 -0
- package/src/settings/plugins/provider.ts +113 -0
- package/src/settings/plugins/reference.ts +68 -0
- package/src/settings/plugins/skill.ts +50 -0
- package/src/settings/plugins.ts +13 -0
- package/src/settings/providers.ts +71 -0
- package/src/settings/references.ts +22 -0
- package/src/settings/tool-output.ts +9 -0
- package/src/settings/watchers.ts +7 -0
- package/src/shared/effect-flock.ts +93 -0
- package/src/shared/encode.ts +51 -0
- package/src/shared/flock.ts +584 -0
- package/src/shared/glob.ts +34 -0
- package/src/shared/hash.ts +11 -0
- package/src/shared/lazy.ts +26 -0
- package/src/shared/prefixed-id.ts +47 -0
- package/src/shared/record.ts +3 -0
- package/src/shared/schema.ts +87 -0
- package/src/shared/slug.ts +74 -0
- package/src/shared/token.ts +5 -0
- package/src/shared/which.ts +14 -0
- package/src/shared/wildcard.ts +48 -0
- package/src/storage/database.ts +63 -0
- package/src/storage/drizzle/effect-sqlite/driver.ts +77 -0
- package/src/storage/drizzle/effect-sqlite/migrator.ts +14 -0
- package/src/storage/drizzle/effect-sqlite/session.ts +218 -0
- package/src/storage/drizzle/index.ts +10 -0
- package/src/storage/drizzle/internal/drizzle-utils.ts +127 -0
- package/src/storage/drizzle/sqlite-core/effect/count.ts +58 -0
- package/src/storage/drizzle/sqlite-core/effect/db.ts +296 -0
- package/src/storage/drizzle/sqlite-core/effect/delete.ts +261 -0
- package/src/storage/drizzle/sqlite-core/effect/insert.ts +349 -0
- package/src/storage/drizzle/sqlite-core/effect/query.ts +198 -0
- package/src/storage/drizzle/sqlite-core/effect/raw.ts +49 -0
- package/src/storage/drizzle/sqlite-core/effect/select.ts +279 -0
- package/src/storage/drizzle/sqlite-core/effect/session.ts +490 -0
- package/src/storage/drizzle/sqlite-core/effect/update.ts +402 -0
- package/src/storage/drizzle/up-migrations/effect-sqlite.ts +102 -0
- package/src/storage/drizzle/up-migrations/sqlite.ts +253 -0
- package/src/storage/drizzle/up-migrations/utils.ts +45 -0
- package/src/storage/migration.gen.ts +62 -0
- package/src/storage/migration.ts +168 -0
- package/src/storage/migrations/20260127222353_familiar_lady_ursula.ts +107 -0
- package/src/storage/migrations/20260211171708_add_project_commands.ts +11 -0
- package/src/storage/migrations/20260213144116_wakeful_the_professor.ts +23 -0
- package/src/storage/migrations/20260225215848_workspace.ts +19 -0
- package/src/storage/migrations/20260227213759_add_session_workspace_id.ts +12 -0
- package/src/storage/migrations/20260228203230_blue_harpoon.ts +30 -0
- package/src/storage/migrations/20260303231226_add_workspace_fields.ts +15 -0
- package/src/storage/migrations/20260309230000_move_org_to_state.ts +15 -0
- package/src/storage/migrations/20260312043431_session_message_cursor.ts +16 -0
- package/src/storage/migrations/20260323234822_events.ts +26 -0
- package/src/storage/migrations/20260410174513_workspace-name.ts +29 -0
- package/src/storage/migrations/20260413175956_chief_energizer.ts +24 -0
- package/src/storage/migrations/20260423070820_add_icon_url_override.ts +14 -0
- package/src/storage/migrations/20260427172553_slow_nightmare.ts +30 -0
- package/src/storage/migrations/20260428004200_add_session_path.ts +11 -0
- package/src/storage/migrations/20260501142318_next_venus.ts +12 -0
- package/src/storage/migrations/20260504145000_add_sync_owner.ts +11 -0
- package/src/storage/migrations/20260507164347_add_workspace_time.ts +11 -0
- package/src/storage/migrations/20260510033149_session_usage.ts +56 -0
- package/src/storage/migrations/20260511000411_data_migration_state.ts +16 -0
- package/src/storage/migrations/20260511173437_session-metadata.ts +16 -0
- package/src/storage/migrations/20260601010001_normalize_storage_paths.ts +22 -0
- package/src/storage/migrations/20260601202201_amazing_prowler.ts +11 -0
- package/src/storage/migrations/20260602002951_lowly_union_jack.ts +24 -0
- package/src/storage/migrations/20260602182828_add_project_directories.ts +20 -0
- package/src/storage/migrations/20260603001617_session_message_projection_indexes.ts +19 -0
- package/src/storage/migrations/20260603040000_session_message_projection_order.ts +19 -0
- package/src/storage/migrations/20260603141458_session_input_inbox.ts +25 -0
- package/src/storage/migrations/20260603160727_jittery_ezekiel_stane.ts +20 -0
- package/src/storage/migrations/20260604172448_event_sourced_session_input.ts +47 -0
- package/src/storage/migrations/20260605003541_add_session_context_snapshot.ts +21 -0
- package/src/storage/migrations/20260605042240_add_context_epoch_agent.ts +11 -0
- package/src/storage/migrations/20260611035744_credential.ts +25 -0
- package/src/storage/migrations/20260611192811_lush_chimera.ts +25 -0
- package/src/storage/migrations/20260612174303_project_dir_strategy.ts +29 -0
- package/src/storage/migrations/20260622142730_simplify_session_context_epoch.ts +13 -0
- package/src/storage/migrations/20260622170816_reset_v2_session_state.ts +17 -0
- package/src/storage/migrations/20260622202450_simplify_session_input.ts +17 -0
- package/src/storage/migrations/20260722030810_rolling_work_context_epoch.ts +44 -0
- package/src/storage/migrations/20260729010558_verification_receipt.ts +45 -0
- package/src/storage/migrations/20260729040943_verification_request_outbox.ts +35 -0
- package/src/storage/migrations/20260731015112_verification_attempt_lease.ts +16 -0
- package/src/storage/migrations/20260731022945_verification_attempt_timeout.ts +11 -0
- package/src/storage/migrations/20260731023300_event_owner_generation.ts +11 -0
- package/src/storage/migrations/20260731031224_session_warp_outbox.ts +38 -0
- package/src/storage/migrations/20260731073410_workspace-mutation-lease.ts +28 -0
- package/src/storage/migrations/20260731074831_verification-execution-attestation.ts +11 -0
- package/src/storage/migrations/20260731081000_workspace-session-mutation-fences.ts +67 -0
- package/src/storage/migrations/20260801155612_session_run_state.ts +33 -0
- package/src/storage/migrations/20260801162000_session_usage_contribution.ts +46 -0
- package/src/storage/migrations/20260801163000_backfill_session_transcript.ts +551 -0
- package/src/storage/migrations/20260913045944_session_tree_budget.ts +20 -0
- package/src/storage/migrations/20261005065909_session_input_origin.ts +25 -0
- package/src/storage/migrations/20261005143808_session_run_input_owner.ts +13 -0
- package/src/storage/migrations/20261006020515_node_command_receipt.ts +19 -0
- package/src/storage/migrations/20261009151628_session_command_receipt.ts +21 -0
- package/src/storage/offline.ts +34 -0
- package/src/storage/path.ts +91 -0
- package/src/storage/schema.gen.ts +490 -0
- package/src/storage/schema.sql.ts +10 -0
- package/src/storage/sqlite.bun.ts +195 -0
- package/src/storage/sqlite.ts +8 -0
- package/src/storage/tables/commands.ts +19 -0
- package/src/storage/tables/credentials.ts +14 -0
- package/src/storage/tables/events.ts +26 -0
- package/src/storage/tables/permissions.ts +20 -0
- package/src/storage/tables/projects.ts +35 -0
- package/src/storage/tables/sessions.ts +358 -0
- package/src/storage/tables/workspaces.ts +87 -0
- package/src/tools/admission.ts +29 -0
- package/src/tools/application.ts +54 -0
- package/src/tools/builtins.ts +50 -0
- package/src/tools/definition.ts +198 -0
- package/src/tools/files/edit.ts +200 -0
- package/src/tools/files/format.ts +46 -0
- package/src/tools/files/glob.ts +102 -0
- package/src/tools/files/grep.ts +134 -0
- package/src/tools/files/patch.ts +179 -0
- package/src/tools/files/read.ts +146 -0
- package/src/tools/files/reader.ts +363 -0
- package/src/tools/files/write.ts +94 -0
- package/src/tools/output-store.ts +217 -0
- package/src/tools/planning.ts +56 -0
- package/src/tools/process/session.ts +44 -0
- package/src/tools/process/shell.ts +271 -0
- package/src/tools/question.ts +107 -0
- package/src/tools/registration.ts +13 -0
- package/src/tools/registry.ts +248 -0
- package/src/tools/skill.ts +103 -0
- package/src/tools/task.ts +100 -0
- package/src/tools/web/body.ts +30 -0
- package/src/tools/web/fetch.ts +211 -0
- package/src/tools/web/search.ts +253 -0
- package/src/transport/api/definition.ts +103 -0
- package/src/transport/api/errors.ts +112 -0
- package/src/transport/api/middleware/authorization.ts +7 -0
- package/src/transport/api/middleware/schema-error.ts +8 -0
- package/src/transport/api/middleware/service-admission.ts +8 -0
- package/src/transport/api/resources/agent.ts +21 -0
- package/src/transport/api/resources/command.ts +28 -0
- package/src/transport/api/resources/credential.ts +38 -0
- package/src/transport/api/resources/event.ts +61 -0
- package/src/transport/api/resources/fs.ts +69 -0
- package/src/transport/api/resources/health.ts +65 -0
- package/src/transport/api/resources/integration.ts +131 -0
- package/src/transport/api/resources/location.ts +43 -0
- package/src/transport/api/resources/message.ts +69 -0
- package/src/transport/api/resources/model.ts +33 -0
- package/src/transport/api/resources/permission.ts +96 -0
- package/src/transport/api/resources/project-copy.ts +57 -0
- package/src/transport/api/resources/project.ts +19 -0
- package/src/transport/api/resources/provider.ts +46 -0
- package/src/transport/api/resources/pty.ts +143 -0
- package/src/transport/api/resources/question.ts +85 -0
- package/src/transport/api/resources/reference.ts +28 -0
- package/src/transport/api/resources/service.ts +46 -0
- package/src/transport/api/resources/session.ts +477 -0
- package/src/transport/api/resources/skill.ts +28 -0
- package/src/transport/api/resources/tui.ts +100 -0
- package/src/transport/client/connection.ts +389 -0
- package/src/transport/client/create.ts +112 -0
- package/src/transport/client/errors.ts +51 -0
- package/src/transport/client/events.ts +218 -0
- package/src/transport/client/generated/client/client.gen.ts +311 -0
- package/src/transport/client/generated/client/index.ts +25 -0
- package/src/transport/client/generated/client/types.gen.ts +241 -0
- package/src/transport/client/generated/client/utils.gen.ts +337 -0
- package/src/transport/client/generated/client.gen.ts +25 -0
- package/src/transport/client/generated/core/auth.gen.ts +42 -0
- package/src/transport/client/generated/core/bodySerializer.gen.ts +100 -0
- package/src/transport/client/generated/core/params.gen.ts +176 -0
- package/src/transport/client/generated/core/pathSerializer.gen.ts +181 -0
- package/src/transport/client/generated/core/queryKeySerializer.gen.ts +136 -0
- package/src/transport/client/generated/core/serverSentEvents.gen.ts +266 -0
- package/src/transport/client/generated/core/types.gen.ts +118 -0
- package/src/transport/client/generated/core/utils.gen.ts +143 -0
- package/src/transport/client/generated/sdk.gen.ts +6695 -0
- package/src/transport/client/generated/types.gen.ts +16571 -0
- package/src/transport/client/session-state.ts +341 -0
- package/src/transport/host/api.ts +9 -0
- package/src/transport/host/auth.ts +64 -0
- package/src/transport/host/cors.ts +35 -0
- package/src/transport/host/handlers/agent.ts +14 -0
- package/src/transport/host/handlers/command.ts +9 -0
- package/src/transport/host/handlers/credential.ts +23 -0
- package/src/transport/host/handlers/event.ts +39 -0
- package/src/transport/host/handlers/fs.ts +40 -0
- package/src/transport/host/handlers/health.ts +11 -0
- package/src/transport/host/handlers/integration.ts +105 -0
- package/src/transport/host/handlers/location.ts +19 -0
- package/src/transport/host/handlers/message.ts +65 -0
- package/src/transport/host/handlers/model.ts +25 -0
- package/src/transport/host/handlers/permission.ts +68 -0
- package/src/transport/host/handlers/project-copy.ts +69 -0
- package/src/transport/host/handlers/project.ts +32 -0
- package/src/transport/host/handlers/provider.ts +33 -0
- package/src/transport/host/handlers/pty.ts +224 -0
- package/src/transport/host/handlers/question.ts +63 -0
- package/src/transport/host/handlers/reference.ts +9 -0
- package/src/transport/host/handlers/service.ts +24 -0
- package/src/transport/host/handlers/session.ts +581 -0
- package/src/transport/host/handlers/skill.ts +9 -0
- package/src/transport/host/handlers/tui.ts +136 -0
- package/src/transport/host/handlers.ts +68 -0
- package/src/transport/host/location.ts +66 -0
- package/src/transport/host/middleware/authorization.ts +59 -0
- package/src/transport/host/middleware/schema-error.ts +17 -0
- package/src/transport/host/middleware/service-admission.ts +22 -0
- package/src/transport/host/middleware/session-location.ts +72 -0
- package/src/transport/host/pty-environment.ts +17 -0
- package/src/transport/host/routes.ts +67 -0
- package/src/transport/host/runtime.ts +22 -0
- package/src/transport/host/service-control.ts +143 -0
- package/src/transport/host/sse.ts +415 -0
- package/src/transport/host/utf8.ts +26 -0
- package/src/verification/authority.ts +547 -0
- package/src/verification/canonical-signature.ts +145 -0
- package/src/verification/containment.ts +197 -0
- package/src/verification/enforcement.ts +255 -0
- package/src/verification/execution-attestation.ts +321 -0
- package/src/verification/key-lifecycle.ts +456 -0
- package/src/verification/local.ts +87 -0
- package/src/verification/oci/containment.ts +529 -0
- package/src/verification/oci/lease.ts +1549 -0
- package/src/verification/oci/runtime.ts +309 -0
- package/src/verification/oci/supervisor.ts +429 -0
- package/src/verification/registry.ts +379 -0
- package/src/verification/settlement-admission.ts +322 -0
- package/src/verification/trusted-file.ts +372 -0
- package/src/workspace/files/access.ts +257 -0
- package/src/workspace/files/diff.ts +6 -0
- package/src/workspace/files/formatter.ts +130 -0
- package/src/workspace/files/ignore.ts +67 -0
- package/src/workspace/files/mutation.ts +203 -0
- package/src/workspace/files/patch.ts +197 -0
- package/src/workspace/files/protected.ts +53 -0
- package/src/workspace/files/service.ts +115 -0
- package/src/workspace/files/watcher.ts +138 -0
- package/src/workspace/location.ts +35 -0
- package/src/workspace/media/image.ts +78 -0
- package/src/workspace/media/photon.ts +95 -0
- package/src/workspace/mutations.ts +158 -0
- package/src/workspace/projects/copy-strategies.ts +35 -0
- package/src/workspace/projects/copy.ts +282 -0
- package/src/workspace/projects/directories.ts +159 -0
- package/src/workspace/projects/schema.ts +16 -0
- package/src/workspace/projects/service.ts +136 -0
- package/src/workspace/repository/cache.ts +261 -0
- package/src/workspace/repository/git.ts +4272 -0
- package/src/workspace/repository/reference.ts +217 -0
- package/src/workspace/repository/retention-barrier.ts +18 -0
- package/src/workspace/repository/snapshot.ts +791 -0
- package/src/workspace/search/binary.ts +134 -0
- package/src/workspace/search/native.ts +140 -0
- package/src/workspace/search/ripgrep.ts +282 -0
- package/src/workspace/search/service.ts +239 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { Auth } from "../core/auth.gen.js";
|
|
4
|
+
import type {
|
|
5
|
+
ServerSentEventsOptions,
|
|
6
|
+
ServerSentEventsResult,
|
|
7
|
+
} from "../core/serverSentEvents.gen.js";
|
|
8
|
+
import type {
|
|
9
|
+
Client as CoreClient,
|
|
10
|
+
Config as CoreConfig,
|
|
11
|
+
} from "../core/types.gen.js";
|
|
12
|
+
import type { Middleware } from "./utils.gen.js";
|
|
13
|
+
|
|
14
|
+
export type ResponseStyle = "data" | "fields";
|
|
15
|
+
|
|
16
|
+
export interface Config<T extends ClientOptions = ClientOptions>
|
|
17
|
+
extends Omit<RequestInit, "body" | "headers" | "method">,
|
|
18
|
+
CoreConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Base URL for all requests made by this client.
|
|
21
|
+
*/
|
|
22
|
+
baseUrl?: T["baseUrl"];
|
|
23
|
+
/**
|
|
24
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
25
|
+
* fetch instance.
|
|
26
|
+
*
|
|
27
|
+
* @default globalThis.fetch
|
|
28
|
+
*/
|
|
29
|
+
fetch?: typeof fetch;
|
|
30
|
+
/**
|
|
31
|
+
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
32
|
+
* options won't have any effect.
|
|
33
|
+
*
|
|
34
|
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
35
|
+
*/
|
|
36
|
+
next?: never;
|
|
37
|
+
/**
|
|
38
|
+
* Return the response data parsed in a specified format. By default, `auto`
|
|
39
|
+
* will infer the appropriate method from the `Content-Type` response header.
|
|
40
|
+
* You can override this behavior with any of the {@link Body} methods.
|
|
41
|
+
* Select `stream` if you don't want to parse response data at all.
|
|
42
|
+
*
|
|
43
|
+
* @default 'auto'
|
|
44
|
+
*/
|
|
45
|
+
parseAs?:
|
|
46
|
+
| "arrayBuffer"
|
|
47
|
+
| "auto"
|
|
48
|
+
| "blob"
|
|
49
|
+
| "formData"
|
|
50
|
+
| "json"
|
|
51
|
+
| "stream"
|
|
52
|
+
| "text";
|
|
53
|
+
/**
|
|
54
|
+
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
55
|
+
*
|
|
56
|
+
* @default 'fields'
|
|
57
|
+
*/
|
|
58
|
+
responseStyle?: ResponseStyle;
|
|
59
|
+
/**
|
|
60
|
+
* Throw an error instead of returning it in the response?
|
|
61
|
+
*
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
throwOnError?: T["throwOnError"];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface RequestOptions<
|
|
68
|
+
TData = unknown,
|
|
69
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
70
|
+
ThrowOnError extends boolean = boolean,
|
|
71
|
+
Url extends string = string,
|
|
72
|
+
> extends Config<{
|
|
73
|
+
responseStyle: TResponseStyle;
|
|
74
|
+
throwOnError: ThrowOnError;
|
|
75
|
+
}>,
|
|
76
|
+
Pick<
|
|
77
|
+
ServerSentEventsOptions<TData>,
|
|
78
|
+
| "onSseError"
|
|
79
|
+
| "onSseEvent"
|
|
80
|
+
| "sseDefaultRetryDelay"
|
|
81
|
+
| "sseMaxRetryAttempts"
|
|
82
|
+
| "sseMaxRetryDelay"
|
|
83
|
+
> {
|
|
84
|
+
/**
|
|
85
|
+
* Any body that you want to add to your request.
|
|
86
|
+
*
|
|
87
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
88
|
+
*/
|
|
89
|
+
body?: unknown;
|
|
90
|
+
path?: Record<string, unknown>;
|
|
91
|
+
query?: Record<string, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* Security mechanism(s) to use for the request.
|
|
94
|
+
*/
|
|
95
|
+
security?: ReadonlyArray<Auth>;
|
|
96
|
+
url: Url;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ResolvedRequestOptions<
|
|
100
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
101
|
+
ThrowOnError extends boolean = boolean,
|
|
102
|
+
Url extends string = string,
|
|
103
|
+
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
104
|
+
serializedBody?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type RequestResult<
|
|
108
|
+
TData = unknown,
|
|
109
|
+
TError = unknown,
|
|
110
|
+
ThrowOnError extends boolean = boolean,
|
|
111
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
112
|
+
> = ThrowOnError extends true
|
|
113
|
+
? Promise<
|
|
114
|
+
TResponseStyle extends "data"
|
|
115
|
+
? TData extends Record<string, unknown>
|
|
116
|
+
? TData[keyof TData]
|
|
117
|
+
: TData
|
|
118
|
+
: {
|
|
119
|
+
data: TData extends Record<string, unknown>
|
|
120
|
+
? TData[keyof TData]
|
|
121
|
+
: TData;
|
|
122
|
+
request: Request;
|
|
123
|
+
response: Response;
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
: Promise<
|
|
127
|
+
TResponseStyle extends "data"
|
|
128
|
+
?
|
|
129
|
+
| (TData extends Record<string, unknown>
|
|
130
|
+
? TData[keyof TData]
|
|
131
|
+
: TData)
|
|
132
|
+
| undefined
|
|
133
|
+
: (
|
|
134
|
+
| {
|
|
135
|
+
data: TData extends Record<string, unknown>
|
|
136
|
+
? TData[keyof TData]
|
|
137
|
+
: TData;
|
|
138
|
+
error: undefined;
|
|
139
|
+
}
|
|
140
|
+
| {
|
|
141
|
+
data: undefined;
|
|
142
|
+
error: TError extends Record<string, unknown>
|
|
143
|
+
? TError[keyof TError]
|
|
144
|
+
: TError;
|
|
145
|
+
}
|
|
146
|
+
) & {
|
|
147
|
+
request: Request;
|
|
148
|
+
response: Response;
|
|
149
|
+
}
|
|
150
|
+
>;
|
|
151
|
+
|
|
152
|
+
export interface ClientOptions {
|
|
153
|
+
baseUrl?: string;
|
|
154
|
+
responseStyle?: ResponseStyle;
|
|
155
|
+
throwOnError?: boolean;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type MethodFn = <
|
|
159
|
+
TData = unknown,
|
|
160
|
+
TError = unknown,
|
|
161
|
+
ThrowOnError extends boolean = false,
|
|
162
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
163
|
+
>(
|
|
164
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
165
|
+
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
166
|
+
|
|
167
|
+
type SseFn = <
|
|
168
|
+
TData = unknown,
|
|
169
|
+
TError = unknown,
|
|
170
|
+
ThrowOnError extends boolean = false,
|
|
171
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
172
|
+
>(
|
|
173
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
174
|
+
) => Promise<ServerSentEventsResult<TData>>;
|
|
175
|
+
|
|
176
|
+
type RequestFn = <
|
|
177
|
+
TData = unknown,
|
|
178
|
+
TError = unknown,
|
|
179
|
+
ThrowOnError extends boolean = false,
|
|
180
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
181
|
+
>(
|
|
182
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> &
|
|
183
|
+
Pick<
|
|
184
|
+
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
|
185
|
+
"method"
|
|
186
|
+
>,
|
|
187
|
+
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
188
|
+
|
|
189
|
+
type BuildUrlFn = <
|
|
190
|
+
TData extends {
|
|
191
|
+
body?: unknown;
|
|
192
|
+
path?: Record<string, unknown>;
|
|
193
|
+
query?: Record<string, unknown>;
|
|
194
|
+
url: string;
|
|
195
|
+
},
|
|
196
|
+
>(
|
|
197
|
+
options: TData & Options<TData>,
|
|
198
|
+
) => string;
|
|
199
|
+
|
|
200
|
+
export type Client = CoreClient<
|
|
201
|
+
RequestFn,
|
|
202
|
+
Config,
|
|
203
|
+
MethodFn,
|
|
204
|
+
BuildUrlFn,
|
|
205
|
+
SseFn
|
|
206
|
+
> & {
|
|
207
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
212
|
+
* and the returned object will become the client's initial configuration.
|
|
213
|
+
*
|
|
214
|
+
* You may want to initialize your client this way instead of calling
|
|
215
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
216
|
+
* to ensure your client always has the correct values.
|
|
217
|
+
*/
|
|
218
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
219
|
+
override?: Config<ClientOptions & T>,
|
|
220
|
+
) => Config<Required<ClientOptions> & T>;
|
|
221
|
+
|
|
222
|
+
export interface TDataShape {
|
|
223
|
+
body?: unknown;
|
|
224
|
+
headers?: unknown;
|
|
225
|
+
path?: unknown;
|
|
226
|
+
query?: unknown;
|
|
227
|
+
url: string;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
231
|
+
|
|
232
|
+
export type Options<
|
|
233
|
+
TData extends TDataShape = TDataShape,
|
|
234
|
+
ThrowOnError extends boolean = boolean,
|
|
235
|
+
TResponse = unknown,
|
|
236
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
237
|
+
> = OmitKeys<
|
|
238
|
+
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
|
239
|
+
"body" | "path" | "query" | "url"
|
|
240
|
+
> &
|
|
241
|
+
([TData] extends [never] ? unknown : Omit<TData, "url">);
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { getAuthToken } from "../core/auth.gen.js";
|
|
4
|
+
import type { QuerySerializerOptions } from "../core/bodySerializer.gen.js";
|
|
5
|
+
import { jsonBodySerializer } from "../core/bodySerializer.gen.js";
|
|
6
|
+
import {
|
|
7
|
+
serializeArrayParam,
|
|
8
|
+
serializeObjectParam,
|
|
9
|
+
serializePrimitiveParam,
|
|
10
|
+
} from "../core/pathSerializer.gen.js";
|
|
11
|
+
import { getUrl } from "../core/utils.gen.js";
|
|
12
|
+
import type {
|
|
13
|
+
Client,
|
|
14
|
+
ClientOptions,
|
|
15
|
+
Config,
|
|
16
|
+
RequestOptions,
|
|
17
|
+
} from "./types.gen.js";
|
|
18
|
+
|
|
19
|
+
export const createQuerySerializer = <T = unknown>({
|
|
20
|
+
parameters = {},
|
|
21
|
+
...args
|
|
22
|
+
}: QuerySerializerOptions = {}) => {
|
|
23
|
+
const querySerializer = (queryParams: T) => {
|
|
24
|
+
const search: string[] = [];
|
|
25
|
+
if (queryParams && typeof queryParams === "object") {
|
|
26
|
+
for (const name in queryParams) {
|
|
27
|
+
const value = queryParams[name];
|
|
28
|
+
|
|
29
|
+
if (value === undefined || value === null) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const options = parameters[name] || args;
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
const serializedArray = serializeArrayParam({
|
|
37
|
+
allowReserved: options.allowReserved,
|
|
38
|
+
explode: true,
|
|
39
|
+
name,
|
|
40
|
+
style: "form",
|
|
41
|
+
value,
|
|
42
|
+
...options.array,
|
|
43
|
+
});
|
|
44
|
+
if (serializedArray) search.push(serializedArray);
|
|
45
|
+
} else if (typeof value === "object") {
|
|
46
|
+
const serializedObject = serializeObjectParam({
|
|
47
|
+
allowReserved: options.allowReserved,
|
|
48
|
+
explode: true,
|
|
49
|
+
name,
|
|
50
|
+
style: "deepObject",
|
|
51
|
+
value: value as Record<string, unknown>,
|
|
52
|
+
...options.object,
|
|
53
|
+
});
|
|
54
|
+
if (serializedObject) search.push(serializedObject);
|
|
55
|
+
} else {
|
|
56
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
57
|
+
allowReserved: options.allowReserved,
|
|
58
|
+
name,
|
|
59
|
+
value: value as string,
|
|
60
|
+
});
|
|
61
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return search.join("&");
|
|
66
|
+
};
|
|
67
|
+
return querySerializer;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Infers parseAs value from provided Content-Type header.
|
|
72
|
+
*/
|
|
73
|
+
export const getParseAs = (
|
|
74
|
+
contentType: string | null,
|
|
75
|
+
): Exclude<Config["parseAs"], "auto"> => {
|
|
76
|
+
if (!contentType) {
|
|
77
|
+
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
78
|
+
// which is effectively the same as the 'stream' option.
|
|
79
|
+
return "stream";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
83
|
+
|
|
84
|
+
if (!cleanContent) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (
|
|
89
|
+
cleanContent.startsWith("application/json") ||
|
|
90
|
+
cleanContent.endsWith("+json")
|
|
91
|
+
) {
|
|
92
|
+
return "json";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (cleanContent === "multipart/form-data") {
|
|
96
|
+
return "formData";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (
|
|
100
|
+
["application/", "audio/", "image/", "video/"].some((type) =>
|
|
101
|
+
cleanContent.startsWith(type),
|
|
102
|
+
)
|
|
103
|
+
) {
|
|
104
|
+
return "blob";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (cleanContent.startsWith("text/")) {
|
|
108
|
+
return "text";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const checkForExistence = (
|
|
115
|
+
options: Pick<RequestOptions, "auth" | "query"> & {
|
|
116
|
+
headers: Headers;
|
|
117
|
+
},
|
|
118
|
+
name?: string,
|
|
119
|
+
): boolean => {
|
|
120
|
+
if (!name) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (
|
|
124
|
+
options.headers.has(name) ||
|
|
125
|
+
options.query?.[name] ||
|
|
126
|
+
options.headers.get("Cookie")?.includes(`${name}=`)
|
|
127
|
+
) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const setAuthParams = async ({
|
|
134
|
+
security,
|
|
135
|
+
...options
|
|
136
|
+
}: Pick<Required<RequestOptions>, "security"> &
|
|
137
|
+
Pick<RequestOptions, "auth" | "query"> & {
|
|
138
|
+
headers: Headers;
|
|
139
|
+
}) => {
|
|
140
|
+
for (const auth of security) {
|
|
141
|
+
if (checkForExistence(options, auth.name)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const token = await getAuthToken(auth, options.auth);
|
|
146
|
+
|
|
147
|
+
if (!token) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const name = auth.name ?? "Authorization";
|
|
152
|
+
|
|
153
|
+
switch (auth.in) {
|
|
154
|
+
case "query":
|
|
155
|
+
if (!options.query) {
|
|
156
|
+
options.query = {};
|
|
157
|
+
}
|
|
158
|
+
options.query[name] = token;
|
|
159
|
+
break;
|
|
160
|
+
case "cookie":
|
|
161
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
162
|
+
break;
|
|
163
|
+
case "header":
|
|
164
|
+
default:
|
|
165
|
+
options.headers.set(name, token);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const buildUrl: Client["buildUrl"] = (options) =>
|
|
172
|
+
getUrl({
|
|
173
|
+
baseUrl: options.baseUrl as string,
|
|
174
|
+
path: options.path,
|
|
175
|
+
query: options.query,
|
|
176
|
+
querySerializer:
|
|
177
|
+
typeof options.querySerializer === "function"
|
|
178
|
+
? options.querySerializer
|
|
179
|
+
: createQuerySerializer(options.querySerializer),
|
|
180
|
+
url: options.url,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
184
|
+
const config = { ...a, ...b };
|
|
185
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
186
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
187
|
+
}
|
|
188
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
189
|
+
return config;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
193
|
+
const entries: Array<[string, string]> = [];
|
|
194
|
+
headers.forEach((value, key) => {
|
|
195
|
+
entries.push([key, value]);
|
|
196
|
+
});
|
|
197
|
+
return entries;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const mergeHeaders = (
|
|
201
|
+
...headers: Array<Required<Config>["headers"] | undefined>
|
|
202
|
+
): Headers => {
|
|
203
|
+
const mergedHeaders = new Headers();
|
|
204
|
+
for (const header of headers) {
|
|
205
|
+
if (!header) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const iterator =
|
|
210
|
+
header instanceof Headers
|
|
211
|
+
? headersEntries(header)
|
|
212
|
+
: Object.entries(header);
|
|
213
|
+
|
|
214
|
+
for (const [key, value] of iterator) {
|
|
215
|
+
if (value === null) {
|
|
216
|
+
mergedHeaders.delete(key);
|
|
217
|
+
} else if (Array.isArray(value)) {
|
|
218
|
+
for (const v of value) {
|
|
219
|
+
mergedHeaders.append(key, v as string);
|
|
220
|
+
}
|
|
221
|
+
} else if (value !== undefined) {
|
|
222
|
+
// assume object headers are meant to be JSON stringified, i.e. their
|
|
223
|
+
// content value in OpenAPI specification is 'application/json'
|
|
224
|
+
mergedHeaders.set(
|
|
225
|
+
key,
|
|
226
|
+
typeof value === "object" ? JSON.stringify(value) : (value as string),
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return mergedHeaders;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
type ErrInterceptor<Err, Res, Req, Options> = (
|
|
235
|
+
error: Err,
|
|
236
|
+
response: Res,
|
|
237
|
+
request: Req,
|
|
238
|
+
options: Options,
|
|
239
|
+
) => Err | Promise<Err>;
|
|
240
|
+
|
|
241
|
+
type ReqInterceptor<Req, Options> = (
|
|
242
|
+
request: Req,
|
|
243
|
+
options: Options,
|
|
244
|
+
) => Req | Promise<Req>;
|
|
245
|
+
|
|
246
|
+
type ResInterceptor<Res, Req, Options> = (
|
|
247
|
+
response: Res,
|
|
248
|
+
request: Req,
|
|
249
|
+
options: Options,
|
|
250
|
+
) => Res | Promise<Res>;
|
|
251
|
+
|
|
252
|
+
class Interceptors<Interceptor> {
|
|
253
|
+
fns: Array<Interceptor | null> = [];
|
|
254
|
+
|
|
255
|
+
clear(): void {
|
|
256
|
+
this.fns = [];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
eject(id: number | Interceptor): void {
|
|
260
|
+
const index = this.getInterceptorIndex(id);
|
|
261
|
+
if (this.fns[index]) {
|
|
262
|
+
this.fns[index] = null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
exists(id: number | Interceptor): boolean {
|
|
267
|
+
const index = this.getInterceptorIndex(id);
|
|
268
|
+
return Boolean(this.fns[index]);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
getInterceptorIndex(id: number | Interceptor): number {
|
|
272
|
+
if (typeof id === "number") {
|
|
273
|
+
return this.fns[id] ? id : -1;
|
|
274
|
+
}
|
|
275
|
+
return this.fns.indexOf(id);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
update(
|
|
279
|
+
id: number | Interceptor,
|
|
280
|
+
fn: Interceptor,
|
|
281
|
+
): number | Interceptor | false {
|
|
282
|
+
const index = this.getInterceptorIndex(id);
|
|
283
|
+
if (this.fns[index]) {
|
|
284
|
+
this.fns[index] = fn;
|
|
285
|
+
return id;
|
|
286
|
+
}
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
use(fn: Interceptor): number {
|
|
291
|
+
this.fns.push(fn);
|
|
292
|
+
return this.fns.length - 1;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface Middleware<Req, Res, Err, Options> {
|
|
297
|
+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
298
|
+
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
299
|
+
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<
|
|
303
|
+
Req,
|
|
304
|
+
Res,
|
|
305
|
+
Err,
|
|
306
|
+
Options
|
|
307
|
+
> => ({
|
|
308
|
+
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
|
|
309
|
+
request: new Interceptors<ReqInterceptor<Req, Options>>(),
|
|
310
|
+
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
const defaultQuerySerializer = createQuerySerializer({
|
|
314
|
+
allowReserved: false,
|
|
315
|
+
array: {
|
|
316
|
+
explode: true,
|
|
317
|
+
style: "form",
|
|
318
|
+
},
|
|
319
|
+
object: {
|
|
320
|
+
explode: true,
|
|
321
|
+
style: "deepObject",
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const defaultHeaders = {
|
|
326
|
+
"Content-Type": "application/json",
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
330
|
+
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
|
331
|
+
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
332
|
+
...jsonBodySerializer,
|
|
333
|
+
headers: defaultHeaders,
|
|
334
|
+
parseAs: "auto",
|
|
335
|
+
querySerializer: defaultQuerySerializer,
|
|
336
|
+
...override,
|
|
337
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ClientOptions,
|
|
5
|
+
type Config,
|
|
6
|
+
createClient,
|
|
7
|
+
createConfig,
|
|
8
|
+
} from "./client/index.js";
|
|
9
|
+
import type { ClientOptions as ClientOptions2 } from "./types.gen.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
13
|
+
* and the returned object will become the client's initial configuration.
|
|
14
|
+
*
|
|
15
|
+
* You may want to initialize your client this way instead of calling
|
|
16
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
17
|
+
* to ensure your client always has the correct values.
|
|
18
|
+
*/
|
|
19
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
|
20
|
+
override?: Config<ClientOptions & T>,
|
|
21
|
+
) => Config<Required<ClientOptions> & T>;
|
|
22
|
+
|
|
23
|
+
export const client = createClient(
|
|
24
|
+
createConfig<ClientOptions2>({ baseUrl: "http://localhost:4096" }),
|
|
25
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type AuthToken = string | undefined;
|
|
4
|
+
|
|
5
|
+
export interface Auth {
|
|
6
|
+
/**
|
|
7
|
+
* Which part of the request do we use to send the auth?
|
|
8
|
+
*
|
|
9
|
+
* @default 'header'
|
|
10
|
+
*/
|
|
11
|
+
in?: "header" | "query" | "cookie";
|
|
12
|
+
/**
|
|
13
|
+
* Header or query parameter name.
|
|
14
|
+
*
|
|
15
|
+
* @default 'Authorization'
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
scheme?: "basic" | "bearer";
|
|
19
|
+
type: "apiKey" | "http";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getAuthToken = async (
|
|
23
|
+
auth: Auth,
|
|
24
|
+
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
25
|
+
): Promise<string | undefined> => {
|
|
26
|
+
const token =
|
|
27
|
+
typeof callback === "function" ? await callback(auth) : callback;
|
|
28
|
+
|
|
29
|
+
if (!token) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (auth.scheme === "bearer") {
|
|
34
|
+
return `Bearer ${token}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (auth.scheme === "basic") {
|
|
38
|
+
return `Basic ${btoa(token)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return token;
|
|
42
|
+
};
|