Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/bundled/agents/AgentBrowse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AGENT_CATALOG_KIND } from "../../features/agents/catalog-envelope";
import { ModelIcon } from "../../features/agents/ModelPicker";
import type {
AgentsClient,
RegisteredAgentType,
AgentTypeView,
} from "../../features/agents/service";
import {
type SharedAgent,
Expand Down Expand Up @@ -51,7 +51,7 @@ const pageSize = 200;
type Importing = Readonly<{
agents: AgentsClient;
/** The types an import can be, which run on this computer. */
types: readonly RegisteredAgentType[];
types: readonly AgentTypeView[];
onImported(): void;
}>;

Expand Down
14 changes: 7 additions & 7 deletions src/bundled/agents/AgentCreateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { randomAgentAvatar } from "../../features/agents/avatar-packs";
import type {
Agent,
AgentsClient,
RegisteredAgentType,
AgentTypeView,
NewAgent,
AgentCreationRequest,
AgentUpdateRequest,
Expand Down Expand Up @@ -37,12 +37,12 @@ const reveal = (element: HTMLElement | null) => {
};

/** Use each registered provider's icon in creation and library cards. */
export function TypeIcon({ type }: { type: RegisteredAgentType | undefined }) {
export function TypeIcon({ type }: { type: AgentTypeView | undefined }) {
const Icon = type?.icon ?? RobotIcon;
return <Icon size={16} aria-hidden="true" />;
}

const startingConfig = (type: RegisteredAgentType | undefined) => {
const startingConfig = (type: AgentTypeView | undefined) => {
try {
return type?.defaults().config;
} catch {
Expand All @@ -61,7 +61,7 @@ export function AgentCreateDialog({
update,
}: {
agents: AgentsClient;
types: readonly RegisteredAgentType[];
types: readonly AgentTypeView[];
community?: string | undefined;
onClose(): void;
onCreated(agent: Agent): void;
Expand Down Expand Up @@ -91,7 +91,7 @@ export function AgentCreateDialog({
"",
);
const type = types.find((item) => item.key === typeKey) ?? types[0];
const migration = (item: RegisteredAgentType | undefined) => {
const migration = (item: AgentTypeView | undefined) => {
if (!edited || !item || item.key === edited.type) return undefined;
try {
return agents.previewRetype(edited.key, item.key);
Expand All @@ -100,7 +100,7 @@ export function AgentCreateDialog({
}
};
/** The agent's settings in `item`, with the requested instructions. */
const seed = (item: RegisteredAgentType | undefined) => {
const seed = (item: AgentTypeView | undefined) => {
if (!update) return startingConfig(item);
const { agent, request } = update;
const config =
Expand All @@ -126,7 +126,7 @@ export function AgentCreateDialog({
const Create = type?.Create;
const Model = type?.CreateModel;
const close = () => setOpen(false);
const chooseModel = (item: RegisteredAgentType, next: unknown) => {
const chooseModel = (item: AgentTypeView, next: unknown) => {
setTypeKey(item.key);
setConfig(next);
setDirty(true);
Expand Down
6 changes: 3 additions & 3 deletions src/bundled/agents/AgentDefaults.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
import type {
AgentsClient,
RegisteredAgentType,
AgentTypeView,
} from "../../features/agents/service";
import {
ContributionBoundary,
Expand Down Expand Up @@ -68,8 +68,8 @@ function ProviderDefaults({
type,
provider,
}: {
type: RegisteredAgentType;
provider: NonNullable<RegisteredAgentType["provider"]>;
type: AgentTypeView;
provider: NonNullable<AgentTypeView["provider"]>;
}) {
const state = useSyncExternalStore(
provider.subscribe,
Expand Down
6 changes: 3 additions & 3 deletions src/bundled/agents/AgentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
Agent,
AgentsClient,
AgentConversation,
RegisteredAgentType,
AgentTypeView,
} from "../../features/agents/service";
import {
AgentArchiveRetry,
Expand Down Expand Up @@ -71,8 +71,8 @@ export function AgentDetails({
}: {
agents: AgentsClient;
agent: Agent;
type: RegisteredAgentType | undefined;
types: readonly RegisteredAgentType[];
type: AgentTypeView | undefined;
types: readonly AgentTypeView[];
channels: readonly ChannelChoice[];
memories: AgentMemories | undefined;
onRemoved(): void;
Expand Down
30 changes: 15 additions & 15 deletions src/bundled/agents/AgentSettingsHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
AgentSettingsHost,
AgentsClient,
Carry,
RegisteredAgentType,
AgentTypeView,
} from "../../features/agents/service";
import { ArrowRightIcon } from "../../shared/design-system/icons";
import { Button } from "../../shared/design-system/ui/Button";
Expand All @@ -28,21 +28,21 @@ const message = (error: unknown) =>
export function useAgentSettingsHost(options: {
agents: AgentsClient;
agent: Agent;
type: RegisteredAgentType | undefined;
types: readonly RegisteredAgentType[];
type: AgentTypeView | undefined;
types: readonly AgentTypeView[];
}): {
agent: Agent;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
settingsHost: AgentSettingsHost;
};
export function useAgentSettingsHost(options: {
agents: AgentsClient | undefined;
agent: Agent | undefined;
type: RegisteredAgentType | undefined;
types: readonly RegisteredAgentType[];
type: AgentTypeView | undefined;
types: readonly AgentTypeView[];
}): {
agent: Agent | undefined;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
settingsHost: AgentSettingsHost | undefined;
};
export function useAgentSettingsHost({
Expand All @@ -53,11 +53,11 @@ export function useAgentSettingsHost({
}: {
agents: AgentsClient | undefined;
agent: Agent | undefined;
type: RegisteredAgentType | undefined;
types: readonly RegisteredAgentType[];
type: AgentTypeView | undefined;
types: readonly AgentTypeView[];
}): {
agent: Agent | undefined;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
settingsHost: AgentSettingsHost | undefined;
} {
const [pendingType, setPendingType] = useState<{
Expand Down Expand Up @@ -126,8 +126,8 @@ function TypeField({
}: {
agents: AgentsClient;
agent: Agent;
type: RegisteredAgentType | undefined;
types: readonly RegisteredAgentType[];
type: AgentTypeView | undefined;
types: readonly AgentTypeView[];
dirty: boolean;
selected: string;
onSelect(type: { key: string; config: unknown } | undefined): void;
Expand All @@ -142,7 +142,7 @@ function TypeField({
const [checking, setChecking] = useState(false);
const [configuring, setConfiguring] = useState(false);
const [migration, setMigration] = useState<{
target: RegisteredAgentType;
target: AgentTypeView;
preview: ReturnType<AgentsClient["previewRetype"]>;
}>();
const choose = (next: string) => {
Expand Down Expand Up @@ -310,8 +310,8 @@ export function MigrationPreview({
preview,
discardDraft,
}: {
source: RegisteredAgentType | undefined;
target: RegisteredAgentType;
source: AgentTypeView | undefined;
target: AgentTypeView;
preview: ReturnType<AgentsClient["previewRetype"]>;
discardDraft: boolean;
}) {
Expand Down
4 changes: 2 additions & 2 deletions src/bundled/agents/AgentTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
AgentConversation,
AgentSettingsHost,
AgentsClient,
RegisteredAgentType,
AgentTypeView,
} from "../../features/agents/service";
import type { AgentMemories } from "../../features/agents/MemoryPanel";
import { agentSections } from "../../features/agents/tabs";
Expand All @@ -15,7 +15,7 @@ import { Tabs } from "../../shared/design-system/ui/Tabs";
export function AgentTabs(props: {
agents: AgentsClient;
agent: Agent;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
channels: readonly ChannelChoice[];
settingsHost: AgentSettingsHost;
memories: AgentMemories | undefined;
Expand Down
12 changes: 6 additions & 6 deletions src/bundled/agents/AgentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import type {
Agent,
AgentsClient,
FoundAgents,
RegisteredAgentType,
AgentTypeView,
Team,
TeamPort,
} from "../../features/agents/service";
Expand Down Expand Up @@ -99,7 +99,7 @@ const message = (error: unknown) =>
error instanceof Error ? error.message : String(error);

/** The type's one-line summary of an agent; its title when it has none. */
function summaryOf(agent: Agent, type: RegisteredAgentType | undefined) {
function summaryOf(agent: Agent, type: AgentTypeView | undefined) {
if (agent.place === "elsewhere") return "On another device";
if (agent.unfinished) return "Setup unfinished";
if (!type) return "Type unavailable";
Expand Down Expand Up @@ -614,7 +614,7 @@ type InventoryProps = {
service: AgentsClient;
agents: readonly Agent[];
selected: string | undefined;
typeOf(agent: Agent): RegisteredAgentType | undefined;
typeOf(agent: Agent): AgentTypeView | undefined;
onSelect(pubkey?: string): void;
onBuild(pubkey: string): void;
newAgent: ReactNode;
Expand Down Expand Up @@ -862,7 +862,7 @@ function InventoryCard({
}: Omit<React.ComponentProps<typeof AgentCard>, "agent"> & {
agent: Agent;
service: AgentsClient;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
onBuild(): void;
onRemoved(): void;
/** Whether it is the community's main agent and can be made it. */
Expand Down Expand Up @@ -1026,7 +1026,7 @@ function AgentPeek({
}: {
agents: AgentsClient;
agent: Agent;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
channels: readonly ChannelChoice[];
onClose(): void;
}) {
Expand Down Expand Up @@ -1165,7 +1165,7 @@ function ImportAgents({
onPendingChange,
}: {
agents: AgentsClient;
types: readonly RegisteredAgentType[];
types: readonly AgentTypeView[];
/** The section its entry point imports. */
only: "agents" | "teams";
onImported(): void;
Expand Down
8 changes: 4 additions & 4 deletions src/bundled/agents/ProviderDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProviderDialogFooter } from "../../features/agents/ProviderDialogActions";
import { useState, useSyncExternalStore, type RefObject } from "react";
import type { RegisteredAgentType } from "../../features/agents/service";
import type { AgentTypeView } from "../../features/agents/service";
import {
ContributionBoundary,
contributionKey,
Expand All @@ -12,7 +12,7 @@ export function ProviderDialog({
finalFocus,
onClose,
}: {
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
finalFocus: RefObject<HTMLButtonElement | null>;
onClose(): void;
}) {
Expand Down Expand Up @@ -51,8 +51,8 @@ function ManagedProviderDialog({
finalFocus,
onClose,
}: {
type: RegisteredAgentType;
provider: NonNullable<RegisteredAgentType["provider"]>;
type: AgentTypeView;
provider: NonNullable<AgentTypeView["provider"]>;
finalFocus: RefObject<HTMLButtonElement | null>;
onClose(): void;
}) {
Expand Down
32 changes: 31 additions & 1 deletion src/features/agents/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,8 +1193,37 @@ export type Agents = {
/** What the app's screens use of the agents. It leaves out what only running
* agents and plugin entries use (registration, tools, wakes, relay access,
* storage), so agents can later run in another page with screens as clients. */
/** An agent type as screens see it: what it shows, its config functions, and
* the reads and calls screens make. Its runtime (`run`, `runOnce`, hosted
* provisioning, session listing and `expose`) stays with the service. */
export type AgentTypeView<Config = unknown> = Contribution<
Pick<
AgentType<Config>,
| "id"
| "title"
| "description"
| "icon"
| "Peek"
| "Create"
| "CreateModel"
| "tabs"
| "provider"
| "models"
| "usage"
| keyof AgentTypeConfig
> &
Readonly<{
/** Present when the type is hosted. */
remote?: object;
sessionControls?: Pick<
NonNullable<AgentType<Config>["sessionControls"]>,
"scope" | "subscribe"
>;
}>
>;
export type AgentsClient = Omit<
Agents,
| "types"
| "addAttentionSource"
| "attentionProviders"
| "register"
Expand All @@ -1207,7 +1236,8 @@ export type AgentsClient = Omit<
| "core"
| "storage"
| "note"
>;
> &
Readonly<{ types(): readonly AgentTypeView[] }>;
declare module "@deepseek-ai/cordis" {
interface Context {
agents: Agents;
Expand Down
4 changes: 2 additions & 2 deletions src/features/agents/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
AgentConversation,
AgentSettingsHost,
AgentsClient,
RegisteredAgentType,
AgentTypeView,
} from "./service";
import { AgentSaveButton } from "./AgentSaveButton";

Expand All @@ -36,7 +36,7 @@ export function agentSections({
}: {
agents: AgentsClient;
agent: Agent;
type: RegisteredAgentType | undefined;
type: AgentTypeView | undefined;
channels: readonly ChannelChoice[];
conversation?: AgentConversation | undefined;
settingsHost?: AgentSettingsHost;
Expand Down
Loading