@ifsoul/core 0.3.0 → 0.5.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 +30 -33
- 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/behavior-types.d.ts +150 -0
- package/dist/packages/runtime/src/behavior-types.js +1 -0
- package/dist/packages/runtime/src/behavior.d.ts +40 -0
- package/dist/packages/runtime/src/behavior.js +621 -0
- package/dist/packages/runtime/src/group-scheduler.d.ts +165 -0
- package/dist/packages/runtime/src/group-scheduler.js +647 -0
- package/dist/packages/runtime/src/index.d.ts +4 -0
- package/dist/packages/runtime/src/index.js +4 -1
- package/dist/packages/runtime/src/participants.d.ts +107 -0
- package/dist/packages/runtime/src/participants.js +309 -0
- package/dist/packages/runtime/src/types.d.ts +1 -0
- 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
|
@@ -6,11 +6,6 @@ export declare function canonical(value: unknown): string;
|
|
|
6
6
|
export { resolveResourceLimits, BUFFERED_JSON_MAX_BYTES, MAX_TIMER_MS, } from "./resource-policy.js";
|
|
7
7
|
export type { BudgetReport } from "./resource-policy.js";
|
|
8
8
|
/** Current train identifier; wire families require exact kind/version validation. */
|
|
9
|
-
export declare const IFSOUL_VERSION: "0.
|
|
10
|
-
/** Reviewed shape-preserving v0.2 to current adapter. Never mutates stored evidence.
|
|
11
|
-
* v0.1 has no generic semantic adapter. */
|
|
12
|
-
export declare function upgradeDocument<T extends import("./types.js").Envelope>(value: T): Omit<T, "schemaVersion"> & {
|
|
13
|
-
schemaVersion: typeof IFSOUL_VERSION;
|
|
14
|
-
};
|
|
9
|
+
export declare const IFSOUL_VERSION: "0.5.0";
|
|
15
10
|
/** Structural current ModelProvider spec validation; not a provider wire transport. */
|
|
16
11
|
export declare function validateModelProviderDocument(value: unknown): boolean;
|
|
@@ -30,9 +30,9 @@ export function validateDocument(value, expectedKind) {
|
|
|
30
30
|
!Object.hasOwn(kinds, kind))
|
|
31
31
|
return false;
|
|
32
32
|
const version = value.schemaVersion;
|
|
33
|
-
if (version !== "
|
|
33
|
+
if (version !== "0.4.0")
|
|
34
34
|
return false;
|
|
35
|
-
return
|
|
35
|
+
return validators["current_" + kinds[kind]](value) === true;
|
|
36
36
|
}
|
|
37
37
|
/** Canonical local equality for JSON documents; not a signature or authentication proof. */
|
|
38
38
|
export function canonical(value) {
|
|
@@ -47,20 +47,7 @@ export function canonical(value) {
|
|
|
47
47
|
}
|
|
48
48
|
export { resolveResourceLimits, BUFFERED_JSON_MAX_BYTES, MAX_TIMER_MS, } from "./resource-policy.js";
|
|
49
49
|
/** Current train identifier; wire families require exact kind/version validation. */
|
|
50
|
-
export const IFSOUL_VERSION = "0.
|
|
51
|
-
/** Reviewed shape-preserving v0.2 to current adapter. Never mutates stored evidence.
|
|
52
|
-
* v0.1 has no generic semantic adapter. */
|
|
53
|
-
export function upgradeDocument(value) {
|
|
54
|
-
if (!validateDocument(value))
|
|
55
|
-
throw new Error("Unsupported or invalid protocol document");
|
|
56
|
-
const copy = structuredClone(value);
|
|
57
|
-
copy.schemaVersion = IFSOUL_VERSION;
|
|
58
|
-
if (copy.kind === "archive-manifest")
|
|
59
|
-
throw new Error("Archive files require an explicit manifest rebuild; generic adaptation is unsupported");
|
|
60
|
-
if (!validateDocument(copy))
|
|
61
|
-
throw new Error("Unsupported protocol adaptation");
|
|
62
|
-
return copy;
|
|
63
|
-
}
|
|
50
|
+
export const IFSOUL_VERSION = "0.5.0";
|
|
64
51
|
/** Structural current ModelProvider spec validation; not a provider wire transport. */
|
|
65
52
|
export function validateModelProviderDocument(value) {
|
|
66
53
|
return validators.current_provider(value) === true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Convenience views for the implemented slice. JSON Schemas remain normative. */
|
|
2
2
|
export interface Envelope {
|
|
3
|
-
schemaVersion: "0.
|
|
3
|
+
schemaVersion: "0.4.0";
|
|
4
4
|
kind: string;
|
|
5
5
|
extensions?: Record<string, unknown>;
|
|
6
6
|
requiredExtensions?: string[];
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export type BehaviorPermission = "observe" | "remember" | "updateRelationship" | "speak" | "requestAction";
|
|
2
|
+
export type BehaviorPermissions = Record<BehaviorPermission, boolean>;
|
|
3
|
+
export type BehaviorEventKind = "provocation" | "helpful" | "observation";
|
|
4
|
+
export interface BehaviorPolicy {
|
|
5
|
+
general: BehaviorPermissions;
|
|
6
|
+
provocation: BehaviorPermissions;
|
|
7
|
+
}
|
|
8
|
+
export interface BehaviorGoal {
|
|
9
|
+
goalId: string;
|
|
10
|
+
objective: string;
|
|
11
|
+
priority: number;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ParameterDefinition {
|
|
15
|
+
parameterId: string;
|
|
16
|
+
label: string;
|
|
17
|
+
kind: "trait" | "state" | "relationship";
|
|
18
|
+
scope: "portable" | "world";
|
|
19
|
+
initial: number;
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
maxDelta: number;
|
|
23
|
+
decay?: {
|
|
24
|
+
perHour: number;
|
|
25
|
+
toward: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface BehaviorSettings {
|
|
29
|
+
policy: BehaviorPolicy;
|
|
30
|
+
goals: BehaviorGoal[];
|
|
31
|
+
}
|
|
32
|
+
export interface BehaviorOverride {
|
|
33
|
+
scope: {
|
|
34
|
+
kind: "npc" | "group" | "world";
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
policy?: {
|
|
38
|
+
general?: Partial<BehaviorPermissions>;
|
|
39
|
+
provocation?: Partial<BehaviorPermissions>;
|
|
40
|
+
};
|
|
41
|
+
goals?: BehaviorGoal[];
|
|
42
|
+
initialValues?: Record<string, number>;
|
|
43
|
+
}
|
|
44
|
+
export interface BehaviorConfiguration {
|
|
45
|
+
version: "ifsoul-behavior/0.4.0";
|
|
46
|
+
revision: number;
|
|
47
|
+
parameters: ParameterDefinition[];
|
|
48
|
+
defaults: BehaviorSettings;
|
|
49
|
+
overrides: BehaviorOverride[];
|
|
50
|
+
}
|
|
51
|
+
/** Injected by trusted server composition; never accepted in configuration bodies. */
|
|
52
|
+
export interface BehaviorOperatorPolicy {
|
|
53
|
+
canEditConfig: boolean;
|
|
54
|
+
lockedParameterIds: string[];
|
|
55
|
+
deniedPermissions: BehaviorPermission[];
|
|
56
|
+
lockedPolicy: boolean;
|
|
57
|
+
lockedGoals: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface BehaviorParameterValue {
|
|
60
|
+
npcId: string;
|
|
61
|
+
parameterId: string;
|
|
62
|
+
targetParticipantId?: string;
|
|
63
|
+
worldId?: string;
|
|
64
|
+
value: number;
|
|
65
|
+
confidence: number;
|
|
66
|
+
revision: number;
|
|
67
|
+
updatedAt: number;
|
|
68
|
+
}
|
|
69
|
+
export interface BehaviorChange {
|
|
70
|
+
changeId: string;
|
|
71
|
+
npcId: string;
|
|
72
|
+
parameterId: string;
|
|
73
|
+
targetParticipantId?: string;
|
|
74
|
+
worldId?: string;
|
|
75
|
+
before: number;
|
|
76
|
+
after: number;
|
|
77
|
+
confidence: number;
|
|
78
|
+
revision: number;
|
|
79
|
+
configRevision: number;
|
|
80
|
+
evidenceEventIds: string[];
|
|
81
|
+
reason: string;
|
|
82
|
+
kind: "evidence" | "decay";
|
|
83
|
+
recordedAt: number;
|
|
84
|
+
}
|
|
85
|
+
export interface BehaviorProposal {
|
|
86
|
+
proposalId: string;
|
|
87
|
+
npcId: string;
|
|
88
|
+
sessionId: string;
|
|
89
|
+
configRevision: number;
|
|
90
|
+
expectedStateRevision: number;
|
|
91
|
+
changes: {
|
|
92
|
+
parameterId: string;
|
|
93
|
+
targetParticipantId?: string;
|
|
94
|
+
delta: number;
|
|
95
|
+
confidence: number;
|
|
96
|
+
evidenceEventIds: string[];
|
|
97
|
+
reason: string;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
export interface BehaviorObservation {
|
|
101
|
+
eventId: string;
|
|
102
|
+
npcId: string;
|
|
103
|
+
kind: BehaviorEventKind;
|
|
104
|
+
configRevision: number;
|
|
105
|
+
permissions: BehaviorPermissions;
|
|
106
|
+
}
|
|
107
|
+
export interface BehaviorState {
|
|
108
|
+
format: "ifsoul-behavior/0.4.0";
|
|
109
|
+
config: BehaviorConfiguration;
|
|
110
|
+
observations: BehaviorObservation[];
|
|
111
|
+
values: BehaviorParameterValue[];
|
|
112
|
+
history: BehaviorChange[];
|
|
113
|
+
proposals: {
|
|
114
|
+
proposal: BehaviorProposal;
|
|
115
|
+
revision: number;
|
|
116
|
+
}[];
|
|
117
|
+
stateRevisions: Record<string, number>;
|
|
118
|
+
}
|
|
119
|
+
export interface BehaviorInspection {
|
|
120
|
+
npcId: string;
|
|
121
|
+
sessionId: string;
|
|
122
|
+
configRevision: number;
|
|
123
|
+
stateRevision: number;
|
|
124
|
+
effective: BehaviorSettings & {
|
|
125
|
+
initialValues: Record<string, number>;
|
|
126
|
+
};
|
|
127
|
+
parameters: ParameterDefinition[];
|
|
128
|
+
values: BehaviorParameterValue[];
|
|
129
|
+
history: BehaviorChange[];
|
|
130
|
+
}
|
|
131
|
+
export interface BehaviorEditorSnapshot {
|
|
132
|
+
config: BehaviorConfiguration;
|
|
133
|
+
operator: BehaviorOperatorPolicy;
|
|
134
|
+
catalog: {
|
|
135
|
+
npcs: {
|
|
136
|
+
npcId: string;
|
|
137
|
+
label: string;
|
|
138
|
+
}[];
|
|
139
|
+
sessions: {
|
|
140
|
+
sessionId: string;
|
|
141
|
+
worldId: string;
|
|
142
|
+
npcIds: string[];
|
|
143
|
+
}[];
|
|
144
|
+
groups: {
|
|
145
|
+
groupId: string;
|
|
146
|
+
npcIds: string[];
|
|
147
|
+
}[];
|
|
148
|
+
worlds: string[];
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ParticipantState, ParticipantStore, SessionAccess } from "./participants.js";
|
|
2
|
+
import type { BehaviorConfiguration, BehaviorOperatorPolicy, BehaviorPermissions, BehaviorSettings, BehaviorInspection, BehaviorProposal, BehaviorEventKind, BehaviorEditorSnapshot } from "./behavior-types.js";
|
|
3
|
+
export type * from "./behavior-types.js";
|
|
4
|
+
export declare const DEFAULT_BEHAVIOR_OPERATOR: Readonly<BehaviorOperatorPolicy>;
|
|
5
|
+
export interface BehaviorLimits {
|
|
6
|
+
parameters: number;
|
|
7
|
+
overrides: number;
|
|
8
|
+
values: number;
|
|
9
|
+
history: number;
|
|
10
|
+
observations: number;
|
|
11
|
+
proposals: number;
|
|
12
|
+
changesPerProposal: number;
|
|
13
|
+
evidencePerChange: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_BEHAVIOR_LIMITS: Readonly<BehaviorLimits>;
|
|
16
|
+
export declare function defaultBehaviorConfiguration(): BehaviorConfiguration;
|
|
17
|
+
/** World -> matching groups in lexicographic ID order -> NPC -> immutable operator denies. */
|
|
18
|
+
export declare function effectiveBehavior(s: ParticipantState, access: SessionAccess, npcId: string, sessionId: string, operator?: BehaviorOperatorPolicy): BehaviorSettings & {
|
|
19
|
+
initialValues: Record<string, number>;
|
|
20
|
+
};
|
|
21
|
+
export declare function behaviorPermissions(s: ParticipantState, access: SessionAccess, npcId: string, sessionId: string, eventId?: string, operator?: BehaviorOperatorPolicy): BehaviorPermissions;
|
|
22
|
+
export declare const behaviorRevision: (s: ParticipantState) => number;
|
|
23
|
+
/** Previously unobserved/unremembered evidence never becomes implicit model context. */
|
|
24
|
+
export declare function behaviorEvidenceVisible(s: ParticipantState, access: SessionAccess, npcId: string, sessionId: string, eventId: string, operator?: BehaviorOperatorPolicy): boolean;
|
|
25
|
+
export declare function createBehaviorRuntime(store: ParticipantStore, options?: {
|
|
26
|
+
operator?: BehaviorOperatorPolicy;
|
|
27
|
+
limits?: Partial<BehaviorLimits>;
|
|
28
|
+
ceilings?: Partial<BehaviorLimits>;
|
|
29
|
+
}): {
|
|
30
|
+
read(a: SessionAccess): BehaviorEditorSnapshot;
|
|
31
|
+
update(a: SessionAccess, expectedRevision: number, config: BehaviorConfiguration): BehaviorConfiguration;
|
|
32
|
+
adminInspect(a: SessionAccess, sessionId: string, npcId: string): BehaviorInspection;
|
|
33
|
+
inspect(a: SessionAccess, sessionId: string, npcId: string): BehaviorInspection;
|
|
34
|
+
observe(a: SessionAccess, sessionId: string, npcId: string, eventId: string, kind: BehaviorEventKind): {
|
|
35
|
+
observation: import("./behavior-types.js").BehaviorObservation;
|
|
36
|
+
fresh: boolean;
|
|
37
|
+
};
|
|
38
|
+
apply(a: SessionAccess, proposal: BehaviorProposal, nowMs: number): BehaviorInspection;
|
|
39
|
+
decay(a: SessionAccess, sessionId: string, npcId: string, nowMs: number): BehaviorInspection;
|
|
40
|
+
};
|