new plugin

This commit is contained in:
2026-03-20 22:53:01 -04:00
parent ecd78f7528
commit 0efd661184
38 changed files with 1570 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
export declare const PLUGIN_ID = "paperclip.plugin-agent-inbox-config";
export declare const PLUGIN_VERSION = "0.1.0";
export declare const SIDEBAR_SLOT_ID = "agent-inbox-config-sidebar";
export declare const PAGE_SLOT_ID = "agent-inbox-config-page";
export declare const AGENT_TAB_SLOT_ID = "agent-inbox-tab";
export declare const EXPORT_NAMES: {
readonly sidebar: "InboxConfigSidebar";
readonly page: "InboxConfigPage";
readonly agentTab: "AgentInboxSettingsTab";
};
export declare const DEFAULT_INBOX_CONFIG: {
statuses: string;
includeBacklog: boolean;
projectId: string | null;
goalId: string | null;
labelIds: string[];
query: string | null;
};
export type AgentInboxConfig = typeof DEFAULT_INBOX_CONFIG;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,wCAAwC,CAAC;AAC/D,eAAO,MAAM,cAAc,UAAU,CAAC;AAGtC,eAAO,MAAM,eAAe,+BAA+B,CAAC;AAC5D,eAAO,MAAM,YAAY,4BAA4B,CAAC;AACtD,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAGnD,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAGX,eAAO,MAAM,oBAAoB;;;eAGZ,MAAM,GAAG,IAAI;YAChB,MAAM,GAAG,IAAI;cACb,MAAM,EAAE;WACT,MAAM,GAAG,IAAI;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,oBAAoB,CAAC"}

View File

@@ -0,0 +1,22 @@
export const PLUGIN_ID = "paperclip.plugin-agent-inbox-config";
export const PLUGIN_VERSION = "0.1.0";
// Slot IDs
export const SIDEBAR_SLOT_ID = "agent-inbox-config-sidebar";
export const PAGE_SLOT_ID = "agent-inbox-config-page";
export const AGENT_TAB_SLOT_ID = "agent-inbox-tab";
// Export names
export const EXPORT_NAMES = {
sidebar: "InboxConfigSidebar",
page: "InboxConfigPage",
agentTab: "AgentInboxSettingsTab",
};
// Default config
export const DEFAULT_INBOX_CONFIG = {
statuses: "todo,in_progress,blocked",
includeBacklog: false,
projectId: null,
goalId: null,
labelIds: [],
query: null,
};
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,qCAAqC,CAAC;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,WAAW;AACX,MAAM,CAAC,MAAM,eAAe,GAAG,4BAA4B,CAAC;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,eAAe;AACf,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,oBAAoB;IAC7B,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,uBAAuB;CACzB,CAAC;AAEX,iBAAiB;AACjB,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,0BAA0B;IACpC,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,IAAqB;IAChC,MAAM,EAAE,IAAqB;IAC7B,QAAQ,EAAE,EAAc;IACxB,KAAK,EAAE,IAAqB;CAC7B,CAAC"}

View File

@@ -0,0 +1,3 @@
export { default as manifest } from "./manifest.js";
export { default as worker } from "./worker.js";
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,3 @@
export { default as manifest } from "./manifest.js";
export { default as worker } from "./worker.js";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}

View File

@@ -0,0 +1,8 @@
import type { PaperclipPluginManifestV1 } from "@paperclipai/plugin-sdk";
/**
* Plugin that provides per-agent inbox-lite configuration via UI toggles.
* Allows configuring which issues appear in each agent's inbox without code changes.
*/
declare const manifest: PaperclipPluginManifestV1;
export default manifest;
//# sourceMappingURL=manifest.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAKzE;;;GAGG;AACH,QAAA,MAAM,QAAQ,EAAE,yBAoEf,CAAC;AAEF,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,77 @@
const PLUGIN_ID = "paperclip.plugin-agent-inbox-config";
const PLUGIN_VERSION = "0.1.0";
/**
* Plugin that provides per-agent inbox-lite configuration via UI toggles.
* Allows configuring which issues appear in each agent's inbox without code changes.
*/
const manifest = {
id: PLUGIN_ID,
apiVersion: 1,
version: PLUGIN_VERSION,
displayName: "Agent Inbox Configuration",
description: "Configure per-agent inbox-lite filters via UI toggles. Control which issues appear in each agent's inbox based on status, project, goal, labels, and search queries.",
author: "Paperclip",
categories: ["ui", "automation"],
capabilities: [
"agents.read",
"projects.read",
"goals.read",
"issues.read",
"plugin.state.read",
"plugin.state.write",
"http.outbound",
"ui.detailTab.register",
"ui.page.register",
],
entrypoints: {
worker: "./dist/worker.js",
ui: "./dist/ui",
},
instanceConfigSchema: {
type: "object",
title: "Agent Inbox Config Plugin Settings",
description: "Default inbox configuration settings for agents.",
properties: {
defaultStatuses: {
type: "string",
title: "Default Statuses",
description: "Default statuses to include in inbox (comma-separated). Override per-agent via agent settings.",
default: "todo,in_progress,blocked",
},
includeBacklog: {
type: "boolean",
title: "Include Backlog by Default",
description: "Whether backlog issues are included by default.",
default: false,
},
maxIssuesPerAgent: {
type: "integer",
title: "Max Issues Per Agent",
description: "Maximum number of issues to return per agent inbox.",
default: 50,
minimum: 1,
maximum: 500,
},
},
},
ui: {
slots: [
{
type: "page",
id: "agent-inbox-config-page",
displayName: "Agent Inbox Configuration",
exportName: "InboxConfigPage",
routePath: "inbox-config",
},
{
type: "detailTab",
id: "agent-inbox-tab",
displayName: "Inbox Settings",
exportName: "AgentInboxSettingsTab",
entityTypes: ["agent"],
},
],
},
};
export default manifest;
//# sourceMappingURL=manifest.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,qCAAqC,CAAC;AACxD,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B;;;GAGG;AACH,MAAM,QAAQ,GAA8B;IAC1C,EAAE,EAAE,SAAS;IACb,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,cAAc;IACvB,WAAW,EAAE,2BAA2B;IACxC,WAAW,EAAE,sKAAsK;IACnL,MAAM,EAAE,WAAW;IACnB,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC;IAChC,YAAY,EAAE;QACZ,aAAa;QACb,eAAe;QACf,YAAY;QACZ,aAAa;QACb,mBAAmB;QACnB,oBAAoB;QACpB,eAAe;QACf,uBAAuB;QACvB,kBAAkB;KACnB;IACD,WAAW,EAAE;QACX,MAAM,EAAE,kBAAkB;QAC1B,EAAE,EAAE,WAAW;KAChB;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,oCAAoC;QAC3C,WAAW,EAAE,kDAAkD;QAC/D,UAAU,EAAE;YACV,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,kBAAkB;gBACzB,WAAW,EAAE,gGAAgG;gBAC7G,OAAO,EAAE,0BAA0B;aACpC;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,4BAA4B;gBACnC,WAAW,EAAE,iDAAiD;gBAC9D,OAAO,EAAE,KAAK;aACf;YACD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,sBAAsB;gBAC7B,WAAW,EAAE,qDAAqD;gBAClE,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;aACb;SACF;KACF;IACD,EAAE,EAAE;QACF,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,yBAAyB;gBAC7B,WAAW,EAAE,2BAA2B;gBACxC,UAAU,EAAE,iBAAiB;gBAC7B,SAAS,EAAE,cAAc;aAC1B;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,EAAE,EAAE,iBAAiB;gBACrB,WAAW,EAAE,gBAAgB;gBAC7B,UAAU,EAAE,uBAAuB;gBACnC,WAAW,EAAE,CAAC,OAAO,CAAC;aACvB;SACF;KACF;CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,4 @@
import { type PluginPageProps, type PluginDetailTabProps } from "@paperclipai/plugin-sdk/ui";
export declare function InboxConfigPage({ context }: PluginPageProps): import("react/jsx-runtime").JSX.Element;
export declare function AgentInboxSettingsTab({ context }: PluginDetailTabProps): import("react/jsx-runtime").JSX.Element;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,4BAA4B,CAAC;AAuHpC,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE,eAAe,2CA+E3D;AA+CD,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE,oBAAoB,2CA4OtE"}

View File

@@ -0,0 +1,251 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useEffect } from "react";
import { usePluginAction, usePluginData, usePluginToast, } from "@paperclipai/plugin-sdk/ui";
import { DEFAULT_INBOX_CONFIG, PAGE_SLOT_ID, AGENT_TAB_SLOT_ID, } from "../constants.js";
// -----------------------------------------------------------------------------
// Styles
// -----------------------------------------------------------------------------
const containerStyle = {
display: "grid",
gap: "16px",
};
const cardStyle = {
border: "1px solid var(--border, #e5e7eb)",
borderRadius: "12px",
padding: "16px",
background: "var(--card, white)",
};
const sectionHeaderStyle = {
display: "flex",
alignItems: "center",
justifyContent: "space-between",
marginBottom: "12px",
};
const buttonStyle = {
appearance: "none",
border: "1px solid var(--border, #e5e7eb)",
borderRadius: "8px",
background: "transparent",
color: "inherit",
padding: "8px 14px",
fontSize: "13px",
cursor: "pointer",
};
const primaryButtonStyle = {
...buttonStyle,
background: "var(--foreground, #1f2937)",
color: "var(--background, white)",
};
const inputStyle = {
width: "100%",
border: "1px solid var(--border, #e5e7eb)",
borderRadius: "8px",
padding: "10px 12px",
background: "transparent",
color: "inherit",
fontSize: "13px",
};
const selectStyle = {
...inputStyle,
};
const checkboxStyle = {
width: "18px",
height: "18px",
accentColor: "var(--foreground, #1f2937)",
};
const rowStyle = {
display: "flex",
alignItems: "center",
gap: "10px",
marginBottom: "12px",
};
const mutedTextStyle = {
fontSize: "12px",
opacity: 0.7,
lineHeight: 1.5,
};
// -----------------------------------------------------------------------------
// Helper functions
// -----------------------------------------------------------------------------
function getStatusOptions() {
return [
{ value: "todo", label: "Todo" },
{ value: "in_progress", label: "In Progress" },
{ value: "blocked", label: "Blocked" },
{ value: "backlog", label: "Backlog" },
{ value: "in_review", label: "In Review" },
{ value: "done", label: "Done" },
{ value: "cancelled", label: "Cancelled" },
];
}
function getStatusLabel(value) {
const option = getStatusOptions().find((o) => o.value === value);
return option?.label || value;
}
// -----------------------------------------------------------------------------
// Page Component - Shows all agents and their inbox configs
// -----------------------------------------------------------------------------
export function InboxConfigPage({ context }) {
const [agents, setAgents] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
async function loadAgents() {
if (!context.companyId)
return;
setLoading(true);
try {
const response = await fetch(`/api/companies/${context.companyId}/agents`, {
credentials: "include",
});
if (!response.ok)
throw new Error(`Failed to load agents: ${response.status}`);
const data = await response.json();
setAgents(Array.isArray(data) ? data : []);
setError(null);
}
catch (err) {
setError(err instanceof Error ? err.message : String(err));
}
finally {
setLoading(false);
}
}
void loadAgents();
}, [context.companyId]);
const agentPath = (agentId) => {
const prefix = context.companyPrefix || "";
return `${prefix ? "/${prefix}" : "/"}/agents/${agentId}`;
};
if (!context.companyId) {
return (_jsx("div", { style: { padding: "24px", fontSize: "14px", opacity: 0.7 }, children: "Select a company to configure agent inboxes." }));
}
if (loading) {
return _jsx("div", { style: { padding: "24px", fontSize: "14px" }, children: "Loading agents\u2026" });
}
return (_jsxs("div", { style: { padding: "24px", maxWidth: "1000px", margin: "0 auto" }, children: [_jsx("h1", { style: { fontSize: "24px", fontWeight: 700, marginBottom: "8px" }, children: "Agent Inbox Configuration" }), _jsx("p", { style: { ...mutedTextStyle, marginBottom: "24px", fontSize: "14px" }, children: "Configure which issues appear in each agent's inbox via the inbox-lite endpoint." }), error ? (_jsx("div", { style: { ...cardStyle, color: "var(--destructive, #dc2626)" }, children: error })) : (_jsxs("div", { style: { display: "grid", gap: "16px" }, children: [agents.map((agent) => (_jsxs("div", { style: cardStyle, children: [_jsxs("div", { style: sectionHeaderStyle, children: [_jsx("strong", { style: { fontSize: "15px" }, children: agent.name }), _jsx("a", { href: `${agentPath(agent.id)}?tab=plugin:${PAGE_SLOT_ID}:${AGENT_TAB_SLOT_ID}`, style: { fontSize: "12px", textDecoration: "underline", cursor: "pointer" }, children: "Configure \u2192" })] }), _jsx("div", { style: { display: "grid", gap: "8px", fontSize: "13px" }, children: _jsx(AgentInboxSummary, { agentId: agent.id }) })] }, agent.id))), agents.length === 0 && (_jsx("div", { style: { ...cardStyle, padding: "24px", textAlign: "center", opacity: 0.7 }, children: "No agents found in this company." }))] }))] }));
}
// -----------------------------------------------------------------------------
// Agent Inbox Summary Component (used in page view)
// -----------------------------------------------------------------------------
function AgentInboxSummary({ agentId }) {
const config = usePluginData("getAgentInboxConfig", { agentId });
if (config.loading)
return _jsx("div", { style: { fontSize: "12px", opacity: 0.6 }, children: "Loading\u2026" });
if (config.error)
return _jsx("div", { style: { fontSize: "12px", color: "var(--destructive, #dc2626)" }, children: "Error loading config" });
const c = config.data || DEFAULT_INBOX_CONFIG;
return (_jsxs("div", { style: { display: "grid", gap: "6px", fontSize: "12px" }, children: [_jsxs("div", { children: [_jsx("strong", { children: "Statuses:" }), " ", c.statuses] }), c.projectId ? (_jsxs("div", { children: [_jsx("strong", { children: "Project:" }), " Filtered"] })) : null, c.goalId ? (_jsxs("div", { children: [_jsx("strong", { children: "Goal:" }), " Filtered"] })) : null, c.labelIds && c.labelIds.length > 0 ? (_jsxs("div", { children: [_jsx("strong", { children: "Labels:" }), " ", c.labelIds.length, " filter(s)"] })) : null, c.query ? (_jsxs("div", { children: [_jsx("strong", { children: "Search:" }), " \"", c.query, "\""] })) : null] }));
}
// -----------------------------------------------------------------------------
// Agent Detail Tab Component - Configure inbox for a specific agent
// -----------------------------------------------------------------------------
export function AgentInboxSettingsTab({ context }) {
const { entityId, entityType } = context;
if (entityType !== "agent") {
return (_jsx("div", { style: { padding: "24px", fontSize: "13px", opacity: 0.7 }, children: "This tab is only available on agent detail pages." }));
}
const agentId = entityId;
const toast = usePluginToast();
// Fetch current config
const configData = usePluginData("getAgentInboxConfig", { agentId });
// Fetch projects for dropdown
const [projects, setProjects] = useState([]);
const [goals, setGoals] = useState([]);
const [loadingOptions, setLoadingOptions] = useState(true);
// Form state
const [formState, setFormState] = useState({
...DEFAULT_INBOX_CONFIG,
statuses: configData.data?.statuses || DEFAULT_INBOX_CONFIG.statuses,
includeBacklog: configData.data?.includeBacklog || DEFAULT_INBOX_CONFIG.includeBacklog,
projectId: configData.data?.projectId || null,
goalId: configData.data?.goalId || null,
labelIds: configData.data?.labelIds || [],
query: configData.data?.query || null,
});
const [saving, setSaving] = useState(false);
// Load projects and goals
useEffect(() => {
async function loadOptions() {
if (!context.companyId)
return;
setLoadingOptions(true);
try {
const [projectsRes, goalsRes] = await Promise.all([
fetch(`/api/companies/${context.companyId}/projects`, { credentials: "include" }),
fetch(`/api/companies/${context.companyId}/goals`, { credentials: "include" }),
]);
if (projectsRes.ok) {
const data = await projectsRes.json();
setProjects(Array.isArray(data) ? data : []);
}
if (goalsRes.ok) {
const data = await goalsRes.json();
setGoals(Array.isArray(data) ? data : []);
}
}
catch (err) {
console.error("Failed to load options:", err);
}
finally {
setLoadingOptions(false);
}
}
void loadOptions();
}, [context.companyId]);
// Update form when config data loads
useEffect(() => {
if (configData.data) {
setFormState({ ...DEFAULT_INBOX_CONFIG, ...configData.data });
}
}, [configData.data]);
const saveConfig = usePluginAction("setAgentInboxConfig");
async function handleSave(e) {
e.preventDefault();
if (!agentId)
return;
setSaving(true);
try {
await saveConfig({
agentId,
config: {
statuses: formState.statuses,
includeBacklog: formState.includeBacklog,
projectId: formState.projectId,
goalId: formState.goalId,
labelIds: formState.labelIds,
query: formState.query,
},
});
toast({
title: "Inbox config saved",
body: `Configuration updated for this agent.`,
tone: "success",
});
}
catch (err) {
const message = err instanceof Error ? err.message : String(err);
toast({
title: "Failed to save config",
body: message,
tone: "error",
});
}
finally {
setSaving(false);
}
}
const statusOptions = getStatusOptions();
const selectedStatuses = formState.statuses.split(",");
return (_jsxs("div", { style: { padding: "20px", maxWidth: "700px" }, children: [_jsx("h2", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Inbox Configuration" }), _jsx("p", { style: { ...mutedTextStyle, marginBottom: "20px", fontSize: "13px" }, children: "Configure which issues appear in this agent's inbox via the inbox-lite endpoint." }), _jsxs("form", { onSubmit: handleSave, style: { display: "grid", gap: "20px" }, children: [_jsxs("div", { style: cardStyle, children: [_jsx("div", { style: { fontWeight: 600, marginBottom: "12px", fontSize: "14px" }, children: "Issue Statuses" }), _jsx("p", { style: { ...mutedTextStyle, marginBottom: "12px", fontSize: "12px" }, children: "Select which issue statuses should appear in this agent's inbox." }), _jsx("div", { style: { display: "grid", gap: "8px" }, children: statusOptions.map((option) => (_jsxs("label", { style: { display: "flex", alignItems: "center", gap: "10px", fontSize: "13px" }, children: [_jsx("input", { type: "checkbox", checked: selectedStatuses.includes(option.value), onChange: (e) => {
const isChecked = e.target.checked;
const current = formState.statuses.split(",");
const next = isChecked
? [...current, option.value].filter(Boolean)
: current.filter((s) => s !== option.value);
setFormState({ ...formState, statuses: next.join(",") });
}, style: checkboxStyle }), _jsx("span", { children: option.label })] }, option.value))) })] }), _jsxs("div", { style: cardStyle, children: [_jsx("div", { style: { fontWeight: 600, marginBottom: "12px", fontSize: "14px" }, children: "Project Filter" }), _jsx("p", { style: { ...mutedTextStyle, marginBottom: "12px", fontSize: "12px" }, children: "Optionally limit inbox to issues from a specific project." }), _jsxs("select", { style: selectStyle, value: formState.projectId || "", onChange: (e) => setFormState({ ...formState, projectId: e.target.value || null }), disabled: loadingOptions, children: [_jsx("option", { value: "", children: "No filter (all projects)" }), projects.map((project) => (_jsx("option", { value: project.id, children: project.name }, project.id)))] })] }), _jsxs("div", { style: cardStyle, children: [_jsx("div", { style: { fontWeight: 600, marginBottom: "12px", fontSize: "14px" }, children: "Goal Filter" }), _jsx("p", { style: { ...mutedTextStyle, marginBottom: "12px", fontSize: "12px" }, children: "Optionally limit inbox to issues linked to a specific goal." }), _jsxs("select", { style: selectStyle, value: formState.goalId || "", onChange: (e) => setFormState({ ...formState, goalId: e.target.value || null }), disabled: loadingOptions, children: [_jsx("option", { value: "", children: "No filter (all goals)" }), goals.map((goal) => (_jsx("option", { value: goal.id, children: goal.title }, goal.id)))] })] }), _jsxs("div", { style: cardStyle, children: [_jsx("div", { style: { fontWeight: 600, marginBottom: "12px", fontSize: "14px" }, children: "Search Query" }), _jsx("p", { style: { ...mutedTextStyle, marginBottom: "12px", fontSize: "12px" }, children: "Optional search query to filter issues by title, description, or comments." }), _jsx("input", { type: "text", style: inputStyle, value: formState.query || "", onChange: (e) => setFormState({ ...formState, query: e.target.value || null }), placeholder: "e.g., docker, deployment, urgent" })] }), _jsxs("div", { style: cardStyle, children: [_jsxs("label", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [_jsx("input", { type: "checkbox", checked: formState.includeBacklog, onChange: (e) => setFormState({ ...formState, includeBacklog: e.target.checked }), style: checkboxStyle }), _jsx("span", { style: { fontSize: "13px" }, children: "Include backlog issues" })] }), _jsx("p", { style: { ...mutedTextStyle, marginTop: "6px", fontSize: "12px" }, children: "When enabled, issues with status \"backlog\" will be included in the inbox." })] }), _jsxs("div", { style: { display: "flex", gap: "10px", justifyContent: "flex-end" }, children: [_jsx("button", { type: "button", style: buttonStyle, onClick: () => {
setFormState({ ...DEFAULT_INBOX_CONFIG });
}, children: "Reset to Defaults" }), _jsx("button", { type: "submit", style: primaryButtonStyle, disabled: saving || configData.loading || loadingOptions, children: saving ? "Saving…" : "Save Configuration" })] })] })] }));
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import { type PaperclipPlugin } from "@paperclipai/plugin-sdk";
declare const plugin: PaperclipPlugin;
export default plugin;
//# sourceMappingURL=worker.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAUxF,QAAA,MAAM,MAAM,EAAE,eAqLZ,CAAC;AAEH,eAAe,MAAM,CAAC"}

165
plugin-agent-inbox-config/dist/worker.js vendored Normal file
View File

@@ -0,0 +1,165 @@
import { definePlugin, runWorker } from "@paperclipai/plugin-sdk";
import { DEFAULT_INBOX_CONFIG, PLUGIN_ID, PLUGIN_VERSION, } from "./constants.js";
const WORKER_KEY = "agent-inbox-config-worker";
const plugin = definePlugin({
async setup(ctx) {
ctx.logger.info(`${PLUGIN_ID} v${PLUGIN_VERSION} starting...`);
// Initialize plugin state with default inbox configs per agent
const existingState = await ctx.state.get({ scopeKind: "instance", stateKey: "agentInboxConfigs" });
if (!existingState) {
await ctx.state.set({ scopeKind: "instance", stateKey: "agentInboxConfigs" }, {});
}
const versionState = await ctx.state.get({ scopeKind: "instance", stateKey: "version" });
if (!versionState) {
await ctx.state.set({ scopeKind: "instance", stateKey: "version" }, PLUGIN_VERSION);
}
// Register data handlers for UI to fetch data
ctx.data.register("agents", async (params) => {
const companyId = typeof params?.companyId === "string" ? params.companyId : "";
if (!companyId)
return [];
return await ctx.agents.list({ companyId, limit: 100, offset: 0 });
});
ctx.data.register("getAgentInboxConfig", async (params) => {
const agentId = typeof params?.agentId === "string" ? params.agentId : "";
if (!agentId)
return null;
const configs = (await ctx.state.get({ scopeKind: "instance", stateKey: "agentInboxConfigs" })) || {};
return configs[agentId] || null;
});
ctx.data.register("listAgentInboxConfigs", async () => {
const configs = (await ctx.state.get({ scopeKind: "instance", stateKey: "agentInboxConfigs" })) || {};
return Object.entries(configs).map(([agentId, config]) => ({ agentId, config }));
});
// Register action handlers for UI to perform actions
ctx.actions.register("setAgentInboxConfig", async (params) => {
const agentId = typeof params?.agentId === "string" ? params.agentId : "";
const config = params?.config;
if (!agentId) {
throw new Error("agentId is required");
}
const configs = (await ctx.state.get({ scopeKind: "instance", stateKey: "agentInboxConfigs" })) || {};
// Merge with defaults
const mergedConfig = {
...DEFAULT_INBOX_CONFIG,
statuses: config?.statuses || DEFAULT_INBOX_CONFIG.statuses,
includeBacklog: config?.includeBacklog ?? DEFAULT_INBOX_CONFIG.includeBacklog,
projectId: config?.projectId ?? null,
goalId: config?.goalId ?? null,
labelIds: config?.labelIds || [],
query: config?.query ?? null,
};
configs[agentId] = mergedConfig;
await ctx.state.set({ scopeKind: "instance", stateKey: "agentInboxConfigs" }, configs);
// Also persist to agent's runtimeConfig for durability and server-side access
try {
const agentResponse = await ctx.http.fetch(`/api/agents/${agentId}`, {
method: "GET",
headers: { "Content-Type": "application/json" },
});
if (agentResponse.ok) {
const agentData = await agentResponse.json();
const currentRuntimeConfig = agentData.runtimeConfig || {};
const agentUpdateResponse = await ctx.http.fetch(`/api/agents/${agentId}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
runtimeConfig: {
...currentRuntimeConfig,
inboxConfig: mergedConfig,
},
}),
});
if (!agentUpdateResponse.ok) {
ctx.logger.warn("Failed to update agent runtimeConfig with inbox config", { agentId, status: agentUpdateResponse.status });
}
}
}
catch (err) {
ctx.logger.warn("Failed to persist inbox config to agent runtimeConfig", { agentId, error: err });
}
ctx.logger.info("Inbox config updated for agent", { agentId });
return { success: true, agentId, config: mergedConfig };
});
ctx.actions.register("resetAgentInboxConfig", async (params) => {
const agentId = typeof params?.agentId === "string" ? params.agentId : "";
if (!agentId) {
throw new Error("agentId is required");
}
const configs = (await ctx.state.get({ scopeKind: "instance", stateKey: "agentInboxConfigs" })) || {};
delete configs[agentId];
await ctx.state.set({ scopeKind: "instance", stateKey: "agentInboxConfigs" }, configs);
// Also clear inboxConfig from agent's runtimeConfig
try {
const agentResponse = await ctx.http.fetch(`/api/agents/${agentId}`, {
method: "GET",
headers: { "Content-Type": "application/json" },
});
if (agentResponse.ok) {
const agentData = await agentResponse.json();
const currentRuntimeConfig = agentData.runtimeConfig || {};
// Remove inboxConfig from runtimeConfig
const updatedRuntimeConfig = { ...currentRuntimeConfig };
delete updatedRuntimeConfig.inboxConfig;
const agentUpdateResponse = await ctx.http.fetch(`/api/agents/${agentId}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
runtimeConfig: updatedRuntimeConfig,
}),
});
if (!agentUpdateResponse.ok) {
ctx.logger.warn("Failed to clear agent runtimeConfig inbox config", { agentId, status: agentUpdateResponse.status });
}
}
}
catch (err) {
ctx.logger.warn("Failed to clear inbox config from agent runtimeConfig", { agentId, error: err });
}
ctx.logger.info("Inbox config reset for agent", { agentId });
return { success: true, agentId };
});
// Event handler for agent creation - set default inbox config
ctx.events.on("agent.created", async (event) => {
const agentId = event.entityId || "";
if (!agentId)
return;
const configs = (await ctx.state.get({ scopeKind: "instance", stateKey: "agentInboxConfigs" })) || {};
// Set default config for new agent in plugin state
configs[agentId] = {
...DEFAULT_INBOX_CONFIG,
};
await ctx.state.set({ scopeKind: "instance", stateKey: "agentInboxConfigs" }, configs);
// Also set default inboxConfig in agent's runtimeConfig
try {
const agentResponse = await ctx.http.fetch(`/api/agents/${agentId}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
runtimeConfig: {
inboxConfig: { ...DEFAULT_INBOX_CONFIG },
},
}),
});
if (!agentResponse.ok) {
ctx.logger.warn("Failed to set default inbox config on new agent", { agentId, status: agentResponse.status });
}
}
catch (err) {
ctx.logger.warn("Failed to set default inbox config on new agent runtimeConfig", { agentId, error: err });
}
ctx.logger.info("Default inbox config set for new agent", { agentId });
});
ctx.logger.info(`${PLUGIN_ID} initialized successfully`);
},
async onHealth() {
return {
status: "ok",
message: "Agent Inbox Config plugin ready",
details: {},
};
},
});
export default plugin;
runWorker(plugin, import.meta.url);
//# sourceMappingURL=worker.js.map

File diff suppressed because one or more lines are too long