Clarify plugin authoring and external dev workflow
This commit is contained in:
@@ -39,8 +39,6 @@ const manifest: PaperclipPluginManifestV1 = {
|
||||
"goals.read",
|
||||
"goals.create",
|
||||
"goals.update",
|
||||
"assets.write",
|
||||
"assets.read",
|
||||
"activity.log.write",
|
||||
"metrics.write",
|
||||
"plugin.state.read",
|
||||
|
||||
@@ -71,7 +71,6 @@ type OverviewData = {
|
||||
};
|
||||
lastJob: unknown;
|
||||
lastWebhook: unknown;
|
||||
lastAsset: unknown;
|
||||
lastProcessResult: unknown;
|
||||
streamChannels: Record<string, string>;
|
||||
safeCommands: Array<{ key: string; label: string; description: string }>;
|
||||
@@ -766,7 +765,6 @@ function KitchenSinkPageWidgets({ context }: { context: PluginPageProps["context
|
||||
value={{
|
||||
lastJob: overview.data?.lastJob ?? null,
|
||||
lastWebhook: overview.data?.lastWebhook ?? null,
|
||||
lastAsset: overview.data?.lastAsset ?? null,
|
||||
lastProcessResult: overview.data?.lastProcessResult ?? null,
|
||||
}}
|
||||
/>
|
||||
@@ -1340,7 +1338,6 @@ function KitchenSinkConsole({ context }: { context: { companyId: string | null;
|
||||
const [secretRef, setSecretRef] = useState("");
|
||||
const [metricName, setMetricName] = useState("manual");
|
||||
const [metricValue, setMetricValue] = useState("1");
|
||||
const [assetContent, setAssetContent] = useState("Kitchen Sink asset demo");
|
||||
const [workspaceId, setWorkspaceId] = useState("");
|
||||
const [workspacePath, setWorkspacePath] = useState<string>(DEFAULT_CONFIG.workspaceScratchFile);
|
||||
const [workspaceContent, setWorkspaceContent] = useState("Kitchen Sink wrote this file.");
|
||||
@@ -1388,7 +1385,6 @@ function KitchenSinkConsole({ context }: { context: { companyId: string | null;
|
||||
const writeMetric = usePluginAction("write-metric");
|
||||
const httpFetch = usePluginAction("http-fetch");
|
||||
const resolveSecret = usePluginAction("resolve-secret");
|
||||
const createAsset = usePluginAction("create-asset");
|
||||
const runProcess = usePluginAction("run-process");
|
||||
const readWorkspaceFile = usePluginAction("read-workspace-file");
|
||||
const writeWorkspaceScratch = usePluginAction("write-workspace-scratch");
|
||||
@@ -1808,7 +1804,7 @@ function KitchenSinkConsole({ context }: { context: { companyId: string | null;
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="HTTP + Secrets + Assets + Activity + Metrics">
|
||||
<Section title="HTTP + Secrets + Activity + Metrics">
|
||||
<div style={{ display: "grid", gap: "12px", gridTemplateColumns: "repeat(auto-fit, minmax(240px, 1fr))" }}>
|
||||
<form
|
||||
style={layoutStack}
|
||||
@@ -1836,22 +1832,6 @@ function KitchenSinkConsole({ context }: { context: { companyId: string | null;
|
||||
<input style={inputStyle} value={secretRef} onChange={(event) => setSecretRef(event.target.value)} placeholder="MY_SECRET_REF" />
|
||||
<button type="submit" style={buttonStyle}>Resolve secret ref</button>
|
||||
</form>
|
||||
<form
|
||||
style={layoutStack}
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void createAsset({ filename: "kitchen-sink-demo.txt", content: assetContent })
|
||||
.then((next) => {
|
||||
setResult(next);
|
||||
overview.refresh();
|
||||
})
|
||||
.catch((error) => setResult({ error: error instanceof Error ? error.message : String(error) }));
|
||||
}}
|
||||
>
|
||||
<strong>Assets</strong>
|
||||
<textarea style={{ ...inputStyle, minHeight: "88px" }} value={assetContent} onChange={(event) => setAssetContent(event.target.value)} />
|
||||
<button type="submit" style={buttonStyle}>Upload text asset</button>
|
||||
</form>
|
||||
<form
|
||||
style={layoutStack}
|
||||
onSubmit={(event) => {
|
||||
|
||||
@@ -262,7 +262,6 @@ async function registerDataHandlers(ctx: PluginContext): Promise<void> {
|
||||
const agents = companyId ? await ctx.agents.list({ companyId, limit: 200, offset: 0 }) : [];
|
||||
const lastJob = await readInstanceState(ctx, "last-job-run");
|
||||
const lastWebhook = await readInstanceState(ctx, "last-webhook");
|
||||
const lastAsset = await readInstanceState(ctx, "last-asset");
|
||||
const entityRecords = await ctx.entities.list({ limit: 10 } satisfies PluginEntityQuery);
|
||||
return {
|
||||
pluginId: PLUGIN_ID,
|
||||
@@ -281,7 +280,6 @@ async function registerDataHandlers(ctx: PluginContext): Promise<void> {
|
||||
},
|
||||
lastJob,
|
||||
lastWebhook,
|
||||
lastAsset,
|
||||
lastProcessResult,
|
||||
streamChannels: STREAM_CHANNELS,
|
||||
safeCommands: SAFE_COMMANDS,
|
||||
@@ -619,24 +617,6 @@ async function registerActionHandlers(ctx: PluginContext): Promise<void> {
|
||||
};
|
||||
});
|
||||
|
||||
ctx.actions.register("create-asset", async (params) => {
|
||||
const filename = typeof params.filename === "string" && params.filename.length > 0
|
||||
? params.filename
|
||||
: `kitchen-sink-${Date.now()}.txt`;
|
||||
const content = typeof params.content === "string" ? params.content : "Kitchen Sink example asset";
|
||||
const uploaded = await ctx.assets.upload(filename, "text/plain", Buffer.from(content, "utf8"));
|
||||
const url = await ctx.assets.getUrl(uploaded.assetId);
|
||||
const result = { ...uploaded, url };
|
||||
await writeInstanceState(ctx, "last-asset", result);
|
||||
pushRecord({
|
||||
level: "info",
|
||||
source: "assets",
|
||||
message: `Uploaded asset ${filename}`,
|
||||
data: { assetId: uploaded.assetId },
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
ctx.actions.register("run-process", async (params) => {
|
||||
const config = await getConfig(ctx);
|
||||
const companyId = getCurrentCompanyId(params);
|
||||
|
||||
Reference in New Issue
Block a user