Rebuild AgentCompany Electron app
This commit is contained in:
1 parent
bc5daa6eb8
commit
fcf6d90731
56 files changed
+8667
No files matched your search
@@ -0,0 +1,106 @@
|
||||
import type {
|
||||
ApprovalState,
|
||||
RiskLevel,
|
||||
SocialPlatform,
|
||||
TaskStatus,
|
||||
} from "./domain";
|
||||
|
||||
export interface CreateOrganizationInput {
|
||||
organizationName: string;
|
||||
mission: string;
|
||||
goal: string;
|
||||
employeeName: string;
|
||||
}
|
||||
|
||||
export interface CreateAgentInput {
|
||||
orgId: string;
|
||||
name: string;
|
||||
role: string;
|
||||
department: string;
|
||||
modelProviderId: string | null;
|
||||
modelId: string | null;
|
||||
budgetCents: number;
|
||||
managerAgentId: string | null;
|
||||
}
|
||||
|
||||
export interface CreateTaskInput {
|
||||
orgId: string;
|
||||
title: string;
|
||||
description: string;
|
||||
status: TaskStatus;
|
||||
assigneeAgentId: string | null;
|
||||
risk: RiskLevel;
|
||||
}
|
||||
|
||||
export interface UpdateTaskStatusInput {
|
||||
orgId: string;
|
||||
taskId: string;
|
||||
status: TaskStatus;
|
||||
}
|
||||
|
||||
export interface CreateApprovalInput {
|
||||
orgId: string;
|
||||
kind: string;
|
||||
title: string;
|
||||
details: string;
|
||||
risk: RiskLevel;
|
||||
requestedByType: "employee" | "agent" | "system";
|
||||
requestedById: string | null;
|
||||
}
|
||||
|
||||
export interface DecideApprovalInput {
|
||||
orgId: string;
|
||||
approvalId: string;
|
||||
state: Extract<ApprovalState, "approved" | "declined">;
|
||||
decidedByEmployeeId: string;
|
||||
}
|
||||
|
||||
export interface SendMessageInput {
|
||||
orgId: string;
|
||||
spaceId: string;
|
||||
threadId: string | null;
|
||||
senderType: "employee" | "agent" | "board" | "system";
|
||||
senderId: string | null;
|
||||
bodyMd: string;
|
||||
}
|
||||
|
||||
export interface SaveProviderCredentialInput {
|
||||
orgId: string;
|
||||
providerId: string;
|
||||
secret: string;
|
||||
model: string | null;
|
||||
}
|
||||
|
||||
export interface ImportSkillDirectoryInput {
|
||||
orgId: string;
|
||||
directoryPath: string;
|
||||
versionSemver: string;
|
||||
}
|
||||
|
||||
export interface BindSkillInput {
|
||||
orgId: string;
|
||||
agentId: string;
|
||||
skillId: string;
|
||||
revisionId: string;
|
||||
}
|
||||
|
||||
export interface CreateSocialAccountInput {
|
||||
orgId: string;
|
||||
platform: SocialPlatform;
|
||||
handle: string;
|
||||
displayName: string;
|
||||
authorizedEmployeeId: string | null;
|
||||
}
|
||||
|
||||
export interface LaunchSocialLoginInput {
|
||||
socialAccountId: string;
|
||||
}
|
||||
|
||||
export interface ImportFileInput {
|
||||
orgId: string;
|
||||
}
|
||||
|
||||
export interface NativeDialogResult {
|
||||
canceled: boolean;
|
||||
filePaths: string[];
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { DesktopResult } from "./result";
|
||||
import type { AppSnapshot } from "./domain";
|
||||
import type {
|
||||
BindSkillInput,
|
||||
CreateAgentInput,
|
||||
CreateApprovalInput,
|
||||
CreateOrganizationInput,
|
||||
CreateSocialAccountInput,
|
||||
CreateTaskInput,
|
||||
DecideApprovalInput,
|
||||
ImportFileInput,
|
||||
ImportSkillDirectoryInput,
|
||||
LaunchSocialLoginInput,
|
||||
SaveProviderCredentialInput,
|
||||
SendMessageInput,
|
||||
UpdateTaskStatusInput,
|
||||
} from "./commands";
|
||||
|
||||
export interface RendererEvent {
|
||||
type: "snapshot-changed";
|
||||
}
|
||||
|
||||
export interface DesktopApi {
|
||||
loadSnapshot(): Promise<DesktopResult<AppSnapshot>>;
|
||||
createOrganization(input: CreateOrganizationInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
createAgent(input: CreateAgentInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
createTask(input: CreateTaskInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
updateTaskStatus(input: UpdateTaskStatusInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
createApproval(input: CreateApprovalInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
decideApproval(input: DecideApprovalInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
sendMessage(input: SendMessageInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
saveProviderCredential(input: SaveProviderCredentialInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
importSkillDirectory(input: ImportSkillDirectoryInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
bindSkill(input: BindSkillInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
createSocialAccount(input: CreateSocialAccountInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
launchSocialLogin(input: LaunchSocialLoginInput): Promise<DesktopResult<null>>;
|
||||
importFile(input: ImportFileInput): Promise<DesktopResult<AppSnapshot>>;
|
||||
subscribe(callback: (event: RendererEvent) => void): () => void;
|
||||
platform: "win32" | "darwin" | "linux";
|
||||
windowMinimize(): Promise<void>;
|
||||
windowMaximize(): Promise<void>;
|
||||
windowClose(): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
export const TASK_STATUS = {
|
||||
BACKLOG: "backlog",
|
||||
IN_PROGRESS: "in_progress",
|
||||
REVIEW: "review",
|
||||
DONE: "done",
|
||||
} as const;
|
||||
|
||||
export const APPROVAL_STATE = {
|
||||
PENDING: "pending",
|
||||
APPROVED: "approved",
|
||||
DECLINED: "declined",
|
||||
} as const;
|
||||
|
||||
export const RISK_LEVEL = {
|
||||
LOW: "low",
|
||||
MEDIUM: "medium",
|
||||
HIGH: "high",
|
||||
} as const;
|
||||
|
||||
export const PROVIDER_AUTH_TYPE = {
|
||||
API_KEY: "api_key",
|
||||
OAUTH_PKCE: "oauth_pkce",
|
||||
ACCOUNT_SUBSCRIPTION: "account_subscription",
|
||||
CLOUD: "cloud",
|
||||
} as const;
|
||||
|
||||
export const SOCIAL_PLATFORM = {
|
||||
X: "x",
|
||||
LINKEDIN: "linkedin",
|
||||
YOUTUBE: "youtube",
|
||||
INSTAGRAM: "instagram",
|
||||
} as const;
|
||||
|
||||
export type ValueOf<T> = T[keyof T];
|
||||
export type TaskStatus = ValueOf<typeof TASK_STATUS>;
|
||||
export type ApprovalState = ValueOf<typeof APPROVAL_STATE>;
|
||||
export type RiskLevel = ValueOf<typeof RISK_LEVEL>;
|
||||
export type ProviderAuthType = ValueOf<typeof PROVIDER_AUTH_TYPE>;
|
||||
export type SocialPlatform = ValueOf<typeof SOCIAL_PLATFORM>;
|
||||
|
||||
export interface OrganizationRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
mission: string;
|
||||
goal: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface EmployeeRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
displayName: string;
|
||||
role: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface AgentRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
name: string;
|
||||
role: string;
|
||||
department: string;
|
||||
modelProviderId: string | null;
|
||||
modelId: string | null;
|
||||
budgetCents: number;
|
||||
managerAgentId: string | null;
|
||||
lifecycle: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface TaskRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
title: string;
|
||||
description: string;
|
||||
status: TaskStatus;
|
||||
assigneeAgentId: string | null;
|
||||
risk: RiskLevel;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ApprovalRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
kind: string;
|
||||
title: string;
|
||||
details: string;
|
||||
risk: RiskLevel;
|
||||
requestedByType: "employee" | "agent" | "system";
|
||||
requestedById: string | null;
|
||||
state: ApprovalState;
|
||||
decidedByEmployeeId: string | null;
|
||||
createdAt: string;
|
||||
decidedAt: string | null;
|
||||
}
|
||||
|
||||
export interface ChatSpaceRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
spaceType: string;
|
||||
name: string;
|
||||
topic: string;
|
||||
visibility: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ChatMessageRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
spaceId: string;
|
||||
threadId: string | null;
|
||||
senderType: "employee" | "agent" | "board" | "system";
|
||||
senderId: string | null;
|
||||
bodyMd: string;
|
||||
createdAt: string;
|
||||
editedAt: string | null;
|
||||
deletedAt: string | null;
|
||||
}
|
||||
|
||||
export interface FileObjectRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
sizeBytes: number;
|
||||
sha256: string;
|
||||
storagePath: string;
|
||||
ownerType: "employee" | "agent" | "system";
|
||||
ownerId: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ProviderRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
providerKey: string;
|
||||
label: string;
|
||||
authType: ProviderAuthType;
|
||||
model: string | null;
|
||||
credentialId: string | null;
|
||||
enabled: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ProviderCatalogEntry {
|
||||
key: string;
|
||||
label: string;
|
||||
authType: ProviderAuthType;
|
||||
defaultModel: string | null;
|
||||
capabilityTags: string[];
|
||||
}
|
||||
|
||||
export interface SkillDefinitionRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
ownerType: string;
|
||||
status: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface SkillRevisionRecord {
|
||||
id: string;
|
||||
skillId: string;
|
||||
versionSemver: string;
|
||||
manifestJson: string;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
publishedAt: string;
|
||||
immutableChecksum: string;
|
||||
}
|
||||
|
||||
export interface SkillBindingRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
agentId: string;
|
||||
skillId: string;
|
||||
pinnedRevisionId: string;
|
||||
bindingMode: string;
|
||||
priority: number;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface SocialAccountRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
platform: SocialPlatform;
|
||||
handle: string;
|
||||
displayName: string;
|
||||
authorizedEmployeeId: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface AuditEventRecord {
|
||||
id: string;
|
||||
orgId: string;
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
actorType: string;
|
||||
actorId: string | null;
|
||||
action: string;
|
||||
payloadJson: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface AppSnapshot {
|
||||
activeOrgId: string | null;
|
||||
organizations: OrganizationRecord[];
|
||||
employees: EmployeeRecord[];
|
||||
agents: AgentRecord[];
|
||||
tasks: TaskRecord[];
|
||||
approvals: ApprovalRecord[];
|
||||
chatSpaces: ChatSpaceRecord[];
|
||||
chatMessages: ChatMessageRecord[];
|
||||
files: FileObjectRecord[];
|
||||
providers: ProviderRecord[];
|
||||
providerCatalog: ProviderCatalogEntry[];
|
||||
skillDefinitions: SkillDefinitionRecord[];
|
||||
skillRevisions: SkillRevisionRecord[];
|
||||
skillBindings: SkillBindingRecord[];
|
||||
socialAccounts: SocialAccountRecord[];
|
||||
auditEvents: AuditEventRecord[];
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export type EntityId = string;
|
||||
|
||||
export function createId(prefix: string): EntityId {
|
||||
return `${prefix}_${crypto.randomUUID().replaceAll("-", "")}`;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
export const IPC_CHANNELS = {
|
||||
loadSnapshot: "agentcompany:load-snapshot",
|
||||
createOrganization: "agentcompany:create-organization",
|
||||
createAgent: "agentcompany:create-agent",
|
||||
createTask: "agentcompany:create-task",
|
||||
updateTaskStatus: "agentcompany:update-task-status",
|
||||
createApproval: "agentcompany:create-approval",
|
||||
decideApproval: "agentcompany:decide-approval",
|
||||
sendMessage: "agentcompany:send-message",
|
||||
saveProviderCredential: "agentcompany:save-provider-credential",
|
||||
importSkillDirectory: "agentcompany:import-skill-directory",
|
||||
bindSkill: "agentcompany:bind-skill",
|
||||
createSocialAccount: "agentcompany:create-social-account",
|
||||
launchSocialLogin: "agentcompany:launch-social-login",
|
||||
importFile: "agentcompany:import-file",
|
||||
rendererEvent: "agentcompany:renderer-event",
|
||||
windowMinimize: "agentcompany:window-minimize",
|
||||
windowMaximize: "agentcompany:window-maximize",
|
||||
windowClose: "agentcompany:window-close",
|
||||
} as const;
|
||||
@@ -0,0 +1,74 @@
|
||||
import { PROVIDER_AUTH_TYPE, type ProviderCatalogEntry } from "./domain";
|
||||
|
||||
export const PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
||||
{
|
||||
key: "openai",
|
||||
label: "OpenAI",
|
||||
authType: PROVIDER_AUTH_TYPE.API_KEY,
|
||||
defaultModel: "gpt-5.1",
|
||||
capabilityTags: ["responses", "tools", "background"],
|
||||
},
|
||||
{
|
||||
key: "anthropic",
|
||||
label: "Anthropic",
|
||||
authType: PROVIDER_AUTH_TYPE.API_KEY,
|
||||
defaultModel: "claude-sonnet-4-5",
|
||||
capabilityTags: ["messages", "tool-use", "token-bucket"],
|
||||
},
|
||||
{
|
||||
key: "xai",
|
||||
label: "xAI Grok",
|
||||
authType: PROVIDER_AUTH_TYPE.API_KEY,
|
||||
defaultModel: "grok-4",
|
||||
capabilityTags: ["chat", "reasoning"],
|
||||
},
|
||||
{
|
||||
key: "github-copilot",
|
||||
label: "GitHub Copilot",
|
||||
authType: PROVIDER_AUTH_TYPE.OAUTH_PKCE,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["account", "coding"],
|
||||
},
|
||||
{
|
||||
key: "google-antigravity",
|
||||
label: "Google Antigravity",
|
||||
authType: PROVIDER_AUTH_TYPE.OAUTH_PKCE,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["account", "coding"],
|
||||
},
|
||||
{
|
||||
key: "gpt-account",
|
||||
label: "GPT account",
|
||||
authType: PROVIDER_AUTH_TYPE.ACCOUNT_SUBSCRIPTION,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["codex", "subscription"],
|
||||
},
|
||||
{
|
||||
key: "azure-openai",
|
||||
label: "Azure OpenAI",
|
||||
authType: PROVIDER_AUTH_TYPE.CLOUD,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["enterprise", "regional"],
|
||||
},
|
||||
{
|
||||
key: "aws-bedrock",
|
||||
label: "AWS Bedrock",
|
||||
authType: PROVIDER_AUTH_TYPE.CLOUD,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["enterprise", "multi-model"],
|
||||
},
|
||||
{
|
||||
key: "vertex-ai",
|
||||
label: "Vertex AI",
|
||||
authType: PROVIDER_AUTH_TYPE.CLOUD,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["enterprise", "regional"],
|
||||
},
|
||||
{
|
||||
key: "groq",
|
||||
label: "Groq",
|
||||
authType: PROVIDER_AUTH_TYPE.API_KEY,
|
||||
defaultModel: null,
|
||||
capabilityTags: ["inference", "low-latency"],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
export interface DesktopError {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type DesktopResult<T> =
|
||||
| { ok: true; data: T }
|
||||
| { ok: false; error: DesktopError };
|
||||
|
||||
export function ok<T>(data: T): DesktopResult<T> {
|
||||
return { ok: true, data };
|
||||
}
|
||||
|
||||
export function fail(code: string, message: string): DesktopResult<never> {
|
||||
return { ok: false, error: { code, message } };
|
||||
}
|
||||
Reference in new issue
Block a user