Multiplayer agent harness for work.
import type { SlackWebClientFactory } from "../slack/web-client.ts";
import type { TeamStore } from "../teams/teams.ts";
import type { DecisionStore } from "../decisions/store.ts";
import type { ExternalSlackPolicies } from "../resolution/external-slack.ts";
import type { ProviderKeys } from "../harness/pi-harness.ts";
import type { ModelGatewayTransportConfig } from "../model/provider-endpoints.ts";
import type { DurableMap } from "../persistence/durable-map.ts";
import type { BackgroundOwnershipControl } from "../runs/background-ownership.ts";
import type { LoopIngressService } from "../loops/ingress.ts";
import type { createSuggestedActivityService } from "../suggestions/activities.ts";
import type { ManagedSlack } from "../surfaces/slack-managed.ts";
import type { InboxSourceRefresh } from "../loops/inbox-source-refresh.ts";
import type { BrokerSessionStore } from "../auth/broker-sessions.ts";
import type { DirectFileUploads } from "../files/direct-file-upload.ts";
import type { SandboxResources } from "../sandbox/sandbox-resources.ts";
import type { ModelVerifier } from "../model/model-verification.ts";
import type { DurableByteStore } from "../files/durable-byte-store.ts";
import type { SessionShareStore } from "../sessions/session-share.ts";
import type { ModelOverlayStore } from "../model/model-overlay-store.ts";
import type { ModelProvider, ModelProviderAvailability } from "../model/pi-models.ts";
import type { ModelCredentialStore } from "../model/model-credential-store.ts";
import type { UserModelCredentialStore } from "../model/user-model-credential-store.ts";
import type { CustomProviderStore } from "../model/custom-provider-store.ts";
import type { McpServerStore } from "../mcp/mcp-server-store.ts";
import type { McpToolService } from "../mcp/mcp-tool-service.ts";
import type { ReplayDedupe } from "../auth/replay-dedupe.ts";
import type { FetchLike, OAuthClientResolver } from "../connectors/oauth.ts";
import type { ConsentLinkStore } from "../connectors/consent-link.ts";
import type { OAuthFlowStore } from "../connectors/oauth-flow-store.ts";
import type { OrgBranding, ScopedConfigStore } from "../resolution/config-store.ts";
import type { AclStore } from "../acl/acl-store.ts";
import type { CredentialUsageSink } from "../admin/credential-usage-sink.ts";
import type { EgressAuditSink } from "../admin/egress-audit-sink.ts";
import type { BrokerFetch } from "./credential-broker.ts";
import type { GitHttpFetch } from "./git-http-broker.ts";
import type { KeychainApprovals } from "../credentials/keychain-approval.ts";
import type { AdminService } from "../admin/admin-service.ts";
import type { Mailer } from "../../plugins/chassis/src/resend.ts";
import type { SessionStore } from "../sessions/session-store.ts";
import type { SecurityScreenProbe } from "../security/security-screener.ts";
import type { AuditLog } from "../audit/audit-log.ts";
import type { ErrorLog } from "../admin/error-log.ts";
import type { RunStore } from "../runs/run-store.ts";
import type { RunSignalStore } from "../runs/run-signal-store.ts";
import type { WorkspaceStore } from "../workspace/workspace-store.ts";
import type { FileArtifactStore } from "../files/file-artifact-store.ts";
import type { MemoryService } from "../memory/memory-service.ts";
import type { EgressEnforcement, Sandbox } from "../sandbox/sandbox.ts";
import type { EnvironmentStore } from "../environments/environment-store.ts";
import type { Scheduler } from "../cron/scheduler.ts";
import type { WebhookReceiver } from "../webhooks/webhook-receiver.ts";
import type { IdentityService } from "../identity/identity-service.ts";
import type { PrincipalLinkService } from "../identity/principal-links.ts";
import type { FeatureFlagStore } from "../feature-flags.ts";
import type {
ConnectorTokenStore,
Keychain,
KeychainAsk,
KeychainGrant,
ServiceCredentialStore,
} from "../credentials/keychain.ts";
import type { SecretDropStore } from "../credentials/secret-drop.ts";
import type { DropResolution } from "../triggers/keychain-ask.ts";
import type { BlobTransferStore } from "../persistence/blob-transfer.ts";
import type { DeliveryStore } from "../delivery/delivery-store.ts";
import type { ControlService } from "./control-service.ts";
import type { LoopServiceDeps } from "./routes/loops.ts";
import type { CronStore } from "../cron/cron-store.ts";
import type { ProcessRegistry } from "../processes/process-registry.ts";
import type { BrowserSessionStore } from "../connectors/browser-session-store.ts";
import type { DirectoryStore } from "../directory/directory-store.ts";
import type { DeploymentLayerStore } from "../deployment/deployment-layer-store.ts";
import type { AmbientJudgmentStore } from "../surface-cache/ambient-judgment-store.ts";
import type { AckEmojiPickStore } from "../surface-cache/ack-emoji-pick-store.ts";
import type { ChannelPolicyStore } from "../surface-cache/channel-policy-store.ts";
import type { UiStateStore } from "../surfaces/ui-state.ts";
import type { SessionStateBus } from "../runs/session-state-bus.ts";
import type { ConnectorTokenSource, SlackUserClient } from "../loops/sources/adapter.ts";
import type { RateLimiter } from "../ratelimit/rate-limiter.ts";
import type { AdvisoryLock } from "../persistence/advisory-lock.ts";
import type { AppPageViewLog } from "../deploy/page-views.ts";
import type { SlackInstallationStore, SlackSocketAppIdReader } from "../surfaces/slack-installation.ts";
import type { SlackAccountLink, ComposioReturn } from "./routes/composio.ts";
export interface ServerDeps {
externalSlackPolicies?: ExternalSlackPolicies;
checkReadiness?: (signal: AbortSignal) => Promise<void>;
browserModelGateway?: ModelGatewayTransportConfig;
resolveBrowserCompanyKeys?: (includeSubscription?: boolean) => Promise<ProviderKeys>;
slackAccounts?: DurableMap<SlackAccountLink>;
composioReturns?: DurableMap<ComposioReturn>;
composioFetch?: typeof fetch;
suggestedActivities?: ReturnType<typeof createSuggestedActivityService>;
production?: boolean;
allowUnauthenticatedCore?: boolean;
signingSecret?: string;
capabilitySecret?: string;
capabilityTokenCompression?: boolean;
portalIdentitySecret?: string;
requireSignedPortalIdentity?: boolean;
control: ControlService;
replayDedupe?: ReplayDedupe;
deploymentLiveSmoke?: () => Promise<void>;
brokerSessions?: BrokerSessionStore;
connectorTokens?: ConnectorTokenStore;
managedSlack?: ManagedSlack;
slackInstallation?: SlackInstallationStore;
slackInstallationFetch?: typeof fetch;
slackWebClient?: SlackWebClientFactory;
slackInstallationSocketAppId?: SlackSocketAppIdReader;
slackEnvironmentState?: "absent" | "configured" | "partial";
slackEventsPort?: number;
slackEnvBotToken?: string;
oauthStateSecret?: string;
oauthFetch?: FetchLike;
oauthEnv?: NodeJS.ProcessEnv;
resolveClient?: OAuthClientResolver;
consentLinks?: ConsentLinkStore;
oauthFlows?: OAuthFlowStore;
apiBaseUrl?: string;
publicUrl?: string;
portalUrl?: string;
config?: ScopedConfigStore;
acl?: AclStore;
credentialUsage?: CredentialUsageSink;
featureFlags?: FeatureFlagStore;
teams?: TeamStore;
decisions?: DecisionStore;
egressAudit?: EgressAuditSink;
brokerFetch?: BrokerFetch;
gitHttpFetch?: GitHttpFetch;
baseModelDefault?: string;
modelProviders?: ModelProviderAvailability;
providerKeys?: ModelProviderAvailability;
modelCredentials?: ModelCredentialStore;
userModelCredentials?: UserModelCredentialStore;
mcpServers?: McpServerStore;
mcpToolService?: McpToolService;
modelCredentialFetch?: typeof fetch;
modelRegistry?: ModelOverlayStore;
modelVerifier?: ModelVerifier;
refreshModels?: () => Promise<void>;
customProviders?: CustomProviderStore;
refreshCustomProviders?: () => Promise<void>;
brandingDefault?: OrgBranding;
harnessId?: string;
harnessCarriedModelAuth?: ModelProvider;
admin?: AdminService;
inviteMailer?: Mailer;
emailAuthPrincipals?: readonly string[];
emailAuthDomain?: string;
slackAllowFrom?: readonly string[];
rateLimiter?: RateLimiter;
sessions?: SessionStore;
screenSecurity?: SecurityScreenProbe;
auditLog?: AuditLog;
errors?: ErrorLog;
crons?: CronStore;
loops?: LoopServiceDeps;
runs?: RunStore;
signals?: RunSignalStore;
sessionStateBus?: SessionStateBus;
workspace?: WorkspaceStore;
files?: FileArtifactStore;
fileUploads?: DirectFileUploads;
filesDirectUploadsEnabled?: boolean;
memory?: MemoryService;
sandboxBackend?: string;
egressDeclaredEnforcement?: EgressEnforcement;
egressEnforcement?: EgressEnforcement;
egressControlPlaneConfigured?: boolean;
sandboxResources?: SandboxResources;
sandbox?: Sandbox;
advisoryLock?: AdvisoryLock;
processes?: ProcessRegistry;
browserSessionStore?: BrowserSessionStore;
directory?: DirectoryStore;
ambientJudgments?: AmbientJudgmentStore;
ackEmojiPicks?: AckEmojiPickStore;
channelPolicy?: ChannelPolicyStore;
uiState?: UiStateStore;
loopSourceTokens?: ConnectorTokenSource;
inboxSourceRefresh?: InboxSourceRefresh;
loopSlackClient?: (token: string) => SlackUserClient;
sessionShares?: SessionShareStore;
sessionShareBytes?: DurableByteStore;
environments?: EnvironmentStore;
deploymentLayer?: DeploymentLayerStore;
backgroundOwnership?: BackgroundOwnershipControl;
deploymentControlSecret?: string;
spendExportToken?: string;
deployDialTimeoutMs?: number;
deployAppsDomain?: string;
deployGateSecret?: string;
deployAppsSessionSecret?: string;
deployAppsLoginUrl?: string;
deployAppsLoginPath?: "/auth/login" | "/auth/trusted/login";
appPageViews?: AppPageViewLog;
scheduler?: Scheduler;
webhookReceiver?: WebhookReceiver;
loopIngress?: LoopIngressService;
identity?: IdentityService;
principalLinks?: PrincipalLinkService;
keychain?: Keychain;
serviceCreds?: ServiceCredentialStore;
deliveries?: DeliveryStore;
keychainApprovals?: KeychainApprovals;
fireAskResolution?: (ask: KeychainAsk, grant?: KeychainGrant) => Promise<unknown>;
secretDrops?: SecretDropStore;
fireDropResolution?: (drop: DropResolution) => Promise<unknown>;
blobTransfer?: BlobTransferStore;
}