@jbkjr/relay 0.0.0-stage → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/Apache-2.0.txt +201 -0
- package/LICENSES/README.md +19 -0
- package/LICENSES/codex-NOTICE.txt +6 -0
- package/README.md +386 -2
- package/SECURITY.md +145 -0
- package/adapters/briefs/claude.md +43 -0
- package/adapters/briefs/codex.md +56 -0
- package/adapters/briefs/models.json +33 -0
- package/adapters/build.mjs +8 -0
- package/adapters/claude/.claude-plugin/marketplace.json +13 -0
- package/adapters/claude/relay/.claude-plugin/plugin.json +5 -0
- package/adapters/claude/relay/agents/codex.md +21 -0
- package/adapters/claude/relay/agents/operator.md +21 -0
- package/adapters/claude/relay/skills/ask/SKILL.md +20 -0
- package/adapters/claude/relay/skills/chat/SKILL.md +13 -0
- package/adapters/claude/relay/skills/delegate/SKILL.md +21 -0
- package/adapters/claude/relay/skills/discuss/SKILL.md +19 -0
- package/adapters/claude/relay/skills/review/SKILL.md +21 -0
- package/adapters/claude/relay/skills/tree/SKILL.md +10 -0
- package/adapters/claude/relay/skills/write-for-codex/SKILL.md +78 -0
- package/adapters/codex/.agents/plugins/marketplace.json +20 -0
- package/adapters/codex/AGENTS.snippet.md +5 -0
- package/adapters/codex/relay/.codex-plugin/plugin.json +6 -0
- package/adapters/codex/relay/skills/relay-ask/SKILL.md +20 -0
- package/adapters/codex/relay/skills/relay-chat/SKILL.md +13 -0
- package/adapters/codex/relay/skills/relay-delegate/SKILL.md +21 -0
- package/adapters/codex/relay/skills/relay-discuss/SKILL.md +19 -0
- package/adapters/codex/relay/skills/relay-review/SKILL.md +21 -0
- package/adapters/codex/relay/skills/relay-tree/SKILL.md +10 -0
- package/adapters/codex/relay/skills/relay-write-for-claude/SKILL.md +66 -0
- package/adapters/generate.mjs +124 -0
- package/bin/relay +59 -0
- package/codex-pin.json +12 -0
- package/dist/backends/acp.js +1424 -0
- package/dist/backends/claude.js +890 -0
- package/dist/backends/cli-version.js +112 -0
- package/dist/backends/codex-app.js +1525 -0
- package/dist/backends/codex-daybreak.js +75 -0
- package/dist/backends/codex-env.js +656 -0
- package/dist/backends/codex-network.js +304 -0
- package/dist/backends/codex-pin.js +320 -0
- package/dist/backends/codex-shell-policy.js +182 -0
- package/dist/backends/codex-stage2.js +998 -0
- package/dist/backends/codex-subagents.js +47 -0
- package/dist/backends/codex.js +637 -0
- package/dist/backends/copilot.js +246 -0
- package/dist/backends/env.js +147 -0
- package/dist/backends/gemini.js +607 -0
- package/dist/backends/grok.js +337 -0
- package/dist/backends/index.js +8 -0
- package/dist/backends/native-temp.js +187 -0
- package/dist/backends/never-admission.js +90 -0
- package/dist/backends/run.js +67 -0
- package/dist/backends/stream.js +230 -0
- package/dist/backends/tool-discovery.js +15 -0
- package/dist/backends/types.js +264 -0
- package/dist/build-info.json +5 -0
- package/dist/cli.js +344 -0
- package/dist/confine/bridge.js +113 -0
- package/dist/confine/broker-core.js +76 -0
- package/dist/confine/broker-http.js +650 -0
- package/dist/confine/broker-names.js +9 -0
- package/dist/confine/broker.js +258 -0
- package/dist/confine/canary.js +380 -0
- package/dist/confine/diagnostics.js +122 -0
- package/dist/confine/gemini-tools-main.js +8 -0
- package/dist/confine/gemini-tools.js +181 -0
- package/dist/confine/hardlinks.js +58 -0
- package/dist/confine/harness-config.js +16 -0
- package/dist/confine/index.js +117 -0
- package/dist/confine/leases.js +217 -0
- package/dist/confine/paths.js +6 -0
- package/dist/confine/peer.js +115 -0
- package/dist/confine/port-policy.js +8 -0
- package/dist/confine/ports.js +365 -0
- package/dist/confine/private-root.js +208 -0
- package/dist/confine/probe-stage2.js +501 -0
- package/dist/confine/probe.js +1109 -0
- package/dist/confine/proxy.js +783 -0
- package/dist/confine/sbcheck.js +208 -0
- package/dist/confine/seatbelt-never.js +41 -0
- package/dist/confine/seatbelt-stage2.js +139 -0
- package/dist/confine/seatbelt.js +1129 -0
- package/dist/confine/sockets.js +36 -0
- package/dist/confine/turn-probe.js +19 -0
- package/dist/confine/turn.js +86 -0
- package/dist/core/adoption.js +124 -0
- package/dist/core/api-keys.js +423 -0
- package/dist/core/approvals.js +740 -0
- package/dist/core/build-identity.js +248 -0
- package/dist/core/caller.js +749 -0
- package/dist/core/calls.js +102 -0
- package/dist/core/claude-settings.js +1045 -0
- package/dist/core/config.js +453 -0
- package/dist/core/context.js +186 -0
- package/dist/core/db.js +753 -0
- package/dist/core/dispatch.js +110 -0
- package/dist/core/env-broker.js +505 -0
- package/dist/core/env-policy.js +182 -0
- package/dist/core/escalation-authority.js +76 -0
- package/dist/core/escalation-contract.js +13 -0
- package/dist/core/escalation-person-path.js +131 -0
- package/dist/core/escalation-policy.js +79 -0
- package/dist/core/escalation-runtime.js +135 -0
- package/dist/core/escalation-state.js +42 -0
- package/dist/core/escalations.js +191 -0
- package/dist/core/events.js +235 -0
- package/dist/core/executables.js +147 -0
- package/dist/core/extensions.js +645 -0
- package/dist/core/families.js +204 -0
- package/dist/core/git.js +657 -0
- package/dist/core/identity.js +113 -0
- package/dist/core/liveness.js +68 -0
- package/dist/core/mediated-network-provider.js +81 -0
- package/dist/core/never-checkpoint.js +76 -0
- package/dist/core/never-coverage.js +97 -0
- package/dist/core/never-network.js +49 -0
- package/dist/core/never-policy.js +302 -0
- package/dist/core/never-proxy-policy.js +109 -0
- package/dist/core/never-schema.js +61 -0
- package/dist/core/never-tools.js +56 -0
- package/dist/core/notices.js +48 -0
- package/dist/core/ops.js +959 -0
- package/dist/core/outcome.js +224 -0
- package/dist/core/params.js +32 -0
- package/dist/core/presence.js +174 -0
- package/dist/core/procs.js +546 -0
- package/dist/core/prompts.js +363 -0
- package/dist/core/protected-config.js +238 -0
- package/dist/core/raw-network.js +192 -0
- package/dist/core/redact.js +152 -0
- package/dist/core/refusal.js +33 -0
- package/dist/core/relay-command.js +310 -0
- package/dist/core/reported.js +3 -0
- package/dist/core/restart-overlay.js +651 -0
- package/dist/core/retention.js +1135 -0
- package/dist/core/secrets.js +329 -0
- package/dist/core/session-token.js +175 -0
- package/dist/core/session.js +744 -0
- package/dist/core/shell.js +2 -0
- package/dist/core/shipped-pin.js +47 -0
- package/dist/core/shown.js +42 -0
- package/dist/core/slots.js +67 -0
- package/dist/core/stage2-executors.js +453 -0
- package/dist/core/stage2-switch.js +5 -0
- package/dist/core/steering.js +149 -0
- package/dist/core/storage.js +358 -0
- package/dist/core/toml.js +175 -0
- package/dist/core/views.js +324 -0
- package/dist/core/wait.js +114 -0
- package/dist/core/wake.js +207 -0
- package/dist/core/watch.js +247 -0
- package/dist/core/worktree.js +213 -0
- package/dist/hosts/claude-desktop.js +274 -0
- package/dist/hosts/claude.js +249 -0
- package/dist/hosts/codex.js +329 -0
- package/dist/hosts/desktop-shared.js +20 -0
- package/dist/hosts/index.js +11 -0
- package/dist/hosts/types.js +4 -0
- package/dist/install/basics.js +18 -0
- package/dist/install/claude-init.js +133 -0
- package/dist/install/common.js +655 -0
- package/dist/install/doctor.js +629 -0
- package/dist/install/qualify-codex.js +205 -0
- package/dist/install.js +524 -0
- package/dist/mcp/elicit.js +209 -0
- package/dist/mcp/gateway.js +218 -0
- package/dist/mcp/host.js +253 -0
- package/dist/mcp/server.js +1124 -0
- package/dist/mcp/stdio.js +37 -0
- package/dist/modes/discussion.js +393 -0
- package/dist/modes/review.js +722 -0
- package/dist/native/relay-sbcheck +0 -0
- package/dist/targets/briefs.js +86 -0
- package/dist/targets/claude.js +94 -0
- package/dist/targets/codex.js +66 -0
- package/dist/targets/copilot.js +93 -0
- package/dist/targets/gemini.js +119 -0
- package/dist/targets/grok.js +126 -0
- package/dist/targets/index.js +192 -0
- package/dist/targets/types.js +18 -0
- package/dist/targets/verified.js +35 -0
- package/dist/worker.js +113 -0
- package/docs/UPGRADING.md +1502 -0
- package/docs/pinned-codex.md +321 -0
- package/experiments/stage2-redteam/lib/oracles.mjs +214 -0
- package/experiments/stage2-redteam/lib/report.mjs +35 -0
- package/npm-shrinkwrap.json +1632 -0
- package/package.json +82 -4
- package/scripts/codex-qualify/codex-pin-store.mjs +353 -0
- package/scripts/codex-qualify/codex-qualifier-process.mjs +265 -0
- package/scripts/codex-qualify/codex-qualifier.example.json +5 -0
- package/scripts/codex-qualify/codex-qualifier.mjs +281 -0
- package/scripts/codex-qualify/codex-shipped-pin.mjs +158 -0
- package/scripts/codex-qualify/codex-stage2-pin.mjs +48 -0
- package/scripts/codex-qualify/codex-stage2.mjs +2381 -0
- package/scripts/codex-qualify/install-codex-qualifier.mjs +98 -0
- package/scripts/codex-qualify/main-module.mjs +14 -0
- package/scripts/codex-qualify/relay-codex-qualifier.plist +37 -0
- package/scripts/codex-qualify/scratch-env.mjs +31 -0
- package/scripts/codex-qualify/session.mjs +96 -0
- package/scripts/codex-qualify/stage2-escalation-cases.mjs +125 -0
- package/test/codex-permissions.test.ts +875 -0
- package/test/fixtures/boundary-probes.mjs +17 -0
- package/test/fixtures/denial-stream-host.mjs +7 -0
- package/test/fixtures/families.json +246 -0
- package/test/fixtures/install-snapshots/claude-desktop-foreign.txt +158 -0
- package/test/fixtures/install-snapshots/claude-desktop-fresh.txt +101 -0
- package/test/fixtures/install-snapshots/claude-desktop-installed.txt +161 -0
- package/test/fixtures/install-snapshots/claude-foreign.txt +133 -0
- package/test/fixtures/install-snapshots/claude-fresh.txt +77 -0
- package/test/fixtures/install-snapshots/claude-installed.txt +133 -0
- package/test/fixtures/install-snapshots/codex-foreign.txt +159 -0
- package/test/fixtures/install-snapshots/codex-fresh.txt +107 -0
- package/test/fixtures/install-snapshots/codex-installed.txt +161 -0
- package/test/fixtures/link-parent.mjs +6 -0
- package/test/fixtures/mediated-command.cjs +72 -0
- package/test/fixtures/native-skill-isolation.json +280 -0
- package/test/fixtures/pinned-codex-app-server.mjs +25 -0
- package/test/fixtures/qualified-ext-adapters.mjs +36 -0
- package/test/fixtures/refusals/README.md +52 -0
- package/test/fixtures/refusals/claude-source-result.json +7 -0
- package/test/fixtures/refusals/openai-app-capacity.json +24 -0
- package/test/fixtures/refusals/openai-app-cyberPolicy.json +24 -0
- package/test/fixtures/refusals/openai-gpt-6-astra-max.json +12 -0
- package/test/fixtures/refusals/openai-gpt-6.1-sol-xhigh.json +12 -0
- package/test/fixtures/refusals/openai-review-capacity.json +24 -0
- package/test/fixtures/relay-0.2.0.sql +57 -0
- package/test/fixtures/relay-0.9.1.gen.mjs +212 -0
- package/test/fixtures/relay-0.9.1.sql +340 -0
- package/test/fixtures/slow-boundary-probes.mjs +37 -0
- package/test/fixtures/stable-surfaces/config.json +1122 -0
- package/test/fixtures/stable-surfaces/escalation.json +128 -0
- package/test/fixtures/stable-surfaces/events.json +37 -0
- package/test/fixtures/stable-surfaces/gemini-native-resume.json +4 -0
- package/test/fixtures/stable-surfaces/inbox.jsonl +2 -0
- package/test/fixtures/stable-surfaces/notice.txt +1 -0
- package/test/fixtures/stable-surfaces/refusal-item.json +28 -0
- package/test/fixtures/stable-surfaces/refusal-review.json +23 -0
- package/test/fixtures/stable-surfaces/registry.json +49 -0
- package/test/fixtures/stable-surfaces/tools-desktop.json +575 -0
- package/test/fixtures/stable-surfaces/tools.json +716 -0
- package/test/fixtures/stable-surfaces/usage.txt +46 -0
- package/test/fixtures/stage2-acp-native.mjs +138 -0
- package/test/fixtures/stage2-app-server.mjs +23 -0
- package/test/fixtures/stage2-catalog.json +91 -0
- package/test/fixtures/stage2-hostile-web.mjs +35 -0
- package/test/fixtures/stage2-native-network.mjs +62 -0
- package/test/fixtures/stage2-worker.ts +87 -0
- package/test/fixtures/status-views/expected.json +7825 -0
- package/test/fixtures/status-views/registries.json +1 -0
- package/test/fixtures/steering.json +209 -0
- package/test/helpers.ts +740 -0
- package/test/host-env.ts +7 -0
- package/test/keychain-decoy.ts +197 -0
- package/test/live-scope.ts +44 -0
- package/test/mediated-network.test.ts +192 -0
- package/test/mediated-proxy.test.ts +264 -0
- package/test/native-temp-alias.ts +10 -0
- package/test/never-policy.test.ts +629 -0
- package/test/never-tools.test.ts +136 -0
- package/test/process-home.ts +18 -0
- package/test/proxy.test.ts +531 -0
- package/test/restart-overlay-live.test.ts +85 -0
- package/test/restart-overlay-profile.test.ts +66 -0
- package/test/restart-overlay.test.ts +416 -0
- package/test/stable-surfaces.test.ts +249 -0
- package/test/stage2-escalation-live.test.ts +544 -0
- package/test/stage2-escalation-qualification.test.ts +170 -0
- package/test/stage2-escalation.test.ts +747 -0
- package/test/stage2-executor.test.ts +849 -0
- package/test/stage2-grant.test.ts +603 -0
- package/test/stage2-native-live.test.ts +647 -0
- package/test/stage2-network-decisions.test.ts +70 -0
- package/test/stage2-probe.test.ts +845 -0
- package/test/stage2-standing-live.test.ts +203 -0
- package/test/stubs/broker-host.mjs +59 -0
- package/test/stubs/broker-peer.mjs +20 -0
- package/test/stubs/confined-harness.mjs +91 -0
- package/test/stubs/ext-broken-server.mjs +2 -0
- package/test/stubs/ext-odd-server.mjs +21 -0
- package/test/stubs/ext-server.mjs +31 -0
- package/test/stubs/fake-host-cli.mjs +218 -0
- package/test/stubs/procargs.mjs +30 -0
- package/test/stubs/stub-acp +4 -0
- package/test/stubs/stub-agent.mjs +322 -0
- package/test/stubs/stub-claude +4 -0
- package/test/stubs/stub-codex +4 -0
- package/test/stubs/targets/acp.mjs +307 -0
- package/test/stubs/targets/claude.mjs +149 -0
- package/test/stubs/targets/codex.mjs +479 -0
- package/test/stubs/targets/gemini.mjs +604 -0
- package/test/temp-root.ts +11 -0
- package/test/wp4-adapters.test.ts +353 -0
- package/test/wp4-interlock.test.ts +136 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Family labels describe the two sides of one item. They never grant authority or route calls.
|
|
2
|
+
import { familyOf } from "./caller.js";
|
|
3
|
+
import { db, getNode, runConfig, setParam, tx } from "./db.js";
|
|
4
|
+
import { sessionParams } from "./params.js";
|
|
5
|
+
import { hostFamilyDoubt } from "../mcp/host.js";
|
|
6
|
+
import { targetDef, TARGETS, vendorFor, VENDOR_NAMES } from "../targets/index.js";
|
|
7
|
+
import { oneLine } from "./shown.js";
|
|
8
|
+
import { managedSettings, settingsEnvProblem } from "./claude-settings.js";
|
|
9
|
+
import { turnSubagents } from "./steering.js";
|
|
10
|
+
const fold = (ids) => ids.length && ids.every((f) => f === ids[0]) ? ids[0] : "unknown";
|
|
11
|
+
export const relationOf = (a, b) => a === "unknown" || b === "unknown" ? "unknown" : a === b ? "same-family" : "cross-family";
|
|
12
|
+
export const vendorName = (f) => f === "unknown" ? "family unknown" : VENDOR_NAMES[f];
|
|
13
|
+
const doubt = (side, code, detail) => ({ side, code, ...(detail ? { detail } : {}) });
|
|
14
|
+
const atomic = (fn) => db().isTransaction ? fn() : tx(fn);
|
|
15
|
+
const waiverFor = (target, cfg) => target === "codex" && cfg.codex_endpoint_override === "accept" ? "codex_endpoint_override_config"
|
|
16
|
+
: target === "claude" && cfg.claude_settings_env === "accept" && settingsEnvProblem({ ...cfg, claude_settings_env: "refuse" }, managedSettings()) ? "claude_settings_env" : null;
|
|
17
|
+
/** Resolve the contribution afresh, including call metadata for native Codex subagent threads. */
|
|
18
|
+
export function callerLabel(inst, call = {}) {
|
|
19
|
+
if (call.identity)
|
|
20
|
+
return call.identity.contribution;
|
|
21
|
+
const own = familyOf(inst);
|
|
22
|
+
let label = own ? targetDef(own).vendor ?? "unknown" : "unknown";
|
|
23
|
+
const doubts = [];
|
|
24
|
+
if (inst.ctx.kind === "child") {
|
|
25
|
+
const n = getNode(inst.ctx.nodeId);
|
|
26
|
+
label = n ? launchedLabel(n) : "unknown";
|
|
27
|
+
if (label === "unknown")
|
|
28
|
+
doubts.push(doubt("caller", "parent", inst.ctx.nodeId));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (inst.registration) {
|
|
32
|
+
label = "unknown";
|
|
33
|
+
doubts.push(doubt("caller", "registration", `${inst.registration.host} (--host), but its client is ${JSON.stringify(inst.registration.client)}`));
|
|
34
|
+
}
|
|
35
|
+
else if (label === "unknown")
|
|
36
|
+
doubts.push(doubt("caller", "host", inst.clientName ?? "no client name"));
|
|
37
|
+
const envDoubt = hostFamilyDoubt(process.env, own ? targetDef(own).vendor : null);
|
|
38
|
+
if (envDoubt) {
|
|
39
|
+
label = "unknown";
|
|
40
|
+
doubts.push(doubt("caller", "environment", envDoubt));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (own === "codex" && call.hostModel !== undefined && !targetDef("codex").ownModels.test(call.hostModel)) {
|
|
44
|
+
label = "unknown";
|
|
45
|
+
doubts.push(doubt("caller", "model", call.hostModel));
|
|
46
|
+
}
|
|
47
|
+
return { label, doubts };
|
|
48
|
+
}
|
|
49
|
+
/** Record only accepted contributions, in the transaction that accepts the message. */
|
|
50
|
+
export function addContribution(id, contribution, doubts = []) {
|
|
51
|
+
const c = typeof contribution === "string" ? { label: contribution, doubts } : contribution;
|
|
52
|
+
atomic(() => {
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
const add = (key) => {
|
|
55
|
+
if (seen.has(key))
|
|
56
|
+
return;
|
|
57
|
+
seen.add(key);
|
|
58
|
+
const n = getNode(key);
|
|
59
|
+
if (!n)
|
|
60
|
+
return;
|
|
61
|
+
const p = sessionParams(n);
|
|
62
|
+
if (c.snapshot && !p.caller_snapshots?.some((s) => s.call_id === c.snapshot.call_id)) {
|
|
63
|
+
const snapshots = [...(p.caller_snapshots ?? []), c.snapshot];
|
|
64
|
+
// Retain origin evidence and a bounded recent window for long-running items.
|
|
65
|
+
setParam(key, "caller_snapshots", snapshots.length <= 21 ? snapshots : [snapshots[0], ...snapshots.slice(-20)]);
|
|
66
|
+
}
|
|
67
|
+
// A continuation of legacy work must retain its unknown history.
|
|
68
|
+
setParam(key, "caller_families", [...new Set([...(p.caller_families ?? ["unknown"]), c.label])]);
|
|
69
|
+
const all = [...(p.family_doubts ?? []), ...(!p.caller_families ? [doubt("caller", "legacy")] : []), ...c.doubts];
|
|
70
|
+
setParam(key, "family_doubts", all.filter((d, i) => all.findIndex((e) => JSON.stringify(e) === JSON.stringify(d)) === i));
|
|
71
|
+
if (n.kind === "discussion") {
|
|
72
|
+
const dp = JSON.parse(n.params_json);
|
|
73
|
+
add(dp.participant);
|
|
74
|
+
if (dp.review_id)
|
|
75
|
+
add(dp.review_id);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
add(id);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function recordStart(id, inst, call, target, model, cfg) {
|
|
82
|
+
atomic(() => {
|
|
83
|
+
setParam(id, "caller_families", []);
|
|
84
|
+
const def = targetDef(target);
|
|
85
|
+
const waiver = waiverFor(target, cfg);
|
|
86
|
+
const initial = waiver ? "unknown" : vendorFor(def, model ?? cfg.targets[target]?.default_model) ?? "unknown";
|
|
87
|
+
setParam(id, "launched_family", initial);
|
|
88
|
+
setParam(id, "family_doubts", waiver ? [doubt("launched", waiver)] : []);
|
|
89
|
+
if (!def.vendor && initial === "unknown") {
|
|
90
|
+
setParam(id, "family_doubts", [doubt("launched", !model || model === def.autoModel ? "auto" : "unlisted", model ?? cfg.targets[target]?.default_model ?? "no model")]);
|
|
91
|
+
}
|
|
92
|
+
addContribution(id, callerLabel(inst, call));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export function recordServed(id, def, model) {
|
|
96
|
+
atomic(() => {
|
|
97
|
+
const n = getNode(id);
|
|
98
|
+
if (!n)
|
|
99
|
+
return;
|
|
100
|
+
const p = sessionParams(n);
|
|
101
|
+
const models = [...(p.served_models ?? [])];
|
|
102
|
+
if (model && models.at(-1) !== model)
|
|
103
|
+
models.push(model);
|
|
104
|
+
setParam(id, "served_models", models);
|
|
105
|
+
setParam(id, "served_model", model);
|
|
106
|
+
const current = vendorFor(def, model) ?? "unknown";
|
|
107
|
+
const before = launchedLabel(n);
|
|
108
|
+
setParam(id, "launched_family", fold([before, current]));
|
|
109
|
+
if (!def.vendor && models.length > 1) {
|
|
110
|
+
const all = [...(p.family_doubts ?? []).filter((d) => d.code !== "switch"), doubt("launched", "switch", models.join(", then "))];
|
|
111
|
+
setParam(id, "family_doubts", all);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export function recordWaiver(id, which) {
|
|
116
|
+
atomic(() => {
|
|
117
|
+
const n = getNode(id);
|
|
118
|
+
if (!n)
|
|
119
|
+
return;
|
|
120
|
+
setParam(id, "launched_family", "unknown");
|
|
121
|
+
const ds = (sessionParams(n).family_doubts ?? []).filter((d) => d.code !== `${which}_config`);
|
|
122
|
+
if (!ds.some((d) => d.code === which))
|
|
123
|
+
setParam(id, "family_doubts", [...ds, doubt("launched", which)]);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** Old rows cannot prove the caller's family, and accepted legacy waivers lower the launch. */
|
|
127
|
+
export function launchedLabel(n, p = sessionParams(n)) {
|
|
128
|
+
if (p.launched_family)
|
|
129
|
+
return p.launched_family;
|
|
130
|
+
if (!n.target)
|
|
131
|
+
return "unknown";
|
|
132
|
+
const cfg = runConfig(n.run_id);
|
|
133
|
+
if (waiverFor(n.target, cfg))
|
|
134
|
+
return "unknown";
|
|
135
|
+
return vendorFor(targetDef(n.target), n.model ?? cfg.targets[n.target]?.default_model) ?? "unknown";
|
|
136
|
+
}
|
|
137
|
+
export function summaryText(kind, caller, launched, relation, family) {
|
|
138
|
+
return relation === "cross-family" ? `Cross-family: ${caller} working with ${launched}.`
|
|
139
|
+
: relation === "same-family" ? `Same-family: ${caller} working with ${launched}. Both run ${vendorName(family)}'s models; this is not a cross-family ${kind}.`
|
|
140
|
+
: `Family unknown: relay cannot show that ${caller} and ${launched} are of different families, so this ${kind} is not known to be cross-family.`;
|
|
141
|
+
}
|
|
142
|
+
/** `harness`: the launched side's harness, by name ("Copilot", "Grok"), for the doubts about the model it ran. */
|
|
143
|
+
export function noteText(ds, legacy, mixed, models, harness) {
|
|
144
|
+
const sentences = ds.map((raw) => {
|
|
145
|
+
const d = { ...raw, ...(raw.detail ? { detail: oneLine(raw.detail, 120) } : {}) };
|
|
146
|
+
switch (d.code) {
|
|
147
|
+
case "registration": return `Relay cannot tell this session's family: it is registered as ${d.detail}.`;
|
|
148
|
+
case "host": return `Relay cannot tell this session's family: its host is not one relay knows (client name ${JSON.stringify(d.detail)}).`;
|
|
149
|
+
case "environment": return `Relay cannot tell this session's family: this session's environment sets ${d.detail}, so its model may not be ${d.detail?.startsWith("ANTHROPIC") ? "Anthropic" : "OpenAI"}'s.`;
|
|
150
|
+
case "model": return `Relay cannot tell this session's family: Codex reported the model ${JSON.stringify(d.detail)} for this call.`;
|
|
151
|
+
case "parent": return `The calling agent ${d.detail} has a family relay cannot tell.`;
|
|
152
|
+
case "auto": return `${harness} chose the model (${d.detail === "no model" ? "no model named" : "auto"}); it reported ${oneLine(models.join(", then "), 120) || "no model"}.`;
|
|
153
|
+
case "unlisted": return `${harness} was asked to run ${JSON.stringify(d.detail)}, which relay's model list does not name.`;
|
|
154
|
+
case "switch": return `${harness} changed models during the work (${d.detail}).`;
|
|
155
|
+
case "codex_endpoint_override": return 'Relay launched Codex with an endpoint its config does not judge (codex_endpoint_override "accept").';
|
|
156
|
+
case "codex_endpoint_override_config": return 'Relay\'s config permits an endpoint override (codex_endpoint_override "accept"); relay conservatively labels this item unknown even when no redirect is active.';
|
|
157
|
+
case "claude_settings_env": return 'Relay launched Claude with settings it does not vet (claude_settings_env "accept").';
|
|
158
|
+
case "legacy": return "This item was recorded before relay kept the caller's family.";
|
|
159
|
+
default: return "";
|
|
160
|
+
}
|
|
161
|
+
}).filter(Boolean);
|
|
162
|
+
if (mixed.length > 1)
|
|
163
|
+
sentences.push(`Sessions of more than one family worked on the calling side (${mixed.map(vendorName).join(", ")}).`);
|
|
164
|
+
if (legacy)
|
|
165
|
+
sentences.push("This item was recorded before relay kept the caller's family.");
|
|
166
|
+
return [...new Set(sentences)].join(" ") || "Relay cannot show the two sides are of different families.";
|
|
167
|
+
}
|
|
168
|
+
export function familiesOf(row, kind = row.kind === "thread" ? "consult" : row.kind) {
|
|
169
|
+
// Always read fresh: backend callbacks and other sessions can have contributed since row was read.
|
|
170
|
+
const n = getNode(row.id) ?? row;
|
|
171
|
+
const p = sessionParams(n);
|
|
172
|
+
const raw = p;
|
|
173
|
+
const part = n.kind === "discussion" ? getNode(raw.participant ?? "") : n.kind === "review" ? getNode(raw.reviewer ?? "") : n;
|
|
174
|
+
// A job's or thread's own params, read once.
|
|
175
|
+
const pp = part === n ? p : part ? sessionParams(part) : {};
|
|
176
|
+
const caller = fold(p.caller_families ?? []);
|
|
177
|
+
const launched = part ? launchedLabel(part, pp) : "unknown";
|
|
178
|
+
const relation = relationOf(caller, launched);
|
|
179
|
+
const mixed = (p.caller_families ?? []).filter((f) => f !== "unknown");
|
|
180
|
+
let parent = n.parent_id ? getNode(n.parent_id) : null;
|
|
181
|
+
if (parent && ["review", "discussion"].includes(parent.kind))
|
|
182
|
+
parent = parent.parent_id ? getNode(parent.parent_id) : null;
|
|
183
|
+
const launchedCaller = parent && ["job", "thread"].includes(parent.kind) ? parent : null;
|
|
184
|
+
const ownName = TARGETS.find((t) => t.vendor === caller)?.name ?? vendorName(caller);
|
|
185
|
+
const c = caller !== "unknown" ? launchedCaller ? `${launchedCaller.id} (${launchedCaller.target ? targetDef(launchedCaller.target).name : ownName}, ${vendorName(caller)})` : `${ownName} (${vendorName(caller)})`
|
|
186
|
+
: mixed.length > 1 ? `sessions of more than one family (${mixed.map(vendorName).join(", ")})` : "a session of unknown family";
|
|
187
|
+
const def = n.target ? targetDef(n.target) : null;
|
|
188
|
+
const model = part?.model ?? (def ? runConfig(n.run_id).targets[def.id]?.default_model : null);
|
|
189
|
+
const a = def ? `${def.name}${!def.vendor ? ` running ${model ? oneLine(model, 60) : "its own choice"}` : ""} (${vendorName(launched)})` : "an agent of unknown family";
|
|
190
|
+
const summary = summaryText(kind, c, a, relation, caller);
|
|
191
|
+
if (relation === "cross-family")
|
|
192
|
+
return { caller, launched, relation, summary };
|
|
193
|
+
const launchedDoubts = (pp.family_doubts ?? []).filter((d) => d.side === "launched");
|
|
194
|
+
if (part && !pp.launched_family) {
|
|
195
|
+
const cfg = runConfig(part.run_id);
|
|
196
|
+
const waiver = part.target && waiverFor(part.target, cfg);
|
|
197
|
+
if (waiver)
|
|
198
|
+
launchedDoubts.push(doubt("launched", waiver));
|
|
199
|
+
}
|
|
200
|
+
const note = relation === "same-family"
|
|
201
|
+
? `Relay started ${a} because the call named it. ${launchedCaller ? (!launchedCaller.target || turnSubagents(launchedCaller.target, launchedCaller.kind === "job" ? launchedCaller.mode : "read") ? "Relay's preamble to you gives your own subagents first place for helpers of your own kind." : "Relay's preamble to you says you have no subagents in this turn, so you may name your own family's target when the work needs another agent of your kind.") : `Its tool descriptions give your own subagents first place for ${ownName} work, unless the user asked for relay or this session has none.`}`
|
|
202
|
+
: noteText([...(p.family_doubts ?? []).filter((d) => d.side === "caller"), ...launchedDoubts], !p.caller_families, mixed, pp.served_models ?? [], part?.target ? targetDef(part.target).name : "Its harness");
|
|
203
|
+
return { caller, launched, relation, summary, note };
|
|
204
|
+
}
|