From bf2bb3d87a6101a7324a58bf3ca9b71b0eb657c2 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 25 Aug 2026 14:19:29 +0800 Subject: [PATCH] Add embedded OpenAPI specification exporter subcommand --- dist/mcp/server.js | 3361 +++++++++++++++++++++++++++++ dist/openapi.json | 2 +- openapi/openapi.yaml | 2 +- src/cli.test.ts | 9 + src/cli/commands/openapi.ts | 8 + src/cli/printer.ts | 1 + src/cli/runner.ts | 7 + src/core/embedded-openapi.test.ts | 12 + src/core/embedded-openapi.ts | 5 + 9 files changed, 3405 insertions(+), 2 deletions(-) create mode 100644 src/cli/commands/openapi.ts create mode 100644 src/core/embedded-openapi.test.ts create mode 100644 src/core/embedded-openapi.ts diff --git a/dist/mcp/server.js b/dist/mcp/server.js index 9223fd5..6a057dd 100644 --- a/dist/mcp/server.js +++ b/dist/mcp/server.js @@ -28740,6 +28740,7 @@ Usage: seal-home skill dump seal-home skill install [--dir |--local] seal-home skill status + seal-home openapi seal-home probe [] seal-home config paths seal-home config get @@ -29550,6 +29551,3361 @@ function printMcpConfig() { } }); } +// dist/openapi.json +var openapi_default = { + openapi: "3.1.0", + info: { + title: "seal-home Wrapped API", + version: "0.7.0", + description: `Planned HTTP contract for the seal-home wrapped backend API. + +These endpoints describe the intended stable API for frontend developers and agents once +the HTTP adapter is implemented. +They are not the raw downstream Seal endpoints. seal-home is responsible for enterprise +selection, source authentication, response compaction, and diagnostics-friendly fields. +` + }, + servers: [ + { + url: "http://localhost:8787", + description: "Reserved for a future local HTTP adapter; the current service uses MCP stdio." + } + ], + security: [ + { + localSession: [] + } + ], + tags: [ + { + name: "Corps", + description: "Local enterprise configuration selection." + }, + { + name: "Source", + description: "Source-derived Seal enterprise configuration." + }, + { + name: "Auth", + description: "Wrapped authentication diagnostics and current identity." + }, + { + name: "Approval Runs", + description: "Wrapped approval run history, summaries, document URLs, and trace bridge helpers." + }, + { + name: "Approval Knowledge", + description: "Wrapped approval rules, documents, preferences, and search." + }, + { + name: "Simulation", + description: "Wrapped simulation batch record access." + } + ], + paths: { + "/v1/corps": { + get: { + tags: [ + "Corps" + ], + operationId: "listCorps", + summary: "List configured enterprises", + responses: { + "200": { + description: "Configured enterprises.", + content: { + "application/json": { + schema: { + type: "array", + items: { + type: "object", + required: [ + "id", + "name", + "sourceType", + "current" + ], + properties: { + id: { + type: "string" + }, + name: { + type: "string" + }, + sourceType: { + type: "string", + enum: [ + "hose", + "direct", + "seal" + ] + }, + current: { + type: "boolean" + } + } + } + } + } + } + } + } + } + }, + "/v1/corps/current": { + get: { + tags: [ + "Corps" + ], + operationId: "getCurrentCorp", + summary: "Get current enterprise", + description: "Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.", + responses: { + "200": { + description: "Current enterprise.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "id", + "name", + "sourceType", + "current" + ], + properties: { + id: { + type: "string" + }, + name: { + type: "string" + }, + sourceType: { + type: "string", + enum: [ + "hose", + "direct", + "seal" + ] + }, + current: { + type: "boolean" + } + } + } + } + } + } + } + } + }, + "/v1/corps/current/switch": { + post: { + tags: [ + "Corps" + ], + operationId: "switchCurrentCorp", + summary: "Switch current enterprise", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + required: [ + "corpId" + ], + properties: { + corpId: { + type: "string" + } + } + } + } + } + }, + responses: { + "200": { + description: "Switched enterprise.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "current", + "id", + "name" + ], + properties: { + current: { + type: "boolean" + }, + id: { + type: "string" + }, + name: { + type: "string" + } + } + } + } + } + }, + "404": { + description: "Requested resource was not found.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + } + } + } + }, + "/v1/source/config": { + get: { + tags: [ + "Source" + ], + operationId: "getSourceConfig", + summary: "Resolve source-derived Seal enterprise config", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + } + ], + responses: { + "200": { + description: "Redacted Seal enterprise config.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + description: "Redacted Seal enterprise config resolved from the configured source." + } + } + } + }, + "401": { + description: "Local service authentication failed or downstream Seal auth failed.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + } + } + } + }, + "/v1/auth/diagnose": { + get: { + tags: [ + "Auth" + ], + operationId: "diagnoseAuth", + summary: "Diagnose wrapped source-to-Seal authentication", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + } + ], + responses: { + "200": { + description: "Authentication stage diagnosis.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "stages" + ], + properties: { + stages: { + type: "array", + items: { + $ref: "#/components/schemas/AuthStage" + } + } + } + } + } + } + } + } + } + }, + "/v1/whoami": { + get: { + tags: [ + "Auth" + ], + operationId: "whoami", + summary: "Get current wrapped Seal identity", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + } + ], + responses: { + "200": { + description: "Current Seal user and tenant.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "user", + "tenant" + ], + properties: { + user: { + $ref: "#/components/schemas/SealUser" + }, + tenant: { + $ref: "#/components/schemas/SealTenant" + } + } + } + } + } + }, + "401": { + description: "Local service authentication failed or downstream Seal auth failed.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + } + } + } + }, + "/v1/session": { + get: { + tags: [ + "Auth" + ], + operationId: "getSession", + summary: "Get current wrapped Seal session metadata", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + } + ], + responses: { + "200": { + description: "Current session metadata.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "user", + "session" + ], + properties: { + user: { + $ref: "#/components/schemas/SealUser" + }, + session: { + type: "object", + additionalProperties: true + } + } + } + } + } + }, + "401": { + description: "Local service authentication failed or downstream Seal auth failed.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + } + } + } + }, + "/v1/approval/context": { + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "getApprovalContext", + summary: "Get rules, documents, and style preferences together", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "documentLimit", + in: "query", + schema: { + type: "integer", + minimum: 1 + } + }, + { + name: "latestRuleVersion", + in: "query", + schema: { + type: "boolean" + } + }, + { + name: "ruleVersionNumber", + in: "query", + schema: { + type: "integer" + } + } + ], + responses: { + "200": { + description: "Approval context.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "rules", + "documents", + "stylePreferences" + ], + properties: { + rules: {}, + documents: {}, + stylePreferences: {} + } + } + } + } + } + } + } + }, + "/v1/approval/search": { + post: { + tags: [ + "Approval Knowledge" + ], + operationId: "searchApprovalKnowledge", + summary: "Search approval rules, documents, and preferences", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + required: [ + "keywords" + ], + properties: { + keywords: { + type: "array", + minItems: 1, + items: { + type: "string" + } + }, + matchMode: { + type: "string", + enum: [ + "any", + "all" + ] + }, + areas: { + type: "array", + items: { + type: "string", + enum: [ + "rules", + "documents", + "preferences" + ] + } + }, + maxResults: { + type: "integer" + } + } + } + } + } + }, + responses: { + "200": { + description: "Search results with line context.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval/rules": { + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "listApprovalRules", + summary: "List current draft approval rules", + responses: { + "200": { + description: "Draft rules.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "rules" + ], + properties: { + rules: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalRule" + } + }, + hasPendingDeletes: { + type: "boolean" + } + } + } + } + } + } + } + }, + post: { + tags: [ + "Approval Knowledge" + ], + operationId: "createApprovalRule", + summary: "Create draft approval rule", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + required: [ + "description", + "scope", + "strictness" + ], + properties: { + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + } + } + } + } + } + }, + responses: { + "200": { + description: "Created rule.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "id", + "description", + "scope", + "strictness" + ], + properties: { + id: { + type: "string" + }, + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + }, + status: { + type: "string" + } + } + } + } + } + } + } + } + }, + "/v1/approval/rules/{ruleId}": { + parameters: [ + { + name: "ruleId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Approval rule ID." + } + ], + patch: { + tags: [ + "Approval Knowledge" + ], + operationId: "updateApprovalRule", + summary: "Update draft approval rule", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + properties: { + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + } + } + } + } + } + }, + responses: { + "200": { + description: "Updated rule.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "id", + "description", + "scope", + "strictness" + ], + properties: { + id: { + type: "string" + }, + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + }, + status: { + type: "string" + } + } + } + } + } + } + } + }, + delete: { + tags: [ + "Approval Knowledge" + ], + operationId: "deleteApprovalRule", + summary: "Delete draft approval rule", + responses: { + "200": { + description: "Deleted." + } + } + } + }, + "/v1/approval/rule-versions": { + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "listApprovalRuleVersions", + summary: "List published approval rule versions", + responses: { + "200": { + description: "Published rule versions.", + content: { + "application/json": { + schema: { + type: "array", + items: { + type: "object", + additionalProperties: true, + required: [ + "id", + "versionNumber", + "versionName", + "rules" + ], + properties: { + id: { + type: "string" + }, + versionNumber: { + type: "integer" + }, + versionName: { + type: "string" + }, + publishedByName: { + type: "string" + }, + rules: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + } + } + } + }, + "/v1/approval/rule-versions/{versionId}": { + parameters: [ + { + name: "versionId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Published rule version ID." + } + ], + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "getApprovalRuleVersion", + summary: "Get published approval rule version", + responses: { + "200": { + description: "Rule version.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "id", + "versionNumber", + "versionName", + "rules" + ], + properties: { + id: { + type: "string" + }, + versionNumber: { + type: "integer" + }, + versionName: { + type: "string" + }, + publishedByName: { + type: "string" + }, + rules: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + } + } + }, + "/v1/approval/rules/by-version": { + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "getApprovalRuleByVersion", + summary: "Get one wrapped rule from a published version", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "versionNumber", + in: "query", + schema: { + type: "integer" + } + }, + { + name: "versionId", + in: "query", + schema: { + type: "string" + } + }, + { + name: "latest", + in: "query", + schema: { + type: "boolean" + } + }, + { + name: "code", + in: "query", + schema: { + type: "string" + }, + description: "Display rule code such as '#0038'." + }, + { + name: "runtimeId", + in: "query", + schema: { + type: "string" + }, + description: "Runtime rule ID such as rule-205." + }, + { + name: "recordId", + in: "query", + schema: { + type: "string" + }, + description: "Infer versionNumber from an approval run." + } + ], + responses: { + "200": { + description: "One rule from a published version.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval/rule-versions/publish": { + post: { + tags: [ + "Approval Knowledge" + ], + operationId: "publishApprovalRuleVersion", + summary: "Publish current draft rules", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + required: [ + "versionName" + ], + properties: { + versionName: { + type: "string" + } + } + } + } + } + }, + responses: { + "200": { + description: "Published version.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval/documents": { + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "listApprovalDocuments", + summary: "List approval knowledge documents", + parameters: [ + { + name: "offset", + in: "query", + schema: { + type: "integer", + minimum: 0, + default: 0 + }, + description: "Zero-based pagination offset." + }, + { + name: "limit", + in: "query", + schema: { + type: "integer", + minimum: 1, + default: 20 + } + }, + { + name: "scenario", + in: "query", + schema: { + type: "array", + items: { + type: "string" + } + }, + style: "form", + explode: true + } + ], + responses: { + "200": { + description: "Documents.", + content: { + "application/json": { + schema: { + type: "object", + required: [ + "articles" + ], + properties: { + articles: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalDocument" + } + }, + total: { + type: "integer" + } + } + } + } + } + } + } + }, + post: { + tags: [ + "Approval Knowledge" + ], + operationId: "createApprovalDocument", + summary: "Create approval knowledge document", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + required: [ + "title", + "purpose", + "content" + ], + properties: { + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string" + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + } + } + } + }, + responses: { + "200": { + description: "Created document.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "id", + "title", + "content" + ], + properties: { + id: { + type: "string" + }, + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string", + description: "Usually Markdown." + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + enabled: { + type: "boolean" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + } + } + } + } + } + } + }, + "/v1/approval/documents/{documentId}": { + parameters: [ + { + name: "documentId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Approval knowledge document ID." + } + ], + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "getApprovalDocument", + summary: "Get approval knowledge document", + responses: { + "200": { + description: "Document.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "id", + "title", + "content" + ], + properties: { + id: { + type: "string" + }, + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string", + description: "Usually Markdown." + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + enabled: { + type: "boolean" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + } + } + } + } + } + }, + patch: { + tags: [ + "Approval Knowledge" + ], + operationId: "updateApprovalDocument", + summary: "Update approval knowledge document", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + properties: { + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string" + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + enabled: { + type: "boolean" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + } + } + } + }, + responses: { + "200": { + description: "Updated document.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "id", + "title", + "content" + ], + properties: { + id: { + type: "string" + }, + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string", + description: "Usually Markdown." + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + enabled: { + type: "boolean" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + } + } + } + } + } + } + }, + "/v1/approval/style-preferences": { + get: { + tags: [ + "Approval Knowledge" + ], + operationId: "getApprovalStylePreferences", + summary: "Get approval style preferences", + responses: { + "200": { + description: "Style preferences.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + properties: { + tone: { + type: "string" + }, + language: { + type: "string" + }, + detailLevel: { + type: "string" + }, + outputFormat: { + type: "string" + }, + examples: { + type: "array", + items: { + type: "string" + } + }, + prohibitedPhrases: { + type: "array", + items: { + type: "string" + } + }, + customInstructions: { + type: "string" + } + } + } + } + } + } + } + }, + patch: { + tags: [ + "Approval Knowledge" + ], + operationId: "updateApprovalStylePreferences", + summary: "Update approval style preferences", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + properties: { + tone: { + type: "string" + }, + language: { + type: "string" + }, + detailLevel: { + type: "string" + }, + outputFormat: { + type: "string" + }, + examples: { + type: "array", + items: { + type: "string" + } + }, + prohibitedPhrases: { + type: "array", + items: { + type: "string" + } + }, + customInstructions: { + type: "string" + } + } + } + } + } + }, + responses: { + "200": { + description: "Updated style preferences.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + properties: { + tone: { + type: "string" + }, + language: { + type: "string" + }, + detailLevel: { + type: "string" + }, + outputFormat: { + type: "string" + }, + examples: { + type: "array", + items: { + type: "string" + } + }, + prohibitedPhrases: { + type: "array", + items: { + type: "string" + } + }, + customInstructions: { + type: "string" + } + } + } + } + } + } + } + } + }, + "/v1/approval-runs": { + get: { + tags: [ + "Approval Runs" + ], + operationId: "searchApprovalRuns", + summary: "Search wrapped approval run history", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "offset", + in: "query", + schema: { + type: "integer", + minimum: 0, + default: 0 + }, + description: "Zero-based pagination offset." + }, + { + name: "limit", + in: "query", + schema: { + type: "integer", + minimum: 1, + maximum: 100, + default: 50 + }, + description: "Maximum number of records to return." + }, + { + name: "startDate", + in: "query", + schema: { + type: "string" + }, + description: "Creation-time lower bound in milliseconds." + }, + { + name: "endDate", + in: "query", + schema: { + type: "string" + }, + description: "Creation-time upper bound in milliseconds." + }, + { + name: "status", + in: "query", + schema: { + type: "string" + } + }, + { + name: "taskMode", + in: "query", + schema: { + type: "string" + } + }, + { + name: "manualApprovalStatus", + in: "query", + schema: { + oneOf: [ + { + type: "string" + }, + { + type: "array", + items: { + type: "string" + } + } + ] + } + }, + { + name: "sourceDocumentSN", + in: "query", + schema: { + type: "string" + }, + description: "Hose/易快报单号 or other external source document number." + }, + { + name: "sourceDocumentId", + in: "query", + schema: { + type: "string" + } + }, + { + name: "humanResult", + in: "query", + schema: { + type: "string" + }, + description: "Local human result contains filter, such as 驳回 or 通过." + }, + { + name: "query", + in: "query", + schema: { + type: "string" + }, + description: "Search across record ID, source document fields, document ID, and trace fields." + }, + { + name: "includeBridge", + in: "query", + schema: { + type: "boolean", + default: false + }, + description: "Include full Langfuse bridge rows." + } + ], + responses: { + "200": { + description: "Compact wrapped approval run list.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "records" + ], + properties: { + records: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalRun" + } + }, + total: { + type: "integer" + }, + bridge: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + } + } + }, + "/v1/approval-runs/summary": { + get: { + tags: [ + "Approval Runs" + ], + operationId: "summarizeApprovalRuns", + summary: "Summarize approval runs by local date", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "date", + in: "query", + schema: { + type: "string", + format: "date" + } + }, + { + name: "timezone", + in: "query", + schema: { + type: "string", + default: "Asia/Shanghai" + } + }, + { + name: "limit", + in: "query", + schema: { + type: "integer", + minimum: 1, + maximum: 100, + default: 50 + }, + description: "Maximum number of records to return." + }, + { + name: "query", + in: "query", + schema: { + type: "string" + } + }, + { + name: "humanResult", + in: "query", + schema: { + type: "string" + } + } + ], + responses: { + "200": { + description: "Date summary with counts and compact records.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + properties: { + date: { + type: "string" + }, + timezone: { + type: "string" + }, + matched: { + type: "integer" + }, + statusCounts: { + type: "object", + additionalProperties: { + type: "integer" + } + }, + taskModeCounts: { + type: "object", + additionalProperties: { + type: "integer" + } + } + } + } + } + } + } + } + } + }, + "/v1/approval-runs/pick": { + get: { + tags: [ + "Approval Runs" + ], + operationId: "pickApprovalRuns", + summary: "Pick likely approval runs by document number or trace key", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "query", + in: "query", + schema: { + type: "string" + } + }, + { + name: "sn", + in: "query", + schema: { + type: "string" + }, + description: "Source document number for direct lookup." + }, + { + name: "batch", + in: "query", + schema: { + type: "string" + }, + description: "Optional simulation batch ID." + }, + { + name: "latest", + in: "query", + schema: { + type: "boolean" + } + }, + { + name: "fields", + in: "query", + schema: { + type: "string" + }, + description: "Comma-separated response fields." + }, + { + name: "limit", + in: "query", + schema: { + type: "integer", + default: 20 + } + }, + { + name: "maxScan", + in: "query", + schema: { + type: "integer", + default: 1000 + } + } + ], + responses: { + "200": { + description: "Picked records and suggested next actions.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval-runs/bridge": { + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRunLangfuseBridge", + summary: "Resolve approval runs to Langfuse trace or session hints", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "recordId", + in: "query", + schema: { + type: "string" + } + }, + { + name: "sourceDocumentSN", + in: "query", + schema: { + type: "string" + } + }, + { + name: "sourceDocumentId", + in: "query", + schema: { + type: "string" + } + }, + { + name: "simulationBatchId", + in: "query", + schema: { + type: "string" + } + } + ], + responses: { + "200": { + description: "Trace/session bridge hints.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + properties: { + count: { + type: "integer" + }, + records: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalRun" + } + }, + bridge: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + } + } + }, + "/v1/approval-runs/url": { + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRunUrl", + summary: "Get enterprise assist URL and optional source document URL", + parameters: [ + { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + name: "recordId", + in: "query", + schema: { + type: "string" + } + }, + { + name: "sourceDocumentSN", + in: "query", + schema: { + type: "string" + } + }, + { + name: "sourceDocumentId", + in: "query", + schema: { + type: "string" + } + } + ], + responses: { + "200": { + description: "Enterprise and document URLs.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + properties: { + enterpriseAssistUrl: { + type: "string" + }, + enterpriseUrl: { + type: "string" + }, + documentUrl: { + type: "string" + }, + recordId: { + type: "string" + }, + sourceDocumentSN: { + type: "string" + } + } + } + } + } + } + } + } + }, + "/v1/approval-runs/{recordId}": { + parameters: [ + { + name: "recordId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "seal-home approval run record ID." + } + ], + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRun", + summary: "Get wrapped approval run detail", + parameters: [ + { + name: "summary", + in: "query", + schema: { + type: "boolean" + } + }, + { + name: "fields", + in: "query", + schema: { + type: "string" + }, + description: "Comma-separated field paths such as metadata,document.fields,result.summary." + } + ], + responses: { + "200": { + description: "Approval run detail plus stable aliases and human result.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval-runs/{recordId}/cited-rules": { + parameters: [ + { + name: "recordId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "seal-home approval run record ID." + } + ], + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRunCitedRules", + summary: "Extract rules cited or matched by the AI result", + responses: { + "200": { + description: "Cited rule summaries.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval-runs/{recordId}/document-summary": { + parameters: [ + { + name: "recordId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "seal-home approval run record ID." + } + ], + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRunDocumentSummary", + summary: "Get key document fields and compact AI/manual result", + responses: { + "200": { + description: "Document summary.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval-runs/{recordId}/attachments": { + parameters: [ + { + name: "recordId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "seal-home approval run record ID." + } + ], + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRunAttachments", + summary: "List compact attachment metadata", + parameters: [ + { + name: "summary", + in: "query", + schema: { + type: "boolean" + } + } + ], + responses: { + "200": { + description: "Attachment metadata.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/approval-runs/{recordId}/result": { + parameters: [ + { + name: "recordId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "seal-home approval run record ID." + } + ], + get: { + tags: [ + "Approval Runs" + ], + operationId: "getApprovalRunResult", + summary: "Get AI result, optionally as a compact summary", + parameters: [ + { + name: "summary", + in: "query", + schema: { + type: "boolean" + } + } + ], + responses: { + "200": { + description: "AI result or summary.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/simulation/create-batch": { + post: { + tags: [ + "Simulation" + ], + operationId: "createSimulationBatch", + summary: "Create a simulation batch", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + }, + responses: { + "200": { + description: "Created batch id.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/simulation/create-material-pack-batch": { + post: { + tags: [ + "Simulation" + ], + operationId: "createMaterialPackBatch", + summary: "Create a material pack simulation batch", + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + }, + responses: { + "200": { + description: "Created batch id.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/simulation/batches": { + get: { + tags: [ + "Simulation" + ], + operationId: "listSimulationBatches", + summary: "List simulation batches", + parameters: [ + { + name: "limit", + in: "query", + schema: { + type: "integer" + }, + description: "Max batches to return." + } + ], + responses: { + "200": { + description: "Simulation batches.", + content: { + "application/json": { + schema: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + }, + "/v1/simulation/batch/{batchId}": { + parameters: [ + { + name: "batchId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Simulation batch ID." + } + ], + get: { + tags: [ + "Simulation" + ], + operationId: "getSimulationBatch", + summary: "Get a simulation batch detail including echoed create params", + responses: { + "200": { + description: "Simulation batch detail.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/simulation/batches/{batchId}/records": { + parameters: [ + { + name: "batchId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Simulation batch ID." + } + ], + get: { + tags: [ + "Simulation" + ], + operationId: "getSimulationBatchRecords", + summary: "Get wrapped simulation batch records", + parameters: [ + { + name: "query", + in: "query", + schema: { + type: "string" + }, + description: "Optional local contains filter for record/document/trace identifiers." + } + ], + responses: { + "200": { + description: "Compact simulation records and bridge hints.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/simulation/templates": { + get: { + tags: [ + "Simulation" + ], + operationId: "listSimulationTemplates", + summary: "List simulation test templates", + responses: { + "200": { + description: "Simulation templates.", + content: { + "application/json": { + schema: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + }, + "/v1/simulation/integration-status": { + get: { + tags: [ + "Simulation" + ], + operationId: "getSimulationIntegrationStatus", + summary: "Get available source integration status for simulation", + responses: { + "200": { + description: "Integration status.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + }, + "/v1/simulation/hosecloud-integrations": { + get: { + tags: [ + "Simulation" + ], + operationId: "listSimulationHosecloudIntegrations", + summary: "List hosecloud source integrations available for simulation", + responses: { + "200": { + description: "Hosecloud integrations.", + content: { + "application/json": { + schema: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + }, + "/v1/material-packages/upload": { + post: { + tags: [ + "Simulation" + ], + operationId: "uploadMaterialPackage", + summary: "Upload a material package ZIP for simulation", + requestBody: { + required: true, + content: { + "multipart/form-data": { + schema: { + type: "object", + properties: { + file: { + type: "string", + format: "binary" + } + } + } + } + } + }, + responses: { + "200": { + description: "Parsed material package with schema config.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true + } + } + } + } + } + } + } + }, + components: { + securitySchemes: { + localSession: { + type: "apiKey", + in: "header", + name: "X-Seal-Home-Session", + description: "Optional local service session header for future HTTP deployments." + } + }, + parameters: { + CorpId: { + name: "corpId", + in: "query", + schema: { + type: "string" + }, + description: "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + Offset: { + name: "offset", + in: "query", + schema: { + type: "integer", + minimum: 0, + default: 0 + }, + description: "Zero-based pagination offset." + }, + Limit: { + name: "limit", + in: "query", + schema: { + type: "integer", + minimum: 1, + maximum: 100, + default: 50 + }, + description: "Maximum number of records to return." + }, + RuleId: { + name: "ruleId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Approval rule ID." + }, + VersionId: { + name: "versionId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Published rule version ID." + }, + DocumentId: { + name: "documentId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Approval knowledge document ID." + }, + RecordId: { + name: "recordId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "seal-home approval run record ID." + }, + BatchId: { + name: "batchId", + in: "path", + required: true, + schema: { + type: "string" + }, + description: "Simulation batch ID." + } + }, + responses: { + BadRequest: { + description: "Invalid request.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + }, + Unauthorized: { + description: "Local service authentication failed or downstream Seal auth failed.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + }, + NotFound: { + description: "Requested resource was not found.", + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + } + } + } + } + }, + schemas: { + ErrorResponse: { + type: "object", + additionalProperties: true, + required: [ + "error" + ], + properties: { + error: { + type: "string" + }, + message: { + type: "string" + }, + details: {} + } + }, + CorpSummary: { + type: "object", + required: [ + "id", + "name", + "sourceType", + "current" + ], + properties: { + id: { + type: "string" + }, + name: { + type: "string" + }, + sourceType: { + type: "string", + enum: [ + "hose", + "direct", + "seal" + ] + }, + current: { + type: "boolean" + } + } + }, + SwitchCorpRequest: { + type: "object", + required: [ + "corpId" + ], + properties: { + corpId: { + type: "string" + } + } + }, + SwitchCorpResponse: { + type: "object", + required: [ + "current", + "id", + "name" + ], + properties: { + current: { + type: "boolean" + }, + id: { + type: "string" + }, + name: { + type: "string" + } + } + }, + SourceConfig: { + type: "object", + additionalProperties: true, + description: "Redacted Seal enterprise config resolved from the configured source." + }, + AuthStage: { + type: "object", + additionalProperties: true, + required: [ + "name", + "ok" + ], + properties: { + name: { + type: "string", + examples: [ + "hose.openapi", + "hose.provisional", + "seal.sso", + "seal.whoami" + ] + }, + ok: { + type: "boolean" + }, + error: { + type: "string" + } + } + }, + AuthDiagnosis: { + type: "object", + required: [ + "stages" + ], + properties: { + stages: { + type: "array", + items: { + $ref: "#/components/schemas/AuthStage" + } + } + } + }, + SealUser: { + type: "object", + additionalProperties: true, + required: [ + "id", + "name" + ], + properties: { + id: { + type: "string" + }, + tenantId: { + type: "string" + }, + name: { + type: "string" + }, + isAdmin: { + type: "boolean" + }, + permissions: { + type: "array", + items: { + type: "string" + } + } + } + }, + SealTenant: { + type: "object", + additionalProperties: true, + required: [ + "id", + "name" + ], + properties: { + id: { + type: "string" + }, + name: { + type: "string" + }, + tenantSlug: { + type: "string" + } + } + }, + WhoamiResponse: { + type: "object", + required: [ + "user", + "tenant" + ], + properties: { + user: { + $ref: "#/components/schemas/SealUser" + }, + tenant: { + $ref: "#/components/schemas/SealTenant" + } + } + }, + SessionResponse: { + type: "object", + additionalProperties: true, + required: [ + "user", + "session" + ], + properties: { + user: { + $ref: "#/components/schemas/SealUser" + }, + session: { + type: "object", + additionalProperties: true + } + } + }, + ApprovalRule: { + type: "object", + additionalProperties: true, + required: [ + "id", + "description", + "scope", + "strictness" + ], + properties: { + id: { + type: "string" + }, + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + }, + status: { + type: "string" + } + } + }, + ApprovalRuleInput: { + type: "object", + required: [ + "description", + "scope", + "strictness" + ], + properties: { + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + } + } + }, + ApprovalRulePatch: { + type: "object", + additionalProperties: false, + properties: { + description: { + type: "string" + }, + scope: { + type: "string" + }, + strictness: { + type: "string", + enum: [ + "MUST_FOLLOW", + "SHOULD_FOLLOW", + "SUGGESTION" + ] + } + } + }, + ApprovalRulesResponse: { + type: "object", + required: [ + "rules" + ], + properties: { + rules: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalRule" + } + }, + hasPendingDeletes: { + type: "boolean" + } + } + }, + RuleSetVersion: { + type: "object", + additionalProperties: true, + required: [ + "id", + "versionNumber", + "versionName", + "rules" + ], + properties: { + id: { + type: "string" + }, + versionNumber: { + type: "integer" + }, + versionName: { + type: "string" + }, + publishedByName: { + type: "string" + }, + rules: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + }, + PublishRuleVersionRequest: { + type: "object", + required: [ + "versionName" + ], + properties: { + versionName: { + type: "string" + } + } + }, + ApprovalDocument: { + type: "object", + additionalProperties: true, + required: [ + "id", + "title", + "content" + ], + properties: { + id: { + type: "string" + }, + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string", + description: "Usually Markdown." + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + enabled: { + type: "boolean" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + }, + ApprovalDocumentInput: { + type: "object", + required: [ + "title", + "purpose", + "content" + ], + properties: { + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string" + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + }, + ApprovalDocumentPatch: { + type: "object", + additionalProperties: false, + properties: { + title: { + type: "string" + }, + purpose: { + type: "string" + }, + content: { + type: "string" + }, + contentType: { + type: "string" + }, + status: { + type: "string" + }, + enabled: { + type: "boolean" + }, + scenarios: { + type: "array", + items: { + type: "string" + } + }, + tags: { + type: "array", + items: { + type: "string" + } + } + } + }, + ApprovalDocumentsResponse: { + type: "object", + required: [ + "articles" + ], + properties: { + articles: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalDocument" + } + }, + total: { + type: "integer" + } + } + }, + ApprovalStylePreferences: { + type: "object", + additionalProperties: true, + properties: { + tone: { + type: "string" + }, + language: { + type: "string" + }, + detailLevel: { + type: "string" + }, + outputFormat: { + type: "string" + }, + examples: { + type: "array", + items: { + type: "string" + } + }, + prohibitedPhrases: { + type: "array", + items: { + type: "string" + } + }, + customInstructions: { + type: "string" + } + } + }, + ApprovalContext: { + type: "object", + required: [ + "rules", + "documents", + "stylePreferences" + ], + properties: { + rules: {}, + documents: {}, + stylePreferences: {} + } + }, + ApprovalSearchRequest: { + type: "object", + required: [ + "keywords" + ], + properties: { + keywords: { + type: "array", + minItems: 1, + items: { + type: "string" + } + }, + matchMode: { + type: "string", + enum: [ + "any", + "all" + ] + }, + areas: { + type: "array", + items: { + type: "string", + enum: [ + "rules", + "documents", + "preferences" + ] + } + }, + maxResults: { + type: "integer" + } + } + }, + ApprovalSearchResponse: { + type: "object", + additionalProperties: true + }, + ApprovalRun: { + type: "object", + additionalProperties: true, + required: [ + "id" + ], + properties: { + id: { + type: "string" + }, + sourceDocumentSN: { + type: "string", + description: "External document number, often Hose/易快报单号." + }, + sourceDocumentId: { + type: "string" + }, + status: { + type: "string" + }, + taskMode: { + type: "string" + }, + finalExecutionMode: { + type: "string" + }, + ruleSetVersionNumber: { + type: "integer" + }, + langfuseTraceId: { + type: "string" + }, + langfuseSessionFallback: { + type: "string" + } + } + }, + ApprovalRunsResponse: { + type: "object", + additionalProperties: true, + required: [ + "records" + ], + properties: { + records: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalRun" + } + }, + total: { + type: "integer" + }, + bridge: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + }, + ApprovalRunsSummary: { + type: "object", + additionalProperties: true, + properties: { + date: { + type: "string" + }, + timezone: { + type: "string" + }, + matched: { + type: "integer" + }, + statusCounts: { + type: "object", + additionalProperties: { + type: "integer" + } + }, + taskModeCounts: { + type: "object", + additionalProperties: { + type: "integer" + } + } + } + }, + RunUrlResponse: { + type: "object", + additionalProperties: true, + properties: { + enterpriseAssistUrl: { + type: "string" + }, + enterpriseUrl: { + type: "string" + }, + documentUrl: { + type: "string" + }, + recordId: { + type: "string" + }, + sourceDocumentSN: { + type: "string" + } + } + }, + BridgeResponse: { + type: "object", + additionalProperties: true, + properties: { + count: { + type: "integer" + }, + records: { + type: "array", + items: { + $ref: "#/components/schemas/ApprovalRun" + } + }, + bridge: { + type: "array", + items: { + type: "object", + additionalProperties: true + } + } + } + } + } + } +}; + +// src/core/embedded-openapi.ts +function getOpenApiSchema() { + return openapi_default; +} + +// src/cli/commands/openapi.ts +function handleOpenApiCommand(args) { + const schema = getOpenApiSchema(); + printJson(schema, { ...outputOptions(args.options), allowFull: true }); +} // src/cli/commands/permissions.ts async function handlePermissionsCommand(action, client, corp, args) { @@ -31521,6 +34877,7 @@ var KNOWN_AREAS = new Set([ "server", "mcp-config", "skill", + "openapi", "probe" ]); var runQueue = Promise.resolve(); @@ -31587,6 +34944,10 @@ async function dispatch(argv, runtime) { if (!KNOWN_AREAS.has(area)) { throw new Error(`Unknown command: ${args.command.join(" ")}. Run 'seal-home help' for available commands.`); } + if (area === "openapi") { + handleOpenApiCommand(args); + return; + } if (area === "mcp-config") { printMcpConfig(); return; diff --git a/dist/openapi.json b/dist/openapi.json index 4fe0caf..8b48f3f 100644 --- a/dist/openapi.json +++ b/dist/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "info": { "title": "seal-home Wrapped API", - "version": "0.4.2", + "version": "0.7.0", "description": "Planned HTTP contract for the seal-home wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-home is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n" }, "servers": [ diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 9578623..01cefcc 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: seal-home Wrapped API - version: 0.4.2 + version: 0.7.0 description: | Planned HTTP contract for the seal-home wrapped backend API. diff --git a/src/cli.test.ts b/src/cli.test.ts index bb4886a..5906690 100644 --- a/src/cli.test.ts +++ b/src/cli.test.ts @@ -156,6 +156,15 @@ describe("CLI version & help handling", () => { expect(parsed.targetDir).toBe(tmp); expect(parsed.fileCount).toBeGreaterThan(5); }); + + test("openapi command outputs embedded OpenAPI specification", () => { + const result = runCli(["openapi"]); + expect(result.status).toBe(0); + const parsed = JSON.parse(result.stdout.trim()); + expect(parsed.openapi).toBe("3.1.0"); + expect(parsed.info.title).toContain("seal-home"); + expect(parsed.paths).toHaveProperty("/v1/corps"); + }); }); function makeConfigEnv(): Record { diff --git a/src/cli/commands/openapi.ts b/src/cli/commands/openapi.ts new file mode 100644 index 0000000..5d625e7 --- /dev/null +++ b/src/cli/commands/openapi.ts @@ -0,0 +1,8 @@ +import { getOpenApiSchema } from "../../core/embedded-openapi.js"; +import { outputOptions, printJson } from "../printer.js"; +import type { ParsedArgs } from "../types.js"; + +export function handleOpenApiCommand(args: ParsedArgs) { + const schema = getOpenApiSchema(); + printJson(schema, { ...outputOptions(args.options), allowFull: true }); +} diff --git a/src/cli/printer.ts b/src/cli/printer.ts index 56ef73c..7f7f420 100644 --- a/src/cli/printer.ts +++ b/src/cli/printer.ts @@ -80,6 +80,7 @@ Usage: seal-home skill dump seal-home skill install [--dir |--local] seal-home skill status + seal-home openapi seal-home probe [] seal-home config paths seal-home config get diff --git a/src/cli/runner.ts b/src/cli/runner.ts index 830878a..b6e9ca5 100755 --- a/src/cli/runner.ts +++ b/src/cli/runner.ts @@ -13,6 +13,7 @@ import { handleCorpsCommand } from "./commands/corps.js"; import { handleDelegationCommand } from "./commands/delegation.js"; import { handleLlmCommand } from "./commands/llm.js"; import { handleMcpCommand, printMcpConfig } from "./commands/mcp.js"; +import { handleOpenApiCommand } from "./commands/openapi.js"; import { handlePermissionsCommand } from "./commands/permissions.js"; import { handleProbeCommand } from "./commands/probe.js"; import { handleRulesCommand } from "./commands/rules.js"; @@ -61,6 +62,7 @@ const KNOWN_AREAS = new Set([ "server", "mcp-config", "skill", + "openapi", "probe" ]); @@ -144,6 +146,11 @@ async function dispatch(argv: string[], runtime: CliRuntime) { throw new Error(`Unknown command: ${args.command.join(" ")}. Run 'seal-home help' for available commands.`); } + if (area === "openapi") { + handleOpenApiCommand(args); + return; + } + if (area === "mcp-config") { printMcpConfig(); return; diff --git a/src/core/embedded-openapi.test.ts b/src/core/embedded-openapi.test.ts new file mode 100644 index 0000000..328d2e5 --- /dev/null +++ b/src/core/embedded-openapi.test.ts @@ -0,0 +1,12 @@ +import { describe, expect, test } from "bun:test"; +import { getOpenApiSchema } from "./embedded-openapi.js"; + +describe("embedded-openapi", () => { + test("returns valid OpenAPI 3.x schema object", () => { + const schema = getOpenApiSchema(); + expect(schema).toBeDefined(); + expect(schema.openapi).toBe("3.1.0"); + expect(schema.info).toHaveProperty("title"); + expect(schema.paths).toBeDefined(); + }); +}); diff --git a/src/core/embedded-openapi.ts b/src/core/embedded-openapi.ts new file mode 100644 index 0000000..70e28f0 --- /dev/null +++ b/src/core/embedded-openapi.ts @@ -0,0 +1,5 @@ +import openapiSchema from "../../dist/openapi.json" with { type: "json" }; + +export function getOpenApiSchema(): Record { + return openapiSchema as Record; +}