@bpmsoftwaresolutions/ai-engine-client 1.1.87 → 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/package.json +1 -1
- package/src/client.js +192 -4903
- package/src/domains/charters.js +5 -0
- package/src/domains/claims.js +58 -0
- package/src/domains/commit-governance.js +68 -0
- package/src/domains/context-orientation.js +48 -0
- package/src/domains/context-sessions.js +46 -0
- package/src/domains/execution-eligibility.js +44 -0
- package/src/domains/governed-implementation.js +7 -0
- package/src/domains/implementation-artifacts.js +61 -0
- package/src/domains/implementation-checks.js +41 -0
- package/src/domains/implementation-items.js +82 -89
- package/src/domains/implementation-packets.js +173 -0
- package/src/domains/implementation-tasks.js +125 -6
- package/src/domains/portfolio.js +125 -1
- package/src/domains/project-chartering.js +18 -0
- package/src/domains/project-reports.js +14 -0
- package/src/domains/project-resume.js +18 -0
- package/src/domains/projects.js +348 -24
- package/src/domains/roadmap-reports.js +6 -0
- package/src/domains/session-governance.js +64 -0
- package/src/domains/tool-binding-approvals.js +102 -0
- package/src/domains/verified-mutations.js +7 -0
- package/src/domains/work-start.js +192 -0
- package/src/domains/workflow-composition.js +3416 -7
- package/src/domains/workflow-turns.js +6 -0
- package/src/index.js +1 -1
- package/src/utils/task-binding.js +31 -0
- package/src/utils/verified-mutations.js +128 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function createWorkflowTurnsDomain(client) {
|
|
2
|
+
return {
|
|
3
|
+
completeTurn: (body = {}) => client._request('/api/turns/complete', { method: 'POST', body }),
|
|
4
|
+
persistAssistantTurn: (body) => client._request('/api/v1/assistant-turns', { method: 'POST', body }),
|
|
5
|
+
};
|
|
6
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AIEngineClient, createAIEngineClient } from './client.js';
|
|
2
|
-
export const AI_ENGINE_CLIENT_VERSION = '1.1.
|
|
2
|
+
export const AI_ENGINE_CLIENT_VERSION = '1.1.89';
|
|
3
3
|
export { GOVERNED_MUTATION_REQUIRED_CAPABILITIES, AI_ENGINE_CLIENT_CAPABILITIES, TASK_BOUND_SUBSTRATE_EXECUTION_POLICY } from './constants/governance.js';
|
|
4
4
|
export { LOGA_CONTRACT, LOGA_INTERACTION_CONTRACT, LOGA_NAVIGATION_CONTRACT, LOGA_PROJECTION_WORKFLOW } from './constants/loga.js';
|
|
5
5
|
export {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TASK_BOUND_SUBSTRATE_EXECUTION_POLICY } from '../constants/governance.js';
|
|
2
|
+
import { cleanList, cleanText, isPlainObject } from './text.js';
|
|
3
|
+
|
|
4
|
+
export function normalizeTaskBindingPolicy(taskBinding, { expectedAction = null } = {}) {
|
|
5
|
+
if (!isPlainObject(taskBinding)) return taskBinding;
|
|
6
|
+
const taskId = cleanText(taskBinding.task_id || taskBinding.implementation_item_task_id);
|
|
7
|
+
const roadmapItemId = cleanText(taskBinding.roadmap_item_id || taskBinding.implementation_item_id);
|
|
8
|
+
const taskStatus = cleanText(taskBinding.task_status || taskBinding.status);
|
|
9
|
+
const allowedActions = cleanList(taskBinding.allowed_actions);
|
|
10
|
+
const substrateAction = cleanText(taskBinding.substrate_action) || cleanText(expectedAction);
|
|
11
|
+
return {
|
|
12
|
+
...taskBinding,
|
|
13
|
+
...(taskId ? { task_id: taskId } : {}),
|
|
14
|
+
...(roadmapItemId ? { roadmap_item_id: roadmapItemId, implementation_item_id: roadmapItemId } : {}),
|
|
15
|
+
...(taskStatus ? { task_status: taskStatus } : {}),
|
|
16
|
+
...(allowedActions.length > 0 ? { allowed_actions: allowedActions } : {}),
|
|
17
|
+
...(substrateAction ? { substrate_action: substrateAction } : {}),
|
|
18
|
+
policy_key: cleanText(taskBinding.policy_key) || 'task_bound_substrate_execution',
|
|
19
|
+
policy_version: cleanText(taskBinding.policy_version) || 'v1',
|
|
20
|
+
policy_identifier: cleanText(taskBinding.policy_identifier) || TASK_BOUND_SUBSTRATE_EXECUTION_POLICY,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function normalizeMetadataTaskBinding(metadata, { expectedAction = null } = {}) {
|
|
25
|
+
if (!isPlainObject(metadata)) return metadata;
|
|
26
|
+
if (!isPlainObject(metadata.task_binding)) return metadata;
|
|
27
|
+
return {
|
|
28
|
+
...metadata,
|
|
29
|
+
task_binding: normalizeTaskBindingPolicy(metadata.task_binding, { expectedAction }),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { cleanText, isPlainObject } from './text.js';
|
|
2
|
+
|
|
3
|
+
export function buildVerificationError(message, details = {}) {
|
|
4
|
+
const error = new Error(message);
|
|
5
|
+
error.code = 'POST_CONDITION_VERIFICATION_FAILED';
|
|
6
|
+
error.details = details;
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function matchesExpectedState(actual, expected) {
|
|
11
|
+
if (typeof expected === 'function') {
|
|
12
|
+
throw new Error('matchesExpectedState does not support function expectations.');
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(expected)) {
|
|
15
|
+
if (!Array.isArray(actual) || actual.length < expected.length) return false;
|
|
16
|
+
return expected.every((item, index) => matchesExpectedState(actual[index], item));
|
|
17
|
+
}
|
|
18
|
+
if (isPlainObject(expected)) {
|
|
19
|
+
if (!isPlainObject(actual)) return false;
|
|
20
|
+
return Object.entries(expected).every(([key, value]) => matchesExpectedState(actual[key], value));
|
|
21
|
+
}
|
|
22
|
+
return Object.is(actual, expected);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function executeVerifiedMutation({
|
|
26
|
+
mutationName,
|
|
27
|
+
mutationFn,
|
|
28
|
+
verificationFn,
|
|
29
|
+
expectedState,
|
|
30
|
+
evidenceLabel,
|
|
31
|
+
} = {}) {
|
|
32
|
+
if (typeof mutationFn !== 'function') throw new Error('mutationFn is required.');
|
|
33
|
+
if (typeof verificationFn !== 'function') throw new Error('verificationFn is required.');
|
|
34
|
+
const normalizedMutationName = cleanText(mutationName) || 'verifiedMutation';
|
|
35
|
+
const normalizedEvidenceLabel = cleanText(evidenceLabel) || normalizedMutationName;
|
|
36
|
+
|
|
37
|
+
return (async () => {
|
|
38
|
+
let mutationResult;
|
|
39
|
+
try {
|
|
40
|
+
mutationResult = await mutationFn();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw buildVerificationError(
|
|
43
|
+
`${normalizedMutationName} mutation failed before post-condition verification.`,
|
|
44
|
+
{
|
|
45
|
+
mutation_name: normalizedMutationName,
|
|
46
|
+
evidence_label: normalizedEvidenceLabel,
|
|
47
|
+
mutation_attempted: true,
|
|
48
|
+
authoritative_read_performed: false,
|
|
49
|
+
post_condition_verified: false,
|
|
50
|
+
expected_state: expectedState ?? null,
|
|
51
|
+
mutation_error: {
|
|
52
|
+
message: error?.message || String(error),
|
|
53
|
+
status: error?.status || null,
|
|
54
|
+
payload: error?.payload || null,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let verificationResult;
|
|
61
|
+
try {
|
|
62
|
+
verificationResult = await verificationFn(mutationResult);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw buildVerificationError(
|
|
65
|
+
`${normalizedMutationName} authoritative read failed after mutation attempt.`,
|
|
66
|
+
{
|
|
67
|
+
mutation_name: normalizedMutationName,
|
|
68
|
+
evidence_label: normalizedEvidenceLabel,
|
|
69
|
+
mutation_attempted: true,
|
|
70
|
+
authoritative_read_performed: false,
|
|
71
|
+
post_condition_verified: false,
|
|
72
|
+
expected_state: expectedState ?? null,
|
|
73
|
+
mutation_result: mutationResult ?? null,
|
|
74
|
+
verification_error: {
|
|
75
|
+
message: error?.message || String(error),
|
|
76
|
+
status: error?.status || null,
|
|
77
|
+
payload: error?.payload || null,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let evaluation;
|
|
84
|
+
if (typeof expectedState === 'function') {
|
|
85
|
+
evaluation = expectedState(verificationResult, mutationResult);
|
|
86
|
+
} else {
|
|
87
|
+
evaluation = {
|
|
88
|
+
ok: matchesExpectedState(verificationResult, expectedState),
|
|
89
|
+
verifiedCurrentState: verificationResult,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (typeof evaluation === 'boolean') {
|
|
93
|
+
evaluation = { ok: evaluation, verifiedCurrentState: verificationResult };
|
|
94
|
+
}
|
|
95
|
+
if (!isPlainObject(evaluation) || typeof evaluation.ok !== 'boolean') {
|
|
96
|
+
throw new Error('expectedState must resolve to a boolean or an object with an ok field.');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const evidence = {
|
|
100
|
+
mutation_name: normalizedMutationName,
|
|
101
|
+
evidence_label: normalizedEvidenceLabel,
|
|
102
|
+
mutation_attempted: true,
|
|
103
|
+
authoritative_read_performed: true,
|
|
104
|
+
post_condition_verified: evaluation.ok,
|
|
105
|
+
expected_state: expectedState ?? null,
|
|
106
|
+
verified_current_state: evaluation.verifiedCurrentState ?? verificationResult ?? null,
|
|
107
|
+
mutation_result: mutationResult ?? null,
|
|
108
|
+
verification_result: verificationResult ?? null,
|
|
109
|
+
verification_message: cleanText(evaluation.message) || null,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
if (!evaluation.ok) {
|
|
113
|
+
throw buildVerificationError(
|
|
114
|
+
cleanText(evaluation.message) || `${normalizedMutationName} post-condition verification failed.`,
|
|
115
|
+
evidence,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
mutationName: normalizedMutationName,
|
|
121
|
+
evidenceLabel: normalizedEvidenceLabel,
|
|
122
|
+
mutationResult,
|
|
123
|
+
verificationResult,
|
|
124
|
+
verifiedCurrentState: evidence.verified_current_state,
|
|
125
|
+
mutationVerificationEvidence: evidence,
|
|
126
|
+
};
|
|
127
|
+
})();
|
|
128
|
+
}
|