@nt-ai-lab/deterministic-agent-workflow-engine 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 +17 -0
- package/dist/index.js +8 -0
- package/dist/platform/domain/base-event.d.ts +13 -0
- package/dist/platform/domain/base-event.js +5 -0
- package/dist/platform/domain/bash-enforcement.d.ts +4 -0
- package/dist/platform/domain/bash-enforcement.js +24 -0
- package/dist/platform/domain/engine-events.d.ts +434 -0
- package/dist/platform/domain/engine-events.js +91 -0
- package/dist/platform/domain/identity-verification.d.ts +13 -0
- package/dist/platform/domain/identity-verification.js +19 -0
- package/dist/platform/domain/precondition-result.d.ts +9 -0
- package/dist/platform/domain/precondition-result.js +5 -0
- package/dist/platform/domain/repository-tracking-events.d.ts +86 -0
- package/dist/platform/domain/repository-tracking-events.js +21 -0
- package/dist/platform/domain/workflow-engine-support.d.ts +13 -0
- package/dist/platform/domain/workflow-engine-support.js +47 -0
- package/dist/platform/domain/workflow-engine-types.d.ts +57 -0
- package/dist/platform/domain/workflow-engine-types.js +1 -0
- package/dist/platform/domain/workflow-engine.d.ts +23 -0
- package/dist/platform/domain/workflow-engine.js +325 -0
- package/dist/platform/domain/workflow-registry.d.ts +41 -0
- package/dist/platform/domain/workflow-registry.js +1 -0
- package/dist/platform/domain/workflow-state.d.ts +8 -0
- package/dist/platform/domain/workflow-state.js +7 -0
- package/dist/platform/infra/cli/presentation/output-guidance.d.ts +15 -0
- package/dist/platform/infra/cli/presentation/output-guidance.js +29 -0
- package/dist/platform/infra/external-clients/transcript/transcript-reader.d.ts +9 -0
- package/dist/platform/infra/external-clients/transcript/transcript-reader.js +1 -0
- package/package.json +19 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { BaseWorkflowState } from './platform/domain/workflow-state';
|
|
2
|
+
export { WorkflowStateError } from './platform/domain/workflow-state';
|
|
3
|
+
export type { BaseEvent } from './platform/domain/base-event';
|
|
4
|
+
export { baseEventSchema } from './platform/domain/base-event';
|
|
5
|
+
export { engineEventSchema } from './platform/domain/engine-events';
|
|
6
|
+
export type { EngineEvent, SessionStartedEvent, TransitionedEvent, AgentRegisteredEvent, AgentShutDownEvent, JournalEntryEvent, WriteCheckedEvent, BashCheckedEvent, PluginReadCheckedEvent, IdleCheckedEvent, IdentityVerifiedEvent, ContextRequestedEvent, } from './platform/domain/engine-events';
|
|
7
|
+
export { repositoryMetadataEventSchema } from './platform/domain/repository-tracking-events';
|
|
8
|
+
export type { DomainMetadataEvent, IssueRecordedEvent, BranchRecordedEvent, PrRecordedEvent, } from './platform/domain/repository-tracking-events';
|
|
9
|
+
export { checkBashCommand } from './platform/domain/bash-enforcement';
|
|
10
|
+
export type { PreconditionResult } from './platform/domain/precondition-result';
|
|
11
|
+
export { pass, fail } from './platform/domain/precondition-result';
|
|
12
|
+
export type { GitInfo, TransitionContext, BashForbiddenConfig, WorkflowStateDefinition, WorkflowRegistry, } from './platform/domain/workflow-registry';
|
|
13
|
+
export { WorkflowEngine } from './platform/domain/workflow-engine';
|
|
14
|
+
export type { EngineResult, RehydratableWorkflow, WorkflowDefinition, WorkflowEventStore, WorkflowEngineDeps, } from './platform/domain/workflow-engine-types';
|
|
15
|
+
export type { TranscriptMessage, TranscriptReader } from './platform/infra/external-clients/transcript/transcript-reader';
|
|
16
|
+
export type { IdentityCheckResult } from './platform/domain/identity-verification';
|
|
17
|
+
export { checkIdentity } from './platform/domain/identity-verification';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { WorkflowStateError } from './platform/domain/workflow-state.js';
|
|
2
|
+
export { baseEventSchema } from './platform/domain/base-event.js';
|
|
3
|
+
export { engineEventSchema } from './platform/domain/engine-events.js';
|
|
4
|
+
export { repositoryMetadataEventSchema } from './platform/domain/repository-tracking-events.js';
|
|
5
|
+
export { checkBashCommand } from './platform/domain/bash-enforcement.js';
|
|
6
|
+
export { pass, fail } from './platform/domain/precondition-result.js';
|
|
7
|
+
export { WorkflowEngine } from './platform/domain/workflow-engine.js';
|
|
8
|
+
export { checkIdentity } from './platform/domain/identity-verification.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const baseEventSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodString;
|
|
4
|
+
at: z.ZodString;
|
|
5
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
6
|
+
type: z.ZodString;
|
|
7
|
+
at: z.ZodString;
|
|
8
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
9
|
+
type: z.ZodString;
|
|
10
|
+
at: z.ZodString;
|
|
11
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
12
|
+
/** @riviere-role value-object */
|
|
13
|
+
export type BaseEvent = z.infer<typeof baseEventSchema>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PreconditionResult } from './precondition-result';
|
|
2
|
+
import type { BashForbiddenConfig } from './workflow-registry';
|
|
3
|
+
/** @riviere-role domain-service */
|
|
4
|
+
export declare function checkBashCommand(command: string, forbidden: BashForbiddenConfig, stateExemptions: readonly string[]): PreconditionResult;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { fail, pass } from './precondition-result.js';
|
|
2
|
+
function buildCommandPattern(command) {
|
|
3
|
+
const parts = command.trim().split(/\s+/);
|
|
4
|
+
const escapedParts = parts.map((part) => part.replaceAll(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
|
5
|
+
const patternBody = escapedParts.join('\\s+');
|
|
6
|
+
return new RegExp(`(?:^|\\s|&&|;)${patternBody}(?:\\s|$|-|;|&)`);
|
|
7
|
+
}
|
|
8
|
+
/** @riviere-role domain-service */
|
|
9
|
+
export function checkBashCommand(command, forbidden, stateExemptions) {
|
|
10
|
+
for (const flag of forbidden.flags ?? []) {
|
|
11
|
+
if (command.includes(flag)) {
|
|
12
|
+
return fail(`Forbidden flag '${flag}' in command.`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
for (const forbiddenCommand of forbidden.commands) {
|
|
16
|
+
if (stateExemptions.includes(forbiddenCommand))
|
|
17
|
+
continue;
|
|
18
|
+
const pattern = buildCommandPattern(forbiddenCommand);
|
|
19
|
+
if (pattern.test(command)) {
|
|
20
|
+
return fail(`Forbidden command '${forbiddenCommand}' in command.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return pass();
|
|
24
|
+
}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const sessionStartedSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"session-started">;
|
|
4
|
+
at: z.ZodString;
|
|
5
|
+
transcriptPath: z.ZodOptional<z.ZodString>;
|
|
6
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
7
|
+
currentState: z.ZodOptional<z.ZodString>;
|
|
8
|
+
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
type: "session-started";
|
|
11
|
+
at: string;
|
|
12
|
+
transcriptPath?: string | undefined;
|
|
13
|
+
repository?: string | undefined;
|
|
14
|
+
currentState?: string | undefined;
|
|
15
|
+
states?: string[] | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
type: "session-started";
|
|
18
|
+
at: string;
|
|
19
|
+
transcriptPath?: string | undefined;
|
|
20
|
+
repository?: string | undefined;
|
|
21
|
+
currentState?: string | undefined;
|
|
22
|
+
states?: string[] | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
declare const transitionedSchema: z.ZodObject<{
|
|
25
|
+
type: z.ZodLiteral<"transitioned">;
|
|
26
|
+
at: z.ZodString;
|
|
27
|
+
from: z.ZodString;
|
|
28
|
+
to: z.ZodString;
|
|
29
|
+
preBlockedState: z.ZodOptional<z.ZodString>;
|
|
30
|
+
iteration: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
developingHeadCommit: z.ZodOptional<z.ZodString>;
|
|
32
|
+
developerDone: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
type: "transitioned";
|
|
35
|
+
at: string;
|
|
36
|
+
from: string;
|
|
37
|
+
to: string;
|
|
38
|
+
preBlockedState?: string | undefined;
|
|
39
|
+
iteration?: number | undefined;
|
|
40
|
+
developingHeadCommit?: string | undefined;
|
|
41
|
+
developerDone?: boolean | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
type: "transitioned";
|
|
44
|
+
at: string;
|
|
45
|
+
from: string;
|
|
46
|
+
to: string;
|
|
47
|
+
preBlockedState?: string | undefined;
|
|
48
|
+
iteration?: number | undefined;
|
|
49
|
+
developingHeadCommit?: string | undefined;
|
|
50
|
+
developerDone?: boolean | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
declare const agentRegisteredSchema: z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"agent-registered">;
|
|
54
|
+
at: z.ZodString;
|
|
55
|
+
agentType: z.ZodString;
|
|
56
|
+
agentId: z.ZodString;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
type: "agent-registered";
|
|
59
|
+
at: string;
|
|
60
|
+
agentType: string;
|
|
61
|
+
agentId: string;
|
|
62
|
+
}, {
|
|
63
|
+
type: "agent-registered";
|
|
64
|
+
at: string;
|
|
65
|
+
agentType: string;
|
|
66
|
+
agentId: string;
|
|
67
|
+
}>;
|
|
68
|
+
declare const agentShutDownSchema: z.ZodObject<{
|
|
69
|
+
type: z.ZodLiteral<"agent-shut-down">;
|
|
70
|
+
at: z.ZodString;
|
|
71
|
+
agentName: z.ZodString;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
type: "agent-shut-down";
|
|
74
|
+
at: string;
|
|
75
|
+
agentName: string;
|
|
76
|
+
}, {
|
|
77
|
+
type: "agent-shut-down";
|
|
78
|
+
at: string;
|
|
79
|
+
agentName: string;
|
|
80
|
+
}>;
|
|
81
|
+
declare const journalEntrySchema: z.ZodObject<{
|
|
82
|
+
type: z.ZodLiteral<"journal-entry">;
|
|
83
|
+
at: z.ZodString;
|
|
84
|
+
agentName: z.ZodString;
|
|
85
|
+
content: z.ZodString;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
type: "journal-entry";
|
|
88
|
+
at: string;
|
|
89
|
+
agentName: string;
|
|
90
|
+
content: string;
|
|
91
|
+
}, {
|
|
92
|
+
type: "journal-entry";
|
|
93
|
+
at: string;
|
|
94
|
+
agentName: string;
|
|
95
|
+
content: string;
|
|
96
|
+
}>;
|
|
97
|
+
declare const writeCheckedSchema: z.ZodObject<{
|
|
98
|
+
type: z.ZodLiteral<"write-checked">;
|
|
99
|
+
at: z.ZodString;
|
|
100
|
+
tool: z.ZodString;
|
|
101
|
+
filePath: z.ZodString;
|
|
102
|
+
allowed: z.ZodBoolean;
|
|
103
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
type: "write-checked";
|
|
106
|
+
at: string;
|
|
107
|
+
tool: string;
|
|
108
|
+
filePath: string;
|
|
109
|
+
allowed: boolean;
|
|
110
|
+
reason?: string | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
type: "write-checked";
|
|
113
|
+
at: string;
|
|
114
|
+
tool: string;
|
|
115
|
+
filePath: string;
|
|
116
|
+
allowed: boolean;
|
|
117
|
+
reason?: string | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
declare const bashCheckedSchema: z.ZodObject<{
|
|
120
|
+
type: z.ZodLiteral<"bash-checked">;
|
|
121
|
+
at: z.ZodString;
|
|
122
|
+
tool: z.ZodString;
|
|
123
|
+
command: z.ZodString;
|
|
124
|
+
allowed: z.ZodBoolean;
|
|
125
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
type: "bash-checked";
|
|
128
|
+
at: string;
|
|
129
|
+
tool: string;
|
|
130
|
+
allowed: boolean;
|
|
131
|
+
command: string;
|
|
132
|
+
reason?: string | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
type: "bash-checked";
|
|
135
|
+
at: string;
|
|
136
|
+
tool: string;
|
|
137
|
+
allowed: boolean;
|
|
138
|
+
command: string;
|
|
139
|
+
reason?: string | undefined;
|
|
140
|
+
}>;
|
|
141
|
+
declare const pluginReadCheckedSchema: z.ZodObject<{
|
|
142
|
+
type: z.ZodLiteral<"plugin-read-checked">;
|
|
143
|
+
at: z.ZodString;
|
|
144
|
+
tool: z.ZodString;
|
|
145
|
+
path: z.ZodString;
|
|
146
|
+
allowed: z.ZodBoolean;
|
|
147
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
type: "plugin-read-checked";
|
|
150
|
+
at: string;
|
|
151
|
+
path: string;
|
|
152
|
+
tool: string;
|
|
153
|
+
allowed: boolean;
|
|
154
|
+
reason?: string | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
type: "plugin-read-checked";
|
|
157
|
+
at: string;
|
|
158
|
+
path: string;
|
|
159
|
+
tool: string;
|
|
160
|
+
allowed: boolean;
|
|
161
|
+
reason?: string | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
declare const idleCheckedSchema: z.ZodObject<{
|
|
164
|
+
type: z.ZodLiteral<"idle-checked">;
|
|
165
|
+
at: z.ZodString;
|
|
166
|
+
agentName: z.ZodString;
|
|
167
|
+
allowed: z.ZodBoolean;
|
|
168
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
169
|
+
}, "strip", z.ZodTypeAny, {
|
|
170
|
+
type: "idle-checked";
|
|
171
|
+
at: string;
|
|
172
|
+
agentName: string;
|
|
173
|
+
allowed: boolean;
|
|
174
|
+
reason?: string | undefined;
|
|
175
|
+
}, {
|
|
176
|
+
type: "idle-checked";
|
|
177
|
+
at: string;
|
|
178
|
+
agentName: string;
|
|
179
|
+
allowed: boolean;
|
|
180
|
+
reason?: string | undefined;
|
|
181
|
+
}>;
|
|
182
|
+
declare const identityVerifiedSchema: z.ZodObject<{
|
|
183
|
+
type: z.ZodLiteral<"identity-verified">;
|
|
184
|
+
at: z.ZodString;
|
|
185
|
+
status: z.ZodString;
|
|
186
|
+
transcriptPath: z.ZodString;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
type: "identity-verified";
|
|
189
|
+
at: string;
|
|
190
|
+
status: string;
|
|
191
|
+
transcriptPath: string;
|
|
192
|
+
}, {
|
|
193
|
+
type: "identity-verified";
|
|
194
|
+
at: string;
|
|
195
|
+
status: string;
|
|
196
|
+
transcriptPath: string;
|
|
197
|
+
}>;
|
|
198
|
+
declare const contextRequestedSchema: z.ZodObject<{
|
|
199
|
+
type: z.ZodLiteral<"context-requested">;
|
|
200
|
+
at: z.ZodString;
|
|
201
|
+
agentName: z.ZodString;
|
|
202
|
+
}, "strip", z.ZodTypeAny, {
|
|
203
|
+
type: "context-requested";
|
|
204
|
+
at: string;
|
|
205
|
+
agentName: string;
|
|
206
|
+
}, {
|
|
207
|
+
type: "context-requested";
|
|
208
|
+
at: string;
|
|
209
|
+
agentName: string;
|
|
210
|
+
}>;
|
|
211
|
+
export declare const engineEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
212
|
+
type: z.ZodLiteral<"session-started">;
|
|
213
|
+
at: z.ZodString;
|
|
214
|
+
transcriptPath: z.ZodOptional<z.ZodString>;
|
|
215
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
216
|
+
currentState: z.ZodOptional<z.ZodString>;
|
|
217
|
+
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
type: "session-started";
|
|
220
|
+
at: string;
|
|
221
|
+
transcriptPath?: string | undefined;
|
|
222
|
+
repository?: string | undefined;
|
|
223
|
+
currentState?: string | undefined;
|
|
224
|
+
states?: string[] | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
type: "session-started";
|
|
227
|
+
at: string;
|
|
228
|
+
transcriptPath?: string | undefined;
|
|
229
|
+
repository?: string | undefined;
|
|
230
|
+
currentState?: string | undefined;
|
|
231
|
+
states?: string[] | undefined;
|
|
232
|
+
}>, z.ZodObject<{
|
|
233
|
+
type: z.ZodLiteral<"transitioned">;
|
|
234
|
+
at: z.ZodString;
|
|
235
|
+
from: z.ZodString;
|
|
236
|
+
to: z.ZodString;
|
|
237
|
+
preBlockedState: z.ZodOptional<z.ZodString>;
|
|
238
|
+
iteration: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
developingHeadCommit: z.ZodOptional<z.ZodString>;
|
|
240
|
+
developerDone: z.ZodOptional<z.ZodBoolean>;
|
|
241
|
+
}, "strip", z.ZodTypeAny, {
|
|
242
|
+
type: "transitioned";
|
|
243
|
+
at: string;
|
|
244
|
+
from: string;
|
|
245
|
+
to: string;
|
|
246
|
+
preBlockedState?: string | undefined;
|
|
247
|
+
iteration?: number | undefined;
|
|
248
|
+
developingHeadCommit?: string | undefined;
|
|
249
|
+
developerDone?: boolean | undefined;
|
|
250
|
+
}, {
|
|
251
|
+
type: "transitioned";
|
|
252
|
+
at: string;
|
|
253
|
+
from: string;
|
|
254
|
+
to: string;
|
|
255
|
+
preBlockedState?: string | undefined;
|
|
256
|
+
iteration?: number | undefined;
|
|
257
|
+
developingHeadCommit?: string | undefined;
|
|
258
|
+
developerDone?: boolean | undefined;
|
|
259
|
+
}>, z.ZodObject<{
|
|
260
|
+
type: z.ZodLiteral<"agent-registered">;
|
|
261
|
+
at: z.ZodString;
|
|
262
|
+
agentType: z.ZodString;
|
|
263
|
+
agentId: z.ZodString;
|
|
264
|
+
}, "strip", z.ZodTypeAny, {
|
|
265
|
+
type: "agent-registered";
|
|
266
|
+
at: string;
|
|
267
|
+
agentType: string;
|
|
268
|
+
agentId: string;
|
|
269
|
+
}, {
|
|
270
|
+
type: "agent-registered";
|
|
271
|
+
at: string;
|
|
272
|
+
agentType: string;
|
|
273
|
+
agentId: string;
|
|
274
|
+
}>, z.ZodObject<{
|
|
275
|
+
type: z.ZodLiteral<"agent-shut-down">;
|
|
276
|
+
at: z.ZodString;
|
|
277
|
+
agentName: z.ZodString;
|
|
278
|
+
}, "strip", z.ZodTypeAny, {
|
|
279
|
+
type: "agent-shut-down";
|
|
280
|
+
at: string;
|
|
281
|
+
agentName: string;
|
|
282
|
+
}, {
|
|
283
|
+
type: "agent-shut-down";
|
|
284
|
+
at: string;
|
|
285
|
+
agentName: string;
|
|
286
|
+
}>, z.ZodObject<{
|
|
287
|
+
type: z.ZodLiteral<"journal-entry">;
|
|
288
|
+
at: z.ZodString;
|
|
289
|
+
agentName: z.ZodString;
|
|
290
|
+
content: z.ZodString;
|
|
291
|
+
}, "strip", z.ZodTypeAny, {
|
|
292
|
+
type: "journal-entry";
|
|
293
|
+
at: string;
|
|
294
|
+
agentName: string;
|
|
295
|
+
content: string;
|
|
296
|
+
}, {
|
|
297
|
+
type: "journal-entry";
|
|
298
|
+
at: string;
|
|
299
|
+
agentName: string;
|
|
300
|
+
content: string;
|
|
301
|
+
}>, z.ZodObject<{
|
|
302
|
+
type: z.ZodLiteral<"write-checked">;
|
|
303
|
+
at: z.ZodString;
|
|
304
|
+
tool: z.ZodString;
|
|
305
|
+
filePath: z.ZodString;
|
|
306
|
+
allowed: z.ZodBoolean;
|
|
307
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
308
|
+
}, "strip", z.ZodTypeAny, {
|
|
309
|
+
type: "write-checked";
|
|
310
|
+
at: string;
|
|
311
|
+
tool: string;
|
|
312
|
+
filePath: string;
|
|
313
|
+
allowed: boolean;
|
|
314
|
+
reason?: string | undefined;
|
|
315
|
+
}, {
|
|
316
|
+
type: "write-checked";
|
|
317
|
+
at: string;
|
|
318
|
+
tool: string;
|
|
319
|
+
filePath: string;
|
|
320
|
+
allowed: boolean;
|
|
321
|
+
reason?: string | undefined;
|
|
322
|
+
}>, z.ZodObject<{
|
|
323
|
+
type: z.ZodLiteral<"bash-checked">;
|
|
324
|
+
at: z.ZodString;
|
|
325
|
+
tool: z.ZodString;
|
|
326
|
+
command: z.ZodString;
|
|
327
|
+
allowed: z.ZodBoolean;
|
|
328
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
329
|
+
}, "strip", z.ZodTypeAny, {
|
|
330
|
+
type: "bash-checked";
|
|
331
|
+
at: string;
|
|
332
|
+
tool: string;
|
|
333
|
+
allowed: boolean;
|
|
334
|
+
command: string;
|
|
335
|
+
reason?: string | undefined;
|
|
336
|
+
}, {
|
|
337
|
+
type: "bash-checked";
|
|
338
|
+
at: string;
|
|
339
|
+
tool: string;
|
|
340
|
+
allowed: boolean;
|
|
341
|
+
command: string;
|
|
342
|
+
reason?: string | undefined;
|
|
343
|
+
}>, z.ZodObject<{
|
|
344
|
+
type: z.ZodLiteral<"plugin-read-checked">;
|
|
345
|
+
at: z.ZodString;
|
|
346
|
+
tool: z.ZodString;
|
|
347
|
+
path: z.ZodString;
|
|
348
|
+
allowed: z.ZodBoolean;
|
|
349
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
350
|
+
}, "strip", z.ZodTypeAny, {
|
|
351
|
+
type: "plugin-read-checked";
|
|
352
|
+
at: string;
|
|
353
|
+
path: string;
|
|
354
|
+
tool: string;
|
|
355
|
+
allowed: boolean;
|
|
356
|
+
reason?: string | undefined;
|
|
357
|
+
}, {
|
|
358
|
+
type: "plugin-read-checked";
|
|
359
|
+
at: string;
|
|
360
|
+
path: string;
|
|
361
|
+
tool: string;
|
|
362
|
+
allowed: boolean;
|
|
363
|
+
reason?: string | undefined;
|
|
364
|
+
}>, z.ZodObject<{
|
|
365
|
+
type: z.ZodLiteral<"idle-checked">;
|
|
366
|
+
at: z.ZodString;
|
|
367
|
+
agentName: z.ZodString;
|
|
368
|
+
allowed: z.ZodBoolean;
|
|
369
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
370
|
+
}, "strip", z.ZodTypeAny, {
|
|
371
|
+
type: "idle-checked";
|
|
372
|
+
at: string;
|
|
373
|
+
agentName: string;
|
|
374
|
+
allowed: boolean;
|
|
375
|
+
reason?: string | undefined;
|
|
376
|
+
}, {
|
|
377
|
+
type: "idle-checked";
|
|
378
|
+
at: string;
|
|
379
|
+
agentName: string;
|
|
380
|
+
allowed: boolean;
|
|
381
|
+
reason?: string | undefined;
|
|
382
|
+
}>, z.ZodObject<{
|
|
383
|
+
type: z.ZodLiteral<"identity-verified">;
|
|
384
|
+
at: z.ZodString;
|
|
385
|
+
status: z.ZodString;
|
|
386
|
+
transcriptPath: z.ZodString;
|
|
387
|
+
}, "strip", z.ZodTypeAny, {
|
|
388
|
+
type: "identity-verified";
|
|
389
|
+
at: string;
|
|
390
|
+
status: string;
|
|
391
|
+
transcriptPath: string;
|
|
392
|
+
}, {
|
|
393
|
+
type: "identity-verified";
|
|
394
|
+
at: string;
|
|
395
|
+
status: string;
|
|
396
|
+
transcriptPath: string;
|
|
397
|
+
}>, z.ZodObject<{
|
|
398
|
+
type: z.ZodLiteral<"context-requested">;
|
|
399
|
+
at: z.ZodString;
|
|
400
|
+
agentName: z.ZodString;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
type: "context-requested";
|
|
403
|
+
at: string;
|
|
404
|
+
agentName: string;
|
|
405
|
+
}, {
|
|
406
|
+
type: "context-requested";
|
|
407
|
+
at: string;
|
|
408
|
+
agentName: string;
|
|
409
|
+
}>]>;
|
|
410
|
+
/** @riviere-role value-object */
|
|
411
|
+
export type EngineEvent = z.infer<typeof engineEventSchema>;
|
|
412
|
+
/** @riviere-role value-object */
|
|
413
|
+
export type SessionStartedEvent = z.infer<typeof sessionStartedSchema>;
|
|
414
|
+
/** @riviere-role value-object */
|
|
415
|
+
export type TransitionedEvent = z.infer<typeof transitionedSchema>;
|
|
416
|
+
/** @riviere-role value-object */
|
|
417
|
+
export type AgentRegisteredEvent = z.infer<typeof agentRegisteredSchema>;
|
|
418
|
+
/** @riviere-role value-object */
|
|
419
|
+
export type AgentShutDownEvent = z.infer<typeof agentShutDownSchema>;
|
|
420
|
+
/** @riviere-role value-object */
|
|
421
|
+
export type JournalEntryEvent = z.infer<typeof journalEntrySchema>;
|
|
422
|
+
/** @riviere-role value-object */
|
|
423
|
+
export type WriteCheckedEvent = z.infer<typeof writeCheckedSchema>;
|
|
424
|
+
/** @riviere-role value-object */
|
|
425
|
+
export type BashCheckedEvent = z.infer<typeof bashCheckedSchema>;
|
|
426
|
+
/** @riviere-role value-object */
|
|
427
|
+
export type PluginReadCheckedEvent = z.infer<typeof pluginReadCheckedSchema>;
|
|
428
|
+
/** @riviere-role value-object */
|
|
429
|
+
export type IdleCheckedEvent = z.infer<typeof idleCheckedSchema>;
|
|
430
|
+
/** @riviere-role value-object */
|
|
431
|
+
export type IdentityVerifiedEvent = z.infer<typeof identityVerifiedSchema>;
|
|
432
|
+
/** @riviere-role value-object */
|
|
433
|
+
export type ContextRequestedEvent = z.infer<typeof contextRequestedSchema>;
|
|
434
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const sessionStartedSchema = z.object({
|
|
3
|
+
type: z.literal('session-started'),
|
|
4
|
+
at: z.string(),
|
|
5
|
+
transcriptPath: z.string().optional(),
|
|
6
|
+
repository: z.string().optional(),
|
|
7
|
+
currentState: z.string().optional(),
|
|
8
|
+
states: z.array(z.string()).optional(),
|
|
9
|
+
});
|
|
10
|
+
const transitionedSchema = z.object({
|
|
11
|
+
type: z.literal('transitioned'),
|
|
12
|
+
at: z.string(),
|
|
13
|
+
from: z.string(),
|
|
14
|
+
to: z.string(),
|
|
15
|
+
preBlockedState: z.string().optional(),
|
|
16
|
+
iteration: z.number().optional(),
|
|
17
|
+
developingHeadCommit: z.string().optional(),
|
|
18
|
+
developerDone: z.boolean().optional(),
|
|
19
|
+
});
|
|
20
|
+
const agentRegisteredSchema = z.object({
|
|
21
|
+
type: z.literal('agent-registered'),
|
|
22
|
+
at: z.string(),
|
|
23
|
+
agentType: z.string(),
|
|
24
|
+
agentId: z.string(),
|
|
25
|
+
});
|
|
26
|
+
const agentShutDownSchema = z.object({
|
|
27
|
+
type: z.literal('agent-shut-down'),
|
|
28
|
+
at: z.string(),
|
|
29
|
+
agentName: z.string(),
|
|
30
|
+
});
|
|
31
|
+
const journalEntrySchema = z.object({
|
|
32
|
+
type: z.literal('journal-entry'),
|
|
33
|
+
at: z.string(),
|
|
34
|
+
agentName: z.string(),
|
|
35
|
+
content: z.string(),
|
|
36
|
+
});
|
|
37
|
+
const writeCheckedSchema = z.object({
|
|
38
|
+
type: z.literal('write-checked'),
|
|
39
|
+
at: z.string(),
|
|
40
|
+
tool: z.string(),
|
|
41
|
+
filePath: z.string(),
|
|
42
|
+
allowed: z.boolean(),
|
|
43
|
+
reason: z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
const bashCheckedSchema = z.object({
|
|
46
|
+
type: z.literal('bash-checked'),
|
|
47
|
+
at: z.string(),
|
|
48
|
+
tool: z.string(),
|
|
49
|
+
command: z.string(),
|
|
50
|
+
allowed: z.boolean(),
|
|
51
|
+
reason: z.string().optional(),
|
|
52
|
+
});
|
|
53
|
+
const pluginReadCheckedSchema = z.object({
|
|
54
|
+
type: z.literal('plugin-read-checked'),
|
|
55
|
+
at: z.string(),
|
|
56
|
+
tool: z.string(),
|
|
57
|
+
path: z.string(),
|
|
58
|
+
allowed: z.boolean(),
|
|
59
|
+
reason: z.string().optional(),
|
|
60
|
+
});
|
|
61
|
+
const idleCheckedSchema = z.object({
|
|
62
|
+
type: z.literal('idle-checked'),
|
|
63
|
+
at: z.string(),
|
|
64
|
+
agentName: z.string(),
|
|
65
|
+
allowed: z.boolean(),
|
|
66
|
+
reason: z.string().optional(),
|
|
67
|
+
});
|
|
68
|
+
const identityVerifiedSchema = z.object({
|
|
69
|
+
type: z.literal('identity-verified'),
|
|
70
|
+
at: z.string(),
|
|
71
|
+
status: z.string(),
|
|
72
|
+
transcriptPath: z.string(),
|
|
73
|
+
});
|
|
74
|
+
const contextRequestedSchema = z.object({
|
|
75
|
+
type: z.literal('context-requested'),
|
|
76
|
+
at: z.string(),
|
|
77
|
+
agentName: z.string(),
|
|
78
|
+
});
|
|
79
|
+
export const engineEventSchema = z.discriminatedUnion('type', [
|
|
80
|
+
sessionStartedSchema,
|
|
81
|
+
transitionedSchema,
|
|
82
|
+
agentRegisteredSchema,
|
|
83
|
+
agentShutDownSchema,
|
|
84
|
+
journalEntrySchema,
|
|
85
|
+
writeCheckedSchema,
|
|
86
|
+
bashCheckedSchema,
|
|
87
|
+
pluginReadCheckedSchema,
|
|
88
|
+
idleCheckedSchema,
|
|
89
|
+
identityVerifiedSchema,
|
|
90
|
+
contextRequestedSchema,
|
|
91
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TranscriptMessage } from '../infra/external-clients/transcript/transcript-reader';
|
|
2
|
+
/** @riviere-role value-object */
|
|
3
|
+
export type IdentityCheckResult = {
|
|
4
|
+
readonly status: 'verified';
|
|
5
|
+
} | {
|
|
6
|
+
readonly status: 'never-spoken';
|
|
7
|
+
} | {
|
|
8
|
+
readonly status: 'silent-turn';
|
|
9
|
+
} | {
|
|
10
|
+
readonly status: 'lost';
|
|
11
|
+
};
|
|
12
|
+
/** @riviere-role domain-service */
|
|
13
|
+
export declare function checkIdentity(messages: readonly TranscriptMessage[], pattern: RegExp): IdentityCheckResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @riviere-role domain-service */
|
|
2
|
+
export function checkIdentity(messages, pattern) {
|
|
3
|
+
const textMessages = messages.filter((message) => message.textContent !== undefined);
|
|
4
|
+
if (textMessages.length === 0) {
|
|
5
|
+
return { status: 'never-spoken' };
|
|
6
|
+
}
|
|
7
|
+
const hasEverSpokenWithPrefix = textMessages.some((message) => message.textContent !== undefined && pattern.test(message.textContent));
|
|
8
|
+
if (!hasEverSpokenWithPrefix) {
|
|
9
|
+
return { status: 'lost' };
|
|
10
|
+
}
|
|
11
|
+
const lastMessage = messages.at(-1);
|
|
12
|
+
if (lastMessage?.textContent === undefined) {
|
|
13
|
+
return { status: 'silent-turn' };
|
|
14
|
+
}
|
|
15
|
+
if (pattern.test(lastMessage.textContent)) {
|
|
16
|
+
return { status: 'verified' };
|
|
17
|
+
}
|
|
18
|
+
return { status: 'lost' };
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @riviere-role value-object */
|
|
2
|
+
export type PreconditionResult = {
|
|
3
|
+
readonly pass: true;
|
|
4
|
+
} | {
|
|
5
|
+
readonly pass: false;
|
|
6
|
+
readonly reason: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const pass: () => PreconditionResult;
|
|
9
|
+
export declare const fail: (reason: string) => PreconditionResult;
|