paperclip-plugin-playbook-runner-otomatik 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/manifest.js CHANGED
@@ -6,7 +6,7 @@ var PLUGIN_ID = "paperclipai.playbook-runner";
6
6
  var manifest = {
7
7
  id: PLUGIN_ID,
8
8
  apiVersion: 1,
9
- version: "0.3.2",
9
+ version: "0.3.3",
10
10
  displayName: "Agents & Workflows",
11
11
  description: "Runs agent-static flows: creates the child tasks of each phase, chains review tasks, counts review rounds, and escalates a loop that does not converge to the sector head.",
12
12
  author: "Local development plugin",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/generated/skill.json", "../src/manifest.ts"],
4
- "sourcesContent": ["{\"skills\":[{\"slug\":\"executive-task-orchestration\",\"title\":\"Executive task orchestration\",\"description\":\"Use when converting owner-approved company priorities into a Paperclip plan, choosing task owners, delegating work, or reviewing cross-team outcomes. Do not use to approve the CEO agent's own consequential actions.\",\"markdown\":\"---\\nname: executive-task-orchestration\\ndescription: >\\n Use when converting owner-approved company priorities into a Paperclip plan, choosing task owners, delegating work, or reviewing cross-team outcomes. Do not use to approve the CEO agent's own consequential actions.\\n---\\n\\n# Executive task orchestration\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read company goals, existing Paperclip tasks, evidence, and current capacity.\\n2. Separate conversation from tracked work; create no task unless requested or authorized.\\n3. Define outcome, one owner, acceptance evidence, assumptions, dependencies, and human approval needs.\\n4. Delegate bounded work through linked tasks and review evidence before summarizing the outcome.\\n\\n## Expected result\\n\\nA concise priority decision, owner-assigned task plan, approval request, or evidence-backed closeout.\\n\\n## Stop and escalate\\n\\nEscalate budget, publication, hiring, production access, legal or safety exposure, and irreversible decisions to the human Owner.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/org/org-structure/\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n\"},{\"slug\":\"marketing-campaign-planning\",\"title\":\"Marketing campaign planning\",\"description\":\"Use when defining a campaign objective, audience, offer, positioning, message, channel mix, measurement, or campaign review. Do not use this skill to publish, spend, or promise results.\",\"markdown\":\"---\\nname: marketing-campaign-planning\\ndescription: >\\n Use when defining a campaign objective, audience, offer, positioning, message, channel mix, measurement, or campaign review. Do not use this skill to publish, spend, or promise results.\\n---\\n\\n# Marketing campaign planning\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read COMPANY.md and BUSINESS.md and identify approved goals, audiences, proof, constraints, and voice.\\n2. Use current research to define one audience problem, offer, message, and measurable conversion.\\n3. Choose channels, owners, budget request, dates, dependencies, and stop criteria.\\n4. Review evidence against targets and recommend continue, revise, or stop.\\n\\n## Expected result\\n\\nA campaign brief with objective, audience, offer, evidence, message, channels, owners, measures, budget request, risks, approvals, and review date.\\n\\n## Stop and escalate\\n\\nDo not invent testimonials, results, audience evidence, or legal claims; seek human approval for budget and publication.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"technical-architecture-and-delegation\",\"title\":\"Technical architecture and delegation\",\"description\":\"Use when a development request needs technical discovery, stack selection, architecture decisions, a fullstack-versus-split decision, or developer assignments. Do not use to make unapproved production changes.\",\"markdown\":\"---\\nname: technical-architecture-and-delegation\\ndescription: >\\n Use when a development request needs technical discovery, stack selection, architecture decisions, a fullstack-versus-split decision, or developer assignments. Do not use to make unapproved production changes.\\n---\\n\\n# Technical architecture and delegation\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect repository instructions, stack and versions, interfaces, data, deployment path, and constraints.\\n2. Define the smallest architecture that meets the approved outcome.\\n3. Choose one implementation owner or split work only when interfaces are stable and risk justifies it.\\n4. Write acceptance checks, security and privacy requirements, dependencies, test evidence, and release conditions.\\n\\n## Expected result\\n\\nA short technical decision record and implementation plan with named owners, interfaces, risks, and verification evidence.\\n\\n## Stop and escalate\\n\\nEscalate unknown production access, regulated data, security findings, major migrations, and infrastructure spend to the human Owner.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/org/org-structure/\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n\"},{\"slug\":\"n8n-workflow-design-and-operations\",\"title\":\"n8n workflow design and operations\",\"description\":\"Use when assessing, designing, implementing, testing, or handing off an approved n8n automation or MCP-exposed workflow.\",\"markdown\":\"---\\nname: n8n-workflow-design-and-operations\\ndescription: >\\n Use when assessing, designing, implementing, testing, or handing off an approved n8n automation or MCP-exposed workflow.\\n---\\n\\n# n8n workflow design and operations\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm the CEO-selected approach, workflow owner, company instance, permitted data, and task acceptance criteria.\\n2. Map triggers, inputs, data movement, side effects, credentials, retries, idempotency, and failure handling before building.\\n3. Build the smallest maintainable workflow in a development or test environment; keep complex reusable business logic in versioned code where that improves testability.\\n4. Test expected, malformed, duplicate, timeout, rate-limit, and partial-failure cases and preserve redacted execution evidence.\\n5. Document monitoring, alerting, recovery, rollback, credential ownership, and human approval required before production activation.\\n\\n## Expected result\\n\\nA workflow design or handoff with owner, version, environment, data flow, integrations, test evidence, residual risks, monitoring, recovery, and approval state.\\n\\n## Stop and escalate\\n\\nStop before production activation, external messaging, destructive changes, or access to another company's data unless the assigned task and authorized human approval explicitly permit the action. Never expose secrets or unnecessary personal data.\\n\\n## References\\n\\n- https://docs.n8n.io/connect/connect-to-n8n-mcp-server/\\n- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/\\n- https://docs.n8n.io/hosting/security/\\n\"},{\"slug\":\"operating-cadence-and-handoffs\",\"title\":\"Operating cadence and handoffs\",\"description\":\"Use when preparing a daily or weekly operating brief, coordinating cross-team dependencies, or diagnosing recurring workflow friction. Do not use to change company strategy or make external commitments.\",\"markdown\":\"---\\nname: operating-cadence-and-handoffs\\ndescription: >\\n Use when preparing a daily or weekly operating brief, coordinating cross-team dependencies, or diagnosing recurring workflow friction. Do not use to change company strategy or make external commitments.\\n---\\n\\n# Operating cadence and handoffs\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read only approved priorities, task statuses, deadlines, and permitted service summaries.\\n2. Separate evidence, estimates, blockers, and owner decisions.\\n3. Rank the three most material actions and name one accountable owner for each.\\n4. Record dependencies, escalation routes, and a review date for any proposed process pilot.\\n\\n## Expected result\\n\\nAn owner-ready operating brief or handoff with status, priorities, accountable owners, evidence, and decisions required.\\n\\n## Stop and escalate\\n\\nDo not message customers, move money, reassign work against the reporting tree, or expose unnecessary personal data.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/org/org-structure/\\n- https://docs.paperclip.ing/guides/projects-workflow/routines/\\n\"},{\"slug\":\"qa-and-release\",\"title\":\"Risk-based QA and release\",\"description\":\"Use when planning tests, validating acceptance criteria, checking regressions, or preparing release evidence for a software change. Do not treat passing tests as proof of zero risk.\",\"markdown\":\"---\\nname: qa-and-release\\ndescription: >\\n Use when planning tests, validating acceptance criteria, checking regressions, or preparing release evidence for a software change. Do not treat passing tests as proof of zero risk.\\n---\\n\\n# Risk-based QA and release\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Map each acceptance criterion to a reproducible check.\\n2. Prioritize user journeys, data boundaries, failure states, integrations, and supported versions by risk.\\n3. Run authorized local or staging checks and preserve commands, results, and defects.\\n4. Review unresolved findings, migration safety, monitoring, backup, rollback, and required approvals.\\n\\n## Expected result\\n\\nA risk-based test plan, reproducible findings, coverage limits, and release recommendation.\\n\\n## Stop and escalate\\n\\nBlock release recommendation for unresolved critical findings, missing authorization, or absent recovery evidence.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/agent-developer/writing-a-skill/\\n- https://github.com/microsoft/playwright-mcp\\n\"},{\"slug\":\"customer-care-triage\",\"title\":\"Customer care triage\",\"description\":\"Use when classifying customer messages, answering approved routine questions, preparing a support reply, or escalating a complaint or sensitive case. Do not provide unapproved legal, medical, safety, or financial advice.\",\"markdown\":\"---\\nname: customer-care-triage\\ndescription: >\\n Use when classifying customer messages, answering approved routine questions, preparing a support reply, or escalating a complaint or sensitive case. Do not provide unapproved legal, medical, safety, or financial advice.\\n---\\n\\n# Customer care triage\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Check the company support policy, approved answer source, queue permissions, and response authority.\\n2. Classify intent, urgency, sensitivity, and responsible service owner.\\n3. Use only current approved facts; draft when send authority is absent.\\n4. Route uncertain or sensitive requests to a named human or qualified professional and record a minimized handoff.\\n\\n## Expected result\\n\\nA categorized queue item, approved answer or draft, or clear escalation with next action and owner.\\n\\n## Stop and escalate\\n\\nNever promise a legal, medical, refund, compliance, or commercial outcome. Minimize personal data and escalate potential harm or formal complaints.\\n\\n## References\\n\\n- https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679\\n\"},{\"slug\":\"market-and-competitor-research\",\"title\":\"Market and competitor research\",\"description\":\"Use when investigating an audience, market opportunity, competitor offer, pricing, demand signal, or channel pattern. Do not present estimates as verified facts or infer private data.\",\"markdown\":\"---\\nname: market-and-competitor-research\\ndescription: >\\n Use when investigating an audience, market opportunity, competitor offer, pricing, demand signal, or channel pattern. Do not present estimates as verified facts or infer private data.\\n---\\n\\n# Market and competitor research\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Define the decision the research must support and the permitted sources.\\n2. Collect dated evidence about customer needs, competitor offers, pricing, positioning, and channel presence.\\n3. Separate observations, estimates, and hypotheses; record source, method, freshness, and confidence.\\n4. Synthesize opportunity, counter-evidence, unknowns, and what should be tested next.\\n\\n## Expected result\\n\\nA concise source-linked research brief with evidence, limitations, opportunity hypotheses, and next validation step.\\n\\n## Stop and escalate\\n\\nDo not use restricted sources, infer sensitive traits, or claim market size or demand without a traceable method.\\n\\n## References\\n\\n- https://support.google.com/trends/answer/4365533\\n- https://github.com/HubSpot/agent-cli-skills\\n\"},{\"slug\":\"brand-positioning-and-creative-brief\",\"title\":\"Brand positioning and creative brief\",\"description\":\"Use when turning approved customer evidence into positioning, a campaign angle, creative direction, or a brief for visual assets. Do not invent company proof or change approved brand commitments.\",\"markdown\":\"---\\nname: brand-positioning-and-creative-brief\\ndescription: >\\n Use when turning approved customer evidence into positioning, a campaign angle, creative direction, or a brief for visual assets. Do not invent company proof or change approved brand commitments.\\n---\\n\\n# Brand positioning and creative brief\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read approved company voice, offers, proof, and audience context.\\n2. Translate research into a customer problem, differentiated value, reason to believe, and message hierarchy.\\n3. Define creative concept, format, audience, placement, accessibility, and claim limits.\\n4. Present alternatives and evidence for owner review before production or publication.\\n\\n## Expected result\\n\\nA positioning statement and creative brief with audience, insight, promise, support, concept, format, and review needs.\\n\\n## Stop and escalate\\n\\nFlag unsupported claims, sensitive imagery, unclear rights, and any material change to brand promises.\\n\\n## References\\n\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"content-strategy-planning\",\"title\":\"Content strategy planning\",\"description\":\"Use when planning an editorial series, content calendar, audience education sequence, or reusable campaign content. Do not create volume without an audience need and measurable purpose.\",\"markdown\":\"---\\nname: content-strategy-planning\\ndescription: >\\n Use when planning an editorial series, content calendar, audience education sequence, or reusable campaign content. Do not create volume without an audience need and measurable purpose.\\n---\\n\\n# Content strategy planning\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Start from approved audience questions, campaign objective, and source material.\\n2. Choose content themes, formats, channel roles, sequence, and an intended audience action.\\n3. Assign source checks, specialist review, voice review, owner, and publication date.\\n4. Define success measures and reuse rules before the content is produced.\\n\\n## Expected result\\n\\nAn editorial brief or calendar with themes, audience intent, formats, owners, sources, reviewers, and measures.\\n\\n## Stop and escalate\\n\\nPause on unsupported factual claims, regulated topics without qualified review, or reuse of identifiable customer stories without consent.\\n\\n## References\\n\\n- https://developers.google.com/search/docs/fundamentals/creating-helpful-content\\n\"},{\"slug\":\"evidence-based-copywriting\",\"title\":\"Evidence-based copywriting\",\"description\":\"Use when drafting or revising customer-facing marketing copy, a landing page, offer, advertisement, or email. Do not fabricate proof, urgency, scarcity, or guaranteed outcomes.\",\"markdown\":\"---\\nname: evidence-based-copywriting\\ndescription: >\\n Use when drafting or revising customer-facing marketing copy, a landing page, offer, advertisement, or email. Do not fabricate proof, urgency, scarcity, or guaranteed outcomes.\\n---\\n\\n# Evidence-based copywriting\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read the approved voice, offer, audience, and evidence in company context.\\n2. Identify the audience problem, single promise, reason to believe, and next action.\\n3. Draft plainly with claims tied to named evidence and limits.\\n4. Check clarity, accessibility, channel fit, required review, and approval before publication.\\n\\n## Expected result\\n\\nA copy draft with audience, purpose, source notes for factual claims, CTA, and open approvals.\\n\\n## Stop and escalate\\n\\nEscalate health, safety, legal, financial, comparative, quantified, or testimonial claims for documented review.\\n\\n## References\\n\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"seo-audit-and-search-content\",\"title\":\"SEO audit and search content\",\"description\":\"Use when diagnosing organic-search visibility, prioritizing an SEO issue, or preparing a search-focused content brief. Do not promise rankings or use manipulative tactics.\",\"markdown\":\"---\\nname: seo-audit-and-search-content\\ndescription: >\\n Use when diagnosing organic-search visibility, prioritizing an SEO issue, or preparing a search-focused content brief. Do not promise rankings or use manipulative tactics.\\n---\\n\\n# SEO audit and search content\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Check the site's technical and content context and identify the target user intent.\\n2. Use permitted Search Console or analytics evidence; distinguish query data from guesses.\\n3. Prioritize crawl, index, performance, accessibility, and content-quality issues by impact and confidence.\\n4. Write a change brief with current state, recommended action, validation evidence, and review date.\\n\\n## Expected result\\n\\nA prioritized SEO issue list or content brief with evidence and validation steps.\\n\\n## Stop and escalate\\n\\nDo not create doorway pages, mass-generated thin content, fake backlinks, or unsupported structured data.\\n\\n## References\\n\\n- https://developers.google.com/search/docs/fundamentals/creating-helpful-content\\n- https://developers.google.com/search/docs/crawling-indexing\\n\"},{\"slug\":\"paid-media-testing\",\"title\":\"Paid media testing\",\"description\":\"Use when designing, reviewing, or analyzing a paid advertising test. Do not launch ads, change bids, or spend budget without explicit authorization.\",\"markdown\":\"---\\nname: paid-media-testing\\ndescription: >\\n Use when designing, reviewing, or analyzing a paid advertising test. Do not launch ads, change bids, or spend budget without explicit authorization.\\n---\\n\\n# Paid media testing\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm approved offer, audience, destination, budget envelope, and claim evidence.\\n2. Define campaign structure, conversion event, exclusions, creative variants, and tracking checks.\\n3. Set baseline, success threshold, stop rule, review window, and accountable human approver.\\n4. Analyze results with spend, qualified outcomes, attribution limits, and risks stated separately.\\n\\n## Expected result\\n\\nAn approval-ready test plan or evidence-based performance report.\\n\\n## Stop and escalate\\n\\nStop on tracking failure, unapproved claims, spend-limit uncertainty, audience-policy risk, or unapproved account changes.\\n\\n## References\\n\\n- https://developers.google.com/google-ads/api/docs/developer-toolkit/mcp-server/\\n- https://github.com/google/agent-skills\\n\"},{\"slug\":\"social-channel-operations\",\"title\":\"Organic social channel operations\",\"description\":\"Use when adapting approved campaign material to social channels, planning a publishing schedule, or preparing moderation guidance. Do not publish or engage in disputes without authorization.\",\"markdown\":\"---\\nname: social-channel-operations\\ndescription: >\\n Use when adapting approved campaign material to social channels, planning a publishing schedule, or preparing moderation guidance. Do not publish or engage in disputes without authorization.\\n---\\n\\n# Organic social channel operations\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm channel, audience, campaign objective, source facts, and approved voice.\\n2. Adapt one idea to the platform's format without changing its evidence or promise.\\n3. Prepare accessible assets, caption, CTA, alt text, timing, and moderation route.\\n4. Submit drafts for approval and record performance or recurring audience questions.\\n\\n## Expected result\\n\\nA channel-ready draft pack and schedule with sources, owner, moderation plan, and approval status.\\n\\n## Stop and escalate\\n\\nEscalate complaints, legal threats, sensitive disclosures, harassment, misinformation risk, or unclear response authority.\\n\\n## References\\n\\n- https://github.com/anthropics/skills/tree/main/skills/internal-comms\\n\"},{\"slug\":\"lifecycle-email-campaigns\",\"title\":\"Lifecycle email campaigns\",\"description\":\"Use when drafting a consent-based onboarding, lifecycle, retention, or customer update email sequence. Do not send to a list without approved audience basis and suppression checks.\",\"markdown\":\"---\\nname: lifecycle-email-campaigns\\ndescription: >\\n Use when drafting a consent-based onboarding, lifecycle, retention, or customer update email sequence. Do not send to a list without approved audience basis and suppression checks.\\n---\\n\\n# Lifecycle email campaigns\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm audience source, communication purpose, legal basis or consent policy, and suppression rules.\\n2. Map the sequence to a customer lifecycle need and one clear action per message.\\n3. Draft subject, body, sender, preference and unsubscribe handling, and tracking.\\n4. Review claims, deliverability, segmentation, and approval before sending; measure meaningful outcomes.\\n\\n## Expected result\\n\\nAn email sequence brief or draft set with audience rules, timing, suppression, approval, and measures.\\n\\n## Stop and escalate\\n\\nStop if contact permission, opt-out handling, sender identity, or sensitive segmentation is unclear.\\n\\n## References\\n\\n- https://developers.google.com/workspace/guides/configure-mcp-servers\\n\"},{\"slug\":\"marketing-measurement\",\"title\":\"Marketing measurement and analysis\",\"description\":\"Use when defining campaign events, checking tracking, analyzing funnel performance, or preparing a marketing report. Do not change campaigns, budgets, or landing pages based on analysis alone.\",\"markdown\":\"---\\nname: marketing-measurement\\ndescription: >\\n Use when defining campaign events, checking tracking, analyzing funnel performance, or preparing a marketing report. Do not change campaigns, budgets, or landing pages based on analysis alone.\\n---\\n\\n# Marketing measurement and analysis\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm objective, metric definitions, reporting period, data source, and known attribution limits.\\n2. Check event coverage and data quality before comparing results.\\n3. Analyze funnel stages with denominators, segments, and uncertainty visible.\\n4. Explain supported findings and recommend a test or decision for the accountable owner.\\n\\n## Expected result\\n\\nA measurement plan, source-linked analysis, or decision brief with definitions, limitations, and next action.\\n\\n## Stop and escalate\\n\\nDo not infer personal behavior beyond authorized aggregation or make causal claims from descriptive data alone.\\n\\n## References\\n\\n- https://developers.google.com/analytics/devguides/MCP\\n- https://posthog.com/docs/model-context-protocol\\n\"},{\"slug\":\"leadgen-strategy-and-funnel\",\"title\":\"Lead generation strategy and funnel\",\"description\":\"Use when defining an ideal customer segment, acquisition funnel, qualification criteria, channel test, or handoff to Sales. Do not maximize raw lead volume without fit and contact safeguards.\",\"markdown\":\"---\\nname: leadgen-strategy-and-funnel\\ndescription: >\\n Use when defining an ideal customer segment, acquisition funnel, qualification criteria, channel test, or handoff to Sales. Do not maximize raw lead volume without fit and contact safeguards.\\n---\\n\\n# Lead generation strategy and funnel\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read approved offer, market evidence, privacy boundaries, and Sales acceptance criteria.\\n2. Define target segment, observable intent signals, exclusions, and conversion event.\\n3. Select a bounded channel experiment with source, cost/effort limit, and stop rule.\\n4. Agree qualification fields and handoff timing with the Sales owner; measure quality through the funnel.\\n\\n## Expected result\\n\\nA segment and funnel brief with qualification, contact rules, channel test, owner, measures, and handoff.\\n\\n## Stop and escalate\\n\\nEscalate unclear contact basis, sensitive profiling, purchased lists, or unsupported targeting data.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server\\n\"},{\"slug\":\"prospect-research-and-data-quality\",\"title\":\"Prospect research and data quality\",\"description\":\"Use when researching or cleaning a business prospect list for an approved purpose. Do not infer sensitive personal traits or treat public data as permission to contact.\",\"markdown\":\"---\\nname: prospect-research-and-data-quality\\ndescription: >\\n Use when researching or cleaning a business prospect list for an approved purpose. Do not infer sensitive personal traits or treat public data as permission to contact.\\n---\\n\\n# Prospect research and data quality\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm research purpose, allowed sources, minimum fields, and contact policy.\\n2. Capture source, retrieval date, freshness, and confidence for important fields.\\n3. Check relevance, duplicates, exclusions, and conflicting information.\\n4. Return only necessary fields and document records removed or needing human review.\\n\\n## Expected result\\n\\nA source-linked prospect or segment evidence table with quality flags and permitted handoff fields.\\n\\n## Stop and escalate\\n\\nDo not scrape restricted sites, fabricate contact details, or export data without approved use and access.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679\\n\"},{\"slug\":\"outreach-campaign-operations\",\"title\":\"Outreach campaign operations\",\"description\":\"Use when preparing an approved outbound outreach sequence, audience rules, or campaign results report. Do not send messages or bypass suppression and opt-out controls.\",\"markdown\":\"---\\nname: outreach-campaign-operations\\ndescription: >\\n Use when preparing an approved outbound outreach sequence, audience rules, or campaign results report. Do not send messages or bypass suppression and opt-out controls.\\n---\\n\\n# Outreach campaign operations\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Verify approved offer, list source, contact basis, segment, and exclusions.\\n2. Draft concise, relevant messages with honest personalization and a clear next step.\\n3. Check suppression, opt-out, frequency, sender, and CRM handoff rules.\\n4. Submit for approval; after authorized launch, report replies, qualified outcomes, complaints, and opt-outs.\\n\\n## Expected result\\n\\nAn outreach draft pack and launch checklist, or a campaign results and stop recommendation.\\n\\n## Stop and escalate\\n\\nPause on unclear permission, complaints, misleading claims, sensitive data, or missing unsubscribe handling.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server\\n\"},{\"slug\":\"administrative-operations-coordination\",\"title\":\"Administrative operations coordination\",\"description\":\"Use when converting internal decisions into action logs, coordinating administrative requests, or preparing routine operating records. Do not commit funds, sign agreements, or send external messages without approval.\",\"markdown\":\"---\\nname: administrative-operations-coordination\\ndescription: >\\n Use when converting internal decisions into action logs, coordinating administrative requests, or preparing routine operating records. Do not commit funds, sign agreements, or send external messages without approval.\\n---\\n\\n# Administrative operations coordination\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm requester, purpose, due date, source record, and approving owner.\\n2. Separate decisions from discussion and assign one owner per action.\\n3. Prepare a reversible draft, calendar entry, or checklist using approved systems.\\n4. Record approval, completion evidence, and unresolved items in the source of truth.\\n\\n## Expected result\\n\\nA clear action record, request route, deadline list, or approval-ready administrative draft.\\n\\n## Stop and escalate\\n\\nEscalate legal, financial, access, privacy, and regulated-record decisions to their named owner.\\n\\n## References\\n\\n- https://developers.google.com/workspace/guides/configure-mcp-servers\\n\"},{\"slug\":\"finance-administration-review\",\"title\":\"Finance administration review\",\"description\":\"Use when reconciling source records, preparing invoice status, checking finance totals, or drafting an approval-ready payment pack. Do not execute payments or provide tax or accounting advice.\",\"markdown\":\"---\\nname: finance-administration-review\\ndescription: >\\n Use when reconciling source records, preparing invoice status, checking finance totals, or drafting an approval-ready payment pack. Do not execute payments or provide tax or accounting advice.\\n---\\n\\n# Finance administration review\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm reporting period, currency, accounting owner, and authoritative source records.\\n2. Reconcile totals and preserve references to source documents.\\n3. Separate actuals, estimates, forecasts, and assumptions; explain variances.\\n4. Prepare proposed actions for review and record the human decision.\\n\\n## Expected result\\n\\nA traceable reconciliation, invoice list, variance note, or approval-ready finance pack.\\n\\n## Stop and escalate\\n\\nEscalate missing evidence, unusual payment changes, tax judgments, bank-detail changes, and payment execution.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n\"},{\"slug\":\"records-and-document-control\",\"title\":\"Records and document control\",\"description\":\"Use when maintaining a document register, checking versions and approvals, or preparing a controlled record for sharing. Do not delete records or invent retention periods.\",\"markdown\":\"---\\nname: records-and-document-control\\ndescription: >\\n Use when maintaining a document register, checking versions and approvals, or preparing a controlled record for sharing. Do not delete records or invent retention periods.\\n---\\n\\n# Records and document control\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm record owner, authoritative location, purpose, sensitivity, and access scope.\\n2. Check version, approval status, date, and duplicate or stale copies.\\n3. Apply the approved naming and filing convention while preserving the source.\\n4. Record missing records, access questions, or retention decisions for the authorized owner.\\n\\n## Expected result\\n\\nAn evidence index, document inventory, version history, or minimized sharing proposal.\\n\\n## Stop and escalate\\n\\nEscalate legal holds, health or case records, deletion, external sharing, and retention changes.\\n\\n## References\\n\\n- https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679\\n\"},{\"slug\":\"sales-pipeline-management\",\"title\":\"Sales pipeline management\",\"description\":\"Use when defining sales stages, reviewing pipeline quality, preparing a forecast, or improving the lead handoff from Marketing. Do not invent forecast certainty or change approved prices.\",\"markdown\":\"---\\nname: sales-pipeline-management\\ndescription: >\\n Use when defining sales stages, reviewing pipeline quality, preparing a forecast, or improving the lead handoff from Marketing. Do not invent forecast certainty or change approved prices.\\n---\\n\\n# Sales pipeline management\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm approved offers, stage definitions, decision roles, and the reporting period.\\n2. Check stage evidence, next action, owner, value, and close conditions.\\n3. Identify stalled, unsupported, duplicate, or no-fit opportunities.\\n4. Summarize supported pipeline ranges, assumptions, handoffs, and owner decisions.\\n\\n## Expected result\\n\\nA stage definition, pipeline review, forecast range, and next-step owner list.\\n\\n## Stop and escalate\\n\\nEscalate pricing, contractual terms, claims, customer data access, and unsupported forecast assumptions.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n\"},{\"slug\":\"sales-lead-qualification\",\"title\":\"Sales lead qualification\",\"description\":\"Use when responding to a new enquiry, preparing discovery questions, or deciding whether a prospect meets approved fit and intent criteria. Do not pressure or mislead a buyer.\",\"markdown\":\"---\\nname: sales-lead-qualification\\ndescription: >\\n Use when responding to a new enquiry, preparing discovery questions, or deciding whether a prospect meets approved fit and intent criteria. Do not pressure or mislead a buyer.\\n---\\n\\n# Sales lead qualification\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Check approved offer, qualification rules, response-time expectations, and contact history.\\n2. Ask only relevant questions about need, context, timing, decision process, and fit.\\n3. Record facts and direct quotes separately from hypotheses.\\n4. Route qualified prospects to the right seller and provide a clear next step or respectful no-fit response.\\n\\n## Expected result\\n\\nA concise qualification record, discovery brief, follow-up draft, or reasoned no-fit outcome.\\n\\n## Stop and escalate\\n\\nEscalate sensitive, regulated, legal, clinical, financial, or complaint-related enquiries.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n\"},{\"slug\":\"consultative-sales-proposals\",\"title\":\"Consultative sales proposals\",\"description\":\"Use when preparing a discovery summary, proposal, objection response, or customer follow-up for an approved offer. Do not promise outcomes outside the approved scope.\",\"markdown\":\"---\\nname: consultative-sales-proposals\\ndescription: >\\n Use when preparing a discovery summary, proposal, objection response, or customer follow-up for an approved offer. Do not promise outcomes outside the approved scope.\\n---\\n\\n# Consultative sales proposals\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Summarize the buyer's stated problem, decision criteria, and desired outcome.\\n2. Match needs to an approved offer and identify gaps or exclusions.\\n3. Draft scope, deliverables, price source, assumptions, timing, and responsibilities.\\n4. Request human approval before sending and record the customer's decision and next step.\\n\\n## Expected result\\n\\nAn evidence-based discovery note, proposal draft, or buyer decision plan.\\n\\n## Stop and escalate\\n\\nDo not invent discounts, deadlines, guarantees, legal conclusions, or product capabilities.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"engineering-delivery-baseline\",\"title\":\"Engineering delivery baseline\",\"description\":\"Use for software implementation tasks across Next.js, MEAN, and WordPress repositories. Do not use to bypass repository instructions, tests, security review, or task approval.\",\"markdown\":\"---\\nname: engineering-delivery-baseline\\ndescription: >\\n Use for software implementation tasks across Next.js, MEAN, and WordPress repositories. Do not use to bypass repository instructions, tests, security review, or task approval.\\n---\\n\\n# Engineering delivery baseline\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect the repository's instructions, existing patterns, versions, and relevant tests before changing files.\\n2. Restate the acceptance criteria and make the smallest scoped change.\\n3. Use authorized checks that match the task risk and project conventions; record commands and results.\\n4. Review the final diff for scope, security, regressions, documentation, and a clear handoff.\\n\\n## Expected result\\n\\nA scoped implementation with acceptance evidence, known limitations, and reviewer-ready change summary.\\n\\n## Stop and escalate\\n\\nDo not expose secrets, write production data, change unrelated architecture, or claim a check passed when it was not run.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/agent-developer/writing-a-skill/\\n- https://github.com/github/github-mcp-server\\n\"},{\"slug\":\"nextjs-development\",\"title\":\"Next.js development\",\"description\":\"Use when implementing or reviewing a Next.js feature, route, server action, API boundary, rendering behavior, or performance issue. Do not assume a router, runtime, cache, or Next.js version.\",\"markdown\":\"---\\nname: nextjs-development\\ndescription: >\\n Use when implementing or reviewing a Next.js feature, route, server action, API boundary, rendering behavior, or performance issue. Do not assume a router, runtime, cache, or Next.js version.\\n---\\n\\n# Next.js development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read package manifests and repository guidance to identify Next.js version, App/Pages Router, runtime, and test setup.\\n2. Keep server-only secrets and privileged logic out of client bundles.\\n3. Follow the existing data-fetching, caching, authentication, and route patterns.\\n4. Use Next.js DevTools only when the documented version and local development-server prerequisites are met; verify behavior with project checks.\\n\\n## Expected result\\n\\nA version-aligned implementation or review with server/client boundaries and test evidence.\\n\\n## Stop and escalate\\n\\nEscalate new database, authentication, runtime, or deployment choices that exceed task scope.\\n\\n## References\\n\\n- https://nextjs.org/docs/app/guides/ai-agents\\n- https://nextjs.org/docs/app/guides/mcp\\n- https://github.com/vercel/next.js/tree/canary/skills\\n\"},{\"slug\":\"mean-stack-development\",\"title\":\"MEAN stack development\",\"description\":\"Use when implementing a feature across Angular, Node/Express, and MongoDB, or when working on one of those layers in a MEAN application. Do not assume library versions or production database access.\",\"markdown\":\"---\\nname: mean-stack-development\\ndescription: >\\n Use when implementing a feature across Angular, Node/Express, and MongoDB, or when working on one of those layers in a MEAN application. Do not assume library versions or production database access.\\n---\\n\\n# MEAN stack development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect Angular, Node, Express, MongoDB, and data-access versions and existing boundaries.\\n2. Define typed API and validation contracts before changing dependent layers.\\n3. Use development data and review schema, index, migration, authorization, and query behavior.\\n4. Run appropriate unit, API, build, and browser checks and document results.\\n\\n## Expected result\\n\\nA coherent layer-specific or vertical-slice change with API, persistence, and UI evidence.\\n\\n## Stop and escalate\\n\\nDo not run destructive operations or production CRUD through MongoDB MCP; escalate schema changes and sensitive data access.\\n\\n## References\\n\\n- https://angular.dev/ai/agent-skills\\n- https://angular.dev/ai/mcp\\n- https://www.mongodb.com/docs/mcp-server/overview/\\n- https://expressjs.com/advanced/best-practice-security/\\n\"},{\"slug\":\"wordpress-site-maintenance\",\"title\":\"WordPress site maintenance\",\"description\":\"Use when diagnosing or maintaining a WordPress site, configuration, integration, upgrade, or migration. Do not edit WordPress core or run unapproved production changes.\",\"markdown\":\"---\\nname: wordpress-site-maintenance\\ndescription: >\\n Use when diagnosing or maintaining a WordPress site, configuration, integration, upgrade, or migration. Do not edit WordPress core or run unapproved production changes.\\n---\\n\\n# WordPress site maintenance\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Identify WordPress, PHP, hosting, theme, plugin, and deployment versions and the site's existing architecture.\\n2. Reproduce the issue in local or staging and identify the responsible layer.\\n3. Prefer supported APIs, WP-CLI, reversible configuration, and documented migration steps.\\n4. Check backup, compatibility, permissions, performance, accessibility, and rollback evidence.\\n\\n## Expected result\\n\\nA bounded site fix or an upgrade/integration plan with reproducible checks and rollback notes.\\n\\n## Stop and escalate\\n\\nRequire human approval, backup, and rollback for production writes, migrations, credentials, or plugin changes.\\n\\n## References\\n\\n- https://developer.wordpress.org/\\n- https://developer.wordpress.org/cli/commands/\\n\"},{\"slug\":\"wordpress-plugin-development\",\"title\":\"WordPress plugin development\",\"description\":\"Use when designing, implementing, testing, or reviewing a WordPress plugin or custom functional extension. Do not edit WordPress core or third-party plugin source.\",\"markdown\":\"---\\nname: wordpress-plugin-development\\ndescription: >\\n Use when designing, implementing, testing, or reviewing a WordPress plugin or custom functional extension. Do not edit WordPress core or third-party plugin source.\\n---\\n\\n# WordPress plugin development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect supported WordPress/PHP versions, plugin structure, hooks, APIs, and existing tests.\\n2. Check capabilities and authorization, nonces, validation, sanitization, escaping, and data lifecycle.\\n3. Implement the smallest change using supported extension points.\\n4. Run authorized checks and prepare compatibility, upgrade, security, and release evidence.\\n\\n## Expected result\\n\\nA maintainable plugin change with permission, data, compatibility, test, and release notes.\\n\\n## Stop and escalate\\n\\nEscalate external service calls, sensitive data, destructive migrations, and live-site writes.\\n\\n## References\\n\\n- https://developer.wordpress.org/plugins/\\n- https://developer.wordpress.org/plugins/security/\\n- https://github.com/WordPress/agent-skills\\n\"},{\"slug\":\"wordpress-theme-development\",\"title\":\"WordPress theme development\",\"description\":\"Use when implementing or reviewing a WordPress theme, block theme, template, pattern, theme.json setting, or editor/front-end presentation. Do not put persistent business logic in a theme.\",\"markdown\":\"---\\nname: wordpress-theme-development\\ndescription: >\\n Use when implementing or reviewing a WordPress theme, block theme, template, pattern, theme.json setting, or editor/front-end presentation. Do not put persistent business logic in a theme.\\n---\\n\\n# WordPress theme development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Identify classic or block theme architecture, supported versions, theme.json, and design tokens.\\n2. Make presentation changes in the correct template, pattern, or style layer.\\n3. Check responsive behavior, editor/front-end parity, accessibility, and performance.\\n4. Capture visual and automated evidence for relevant templates and states.\\n\\n## Expected result\\n\\nA focused theme change with responsive, accessible, editor, and visual evidence.\\n\\n## Stop and escalate\\n\\nRoute persistent data, business logic, and functional integrations to a plugin or application layer.\\n\\n## References\\n\\n- https://developer.wordpress.org/themes/\\n- https://developer.wordpress.org/themes/global-settings-and-styles/\\n- https://github.com/WordPress/agent-skills\\n\"},{\"slug\":\"run-playbook\",\"title\":\"Run a playbook\",\"description\":\"Use when a Paperclip task carries a playbook, when you are asked to start one, or when your assigned task is a step of a playbook run (a child task created from a flow). Do not use for ordinary tasks that no playbook covers.\",\"markdown\":\"---\\nname: run-playbook\\ndescription: >\\n Use when a Paperclip task carries a playbook, when you are asked to start one, or when your assigned task is a step of a playbook run (a child task created from a flow). Do not use for ordinary tasks that no playbook covers.\\n---\\n\\n# Run a playbook\\n\\nThis is an original, markdown-only Paperclip skill. It guides work; it does not grant access, make approvals, or replace Paperclip's own task status. Paperclip has no native playbook object: this skill builds the flow out of native tasks, blockers, task documents and execution policies.\\n\\n## Two kinds of playbook\\n\\n- **Checklist** \u2014 `PLAYBOOKS/NN-*.md` in your role folder. Ordered steps for one agent inside one task.\\n- **Flow** \u2014 `PLAYBOOKS/flows/*.yaml` in the folder of the role that owns it. Steps belong to different roles; each `task` step becomes its own Paperclip task, chained with blockers.\\n\\nIf no playbook fits, use the default delivery checklist below.\\n\\n## Run a checklist (one agent, one task)\\n\\n1. Keep the run register in the task document with key `playbook` (format: `templates/PLAYBOOK-REGISTER.md`, shown in the task as plain Markdown). If the document already exists, read it and resume; never start a second run.\\n2. Fill the header: task, one owner, approved outcome and acceptance checks, assumptions, escalation owner, Owner approval status. Copy the steps in order; step 1 is IN_PROGRESS, the rest PENDING.\\n3. Work one step at a time. A step becomes PASS only with evidence on its line (link, artifact, task comment, check output). Then activate only the next step.\\n4. When blocked, mark the step BLOCKED with the reason and who must act, leave later steps PENDING, and put the Paperclip task itself in a waiting state: `blocked` with `blockedByIssueIds`, or a pending interaction with `in_review` for a human decision. Text in the register alone does not stop or wake anyone. Then stop.\\n5. Update the document with the revision-safe procedure of the Paperclip skill (`PUT /api/issues/{issueId}/documents/playbook`, send `baseRevisionId` on updates, reconcile on `409`).\\n6. If you can run scripts, `node validate-run.mjs <register-file>` checks the register (0 valid, 2 valid but halted, 1 invalid). If you cannot run it, check the rules by hand: one IN_PROGRESS step, earlier steps PASS, later steps PENDING, evidence on every PASS.\\n7. When every step is PASS, post an evidence summary and set the task `done`. If the task has an execution policy, `done` moves it to review or approval: that is expected, not an error.\\n\\n## Run a flow (owner role)\\n\\nOnly the agent whose role is the flow's `owner_role` starts it, and only for a task the Owner has approved.\\n\\n1. Read the flow file. Confirm every item in `inputs` from the task text; if one is missing, ask the Owner in the task and stop.\\n2. Resolve each `role` to an active agent with the team briefing tool (`get-team-briefing`) or the company agent list. If a role has no active agent, mark the run BLOCKED and ask the Owner; never substitute another role silently.\\n3. Write the register in the parent task's `playbook` document, listing every step with its owner.\\n4. Create the steps of the current phase. For each `mode: task` step create a child task: `parentId` = the parent task, the assignee, a title, a description with `done_when`, the evidence required and a link to the parent register, and `blockedByIssueIds` = the child tasks of its `depends_on` steps (status `blocked` if it has blockers, otherwise `todo`). Create in dependency order. For a step with `review`, set the task's `executionPolicy` with a `review` stage whose participant is that reviewer; if the API refuses it for your role, ask the Owner to set it in the task. `mode: checklist` steps stay as lines in the parent register, handled by you.\\n5. Slots (`slots:`) name a role chosen by an earlier step. Create the steps that use a slot only after the choosing step is done: Paperclip wakes you when all current children are terminal, then you create the next phase.\\n6. Paperclip wakes each assignee when its blockers are done and wakes you when all children are done. On each wake, copy the child result into the register as PASS with evidence (or BLOCKED), then continue.\\n7. Close out: check every acceptance check against the evidence, post the summary, and set the parent `done`.\\n\\n## With the Playbook Runner plugin\\n\\nIf the tools `playbook-start-flow`, `playbook-complete-step`, `playbook-review-verdict` and `playbook-status` are available, use them instead of creating tasks by hand. As the owner, pass the flow file's text to `playbook-start-flow`: roles are matched to agents by name or title, and you only pass `assignees` (role \u2192 agent id) for the ones it reports as not found. A step with `approval: owner` needs `ownerApproval` (the reference to the Owner's approval, obtained through the CEO) when you close it; close your checklist steps with `playbook-complete-step` (this also supplies the implementer or channel roles you chose). As a reviewer, give your verdict with `playbook-review-verdict`, never by just setting the review task done. The plugin counts the review rounds and opens the escalation task itself. If you hold an escalation task: when you resolved it, set that task done (a new review cycle starts); when your one attempt failed, call `playbook-escalate` with what you tried, and the case goes to the next level (sector head \u2192 CEO \u2192 Owner).\\n\\n## You were assigned a step of a flow\\n\\nRead your task description and the parent register. Do the work inside the stated scope, record the evidence in a task comment, then set the task `done`. A reviewer may follow because of the task's execution policy; if they request changes, fix what they listed and resubmit. If you cannot finish for a reason outside your control, set the task `blocked` and say what is needed and from whom.\\n\\n## Default delivery checklist\\n\\n1. Confirm the assigned task, scope, acceptance checks, owner, dependencies and latest status.\\n2. Inspect the relevant repository, source material, account evidence or existing deliverable; record material unknowns.\\n3. Write the smallest complete plan with assumptions, risks, ordered actions and the evidence you will provide.\\n4. Do the role work in scope and preserve established sources of truth.\\n5. Check each acceptance item against evidence; list gaps, unavailable checks and blockers.\\n6. Attach evidence and hand off in Paperclip; update only your own task.\\n\\n## What is and is not enforced\\n\\n- Enforced by Paperclip: a blocked task does not start until its blockers are done; the parent is woken when its children finish; an execution policy turns `done` into review/approval.\\n- Not enforced: the register is advisory text, and the assignee still sets `done`. Use a review stage wherever evidence must be checked by someone else.\\n\\n## Review loop and escalation\\n\\nEach sector resolves its own work. The Owner assigns to the CEO, the CEO to the sector head (CTO, marketing director, COO, sales lead), the sector head to the team. Escalation moves up one level at a time:\\n\\n1. **Team.** A reviewer in the same sector (for development, QA reviews the implementer) who finds defects uses *request changes* with a concrete list of what fails and how it was seen. The task returns to its producer, who fixes and resubmits. Keep a round counter in the task's `playbook` document or parent register (`round N of 3`); do not rely on Paperclip to count.\\n2. **Sector head.** After the third rejected round, the reviewer stops the loop, wakes the sector head with the defect list and the three rounds' history. The head gets one resolution attempt: change approach, reassign, reduce scope or rewrite the plan, then restarts the loop with the counter reset to 1.\\n3. **CEO.** If the head cannot unblock it, the head hands the CEO what was tried at each level. The CEO gets one attempt.\\n4. **Owner.** Only if the CEO also cannot unblock it, the CEO reports a block to the Owner: what was asked, what each level tried, what decision or resource is missing.\\n\\nA step with `via: ceo` belongs to another sector: do not assign it across sectors yourself. Create it as a task for the CEO, who routes it to the right sector head and reports back. Steps in a flow that are independent of each other run in parallel; steps that depend on another stay chained with blockers. The level order is advisory text, not enforced by Paperclip: say clearly in the task comment at each hand-up who is now responsible.\\n\\n## Stop and escalate to the Owner immediately\\n\\nSpending, publication, hiring, permission changes, production access, legal or safety exposure and irreversible decisions go to the human Owner (through the CEO) without waiting for the loop above. A flow never grants a tool permission or an approval that is not recorded in Paperclip.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n- https://docs.paperclip.ing/guides/projects-workflow/routines/\\n\"}]}", "import type { PaperclipPluginManifestV1 } from \"@paperclipai/plugin-sdk\";\nimport skill from \"./generated/skill.json\" with { type: \"json\" };\n\nexport const PLUGIN_ID = \"paperclipai.playbook-runner\";\n\nconst manifest: PaperclipPluginManifestV1 = {\n id: PLUGIN_ID,\n apiVersion: 1,\n version: \"0.3.2\",\n displayName: \"Agents & Workflows\",\n description: \"Runs agent-static flows: creates the child tasks of each phase, chains review tasks, counts review rounds, and escalates a loop that does not converge to the sector head.\",\n author: \"Local development plugin\",\n categories: [\"automation\", \"ui\"],\n capabilities: [\n \"issues.read\",\n \"agents.read\",\n \"agent.sessions.create\",\n \"agent.sessions.send\",\n \"agent.sessions.close\",\n \"http.outbound\",\n \"issues.create\",\n \"issues.update\",\n \"issue.relations.write\",\n \"issue.comments.create\",\n \"issue.documents.read\",\n \"issue.documents.write\",\n \"plugin.state.read\",\n \"plugin.state.write\",\n \"events.subscribe\",\n \"agent.tools.register\",\n \"skills.managed\",\n \"ui.sidebar.register\",\n \"ui.page.register\",\n ],\n entrypoints: { worker: \"./dist/worker.js\", ui: \"./dist/ui\" },\n ui: { slots: [\n { type: \"sidebar\", id: \"playbook-sidebar\", displayName: \"Agents & Workflows\", exportName: \"PlaybookSidebar\", order: 99 },\n { type: \"page\", id: \"playbook-page\", displayName: \"Agents & Workflows\", exportName: \"PlaybookPage\", routePath: \"agents-workflows\" },\n ] },\n skills: skill.skills.map((s) => ({ skillKey: s.slug, displayName: s.title, slug: s.slug, description: String(s.description).replace(/\\s+/g, \" \").trim().slice(0, 300), markdown: s.markdown })),\n tools: [\n {\n name: \"playbook-start-flow\",\n displayName: \"Start a playbook flow\",\n description: \"Owner of a flow only. Instantiates a flow file (PLAYBOOKS/flows/*.yaml) on the parent task: creates the child tasks of the first phase, the review tasks and the run register document.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n parentIssueId: { type: \"string\" },\n flowKey: { type: \"string\" },\n flowYaml: { type: \"string\" },\n assignees: { type: \"object\", additionalProperties: { type: \"string\" } },\n slotChoices: { type: \"object\", additionalProperties: { type: \"array\", items: { type: \"string\" } } },\n includeOptional: { type: \"array\", items: { type: \"string\" } },\n outcome: { type: \"string\" },\n approval: { type: \"string\" },\n },\n required: [\"parentIssueId\"],\n },\n },\n {\n name: \"playbook-complete-step\",\n displayName: \"Complete a checklist step of a flow\",\n description: \"Owner of a flow only. Marks one of your own checklist steps done with evidence and creates whatever becomes ready. Also supplies slot choices or missing assignees.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n parentIssueId: { type: \"string\" },\n stepId: { type: \"string\" },\n evidence: { type: \"string\" },\n ownerApproval: { type: \"string\" },\n slotChoices: { type: \"object\", additionalProperties: { type: \"array\", items: { type: \"string\" } } },\n assignees: { type: \"object\", additionalProperties: { type: \"string\" } },\n },\n required: [\"parentIssueId\"],\n },\n },\n {\n name: \"playbook-review-verdict\",\n displayName: \"Give the verdict on a review task\",\n description: \"Reviewer only. approve closes the step; changes sends the work back with your defect list, and after the maximum rounds the step is escalated to the sector head.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n reviewIssueId: { type: \"string\" },\n verdict: { type: \"string\", enum: [\"approve\", \"changes\"] },\n defects: { type: \"string\" },\n },\n required: [\"reviewIssueId\", \"verdict\"],\n },\n },\n {\n name: \"playbook-escalate\",\n displayName: \"Hand an escalation up one level\",\n description: \"Holder of an escalation task only, after your one resolution attempt failed. Hands the case to the next level (sector head -> CEO -> Owner) with what you tried.\",\n parametersSchema: { type: \"object\", properties: { escalationIssueId: { type: \"string\" }, tried: { type: \"string\" } }, required: [\"escalationIssueId\", \"tried\"] },\n },\n {\n name: \"playbook-status\",\n displayName: \"Show the register of a running flow\",\n description: \"Returns the run register and per-step state of the flow running on a parent task.\",\n parametersSchema: { type: \"object\", properties: { parentIssueId: { type: \"string\" } }, required: [\"parentIssueId\"] },\n },\n ],\n};\n\nexport default manifest;\n"],
4
+ "sourcesContent": ["{\"skills\":[{\"slug\":\"executive-task-orchestration\",\"title\":\"Executive task orchestration\",\"description\":\"Use when converting owner-approved company priorities into a Paperclip plan, choosing task owners, delegating work, or reviewing cross-team outcomes. Do not use to approve the CEO agent's own consequential actions.\",\"markdown\":\"---\\nname: executive-task-orchestration\\ndescription: >\\n Use when converting owner-approved company priorities into a Paperclip plan, choosing task owners, delegating work, or reviewing cross-team outcomes. Do not use to approve the CEO agent's own consequential actions.\\n---\\n\\n# Executive task orchestration\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read company goals, existing Paperclip tasks, evidence, and current capacity.\\n2. Separate conversation from tracked work; create no task unless requested or authorized.\\n3. Define outcome, one owner, acceptance evidence, assumptions, dependencies, and human approval needs.\\n4. Delegate bounded work through linked tasks and review evidence before summarizing the outcome.\\n\\n## Expected result\\n\\nA concise priority decision, owner-assigned task plan, approval request, or evidence-backed closeout.\\n\\n## Stop and escalate\\n\\nEscalate budget, publication, hiring, production access, legal or safety exposure, and irreversible decisions to the human Owner.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/org/org-structure/\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n\"},{\"slug\":\"marketing-campaign-planning\",\"title\":\"Marketing campaign planning\",\"description\":\"Use when defining a campaign objective, audience, offer, positioning, message, channel mix, measurement, or campaign review. Do not use this skill to publish, spend, or promise results.\",\"markdown\":\"---\\nname: marketing-campaign-planning\\ndescription: >\\n Use when defining a campaign objective, audience, offer, positioning, message, channel mix, measurement, or campaign review. Do not use this skill to publish, spend, or promise results.\\n---\\n\\n# Marketing campaign planning\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read COMPANY.md and BUSINESS.md and identify approved goals, audiences, proof, constraints, and voice.\\n2. Use current research to define one audience problem, offer, message, and measurable conversion.\\n3. Choose channels, owners, budget request, dates, dependencies, and stop criteria.\\n4. Review evidence against targets and recommend continue, revise, or stop.\\n\\n## Expected result\\n\\nA campaign brief with objective, audience, offer, evidence, message, channels, owners, measures, budget request, risks, approvals, and review date.\\n\\n## Stop and escalate\\n\\nDo not invent testimonials, results, audience evidence, or legal claims; seek human approval for budget and publication.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"technical-architecture-and-delegation\",\"title\":\"Technical architecture and delegation\",\"description\":\"Use when a development request needs technical discovery, stack selection, architecture decisions, a fullstack-versus-split decision, or developer assignments. Do not use to make unapproved production changes.\",\"markdown\":\"---\\nname: technical-architecture-and-delegation\\ndescription: >\\n Use when a development request needs technical discovery, stack selection, architecture decisions, a fullstack-versus-split decision, or developer assignments. Do not use to make unapproved production changes.\\n---\\n\\n# Technical architecture and delegation\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect repository instructions, stack and versions, interfaces, data, deployment path, and constraints.\\n2. Define the smallest architecture that meets the approved outcome.\\n3. Choose one implementation owner or split work only when interfaces are stable and risk justifies it.\\n4. Write acceptance checks, security and privacy requirements, dependencies, test evidence, and release conditions.\\n\\n## Expected result\\n\\nA short technical decision record and implementation plan with named owners, interfaces, risks, and verification evidence.\\n\\n## Stop and escalate\\n\\nEscalate unknown production access, regulated data, security findings, major migrations, and infrastructure spend to the human Owner.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/org/org-structure/\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n\"},{\"slug\":\"n8n-workflow-design-and-operations\",\"title\":\"n8n workflow design and operations\",\"description\":\"Use when assessing, designing, implementing, testing, or handing off an approved n8n automation or MCP-exposed workflow.\",\"markdown\":\"---\\nname: n8n-workflow-design-and-operations\\ndescription: >\\n Use when assessing, designing, implementing, testing, or handing off an approved n8n automation or MCP-exposed workflow.\\n---\\n\\n# n8n workflow design and operations\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm the CEO-selected approach, workflow owner, company instance, permitted data, and task acceptance criteria.\\n2. Map triggers, inputs, data movement, side effects, credentials, retries, idempotency, and failure handling before building.\\n3. Build the smallest maintainable workflow in a development or test environment; keep complex reusable business logic in versioned code where that improves testability.\\n4. Test expected, malformed, duplicate, timeout, rate-limit, and partial-failure cases and preserve redacted execution evidence.\\n5. Document monitoring, alerting, recovery, rollback, credential ownership, and human approval required before production activation.\\n\\n## Expected result\\n\\nA workflow design or handoff with owner, version, environment, data flow, integrations, test evidence, residual risks, monitoring, recovery, and approval state.\\n\\n## Stop and escalate\\n\\nStop before production activation, external messaging, destructive changes, or access to another company's data unless the assigned task and authorized human approval explicitly permit the action. Never expose secrets or unnecessary personal data.\\n\\n## References\\n\\n- https://docs.n8n.io/connect/connect-to-n8n-mcp-server/\\n- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/\\n- https://docs.n8n.io/hosting/security/\\n\"},{\"slug\":\"operating-cadence-and-handoffs\",\"title\":\"Operating cadence and handoffs\",\"description\":\"Use when preparing a daily or weekly operating brief, coordinating cross-team dependencies, or diagnosing recurring workflow friction. Do not use to change company strategy or make external commitments.\",\"markdown\":\"---\\nname: operating-cadence-and-handoffs\\ndescription: >\\n Use when preparing a daily or weekly operating brief, coordinating cross-team dependencies, or diagnosing recurring workflow friction. Do not use to change company strategy or make external commitments.\\n---\\n\\n# Operating cadence and handoffs\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read only approved priorities, task statuses, deadlines, and permitted service summaries.\\n2. Separate evidence, estimates, blockers, and owner decisions.\\n3. Rank the three most material actions and name one accountable owner for each.\\n4. Record dependencies, escalation routes, and a review date for any proposed process pilot.\\n\\n## Expected result\\n\\nAn owner-ready operating brief or handoff with status, priorities, accountable owners, evidence, and decisions required.\\n\\n## Stop and escalate\\n\\nDo not message customers, move money, reassign work against the reporting tree, or expose unnecessary personal data.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/org/org-structure/\\n- https://docs.paperclip.ing/guides/projects-workflow/routines/\\n\"},{\"slug\":\"qa-and-release\",\"title\":\"Risk-based QA and release\",\"description\":\"Use when planning tests, validating acceptance criteria, checking regressions, or preparing release evidence for a software change. Do not treat passing tests as proof of zero risk.\",\"markdown\":\"---\\nname: qa-and-release\\ndescription: >\\n Use when planning tests, validating acceptance criteria, checking regressions, or preparing release evidence for a software change. Do not treat passing tests as proof of zero risk.\\n---\\n\\n# Risk-based QA and release\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Map each acceptance criterion to a reproducible check.\\n2. Prioritize user journeys, data boundaries, failure states, integrations, and supported versions by risk.\\n3. Run authorized local or staging checks and preserve commands, results, and defects.\\n4. Review unresolved findings, migration safety, monitoring, backup, rollback, and required approvals.\\n\\n## Expected result\\n\\nA risk-based test plan, reproducible findings, coverage limits, and release recommendation.\\n\\n## Stop and escalate\\n\\nBlock release recommendation for unresolved critical findings, missing authorization, or absent recovery evidence.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/agent-developer/writing-a-skill/\\n- https://github.com/microsoft/playwright-mcp\\n\"},{\"slug\":\"customer-care-triage\",\"title\":\"Customer care triage\",\"description\":\"Use when classifying customer messages, answering approved routine questions, preparing a support reply, or escalating a complaint or sensitive case. Do not provide unapproved legal, medical, safety, or financial advice.\",\"markdown\":\"---\\nname: customer-care-triage\\ndescription: >\\n Use when classifying customer messages, answering approved routine questions, preparing a support reply, or escalating a complaint or sensitive case. Do not provide unapproved legal, medical, safety, or financial advice.\\n---\\n\\n# Customer care triage\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Check the company support policy, approved answer source, queue permissions, and response authority.\\n2. Classify intent, urgency, sensitivity, and responsible service owner.\\n3. Use only current approved facts; draft when send authority is absent.\\n4. Route uncertain or sensitive requests to a named human or qualified professional and record a minimized handoff.\\n\\n## Expected result\\n\\nA categorized queue item, approved answer or draft, or clear escalation with next action and owner.\\n\\n## Stop and escalate\\n\\nNever promise a legal, medical, refund, compliance, or commercial outcome. Minimize personal data and escalate potential harm or formal complaints.\\n\\n## References\\n\\n- https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679\\n\"},{\"slug\":\"market-and-competitor-research\",\"title\":\"Market and competitor research\",\"description\":\"Use when investigating an audience, market opportunity, competitor offer, pricing, demand signal, or channel pattern. Do not present estimates as verified facts or infer private data.\",\"markdown\":\"---\\nname: market-and-competitor-research\\ndescription: >\\n Use when investigating an audience, market opportunity, competitor offer, pricing, demand signal, or channel pattern. Do not present estimates as verified facts or infer private data.\\n---\\n\\n# Market and competitor research\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Define the decision the research must support and the permitted sources.\\n2. Collect dated evidence about customer needs, competitor offers, pricing, positioning, and channel presence.\\n3. Separate observations, estimates, and hypotheses; record source, method, freshness, and confidence.\\n4. Synthesize opportunity, counter-evidence, unknowns, and what should be tested next.\\n\\n## Expected result\\n\\nA concise source-linked research brief with evidence, limitations, opportunity hypotheses, and next validation step.\\n\\n## Stop and escalate\\n\\nDo not use restricted sources, infer sensitive traits, or claim market size or demand without a traceable method.\\n\\n## References\\n\\n- https://support.google.com/trends/answer/4365533\\n- https://github.com/HubSpot/agent-cli-skills\\n\"},{\"slug\":\"brand-positioning-and-creative-brief\",\"title\":\"Brand positioning and creative brief\",\"description\":\"Use when turning approved customer evidence into positioning, a campaign angle, creative direction, or a brief for visual assets. Do not invent company proof or change approved brand commitments.\",\"markdown\":\"---\\nname: brand-positioning-and-creative-brief\\ndescription: >\\n Use when turning approved customer evidence into positioning, a campaign angle, creative direction, or a brief for visual assets. Do not invent company proof or change approved brand commitments.\\n---\\n\\n# Brand positioning and creative brief\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read approved company voice, offers, proof, and audience context.\\n2. Translate research into a customer problem, differentiated value, reason to believe, and message hierarchy.\\n3. Define creative concept, format, audience, placement, accessibility, and claim limits.\\n4. Present alternatives and evidence for owner review before production or publication.\\n\\n## Expected result\\n\\nA positioning statement and creative brief with audience, insight, promise, support, concept, format, and review needs.\\n\\n## Stop and escalate\\n\\nFlag unsupported claims, sensitive imagery, unclear rights, and any material change to brand promises.\\n\\n## References\\n\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"content-strategy-planning\",\"title\":\"Content strategy planning\",\"description\":\"Use when planning an editorial series, content calendar, audience education sequence, or reusable campaign content. Do not create volume without an audience need and measurable purpose.\",\"markdown\":\"---\\nname: content-strategy-planning\\ndescription: >\\n Use when planning an editorial series, content calendar, audience education sequence, or reusable campaign content. Do not create volume without an audience need and measurable purpose.\\n---\\n\\n# Content strategy planning\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Start from approved audience questions, campaign objective, and source material.\\n2. Choose content themes, formats, channel roles, sequence, and an intended audience action.\\n3. Assign source checks, specialist review, voice review, owner, and publication date.\\n4. Define success measures and reuse rules before the content is produced.\\n\\n## Expected result\\n\\nAn editorial brief or calendar with themes, audience intent, formats, owners, sources, reviewers, and measures.\\n\\n## Stop and escalate\\n\\nPause on unsupported factual claims, regulated topics without qualified review, or reuse of identifiable customer stories without consent.\\n\\n## References\\n\\n- https://developers.google.com/search/docs/fundamentals/creating-helpful-content\\n\"},{\"slug\":\"evidence-based-copywriting\",\"title\":\"Evidence-based copywriting\",\"description\":\"Use when drafting or revising customer-facing marketing copy, a landing page, offer, advertisement, or email. Do not fabricate proof, urgency, scarcity, or guaranteed outcomes.\",\"markdown\":\"---\\nname: evidence-based-copywriting\\ndescription: >\\n Use when drafting or revising customer-facing marketing copy, a landing page, offer, advertisement, or email. Do not fabricate proof, urgency, scarcity, or guaranteed outcomes.\\n---\\n\\n# Evidence-based copywriting\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read the approved voice, offer, audience, and evidence in company context.\\n2. Identify the audience problem, single promise, reason to believe, and next action.\\n3. Draft plainly with claims tied to named evidence and limits.\\n4. Check clarity, accessibility, channel fit, required review, and approval before publication.\\n\\n## Expected result\\n\\nA copy draft with audience, purpose, source notes for factual claims, CTA, and open approvals.\\n\\n## Stop and escalate\\n\\nEscalate health, safety, legal, financial, comparative, quantified, or testimonial claims for documented review.\\n\\n## References\\n\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"seo-audit-and-search-content\",\"title\":\"SEO audit and search content\",\"description\":\"Use when diagnosing organic-search visibility, prioritizing an SEO issue, or preparing a search-focused content brief. Do not promise rankings or use manipulative tactics.\",\"markdown\":\"---\\nname: seo-audit-and-search-content\\ndescription: >\\n Use when diagnosing organic-search visibility, prioritizing an SEO issue, or preparing a search-focused content brief. Do not promise rankings or use manipulative tactics.\\n---\\n\\n# SEO audit and search content\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Check the site's technical and content context and identify the target user intent.\\n2. Use permitted Search Console or analytics evidence; distinguish query data from guesses.\\n3. Prioritize crawl, index, performance, accessibility, and content-quality issues by impact and confidence.\\n4. Write a change brief with current state, recommended action, validation evidence, and review date.\\n\\n## Expected result\\n\\nA prioritized SEO issue list or content brief with evidence and validation steps.\\n\\n## Stop and escalate\\n\\nDo not create doorway pages, mass-generated thin content, fake backlinks, or unsupported structured data.\\n\\n## References\\n\\n- https://developers.google.com/search/docs/fundamentals/creating-helpful-content\\n- https://developers.google.com/search/docs/crawling-indexing\\n\"},{\"slug\":\"paid-media-testing\",\"title\":\"Paid media testing\",\"description\":\"Use when designing, reviewing, or analyzing a paid advertising test. Do not launch ads, change bids, or spend budget without explicit authorization.\",\"markdown\":\"---\\nname: paid-media-testing\\ndescription: >\\n Use when designing, reviewing, or analyzing a paid advertising test. Do not launch ads, change bids, or spend budget without explicit authorization.\\n---\\n\\n# Paid media testing\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm approved offer, audience, destination, budget envelope, and claim evidence.\\n2. Define campaign structure, conversion event, exclusions, creative variants, and tracking checks.\\n3. Set baseline, success threshold, stop rule, review window, and accountable human approver.\\n4. Analyze results with spend, qualified outcomes, attribution limits, and risks stated separately.\\n\\n## Expected result\\n\\nAn approval-ready test plan or evidence-based performance report.\\n\\n## Stop and escalate\\n\\nStop on tracking failure, unapproved claims, spend-limit uncertainty, audience-policy risk, or unapproved account changes.\\n\\n## References\\n\\n- https://developers.google.com/google-ads/api/docs/developer-toolkit/mcp-server/\\n- https://github.com/google/agent-skills\\n\"},{\"slug\":\"social-channel-operations\",\"title\":\"Organic social channel operations\",\"description\":\"Use when adapting approved campaign material to social channels, planning a publishing schedule, or preparing moderation guidance. Do not publish or engage in disputes without authorization.\",\"markdown\":\"---\\nname: social-channel-operations\\ndescription: >\\n Use when adapting approved campaign material to social channels, planning a publishing schedule, or preparing moderation guidance. Do not publish or engage in disputes without authorization.\\n---\\n\\n# Organic social channel operations\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm channel, audience, campaign objective, source facts, and approved voice.\\n2. Adapt one idea to the platform's format without changing its evidence or promise.\\n3. Prepare accessible assets, caption, CTA, alt text, timing, and moderation route.\\n4. Submit drafts for approval and record performance or recurring audience questions.\\n\\n## Expected result\\n\\nA channel-ready draft pack and schedule with sources, owner, moderation plan, and approval status.\\n\\n## Stop and escalate\\n\\nEscalate complaints, legal threats, sensitive disclosures, harassment, misinformation risk, or unclear response authority.\\n\\n## References\\n\\n- https://github.com/anthropics/skills/tree/main/skills/internal-comms\\n\"},{\"slug\":\"lifecycle-email-campaigns\",\"title\":\"Lifecycle email campaigns\",\"description\":\"Use when drafting a consent-based onboarding, lifecycle, retention, or customer update email sequence. Do not send to a list without approved audience basis and suppression checks.\",\"markdown\":\"---\\nname: lifecycle-email-campaigns\\ndescription: >\\n Use when drafting a consent-based onboarding, lifecycle, retention, or customer update email sequence. Do not send to a list without approved audience basis and suppression checks.\\n---\\n\\n# Lifecycle email campaigns\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm audience source, communication purpose, legal basis or consent policy, and suppression rules.\\n2. Map the sequence to a customer lifecycle need and one clear action per message.\\n3. Draft subject, body, sender, preference and unsubscribe handling, and tracking.\\n4. Review claims, deliverability, segmentation, and approval before sending; measure meaningful outcomes.\\n\\n## Expected result\\n\\nAn email sequence brief or draft set with audience rules, timing, suppression, approval, and measures.\\n\\n## Stop and escalate\\n\\nStop if contact permission, opt-out handling, sender identity, or sensitive segmentation is unclear.\\n\\n## References\\n\\n- https://developers.google.com/workspace/guides/configure-mcp-servers\\n\"},{\"slug\":\"marketing-measurement\",\"title\":\"Marketing measurement and analysis\",\"description\":\"Use when defining campaign events, checking tracking, analyzing funnel performance, or preparing a marketing report. Do not change campaigns, budgets, or landing pages based on analysis alone.\",\"markdown\":\"---\\nname: marketing-measurement\\ndescription: >\\n Use when defining campaign events, checking tracking, analyzing funnel performance, or preparing a marketing report. Do not change campaigns, budgets, or landing pages based on analysis alone.\\n---\\n\\n# Marketing measurement and analysis\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm objective, metric definitions, reporting period, data source, and known attribution limits.\\n2. Check event coverage and data quality before comparing results.\\n3. Analyze funnel stages with denominators, segments, and uncertainty visible.\\n4. Explain supported findings and recommend a test or decision for the accountable owner.\\n\\n## Expected result\\n\\nA measurement plan, source-linked analysis, or decision brief with definitions, limitations, and next action.\\n\\n## Stop and escalate\\n\\nDo not infer personal behavior beyond authorized aggregation or make causal claims from descriptive data alone.\\n\\n## References\\n\\n- https://developers.google.com/analytics/devguides/MCP\\n- https://posthog.com/docs/model-context-protocol\\n\"},{\"slug\":\"leadgen-strategy-and-funnel\",\"title\":\"Lead generation strategy and funnel\",\"description\":\"Use when defining an ideal customer segment, acquisition funnel, qualification criteria, channel test, or handoff to Sales. Do not maximize raw lead volume without fit and contact safeguards.\",\"markdown\":\"---\\nname: leadgen-strategy-and-funnel\\ndescription: >\\n Use when defining an ideal customer segment, acquisition funnel, qualification criteria, channel test, or handoff to Sales. Do not maximize raw lead volume without fit and contact safeguards.\\n---\\n\\n# Lead generation strategy and funnel\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read approved offer, market evidence, privacy boundaries, and Sales acceptance criteria.\\n2. Define target segment, observable intent signals, exclusions, and conversion event.\\n3. Select a bounded channel experiment with source, cost/effort limit, and stop rule.\\n4. Agree qualification fields and handoff timing with the Sales owner; measure quality through the funnel.\\n\\n## Expected result\\n\\nA segment and funnel brief with qualification, contact rules, channel test, owner, measures, and handoff.\\n\\n## Stop and escalate\\n\\nEscalate unclear contact basis, sensitive profiling, purchased lists, or unsupported targeting data.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server\\n\"},{\"slug\":\"prospect-research-and-data-quality\",\"title\":\"Prospect research and data quality\",\"description\":\"Use when researching or cleaning a business prospect list for an approved purpose. Do not infer sensitive personal traits or treat public data as permission to contact.\",\"markdown\":\"---\\nname: prospect-research-and-data-quality\\ndescription: >\\n Use when researching or cleaning a business prospect list for an approved purpose. Do not infer sensitive personal traits or treat public data as permission to contact.\\n---\\n\\n# Prospect research and data quality\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm research purpose, allowed sources, minimum fields, and contact policy.\\n2. Capture source, retrieval date, freshness, and confidence for important fields.\\n3. Check relevance, duplicates, exclusions, and conflicting information.\\n4. Return only necessary fields and document records removed or needing human review.\\n\\n## Expected result\\n\\nA source-linked prospect or segment evidence table with quality flags and permitted handoff fields.\\n\\n## Stop and escalate\\n\\nDo not scrape restricted sites, fabricate contact details, or export data without approved use and access.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679\\n\"},{\"slug\":\"outreach-campaign-operations\",\"title\":\"Outreach campaign operations\",\"description\":\"Use when preparing an approved outbound outreach sequence, audience rules, or campaign results report. Do not send messages or bypass suppression and opt-out controls.\",\"markdown\":\"---\\nname: outreach-campaign-operations\\ndescription: >\\n Use when preparing an approved outbound outreach sequence, audience rules, or campaign results report. Do not send messages or bypass suppression and opt-out controls.\\n---\\n\\n# Outreach campaign operations\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Verify approved offer, list source, contact basis, segment, and exclusions.\\n2. Draft concise, relevant messages with honest personalization and a clear next step.\\n3. Check suppression, opt-out, frequency, sender, and CRM handoff rules.\\n4. Submit for approval; after authorized launch, report replies, qualified outcomes, complaints, and opt-outs.\\n\\n## Expected result\\n\\nAn outreach draft pack and launch checklist, or a campaign results and stop recommendation.\\n\\n## Stop and escalate\\n\\nPause on unclear permission, complaints, misleading claims, sensitive data, or missing unsubscribe handling.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server\\n\"},{\"slug\":\"administrative-operations-coordination\",\"title\":\"Administrative operations coordination\",\"description\":\"Use when converting internal decisions into action logs, coordinating administrative requests, or preparing routine operating records. Do not commit funds, sign agreements, or send external messages without approval.\",\"markdown\":\"---\\nname: administrative-operations-coordination\\ndescription: >\\n Use when converting internal decisions into action logs, coordinating administrative requests, or preparing routine operating records. Do not commit funds, sign agreements, or send external messages without approval.\\n---\\n\\n# Administrative operations coordination\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm requester, purpose, due date, source record, and approving owner.\\n2. Separate decisions from discussion and assign one owner per action.\\n3. Prepare a reversible draft, calendar entry, or checklist using approved systems.\\n4. Record approval, completion evidence, and unresolved items in the source of truth.\\n\\n## Expected result\\n\\nA clear action record, request route, deadline list, or approval-ready administrative draft.\\n\\n## Stop and escalate\\n\\nEscalate legal, financial, access, privacy, and regulated-record decisions to their named owner.\\n\\n## References\\n\\n- https://developers.google.com/workspace/guides/configure-mcp-servers\\n\"},{\"slug\":\"finance-administration-review\",\"title\":\"Finance administration review\",\"description\":\"Use when reconciling source records, preparing invoice status, checking finance totals, or drafting an approval-ready payment pack. Do not execute payments or provide tax or accounting advice.\",\"markdown\":\"---\\nname: finance-administration-review\\ndescription: >\\n Use when reconciling source records, preparing invoice status, checking finance totals, or drafting an approval-ready payment pack. Do not execute payments or provide tax or accounting advice.\\n---\\n\\n# Finance administration review\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm reporting period, currency, accounting owner, and authoritative source records.\\n2. Reconcile totals and preserve references to source documents.\\n3. Separate actuals, estimates, forecasts, and assumptions; explain variances.\\n4. Prepare proposed actions for review and record the human decision.\\n\\n## Expected result\\n\\nA traceable reconciliation, invoice list, variance note, or approval-ready finance pack.\\n\\n## Stop and escalate\\n\\nEscalate missing evidence, unusual payment changes, tax judgments, bank-detail changes, and payment execution.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n\"},{\"slug\":\"records-and-document-control\",\"title\":\"Records and document control\",\"description\":\"Use when maintaining a document register, checking versions and approvals, or preparing a controlled record for sharing. Do not delete records or invent retention periods.\",\"markdown\":\"---\\nname: records-and-document-control\\ndescription: >\\n Use when maintaining a document register, checking versions and approvals, or preparing a controlled record for sharing. Do not delete records or invent retention periods.\\n---\\n\\n# Records and document control\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm record owner, authoritative location, purpose, sensitivity, and access scope.\\n2. Check version, approval status, date, and duplicate or stale copies.\\n3. Apply the approved naming and filing convention while preserving the source.\\n4. Record missing records, access questions, or retention decisions for the authorized owner.\\n\\n## Expected result\\n\\nAn evidence index, document inventory, version history, or minimized sharing proposal.\\n\\n## Stop and escalate\\n\\nEscalate legal holds, health or case records, deletion, external sharing, and retention changes.\\n\\n## References\\n\\n- https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679\\n\"},{\"slug\":\"sales-pipeline-management\",\"title\":\"Sales pipeline management\",\"description\":\"Use when defining sales stages, reviewing pipeline quality, preparing a forecast, or improving the lead handoff from Marketing. Do not invent forecast certainty or change approved prices.\",\"markdown\":\"---\\nname: sales-pipeline-management\\ndescription: >\\n Use when defining sales stages, reviewing pipeline quality, preparing a forecast, or improving the lead handoff from Marketing. Do not invent forecast certainty or change approved prices.\\n---\\n\\n# Sales pipeline management\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Confirm approved offers, stage definitions, decision roles, and the reporting period.\\n2. Check stage evidence, next action, owner, value, and close conditions.\\n3. Identify stalled, unsupported, duplicate, or no-fit opportunities.\\n4. Summarize supported pipeline ranges, assumptions, handoffs, and owner decisions.\\n\\n## Expected result\\n\\nA stage definition, pipeline review, forecast range, and next-step owner list.\\n\\n## Stop and escalate\\n\\nEscalate pricing, contractual terms, claims, customer data access, and unsupported forecast assumptions.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n\"},{\"slug\":\"sales-lead-qualification\",\"title\":\"Sales lead qualification\",\"description\":\"Use when responding to a new enquiry, preparing discovery questions, or deciding whether a prospect meets approved fit and intent criteria. Do not pressure or mislead a buyer.\",\"markdown\":\"---\\nname: sales-lead-qualification\\ndescription: >\\n Use when responding to a new enquiry, preparing discovery questions, or deciding whether a prospect meets approved fit and intent criteria. Do not pressure or mislead a buyer.\\n---\\n\\n# Sales lead qualification\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Check approved offer, qualification rules, response-time expectations, and contact history.\\n2. Ask only relevant questions about need, context, timing, decision process, and fit.\\n3. Record facts and direct quotes separately from hypotheses.\\n4. Route qualified prospects to the right seller and provide a clear next step or respectful no-fit response.\\n\\n## Expected result\\n\\nA concise qualification record, discovery brief, follow-up draft, or reasoned no-fit outcome.\\n\\n## Stop and escalate\\n\\nEscalate sensitive, regulated, legal, clinical, financial, or complaint-related enquiries.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n\"},{\"slug\":\"consultative-sales-proposals\",\"title\":\"Consultative sales proposals\",\"description\":\"Use when preparing a discovery summary, proposal, objection response, or customer follow-up for an approved offer. Do not promise outcomes outside the approved scope.\",\"markdown\":\"---\\nname: consultative-sales-proposals\\ndescription: >\\n Use when preparing a discovery summary, proposal, objection response, or customer follow-up for an approved offer. Do not promise outcomes outside the approved scope.\\n---\\n\\n# Consultative sales proposals\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Summarize the buyer's stated problem, decision criteria, and desired outcome.\\n2. Match needs to an approved offer and identify gaps or exclusions.\\n3. Draft scope, deliverables, price source, assumptions, timing, and responsibilities.\\n4. Request human approval before sending and record the customer's decision and next step.\\n\\n## Expected result\\n\\nAn evidence-based discovery note, proposal draft, or buyer decision plan.\\n\\n## Stop and escalate\\n\\nDo not invent discounts, deadlines, guarantees, legal conclusions, or product capabilities.\\n\\n## References\\n\\n- https://github.com/HubSpot/agent-cli-skills\\n- https://www.agcm.it/per-i-consumatori/le-pratiche-commerciali-scorrette-e-la-pubblicit-ingannevole/\\n\"},{\"slug\":\"engineering-delivery-baseline\",\"title\":\"Engineering delivery baseline\",\"description\":\"Use for software implementation tasks across Next.js, MEAN, and WordPress repositories. Do not use to bypass repository instructions, tests, security review, or task approval.\",\"markdown\":\"---\\nname: engineering-delivery-baseline\\ndescription: >\\n Use for software implementation tasks across Next.js, MEAN, and WordPress repositories. Do not use to bypass repository instructions, tests, security review, or task approval.\\n---\\n\\n# Engineering delivery baseline\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect the repository's instructions, existing patterns, versions, and relevant tests before changing files.\\n2. Restate the acceptance criteria and make the smallest scoped change.\\n3. Use authorized checks that match the task risk and project conventions; record commands and results.\\n4. Review the final diff for scope, security, regressions, documentation, and a clear handoff.\\n\\n## Expected result\\n\\nA scoped implementation with acceptance evidence, known limitations, and reviewer-ready change summary.\\n\\n## Stop and escalate\\n\\nDo not expose secrets, write production data, change unrelated architecture, or claim a check passed when it was not run.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/agent-developer/writing-a-skill/\\n- https://github.com/github/github-mcp-server\\n\"},{\"slug\":\"nextjs-development\",\"title\":\"Next.js development\",\"description\":\"Use when implementing or reviewing a Next.js feature, route, server action, API boundary, rendering behavior, or performance issue. Do not assume a router, runtime, cache, or Next.js version.\",\"markdown\":\"---\\nname: nextjs-development\\ndescription: >\\n Use when implementing or reviewing a Next.js feature, route, server action, API boundary, rendering behavior, or performance issue. Do not assume a router, runtime, cache, or Next.js version.\\n---\\n\\n# Next.js development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Read package manifests and repository guidance to identify Next.js version, App/Pages Router, runtime, and test setup.\\n2. Keep server-only secrets and privileged logic out of client bundles.\\n3. Follow the existing data-fetching, caching, authentication, and route patterns.\\n4. Use Next.js DevTools only when the documented version and local development-server prerequisites are met; verify behavior with project checks.\\n\\n## Expected result\\n\\nA version-aligned implementation or review with server/client boundaries and test evidence.\\n\\n## Stop and escalate\\n\\nEscalate new database, authentication, runtime, or deployment choices that exceed task scope.\\n\\n## References\\n\\n- https://nextjs.org/docs/app/guides/ai-agents\\n- https://nextjs.org/docs/app/guides/mcp\\n- https://github.com/vercel/next.js/tree/canary/skills\\n\"},{\"slug\":\"mean-stack-development\",\"title\":\"MEAN stack development\",\"description\":\"Use when implementing a feature across Angular, Node/Express, and MongoDB, or when working on one of those layers in a MEAN application. Do not assume library versions or production database access.\",\"markdown\":\"---\\nname: mean-stack-development\\ndescription: >\\n Use when implementing a feature across Angular, Node/Express, and MongoDB, or when working on one of those layers in a MEAN application. Do not assume library versions or production database access.\\n---\\n\\n# MEAN stack development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect Angular, Node, Express, MongoDB, and data-access versions and existing boundaries.\\n2. Define typed API and validation contracts before changing dependent layers.\\n3. Use development data and review schema, index, migration, authorization, and query behavior.\\n4. Run appropriate unit, API, build, and browser checks and document results.\\n\\n## Expected result\\n\\nA coherent layer-specific or vertical-slice change with API, persistence, and UI evidence.\\n\\n## Stop and escalate\\n\\nDo not run destructive operations or production CRUD through MongoDB MCP; escalate schema changes and sensitive data access.\\n\\n## References\\n\\n- https://angular.dev/ai/agent-skills\\n- https://angular.dev/ai/mcp\\n- https://www.mongodb.com/docs/mcp-server/overview/\\n- https://expressjs.com/advanced/best-practice-security/\\n\"},{\"slug\":\"wordpress-site-maintenance\",\"title\":\"WordPress site maintenance\",\"description\":\"Use when diagnosing or maintaining a WordPress site, configuration, integration, upgrade, or migration. Do not edit WordPress core or run unapproved production changes.\",\"markdown\":\"---\\nname: wordpress-site-maintenance\\ndescription: >\\n Use when diagnosing or maintaining a WordPress site, configuration, integration, upgrade, or migration. Do not edit WordPress core or run unapproved production changes.\\n---\\n\\n# WordPress site maintenance\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Identify WordPress, PHP, hosting, theme, plugin, and deployment versions and the site's existing architecture.\\n2. Reproduce the issue in local or staging and identify the responsible layer.\\n3. Prefer supported APIs, WP-CLI, reversible configuration, and documented migration steps.\\n4. Check backup, compatibility, permissions, performance, accessibility, and rollback evidence.\\n\\n## Expected result\\n\\nA bounded site fix or an upgrade/integration plan with reproducible checks and rollback notes.\\n\\n## Stop and escalate\\n\\nRequire human approval, backup, and rollback for production writes, migrations, credentials, or plugin changes.\\n\\n## References\\n\\n- https://developer.wordpress.org/\\n- https://developer.wordpress.org/cli/commands/\\n\"},{\"slug\":\"wordpress-plugin-development\",\"title\":\"WordPress plugin development\",\"description\":\"Use when designing, implementing, testing, or reviewing a WordPress plugin or custom functional extension. Do not edit WordPress core or third-party plugin source.\",\"markdown\":\"---\\nname: wordpress-plugin-development\\ndescription: >\\n Use when designing, implementing, testing, or reviewing a WordPress plugin or custom functional extension. Do not edit WordPress core or third-party plugin source.\\n---\\n\\n# WordPress plugin development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Inspect supported WordPress/PHP versions, plugin structure, hooks, APIs, and existing tests.\\n2. Check capabilities and authorization, nonces, validation, sanitization, escaping, and data lifecycle.\\n3. Implement the smallest change using supported extension points.\\n4. Run authorized checks and prepare compatibility, upgrade, security, and release evidence.\\n\\n## Expected result\\n\\nA maintainable plugin change with permission, data, compatibility, test, and release notes.\\n\\n## Stop and escalate\\n\\nEscalate external service calls, sensitive data, destructive migrations, and live-site writes.\\n\\n## References\\n\\n- https://developer.wordpress.org/plugins/\\n- https://developer.wordpress.org/plugins/security/\\n- https://github.com/WordPress/agent-skills\\n\"},{\"slug\":\"wordpress-theme-development\",\"title\":\"WordPress theme development\",\"description\":\"Use when implementing or reviewing a WordPress theme, block theme, template, pattern, theme.json setting, or editor/front-end presentation. Do not put persistent business logic in a theme.\",\"markdown\":\"---\\nname: wordpress-theme-development\\ndescription: >\\n Use when implementing or reviewing a WordPress theme, block theme, template, pattern, theme.json setting, or editor/front-end presentation. Do not put persistent business logic in a theme.\\n---\\n\\n# WordPress theme development\\n\\nThis is an original, markdown-only Paperclip skill designed for Pi Agent and Claude Code skill discovery. It guides work; it does not grant access, decide approvals, or replace the role's immutable playbook.\\n\\n## Before starting\\n\\n- Read the assigned role instructions, COMPANY.md, BUSINESS.md, and the task acceptance criteria.\\n- Confirm the task owner and required approval in Paperclip.\\n- Use only tools, data, and environments authorized for this company.\\n\\n## Procedure\\n\\n1. Identify classic or block theme architecture, supported versions, theme.json, and design tokens.\\n2. Make presentation changes in the correct template, pattern, or style layer.\\n3. Check responsive behavior, editor/front-end parity, accessibility, and performance.\\n4. Capture visual and automated evidence for relevant templates and states.\\n\\n## Expected result\\n\\nA focused theme change with responsive, accessible, editor, and visual evidence.\\n\\n## Stop and escalate\\n\\nRoute persistent data, business logic, and functional integrations to a plugin or application layer.\\n\\n## References\\n\\n- https://developer.wordpress.org/themes/\\n- https://developer.wordpress.org/themes/global-settings-and-styles/\\n- https://github.com/WordPress/agent-skills\\n\"},{\"slug\":\"run-playbook\",\"title\":\"Run a playbook\",\"description\":\"Use when a Paperclip task carries a playbook, when you are asked to start one, or when your assigned task is a step of a playbook run (a child task created from a flow). Do not use for ordinary tasks that no playbook covers.\",\"markdown\":\"---\\nname: run-playbook\\ndescription: >\\n Use when a Paperclip task carries a playbook, when you are asked to start one, or when your assigned task is a step of a playbook run (a child task created from a flow). Do not use for ordinary tasks that no playbook covers.\\n---\\n\\n# Run a playbook\\n\\nThis is an original, markdown-only Paperclip skill. It guides work; it does not grant access, make approvals, or replace Paperclip's own task status. Paperclip has no native playbook object: this skill builds the flow out of native tasks, blockers, task documents and execution policies.\\n\\n## Two kinds of playbook\\n\\n- **Checklist** \u2014 `PLAYBOOKS/NN-*.md` in your role folder. Ordered steps for one agent inside one task.\\n- **Flow** \u2014 `PLAYBOOKS/flows/*.yaml` in the folder of the role that owns it. Steps belong to different roles; each `task` step becomes its own Paperclip task, chained with blockers.\\n\\nIf no playbook fits, use the default delivery checklist below.\\n\\n## Run a checklist (one agent, one task)\\n\\n1. Keep the run register in the task document with key `playbook` (format: `templates/PLAYBOOK-REGISTER.md`, shown in the task as plain Markdown). If the document already exists, read it and resume; never start a second run.\\n2. Fill the header: task, one owner, approved outcome and acceptance checks, assumptions, escalation owner, Owner approval status. Copy the steps in order; step 1 is IN_PROGRESS, the rest PENDING.\\n3. Work one step at a time. A step becomes PASS only with evidence on its line (link, artifact, task comment, check output). Then activate only the next step.\\n4. When blocked, mark the step BLOCKED with the reason and who must act, leave later steps PENDING, and put the Paperclip task itself in a waiting state: `blocked` with `blockedByIssueIds`, or a pending interaction with `in_review` for a human decision. Text in the register alone does not stop or wake anyone. Then stop.\\n5. Update the document with the revision-safe procedure of the Paperclip skill (`PUT /api/issues/{issueId}/documents/playbook`, send `baseRevisionId` on updates, reconcile on `409`).\\n6. If you can run scripts, `node validate-run.mjs <register-file>` checks the register (0 valid, 2 valid but halted, 1 invalid). If you cannot run it, check the rules by hand: one IN_PROGRESS step, earlier steps PASS, later steps PENDING, evidence on every PASS.\\n7. When every step is PASS, post an evidence summary and set the task `done`. If the task has an execution policy, `done` moves it to review or approval: that is expected, not an error.\\n\\n## Run a flow (owner role)\\n\\nOnly the agent whose role is the flow's `owner_role` starts it, and only for a task the Owner has approved.\\n\\n1. Read the flow file. Confirm every item in `inputs` from the task text; if one is missing, ask the Owner in the task and stop.\\n2. Resolve each `role` to an active agent with the team briefing tool (`get-team-briefing`) or the company agent list. If a role has no active agent, mark the run BLOCKED and ask the Owner; never substitute another role silently.\\n3. Write the register in the parent task's `playbook` document, listing every step with its owner.\\n4. Create the steps of the current phase. For each `mode: task` step create a child task: `parentId` = the parent task, the assignee, a title, a description with `done_when`, the evidence required and a link to the parent register, and `blockedByIssueIds` = the child tasks of its `depends_on` steps (status `blocked` if it has blockers, otherwise `todo`). Create in dependency order. For a step with `review`, set the task's `executionPolicy` with a `review` stage whose participant is that reviewer; if the API refuses it for your role, ask the Owner to set it in the task. `mode: checklist` steps stay as lines in the parent register, handled by you.\\n5. Slots (`slots:`) name a role chosen by an earlier step. Create the steps that use a slot only after the choosing step is done: Paperclip wakes you when all current children are terminal, then you create the next phase.\\n6. Paperclip wakes each assignee when its blockers are done and wakes you when all children are done. On each wake, copy the child result into the register as PASS with evidence (or BLOCKED), then continue.\\n7. Close out: check every acceptance check against the evidence, post the summary, and set the parent `done`.\\n\\n## With the Playbook Runner plugin\\n\\nIf the tools `playbook-start-flow`, `playbook-complete-step`, `playbook-review-verdict` and `playbook-status` are available, use them instead of creating tasks by hand. As the owner, pass the flow file's text to `playbook-start-flow`: roles are matched to agents by name or title, and you only pass `assignees` (role \u2192 agent id) for the ones it reports as not found. A step with `approval: owner` needs `ownerApproval` (the reference to the Owner's approval, obtained through the CEO) when you close it; close your checklist steps with `playbook-complete-step` (this also supplies the implementer or channel roles you chose). As a reviewer, give your verdict with `playbook-review-verdict`, never by just setting the review task done. The plugin counts the review rounds and opens the escalation task itself. If you hold an escalation task: when you resolved it, set that task done (a new review cycle starts); when your one attempt failed, call `playbook-escalate` with what you tried, and the case goes to the next level (sector head \u2192 CEO \u2192 Owner).\\n\\n## You were assigned a step of a flow\\n\\nRead your task description and the parent register. Do the work inside the stated scope, record the evidence in a task comment, then set the task `done`. A reviewer may follow because of the task's execution policy; if they request changes, fix what they listed and resubmit. If you cannot finish for a reason outside your control, set the task `blocked` and say what is needed and from whom.\\n\\n## Default delivery checklist\\n\\n1. Confirm the assigned task, scope, acceptance checks, owner, dependencies and latest status.\\n2. Inspect the relevant repository, source material, account evidence or existing deliverable; record material unknowns.\\n3. Write the smallest complete plan with assumptions, risks, ordered actions and the evidence you will provide.\\n4. Do the role work in scope and preserve established sources of truth.\\n5. Check each acceptance item against evidence; list gaps, unavailable checks and blockers.\\n6. Attach evidence and hand off in Paperclip; update only your own task.\\n\\n## What is and is not enforced\\n\\n- Enforced by Paperclip: a blocked task does not start until its blockers are done; the parent is woken when its children finish; an execution policy turns `done` into review/approval.\\n- Not enforced: the register is advisory text, and the assignee still sets `done`. Use a review stage wherever evidence must be checked by someone else.\\n\\n## Review loop and escalation\\n\\nEach sector resolves its own work. The Owner assigns to the CEO, the CEO to the sector head (CTO, marketing director, COO, sales lead), the sector head to the team. Escalation moves up one level at a time:\\n\\n1. **Team.** A reviewer in the same sector (for development, QA reviews the implementer) who finds defects uses *request changes* with a concrete list of what fails and how it was seen. The task returns to its producer, who fixes and resubmits. Keep a round counter in the task's `playbook` document or parent register (`round N of 3`); do not rely on Paperclip to count.\\n2. **Sector head.** After the third rejected round, the reviewer stops the loop, wakes the sector head with the defect list and the three rounds' history. The head gets one resolution attempt: change approach, reassign, reduce scope or rewrite the plan, then restarts the loop with the counter reset to 1.\\n3. **CEO.** If the head cannot unblock it, the head hands the CEO what was tried at each level. The CEO gets one attempt.\\n4. **Owner.** Only if the CEO also cannot unblock it, the CEO reports a block to the Owner: what was asked, what each level tried, what decision or resource is missing.\\n\\nA step with `via: ceo` belongs to another sector: do not assign it across sectors yourself. Create it as a task for the CEO, who routes it to the right sector head and reports back. Steps in a flow that are independent of each other run in parallel; steps that depend on another stay chained with blockers. The level order is advisory text, not enforced by Paperclip: say clearly in the task comment at each hand-up who is now responsible.\\n\\n## Stop and escalate to the Owner immediately\\n\\nSpending, publication, hiring, permission changes, production access, legal or safety exposure and irreversible decisions go to the human Owner (through the CEO) without waiting for the loop above. A flow never grants a tool permission or an approval that is not recorded in Paperclip.\\n\\n## References\\n\\n- https://docs.paperclip.ing/guides/power/execution-policy/\\n- https://docs.paperclip.ing/guides/projects-workflow/routines/\\n\"}]}", "import type { PaperclipPluginManifestV1 } from \"@paperclipai/plugin-sdk\";\nimport skill from \"./generated/skill.json\" with { type: \"json\" };\n\nexport const PLUGIN_ID = \"paperclipai.playbook-runner\";\n\nconst manifest: PaperclipPluginManifestV1 = {\n id: PLUGIN_ID,\n apiVersion: 1,\n version: \"0.3.3\",\n displayName: \"Agents & Workflows\",\n description: \"Runs agent-static flows: creates the child tasks of each phase, chains review tasks, counts review rounds, and escalates a loop that does not converge to the sector head.\",\n author: \"Local development plugin\",\n categories: [\"automation\", \"ui\"],\n capabilities: [\n \"issues.read\",\n \"agents.read\",\n \"agent.sessions.create\",\n \"agent.sessions.send\",\n \"agent.sessions.close\",\n \"http.outbound\",\n \"issues.create\",\n \"issues.update\",\n \"issue.relations.write\",\n \"issue.comments.create\",\n \"issue.documents.read\",\n \"issue.documents.write\",\n \"plugin.state.read\",\n \"plugin.state.write\",\n \"events.subscribe\",\n \"agent.tools.register\",\n \"skills.managed\",\n \"ui.sidebar.register\",\n \"ui.page.register\",\n ],\n entrypoints: { worker: \"./dist/worker.js\", ui: \"./dist/ui\" },\n ui: { slots: [\n { type: \"sidebar\", id: \"playbook-sidebar\", displayName: \"Agents & Workflows\", exportName: \"PlaybookSidebar\", order: 99 },\n { type: \"page\", id: \"playbook-page\", displayName: \"Agents & Workflows\", exportName: \"PlaybookPage\", routePath: \"agents-workflows\" },\n ] },\n skills: skill.skills.map((s) => ({ skillKey: s.slug, displayName: s.title, slug: s.slug, description: String(s.description).replace(/\\s+/g, \" \").trim().slice(0, 300), markdown: s.markdown })),\n tools: [\n {\n name: \"playbook-start-flow\",\n displayName: \"Start a playbook flow\",\n description: \"Owner of a flow only. Instantiates a flow file (PLAYBOOKS/flows/*.yaml) on the parent task: creates the child tasks of the first phase, the review tasks and the run register document.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n parentIssueId: { type: \"string\" },\n flowKey: { type: \"string\" },\n flowYaml: { type: \"string\" },\n assignees: { type: \"object\", additionalProperties: { type: \"string\" } },\n slotChoices: { type: \"object\", additionalProperties: { type: \"array\", items: { type: \"string\" } } },\n includeOptional: { type: \"array\", items: { type: \"string\" } },\n outcome: { type: \"string\" },\n approval: { type: \"string\" },\n },\n required: [\"parentIssueId\"],\n },\n },\n {\n name: \"playbook-complete-step\",\n displayName: \"Complete a checklist step of a flow\",\n description: \"Owner of a flow only. Marks one of your own checklist steps done with evidence and creates whatever becomes ready. Also supplies slot choices or missing assignees.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n parentIssueId: { type: \"string\" },\n stepId: { type: \"string\" },\n evidence: { type: \"string\" },\n ownerApproval: { type: \"string\" },\n slotChoices: { type: \"object\", additionalProperties: { type: \"array\", items: { type: \"string\" } } },\n assignees: { type: \"object\", additionalProperties: { type: \"string\" } },\n },\n required: [\"parentIssueId\"],\n },\n },\n {\n name: \"playbook-review-verdict\",\n displayName: \"Give the verdict on a review task\",\n description: \"Reviewer only. approve closes the step; changes sends the work back with your defect list, and after the maximum rounds the step is escalated to the sector head.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n reviewIssueId: { type: \"string\" },\n verdict: { type: \"string\", enum: [\"approve\", \"changes\"] },\n defects: { type: \"string\" },\n },\n required: [\"reviewIssueId\", \"verdict\"],\n },\n },\n {\n name: \"playbook-escalate\",\n displayName: \"Hand an escalation up one level\",\n description: \"Holder of an escalation task only, after your one resolution attempt failed. Hands the case to the next level (sector head -> CEO -> Owner) with what you tried.\",\n parametersSchema: { type: \"object\", properties: { escalationIssueId: { type: \"string\" }, tried: { type: \"string\" } }, required: [\"escalationIssueId\", \"tried\"] },\n },\n {\n name: \"playbook-status\",\n displayName: \"Show the register of a running flow\",\n description: \"Returns the run register and per-step state of the flow running on a parent task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AM,UAAU,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,GAAG,OAAO,EAAE,MAAM,SAAS,EAAE,GAAG,UAAU,CAAC,qBAAqB,OAAO,EAAE;AAAA,IACjK;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,aAAa;AAAA,MACb,kBAAkB,EAAE,MAAM,UAAU,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,EAAE,GAAG,UAAU,CAAC,eAAe,EAAE;AAAA,IACrH;AAAA,EACF;AACF;AAEA,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
package/dist/ui/index.js CHANGED
@@ -92,29 +92,16 @@ function Guide({ id, children }) {
92
92
  /* @__PURE__ */ jsx("strong", { style: { fontSize: 13 }, children: g.title }),
93
93
  /* @__PURE__ */ jsx("span", { style: S.muted, children: g.text })
94
94
  ] }, g.title)) }),
95
- /* @__PURE__ */ jsxs("div", { style: S.muted, children: [
96
- /* @__PURE__ */ jsx("strong", { children: "Two words to know." }),
97
- " A ",
98
- /* @__PURE__ */ jsx("em", { children: "procedure" }),
99
- " is a checklist for one agent working alone. A ",
100
- /* @__PURE__ */ jsx("em", { children: "workflow" }),
101
- ' is the same idea for several agents working one after another. To try it: pick a workflow below, choose a task and press "Start workflow".'
102
- ] })
95
+ /* @__PURE__ */ jsx("div", { style: S.muted, children: "Two words to know. A procedure is a checklist for one agent working alone. A workflow is the same idea for several agents working one after another. To try it: pick a workflow below, choose a task and press \u201CStart workflow\u201D." })
103
96
  ] }))
104
97
  ] });
105
98
  }
106
99
  function StepDiagram({ flow, roleTitle }) {
107
100
  return /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "stretch", gap: 6 }, children: flow.steps.map((step, i) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
108
101
  /* @__PURE__ */ jsxs("div", { style: { border: "1px solid var(--border, #333)", borderRadius: 8, padding: "6px 10px", maxWidth: 210, opacity: step.optional ? 0.7 : 1 }, children: [
109
- /* @__PURE__ */ jsxs("div", { style: { fontSize: 12, fontWeight: 600 }, children: [
110
- roleTitle(step.role),
111
- step.via ? " (through the CEO)" : ""
112
- ] }),
102
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 12, fontWeight: 600 }, children: `${roleTitle(step.role)}${step.via ? " (through the CEO)" : ""}` }),
113
103
  /* @__PURE__ */ jsx("div", { style: { fontSize: 12.5 }, children: step.title }),
114
- step.reviewBy && /* @__PURE__ */ jsxs("div", { style: { fontSize: 12, marginTop: 4, color: "var(--muted-foreground, #999)" }, children: [
115
- "checked by ",
116
- roleTitle(step.reviewBy)
117
- ] }),
104
+ step.reviewBy && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, marginTop: 4, color: "var(--muted-foreground, #999)" }, children: `checked by ${roleTitle(step.reviewBy)}` }),
118
105
  step.optional && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--muted-foreground, #999)" }, children: "only if needed" })
119
106
  ] }),
120
107
  i < flow.steps.length - 1 && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2192" })
@@ -164,10 +151,7 @@ function PlaybookPage() {
164
151
  /* @__PURE__ */ jsx(Tab, { id: "settings", current: tab, set: setTab, children: "Settings" })
165
152
  ] }),
166
153
  message && /* @__PURE__ */ jsx("div", { role: "status", style: { ...S.card, borderColor: message.kind === "ok" ? "#22c55e" : "#ef4444" }, children: message.text }),
167
- catalog.error && /* @__PURE__ */ jsxs("div", { role: "alert", style: S.card, children: [
168
- "Error: ",
169
- catalog.error.message
170
- ] }),
154
+ catalog.error && /* @__PURE__ */ jsx("div", { role: "alert", style: S.card, children: `Error: ${catalog.error.message}` }),
171
155
  !ready ? /* @__PURE__ */ jsx("div", { style: S.muted, children: "Loading\u2026" }) : tab === "mine" ? /* @__PURE__ */ jsx(MyAgentsTab, { companyId, catalog: catalog.data, builder: builder.data, refresh: refreshAll, say, draft, setDraft, askAssistant: (text) => {
172
156
  setPending(text);
173
157
  setTab("assistant");
@@ -285,13 +269,7 @@ function AgentsTab({ companyId, catalog, refresh, say }) {
285
269
  ] }),
286
270
  /* @__PURE__ */ jsxs("div", { style: S.card, children: [
287
271
  /* @__PURE__ */ jsxs("div", { style: { ...S.row, justifyContent: "space-between" }, children: [
288
- /* @__PURE__ */ jsxs("strong", { children: [
289
- "2. Roles in the pack (",
290
- present,
291
- " of ",
292
- catalog.roles.length,
293
- " present)"
294
- ] }),
272
+ /* @__PURE__ */ jsx("strong", { children: `2. Roles in the pack (${present} of ${catalog.roles.length} present)` }),
295
273
  /* @__PURE__ */ jsx("input", { "aria-label": "Filter roles", placeholder: "Filter\u2026", value: filter, onChange: (e) => setFilter(e.target.value), style: S.select })
296
274
  ] }),
297
275
  /* @__PURE__ */ jsxs("table", { style: { borderCollapse: "collapse", width: "100%" }, children: [
@@ -367,13 +345,7 @@ function FlowsTab({ companyId, catalog, say, goRuns }) {
367
345
  catalog.flows.map((flow) => /* @__PURE__ */ jsxs("div", { style: S.card, children: [
368
346
  /* @__PURE__ */ jsxs("div", { style: { ...S.row, justifyContent: "space-between" }, children: [
369
347
  /* @__PURE__ */ jsx("strong", { children: flow.title }),
370
- flow.ownerAgentId ? /* @__PURE__ */ jsxs(Badge, { ok: true, children: [
371
- "owner: ",
372
- roleTitle(flow.ownerRole)
373
- ] }) : /* @__PURE__ */ jsxs(Badge, { ok: false, children: [
374
- "missing agent: ",
375
- roleTitle(flow.ownerRole)
376
- ] })
348
+ flow.ownerAgentId ? /* @__PURE__ */ jsx(Badge, { ok: true, children: `owner: ${roleTitle(flow.ownerRole)}` }) : /* @__PURE__ */ jsx(Badge, { ok: false, children: `missing agent: ${roleTitle(flow.ownerRole)}` })
377
349
  ] }),
378
350
  /* @__PURE__ */ jsx("div", { style: S.muted, children: flow.useWhen }),
379
351
  /* @__PURE__ */ jsx(StepDiagram, { flow, roleTitle }),
@@ -390,6 +362,7 @@ function FlowsTab({ companyId, catalog, say, goRuns }) {
390
362
  ] }, flow.key))
391
363
  ] });
392
364
  }
365
+ var STATE_LABEL = { PENDING: "Waiting", IN_PROGRESS: "In progress", PASS: "Done", BLOCKED: "Blocked", SKIPPED: "Skipped" };
393
366
  function RunsTab({ companyId, prefix }) {
394
367
  const runs = usePluginData("runs", { companyId });
395
368
  const nav = useHostNavigation();
@@ -397,7 +370,7 @@ function RunsTab({ companyId, prefix }) {
397
370
  if (runs.data.runs.length === 0) return /* @__PURE__ */ jsx("div", { style: S.card, children: 'No workflow started yet. Go to "Workflows" and start one on a task.' });
398
371
  return /* @__PURE__ */ jsxs(Fragment, { children: [
399
372
  /* @__PURE__ */ jsxs("div", { style: { ...S.row, justifyContent: "space-between" }, children: [
400
- /* @__PURE__ */ jsx("span", { style: S.muted, children: "PENDING = not started \xB7 IN_PROGRESS = being worked on \xB7 PASS = done, with proof \xB7 BLOCKED = stuck, someone must decide" }),
373
+ /* @__PURE__ */ jsx("span", { style: S.muted, children: "Each step shows its state, who does it and, once done, the proof." }),
401
374
  /* @__PURE__ */ jsx(Btn, { onClick: runs.refresh, children: "Refresh" })
402
375
  ] }),
403
376
  runs.data.runs.map((run) => /* @__PURE__ */ jsxs("div", { style: S.card, children: [
@@ -408,7 +381,19 @@ function RunsTab({ companyId, prefix }) {
408
381
  ] }) }),
409
382
  /* @__PURE__ */ jsx(Badge, { ok: run.finished, children: run.finished ? "completed" : run.register.includes("[BLOCKED]") ? "blocked" : "in progress" })
410
383
  ] }),
411
- /* @__PURE__ */ jsx("pre", { style: S.pre, children: run.register.split("## Steps")[1]?.split("\n_Maintained")[0]?.trim() ?? run.register })
384
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: (run.register.split("## Steps")[1]?.split("\n_Maintained")[0] ?? "").split("\n").map((line) => line.match(/^(\d+)\. \[(\w+)\] (.+?) \(([^()]*)\)(.*)$/)).filter(Boolean).map((m) => {
385
+ const state = STATE_LABEL[m[2]] ?? m[2];
386
+ return /* @__PURE__ */ jsxs("div", { style: { ...S.row, alignItems: "baseline" }, children: [
387
+ /* @__PURE__ */ jsxs("span", { style: { ...S.muted, minWidth: 18 }, children: [
388
+ m[1],
389
+ "."
390
+ ] }),
391
+ /* @__PURE__ */ jsx(Badge, { ok: m[2] === "PASS", children: state }),
392
+ /* @__PURE__ */ jsx("span", { children: m[3] }),
393
+ /* @__PURE__ */ jsx("span", { style: S.muted, children: m[4] }),
394
+ m[5].trim() && /* @__PURE__ */ jsx("span", { style: { ...S.muted, wordBreak: "break-word" }, children: m[5].replace(/^ — /, "").trim() })
395
+ ] }, m[1]);
396
+ }) })
412
397
  ] }, run.parentId))
413
398
  ] });
414
399
  }
@@ -649,11 +634,7 @@ ${draft.description.trim()}
649
634
  /* @__PURE__ */ jsx("strong", { children: "New agent" }),
650
635
  /* @__PURE__ */ jsx(Btn, { onClick: () => setDraft(null), children: "Cancel" })
651
636
  ] }),
652
- /* @__PURE__ */ jsx("ol", { style: { display: "flex", gap: 6, listStyle: "none", padding: 0, margin: 0, flexWrap: "wrap" }, children: steps.map((label, i) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", { type: "button", "aria-current": step === i + 1 ? "step" : void 0, onClick: () => setStep(i + 1), style: { padding: "4px 10px", borderRadius: 999, border: "1px solid var(--border, #333)", cursor: "pointer", color: "inherit", background: step === i + 1 ? "color-mix(in srgb, var(--primary, #2563eb) 30%, transparent)" : "transparent", fontSize: 13 }, children: [
653
- i + 1,
654
- ". ",
655
- label
656
- ] }) }, label)) }),
637
+ /* @__PURE__ */ jsx("ol", { style: { display: "flex", gap: 6, listStyle: "none", padding: 0, margin: 0, flexWrap: "wrap" }, children: steps.map((label, i) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", { type: "button", "aria-current": step === i + 1 ? "step" : void 0, onClick: () => setStep(i + 1), style: { padding: "4px 10px", borderRadius: 999, border: "1px solid var(--border, #333)", cursor: "pointer", color: "inherit", background: step === i + 1 ? "color-mix(in srgb, var(--primary, #2563eb) 30%, transparent)" : "transparent", fontSize: 13 }, children: `${i + 1}. ${label}` }) }, label)) }),
657
638
  step === 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
658
639
  /* @__PURE__ */ jsx(Field, { label: "Name", hint: "How the agent will appear in Paperclip, e.g. \u201CInvoice Assistant\u201D.", children: /* @__PURE__ */ jsx("input", { "aria-label": "Agent name", style: input, value: draft.name, onChange: (e) => set({ name: e.target.value }) }) }),
659
640
  /* @__PURE__ */ jsx(Field, { label: "What should this agent do?", hint: "Write it as you would explain it to a new colleague.", children: /* @__PURE__ */ jsx("textarea", { "aria-label": "What should this agent do?", rows: 4, style: input, value: draft.description, onChange: (e) => set({ description: e.target.value }) }) }),
@@ -717,27 +698,13 @@ ${draft.description.trim()}
717
698
  step === 4 && /* @__PURE__ */ jsxs(Fragment, { children: [
718
699
  /* @__PURE__ */ jsxs("div", { children: [
719
700
  /* @__PURE__ */ jsx("strong", { children: draft.name || "(no name)" }),
720
- " \u2014 reports to ",
721
- catalog.agents.find((a) => a.id === draft.reportsTo)?.name ?? "you"
701
+ ` \u2014 reports to ${catalog.agents.find((a) => a.id === draft.reportsTo)?.name ?? "you"}`
722
702
  ] }),
723
703
  /* @__PURE__ */ jsx("div", { style: S.muted, children: draft.description || (draft.baseRole ? "From the ready-made role." : "") }),
724
704
  /* @__PURE__ */ jsxs("ul", { style: { margin: 0, paddingLeft: 20 }, children: [
725
- /* @__PURE__ */ jsxs("li", { children: [
726
- draft.skills.length + 1,
727
- " skill(s) from the library, ",
728
- draft.links.filter((l) => l.kind === "skill").length,
729
- " by link"
730
- ] }),
731
- /* @__PURE__ */ jsxs("li", { children: [
732
- draft.links.filter((l) => l.kind === "mcp").length,
733
- " tool(s) (MCP servers) to install after creation"
734
- ] }),
735
- /* @__PURE__ */ jsxs("li", { children: [
736
- draft.procedures.filter((p) => p.title.trim()).length,
737
- " procedure(s), ",
738
- draft.links.filter((l) => l.kind === "playbook").length,
739
- " playbook(s) by link"
740
- ] })
705
+ /* @__PURE__ */ jsx("li", { children: `${draft.skills.length + 1} skill(s) from the library, ${draft.links.filter((l) => l.kind === "skill").length} by link` }),
706
+ /* @__PURE__ */ jsx("li", { children: `${draft.links.filter((l) => l.kind === "mcp").length} tool(s) (MCP servers) to install after creation` }),
707
+ /* @__PURE__ */ jsx("li", { children: `${draft.procedures.filter((p) => p.title.trim()).length} procedure(s), ${draft.links.filter((l) => l.kind === "playbook").length} playbook(s) by link` })
741
708
  ] }),
742
709
  problems.map((p) => /* @__PURE__ */ jsx("div", { role: "alert", style: { color: "#ef4444" }, children: p }, p))
743
710
  ] }),
@@ -800,14 +767,8 @@ function AssistantTab({ companyId, catalog, refreshAll, builder, refresh, useDra
800
767
  return /* @__PURE__ */ jsxs("div", { style: { alignSelf: m.role === "user" ? "flex-end" : "flex-start", maxWidth: "85%", ...S.pre, fontFamily: "inherit", fontSize: 14, background: m.role === "user" ? "color-mix(in srgb, var(--primary, #2563eb) 25%, transparent)" : m.role === "system" ? "color-mix(in srgb, #ef4444 20%, transparent)" : S.pre.background }, children: [
801
768
  m.text.replace(/```(agent-draft|mcp-result)[\s\S]*?```/g, "").trim(),
802
769
  mcp && /* @__PURE__ */ jsxs("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: [
803
- /* @__PURE__ */ jsxs("span", { style: S.muted, children: [
804
- mcp.remoteUrl ? `Hosted server: ${mcp.remoteUrl}` : `Starts with: ${[mcp.command, ...mcp.args ?? []].join(" ")}`,
805
- " \xB7 ",
806
- (mcp.tools ?? []).length,
807
- " tools \xB7 ",
808
- mcp.tested ? "tested by the assistant" : "NOT tested"
809
- ] }),
810
- targets.length === 0 ? /* @__PURE__ */ jsx("span", { style: S.muted, children: "Create a custom agent first, then come back to assign this tool." }) : targets.map((a) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Btn, { primary: true, disabled: registering, onClick: async () => {
770
+ /* @__PURE__ */ jsx("span", { style: S.muted, children: `${mcp.remoteUrl ? `Hosted server: ${mcp.remoteUrl}` : `Starts with: ${[mcp.command, ...mcp.args ?? []].join(" ")}`} \xB7 ${(mcp.tools ?? []).length} tools \xB7 ${mcp.tested ? "tested by the assistant" : "NOT tested"}` }),
771
+ targets.length === 0 ? /* @__PURE__ */ jsx("span", { style: S.muted, children: "Create a custom agent first, then come back to assign this tool." }) : targets.map((a) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Btn, { primary: true, disabled: registering, onClick: async () => {
811
772
  setRegistering(true);
812
773
  try {
813
774
  say("ok", await registerMcp(companyId, a, mcp));
@@ -817,10 +778,7 @@ function AssistantTab({ companyId, catalog, refreshAll, builder, refresh, useDra
817
778
  } finally {
818
779
  setRegistering(false);
819
780
  }
820
- }, children: [
821
- "Register and assign to ",
822
- a.name
823
- ] }) }, a.id))
781
+ }, children: `Register and assign to ${a.name}` }) }, a.id))
824
782
  ] }),
825
783
  draft && /* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ jsx(Btn, { primary: true, onClick: () => useDraft(draft), children: "Review and create this agent" }) })
826
784
  ] }, i);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/index.tsx"],
4
- "sourcesContent": ["import { useEffect, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { useHostContext, useHostLocation, useHostNavigation, usePluginAction, usePluginData } from \"@paperclipai/plugin-sdk/ui\";\n\n// ---------- types ----------\ntype Role = { skills: string[]; key: string; title: string; path: string; reportsTo: string | null; nativeRole: string; fileCount: number; playbooks: number; agentId: string | null };\ntype FlowStep = { id: string; title: string; role: string; via: string | null; mode: string; reviewBy: string | null; optional: boolean };\ntype Flow = { key: string; title: string; ownerRole: string; useWhen: string; ownerAgentId: string | null; steps: FlowStep[] };\ntype AgentRow = { custom: boolean; mcp: { url: string; status: string }[]; urlKey: string | null; id: string; name: string; title: string | null; role: string; adapterType: string };\ntype Catalog = { roles: Role[]; flows: Flow[]; agents: AgentRow[] };\ntype Run = { parentId: string; identifier: string | null; title: string; flowKey: string; finished: boolean; register: string };\n\n// ---------- native API (the signed-in user's own session) ----------\nasync function api<T = any>(method: string, path: string, body?: unknown): Promise<T> {\n const response = await fetch(path, { method, credentials: \"include\", headers: body === undefined ? undefined : { \"content-type\": \"application/json\" }, body: body === undefined ? undefined : JSON.stringify(body) });\n const text = await response.text();\n let payload: any = null;\n try { payload = text ? JSON.parse(text) : null; } catch { payload = text; }\n if (!response.ok) throw new Error(`${response.status}: ${typeof payload === \"string\" ? payload : payload?.error ?? JSON.stringify(payload)}`);\n return payload as T;\n}\nconst INSTRUCTION_KEYS = [\"instructionsBundleMode\", \"instructionsRootPath\", \"instructionsEntryFile\", \"instructionsFilePath\", \"agentsMdPath\", \"promptTemplate\"];\nconst PLAYBOOK_SECTION = \"\\n\\n## Playbooks\\nWhen a task carries a playbook, or matches one in PLAYBOOKS/, follow the `run-playbook` skill: keep the run register in the task document `playbook`, one step IN_PROGRESS at a time, evidence on every PASS. On a blocker, mark the step BLOCKED, say what is needed and from whom, and stop.\\n\";\n\n/** Paperclip requires the base of an edit: the file hash (null for a new file), or the revision id for the entry file. */\nasync function writeFile(agentId: string, path: string, content: string) {\n const url = `/api/agents/${agentId}/instructions-bundle/file`;\n const current = await api<any>(\"GET\", `${url}?path=${encodeURIComponent(path)}`).catch(() => null);\n if (current && current.content === content) return;\n const base = !current ? (path === \"AGENTS.md\" ? { baseRevisionId: null, baseHash: null } : { baseHash: null })\n : current.isEntryFile ? { baseRevisionId: current.revision?.id ?? null } : { baseHash: current.contentHash ?? null };\n await api(\"PUT\", url, { path, content, ...base });\n}\nasync function writeFiles(agentId: string, files: Record<string, string>) {\n for (const [path, content] of Object.entries(files)) await writeFile(agentId, path, content);\n}\nasync function assignSkills(agentId: string, skills: { keys: string[]; failed: string[] }): Promise<string | null> {\n const problems = skills.failed.length ? [`skills not available: ${skills.failed.join(\", \")}`] : [];\n if (skills.keys.length) {\n try { await api(\"POST\", `/api/agents/${agentId}/skills/sync`, { mode: \"add\", desiredSkills: skills.keys }); }\n catch (error) { problems.push(\"skills not assigned (\" + String((error as Error).message).slice(0, 80) + \"): assign them manually\"); }\n }\n return problems.length ? problems.join(\"; \") : null;\n}\nconst ORG_FILES = [\"COMPANY.md\", \"BUSINESS.md\"];\nconst readFile = (agentId: string, path: string) => api<any>(\"GET\", `/api/agents/${agentId}/instructions-bundle/file?path=${encodeURIComponent(path)}`).then((f) => String(f?.content ?? \"\")).catch(() => \"\");\n\n// ---------- styles ----------\nconst S: Record<string, CSSProperties> = {\n page: { padding: 24, maxWidth: 1100, display: \"flex\", flexDirection: \"column\", gap: 16, fontSize: 14 },\n tabs: { display: \"flex\", gap: 4, borderBottom: \"1px solid var(--border, #333)\" },\n card: { border: \"1px solid var(--border, #333)\", borderRadius: 8, padding: 14, display: \"flex\", flexDirection: \"column\", gap: 8 },\n row: { display: \"flex\", alignItems: \"center\", gap: 8, flexWrap: \"wrap\" },\n muted: { color: \"var(--muted-foreground, #999)\", fontSize: 13 },\n th: { textAlign: \"left\", padding: \"6px 8px\", borderBottom: \"1px solid var(--border, #333)\", fontWeight: 600, fontSize: 12 },\n td: { padding: \"6px 8px\", borderBottom: \"1px solid color-mix(in srgb, var(--border, #333) 50%, transparent)\", verticalAlign: \"middle\" },\n select: { padding: \"5px 8px\", borderRadius: 6, border: \"1px solid var(--border, #333)\", background: \"var(--background, transparent)\", color: \"inherit\", maxWidth: 340 },\n pre: { margin: 0, padding: 10, borderRadius: 6, background: \"color-mix(in srgb, var(--foreground, #fff) 6%, transparent)\", whiteSpace: \"pre-wrap\", fontSize: 12.5, fontFamily: \"ui-monospace, monospace\" },\n};\nfunction Btn({ children, onClick, disabled, primary }: { children: ReactNode; onClick: () => void; disabled?: boolean; primary?: boolean }) {\n return <button type=\"button\" onClick={onClick} disabled={disabled} style={{ padding: \"5px 10px\", borderRadius: 6, cursor: disabled ? \"default\" : \"pointer\", opacity: disabled ? 0.5 : 1, fontSize: 13, border: \"1px solid var(--border, #333)\", background: primary ? \"var(--primary, #2563eb)\" : \"transparent\", color: primary ? \"var(--primary-foreground, #fff)\" : \"inherit\" }}>{children}</button>;\n}\nfunction Tab({ id, current, set, children }: { id: string; current: string; set: (id: string) => void; children: ReactNode }) {\n const active = id === current;\n return <button type=\"button\" role=\"tab\" aria-selected={active} onClick={() => set(id)} style={{ padding: \"8px 14px\", border: \"none\", background: \"transparent\", color: \"inherit\", cursor: \"pointer\", fontSize: 14, fontWeight: active ? 600 : 400, borderBottom: active ? \"2px solid var(--primary, #2563eb)\" : \"2px solid transparent\" }}>{children}</button>;\n}\nconst Badge = ({ ok, children }: { ok: boolean; children: ReactNode }) => <span style={{ fontSize: 12, padding: \"2px 8px\", borderRadius: 999, background: ok ? \"color-mix(in srgb, #22c55e 22%, transparent)\" : \"color-mix(in srgb, #f59e0b 22%, transparent)\" }}>{children}</span>;\n\n// ---------- plain-language guide ----------\nconst GUIDE: { title: string; text: string }[] = [\n { title: \"1. You give a job to one agent\", text: \"Create a task as usual and assign it to the agent in charge of that area, for example the CTO for software work.\" },\n { title: \"2. A workflow splits the job between agents\", text: \"A workflow is a recipe: who does what, in which order. When you start it on the task, the steps become small tasks, each given to the right agent.\" },\n { title: \"3. One agent works, another one checks\", text: \"When an agent finishes, a colleague checks the result. If something is wrong the work goes back with a list of what to fix. This can happen at most 3 times.\" },\n { title: \"4. Problems go up one level at a time\", text: \"If it is still not right after 3 tries, the head of the area steps in. If they cannot solve it, the CEO tries. Only then are you asked to decide.\" },\n { title: \"5. You follow everything in Progress\", text: \"The Progress tab shows each step: waiting, in progress, done (with the proof) or blocked. You do not need to open the single tasks.\" },\n];\nfunction Guide({ id, children }: { id: string; children?: ReactNode }) {\n const key = \"agents-workflows-guide-\" + id;\n const [open, setOpen] = useState(() => { try { return localStorage.getItem(key) !== \"closed\"; } catch { return true; } });\n const toggle = () => { const next = !open; setOpen(next); try { localStorage.setItem(key, next ? \"open\" : \"closed\"); } catch { /* storage not available */ } };\n return <div style={{ ...S.card, background: \"color-mix(in srgb, var(--primary, #2563eb) 8%, transparent)\" }}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><strong>How does this work?</strong><Btn onClick={toggle}>{open ? \"Hide guide\" : \"Show guide\"}</Btn></div>\n {open && (children ?? <>\n <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fit, minmax(190px, 1fr))\", gap: 10 }}>\n {GUIDE.map((g) => <div key={g.title} style={{ ...S.card, gap: 4, background: \"var(--background, transparent)\" }}><strong style={{ fontSize: 13 }}>{g.title}</strong><span style={S.muted}>{g.text}</span></div>)}\n </div>\n <div style={S.muted}><strong>Two words to know.</strong> A <em>procedure</em> is a checklist for one agent working alone. A <em>workflow</em> is the same idea for several agents working one after another. To try it: pick a workflow below, choose a task and press \"Start workflow\".</div>\n </>)}\n </div>;\n}\nfunction StepDiagram({ flow, roleTitle }: { flow: Flow; roleTitle: (key: string) => string }) {\n return <div style={{ display: \"flex\", flexWrap: \"wrap\", alignItems: \"stretch\", gap: 6 }}>{flow.steps.map((step, i) => <div key={step.id} style={{ display: \"flex\", alignItems: \"center\", gap: 6 }}>\n <div style={{ border: \"1px solid var(--border, #333)\", borderRadius: 8, padding: \"6px 10px\", maxWidth: 210, opacity: step.optional ? 0.7 : 1 }}>\n <div style={{ fontSize: 12, fontWeight: 600 }}>{roleTitle(step.role)}{step.via ? \" (through the CEO)\" : \"\"}</div>\n <div style={{ fontSize: 12.5 }}>{step.title}</div>\n {step.reviewBy && <div style={{ fontSize: 12, marginTop: 4, color: \"var(--muted-foreground, #999)\" }}>checked by {roleTitle(step.reviewBy)}</div>}\n {step.optional && <div style={{ fontSize: 12, color: \"var(--muted-foreground, #999)\" }}>only if needed</div>}\n </div>\n {i < flow.steps.length - 1 && <span aria-hidden=\"true\">\u2192</span>}\n </div>)}</div>;\n}\n\n// ---------- sidebar ----------\nexport function PlaybookSidebar() {\n const nav = useHostNavigation();\n const { companyPrefix } = useHostContext();\n const { pathname } = useHostLocation();\n const href = (companyPrefix ? \"/\" + companyPrefix : \"\") + \"/agents-workflows\";\n const active = pathname.replace(/\\/+$/, \"\") === href;\n return <a {...nav.linkProps(href)} data-plugin-sidebar-link=\"agents-workflows\" aria-current={active ? \"page\" : undefined} style={{ display: \"flex\", alignItems: \"center\", gap: 10, margin: \"0 8px\", borderRadius: 8, padding: \"6px 8px\", textDecoration: \"none\", fontSize: \"var(--text-compact, 13px)\", fontWeight: 500, color: active ? \"var(--sidebar-accent-foreground, #f5f5f5)\" : \"color-mix(in srgb, var(--foreground, #f5f5f5) 80%, transparent)\", background: active ? \"var(--sidebar-accent, rgba(255,255,255,.08))\" : \"transparent\" }}>\n <span data-plugin-sidebar-icon=\"true\" aria-hidden=\"true\" style={{ display: \"inline-flex\", width: 16, height: 16, justifyContent: \"center\" }}>\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M4 19.5A2.5 2.5 0 0 1 6.5 17H20V3H6.5A2.5 2.5 0 0 0 4 5.5z\" /><path d=\"M4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5\" /><path d=\"M9 8l2 2 4-4\" /></svg>\n </span>\n <span data-plugin-sidebar-label=\"true\">Agents & Workflows</span>\n </a>;\n}\n\n// ---------- page ----------\nexport function PlaybookPage() {\n const { companyId, companyPrefix } = useHostContext();\n const [tab, setTab] = useState(\"mine\");\n const catalog = usePluginData<Catalog>(\"catalog\", { companyId: companyId ?? \"\" });\n const builder = usePluginData<Builder>(\"builder\", { companyId: companyId ?? \"\" });\n const [message, setMessage] = useState<{ kind: \"ok\" | \"error\"; text: string } | null>(null);\n const [draft, setDraft] = useState<Draft | null>(null);\n const [pending, setPending] = useState(\"\");\n const say = (kind: \"ok\" | \"error\", text: string) => setMessage({ kind, text });\n const refreshAll = () => { catalog.refresh(); builder.refresh(); };\n if (!companyId) return <div style={S.page}>Select a company.</div>;\n const ready = catalog.data && builder.data;\n return <div style={S.page}>\n <div>\n <h1 style={{ fontSize: 22, fontWeight: 600, margin: 0 }}>Agents & Workflows</h1>\n <div style={S.muted}>Create your own agents, give them skills, tools and procedures, and run workflows between them.</div>\n </div>\n <div role=\"tablist\" style={S.tabs}>\n <Tab id=\"mine\" current={tab} set={setTab}>My agents</Tab>\n <Tab id=\"assistant\" current={tab} set={setTab}>Assistant</Tab>\n <Tab id=\"agents\" current={tab} set={setTab}>Role library</Tab>\n <Tab id=\"flows\" current={tab} set={setTab}>Workflows</Tab>\n <Tab id=\"runs\" current={tab} set={setTab}>Progress</Tab>\n <Tab id=\"settings\" current={tab} set={setTab}>Settings</Tab>\n </div>\n {message && <div role=\"status\" style={{ ...S.card, borderColor: message.kind === \"ok\" ? \"#22c55e\" : \"#ef4444\" }}>{message.text}</div>}\n {catalog.error && <div role=\"alert\" style={S.card}>Error: {catalog.error.message}</div>}\n {!ready ? <div style={S.muted}>Loading\u2026</div>\n : tab === \"mine\" ? <MyAgentsTab companyId={companyId} catalog={catalog.data!} builder={builder.data!} refresh={refreshAll} say={say} draft={draft} setDraft={setDraft} askAssistant={(text) => { setPending(text); setTab(\"assistant\"); }} />\n : tab === \"assistant\" ? <AssistantTab companyId={companyId} catalog={catalog.data!} refreshAll={refreshAll} builder={builder.data!} refresh={builder.refresh} say={say} pending={pending} clearPending={() => setPending(\"\")} goSettings={() => setTab(\"settings\")} useDraft={(d) => { setDraft({ ...emptyDraft(), ...d, skills: d.skills ?? [], links: d.links ?? [], procedures: d.procedures ?? [] }); setTab(\"mine\"); }} />\n : tab === \"agents\" ? <AgentsTab companyId={companyId} catalog={catalog.data!} refresh={catalog.refresh} say={say} />\n : tab === \"flows\" ? <FlowsTab companyId={companyId} catalog={catalog.data!} say={say} goRuns={() => setTab(\"runs\")} />\n : tab === \"settings\" ? <SettingsTab companyId={companyId} catalog={catalog.data!} builder={builder.data!} refresh={builder.refresh} say={say} />\n : <RunsTab companyId={companyId} prefix={companyPrefix} />}\n </div>;\n}\n\nfunction AgentsTab({ companyId, catalog, refresh, say }: { companyId: string; catalog: Catalog; refresh: () => void; say: (k: \"ok\" | \"error\", t: string) => void }) {\n const [templateId, setTemplateId] = useState(\"\");\n const [busy, setBusy] = useState<string | null>(null);\n const [target, setTarget] = useState(\"\");\n const [targetRole, setTargetRole] = useState(\"\");\n const [filter, setFilter] = useState(\"\");\n const nav = useHostNavigation();\n const { companyPrefix } = useHostContext();\n const prefix = companyPrefix ? \"/\" + companyPrefix : \"\";\n const agentName = (id: string | null) => catalog.agents.find((a) => a.id === id)?.name ?? null;\n const roleFiles = usePluginAction(\"role-files\");\n const roleSkills = usePluginAction(\"role-skills\");\n const skillsFor = async (key: string) => (await roleSkills({ companyId, key })) as { keys: string[]; failed: string[] };\n const getFiles = async (key: string): Promise<Record<string, string>> => {\n const response = (await roleFiles({ key })) as { files: Record<string, string> | null };\n if (!response?.files) throw new Error(\"role files not available\");\n return response.files;\n };\n const run = async (id: string, job: () => Promise<string>) => {\n setBusy(id);\n try { say(\"ok\", await job()); refresh(); }\n catch (error) { say(\"error\", String((error as Error).message ?? error)); }\n finally { setBusy(null); }\n };\n\n const create = (role: Role) => run(role.key, async () => {\n if (!templateId) throw new Error(\"First choose which agent to copy the technical setup from.\");\n const template = await api<any>(\"GET\", `/api/agents/${templateId}`);\n const adapterConfig = { ...(template.adapterConfig ?? {}) };\n for (const key of INSTRUCTION_KEYS) delete adapterConfig[key];\n const files = await getFiles(role.key);\n // The company and business descriptions come from the agent you copy from, when it has them.\n let inherited = 0;\n for (const name of ORG_FILES) { const text = await readFile(templateId, name); if (text.trim()) { files[name] = text; inherited++; } }\n const manager = catalog.roles.find((r) => r.key === role.reportsTo)?.agentId ?? null;\n const created = await api<any>(\"POST\", `/api/companies/${companyId}/agents`, {\n name: role.title, title: role.title, role: role.nativeRole, reportsTo: manager,\n adapterType: template.adapterType, adapterConfig, runtimeConfig: template.runtimeConfig ?? {},\n runner: template.adapterType === \"paperclip_runner\" ? \"paperclip\" : \"legacy\", // keep the same kind of engine as the template\n instructionsBundle: { entryFile: \"AGENTS.md\", files }, metadata: { agentStaticRole: role.key },\n });\n const agent = created.agent ?? created;\n if (agent?.id) {\n const bundle = await api(\"GET\", `/api/agents/${agent.id}/instructions-bundle`).catch(() => null);\n if (!bundle) return `Created \"${role.title}\", but the \"${template.adapterType}\" engine does not support instruction files: instructions and procedures were NOT loaded. Use a Claude Code, Pi, Codex or similar agent as the model.`;\n }\n const warn = agent?.id ? await assignSkills(agent.id, await skillsFor(role.key)) : \"agent awaiting approval\";\n return `Created \"${role.title}\" with ${Object.keys(files).length} files and ${role.skills.length} skills${inherited ? \"\" : \" (company and business files are blank templates: fill them in)\"}${manager ? \"\" : role.reportsTo ? \" (manager not present yet: set it later)\" : \"\"}${warn ? \" \u2014 \" + warn : \"\"}.`;\n });\n\n const update = (role: Role) => run(role.key, async () => {\n const files = await getFiles(role.key);\n for (const name of ORG_FILES) if ((await readFile(role.agentId!, name)).trim()) delete files[name]; // keep the company's own text\n await writeFiles(role.agentId!, files);\n const warn = await assignSkills(role.agentId!, await skillsFor(role.key));\n return `Instructions of \"${role.title}\" updated (${Object.keys(files).length} files)${warn ? \" \u2014 \" + warn : \"\"}.`;\n });\n\n const addPlaybooks = () => run(\"native\", async () => {\n if (!target || !targetRole) throw new Error(\"Choose the agent and the role to take the procedures from.\");\n const all = await getFiles(targetRole);\n const playbooks = Object.fromEntries(Object.entries(all).filter(([path]) => path.startsWith(\"PLAYBOOKS/\")));\n await writeFiles(target, playbooks);\n const entry = await api<any>(\"GET\", `/api/agents/${target}/instructions-bundle/file?path=AGENTS.md`).catch(() => null);\n const current = String(entry?.content ?? \"\");\n if (!current.includes(\"run-playbook\")) await writeFile(target, \"AGENTS.md\", (current || \"# Agent instructions\") + PLAYBOOK_SECTION);\n const role = catalog.roles.find((r) => r.key === targetRole)!;\n const existing = await api<any>(\"GET\", `/api/agents/${target}`);\n await api(\"PATCH\", `/api/agents/${target}`, { metadata: { ...(existing.metadata ?? {}), agentStaticRole: role.key } }).catch(() => null);\n const warn = await assignSkills(target, { keys: (await skillsFor(\"__none__\")).keys, failed: [] });\n return `Added ${Object.keys(playbooks).length} procedure files to \"${agentName(target)}\" and linked it to the role ${role.title}${warn ? \" \u2014 \" + warn : \"\"}. Its other instructions were not touched.`;\n });\n\n const shown = catalog.roles.filter((r) => !filter || (r.title + \" \" + r.path).toLowerCase().includes(filter.toLowerCase()));\n const present = catalog.roles.filter((r) => r.agentId).length;\n return <>\n <div style={S.card}>\n <strong>1. Technical setup for new agents</strong>\n <div style={S.muted}>A new agent needs an engine (Claude Code, Pi, \u2026) and its credentials. They are copied from an agent that already works.</div>\n <div style={S.row}>\n <label htmlFor=\"pb-template\">Copy from</label>\n <select id=\"pb-template\" style={S.select} value={templateId} onChange={(e) => setTemplateId(e.target.value)}>\n <option value=\"\">\u2014 choose an existing agent \u2014</option>\n {catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name} ({a.adapterType})</option>)}\n </select>\n {catalog.agents.length === 0 && <span style={S.muted}>There is no agent yet: create one from Paperclip's Agents menu, then come back.</span>}\n </div>\n </div>\n\n <div style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <strong>2. Roles in the pack ({present} of {catalog.roles.length} present)</strong>\n <input aria-label=\"Filter roles\" placeholder=\"Filter\u2026\" value={filter} onChange={(e) => setFilter(e.target.value)} style={S.select} />\n </div>\n <table style={{ borderCollapse: \"collapse\", width: \"100%\" }}>\n <thead><tr><th style={S.th}>Role</th><th style={S.th}>Reports to</th><th style={S.th}>Procedures</th><th style={S.th}>Skills</th><th style={S.th}>In Paperclip</th><th style={S.th} /></tr></thead>\n <tbody>{shown.map((role) => <tr key={role.key}>\n <td style={S.td}><div>{role.title}</div><div style={S.muted}>{role.path}</div></td>\n <td style={S.td}>{catalog.roles.find((r) => r.key === role.reportsTo)?.title ?? \"Owner\"}</td>\n <td style={S.td}>{role.playbooks}</td><td style={S.td}>{role.skills.length}</td>\n <td style={S.td}>{role.agentId ? <><Badge ok>{agentName(role.agentId)}</Badge> <a {...nav.linkProps(`${prefix}/agents/${catalog.agents.find((a) => a.id === role.agentId)?.urlKey ?? role.agentId}/instructions`)} style={{ fontSize: 12, marginLeft: 6 }}>Open instructions</a></> : <Badge ok={false}>not present</Badge>}</td>\n <td style={{ ...S.td, textAlign: \"right\" }}>{role.agentId\n ? <Btn onClick={() => update(role)} disabled={busy !== null}>{busy === role.key ? \"\u2026\" : \"Update instructions\"}</Btn>\n : <Btn primary onClick={() => create(role)} disabled={busy !== null}>{busy === role.key ? \"\u2026\" : \"Create agent\"}</Btn>}</td>\n </tr>)}</tbody>\n </table>\n </div>\n\n <div style={S.card}>\n <strong>3. Add procedures to an agent you already have</strong>\n <div style={S.muted}>For native Paperclip agents: adds only the PLAYBOOKS folder, one paragraph at the end of AGENTS.md and the skill. The rest of the instructions is left as it is.</div>\n <div style={S.row}>\n <select aria-label=\"Existing agent\" style={S.select} value={target} onChange={(e) => setTarget(e.target.value)}>\n <option value=\"\">\u2014 agent \u2014</option>\n {catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name}</option>)}\n </select>\n <span>gets the procedures of</span>\n <select aria-label=\"Pack role\" style={S.select} value={targetRole} onChange={(e) => setTargetRole(e.target.value)}>\n <option value=\"\">\u2014 role \u2014</option>\n {catalog.roles.map((r) => <option key={r.key} value={r.key}>{r.title}</option>)}\n </select>\n <Btn primary onClick={addPlaybooks} disabled={busy !== null}>{busy === \"native\" ? \"\u2026\" : \"Add procedures\"}</Btn>\n </div>\n </div>\n </>;\n}\n\nfunction FlowsTab({ companyId, catalog, say, goRuns }: { companyId: string; catalog: Catalog; say: (k: \"ok\" | \"error\", t: string) => void; goRuns: () => void }) {\n const start = usePluginAction(\"start-flow\");\n const [issues, setIssues] = useState<{ id: string; identifier: string | null; title: string }[]>([]);\n const [chosen, setChosen] = useState<Record<string, string>>({});\n const [busy, setBusy] = useState<string | null>(null);\n useEffect(() => {\n api<any>(\"GET\", `/api/companies/${companyId}/issues?limit=100`).then((list) => {\n const rows = (Array.isArray(list) ? list : list.issues ?? []).filter((i: any) => ![\"done\", \"cancelled\"].includes(i.status) && !i.parentId);\n setIssues(rows.map((i: any) => ({ id: i.id, identifier: i.identifier ?? null, title: i.title })));\n }).catch(() => setIssues([]));\n }, [companyId]);\n const roleTitle = (key: string) => catalog.roles.find((r) => r.key === key)?.title ?? key;\n const go = async (flow: Flow) => {\n setBusy(flow.key);\n try {\n const outcome = (await start({ companyId, parentIssueId: chosen[flow.key], flowKey: flow.key })) as { content?: string };\n say(\"ok\", `Workflow \"${flow.key}\" started. ${String(outcome?.content ?? \"\").split(\"\\n\").slice(1).join(\" \")}`);\n goRuns();\n } catch (error) { say(\"error\", String((error as Error).message ?? error)); }\n finally { setBusy(null); }\n };\n return <><Guide id=\"workflows\" />{catalog.flows.map((flow) => <div key={flow.key} style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <strong>{flow.title}</strong>\n {flow.ownerAgentId ? <Badge ok>owner: {roleTitle(flow.ownerRole)}</Badge> : <Badge ok={false}>missing agent: {roleTitle(flow.ownerRole)}</Badge>}\n </div>\n <div style={S.muted}>{flow.useWhen}</div>\n <StepDiagram flow={flow} roleTitle={roleTitle} />\n <div style={S.row}>\n <select aria-label={`Task for ${flow.key}`} style={S.select} value={chosen[flow.key] ?? \"\"} onChange={(e) => setChosen({ ...chosen, [flow.key]: e.target.value })}>\n <option value=\"\">\u2014 choose the task to start it on \u2014</option>\n {issues.map((i) => <option key={i.id} value={i.id}>{i.identifier ? i.identifier + \" \u00B7 \" : \"\"}{i.title}</option>)}\n </select>\n <Btn primary onClick={() => go(flow)} disabled={!chosen[flow.key] || !flow.ownerAgentId || busy !== null}>{busy === flow.key ? \"\u2026\" : \"Start workflow\"}</Btn>\n </div>\n </div>)}</>;\n}\n\nfunction RunsTab({ companyId, prefix }: { companyId: string; prefix: string | null }) {\n const runs = usePluginData<{ runs: Run[] }>(\"runs\", { companyId });\n const nav = useHostNavigation();\n if (!runs.data) return <div style={S.muted}>Loading\u2026</div>;\n if (runs.data.runs.length === 0) return <div style={S.card}>No workflow started yet. Go to \"Workflows\" and start one on a task.</div>;\n return <>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><span style={S.muted}>PENDING = not started \u00B7 IN_PROGRESS = being worked on \u00B7 PASS = done, with proof \u00B7 BLOCKED = stuck, someone must decide</span><Btn onClick={runs.refresh}>Refresh</Btn></div>\n {runs.data.runs.map((run) => <div key={run.parentId} style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <a {...nav.linkProps(`${prefix ? \"/\" + prefix : \"\"}/issues/${run.identifier ?? run.parentId}`)}><strong>{run.identifier ? run.identifier + \" \u00B7 \" : \"\"}{run.title}</strong></a>\n <Badge ok={run.finished}>{run.finished ? \"completed\" : run.register.includes(\"[BLOCKED]\") ? \"blocked\" : \"in progress\"}</Badge>\n </div>\n <pre style={S.pre}>{run.register.split(\"## Steps\")[1]?.split(\"\\n_Maintained\")[0]?.trim() ?? run.register}</pre>\n </div>)}\n </>;\n}\n\n// ====================== Agent builder: my agents, wizard, assistant, settings ======================\ntype LinkItem = { kind: \"skill\" | \"mcp\" | \"playbook\"; url: string };\ntype Procedure = { title: string; useWhen: string; steps: string[] };\ntype Draft = { name: string; description: string; reportsTo: string; baseRole: string; templateId: string; skills: string[]; links: LinkItem[]; procedures: Procedure[] };\ntype Thread = { busy: boolean; messages: { role: \"user\" | \"assistant\" | \"system\"; text: string; at: string }[] };\ntype Builder = { settings: { assistantAgentId?: string }; librarySkills: { slug: string; title: string; description: string }[]; thread: Thread };\nconst emptyDraft = (): Draft => ({ name: \"\", description: \"\", reportsTo: \"\", baseRole: \"\", templateId: \"\", skills: [], links: [], procedures: [] });\nconst slugify = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-|-$/g, \"\").slice(0, 50) || \"procedure\";\nfunction guessKind(url: string): LinkItem[\"kind\"] {\n const u = url.toLowerCase();\n if (/skill\\.md|\\/skills?\\//.test(u)) return \"skill\";\n if (/playbook|workflow|\\.ya?ml($|\\?)/.test(u)) return \"playbook\";\n return \"mcp\";\n}\nfunction parseBlock<T>(text: string, tag: string): T | null {\n const match = text.match(new RegExp(\"```\" + tag + \"\\\\s*([\\\\s\\\\S]*?)```\"));\n if (!match) return null;\n try { return JSON.parse(match[1]) as T; } catch { return null; }\n}\ntype McpResult = { url?: string; name?: string; remoteUrl?: string | null; command?: string; args?: string[]; envKeys?: string[]; tools?: { name: string; description?: string; inputSchema?: unknown }[]; tested?: boolean; notes?: string };\n/** Register an MCP server in Paperclip's own Tools and give it to one agent: template -> connection -> health check -> profile -> binding. */\nasync function registerMcp(companyId: string, agent: AgentRow, r: McpResult): Promise<string> {\n const key = slugify(`${r.name || \"mcp\"}-${agent.name}`).slice(0, 60) + \"-\" + Date.now().toString(36);\n const name = `${r.name || \"MCP server\"} (${agent.name})`.slice(0, 150);\n let body: Record<string, unknown>;\n if (r.remoteUrl) body = { name, transport: \"mcp_remote\", config: { url: r.remoteUrl }, transportConfig: { url: r.remoteUrl } };\n else {\n if (!r.command) throw new Error(\"The assistant did not say how to start this server.\");\n await api(\"POST\", `/api/companies/${companyId}/tools/stdio-templates`, { templateId: key, name, description: r.notes?.slice(0, 3000) ?? null, command: r.command, args: r.args ?? [], envKeys: r.envKeys ?? [], tools: (r.tools ?? []).filter((x) => x?.name).map((x) => ({ name: x.name, description: x.description ?? null, ...(x.inputSchema && typeof x.inputSchema === \"object\" ? { inputSchema: x.inputSchema } : {}) })) });\n body = { name, transport: \"local_stdio\", config: { templateId: key }, transportConfig: { templateId: key } };\n }\n const connection = await api<any>(\"POST\", `/api/companies/${companyId}/tools/connections`, body);\n await api(\"PATCH\", `/api/tool-connections/${connection.id}`, { enabled: true, status: \"active\" });\n const health = await api<any>(\"POST\", `/api/tool-connections/${connection.id}/health-check`).catch((error) => ({ connection: { healthStatus: \"failed: \" + String(error.message).slice(0, 80) } }));\n await api(\"POST\", `/api/tool-connections/${connection.id}/catalog/refresh`).catch(() => null);\n const profile = await api<any>(\"POST\", `/api/companies/${companyId}/tools/profiles`, { profileKey: \"p-\" + key, name: `Tools: ${name}`.slice(0, 150), defaultAction: \"deny\", entries: [{ selectorType: \"connection\", effect: \"include\", connectionId: connection.id }] });\n await api(\"POST\", `/api/companies/${companyId}/tools/profiles/${profile.id}/bind`, { targetType: \"agent\", targetId: agent.id });\n const full = await api<any>(\"GET\", `/api/agents/${agent.id}`);\n const requested: { url: string; status: string }[] = Array.isArray(full.metadata?.requestedMcp) ? full.metadata.requestedMcp : [];\n const next = requested.some((m) => m.url === r.url) ? requested.map((m) => (m.url === r.url ? { ...m, status: \"installed\", connectionId: connection.id } : m)) : [...requested, { url: r.url ?? r.remoteUrl ?? name, status: \"installed\", connectionId: connection.id }];\n await api(\"PATCH\", `/api/agents/${agent.id}`, { metadata: { ...(full.metadata ?? {}), requestedMcp: next } });\n const secrets = (r.envKeys ?? []).length ? ` It needs ${r.envKeys!.length} secret value(s) (${r.envKeys!.join(\", \")}): add them in Connectors before the agent uses it.` : \"\";\n return `\"${r.name || \"MCP server\"}\" is registered in Paperclip and assigned to ${agent.name} (check: ${health?.connection?.healthStatus ?? \"unknown\"}, ${(r.tools ?? []).length} tools).${secrets}`;\n}\n\nconst input: CSSProperties = { ...S.select, maxWidth: \"100%\", width: \"100%\", boxSizing: \"border-box\" };\nconst Field = ({ label, hint, children }: { label: string; hint?: string; children: ReactNode }) => <label style={{ display: \"flex\", flexDirection: \"column\", gap: 4 }}>\n <span style={{ fontWeight: 600 }}>{label}</span>{hint && <span style={S.muted}>{hint}</span>}{children}\n</label>;\n\nfunction procedureFile(agentName: string, p: Procedure) {\n return [`# Playbook: ${p.title}`, \"\", `**Role:** ${agentName}`, `**Use when:** ${p.useWhen || \"the task matches this procedure.\"}`, \"\", \"Run this checklist with the `run-playbook` skill. This file is a read-only template; the run register lives in the task document `playbook`.\", \"\", \"## Steps\", ...p.steps.filter((s) => s.trim()).map((s, i) => `${i + 1}. ${s.trim()}`), \"\"].join(\"\\n\");\n}\nfunction entryFile(d: Draft, managerName: string | null) {\n return [`# ${d.name} \u2014 Paperclip entry instructions`, \"\", \"This is the entry file. Paperclip loads it automatically; sibling files are references to read when this file says so.\", \"\",\n \"## At every task start\", \"1. Work only on the task assigned to you. A chat does not create work unless the human explicitly asks.\", \"2. Read COMPANY.md and BUSINESS.md for the organization's context.\", \"3. If the task matches a procedure in PLAYBOOKS/, follow the `run-playbook` skill: keep the run register in the task document `playbook`, one step IN_PROGRESS at a time, evidence on every PASS.\", \"4. On a blocker, say what is needed and from whom, set the task to a waiting state, and stop.\", \"\",\n \"## Role\", d.description.trim(), \"\", `Reports to: ${managerName ?? \"the human Owner\"}.`, \"\",\n \"## Boundaries\", \"Do not spend money, publish, change permissions or act outside your assigned task without a recorded approval. Escalate to your manager when unsure.\", \"\"].join(\"\\n\");\n}\n\nfunction MyAgentsTab({ companyId, catalog, builder, refresh, say, draft, setDraft, askAssistant }: { companyId: string; catalog: Catalog; builder: Builder; refresh: () => void; say: (k: \"ok\" | \"error\", t: string) => void; draft: Draft | null; setDraft: (d: Draft | null) => void; askAssistant: (text: string) => void }) {\n const nav = useHostNavigation();\n const { companyPrefix } = useHostContext();\n const prefix = companyPrefix ? \"/\" + companyPrefix : \"\";\n const custom = catalog.agents.filter((a) => a.custom);\n if (draft) return <Wizard companyId={companyId} catalog={catalog} builder={builder} draft={draft} setDraft={setDraft} done={(text) => { setDraft(null); say(\"ok\", text); refresh(); }} fail={(text) => say(\"error\", text)} />;\n return <>\n <div style={{ ...S.card, flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", flexWrap: \"wrap\" }}>\n <div><strong>Create a custom agent</strong><div style={S.muted}>Describe what it should do, pick its skills and tools, and write the steps it must follow. You can also let the assistant interview you.</div></div>\n <div style={S.row}><Btn primary onClick={() => setDraft(emptyDraft())}>+ New agent</Btn><Btn onClick={() => askAssistant(\"\")}>Ask the assistant</Btn></div>\n </div>\n {custom.length === 0 ? <div style={S.card}><span style={S.muted}>You have not created any custom agent yet. Ready-made roles are under \"Role library\".</span></div>\n : custom.map((a) => <div key={a.id} style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <strong>{a.name}</strong>\n <a {...nav.linkProps(`${prefix}/agents/${a.urlKey ?? a.id}/instructions`)} style={{ fontSize: 13 }}>Open instructions</a>\n </div>\n {a.mcp.length > 0 && <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6 }}>\n <span style={S.muted}>Tools (MCP servers) requested for this agent</span>\n {a.mcp.map((m) => <div key={m.url} style={S.row}>\n <Badge ok={m.status === \"installed\"}>{m.status === \"installed\" ? \"installed\" : \"not installed yet\"}</Badge>\n <span style={{ wordBreak: \"break-all\" }}>{m.url}</span>\n {m.status !== \"installed\" && <Btn onClick={() => askAssistant(`Set up and test the MCP server at ${m.url} for the agent \"${a.name}\". Tell me first the exact command you will run and which secrets it needs, then do it and give me the mcp-result block.`)}>Install with the assistant</Btn>}\n </div>)}\n </div>}\n <ManualTool companyId={companyId} agent={a} say={say} refresh={refresh} />\n </div>)}\n </>;\n}\n\nfunction ManualTool({ companyId, agent, say, refresh }: { companyId: string; agent: AgentRow; say: (k: \"ok\" | \"error\", t: string) => void; refresh: () => void }) {\n const [name, setName] = useState(\"\");\n const [start, setStart] = useState(\"\");\n const [secrets, setSecrets] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const add = async () => {\n setBusy(true);\n try {\n const value = start.trim();\n const parts = value.split(/\\s+/);\n const result: McpResult = /^https:\\/\\//.test(value) ? { name, url: value, remoteUrl: value } : { name, url: value, command: parts[0], args: parts.slice(1) };\n result.envKeys = secrets.split(\",\").map((s) => s.trim()).filter(Boolean);\n say(\"ok\", await registerMcp(companyId, agent, result));\n setName(\"\"); setStart(\"\"); setSecrets(\"\"); refresh();\n } catch (error) { say(\"error\", \"Could not register the tool: \" + String((error as Error).message)); }\n finally { setBusy(false); }\n };\n return <details><summary style={{ cursor: \"pointer\", fontSize: 13 }}>Advanced: add a tool (MCP server) by hand</summary>\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6, marginTop: 8 }}>\n <input aria-label={`Tool name for ${agent.name}`} placeholder=\"Name, e.g. Filesystem\" style={input} value={name} onChange={(e) => setName(e.target.value)} />\n <input aria-label={`Start command or URL for ${agent.name}`} placeholder=\"Start command (npx -y package) or https:// address\" style={input} value={start} onChange={(e) => setStart(e.target.value)} />\n <input aria-label={`Secret names for ${agent.name}`} placeholder=\"Names of the secrets it needs, separated by commas (optional)\" style={input} value={secrets} onChange={(e) => setSecrets(e.target.value)} />\n <div><Btn primary onClick={add} disabled={busy || !name.trim() || !start.trim()}>{busy ? \"\u2026\" : \"Register and assign\"}</Btn></div>\n </div>\n </details>;\n}\n\nfunction Wizard({ companyId, catalog, builder, draft, setDraft, done, fail }: { companyId: string; catalog: Catalog; builder: Builder; draft: Draft; setDraft: (d: Draft | null) => void; done: (text: string) => void; fail: (text: string) => void }) {\n const [step, setStep] = useState(1);\n const [link, setLink] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const roleFiles = usePluginAction(\"role-files\");\n const skillKeys = usePluginAction(\"skill-keys\");\n const fetchText = usePluginAction(\"fetch-text\");\n const set = (patch: Partial<Draft>) => setDraft({ ...draft, ...patch });\n const steps = [\"What it does\", \"Skills and tools\", \"How it works\", \"Review\"];\n const problems = [!draft.name.trim() && \"Give the agent a name.\", !draft.description.trim() && !draft.baseRole && \"Describe what the agent should do.\", !draft.templateId && \"Choose which existing agent to copy the engine from.\"].filter(Boolean) as string[];\n const addLink = () => { const url = link.trim(); if (!/^https:\\/\\//.test(url)) return fail(\"Paste a full link starting with https://\"); set({ links: [...draft.links, { kind: guessKind(url), url }] }); setLink(\"\"); };\n const setProc = (i: number, patch: Partial<Procedure>) => set({ procedures: draft.procedures.map((p, n) => (n === i ? { ...p, ...patch } : p)) });\n\n const create = async () => {\n setBusy(true);\n try {\n const template = await api<any>(\"GET\", `/api/agents/${draft.templateId}`);\n const adapterConfig = { ...(template.adapterConfig ?? {}) };\n for (const key of INSTRUCTION_KEYS) delete adapterConfig[key];\n const base = draft.baseRole ? ((await roleFiles({ key: draft.baseRole })) as { files: Record<string, string> | null }).files ?? {} : {};\n const files: Record<string, string> = { ...base };\n const manager = catalog.agents.find((a) => a.id === draft.reportsTo) ?? null;\n if (!draft.baseRole) files[\"AGENTS.md\"] = entryFile(draft, manager?.name ?? null);\n else if (draft.description.trim()) files[\"AGENTS.md\"] = (files[\"AGENTS.md\"] ?? \"\") + `\\n\\n## Additional instructions\\n${draft.description.trim()}\\n`;\n for (const name of ORG_FILES) { const text = await readFile(draft.templateId, name); if (text.trim()) files[name] = text; }\n const offset = Object.keys(files).filter((f) => /^PLAYBOOKS\\/\\d\\d-/.test(f)).length + 1;\n draft.procedures.filter((p) => p.title.trim() && p.steps.some((s) => s.trim())).forEach((p, i) => { files[`PLAYBOOKS/${String(offset + i + 1).padStart(2, \"0\")}-${slugify(p.title)}.md`] = procedureFile(draft.name, p); });\n const notes: string[] = [];\n let imported = 0;\n for (const item of draft.links.filter((l) => l.kind === \"playbook\")) {\n try { const { text } = (await fetchText({ url: item.url })) as { text: string }; imported++; files[/^schema:\\s*agent-static\\.playbook-flow/m.test(text) ? `PLAYBOOKS/flows/imported-${imported}.yaml` : `PLAYBOOKS/imported-${imported}.md`] = text; }\n catch (error) { notes.push(`playbook link not imported (${String((error as Error).message).slice(0, 60)})`); }\n }\n const mcp = draft.links.filter((l) => l.kind === \"mcp\").map((l) => ({ url: l.url, status: \"requested\" }));\n if (mcp.length) files[\"TOOLS.md\"] = (files[\"TOOLS.md\"] ?? \"# Tools\\n\") + \"\\n\\n## Requested MCP servers\\nThese are requested for this agent and are usable only after they are installed and assigned in Paperclip:\\n\" + mcp.map((m) => `- ${m.url}`).join(\"\\n\") + \"\\n\";\n const created = await api<any>(\"POST\", `/api/companies/${companyId}/agents`, {\n name: draft.name.trim(), title: draft.name.trim(), role: catalog.roles.find((r) => r.key === draft.baseRole)?.nativeRole ?? \"general\", reportsTo: draft.reportsTo || null,\n adapterType: template.adapterType, adapterConfig, runtimeConfig: template.runtimeConfig ?? {}, runner: template.adapterType === \"paperclip_runner\" ? \"paperclip\" : \"legacy\",\n instructionsBundle: { entryFile: \"AGENTS.md\", files }, metadata: { agentBuilder: true, requestedMcp: mcp, ...(draft.baseRole ? { agentStaticRole: draft.baseRole } : {}) },\n });\n const agent = created.agent ?? created;\n if (!agent?.id) return done(`\"${draft.name}\" was submitted and is awaiting approval.`);\n if (!(await api(\"GET\", `/api/agents/${agent.id}/instructions-bundle`).catch(() => null))) notes.push(`the \"${template.adapterType}\" engine does not support instruction files, so instructions were NOT loaded`);\n const slugs = [...new Set([\"run-playbook\", ...draft.skills, ...(catalog.roles.find((r) => r.key === draft.baseRole)?.skills ?? [])])];\n const library = (await skillKeys({ companyId, slugs })) as { keys: string[]; failed: string[] };\n for (const item of draft.links.filter((l) => l.kind === \"skill\")) {\n try { const result = await api<any>(\"POST\", `/api/companies/${companyId}/skills/import`, { source: item.url }); const key = result?.imported?.[0]?.key ?? result?.skills?.[0]?.key ?? result?.[0]?.key ?? result?.key; if (key) library.keys.push(key); else notes.push(\"skill link imported but not assigned: assign it from the agent's Skills\"); }\n catch (error) { notes.push(`skill link not imported (${String((error as Error).message).slice(0, 60)})`); }\n }\n const warn = await assignSkills(agent.id, library);\n if (warn) notes.push(warn);\n if (mcp.length) notes.push(`${mcp.length} MCP server(s) are recorded as requested: use \"Install with the assistant\" on the agent's card`);\n done(`Created \"${draft.name}\" with ${Object.keys(files).length} files and ${library.keys.length} skills${notes.length ? \" \u2014 \" + notes.join(\"; \") : \"\"}.`);\n } catch (error) { fail(String((error as Error).message ?? error)); }\n finally { setBusy(false); }\n };\n\n return <div style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><strong>New agent</strong><Btn onClick={() => setDraft(null)}>Cancel</Btn></div>\n <ol style={{ display: \"flex\", gap: 6, listStyle: \"none\", padding: 0, margin: 0, flexWrap: \"wrap\" }}>{steps.map((label, i) => <li key={label}>\n <button type=\"button\" aria-current={step === i + 1 ? \"step\" : undefined} onClick={() => setStep(i + 1)} style={{ padding: \"4px 10px\", borderRadius: 999, border: \"1px solid var(--border, #333)\", cursor: \"pointer\", color: \"inherit\", background: step === i + 1 ? \"color-mix(in srgb, var(--primary, #2563eb) 30%, transparent)\" : \"transparent\", fontSize: 13 }}>{i + 1}. {label}</button>\n </li>)}</ol>\n\n {step === 1 && <>\n <Field label=\"Name\" hint=\"How the agent will appear in Paperclip, e.g. \u201CInvoice Assistant\u201D.\"><input aria-label=\"Agent name\" style={input} value={draft.name} onChange={(e) => set({ name: e.target.value })} /></Field>\n <Field label=\"What should this agent do?\" hint=\"Write it as you would explain it to a new colleague.\"><textarea aria-label=\"What should this agent do?\" rows={4} style={input} value={draft.description} onChange={(e) => set({ description: e.target.value })} /></Field>\n <Field label=\"Who does it report to?\" hint=\"The agent that gives it work and receives its results. Leave empty to report to you.\">\n <select aria-label=\"Reports to\" style={input} value={draft.reportsTo} onChange={(e) => set({ reportsTo: e.target.value })}><option value=\"\">\u2014 me (the Owner) \u2014</option>{catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name}</option>)}</select></Field>\n <Field label=\"Engine\" hint=\"The new agent uses the same engine and login as an agent that already works.\">\n <select aria-label=\"Copy engine from\" style={input} value={draft.templateId} onChange={(e) => set({ templateId: e.target.value })}><option value=\"\">\u2014 choose an existing agent \u2014</option>{catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name} ({a.adapterType})</option>)}</select></Field>\n <details><summary style={{ cursor: \"pointer\" }}>Advanced: start from a ready-made role</summary>\n <select aria-label=\"Start from role\" style={{ ...input, marginTop: 6 }} value={draft.baseRole} onChange={(e) => set({ baseRole: e.target.value })}><option value=\"\">\u2014 no, start empty \u2014</option>{catalog.roles.map((r) => <option key={r.key} value={r.key}>{r.title}</option>)}</select></details>\n </>}\n\n {step === 2 && <>\n <Field label=\"Skills\" hint=\"Skills are know-how the agent can read when needed. Tick the ones that fit.\">\n <div style={{ maxHeight: 220, overflow: \"auto\", border: \"1px solid var(--border, #333)\", borderRadius: 6, padding: 8, display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(260px, 1fr))\", gap: 4 }}>\n {builder.librarySkills.filter((s) => s.slug !== \"run-playbook\").map((s) => <label key={s.slug} title={s.description} style={{ display: \"flex\", gap: 6, alignItems: \"center\", fontSize: 13 }}>\n <input type=\"checkbox\" checked={draft.skills.includes(s.slug)} onChange={(e) => set({ skills: e.target.checked ? [...draft.skills, s.slug] : draft.skills.filter((x) => x !== s.slug) })} />{s.title}</label>)}\n </div></Field>\n <Field label=\"Add by link\" hint=\"Paste the link of a skill, of a tool (MCP server) or of a playbook. Tools are installed afterwards, with the assistant.\">\n <div style={S.row}><input aria-label=\"Link\" placeholder=\"https://\u2026\" style={{ ...input, flex: 1, width: \"auto\" }} value={link} onChange={(e) => setLink(e.target.value)} onKeyDown={(e) => { if (e.key === \"Enter\") { e.preventDefault(); addLink(); } }} /><Btn onClick={addLink}>Add</Btn></div></Field>\n {draft.links.map((item, i) => <div key={item.url + i} style={S.row}>\n <select aria-label={`Type of link ${i + 1}`} style={S.select} value={item.kind} onChange={(e) => set({ links: draft.links.map((l, n) => (n === i ? { ...l, kind: e.target.value as LinkItem[\"kind\"] } : l)) })}><option value=\"skill\">Skill</option><option value=\"mcp\">Tool (MCP server)</option><option value=\"playbook\">Playbook</option></select>\n <span style={{ wordBreak: \"break-all\", flex: 1 }}>{item.url}</span><Btn onClick={() => set({ links: draft.links.filter((_, n) => n !== i) })}>Remove</Btn></div>)}\n </>}\n\n {step === 3 && <>\n <Guide id=\"procedures\"><div style={S.muted}>A procedure is a checklist for one kind of job. When the agent gets a task that matches, it copies the steps into the task, works on them one at a time, and for each step it must write the proof (a link, a file, a result) before moving on. If it gets stuck it says what it needs and stops instead of guessing. Write short steps, each with a clear result. You can add or change procedures later from the agent's instructions.</div></Guide>\n {draft.procedures.map((p, i) => <div key={i} style={{ ...S.card, gap: 6 }}>\n <div style={S.row}><input aria-label={`Procedure ${i + 1} title`} placeholder=\"Title, e.g. \u201CPrepare a monthly report\u201D\" style={{ ...input, flex: 1, width: \"auto\" }} value={p.title} onChange={(e) => setProc(i, { title: e.target.value })} /><Btn onClick={() => set({ procedures: draft.procedures.filter((_, n) => n !== i) })}>Remove</Btn></div>\n <input aria-label={`Procedure ${i + 1} use when`} placeholder=\"Use when\u2026 (optional)\" style={input} value={p.useWhen} onChange={(e) => setProc(i, { useWhen: e.target.value })} />\n <textarea aria-label={`Procedure ${i + 1} steps`} rows={5} placeholder={\"One step per line, in order\\nCollect the figures\\nCheck them against the source\\nWrite the summary\"} style={input} value={p.steps.join(\"\\n\")} onChange={(e) => setProc(i, { steps: e.target.value.split(\"\\n\") })} />\n </div>)}\n <div><Btn onClick={() => set({ procedures: [...draft.procedures, { title: \"\", useWhen: \"\", steps: [] }] })}>+ Add a procedure</Btn></div>\n </>}\n\n {step === 4 && <>\n <div><strong>{draft.name || \"(no name)\"}</strong> \u2014 reports to {catalog.agents.find((a) => a.id === draft.reportsTo)?.name ?? \"you\"}</div>\n <div style={S.muted}>{draft.description || (draft.baseRole ? \"From the ready-made role.\" : \"\")}</div>\n <ul style={{ margin: 0, paddingLeft: 20 }}>\n <li>{draft.skills.length + 1} skill(s) from the library, {draft.links.filter((l) => l.kind === \"skill\").length} by link</li>\n <li>{draft.links.filter((l) => l.kind === \"mcp\").length} tool(s) (MCP servers) to install after creation</li>\n <li>{draft.procedures.filter((p) => p.title.trim()).length} procedure(s), {draft.links.filter((l) => l.kind === \"playbook\").length} playbook(s) by link</li>\n </ul>\n {problems.map((p) => <div key={p} role=\"alert\" style={{ color: \"#ef4444\" }}>{p}</div>)}\n </>}\n\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <Btn onClick={() => setStep(Math.max(1, step - 1))} disabled={step === 1}>Back</Btn>\n {step < 4 ? <Btn primary onClick={() => setStep(step + 1)}>Next</Btn> : <Btn primary onClick={create} disabled={busy || problems.length > 0}>{busy ? \"Creating\u2026\" : \"Create agent\"}</Btn>}\n </div>\n </div>;\n}\n\nfunction AssistantTab({ companyId, catalog, refreshAll, builder, refresh, useDraft, say, pending, clearPending, goSettings }: { companyId: string; catalog: Catalog; refreshAll: () => void; builder: Builder; refresh: () => void; useDraft: (d: Partial<Draft>) => void; say: (k: \"ok\" | \"error\", t: string) => void; pending: string; clearPending: () => void; goSettings: () => void }) {\n const send = usePluginAction(\"assistant-send\");\n const reset = usePluginAction(\"assistant-reset\");\n const [text, setText] = useState(pending);\n const [sending, setSending] = useState(false);\n const [registering, setRegistering] = useState(false);\n useEffect(() => { if (pending) { setText(pending); clearPending(); } }, [pending]);\n useEffect(() => { if (!builder.thread.busy) return; const timer = setInterval(refresh, 3000); return () => clearInterval(timer); }, [builder.thread.busy]);\n if (!builder.settings.assistantAgentId) return <div style={S.card}><strong>The assistant is not set up yet</strong><span style={S.muted}>Choose which of your agents powers it (its engine does the thinking, the web searches and the installations).</span><div><Btn primary onClick={goSettings}>Open settings</Btn></div></div>;\n const go = async () => { setSending(true); try { await send({ companyId, text }); setText(\"\"); refresh(); } catch (error) { say(\"error\", String((error as Error).message ?? error)); } finally { setSending(false); } };\n return <div style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><strong>Assistant</strong><Btn onClick={async () => { await reset({ companyId }); refresh(); }}>Start over</Btn></div>\n <span style={S.muted}>Tell it what agent you need. It asks a few questions, can search the web for tools and skills, and prepares the agent for you to review. Each message uses your engine's credits.</span>\n <div aria-live=\"polite\" style={{ display: \"flex\", flexDirection: \"column\", gap: 8, maxHeight: 460, overflow: \"auto\" }}>\n {builder.thread.messages.length === 0 && <span style={S.muted}>Example: \u201CI need an agent that answers supplier emails and files the invoices.\u201D</span>}\n {builder.thread.messages.map((m, i) => {\n const draft = m.role === \"assistant\" ? parseBlock<Partial<Draft>>(m.text, \"agent-draft\") : null;\n const mcp = m.role === \"assistant\" ? parseBlock<McpResult>(m.text, \"mcp-result\") : null;\n const wanted = mcp ? catalog.agents.filter((a) => a.mcp.some((x) => x.url === mcp.url && x.status !== \"installed\")) : [];\n const targets = mcp ? (wanted.length ? wanted : catalog.agents.filter((a) => a.custom)) : [];\n return <div key={i} style={{ alignSelf: m.role === \"user\" ? \"flex-end\" : \"flex-start\", maxWidth: \"85%\", ...S.pre, fontFamily: \"inherit\", fontSize: 14, background: m.role === \"user\" ? \"color-mix(in srgb, var(--primary, #2563eb) 25%, transparent)\" : m.role === \"system\" ? \"color-mix(in srgb, #ef4444 20%, transparent)\" : S.pre.background }}>\n {m.text.replace(/```(agent-draft|mcp-result)[\\s\\S]*?```/g, \"\").trim()}\n {mcp && <div style={{ marginTop: 8, display: \"flex\", flexDirection: \"column\", gap: 6 }}>\n <span style={S.muted}>{mcp.remoteUrl ? `Hosted server: ${mcp.remoteUrl}` : `Starts with: ${[mcp.command, ...(mcp.args ?? [])].join(\" \")}`} \u00B7 {(mcp.tools ?? []).length} tools \u00B7 {mcp.tested ? \"tested by the assistant\" : \"NOT tested\"}</span>\n {targets.length === 0 ? <span style={S.muted}>Create a custom agent first, then come back to assign this tool.</span> : targets.map((a) => <div key={a.id}><Btn primary disabled={registering} onClick={async () => { setRegistering(true); try { say(\"ok\", await registerMcp(companyId, a, mcp)); refreshAll(); } catch (error) { say(\"error\", \"Could not register the tool: \" + String((error as Error).message)); } finally { setRegistering(false); } }}>Register and assign to {a.name}</Btn></div>)}\n </div>}\n {draft && <div style={{ marginTop: 8 }}><Btn primary onClick={() => useDraft(draft)}>Review and create this agent</Btn></div>}\n </div>;\n })}\n {builder.thread.busy && <span style={S.muted}>The assistant is working\u2026</span>}\n </div>\n <div style={S.row}><textarea aria-label=\"Message to the assistant\" rows={2} style={{ ...input, flex: 1, width: \"auto\" }} value={text} onChange={(e) => setText(e.target.value)} /><Btn primary onClick={go} disabled={sending || builder.thread.busy || !text.trim()}>Send</Btn></div>\n </div>;\n}\n\nfunction SettingsTab({ companyId, catalog, builder, refresh, say }: { companyId: string; catalog: Catalog; builder: Builder; refresh: () => void; say: (k: \"ok\" | \"error\", t: string) => void }) {\n const save = usePluginAction(\"save-settings\");\n const [agentId, setAgentId] = useState(builder.settings.assistantAgentId ?? \"\");\n return <div style={S.card}>\n <strong>Assistant engine</strong>\n <span style={S.muted}>The assistant has no engine of its own: it borrows the engine (Claude Code, Pi, Codex\u2026) and login of one of your agents. Because that engine runs on your server, it is also what installs and tests tools (MCP servers) there.</span>\n <div style={S.row}>\n <select aria-label=\"Assistant engine\" style={S.select} value={agentId} onChange={(e) => setAgentId(e.target.value)}><option value=\"\">\u2014 choose an agent \u2014</option>{catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name} ({a.adapterType})</option>)}</select>\n <Btn primary onClick={async () => { try { await save({ companyId, assistantAgentId: agentId }); say(\"ok\", \"Settings saved.\"); refresh(); } catch (error) { say(\"error\", String((error as Error).message)); } }}>Save</Btn>\n </div>\n <span style={S.muted}>Tip: use an agent dedicated to this, so its other work is not mixed with the assistant's conversations.</span>\n </div>;\n}\n"],
5
- "mappings": ";AAAA,SAAS,WAAW,gBAAoD;AACxE,SAAS,gBAAgB,iBAAiB,mBAAmB,iBAAiB,qBAAqB;AA0D1F,SAsBiB,UAtBjB,KAqBL,YArBK;AA/CT,eAAe,IAAa,QAAgB,MAAc,MAA4B;AACpF,QAAM,WAAW,MAAM,MAAM,MAAM,EAAE,QAAQ,aAAa,WAAW,SAAS,SAAS,SAAY,SAAY,EAAE,gBAAgB,mBAAmB,GAAG,MAAM,SAAS,SAAY,SAAY,KAAK,UAAU,IAAI,EAAE,CAAC;AACpN,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,UAAe;AACnB,MAAI;AAAE,cAAU,OAAO,KAAK,MAAM,IAAI,IAAI;AAAA,EAAM,QAAQ;AAAE,cAAU;AAAA,EA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AAE,WAAW,kBAAkB,QAAQ,CAAC;AAAG,cAAI,MAAM,iBAAiB;AAAG,kBAAQ;AAAA,QAAG,SAAS,OAAO;AAAE,cAAI,SAAS,OAAQ,MAAgB,OAAO,CAAC;AAAA,QAAG;AAAA,MAAE,GAAG,kBAAI;AAAA,OACtN;AAAA,IACA,oBAAC,UAAK,OAAO,EAAE,OAAO,qHAAuG;AAAA,KAC/H;AACF;",
4
+ "sourcesContent": ["import { useEffect, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { useHostContext, useHostLocation, useHostNavigation, usePluginAction, usePluginData } from \"@paperclipai/plugin-sdk/ui\";\n\n// ---------- types ----------\ntype Role = { skills: string[]; key: string; title: string; path: string; reportsTo: string | null; nativeRole: string; fileCount: number; playbooks: number; agentId: string | null };\ntype FlowStep = { id: string; title: string; role: string; via: string | null; mode: string; reviewBy: string | null; optional: boolean };\ntype Flow = { key: string; title: string; ownerRole: string; useWhen: string; ownerAgentId: string | null; steps: FlowStep[] };\ntype AgentRow = { custom: boolean; mcp: { url: string; status: string }[]; urlKey: string | null; id: string; name: string; title: string | null; role: string; adapterType: string };\ntype Catalog = { roles: Role[]; flows: Flow[]; agents: AgentRow[] };\ntype Run = { parentId: string; identifier: string | null; title: string; flowKey: string; finished: boolean; register: string };\n\n// ---------- native API (the signed-in user's own session) ----------\nasync function api<T = any>(method: string, path: string, body?: unknown): Promise<T> {\n const response = await fetch(path, { method, credentials: \"include\", headers: body === undefined ? undefined : { \"content-type\": \"application/json\" }, body: body === undefined ? undefined : JSON.stringify(body) });\n const text = await response.text();\n let payload: any = null;\n try { payload = text ? JSON.parse(text) : null; } catch { payload = text; }\n if (!response.ok) throw new Error(`${response.status}: ${typeof payload === \"string\" ? payload : payload?.error ?? JSON.stringify(payload)}`);\n return payload as T;\n}\nconst INSTRUCTION_KEYS = [\"instructionsBundleMode\", \"instructionsRootPath\", \"instructionsEntryFile\", \"instructionsFilePath\", \"agentsMdPath\", \"promptTemplate\"];\nconst PLAYBOOK_SECTION = \"\\n\\n## Playbooks\\nWhen a task carries a playbook, or matches one in PLAYBOOKS/, follow the `run-playbook` skill: keep the run register in the task document `playbook`, one step IN_PROGRESS at a time, evidence on every PASS. On a blocker, mark the step BLOCKED, say what is needed and from whom, and stop.\\n\";\n\n/** Paperclip requires the base of an edit: the file hash (null for a new file), or the revision id for the entry file. */\nasync function writeFile(agentId: string, path: string, content: string) {\n const url = `/api/agents/${agentId}/instructions-bundle/file`;\n const current = await api<any>(\"GET\", `${url}?path=${encodeURIComponent(path)}`).catch(() => null);\n if (current && current.content === content) return;\n const base = !current ? (path === \"AGENTS.md\" ? { baseRevisionId: null, baseHash: null } : { baseHash: null })\n : current.isEntryFile ? { baseRevisionId: current.revision?.id ?? null } : { baseHash: current.contentHash ?? null };\n await api(\"PUT\", url, { path, content, ...base });\n}\nasync function writeFiles(agentId: string, files: Record<string, string>) {\n for (const [path, content] of Object.entries(files)) await writeFile(agentId, path, content);\n}\nasync function assignSkills(agentId: string, skills: { keys: string[]; failed: string[] }): Promise<string | null> {\n const problems = skills.failed.length ? [`skills not available: ${skills.failed.join(\", \")}`] : [];\n if (skills.keys.length) {\n try { await api(\"POST\", `/api/agents/${agentId}/skills/sync`, { mode: \"add\", desiredSkills: skills.keys }); }\n catch (error) { problems.push(\"skills not assigned (\" + String((error as Error).message).slice(0, 80) + \"): assign them manually\"); }\n }\n return problems.length ? problems.join(\"; \") : null;\n}\nconst ORG_FILES = [\"COMPANY.md\", \"BUSINESS.md\"];\nconst readFile = (agentId: string, path: string) => api<any>(\"GET\", `/api/agents/${agentId}/instructions-bundle/file?path=${encodeURIComponent(path)}`).then((f) => String(f?.content ?? \"\")).catch(() => \"\");\n\n// ---------- styles ----------\nconst S: Record<string, CSSProperties> = {\n page: { padding: 24, maxWidth: 1100, display: \"flex\", flexDirection: \"column\", gap: 16, fontSize: 14 },\n tabs: { display: \"flex\", gap: 4, borderBottom: \"1px solid var(--border, #333)\" },\n card: { border: \"1px solid var(--border, #333)\", borderRadius: 8, padding: 14, display: \"flex\", flexDirection: \"column\", gap: 8 },\n row: { display: \"flex\", alignItems: \"center\", gap: 8, flexWrap: \"wrap\" },\n muted: { color: \"var(--muted-foreground, #999)\", fontSize: 13 },\n th: { textAlign: \"left\", padding: \"6px 8px\", borderBottom: \"1px solid var(--border, #333)\", fontWeight: 600, fontSize: 12 },\n td: { padding: \"6px 8px\", borderBottom: \"1px solid color-mix(in srgb, var(--border, #333) 50%, transparent)\", verticalAlign: \"middle\" },\n select: { padding: \"5px 8px\", borderRadius: 6, border: \"1px solid var(--border, #333)\", background: \"var(--background, transparent)\", color: \"inherit\", maxWidth: 340 },\n pre: { margin: 0, padding: 10, borderRadius: 6, background: \"color-mix(in srgb, var(--foreground, #fff) 6%, transparent)\", whiteSpace: \"pre-wrap\", fontSize: 12.5, fontFamily: \"ui-monospace, monospace\" },\n};\nfunction Btn({ children, onClick, disabled, primary }: { children: ReactNode; onClick: () => void; disabled?: boolean; primary?: boolean }) {\n return <button type=\"button\" onClick={onClick} disabled={disabled} style={{ padding: \"5px 10px\", borderRadius: 6, cursor: disabled ? \"default\" : \"pointer\", opacity: disabled ? 0.5 : 1, fontSize: 13, border: \"1px solid var(--border, #333)\", background: primary ? \"var(--primary, #2563eb)\" : \"transparent\", color: primary ? \"var(--primary-foreground, #fff)\" : \"inherit\" }}>{children}</button>;\n}\nfunction Tab({ id, current, set, children }: { id: string; current: string; set: (id: string) => void; children: ReactNode }) {\n const active = id === current;\n return <button type=\"button\" role=\"tab\" aria-selected={active} onClick={() => set(id)} style={{ padding: \"8px 14px\", border: \"none\", background: \"transparent\", color: \"inherit\", cursor: \"pointer\", fontSize: 14, fontWeight: active ? 600 : 400, borderBottom: active ? \"2px solid var(--primary, #2563eb)\" : \"2px solid transparent\" }}>{children}</button>;\n}\nconst Badge = ({ ok, children }: { ok: boolean; children: ReactNode }) => <span style={{ fontSize: 12, padding: \"2px 8px\", borderRadius: 999, background: ok ? \"color-mix(in srgb, #22c55e 22%, transparent)\" : \"color-mix(in srgb, #f59e0b 22%, transparent)\" }}>{children}</span>;\n\n// ---------- plain-language guide ----------\nconst GUIDE: { title: string; text: string }[] = [\n { title: \"1. You give a job to one agent\", text: \"Create a task as usual and assign it to the agent in charge of that area, for example the CTO for software work.\" },\n { title: \"2. A workflow splits the job between agents\", text: \"A workflow is a recipe: who does what, in which order. When you start it on the task, the steps become small tasks, each given to the right agent.\" },\n { title: \"3. One agent works, another one checks\", text: \"When an agent finishes, a colleague checks the result. If something is wrong the work goes back with a list of what to fix. This can happen at most 3 times.\" },\n { title: \"4. Problems go up one level at a time\", text: \"If it is still not right after 3 tries, the head of the area steps in. If they cannot solve it, the CEO tries. Only then are you asked to decide.\" },\n { title: \"5. You follow everything in Progress\", text: \"The Progress tab shows each step: waiting, in progress, done (with the proof) or blocked. You do not need to open the single tasks.\" },\n];\nfunction Guide({ id, children }: { id: string; children?: ReactNode }) {\n const key = \"agents-workflows-guide-\" + id;\n const [open, setOpen] = useState(() => { try { return localStorage.getItem(key) !== \"closed\"; } catch { return true; } });\n const toggle = () => { const next = !open; setOpen(next); try { localStorage.setItem(key, next ? \"open\" : \"closed\"); } catch { /* storage not available */ } };\n return <div style={{ ...S.card, background: \"color-mix(in srgb, var(--primary, #2563eb) 8%, transparent)\" }}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><strong>How does this work?</strong><Btn onClick={toggle}>{open ? \"Hide guide\" : \"Show guide\"}</Btn></div>\n {open && (children ?? <>\n <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fit, minmax(190px, 1fr))\", gap: 10 }}>\n {GUIDE.map((g) => <div key={g.title} style={{ ...S.card, gap: 4, background: \"var(--background, transparent)\" }}><strong style={{ fontSize: 13 }}>{g.title}</strong><span style={S.muted}>{g.text}</span></div>)}\n </div>\n <div style={S.muted}>{\"Two words to know. A procedure is a checklist for one agent working alone. A workflow is the same idea for several agents working one after another. To try it: pick a workflow below, choose a task and press \u201CStart workflow\u201D.\"}</div>\n </>)}\n </div>;\n}\nfunction StepDiagram({ flow, roleTitle }: { flow: Flow; roleTitle: (key: string) => string }) {\n return <div style={{ display: \"flex\", flexWrap: \"wrap\", alignItems: \"stretch\", gap: 6 }}>{flow.steps.map((step, i) => <div key={step.id} style={{ display: \"flex\", alignItems: \"center\", gap: 6 }}>\n <div style={{ border: \"1px solid var(--border, #333)\", borderRadius: 8, padding: \"6px 10px\", maxWidth: 210, opacity: step.optional ? 0.7 : 1 }}>\n <div style={{ fontSize: 12, fontWeight: 600 }}>{`${roleTitle(step.role)}${step.via ? \" (through the CEO)\" : \"\"}`}</div>\n <div style={{ fontSize: 12.5 }}>{step.title}</div>\n {step.reviewBy && <div style={{ fontSize: 12, marginTop: 4, color: \"var(--muted-foreground, #999)\" }}>{`checked by ${roleTitle(step.reviewBy)}`}</div>}\n {step.optional && <div style={{ fontSize: 12, color: \"var(--muted-foreground, #999)\" }}>only if needed</div>}\n </div>\n {i < flow.steps.length - 1 && <span aria-hidden=\"true\">\u2192</span>}\n </div>)}</div>;\n}\n\n// ---------- sidebar ----------\nexport function PlaybookSidebar() {\n const nav = useHostNavigation();\n const { companyPrefix } = useHostContext();\n const { pathname } = useHostLocation();\n const href = (companyPrefix ? \"/\" + companyPrefix : \"\") + \"/agents-workflows\";\n const active = pathname.replace(/\\/+$/, \"\") === href;\n return <a {...nav.linkProps(href)} data-plugin-sidebar-link=\"agents-workflows\" aria-current={active ? \"page\" : undefined} style={{ display: \"flex\", alignItems: \"center\", gap: 10, margin: \"0 8px\", borderRadius: 8, padding: \"6px 8px\", textDecoration: \"none\", fontSize: \"var(--text-compact, 13px)\", fontWeight: 500, color: active ? \"var(--sidebar-accent-foreground, #f5f5f5)\" : \"color-mix(in srgb, var(--foreground, #f5f5f5) 80%, transparent)\", background: active ? \"var(--sidebar-accent, rgba(255,255,255,.08))\" : \"transparent\" }}>\n <span data-plugin-sidebar-icon=\"true\" aria-hidden=\"true\" style={{ display: \"inline-flex\", width: 16, height: 16, justifyContent: \"center\" }}>\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M4 19.5A2.5 2.5 0 0 1 6.5 17H20V3H6.5A2.5 2.5 0 0 0 4 5.5z\" /><path d=\"M4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5\" /><path d=\"M9 8l2 2 4-4\" /></svg>\n </span>\n <span data-plugin-sidebar-label=\"true\">Agents & Workflows</span>\n </a>;\n}\n\n// ---------- page ----------\nexport function PlaybookPage() {\n const { companyId, companyPrefix } = useHostContext();\n const [tab, setTab] = useState(\"mine\");\n const catalog = usePluginData<Catalog>(\"catalog\", { companyId: companyId ?? \"\" });\n const builder = usePluginData<Builder>(\"builder\", { companyId: companyId ?? \"\" });\n const [message, setMessage] = useState<{ kind: \"ok\" | \"error\"; text: string } | null>(null);\n const [draft, setDraft] = useState<Draft | null>(null);\n const [pending, setPending] = useState(\"\");\n const say = (kind: \"ok\" | \"error\", text: string) => setMessage({ kind, text });\n const refreshAll = () => { catalog.refresh(); builder.refresh(); };\n if (!companyId) return <div style={S.page}>Select a company.</div>;\n const ready = catalog.data && builder.data;\n return <div style={S.page}>\n <div>\n <h1 style={{ fontSize: 22, fontWeight: 600, margin: 0 }}>Agents & Workflows</h1>\n <div style={S.muted}>Create your own agents, give them skills, tools and procedures, and run workflows between them.</div>\n </div>\n <div role=\"tablist\" style={S.tabs}>\n <Tab id=\"mine\" current={tab} set={setTab}>My agents</Tab>\n <Tab id=\"assistant\" current={tab} set={setTab}>Assistant</Tab>\n <Tab id=\"agents\" current={tab} set={setTab}>Role library</Tab>\n <Tab id=\"flows\" current={tab} set={setTab}>Workflows</Tab>\n <Tab id=\"runs\" current={tab} set={setTab}>Progress</Tab>\n <Tab id=\"settings\" current={tab} set={setTab}>Settings</Tab>\n </div>\n {message && <div role=\"status\" style={{ ...S.card, borderColor: message.kind === \"ok\" ? \"#22c55e\" : \"#ef4444\" }}>{message.text}</div>}\n {catalog.error && <div role=\"alert\" style={S.card}>{`Error: ${catalog.error.message}`}</div>}\n {!ready ? <div style={S.muted}>Loading\u2026</div>\n : tab === \"mine\" ? <MyAgentsTab companyId={companyId} catalog={catalog.data!} builder={builder.data!} refresh={refreshAll} say={say} draft={draft} setDraft={setDraft} askAssistant={(text) => { setPending(text); setTab(\"assistant\"); }} />\n : tab === \"assistant\" ? <AssistantTab companyId={companyId} catalog={catalog.data!} refreshAll={refreshAll} builder={builder.data!} refresh={builder.refresh} say={say} pending={pending} clearPending={() => setPending(\"\")} goSettings={() => setTab(\"settings\")} useDraft={(d) => { setDraft({ ...emptyDraft(), ...d, skills: d.skills ?? [], links: d.links ?? [], procedures: d.procedures ?? [] }); setTab(\"mine\"); }} />\n : tab === \"agents\" ? <AgentsTab companyId={companyId} catalog={catalog.data!} refresh={catalog.refresh} say={say} />\n : tab === \"flows\" ? <FlowsTab companyId={companyId} catalog={catalog.data!} say={say} goRuns={() => setTab(\"runs\")} />\n : tab === \"settings\" ? <SettingsTab companyId={companyId} catalog={catalog.data!} builder={builder.data!} refresh={builder.refresh} say={say} />\n : <RunsTab companyId={companyId} prefix={companyPrefix} />}\n </div>;\n}\n\nfunction AgentsTab({ companyId, catalog, refresh, say }: { companyId: string; catalog: Catalog; refresh: () => void; say: (k: \"ok\" | \"error\", t: string) => void }) {\n const [templateId, setTemplateId] = useState(\"\");\n const [busy, setBusy] = useState<string | null>(null);\n const [target, setTarget] = useState(\"\");\n const [targetRole, setTargetRole] = useState(\"\");\n const [filter, setFilter] = useState(\"\");\n const nav = useHostNavigation();\n const { companyPrefix } = useHostContext();\n const prefix = companyPrefix ? \"/\" + companyPrefix : \"\";\n const agentName = (id: string | null) => catalog.agents.find((a) => a.id === id)?.name ?? null;\n const roleFiles = usePluginAction(\"role-files\");\n const roleSkills = usePluginAction(\"role-skills\");\n const skillsFor = async (key: string) => (await roleSkills({ companyId, key })) as { keys: string[]; failed: string[] };\n const getFiles = async (key: string): Promise<Record<string, string>> => {\n const response = (await roleFiles({ key })) as { files: Record<string, string> | null };\n if (!response?.files) throw new Error(\"role files not available\");\n return response.files;\n };\n const run = async (id: string, job: () => Promise<string>) => {\n setBusy(id);\n try { say(\"ok\", await job()); refresh(); }\n catch (error) { say(\"error\", String((error as Error).message ?? error)); }\n finally { setBusy(null); }\n };\n\n const create = (role: Role) => run(role.key, async () => {\n if (!templateId) throw new Error(\"First choose which agent to copy the technical setup from.\");\n const template = await api<any>(\"GET\", `/api/agents/${templateId}`);\n const adapterConfig = { ...(template.adapterConfig ?? {}) };\n for (const key of INSTRUCTION_KEYS) delete adapterConfig[key];\n const files = await getFiles(role.key);\n // The company and business descriptions come from the agent you copy from, when it has them.\n let inherited = 0;\n for (const name of ORG_FILES) { const text = await readFile(templateId, name); if (text.trim()) { files[name] = text; inherited++; } }\n const manager = catalog.roles.find((r) => r.key === role.reportsTo)?.agentId ?? null;\n const created = await api<any>(\"POST\", `/api/companies/${companyId}/agents`, {\n name: role.title, title: role.title, role: role.nativeRole, reportsTo: manager,\n adapterType: template.adapterType, adapterConfig, runtimeConfig: template.runtimeConfig ?? {},\n runner: template.adapterType === \"paperclip_runner\" ? \"paperclip\" : \"legacy\", // keep the same kind of engine as the template\n instructionsBundle: { entryFile: \"AGENTS.md\", files }, metadata: { agentStaticRole: role.key },\n });\n const agent = created.agent ?? created;\n if (agent?.id) {\n const bundle = await api(\"GET\", `/api/agents/${agent.id}/instructions-bundle`).catch(() => null);\n if (!bundle) return `Created \"${role.title}\", but the \"${template.adapterType}\" engine does not support instruction files: instructions and procedures were NOT loaded. Use a Claude Code, Pi, Codex or similar agent as the model.`;\n }\n const warn = agent?.id ? await assignSkills(agent.id, await skillsFor(role.key)) : \"agent awaiting approval\";\n return `Created \"${role.title}\" with ${Object.keys(files).length} files and ${role.skills.length} skills${inherited ? \"\" : \" (company and business files are blank templates: fill them in)\"}${manager ? \"\" : role.reportsTo ? \" (manager not present yet: set it later)\" : \"\"}${warn ? \" \u2014 \" + warn : \"\"}.`;\n });\n\n const update = (role: Role) => run(role.key, async () => {\n const files = await getFiles(role.key);\n for (const name of ORG_FILES) if ((await readFile(role.agentId!, name)).trim()) delete files[name]; // keep the company's own text\n await writeFiles(role.agentId!, files);\n const warn = await assignSkills(role.agentId!, await skillsFor(role.key));\n return `Instructions of \"${role.title}\" updated (${Object.keys(files).length} files)${warn ? \" \u2014 \" + warn : \"\"}.`;\n });\n\n const addPlaybooks = () => run(\"native\", async () => {\n if (!target || !targetRole) throw new Error(\"Choose the agent and the role to take the procedures from.\");\n const all = await getFiles(targetRole);\n const playbooks = Object.fromEntries(Object.entries(all).filter(([path]) => path.startsWith(\"PLAYBOOKS/\")));\n await writeFiles(target, playbooks);\n const entry = await api<any>(\"GET\", `/api/agents/${target}/instructions-bundle/file?path=AGENTS.md`).catch(() => null);\n const current = String(entry?.content ?? \"\");\n if (!current.includes(\"run-playbook\")) await writeFile(target, \"AGENTS.md\", (current || \"# Agent instructions\") + PLAYBOOK_SECTION);\n const role = catalog.roles.find((r) => r.key === targetRole)!;\n const existing = await api<any>(\"GET\", `/api/agents/${target}`);\n await api(\"PATCH\", `/api/agents/${target}`, { metadata: { ...(existing.metadata ?? {}), agentStaticRole: role.key } }).catch(() => null);\n const warn = await assignSkills(target, { keys: (await skillsFor(\"__none__\")).keys, failed: [] });\n return `Added ${Object.keys(playbooks).length} procedure files to \"${agentName(target)}\" and linked it to the role ${role.title}${warn ? \" \u2014 \" + warn : \"\"}. Its other instructions were not touched.`;\n });\n\n const shown = catalog.roles.filter((r) => !filter || (r.title + \" \" + r.path).toLowerCase().includes(filter.toLowerCase()));\n const present = catalog.roles.filter((r) => r.agentId).length;\n return <>\n <div style={S.card}>\n <strong>1. Technical setup for new agents</strong>\n <div style={S.muted}>A new agent needs an engine (Claude Code, Pi, \u2026) and its credentials. They are copied from an agent that already works.</div>\n <div style={S.row}>\n <label htmlFor=\"pb-template\">Copy from</label>\n <select id=\"pb-template\" style={S.select} value={templateId} onChange={(e) => setTemplateId(e.target.value)}>\n <option value=\"\">\u2014 choose an existing agent \u2014</option>\n {catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name} ({a.adapterType})</option>)}\n </select>\n {catalog.agents.length === 0 && <span style={S.muted}>There is no agent yet: create one from Paperclip's Agents menu, then come back.</span>}\n </div>\n </div>\n\n <div style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <strong>{`2. Roles in the pack (${present} of ${catalog.roles.length} present)`}</strong>\n <input aria-label=\"Filter roles\" placeholder=\"Filter\u2026\" value={filter} onChange={(e) => setFilter(e.target.value)} style={S.select} />\n </div>\n <table style={{ borderCollapse: \"collapse\", width: \"100%\" }}>\n <thead><tr><th style={S.th}>Role</th><th style={S.th}>Reports to</th><th style={S.th}>Procedures</th><th style={S.th}>Skills</th><th style={S.th}>In Paperclip</th><th style={S.th} /></tr></thead>\n <tbody>{shown.map((role) => <tr key={role.key}>\n <td style={S.td}><div>{role.title}</div><div style={S.muted}>{role.path}</div></td>\n <td style={S.td}>{catalog.roles.find((r) => r.key === role.reportsTo)?.title ?? \"Owner\"}</td>\n <td style={S.td}>{role.playbooks}</td><td style={S.td}>{role.skills.length}</td>\n <td style={S.td}>{role.agentId ? <><Badge ok>{agentName(role.agentId)}</Badge> <a {...nav.linkProps(`${prefix}/agents/${catalog.agents.find((a) => a.id === role.agentId)?.urlKey ?? role.agentId}/instructions`)} style={{ fontSize: 12, marginLeft: 6 }}>Open instructions</a></> : <Badge ok={false}>not present</Badge>}</td>\n <td style={{ ...S.td, textAlign: \"right\" }}>{role.agentId\n ? <Btn onClick={() => update(role)} disabled={busy !== null}>{busy === role.key ? \"\u2026\" : \"Update instructions\"}</Btn>\n : <Btn primary onClick={() => create(role)} disabled={busy !== null}>{busy === role.key ? \"\u2026\" : \"Create agent\"}</Btn>}</td>\n </tr>)}</tbody>\n </table>\n </div>\n\n <div style={S.card}>\n <strong>3. Add procedures to an agent you already have</strong>\n <div style={S.muted}>For native Paperclip agents: adds only the PLAYBOOKS folder, one paragraph at the end of AGENTS.md and the skill. The rest of the instructions is left as it is.</div>\n <div style={S.row}>\n <select aria-label=\"Existing agent\" style={S.select} value={target} onChange={(e) => setTarget(e.target.value)}>\n <option value=\"\">\u2014 agent \u2014</option>\n {catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name}</option>)}\n </select>\n <span>gets the procedures of</span>\n <select aria-label=\"Pack role\" style={S.select} value={targetRole} onChange={(e) => setTargetRole(e.target.value)}>\n <option value=\"\">\u2014 role \u2014</option>\n {catalog.roles.map((r) => <option key={r.key} value={r.key}>{r.title}</option>)}\n </select>\n <Btn primary onClick={addPlaybooks} disabled={busy !== null}>{busy === \"native\" ? \"\u2026\" : \"Add procedures\"}</Btn>\n </div>\n </div>\n </>;\n}\n\nfunction FlowsTab({ companyId, catalog, say, goRuns }: { companyId: string; catalog: Catalog; say: (k: \"ok\" | \"error\", t: string) => void; goRuns: () => void }) {\n const start = usePluginAction(\"start-flow\");\n const [issues, setIssues] = useState<{ id: string; identifier: string | null; title: string }[]>([]);\n const [chosen, setChosen] = useState<Record<string, string>>({});\n const [busy, setBusy] = useState<string | null>(null);\n useEffect(() => {\n api<any>(\"GET\", `/api/companies/${companyId}/issues?limit=100`).then((list) => {\n const rows = (Array.isArray(list) ? list : list.issues ?? []).filter((i: any) => ![\"done\", \"cancelled\"].includes(i.status) && !i.parentId);\n setIssues(rows.map((i: any) => ({ id: i.id, identifier: i.identifier ?? null, title: i.title })));\n }).catch(() => setIssues([]));\n }, [companyId]);\n const roleTitle = (key: string) => catalog.roles.find((r) => r.key === key)?.title ?? key;\n const go = async (flow: Flow) => {\n setBusy(flow.key);\n try {\n const outcome = (await start({ companyId, parentIssueId: chosen[flow.key], flowKey: flow.key })) as { content?: string };\n say(\"ok\", `Workflow \"${flow.key}\" started. ${String(outcome?.content ?? \"\").split(\"\\n\").slice(1).join(\" \")}`);\n goRuns();\n } catch (error) { say(\"error\", String((error as Error).message ?? error)); }\n finally { setBusy(null); }\n };\n return <><Guide id=\"workflows\" />{catalog.flows.map((flow) => <div key={flow.key} style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <strong>{flow.title}</strong>\n {flow.ownerAgentId ? <Badge ok>{`owner: ${roleTitle(flow.ownerRole)}`}</Badge> : <Badge ok={false}>{`missing agent: ${roleTitle(flow.ownerRole)}`}</Badge>}\n </div>\n <div style={S.muted}>{flow.useWhen}</div>\n <StepDiagram flow={flow} roleTitle={roleTitle} />\n <div style={S.row}>\n <select aria-label={`Task for ${flow.key}`} style={S.select} value={chosen[flow.key] ?? \"\"} onChange={(e) => setChosen({ ...chosen, [flow.key]: e.target.value })}>\n <option value=\"\">\u2014 choose the task to start it on \u2014</option>\n {issues.map((i) => <option key={i.id} value={i.id}>{i.identifier ? i.identifier + \" \u00B7 \" : \"\"}{i.title}</option>)}\n </select>\n <Btn primary onClick={() => go(flow)} disabled={!chosen[flow.key] || !flow.ownerAgentId || busy !== null}>{busy === flow.key ? \"\u2026\" : \"Start workflow\"}</Btn>\n </div>\n </div>)}</>;\n}\n\nconst STATE_LABEL: Record<string, string> = { PENDING: \"Waiting\", IN_PROGRESS: \"In progress\", PASS: \"Done\", BLOCKED: \"Blocked\", SKIPPED: \"Skipped\" };\nfunction RunsTab({ companyId, prefix }: { companyId: string; prefix: string | null }) {\n const runs = usePluginData<{ runs: Run[] }>(\"runs\", { companyId });\n const nav = useHostNavigation();\n if (!runs.data) return <div style={S.muted}>Loading\u2026</div>;\n if (runs.data.runs.length === 0) return <div style={S.card}>No workflow started yet. Go to \"Workflows\" and start one on a task.</div>;\n return <>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><span style={S.muted}>Each step shows its state, who does it and, once done, the proof.</span><Btn onClick={runs.refresh}>Refresh</Btn></div>\n {runs.data.runs.map((run) => <div key={run.parentId} style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <a {...nav.linkProps(`${prefix ? \"/\" + prefix : \"\"}/issues/${run.identifier ?? run.parentId}`)}><strong>{run.identifier ? run.identifier + \" \u00B7 \" : \"\"}{run.title}</strong></a>\n <Badge ok={run.finished}>{run.finished ? \"completed\" : run.register.includes(\"[BLOCKED]\") ? \"blocked\" : \"in progress\"}</Badge>\n </div>\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6 }}>{(run.register.split(\"## Steps\")[1]?.split(\"\\n_Maintained\")[0] ?? \"\").split(\"\\n\").map((line) => line.match(/^(\\d+)\\. \\[(\\w+)\\] (.+?) \\(([^()]*)\\)(.*)$/)).filter(Boolean).map((m) => {\n const state = STATE_LABEL[m![2]] ?? m![2];\n return <div key={m![1]} style={{ ...S.row, alignItems: \"baseline\" }}>\n <span style={{ ...S.muted, minWidth: 18 }}>{m![1]}.</span>\n <Badge ok={m![2] === \"PASS\"}>{state}</Badge>\n <span>{m![3]}</span>\n <span style={S.muted}>{m![4]}</span>\n {m![5].trim() && <span style={{ ...S.muted, wordBreak: \"break-word\" }}>{m![5].replace(/^ \u2014 /, \"\").trim()}</span>}\n </div>;\n })}</div>\n </div>)}\n </>;\n}\n\n// ====================== Agent builder: my agents, wizard, assistant, settings ======================\ntype LinkItem = { kind: \"skill\" | \"mcp\" | \"playbook\"; url: string };\ntype Procedure = { title: string; useWhen: string; steps: string[] };\ntype Draft = { name: string; description: string; reportsTo: string; baseRole: string; templateId: string; skills: string[]; links: LinkItem[]; procedures: Procedure[] };\ntype Thread = { busy: boolean; messages: { role: \"user\" | \"assistant\" | \"system\"; text: string; at: string }[] };\ntype Builder = { settings: { assistantAgentId?: string }; librarySkills: { slug: string; title: string; description: string }[]; thread: Thread };\nconst emptyDraft = (): Draft => ({ name: \"\", description: \"\", reportsTo: \"\", baseRole: \"\", templateId: \"\", skills: [], links: [], procedures: [] });\nconst slugify = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-|-$/g, \"\").slice(0, 50) || \"procedure\";\nfunction guessKind(url: string): LinkItem[\"kind\"] {\n const u = url.toLowerCase();\n if (/skill\\.md|\\/skills?\\//.test(u)) return \"skill\";\n if (/playbook|workflow|\\.ya?ml($|\\?)/.test(u)) return \"playbook\";\n return \"mcp\";\n}\nfunction parseBlock<T>(text: string, tag: string): T | null {\n const match = text.match(new RegExp(\"```\" + tag + \"\\\\s*([\\\\s\\\\S]*?)```\"));\n if (!match) return null;\n try { return JSON.parse(match[1]) as T; } catch { return null; }\n}\ntype McpResult = { url?: string; name?: string; remoteUrl?: string | null; command?: string; args?: string[]; envKeys?: string[]; tools?: { name: string; description?: string; inputSchema?: unknown }[]; tested?: boolean; notes?: string };\n/** Register an MCP server in Paperclip's own Tools and give it to one agent: template -> connection -> health check -> profile -> binding. */\nasync function registerMcp(companyId: string, agent: AgentRow, r: McpResult): Promise<string> {\n const key = slugify(`${r.name || \"mcp\"}-${agent.name}`).slice(0, 60) + \"-\" + Date.now().toString(36);\n const name = `${r.name || \"MCP server\"} (${agent.name})`.slice(0, 150);\n let body: Record<string, unknown>;\n if (r.remoteUrl) body = { name, transport: \"mcp_remote\", config: { url: r.remoteUrl }, transportConfig: { url: r.remoteUrl } };\n else {\n if (!r.command) throw new Error(\"The assistant did not say how to start this server.\");\n await api(\"POST\", `/api/companies/${companyId}/tools/stdio-templates`, { templateId: key, name, description: r.notes?.slice(0, 3000) ?? null, command: r.command, args: r.args ?? [], envKeys: r.envKeys ?? [], tools: (r.tools ?? []).filter((x) => x?.name).map((x) => ({ name: x.name, description: x.description ?? null, ...(x.inputSchema && typeof x.inputSchema === \"object\" ? { inputSchema: x.inputSchema } : {}) })) });\n body = { name, transport: \"local_stdio\", config: { templateId: key }, transportConfig: { templateId: key } };\n }\n const connection = await api<any>(\"POST\", `/api/companies/${companyId}/tools/connections`, body);\n await api(\"PATCH\", `/api/tool-connections/${connection.id}`, { enabled: true, status: \"active\" });\n const health = await api<any>(\"POST\", `/api/tool-connections/${connection.id}/health-check`).catch((error) => ({ connection: { healthStatus: \"failed: \" + String(error.message).slice(0, 80) } }));\n await api(\"POST\", `/api/tool-connections/${connection.id}/catalog/refresh`).catch(() => null);\n const profile = await api<any>(\"POST\", `/api/companies/${companyId}/tools/profiles`, { profileKey: \"p-\" + key, name: `Tools: ${name}`.slice(0, 150), defaultAction: \"deny\", entries: [{ selectorType: \"connection\", effect: \"include\", connectionId: connection.id }] });\n await api(\"POST\", `/api/companies/${companyId}/tools/profiles/${profile.id}/bind`, { targetType: \"agent\", targetId: agent.id });\n const full = await api<any>(\"GET\", `/api/agents/${agent.id}`);\n const requested: { url: string; status: string }[] = Array.isArray(full.metadata?.requestedMcp) ? full.metadata.requestedMcp : [];\n const next = requested.some((m) => m.url === r.url) ? requested.map((m) => (m.url === r.url ? { ...m, status: \"installed\", connectionId: connection.id } : m)) : [...requested, { url: r.url ?? r.remoteUrl ?? name, status: \"installed\", connectionId: connection.id }];\n await api(\"PATCH\", `/api/agents/${agent.id}`, { metadata: { ...(full.metadata ?? {}), requestedMcp: next } });\n const secrets = (r.envKeys ?? []).length ? ` It needs ${r.envKeys!.length} secret value(s) (${r.envKeys!.join(\", \")}): add them in Connectors before the agent uses it.` : \"\";\n return `\"${r.name || \"MCP server\"}\" is registered in Paperclip and assigned to ${agent.name} (check: ${health?.connection?.healthStatus ?? \"unknown\"}, ${(r.tools ?? []).length} tools).${secrets}`;\n}\n\nconst input: CSSProperties = { ...S.select, maxWidth: \"100%\", width: \"100%\", boxSizing: \"border-box\" };\nconst Field = ({ label, hint, children }: { label: string; hint?: string; children: ReactNode }) => <label style={{ display: \"flex\", flexDirection: \"column\", gap: 4 }}>\n <span style={{ fontWeight: 600 }}>{label}</span>{hint && <span style={S.muted}>{hint}</span>}{children}\n</label>;\n\nfunction procedureFile(agentName: string, p: Procedure) {\n return [`# Playbook: ${p.title}`, \"\", `**Role:** ${agentName}`, `**Use when:** ${p.useWhen || \"the task matches this procedure.\"}`, \"\", \"Run this checklist with the `run-playbook` skill. This file is a read-only template; the run register lives in the task document `playbook`.\", \"\", \"## Steps\", ...p.steps.filter((s) => s.trim()).map((s, i) => `${i + 1}. ${s.trim()}`), \"\"].join(\"\\n\");\n}\nfunction entryFile(d: Draft, managerName: string | null) {\n return [`# ${d.name} \u2014 Paperclip entry instructions`, \"\", \"This is the entry file. Paperclip loads it automatically; sibling files are references to read when this file says so.\", \"\",\n \"## At every task start\", \"1. Work only on the task assigned to you. A chat does not create work unless the human explicitly asks.\", \"2. Read COMPANY.md and BUSINESS.md for the organization's context.\", \"3. If the task matches a procedure in PLAYBOOKS/, follow the `run-playbook` skill: keep the run register in the task document `playbook`, one step IN_PROGRESS at a time, evidence on every PASS.\", \"4. On a blocker, say what is needed and from whom, set the task to a waiting state, and stop.\", \"\",\n \"## Role\", d.description.trim(), \"\", `Reports to: ${managerName ?? \"the human Owner\"}.`, \"\",\n \"## Boundaries\", \"Do not spend money, publish, change permissions or act outside your assigned task without a recorded approval. Escalate to your manager when unsure.\", \"\"].join(\"\\n\");\n}\n\nfunction MyAgentsTab({ companyId, catalog, builder, refresh, say, draft, setDraft, askAssistant }: { companyId: string; catalog: Catalog; builder: Builder; refresh: () => void; say: (k: \"ok\" | \"error\", t: string) => void; draft: Draft | null; setDraft: (d: Draft | null) => void; askAssistant: (text: string) => void }) {\n const nav = useHostNavigation();\n const { companyPrefix } = useHostContext();\n const prefix = companyPrefix ? \"/\" + companyPrefix : \"\";\n const custom = catalog.agents.filter((a) => a.custom);\n if (draft) return <Wizard companyId={companyId} catalog={catalog} builder={builder} draft={draft} setDraft={setDraft} done={(text) => { setDraft(null); say(\"ok\", text); refresh(); }} fail={(text) => say(\"error\", text)} />;\n return <>\n <div style={{ ...S.card, flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", flexWrap: \"wrap\" }}>\n <div><strong>Create a custom agent</strong><div style={S.muted}>Describe what it should do, pick its skills and tools, and write the steps it must follow. You can also let the assistant interview you.</div></div>\n <div style={S.row}><Btn primary onClick={() => setDraft(emptyDraft())}>+ New agent</Btn><Btn onClick={() => askAssistant(\"\")}>Ask the assistant</Btn></div>\n </div>\n {custom.length === 0 ? <div style={S.card}><span style={S.muted}>You have not created any custom agent yet. Ready-made roles are under \"Role library\".</span></div>\n : custom.map((a) => <div key={a.id} style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <strong>{a.name}</strong>\n <a {...nav.linkProps(`${prefix}/agents/${a.urlKey ?? a.id}/instructions`)} style={{ fontSize: 13 }}>Open instructions</a>\n </div>\n {a.mcp.length > 0 && <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6 }}>\n <span style={S.muted}>Tools (MCP servers) requested for this agent</span>\n {a.mcp.map((m) => <div key={m.url} style={S.row}>\n <Badge ok={m.status === \"installed\"}>{m.status === \"installed\" ? \"installed\" : \"not installed yet\"}</Badge>\n <span style={{ wordBreak: \"break-all\" }}>{m.url}</span>\n {m.status !== \"installed\" && <Btn onClick={() => askAssistant(`Set up and test the MCP server at ${m.url} for the agent \"${a.name}\". Tell me first the exact command you will run and which secrets it needs, then do it and give me the mcp-result block.`)}>Install with the assistant</Btn>}\n </div>)}\n </div>}\n <ManualTool companyId={companyId} agent={a} say={say} refresh={refresh} />\n </div>)}\n </>;\n}\n\nfunction ManualTool({ companyId, agent, say, refresh }: { companyId: string; agent: AgentRow; say: (k: \"ok\" | \"error\", t: string) => void; refresh: () => void }) {\n const [name, setName] = useState(\"\");\n const [start, setStart] = useState(\"\");\n const [secrets, setSecrets] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const add = async () => {\n setBusy(true);\n try {\n const value = start.trim();\n const parts = value.split(/\\s+/);\n const result: McpResult = /^https:\\/\\//.test(value) ? { name, url: value, remoteUrl: value } : { name, url: value, command: parts[0], args: parts.slice(1) };\n result.envKeys = secrets.split(\",\").map((s) => s.trim()).filter(Boolean);\n say(\"ok\", await registerMcp(companyId, agent, result));\n setName(\"\"); setStart(\"\"); setSecrets(\"\"); refresh();\n } catch (error) { say(\"error\", \"Could not register the tool: \" + String((error as Error).message)); }\n finally { setBusy(false); }\n };\n return <details><summary style={{ cursor: \"pointer\", fontSize: 13 }}>Advanced: add a tool (MCP server) by hand</summary>\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6, marginTop: 8 }}>\n <input aria-label={`Tool name for ${agent.name}`} placeholder=\"Name, e.g. Filesystem\" style={input} value={name} onChange={(e) => setName(e.target.value)} />\n <input aria-label={`Start command or URL for ${agent.name}`} placeholder=\"Start command (npx -y package) or https:// address\" style={input} value={start} onChange={(e) => setStart(e.target.value)} />\n <input aria-label={`Secret names for ${agent.name}`} placeholder=\"Names of the secrets it needs, separated by commas (optional)\" style={input} value={secrets} onChange={(e) => setSecrets(e.target.value)} />\n <div><Btn primary onClick={add} disabled={busy || !name.trim() || !start.trim()}>{busy ? \"\u2026\" : \"Register and assign\"}</Btn></div>\n </div>\n </details>;\n}\n\nfunction Wizard({ companyId, catalog, builder, draft, setDraft, done, fail }: { companyId: string; catalog: Catalog; builder: Builder; draft: Draft; setDraft: (d: Draft | null) => void; done: (text: string) => void; fail: (text: string) => void }) {\n const [step, setStep] = useState(1);\n const [link, setLink] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const roleFiles = usePluginAction(\"role-files\");\n const skillKeys = usePluginAction(\"skill-keys\");\n const fetchText = usePluginAction(\"fetch-text\");\n const set = (patch: Partial<Draft>) => setDraft({ ...draft, ...patch });\n const steps = [\"What it does\", \"Skills and tools\", \"How it works\", \"Review\"];\n const problems = [!draft.name.trim() && \"Give the agent a name.\", !draft.description.trim() && !draft.baseRole && \"Describe what the agent should do.\", !draft.templateId && \"Choose which existing agent to copy the engine from.\"].filter(Boolean) as string[];\n const addLink = () => { const url = link.trim(); if (!/^https:\\/\\//.test(url)) return fail(\"Paste a full link starting with https://\"); set({ links: [...draft.links, { kind: guessKind(url), url }] }); setLink(\"\"); };\n const setProc = (i: number, patch: Partial<Procedure>) => set({ procedures: draft.procedures.map((p, n) => (n === i ? { ...p, ...patch } : p)) });\n\n const create = async () => {\n setBusy(true);\n try {\n const template = await api<any>(\"GET\", `/api/agents/${draft.templateId}`);\n const adapterConfig = { ...(template.adapterConfig ?? {}) };\n for (const key of INSTRUCTION_KEYS) delete adapterConfig[key];\n const base = draft.baseRole ? ((await roleFiles({ key: draft.baseRole })) as { files: Record<string, string> | null }).files ?? {} : {};\n const files: Record<string, string> = { ...base };\n const manager = catalog.agents.find((a) => a.id === draft.reportsTo) ?? null;\n if (!draft.baseRole) files[\"AGENTS.md\"] = entryFile(draft, manager?.name ?? null);\n else if (draft.description.trim()) files[\"AGENTS.md\"] = (files[\"AGENTS.md\"] ?? \"\") + `\\n\\n## Additional instructions\\n${draft.description.trim()}\\n`;\n for (const name of ORG_FILES) { const text = await readFile(draft.templateId, name); if (text.trim()) files[name] = text; }\n const offset = Object.keys(files).filter((f) => /^PLAYBOOKS\\/\\d\\d-/.test(f)).length + 1;\n draft.procedures.filter((p) => p.title.trim() && p.steps.some((s) => s.trim())).forEach((p, i) => { files[`PLAYBOOKS/${String(offset + i + 1).padStart(2, \"0\")}-${slugify(p.title)}.md`] = procedureFile(draft.name, p); });\n const notes: string[] = [];\n let imported = 0;\n for (const item of draft.links.filter((l) => l.kind === \"playbook\")) {\n try { const { text } = (await fetchText({ url: item.url })) as { text: string }; imported++; files[/^schema:\\s*agent-static\\.playbook-flow/m.test(text) ? `PLAYBOOKS/flows/imported-${imported}.yaml` : `PLAYBOOKS/imported-${imported}.md`] = text; }\n catch (error) { notes.push(`playbook link not imported (${String((error as Error).message).slice(0, 60)})`); }\n }\n const mcp = draft.links.filter((l) => l.kind === \"mcp\").map((l) => ({ url: l.url, status: \"requested\" }));\n if (mcp.length) files[\"TOOLS.md\"] = (files[\"TOOLS.md\"] ?? \"# Tools\\n\") + \"\\n\\n## Requested MCP servers\\nThese are requested for this agent and are usable only after they are installed and assigned in Paperclip:\\n\" + mcp.map((m) => `- ${m.url}`).join(\"\\n\") + \"\\n\";\n const created = await api<any>(\"POST\", `/api/companies/${companyId}/agents`, {\n name: draft.name.trim(), title: draft.name.trim(), role: catalog.roles.find((r) => r.key === draft.baseRole)?.nativeRole ?? \"general\", reportsTo: draft.reportsTo || null,\n adapterType: template.adapterType, adapterConfig, runtimeConfig: template.runtimeConfig ?? {}, runner: template.adapterType === \"paperclip_runner\" ? \"paperclip\" : \"legacy\",\n instructionsBundle: { entryFile: \"AGENTS.md\", files }, metadata: { agentBuilder: true, requestedMcp: mcp, ...(draft.baseRole ? { agentStaticRole: draft.baseRole } : {}) },\n });\n const agent = created.agent ?? created;\n if (!agent?.id) return done(`\"${draft.name}\" was submitted and is awaiting approval.`);\n if (!(await api(\"GET\", `/api/agents/${agent.id}/instructions-bundle`).catch(() => null))) notes.push(`the \"${template.adapterType}\" engine does not support instruction files, so instructions were NOT loaded`);\n const slugs = [...new Set([\"run-playbook\", ...draft.skills, ...(catalog.roles.find((r) => r.key === draft.baseRole)?.skills ?? [])])];\n const library = (await skillKeys({ companyId, slugs })) as { keys: string[]; failed: string[] };\n for (const item of draft.links.filter((l) => l.kind === \"skill\")) {\n try { const result = await api<any>(\"POST\", `/api/companies/${companyId}/skills/import`, { source: item.url }); const key = result?.imported?.[0]?.key ?? result?.skills?.[0]?.key ?? result?.[0]?.key ?? result?.key; if (key) library.keys.push(key); else notes.push(\"skill link imported but not assigned: assign it from the agent's Skills\"); }\n catch (error) { notes.push(`skill link not imported (${String((error as Error).message).slice(0, 60)})`); }\n }\n const warn = await assignSkills(agent.id, library);\n if (warn) notes.push(warn);\n if (mcp.length) notes.push(`${mcp.length} MCP server(s) are recorded as requested: use \"Install with the assistant\" on the agent's card`);\n done(`Created \"${draft.name}\" with ${Object.keys(files).length} files and ${library.keys.length} skills${notes.length ? \" \u2014 \" + notes.join(\"; \") : \"\"}.`);\n } catch (error) { fail(String((error as Error).message ?? error)); }\n finally { setBusy(false); }\n };\n\n return <div style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><strong>New agent</strong><Btn onClick={() => setDraft(null)}>Cancel</Btn></div>\n <ol style={{ display: \"flex\", gap: 6, listStyle: \"none\", padding: 0, margin: 0, flexWrap: \"wrap\" }}>{steps.map((label, i) => <li key={label}>\n <button type=\"button\" aria-current={step === i + 1 ? \"step\" : undefined} onClick={() => setStep(i + 1)} style={{ padding: \"4px 10px\", borderRadius: 999, border: \"1px solid var(--border, #333)\", cursor: \"pointer\", color: \"inherit\", background: step === i + 1 ? \"color-mix(in srgb, var(--primary, #2563eb) 30%, transparent)\" : \"transparent\", fontSize: 13 }}>{`${i + 1}. ${label}`}</button>\n </li>)}</ol>\n\n {step === 1 && <>\n <Field label=\"Name\" hint=\"How the agent will appear in Paperclip, e.g. \u201CInvoice Assistant\u201D.\"><input aria-label=\"Agent name\" style={input} value={draft.name} onChange={(e) => set({ name: e.target.value })} /></Field>\n <Field label=\"What should this agent do?\" hint=\"Write it as you would explain it to a new colleague.\"><textarea aria-label=\"What should this agent do?\" rows={4} style={input} value={draft.description} onChange={(e) => set({ description: e.target.value })} /></Field>\n <Field label=\"Who does it report to?\" hint=\"The agent that gives it work and receives its results. Leave empty to report to you.\">\n <select aria-label=\"Reports to\" style={input} value={draft.reportsTo} onChange={(e) => set({ reportsTo: e.target.value })}><option value=\"\">\u2014 me (the Owner) \u2014</option>{catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name}</option>)}</select></Field>\n <Field label=\"Engine\" hint=\"The new agent uses the same engine and login as an agent that already works.\">\n <select aria-label=\"Copy engine from\" style={input} value={draft.templateId} onChange={(e) => set({ templateId: e.target.value })}><option value=\"\">\u2014 choose an existing agent \u2014</option>{catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name} ({a.adapterType})</option>)}</select></Field>\n <details><summary style={{ cursor: \"pointer\" }}>Advanced: start from a ready-made role</summary>\n <select aria-label=\"Start from role\" style={{ ...input, marginTop: 6 }} value={draft.baseRole} onChange={(e) => set({ baseRole: e.target.value })}><option value=\"\">\u2014 no, start empty \u2014</option>{catalog.roles.map((r) => <option key={r.key} value={r.key}>{r.title}</option>)}</select></details>\n </>}\n\n {step === 2 && <>\n <Field label=\"Skills\" hint=\"Skills are know-how the agent can read when needed. Tick the ones that fit.\">\n <div style={{ maxHeight: 220, overflow: \"auto\", border: \"1px solid var(--border, #333)\", borderRadius: 6, padding: 8, display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(260px, 1fr))\", gap: 4 }}>\n {builder.librarySkills.filter((s) => s.slug !== \"run-playbook\").map((s) => <label key={s.slug} title={s.description} style={{ display: \"flex\", gap: 6, alignItems: \"center\", fontSize: 13 }}>\n <input type=\"checkbox\" checked={draft.skills.includes(s.slug)} onChange={(e) => set({ skills: e.target.checked ? [...draft.skills, s.slug] : draft.skills.filter((x) => x !== s.slug) })} />{s.title}</label>)}\n </div></Field>\n <Field label=\"Add by link\" hint=\"Paste the link of a skill, of a tool (MCP server) or of a playbook. Tools are installed afterwards, with the assistant.\">\n <div style={S.row}><input aria-label=\"Link\" placeholder=\"https://\u2026\" style={{ ...input, flex: 1, width: \"auto\" }} value={link} onChange={(e) => setLink(e.target.value)} onKeyDown={(e) => { if (e.key === \"Enter\") { e.preventDefault(); addLink(); } }} /><Btn onClick={addLink}>Add</Btn></div></Field>\n {draft.links.map((item, i) => <div key={item.url + i} style={S.row}>\n <select aria-label={`Type of link ${i + 1}`} style={S.select} value={item.kind} onChange={(e) => set({ links: draft.links.map((l, n) => (n === i ? { ...l, kind: e.target.value as LinkItem[\"kind\"] } : l)) })}><option value=\"skill\">Skill</option><option value=\"mcp\">Tool (MCP server)</option><option value=\"playbook\">Playbook</option></select>\n <span style={{ wordBreak: \"break-all\", flex: 1 }}>{item.url}</span><Btn onClick={() => set({ links: draft.links.filter((_, n) => n !== i) })}>Remove</Btn></div>)}\n </>}\n\n {step === 3 && <>\n <Guide id=\"procedures\"><div style={S.muted}>A procedure is a checklist for one kind of job. When the agent gets a task that matches, it copies the steps into the task, works on them one at a time, and for each step it must write the proof (a link, a file, a result) before moving on. If it gets stuck it says what it needs and stops instead of guessing. Write short steps, each with a clear result. You can add or change procedures later from the agent's instructions.</div></Guide>\n {draft.procedures.map((p, i) => <div key={i} style={{ ...S.card, gap: 6 }}>\n <div style={S.row}><input aria-label={`Procedure ${i + 1} title`} placeholder=\"Title, e.g. \u201CPrepare a monthly report\u201D\" style={{ ...input, flex: 1, width: \"auto\" }} value={p.title} onChange={(e) => setProc(i, { title: e.target.value })} /><Btn onClick={() => set({ procedures: draft.procedures.filter((_, n) => n !== i) })}>Remove</Btn></div>\n <input aria-label={`Procedure ${i + 1} use when`} placeholder=\"Use when\u2026 (optional)\" style={input} value={p.useWhen} onChange={(e) => setProc(i, { useWhen: e.target.value })} />\n <textarea aria-label={`Procedure ${i + 1} steps`} rows={5} placeholder={\"One step per line, in order\\nCollect the figures\\nCheck them against the source\\nWrite the summary\"} style={input} value={p.steps.join(\"\\n\")} onChange={(e) => setProc(i, { steps: e.target.value.split(\"\\n\") })} />\n </div>)}\n <div><Btn onClick={() => set({ procedures: [...draft.procedures, { title: \"\", useWhen: \"\", steps: [] }] })}>+ Add a procedure</Btn></div>\n </>}\n\n {step === 4 && <>\n <div><strong>{draft.name || \"(no name)\"}</strong>{` \u2014 reports to ${catalog.agents.find((a) => a.id === draft.reportsTo)?.name ?? \"you\"}`}</div>\n <div style={S.muted}>{draft.description || (draft.baseRole ? \"From the ready-made role.\" : \"\")}</div>\n <ul style={{ margin: 0, paddingLeft: 20 }}>\n <li>{`${draft.skills.length + 1} skill(s) from the library, ${draft.links.filter((l) => l.kind === \"skill\").length} by link`}</li>\n <li>{`${draft.links.filter((l) => l.kind === \"mcp\").length} tool(s) (MCP servers) to install after creation`}</li>\n <li>{`${draft.procedures.filter((p) => p.title.trim()).length} procedure(s), ${draft.links.filter((l) => l.kind === \"playbook\").length} playbook(s) by link`}</li>\n </ul>\n {problems.map((p) => <div key={p} role=\"alert\" style={{ color: \"#ef4444\" }}>{p}</div>)}\n </>}\n\n <div style={{ ...S.row, justifyContent: \"space-between\" }}>\n <Btn onClick={() => setStep(Math.max(1, step - 1))} disabled={step === 1}>Back</Btn>\n {step < 4 ? <Btn primary onClick={() => setStep(step + 1)}>Next</Btn> : <Btn primary onClick={create} disabled={busy || problems.length > 0}>{busy ? \"Creating\u2026\" : \"Create agent\"}</Btn>}\n </div>\n </div>;\n}\n\nfunction AssistantTab({ companyId, catalog, refreshAll, builder, refresh, useDraft, say, pending, clearPending, goSettings }: { companyId: string; catalog: Catalog; refreshAll: () => void; builder: Builder; refresh: () => void; useDraft: (d: Partial<Draft>) => void; say: (k: \"ok\" | \"error\", t: string) => void; pending: string; clearPending: () => void; goSettings: () => void }) {\n const send = usePluginAction(\"assistant-send\");\n const reset = usePluginAction(\"assistant-reset\");\n const [text, setText] = useState(pending);\n const [sending, setSending] = useState(false);\n const [registering, setRegistering] = useState(false);\n useEffect(() => { if (pending) { setText(pending); clearPending(); } }, [pending]);\n useEffect(() => { if (!builder.thread.busy) return; const timer = setInterval(refresh, 3000); return () => clearInterval(timer); }, [builder.thread.busy]);\n if (!builder.settings.assistantAgentId) return <div style={S.card}><strong>The assistant is not set up yet</strong><span style={S.muted}>Choose which of your agents powers it (its engine does the thinking, the web searches and the installations).</span><div><Btn primary onClick={goSettings}>Open settings</Btn></div></div>;\n const go = async () => { setSending(true); try { await send({ companyId, text }); setText(\"\"); refresh(); } catch (error) { say(\"error\", String((error as Error).message ?? error)); } finally { setSending(false); } };\n return <div style={S.card}>\n <div style={{ ...S.row, justifyContent: \"space-between\" }}><strong>Assistant</strong><Btn onClick={async () => { await reset({ companyId }); refresh(); }}>Start over</Btn></div>\n <span style={S.muted}>Tell it what agent you need. It asks a few questions, can search the web for tools and skills, and prepares the agent for you to review. Each message uses your engine's credits.</span>\n <div aria-live=\"polite\" style={{ display: \"flex\", flexDirection: \"column\", gap: 8, maxHeight: 460, overflow: \"auto\" }}>\n {builder.thread.messages.length === 0 && <span style={S.muted}>Example: \u201CI need an agent that answers supplier emails and files the invoices.\u201D</span>}\n {builder.thread.messages.map((m, i) => {\n const draft = m.role === \"assistant\" ? parseBlock<Partial<Draft>>(m.text, \"agent-draft\") : null;\n const mcp = m.role === \"assistant\" ? parseBlock<McpResult>(m.text, \"mcp-result\") : null;\n const wanted = mcp ? catalog.agents.filter((a) => a.mcp.some((x) => x.url === mcp.url && x.status !== \"installed\")) : [];\n const targets = mcp ? (wanted.length ? wanted : catalog.agents.filter((a) => a.custom)) : [];\n return <div key={i} style={{ alignSelf: m.role === \"user\" ? \"flex-end\" : \"flex-start\", maxWidth: \"85%\", ...S.pre, fontFamily: \"inherit\", fontSize: 14, background: m.role === \"user\" ? \"color-mix(in srgb, var(--primary, #2563eb) 25%, transparent)\" : m.role === \"system\" ? \"color-mix(in srgb, #ef4444 20%, transparent)\" : S.pre.background }}>\n {m.text.replace(/```(agent-draft|mcp-result)[\\s\\S]*?```/g, \"\").trim()}\n {mcp && <div style={{ marginTop: 8, display: \"flex\", flexDirection: \"column\", gap: 6 }}>\n <span style={S.muted}>{`${mcp.remoteUrl ? `Hosted server: ${mcp.remoteUrl}` : `Starts with: ${[mcp.command, ...(mcp.args ?? [])].join(\" \")}`} \u00B7 ${(mcp.tools ?? []).length} tools \u00B7 ${mcp.tested ? \"tested by the assistant\" : \"NOT tested\"}`}</span>\n {targets.length === 0 ? <span style={S.muted}>Create a custom agent first, then come back to assign this tool.</span> : targets.map((a) => <div key={a.id}><Btn primary disabled={registering} onClick={async () => { setRegistering(true); try { say(\"ok\", await registerMcp(companyId, a, mcp)); refreshAll(); } catch (error) { say(\"error\", \"Could not register the tool: \" + String((error as Error).message)); } finally { setRegistering(false); } }}>{`Register and assign to ${a.name}`}</Btn></div>)}\n </div>}\n {draft && <div style={{ marginTop: 8 }}><Btn primary onClick={() => useDraft(draft)}>Review and create this agent</Btn></div>}\n </div>;\n })}\n {builder.thread.busy && <span style={S.muted}>The assistant is working\u2026</span>}\n </div>\n <div style={S.row}><textarea aria-label=\"Message to the assistant\" rows={2} style={{ ...input, flex: 1, width: \"auto\" }} value={text} onChange={(e) => setText(e.target.value)} /><Btn primary onClick={go} disabled={sending || builder.thread.busy || !text.trim()}>Send</Btn></div>\n </div>;\n}\n\nfunction SettingsTab({ companyId, catalog, builder, refresh, say }: { companyId: string; catalog: Catalog; builder: Builder; refresh: () => void; say: (k: \"ok\" | \"error\", t: string) => void }) {\n const save = usePluginAction(\"save-settings\");\n const [agentId, setAgentId] = useState(builder.settings.assistantAgentId ?? \"\");\n return <div style={S.card}>\n <strong>Assistant engine</strong>\n <span style={S.muted}>The assistant has no engine of its own: it borrows the engine (Claude Code, Pi, Codex\u2026) and login of one of your agents. Because that engine runs on your server, it is also what installs and tests tools (MCP servers) there.</span>\n <div style={S.row}>\n <select aria-label=\"Assistant engine\" style={S.select} value={agentId} onChange={(e) => setAgentId(e.target.value)}><option value=\"\">\u2014 choose an agent \u2014</option>{catalog.agents.map((a) => <option key={a.id} value={a.id}>{a.name} ({a.adapterType})</option>)}</select>\n <Btn primary onClick={async () => { try { await save({ companyId, assistantAgentId: agentId }); say(\"ok\", \"Settings saved.\"); refresh(); } catch (error) { say(\"error\", String((error as Error).message)); } }}>Save</Btn>\n </div>\n <span style={S.muted}>Tip: use an agent dedicated to this, so its other work is not mixed with the assistant's conversations.</span>\n </div>;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,WAAW,gBAAoD;AACxE,SAAS,gBAAgB,iBAAiB,mBAAmB,iBAAiB,qBAAqB;AA0D1F,SAsBiB,UAtBjB,KAqBL,YArBK;AA/CT,eAAe,IAAa,QAAgB,MAAc,MAA4B;AACpF,QAAM,WAAW,MAAM,MAAM,MAAM,EAAE,QAAQ,aAAa,WAAW,SAAS,SAAS,SAAY,SAAY,EAAE,gBAAgB,mBAAmB,GAAG,MAAM,SAAS,SAAY,SAAY,KAAK,UAAU,IAAI,EAAE,CAAC;AACpN,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,UAAe;AACnB,MAAI;AAAE,cAAU,OAAO,KAAK,MAAM,IAAI,IAAI;AAAA,EAAM,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AO,EAAE,MACnB;AAAA,wBAAC,YAAO,8BAAgB;AAAA,IACxB,oBAAC,UAAK,OAAO,EAAE,OAAO,kPAA+N;AAAA,IACrP,qBAAC,SAAI,OAAO,EAAE,KACZ;AAAA,2BAAC,YAAO,cAAW,oBAAmB,OAAO,EAAE,QAAQ,OAAO,SAAS,UAAU,CAAC,MAAM,WAAW,EAAE,OAAO,KAAK,GAAG;AAAA,4BAAC,YAAO,OAAM,IAAG,2CAAmB;AAAA,QAAU,QAAQ,OAAO,IAAI,CAAC,MAAM,qBAAC,YAAkB,OAAO,EAAE,IAAK;AAAA,YAAE;AAAA,UAAK;AAAA,UAAG,EAAE;AAAA,UAAY;AAAA,aAA5C,EAAE,EAA2C,CAAS;AAAA,SAAE;AAAA,MACjQ,oBAAC,OAAI,SAAO,MAAC,SAAS,YAAY;AAAE,YAAI;AAAE,gBAAM,KAAK,EAAE,WAAW,kBAAkB,QAAQ,CAAC;AAAG,cAAI,MAAM,iBAAiB;AAAG,kBAAQ;AAAA,QAAG,SAAS,OAAO;AAAE,cAAI,SAAS,OAAQ,MAAgB,OAAO,CAAC;AAAA,QAAG;AAAA,MAAE,GAAG,kBAAI;AAAA,OACtN;AAAA,IACA,oBAAC,UAAK,OAAO,EAAE,OAAO,qHAAuG;AAAA,KAC/H;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-playbook-runner-otomatik",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "description": "Runs agent-static flows: creates the child tasks with blockers, counts review rounds and escalates a stuck loop to the sector head.",
6
6
  "files": [