@nt-ai-lab/deterministic-agent-workflow-dsl 0.1.0
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/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/platform/domain/recording-ops.d.ts +33 -0
- package/dist/platform/domain/recording-ops.js +42 -0
- package/dist/shell/bash-enforcement.d.ts +1 -0
- package/dist/shell/bash-enforcement.js +1 -0
- package/dist/shell/result.d.ts +2 -0
- package/dist/shell/result.js +1 -0
- package/dist/shell/types.d.ts +1 -0
- package/dist/shell/types.js +1 -0
- package/package.json +19 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { fail, pass, } from './shell/result';
|
|
2
|
+
export type { PreconditionResult } from './shell/result';
|
|
3
|
+
export type { BashForbiddenConfig, GitInfo, TransitionContext, WorkflowRegistry, WorkflowStateDefinition, } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
4
|
+
export { checkBashCommand } from './shell/bash-enforcement';
|
|
5
|
+
export { checkOperationGate, defineRecordingOps, } from './platform/domain/recording-ops';
|
|
6
|
+
export type { RecordingOpDefinition, RecordingOpResult, RecordingOpsFactory, } from './platform/domain/recording-ops';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PreconditionResult, WorkflowRegistry } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
2
|
+
/** @riviere-role domain-service */
|
|
3
|
+
export declare function checkOperationGate<TStateName extends string, TState extends {
|
|
4
|
+
currentStateMachineState: TStateName;
|
|
5
|
+
}, TOperation extends string>(op: TOperation, state: TState, registry: WorkflowRegistry<TState, TStateName, TOperation>): PreconditionResult;
|
|
6
|
+
/** @riviere-role value-object */
|
|
7
|
+
export type RecordingOpDefinition<TArgs extends readonly unknown[]> = {
|
|
8
|
+
readonly event: string;
|
|
9
|
+
readonly payload: (...args: TArgs) => Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
/** @riviere-role value-object */
|
|
12
|
+
export type RecordingOpResult = {
|
|
13
|
+
readonly pass: true;
|
|
14
|
+
readonly event: {
|
|
15
|
+
readonly type: string;
|
|
16
|
+
readonly at: string;
|
|
17
|
+
} & Record<string, unknown>;
|
|
18
|
+
} | {
|
|
19
|
+
readonly pass: false;
|
|
20
|
+
readonly reason: string;
|
|
21
|
+
};
|
|
22
|
+
/** @riviere-role value-object */
|
|
23
|
+
export type RecordingOpsFactory<TStateName extends string, TState extends {
|
|
24
|
+
currentStateMachineState: TStateName;
|
|
25
|
+
}, TOperation extends string> = {
|
|
26
|
+
readonly executeOp: (opName: TOperation, state: TState, now: string, args: readonly unknown[]) => RecordingOpResult;
|
|
27
|
+
};
|
|
28
|
+
/** @riviere-role domain-service */
|
|
29
|
+
export declare function defineRecordingOps<TStateName extends string, TState extends {
|
|
30
|
+
currentStateMachineState: TStateName;
|
|
31
|
+
}, TOperation extends string>(registry: WorkflowRegistry<TState, TStateName, TOperation>, ops: {
|
|
32
|
+
readonly [K in string]: RecordingOpDefinition<readonly unknown[]>;
|
|
33
|
+
}): RecordingOpsFactory<TStateName, TState, TOperation>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { pass, fail, } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
2
|
+
/** @riviere-role domain-service */
|
|
3
|
+
export function checkOperationGate(op, state, registry) {
|
|
4
|
+
const stateName = state.currentStateMachineState;
|
|
5
|
+
const stateDef = registry[stateName];
|
|
6
|
+
if (stateDef.allowedWorkflowOperations.includes(op)) {
|
|
7
|
+
return pass();
|
|
8
|
+
}
|
|
9
|
+
return fail(`${op} is not allowed in state ${state.currentStateMachineState}.`);
|
|
10
|
+
}
|
|
11
|
+
/** @riviere-role domain-service */
|
|
12
|
+
export function defineRecordingOps(registry, ops) {
|
|
13
|
+
return {
|
|
14
|
+
executeOp: (opName, state, now, args) => {
|
|
15
|
+
const gate = checkOperationGate(opName, state, registry);
|
|
16
|
+
if (!gate.pass) {
|
|
17
|
+
return {
|
|
18
|
+
pass: false,
|
|
19
|
+
reason: gate.reason,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const opDef = Object.hasOwn(ops, opName)
|
|
23
|
+
? ops[opName]
|
|
24
|
+
: undefined;
|
|
25
|
+
if (opDef === undefined) {
|
|
26
|
+
return {
|
|
27
|
+
pass: false,
|
|
28
|
+
reason: `Unknown recording operation: ${opName}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const payload = opDef.payload(...args);
|
|
32
|
+
return {
|
|
33
|
+
pass: true,
|
|
34
|
+
event: {
|
|
35
|
+
type: opDef.event,
|
|
36
|
+
at: now,
|
|
37
|
+
...payload,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkBashCommand } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkBashCommand } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fail, pass, } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { GitInfo, TransitionContext, BashForbiddenConfig, WorkflowStateDefinition, WorkflowRegistry, } from '@nt-ai-lab/deterministic-agent-workflow-engine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nt-ai-lab/deterministic-agent-workflow-dsl",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@nt-ai-lab/deterministic-agent-workflow-engine": "workspace:*"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
}
|
|
19
|
+
}
|