Files
browser/openspec/changes/implement-platform-mediated-ai-invocation/tasks.md
T
2026-07-11 14:56:10 +08:00

3.8 KiB

1. Platform AI Invocation Contracts

  • 1.1 Add domain and DTO contracts for AI invocation requests, context refs, purposes, recommendations, usage metadata, and safe errors.
  • 1.2 Add validators for purpose authorization, provider IDs, model preferences, bounded input/output, context refs, and unsafe credential/path/socket content.
  • 1.3 Add a platform provider client interface and deterministic mock provider implementation for tests/local verification.

2. Platform AI Invocation Service And API

  • 2.1 Add service methods that authorize purpose-scoped invocation, select enabled providers, call the provider client, redact outputs, and return typed responses.
  • 2.2 Implement AI invocation route using named DTOs and service methods.
  • 2.3 Ensure config-related AI responses produce reviewable recommendations/diffs and never dispatch run-side writes directly.
  • 2.4 Update platform route/protocol documentation for mediated AI invocation and live-provider deferral.
  • 2.5 Add platform tests for allowed invocation, undeclared purpose denial, unsafe payload rejection, provider failure redaction, config recommendation reviewability, and no raw key exposure.

3. Frontend And Plugin Integration

  • 3.1 Add centralized platform_web/api AI invocation types and client methods.
  • 3.2 Integrate AI invocation into plugin bridge host execution flow for ai.invoke responses.
  • 3.3 Add plugin SDK/example helpers for AI invocation request builders and safe response parsing.
  • 3.4 Add frontend and plugin tests for mediated AI requests, denied purposes, redacted results, and no direct provider config exposure.

4. Verification

  • 4.1 Run cd platform && go test ./... and record evidence.
  • 4.2 Run cd platform_web && npm run typecheck && npm test && npm run build and record evidence.
  • 4.3 Run cd plugins && npm run typecheck && npm test and record evidence.
  • 4.4 Run browser walkthrough for mediated AI invocation and record evidence.
  • 4.5 Run scripts/check-structure.sh and record evidence.
  • 4.6 Run openspec validate implement-platform-mediated-ai-invocation --strict and record evidence.

Evidence

  • 2026-07-06: cd platform && GOCACHE=/private/tmp/browser-go-build-cache go test ./... -run TestAIInvocationAPIIsMediatedAndSafe -count=1 passed for mediated invocation, purpose denial, unsafe prompt rejection, config suggestion reviewability/no job dispatch, bridge ai.invoke, and no forbidden response fragments.
  • 2026-07-06: cd platform_web && npm run typecheck and cd platform_web && npm test -- --run api/client.test.ts utils/pluginBridgeHost.test.ts passed for AI invocation API types/client and bridge ai.invoke dispatcher behavior.
  • 2026-07-06: cd plugins && npm run typecheck and cd plugins && npm test -- --run tests/manifest-validation.test.ts passed for SDK AI invocation request/response helpers and no provider config exposure.
  • 2026-07-06: cd platform && GOCACHE=/private/tmp/browser-go-build-cache go test ./... passed.
  • 2026-07-06: cd platform_web && npm run typecheck, cd platform_web && npm test, and cd platform_web && npm run build passed.
  • 2026-07-06: cd plugins && npm run typecheck and cd plugins && npm test passed.
  • 2026-07-06: Browser walkthrough passed using a local mock platform API plus headless Chrome: logged in, opened #/servers/server-ai-walkthrough, switched to 插件控制, clicked AI 调用, verified AI 建议已返回, and confirmed no forbidden credential/path/provider fragments were rendered.
  • 2026-07-06: scripts/check-structure.sh passed.
  • 2026-07-06: openspec validate implement-platform-mediated-ai-invocation --strict passed (Change 'implement-platform-mediated-ai-invocation' is valid; PostHog DNS flush warnings were non-fatal telemetry failures).