@withgateway/sdk 0.2.6 → 0.2.9
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 +24 -8
- package/dist/cli.js +15468 -11263
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +15233 -11028
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.d.mts +1 -1
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +291 -40
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +284 -37
- 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 +203 -47
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +198 -42
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-BaKu5ZSU.d.mts → index-C3UzD0G3.d.mts} +75 -1
- package/dist/{index-BaKu5ZSU.d.ts → index-C3UzD0G3.d.ts} +75 -1
- package/dist/{index-CLkMr6VG.d.ts → index-D-_4Ibcn.d.ts} +36 -4
- package/dist/{index-CdbmO4aX.d.mts → index-FfK4Nump.d.mts} +36 -4
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2149 -615
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2053 -566
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +268 -31
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +262 -28
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.js +19 -11
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +19 -11
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +886 -117
- package/dist/worlds/index.d.ts +886 -117
- package/dist/worlds/index.js +1770 -452
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +1752 -434
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +14 -10
- package/runtime/gatewaysdk/environment/_toml.py +3 -10
- package/runtime/gatewaysdk/environment/_world.py +95 -28
- package/runtime/gatewaysdk/environment/runtime.py +10 -6
- package/runtime/gatewaysdk/environment/schema/__main__.py +35 -0
- package/runtime/gatewaysdk/environment/schema/api.py +19 -23
- package/runtime/gatewaysdk/environment/schema/batch.py +68 -14
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +4 -2
- package/runtime/gatewaysdk/environment/schema/cast.py +264 -0
- package/runtime/gatewaysdk/environment/schema/compiler.py +35 -1
- package/runtime/gatewaysdk/environment/schema/conform.py +28 -10
- package/runtime/gatewaysdk/environment/schema/connector.py +59 -14
- package/runtime/gatewaysdk/environment/schema/connectors/custom/handlers.py +38 -1
- package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.toml +3 -1
- package/runtime/gatewaysdk/environment/schema/credentials.py +20 -0
- package/runtime/gatewaysdk/environment/schema/csv_rows.py +117 -0
- package/runtime/gatewaysdk/environment/schema/cycles.py +121 -0
- package/runtime/gatewaysdk/environment/schema/data.py +21 -5
- package/runtime/gatewaysdk/environment/schema/grading.py +95 -13
- package/runtime/gatewaysdk/environment/schema/handler_errors.py +44 -0
- package/runtime/gatewaysdk/environment/schema/handler_scan.py +175 -0
- package/runtime/gatewaysdk/environment/schema/host.py +68 -115
- package/runtime/gatewaysdk/environment/schema/host_requests.py +78 -0
- package/runtime/gatewaysdk/environment/schema/host_surfaces.py +12 -0
- package/runtime/gatewaysdk/environment/schema/ingest.py +5 -18
- package/runtime/gatewaysdk/environment/schema/local.py +7 -10
- package/runtime/gatewaysdk/environment/schema/openapi_document.py +322 -0
- package/runtime/gatewaysdk/environment/schema/openapi_import.py +382 -0
- package/runtime/gatewaysdk/environment/schema/openapi_routes.py +441 -0
- package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +629 -0
- package/runtime/gatewaysdk/environment/schema/openapi_source.py +210 -0
- package/runtime/gatewaysdk/environment/schema/platform.py +110 -299
- package/runtime/gatewaysdk/environment/schema/platform_import.py +182 -0
- package/runtime/gatewaysdk/environment/schema/platform_query.py +95 -0
- package/runtime/gatewaysdk/environment/schema/route_bindings.py +176 -0
- package/runtime/gatewaysdk/environment/schema/runtime.py +56 -7
- package/runtime/gatewaysdk/environment/schema/scaffold.py +64 -5
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +70 -22
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +54 -4
- package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +27 -2
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +62 -0
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +91 -54
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +146 -146
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +11 -7
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +30 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/new-world-sandbox.md +43 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/openapi-import.md +90 -0
- package/runtime/gatewaysdk/environment/schema/store.py +15 -6
- package/runtime/gatewaysdk/environment/schema/store_contract.py +119 -0
- package/runtime/gatewaysdk/environment/schema/tasks.py +121 -32
- package/runtime/gatewaysdk/environment/schema/tools_world.py +32 -10
- package/runtime/gatewaysdk/environment/schema/tree_import.py +228 -0
- package/runtime/gatewaysdk/environment/schema/ui.py +18 -2
- package/runtime/gatewaysdk/environment/schema/validation.py +35 -0
- package/runtime/gatewaysdk/environment/schema/verbs.py +8 -2
- package/runtime/gatewaysdk/environment/world.py +42 -3
- package/runtime/gatewaysdk/environment/world_session_contract.py +57 -0
- package/skills/benchmarks-getting-started/SKILL.md +70 -22
- package/skills/connector-schema-authoring/SKILL.md +54 -4
- package/skills/connector-schema-authoring/connector-worlds.md +21 -7
- package/skills/connector-schema-authoring/world-schema.md +144 -83
- package/skills/hooks-getting-started/SKILL.md +27 -2
- package/skills/world-data-ingestion/ROWS.md +62 -0
- package/skills/world-data-ingestion/SKILL.md +91 -54
- package/skills/worlds-getting-started/SKILL.md +146 -146
- package/skills/worlds-getting-started/references/cli-mcp-map.md +11 -7
- package/skills/worlds-getting-started/references/gotchas.md +30 -0
- package/skills/worlds-getting-started/references/new-world-sandbox.md +43 -0
- package/skills/worlds-getting-started/references/openapi-import.md +90 -0
package/dist/hooks/index.mjs
CHANGED
|
@@ -44,8 +44,45 @@ function swapValue(text, needle, replacement) {
|
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// src/hooks/standInDigits.ts
|
|
48
|
+
import { createHash } from "crypto";
|
|
49
|
+
function standInDigits(realDigits, identityName) {
|
|
50
|
+
if (!realDigits) return "";
|
|
51
|
+
const digest = createHash("sha256").update(`${identityName}:${realDigits}`).digest("hex");
|
|
52
|
+
let digits = "";
|
|
53
|
+
for (let i = 0; i < realDigits.length; i++)
|
|
54
|
+
digits += String(parseInt(digest[i % digest.length], 16) % 10);
|
|
55
|
+
if (digits !== realDigits) return digits;
|
|
56
|
+
return String((Number(digits[0]) + 1) % 10) + digits.slice(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/hooks/declared.ts
|
|
60
|
+
var DeclaredStandIn = class _DeclaredStandIn {
|
|
61
|
+
alias;
|
|
62
|
+
variants;
|
|
63
|
+
constructor(alias, variants = []) {
|
|
64
|
+
this.alias = typeof alias === "string" && alias.trim() ? alias.trim() : null;
|
|
65
|
+
this.variants = Array.isArray(variants) ? variants.filter(
|
|
66
|
+
(v) => typeof v === "string" && v.trim() !== ""
|
|
67
|
+
) : [];
|
|
68
|
+
}
|
|
69
|
+
static of(entity) {
|
|
70
|
+
return new _DeclaredStandIn(entity.alias, entity.variants ?? []);
|
|
71
|
+
}
|
|
72
|
+
get declared() {
|
|
73
|
+
return this.alias !== null || this.variants.length > 0;
|
|
74
|
+
}
|
|
75
|
+
/** The pairings for `display`: the real value's forms, then every extra spelling in the
|
|
76
|
+
* same forms, each mapped onto the stand-in. */
|
|
77
|
+
pairs(real, display, build) {
|
|
78
|
+
const out = [...build(real, display)];
|
|
79
|
+
for (const spelling of this.variants) out.push(...build(spelling, display));
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
47
84
|
// src/hooks/alias.ts
|
|
48
|
-
import { createHash, createHmac, randomBytes } from "crypto";
|
|
85
|
+
import { createHash as createHash2, createHmac, randomBytes } from "crypto";
|
|
49
86
|
var GIVEN = [
|
|
50
87
|
"John",
|
|
51
88
|
"Mary",
|
|
@@ -478,6 +515,14 @@ function genericPairs(real, fake) {
|
|
|
478
515
|
}
|
|
479
516
|
return dedupe(out);
|
|
480
517
|
}
|
|
518
|
+
function pairBuilder(kind) {
|
|
519
|
+
const builders = {
|
|
520
|
+
person_name: namePairs,
|
|
521
|
+
email: emailPairs,
|
|
522
|
+
phone: phonePairs
|
|
523
|
+
};
|
|
524
|
+
return builders[kind] ?? genericPairs;
|
|
525
|
+
}
|
|
481
526
|
function dedupe(pairs) {
|
|
482
527
|
const seen = /* @__PURE__ */ new Set();
|
|
483
528
|
const out = [];
|
|
@@ -489,7 +534,12 @@ function dedupe(pairs) {
|
|
|
489
534
|
}
|
|
490
535
|
return out.sort((a, b) => b[0].length - a[0].length);
|
|
491
536
|
}
|
|
537
|
+
function isSubject(alias) {
|
|
538
|
+
return alias.provenance === "seed";
|
|
539
|
+
}
|
|
492
540
|
var fullName = (identity) => `${identity.given} ${identity.surname}`;
|
|
541
|
+
var DeclaredOnlyError = class extends Error {
|
|
542
|
+
};
|
|
493
543
|
var AliasMap = class _AliasMap {
|
|
494
544
|
constructor(runKey, slugs = [], options = {}) {
|
|
495
545
|
this.runKey = runKey;
|
|
@@ -499,7 +549,14 @@ var AliasMap = class _AliasMap {
|
|
|
499
549
|
this.publicLayerWins = options.publicLayerWins ?? true;
|
|
500
550
|
this.publicMailboxDomains = options.publicMailboxDomains ?? null;
|
|
501
551
|
this.mintInbound = options.mintInbound ?? [];
|
|
552
|
+
this.declaredOnly = options.declaredOnly ?? false;
|
|
553
|
+
if (this.declaredOnly && this.mintInbound.length)
|
|
554
|
+
throw new DeclaredOnlyError(
|
|
555
|
+
"declared_only and mint_inbound cannot both be set: nothing is minted on sight"
|
|
556
|
+
);
|
|
502
557
|
}
|
|
558
|
+
runKey;
|
|
559
|
+
slugs;
|
|
503
560
|
aliases = /* @__PURE__ */ new Map();
|
|
504
561
|
identities = /* @__PURE__ */ new Map();
|
|
505
562
|
taken = /* @__PURE__ */ new Set();
|
|
@@ -507,6 +564,9 @@ var AliasMap = class _AliasMap {
|
|
|
507
564
|
aliasDigests = /* @__PURE__ */ new Set();
|
|
508
565
|
leaksIn = [];
|
|
509
566
|
leaksOut = [];
|
|
567
|
+
/** As `leaksIn` / `leaksOut`, for values minted on sight: counted, never a failure. */
|
|
568
|
+
bystandersIn = [];
|
|
569
|
+
bystandersOut = [];
|
|
510
570
|
unresolvedOut = [];
|
|
511
571
|
/** Every value minted on sight: `{where, kind, alias}`. */
|
|
512
572
|
found = [];
|
|
@@ -530,6 +590,20 @@ var AliasMap = class _AliasMap {
|
|
|
530
590
|
* subject. Off (the default) such a value reaches the agent as it is — the seed
|
|
531
591
|
* list is the whole map. */
|
|
532
592
|
mintInbound;
|
|
593
|
+
/** Every private seed must carry its own `alias`; a seed without one is refused instead
|
|
594
|
+
* of getting a generated persona, and nothing is minted on arrival. */
|
|
595
|
+
declaredOnly;
|
|
596
|
+
/** `declaredOnly`: refuse a private value that would need a generated persona. */
|
|
597
|
+
requireDeclared(kind, provenance, declared) {
|
|
598
|
+
if (!this.declaredOnly || declared?.alias) return;
|
|
599
|
+
if (provenance === "seed")
|
|
600
|
+
throw new DeclaredOnlyError(
|
|
601
|
+
`declared_only: the seed of kind '${kind}' carries no \`alias\`; give every private seed its stand-in or turn declared_only off`
|
|
602
|
+
);
|
|
603
|
+
throw new DeclaredOnlyError(
|
|
604
|
+
`declared_only: a value of kind '${kind}' arrived unseeded and nothing may be minted on sight; seed it with an \`alias\`, or turn declared_only off`
|
|
605
|
+
);
|
|
606
|
+
}
|
|
533
607
|
mailboxDomains() {
|
|
534
608
|
if (this.publicMailboxDomains === null) return PUBLIC_MAILBOX_DOMAINS;
|
|
535
609
|
return new Set(this.publicMailboxDomains.map((d) => d.toLowerCase()));
|
|
@@ -599,8 +673,14 @@ var AliasMap = class _AliasMap {
|
|
|
599
673
|
return alias2;
|
|
600
674
|
}
|
|
601
675
|
const identityKey = opts.identityKey ?? `${kind}:${canon}`;
|
|
676
|
+
this.requireDeclared(kind, provenance, opts.declared);
|
|
602
677
|
const identity = this.identityFor(identityKey);
|
|
603
|
-
const [display, variants] = this.derive(
|
|
678
|
+
const [display, variants] = this.derive(
|
|
679
|
+
kind,
|
|
680
|
+
real,
|
|
681
|
+
identity,
|
|
682
|
+
opts.declared ?? new DeclaredStandIn()
|
|
683
|
+
);
|
|
604
684
|
const alias = {
|
|
605
685
|
kind,
|
|
606
686
|
canonical: canon,
|
|
@@ -723,7 +803,15 @@ var AliasMap = class _AliasMap {
|
|
|
723
803
|
}
|
|
724
804
|
return out;
|
|
725
805
|
}
|
|
726
|
-
|
|
806
|
+
/** The stand-in and its pairings. A declared stand-in replaces the generated one; the
|
|
807
|
+
* kind's own pair builder runs over it and over every declared spelling. */
|
|
808
|
+
derive(kind, real, identity, declared) {
|
|
809
|
+
const [display, variants] = this.generated(kind, real, identity);
|
|
810
|
+
if (!declared.declared) return [display, variants];
|
|
811
|
+
const chosen = declared.alias ?? display;
|
|
812
|
+
return [chosen, dedupe(declared.pairs(real, chosen, pairBuilder(kind)))];
|
|
813
|
+
}
|
|
814
|
+
generated(kind, real, identity) {
|
|
727
815
|
if (kind === "person_name") {
|
|
728
816
|
const display2 = fullName(identity);
|
|
729
817
|
return [display2, namePairs(real, display2)];
|
|
@@ -810,13 +898,14 @@ var AliasMap = class _AliasMap {
|
|
|
810
898
|
for (const entity of entities) {
|
|
811
899
|
const alias = this.mint(entity.type, entity.value, {
|
|
812
900
|
identityKey: entity.identity,
|
|
813
|
-
role: entity.role ?? "private"
|
|
901
|
+
role: entity.role ?? "private",
|
|
902
|
+
declared: DeclaredStandIn.of(entity)
|
|
814
903
|
});
|
|
815
904
|
if (alias.role === "private") {
|
|
816
905
|
for (const slug of this.slugs) {
|
|
817
|
-
const standIn = "sha256:" +
|
|
906
|
+
const standIn = "sha256:" + createHash2("sha256").update(`${slug}:${canonical(alias.kind, alias.display)}`, "utf8").digest("hex");
|
|
818
907
|
alias.variants.push([
|
|
819
|
-
"sha256:" +
|
|
908
|
+
"sha256:" + createHash2("sha256").update(`${slug}:${alias.canonical}`, "utf8").digest("hex"),
|
|
820
909
|
standIn
|
|
821
910
|
]);
|
|
822
911
|
this.aliasDigests.add(standIn.toLowerCase());
|
|
@@ -938,45 +1027,51 @@ var AliasMap = class _AliasMap {
|
|
|
938
1027
|
/** Requirement 3: count what slipped, do not assume nothing did. The scan is
|
|
939
1028
|
* case-folded with whitespace collapsed and walks EVERY variant of every alias,
|
|
940
1029
|
* not only the pairs the rewriter used. */
|
|
941
|
-
|
|
942
|
-
|
|
1030
|
+
/** Every private alias with a real variant of 4+ characters in the folded text,
|
|
1031
|
+
* case subjects first. */
|
|
1032
|
+
surviving(haystack) {
|
|
943
1033
|
const pub = this.publicFolded();
|
|
1034
|
+
const found = [];
|
|
944
1035
|
for (const alias of this.aliases.values()) {
|
|
945
1036
|
if (alias.role === "public") continue;
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
kind: alias.kind,
|
|
951
|
-
variant: shorten(real),
|
|
952
|
-
alias: alias.display
|
|
953
|
-
});
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
}
|
|
1037
|
+
const variant = alias.variants.find(
|
|
1038
|
+
([real]) => real.length >= 4 && !pub.has(folded(real)) && haystack.includes(folded(real))
|
|
1039
|
+
);
|
|
1040
|
+
if (variant !== void 0) found.push([alias, variant[0]]);
|
|
957
1041
|
}
|
|
1042
|
+
return [
|
|
1043
|
+
...found.filter(([a]) => isSubject(a)),
|
|
1044
|
+
...found.filter(([a]) => !isSubject(a))
|
|
1045
|
+
];
|
|
958
1046
|
}
|
|
959
|
-
/**
|
|
1047
|
+
/** A leak is about a CASE SUBJECT (a seeded entity); a value that only arrived in a
|
|
1048
|
+
* result and was given a stand-in on sight is a bystander, counted apart. */
|
|
1049
|
+
meter(text, where) {
|
|
1050
|
+
const hit = this.surviving(folded(text))[0];
|
|
1051
|
+
if (hit === void 0) return;
|
|
1052
|
+
const [alias, real] = hit;
|
|
1053
|
+
const rows = isSubject(alias) ? this.leaksIn : this.bystandersIn;
|
|
1054
|
+
rows.push({
|
|
1055
|
+
where,
|
|
1056
|
+
kind: alias.kind,
|
|
1057
|
+
variant: shorten(real),
|
|
1058
|
+
alias: alias.display
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
/** Requirement 4: the report and the artifacts must contain no real value OF A CASE
|
|
1062
|
+
* SUBJECT. Bystanders are counted, never returned. */
|
|
960
1063
|
scanOutgoing(text, where) {
|
|
961
|
-
const
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
where,
|
|
971
|
-
kind: alias.kind,
|
|
972
|
-
alias: alias.display,
|
|
973
|
-
variant: shorten(real)
|
|
974
|
-
});
|
|
975
|
-
break;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
1064
|
+
const found = this.surviving(typeof text === "string" ? folded(text) : "");
|
|
1065
|
+
const row = ([alias, real]) => ({
|
|
1066
|
+
check: "leak_outbound",
|
|
1067
|
+
where,
|
|
1068
|
+
kind: alias.kind,
|
|
1069
|
+
alias: alias.display,
|
|
1070
|
+
variant: shorten(real)
|
|
1071
|
+
});
|
|
1072
|
+
const hits = found.filter(([a]) => isSubject(a)).map(row);
|
|
979
1073
|
this.leaksOut.push(...hits);
|
|
1074
|
+
this.bystandersOut.push(...found.filter(([a]) => !isSubject(a)).map(row));
|
|
980
1075
|
return hits;
|
|
981
1076
|
}
|
|
982
1077
|
// ------------------------------------------------------------ reporting
|
|
@@ -1073,6 +1168,8 @@ var AliasMap = class _AliasMap {
|
|
|
1073
1168
|
leak_through_inbound_detail: this.leaksIn.slice(0, 50),
|
|
1074
1169
|
leaks_outbound: this.leaksOut.length,
|
|
1075
1170
|
leaks_outbound_detail: this.leaksOut.slice(0, 50),
|
|
1171
|
+
bystander_leak_through_inbound: this.bystandersIn.length,
|
|
1172
|
+
bystander_leaks_outbound: this.bystandersOut.length,
|
|
1076
1173
|
unresolved_aliases_outbound: this.unresolvedOut.length,
|
|
1077
1174
|
unresolved_detail: this.unresolvedOut.slice(0, 50),
|
|
1078
1175
|
found_inbound: this.found.length,
|
|
@@ -1099,8 +1196,9 @@ function mirrorHandle(handle, identity) {
|
|
|
1099
1196
|
const surname = identity.surname.toLowerCase();
|
|
1100
1197
|
const text = handle.toLowerCase();
|
|
1101
1198
|
const digits = /\d+$/.exec(text);
|
|
1102
|
-
const
|
|
1103
|
-
const body = text.slice(0, text.length -
|
|
1199
|
+
const realSuffix = digits ? digits[0] : "";
|
|
1200
|
+
const body = text.slice(0, text.length - realSuffix.length);
|
|
1201
|
+
const suffix = standInDigits(realSuffix, `${given} ${surname}`);
|
|
1104
1202
|
for (const separator of [".", "_", "-"]) {
|
|
1105
1203
|
if (body.includes(separator))
|
|
1106
1204
|
return `${given}${separator}${surname}${suffix}`;
|
|
@@ -1348,6 +1446,11 @@ var HookDenied = class extends Error {
|
|
|
1348
1446
|
this.handler = handler;
|
|
1349
1447
|
this.name = "HookDenied";
|
|
1350
1448
|
}
|
|
1449
|
+
event;
|
|
1450
|
+
toolName;
|
|
1451
|
+
reason;
|
|
1452
|
+
findings;
|
|
1453
|
+
handler;
|
|
1351
1454
|
};
|
|
1352
1455
|
var HookError = class extends Error {
|
|
1353
1456
|
constructor(event, toolName, handler, detail) {
|
|
@@ -1358,6 +1461,10 @@ var HookError = class extends Error {
|
|
|
1358
1461
|
this.detail = detail;
|
|
1359
1462
|
this.name = "HookError";
|
|
1360
1463
|
}
|
|
1464
|
+
event;
|
|
1465
|
+
toolName;
|
|
1466
|
+
handler;
|
|
1467
|
+
detail;
|
|
1361
1468
|
};
|
|
1362
1469
|
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1363
1470
|
function resultFromJson(raw, handler = "handler") {
|
|
@@ -1902,6 +2009,7 @@ var emptyConfig = () => ({
|
|
|
1902
2009
|
aliasPublicLayerWins: true,
|
|
1903
2010
|
aliasPublicMailboxDomains: null,
|
|
1904
2011
|
aliasMintInbound: [],
|
|
2012
|
+
aliasDeclaredOnly: false,
|
|
1905
2013
|
aliasLegend: null,
|
|
1906
2014
|
vendors: {},
|
|
1907
2015
|
live: emptyLive()
|
|
@@ -2014,7 +2122,8 @@ function parseHookConfig(data, source) {
|
|
|
2014
2122
|
"public_layer_wins",
|
|
2015
2123
|
"public_mailbox_domains",
|
|
2016
2124
|
"mint_inbound",
|
|
2017
|
-
"legend"
|
|
2125
|
+
"legend",
|
|
2126
|
+
"declared_only"
|
|
2018
2127
|
].includes(k)
|
|
2019
2128
|
);
|
|
2020
2129
|
if (unknownAlias.length)
|
|
@@ -2041,6 +2150,13 @@ function parseHookConfig(data, source) {
|
|
|
2041
2150
|
throw new HookConfigError(
|
|
2042
2151
|
`alias.mint_inbound: ${badKinds.join(", ")} cannot be found by a pattern; only ${INBOUND_KINDS.join(", ")} can (a name or a handle is seeded, never guessed)`
|
|
2043
2152
|
);
|
|
2153
|
+
const declaredOnly = alias.declared_only ?? false;
|
|
2154
|
+
if (typeof declaredOnly !== "boolean")
|
|
2155
|
+
throw new HookConfigError("alias.declared_only must be true or false");
|
|
2156
|
+
if (declaredOnly && mintInboundRaw.length)
|
|
2157
|
+
throw new HookConfigError(
|
|
2158
|
+
"alias.declared_only and alias.mint_inbound cannot both be set: nothing is minted on sight"
|
|
2159
|
+
);
|
|
2044
2160
|
const legendPath = alias.legend ?? null;
|
|
2045
2161
|
if (legendPath !== null && (typeof legendPath !== "string" || !legendPath.trim()))
|
|
2046
2162
|
throw new HookConfigError(
|
|
@@ -2073,6 +2189,7 @@ function parseHookConfig(data, source) {
|
|
|
2073
2189
|
aliasPublicLayerWins: publicLayerWins,
|
|
2074
2190
|
aliasPublicMailboxDomains: mailbox,
|
|
2075
2191
|
aliasMintInbound: mintInboundRaw,
|
|
2192
|
+
aliasDeclaredOnly: declaredOnly,
|
|
2076
2193
|
aliasLegend: legendPath,
|
|
2077
2194
|
vendors,
|
|
2078
2195
|
live: parseLive(data.live ?? {}, data.tools ?? {}),
|
|
@@ -2351,6 +2468,8 @@ var CommandHandler = class {
|
|
|
2351
2468
|
this.command = command;
|
|
2352
2469
|
this.opts = opts;
|
|
2353
2470
|
}
|
|
2471
|
+
command;
|
|
2472
|
+
opts;
|
|
2354
2473
|
describe() {
|
|
2355
2474
|
return `command ${this.command}${this.opts.args?.length ? " " + this.opts.args.join(" ") : ""}`;
|
|
2356
2475
|
}
|
|
@@ -2453,6 +2572,8 @@ var HttpHandler = class {
|
|
|
2453
2572
|
this.url = url;
|
|
2454
2573
|
this.opts = opts;
|
|
2455
2574
|
}
|
|
2575
|
+
url;
|
|
2576
|
+
opts;
|
|
2456
2577
|
describe() {
|
|
2457
2578
|
return `http ${this.url}`;
|
|
2458
2579
|
}
|
|
@@ -2489,6 +2610,7 @@ var DenyHandler = class {
|
|
|
2489
2610
|
constructor(reason = "denied by rule") {
|
|
2490
2611
|
this.reason = reason;
|
|
2491
2612
|
}
|
|
2613
|
+
reason;
|
|
2492
2614
|
describe() {
|
|
2493
2615
|
return `deny: ${this.reason}`;
|
|
2494
2616
|
}
|
|
@@ -2501,6 +2623,8 @@ var RecordHandler = class {
|
|
|
2501
2623
|
this.sink = sink;
|
|
2502
2624
|
this.opts = opts;
|
|
2503
2625
|
}
|
|
2626
|
+
sink;
|
|
2627
|
+
opts;
|
|
2504
2628
|
describe() {
|
|
2505
2629
|
return `record -> ${typeof this.sink === "string" ? this.sink : typeof this.sink === "function" ? "callback" : "array"}`;
|
|
2506
2630
|
}
|
|
@@ -2537,6 +2661,7 @@ var RedactHandler = class {
|
|
|
2537
2661
|
this.patterns = (opts.patterns ?? []).map((p) => new RegExp(p, "g"));
|
|
2538
2662
|
this.token = opts.token ?? "[redacted {kind}]";
|
|
2539
2663
|
}
|
|
2664
|
+
aliases;
|
|
2540
2665
|
kinds;
|
|
2541
2666
|
/** Literal strings (a name, a company, a phrase) removed wherever they appear, any
|
|
2542
2667
|
* case — the arbitrary half of redaction; `patterns` is the shaped half. */
|
|
@@ -2597,6 +2722,8 @@ var AliasHandler = class {
|
|
|
2597
2722
|
this.aliases = aliases;
|
|
2598
2723
|
this.opts = opts;
|
|
2599
2724
|
}
|
|
2725
|
+
aliases;
|
|
2726
|
+
opts;
|
|
2600
2727
|
describe() {
|
|
2601
2728
|
if (this.opts.check) return `alias check=${this.opts.check}`;
|
|
2602
2729
|
return this.opts.direction ? `alias direction=${this.opts.direction}` : "alias";
|
|
@@ -2717,6 +2844,8 @@ var FunctionHandler = class {
|
|
|
2717
2844
|
this.fn = fn;
|
|
2718
2845
|
this.name = name;
|
|
2719
2846
|
}
|
|
2847
|
+
fn;
|
|
2848
|
+
name;
|
|
2720
2849
|
describe() {
|
|
2721
2850
|
return `callable ${this.name}`;
|
|
2722
2851
|
}
|
|
@@ -3043,6 +3172,8 @@ var HttpTool = class _HttpTool {
|
|
|
3043
3172
|
this.spec = spec;
|
|
3044
3173
|
this.live = live;
|
|
3045
3174
|
}
|
|
3175
|
+
spec;
|
|
3176
|
+
live;
|
|
3046
3177
|
/** Shared across tools: the pace is per tool name, not per HttpTool instance. */
|
|
3047
3178
|
static pacer = new Pacer();
|
|
3048
3179
|
/** The status of the most recent answer, for the recording line. */
|
|
@@ -3139,6 +3270,8 @@ var CallableTool = class _CallableTool {
|
|
|
3139
3270
|
this.spec = spec;
|
|
3140
3271
|
this.fn = fn;
|
|
3141
3272
|
}
|
|
3273
|
+
spec;
|
|
3274
|
+
fn;
|
|
3142
3275
|
static async create(spec, cwd) {
|
|
3143
3276
|
const fn = await importCallable(spec.options.callable, cwd);
|
|
3144
3277
|
return new _CallableTool(
|
|
@@ -3213,6 +3346,8 @@ var ConnectorTool = class {
|
|
|
3213
3346
|
);
|
|
3214
3347
|
}
|
|
3215
3348
|
}
|
|
3349
|
+
spec;
|
|
3350
|
+
live;
|
|
3216
3351
|
connection;
|
|
3217
3352
|
operation;
|
|
3218
3353
|
get placeholders() {
|
|
@@ -3343,6 +3478,7 @@ var Recorder = class {
|
|
|
3343
3478
|
constructor(file) {
|
|
3344
3479
|
this.file = file;
|
|
3345
3480
|
}
|
|
3481
|
+
file;
|
|
3346
3482
|
write(line) {
|
|
3347
3483
|
fs3.mkdirSync(path2.dirname(this.file), { recursive: true });
|
|
3348
3484
|
fs3.appendFileSync(this.file, canonical2(line) + "\n");
|
|
@@ -3373,6 +3509,7 @@ var Replay = class {
|
|
|
3373
3509
|
);
|
|
3374
3510
|
});
|
|
3375
3511
|
}
|
|
3512
|
+
file;
|
|
3376
3513
|
answers = /* @__PURE__ */ new Map();
|
|
3377
3514
|
tool(spec) {
|
|
3378
3515
|
const answers = this.answers;
|
|
@@ -3413,6 +3550,8 @@ var LiveTools = class _LiveTools {
|
|
|
3413
3550
|
if (live.replay) this.replay = new Replay(live.replay);
|
|
3414
3551
|
if (live.record) this.recorder = new Recorder(live.record);
|
|
3415
3552
|
}
|
|
3553
|
+
run;
|
|
3554
|
+
live;
|
|
3416
3555
|
replay;
|
|
3417
3556
|
recorder;
|
|
3418
3557
|
built = {};
|
|
@@ -3564,6 +3703,9 @@ var Identifier = class {
|
|
|
3564
3703
|
this.value = value;
|
|
3565
3704
|
this.source = source;
|
|
3566
3705
|
}
|
|
3706
|
+
kind;
|
|
3707
|
+
value;
|
|
3708
|
+
source;
|
|
3567
3709
|
get key() {
|
|
3568
3710
|
return folded(this.value);
|
|
3569
3711
|
}
|
|
@@ -3597,6 +3739,7 @@ var FieldSource = class extends IdentifierSource {
|
|
|
3597
3739
|
super();
|
|
3598
3740
|
this.fieldKinds = fieldKinds;
|
|
3599
3741
|
}
|
|
3742
|
+
fieldKinds;
|
|
3600
3743
|
name = "fields";
|
|
3601
3744
|
kindsFor(tool) {
|
|
3602
3745
|
return { ...this.fieldKinds[ANY_TOOL] ?? {}, ...this.fieldKinds[tool] ?? {} };
|
|
@@ -3636,6 +3779,7 @@ var IdentifierCensus = class {
|
|
|
3636
3779
|
constructor(sources) {
|
|
3637
3780
|
this.sources = sources;
|
|
3638
3781
|
}
|
|
3782
|
+
sources;
|
|
3639
3783
|
get detectors() {
|
|
3640
3784
|
return this.sources.map((source) => source.name);
|
|
3641
3785
|
}
|
|
@@ -3674,6 +3818,12 @@ var AuditReport = class {
|
|
|
3674
3818
|
this.leakedIdentifiers = leakedIdentifiers;
|
|
3675
3819
|
this.cleanTexts = cleanTexts;
|
|
3676
3820
|
}
|
|
3821
|
+
findings;
|
|
3822
|
+
census;
|
|
3823
|
+
detectors;
|
|
3824
|
+
recordsScanned;
|
|
3825
|
+
leakedIdentifiers;
|
|
3826
|
+
cleanTexts;
|
|
3677
3827
|
get ok() {
|
|
3678
3828
|
return this.findings.length === 0;
|
|
3679
3829
|
}
|
|
@@ -3717,6 +3867,7 @@ var RedactionAudit = class _RedactionAudit {
|
|
|
3717
3867
|
constructor(census) {
|
|
3718
3868
|
this.census = census;
|
|
3719
3869
|
}
|
|
3870
|
+
census;
|
|
3720
3871
|
/** The standard audit: the run's legend, declared field kinds, pattern finders. */
|
|
3721
3872
|
static forRun(options) {
|
|
3722
3873
|
return new _RedactionAudit(
|
|
@@ -3799,7 +3950,8 @@ var HookRun = class _HookRun {
|
|
|
3799
3950
|
this.alias = new AliasMap(this.runKey, options.slugs ?? config.aliasSlugs, {
|
|
3800
3951
|
publicLayerWins: config.aliasPublicLayerWins,
|
|
3801
3952
|
publicMailboxDomains: config.aliasPublicMailboxDomains,
|
|
3802
|
-
mintInbound: options.mintInbound ?? config.aliasMintInbound
|
|
3953
|
+
mintInbound: options.mintInbound ?? config.aliasMintInbound,
|
|
3954
|
+
declaredOnly: options.declaredOnly ?? config.aliasDeclaredOnly
|
|
3803
3955
|
});
|
|
3804
3956
|
this.cwd = options.cwd ?? process.cwd();
|
|
3805
3957
|
this.runDir = options.runDir ?? path3.join(this.cwd, "runs", this.runId);
|
|
@@ -4277,6 +4429,10 @@ var HookedSession = class {
|
|
|
4277
4429
|
this.vendor = vendor;
|
|
4278
4430
|
this.requestFn = requestFn;
|
|
4279
4431
|
}
|
|
4432
|
+
run;
|
|
4433
|
+
inner;
|
|
4434
|
+
vendor;
|
|
4435
|
+
requestFn;
|
|
4280
4436
|
async call(tool, args = {}, ...rest) {
|
|
4281
4437
|
const [real, context] = await this.run.beforeCall(
|
|
4282
4438
|
tool,
|