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
1 change: 1 addition & 0 deletions apps/hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@chat-adapter/state-memory": "^4.35.0",
"@corbits/agent-directory": "workspace:*",
"@corbits/agent-lifecycle": "workspace:*",
"@corbits/agent-runtime": "workspace:*",
"@corbits/approvals": "workspace:*",
"@corbits/artifacts": "github:corbitsdev/corbits-artifacts#dc435ba749b4378f19e5de772159c2a57e932938",
"@corbits/artifacts-hub": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// up here, not only when a real workbench host tries to use it.
import { describe, expect, test } from "bun:test";
import { type } from "arktype";
import { createNoopInferenceRoutes } from "../src/noop-inference";
import { createNoopInferenceRoutes } from "./noop-inference";

const ContentBlockDelta = type({
type: "'content_block_delta'",
Expand Down
12 changes: 12 additions & 0 deletions apps/hub/src/grant-conditions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { timeWindowEvaluator } from "@intx/authz";
import type { ConditionRegistry } from "@intx/types/authz";

/**
* Grant conditions the hub evaluates on every mount that takes a
* `conditionRegistry`. Nothing here is chat-specific: `time_window` is
* `@intx/authz`'s own evaluator, matching the default `mountHubRoutes`
* builds when no registry is supplied.
*/
export const grantConditionRegistry: ConditionRegistry = {
time_window: timeWindowEvaluator,
};
64 changes: 30 additions & 34 deletions apps/hub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import {
createEnvKeyCredentialCipher,
createNoopCredentialCipher,
} from "@intx/crypto";
import { timeWindowEvaluator } from "@intx/authz";
import type { ConditionRegistry } from "@intx/types/authz";
import type { CredentialCipher } from "@intx/types";
import {
createApp,
Expand All @@ -50,27 +48,18 @@ import { isPlannerCreatedDefinitionName } from "@corbits/agent-directory";

import {
DEFAULT_TURN_CLAIM_TTL_MS,
createArtifactDeliveryHandler,
createDrizzleAgentTurnStore,
createInMemoryTurnClaimStore,
createWorkbenchHostInferencePreferencesResolver,
createWorkbenchSubscriberRegistry,
createWorkbenchTurnQueue,
createTurnCancelRegistry,
createChatOrchestrator,
createChatRoutes,
createDrizzleBlockResponseStore,
createDrizzleChatStore,
createDrizzleClientIdStore,
createDrizzleNativePrincipalStore,
createDrizzlePinStore,
createDrizzleReactionStore,
createDrizzleRoomMessageStore,
createDrizzleThreadStore,
createDrizzleTurnMailCorrelationStore,
createDrizzleWriteClaimStore,
createHubChatPlatform,
createNoopInferenceRoutes,
createRelaunchNoticePoster,
createRunTriggerClient,
createWorkflowParticipantRoutes,
Expand All @@ -83,6 +72,16 @@ import {
tagCredentialCipher,
verifyInternalRunTriggerToken,
} from "@corbits/chat";
import {
createArtifactDeliveryHandler,
createChatOrchestrator,
createDrizzleAgentTurnStore,
createDrizzleClientIdStore,
createDrizzleTurnMailCorrelationStore,
createDrizzleWriteClaimStore,
createInMemoryTurnClaimStore,
createWorkbenchTurnQueue,
} from "@corbits/agent-runtime";
import {
createDrizzleMailboxWriter,
type MailboxFanoutDeps,
Expand Down Expand Up @@ -173,6 +172,8 @@ import {
} from "@intx/hub-sessions";
import { createLaunchCaches } from "./launch-caches";
import { hubErrorHandler } from "./hub-error-handler";
import { grantConditionRegistry } from "./grant-conditions";
import { createNoopInferenceRoutes } from "./e2e/noop-inference";
import { wireMailRedelivery } from "./mail-redelivery";
import { getLogger, setup } from "@intx/log";
import { hexEncode } from "@intx/types";
Expand Down Expand Up @@ -1152,16 +1153,11 @@ export async function createHub(config: HubConfig) {
// Presence rooms are ephemeral and process-local by design.
const presenceRoomRegistry = createPresenceRoomRegistry();

// Chat's own grant store/condition registry, built the same way
// `createApp` builds its default when none is supplied (see
// `@intx/hub-api`'s `mountHubRoutes`): a db-backed grant store and
// the time-window condition evaluator. `createRequireGrant` is the
// published construction the platform's own internal instance is
// not exported for.
// The hub's own grant store, built the same way `createApp` builds its
// default when none is supplied (see `@intx/hub-api`'s
// `mountHubRoutes`). `createRequireGrant` is the published construction
// the platform's own internal instance is not exported for.
const chatGrantStore = createGrantStore(db);
const chatConditionRegistry: ConditionRegistry = {
time_window: timeWindowEvaluator,
};
// CL-6345: arm the grant-allowance gate declared up at `lookups`. The
// one annotation today is `mcp_call` (registered under both its bare
// and pinned-namespaced names): a downstream MCP tool the server
Expand Down Expand Up @@ -1213,7 +1209,7 @@ export async function createHub(config: HubConfig) {
};
},
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
approvalStore: createApprovalStore(db),
signalCorrelationStore: createSignalCorrelationStore(db),
},
Expand All @@ -1229,7 +1225,7 @@ export async function createHub(config: HubConfig) {
registry: presenceRoomRegistry,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
}),
);
Expand Down Expand Up @@ -1555,7 +1551,7 @@ export async function createHub(config: HubConfig) {
turnCancellation,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
isInvitableDefinition: isPickerListableDefinition,
turnTimeoutMs: DEFAULT_TURN_CLAIM_TTL_MS,
Expand Down Expand Up @@ -1662,7 +1658,7 @@ export async function createHub(config: HubConfig) {
store: insightsUsage.store,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
runTraceReader: createDrizzleRunTraceReader(db),
latencyStore: insightsLatency.store,
Expand All @@ -1687,7 +1683,7 @@ export async function createHub(config: HubConfig) {
db,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
}),
);
Expand All @@ -1703,7 +1699,7 @@ export async function createHub(config: HubConfig) {
db,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
runNow: async (args) =>
runNowScheduledDefinition(
Expand Down Expand Up @@ -1738,7 +1734,7 @@ export async function createHub(config: HubConfig) {
store: evalRuns.store,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
}),
);
Expand Down Expand Up @@ -1879,7 +1875,7 @@ export async function createHub(config: HubConfig) {
assetService,
repoStore: agentRepoStore.repoStore,
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
}),
);
Expand All @@ -1889,7 +1885,7 @@ export async function createHub(config: HubConfig) {
registry: commandRegistry,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
workbenchBelongsToTenant: async (tenantId, chatId) =>
(await chatStore.getWorkbenchSettings(tenantId, chatId)) !==
Expand Down Expand Up @@ -1918,7 +1914,7 @@ export async function createHub(config: HubConfig) {
store: webhookTriggerStore,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
workflowDefinitionInTenant: async (tenantId, definitionId) => {
const row = await db.query.workflowDefinition.findFirst({
Expand Down Expand Up @@ -2012,7 +2008,7 @@ export async function createHub(config: HubConfig) {
registry: CONNECTOR_REGISTRY,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
log: (line) => log.info`${line}`,
// Same env bag the OAuth connect flow itself reads below, so
Expand Down Expand Up @@ -2108,7 +2104,7 @@ export async function createHub(config: HubConfig) {
createCatalogBlockRoutes({
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
log: (line) => log.info`${line}`,
inferencePreferences: (tenantId) =>
Expand Down Expand Up @@ -2197,7 +2193,7 @@ export async function createHub(config: HubConfig) {
hubUrl: config.baseUrl,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
log: (line) => log.info`${line}`,
presets: MCP_PRESETS,
Expand All @@ -2214,7 +2210,7 @@ export async function createHub(config: HubConfig) {
hubUrl: config.baseUrl,
requireGrant: createRequireGrant({
grantStore: chatGrantStore,
conditionRegistry: chatConditionRegistry,
conditionRegistry: grantConditionRegistry,
}),
log: (line) => log.info`${line}`,
credentialCipher,
Expand Down
29 changes: 29 additions & 0 deletions bun.lock

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

14 changes: 13 additions & 1 deletion packages/agent-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,24 @@
"test": "bun test"
},
"dependencies": {
"@corbits/agent-events": "workspace:*",
"@corbits/approvals": "workspace:*",
"@corbits/chat": "workspace:*",
"@corbits/collections": "workspace:*",
"@corbits/connections": "workspace:*",
"@corbits/error-sink": "workspace:*",
"@corbits/memory": "github:corbitsdev/corbits-memory#9e6f213fa2c002b531d3f6af1aa0abd737b8afe3",
"@corbits/turn-artifacts": "workspace:*",
"@corbits/workflows": "workspace:*",
"@intx/agent": "workspace:*",
"@intx/db": "workspace:*",
"@intx/hub-sessions": "workspace:*",
"@intx/log": "0.3.0",
"@intx/types": "workspace:*",
"@intx/workflow": "workspace:*",
"@intx/workflow-deploy": "workspace:*",
"arktype": "catalog:"
"arktype": "catalog:",
"drizzle-orm": "catalog:"
},
"devDependencies": {
"@types/bun": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
} from "@corbits/agent-runtime";
import { and, asc, desc, eq, inArray, lt, sql } from "drizzle-orm";

import { agentTurns } from "./schema";
import type { ChatDb } from "./store";
import { agentTurns } from "@corbits/chat/schema";
import type { ChatDb } from "@corbits/chat/store";
import { CHAT_TURN_TIMEOUT_MS } from "./turn-claims";

export type AgentTurnStatus = "running" | "completed" | "failed" | "cancelled";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type PersistedArtifact,
} from "@corbits/turn-artifacts";

import type { FilePart } from "./parts";
import type { FilePart } from "@corbits/chat/parts";

function mediaTypeForArtifactKind(kind: string): string {
return kind === "text" ? "text/plain" : "application/octet-stream";
Expand Down
Loading
Loading