@jbkjr/relay 0.0.0-stage → 1.2.2
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 +393 -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 +1539 -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 +345 -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 +641 -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 +345 -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 +635 -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 +1518 -0
- package/docs/pinned-codex.md +333 -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,37 @@
|
|
|
1
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
+
import { serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
3
|
+
/** The SDK resolves send on buffer acceptance. Event delivery needs the completed write. */
|
|
4
|
+
export class RelayStdioTransport extends StdioServerTransport {
|
|
5
|
+
output;
|
|
6
|
+
constructor(input = process.stdin, output = process.stdout) {
|
|
7
|
+
super(input, output);
|
|
8
|
+
this.output = output;
|
|
9
|
+
}
|
|
10
|
+
send(message) {
|
|
11
|
+
const line = serializeMessage(message);
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const cleanup = () => {
|
|
14
|
+
this.output.off("close", closed);
|
|
15
|
+
this.output.off("error", failed);
|
|
16
|
+
};
|
|
17
|
+
const failed = (error) => { cleanup(); reject(error); };
|
|
18
|
+
const closed = () => failed(new Error("Output closed before reply was written"));
|
|
19
|
+
this.output.once("close", closed);
|
|
20
|
+
this.output.once("error", failed);
|
|
21
|
+
try {
|
|
22
|
+
this.output.write(line, error => {
|
|
23
|
+
// Keep the error listener until the stream emits the error after this callback.
|
|
24
|
+
if (error)
|
|
25
|
+
reject(error);
|
|
26
|
+
else {
|
|
27
|
+
cleanup();
|
|
28
|
+
resolve();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
failed(error);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
// A discussion: the calling agent and one agent of the other family. Relay launches only the other
|
|
2
|
+
// side, passes each message verbatim, keeps the transcript, and says when it is over. A review's
|
|
3
|
+
// reconciliation is a discussion with its reviewer (modes/review.ts), which it ends.
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { refusalNote } from "../core/refusal.js";
|
|
6
|
+
import { recordStart, addContribution, callerLabel, familiesOf } from "../core/families.js";
|
|
7
|
+
import { describeSide } from "../core/steering.js";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { admitExisting, admitNew, admitSpeed, admitWork, authority, callerSide, changeSpeed, familyOf, grantOf, knownCaller, refused, } from "../core/caller.js";
|
|
10
|
+
import { noteCall } from "../core/calls.js";
|
|
11
|
+
import { holdsServers } from "../core/extensions.js";
|
|
12
|
+
import { persistentGrant } from "../core/caller.js";
|
|
13
|
+
import { recordEnvironmentRequest } from "../core/env-broker.js";
|
|
14
|
+
import { runDir } from "../core/config.js";
|
|
15
|
+
import { ACTIVE, db, getNode, getTurn, insertNode, newId, now, runConfig, setParam, speedAfter, tx, turnSettled, updateNode, workerLive } from "../core/db.js";
|
|
16
|
+
import { dispatch, queueTurn } from "../core/dispatch.js";
|
|
17
|
+
import { discussionParams, reviewParams } from "../core/params.js";
|
|
18
|
+
import { contextBlock, discussionOpening, HUMAN_LABEL, parseMarker, ROLE_PRESETS } from "../core/prompts.js";
|
|
19
|
+
import { denialsOf, recordOwnOutcome } from "../core/outcome.js";
|
|
20
|
+
import { CALLER_LABEL, targetDef, targetLabel } from "../targets/index.js";
|
|
21
|
+
import { keepRecord } from "../core/storage.js";
|
|
22
|
+
import { notesView, pendingHandle, runRecovery, speedView } from "../core/views.js";
|
|
23
|
+
import { waitOpts, waitUntil } from "../core/wait.js";
|
|
24
|
+
import { finishReview, openReviewOf, reviewOnly } from "./review.js";
|
|
25
|
+
/**
|
|
26
|
+
* A discussion or review recorded by the first relay, which launched both sides itself: it has no
|
|
27
|
+
* target and none of the fields this version keeps (the participant or reviewer, the side labels).
|
|
28
|
+
* It is shown as stored and never continued.
|
|
29
|
+
*/
|
|
30
|
+
export function legacyTwoSided(n) {
|
|
31
|
+
if (n.kind !== "discussion" && n.kind !== "review")
|
|
32
|
+
return false;
|
|
33
|
+
let p;
|
|
34
|
+
try {
|
|
35
|
+
p = JSON.parse(n.params_json ?? "null");
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return n.kind === "discussion" ? typeof p?.participant !== "string" || !p?.state : typeof p?.reviewer !== "string";
|
|
41
|
+
}
|
|
42
|
+
export const LEGACY_NOTE = "This item was recorded by an earlier relay that launched both sides itself; it is shown as stored and cannot be continued.";
|
|
43
|
+
export const legacyRefusal = (n) => ({ error: `${n.id} was recorded by an earlier relay that launched both sides itself, so it cannot be continued. Start a new ${n.kind} instead.` });
|
|
44
|
+
/** The participant's side label. In an older row it is the participant session's target. */
|
|
45
|
+
export const otherSide = (p) => p.other ?? getNode(p.participant)?.target ?? CALLER_LABEL;
|
|
46
|
+
/** Marks a message as taken while its turn is being queued. */
|
|
47
|
+
const RESERVED = -1;
|
|
48
|
+
const cruxOf = (m) => (m?.kind === "CRUX" ? m.text : null);
|
|
49
|
+
/** A side's last marker as it wrote it ("AGREE: …", "CRUX: …", "CONTINUE"), or null for none. */
|
|
50
|
+
const positionOf = (m) => (!m || m.kind === "NONE" ? null : m.kind === "CONTINUE" ? "CONTINUE" : `${m.kind}: ${m.text}`);
|
|
51
|
+
const DISCUSS_NEXT = "Answer with discuss (discussion_id and message). End each message with CONTINUE, AGREE: <the conclusion>, or CRUX: <what you cannot agree on>, on its own line. " +
|
|
52
|
+
"It ends when you both write AGREE in a row, or when you write CRUX and the other has answered.";
|
|
53
|
+
/**
|
|
54
|
+
* Adds to a discussion's transcript. The discussion itself is in the registry, so a transcript that
|
|
55
|
+
* cannot be written (a full disk, say) does not stop it: the first failure is a warning in its
|
|
56
|
+
* result, and relay goes on trying for later turns.
|
|
57
|
+
*/
|
|
58
|
+
function transcribe(file, p, text, o = {}) {
|
|
59
|
+
const problem = keepRecord(file, text, { append: !o.start, consequence: "the transcript is incomplete, though the discussion itself is in the registry" });
|
|
60
|
+
if (problem && !p.state.warnings.some((w) => w.startsWith(`relay could not write ${file} `)))
|
|
61
|
+
p.state.warnings.push(`${problem}.`);
|
|
62
|
+
}
|
|
63
|
+
function closeDiscussion(id, p, end) {
|
|
64
|
+
const d = getNode(id);
|
|
65
|
+
const other = otherSide(p);
|
|
66
|
+
const cruxes = { [p.caller]: cruxOf(p.state.markers[p.caller]), [other]: cruxOf(p.state.markers[other]) };
|
|
67
|
+
// Each side's final position, so that an AGREE answering the other's CRUX keeps its conclusion.
|
|
68
|
+
const final_positions = { [p.caller]: positionOf(p.state.markers[p.caller]), [other]: positionOf(p.state.markers[other]) };
|
|
69
|
+
const agreedAtEnd = [p.caller, other].filter((side) => p.state.markers[side]?.kind === "AGREE");
|
|
70
|
+
if (d.transcript_path) {
|
|
71
|
+
transcribe(d.transcript_path, p, `\n(relay) Families: ${familiesOf(d).summary}\n`);
|
|
72
|
+
transcribe(d.transcript_path, p, end.outcome === "agree" ? `\n## Outcome\n\nAGREE: ${end.conclusion}\n`
|
|
73
|
+
: end.outcome === "no_agreement" ? `\n## Outcome\n\nNo agreement after ${p.state.turns} turns.\n\n${p.caller}'s crux: ${cruxes[p.caller] ?? "(none stated)"}\n\n${other}'s crux: ${cruxes[other] ?? "(none stated)"}\n${agreedAtEnd.map((side) => `\n${side}'s final position: ${final_positions[side]}\n`).join("")}`
|
|
74
|
+
: `\n## Ended early\n\n${end.error}\n`);
|
|
75
|
+
}
|
|
76
|
+
const base = { families: familiesOf(d), transcript_path: d.transcript_path, turns: p.state.turns, participant: p.participant, ...(p.state.warnings.length ? { warnings: p.state.warnings } : {}) };
|
|
77
|
+
const result = end.outcome === "agree" ? { outcome: "agree", conclusion: end.conclusion, closed_by: end.closer, ...base }
|
|
78
|
+
: end.outcome === "no_agreement" ? { outcome: "no_agreement", cruxes, final_positions, ...base }
|
|
79
|
+
: { outcome: end.outcome, error: end.error, ...(end.outcome === "refused" ? { refusal: end.refusal, note: refusalNote(end.refusal), unfinished: true } : {}), cruxes, final_positions, ...base };
|
|
80
|
+
updateNode(id, { result_json: JSON.stringify(result), error: end.outcome === "error" || end.outcome === "refused" ? end.error : null, ended_at: now() });
|
|
81
|
+
db().prepare("UPDATE nodes SET status = ? WHERE id = ? AND status = 'open'").run(end.outcome === "refused" ? "refused" : end.outcome === "error" ? "failed" : "done", id);
|
|
82
|
+
if (p.review_id)
|
|
83
|
+
finishReview(p.review_id, id);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Folds the participant's finished reply into the discussion: the transcript, its marker, and
|
|
87
|
+
* whether that ends it. Returns false while the reply is still being written, or its session is
|
|
88
|
+
* still recording the turn's end (db.ts turnSettled). Safe to call from anywhere, any number of times.
|
|
89
|
+
*/
|
|
90
|
+
export function settleDiscussion(id) {
|
|
91
|
+
return tx(() => {
|
|
92
|
+
const d = getNode(id);
|
|
93
|
+
if (!d || d.kind !== "discussion" || d.status !== "open")
|
|
94
|
+
return true;
|
|
95
|
+
const p = discussionParams(d);
|
|
96
|
+
if (p.state.pending === undefined)
|
|
97
|
+
return true;
|
|
98
|
+
if (p.state.pending === RESERVED)
|
|
99
|
+
return false;
|
|
100
|
+
const t = getTurn(p.state.pending);
|
|
101
|
+
const part = getNode(p.participant);
|
|
102
|
+
const inFlight = Boolean(t && ["queued", "running"].includes(t.status));
|
|
103
|
+
// Still coming, unless nothing is left that could produce it.
|
|
104
|
+
if (inFlight && part && (workerLive(part) || ACTIVE.includes(part.status)))
|
|
105
|
+
return false;
|
|
106
|
+
// Written, but its session has not yet recorded the turn's end: the reply is taken with the
|
|
107
|
+
// session settled with it (or gone on to its next turn), so that whoever reads it finds the
|
|
108
|
+
// session as the reply left it.
|
|
109
|
+
if (!inFlight && !turnSettled(t))
|
|
110
|
+
return false;
|
|
111
|
+
const other = otherSide(p);
|
|
112
|
+
delete p.state.pending;
|
|
113
|
+
if (!t || t.status !== "done") {
|
|
114
|
+
updateNode(id, { params_json: JSON.stringify(p) });
|
|
115
|
+
if (t?.status === "refused" && t.refusal_json) {
|
|
116
|
+
closeDiscussion(id, p, { outcome: "refused", error: t.error ?? "vendor refusal", refusal: JSON.parse(t.refusal_json) });
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
closeDiscussion(id, p, { outcome: "error", error: `${other}'s turn ${!t ? "was lost" : t.status === "failed" && t.error ? `failed: ${t.error}` : `ended as ${t.status}`}` });
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const reply = t.reply ?? "";
|
|
123
|
+
const marker = parseMarker(reply);
|
|
124
|
+
p.state.turns++;
|
|
125
|
+
p.state.last[other] = reply;
|
|
126
|
+
p.state.markers[other] = marker;
|
|
127
|
+
// A reply can come with a warning about processes its agent left behind.
|
|
128
|
+
if (t.error)
|
|
129
|
+
p.state.warnings.push(`${other}, turn ${p.state.turns}: ${t.error}`);
|
|
130
|
+
if (t.denials)
|
|
131
|
+
p.state.warnings.push(`${other}, turn ${p.state.turns}: was refused ${denialsOf(t).join("; ")}`);
|
|
132
|
+
if (d.transcript_path)
|
|
133
|
+
transcribe(d.transcript_path, p, `\n## Turn ${p.state.turns} — ${other}\n\n${reply.trim()}\n${marker.kind === "NONE" ? "\n(relay: no final marker found; treated as CONTINUE)\n" : ""}`);
|
|
134
|
+
updateNode(id, { params_json: JSON.stringify(p) });
|
|
135
|
+
const mine = p.state.markers[p.caller];
|
|
136
|
+
// The second AGREE was written after reading the first, so whether the two conclusions are compatible is that side's own judgment.
|
|
137
|
+
if (mine?.kind === "AGREE" && marker.kind === "AGREE")
|
|
138
|
+
closeDiscussion(id, p, { outcome: "agree", conclusion: marker.text, closer: other });
|
|
139
|
+
else if (mine?.kind === "CRUX" || (p.max_turns !== undefined && p.state.turns >= p.max_turns))
|
|
140
|
+
closeDiscussion(id, p, { outcome: "no_agreement" });
|
|
141
|
+
return true;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
export function discussionView(id) {
|
|
145
|
+
const d = getNode(id);
|
|
146
|
+
const p = discussionParams(d);
|
|
147
|
+
const other = otherSide(p);
|
|
148
|
+
// Anything the user said since the caller last looked. The participant gets the same on its next turn.
|
|
149
|
+
const fresh = tx(() => {
|
|
150
|
+
const now_ = discussionParams(getNode(id));
|
|
151
|
+
const rows = db().prepare("SELECT id, body FROM injections WHERE discussion_id = ? AND id > ? ORDER BY id").all(id, now_.state.shown);
|
|
152
|
+
if (rows.length) {
|
|
153
|
+
now_.state.shown = rows[rows.length - 1].id;
|
|
154
|
+
updateNode(id, { params_json: JSON.stringify(now_) });
|
|
155
|
+
}
|
|
156
|
+
return rows.map((r) => r.body);
|
|
157
|
+
});
|
|
158
|
+
const reply = p.state.last[other];
|
|
159
|
+
const result = d.result_json ? JSON.parse(d.result_json) : {};
|
|
160
|
+
// Closed by the caller's own AGREE: the other side wrote nothing after it, so there is no reply.
|
|
161
|
+
// Its last message (the AGREE the caller answered) is in the transcript.
|
|
162
|
+
const closedByCaller = result.outcome === "agree" && result.closed_by === p.caller;
|
|
163
|
+
// The other side's speed where it is not standard, as status gives it for its session (views.ts speedView).
|
|
164
|
+
const part = getNode(p.participant);
|
|
165
|
+
const speed = part ? speedView(part) : null;
|
|
166
|
+
return {
|
|
167
|
+
discussion_id: id, ...runRecovery(d.run_id), status: d.status, with: other, participant: p.participant, ...(speed ? { speed } : {}), turns: p.state.turns,
|
|
168
|
+
...(d.target && !targetDef(d.target).qualified ? { target_label: targetLabel(targetDef(d.target)) } : {}),
|
|
169
|
+
...(closedByCaller ? { reply: null, reply_note: `Your AGREE closed the discussion, so ${other} has not replied to it. Its last message, the AGREE you answered, is in the transcript.` }
|
|
170
|
+
: reply !== undefined ? { reply, marker: p.state.markers[other]?.kind ?? "NONE" } : {}),
|
|
171
|
+
...(fresh.length ? { human_messages: fresh } : {}),
|
|
172
|
+
transcript_path: d.transcript_path, chat: `relay chat ${id}`,
|
|
173
|
+
...result,
|
|
174
|
+
families: familiesOf(d, "discussion"),
|
|
175
|
+
...notesView(d),
|
|
176
|
+
...(d.status === "open" && p.state.pending === undefined ? { next: DISCUSS_NEXT } : {}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Starts a discussion or carries one on: the calling agent's message goes to the other side, and
|
|
181
|
+
* the reply comes back. ops.ts discuss, the tool, answers a repeated request_id first; a review's
|
|
182
|
+
* reconciliation (`within`) calls this directly.
|
|
183
|
+
*/
|
|
184
|
+
export async function discuss(inst, a, w = {}, within) {
|
|
185
|
+
let id;
|
|
186
|
+
let caller;
|
|
187
|
+
/** The speed an existing session goes on at, set only once the message is taken and its turn queued (changeSpeed). */
|
|
188
|
+
let respeed;
|
|
189
|
+
let turnGrant;
|
|
190
|
+
if (a.discussion_id) {
|
|
191
|
+
const d = getNode(a.discussion_id);
|
|
192
|
+
if (!d || d.kind !== "discussion")
|
|
193
|
+
return { error: `${a.discussion_id} is not a discussion` };
|
|
194
|
+
if (legacyTwoSided(d))
|
|
195
|
+
return legacyRefusal(d);
|
|
196
|
+
const c = admitExisting(inst, d, "continue", a.cwd);
|
|
197
|
+
if ("reason" in c)
|
|
198
|
+
return refused(c.reason);
|
|
199
|
+
caller = c;
|
|
200
|
+
// A session borrowed for the discussion is checked again each time: it may since have been
|
|
201
|
+
// given more access than the caller has.
|
|
202
|
+
const dp = discussionParams(d);
|
|
203
|
+
const borrowed = dp.borrowed ? getNode(dp.participant) : undefined;
|
|
204
|
+
const noPart = borrowed ? authority(caller, borrowed, "carry on a discussion with") : null;
|
|
205
|
+
if (noPart)
|
|
206
|
+
return refused(noPart);
|
|
207
|
+
const unknown = knownCaller(inst);
|
|
208
|
+
if (unknown)
|
|
209
|
+
return refused(unknown);
|
|
210
|
+
// A speed given here is the other side's from the turn this message queues. Asked whether or not
|
|
211
|
+
// the call names one: a launched agent may not carry on a session faster than itself.
|
|
212
|
+
const part = getNode(dp.participant);
|
|
213
|
+
if (part?.target) {
|
|
214
|
+
const g = admitWork(caller, part.target, { mode: "read", grant: a.grant, kept: grantOf(part), continues: true, servers: holdsServers(part) }, w);
|
|
215
|
+
if ("reason" in g)
|
|
216
|
+
return refused(g.reason);
|
|
217
|
+
turnGrant = g.grant;
|
|
218
|
+
const sp = admitSpeed(caller, part.target, { speed: a.speed, current: speedAfter(part), model: part.model }, w);
|
|
219
|
+
if ("reason" in sp)
|
|
220
|
+
return refused(sp.reason);
|
|
221
|
+
respeed = sp.speed;
|
|
222
|
+
}
|
|
223
|
+
id = d.id;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
if (!a.topic)
|
|
227
|
+
return { error: "a new discussion needs a topic" };
|
|
228
|
+
let session = null;
|
|
229
|
+
if (a.with) {
|
|
230
|
+
session = getNode(a.with) ?? null;
|
|
231
|
+
if (!session || !["job", "thread"].includes(session.kind) || !session.target)
|
|
232
|
+
return { error: `${a.with} is not a job or thread id` };
|
|
233
|
+
}
|
|
234
|
+
const admitted = admitNew(inst, { target: a.target, model: a.model, cwd: a.cwd, existing: session });
|
|
235
|
+
if ("reason" in admitted)
|
|
236
|
+
return refused(admitted.reason);
|
|
237
|
+
caller = admitted.caller;
|
|
238
|
+
const to = admitted.to;
|
|
239
|
+
if (session) {
|
|
240
|
+
const review = openReviewOf(session);
|
|
241
|
+
if (review && within?.reviewId !== review.id)
|
|
242
|
+
return refused(reviewOnly(session, review, "bring into a discussion"));
|
|
243
|
+
if (session.status === "cancelled")
|
|
244
|
+
return refused(`${session.id} was cancelled. Resume it first, or start the discussion without it.`);
|
|
245
|
+
}
|
|
246
|
+
// A discussion is several turns of one session.
|
|
247
|
+
const g = admitWork(caller, to.target, { mode: "read", grant: a.grant, kept: session ? grantOf(session) : undefined, continues: true, servers: holdsServers(session ?? undefined) }, w);
|
|
248
|
+
if ("reason" in g)
|
|
249
|
+
return refused(g.reason);
|
|
250
|
+
turnGrant = g.grant;
|
|
251
|
+
// An existing session goes on at its own speed, unless the call gives one.
|
|
252
|
+
const sp = admitSpeed(caller, to.target, { speed: a.speed, current: session ? speedAfter(session) : undefined, model: session ? session.model : (to.model ?? a.model) }, w);
|
|
253
|
+
if ("reason" in sp)
|
|
254
|
+
return refused(sp.reason);
|
|
255
|
+
const role = a.role ?? (session ? "peer" : "critic");
|
|
256
|
+
const node = insertNode({
|
|
257
|
+
id: newId("discussion"), run_id: caller.runId, parent_id: within?.reviewId ?? caller.node?.id ?? null, kind: "discussion", target: to.target, mode: "read",
|
|
258
|
+
depth: caller.depth + 1, allow_delegation: a.allow_delegation ? 1 : 0, task: a.topic, cwd: caller.cwd, status: "open",
|
|
259
|
+
});
|
|
260
|
+
const participant = session ?? insertNode({
|
|
261
|
+
id: newId("thread"), run_id: caller.runId, parent_id: node.id, kind: "thread", target: to.target, mode: "read",
|
|
262
|
+
depth: caller.depth + 1, allow_delegation: a.allow_delegation ? 1 : 0, task: `discussion with ${familyOf(inst) ?? "the caller"}: ${a.topic}`, cwd: caller.cwd,
|
|
263
|
+
// A session made for the discussion stays idle until its first message arrives.
|
|
264
|
+
status: "done", model: to.model ?? a.model ?? null, effort: a.effort ?? null, params_json: JSON.stringify({ grant: persistentGrant(g.grant), speed: sp.speed }),
|
|
265
|
+
});
|
|
266
|
+
if (!session)
|
|
267
|
+
recordStart(participant.id, inst, w, to.target, participant.model, runConfig(caller.runId));
|
|
268
|
+
// Only the grant is set now, never the session's other keys from the row read above (review C11);
|
|
269
|
+
// the speed, with the first message's turn.
|
|
270
|
+
if (session && g.grant)
|
|
271
|
+
setParam(session.id, "grant", persistentGrant(g.grant));
|
|
272
|
+
if (session)
|
|
273
|
+
respeed = sp.speed;
|
|
274
|
+
const transcript = path.join(runDir(node.run_id), "discussions", `${node.id}.md`);
|
|
275
|
+
const p = {
|
|
276
|
+
topic: a.topic, role, ...(a.max_turns !== undefined ? { max_turns: a.max_turns } : {}), participant: participant.id, borrowed: Boolean(session),
|
|
277
|
+
caller: within?.caller ?? callerSide(inst, to.target), other: to.target, ...(within ? { extra_rules: within.extraRules, review_id: within.reviewId } : {}),
|
|
278
|
+
state: { turns: 0, opened: false, seen: 0, shown: 0, last: {}, markers: {}, warnings: [] },
|
|
279
|
+
};
|
|
280
|
+
try {
|
|
281
|
+
fs.mkdirSync(path.dirname(transcript), { recursive: true });
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// Said by the write below.
|
|
285
|
+
}
|
|
286
|
+
transcribe(transcript, p, `# Discussion ${node.id}\n\nTopic: ${a.topic}\n\n${targetLabel(targetDef(to.target), to.target)}: ${session ? `existing session ${session.id}` : `new session ${participant.id}`}\n`, { start: true });
|
|
287
|
+
updateNode(node.id, { params_json: JSON.stringify(p), transcript_path: transcript, started_at: now() });
|
|
288
|
+
recordStart(node.id, inst, w, to.target, participant.model, runConfig(caller.runId));
|
|
289
|
+
// A review learns its reconciliation's id now, before anything is awaited, so that it can be
|
|
290
|
+
// picked up again if the session that opened it goes away.
|
|
291
|
+
if (within) {
|
|
292
|
+
const r = getNode(within.reviewId);
|
|
293
|
+
if (r)
|
|
294
|
+
updateNode(r.id, { params_json: JSON.stringify({ ...reviewParams(r), discussion: node.id }) });
|
|
295
|
+
}
|
|
296
|
+
id = node.id;
|
|
297
|
+
}
|
|
298
|
+
settleDiscussion(id);
|
|
299
|
+
const mine = parseMarker(a.message);
|
|
300
|
+
// A marker relay could not find, or found only at the end of a line, is said, so that a closing
|
|
301
|
+
// the caller meant is not passed off silently as CONTINUE.
|
|
302
|
+
const markerNote = mine.kind === "NONE"
|
|
303
|
+
? "relay found no CONTINUE, AGREE: or CRUX: on a line of its own in your message, so it was taken as CONTINUE. To agree or state a crux, put the marker on its own line at the end of your next message."
|
|
304
|
+
: mine.inline ? `relay read your ${mine.kind}${mine.kind === "CONTINUE" ? "" : ":"} from the end of your last line. Put the marker on its own line at the end next time.` : null;
|
|
305
|
+
const noted = (out) => (markerNote ? { ...out, marker_note: markerNote } : out);
|
|
306
|
+
// The message is taken in one transaction, so two calls at once cannot both send.
|
|
307
|
+
const taken = tx(() => {
|
|
308
|
+
const now_ = getNode(id);
|
|
309
|
+
if (now_.status !== "open")
|
|
310
|
+
return "ended";
|
|
311
|
+
let q = discussionParams(now_);
|
|
312
|
+
if (q.state.pending !== undefined)
|
|
313
|
+
return "busy";
|
|
314
|
+
addContribution(id, callerLabel(inst, w));
|
|
315
|
+
q = discussionParams(getNode(id));
|
|
316
|
+
q.state.turns++;
|
|
317
|
+
q.state.last[q.caller] = a.message;
|
|
318
|
+
q.state.markers[q.caller] = mine;
|
|
319
|
+
q.state.pending = RESERVED;
|
|
320
|
+
transcribe(now_.transcript_path, q, `\n## Turn ${q.state.turns} — ${q.caller}\n\n${a.message.trim()}\n`);
|
|
321
|
+
updateNode(id, { params_json: JSON.stringify(q) });
|
|
322
|
+
// A new discussion's request_id is bound here, with its opening message: a repeat (perhaps from
|
|
323
|
+
// another relay process of the same agent) then finds a reply on its way and waits for it.
|
|
324
|
+
noteCall(inst, a, id);
|
|
325
|
+
return q;
|
|
326
|
+
});
|
|
327
|
+
if (taken === "ended")
|
|
328
|
+
return { ...discussionView(id), note: "This discussion has ended, so your message was not sent." };
|
|
329
|
+
if (taken === "busy") {
|
|
330
|
+
return { ...pendingHandle(id, { discussion_id: id }, inst), not_sent: `The other side is still writing its reply to your last message, so this one was not sent. Call status with id "${id}" and wait_s, then send it.` };
|
|
331
|
+
}
|
|
332
|
+
const p = taken;
|
|
333
|
+
const d = getNode(id);
|
|
334
|
+
const other = otherSide(p);
|
|
335
|
+
if (mine.kind === "AGREE" && p.state.markers[other]?.kind === "AGREE") {
|
|
336
|
+
delete p.state.pending;
|
|
337
|
+
updateNode(id, { params_json: JSON.stringify(p) });
|
|
338
|
+
closeDiscussion(id, p, { outcome: "agree", conclusion: mine.text, closer: p.caller });
|
|
339
|
+
return noted(discussionView(id));
|
|
340
|
+
}
|
|
341
|
+
const part = getNode(p.participant);
|
|
342
|
+
const cfg = runConfig(d.run_id);
|
|
343
|
+
const parts = [];
|
|
344
|
+
if (!p.state.opened) {
|
|
345
|
+
parts.push(discussionOpening({
|
|
346
|
+
topic: p.topic, context: a.context, role: ROLE_PRESETS[p.role] ?? p.role, other: describeSide(familiesOf(d).caller, familiesOf(d).launched), resumed: p.borrowed,
|
|
347
|
+
extraRules: p.extra_rules, mayDelegate: part.allow_delegation === 1 && part.depth < cfg.max_depth, target: part.target, model: part.model, cfg,
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
else if (a.context?.length)
|
|
351
|
+
parts.push(contextBlock(a.context).trimEnd());
|
|
352
|
+
const injected = db().prepare("SELECT id, body FROM injections WHERE discussion_id = ? AND id > ? ORDER BY id").all(id, p.state.seen);
|
|
353
|
+
for (const m of injected) {
|
|
354
|
+
parts.push(`${HUMAN_LABEL}\n${m.body}`);
|
|
355
|
+
p.state.seen = m.id;
|
|
356
|
+
}
|
|
357
|
+
parts.push(`[${p.caller}'s message, verbatim]\n${a.message}`);
|
|
358
|
+
if (mine.kind === "CRUX")
|
|
359
|
+
parts.push("The other participant has stated its crux and is ending the discussion with this message. Answer once: AGREE: if you can accept a conclusion, otherwise CRUX: with yours.");
|
|
360
|
+
else if (p.max_turns !== undefined && p.state.turns + 1 >= p.max_turns)
|
|
361
|
+
parts.push("This is your final turn in this discussion. End with AGREE: or CRUX:, not CONTINUE.");
|
|
362
|
+
// A discussion turn is read-only, whatever the session did before. It is queued only while the
|
|
363
|
+
// discussion is still open, in one transaction, so a cancel cannot slip in between.
|
|
364
|
+
const turnId = tx(() => {
|
|
365
|
+
if (getNode(id)?.status !== "open")
|
|
366
|
+
return null;
|
|
367
|
+
const { turnId: t } = queueTurn(part.id, `discussion:${id}`, parts.join("\n\n"), "read", {
|
|
368
|
+
// A borrowed session settles with its own outcome again after this turn (requeue clears its error).
|
|
369
|
+
idle: (session) => {
|
|
370
|
+
if (p.borrowed && (session.kind === "job" || session.kind === "thread"))
|
|
371
|
+
recordOwnOutcome(session.id, { status: session.status, error: session.error });
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
if (respeed)
|
|
375
|
+
changeSpeed(part.id, t, respeed);
|
|
376
|
+
if (turnGrant)
|
|
377
|
+
setParam(part.id, "grant", persistentGrant(turnGrant));
|
|
378
|
+
recordEnvironmentRequest(t, turnGrant?.env);
|
|
379
|
+
p.state.opened = true;
|
|
380
|
+
p.state.pending = t;
|
|
381
|
+
updateNode(id, { params_json: JSON.stringify(p) });
|
|
382
|
+
return t;
|
|
383
|
+
});
|
|
384
|
+
if (turnId === null)
|
|
385
|
+
return noted({ ...discussionView(id), note: "This discussion has ended, so your message was not sent." });
|
|
386
|
+
const notStarted = dispatch(part.id);
|
|
387
|
+
if (notStarted)
|
|
388
|
+
return noted({ ...pendingHandle(id, { discussion_id: id }, inst), warning: notStarted });
|
|
389
|
+
const done = await waitUntil(() => settleDiscussion(id), waitOpts(inst, d.run_id, w, { progressOf: part.id, awaits: [id, ...(d.parent_id ? [d.parent_id] : [])] }));
|
|
390
|
+
if (!done)
|
|
391
|
+
return noted(pendingHandle(id, { discussion_id: id }, inst));
|
|
392
|
+
return noted(discussionView(id));
|
|
393
|
+
}
|