@ifsoul/core 0.3.0 → 0.4.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/README.md +28 -34
- package/dist/packages/memory/src/sql.js +54 -5
- package/dist/packages/protocol/src/generated/validators.cjs +1 -1
- package/dist/packages/protocol/src/index.d.ts +1 -6
- package/dist/packages/protocol/src/index.js +3 -16
- package/dist/packages/protocol/src/types.d.ts +1 -1
- package/dist/packages/runtime/src/index.js +1 -1
- package/package.json +2 -3
- package/packages/protocol/schemas/current/archive.schema.json +16 -16
- package/packages/protocol/schemas/current/character.schema.json +21 -21
- package/packages/protocol/schemas/current/common.schema.json +15 -15
- package/packages/protocol/schemas/current/context.schema.json +24 -24
- package/packages/protocol/schemas/current/conversation.schema.json +39 -39
- package/packages/protocol/schemas/current/environment.schema.json +18 -18
- package/packages/protocol/schemas/current/memory.schema.json +66 -66
- package/packages/protocol/schemas/current/model-provider.schema.json +40 -40
- package/packages/protocol/schemas/current/planning.schema.json +61 -61
- package/packages/protocol/schemas/current/provider-common.schema.json +6 -6
- package/release.json +7 -12
- package/specs/README.md +3 -86
- package/specs/current/README.md +3 -5
- package/specs/current/examples/archive-fork.json +12 -12
- package/specs/current/examples/archive-resume.json +12 -12
- package/specs/current/examples/character-instance.json +1 -1
- package/specs/current/examples/character-template.json +1 -1
- package/specs/current/examples/context-after-inspection.json +1 -1
- package/specs/current/examples/context-chat.json +1 -1
- package/specs/current/examples/context-daily.json +1 -1
- package/specs/current/examples/context-no-speech.json +1 -1
- package/specs/current/examples/conversation-delivery.json +1 -1
- package/specs/current/examples/conversation-live-request.json +1 -1
- package/specs/current/examples/conversation-live-response.json +1 -1
- package/specs/current/examples/conversation-no-speech-request.json +1 -1
- package/specs/current/examples/conversation-no-speech-response.json +1 -1
- package/specs/current/examples/conversation-requested-request.json +1 -1
- package/specs/current/examples/conversation-requested-response.json +1 -1
- package/specs/current/examples/environment-chat.json +1 -1
- package/specs/current/examples/environment-game.json +1 -1
- package/specs/current/examples/environment-no-speech.json +1 -1
- package/specs/current/examples/intent-checkpoint.json +1 -1
- package/specs/current/examples/memory-episode.json +1 -1
- package/specs/current/examples/memory-event-conversation.json +1 -1
- package/specs/current/examples/memory-event-observed.json +2 -2
- package/specs/current/examples/memory-event-plan-proposal.json +2 -2
- package/specs/current/examples/memory-event-proposed.json +2 -2
- package/specs/current/examples/memory-fact.json +1 -1
- package/specs/current/examples/memory-relationship.json +1 -1
- package/specs/current/examples/memory-working-context.json +1 -1
- package/specs/current/examples/plan-cancel-request.json +1 -1
- package/specs/current/examples/plan-cancel-result.json +1 -1
- package/specs/current/examples/plan-daily.json +1 -1
- package/specs/current/examples/plan-partial-decision.json +1 -1
- package/specs/current/examples/portable-memory.jsonl +9 -9
- package/specs/current/examples/task-outcome.json +1 -1
- package/specs/current/examples/task-progress.json +1 -1
- package/specs/current/model-provider/examples/capabilities.json +1 -1
- package/specs/current/model-provider/examples/error.json +1 -1
- package/specs/current/model-provider/examples/request.json +1 -1
- package/specs/current/model-provider/examples/response.json +1 -1
- package/docs/npm-publishing.md +0 -44
- package/packages/protocol/schemas/action-result.schema.json +0 -187
- package/packages/protocol/schemas/action.schema.json +0 -68
- package/packages/protocol/schemas/archive-manifest.schema.json +0 -126
- package/packages/protocol/schemas/capability.schema.json +0 -131
- package/packages/protocol/schemas/character-instance.schema.json +0 -73
- package/packages/protocol/schemas/character-template.schema.json +0 -67
- package/packages/protocol/schemas/common.schema.json +0 -154
- package/packages/protocol/schemas/derived-memory.schema.json +0 -145
- package/packages/protocol/schemas/memory-event.schema.json +0 -123
- package/packages/protocol/schemas/model-provider.schema.json +0 -326
- package/packages/protocol/schemas/perception.schema.json +0 -89
- package/packages/protocol/schemas/permission-policy.schema.json +0 -153
- package/packages/protocol/schemas/v0.2/archive.schema.json +0 -205
- package/packages/protocol/schemas/v0.2/character.schema.json +0 -344
- package/packages/protocol/schemas/v0.2/common.schema.json +0 -239
- package/packages/protocol/schemas/v0.2/context.schema.json +0 -230
- package/packages/protocol/schemas/v0.2/conversation.schema.json +0 -340
- package/packages/protocol/schemas/v0.2/environment.schema.json +0 -244
- package/packages/protocol/schemas/v0.2/memory.schema.json +0 -495
- package/packages/protocol/schemas/v0.2/planning.schema.json +0 -443
- package/packages/protocol/schemas/world-event.schema.json +0 -74
- package/specs/character/README.md +0 -84
- package/specs/character/examples/archive-manifest.json +0 -32
- package/specs/character/examples/character-instance.json +0 -20
- package/specs/character/examples/character-template.json +0 -19
- package/specs/memory/README.md +0 -80
- package/specs/memory/examples/derived-memory.json +0 -21
- package/specs/memory/examples/memory-event.json +0 -35
- package/specs/model-provider/README.md +0 -85
- package/specs/model-provider/examples/capabilities.json +0 -10
- package/specs/model-provider/examples/error.json +0 -18
- package/specs/model-provider/examples/request.json +0 -17
- package/specs/model-provider/examples/response.json +0 -19
- package/specs/v0.2/README.md +0 -421
- package/specs/v0.2/examples/archive-fork.json +0 -64
- package/specs/v0.2/examples/archive-resume.json +0 -63
- package/specs/v0.2/examples/character-instance.json +0 -57
- package/specs/v0.2/examples/character-template.json +0 -45
- package/specs/v0.2/examples/context-after-inspection.json +0 -44
- package/specs/v0.2/examples/context-chat.json +0 -27
- package/specs/v0.2/examples/context-daily.json +0 -69
- package/specs/v0.2/examples/context-no-speech.json +0 -27
- package/specs/v0.2/examples/conversation-delivery.json +0 -17
- package/specs/v0.2/examples/conversation-live-request.json +0 -31
- package/specs/v0.2/examples/conversation-live-response.json +0 -23
- package/specs/v0.2/examples/conversation-no-speech-request.json +0 -23
- package/specs/v0.2/examples/conversation-no-speech-response.json +0 -22
- package/specs/v0.2/examples/conversation-requested-request.json +0 -31
- package/specs/v0.2/examples/conversation-requested-response.json +0 -23
- package/specs/v0.2/examples/environment-chat.json +0 -43
- package/specs/v0.2/examples/environment-game.json +0 -80
- package/specs/v0.2/examples/environment-no-speech.json +0 -47
- package/specs/v0.2/examples/intent-checkpoint.json +0 -29
- package/specs/v0.2/examples/memory-episode.json +0 -28
- package/specs/v0.2/examples/memory-event-conversation.json +0 -32
- package/specs/v0.2/examples/memory-event-observed.json +0 -50
- package/specs/v0.2/examples/memory-event-plan-proposal.json +0 -82
- package/specs/v0.2/examples/memory-event-proposed.json +0 -53
- package/specs/v0.2/examples/memory-fact.json +0 -23
- package/specs/v0.2/examples/memory-relationship.json +0 -25
- package/specs/v0.2/examples/memory-working-context.json +0 -24
- package/specs/v0.2/examples/plan-cancel-request.json +0 -16
- package/specs/v0.2/examples/plan-cancel-result.json +0 -21
- package/specs/v0.2/examples/plan-daily.json +0 -57
- package/specs/v0.2/examples/plan-partial-decision.json +0 -28
- package/specs/v0.2/examples/portable-memory.jsonl +0 -9
- package/specs/v0.2/examples/task-outcome.json +0 -21
- package/specs/v0.2/examples/task-progress.json +0 -19
- package/specs/world-adapter/README.md +0 -114
- package/specs/world-adapter/examples/action-result-unknown.json +0 -23
- package/specs/world-adapter/examples/action-result.json +0 -45
- package/specs/world-adapter/examples/action.json +0 -17
- package/specs/world-adapter/examples/capability.json +0 -44
- package/specs/world-adapter/examples/perception.json +0 -30
- package/specs/world-adapter/examples/permission-decision.json +0 -14
- package/specs/world-adapter/examples/permission-policy.json +0 -17
- package/specs/world-adapter/examples/world-event.json +0 -25
package/README.md
CHANGED
|
@@ -8,24 +8,18 @@ This repository contains no game, website, React UI, Clerk authentication or
|
|
|
8
8
|
managed deployment. The public [SDK](https://github.com/openifsoul/sdk) owns
|
|
9
9
|
bounded host bridges; public [App](https://github.com/openifsoul/app) owns
|
|
10
10
|
self-hostable composition and the local laboratory. Private Website and Cloud
|
|
11
|
-
compose these public artifacts. See [repository ownership](https://github.com/openifsoul/core/blob/main/docs/
|
|
11
|
+
compose these public artifacts. See [repository ownership](https://github.com/openifsoul/core/blob/main/docs/architecture.md).
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Install
|
|
14
14
|
|
|
15
|
-
Use Node.js
|
|
15
|
+
Use Node.js 22.18–24 and an ESM project:
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
|
|
19
|
-
pnpm check
|
|
20
|
-
pnpm build
|
|
21
|
-
pnpm pack:core
|
|
18
|
+
npm install @ifsoul/core@0.4.0
|
|
22
19
|
```
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
sibling/private repository or account is needed. [Development](https://github.com/openifsoul/core/blob/main/docs/development.md)
|
|
27
|
-
describes validation; [deployment policy](https://github.com/openifsoul/core/blob/main/docs/deployment.md) prohibits automatic
|
|
28
|
-
remote execution.
|
|
21
|
+
The package includes compiled JavaScript and TypeScript declarations. Import the
|
|
22
|
+
explicit module you need:
|
|
29
23
|
|
|
30
24
|
```ts
|
|
31
25
|
import { validateDocument } from "@ifsoul/core/protocol";
|
|
@@ -41,30 +35,30 @@ connections confer no control authority.
|
|
|
41
35
|
|
|
42
36
|
## Contracts and limits
|
|
43
37
|
|
|
44
|
-
The [current contracts](specs/current/README.md) use IfSoul 0.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[versioning](https://github.com/openifsoul/core/blob/main/docs/versioning.md).
|
|
38
|
+
The [current contracts](specs/current/README.md) use IfSoul 0.4.0. See
|
|
39
|
+
[compatibility](https://github.com/openifsoul/core/blob/main/docs/compatibility.md)
|
|
40
|
+
for identifiers and validation, and the
|
|
41
|
+
[runtime API](https://github.com/openifsoul/core/blob/main/docs/runtime-api.md)
|
|
42
|
+
for integration details. Matching release identifiers do not make different
|
|
43
|
+
format families interchangeable.
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
Trusted configurable provider/runtime budgets are separate from model token
|
|
46
|
+
context, permissions and host authority. See
|
|
47
|
+
[resource budgets](https://github.com/openifsoul/core/blob/main/docs/resource-budgets.md)
|
|
48
|
+
and [security](https://github.com/openifsoul/core/blob/main/docs/security.md).
|
|
49
|
+
Relationship interpretation and revision are model-dependent. Current validation
|
|
50
|
+
and persistence checks do not establish reliable semantic reassessment.
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
## Develop locally
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
Clone this repository and use pnpm 10.15.0:
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## npm publication status
|
|
56
|
+
```sh
|
|
57
|
+
pnpm install --frozen-lockfile
|
|
58
|
+
pnpm check
|
|
59
|
+
pnpm build
|
|
60
|
+
```
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
remains supported until a real registry release is verified.
|
|
62
|
+
See [development](https://github.com/openifsoul/core/blob/main/docs/development.md),
|
|
63
|
+
[architecture](https://github.com/openifsoul/core/blob/main/docs/architecture.md)
|
|
64
|
+
and [contribution](https://github.com/openifsoul/core/blob/main/CONTRIBUTING.md).
|
|
@@ -27,13 +27,62 @@ export function createSQLMemory(db, closeOwner = () => { }) {
|
|
|
27
27
|
try {
|
|
28
28
|
return action();
|
|
29
29
|
}
|
|
30
|
-
catch {
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof CommitFailure)
|
|
32
|
+
return failure(error.code, error.message);
|
|
31
33
|
return failure("storage", "Memory operation failed.");
|
|
32
34
|
}
|
|
33
35
|
};
|
|
36
|
+
const productKinds = new Set([
|
|
37
|
+
"character-instance",
|
|
38
|
+
"character-template",
|
|
39
|
+
"environment-profile",
|
|
40
|
+
"context-report",
|
|
41
|
+
"plan-proposal",
|
|
42
|
+
"plan-decision",
|
|
43
|
+
"task-report",
|
|
44
|
+
"plan-cancel-request",
|
|
45
|
+
"plan-cancel-result",
|
|
46
|
+
"conversation-request",
|
|
47
|
+
"conversation-response",
|
|
48
|
+
"conversation-delivery",
|
|
49
|
+
"memory-event",
|
|
50
|
+
"working-context",
|
|
51
|
+
"memory-episode",
|
|
52
|
+
"memory-fact",
|
|
53
|
+
"memory-relationship",
|
|
54
|
+
"intent-checkpoint",
|
|
55
|
+
"archive-manifest",
|
|
56
|
+
"provider-capabilities",
|
|
57
|
+
"model-request",
|
|
58
|
+
"model-response",
|
|
59
|
+
"model-error",
|
|
60
|
+
]);
|
|
61
|
+
const stored = (text, kind) => {
|
|
62
|
+
const value = JSON.parse(text);
|
|
63
|
+
if (kind && !validateDocument(value, kind))
|
|
64
|
+
throw new CommitFailure("unsupported", "Stored document format is unsupported; no migration or reset was performed.");
|
|
65
|
+
// Journals may nest protocol/provider envelopes. They are not silently adapted.
|
|
66
|
+
const rejectObsolete = (node) => {
|
|
67
|
+
if (!node || typeof node !== "object")
|
|
68
|
+
return;
|
|
69
|
+
const object = node;
|
|
70
|
+
if (typeof object.kind === "string" &&
|
|
71
|
+
productKinds.has(object.kind) &&
|
|
72
|
+
typeof object.schemaVersion === "string" &&
|
|
73
|
+
object.schemaVersion !== "0.4.0")
|
|
74
|
+
throw new CommitFailure("unsupported", "Stored document format is unsupported; no migration or reset was performed.");
|
|
75
|
+
for (const child of Object.values(object))
|
|
76
|
+
rejectObsolete(child);
|
|
77
|
+
};
|
|
78
|
+
rejectObsolete(value);
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
34
81
|
const read = (table, id) => {
|
|
35
82
|
const row = db.prepare(`SELECT document FROM ${table} WHERE id=?`).get(id);
|
|
36
|
-
return row
|
|
83
|
+
return row
|
|
84
|
+
? stored(row.document, table === "characters" ? "character-instance" : undefined)
|
|
85
|
+
: undefined;
|
|
37
86
|
};
|
|
38
87
|
let pruning;
|
|
39
88
|
const port = {
|
|
@@ -55,7 +104,7 @@ export function createSQLMemory(db, closeOwner = () => { }) {
|
|
|
55
104
|
return success(db
|
|
56
105
|
.prepare("SELECT document FROM characters ORDER BY id LIMIT ?")
|
|
57
106
|
.all(limit)
|
|
58
|
-
.map((row) =>
|
|
107
|
+
.map((row) => stored(row.document, "character-instance")));
|
|
59
108
|
}),
|
|
60
109
|
getCharacter: (id) => guarded(() => success(read("characters", id))),
|
|
61
110
|
getExchange: (id) => guarded(() => success(read("exchanges", id))),
|
|
@@ -120,7 +169,7 @@ export function createSQLMemory(db, closeOwner = () => { }) {
|
|
|
120
169
|
.prepare("SELECT document FROM events WHERE id=?")
|
|
121
170
|
.get(id);
|
|
122
171
|
const old = row &&
|
|
123
|
-
|
|
172
|
+
stored(String(row.document), "memory-event");
|
|
124
173
|
if (!old ||
|
|
125
174
|
old.characterId !== retention.characterId ||
|
|
126
175
|
old.environmentId !== retention.environmentId ||
|
|
@@ -215,7 +264,7 @@ export function createSQLMemory(db, closeOwner = () => { }) {
|
|
|
215
264
|
if (size + bytes > query.maxBytes)
|
|
216
265
|
continue;
|
|
217
266
|
size += bytes;
|
|
218
|
-
selected.push(
|
|
267
|
+
selected.push(stored(row.document, "memory-event"));
|
|
219
268
|
}
|
|
220
269
|
return success(selected.reverse());
|
|
221
270
|
}),
|