From 58e74ab5a78c0e14fa2f2ca765bb47689a6be74f Mon Sep 17 00:00:00 2001 From: Fengzdadi <453788063@qq.com> Date: Sat, 31 Oct 2026 00:02:10 -0400 Subject: [PATCH 1/4] fix(integrations): report a coded 404 as an invalid response in WorkBuddy and OpenCode WorkBuddy and OpenCode reported every HTTP 404 as version_mismatch. The Server also answers 404 with an error code, such as scope_not_found for a configured Scope that does not exist, and for that the advice to install the package and plugin from one ref is wrong. WorkBuddy reads error.code from an error body in the Scope resolver and the hook's requests. Only a 404 without a code is version_mismatch; any other 404 is invalid_response, and the diagnostic carries error_code. The OpenCode statusline passes the code into its outcome mapping. It reads get_stats through the client, so the not_found fallback of the tool result no longer hides whether the Server sent a code. Closes #2321 --- docs/en/docs/integrations/workbuddy.md | 14 +- docs/zh/docs/integrations/workbuddy.md | 8 +- .../plugins/powercontext/lib/index.js | 172 ++++++++++++++- .../opencode/plugins/powercontext/lib/tui.js | 207 +++++++++++++++--- .../plugins/powercontext/src/invoke.ts | 16 +- .../opencode/plugins/powercontext/src/tui.tsx | 38 ++-- .../plugins/powercontext/tests/tui.spec.tsx | 35 ++- integrations/workbuddy/README.md | 8 +- .../hooks/workbuddy_powercontext_hook.py | 52 +++-- .../powercontext/scripts/workspace_scope.py | 42 +++- tests/workbuddy_plugin/test_hook.py | 82 ++++++- 11 files changed, 574 insertions(+), 100 deletions(-) diff --git a/docs/en/docs/integrations/workbuddy.md b/docs/en/docs/integrations/workbuddy.md index 4a304c868a..4fc9374bb4 100644 --- a/docs/en/docs/integrations/workbuddy.md +++ b/docs/en/docs/integrations/workbuddy.md @@ -288,7 +288,8 @@ blocking the WorkBuddy session. | Server unavailable | Hook recall and capture fail open; the prompt proceeds without injected context. MCP tools report that the service is unavailable | | Authentication failure | Hook fails open and emits an `authentication_failed` diagnostic; MCP tools remain unavailable | | Empty prepared context | No context is injected; the hook emits an `empty` diagnostic | -| Version mismatch | Hook fails open and emits a `version_mismatch` diagnostic | +| Version mismatch: HTTP 404 without an error code | Hook fails open and emits a `version_mismatch` diagnostic | +| Another HTTP error, including a coded 404 such as `scope_not_found` | Hook fails open and emits an `invalid_response` diagnostic with the status and any error code | | Invalid or oversized response | Hook fails open and emits an `invalid_response` diagnostic; nothing is injected | | Hook timeout (30 s) | WorkBuddy continues; the hook process is stopped by the outer hook timeout | @@ -299,9 +300,14 @@ blocks normal WorkBuddy work. For a normal empty result or recall failure, the Hook writes one content-free JSON diagnostic to stderr. Outcomes include `empty`, `authentication_failed`, -`version_mismatch`, `server_unavailable`, and `invalid_response`. The event -never contains the query, scope, prepared content, citation, response body, or -authorization value. +`version_mismatch`, `server_unavailable`, and `invalid_response`. An HTTP +failure carries `http_status` and, when the Server returned one, its +`error_code`. `version_mismatch` means the Server answered HTTP 404 without an +error code because it does not provide a route the hook requires; install the +package and plugin from the same ref. An `invalid_response` event with +`error_code: scope_not_found` means the configured Scope does not exist or no +binding resolves. The event never contains the query, scope, prepared content, +citation, response body, or authorization value. During each prompt you should see the hook's `Syncing PowerContext` status message. Verify the whole installation with `powercontext doctor`. diff --git a/docs/zh/docs/integrations/workbuddy.md b/docs/zh/docs/integrations/workbuddy.md index e75e6da443..0c8604144a 100644 --- a/docs/zh/docs/integrations/workbuddy.md +++ b/docs/zh/docs/integrations/workbuddy.md @@ -253,7 +253,8 @@ export POWERCONTEXT_WORKBUDDY_AUTHORIZATION="Bearer $POWERCONTEXT_LOCAL_TOKEN" | Server 不可用 | Hook 的恢复和采集正常降级,提示词继续执行且不注入上下文;MCP 工具报告服务不可用 | | 鉴权失败 | Hook 正常降级并写出 `authentication_failed` 诊断;MCP 工具不可用 | | 空 prepared context | 不注入任何上下文;Hook 写出 `empty` 诊断 | -| 版本不匹配 | Hook 正常降级并写出 `version_mismatch` 诊断 | +| 版本不匹配:不带错误码的 HTTP 404 | Hook 正常降级并写出 `version_mismatch` 诊断 | +| 其他 HTTP 错误,包括 `scope_not_found` 这类带错误码的 404 | Hook 正常降级并写出 `invalid_response` 诊断,带上状态码和 Server 返回的错误码 | | 无效或超限响应 | Hook 正常降级并写出 `invalid_response` 诊断;不注入任何内容 | | Hook 超时(30 秒) | WorkBuddy 继续执行;hook 进程被外层 hook 超时机制终止 | @@ -262,7 +263,10 @@ export POWERCONTEXT_WORKBUDDY_AUTHORIZATION="Bearer $POWERCONTEXT_LOCAL_TOKEN" ## 诊断 正常空结果或召回失败时,Hook 会向 stderr 写一行不含正文的 JSON 诊断。outcome 包括 `empty`、 -`authentication_failed`、`version_mismatch`、`server_unavailable` 和 `invalid_response`;事件不会包含 +`authentication_failed`、`version_mismatch`、`server_unavailable` 和 `invalid_response`。HTTP 失败会带上 +`http_status`,Server 返回了错误码时还会带上 `error_code`。`version_mismatch` 表示 Server 对 Hook 依赖的路由 +返回了不带错误码的 HTTP 404,即 Server 不提供该路由;请从同一个 ref 安装 package 和插件。带 +`error_code: scope_not_found` 的 `invalid_response` 表示配置的 Scope 不存在,或者没有可解析的绑定。事件不会包含 query、scope、prepared content、citation、response body 或 authorization value。 每个提示词期间应能看到 hook 的 `Syncing PowerContext` 状态消息。使用 `powercontext doctor` 验证整体 diff --git a/integrations/opencode/plugins/powercontext/lib/index.js b/integrations/opencode/plugins/powercontext/lib/index.js index 9e1697ad6e..0ae26d50aa 100644 --- a/integrations/opencode/plugins/powercontext/lib/index.js +++ b/integrations/opencode/plugins/powercontext/lib/index.js @@ -69,6 +69,17 @@ var ServerResponseError = class extends ClientError { //#endregion //#region src/operations.generated.ts const OPERATIONS = { + get_recall_manifest: { + method: "POST", + path: "/v1/recall/manifest", + location: "body", + scopeMode: "current", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, list_atomic_memories: { method: "POST", path: "/v1/atomic-memory/list", @@ -1518,6 +1529,160 @@ const OPERATIONS = { headerParams: [], successStatuses: [200], emptyStatuses: [] + }, + pc_source_capabilities: { + method: "POST", + path: "/v1/source-management/capabilities", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_add: { + method: "POST", + path: "/v1/source-management/add", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_status: { + method: "POST", + path: "/v1/source-management/status", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_target_set_enabled: { + method: "POST", + path: "/v1/source-management/target-set-enabled", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_instances: { + method: "POST", + path: "/v1/source-management/instances", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_instance_set_enabled: { + method: "POST", + path: "/v1/source-management/instance-set-enabled", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_configure: { + method: "POST", + path: "/v1/source-management/configure", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + load_source_write_plugin: { + method: "POST", + path: "/v1/source-management/write/load", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_open: { + method: "POST", + path: "/v1/source-management/channel/open", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_catalog: { + method: "POST", + path: "/v1/source-management/channel/catalog", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_poll: { + method: "POST", + path: "/v1/source-management/channel/poll", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_reply: { + method: "POST", + path: "/v1/source-management/channel/reply", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_close: { + method: "POST", + path: "/v1/source-management/channel/close", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_instance_exchange: { + method: "POST", + path: "/v1/source-management/instances/{instance_id}/{operation}", + location: "body", + scopeMode: "none", + pathParameters: ["instance_id", "operation"], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] } }; const OPERATION_IDS = Object.keys(OPERATIONS); @@ -2045,9 +2210,9 @@ function errorResult(error) { message: "PowerContext is unavailable; continue the task." }; } -async function invokeOperation(client, operationId, payload, scopeId, signal) { +function scopedPayload(operationId, payload, scopeId) { const mode = OPERATIONS[operationId].scopeMode; - const body = mode === "selection" ? { + return mode === "selection" ? { ...payload, selection: { mode: "exact", @@ -2057,6 +2222,9 @@ async function invokeOperation(client, operationId, payload, scopeId, signal) { ...payload, scope_id: scopeId } : payload; +} +async function invokeOperation(client, operationId, payload, scopeId, signal) { + const body = scopedPayload(operationId, payload, scopeId); if (operationMutates(operationId) && hasSecret(body)) return { ok: false, code: "secret_rejected", diff --git a/integrations/opencode/plugins/powercontext/lib/tui.js b/integrations/opencode/plugins/powercontext/lib/tui.js index 0ee209714c..7e445528eb 100644 --- a/integrations/opencode/plugins/powercontext/lib/tui.js +++ b/integrations/opencode/plugins/powercontext/lib/tui.js @@ -69,6 +69,17 @@ var ServerResponseError = class extends ClientError { //#endregion //#region src/operations.generated.ts const OPERATIONS = { + get_recall_manifest: { + method: "POST", + path: "/v1/recall/manifest", + location: "body", + scopeMode: "current", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, list_atomic_memories: { method: "POST", path: "/v1/atomic-memory/list", @@ -1518,6 +1529,160 @@ const OPERATIONS = { headerParams: [], successStatuses: [200], emptyStatuses: [] + }, + pc_source_capabilities: { + method: "POST", + path: "/v1/source-management/capabilities", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_add: { + method: "POST", + path: "/v1/source-management/add", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_status: { + method: "POST", + path: "/v1/source-management/status", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_target_set_enabled: { + method: "POST", + path: "/v1/source-management/target-set-enabled", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_instances: { + method: "POST", + path: "/v1/source-management/instances", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + pc_source_instance_set_enabled: { + method: "POST", + path: "/v1/source-management/instance-set-enabled", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_configure: { + method: "POST", + path: "/v1/source-management/configure", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + load_source_write_plugin: { + method: "POST", + path: "/v1/source-management/write/load", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_open: { + method: "POST", + path: "/v1/source-management/channel/open", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_catalog: { + method: "POST", + path: "/v1/source-management/channel/catalog", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_poll: { + method: "POST", + path: "/v1/source-management/channel/poll", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_reply: { + method: "POST", + path: "/v1/source-management/channel/reply", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_channel_close: { + method: "POST", + path: "/v1/source-management/channel/close", + location: "body", + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + source_instance_exchange: { + method: "POST", + path: "/v1/source-management/instances/{instance_id}/{operation}", + location: "body", + scopeMode: "none", + pathParameters: ["instance_id", "operation"], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] } }; const OPERATION_IDS = Object.keys(OPERATIONS); @@ -1973,9 +2138,9 @@ function errorResult(error) { message: "PowerContext is unavailable; continue the task." }; } -async function invokeOperation(client, operationId, payload, scopeId, signal) { +function scopedPayload(operationId, payload, scopeId) { const mode = OPERATIONS[operationId].scopeMode; - const body = mode === "selection" ? { + return mode === "selection" ? { ...payload, selection: { mode: "exact", @@ -1985,6 +2150,9 @@ async function invokeOperation(client, operationId, payload, scopeId, signal) { ...payload, scope_id: scopeId } : payload; +} +async function invokeOperation(client, operationId, payload, scopeId, signal) { + const body = scopedPayload(operationId, payload, scopeId); if (operationMutates(operationId) && hasSecret(body)) return { ok: false, code: "secret_rejected", @@ -2306,23 +2474,20 @@ var StatusTimeoutError = class extends Error { this.name = "StatusTimeoutError"; } }; -function httpOutcome(status) { +function httpOutcome(status, code) { if (status === 401) return "authentication_failed"; - if (status === 404) return "version_mismatch"; + if (status === 404 && code === void 0) return "version_mismatch"; if (status === 503) return "server_unavailable"; return "invalid_response"; } -function scopeFailureOutcome(error) { +function requestFailureOutcome(error) { if (error instanceof StatusTimeoutError) return "server_unavailable"; - if (error instanceof ServerResponseError) return httpOutcome(error.statusCode); + if (error instanceof ServerResponseError) return httpOutcome(error.statusCode, error.code); if (error instanceof UnavailableError) return "server_unavailable"; return "invalid_response"; } -function statsFailureOutcome(result) { - if (result.code === "authentication_failed") return "authentication_failed"; - if (result.code === "unavailable") return "server_unavailable"; - if (typeof result.status === "number") return httpOutcome(result.status); - return "invalid_response"; +async function loadStats(client, period, scopeId, signal) { + return (await client.request("get_stats", scopedPayload("get_stats", { period }, scopeId), signal)).value; } function textNode(text, color, onMouseUp) { const node = createElement("text"); @@ -2358,35 +2523,27 @@ async function loadStatuslineStatus(runtime, sessionID, cwd, signal) { } catch (error) { return { connected: false, - label: failureLabel(scopeFailureOutcome(error)) + label: failureLabel(requestFailureOutcome(error)) }; } try { - const [today, month] = await Promise.all([withTimeout(invokeOperation(runtime.client, "get_stats", { period: "today" }, scopeId, signal), STATUS_TIMEOUT_MS), withTimeout(invokeOperation(runtime.client, "get_stats", { period: "30d" }, scopeId, signal), STATUS_TIMEOUT_MS)]); - if (!today.ok) return { - connected: false, - label: failureLabel(statsFailureOutcome(today)) - }; - if (!month.ok) return { - connected: false, - label: failureLabel(statsFailureOutcome(month)) - }; - const todayTotals = tokenTotals(today.data); - const monthTotals = tokenTotals(month.data); + const [today, month] = await Promise.all([withTimeout(loadStats(runtime.client, "today", scopeId, signal), STATUS_TIMEOUT_MS), withTimeout(loadStats(runtime.client, "30d", scopeId, signal), STATUS_TIMEOUT_MS)]); + const todayTotals = tokenTotals(today); + const monthTotals = tokenTotals(month); if (!todayTotals || !monthTotals) return { connected: false, label: failureLabel("invalid_response") }; return { connected: true, - label: formatPowerContextStatus(today.data, month.data), + label: formatPowerContextStatus(today, month), todayReduction: todayTotals.token_reduction, monthReduction: monthTotals.token_reduction }; } catch (error) { return { connected: false, - label: failureLabel(scopeFailureOutcome(error)) + label: failureLabel(requestFailureOutcome(error)) }; } } diff --git a/integrations/opencode/plugins/powercontext/src/invoke.ts b/integrations/opencode/plugins/powercontext/src/invoke.ts index d7ca8cd284..d5afbed6ab 100644 --- a/integrations/opencode/plugins/powercontext/src/invoke.ts +++ b/integrations/opencode/plugins/powercontext/src/invoke.ts @@ -82,6 +82,15 @@ function errorResult(error: unknown): ToolResult { return { ok: false, code: 'unavailable', message: 'PowerContext is unavailable; continue the task.' } } +export function scopedPayload(operationId: OperationId, payload: JsonObject, scopeId: string): JsonObject { + const mode = OPERATIONS[operationId].scopeMode + return mode === 'selection' + ? { ...payload, selection: { mode: 'exact', scope_ids: [scopeId] } } + : mode === 'current' || operationId === 'get_atomic_memory_state' + ? { ...payload, scope_id: scopeId } + : payload +} + export async function invokeOperation( client: PowerContextClient, operationId: OperationId, @@ -89,12 +98,7 @@ export async function invokeOperation( scopeId: string, signal?: AbortSignal, ): Promise { - const mode = OPERATIONS[operationId].scopeMode - const body = mode === 'selection' - ? { ...payload, selection: { mode: 'exact', scope_ids: [scopeId] } } - : mode === 'current' || operationId === 'get_atomic_memory_state' - ? { ...payload, scope_id: scopeId } - : payload + const body = scopedPayload(operationId, payload, scopeId) if (operationMutates(operationId) && hasSecret(body)) { return { ok: false, code: 'secret_rejected', message: 'Refused to send secret-like content to PowerContext.' } } diff --git a/integrations/opencode/plugins/powercontext/src/tui.tsx b/integrations/opencode/plugins/powercontext/src/tui.tsx index 8ed1f9e22f..bc17ffe8f4 100644 --- a/integrations/opencode/plugins/powercontext/src/tui.tsx +++ b/integrations/opencode/plugins/powercontext/src/tui.tsx @@ -22,7 +22,7 @@ import { combineSignals, PowerContextClient } from './client.ts' import { PC_COMMAND_USAGE, handlePcCommand, type PcCommandResult, type PcCommandRuntime } from './commands.ts' import { resolveConfig } from './config.ts' import { PLUGIN_NAME, ServerResponseError, UnavailableError } from './errors.ts' -import { invokeOperation, type ToolResult } from './invoke.ts' +import { scopedPayload } from './invoke.ts' import { resolveScopeId } from './scope.ts' const COMMAND_NAME = 'powercontext.pc' @@ -149,25 +149,27 @@ class StatusTimeoutError extends Error { } } -function httpOutcome(status: number): FailureOutcome { +function httpOutcome(status: number, code: string | undefined): FailureOutcome { if (status === 401) return 'authentication_failed' - if (status === 404) return 'version_mismatch' + // Only a Server without the route answers 404 without an error code. A coded 404, such as + // scope_not_found for a configured Scope that does not exist, comes from a Server that has it. + if (status === 404 && code === undefined) return 'version_mismatch' if (status === 503) return 'server_unavailable' return 'invalid_response' } -function scopeFailureOutcome(error: unknown): FailureOutcome { +function requestFailureOutcome(error: unknown): FailureOutcome { if (error instanceof StatusTimeoutError) return 'server_unavailable' - if (error instanceof ServerResponseError) return httpOutcome(error.statusCode) + if (error instanceof ServerResponseError) return httpOutcome(error.statusCode, error.code) if (error instanceof UnavailableError) return 'server_unavailable' return 'invalid_response' } -function statsFailureOutcome(result: ToolResult): FailureOutcome { - if (result.code === 'authentication_failed') return 'authentication_failed' - if (result.code === 'unavailable') return 'server_unavailable' - if (typeof result.status === 'number') return httpOutcome(result.status) - return 'invalid_response' +// The statusline reads statistics from the client rather than through invokeOperation, whose tool +// result gives an uncoded 404 the not_found code and so hides whether the Server sent one. +async function loadStats(client: PowerContextClient, period: string, scopeId: string, signal?: AbortSignal) { + const result = await client.request('get_stats', scopedPayload('get_stats', { period }, scopeId), signal) + return result.value } function textNode(text: string, color: unknown, onMouseUp?: () => void): any { @@ -212,26 +214,24 @@ export async function loadStatuslineStatus( STATUS_TIMEOUT_MS, ) } catch (error) { - return { connected: false, label: failureLabel(scopeFailureOutcome(error)) } + return { connected: false, label: failureLabel(requestFailureOutcome(error)) } } try { const [today, month] = await Promise.all([ - withTimeout(invokeOperation(runtime.client, 'get_stats', { period: 'today' }, scopeId, signal), STATUS_TIMEOUT_MS), - withTimeout(invokeOperation(runtime.client, 'get_stats', { period: '30d' }, scopeId, signal), STATUS_TIMEOUT_MS), + withTimeout(loadStats(runtime.client, 'today', scopeId, signal), STATUS_TIMEOUT_MS), + withTimeout(loadStats(runtime.client, '30d', scopeId, signal), STATUS_TIMEOUT_MS), ]) - if (!today.ok) return { connected: false, label: failureLabel(statsFailureOutcome(today)) } - if (!month.ok) return { connected: false, label: failureLabel(statsFailureOutcome(month)) } - const todayTotals = tokenTotals(today.data) - const monthTotals = tokenTotals(month.data) + const todayTotals = tokenTotals(today) + const monthTotals = tokenTotals(month) if (!todayTotals || !monthTotals) return { connected: false, label: failureLabel('invalid_response') } return { connected: true, - label: formatPowerContextStatus(today.data, month.data), + label: formatPowerContextStatus(today, month), todayReduction: todayTotals.token_reduction, monthReduction: monthTotals.token_reduction, } } catch (error) { - return { connected: false, label: failureLabel(scopeFailureOutcome(error)) } + return { connected: false, label: failureLabel(requestFailureOutcome(error)) } } } diff --git a/integrations/opencode/plugins/powercontext/tests/tui.spec.tsx b/integrations/opencode/plugins/powercontext/tests/tui.spec.tsx index b303689fc9..8685b00075 100644 --- a/integrations/opencode/plugins/powercontext/tests/tui.spec.tsx +++ b/integrations/opencode/plugins/powercontext/tests/tui.spec.tsx @@ -260,19 +260,20 @@ describe('PowerContextTuiPlugin', () => { it('keeps authentication, version, transport, and protocol failures distinct', async () => { const { PowerContextClient } = await import('../src/client.ts') - const cases: Array<[number, string]> = [ - [401, 'PC auth failed'], - [404, 'PC version mismatch'], - [503, 'PC offline · run powercontext doctor'], - [500, 'PC invalid response'], + const cases: Array<[number, unknown, string]> = [ + [401, { error: { code: 'failure' } }, 'PC auth failed'], + [404, { detail: 'Not Found' }, 'PC version mismatch'], + [404, { error: { code: 'scope_not_found' } }, 'PC invalid response'], + [503, { error: { code: 'failure' } }, 'PC offline · run powercontext doctor'], + [500, { error: { code: 'failure' } }, 'PC invalid response'], ] - for (const [status, label] of cases) { + for (const [status, body, label] of cases) { const client = new PowerContextClient({ baseUrl: 'http://127.0.0.1:9', requestTimeoutMs: 1_000, fetch: async (url: string) => (url.endsWith('/v1/scope-bindings/resolve') ? Response.json({ scope_id: 'project:test' }) - : Response.json({ error: { code: 'failure' } }, { status })), + : Response.json(body, { status })), }) const runtime = { config: { scopeId: 'project:test' }, client } @@ -283,6 +284,26 @@ describe('PowerContextTuiPlugin', () => { } }) + it('reports a missing configured Scope as an invalid response, not a version mismatch', async () => { + const { PowerContextClient } = await import('../src/client.ts') + const cases: Array<[unknown, string]> = [ + [{ detail: 'Not Found' }, 'PC version mismatch'], + [{ error: { code: 'scope_not_found', message: 'The requested Scope was not found.' } }, 'PC invalid response'], + ] + for (const [body, label] of cases) { + const client = new PowerContextClient({ + baseUrl: 'http://127.0.0.1:9', + requestTimeoutMs: 1_000, + fetch: async () => Response.json(body, { status: 404 }), + }) + const runtime = { config: { scopeId: 'scp_missing' }, client } + + const state = await loadStatuslineStatus(runtime as any, 'session-1', '/tmp/project') + + expect(state).toEqual({ connected: false, label }) + } + }) + it('rejects a malformed stats payload instead of rendering no data', async () => { const { PowerContextClient } = await import('../src/client.ts') const client = new PowerContextClient({ diff --git a/integrations/workbuddy/README.md b/integrations/workbuddy/README.md index 7752ade889..2a660b2bbd 100644 --- a/integrations/workbuddy/README.md +++ b/integrations/workbuddy/README.md @@ -237,9 +237,11 @@ HTTPS certificate verification remains enabled. blocks normal WorkBuddy work. - For an empty result, authentication failure, version mismatch, unavailable Server, or invalid response, the hook writes one diagnostic JSON line to - stderr. Diagnostics carry status codes, byte and character counts, and which - query source produced them—never the query, scope, content, citation, response - body, or authorization value. + stderr. Diagnostics carry status codes, the Server's error code, byte and + character counts, and which query source produced them—never the query, scope, + content, citation, response body, or authorization value. Only an HTTP 404 + without an error code is a version mismatch; a coded 404 such as + `scope_not_found` is reported as an invalid response. ## Authentication diff --git a/integrations/workbuddy/plugins/powercontext/hooks/workbuddy_powercontext_hook.py b/integrations/workbuddy/plugins/powercontext/hooks/workbuddy_powercontext_hook.py index d5a761a4eb..43a40d1dbf 100644 --- a/integrations/workbuddy/plugins/powercontext/hooks/workbuddy_powercontext_hook.py +++ b/integrations/workbuddy/plugins/powercontext/hooks/workbuddy_powercontext_hook.py @@ -25,6 +25,7 @@ from collections.abc import Mapping from contextlib import suppress from hashlib import sha256 +from http.client import HTTPException from pathlib import Path from time import monotonic from typing import Any, Protocol, cast @@ -87,18 +88,13 @@ class _Response(Protocol): - status: int - - def __enter__(self) -> _Response: ... - - def __exit__(self, *args: object) -> object: ... - - def read(self, amount: int = -1) -> bytes: ... + def read(self, amount: int = -1, /) -> bytes: ... class _HttpStatusError(RuntimeError): - def __init__(self, status: int) -> None: + def __init__(self, status: int, code: str | None = None) -> None: self.status = status + self.code = code super().__init__(f"PowerContext returned HTTP {status}") @@ -199,8 +195,13 @@ def _resolve_scope( except ScopeBindingUnavailableError: _emit_context_event("server_unavailable") except ScopeBindingStatusError as error: - outcome = "version_mismatch" if error.status == 404 else "invalid_response" - _emit_context_event(outcome, http_status=error.status) + # ty resolves workspace_scope to the Claude Code plugin's module of the same name, so the code that + # WorkBuddy's own resolver keeps on the error is read by name. + code: str | None = getattr(error, "code", None) + # Only a Server without the route answers 404 without an error code. A coded 404, such as + # scope_not_found for a configured Scope that does not exist, comes from a Server that has it. + outcome = "version_mismatch" if error.status == 404 and code is None else "invalid_response" + _emit_context_event(outcome, http_status=error.status, error_code=code) except ScopeBindingError: _emit_context_event("invalid_response") except Exception: @@ -487,7 +488,7 @@ def _post_json( raise _HttpStatusError(response.status) result = json.loads(_read_response(response, deadline=request_deadline)) except HTTPError as error: - raise _HttpStatusError(error.code) from error + raise _HttpStatusError(error.code, _read_error_code(error, deadline=request_deadline)) from error except OSError as error: raise _ServerUnavailableError from error except ValueError as error: @@ -497,6 +498,28 @@ def _post_json( return cast(dict[str, object], result) +def _read_error_code(error: HTTPError, *, deadline: float) -> str | None: + try: + raw = _read_response(error, deadline=deadline) + except (OSError, HTTPException) as failure: + # A stalled, reset, or truncated error body is a transport failure. + raise _ServerUnavailableError from failure + except ValueError as failure: + raise _InvalidResponseError from failure + return _decode_error_code(raw) + + +def _decode_error_code(raw: bytes) -> str | None: + try: + body: Any = json.loads(raw) + except (ValueError, RecursionError): + # Besides JSONDecodeError, json raises ValueError for an over-long integer and RecursionError for deep nesting. + return None + detail = body.get("error") if isinstance(body, dict) else None + code = detail.get("code") if isinstance(detail, dict) else None + return code if isinstance(code, str) else None + + def _request_headers(settings: WorkBuddyPluginSettings) -> dict[str, str]: headers = dict(_REQUEST_HEADERS) if settings.authorization is not None: @@ -549,13 +572,13 @@ def _recall_context( except _HttpStatusError as error: if error.status == 401: outcome = "authentication_failed" - elif error.status == 404: + elif error.status == 404 and error.code is None: outcome = "version_mismatch" elif error.status == 503: outcome = "server_unavailable" else: outcome = "invalid_response" - _emit_context_event(outcome, http_status=error.status) + _emit_context_event(outcome, http_status=error.status, error_code=error.code) return None except (_ServerUnavailableError, TimeoutError): _emit_context_event("server_unavailable") @@ -578,6 +601,7 @@ def _emit_context_event( event_name: str = "context_prepare", reason: str | None = None, http_status: int | None = None, + error_code: str | None = None, context_status: str | None = None, content_bytes: int | None = None, ) -> None: @@ -588,6 +612,8 @@ def _emit_context_event( } if http_status is not None: event["http_status"] = http_status + if error_code is not None: + event["error_code"] = error_code if context_status is not None: event["context_status"] = context_status if content_bytes is not None: diff --git a/integrations/workbuddy/plugins/powercontext/scripts/workspace_scope.py b/integrations/workbuddy/plugins/powercontext/scripts/workspace_scope.py index 6ba7707748..d34100a8f3 100644 --- a/integrations/workbuddy/plugins/powercontext/scripts/workspace_scope.py +++ b/integrations/workbuddy/plugins/powercontext/scripts/workspace_scope.py @@ -25,6 +25,7 @@ import threading from collections.abc import Mapping, Sequence from hashlib import sha256 +from http.client import HTTPException from pathlib import Path from shutil import which from time import monotonic @@ -63,11 +64,12 @@ class ScopeBindingRejectedError(ScopeBindingError): class ScopeBindingStatusError(ScopeBindingError): - """A non-successful HTTP status outside the fixed classifications.""" + """A non-successful HTTP status outside the fixed classifications, with the error code the Server sent.""" - def __init__(self, status: int, path: str) -> None: + def __init__(self, status: int, path: str, code: str | None = None) -> None: self.status = status self.path = path + self.code = code super().__init__(f"PowerContext returned HTTP {status}") @@ -81,13 +83,7 @@ class ScopeBindingSettings(Protocol): class _Response(Protocol): - status: int - - def __enter__(self) -> _Response: ... - - def __exit__(self, *args: object) -> object: ... - - def read(self, amount: int = -1) -> bytes: ... + def read(self, amount: int = -1, /) -> bytes: ... class _RejectRedirects(HTTPRedirectHandler): @@ -247,9 +243,9 @@ def _request_json( headers=headers, method=method, ) + request_timeout = min(settings.request_timeout_seconds, remaining) + request_deadline = min(deadline, monotonic() + request_timeout) try: - request_timeout = min(settings.request_timeout_seconds, remaining) - request_deadline = min(deadline, monotonic() + request_timeout) with open_bounded(request, timeout=request_timeout) as response: if response.status < 200 or response.status >= 300: raise ScopeBindingStatusError(response.status, path) @@ -259,7 +255,7 @@ def _request_json( raise ScopeBindingRejectedError from error if error.code == 503: raise ScopeBindingUnavailableError from error - raise ScopeBindingStatusError(error.code, path) from error + raise ScopeBindingStatusError(error.code, path, _read_error_code(error, deadline=request_deadline)) from error except (OSError, TimeoutError) as error: raise ScopeBindingUnavailableError from error try: @@ -271,6 +267,28 @@ def _request_json( return value +def _decode_error_code(raw: bytes) -> str | None: + """Return the ``error.code`` of one error body, or None when the body carries no code.""" + + try: + body: Any = json.loads(raw) + except (ValueError, RecursionError): + # Besides JSONDecodeError, json raises ValueError for an over-long integer and RecursionError for deep nesting. + return None + detail = body.get("error") if isinstance(body, dict) else None + code = detail.get("code") if isinstance(detail, dict) else None + return code if isinstance(code, str) else None + + +def _read_error_code(error: HTTPError, *, deadline: float) -> str | None: + try: + raw = _read_bounded(error, deadline=deadline) + except (OSError, HTTPException) as failure: + # A stalled, reset, or truncated error body is a transport failure. + raise ScopeBindingUnavailableError from failure + return _decode_error_code(raw) + + def _remaining_time(deadline: float) -> float: remaining = deadline - monotonic() if remaining <= 0: diff --git a/tests/workbuddy_plugin/test_hook.py b/tests/workbuddy_plugin/test_hook.py index e76a4d2237..d249872d45 100644 --- a/tests/workbuddy_plugin/test_hook.py +++ b/tests/workbuddy_plugin/test_hook.py @@ -620,13 +620,28 @@ def log_message(self, format: str, *args: Any) -> None: # noqa: A002 assert target_headers == [] +_UNTRUSTED_BODY = b"untrusted response body" +_UNCODED_404_BODY = json.dumps({"detail": "Not Found"}).encode() +_SCOPE_NOT_FOUND_BODY = json.dumps({ + "error": {"code": "scope_not_found", "message": "The requested Scope was not found.", "details": None} +}).encode() + + @pytest.mark.parametrize( - ("status", "outcome"), + ("status", "body", "outcome", "fields"), [ - (401, "authentication_failed"), - (403, "invalid_response"), - (404, "version_mismatch"), - (503, "server_unavailable"), + pytest.param(401, _UNTRUSTED_BODY, "authentication_failed", {}, id="401"), + pytest.param(403, _UNTRUSTED_BODY, "invalid_response", {"http_status": 403}, id="403"), + pytest.param(404, _UNTRUSTED_BODY, "version_mismatch", {"http_status": 404}, id="404-non-json"), + pytest.param(404, _UNCODED_404_BODY, "version_mismatch", {"http_status": 404}, id="404-uncoded"), + pytest.param( + 404, + _SCOPE_NOT_FOUND_BODY, + "invalid_response", + {"http_status": 404, "error_code": "scope_not_found"}, + id="404-coded", + ), + pytest.param(503, _UNTRUSTED_BODY, "server_unavailable", {}, id="503"), ], ) def test_scope_resolution_failure_emits_the_documented_diagnostic( @@ -634,8 +649,16 @@ def test_scope_resolution_failure_emits_the_documented_diagnostic( monkeypatch: pytest.MonkeyPatch, tmp_path: Path, status: int, + body: bytes, outcome: str, + fields: dict[str, object], ) -> None: + """Only a 404 without an error code means the Server lacks the route. + + A configured Scope that does not exist is a coded 404, for which the version-mismatch advice to + reinstall from one ref does not help. + """ + paths: list[str] = [] class RejectedBindingHandler(BaseHTTPRequestHandler): @@ -644,7 +667,7 @@ def do_POST(self) -> None: paths.append(self.path) self.send_response(status) self.end_headers() - self.wfile.write(b"untrusted response body") + self.wfile.write(body) def log_message(self, format: str, *args: Any) -> None: # noqa: A002 pass @@ -669,5 +692,50 @@ def log_message(self, format: str, *args: Any) -> None: # noqa: A002 "component": "powercontext.workbuddy.recall", "event": "context_prepare", "outcome": outcome, - **({"http_status": status} if status not in {401, 503} else {}), + **fields, + } + + +@pytest.mark.parametrize( + ("body", "outcome", "fields"), + [ + pytest.param(_UNCODED_404_BODY, "version_mismatch", {}, id="uncoded"), + pytest.param(_SCOPE_NOT_FOUND_BODY, "invalid_response", {"error_code": "scope_not_found"}, id="coded"), + ], +) +def test_prepare_404_is_a_version_mismatch_only_without_an_error_code( + hook_module: ModuleType, + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, + body: bytes, + outcome: str, + fields: dict[str, object], +) -> None: + class MissingScopeHandler(BaseHTTPRequestHandler): + def do_POST(self) -> None: + self.rfile.read(int(self.headers.get("Content-Length", "0"))) + if self.path == "/v1/scope-bindings/resolve": + self.send_response(200) + self.end_headers() + self.wfile.write(_SCOPE_BODY) + return + self.send_response(404) + self.end_headers() + self.wfile.write(body) + + def log_message(self, format: str, *args: Any) -> None: # noqa: A002 + pass + + with _serve(MissingScopeHandler) as server_url: + monkeypatch.setenv("POWERCONTEXT_WORKBUDDY_SERVER_URL", server_url) + monkeypatch.setenv("POWERCONTEXT_WORKBUDDY_CAPTURE_PROMPTS", "false") + output, errors = _run_main(hook_module, monkeypatch, {**_payload("what did we decide?"), "cwd": str(tmp_path)}) + + assert json.loads(output)["hookSpecificOutput"]["additionalContext"] == "" + assert json.loads(errors) == { + "component": "powercontext.workbuddy.recall", + "event": "context_prepare", + "outcome": outcome, + "http_status": 404, + **fields, } From 910a5be9a115b10dbea844f8459ee9757e131414 Mon Sep 17 00:00:00 2001 From: Fengzdadi <453788063@qq.com> Date: Sat, 31 Oct 2026 00:20:37 -0400 Subject: [PATCH 2/4] docs(workbuddy): say which diagnostics carry http_status and error_code --- docs/en/docs/integrations/workbuddy.md | 6 +++--- docs/zh/docs/integrations/workbuddy.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/en/docs/integrations/workbuddy.md b/docs/en/docs/integrations/workbuddy.md index 4fc9374bb4..8b23e03f49 100644 --- a/docs/en/docs/integrations/workbuddy.md +++ b/docs/en/docs/integrations/workbuddy.md @@ -300,9 +300,9 @@ blocks normal WorkBuddy work. For a normal empty result or recall failure, the Hook writes one content-free JSON diagnostic to stderr. Outcomes include `empty`, `authentication_failed`, -`version_mismatch`, `server_unavailable`, and `invalid_response`. An HTTP -failure carries `http_status` and, when the Server returned one, its -`error_code`. `version_mismatch` means the Server answered HTTP 404 without an +`version_mismatch`, `server_unavailable`, and `invalid_response`. An event for +an HTTP error can carry `http_status` and, when the Server's error body names +one, `error_code`. `version_mismatch` means the Server answered HTTP 404 without an error code because it does not provide a route the hook requires; install the package and plugin from the same ref. An `invalid_response` event with `error_code: scope_not_found` means the configured Scope does not exist or no diff --git a/docs/zh/docs/integrations/workbuddy.md b/docs/zh/docs/integrations/workbuddy.md index 0c8604144a..f0537acdb4 100644 --- a/docs/zh/docs/integrations/workbuddy.md +++ b/docs/zh/docs/integrations/workbuddy.md @@ -263,8 +263,8 @@ export POWERCONTEXT_WORKBUDDY_AUTHORIZATION="Bearer $POWERCONTEXT_LOCAL_TOKEN" ## 诊断 正常空结果或召回失败时,Hook 会向 stderr 写一行不含正文的 JSON 诊断。outcome 包括 `empty`、 -`authentication_failed`、`version_mismatch`、`server_unavailable` 和 `invalid_response`。HTTP 失败会带上 -`http_status`,Server 返回了错误码时还会带上 `error_code`。`version_mismatch` 表示 Server 对 Hook 依赖的路由 +`authentication_failed`、`version_mismatch`、`server_unavailable` 和 `invalid_response`。HTTP 错误的事件可能带有 +`http_status`,Server 的错误体给出错误码时还会带上 `error_code`。`version_mismatch` 表示 Server 对 Hook 依赖的路由 返回了不带错误码的 HTTP 404,即 Server 不提供该路由;请从同一个 ref 安装 package 和插件。带 `error_code: scope_not_found` 的 `invalid_response` 表示配置的 Scope 不存在,或者没有可解析的绑定。事件不会包含 query、scope、prepared content、citation、response body 或 authorization value。 From cafa16397e39e0c13acc9d5315595870e277cf0c Mon Sep 17 00:00:00 2001 From: Fengzdadi <453788063@qq.com> Date: Sat, 31 Oct 2026 03:15:53 -0400 Subject: [PATCH 3/4] build(opencode): fail opencode-test when the committed bundle is stale --- .gitattributes | 2 ++ Makefile | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 30de316df6..abf206b8e9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,6 +8,8 @@ e2e/bub/tasks/*.yaml text eol=lf integrations/dsh/plugins/powercontext/src/operations.generated.ts text eol=lf integrations/dsh/plugins/powercontext/lib/*.js text eol=lf integrations/dsh/plugins/powercontext/lib/*.d.ts text eol=lf +integrations/opencode/plugins/powercontext/lib/*.js text eol=lf +integrations/opencode/plugins/powercontext/lib/*.d.ts text eol=lf # Generated guidance compares canonical bytes; keep user notes outside its markers untouched. integrations/**/skills/powercontext-project-context/** text eol=lf # Migration evidence hashes exact resource bytes on every platform. diff --git a/Makefile b/Makefile index bb6e355324..8d979d919d 100644 --- a/Makefile +++ b/Makefile @@ -205,11 +205,12 @@ openclaw-plugin-pack: ## Build and pack the external OpenClaw memory plugin. @pnpm --dir integrations/openclaw/plugins/memory-powercontext pack:local .PHONY: opencode-test -opencode-test: ## Install, test, type-check, and build the OpenCode plugin. +opencode-test: ## Install, test, type-check, and build the OpenCode plugin; verify the committed bundle is current. @pnpm --dir integrations/opencode/plugins/powercontext install --frozen-lockfile @pnpm --dir integrations/opencode/plugins/powercontext test @pnpm --dir integrations/opencode/plugins/powercontext run typecheck @pnpm --dir integrations/opencode/plugins/powercontext run build + @git diff --exit-code -- integrations/opencode/plugins/powercontext/lib .PHONY: pi-test pi-test: ## Install and test the Pi package. From 6734e94a72588985c9ee8a5f61a0c8a5365666ee Mon Sep 17 00:00:00 2001 From: Fengzdadi <453788063@qq.com> Date: Sat, 31 Oct 2026 16:25:37 -0400 Subject: [PATCH 4/4] build(opencode): rebuild the bundle with the artifact plugin operations --- .../plugins/powercontext/lib/index.js | 77 +++++++++++++++++++ .../opencode/plugins/powercontext/lib/tui.js | 77 +++++++++++++++++++ 2 files changed, 154 insertions(+) diff --git a/integrations/opencode/plugins/powercontext/lib/index.js b/integrations/opencode/plugins/powercontext/lib/index.js index 0ae26d50aa..d6b59b68ac 100644 --- a/integrations/opencode/plugins/powercontext/lib/index.js +++ b/integrations/opencode/plugins/powercontext/lib/index.js @@ -234,6 +234,83 @@ const OPERATIONS = { successStatuses: [200], emptyStatuses: [] }, + list_artifact_plugins: { + method: "GET", + path: "/v1/admin/artifact-plugins", + location: null, + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + get_artifact_plugin: { + method: "GET", + path: "/v1/admin/artifact-plugins/{binding_name}", + location: null, + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + enable_all_artifact_plugins: { + method: "POST", + path: "/v1/admin/artifact-plugins/enable-all", + location: null, + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + reload_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/reload", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, + enable_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/enable", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, + disable_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/disable", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, + unload_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/unload", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, get_capabilities: { method: "GET", path: "/v1/capabilities", diff --git a/integrations/opencode/plugins/powercontext/lib/tui.js b/integrations/opencode/plugins/powercontext/lib/tui.js index 7e445528eb..71cb04d8f9 100644 --- a/integrations/opencode/plugins/powercontext/lib/tui.js +++ b/integrations/opencode/plugins/powercontext/lib/tui.js @@ -234,6 +234,83 @@ const OPERATIONS = { successStatuses: [200], emptyStatuses: [] }, + list_artifact_plugins: { + method: "GET", + path: "/v1/admin/artifact-plugins", + location: null, + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + get_artifact_plugin: { + method: "GET", + path: "/v1/admin/artifact-plugins/{binding_name}", + location: null, + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + enable_all_artifact_plugins: { + method: "POST", + path: "/v1/admin/artifact-plugins/enable-all", + location: null, + scopeMode: "none", + pathParameters: [], + queryParams: [], + headerParams: [], + successStatuses: [200], + emptyStatuses: [] + }, + reload_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/reload", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, + enable_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/enable", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, + disable_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/disable", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, + unload_artifact_plugin: { + method: "POST", + path: "/v1/admin/artifact-plugins/{binding_name}/unload", + location: "body", + scopeMode: "none", + pathParameters: ["binding_name"], + queryParams: [], + headerParams: [], + successStatuses: [202], + emptyStatuses: [] + }, get_capabilities: { method: "GET", path: "/v1/capabilities",