@withgateway/sdk 0.3.3 → 0.6.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.
- package/README.md +4 -3
- package/dist/cli.js +3005 -1401
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2996 -1392
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +128 -37
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +126 -35
- package/dist/files/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +124 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +124 -11
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-C3UzD0G3.d.mts → index-CDPQBsU5.d.mts} +19 -3
- package/dist/{index-C3UzD0G3.d.ts → index-CDPQBsU5.d.ts} +19 -3
- package/dist/{index-mJhG3vZU.d.mts → index-Di9nNqOY.d.mts} +26 -3
- package/dist/{index-DUHmS74p.d.ts → index-LA-PMRJT.d.ts} +26 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1078 -260
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1040 -251
- package/dist/index.mjs.map +1 -1
- package/dist/replay/index.d.mts +1 -1
- package/dist/replay/index.d.ts +1 -1
- package/dist/replay/index.js.map +1 -1
- package/dist/replay/index.mjs.map +1 -1
- package/dist/traces/index.js +125 -34
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +123 -32
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +1 -1
- package/dist/tracing/index.d.ts +1 -1
- package/dist/tracing/index.js +7 -1
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +7 -1
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +819 -438
- package/dist/worlds/index.d.ts +819 -438
- package/dist/worlds/index.js +912 -236
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +908 -232
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +1 -1
- package/runtime/gatewaysdk/environment/_bundle.py +4 -6
- package/runtime/gatewaysdk/environment/_materialize.py +5 -25
- package/runtime/gatewaysdk/environment/_world.py +82 -66
- package/runtime/gatewaysdk/environment/backing.py +20 -24
- package/runtime/gatewaysdk/environment/core.py +1 -16
- package/runtime/gatewaysdk/environment/legacy_sqlite.py +14 -27
- package/runtime/gatewaysdk/environment/runtime.py +45 -2
- package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
- package/runtime/gatewaysdk/environment/schema/api.py +198 -474
- package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
- package/runtime/gatewaysdk/environment/schema/batch.py +3 -3
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +1 -0
- package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
- package/runtime/gatewaysdk/environment/schema/call_capture.py +321 -0
- package/runtime/gatewaysdk/environment/schema/call_log.py +276 -18
- package/runtime/gatewaysdk/environment/schema/call_redaction.py +207 -19
- package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
- package/runtime/gatewaysdk/environment/schema/compiler.py +4 -1
- package/runtime/gatewaysdk/environment/schema/conform.py +38 -35
- package/runtime/gatewaysdk/environment/schema/connector.py +94 -152
- package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
- package/runtime/gatewaysdk/environment/schema/connectors/custom/handlers.py +2 -1
- package/runtime/gatewaysdk/environment/schema/connectors/github/api/handlers.py +217 -58
- package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +10 -19
- package/runtime/gatewaysdk/environment/schema/connectors/github/scenarios/default/seed/github_webhooks.json +10 -2
- package/runtime/gatewaysdk/environment/schema/connectors/github/tests/webhooks.json +47 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/world.json +21 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/api/handlers.py +185 -18
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/connector.toml +29 -14
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/provenance.json +43 -12
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/scenarios/default/seed/jamf_webhooks.json +2 -2
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/scope.toml +4 -17
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/tests/webhooks.json +107 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/vendor-openapi.json +1 -1
- package/runtime/gatewaysdk/environment/schema/connectors/linear/api/handlers.py +85 -1
- package/runtime/gatewaysdk/environment/schema/connectors/linear/connector.toml +19 -31
- package/runtime/gatewaysdk/environment/schema/connectors/linear/provenance.json +18 -8
- package/runtime/gatewaysdk/environment/schema/connectors/linear/scenarios/default/seed/webhooks.json +19 -3
- package/runtime/gatewaysdk/environment/schema/connectors/linear/tests/test_webhooks.py +71 -0
- package/runtime/gatewaysdk/environment/schema/connectors/servicenow/connector.toml +2 -5
- package/runtime/gatewaysdk/environment/schema/cors.py +54 -0
- package/runtime/gatewaysdk/environment/schema/credentials.py +313 -8
- package/runtime/gatewaysdk/environment/schema/data.py +14 -13
- package/runtime/gatewaysdk/environment/schema/database/base.py +106 -165
- package/runtime/gatewaysdk/environment/schema/database/guard.py +45 -37
- package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
- package/runtime/gatewaysdk/environment/schema/database/sqlite.py +57 -31
- package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
- package/runtime/gatewaysdk/environment/schema/door.py +899 -0
- package/runtime/gatewaysdk/environment/schema/envelope.py +86 -28
- package/runtime/gatewaysdk/environment/schema/grading.py +58 -86
- package/runtime/gatewaysdk/environment/schema/handler_errors.py +52 -5
- package/runtime/gatewaysdk/environment/schema/host.py +229 -1695
- package/runtime/gatewaysdk/environment/schema/host_control.py +144 -0
- package/runtime/gatewaysdk/environment/schema/host_handoff.py +370 -0
- package/runtime/gatewaysdk/environment/schema/host_loops.py +97 -0
- package/runtime/gatewaysdk/environment/schema/host_owners.py +121 -0
- package/runtime/gatewaysdk/environment/schema/host_proxy.py +111 -0
- package/runtime/gatewaysdk/environment/schema/host_requests.py +6 -0
- package/runtime/gatewaysdk/environment/schema/host_session.py +126 -0
- package/runtime/gatewaysdk/environment/schema/host_surfaces.py +79 -21
- package/runtime/gatewaysdk/environment/schema/host_transfers.py +127 -0
- package/runtime/gatewaysdk/environment/schema/host_versions.py +242 -0
- package/runtime/gatewaysdk/environment/schema/host_workers.py +577 -0
- package/runtime/gatewaysdk/environment/schema/journal.py +438 -0
- package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
- package/runtime/gatewaysdk/environment/schema/local.py +32 -116
- package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +20 -5
- package/runtime/gatewaysdk/environment/schema/platform.py +29 -234
- package/runtime/gatewaysdk/environment/schema/request_body.py +238 -0
- package/runtime/gatewaysdk/environment/schema/request_ledger.py +958 -0
- package/runtime/gatewaysdk/environment/schema/route_bindings.py +25 -3
- package/runtime/gatewaysdk/environment/schema/route_miss.py +54 -0
- package/runtime/gatewaysdk/environment/schema/runtime.py +136 -176
- package/runtime/gatewaysdk/environment/schema/scaffold.py +2 -1
- package/runtime/gatewaysdk/environment/schema/session_files.py +133 -24
- package/runtime/gatewaysdk/environment/schema/session_move.py +275 -0
- package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +5 -1
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +8 -9
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/CONNECTORS.md +3 -3
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +50 -28
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +12 -8
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +20 -22
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +25 -25
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +71 -7
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +150 -30
- package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
- package/runtime/gatewaysdk/environment/schema/tasks.py +229 -323
- package/runtime/gatewaysdk/environment/schema/tools_world.py +103 -203
- package/runtime/gatewaysdk/environment/schema/validation.py +69 -1
- package/runtime/gatewaysdk/environment/schema/verbs.py +38 -36
- package/runtime/gatewaysdk/environment/schema/webhooks.py +687 -0
- package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
- package/runtime/gatewaysdk/environment/schema/workers.py +203 -39
- package/runtime/gatewaysdk/environment/schema/world_host.py +970 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +83 -11
- package/runtime/gatewaysdk/environment/world.py +1 -1
- package/runtime/gatewaysdk/environment/world_session_contract.py +14 -0
- package/skills/agents/connector-template-author.md +5 -1
- package/skills/benchmarks-getting-started/SKILL.md +8 -9
- package/skills/connector-schema-authoring/CONNECTORS.md +3 -3
- package/skills/connector-schema-authoring/SKILL.md +50 -28
- package/skills/connector-schema-authoring/connector-worlds.md +282 -18
- package/skills/connector-schema-authoring/world-schema.md +7 -6
- package/skills/world-data-ingestion/ROWS.md +12 -8
- package/skills/world-data-ingestion/SKILL.md +20 -22
- package/skills/worlds-getting-started/SKILL.md +25 -25
- package/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
- package/skills/worlds-getting-started/references/gotchas.md +71 -7
- package/skills/worlds-getting-started/references/journal-checks.md +182 -0
package/dist/hooks/index.d.mts
CHANGED
|
@@ -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-
|
|
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';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -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-
|
|
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';
|
package/dist/hooks/index.js
CHANGED
|
@@ -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(
|
|
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:
|
|
3430
|
-
|
|
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
|
|
3543
|
-
|
|
3544
|
-
|
|
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,
|