/** * --describe for a service package. Prints the manifest as JSON. The `kind: * "service"` marker tells the CLI to register a dependency service_specification * (with use_default_actions) instead of a scope + scope type. */ import { resolveAgentConfig } from "../scope"; import type { ServiceDefinition } from "./index"; export function handleServiceDescribe(definition: ServiceDefinition): void { // Only CUSTOM actions are described — the platform generates create/update/ // delete when useDefaultActions is on, so we don't ship specs for them. const defaultTypes = new Set(["create", "update", "delete"]); const actionSpecs: Record = {}; for (const [slug, action] of Object.entries(definition.actions)) { if (definition.useDefaultActions !== false && defaultTypes.has(slug)) continue; actionSpecs[slug] = { name: action.name ?? slug, type: action.type ?? "custom", retryable: action.retryable ?? false, lifecycle: true, input: action.input, output: action.output, }; } const output = { kind: "service", name: definition.name, version: definition.version, description: definition.description, category: definition.category, provider: definition.provider, schema: definition.schema, uiSchema: definition.uiSchema, useDefaultActions: definition.useDefaultActions ?? true, assignableTo: definition.assignableTo ?? "any", actions: actionSpecs, agent: resolveAgentConfig(definition as any), }; console.log(JSON.stringify(JSON.parse(JSON.stringify(output)), null, 2)); }