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
2 changes: 0 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@corbits/hub-api-client",
"@corbits/icons",
"@corbits/inbox",
"@corbits/inference-catalog",
"@corbits/inference-settings",
"@corbits/insights",
"@corbits/jimmy-agent",
Expand All @@ -43,7 +42,6 @@
"@corbits/migration-runner",
"@corbits/mocks",
"@corbits/notify",
"@corbits/ollama-adapter",
"@corbits/plugins-ui",
"@corbits/presence",
"@corbits/process-provisioner",
Expand Down
1 change: 0 additions & 1 deletion apps/hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"@corbits/granola-call-workflow": "workspace:*",
"@corbits/hub-api-client": "workspace:*",
"@corbits/inbox": "workspace:*",
"@corbits/inference-catalog": "workspace:*",
"@corbits/insights": "workspace:*",
"@corbits/last-30-days-research-workflow": "workspace:*",
"@corbits/mailbox": "github:corbitsdev/corbits-mailbox#118a2cd3b0b2d83abcd57b4bed1698e95ee41b6d",
Expand Down
33 changes: 0 additions & 33 deletions apps/hub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
} from "@intx/db";
import {
asset as assetTable,
modelPricing,
tenant as tenantTable,
user as userTable,
workflowDefinition,
Expand Down Expand Up @@ -105,11 +104,6 @@ import {
createUsageSink,
withTurnPartPersistGuard,
} from "@corbits/insights";
import {
applyInferenceCatalogMigrations,
createPostgresBenchModelPolicyStore,
createWorkflowCatalogRoutes,
} from "@corbits/inference-catalog";
import { generateId } from "@intx/hub-common";

import {
Expand Down Expand Up @@ -1706,13 +1700,6 @@ export async function createHub(config: HubConfig) {
),
}),
);
// Bench model policy migrations still run: the store itself is read
// below (tenant-session bench-model-policy read), even though the
// dedicated read/write mount is gone.
await applyInferenceCatalogMigrations(config.databaseUrl);
const benchModelPolicy = createPostgresBenchModelPolicyStore(
config.databaseUrl,
);
{
const mailboxApp = new Hono<TenantEnv>();
mountMailbox(mailboxApp, {
Expand Down Expand Up @@ -2210,26 +2197,6 @@ export async function createHub(config: HubConfig) {
listMcpServers: (tenantId) => listMcpServerConnections(db, tenantId),
}),
);
// How a running agent asks what this bench can reach for a kind of work
// (`@corbits/catalog-tools`' `list_model_concepts` / `pick_models` /
// `estimate_run_cost`): the workflow-run-authenticated counterpart to
// the tenant-session bench-model-policy mount above. Read-only, and it
// takes ports rather than a db handle, so the package never learns the
// catalog schema.
app.route(
"/api/workflow-inference-catalog",
createWorkflowCatalogRoutes({
authenticator: createWorkflowRunAuthenticator({ db }),
listOfferings: (tenantId) => listVisibleOfferings(db, tenantId),
listPricing: async (_tenantId, offeringIds) =>
offeringIds.length === 0
? []
: await db.query.modelPricing.findMany({
where: inArray(modelPricing.offeringId, [...offeringIds]),
}),
getPolicy: (tenantId) => benchModelPolicy.store.getPolicy(tenantId),
}),
);
// Notify-to-reconnect for an OAuth-connected credential whose token
// expired (Hugging Face today — see docs/onboarding-huggingface-connect.md)
// is now `workflows/credential-expiry` (CL-8181), a schedule-triggered
Expand Down
7 changes: 4 additions & 3 deletions apps/sidecar/src/workflow-substrate-factory/step-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,9 @@ export function createSidecarStepBuildEnv(
hubRoutinesUrl: deps.hubArtifactsUrl,
hubConnectionsUrl: deps.hubArtifactsUrl,
// And once more under the key `@corbits/catalog-tools` declares
// (`requires: ["hubCatalogUrl", "sidecarToken", "address"]`) for the
// inference catalog's own run-authenticated surface.
// (`requires: ["hubCatalogUrl", "tenantId", "sidecarToken",
// "address"]`) for the stock tenant model-discovery and tenant reads
// it resolves a model chain from.
hubCatalogUrl: deps.hubArtifactsUrl,
hubAgentDirectoryUrl: deps.hubArtifactsUrl,
hubChatUrl: deps.hubArtifactsUrl,
Expand All @@ -466,7 +467,7 @@ export function createSidecarStepBuildEnv(
// The run's own tenant/principal, for the tool bundles that address
// stock `/api/tenants/:tenantId/*` routes with the run bearer
// (`@corbits/access-tools`, `@corbits/connections-tools`,
// `@corbits/workflow-authoring-tools`).
// `@corbits/workflow-authoring-tools`, `@corbits/catalog-tools`).
tenantId: deps.tenantId,
principalId: deps.principalId,
};
Expand Down
27 changes: 12 additions & 15 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/catalog-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@corbits/catalog-tools",
"description": "The list_model_concepts, pick_models and estimate_run_cost tools as an @intx/agent bundle: an agent asks for a model by what the work needs and gets back an ordered, priced chain of what this bench can actually reach — never a model named by hand.",
"version": "0.0.6",
"version": "0.1.0",
"license": "LGPL-2.1-or-later",
"type": "module",
"exports": {
Expand All @@ -25,6 +25,7 @@
"test": "bun test"
},
"dependencies": {
"@corbits/inference-catalog": "0.1.0",
"arktype": "catalog:"
},
"peerDependencies": {
Expand Down
67 changes: 67 additions & 0 deletions packages/catalog-tools/src/chain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Chain resolution, in the workflow child.
//
// The two stock reads happen once per tool call and are then used for every
// question that call asks — `list_model_concepts` ranks every concept off
// one catalog read rather than one read per concept, which is what the
// deleted hub route did per request.
import {
catalogOfferingsFrom,
resolveModelChain,
type BenchModelPolicy,
type ChainNeed,
type ChainOrder,
type DiscoveredModel,
type ModelChain,
} from "@corbits/inference-catalog";

import {
fetchCatalog,
fetchModelPolicy,
type CatalogToolClientConfig,
} from "./client";

/** What this bench can reach and what it is willing to spend, read once. */
export type BenchCatalog = {
readonly models: readonly DiscoveredModel[];
readonly policy: BenchModelPolicy;
};

export async function readBenchCatalog(
config: CatalogToolClientConfig,
): Promise<BenchCatalog> {
const [models, policy] = await Promise.all([
fetchCatalog(config),
fetchModelPolicy(config),
]);
return { models, policy };
}

export function chainFor(
bench: BenchCatalog,
need: ChainNeed,
order?: ChainOrder,
limit?: number,
): ModelChain {
const { offerings, pricing } = catalogOfferingsFrom(bench.models);
return resolveModelChain({
need,
offerings,
pricing,
policy: bench.policy,
...(order !== undefined ? { order } : {}),
...(limit !== undefined ? { limit } : {}),
});
}

/** The one line that explains an otherwise puzzling chain: empty, entirely
* unpriced, or partly over this bench's ceiling. */
export function chainNote(chain: ModelChain): string | null {
if (chain.entries.length === 0) return "nothing on this bench can do that";
if (chain.entries.every((entry) => !entry.price.known)) {
return "nothing on this bench is priced yet, so cheapest-first is ordered by catalog priority";
}
if (chain.entries.some((entry) => entry.overCeiling)) {
return "some of these cost more than this bench's ceiling for that kind of work";
}
return null;
}
Loading
Loading