@ifsoul/core 0.4.0 → 0.6.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/memory/src/port.d.ts +31 -0
- package/dist/packages/memory/src/sql.d.ts +3 -1
- package/dist/packages/memory/src/sql.js +105 -1
- package/dist/packages/memory/src/sqlite-search.d.ts +3 -0
- package/dist/packages/memory/src/sqlite-search.js +44 -0
- package/dist/packages/memory/src/sqlite.js +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
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { BehaviorOperatorPolicy, BehaviorPermissions, BehaviorGoal } from "./behavior-types.js";
|
|
2
|
+
import type { AddressedEvent, ParticipantStore, SessionAccess } from "./participants.js";
|
|
3
|
+
export interface PlanningActor {
|
|
4
|
+
participantId: string;
|
|
5
|
+
roleId: string;
|
|
6
|
+
capabilities: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface PlanningIntent {
|
|
9
|
+
intentId: string;
|
|
10
|
+
roleIds: string[];
|
|
11
|
+
requiredCapabilities: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface GroupPlanningSpec {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
sessionRevision: number;
|
|
16
|
+
groupId?: string;
|
|
17
|
+
actors: PlanningActor[];
|
|
18
|
+
intents: PlanningIntent[];
|
|
19
|
+
objective: string;
|
|
20
|
+
channelId: string;
|
|
21
|
+
sharedEventIds: string[];
|
|
22
|
+
goalId?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface GroupAssignment {
|
|
25
|
+
assignmentId: string;
|
|
26
|
+
actorId: string;
|
|
27
|
+
intentId: string;
|
|
28
|
+
dependsOn: string[];
|
|
29
|
+
}
|
|
30
|
+
/** Proposal only. No speech, mechanics or successful effects may be returned here. */
|
|
31
|
+
export interface GroupPlan {
|
|
32
|
+
objective: string;
|
|
33
|
+
assignments: GroupAssignment[];
|
|
34
|
+
}
|
|
35
|
+
export interface PlanningClock {
|
|
36
|
+
wallTimeMs: number;
|
|
37
|
+
worldTicks: Record<string, number>;
|
|
38
|
+
}
|
|
39
|
+
export interface PlanSchedule {
|
|
40
|
+
scheduleId: string;
|
|
41
|
+
revision: number;
|
|
42
|
+
state: "running" | "paused" | "cancelled";
|
|
43
|
+
spec: GroupPlanningSpec;
|
|
44
|
+
clock: "wall" | "world";
|
|
45
|
+
interval: number;
|
|
46
|
+
nextDue: number;
|
|
47
|
+
maxRuns: number;
|
|
48
|
+
}
|
|
49
|
+
export type PlanningTrigger = {
|
|
50
|
+
kind: "due";
|
|
51
|
+
} | {
|
|
52
|
+
kind: "manual";
|
|
53
|
+
triggerId: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "event";
|
|
56
|
+
eventId: string;
|
|
57
|
+
};
|
|
58
|
+
export interface PlanningClaim {
|
|
59
|
+
claimId: string;
|
|
60
|
+
fence: number;
|
|
61
|
+
behaviorRevision?: number;
|
|
62
|
+
workerId: string;
|
|
63
|
+
scheduleId: string;
|
|
64
|
+
scheduleRevision: number;
|
|
65
|
+
sessionRevision: number;
|
|
66
|
+
leaseUntil: number;
|
|
67
|
+
triggerKey: string;
|
|
68
|
+
actorIds: string[];
|
|
69
|
+
groupKey: string;
|
|
70
|
+
status: "active" | "proposed" | "unknown" | "resolved" | "failed" | "superseded";
|
|
71
|
+
plan?: GroupPlan;
|
|
72
|
+
adoptedIds?: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface PlanningInput {
|
|
75
|
+
claim: PlanningClaim;
|
|
76
|
+
spec: GroupPlanningSpec;
|
|
77
|
+
sharedEvents: AddressedEvent[];
|
|
78
|
+
behavior?: {
|
|
79
|
+
configRevision: number;
|
|
80
|
+
policy: BehaviorPermissions;
|
|
81
|
+
goals: BehaviorGoal[];
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export interface PlanHostReport {
|
|
85
|
+
reportId: string;
|
|
86
|
+
claimId: string;
|
|
87
|
+
status: "adopted" | "rejected" | "completed" | "failed" | "unknown";
|
|
88
|
+
assignmentIds: string[];
|
|
89
|
+
summary: string;
|
|
90
|
+
}
|
|
91
|
+
export interface PlanningState {
|
|
92
|
+
format: "ifsoul-group-scheduler/0.4.0";
|
|
93
|
+
schedules: PlanSchedule[];
|
|
94
|
+
claims: PlanningClaim[];
|
|
95
|
+
reports: PlanHostReport[];
|
|
96
|
+
cursors: {
|
|
97
|
+
scheduleId: string;
|
|
98
|
+
lastClock?: number;
|
|
99
|
+
lastStarted?: number;
|
|
100
|
+
runs: number;
|
|
101
|
+
triggerKeys: string[];
|
|
102
|
+
}[];
|
|
103
|
+
lastWallTime: number;
|
|
104
|
+
calls: number;
|
|
105
|
+
npcCalls: Record<string, number>;
|
|
106
|
+
groupCalls: Record<string, number>;
|
|
107
|
+
}
|
|
108
|
+
export interface PlanningBudgets {
|
|
109
|
+
principalCalls: number;
|
|
110
|
+
npcCalls: number;
|
|
111
|
+
groupCalls: number;
|
|
112
|
+
concurrentPlans: number;
|
|
113
|
+
schedules: number;
|
|
114
|
+
claims: number;
|
|
115
|
+
reports: number;
|
|
116
|
+
runsPerSchedule: number;
|
|
117
|
+
actorsPerPlan: number;
|
|
118
|
+
assignmentsPerPlan: number;
|
|
119
|
+
assignmentsPerActor: number;
|
|
120
|
+
sharedEvents: number;
|
|
121
|
+
contextBytes: number;
|
|
122
|
+
}
|
|
123
|
+
export declare const DEFAULT_PLANNING_LIMITS: Readonly<PlanningBudgets>;
|
|
124
|
+
export declare function resolvePlanningLimits(requested?: Partial<PlanningBudgets>, ceilings?: Partial<PlanningBudgets>): import("../../protocol/src/resource-policy.js").BudgetReport<{
|
|
125
|
+
principalCalls: number;
|
|
126
|
+
npcCalls: number;
|
|
127
|
+
groupCalls: number;
|
|
128
|
+
concurrentPlans: number;
|
|
129
|
+
schedules: number;
|
|
130
|
+
claims: number;
|
|
131
|
+
reports: number;
|
|
132
|
+
runsPerSchedule: number;
|
|
133
|
+
actorsPerPlan: number;
|
|
134
|
+
assignmentsPerPlan: number;
|
|
135
|
+
assignmentsPerActor: number;
|
|
136
|
+
sharedEvents: number;
|
|
137
|
+
contextBytes: number;
|
|
138
|
+
}>;
|
|
139
|
+
/** Reject the whole proposal. One invalid assignment never grants another action. */
|
|
140
|
+
export declare function validGroupPlan(value: unknown, spec: GroupPlanningSpec, limits?: PlanningBudgets): value is GroupPlan;
|
|
141
|
+
export declare function createGroupSchedulerRuntime(store: ParticipantStore, requestedBudgets?: Partial<PlanningBudgets>, ceilings?: Partial<PlanningBudgets>, behaviorOperator?: BehaviorOperatorPolicy): {
|
|
142
|
+
configure(access: SessionAccess, expectedRevision: number, config: PlanSchedule): PlanSchedule;
|
|
143
|
+
control(access: SessionAccess, scheduleId: string, expectedRevision: number, action: "pause" | "resume" | "cancel"): PlanSchedule;
|
|
144
|
+
list(access: SessionAccess): PlanSchedule[];
|
|
145
|
+
claim(access: SessionAccess, scheduleId: string, trigger: PlanningTrigger, clock: PlanningClock, workerId: string, leaseMs: number, hostAvailable: boolean): PlanningInput | {
|
|
146
|
+
status: "not-due" | "paused" | "host-unavailable" | "busy" | "budget" | "replay" | "unknown" | "policy-denied";
|
|
147
|
+
};
|
|
148
|
+
complete(access: SessionAccess, ticket: PlanningClaim, output: unknown, clock: PlanningClock): PlanningClaim;
|
|
149
|
+
fail(access: SessionAccess, ticket: PlanningClaim, uncertain: boolean): PlanningClaim;
|
|
150
|
+
report(access: SessionAccess, report: PlanHostReport): PlanningClaim;
|
|
151
|
+
reconcile(access: SessionAccess, claimId: string): PlanningClaim;
|
|
152
|
+
inspect(access: SessionAccess, scheduleId: string): {
|
|
153
|
+
config: PlanSchedule;
|
|
154
|
+
cursor: {
|
|
155
|
+
scheduleId: string;
|
|
156
|
+
lastClock?: number;
|
|
157
|
+
lastStarted?: number;
|
|
158
|
+
runs: number;
|
|
159
|
+
triggerKeys: string[];
|
|
160
|
+
};
|
|
161
|
+
claims: PlanningClaim[];
|
|
162
|
+
reports: PlanHostReport[];
|
|
163
|
+
calls: number;
|
|
164
|
+
};
|
|
165
|
+
};
|