@bpmsoftwaresolutions/ai-engine-client 1.1.88 → 1.1.89

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/src/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AI_ENGINE_CLIENT_CAPABILITIES, GOVERNED_MUTATION_REQUIRED_CAPABILITIES, TASK_BOUND_SUBSTRATE_EXECUTION_POLICY } from './constants/governance.js';
1
+ import { AI_ENGINE_CLIENT_CAPABILITIES } from './constants/governance.js';
2
2
  import { AGENT_COMMUNICATION_CONTRACT_VERSION, AGENT_COMMUNICATION_MESSAGE_KINDS, AGENT_COMMUNICATION_RECIPIENT_MODES, AGENT_COMMUNICATION_THREAD_TYPES, AGENT_COMMUNICATION_TRANSFER_KINDS, AGENT_COMMUNICATION_TRANSFER_LIFECYCLE_STATES, AGENT_COMMUNICATION_TRANSFER_MODES, AGENT_COMMUNICATION_TRANSFER_RECEIPT_TYPES } from './constants/agent-communications.js';
3
3
  import { AI_ENGINE_CLIENT_VERSION, DEFAULT_TIMEOUT_MS } from './constants/client.js';
4
4
  import { LOGA_CONTRACT, LOGA_INTERACTION_CONTRACT, LOGA_NAVIGATION_CONTRACT, LOGA_PROJECTION_WORKFLOW } from './constants/loga.js';
@@ -18,6 +18,7 @@ import { createNotesLabDomain } from './domains/notes-lab.js';
18
18
  import { createPortfolioDomain } from './domains/portfolio.js';
19
19
  import { createProjectReportsDomain } from './domains/project-reports.js';
20
20
  import { createProjectResumeDomain } from './domains/project-resume.js';
21
+ import { createGovernedImplementationDomain } from './domains/governed-implementation.js';
21
22
  import { createProjectionsDomain } from './domains/projections.js';
22
23
  import { createReportsDomain } from './domains/reports.js';
23
24
  import { createRoadmapReportsDomain } from './domains/roadmap-reports.js';
@@ -43,6 +44,17 @@ import { createSkillGovernanceDomain } from './domains/skill-governance.js';
43
44
  import { createSkillsDomain } from './domains/skills.js';
44
45
  import { createSearchContactsDomain } from './domains/search-contacts.js';
45
46
  import { createAgentCommunicationsFacade, createCollaborationFacade } from './compat/facades.js';
47
+ import { createClaimsDomain } from './domains/claims.js';
48
+ import { createSessionGovernanceDomain } from './domains/session-governance.js';
49
+ import { createContextSessionsDomain } from './domains/context-sessions.js';
50
+ import { createContextOrientationDomain } from './domains/context-orientation.js';
51
+ import { createCommitGovernanceDomain } from './domains/commit-governance.js';
52
+ import { createExecutionEligibilityDomain } from './domains/execution-eligibility.js';
53
+ import { createToolBindingApprovalsDomain } from './domains/tool-binding-approvals.js';
54
+ import { createVerifiedMutationsDomain } from './domains/verified-mutations.js';
55
+ import { createWorkflowTurnsDomain } from './domains/workflow-turns.js';
56
+ import { createChartersDomain } from './domains/charters.js';
57
+ import { createWorkStartDomain } from './domains/work-start.js';
46
58
  import { createCollaborationDomain } from './domains/collaboration.js';
47
59
  import { createMessageWatchDomain } from './domains/message-watch.js';
48
60
  import { createPingPongDomain } from './domains/ping-pong.js';
@@ -55,8 +67,6 @@ import { createWorkflowsDomain } from './domains/workflows.js';
55
67
  import { createWarehouseDomain } from './domains/warehouse.js';
56
68
  import { buildHeaders, requestBinary, requestJson, requestLogaProjection, requestText, resolveAccessToken } from './transport/index.js';
57
69
  import { normalizeEnum, trimTrailingSlash } from './utils/text.js';
58
- import { normalizeMetadataTaskBinding, normalizeTaskBindingPolicy } from './utils/task-binding.js';
59
- import { executeVerifiedMutation } from './utils/verified-mutations.js';
60
70
 
61
71
  function normalizeThreadType(value) {
62
72
  return normalizeEnum(value, AGENT_COMMUNICATION_THREAD_TYPES, 'coordination', 'thread_type', {
@@ -234,58 +244,6 @@ function isPlainObject(value) {
234
244
  return value !== null && typeof value === 'object' && !Array.isArray(value);
235
245
  }
236
246
 
237
- function isActiveBinding(binding) {
238
- return isPlainObject(binding) && (
239
- binding.is_active === true ||
240
- binding.is_active === 1 ||
241
- binding.is_active === 'true' ||
242
- binding.is_active === 'True'
243
- );
244
- }
245
-
246
- function activeToolKeysFromRegistry(registry) {
247
- const bindings = Array.isArray(registry?.bindings) ? registry.bindings : [];
248
- const seen = new Set();
249
- const keys = [];
250
- for (const binding of bindings) {
251
- if (!isActiveBinding(binding)) continue;
252
- const key = cleanText(binding.tool_key);
253
- if (!key || seen.has(key)) continue;
254
- seen.add(key);
255
- keys.push(key);
256
- }
257
- return keys;
258
- }
259
-
260
- function reminderTokens(reminders) {
261
- const tokens = [];
262
- for (const reminder of Array.isArray(reminders) ? reminders : []) {
263
- if (!isPlainObject(reminder)) continue;
264
- for (const value of [reminder.reminder_key, reminder.reminder_id]) {
265
- const token = cleanText(value);
266
- if (token && !tokens.includes(token)) tokens.push(token);
267
- }
268
- }
269
- return tokens;
270
- }
271
-
272
- function contextSessionIdFromInput(input) {
273
- if (isPlainObject(input)) {
274
- return cleanText(input.contextSessionId)
275
- || cleanText(input.context_session_id)
276
- || cleanText(input.context_session?.context_session_id)
277
- || cleanText(input.claim?.context_session_id);
278
- }
279
- return cleanText(input);
280
- }
281
-
282
- function buildEligibilityError(message, details = {}) {
283
- const error = new Error(message);
284
- error.code = 'EXECUTION_ELIGIBILITY_FAILED';
285
- error.details = details;
286
- return error;
287
- }
288
-
289
247
  export class AIEngineClient {
290
248
  constructor({ baseUrl, accessToken, tokenProvider, apiKey, clientId, actorId, agentSessionId, fetchImpl, timeoutMs } = {}) {
291
249
  if (!baseUrl) throw new Error('baseUrl is required.');
@@ -314,6 +272,18 @@ export class AIEngineClient {
314
272
  this.projectChartering = createProjectCharteringDomain(this);
315
273
  this.projectReports = createProjectReportsDomain(this);
316
274
  this.projectResume = createProjectResumeDomain(this);
275
+ this.claims = createClaimsDomain(this);
276
+ this.sessionGovernance = createSessionGovernanceDomain(this);
277
+ this.executionEligibility = createExecutionEligibilityDomain(this);
278
+ this.toolBindingApprovals = createToolBindingApprovalsDomain(this);
279
+ this.workflowTurns = createWorkflowTurnsDomain(this);
280
+ this.contextSessions = createContextSessionsDomain(this);
281
+ this.contextOrientation = createContextOrientationDomain(this);
282
+ this.commitGovernance = createCommitGovernanceDomain(this);
283
+ this.verifiedMutations = createVerifiedMutationsDomain(this);
284
+ this.charters = createChartersDomain(this);
285
+ this.workStart = createWorkStartDomain(this);
286
+ this.governedImplementation = createGovernedImplementationDomain(this);
317
287
  this.roadmaps = createRoadmapsDomain(this);
318
288
  this.roadmapReports = createRoadmapReportsDomain(this);
319
289
  this.implementationPackets = createImplementationPacketsDomain(this);
@@ -3087,252 +3057,44 @@ export class AIEngineClient {
3087
3057
  return this._request('/api/dashboard');
3088
3058
  }
3089
3059
 
3090
- async startSessionGovernance({
3091
- intent,
3092
- objective,
3093
- allowedScopes,
3094
- allowedMutationSurfaces,
3095
- requiredToolKeys,
3096
- sessionKey,
3097
- workflowRunId,
3098
- workflowId,
3099
- workflowSlug,
3100
- governedScope,
3101
- successCriteria,
3102
- disallowedSurfaces,
3103
- ...rest
3104
- } = {}) {
3105
- return this._request('/api/v1/session-governance/startup', {
3106
- method: 'POST',
3107
- body: {
3108
- ...rest,
3109
- objective: objective ?? intent,
3110
- allowed_mutation_surfaces: allowedMutationSurfaces ?? allowedScopes,
3111
- required_tool_keys: requiredToolKeys,
3112
- session_key: sessionKey,
3113
- workflow_run_id: workflowRunId,
3114
- workflow_id: workflowId,
3115
- workflow_slug: workflowSlug,
3116
- governed_scope: governedScope,
3117
- success_criteria: successCriteria,
3118
- disallowed_surfaces: disallowedSurfaces,
3119
- },
3120
- });
3060
+ async startSessionGovernance(request = {}) {
3061
+ return this.sessionGovernance.startSessionGovernance(request);
3121
3062
  }
3122
3063
 
3123
- async startReviewGovernance({
3124
- intent,
3125
- objective,
3126
- readScope,
3127
- requiredToolKeys,
3128
- sessionKey,
3129
- workflowRunId,
3130
- workflowId,
3131
- workflowSlug,
3132
- turnPersisted,
3133
- ...rest
3134
- } = {}) {
3135
- return this._request('/api/v1/session-governance/review/startup', {
3136
- method: 'POST',
3137
- body: {
3138
- ...rest,
3139
- intent: intent ?? 'review code',
3140
- objective: objective ?? intent,
3141
- read_scope: readScope,
3142
- required_tool_keys: requiredToolKeys,
3143
- session_key: sessionKey,
3144
- workflow_run_id: workflowRunId,
3145
- workflow_id: workflowId,
3146
- workflow_slug: workflowSlug ?? 'code-review/read-only',
3147
- turn_persisted: turnPersisted,
3148
- },
3149
- });
3064
+ async startReviewGovernance(request = {}) {
3065
+ return this.sessionGovernance.startReviewGovernance(request);
3150
3066
  }
3151
3067
 
3152
3068
  async startWork(body = {}) {
3153
- return this._request('/api/work/start', { method: 'POST', body });
3069
+ return this.workStart.startWork(body);
3154
3070
  }
3155
3071
 
3156
- async startClaimedWork({
3157
- claimName,
3158
- actorId,
3159
- intentId,
3160
- declaredScopeFiles,
3161
- allowedMutationSurfaces,
3162
- runtimeSessionId,
3163
- executionPurpose,
3164
- successCriteria,
3165
- mutationAllowed,
3166
- metadata,
3167
- ...rest
3168
- } = {}) {
3169
- return this._request('/api/governance/claims/start-claimed-work', {
3170
- method: 'POST',
3171
- body: {
3172
- ...rest,
3173
- claim_name: claimName,
3174
- actor_id: actorId,
3175
- intent_id: intentId,
3176
- declared_scope_files: declaredScopeFiles,
3177
- allowed_mutation_surfaces: allowedMutationSurfaces,
3178
- runtime_session_id: runtimeSessionId,
3179
- execution_purpose: executionPurpose,
3180
- success_criteria: successCriteria,
3181
- mutation_allowed: mutationAllowed,
3182
- metadata: normalizeMetadataTaskBinding(metadata),
3183
- },
3184
- });
3072
+ async startClaimedWork(request = {}) {
3073
+ return this.workStart.startClaimedWork(request);
3185
3074
  }
3186
3075
 
3187
3076
  async claimWorkItem(body = {}) {
3188
- const normalizedBody = isPlainObject(body)
3189
- ? {
3190
- ...body,
3191
- ...(isPlainObject(body.task_binding)
3192
- ? { task_binding: normalizeTaskBindingPolicy(body.task_binding) }
3193
- : {}),
3194
- metadata: normalizeMetadataTaskBinding(body.metadata),
3195
- }
3196
- : body;
3197
- return this._request('/api/governance/claims/claim-work-item', { method: 'POST', body: normalizedBody });
3077
+ return this.workStart.claimWorkItem(body);
3198
3078
  }
3199
3079
 
3200
- async bindClaimedWorkItem({
3201
- claimId,
3202
- contextSessionId,
3203
- workflowRunId,
3204
- agentSessionId,
3205
- claimedItemId,
3206
- claimedItemKey,
3207
- claimName,
3208
- actorId,
3209
- workflowId,
3210
- workflowSlug,
3211
- requiredToolKeys,
3212
- declaredScopeFiles,
3213
- allowedMutationSurfaces,
3214
- successCriteria,
3215
- acknowledgedReminders,
3216
- intentConfirmation,
3217
- actorSignature,
3218
- autoSignoff = true,
3219
- metadata,
3220
- } = {}) {
3221
- const normalizedContextSessionId = contextSessionIdFromInput({
3222
- contextSessionId,
3223
- context_session_id: contextSessionId,
3224
- claim: { context_session_id: contextSessionId },
3225
- });
3226
- const normalizedClaimId = cleanText(claimId);
3227
- const normalizedWorkflowRunId = cleanText(workflowRunId);
3228
- const normalizedAgentSessionId = cleanText(agentSessionId);
3229
- const normalizedClaimedItemId = cleanText(claimedItemId);
3230
- const normalizedClaimedItemKey = cleanText(claimedItemKey);
3231
- const normalizedClaimedItemRef = normalizedClaimedItemId || normalizedClaimedItemKey;
3232
- if (!normalizedContextSessionId) throw new Error('contextSessionId is required.');
3233
- if (!normalizedWorkflowRunId) throw new Error('workflowRunId is required.');
3234
- if (!normalizedAgentSessionId) throw new Error('agentSessionId is required.');
3235
- if (!normalizedClaimedItemRef) throw new Error('claimedItemId or claimedItemKey is required.');
3236
-
3237
- const normalizedWorkflowId = cleanText(workflowId);
3238
- const normalizedWorkflowSlug = cleanText(workflowSlug);
3239
- let normalizedRequiredToolKeys = cleanList(requiredToolKeys);
3240
- let workflowRegistry = null;
3241
- if (normalizedRequiredToolKeys.length === 0 && (normalizedWorkflowId || normalizedWorkflowSlug)) {
3242
- workflowRegistry = await this.getWorkflowToolRegistry({
3243
- workflowId: normalizedWorkflowId,
3244
- workflowSlug: normalizedWorkflowSlug,
3245
- });
3246
- normalizedRequiredToolKeys = activeToolKeysFromRegistry(workflowRegistry);
3247
- }
3248
-
3249
- const lockClaimResult = await this.lockContextSessionClaim(normalizedContextSessionId);
3250
- const lockedContextSession = lockClaimResult?.context_session || lockClaimResult;
3251
- const lockedContextSessionId = contextSessionIdFromInput(lockedContextSession) || normalizedContextSessionId;
3252
-
3253
- const claimWorkItemResult = await this.claimWorkItem({
3254
- context_session_id: lockedContextSessionId,
3255
- workflow_run_id: normalizedWorkflowRunId,
3256
- agent_session_id: normalizedAgentSessionId,
3257
- claimed_item_id: normalizedClaimedItemId,
3258
- claimed_item_key: normalizedClaimedItemKey,
3259
- claim_name: claimName,
3260
- actor_id: actorId,
3261
- workflow_id: normalizedWorkflowId,
3262
- workflow_slug: normalizedWorkflowSlug,
3263
- required_tool_keys: normalizedRequiredToolKeys,
3264
- declared_scope_files: cleanList(declaredScopeFiles).length > 0
3265
- ? cleanList(declaredScopeFiles)
3266
- : [normalizedClaimedItemRef],
3267
- allowed_mutation_surfaces: cleanList(allowedMutationSurfaces).length > 0
3268
- ? cleanList(allowedMutationSurfaces)
3269
- : ['project_roadmap_task'],
3270
- success_criteria: successCriteria,
3271
- metadata,
3272
- });
3273
-
3274
- let signedClaim = null;
3275
- const resolvedClaimId = cleanText(claimWorkItemResult?.claim_id) || normalizedClaimId;
3276
- if (autoSignoff && resolvedClaimId) {
3277
- const claimEnvelope = isPlainObject(claimWorkItemResult?.claim) ? claimWorkItemResult.claim : claimWorkItemResult;
3278
- const reminders = cleanList(acknowledgedReminders).length > 0
3279
- ? cleanList(acknowledgedReminders)
3280
- : reminderTokens(claimEnvelope?.required_reminders);
3281
- if (reminders.length > 0) {
3282
- signedClaim = await this.signoffClaim(resolvedClaimId, {
3283
- acknowledged_reminders: reminders,
3284
- intent_confirmation: cleanText(intentConfirmation) || 'I confirm this governed execution intent and scope.',
3285
- actor_signature: cleanText(actorSignature) || cleanText(actorId) || this.actorId,
3286
- });
3287
- }
3288
- }
3289
-
3290
- return {
3291
- claim_id: resolvedClaimId,
3292
- context_session_id: lockedContextSessionId,
3293
- workflow_run_id: normalizedWorkflowRunId,
3294
- agent_session_id: normalizedAgentSessionId,
3295
- required_tool_keys: normalizedRequiredToolKeys,
3296
- workflow_registry: workflowRegistry,
3297
- lock_claim_result: lockClaimResult,
3298
- claim_work_item_result: claimWorkItemResult,
3299
- signed_claim: signedClaim,
3300
- approved_tool_keys: cleanList(
3301
- signedClaim?.approved_tool_keys ||
3302
- signedClaim?.claim?.approved_tool_keys ||
3303
- claimWorkItemResult?.approved_tool_keys ||
3304
- claimWorkItemResult?.claim?.approved_tool_keys
3305
- ),
3306
- };
3080
+ async bindClaimedWorkItem(request = {}) {
3081
+ return this.workStart.bindClaimedWorkItem(request);
3307
3082
  }
3308
3083
 
3309
3084
  async getClaim(claimId) {
3310
- if (!claimId) throw new Error('claimId is required.');
3311
- return this._request(`/api/governance/claims/${encodeURIComponent(claimId)}`);
3085
+ return this.claims.getClaim(claimId);
3312
3086
  }
3313
3087
 
3314
3088
  async claimIsValid(claimId) {
3315
- const claim = await this.getClaim(claimId);
3316
- return cleanText(claim?.status) === 'active';
3089
+ return this.claims.claimIsValid(claimId);
3317
3090
  }
3318
3091
 
3319
3092
  async getExecutionEligibility(body = {}) {
3320
- return this._request('/api/governance/execution-eligibility', {
3321
- method: 'POST',
3322
- body: {
3323
- required_capabilities: GOVERNED_MUTATION_REQUIRED_CAPABILITIES,
3324
- verification_required: true,
3325
- ...body,
3326
- },
3327
- });
3093
+ return this.executionEligibility.getExecutionEligibility(body);
3328
3094
  }
3329
3095
 
3330
3096
  async signoffClaim(claimId, body = {}) {
3331
- if (!claimId) throw new Error('claimId is required.');
3332
- return this._request(`/api/governance/claims/${encodeURIComponent(claimId)}/signoff`, {
3333
- method: 'POST',
3334
- body,
3335
- });
3097
+ return this.claims.signoffClaim(claimId, body);
3336
3098
  }
3337
3099
 
3338
3100
  /**
@@ -3411,124 +3173,36 @@ export class AIEngineClient {
3411
3173
  * @param {object} [params.metadata]
3412
3174
  * @returns {Promise<object>}
3413
3175
  */
3414
- async createWorkflowToolBindingApprovalLane({
3415
- operatorActorType,
3416
- requesterActor,
3417
- requestedToolKeys,
3418
- blockedReason,
3419
- rollbackPlan,
3420
- requesterActorType,
3421
- operatorActorId,
3422
- targetWorkflowId,
3423
- targetWorkflowRunId,
3424
- relatedGapRecordIds,
3425
- requestedBindingScope,
3426
- riskClassification,
3427
- metadata,
3428
- ...rest
3429
- } = {}) {
3430
- if (!operatorActorType) throw new Error('operatorActorType is required.');
3431
- if (!requesterActor) throw new Error('requesterActor is required.');
3432
- if (!Array.isArray(requestedToolKeys) || requestedToolKeys.length === 0) {
3433
- throw new Error('requestedToolKeys must be a non-empty array.');
3434
- }
3435
- if (!blockedReason) throw new Error('blockedReason is required.');
3436
- if (!rollbackPlan) throw new Error('rollbackPlan is required.');
3437
- return this._request('/api/governance/bootstrap/workflow-tool-binding-approval/create', {
3438
- method: 'POST',
3439
- body: {
3440
- ...rest,
3441
- operator_actor_type: operatorActorType,
3442
- requester_actor: requesterActor,
3443
- requested_tool_keys: requestedToolKeys,
3444
- blocked_reason: blockedReason,
3445
- rollback_plan: rollbackPlan,
3446
- requester_actor_type: requesterActorType,
3447
- operator_actor_id: operatorActorId,
3448
- target_workflow_id: targetWorkflowId,
3449
- target_workflow_run_id: targetWorkflowRunId,
3450
- related_gap_record_ids: relatedGapRecordIds,
3451
- requested_binding_scope: requestedBindingScope,
3452
- risk_classification: riskClassification,
3453
- metadata,
3454
- },
3455
- });
3176
+ async createWorkflowToolBindingApprovalLane(request = {}) {
3177
+ return this.toolBindingApprovals.createWorkflowToolBindingApprovalLane(request);
3456
3178
  }
3457
3179
 
3458
- async recordWorkflowToolBindingApprovalDecision(approvalRequestId, {
3459
- operatorActorType,
3460
- decision,
3461
- operatorActorId,
3462
- decisionNotes,
3463
- decisionConditions,
3464
- ...rest
3465
- } = {}) {
3466
- if (!approvalRequestId) throw new Error('approvalRequestId is required.');
3467
- if (!operatorActorType) throw new Error('operatorActorType is required.');
3468
- if (!decision) throw new Error('decision is required.');
3469
- return this._request(`/api/governance/bootstrap/workflow-tool-binding-approval/${encodeURIComponent(approvalRequestId)}/approval-decision`, {
3470
- method: 'POST',
3471
- body: {
3472
- ...rest,
3473
- operator_actor_type: operatorActorType,
3474
- operator_actor_id: operatorActorId,
3475
- decision,
3476
- decision_notes: decisionNotes,
3477
- decision_conditions: decisionConditions,
3478
- },
3479
- });
3180
+ async recordWorkflowToolBindingApprovalDecision(approvalRequestId, request = {}) {
3181
+ return this.toolBindingApprovals.recordWorkflowToolBindingApprovalDecision(approvalRequestId, request);
3480
3182
  }
3481
3183
 
3482
- async executeWorkflowToolBindingApprovalBinding(approvalRequestId, {
3483
- operatorActorType,
3484
- operatorActorId,
3485
- ...rest
3486
- } = {}) {
3487
- if (!approvalRequestId) throw new Error('approvalRequestId is required.');
3488
- if (!operatorActorType) throw new Error('operatorActorType is required.');
3489
- return this._request(`/api/governance/bootstrap/workflow-tool-binding-approval/${encodeURIComponent(approvalRequestId)}/binding-execution`, {
3490
- method: 'POST',
3491
- body: {
3492
- ...rest,
3493
- operator_actor_type: operatorActorType,
3494
- operator_actor_id: operatorActorId,
3495
- },
3496
- });
3184
+ async executeWorkflowToolBindingApprovalBinding(approvalRequestId, request = {}) {
3185
+ return this.toolBindingApprovals.executeWorkflowToolBindingApprovalBinding(approvalRequestId, request);
3497
3186
  }
3498
3187
 
3499
- async revalidateWorkflowToolBindingStartup(approvalRequestId, {
3500
- operatorActorType,
3501
- operatorActorId,
3502
- ...rest
3503
- } = {}) {
3504
- if (!approvalRequestId) throw new Error('approvalRequestId is required.');
3505
- if (!operatorActorType) throw new Error('operatorActorType is required.');
3506
- return this._request(`/api/governance/bootstrap/workflow-tool-binding-approval/${encodeURIComponent(approvalRequestId)}/startup-revalidation`, {
3507
- method: 'POST',
3508
- body: {
3509
- ...rest,
3510
- operator_actor_type: operatorActorType,
3511
- operator_actor_id: operatorActorId,
3512
- },
3513
- });
3188
+ async revalidateWorkflowToolBindingStartup(approvalRequestId, request = {}) {
3189
+ return this.toolBindingApprovals.revalidateWorkflowToolBindingStartup(approvalRequestId, request);
3514
3190
  }
3515
3191
 
3516
3192
  async completeTurn(body = {}) {
3517
- return this._request('/api/turns/complete', { method: 'POST', body });
3193
+ return this.workflowTurns.completeTurn(body);
3518
3194
  }
3519
3195
 
3520
3196
  async evaluateTurnCompliance(sessionId) {
3521
- return this._request(`/api/v1/session-governance/${encodeURIComponent(sessionId)}/compliance`);
3197
+ return this.sessionGovernance.evaluateTurnCompliance(sessionId);
3522
3198
  }
3523
3199
 
3524
3200
  async blockIfNonCompliant(sessionId) {
3525
- return this._request(`/api/v1/session-governance/${encodeURIComponent(sessionId)}/block-if-non-compliant`, {
3526
- method: 'POST',
3527
- });
3201
+ return this.sessionGovernance.blockIfNonCompliant(sessionId);
3528
3202
  }
3529
3203
 
3530
3204
  async runCharter(body = {}) {
3531
- return this._request('/api/charters/run', { method: 'POST', body });
3205
+ return this.charters.runCharter(body);
3532
3206
  }
3533
3207
 
3534
3208
  async createProjectDelivery(body = {}) {
@@ -3556,7 +3230,7 @@ export class AIEngineClient {
3556
3230
  }
3557
3231
 
3558
3232
  async persistAssistantTurn(body) {
3559
- return this._request('/api/v1/assistant-turns', { method: 'POST', body });
3233
+ return this.workflowTurns.persistAssistantTurn(body);
3560
3234
  }
3561
3235
 
3562
3236
  async getExternalProjectStatus(projectId) {
@@ -4391,7 +4065,7 @@ export class AIEngineClient {
4391
4065
  expectedState,
4392
4066
  evidenceLabel,
4393
4067
  } = {}) {
4394
- return executeVerifiedMutation({
4068
+ return this.verifiedMutations.executeVerifiedMutation({
4395
4069
  mutationName,
4396
4070
  mutationFn,
4397
4071
  verificationFn,
@@ -4872,173 +4546,50 @@ export class AIEngineClient {
4872
4546
 
4873
4547
  // ─── Commit Governance ────────────────────────────────────────────────────
4874
4548
 
4875
- async evaluateCommitGovernance({
4876
- claimId,
4877
- contextSessionId,
4878
- agentId,
4879
- intentId,
4880
- changedFiles,
4881
- declaredScopeFiles,
4882
- diffSummary,
4883
- branch,
4884
- headSha,
4885
- } = {}) {
4886
- return this._request('/api/commit-governance/evaluate', {
4887
- method: 'POST',
4888
- body: {
4889
- claim_id: claimId,
4890
- context_session_id: contextSessionId,
4891
- agent_id: agentId,
4892
- intent_id: intentId,
4893
- changed_files: changedFiles,
4894
- declared_scope_files: declaredScopeFiles,
4895
- diff_summary: diffSummary,
4896
- branch,
4897
- head_sha: headSha,
4898
- },
4899
- });
4549
+ async evaluateCommitGovernance(request = {}) {
4550
+ return this.commitGovernance.evaluateCommitGovernance(request);
4900
4551
  }
4901
4552
 
4902
- async checkGitShipReadiness({
4903
- claimId,
4904
- actorId,
4905
- targetBranch,
4906
- shipCommand,
4907
- packageName,
4908
- declaredScopeFiles,
4909
- stagedFiles,
4910
- dirtyFiles,
4911
- branch,
4912
- headSha,
4913
- packageJsonVersion,
4914
- facadeMinClientVersion,
4915
- packageRelease,
4916
- packageJsonHash,
4917
- sdkVersionHash,
4918
- } = {}) {
4919
- return this._request('/api/commit-governance/ship-readiness', {
4920
- method: 'POST',
4921
- body: {
4922
- claim_id: claimId,
4923
- actor_id: actorId,
4924
- target_branch: targetBranch,
4925
- ship_command: shipCommand,
4926
- package_name: packageName,
4927
- declared_scope_files: declaredScopeFiles,
4928
- staged_files: stagedFiles,
4929
- dirty_files: dirtyFiles,
4930
- branch,
4931
- head_sha: headSha,
4932
- package_json_version: packageJsonVersion,
4933
- facade_min_client_version: facadeMinClientVersion,
4934
- package_release: packageRelease,
4935
- package_json_hash: packageJsonHash,
4936
- sdk_version_hash: sdkVersionHash,
4937
- },
4938
- });
4553
+ async checkGitShipReadiness(request = {}) {
4554
+ return this.commitGovernance.checkGitShipReadiness(request);
4939
4555
  }
4940
4556
 
4941
4557
  async getCommitGovernanceEvaluation(evaluationId) {
4942
- return this._request(`/api/commit-governance/evaluations/${encodeURIComponent(evaluationId)}`);
4558
+ return this.commitGovernance.getCommitGovernanceEvaluation(evaluationId);
4943
4559
  }
4944
4560
 
4945
4561
  async listCommitGovernanceEvaluationsByClaim(claimId, { limit } = {}) {
4946
- return this._request(`/api/commit-governance/claims/${encodeURIComponent(claimId)}/evaluations`, {
4947
- query: { limit },
4948
- });
4562
+ return this.commitGovernance.listCommitGovernanceEvaluationsByClaim(claimId, { limit });
4949
4563
  }
4950
4564
 
4951
4565
  // ─── Context Session Orientation ──────────────────────────────────────────
4952
4566
 
4953
- async openContextSession({ agentId, runtimeSessionId, intentId, executionPurpose, notes } = {}) {
4954
- return this._request('/api/context-session/open', {
4955
- method: 'POST',
4956
- body: {
4957
- agent_id: agentId,
4958
- runtime_session_id: runtimeSessionId,
4959
- intent_id: intentId,
4960
- execution_purpose: executionPurpose,
4961
- notes,
4962
- },
4963
- });
4567
+ async openContextSession(request = {}) {
4568
+ return this.contextSessions.openContextSession(request);
4964
4569
  }
4965
4570
 
4966
4571
  async getOrientationWindow(contextSessionId) {
4967
- return this._request(`/api/context-session/${encodeURIComponent(contextSessionId)}/window`);
4572
+ return this.contextSessions.getOrientationWindow(contextSessionId);
4968
4573
  }
4969
4574
 
4970
- async acknowledgeReminder(contextSessionId, { reminderId, agentSignature, understandingSummary } = {}) {
4971
- return this._request(`/api/context-session/${encodeURIComponent(contextSessionId)}/acknowledge`, {
4972
- method: 'POST',
4973
- body: {
4974
- reminder_id: reminderId,
4975
- agent_signature: agentSignature,
4976
- understanding_summary: understandingSummary,
4977
- },
4978
- });
4575
+ async acknowledgeReminder(contextSessionId, request = {}) {
4576
+ return this.contextSessions.acknowledgeReminder(contextSessionId, request);
4979
4577
  }
4980
4578
 
4981
4579
  async completeOrientation(contextSessionId) {
4982
- return this._request(`/api/context-session/${encodeURIComponent(contextSessionId)}/complete`, {
4983
- method: 'POST',
4984
- });
4580
+ return this.contextSessions.completeOrientation(contextSessionId);
4985
4581
  }
4986
4582
 
4987
4583
  async lockContextSessionClaim(input) {
4988
- const contextSessionId = contextSessionIdFromInput(input);
4989
- if (!contextSessionId) throw new Error('contextSessionId is required.');
4990
- return this._request(`/api/context-session/${encodeURIComponent(contextSessionId)}/lock-claim`, {
4991
- method: 'POST',
4992
- });
4584
+ return this.contextSessions.lockContextSessionClaim(input);
4993
4585
  }
4994
4586
 
4995
4587
  async getContextSessionGateStatus(contextSessionId) {
4996
- return this._request(`/api/context-session/${encodeURIComponent(contextSessionId)}/gate-status`);
4588
+ return this.contextSessions.getContextSessionGateStatus(contextSessionId);
4997
4589
  }
4998
4590
 
4999
- async conductOrientation({
5000
- agentId,
5001
- runtimeSessionId,
5002
- intentId,
5003
- executionPurpose,
5004
- agentSignature,
5005
- understandingSummary,
5006
- lockClaim = true,
5007
- } = {}) {
5008
- const { context_session, reminders } = await this.openContextSession({
5009
- agentId,
5010
- runtimeSessionId,
5011
- intentId,
5012
- executionPurpose,
5013
- });
5014
- const sessionId = context_session.context_session_id;
5015
-
5016
- const required = (reminders || []).filter(r => r.severity === 'required');
5017
- let acknowledgedCount = 0;
5018
- for (const reminder of required) {
5019
- await this.acknowledgeReminder(sessionId, {
5020
- reminderId: reminder.reminder_id,
5021
- agentSignature,
5022
- understandingSummary,
5023
- });
5024
- acknowledgedCount++;
5025
- }
5026
-
5027
- const completion = await this.completeOrientation(sessionId);
5028
-
5029
- let claimLockResult = null;
5030
- if (lockClaim) {
5031
- claimLockResult = await this.lockContextSessionClaim(sessionId);
5032
- }
5033
-
5034
- return {
5035
- context_session_id: sessionId,
5036
- intent_id: intentId,
5037
- context_session: claimLockResult?.context_session || completion.context_session,
5038
- gate_result: claimLockResult?.gate_result || completion.gate_result,
5039
- acknowledged_count: acknowledgedCount,
5040
- claim_locked: lockClaim && !!claimLockResult,
5041
- };
4591
+ async conductOrientation(request = {}) {
4592
+ return this.contextOrientation.conductOrientation(request);
5042
4593
  }
5043
4594
 
5044
4595
  // ─── Core HTTP ─────────────────────────────────────────────────────────────
@@ -5052,23 +4603,7 @@ export class AIEngineClient {
5052
4603
  }
5053
4604
 
5054
4605
  async _assertExecutionEligibility(body = {}) {
5055
- const eligibility = await this.getExecutionEligibility(body);
5056
- if (eligibility?.execution_eligible && eligibility?.mutation_allowed) {
5057
- return eligibility;
5058
- }
5059
- const remediation = cleanText(eligibility?.remediation_command);
5060
- const verification = cleanText(eligibility?.verification_command);
5061
- throw buildEligibilityError(
5062
- [
5063
- `Execution eligibility gate blocked mutation${cleanText(body?.requested_mutation_surface) ? ` on ${cleanText(body.requested_mutation_surface)}` : ''}.`,
5064
- remediation ? `Fix: ${remediation}` : null,
5065
- verification ? `Then verify: ${verification}` : null,
5066
- ].filter(Boolean).join(' '),
5067
- {
5068
- required_gate: eligibility?.required_gate || 'execution_eligibility.required_gate',
5069
- execution_eligibility: eligibility ?? null,
5070
- },
5071
- );
4606
+ return this.executionEligibility._assertExecutionEligibility(body);
5072
4607
  }
5073
4608
 
5074
4609
  async _request(path, { method = 'GET', query, headers, body } = {}) {