Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/hub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ export async function createHub(config: HubConfig) {
},
},
});
const isSidecarRoutable = (address: string) =>
sidecarRouter.getRoutableAddresses().includes(address);
// A finalized turn's persisted-artifact tool-call results become
// delivery file parts (CL-6000) via `createArtifactDeliveryHandler`,
// built once `chatStore`/`chatPlatform` exist further down this
Expand Down Expand Up @@ -2487,8 +2489,7 @@ export async function createHub(config: HubConfig) {
workflowAllocationService,
credentialCipher,
eventCollectors,
isRoutable: (address) =>
sidecarRouter.getRoutableAddresses().includes(address),
isRoutable: isSidecarRoutable,
cryptoProviderCache: cryptoProviders,
persistLaunch: async (input) => {
await workbenchLaunchPersistExtra(input)(db);
Expand Down Expand Up @@ -3303,6 +3304,7 @@ export async function createHub(config: HubConfig) {
workflowAllocationService,
sessionService,
eventCollectors,
isRoutable: isSidecarRoutable,
},
runnerInput,
),
Expand Down
54 changes: 54 additions & 0 deletions apps/hub/src/routability-wiring.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// CL-7543 follow-up: the planner's one-shot runner and the webhook
// launch path must both consult the hub's live sidecar routing table
// through the shared `isSidecarRoutable` local. A regression replacing
// either wiring with a constant (`() => true`) or dropping the hoisted
// predicate would still typecheck; this source scan is the pin, in the
// same style as `crypto-provider-cache-wiring.test.ts`.
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import path from "node:path";

const HUB_INDEX = path.join(import.meta.dir, "index.ts");

/** The full `callee(...)` text of the first call in `source`. */
function firstCall(source: string, callee: string): string {
const token = `${callee}(`;
const start = source.indexOf(token);
if (start < 0) {
throw new Error(`expected ${callee}(...) in hub index.ts`);
}
let depth = 1;
let i = start + token.length;
while (i < source.length && depth > 0) {
const ch = source[i];
if (ch === "(") depth += 1;
else if (ch === ")") depth -= 1;
i += 1;
}
return source.slice(start, i);
}

describe("hub sidecar routability wiring", () => {
test("one shared isSidecarRoutable predicate feeds both launch paths", () => {
const source = readFileSync(HUB_INDEX, "utf8");

const assigned =
/const\s+isSidecarRoutable\s*=\s*\(address:\s*string\)\s*=>\s*\n?\s*sidecarRouter\.getRoutableAddresses\(\)\.includes\(address\)/.exec(
source,
);
expect(assigned).not.toBeNull();

// Exactly one definition: no second, diverging routability source.
const definitionCount = source.match(
/getRoutableAddresses\(\)\.includes\(/g,
);
expect(definitionCount).toHaveLength(1);

expect(firstCall(source, "runOneShotPrompt")).toContain(
"isRoutable: isSidecarRoutable",
);
expect(firstCall(source, "launchWebhookTrigger")).toContain(
"isRoutable: isSidecarRoutable",
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type { TenantEnv, RequireGrant } from "@intx/hub-api";
import {
OneShotRunFailedError,
OneShotRunTimedOutError,
OneShotRunUnreachableError,
} from "./one-shot-prompt";
import { makeErrorEnvelope, reportError } from "@corbits/error-sink";
import {
Expand Down Expand Up @@ -64,6 +65,7 @@ function isDraftingFailure(err: unknown): boolean {
err instanceof MyraAgentDefinitionDraftingUnavailableError ||
err instanceof OneShotRunTimedOutError ||
err instanceof OneShotRunFailedError ||
err instanceof OneShotRunUnreachableError ||
err instanceof AgentDefinitionDraftReplyUnparseableError ||
err instanceof AgentDefinitionDraftReferenceOutOfInventoryError
);
Expand Down
1 change: 1 addition & 0 deletions packages/agent-directory/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export {
OneShotDefinitionNotFoundError,
OneShotRunTimedOutError,
OneShotRunFailedError,
OneShotRunUnreachableError,
type OneShotReply,
type OneShotRunnerDeps,
type OneShotPromptInput,
Expand Down
Loading
Loading