@bpmsoftwaresolutions/ai-engine-client 0.1.0 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +342 -69
- package/package.json +1 -1
- package/src/index.js +1012 -162
package/src/index.js
CHANGED
|
@@ -1,162 +1,1012 @@
|
|
|
1
|
-
const DEFAULT_TIMEOUT_MS = 30000;
|
|
2
|
-
|
|
3
|
-
function trimTrailingSlash(value) {
|
|
4
|
-
return String(value || '').replace(/\/+$/, '');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function appendQuery(url, query) {
|
|
8
|
-
const target = new URL(url);
|
|
9
|
-
for (const [key, value] of Object.entries(query || {})) {
|
|
10
|
-
if (value === undefined || value === null || value === '')
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
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
|
-
async getSymbolDefinition({ symbolKey, qualifiedName, symbolName, projectScope, includeCode = true, maxLines = 120, requestedBy } = {}) {
|
|
102
|
-
return this._request('/api/operator/retrieval/wrapper/symbol-definition', {
|
|
103
|
-
query: {
|
|
104
|
-
symbol_key: symbolKey,
|
|
105
|
-
qualified_name: qualifiedName,
|
|
106
|
-
symbol_name: symbolName,
|
|
107
|
-
project_scope: projectScope,
|
|
108
|
-
include_code: includeCode,
|
|
109
|
-
max_lines: maxLines,
|
|
110
|
-
requested_by: requestedBy
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async getRelatedCode({ symbolKey, qualifiedName, relationshipType, depth = 1, includeCode = false, maxLines = 80, requestedBy } = {}) {
|
|
116
|
-
return this._request('/api/operator/retrieval/wrapper/related-code', {
|
|
117
|
-
query: {
|
|
118
|
-
symbol_key: symbolKey,
|
|
119
|
-
qualified_name: qualifiedName,
|
|
120
|
-
relationship_type: relationshipType,
|
|
121
|
-
depth,
|
|
122
|
-
include_code: includeCode,
|
|
123
|
-
max_lines: maxLines,
|
|
124
|
-
requested_by: requestedBy
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
1
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
2
|
+
|
|
3
|
+
function trimTrailingSlash(value) {
|
|
4
|
+
return String(value || '').replace(/\/+$/, '');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function appendQuery(url, query) {
|
|
8
|
+
const target = new URL(url);
|
|
9
|
+
for (const [key, value] of Object.entries(query || {})) {
|
|
10
|
+
if (value === undefined || value === null || value === '') continue;
|
|
11
|
+
target.searchParams.set(key, String(value));
|
|
12
|
+
}
|
|
13
|
+
return target;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function readJson(response) {
|
|
17
|
+
const contentType = response.headers.get('content-type') || '';
|
|
18
|
+
if (contentType.includes('application/json')) return response.json();
|
|
19
|
+
const text = await response.text();
|
|
20
|
+
return { message: text };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class AIEngineClient {
|
|
24
|
+
constructor({ baseUrl, apiKey, actorId, fetchImpl, timeoutMs } = {}) {
|
|
25
|
+
if (!baseUrl) throw new Error('baseUrl is required.');
|
|
26
|
+
this.baseUrl = trimTrailingSlash(baseUrl);
|
|
27
|
+
this.apiKey = apiKey || null;
|
|
28
|
+
this.actorId = actorId || 'sdk:npm-ai-engine-client';
|
|
29
|
+
this.fetchImpl = fetchImpl || globalThis.fetch;
|
|
30
|
+
this.timeoutMs = timeoutMs || DEFAULT_TIMEOUT_MS;
|
|
31
|
+
if (typeof this.fetchImpl !== 'function') {
|
|
32
|
+
throw new Error('A fetch implementation is required. Use Node 18+ or supply fetchImpl.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static fromEnv(options = {}) {
|
|
37
|
+
return new AIEngineClient({
|
|
38
|
+
baseUrl: options.baseUrl || process.env.AI_ENGINE_BASE_URL || process.env.AI_ENGINE_API_BASE_URL,
|
|
39
|
+
apiKey: options.apiKey || process.env.AI_ENGINE_API_KEY || null,
|
|
40
|
+
actorId: options.actorId || process.env.AI_ENGINE_ACTOR_ID || 'sdk:npm-ai-engine-client',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ─── Health ────────────────────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
async ping() {
|
|
47
|
+
const [health, workflow] = await Promise.all([
|
|
48
|
+
this._request('/healthz'),
|
|
49
|
+
this.currentWorkflowStatus(),
|
|
50
|
+
]);
|
|
51
|
+
return {
|
|
52
|
+
status: health.status || 'ok',
|
|
53
|
+
workflow_name: workflow?.summary?.workflow_name || null,
|
|
54
|
+
run_status: workflow?.summary?.run_status || null,
|
|
55
|
+
base_url: this.baseUrl,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ─── Operator Status ───────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
async currentWorkflowStatus() {
|
|
62
|
+
return this._request('/api/operator/current-workflow-status');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async currentArchitectureIntegrityStatus() {
|
|
66
|
+
return this._request('/api/operator/current-architecture-integrity-status');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async currentSecurityGovernanceStatus({ environment, topN } = {}) {
|
|
70
|
+
return this._request('/api/operator/current-security-governance-status', {
|
|
71
|
+
query: { environment, top_n: topN },
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async currentCodebaseShapeStatus() {
|
|
76
|
+
return this._request('/api/operator/current-codebase-shape-status');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getLatestMemoryProjection() {
|
|
80
|
+
return this._request('/api/operator/latest-memory-projection');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async getDashboard() {
|
|
84
|
+
return this._request('/api/dashboard');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ─── Retrieval Wrapper ─────────────────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
async getCommandCard({ commandKey, alias, intentText, requestedBy } = {}) {
|
|
90
|
+
return this._request('/api/operator/retrieval/wrapper/command-card', {
|
|
91
|
+
query: { command_key: commandKey, alias, intent_text: intentText, requested_by: requestedBy },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async resolveOperatingProcedure({ procedureKey, intentText, requestedBy } = {}) {
|
|
96
|
+
return this._request('/api/operator/retrieval/wrapper/operating-procedure', {
|
|
97
|
+
query: { procedure_key: procedureKey, intent_text: intentText, requested_by: requestedBy },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getSymbolDefinition({ symbolKey, qualifiedName, symbolName, projectScope, includeCode = true, maxLines = 120, requestedBy } = {}) {
|
|
102
|
+
return this._request('/api/operator/retrieval/wrapper/symbol-definition', {
|
|
103
|
+
query: {
|
|
104
|
+
symbol_key: symbolKey,
|
|
105
|
+
qualified_name: qualifiedName,
|
|
106
|
+
symbol_name: symbolName,
|
|
107
|
+
project_scope: projectScope,
|
|
108
|
+
include_code: includeCode,
|
|
109
|
+
max_lines: maxLines,
|
|
110
|
+
requested_by: requestedBy,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async getRelatedCode({ symbolKey, qualifiedName, relationshipType, depth = 1, includeCode = false, maxLines = 80, requestedBy } = {}) {
|
|
116
|
+
return this._request('/api/operator/retrieval/wrapper/related-code', {
|
|
117
|
+
query: {
|
|
118
|
+
symbol_key: symbolKey,
|
|
119
|
+
qualified_name: qualifiedName,
|
|
120
|
+
relationship_type: relationshipType,
|
|
121
|
+
depth,
|
|
122
|
+
include_code: includeCode,
|
|
123
|
+
max_lines: maxLines,
|
|
124
|
+
requested_by: requestedBy,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ─── Repo Inventory ───────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
async listRepositories({ limit } = {}) {
|
|
132
|
+
return this._request('/api/repo/repositories', {
|
|
133
|
+
query: { limit },
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async getRepository(repositoryId) {
|
|
138
|
+
return this._request(`/api/repo/repositories/${repositoryId}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async listProjects({ repositoryId, repoKey, limit } = {}) {
|
|
142
|
+
return this._request('/api/repo/projects', {
|
|
143
|
+
query: { repository_id: repositoryId, repo_key: repoKey, limit },
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async getProject(projectId) {
|
|
148
|
+
return this._request(`/api/repo/projects/${projectId}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async listCodeFiles({ repositoryId, projectId, language, pathPrefix, page = 1, pageSize = 50 } = {}) {
|
|
152
|
+
return this._request('/api/repo/files', {
|
|
153
|
+
query: {
|
|
154
|
+
repository_id: repositoryId,
|
|
155
|
+
project_id: projectId,
|
|
156
|
+
language,
|
|
157
|
+
path_prefix: pathPrefix,
|
|
158
|
+
page,
|
|
159
|
+
page_size: pageSize,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async getCodeFile(fileId) {
|
|
165
|
+
return this._request(`/api/repo/files/${fileId}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async listCodeSymbolsByFile(fileId, { limit = 500 } = {}) {
|
|
169
|
+
return this._request(`/api/repo/files/${fileId}/symbols`, {
|
|
170
|
+
query: { limit },
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async getCodeSymbol(symbolId, { includeCode = false, maxLines = 120 } = {}) {
|
|
175
|
+
return this._request(`/api/repo/symbols/${symbolId}`, {
|
|
176
|
+
query: { include_code: includeCode, max_lines: maxLines },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async searchSymbols({ query, projectScope, maxResults = 10 } = {}) {
|
|
181
|
+
return this._request('/api/repo/symbols/search', {
|
|
182
|
+
query: { query, project_scope: projectScope, max_results: maxResults },
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async getSymbolRelationships(symbolId, { relationshipType, depth = 1 } = {}) {
|
|
187
|
+
return this._request(`/api/repo/symbols/${symbolId}/relationships`, {
|
|
188
|
+
query: { relationship_type: relationshipType, depth },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ─── Retrieval Management ──────────────────────────────────────────────────
|
|
193
|
+
|
|
194
|
+
async getRetrievalStatus() {
|
|
195
|
+
return this._request('/api/operator/retrieval/status');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async getRetrievalProfileMetrics() {
|
|
199
|
+
return this._request('/api/operator/retrieval/profiles/metrics');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async getRetrievalFeedbackMetrics() {
|
|
203
|
+
return this._request('/api/operator/retrieval/feedback-metrics');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async getRetrievalQuery(retrievalQueryId) {
|
|
207
|
+
return this._request(`/api/operator/retrieval/queries/${retrievalQueryId}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async getRetrievalPacket(retrievalPacketId) {
|
|
211
|
+
return this._request(`/api/operator/retrieval/packets/${retrievalPacketId}`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async generateRetrievalCandidates(body) {
|
|
215
|
+
return this._request('/api/operator/retrieval/generate-candidates', { method: 'POST', body });
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async selectRetrievalPacket(body) {
|
|
219
|
+
return this._request('/api/operator/retrieval/select-packet', { method: 'POST', body });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async recordRetrievalFeedback(body) {
|
|
223
|
+
return this._request('/api/operator/retrieval/feedback', { method: 'POST', body });
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async deriveRetrievalOptimizationCandidates(body) {
|
|
227
|
+
return this._request('/api/operator/retrieval/optimization-candidates', { method: 'POST', body });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async validatePromptAssembly(body) {
|
|
231
|
+
return this._request('/api/operator/retrieval/validate-prompt-assembly', { method: 'POST', body });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ─── Workflows ─────────────────────────────────────────────────────────────
|
|
235
|
+
|
|
236
|
+
async listWorkflows({ status, includeSteps } = {}) {
|
|
237
|
+
return this._request('/api/workflows', {
|
|
238
|
+
query: { status, include_steps: includeSteps },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async createWorkflow({ name, slug, description, goal, governanceProfile, steps = [] } = {}) {
|
|
243
|
+
return this._request('/api/workflows', {
|
|
244
|
+
method: 'POST',
|
|
245
|
+
body: { name, slug, description, goal, governance_profile: governanceProfile, steps },
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async getWorkflow(workflowId) {
|
|
250
|
+
return this._request(`/api/workflows/${workflowId}`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async replaceWorkflowSteps(workflowId, steps) {
|
|
254
|
+
return this._request(`/api/workflows/${workflowId}/steps`, { method: 'PUT', body: { steps } });
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async publishWorkflow(workflowId) {
|
|
258
|
+
return this._request(`/api/workflows/${workflowId}/publish`, { method: 'POST' });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async cloneWorkflow(workflowId) {
|
|
262
|
+
return this._request(`/api/workflows/${workflowId}/clone`, { method: 'POST' });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ─── Workflow Governance ───────────────────────────────────────────────────
|
|
266
|
+
|
|
267
|
+
async evaluateWorkflowGovernance(workflowId) {
|
|
268
|
+
return this._request(`/api/workflows/${workflowId}/governance/evaluate`, { method: 'POST' });
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
async listWorkflowGovernanceDecisions(workflowId) {
|
|
272
|
+
return this._request(`/api/workflows/${workflowId}/governance/decisions`);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async getWorkflowGovernanceSimulation(workflowId) {
|
|
276
|
+
return this._request(`/api/workflows/${workflowId}/governance/simulation`);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async listWorkflowGovernanceBundles(workflowId) {
|
|
280
|
+
return this._request(`/api/workflows/${workflowId}/governance/bundles`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async listWorkflowGovernanceApprovals(workflowId) {
|
|
284
|
+
return this._request(`/api/workflows/${workflowId}/governance/approvals`);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async listWorkflowGovernanceEvents(workflowId) {
|
|
288
|
+
return this._request(`/api/workflows/${workflowId}/governance/events`);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async getWorkflowGovernanceReview(workflowId) {
|
|
292
|
+
return this._request(`/api/workflows/${workflowId}/governance/review`);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async createWorkflowGovernanceReviewDecision(workflowId, body) {
|
|
296
|
+
return this._request(`/api/workflows/${workflowId}/governance/review-decisions`, {
|
|
297
|
+
method: 'POST', body,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ─── Workflow Runs ─────────────────────────────────────────────────────────
|
|
302
|
+
|
|
303
|
+
async createWorkflowRun(body) {
|
|
304
|
+
return this._request('/api/workflow-runs', { method: 'POST', body });
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async getWorkflowRun(workflowRunId) {
|
|
308
|
+
return this._request(`/api/workflow-runs/${workflowRunId}`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async listWorkflowArtifacts(workflowRunId) {
|
|
312
|
+
return this._request(`/api/workflow-runs/${workflowRunId}/artifacts`);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async getWorkflowRunSubstrate(workflowRunId) {
|
|
316
|
+
return this._request(`/api/workflow-runs/${workflowRunId}/substrate`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async resumeWorkflowRun(workflowRunId, body = {}) {
|
|
320
|
+
return this._request(`/api/workflow-runs/${workflowRunId}/resume`, { method: 'POST', body });
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// ─── Workflow Inspector ────────────────────────────────────────────────────
|
|
324
|
+
|
|
325
|
+
async listRecentInspectorRuns({ limit } = {}) {
|
|
326
|
+
return this._request('/api/workflow-inspector/runs/recent', { query: { limit } });
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async inspectWorkflowRun(workflowRunId) {
|
|
330
|
+
return this._request(`/api/workflow-inspector/runs/${workflowRunId}`);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ─── Manual & Approval Tasks ───────────────────────────────────────────────
|
|
334
|
+
|
|
335
|
+
async listManualTasks() {
|
|
336
|
+
return this._request('/api/manual-tasks');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async listApprovalTasks() {
|
|
340
|
+
return this._request('/api/approval-tasks');
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async completeManualTask(stepRunId, body = {}) {
|
|
344
|
+
return this._request(`/api/manual-tasks/${stepRunId}/complete`, { method: 'POST', body });
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async approveTask(stepRunId, body = {}) {
|
|
348
|
+
return this._request(`/api/approval-tasks/${stepRunId}/approve`, { method: 'POST', body });
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// ─── Projects & Chartering ─────────────────────────────────────────────────
|
|
352
|
+
|
|
353
|
+
async createProjectCharter({
|
|
354
|
+
projectName,
|
|
355
|
+
objective,
|
|
356
|
+
businessContext,
|
|
357
|
+
successCriteria,
|
|
358
|
+
priority,
|
|
359
|
+
constraints = [],
|
|
360
|
+
inScope = [],
|
|
361
|
+
outOfScope = [],
|
|
362
|
+
assumptions = [],
|
|
363
|
+
linkedWorkflows = [],
|
|
364
|
+
testingStrategy = {},
|
|
365
|
+
initialContext = {},
|
|
366
|
+
requestedBy,
|
|
367
|
+
} = {}) {
|
|
368
|
+
return this._request('/api/projects/charter', {
|
|
369
|
+
method: 'POST',
|
|
370
|
+
body: {
|
|
371
|
+
project_name: projectName,
|
|
372
|
+
objective,
|
|
373
|
+
business_context: businessContext,
|
|
374
|
+
success_criteria: successCriteria,
|
|
375
|
+
priority,
|
|
376
|
+
constraints,
|
|
377
|
+
in_scope: inScope,
|
|
378
|
+
out_of_scope: outOfScope,
|
|
379
|
+
assumptions,
|
|
380
|
+
linked_workflows: linkedWorkflows,
|
|
381
|
+
testing_strategy: testingStrategy,
|
|
382
|
+
initial_context: initialContext,
|
|
383
|
+
requested_by: requestedBy,
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async listProjects({ limit, includeInactive, processStatus, charterStatus } = {}) {
|
|
389
|
+
return this._request('/api/operator/projects', {
|
|
390
|
+
query: {
|
|
391
|
+
limit,
|
|
392
|
+
include_inactive: includeInactive,
|
|
393
|
+
process_status: processStatus,
|
|
394
|
+
charter_status: charterStatus,
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async getProject(projectId) {
|
|
400
|
+
return this._request(`/api/operator/projects/${projectId}`);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// ─── Roadmaps ──────────────────────────────────────────────────────────────
|
|
404
|
+
|
|
405
|
+
async listProjectRoadmaps({ includeInactive } = {}) {
|
|
406
|
+
return this._request('/api/operator/projects/implementation-roadmaps', {
|
|
407
|
+
query: { include_inactive: includeInactive },
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
async getProjectRoadmap(projectId) {
|
|
412
|
+
return this._request(`/api/operator/projects/${projectId}/implementation-roadmap`);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
async getProjectRoadmapSummary(projectId) {
|
|
416
|
+
return this._request(`/api/operator/projects/${projectId}/implementation-roadmap/summary`);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async getProjectRoadmapActiveItem(projectId) {
|
|
420
|
+
return this._request(`/api/operator/projects/${projectId}/implementation-roadmap/active-item`);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
async listProjectOpenTasks(projectId) {
|
|
424
|
+
return this._request(`/api/operator/projects/${projectId}/open-tasks`);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async getProjectPerformanceMetrics(projectId, { workflowId, workflowRunId, sinceUtc } = {}) {
|
|
428
|
+
return this._request(`/api/operator/projects/${projectId}/performance-metrics`, {
|
|
429
|
+
query: { workflow_id: workflowId, workflow_run_id: workflowRunId, since_utc: sinceUtc },
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// ─── Implementation Tasks ──────────────────────────────────────────────────
|
|
434
|
+
|
|
435
|
+
async createImplementationTask(implementationItemId, {
|
|
436
|
+
title,
|
|
437
|
+
implementationPacketId,
|
|
438
|
+
description,
|
|
439
|
+
priority,
|
|
440
|
+
assignedTo,
|
|
441
|
+
assignedBy,
|
|
442
|
+
dueAt,
|
|
443
|
+
sortOrder,
|
|
444
|
+
notes,
|
|
445
|
+
createdBy,
|
|
446
|
+
parentTaskId,
|
|
447
|
+
} = {}) {
|
|
448
|
+
return this._request(`/api/operator/implementation-items/${implementationItemId}/tasks`, {
|
|
449
|
+
method: 'POST',
|
|
450
|
+
body: {
|
|
451
|
+
title,
|
|
452
|
+
implementation_packet_id: implementationPacketId,
|
|
453
|
+
description,
|
|
454
|
+
priority,
|
|
455
|
+
assigned_to: assignedTo,
|
|
456
|
+
assigned_by: assignedBy,
|
|
457
|
+
due_at: dueAt,
|
|
458
|
+
sort_order: sortOrder,
|
|
459
|
+
notes,
|
|
460
|
+
created_by: createdBy,
|
|
461
|
+
parent_task_id: parentTaskId,
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async listImplementationTasks(implementationItemId) {
|
|
467
|
+
return this._request(`/api/operator/implementation-items/${implementationItemId}/tasks`);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async listImplementationSubtasks(taskId) {
|
|
471
|
+
return this._request(`/api/operator/implementation-item-tasks/${taskId}/subtasks`);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async updateImplementationTask(taskId, updates) {
|
|
475
|
+
return this._request(`/api/operator/implementation-item-tasks/${taskId}`, {
|
|
476
|
+
method: 'PATCH',
|
|
477
|
+
body: updates,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
async assignImplementationTask(taskId, { assignedTo, assignedBy } = {}) {
|
|
482
|
+
return this._request(`/api/operator/implementation-item-tasks/${taskId}/assign`, {
|
|
483
|
+
method: 'POST',
|
|
484
|
+
body: { assigned_to: assignedTo, assigned_by: assignedBy },
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
async completeImplementationTask(taskId, { completedBy } = {}) {
|
|
489
|
+
return this._request(`/api/operator/implementation-item-tasks/${taskId}/complete`, {
|
|
490
|
+
method: 'POST',
|
|
491
|
+
body: { completed_by: completedBy },
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// ─── Governed Implementation ───────────────────────────────────────────────
|
|
496
|
+
|
|
497
|
+
async importImplementationPacket(body) {
|
|
498
|
+
return this._request('/api/governed-implementation/packets/import', { method: 'POST', body });
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async listImplementationPackets({ status, packetType } = {}) {
|
|
502
|
+
return this._request('/api/governed-implementation/packets', {
|
|
503
|
+
query: { status, packet_type: packetType },
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
async getImplementationPacket(packetId) {
|
|
508
|
+
return this._request(`/api/governed-implementation/packets/${packetId}`);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async updateImplementationItemStatus(implementationItemId, body) {
|
|
512
|
+
return this._request(`/api/governed-implementation/items/${implementationItemId}/status`, {
|
|
513
|
+
method: 'PATCH', body,
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
async addImplementationItemEvidence(implementationItemId, body) {
|
|
518
|
+
return this._request(`/api/governed-implementation/items/${implementationItemId}/evidence`, {
|
|
519
|
+
method: 'POST', body,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
async addImplementationItemActivity(implementationItemId, body) {
|
|
524
|
+
return this._request(`/api/governed-implementation/items/${implementationItemId}/activity`, {
|
|
525
|
+
method: 'POST', body,
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async listImplementationItemActivity(implementationItemId) {
|
|
530
|
+
return this._request(`/api/governed-implementation/items/${implementationItemId}/activity`);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
async updateAcceptanceCheckStatus(implementationItemId, acceptanceCheckId, body) {
|
|
534
|
+
return this._request(
|
|
535
|
+
`/api/governed-implementation/items/${implementationItemId}/acceptance-checks/${acceptanceCheckId}/status`,
|
|
536
|
+
{ method: 'PATCH', body }
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
async createImplementationPacketGateDecision(packetId, body) {
|
|
541
|
+
return this._request(`/api/governed-implementation/packets/${packetId}/gate-decisions`, {
|
|
542
|
+
method: 'POST', body,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
async bindImplementationPacketToWorkflow(workflowId, body) {
|
|
547
|
+
return this._request(`/api/governed-implementation/workflows/${workflowId}/bindings`, {
|
|
548
|
+
method: 'POST', body,
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
async getWorkflowImplementationRoadmap(workflowId) {
|
|
553
|
+
return this._request(`/api/governed-implementation/workflows/${workflowId}/roadmap`);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async getWorkflowResumeContext(workflowId) {
|
|
557
|
+
return this._request(`/api/governed-implementation/workflows/${workflowId}/resume-context`);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ─── Skills ────────────────────────────────────────────────────────────────
|
|
561
|
+
|
|
562
|
+
async currentSkillRegistryStatus() {
|
|
563
|
+
return this._request('/api/operator/current-skill-registry-status');
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
async getSkillContract({ skillId, skillKey } = {}) {
|
|
567
|
+
return this._request('/api/skills/contract', { query: { skill_id: skillId, skill_key: skillKey } });
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
async getSkillGovernance({ skillId, skillKey, skillVersionId } = {}) {
|
|
571
|
+
return this._request('/api/operator/skills/governance', {
|
|
572
|
+
query: { skill_id: skillId, skill_key: skillKey, skill_version_id: skillVersionId },
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
async createSkillContractDraft(body) {
|
|
577
|
+
return this._request('/api/operator/skills/contracts/drafts', { method: 'POST', body });
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
async recordSkillPatternReview(skillVersionId, body) {
|
|
581
|
+
return this._request(`/api/operator/skills/contracts/${skillVersionId}/pattern-reviews`, {
|
|
582
|
+
method: 'POST', body,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
async approveSkillContract(skillVersionId, body = {}) {
|
|
587
|
+
return this._request(`/api/operator/skills/contracts/${skillVersionId}/approve`, {
|
|
588
|
+
method: 'POST', body,
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
async createWorkflowSkillContract(body) {
|
|
593
|
+
return this._request('/api/skills/workflow-contracts', { method: 'POST', body });
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
async listWorkflowSkillBindings(workflowId, { workflowStepId } = {}) {
|
|
597
|
+
return this._request(`/api/workflows/${workflowId}/skill-bindings`, {
|
|
598
|
+
query: { workflow_step_id: workflowStepId },
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async seedFrequentOperationSkills({ createdBy } = {}) {
|
|
603
|
+
return this._request('/api/operator/skills/seed-frequent-operations', {
|
|
604
|
+
method: 'POST',
|
|
605
|
+
body: { created_by: createdBy },
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// ─── Skill Governance ──────────────────────────────────────────────────────
|
|
610
|
+
|
|
611
|
+
async createSkillGovernanceChange(body) {
|
|
612
|
+
return this._request('/api/operator/skill-governance/changes', { method: 'POST', body });
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
async listSkillGovernanceChanges({ limit, processStatus, changeStatus } = {}) {
|
|
616
|
+
return this._request('/api/operator/skill-governance/changes', {
|
|
617
|
+
query: { limit, process_status: processStatus, change_status: changeStatus },
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
async getSkillGovernanceChange(governanceChangeId) {
|
|
622
|
+
return this._request(`/api/operator/skill-governance/changes/${governanceChangeId}`);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// ─── Capabilities ──────────────────────────────────────────────────────────
|
|
626
|
+
|
|
627
|
+
async listCapabilities() {
|
|
628
|
+
return this._request('/api/capabilities');
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
async createCapability(body) {
|
|
632
|
+
return this._request('/api/capabilities', { method: 'POST', body });
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
async testCapability(capabilityId, body = {}) {
|
|
636
|
+
return this._request(`/api/capabilities/${capabilityId}/test`, { method: 'POST', body });
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// ─── Tool Registry ─────────────────────────────────────────────────────────
|
|
640
|
+
|
|
641
|
+
async currentToolRegistryStatus() {
|
|
642
|
+
return this._request('/api/operator/current-tool-registry-status');
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async getWorkflowToolRegistry({ workflowId, workflowSlug } = {}) {
|
|
646
|
+
return this._request('/api/operator/workflow-tool-registry', {
|
|
647
|
+
query: { workflow_id: workflowId, workflow_slug: workflowSlug },
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
async currentAssistantToolContext() {
|
|
652
|
+
return this._request('/api/operator/current-assistant-tool-context');
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
async getTool(toolKey) {
|
|
656
|
+
return this._request(`/api/tools/${toolKey}`);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
async getToolHistory(toolKey) {
|
|
660
|
+
return this._request(`/api/tools/${toolKey}/history`);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
async getToolInvocations(toolKey) {
|
|
664
|
+
return this._request(`/api/tools/${toolKey}/invocations`);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
async getToolGovernance(toolKey) {
|
|
668
|
+
return this._request(`/api/tools/${toolKey}/governance`);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
async getToolEventReplayBundle(toolEventSummaryId) {
|
|
672
|
+
return this._request(`/api/operator/tool-events/${toolEventSummaryId}/replay-bundle`);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
async createToolReviewDecision(toolKey, body) {
|
|
676
|
+
return this._request(`/api/governance/tools/${toolKey}/review-decisions`, {
|
|
677
|
+
method: 'POST', body,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
async createToolGateDecision(toolKey, body) {
|
|
682
|
+
return this._request(`/api/governance/tools/${toolKey}/gate-decisions`, {
|
|
683
|
+
method: 'POST', body,
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// ─── Context Assembly ──────────────────────────────────────────────────────
|
|
688
|
+
|
|
689
|
+
async getContextAssemblyContract(workflowRunId, { stepRunId } = {}) {
|
|
690
|
+
return this._request(`/api/context-assembly/workflow-runs/${workflowRunId}/contract`, {
|
|
691
|
+
query: { step_run_id: stepRunId },
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
async getContextAssemblyStatus(workflowRunId, { stepRunId } = {}) {
|
|
696
|
+
return this._request(`/api/context-assembly/workflow-runs/${workflowRunId}/status`, {
|
|
697
|
+
query: { step_run_id: stepRunId },
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
async getOperatorContext(workflowRunId, { stepRunId } = {}) {
|
|
702
|
+
return this._request(`/api/operator/runs/${workflowRunId}/context`, {
|
|
703
|
+
query: { step_run_id: stepRunId },
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
async getContextFragments(workflowRunId, { stepRunId } = {}) {
|
|
708
|
+
return this._request(`/api/operator/runs/${workflowRunId}/context/fragments`, {
|
|
709
|
+
query: { step_run_id: stepRunId },
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
async getContextReuse(workflowRunId, { stepRunId } = {}) {
|
|
714
|
+
return this._request(`/api/operator/runs/${workflowRunId}/context/reuse`, {
|
|
715
|
+
query: { step_run_id: stepRunId },
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
async listPromptAssemblies(workflowRunId) {
|
|
720
|
+
return this._request(`/api/operator/workflow-runs/${workflowRunId}/prompt-assemblies`);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// ─── Performance ───────────────────────────────────────────────────────────
|
|
724
|
+
|
|
725
|
+
async getSessionPerformanceMetrics({ clientType, workflowRunId, sessionId } = {}) {
|
|
726
|
+
return this._request('/api/operator/performance/sessions', {
|
|
727
|
+
query: { client_type: clientType, workflow_run_id: workflowRunId, session_id: sessionId },
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
async captureBenchmarkSnapshot(body) {
|
|
732
|
+
return this._request('/api/operator/performance/benchmarks', { method: 'POST', body });
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
async listBenchmarks({ benchmarkScope } = {}) {
|
|
736
|
+
return this._request('/api/operator/performance/benchmarks', {
|
|
737
|
+
query: { benchmark_scope: benchmarkScope },
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
async getBenchmarkMetrics(benchmarkName) {
|
|
742
|
+
return this._request(`/api/operator/performance/benchmarks/${benchmarkName}/metrics`);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
async getBenchmarkDelta({ baseline, current } = {}) {
|
|
746
|
+
return this._request('/api/operator/performance/delta', { query: { baseline, current } });
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
async getBenchmarkTrend({ metricKey, dimensionValue, limit } = {}) {
|
|
750
|
+
return this._request('/api/operator/performance/trend', {
|
|
751
|
+
query: { metric_key: metricKey, dimension_value: dimensionValue, limit },
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
async getPerformanceDashboard({ clientType, workflowRunId } = {}) {
|
|
756
|
+
return this._request('/api/operator/performance/dashboard', {
|
|
757
|
+
query: { client_type: clientType, workflow_run_id: workflowRunId },
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// ─── Portfolio ─────────────────────────────────────────────────────────────
|
|
762
|
+
|
|
763
|
+
async getPortfolioStatus({ projectId } = {}) {
|
|
764
|
+
return this._request('/api/operator/portfolio/status', { query: { project_id: projectId } });
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
async getPortfolioSummary() {
|
|
768
|
+
return this._request('/api/operator/portfolio/summary');
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
async getPortfolioExceptions() {
|
|
772
|
+
return this._request('/api/operator/portfolio/exceptions');
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
async getPortfolioProject(projectId) {
|
|
776
|
+
return this._request(`/api/operator/portfolio/projects/${projectId}`);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
async getPortfolioReport() {
|
|
780
|
+
return this._request('/api/operator/portfolio/report');
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
async getPortfolioBundle() {
|
|
784
|
+
return this._request('/api/operator/portfolio/bundle');
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// ─── Self-Learning ─────────────────────────────────────────────────────────
|
|
788
|
+
|
|
789
|
+
async getSelfLearningPosture({ workflowRunId, limit } = {}) {
|
|
790
|
+
return this._request('/api/operator/self-learning/posture', {
|
|
791
|
+
query: { workflow_run_id: workflowRunId, limit },
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
async listLearningRecords({ workflowRunId, learningCategory, promotionReadiness, limit } = {}) {
|
|
796
|
+
return this._request('/api/operator/self-learning/records', {
|
|
797
|
+
query: {
|
|
798
|
+
workflow_run_id: workflowRunId,
|
|
799
|
+
learning_category: learningCategory,
|
|
800
|
+
promotion_readiness: promotionReadiness,
|
|
801
|
+
limit,
|
|
802
|
+
},
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
async getLearningRecord(learningRecordId) {
|
|
807
|
+
return this._request(`/api/operator/self-learning/records/${learningRecordId}`);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
async listPromotionCandidates({ workflowRunId, learningCategory, promotionReadiness, limit } = {}) {
|
|
811
|
+
return this._request('/api/operator/self-learning/promotion-candidates', {
|
|
812
|
+
query: {
|
|
813
|
+
workflow_run_id: workflowRunId,
|
|
814
|
+
learning_category: learningCategory,
|
|
815
|
+
promotion_readiness: promotionReadiness,
|
|
816
|
+
limit,
|
|
817
|
+
},
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
async getPromotionCandidate(candidateKey) {
|
|
822
|
+
return this._request(`/api/operator/self-learning/promotion-candidates/${candidateKey}`);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
async listPromotionFlows({ flowStatus, targetType, candidateKey, limit } = {}) {
|
|
826
|
+
return this._request('/api/operator/self-learning/promotion-flows', {
|
|
827
|
+
query: {
|
|
828
|
+
flow_status: flowStatus,
|
|
829
|
+
target_type: targetType,
|
|
830
|
+
candidate_key: candidateKey,
|
|
831
|
+
limit,
|
|
832
|
+
},
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// ─── Self-Optimization ─────────────────────────────────────────────────────
|
|
837
|
+
|
|
838
|
+
async getSelfOptimizationDashboard() {
|
|
839
|
+
return this._request('/api/operator/self-optimization/dashboard');
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
async getSelfOptimizationCandidateQueue({ objectiveCategory, impactPosture, blockedByDefault, limit } = {}) {
|
|
843
|
+
return this._request('/api/operator/self-optimization/candidate-queue', {
|
|
844
|
+
query: {
|
|
845
|
+
objective_category: objectiveCategory,
|
|
846
|
+
impact_posture: impactPosture,
|
|
847
|
+
blocked_by_default: blockedByDefault,
|
|
848
|
+
limit,
|
|
849
|
+
},
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
async getSelfOptimizationBacklogPosture({ snapshotKey } = {}) {
|
|
854
|
+
return this._request('/api/operator/self-optimization/backlog-posture', {
|
|
855
|
+
query: { snapshot_key: snapshotKey },
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
async getSelfOptimizationPendingHandoffs({ downstreamLane } = {}) {
|
|
860
|
+
return this._request('/api/operator/self-optimization/pending-handoffs', {
|
|
861
|
+
query: { downstream_lane: downstreamLane },
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// ─── Design Intelligence ───────────────────────────────────────────────────
|
|
866
|
+
|
|
867
|
+
async getDesignIntelligenceDashboard() {
|
|
868
|
+
return this._request('/api/design-intelligence/dashboard');
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
async listDesignDecisions() {
|
|
872
|
+
return this._request('/api/design-intelligence/decisions');
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
async getDesignDecision(decisionId) {
|
|
876
|
+
return this._request(`/api/design-intelligence/decisions/${decisionId}`);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
async getDesignDecisionVariants(decisionId) {
|
|
880
|
+
return this._request(`/api/design-intelligence/decisions/${decisionId}/variants`);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
async getDesignDecisionCritique(decisionId) {
|
|
884
|
+
return this._request(`/api/design-intelligence/decisions/${decisionId}/critique`);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
async getDesignDecisionLineage(decisionId) {
|
|
888
|
+
return this._request(`/api/design-intelligence/decisions/${decisionId}/lineage`);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
async listDesignPatterns() {
|
|
892
|
+
return this._request('/api/design-intelligence/patterns');
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
async getDecisionLabCanvas() {
|
|
896
|
+
return this._request('/api/design-intelligence/decision-lab/canvas');
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
async getDesignRecommendations() {
|
|
900
|
+
return this._request('/api/design-intelligence/recommendations');
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
async getDesignPromotions() {
|
|
904
|
+
return this._request('/api/design-intelligence/promotions');
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
async previewDesignPromotion(body) {
|
|
908
|
+
return this._request('/api/design-intelligence/promotions/preview', { method: 'POST', body });
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
async getDesignIntelligenceMetrics() {
|
|
912
|
+
return this._request('/api/design-intelligence/metrics');
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// ─── Script Discovery ──────────────────────────────────────────────────────
|
|
916
|
+
|
|
917
|
+
async scanScripts(body = {}) {
|
|
918
|
+
return this._request('/api/script-discovery/scan', { method: 'POST', body });
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
async listDiscoveredScriptAssets({ limit } = {}) {
|
|
922
|
+
return this._request('/api/script-discovery/script-assets', { query: { limit } });
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
async listDiscoveredCapabilities({ limit } = {}) {
|
|
926
|
+
return this._request('/api/script-discovery/discovered-capabilities', { query: { limit } });
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
async listWorkflowCandidates({ limit } = {}) {
|
|
930
|
+
return this._request('/api/script-discovery/workflow-candidates', { query: { limit } });
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
async promoteWorkflowCandidate(workflowCandidateId, body = {}) {
|
|
934
|
+
return this._request(`/api/script-discovery/workflow-candidates/${workflowCandidateId}/promote`, {
|
|
935
|
+
method: 'POST', body,
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// ─── Notes Lab ─────────────────────────────────────────────────────────────
|
|
940
|
+
|
|
941
|
+
async getNotesLabConfig() {
|
|
942
|
+
return this._request('/api/notes-lab/config');
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
async submitNote(body) {
|
|
946
|
+
return this._request('/api/notes-lab/submit', { method: 'POST', body });
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
async approveNoteReview(body) {
|
|
950
|
+
return this._request('/api/notes-lab/approve-review', { method: 'POST', body });
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// ─── Search & Contacts ─────────────────────────────────────────────────────
|
|
954
|
+
|
|
955
|
+
async search(query) {
|
|
956
|
+
return this._request('/api/search', { query: { q: query } });
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
async getOrganization(entityId) {
|
|
960
|
+
return this._request(`/api/organizations/${entityId}`);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
async getContact(contactId) {
|
|
964
|
+
return this._request(`/api/contacts/${contactId}`);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// ─── Benchmarks ────────────────────────────────────────────────────────────
|
|
968
|
+
|
|
969
|
+
async listRecentBenchmarkRuns({ limit } = {}) {
|
|
970
|
+
return this._request('/api/benchmarks/reasoners/runs/recent', { query: { limit } });
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
async getBenchmarkRun(benchmarkRunId) {
|
|
974
|
+
return this._request(`/api/benchmarks/reasoners/runs/${benchmarkRunId}`);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// ─── Core HTTP ─────────────────────────────────────────────────────────────
|
|
978
|
+
|
|
979
|
+
async _request(path, { method = 'GET', query, headers, body } = {}) {
|
|
980
|
+
const url = appendQuery(`${this.baseUrl}${path}`, query);
|
|
981
|
+
const controller = new AbortController();
|
|
982
|
+
const timeoutHandle = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
983
|
+
try {
|
|
984
|
+
const response = await this.fetchImpl(url, {
|
|
985
|
+
method,
|
|
986
|
+
headers: {
|
|
987
|
+
accept: 'application/json',
|
|
988
|
+
'content-type': body ? 'application/json' : undefined,
|
|
989
|
+
'x-actor-id': this.actorId,
|
|
990
|
+
authorization: this.apiKey ? `Bearer ${this.apiKey}` : undefined,
|
|
991
|
+
...headers,
|
|
992
|
+
},
|
|
993
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
994
|
+
signal: controller.signal,
|
|
995
|
+
});
|
|
996
|
+
const payload = await readJson(response);
|
|
997
|
+
if (!response.ok) {
|
|
998
|
+
const error = new Error(payload?.message || payload?.error || `Request failed with status ${response.status}.`);
|
|
999
|
+
error.status = response.status;
|
|
1000
|
+
error.payload = payload;
|
|
1001
|
+
throw error;
|
|
1002
|
+
}
|
|
1003
|
+
return payload;
|
|
1004
|
+
} finally {
|
|
1005
|
+
clearTimeout(timeoutHandle);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
export function createAIEngineClient(options) {
|
|
1011
|
+
return new AIEngineClient(options);
|
|
1012
|
+
}
|