@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.mjs
CHANGED
|
@@ -2922,6 +2922,120 @@ async function buildHandler(spec, aliases, opts) {
|
|
|
2922
2922
|
// src/hooks/live.ts
|
|
2923
2923
|
import * as fs3 from "fs";
|
|
2924
2924
|
import * as path2 from "path";
|
|
2925
|
+
|
|
2926
|
+
// src/hooks/vendorAuth.ts
|
|
2927
|
+
var bearer = (auth, value) => ({
|
|
2928
|
+
headers: { authorization: `${prefixesOf(auth)[0]} ${value}` },
|
|
2929
|
+
query: []
|
|
2930
|
+
});
|
|
2931
|
+
var CARRIERS = /* @__PURE__ */ new Map([
|
|
2932
|
+
[
|
|
2933
|
+
"header",
|
|
2934
|
+
(auth, value) => ({
|
|
2935
|
+
headers: {
|
|
2936
|
+
[String(auth.name ?? "").trim().toLowerCase()]: value
|
|
2937
|
+
},
|
|
2938
|
+
query: []
|
|
2939
|
+
})
|
|
2940
|
+
],
|
|
2941
|
+
["bearer", bearer],
|
|
2942
|
+
[
|
|
2943
|
+
"basic",
|
|
2944
|
+
(auth, value) => ({
|
|
2945
|
+
headers: {
|
|
2946
|
+
authorization: `Basic ${Buffer.from(basicPair(auth, value)).toString("base64")}`
|
|
2947
|
+
},
|
|
2948
|
+
query: []
|
|
2949
|
+
})
|
|
2950
|
+
],
|
|
2951
|
+
[
|
|
2952
|
+
"query",
|
|
2953
|
+
(auth, value) => ({
|
|
2954
|
+
headers: {},
|
|
2955
|
+
query: [[String(auth.name ?? "").trim(), value]]
|
|
2956
|
+
})
|
|
2957
|
+
],
|
|
2958
|
+
["oauth2", bearer],
|
|
2959
|
+
["none", () => ({ headers: {}, query: [] })]
|
|
2960
|
+
]);
|
|
2961
|
+
var AUTH_WORD = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/;
|
|
2962
|
+
var OWNERS = [
|
|
2963
|
+
["client_id_env", ["oauth2"]],
|
|
2964
|
+
["credential", ["basic"]],
|
|
2965
|
+
["prefixes", ["bearer", "oauth2"]],
|
|
2966
|
+
["scope", ["oauth2"]],
|
|
2967
|
+
["token_url", ["oauth2"]],
|
|
2968
|
+
["ttl_seconds", ["oauth2"]]
|
|
2969
|
+
];
|
|
2970
|
+
var AUTH_MODES = ["vendor", "open"];
|
|
2971
|
+
var positiveSeconds = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1;
|
|
2972
|
+
var NAMED = /* @__PURE__ */ new Set(["header", "query"]);
|
|
2973
|
+
function prefixesOf(auth) {
|
|
2974
|
+
const words2 = auth.prefixes ?? ["Bearer"];
|
|
2975
|
+
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;
|
|
2976
|
+
if (!valid)
|
|
2977
|
+
throw new Error(
|
|
2978
|
+
"auth.prefixes lists the distinct words the vendor takes before the key in Authorization"
|
|
2979
|
+
);
|
|
2980
|
+
return words2;
|
|
2981
|
+
}
|
|
2982
|
+
function basicHalf(auth) {
|
|
2983
|
+
const half = auth.credential ?? "user";
|
|
2984
|
+
if (half !== "user" && half !== "password")
|
|
2985
|
+
throw new Error(
|
|
2986
|
+
"auth.credential is the half of the Basic pair the key is: user or password"
|
|
2987
|
+
);
|
|
2988
|
+
return half;
|
|
2989
|
+
}
|
|
2990
|
+
function basicPair(auth, value) {
|
|
2991
|
+
if (value.includes(":")) return value;
|
|
2992
|
+
return basicHalf(auth) === "password" ? `:${value}` : `${value}:`;
|
|
2993
|
+
}
|
|
2994
|
+
var GRAMMAR = /* @__PURE__ */ new Map([
|
|
2995
|
+
["bearer", prefixesOf],
|
|
2996
|
+
["oauth2", prefixesOf],
|
|
2997
|
+
["basic", basicHalf]
|
|
2998
|
+
]);
|
|
2999
|
+
function authScheme(value) {
|
|
3000
|
+
if (value === void 0) throw new Error("Missing scheme");
|
|
3001
|
+
if (value === "open")
|
|
3002
|
+
throw new Error(
|
|
3003
|
+
'auth.scheme is how the vendor takes its key; a world whose sessions ask for none is auth.mode = "open"'
|
|
3004
|
+
);
|
|
3005
|
+
if (typeof value !== "string" || !CARRIERS.has(value))
|
|
3006
|
+
throw new Error(
|
|
3007
|
+
`auth.scheme must be one of ${[...CARRIERS.keys()].join(", ")}`
|
|
3008
|
+
);
|
|
3009
|
+
return value;
|
|
3010
|
+
}
|
|
3011
|
+
function vendorAuth(auth) {
|
|
3012
|
+
const scheme = authScheme(auth.scheme);
|
|
3013
|
+
const stray = OWNERS.find(
|
|
3014
|
+
([key2, owners]) => auth[key2] !== void 0 && !owners.includes(scheme)
|
|
3015
|
+
);
|
|
3016
|
+
if (stray)
|
|
3017
|
+
throw new Error(
|
|
3018
|
+
`${stray[0]} belongs to auth.scheme ${stray[1].join(" or ")}`
|
|
3019
|
+
);
|
|
3020
|
+
if (scheme === "none" && (auth.name ?? auth.secret_env) !== void 0)
|
|
3021
|
+
throw new Error("auth.scheme none takes no name or secret_env");
|
|
3022
|
+
if (NAMED.has(scheme) && auth.name === void 0)
|
|
3023
|
+
throw new Error("Missing name");
|
|
3024
|
+
if (auth.name !== void 0 && (typeof auth.name !== "string" || !auth.name.trim()))
|
|
3025
|
+
throw new Error("name must be a non-empty string");
|
|
3026
|
+
GRAMMAR.get(scheme)?.(auth);
|
|
3027
|
+
if (auth.mode !== void 0 && !AUTH_MODES.includes(auth.mode))
|
|
3028
|
+
throw new Error(`auth.mode is one of ${AUTH_MODES.join(", ")}`);
|
|
3029
|
+
if (auth.ttl_seconds !== void 0 && !positiveSeconds(auth.ttl_seconds))
|
|
3030
|
+
throw new Error("ttl_seconds is a positive whole number of seconds");
|
|
3031
|
+
return { ...auth, scheme };
|
|
3032
|
+
}
|
|
3033
|
+
function carryCredential(auth, value) {
|
|
3034
|
+
const checked = vendorAuth(auth);
|
|
3035
|
+
return CARRIERS.get(checked.scheme)(checked, value);
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
// src/hooks/live.ts
|
|
2925
3039
|
var USER_AGENT = "gateway-hooks/1 (+https://withgateway.ai)";
|
|
2926
3040
|
var TAGS = /<(script|style)[^>]*>.*?<\/\1>/gis;
|
|
2927
3041
|
var STRIP = /<[^>]+>/g;
|
|
@@ -3242,7 +3356,9 @@ var HttpTool = class _HttpTool {
|
|
|
3242
3356
|
const okStatus = o.ok_status ?? [
|
|
3243
3357
|
[200, 200]
|
|
3244
3358
|
];
|
|
3245
|
-
if (!okStatus.some(
|
|
3359
|
+
if (!okStatus.some(
|
|
3360
|
+
([low, high]) => response.status >= low && response.status <= high
|
|
3361
|
+
)) {
|
|
3246
3362
|
const expected = okStatus.map(([low, high]) => low === high ? String(low) : `${low}-${high}`).join(", ");
|
|
3247
3363
|
throw new LiveToolError(
|
|
3248
3364
|
`${this.spec.name}: ${url} answered HTTP ${response.status} (ok_status ${expected}): ${JSON.stringify(body.slice(0, 200))}`,
|
|
@@ -3293,7 +3409,8 @@ function readConnection(root) {
|
|
|
3293
3409
|
if (!fs3.existsSync(file)) throw new Error(`no connector.toml at ${root}`);
|
|
3294
3410
|
const raw = parseToml(fs3.readFileSync(file, "utf8"));
|
|
3295
3411
|
const connector = raw.connector ?? {};
|
|
3296
|
-
const auth = raw.auth ?? {};
|
|
3412
|
+
const auth = raw.auth ?? { scheme: "none" };
|
|
3413
|
+
const carrier = vendorAuth(auth);
|
|
3297
3414
|
const operations = {};
|
|
3298
3415
|
for (const op of raw.operations ?? []) {
|
|
3299
3416
|
operations[op.name] = {
|
|
@@ -3307,8 +3424,8 @@ function readConnection(root) {
|
|
|
3307
3424
|
return {
|
|
3308
3425
|
slug: connector.slug ?? path2.basename(root),
|
|
3309
3426
|
baseUrl: (connector.base_url ?? "").replace(/\/+$/, ""),
|
|
3310
|
-
scheme:
|
|
3311
|
-
|
|
3427
|
+
scheme: carrier.scheme,
|
|
3428
|
+
carrier,
|
|
3312
3429
|
...typeof auth.secret_env === "string" ? { secretEnv: auth.secret_env } : {},
|
|
3313
3430
|
...typeof auth.client_id_env === "string" ? { clientIdEnv: auth.client_id_env } : {},
|
|
3314
3431
|
...typeof auth.token_url === "string" ? { tokenUrl: auth.token_url } : {},
|
|
@@ -3420,13 +3537,9 @@ var ConnectorTool = class {
|
|
|
3420
3537
|
};
|
|
3421
3538
|
for (const [header, variable] of Object.entries(c.extraHeaders))
|
|
3422
3539
|
headers[header] = this.env(variable, `the ${header} header`);
|
|
3423
|
-
const
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
headers.authorization = `Bearer ${secret}`;
|
|
3427
|
-
else if (c.scheme === "basic")
|
|
3428
|
-
headers.authorization = "Basic " + Buffer.from(secret ?? "").toString("base64");
|
|
3429
|
-
else if (c.scheme === "query") query.append(c.authName ?? "", secret ?? "");
|
|
3540
|
+
const carried = carryCredential(c.carrier, await this.credential() ?? "");
|
|
3541
|
+
Object.assign(headers, carried.headers);
|
|
3542
|
+
for (const [key2, value] of carried.query) query.append(key2, value);
|
|
3430
3543
|
const url = c.baseUrl + pathText + (query.toString() ? `?${query.toString()}` : "");
|
|
3431
3544
|
const response = await fetch(url, {
|
|
3432
3545
|
method: this.operation.method,
|