@actrun_ai/tastekit-core 0.1.0
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/compiler/compiler.d.ts +24 -0
- package/dist/compiler/compiler.d.ts.map +1 -0
- package/dist/compiler/compiler.js +153 -0
- package/dist/compiler/compiler.js.map +1 -0
- package/dist/compiler/constitution-compiler.d.ts +11 -0
- package/dist/compiler/constitution-compiler.d.ts.map +1 -0
- package/dist/compiler/constitution-compiler.js +154 -0
- package/dist/compiler/constitution-compiler.js.map +1 -0
- package/dist/compiler/derivation.d.ts +125 -0
- package/dist/compiler/derivation.d.ts.map +1 -0
- package/dist/compiler/derivation.js +109 -0
- package/dist/compiler/derivation.js.map +1 -0
- package/dist/compiler/guardrails-compiler.d.ts +11 -0
- package/dist/compiler/guardrails-compiler.d.ts.map +1 -0
- package/dist/compiler/guardrails-compiler.js +362 -0
- package/dist/compiler/guardrails-compiler.js.map +1 -0
- package/dist/compiler/index.d.ts +13 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +13 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/memory-compiler.d.ts +12 -0
- package/dist/compiler/memory-compiler.d.ts.map +1 -0
- package/dist/compiler/memory-compiler.js +293 -0
- package/dist/compiler/memory-compiler.js.map +1 -0
- package/dist/compiler/playbook-compiler.d.ts +15 -0
- package/dist/compiler/playbook-compiler.d.ts.map +1 -0
- package/dist/compiler/playbook-compiler.js +1143 -0
- package/dist/compiler/playbook-compiler.js.map +1 -0
- package/dist/compiler/skills-compiler.d.ts +15 -0
- package/dist/compiler/skills-compiler.d.ts.map +1 -0
- package/dist/compiler/skills-compiler.js +203 -0
- package/dist/compiler/skills-compiler.js.map +1 -0
- package/dist/domains/development-agent/domain.d.ts +8 -0
- package/dist/domains/development-agent/domain.d.ts.map +1 -0
- package/dist/domains/development-agent/domain.js +35 -0
- package/dist/domains/development-agent/domain.js.map +1 -0
- package/dist/domains/development-agent/index.d.ts +3 -0
- package/dist/domains/development-agent/index.d.ts.map +1 -0
- package/dist/domains/development-agent/index.js +3 -0
- package/dist/domains/development-agent/index.js.map +1 -0
- package/dist/domains/development-agent/rubric.d.ts +13 -0
- package/dist/domains/development-agent/rubric.d.ts.map +1 -0
- package/dist/domains/development-agent/rubric.js +451 -0
- package/dist/domains/development-agent/rubric.js.map +1 -0
- package/dist/domains/development-agent/skills/code-review.d.ts +25 -0
- package/dist/domains/development-agent/skills/code-review.d.ts.map +1 -0
- package/dist/domains/development-agent/skills/code-review.js +146 -0
- package/dist/domains/development-agent/skills/code-review.js.map +1 -0
- package/dist/domains/development-agent/skills/debugging-issues.d.ts +25 -0
- package/dist/domains/development-agent/skills/debugging-issues.d.ts.map +1 -0
- package/dist/domains/development-agent/skills/debugging-issues.js +155 -0
- package/dist/domains/development-agent/skills/debugging-issues.js.map +1 -0
- package/dist/domains/development-agent/skills/documenting-code.d.ts +19 -0
- package/dist/domains/development-agent/skills/documenting-code.d.ts.map +1 -0
- package/dist/domains/development-agent/skills/documenting-code.js +92 -0
- package/dist/domains/development-agent/skills/documenting-code.js.map +1 -0
- package/dist/domains/development-agent/skills/index.d.ts +55 -0
- package/dist/domains/development-agent/skills/index.d.ts.map +1 -0
- package/dist/domains/development-agent/skills/index.js +19 -0
- package/dist/domains/development-agent/skills/index.js.map +1 -0
- package/dist/domains/development-agent/skills/refactor-plan.d.ts +19 -0
- package/dist/domains/development-agent/skills/refactor-plan.d.ts.map +1 -0
- package/dist/domains/development-agent/skills/refactor-plan.js +117 -0
- package/dist/domains/development-agent/skills/refactor-plan.js.map +1 -0
- package/dist/domains/development-agent/skills/writing-tests.d.ts +20 -0
- package/dist/domains/development-agent/skills/writing-tests.d.ts.map +1 -0
- package/dist/domains/development-agent/skills/writing-tests.js +93 -0
- package/dist/domains/development-agent/skills/writing-tests.js.map +1 -0
- package/dist/domains/general-agent/domain.d.ts +9 -0
- package/dist/domains/general-agent/domain.d.ts.map +1 -0
- package/dist/domains/general-agent/domain.js +36 -0
- package/dist/domains/general-agent/domain.js.map +1 -0
- package/dist/domains/general-agent/index.d.ts +4 -0
- package/dist/domains/general-agent/index.d.ts.map +1 -0
- package/dist/domains/general-agent/index.js +4 -0
- package/dist/domains/general-agent/index.js.map +1 -0
- package/dist/domains/general-agent/rubric.d.ts +8 -0
- package/dist/domains/general-agent/rubric.d.ts.map +1 -0
- package/dist/domains/general-agent/rubric.js +332 -0
- package/dist/domains/general-agent/rubric.js.map +1 -0
- package/dist/domains/general-agent/skills/context-synthesis.d.ts +19 -0
- package/dist/domains/general-agent/skills/context-synthesis.d.ts.map +1 -0
- package/dist/domains/general-agent/skills/context-synthesis.js +94 -0
- package/dist/domains/general-agent/skills/context-synthesis.js.map +1 -0
- package/dist/domains/general-agent/skills/index.d.ts +32 -0
- package/dist/domains/general-agent/skills/index.d.ts.map +1 -0
- package/dist/domains/general-agent/skills/index.js +11 -0
- package/dist/domains/general-agent/skills/index.js.map +1 -0
- package/dist/domains/general-agent/skills/task-orchestration.d.ts +19 -0
- package/dist/domains/general-agent/skills/task-orchestration.d.ts.map +1 -0
- package/dist/domains/general-agent/skills/task-orchestration.js +101 -0
- package/dist/domains/general-agent/skills/task-orchestration.js.map +1 -0
- package/dist/domains/index.d.ts +21 -0
- package/dist/domains/index.d.ts.map +1 -0
- package/dist/domains/index.js +37 -0
- package/dist/domains/index.js.map +1 -0
- package/dist/domains/types.d.ts +22 -0
- package/dist/domains/types.d.ts.map +1 -0
- package/dist/domains/types.js +2 -0
- package/dist/domains/types.js.map +1 -0
- package/dist/drift/consolidator.d.ts +47 -0
- package/dist/drift/consolidator.d.ts.map +1 -0
- package/dist/drift/consolidator.js +116 -0
- package/dist/drift/consolidator.js.map +1 -0
- package/dist/drift/detector.d.ts +79 -0
- package/dist/drift/detector.d.ts.map +1 -0
- package/dist/drift/detector.js +424 -0
- package/dist/drift/detector.js.map +1 -0
- package/dist/drift/index.d.ts +9 -0
- package/dist/drift/index.d.ts.map +1 -0
- package/dist/drift/index.js +9 -0
- package/dist/drift/index.js.map +1 -0
- package/dist/drift/proposal.d.ts +108 -0
- package/dist/drift/proposal.d.ts.map +1 -0
- package/dist/drift/proposal.js +2 -0
- package/dist/drift/proposal.js.map +1 -0
- package/dist/eval/index.d.ts +9 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +9 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/judge.d.ts +33 -0
- package/dist/eval/judge.d.ts.map +1 -0
- package/dist/eval/judge.js +209 -0
- package/dist/eval/judge.js.map +1 -0
- package/dist/eval/replay.d.ts +23 -0
- package/dist/eval/replay.d.ts.map +1 -0
- package/dist/eval/replay.js +42 -0
- package/dist/eval/replay.js.map +1 -0
- package/dist/eval/runner.d.ts +35 -0
- package/dist/eval/runner.d.ts.map +1 -0
- package/dist/eval/runner.js +52 -0
- package/dist/eval/runner.js.map +1 -0
- package/dist/generators/agents-md-generator.d.ts +9 -0
- package/dist/generators/agents-md-generator.d.ts.map +1 -0
- package/dist/generators/agents-md-generator.js +71 -0
- package/dist/generators/agents-md-generator.js.map +1 -0
- package/dist/generators/blocks/domain-context.d.ts +7 -0
- package/dist/generators/blocks/domain-context.d.ts.map +1 -0
- package/dist/generators/blocks/domain-context.js +26 -0
- package/dist/generators/blocks/domain-context.js.map +1 -0
- package/dist/generators/blocks/drift-awareness.d.ts +6 -0
- package/dist/generators/blocks/drift-awareness.d.ts.map +1 -0
- package/dist/generators/blocks/drift-awareness.js +28 -0
- package/dist/generators/blocks/drift-awareness.js.map +1 -0
- package/dist/generators/blocks/evaluation-criteria.d.ts +7 -0
- package/dist/generators/blocks/evaluation-criteria.d.ts.map +1 -0
- package/dist/generators/blocks/evaluation-criteria.js +18 -0
- package/dist/generators/blocks/evaluation-criteria.js.map +1 -0
- package/dist/generators/blocks/guardrails.d.ts +6 -0
- package/dist/generators/blocks/guardrails.d.ts.map +1 -0
- package/dist/generators/blocks/guardrails.js +44 -0
- package/dist/generators/blocks/guardrails.js.map +1 -0
- package/dist/generators/blocks/identity.d.ts +6 -0
- package/dist/generators/blocks/identity.d.ts.map +1 -0
- package/dist/generators/blocks/identity.js +36 -0
- package/dist/generators/blocks/identity.js.map +1 -0
- package/dist/generators/blocks/memory-policy.d.ts +6 -0
- package/dist/generators/blocks/memory-policy.d.ts.map +1 -0
- package/dist/generators/blocks/memory-policy.js +34 -0
- package/dist/generators/blocks/memory-policy.js.map +1 -0
- package/dist/generators/blocks/playbook-index.d.ts +7 -0
- package/dist/generators/blocks/playbook-index.d.ts.map +1 -0
- package/dist/generators/blocks/playbook-index.js +14 -0
- package/dist/generators/blocks/playbook-index.js.map +1 -0
- package/dist/generators/blocks/session-rhythm.d.ts +6 -0
- package/dist/generators/blocks/session-rhythm.d.ts.map +1 -0
- package/dist/generators/blocks/session-rhythm.js +11 -0
- package/dist/generators/blocks/session-rhythm.js.map +1 -0
- package/dist/generators/blocks/skills-index.d.ts +6 -0
- package/dist/generators/blocks/skills-index.d.ts.map +1 -0
- package/dist/generators/blocks/skills-index.js +36 -0
- package/dist/generators/blocks/skills-index.js.map +1 -0
- package/dist/generators/blocks/tool-usage.d.ts +6 -0
- package/dist/generators/blocks/tool-usage.d.ts.map +1 -0
- package/dist/generators/blocks/tool-usage.js +31 -0
- package/dist/generators/blocks/tool-usage.js.map +1 -0
- package/dist/generators/blocks/vocabulary.d.ts +7 -0
- package/dist/generators/blocks/vocabulary.d.ts.map +1 -0
- package/dist/generators/blocks/vocabulary.js +27 -0
- package/dist/generators/blocks/vocabulary.js.map +1 -0
- package/dist/generators/claude-hooks-compat.d.ts +33 -0
- package/dist/generators/claude-hooks-compat.d.ts.map +1 -0
- package/dist/generators/claude-hooks-compat.js +322 -0
- package/dist/generators/claude-hooks-compat.js.map +1 -0
- package/dist/generators/claude-md-generator.d.ts +12 -0
- package/dist/generators/claude-md-generator.d.ts.map +1 -0
- package/dist/generators/claude-md-generator.js +60 -0
- package/dist/generators/claude-md-generator.js.map +1 -0
- package/dist/generators/index.d.ts +11 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +11 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/soul-md-generator.d.ts +9 -0
- package/dist/generators/soul-md-generator.d.ts.map +1 -0
- package/dist/generators/soul-md-generator.js +104 -0
- package/dist/generators/soul-md-generator.js.map +1 -0
- package/dist/generators/types.d.ts +55 -0
- package/dist/generators/types.d.ts.map +1 -0
- package/dist/generators/types.js +7 -0
- package/dist/generators/types.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/interview/index.d.ts +11 -0
- package/dist/interview/index.d.ts.map +1 -0
- package/dist/interview/index.js +11 -0
- package/dist/interview/index.js.map +1 -0
- package/dist/interview/interviewer.d.ts +94 -0
- package/dist/interview/interviewer.d.ts.map +1 -0
- package/dist/interview/interviewer.js +516 -0
- package/dist/interview/interviewer.js.map +1 -0
- package/dist/interview/questions.d.ts +15 -0
- package/dist/interview/questions.d.ts.map +1 -0
- package/dist/interview/questions.js +86 -0
- package/dist/interview/questions.js.map +1 -0
- package/dist/interview/rubric.d.ts +265 -0
- package/dist/interview/rubric.d.ts.map +1 -0
- package/dist/interview/rubric.js +74 -0
- package/dist/interview/rubric.js.map +1 -0
- package/dist/interview/session.d.ts +9 -0
- package/dist/interview/session.d.ts.map +1 -0
- package/dist/interview/session.js +33 -0
- package/dist/interview/session.js.map +1 -0
- package/dist/interview/universal-rubric.d.ts +11 -0
- package/dist/interview/universal-rubric.d.ts.map +1 -0
- package/dist/interview/universal-rubric.js +165 -0
- package/dist/interview/universal-rubric.js.map +1 -0
- package/dist/llm/index.d.ts +8 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +8 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/provider.d.ts +62 -0
- package/dist/llm/provider.d.ts.map +1 -0
- package/dist/llm/provider.js +24 -0
- package/dist/llm/provider.js.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +18 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.js +56 -0
- package/dist/llm/providers/anthropic.js.map +1 -0
- package/dist/llm/providers/ollama.d.ts +17 -0
- package/dist/llm/providers/ollama.d.ts.map +1 -0
- package/dist/llm/providers/ollama.js +45 -0
- package/dist/llm/providers/ollama.js.map +1 -0
- package/dist/llm/providers/openai.d.ts +19 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/providers/openai.js +52 -0
- package/dist/llm/providers/openai.js.map +1 -0
- package/dist/llm/resolve.d.ts +11 -0
- package/dist/llm/resolve.d.ts.map +1 -0
- package/dist/llm/resolve.js +56 -0
- package/dist/llm/resolve.js.map +1 -0
- package/dist/mcp/binder.d.ts +28 -0
- package/dist/mcp/binder.d.ts.map +1 -0
- package/dist/mcp/binder.js +87 -0
- package/dist/mcp/binder.js.map +1 -0
- package/dist/mcp/client.d.ts +99 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +196 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/index.d.ts +9 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/inspector.d.ts +29 -0
- package/dist/mcp/inspector.d.ts.map +1 -0
- package/dist/mcp/inspector.js +44 -0
- package/dist/mcp/inspector.js.map +1 -0
- package/dist/schemas/bindings.d.ts +248 -0
- package/dist/schemas/bindings.d.ts.map +1 -0
- package/dist/schemas/bindings.js +34 -0
- package/dist/schemas/bindings.js.map +1 -0
- package/dist/schemas/constitution.d.ts +229 -0
- package/dist/schemas/constitution.d.ts.map +1 -0
- package/dist/schemas/constitution.js +47 -0
- package/dist/schemas/constitution.js.map +1 -0
- package/dist/schemas/evalpack.d.ts +322 -0
- package/dist/schemas/evalpack.d.ts.map +1 -0
- package/dist/schemas/evalpack.js +43 -0
- package/dist/schemas/evalpack.js.map +1 -0
- package/dist/schemas/guardrails.d.ts +171 -0
- package/dist/schemas/guardrails.d.ts.map +1 -0
- package/dist/schemas/guardrails.js +35 -0
- package/dist/schemas/guardrails.js.map +1 -0
- package/dist/schemas/index.d.ts +18 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +18 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/memory.d.ts +277 -0
- package/dist/schemas/memory.d.ts.map +1 -0
- package/dist/schemas/memory.js +42 -0
- package/dist/schemas/memory.js.map +1 -0
- package/dist/schemas/playbook.d.ts +270 -0
- package/dist/schemas/playbook.d.ts.map +1 -0
- package/dist/schemas/playbook.js +52 -0
- package/dist/schemas/playbook.js.map +1 -0
- package/dist/schemas/skills.d.ts +320 -0
- package/dist/schemas/skills.d.ts.map +1 -0
- package/dist/schemas/skills.js +84 -0
- package/dist/schemas/skills.js.map +1 -0
- package/dist/schemas/trace.d.ts +126 -0
- package/dist/schemas/trace.d.ts.map +1 -0
- package/dist/schemas/trace.js +70 -0
- package/dist/schemas/trace.js.map +1 -0
- package/dist/schemas/trust.d.ts +142 -0
- package/dist/schemas/trust.d.ts.map +1 -0
- package/dist/schemas/trust.js +30 -0
- package/dist/schemas/trust.js.map +1 -0
- package/dist/schemas/validators.d.ts +26 -0
- package/dist/schemas/validators.d.ts.map +1 -0
- package/dist/schemas/validators.js +79 -0
- package/dist/schemas/validators.js.map +1 -0
- package/dist/schemas/workspace.d.ts +725 -0
- package/dist/schemas/workspace.d.ts.map +1 -0
- package/dist/schemas/workspace.js +119 -0
- package/dist/schemas/workspace.js.map +1 -0
- package/dist/skills/constraints.d.ts +19 -0
- package/dist/skills/constraints.d.ts.map +1 -0
- package/dist/skills/constraints.js +91 -0
- package/dist/skills/constraints.js.map +1 -0
- package/dist/skills/generator.d.ts +13 -0
- package/dist/skills/generator.d.ts.map +1 -0
- package/dist/skills/generator.js +126 -0
- package/dist/skills/generator.js.map +1 -0
- package/dist/skills/graph.d.ts +42 -0
- package/dist/skills/graph.d.ts.map +1 -0
- package/dist/skills/graph.js +217 -0
- package/dist/skills/graph.js.map +1 -0
- package/dist/skills/index.d.ts +13 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +13 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/linter.d.ts +22 -0
- package/dist/skills/linter.d.ts.map +1 -0
- package/dist/skills/linter.js +201 -0
- package/dist/skills/linter.js.map +1 -0
- package/dist/skills/packer.d.ts +27 -0
- package/dist/skills/packer.d.ts.map +1 -0
- package/dist/skills/packer.js +72 -0
- package/dist/skills/packer.js.map +1 -0
- package/dist/skills/tracker.d.ts +27 -0
- package/dist/skills/tracker.d.ts.map +1 -0
- package/dist/skills/tracker.js +131 -0
- package/dist/skills/tracker.js.map +1 -0
- package/dist/skills/versioner.d.ts +19 -0
- package/dist/skills/versioner.d.ts.map +1 -0
- package/dist/skills/versioner.js +76 -0
- package/dist/skills/versioner.js.map +1 -0
- package/dist/tracing/index.d.ts +8 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +8 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/reader.d.ts +18 -0
- package/dist/tracing/reader.d.ts.map +1 -0
- package/dist/tracing/reader.js +34 -0
- package/dist/tracing/reader.js.map +1 -0
- package/dist/tracing/tracer.d.ts +22 -0
- package/dist/tracing/tracer.d.ts.map +1 -0
- package/dist/tracing/tracer.js +105 -0
- package/dist/tracing/tracer.js.map +1 -0
- package/dist/trust/auditor.d.ts +35 -0
- package/dist/trust/auditor.d.ts.map +1 -0
- package/dist/trust/auditor.js +78 -0
- package/dist/trust/auditor.js.map +1 -0
- package/dist/trust/index.d.ts +8 -0
- package/dist/trust/index.d.ts.map +1 -0
- package/dist/trust/index.js +8 -0
- package/dist/trust/index.js.map +1 -0
- package/dist/trust/manager.d.ts +18 -0
- package/dist/trust/manager.d.ts.map +1 -0
- package/dist/trust/manager.js +60 -0
- package/dist/trust/manager.js.map +1 -0
- package/dist/utils/filesystem.d.ts +15 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +53 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/hash.d.ts +7 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +15 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/yaml.d.ts +6 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +14 -0
- package/dist/utils/yaml.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,1143 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { writeFileSafe, resolvePlaybooksPath } from '../utils/filesystem.js';
|
|
3
|
+
import { stringifyYAML } from '../utils/yaml.js';
|
|
4
|
+
/**
|
|
5
|
+
* Compile playbooks from domain definitions + constitution.
|
|
6
|
+
*
|
|
7
|
+
* Resolves domain-specific playbooks, personalizes them with
|
|
8
|
+
* constitution data, and writes playbook YAML files.
|
|
9
|
+
*/
|
|
10
|
+
export async function compilePlaybooks(options) {
|
|
11
|
+
const { workspacePath, session, constitution } = options;
|
|
12
|
+
const playbooksPath = resolvePlaybooksPath(workspacePath);
|
|
13
|
+
const artifacts = [];
|
|
14
|
+
// Resolve domain playbooks
|
|
15
|
+
const domainPlaybooks = await resolveDomainPlaybooks(session.domain_id);
|
|
16
|
+
const allPlaybooks = [];
|
|
17
|
+
for (const dp of domainPlaybooks) {
|
|
18
|
+
allPlaybooks.push(dp.playbook);
|
|
19
|
+
}
|
|
20
|
+
// If no domain playbooks were found, generate a generic one
|
|
21
|
+
if (allPlaybooks.length === 0) {
|
|
22
|
+
allPlaybooks.push(generateGenericPlaybook(constitution));
|
|
23
|
+
}
|
|
24
|
+
// Write each playbook
|
|
25
|
+
for (const playbook of allPlaybooks) {
|
|
26
|
+
const filename = `${playbook.id}.v1.yaml`;
|
|
27
|
+
writeFileSafe(join(playbooksPath, filename), stringifyYAML(playbook));
|
|
28
|
+
artifacts.push(`playbooks/${filename}`);
|
|
29
|
+
}
|
|
30
|
+
return artifacts;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Dynamically resolve domain playbooks by domain_id.
|
|
34
|
+
*/
|
|
35
|
+
async function resolveDomainPlaybooks(domainId) {
|
|
36
|
+
if (!domainId)
|
|
37
|
+
return [];
|
|
38
|
+
switch (domainId) {
|
|
39
|
+
case 'content-agent':
|
|
40
|
+
return getContentAgentPlaybooks();
|
|
41
|
+
case 'research-agent':
|
|
42
|
+
return getResearchAgentPlaybooks();
|
|
43
|
+
case 'sales-agent':
|
|
44
|
+
return getSalesAgentPlaybooks();
|
|
45
|
+
case 'support-agent':
|
|
46
|
+
return getSupportAgentPlaybooks();
|
|
47
|
+
case 'general-agent':
|
|
48
|
+
return getGeneralAgentPlaybooks();
|
|
49
|
+
default:
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Content agent playbooks — pre-built workflows for content creation.
|
|
55
|
+
*/
|
|
56
|
+
function getContentAgentPlaybooks() {
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
playbook: {
|
|
60
|
+
schema_version: 'playbook.v1',
|
|
61
|
+
id: 'simple-post',
|
|
62
|
+
name: 'Simple Post Creation',
|
|
63
|
+
description: 'Quick workflow: research optional, generate options, user picks, publish.',
|
|
64
|
+
triggers: [
|
|
65
|
+
{ type: 'manual' },
|
|
66
|
+
],
|
|
67
|
+
inputs: [
|
|
68
|
+
{ name: 'topic', type: 'string', required: true, description: 'Topic or subject for the post' },
|
|
69
|
+
{ name: 'platform', type: 'string', required: true, description: 'Target platform (twitter, linkedin, etc.)' },
|
|
70
|
+
{ name: 'tone_override', type: 'string', required: false, description: 'Override default voice tone' },
|
|
71
|
+
],
|
|
72
|
+
steps: [
|
|
73
|
+
{
|
|
74
|
+
step_id: 'understand-context',
|
|
75
|
+
type: 'think',
|
|
76
|
+
outputs: ['context_summary'],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
step_id: 'generate-options',
|
|
80
|
+
type: 'tool',
|
|
81
|
+
tool_ref: 'skill:generate-post-options',
|
|
82
|
+
params_template: {
|
|
83
|
+
topic: '{{topic}}',
|
|
84
|
+
platform: '{{platform}}',
|
|
85
|
+
num_options: 3,
|
|
86
|
+
},
|
|
87
|
+
outputs: ['post_options'],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
step_id: 'user-selects',
|
|
91
|
+
type: 'approval_gate',
|
|
92
|
+
params_template: {
|
|
93
|
+
message: 'Choose a post option or request modifications.',
|
|
94
|
+
options: '{{post_options}}',
|
|
95
|
+
},
|
|
96
|
+
outputs: ['selected_post'],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
step_id: 'finalize',
|
|
100
|
+
type: 'write',
|
|
101
|
+
params_template: {
|
|
102
|
+
content: '{{selected_post}}',
|
|
103
|
+
format: '{{platform}}_post',
|
|
104
|
+
},
|
|
105
|
+
outputs: ['final_post'],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
checks: [
|
|
109
|
+
{
|
|
110
|
+
check_id: 'voice-match',
|
|
111
|
+
type: 'taste',
|
|
112
|
+
condition: 'Post matches constitution voice_keywords and avoids forbidden_phrases',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
check_id: 'platform-fit',
|
|
116
|
+
type: 'format',
|
|
117
|
+
condition: 'Post fits platform character limits and format requirements',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
stop_conditions: [
|
|
121
|
+
{
|
|
122
|
+
condition: 'User cancels or rejects all options',
|
|
123
|
+
reason: 'User does not want to proceed with any variation',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
escalations: [
|
|
127
|
+
{
|
|
128
|
+
escalation_id: 'sensitive-topic',
|
|
129
|
+
trigger: 'Topic involves controversy, politics, or sensitive subjects',
|
|
130
|
+
approval_ref: 'guardrails.approval_rules.content_review',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
playbook: {
|
|
137
|
+
schema_version: 'playbook.v1',
|
|
138
|
+
id: 'research-and-post',
|
|
139
|
+
name: 'Research-Driven Post',
|
|
140
|
+
description: 'Full workflow: research trends, generate ideas informed by research, create and review.',
|
|
141
|
+
triggers: [
|
|
142
|
+
{ type: 'manual' },
|
|
143
|
+
],
|
|
144
|
+
inputs: [
|
|
145
|
+
{ name: 'niche', type: 'string', required: true, description: 'Topic area or industry' },
|
|
146
|
+
{ name: 'platform', type: 'string', required: true, description: 'Target platform' },
|
|
147
|
+
{ name: 'timeframe', type: 'string', required: false, description: 'Trend timeframe (default: past week)' },
|
|
148
|
+
],
|
|
149
|
+
steps: [
|
|
150
|
+
{
|
|
151
|
+
step_id: 'research-trends',
|
|
152
|
+
type: 'tool',
|
|
153
|
+
tool_ref: 'skill:research-trends',
|
|
154
|
+
params_template: {
|
|
155
|
+
niche: '{{niche}}',
|
|
156
|
+
platform: '{{platform}}',
|
|
157
|
+
timeframe: '{{timeframe || "past week"}}',
|
|
158
|
+
},
|
|
159
|
+
outputs: ['trend_data'],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
step_id: 'analyze-findings',
|
|
163
|
+
type: 'think',
|
|
164
|
+
params_template: {
|
|
165
|
+
research: '{{trend_data}}',
|
|
166
|
+
instruction: 'Identify the best angle based on research findings and user principles',
|
|
167
|
+
},
|
|
168
|
+
outputs: ['selected_angle'],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
step_id: 'generate-options',
|
|
172
|
+
type: 'tool',
|
|
173
|
+
tool_ref: 'skill:generate-post-options',
|
|
174
|
+
params_template: {
|
|
175
|
+
topic: '{{selected_angle}}',
|
|
176
|
+
platform: '{{platform}}',
|
|
177
|
+
num_options: 3,
|
|
178
|
+
},
|
|
179
|
+
outputs: ['post_options'],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
step_id: 'user-review',
|
|
183
|
+
type: 'approval_gate',
|
|
184
|
+
params_template: {
|
|
185
|
+
message: 'Review options based on trend research. Choose or request changes.',
|
|
186
|
+
options: '{{post_options}}',
|
|
187
|
+
context: '{{trend_data}}',
|
|
188
|
+
},
|
|
189
|
+
outputs: ['selected_post'],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
step_id: 'finalize',
|
|
193
|
+
type: 'write',
|
|
194
|
+
params_template: {
|
|
195
|
+
content: '{{selected_post}}',
|
|
196
|
+
format: '{{platform}}_post',
|
|
197
|
+
},
|
|
198
|
+
outputs: ['final_post'],
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
checks: [
|
|
202
|
+
{
|
|
203
|
+
check_id: 'voice-match',
|
|
204
|
+
type: 'taste',
|
|
205
|
+
condition: 'Post matches constitution voice_keywords and avoids forbidden_phrases',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
check_id: 'trend-relevance',
|
|
209
|
+
type: 'facts',
|
|
210
|
+
condition: 'Post is informed by actual research findings, not generic advice',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
check_id: 'platform-fit',
|
|
214
|
+
type: 'format',
|
|
215
|
+
condition: 'Post fits platform character limits and format requirements',
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
stop_conditions: [
|
|
219
|
+
{
|
|
220
|
+
condition: 'No relevant trends found in research',
|
|
221
|
+
reason: 'Research did not yield actionable insights',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
condition: 'User cancels',
|
|
225
|
+
reason: 'User does not want to proceed',
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
escalations: [
|
|
229
|
+
{
|
|
230
|
+
escalation_id: 'sensitive-topic',
|
|
231
|
+
trigger: 'Research reveals sensitive or controversial trending topics',
|
|
232
|
+
approval_ref: 'guardrails.approval_rules.content_review',
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
playbook: {
|
|
239
|
+
schema_version: 'playbook.v1',
|
|
240
|
+
id: 'content-calendar',
|
|
241
|
+
name: 'Content Calendar Planning',
|
|
242
|
+
description: 'Plan a week of content: research trends, map to themes, schedule posts.',
|
|
243
|
+
triggers: [
|
|
244
|
+
{ type: 'manual' },
|
|
245
|
+
{ type: 'cron', schedule: '0 9 * * 1' }, // Monday at 9am
|
|
246
|
+
],
|
|
247
|
+
inputs: [
|
|
248
|
+
{ name: 'niche', type: 'string', required: true, description: 'Topic area' },
|
|
249
|
+
{ name: 'platforms', type: 'string', required: true, description: 'Target platforms (comma-separated)' },
|
|
250
|
+
{ name: 'posts_per_week', type: 'number', required: false, description: 'Posts per week (default: 5)' },
|
|
251
|
+
],
|
|
252
|
+
steps: [
|
|
253
|
+
{
|
|
254
|
+
step_id: 'research-trends',
|
|
255
|
+
type: 'tool',
|
|
256
|
+
tool_ref: 'skill:research-trends',
|
|
257
|
+
params_template: {
|
|
258
|
+
niche: '{{niche}}',
|
|
259
|
+
platform: '{{platforms}}',
|
|
260
|
+
timeframe: 'past week',
|
|
261
|
+
},
|
|
262
|
+
outputs: ['trend_data'],
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
step_id: 'plan-themes',
|
|
266
|
+
type: 'think',
|
|
267
|
+
params_template: {
|
|
268
|
+
research: '{{trend_data}}',
|
|
269
|
+
instruction: 'Map trends to daily themes for {{posts_per_week || 5}} posts across {{platforms}}',
|
|
270
|
+
},
|
|
271
|
+
outputs: ['theme_plan'],
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
step_id: 'review-plan',
|
|
275
|
+
type: 'approval_gate',
|
|
276
|
+
params_template: {
|
|
277
|
+
message: 'Review the proposed content calendar. Approve or adjust.',
|
|
278
|
+
plan: '{{theme_plan}}',
|
|
279
|
+
},
|
|
280
|
+
outputs: ['approved_plan'],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
step_id: 'write-calendar',
|
|
284
|
+
type: 'write',
|
|
285
|
+
params_template: {
|
|
286
|
+
content: '{{approved_plan}}',
|
|
287
|
+
format: 'content_calendar_md',
|
|
288
|
+
},
|
|
289
|
+
outputs: ['calendar_file'],
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
checks: [
|
|
293
|
+
{
|
|
294
|
+
check_id: 'variety',
|
|
295
|
+
type: 'taste',
|
|
296
|
+
condition: 'Calendar has varied topics and formats, not repetitive',
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
check_id: 'coverage',
|
|
300
|
+
type: 'format',
|
|
301
|
+
condition: 'All target platforms are represented in the calendar',
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
stop_conditions: [
|
|
305
|
+
{
|
|
306
|
+
condition: 'No research data available',
|
|
307
|
+
reason: 'Cannot plan without trend data',
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
escalations: [
|
|
311
|
+
{
|
|
312
|
+
escalation_id: 'high-volume',
|
|
313
|
+
trigger: 'Posts per week exceeds 10',
|
|
314
|
+
approval_ref: 'guardrails.approval_rules.resource_usage',
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Research agent playbooks — workflows for information gathering and analysis.
|
|
323
|
+
*/
|
|
324
|
+
function getResearchAgentPlaybooks() {
|
|
325
|
+
return [
|
|
326
|
+
{
|
|
327
|
+
playbook: {
|
|
328
|
+
schema_version: 'playbook.v1',
|
|
329
|
+
id: 'quick-lookup',
|
|
330
|
+
name: 'Quick Lookup',
|
|
331
|
+
description: 'Simple fact-finding: research a question, synthesize findings, present answer.',
|
|
332
|
+
triggers: [{ type: 'manual' }],
|
|
333
|
+
inputs: [
|
|
334
|
+
{ name: 'question', type: 'string', required: true, description: 'The question to research' },
|
|
335
|
+
{ name: 'source_preferences', type: 'string', required: false, description: 'Preferred source types' },
|
|
336
|
+
],
|
|
337
|
+
steps: [
|
|
338
|
+
{
|
|
339
|
+
step_id: 'research',
|
|
340
|
+
type: 'tool',
|
|
341
|
+
tool_ref: 'skill:web-research',
|
|
342
|
+
params_template: {
|
|
343
|
+
topic: '{{question}}',
|
|
344
|
+
scope: 'narrow',
|
|
345
|
+
max_sources: 5,
|
|
346
|
+
},
|
|
347
|
+
outputs: ['research_findings'],
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
step_id: 'synthesize',
|
|
351
|
+
type: 'think',
|
|
352
|
+
params_template: {
|
|
353
|
+
findings: '{{research_findings}}',
|
|
354
|
+
instruction: 'Synthesize findings into a concise answer',
|
|
355
|
+
},
|
|
356
|
+
outputs: ['answer'],
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
step_id: 'format-output',
|
|
360
|
+
type: 'write',
|
|
361
|
+
params_template: {
|
|
362
|
+
content: '{{answer}}',
|
|
363
|
+
format: 'research_summary',
|
|
364
|
+
},
|
|
365
|
+
outputs: ['final_answer'],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
checks: [
|
|
369
|
+
{
|
|
370
|
+
check_id: 'source-quality',
|
|
371
|
+
type: 'facts',
|
|
372
|
+
condition: 'Answer is supported by credible sources',
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
check_id: 'completeness',
|
|
376
|
+
type: 'taste',
|
|
377
|
+
condition: 'Answer addresses the original question fully',
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
stop_conditions: [
|
|
381
|
+
{
|
|
382
|
+
condition: 'No relevant sources found',
|
|
383
|
+
reason: 'Cannot answer without credible sources',
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
escalations: [],
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
playbook: {
|
|
391
|
+
schema_version: 'playbook.v1',
|
|
392
|
+
id: 'deep-dive-analysis',
|
|
393
|
+
name: 'Deep Dive Analysis',
|
|
394
|
+
description: 'Multi-source research: plan scope, gather sources, cross-reference, synthesize, and review.',
|
|
395
|
+
triggers: [{ type: 'manual' }],
|
|
396
|
+
inputs: [
|
|
397
|
+
{ name: 'topic', type: 'string', required: true, description: 'Research topic' },
|
|
398
|
+
{ name: 'scope', type: 'string', required: false, description: 'Research scope and boundaries' },
|
|
399
|
+
{ name: 'output_format', type: 'string', required: false, description: 'Desired output format' },
|
|
400
|
+
],
|
|
401
|
+
steps: [
|
|
402
|
+
{
|
|
403
|
+
step_id: 'plan-scope',
|
|
404
|
+
type: 'think',
|
|
405
|
+
params_template: {
|
|
406
|
+
topic: '{{topic}}',
|
|
407
|
+
instruction: 'Define research scope, key questions, and source strategy',
|
|
408
|
+
},
|
|
409
|
+
outputs: ['research_plan'],
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
step_id: 'gather-sources',
|
|
413
|
+
type: 'tool',
|
|
414
|
+
tool_ref: 'skill:web-research',
|
|
415
|
+
params_template: {
|
|
416
|
+
topic: '{{topic}}',
|
|
417
|
+
scope: 'broad',
|
|
418
|
+
max_sources: 15,
|
|
419
|
+
},
|
|
420
|
+
outputs: ['raw_findings'],
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
step_id: 'cross-reference',
|
|
424
|
+
type: 'think',
|
|
425
|
+
params_template: {
|
|
426
|
+
findings: '{{raw_findings}}',
|
|
427
|
+
instruction: 'Cross-reference findings, identify consensus and conflicts',
|
|
428
|
+
},
|
|
429
|
+
outputs: ['verified_findings'],
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
step_id: 'synthesize',
|
|
433
|
+
type: 'think',
|
|
434
|
+
params_template: {
|
|
435
|
+
findings: '{{verified_findings}}',
|
|
436
|
+
plan: '{{research_plan}}',
|
|
437
|
+
instruction: 'Synthesize into structured analysis with citations',
|
|
438
|
+
},
|
|
439
|
+
outputs: ['analysis'],
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
step_id: 'review',
|
|
443
|
+
type: 'approval_gate',
|
|
444
|
+
params_template: {
|
|
445
|
+
message: 'Review the research analysis. Approve or request deeper investigation.',
|
|
446
|
+
analysis: '{{analysis}}',
|
|
447
|
+
},
|
|
448
|
+
outputs: ['approved_analysis'],
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
step_id: 'finalize',
|
|
452
|
+
type: 'write',
|
|
453
|
+
params_template: {
|
|
454
|
+
content: '{{approved_analysis}}',
|
|
455
|
+
format: '{{output_format || "detailed_report"}}',
|
|
456
|
+
},
|
|
457
|
+
outputs: ['final_report'],
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
checks: [
|
|
461
|
+
{
|
|
462
|
+
check_id: 'multi-source',
|
|
463
|
+
type: 'facts',
|
|
464
|
+
condition: 'Key claims supported by multiple independent sources',
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
check_id: 'bias-check',
|
|
468
|
+
type: 'taste',
|
|
469
|
+
condition: 'Analysis presents balanced perspectives where applicable',
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
check_id: 'citation-quality',
|
|
473
|
+
type: 'format',
|
|
474
|
+
condition: 'All claims properly cited per user citation standards',
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
stop_conditions: [
|
|
478
|
+
{
|
|
479
|
+
condition: 'Insufficient credible sources on the topic',
|
|
480
|
+
reason: 'Cannot produce reliable analysis without adequate sourcing',
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
escalations: [
|
|
484
|
+
{
|
|
485
|
+
escalation_id: 'sensitive-research',
|
|
486
|
+
trigger: 'Research involves confidential, proprietary, or ethically sensitive data',
|
|
487
|
+
approval_ref: 'guardrails.approval_rules.research_ethics',
|
|
488
|
+
},
|
|
489
|
+
],
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
];
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Sales agent playbooks — workflows for lead management and deal progression.
|
|
496
|
+
*/
|
|
497
|
+
function getSalesAgentPlaybooks() {
|
|
498
|
+
return [
|
|
499
|
+
{
|
|
500
|
+
playbook: {
|
|
501
|
+
schema_version: 'playbook.v1',
|
|
502
|
+
id: 'lead-outreach',
|
|
503
|
+
name: 'Lead Outreach',
|
|
504
|
+
description: 'Initial outreach to a new lead: research, qualify, draft email, review, send.',
|
|
505
|
+
triggers: [{ type: 'manual' }],
|
|
506
|
+
inputs: [
|
|
507
|
+
{ name: 'lead_data', type: 'string', required: true, description: 'Lead information (name, company, role, context)' },
|
|
508
|
+
{ name: 'outreach_type', type: 'string', required: false, description: 'Type of outreach (cold, warm, referral)' },
|
|
509
|
+
],
|
|
510
|
+
steps: [
|
|
511
|
+
{
|
|
512
|
+
step_id: 'qualify-lead',
|
|
513
|
+
type: 'tool',
|
|
514
|
+
tool_ref: 'skill:lead-qualification',
|
|
515
|
+
params_template: {
|
|
516
|
+
lead_data: '{{lead_data}}',
|
|
517
|
+
},
|
|
518
|
+
outputs: ['qualification'],
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
step_id: 'assess-fit',
|
|
522
|
+
type: 'think',
|
|
523
|
+
params_template: {
|
|
524
|
+
qualification: '{{qualification}}',
|
|
525
|
+
instruction: 'Determine if lead is worth pursuing and best approach',
|
|
526
|
+
},
|
|
527
|
+
outputs: ['approach_decision'],
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
step_id: 'draft-email',
|
|
531
|
+
type: 'tool',
|
|
532
|
+
tool_ref: 'skill:outreach-email',
|
|
533
|
+
params_template: {
|
|
534
|
+
recipient: '{{lead_data}}',
|
|
535
|
+
purpose: '{{outreach_type || "cold_outreach"}}',
|
|
536
|
+
context: '{{approach_decision}}',
|
|
537
|
+
sequence_position: 1,
|
|
538
|
+
},
|
|
539
|
+
outputs: ['draft_email'],
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
step_id: 'review-email',
|
|
543
|
+
type: 'approval_gate',
|
|
544
|
+
params_template: {
|
|
545
|
+
message: 'Review outreach email before sending.',
|
|
546
|
+
email: '{{draft_email}}',
|
|
547
|
+
qualification: '{{qualification}}',
|
|
548
|
+
},
|
|
549
|
+
outputs: ['approved_email'],
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
step_id: 'send',
|
|
553
|
+
type: 'tool',
|
|
554
|
+
tool_ref: 'email-sender',
|
|
555
|
+
params_template: {
|
|
556
|
+
email: '{{approved_email}}',
|
|
557
|
+
},
|
|
558
|
+
outputs: ['send_result'],
|
|
559
|
+
},
|
|
560
|
+
],
|
|
561
|
+
checks: [
|
|
562
|
+
{
|
|
563
|
+
check_id: 'qualification-check',
|
|
564
|
+
type: 'taste',
|
|
565
|
+
condition: 'Lead meets minimum qualification criteria before outreach',
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
check_id: 'compliance-check',
|
|
569
|
+
type: 'safety',
|
|
570
|
+
condition: 'Email complies with CAN-SPAM/GDPR regulations',
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
check_id: 'tone-check',
|
|
574
|
+
type: 'taste',
|
|
575
|
+
condition: 'Email matches sales communication style from constitution',
|
|
576
|
+
},
|
|
577
|
+
],
|
|
578
|
+
stop_conditions: [
|
|
579
|
+
{
|
|
580
|
+
condition: 'Lead scores D or is disqualified',
|
|
581
|
+
reason: 'Lead does not meet minimum qualification criteria',
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
escalations: [
|
|
585
|
+
{
|
|
586
|
+
escalation_id: 'high-value-lead',
|
|
587
|
+
trigger: 'Lead is enterprise-tier or strategic account',
|
|
588
|
+
approval_ref: 'guardrails.approval_rules.strategic_outreach',
|
|
589
|
+
},
|
|
590
|
+
],
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
playbook: {
|
|
595
|
+
schema_version: 'playbook.v1',
|
|
596
|
+
id: 'proposal-workflow',
|
|
597
|
+
name: 'Proposal Workflow',
|
|
598
|
+
description: 'Create and deliver a sales proposal: gather requirements, draft, review, deliver.',
|
|
599
|
+
triggers: [{ type: 'manual' }],
|
|
600
|
+
inputs: [
|
|
601
|
+
{ name: 'prospect', type: 'string', required: true, description: 'Prospect information and deal context' },
|
|
602
|
+
{ name: 'requirements', type: 'string', required: true, description: 'Gathered requirements and pain points' },
|
|
603
|
+
{ name: 'proposal_format', type: 'string', required: false, description: 'Desired format (doc, deck, email)' },
|
|
604
|
+
],
|
|
605
|
+
steps: [
|
|
606
|
+
{
|
|
607
|
+
step_id: 'analyze-requirements',
|
|
608
|
+
type: 'think',
|
|
609
|
+
params_template: {
|
|
610
|
+
prospect: '{{prospect}}',
|
|
611
|
+
requirements: '{{requirements}}',
|
|
612
|
+
instruction: 'Analyze requirements and map to solution components',
|
|
613
|
+
},
|
|
614
|
+
outputs: ['solution_mapping'],
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
step_id: 'draft-proposal',
|
|
618
|
+
type: 'write',
|
|
619
|
+
params_template: {
|
|
620
|
+
content: '{{solution_mapping}}',
|
|
621
|
+
format: '{{proposal_format || "detailed_document"}}',
|
|
622
|
+
},
|
|
623
|
+
outputs: ['draft_proposal'],
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
step_id: 'review-proposal',
|
|
627
|
+
type: 'approval_gate',
|
|
628
|
+
params_template: {
|
|
629
|
+
message: 'Review proposal before delivering to prospect.',
|
|
630
|
+
proposal: '{{draft_proposal}}',
|
|
631
|
+
context: '{{requirements}}',
|
|
632
|
+
},
|
|
633
|
+
outputs: ['approved_proposal'],
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
step_id: 'deliver',
|
|
637
|
+
type: 'write',
|
|
638
|
+
params_template: {
|
|
639
|
+
content: '{{approved_proposal}}',
|
|
640
|
+
format: 'final_proposal',
|
|
641
|
+
},
|
|
642
|
+
outputs: ['delivered_proposal'],
|
|
643
|
+
},
|
|
644
|
+
],
|
|
645
|
+
checks: [
|
|
646
|
+
{
|
|
647
|
+
check_id: 'requirements-coverage',
|
|
648
|
+
type: 'taste',
|
|
649
|
+
condition: 'Proposal addresses all stated requirements',
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
check_id: 'pricing-check',
|
|
653
|
+
type: 'safety',
|
|
654
|
+
condition: 'Pricing is within approved ranges and discount policies',
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
check_id: 'brand-consistency',
|
|
658
|
+
type: 'format',
|
|
659
|
+
condition: 'Proposal follows brand guidelines and formatting standards',
|
|
660
|
+
},
|
|
661
|
+
],
|
|
662
|
+
stop_conditions: [
|
|
663
|
+
{
|
|
664
|
+
condition: 'Requirements are unclear or contradictory',
|
|
665
|
+
reason: 'Cannot create proposal without clear requirements',
|
|
666
|
+
},
|
|
667
|
+
],
|
|
668
|
+
escalations: [
|
|
669
|
+
{
|
|
670
|
+
escalation_id: 'custom-pricing',
|
|
671
|
+
trigger: 'Proposal requires pricing outside standard range',
|
|
672
|
+
approval_ref: 'guardrails.approval_rules.pricing_override',
|
|
673
|
+
},
|
|
674
|
+
],
|
|
675
|
+
},
|
|
676
|
+
},
|
|
677
|
+
];
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Support agent playbooks — workflows for customer support and ticket resolution.
|
|
681
|
+
*/
|
|
682
|
+
function getSupportAgentPlaybooks() {
|
|
683
|
+
return [
|
|
684
|
+
{
|
|
685
|
+
playbook: {
|
|
686
|
+
schema_version: 'playbook.v1',
|
|
687
|
+
id: 'standard-ticket',
|
|
688
|
+
name: 'Standard Ticket Resolution',
|
|
689
|
+
description: 'Standard ticket flow: triage, research, draft response, review, send.',
|
|
690
|
+
triggers: [
|
|
691
|
+
{ type: 'manual' },
|
|
692
|
+
{ type: 'event', event_pattern: 'ticket.created' },
|
|
693
|
+
],
|
|
694
|
+
inputs: [
|
|
695
|
+
{ name: 'ticket', type: 'string', required: true, description: 'Ticket content and customer info' },
|
|
696
|
+
{ name: 'channel', type: 'string', required: false, description: 'Support channel (email, chat, etc.)' },
|
|
697
|
+
],
|
|
698
|
+
steps: [
|
|
699
|
+
{
|
|
700
|
+
step_id: 'triage',
|
|
701
|
+
type: 'tool',
|
|
702
|
+
tool_ref: 'skill:ticket-triage',
|
|
703
|
+
params_template: {
|
|
704
|
+
ticket: '{{ticket}}',
|
|
705
|
+
},
|
|
706
|
+
outputs: ['triage_result'],
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
step_id: 'research-solution',
|
|
710
|
+
type: 'think',
|
|
711
|
+
params_template: {
|
|
712
|
+
ticket: '{{ticket}}',
|
|
713
|
+
triage: '{{triage_result}}',
|
|
714
|
+
instruction: 'Research the issue and identify the best resolution',
|
|
715
|
+
},
|
|
716
|
+
outputs: ['resolution'],
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
step_id: 'draft-response',
|
|
720
|
+
type: 'tool',
|
|
721
|
+
tool_ref: 'skill:response-draft',
|
|
722
|
+
params_template: {
|
|
723
|
+
ticket: '{{ticket}}',
|
|
724
|
+
channel: '{{channel || "email"}}',
|
|
725
|
+
triage: '{{triage_result}}',
|
|
726
|
+
resolution: '{{resolution}}',
|
|
727
|
+
},
|
|
728
|
+
outputs: ['draft_response'],
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
step_id: 'review',
|
|
732
|
+
type: 'approval_gate',
|
|
733
|
+
params_template: {
|
|
734
|
+
message: 'Review response before sending to customer.',
|
|
735
|
+
response: '{{draft_response}}',
|
|
736
|
+
triage: '{{triage_result}}',
|
|
737
|
+
},
|
|
738
|
+
outputs: ['approved_response'],
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
step_id: 'send',
|
|
742
|
+
type: 'write',
|
|
743
|
+
params_template: {
|
|
744
|
+
content: '{{approved_response}}',
|
|
745
|
+
format: '{{channel}}_response',
|
|
746
|
+
},
|
|
747
|
+
outputs: ['sent_response'],
|
|
748
|
+
},
|
|
749
|
+
],
|
|
750
|
+
checks: [
|
|
751
|
+
{
|
|
752
|
+
check_id: 'tone-match',
|
|
753
|
+
type: 'taste',
|
|
754
|
+
condition: 'Response matches support tone and empathy requirements',
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
check_id: 'resolution-quality',
|
|
758
|
+
type: 'taste',
|
|
759
|
+
condition: 'Response actually resolves the issue or clearly explains next steps',
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
check_id: 'channel-format',
|
|
763
|
+
type: 'format',
|
|
764
|
+
condition: 'Response is appropriate for the support channel',
|
|
765
|
+
},
|
|
766
|
+
],
|
|
767
|
+
stop_conditions: [
|
|
768
|
+
{
|
|
769
|
+
condition: 'Ticket requires escalation based on triage',
|
|
770
|
+
reason: 'Issue is beyond agent capability or requires human intervention',
|
|
771
|
+
},
|
|
772
|
+
],
|
|
773
|
+
escalations: [
|
|
774
|
+
{
|
|
775
|
+
escalation_id: 'angry-customer',
|
|
776
|
+
trigger: 'Customer sentiment is very negative or threatening',
|
|
777
|
+
approval_ref: 'guardrails.approval_rules.escalation',
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
escalation_id: 'billing-dispute',
|
|
781
|
+
trigger: 'Ticket involves billing, refunds, or financial matters',
|
|
782
|
+
approval_ref: 'guardrails.approval_rules.financial',
|
|
783
|
+
},
|
|
784
|
+
],
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
playbook: {
|
|
789
|
+
schema_version: 'playbook.v1',
|
|
790
|
+
id: 'escalation-workflow',
|
|
791
|
+
name: 'Escalation Workflow',
|
|
792
|
+
description: 'Escalation flow: assess severity, gather context, create escalation package, hand off.',
|
|
793
|
+
triggers: [{ type: 'manual' }],
|
|
794
|
+
inputs: [
|
|
795
|
+
{ name: 'ticket', type: 'string', required: true, description: 'Ticket requiring escalation' },
|
|
796
|
+
{ name: 'reason', type: 'string', required: true, description: 'Reason for escalation' },
|
|
797
|
+
{ name: 'target_team', type: 'string', required: false, description: 'Target team for escalation' },
|
|
798
|
+
],
|
|
799
|
+
steps: [
|
|
800
|
+
{
|
|
801
|
+
step_id: 'assess-severity',
|
|
802
|
+
type: 'think',
|
|
803
|
+
params_template: {
|
|
804
|
+
ticket: '{{ticket}}',
|
|
805
|
+
reason: '{{reason}}',
|
|
806
|
+
instruction: 'Assess severity and determine appropriate escalation level',
|
|
807
|
+
},
|
|
808
|
+
outputs: ['severity_assessment'],
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
step_id: 'gather-context',
|
|
812
|
+
type: 'think',
|
|
813
|
+
params_template: {
|
|
814
|
+
ticket: '{{ticket}}',
|
|
815
|
+
assessment: '{{severity_assessment}}',
|
|
816
|
+
instruction: 'Compile all relevant context, customer history, and attempted resolutions',
|
|
817
|
+
},
|
|
818
|
+
outputs: ['escalation_context'],
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
step_id: 'create-package',
|
|
822
|
+
type: 'write',
|
|
823
|
+
params_template: {
|
|
824
|
+
content: '{{escalation_context}}',
|
|
825
|
+
format: 'escalation_package',
|
|
826
|
+
},
|
|
827
|
+
outputs: ['escalation_package'],
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
step_id: 'notify-customer',
|
|
831
|
+
type: 'tool',
|
|
832
|
+
tool_ref: 'skill:response-draft',
|
|
833
|
+
params_template: {
|
|
834
|
+
ticket: '{{ticket}}',
|
|
835
|
+
channel: 'email',
|
|
836
|
+
resolution: 'escalation_notification',
|
|
837
|
+
},
|
|
838
|
+
outputs: ['customer_notification'],
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
step_id: 'approve-handoff',
|
|
842
|
+
type: 'approval_gate',
|
|
843
|
+
params_template: {
|
|
844
|
+
message: 'Review escalation package and customer notification before handoff.',
|
|
845
|
+
package: '{{escalation_package}}',
|
|
846
|
+
notification: '{{customer_notification}}',
|
|
847
|
+
},
|
|
848
|
+
outputs: ['approved_handoff'],
|
|
849
|
+
},
|
|
850
|
+
],
|
|
851
|
+
checks: [
|
|
852
|
+
{
|
|
853
|
+
check_id: 'context-completeness',
|
|
854
|
+
type: 'taste',
|
|
855
|
+
condition: 'Escalation package includes all relevant context and attempted resolutions',
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
check_id: 'customer-communication',
|
|
859
|
+
type: 'taste',
|
|
860
|
+
condition: 'Customer is notified about the escalation with appropriate empathy',
|
|
861
|
+
},
|
|
862
|
+
],
|
|
863
|
+
stop_conditions: [
|
|
864
|
+
{
|
|
865
|
+
condition: 'Issue is resolved during escalation preparation',
|
|
866
|
+
reason: 'Resolution found, escalation no longer needed',
|
|
867
|
+
},
|
|
868
|
+
],
|
|
869
|
+
escalations: [
|
|
870
|
+
{
|
|
871
|
+
escalation_id: 'critical-severity',
|
|
872
|
+
trigger: 'Severity is critical (data loss, security breach, complete outage)',
|
|
873
|
+
approval_ref: 'guardrails.approval_rules.critical_escalation',
|
|
874
|
+
},
|
|
875
|
+
],
|
|
876
|
+
},
|
|
877
|
+
},
|
|
878
|
+
];
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* General agent playbooks — reusable workflows for broad, mixed workloads.
|
|
882
|
+
*/
|
|
883
|
+
function getGeneralAgentPlaybooks() {
|
|
884
|
+
return [
|
|
885
|
+
{
|
|
886
|
+
playbook: {
|
|
887
|
+
schema_version: 'playbook.v1',
|
|
888
|
+
id: 'general-task-execution',
|
|
889
|
+
name: 'General Task Execution',
|
|
890
|
+
description: 'Synthesize context, orchestrate execution, and close with a concise delivery summary.',
|
|
891
|
+
triggers: [{ type: 'manual' }],
|
|
892
|
+
inputs: [
|
|
893
|
+
{ name: 'goal', type: 'string', required: true, description: 'Desired outcome to achieve' },
|
|
894
|
+
{ name: 'context_sources', type: 'string', required: false, description: 'Relevant files/notes/links to ground the task' },
|
|
895
|
+
{ name: 'constraints', type: 'string', required: false, description: 'Policy, timeline, budget, or tooling constraints' },
|
|
896
|
+
],
|
|
897
|
+
steps: [
|
|
898
|
+
{
|
|
899
|
+
step_id: 'synthesize-context',
|
|
900
|
+
type: 'tool',
|
|
901
|
+
tool_ref: 'skill:context-synthesis',
|
|
902
|
+
params_template: {
|
|
903
|
+
question: '{{goal}}',
|
|
904
|
+
sources: '{{context_sources}}',
|
|
905
|
+
},
|
|
906
|
+
outputs: ['context_brief'],
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
step_id: 'plan-work',
|
|
910
|
+
type: 'think',
|
|
911
|
+
params_template: {
|
|
912
|
+
goal: '{{goal}}',
|
|
913
|
+
constraints: '{{constraints}}',
|
|
914
|
+
context: '{{context_brief}}',
|
|
915
|
+
},
|
|
916
|
+
outputs: ['execution_plan'],
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
step_id: 'execute-work',
|
|
920
|
+
type: 'tool',
|
|
921
|
+
tool_ref: 'skill:task-orchestration',
|
|
922
|
+
params_template: {
|
|
923
|
+
goal: '{{goal}}',
|
|
924
|
+
constraints: '{{constraints}}',
|
|
925
|
+
context_snapshot: '{{context_brief}}',
|
|
926
|
+
},
|
|
927
|
+
outputs: ['execution_result'],
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
step_id: 'approval-checkpoint',
|
|
931
|
+
type: 'approval_gate',
|
|
932
|
+
params_template: {
|
|
933
|
+
message: 'Review execution summary before final delivery.',
|
|
934
|
+
summary: '{{execution_result}}',
|
|
935
|
+
},
|
|
936
|
+
outputs: ['approved_result'],
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
step_id: 'finalize',
|
|
940
|
+
type: 'write',
|
|
941
|
+
params_template: {
|
|
942
|
+
content: '{{approved_result}}',
|
|
943
|
+
format: 'operator_summary',
|
|
944
|
+
},
|
|
945
|
+
outputs: ['final_output'],
|
|
946
|
+
},
|
|
947
|
+
],
|
|
948
|
+
checks: [
|
|
949
|
+
{
|
|
950
|
+
check_id: 'goal-alignment',
|
|
951
|
+
type: 'taste',
|
|
952
|
+
condition: 'Execution result directly addresses the user goal and operating principles',
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
check_id: 'risk-compliance',
|
|
956
|
+
type: 'safety',
|
|
957
|
+
condition: 'No taboo or high-risk action was executed without required escalation',
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
check_id: 'evidence-quality',
|
|
961
|
+
type: 'facts',
|
|
962
|
+
condition: 'Claims in the final output reflect context synthesis confidence and citation expectations',
|
|
963
|
+
},
|
|
964
|
+
],
|
|
965
|
+
stop_conditions: [
|
|
966
|
+
{
|
|
967
|
+
condition: 'Critical context gaps remain unresolved after synthesis',
|
|
968
|
+
reason: 'Cannot continue safely without additional user input',
|
|
969
|
+
},
|
|
970
|
+
],
|
|
971
|
+
escalations: [
|
|
972
|
+
{
|
|
973
|
+
escalation_id: 'high-risk-action',
|
|
974
|
+
trigger: 'Execution requires destructive, irreversible, legal, or financial actions',
|
|
975
|
+
approval_ref: 'guardrails.approval_rules.approve_high_risk',
|
|
976
|
+
},
|
|
977
|
+
],
|
|
978
|
+
},
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
playbook: {
|
|
982
|
+
schema_version: 'playbook.v1',
|
|
983
|
+
id: 'research-then-act',
|
|
984
|
+
name: 'Research Then Act',
|
|
985
|
+
description: 'Gather context, choose an execution path, and deliver an evidence-backed recommendation or action plan.',
|
|
986
|
+
triggers: [{ type: 'manual' }],
|
|
987
|
+
inputs: [
|
|
988
|
+
{ name: 'question', type: 'string', required: true, description: 'Decision or task question to resolve' },
|
|
989
|
+
{ name: 'sources', type: 'string', required: false, description: 'Optional initial sources to bootstrap synthesis' },
|
|
990
|
+
{ name: 'decision_deadline', type: 'string', required: false, description: 'Optional timing constraint for recommendation' },
|
|
991
|
+
],
|
|
992
|
+
steps: [
|
|
993
|
+
{
|
|
994
|
+
step_id: 'capture-context',
|
|
995
|
+
type: 'tool',
|
|
996
|
+
tool_ref: 'skill:context-synthesis',
|
|
997
|
+
params_template: {
|
|
998
|
+
question: '{{question}}',
|
|
999
|
+
sources: '{{sources}}',
|
|
1000
|
+
},
|
|
1001
|
+
outputs: ['brief', 'confidence_map', 'open_questions'],
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
step_id: 'select-path',
|
|
1005
|
+
type: 'think',
|
|
1006
|
+
params_template: {
|
|
1007
|
+
brief: '{{brief}}',
|
|
1008
|
+
confidence_map: '{{confidence_map}}',
|
|
1009
|
+
deadline: '{{decision_deadline}}',
|
|
1010
|
+
instruction: 'Select a recommended path with two alternatives and explicit tradeoffs.',
|
|
1011
|
+
},
|
|
1012
|
+
outputs: ['recommended_path'],
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
step_id: 'execute-path',
|
|
1016
|
+
type: 'tool',
|
|
1017
|
+
tool_ref: 'skill:task-orchestration',
|
|
1018
|
+
params_template: {
|
|
1019
|
+
goal: '{{question}}',
|
|
1020
|
+
context_snapshot: '{{brief}}',
|
|
1021
|
+
constraints: '{{decision_deadline}}',
|
|
1022
|
+
},
|
|
1023
|
+
outputs: ['path_result'],
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
step_id: 'deliver',
|
|
1027
|
+
type: 'write',
|
|
1028
|
+
params_template: {
|
|
1029
|
+
content: '{{path_result}}',
|
|
1030
|
+
include: ['recommended_path', 'confidence_map', 'open_questions'],
|
|
1031
|
+
},
|
|
1032
|
+
outputs: ['delivery_packet'],
|
|
1033
|
+
},
|
|
1034
|
+
],
|
|
1035
|
+
checks: [
|
|
1036
|
+
{
|
|
1037
|
+
check_id: 'traceability',
|
|
1038
|
+
type: 'facts',
|
|
1039
|
+
condition: 'Recommendation and actions are traceable to synthesized context and confidence markers',
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
check_id: 'format-quality',
|
|
1043
|
+
type: 'format',
|
|
1044
|
+
condition: 'Delivery packet clearly separates facts, assumptions, risks, and next actions',
|
|
1045
|
+
},
|
|
1046
|
+
],
|
|
1047
|
+
stop_conditions: [
|
|
1048
|
+
{
|
|
1049
|
+
condition: 'No viable path can be recommended from available evidence',
|
|
1050
|
+
reason: 'Insufficient confidence to proceed responsibly',
|
|
1051
|
+
},
|
|
1052
|
+
],
|
|
1053
|
+
escalations: [
|
|
1054
|
+
{
|
|
1055
|
+
escalation_id: 'policy-or-risk-blocker',
|
|
1056
|
+
trigger: 'Recommended path conflicts with trust/guardrail policy or crosses high-risk thresholds',
|
|
1057
|
+
approval_ref: 'guardrails.approval_rules.approve_high_risk',
|
|
1058
|
+
},
|
|
1059
|
+
],
|
|
1060
|
+
},
|
|
1061
|
+
},
|
|
1062
|
+
];
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Generate a generic playbook when no domain playbooks are available.
|
|
1066
|
+
* Uses constitution data to personalize the workflow.
|
|
1067
|
+
*/
|
|
1068
|
+
function generateGenericPlaybook(constitution) {
|
|
1069
|
+
const autonomyLevel = constitution.tradeoffs.autonomy_level;
|
|
1070
|
+
// If low autonomy, always include approval gate
|
|
1071
|
+
const approvalStep = autonomyLevel < 0.5;
|
|
1072
|
+
const steps = [
|
|
1073
|
+
{
|
|
1074
|
+
step_id: 'understand-task',
|
|
1075
|
+
type: 'think',
|
|
1076
|
+
outputs: ['task_analysis'],
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
step_id: 'execute-task',
|
|
1080
|
+
type: 'tool',
|
|
1081
|
+
params_template: {
|
|
1082
|
+
instruction: 'Execute the task based on analysis',
|
|
1083
|
+
},
|
|
1084
|
+
outputs: ['task_result'],
|
|
1085
|
+
},
|
|
1086
|
+
];
|
|
1087
|
+
if (approvalStep) {
|
|
1088
|
+
steps.push({
|
|
1089
|
+
step_id: 'review-result',
|
|
1090
|
+
type: 'approval_gate',
|
|
1091
|
+
params_template: {
|
|
1092
|
+
message: 'Review the result before finalizing.',
|
|
1093
|
+
},
|
|
1094
|
+
outputs: ['approved_result'],
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
steps.push({
|
|
1098
|
+
step_id: 'finalize',
|
|
1099
|
+
type: 'write',
|
|
1100
|
+
params_template: {
|
|
1101
|
+
content: approvalStep ? '{{approved_result}}' : '{{task_result}}',
|
|
1102
|
+
},
|
|
1103
|
+
outputs: ['final_output'],
|
|
1104
|
+
});
|
|
1105
|
+
return {
|
|
1106
|
+
schema_version: 'playbook.v1',
|
|
1107
|
+
id: 'general-task',
|
|
1108
|
+
name: 'General Task Execution',
|
|
1109
|
+
description: 'Generic task workflow that follows user principles and tone preferences.',
|
|
1110
|
+
triggers: [{ type: 'manual' }],
|
|
1111
|
+
inputs: [
|
|
1112
|
+
{ name: 'task', type: 'string', required: true, description: 'The task to perform' },
|
|
1113
|
+
{ name: 'context', type: 'string', required: false, description: 'Additional context' },
|
|
1114
|
+
],
|
|
1115
|
+
steps,
|
|
1116
|
+
checks: [
|
|
1117
|
+
{
|
|
1118
|
+
check_id: 'principles-check',
|
|
1119
|
+
type: 'taste',
|
|
1120
|
+
condition: 'Output follows user constitution principles',
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
check_id: 'safety-check',
|
|
1124
|
+
type: 'safety',
|
|
1125
|
+
condition: 'No taboo actions taken, escalation rules respected',
|
|
1126
|
+
},
|
|
1127
|
+
],
|
|
1128
|
+
stop_conditions: [
|
|
1129
|
+
{
|
|
1130
|
+
condition: 'Task cannot be completed with available tools',
|
|
1131
|
+
reason: 'Required capabilities not available',
|
|
1132
|
+
},
|
|
1133
|
+
],
|
|
1134
|
+
escalations: [
|
|
1135
|
+
{
|
|
1136
|
+
escalation_id: 'irreversible-action',
|
|
1137
|
+
trigger: 'Task involves irreversible actions (delete, publish, send)',
|
|
1138
|
+
approval_ref: 'guardrails.approval_rules.irreversible',
|
|
1139
|
+
},
|
|
1140
|
+
],
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
//# sourceMappingURL=playbook-compiler.js.map
|