@withgateway/sdk 0.3.3 → 0.4.0

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.
Files changed (123) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +2221 -962
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +2212 -953
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.js +81 -19
  7. package/dist/files/index.js.map +1 -1
  8. package/dist/files/index.mjs +79 -17
  9. package/dist/files/index.mjs.map +1 -1
  10. package/dist/hooks/index.d.mts +1 -1
  11. package/dist/hooks/index.d.ts +1 -1
  12. package/dist/hooks/index.js +124 -11
  13. package/dist/hooks/index.js.map +1 -1
  14. package/dist/hooks/index.mjs +124 -11
  15. package/dist/hooks/index.mjs.map +1 -1
  16. package/dist/{index-C3UzD0G3.d.mts → index-CDPQBsU5.d.mts} +19 -3
  17. package/dist/{index-C3UzD0G3.d.ts → index-CDPQBsU5.d.ts} +19 -3
  18. package/dist/index.d.mts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +903 -221
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +868 -212
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/traces/index.js +78 -16
  25. package/dist/traces/index.js.map +1 -1
  26. package/dist/traces/index.mjs +76 -14
  27. package/dist/traces/index.mjs.map +1 -1
  28. package/dist/tracing/index.js +7 -1
  29. package/dist/tracing/index.js.map +1 -1
  30. package/dist/tracing/index.mjs +7 -1
  31. package/dist/tracing/index.mjs.map +1 -1
  32. package/dist/worlds/index.d.mts +692 -410
  33. package/dist/worlds/index.d.ts +692 -410
  34. package/dist/worlds/index.js +740 -197
  35. package/dist/worlds/index.js.map +1 -1
  36. package/dist/worlds/index.mjs +736 -193
  37. package/dist/worlds/index.mjs.map +1 -1
  38. package/package.json +1 -1
  39. package/runtime/gatewaysdk/environment/_materialize.py +5 -25
  40. package/runtime/gatewaysdk/environment/_world.py +58 -65
  41. package/runtime/gatewaysdk/environment/backing.py +20 -24
  42. package/runtime/gatewaysdk/environment/core.py +1 -16
  43. package/runtime/gatewaysdk/environment/legacy_sqlite.py +14 -27
  44. package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
  45. package/runtime/gatewaysdk/environment/schema/api.py +174 -471
  46. package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
  47. package/runtime/gatewaysdk/environment/schema/batch.py +3 -3
  48. package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
  49. package/runtime/gatewaysdk/environment/schema/call_capture.py +309 -0
  50. package/runtime/gatewaysdk/environment/schema/call_log.py +230 -18
  51. package/runtime/gatewaysdk/environment/schema/call_redaction.py +201 -19
  52. package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
  53. package/runtime/gatewaysdk/environment/schema/conform.py +6 -27
  54. package/runtime/gatewaysdk/environment/schema/connector.py +89 -152
  55. package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
  56. package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +1 -0
  57. package/runtime/gatewaysdk/environment/schema/connectors/servicenow/connector.toml +2 -5
  58. package/runtime/gatewaysdk/environment/schema/cors.py +54 -0
  59. package/runtime/gatewaysdk/environment/schema/credentials.py +313 -8
  60. package/runtime/gatewaysdk/environment/schema/data.py +14 -13
  61. package/runtime/gatewaysdk/environment/schema/database/base.py +106 -165
  62. package/runtime/gatewaysdk/environment/schema/database/guard.py +43 -36
  63. package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
  64. package/runtime/gatewaysdk/environment/schema/database/sqlite.py +57 -31
  65. package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
  66. package/runtime/gatewaysdk/environment/schema/door.py +899 -0
  67. package/runtime/gatewaysdk/environment/schema/envelope.py +86 -28
  68. package/runtime/gatewaysdk/environment/schema/grading.py +58 -86
  69. package/runtime/gatewaysdk/environment/schema/handler_errors.py +25 -4
  70. package/runtime/gatewaysdk/environment/schema/host.py +229 -1695
  71. package/runtime/gatewaysdk/environment/schema/host_control.py +144 -0
  72. package/runtime/gatewaysdk/environment/schema/host_handoff.py +370 -0
  73. package/runtime/gatewaysdk/environment/schema/host_loops.py +97 -0
  74. package/runtime/gatewaysdk/environment/schema/host_owners.py +121 -0
  75. package/runtime/gatewaysdk/environment/schema/host_proxy.py +111 -0
  76. package/runtime/gatewaysdk/environment/schema/host_requests.py +6 -0
  77. package/runtime/gatewaysdk/environment/schema/host_session.py +126 -0
  78. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +79 -21
  79. package/runtime/gatewaysdk/environment/schema/host_transfers.py +127 -0
  80. package/runtime/gatewaysdk/environment/schema/host_versions.py +242 -0
  81. package/runtime/gatewaysdk/environment/schema/host_workers.py +577 -0
  82. package/runtime/gatewaysdk/environment/schema/journal.py +437 -0
  83. package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
  84. package/runtime/gatewaysdk/environment/schema/local.py +31 -116
  85. package/runtime/gatewaysdk/environment/schema/platform.py +15 -17
  86. package/runtime/gatewaysdk/environment/schema/request_body.py +238 -0
  87. package/runtime/gatewaysdk/environment/schema/request_ledger.py +958 -0
  88. package/runtime/gatewaysdk/environment/schema/route_bindings.py +25 -3
  89. package/runtime/gatewaysdk/environment/schema/route_miss.py +54 -0
  90. package/runtime/gatewaysdk/environment/schema/runtime.py +129 -176
  91. package/runtime/gatewaysdk/environment/schema/session_files.py +133 -24
  92. package/runtime/gatewaysdk/environment/schema/session_move.py +275 -0
  93. package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +5 -1
  94. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +8 -9
  95. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +31 -6
  96. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +12 -8
  97. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +13 -13
  98. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +23 -23
  99. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +11 -6
  100. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +35 -2
  101. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
  102. package/runtime/gatewaysdk/environment/schema/snapshot.py +149 -29
  103. package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
  104. package/runtime/gatewaysdk/environment/schema/tasks.py +229 -323
  105. package/runtime/gatewaysdk/environment/schema/tools_world.py +84 -203
  106. package/runtime/gatewaysdk/environment/schema/validation.py +69 -1
  107. package/runtime/gatewaysdk/environment/schema/verbs.py +32 -36
  108. package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
  109. package/runtime/gatewaysdk/environment/schema/workers.py +203 -39
  110. package/runtime/gatewaysdk/environment/schema/world_host.py +953 -0
  111. package/runtime/gatewaysdk/environment/schema/world_tests.py +9 -11
  112. package/runtime/gatewaysdk/environment/world.py +1 -1
  113. package/runtime/gatewaysdk/environment/world_session_contract.py +14 -0
  114. package/skills/agents/connector-template-author.md +5 -1
  115. package/skills/benchmarks-getting-started/SKILL.md +8 -9
  116. package/skills/connector-schema-authoring/SKILL.md +31 -6
  117. package/skills/connector-schema-authoring/connector-worlds.md +129 -7
  118. package/skills/world-data-ingestion/ROWS.md +12 -8
  119. package/skills/world-data-ingestion/SKILL.md +13 -13
  120. package/skills/worlds-getting-started/SKILL.md +23 -23
  121. package/skills/worlds-getting-started/references/cli-mcp-map.md +11 -6
  122. package/skills/worlds-getting-started/references/gotchas.md +35 -2
  123. package/skills/worlds-getting-started/references/journal-checks.md +182 -0
@@ -1 +1 @@
1
- export { A as Alias, a as AliasHandler, b as AliasMap, c as AuditFinding, d as AuditRecord, e as AuditReport, B as Bound, C as CONTEXT_KEY, f as CallableTool, g as CommandHandler, h as ConnectorTool, D as Decision, j as DenyHandler, E as EVENTS, k as EVENT_ALIASES, F as FieldKinds, l as FieldSource, m as FinderSource, n as Finding, o as FunctionHandler, H as HANDLER_TYPES, p as Handler, q as HandlerFn, r as HandlerSpec, s as HandlerType, t as HookConfig, u as HookConfigError, v as HookDenied, w as HookError, x as HookEvent, y as HookEventName, z as HookRequest, G as HookResponse, I as HookResult, J as HookRule, K as HookRun, L as HookRunOptions, M as HookedSession, N as HttpHandler, O as HttpTool, P as INBOUND_KINDS, Q as INPUT_TYPES, R as Identifier, S as IdentifierCensus, T as IdentifierSource, U as Identity, V as InboundKind, W as JsonSchema, X as KINDS, Y as LegendEntry, Z as LegendRow, _ as LegendSource, $ as LiveConfig, a0 as LiveTool, a1 as LiveToolError, a2 as LiveTools, a3 as Matcher, a4 as PARSE_MODES, a5 as Pair, a6 as ParseMode, a7 as RecordHandler, a8 as RecordSink, a9 as Recorder, aa as RedactHandler, ab as RedactionAudit, ac as Replay, ad as RequestFn, ae as RunVerdict, af as SeedEntity, ag as SeedRow, ah as SessionLike, ai as TOOL_KINDS, aj as ToolFn, ak as ToolFunctions, al as ToolKind, am as ToolSpec, an as WrappedTools, ao as applyLimit, ap as applyResult, aq as buildTool, ar as canonical, as as definition, at as describeHandler, au as describeMatcher, av as describeTool, aw as emailPairs, ax as emptyConfig, ay as emptyLive, az as eventToJson, aA as explodeIp, aB as findKind, aC as folded, aD as genericPairs, aE as importCallable, aF as inputSchema, aG as interpolateHeaders, aH as interpolatePath, aI as isGlobalIpv4, aJ as jsPattern, aK as jsonPath, aL as loadHookConfig, aM as mapFields, aN as matches, aO as mirrorHandle, aP as namePairs, aQ as newRunKey, aR as normalizeEvent, aS as pageTitle, aT as parseHookConfig, aU as parseJson, aV as parseMatcher, aW as parseRegex, aX as parseStdout, aY as parseText, aZ as phonePairs, a_ as pyQuote, a$ as readConnection, b0 as readable, b1 as refusalReason, b2 as render, b3 as resultFromJson, b4 as splitTopLevel, b5 as stripTags, b6 as unescapeHtml, b7 as vendorOf, b8 as withContext, b9 as withDefaults } from '../index-C3UzD0G3.mjs';
1
+ export { A as Alias, a as AliasHandler, b as AliasMap, c as AuditFinding, d as AuditRecord, e as AuditReport, B as Bound, C as CONTEXT_KEY, f as CallableTool, g as CommandHandler, h as ConnectorTool, D as Decision, j as DenyHandler, E as EVENTS, k as EVENT_ALIASES, F as FieldKinds, l as FieldSource, m as FinderSource, n as Finding, o as FunctionHandler, H as HANDLER_TYPES, p as Handler, q as HandlerFn, r as HandlerSpec, s as HandlerType, t as HookConfig, u as HookConfigError, v as HookDenied, w as HookError, x as HookEvent, y as HookEventName, z as HookRequest, G as HookResponse, I as HookResult, J as HookRule, K as HookRun, L as HookRunOptions, M as HookedSession, N as HttpHandler, O as HttpTool, P as INBOUND_KINDS, Q as INPUT_TYPES, R as Identifier, S as IdentifierCensus, T as IdentifierSource, U as Identity, V as InboundKind, W as JsonSchema, X as KINDS, Y as LegendEntry, Z as LegendRow, _ as LegendSource, $ as LiveConfig, a0 as LiveTool, a1 as LiveToolError, a2 as LiveTools, a3 as Matcher, a4 as PARSE_MODES, a5 as Pair, a6 as ParseMode, a7 as RecordHandler, a8 as RecordSink, a9 as Recorder, aa as RedactHandler, ab as RedactionAudit, ac as Replay, ad as RequestFn, ae as RunVerdict, af as SeedEntity, ag as SeedRow, ah as SessionLike, ai as TOOL_KINDS, aj as ToolFn, ak as ToolFunctions, al as ToolKind, am as ToolSpec, an as WrappedTools, ao as applyLimit, ap as applyResult, aq as buildTool, ar as canonical, as as definition, at as describeHandler, au as describeMatcher, av as describeTool, aw as emailPairs, ax as emptyConfig, ay as emptyLive, az as eventToJson, aA as explodeIp, aB as findKind, aC as folded, aD as genericPairs, aE as importCallable, aF as inputSchema, aG as interpolateHeaders, aH as interpolatePath, aI as isGlobalIpv4, aJ as jsPattern, aK as jsonPath, aL as loadHookConfig, aM as mapFields, aN as matches, aO as mirrorHandle, aP as namePairs, aQ as newRunKey, aR as normalizeEvent, aS as pageTitle, aT as parseHookConfig, aU as parseJson, aV as parseMatcher, aW as parseRegex, aX as parseStdout, aY as parseText, aZ as phonePairs, a_ as pyQuote, a$ as readConnection, b0 as readable, b1 as refusalReason, b2 as render, b3 as resultFromJson, b4 as splitTopLevel, b5 as stripTags, b6 as unescapeHtml, b7 as vendorOf, b8 as withContext, b9 as withDefaults } from '../index-CDPQBsU5.mjs';
@@ -1 +1 @@
1
- export { A as Alias, a as AliasHandler, b as AliasMap, c as AuditFinding, d as AuditRecord, e as AuditReport, B as Bound, C as CONTEXT_KEY, f as CallableTool, g as CommandHandler, h as ConnectorTool, D as Decision, j as DenyHandler, E as EVENTS, k as EVENT_ALIASES, F as FieldKinds, l as FieldSource, m as FinderSource, n as Finding, o as FunctionHandler, H as HANDLER_TYPES, p as Handler, q as HandlerFn, r as HandlerSpec, s as HandlerType, t as HookConfig, u as HookConfigError, v as HookDenied, w as HookError, x as HookEvent, y as HookEventName, z as HookRequest, G as HookResponse, I as HookResult, J as HookRule, K as HookRun, L as HookRunOptions, M as HookedSession, N as HttpHandler, O as HttpTool, P as INBOUND_KINDS, Q as INPUT_TYPES, R as Identifier, S as IdentifierCensus, T as IdentifierSource, U as Identity, V as InboundKind, W as JsonSchema, X as KINDS, Y as LegendEntry, Z as LegendRow, _ as LegendSource, $ as LiveConfig, a0 as LiveTool, a1 as LiveToolError, a2 as LiveTools, a3 as Matcher, a4 as PARSE_MODES, a5 as Pair, a6 as ParseMode, a7 as RecordHandler, a8 as RecordSink, a9 as Recorder, aa as RedactHandler, ab as RedactionAudit, ac as Replay, ad as RequestFn, ae as RunVerdict, af as SeedEntity, ag as SeedRow, ah as SessionLike, ai as TOOL_KINDS, aj as ToolFn, ak as ToolFunctions, al as ToolKind, am as ToolSpec, an as WrappedTools, ao as applyLimit, ap as applyResult, aq as buildTool, ar as canonical, as as definition, at as describeHandler, au as describeMatcher, av as describeTool, aw as emailPairs, ax as emptyConfig, ay as emptyLive, az as eventToJson, aA as explodeIp, aB as findKind, aC as folded, aD as genericPairs, aE as importCallable, aF as inputSchema, aG as interpolateHeaders, aH as interpolatePath, aI as isGlobalIpv4, aJ as jsPattern, aK as jsonPath, aL as loadHookConfig, aM as mapFields, aN as matches, aO as mirrorHandle, aP as namePairs, aQ as newRunKey, aR as normalizeEvent, aS as pageTitle, aT as parseHookConfig, aU as parseJson, aV as parseMatcher, aW as parseRegex, aX as parseStdout, aY as parseText, aZ as phonePairs, a_ as pyQuote, a$ as readConnection, b0 as readable, b1 as refusalReason, b2 as render, b3 as resultFromJson, b4 as splitTopLevel, b5 as stripTags, b6 as unescapeHtml, b7 as vendorOf, b8 as withContext, b9 as withDefaults } from '../index-C3UzD0G3.js';
1
+ export { A as Alias, a as AliasHandler, b as AliasMap, c as AuditFinding, d as AuditRecord, e as AuditReport, B as Bound, C as CONTEXT_KEY, f as CallableTool, g as CommandHandler, h as ConnectorTool, D as Decision, j as DenyHandler, E as EVENTS, k as EVENT_ALIASES, F as FieldKinds, l as FieldSource, m as FinderSource, n as Finding, o as FunctionHandler, H as HANDLER_TYPES, p as Handler, q as HandlerFn, r as HandlerSpec, s as HandlerType, t as HookConfig, u as HookConfigError, v as HookDenied, w as HookError, x as HookEvent, y as HookEventName, z as HookRequest, G as HookResponse, I as HookResult, J as HookRule, K as HookRun, L as HookRunOptions, M as HookedSession, N as HttpHandler, O as HttpTool, P as INBOUND_KINDS, Q as INPUT_TYPES, R as Identifier, S as IdentifierCensus, T as IdentifierSource, U as Identity, V as InboundKind, W as JsonSchema, X as KINDS, Y as LegendEntry, Z as LegendRow, _ as LegendSource, $ as LiveConfig, a0 as LiveTool, a1 as LiveToolError, a2 as LiveTools, a3 as Matcher, a4 as PARSE_MODES, a5 as Pair, a6 as ParseMode, a7 as RecordHandler, a8 as RecordSink, a9 as Recorder, aa as RedactHandler, ab as RedactionAudit, ac as Replay, ad as RequestFn, ae as RunVerdict, af as SeedEntity, ag as SeedRow, ah as SessionLike, ai as TOOL_KINDS, aj as ToolFn, ak as ToolFunctions, al as ToolKind, am as ToolSpec, an as WrappedTools, ao as applyLimit, ap as applyResult, aq as buildTool, ar as canonical, as as definition, at as describeHandler, au as describeMatcher, av as describeTool, aw as emailPairs, ax as emptyConfig, ay as emptyLive, az as eventToJson, aA as explodeIp, aB as findKind, aC as folded, aD as genericPairs, aE as importCallable, aF as inputSchema, aG as interpolateHeaders, aH as interpolatePath, aI as isGlobalIpv4, aJ as jsPattern, aK as jsonPath, aL as loadHookConfig, aM as mapFields, aN as matches, aO as mirrorHandle, aP as namePairs, aQ as newRunKey, aR as normalizeEvent, aS as pageTitle, aT as parseHookConfig, aU as parseJson, aV as parseMatcher, aW as parseRegex, aX as parseStdout, aY as parseText, aZ as phonePairs, a_ as pyQuote, a$ as readConnection, b0 as readable, b1 as refusalReason, b2 as render, b3 as resultFromJson, b4 as splitTopLevel, b5 as stripTags, b6 as unescapeHtml, b7 as vendorOf, b8 as withContext, b9 as withDefaults } from '../index-CDPQBsU5.js';
@@ -3041,6 +3041,120 @@ async function buildHandler(spec, aliases, opts) {
3041
3041
  // src/hooks/live.ts
3042
3042
  var fs3 = __toESM(require("fs"));
3043
3043
  var path2 = __toESM(require("path"));
3044
+
3045
+ // src/hooks/vendorAuth.ts
3046
+ var bearer = (auth, value) => ({
3047
+ headers: { authorization: `${prefixesOf(auth)[0]} ${value}` },
3048
+ query: []
3049
+ });
3050
+ var CARRIERS = /* @__PURE__ */ new Map([
3051
+ [
3052
+ "header",
3053
+ (auth, value) => ({
3054
+ headers: {
3055
+ [String(auth.name ?? "").trim().toLowerCase()]: value
3056
+ },
3057
+ query: []
3058
+ })
3059
+ ],
3060
+ ["bearer", bearer],
3061
+ [
3062
+ "basic",
3063
+ (auth, value) => ({
3064
+ headers: {
3065
+ authorization: `Basic ${Buffer.from(basicPair(auth, value)).toString("base64")}`
3066
+ },
3067
+ query: []
3068
+ })
3069
+ ],
3070
+ [
3071
+ "query",
3072
+ (auth, value) => ({
3073
+ headers: {},
3074
+ query: [[String(auth.name ?? "").trim(), value]]
3075
+ })
3076
+ ],
3077
+ ["oauth2", bearer],
3078
+ ["none", () => ({ headers: {}, query: [] })]
3079
+ ]);
3080
+ var AUTH_WORD = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/;
3081
+ var OWNERS = [
3082
+ ["client_id_env", ["oauth2"]],
3083
+ ["credential", ["basic"]],
3084
+ ["prefixes", ["bearer", "oauth2"]],
3085
+ ["scope", ["oauth2"]],
3086
+ ["token_url", ["oauth2"]],
3087
+ ["ttl_seconds", ["oauth2"]]
3088
+ ];
3089
+ var AUTH_MODES = ["vendor", "open"];
3090
+ var positiveSeconds = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1;
3091
+ var NAMED = /* @__PURE__ */ new Set(["header", "query"]);
3092
+ function prefixesOf(auth) {
3093
+ const words2 = auth.prefixes ?? ["Bearer"];
3094
+ const valid = Array.isArray(words2) && words2.length > 0 && words2.every((word) => typeof word === "string" && AUTH_WORD.test(word)) && new Set(words2.map((word) => word.toLowerCase())).size === words2.length;
3095
+ if (!valid)
3096
+ throw new Error(
3097
+ "auth.prefixes lists the distinct words the vendor takes before the key in Authorization"
3098
+ );
3099
+ return words2;
3100
+ }
3101
+ function basicHalf(auth) {
3102
+ const half = auth.credential ?? "user";
3103
+ if (half !== "user" && half !== "password")
3104
+ throw new Error(
3105
+ "auth.credential is the half of the Basic pair the key is: user or password"
3106
+ );
3107
+ return half;
3108
+ }
3109
+ function basicPair(auth, value) {
3110
+ if (value.includes(":")) return value;
3111
+ return basicHalf(auth) === "password" ? `:${value}` : `${value}:`;
3112
+ }
3113
+ var GRAMMAR = /* @__PURE__ */ new Map([
3114
+ ["bearer", prefixesOf],
3115
+ ["oauth2", prefixesOf],
3116
+ ["basic", basicHalf]
3117
+ ]);
3118
+ function authScheme(value) {
3119
+ if (value === void 0) throw new Error("Missing scheme");
3120
+ if (value === "open")
3121
+ throw new Error(
3122
+ 'auth.scheme is how the vendor takes its key; a world whose sessions ask for none is auth.mode = "open"'
3123
+ );
3124
+ if (typeof value !== "string" || !CARRIERS.has(value))
3125
+ throw new Error(
3126
+ `auth.scheme must be one of ${[...CARRIERS.keys()].join(", ")}`
3127
+ );
3128
+ return value;
3129
+ }
3130
+ function vendorAuth(auth) {
3131
+ const scheme = authScheme(auth.scheme);
3132
+ const stray = OWNERS.find(
3133
+ ([key2, owners]) => auth[key2] !== void 0 && !owners.includes(scheme)
3134
+ );
3135
+ if (stray)
3136
+ throw new Error(
3137
+ `${stray[0]} belongs to auth.scheme ${stray[1].join(" or ")}`
3138
+ );
3139
+ if (scheme === "none" && (auth.name ?? auth.secret_env) !== void 0)
3140
+ throw new Error("auth.scheme none takes no name or secret_env");
3141
+ if (NAMED.has(scheme) && auth.name === void 0)
3142
+ throw new Error("Missing name");
3143
+ if (auth.name !== void 0 && (typeof auth.name !== "string" || !auth.name.trim()))
3144
+ throw new Error("name must be a non-empty string");
3145
+ GRAMMAR.get(scheme)?.(auth);
3146
+ if (auth.mode !== void 0 && !AUTH_MODES.includes(auth.mode))
3147
+ throw new Error(`auth.mode is one of ${AUTH_MODES.join(", ")}`);
3148
+ if (auth.ttl_seconds !== void 0 && !positiveSeconds(auth.ttl_seconds))
3149
+ throw new Error("ttl_seconds is a positive whole number of seconds");
3150
+ return { ...auth, scheme };
3151
+ }
3152
+ function carryCredential(auth, value) {
3153
+ const checked = vendorAuth(auth);
3154
+ return CARRIERS.get(checked.scheme)(checked, value);
3155
+ }
3156
+
3157
+ // src/hooks/live.ts
3044
3158
  var USER_AGENT = "gateway-hooks/1 (+https://withgateway.ai)";
3045
3159
  var TAGS = /<(script|style)[^>]*>.*?<\/\1>/gis;
3046
3160
  var STRIP = /<[^>]+>/g;
@@ -3361,7 +3475,9 @@ var HttpTool = class _HttpTool {
3361
3475
  const okStatus = o.ok_status ?? [
3362
3476
  [200, 200]
3363
3477
  ];
3364
- if (!okStatus.some(([low, high]) => response.status >= low && response.status <= high)) {
3478
+ if (!okStatus.some(
3479
+ ([low, high]) => response.status >= low && response.status <= high
3480
+ )) {
3365
3481
  const expected = okStatus.map(([low, high]) => low === high ? String(low) : `${low}-${high}`).join(", ");
3366
3482
  throw new LiveToolError(
3367
3483
  `${this.spec.name}: ${url} answered HTTP ${response.status} (ok_status ${expected}): ${JSON.stringify(body.slice(0, 200))}`,
@@ -3412,7 +3528,8 @@ function readConnection(root) {
3412
3528
  if (!fs3.existsSync(file)) throw new Error(`no connector.toml at ${root}`);
3413
3529
  const raw = parseToml(fs3.readFileSync(file, "utf8"));
3414
3530
  const connector = raw.connector ?? {};
3415
- const auth = raw.auth ?? {};
3531
+ const auth = raw.auth ?? { scheme: "none" };
3532
+ const carrier = vendorAuth(auth);
3416
3533
  const operations = {};
3417
3534
  for (const op of raw.operations ?? []) {
3418
3535
  operations[op.name] = {
@@ -3426,8 +3543,8 @@ function readConnection(root) {
3426
3543
  return {
3427
3544
  slug: connector.slug ?? path2.basename(root),
3428
3545
  baseUrl: (connector.base_url ?? "").replace(/\/+$/, ""),
3429
- scheme: auth.scheme ?? "none",
3430
- ...typeof auth.name === "string" ? { authName: auth.name } : {},
3546
+ scheme: carrier.scheme,
3547
+ carrier,
3431
3548
  ...typeof auth.secret_env === "string" ? { secretEnv: auth.secret_env } : {},
3432
3549
  ...typeof auth.client_id_env === "string" ? { clientIdEnv: auth.client_id_env } : {},
3433
3550
  ...typeof auth.token_url === "string" ? { tokenUrl: auth.token_url } : {},
@@ -3539,13 +3656,9 @@ var ConnectorTool = class {
3539
3656
  };
3540
3657
  for (const [header, variable] of Object.entries(c.extraHeaders))
3541
3658
  headers[header] = this.env(variable, `the ${header} header`);
3542
- const secret = await this.credential();
3543
- if (c.scheme === "header") headers[c.authName ?? ""] = secret ?? "";
3544
- else if (c.scheme === "bearer" || c.scheme === "oauth2")
3545
- headers.authorization = `Bearer ${secret}`;
3546
- else if (c.scheme === "basic")
3547
- headers.authorization = "Basic " + Buffer.from(secret ?? "").toString("base64");
3548
- else if (c.scheme === "query") query.append(c.authName ?? "", secret ?? "");
3659
+ const carried = carryCredential(c.carrier, await this.credential() ?? "");
3660
+ Object.assign(headers, carried.headers);
3661
+ for (const [key2, value] of carried.query) query.append(key2, value);
3549
3662
  const url = c.baseUrl + pathText + (query.toString() ? `?${query.toString()}` : "");
3550
3663
  const response = await fetch(url, {
3551
3664
  method: this.operation.method,