@lmzhen/dsh-evolution-state-domain 0.17.0 → 0.18.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/lib/index.js +6 -18
- package/lib/types/index.d.ts +11 -2
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { DomainError, defineDomain, domainTable } from "@deepseek-ai/dsh-storage-domain";
|
|
3
|
-
import { CURATOR_STATE_KEY, CURATOR_STATE_TABLE, PENDING_RESOLVED_CAP, PENDING_TABLE, PROVIDER_DOMAIN, REVIEW_STATE_SESSION_CAP, REVIEW_STATE_TABLE, assertCloneable, canClaimPending, canResolvePending, cloneRecord, recordIssue, releasedStatus, selectPendingOverflow, selectSessionOverflow } from "@lmzhen/dsh-evolution-state-storage";
|
|
3
|
+
import { CURATOR_STATE_KEY, CURATOR_STATE_TABLE, PENDING_KINDS, PENDING_RESOLVED_CAP, PENDING_STATUSES, PENDING_TABLE, PROVIDER_DOMAIN, REVIEW_STATE_SESSION_CAP, REVIEW_STATE_TABLE, assertCloneable, canClaimPending, canResolvePending, cloneRecord, recordIssue, releasedStatus, selectPendingOverflow, selectSessionOverflow } from "@lmzhen/dsh-evolution-state-storage";
|
|
4
4
|
//#region lib/types/index.js
|
|
5
5
|
/**
|
|
6
6
|
* storage-domain provider for evolution state.
|
|
@@ -44,20 +44,11 @@ const curatorStateSchema = z.object({
|
|
|
44
44
|
*/
|
|
45
45
|
const pendingSchema = z.object({
|
|
46
46
|
id: z.string(),
|
|
47
|
-
kind: z.
|
|
48
|
-
z.literal("memory"),
|
|
49
|
-
z.literal("skill"),
|
|
50
|
-
z.literal("capability")
|
|
51
|
-
]),
|
|
47
|
+
kind: z.enum(PENDING_KINDS),
|
|
52
48
|
summary: z.string(),
|
|
53
49
|
args: z.unknown(),
|
|
54
50
|
createdAt: z.string(),
|
|
55
|
-
status: z.
|
|
56
|
-
z.literal("pending"),
|
|
57
|
-
z.literal("executing"),
|
|
58
|
-
z.literal("approved"),
|
|
59
|
-
z.literal("rejected")
|
|
60
|
-
]),
|
|
51
|
+
status: z.enum(PENDING_STATUSES),
|
|
61
52
|
resolvedAt: z.string().optional(),
|
|
62
53
|
claimedBy: z.string().optional(),
|
|
63
54
|
claimedAt: z.string().optional(),
|
|
@@ -235,19 +226,16 @@ function apply(ctx) {
|
|
|
235
226
|
}
|
|
236
227
|
const final = drifted.length > 0 ? [...table.entries()] : entries;
|
|
237
228
|
const seen = /* @__PURE__ */ new Set();
|
|
238
|
-
return final.filter(([, value]) => {
|
|
229
|
+
return final.filter(([, value]) => value.status === status).filter(([, value]) => {
|
|
239
230
|
if (seen.has(value.id)) return false;
|
|
240
231
|
seen.add(value.id);
|
|
241
|
-
return
|
|
232
|
+
return true;
|
|
242
233
|
}).map(([, value]) => structuredClone(value));
|
|
243
234
|
},
|
|
244
235
|
async savePending(record) {
|
|
245
236
|
const issue = recordIssue(PENDING_TABLE, record) ?? assertCloneable(record);
|
|
246
237
|
if (issue !== null) throw new Error(`evolution-state-domain: refusing to persist an invalid pending record: ${issue}`);
|
|
247
|
-
const parsed = pendingSchema.safeParse(
|
|
248
|
-
...record,
|
|
249
|
-
args: record.args
|
|
250
|
-
});
|
|
238
|
+
const parsed = pendingSchema.safeParse(record);
|
|
251
239
|
if (!parsed.success) throw new Error(`evolution-state-domain: refusing to persist an invalid pending record: ${parsed.error.issues[0]?.message ?? "schema mismatch"}`);
|
|
252
240
|
await (await ensure()).table(PENDING_TABLE).put(record.id, cloneRecord(parsed.data));
|
|
253
241
|
},
|
package/lib/types/index.d.ts
CHANGED
|
@@ -42,11 +42,20 @@ export declare const curatorStateSchema: z.ZodObject<{
|
|
|
42
42
|
*/
|
|
43
43
|
export declare const pendingSchema: z.ZodObject<{
|
|
44
44
|
id: z.ZodString;
|
|
45
|
-
kind: z.
|
|
45
|
+
kind: z.ZodEnum<{
|
|
46
|
+
memory: "memory";
|
|
47
|
+
skill: "skill";
|
|
48
|
+
capability: "capability";
|
|
49
|
+
}>;
|
|
46
50
|
summary: z.ZodString;
|
|
47
51
|
args: z.ZodUnknown;
|
|
48
52
|
createdAt: z.ZodString;
|
|
49
|
-
status: z.
|
|
53
|
+
status: z.ZodEnum<{
|
|
54
|
+
pending: "pending";
|
|
55
|
+
executing: "executing";
|
|
56
|
+
approved: "approved";
|
|
57
|
+
rejected: "rejected";
|
|
58
|
+
}>;
|
|
50
59
|
resolvedAt: z.ZodOptional<z.ZodString>;
|
|
51
60
|
claimedBy: z.ZodOptional<z.ZodString>;
|
|
52
61
|
claimedAt: z.ZodOptional<z.ZodString>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-state-domain",
|
|
3
3
|
"description": "storage-domain provider for evolution state (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
33
33
|
"@deepseek-ai/dsh-storage-domain": "^0.2.0-rc.1",
|
|
34
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.
|
|
34
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.18.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@deepseek-ai/dsh-storage-domain": "^0.2.0-rc.1",
|
|
38
38
|
"@deepseek-ai/dsh-storage": "^0.2.0-rc.1",
|
|
39
39
|
"@deepseek-ai/dsh-storage-json": "^0.2.0-rc.1",
|
|
40
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.
|
|
40
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.18.0"
|
|
41
41
|
}
|
|
42
42
|
}
|