@ifsoul/core 0.4.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 +4 -1
- package/dist/packages/protocol/src/index.d.ts +1 -1
- package/dist/packages/protocol/src/index.js +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 +3 -0
- 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 +1 -1
- package/release.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ compose these public artifacts. See [repository ownership](https://github.com/op
|
|
|
15
15
|
Use Node.js 22.18–24 and an ESM project:
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
npm install @ifsoul/core@0.
|
|
18
|
+
npm install @ifsoul/core@0.5.0
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
The package includes compiled JavaScript and TypeScript declarations. Import the
|
|
@@ -62,3 +62,6 @@ pnpm build
|
|
|
62
62
|
See [development](https://github.com/openifsoul/core/blob/main/docs/development.md),
|
|
63
63
|
[architecture](https://github.com/openifsoul/core/blob/main/docs/architecture.md)
|
|
64
64
|
and [contribution](https://github.com/openifsoul/core/blob/main/CONTRIBUTING.md).
|
|
65
|
+
|
|
66
|
+
See [behavior configuration and dynamic parameters](docs/behavior.md) for shared goals,
|
|
67
|
+
reaction policy and evidence-linked state.
|
|
@@ -6,6 +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.
|
|
9
|
+
export declare const IFSOUL_VERSION: "0.5.0";
|
|
10
10
|
/** Structural current ModelProvider spec validation; not a provider wire transport. */
|
|
11
11
|
export declare function validateModelProviderDocument(value: unknown): boolean;
|
|
@@ -47,7 +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.
|
|
50
|
+
export const IFSOUL_VERSION = "0.5.0";
|
|
51
51
|
/** Structural current ModelProvider spec validation; not a provider wire transport. */
|
|
52
52
|
export function validateModelProviderDocument(value) {
|
|
53
53
|
return validators.current_provider(value) === true;
|
|
@@ -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
|
+
};
|