@siduri-x/core 1.0.9 → 2.0.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/dist/action-policy.d.ts +28 -1
- package/dist/action-policy.js +167 -7
- package/dist/action-policy.test.js +104 -0
- package/dist/adversarial.test.js +4 -2
- package/dist/architecture-boundary.test.js +4 -12
- package/dist/capability.d.ts +11 -2
- package/dist/capability.js +8 -1
- package/dist/capability.test.js +43 -1
- package/dist/context-retriever.d.ts +8 -5
- package/dist/context-retriever.js +44 -15
- package/dist/database.d.ts +1 -0
- package/dist/database.js +17 -0
- package/dist/index.d.ts +46 -7
- package/dist/index.js +2 -0
- package/dist/prompt-compiler.d.ts +1 -0
- package/dist/prompt-compiler.js +7 -1
- package/dist/runtime.d.ts +12 -5
- package/dist/runtime.js +26 -8
- package/dist/schema-validator.test.js +2 -2
- package/dist/siduri-db.d.ts +138 -0
- package/dist/siduri-db.js +687 -0
- package/dist/siduri-db.test.d.ts +1 -0
- package/dist/siduri-db.test.js +863 -0
- package/dist/sqlite-action-store.d.ts +3 -2
- package/dist/sqlite-action-store.js +27 -4
- package/dist/sqlite-action-store.test.js +1 -0
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActionAuditEvent } from './action';
|
|
2
|
-
import { ActionStore, PersistentExecutionRecord } from './capability';
|
|
2
|
+
import { ActionStore, PersistentExecutionRecord, ActionApprovalRecord } from './capability';
|
|
3
3
|
export interface SqliteActionStoreOptions {
|
|
4
4
|
dbPath?: string;
|
|
5
5
|
}
|
|
@@ -12,8 +12,9 @@ export declare class SqliteActionStore implements ActionStore {
|
|
|
12
12
|
reserveExecution(record: PersistentExecutionRecord): Promise<boolean>;
|
|
13
13
|
updateExecution(record: PersistentExecutionRecord): Promise<void>;
|
|
14
14
|
getExecution(executionId: string): Promise<PersistentExecutionRecord | undefined>;
|
|
15
|
-
saveApproval(executionId: string, approverActorId: string, reason?: string): Promise<void>;
|
|
15
|
+
saveApproval(executionId: string, approverActorId: string, reason?: string, approverRole?: string): Promise<void>;
|
|
16
16
|
isActionApproved(executionId: string): Promise<boolean>;
|
|
17
|
+
getApproval(executionId: string): Promise<ActionApprovalRecord | undefined>;
|
|
17
18
|
appendAudit(event: ActionAuditEvent): Promise<void>;
|
|
18
19
|
getAuditLog(executionId?: string): Promise<ActionAuditEvent[]>;
|
|
19
20
|
close(): void;
|
|
@@ -36,6 +36,7 @@ class SqliteActionStore {
|
|
|
36
36
|
execution_id TEXT PRIMARY KEY,
|
|
37
37
|
approver_actor_id TEXT NOT NULL,
|
|
38
38
|
reason TEXT,
|
|
39
|
+
approver_role TEXT,
|
|
39
40
|
approved_at TEXT NOT NULL
|
|
40
41
|
);
|
|
41
42
|
|
|
@@ -62,6 +63,12 @@ class SqliteActionStore {
|
|
|
62
63
|
timestamp TEXT NOT NULL
|
|
63
64
|
);
|
|
64
65
|
`);
|
|
66
|
+
try {
|
|
67
|
+
this.db.exec('ALTER TABLE action_approvals ADD COLUMN approver_role TEXT;');
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Column already exists or table freshly created
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
73
|
initLastAuditHash() {
|
|
67
74
|
const row = this.db.prepare('SELECT event_hash FROM action_audit_log ORDER BY id DESC LIMIT 1').get();
|
|
@@ -127,22 +134,37 @@ class SqliteActionStore {
|
|
|
127
134
|
updatedAt: row.updated_at,
|
|
128
135
|
};
|
|
129
136
|
}
|
|
130
|
-
async saveApproval(executionId, approverActorId, reason) {
|
|
137
|
+
async saveApproval(executionId, approverActorId, reason, approverRole) {
|
|
131
138
|
const stmt = this.db.prepare(`
|
|
132
|
-
INSERT INTO action_approvals (execution_id, approver_actor_id, reason, approved_at)
|
|
133
|
-
VALUES (?, ?, ?, ?)
|
|
139
|
+
INSERT INTO action_approvals (execution_id, approver_actor_id, reason, approver_role, approved_at)
|
|
140
|
+
VALUES (?, ?, ?, ?, ?)
|
|
134
141
|
ON CONFLICT(execution_id) DO UPDATE SET
|
|
135
142
|
approver_actor_id = excluded.approver_actor_id,
|
|
136
143
|
reason = excluded.reason,
|
|
144
|
+
approver_role = excluded.approver_role,
|
|
137
145
|
approved_at = excluded.approved_at
|
|
138
146
|
`);
|
|
139
|
-
stmt.run(executionId, approverActorId, reason ?? null, new Date().toISOString());
|
|
147
|
+
stmt.run(executionId, approverActorId, reason ?? null, approverRole ?? null, new Date().toISOString());
|
|
140
148
|
}
|
|
141
149
|
async isActionApproved(executionId) {
|
|
142
150
|
const stmt = this.db.prepare('SELECT 1 FROM action_approvals WHERE execution_id = ?');
|
|
143
151
|
const row = stmt.get(executionId);
|
|
144
152
|
return !!row;
|
|
145
153
|
}
|
|
154
|
+
async getApproval(executionId) {
|
|
155
|
+
const stmt = this.db.prepare('SELECT * FROM action_approvals WHERE execution_id = ?');
|
|
156
|
+
const row = stmt.get(executionId);
|
|
157
|
+
if (!row) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
executionId: row.execution_id,
|
|
162
|
+
approverActorId: row.approver_actor_id,
|
|
163
|
+
reason: row.reason ?? undefined,
|
|
164
|
+
approverRole: row.approver_role ?? undefined,
|
|
165
|
+
approvedAt: row.approved_at,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
146
168
|
async appendAudit(event) {
|
|
147
169
|
const prevHash = this.lastAuditHash;
|
|
148
170
|
const eventPayload = {
|
|
@@ -164,6 +186,7 @@ class SqliteActionStore {
|
|
|
164
186
|
decisionCode: event.decision.decisionCode,
|
|
165
187
|
} : null,
|
|
166
188
|
parametersHash: event.parametersHash || null,
|
|
189
|
+
resultHash: event.resultHash || null,
|
|
167
190
|
error: event.error || null,
|
|
168
191
|
timestamp: event.timestamp,
|
|
169
192
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siduri-x/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Core runtime types, evidence protocol, action dispatcher, capability validation, and SiduriRuntime protocol",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=22.16.0"
|
|
21
21
|
},
|
|
22
22
|
"main": "dist/index.js",
|
|
23
23
|
"types": "dist/index.d.ts",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/jest": "^
|
|
33
|
-
"@types/node": "^26.
|
|
34
|
-
"jest": "^
|
|
32
|
+
"@types/jest": "^30.0.0",
|
|
33
|
+
"@types/node": "^26.5.1",
|
|
34
|
+
"jest": "^30.5.1",
|
|
35
35
|
"ts-jest": "^29.4.12",
|
|
36
|
-
"typescript": "^5.
|
|
36
|
+
"typescript": "^5.9.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc",
|