File size: 3,724 Bytes
4e7644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { request } from "../request";

export interface HarnessProvider {
  id: string;
  name: string;
  available: boolean;
  coming_soon: boolean;
  installed: boolean;
  authenticated: boolean;
  account: {
    type?: string;
    username?: string | null;
    email?: string | null;
    planType?: string;
  } | null;
  runtime_path: string | null;
  runtime_source: string | null;
  error: string | null;
  capabilities: HarnessCapabilities;
}

export interface HarnessCommand {
  name: string;
  description: string;
  accepts_arguments: boolean;
}

export interface HarnessApprovalPreset {
  id: string;
  name: string;
  description: string;
  settings: Record<string, unknown>;
}

export interface HarnessCapabilities {
  authentication: boolean;
  model_selection: boolean;
  reasoning_effort: boolean;
  reasoning_stream: boolean;
  tool_stream: boolean;
  session_resume: boolean;
  workspace_ui: boolean;
  native_skills_ui: boolean;
  native_tools_ui: boolean;
  native_mcp_ui: boolean;
  loop_modes: boolean;
  attachments: boolean;
  context_usage: boolean;
  skills_commands: boolean;
  qwenpaw_skills_projection: boolean;
  qwenpaw_mcp_projection: boolean;
  provider_skills_discovery: boolean;
  provider_mcp_discovery: boolean;
  mcp_tool_allowlist: boolean;
  commands: HarnessCommand[];
  approval_presets: HarnessApprovalPreset[];
}

export interface HarnessModel {
  id: string;
  name: string;
  description: string;
  is_default: boolean;
  reasoning_efforts: string[];
  default_reasoning_effort: string | null;
}

export interface HarnessDiscoveredMCPServer {
  name: string;
  provider_id: string;
  transport: string;
  enabled: boolean;
  auth_status: string;
  read_only: boolean;
  scope: "provider";
}

export interface HarnessDiscoveredSkill {
  name: string;
  description: string;
  provider_id: string;
  source: string;
  enabled: boolean;
  read_only: boolean;
  scope: "provider";
}

export interface HarnessLogin {
  type: string;
  loginId: string;
  authUrl?: string;
  verificationUrl?: string;
  userCode?: string;
  command?: string;
}

export const harnessApi = {
  list: () =>
    request<{ providers: HarnessProvider[] }>("/harnesses", {
      timeout: 60_000,
    }),
  listModels: (providerId: string) =>
    request<{ models: HarnessModel[]; message?: string }>(
      `/harnesses/${encodeURIComponent(providerId)}/models`,
      { timeout: 60_000 },
    ),
  listMCP: (providerId: string) =>
    request<{ servers: HarnessDiscoveredMCPServer[]; message?: string }>(
      `/harnesses/${encodeURIComponent(providerId)}/mcp`,
      { timeout: 60_000 },
    ),
  listSkills: (providerId: string) =>
    request<{ skills: HarnessDiscoveredSkill[]; message?: string }>(
      `/harnesses/${encodeURIComponent(providerId)}/skills`,
      { timeout: 60_000 },
    ),
  status: (providerId: string, settings: Record<string, unknown> = {}) =>
    request<HarnessProvider>(
      `/harnesses/${encodeURIComponent(providerId)}/status`,
      {
        method: "POST",
        body: JSON.stringify({ settings }),
        timeout: 60_000,
      },
    ),
  login: (
    providerId: string,
    deviceCode = false,
    settings: Record<string, unknown> = {},
  ) =>
    request<HarnessLogin>(
      `/harnesses/${encodeURIComponent(providerId)}/login`,
      {
        method: "POST",
        body: JSON.stringify({
          device_code: deviceCode,
          settings,
        }),
        timeout: 60_000,
      },
    ),
  logout: (providerId: string, settings: Record<string, unknown> = {}) =>
    request<{ ok: boolean }>(
      `/harnesses/${encodeURIComponent(providerId)}/logout`,
      {
        method: "POST",
        body: JSON.stringify({ settings }),
      },
    ),
};