external-agent-helpers.mjs
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
15 hours ago
| 1 | /** |
| 2 | * Shared helpers for Flow external-agent tiers (7A-L2b). |
| 3 | */ |
| 4 | import fs from 'node:fs'; |
| 5 | import path from 'node:path'; |
| 6 | |
| 7 | import { buildFlowStepId } from '../../../lib/flow/flow-store.mjs'; |
| 8 | import { FLOW_EXTERNAL_AGENT_POLICY_FILE } from '../../../lib/flow/external-agent.mjs'; |
| 9 | |
| 10 | /** |
| 11 | * @param {string} dataDir |
| 12 | * @param {string[]} [allowedTools] |
| 13 | */ |
| 14 | export function writeExternalAgentPolicy(dataDir, allowedTools = ['web_search']) { |
| 15 | const fp = path.join(dataDir, FLOW_EXTERNAL_AGENT_POLICY_FILE); |
| 16 | fs.writeFileSync( |
| 17 | fp, |
| 18 | JSON.stringify({ |
| 19 | external_agent: { |
| 20 | enabled: true, |
| 21 | hosted_projection_enabled: true, |
| 22 | allowed_tools: allowedTools.map((id) => ({ id, description: id })), |
| 23 | default_ttl_seconds: 3600, |
| 24 | max_ttl_seconds: 86400, |
| 25 | import_policy: 'reject', |
| 26 | }, |
| 27 | }), |
| 28 | 'utf8', |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @param {{ flowId?: string, toolId?: string, scope?: string, version?: string }} [opts] |
| 34 | */ |
| 35 | export function makeExternalToolFlowBundle(opts = {}) { |
| 36 | const flowId = opts.flowId ?? 'flow_ext_agent_test'; |
| 37 | const toolId = opts.toolId ?? 'web_search'; |
| 38 | const scope = opts.scope ?? 'personal'; |
| 39 | const version = opts.version ?? '1.0.0'; |
| 40 | const stepId = buildFlowStepId(flowId, 1); |
| 41 | return { |
| 42 | flow: { |
| 43 | schema: 'knowtation.flow/v0', |
| 44 | flow_id: flowId, |
| 45 | title: 'External agent test flow', |
| 46 | version, |
| 47 | scope, |
| 48 | summary: 'Flow with external_tool ref for grant tests.', |
| 49 | tags: ['test'], |
| 50 | steps: [stepId], |
| 51 | inputs: [], |
| 52 | vault_mirror_path: `meta/flows/${flowId.replace(/^flow_/, '')}.md`, |
| 53 | updated: '2026-06-20T00:00:00Z', |
| 54 | truncated: false, |
| 55 | }, |
| 56 | steps: [ |
| 57 | { |
| 58 | schema: 'knowtation.flow_step/v0', |
| 59 | step_id: stepId, |
| 60 | flow_id: flowId, |
| 61 | ordinal: 1, |
| 62 | owned_job: 'Search the web', |
| 63 | instruction: 'Use the scoped web search tool when needed.', |
| 64 | trigger: 'On request', |
| 65 | when_not_to_run: 'When offline', |
| 66 | boundaries: ['Read only'], |
| 67 | skill_refs: [{ kind: 'external_tool', id: toolId }], |
| 68 | output_shape: 'Search summary', |
| 69 | verification: { |
| 70 | kind: 'human_review', |
| 71 | evidence_required: true, |
| 72 | description: 'Human checks results', |
| 73 | }, |
| 74 | automatable: 'manual', |
| 75 | }, |
| 76 | ], |
| 77 | }; |
| 78 | } |
File History
1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
15 hours ago