@plasius/ai-game 0.6.2 → 0.6.4
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/CHANGELOG.md +34 -0
- package/README.md +45 -0
- package/dist/index.cjs +617 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +278 -1
- package/dist/index.d.ts +278 -1
- package/dist/index.js +585 -5
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0018-apprenticeship-handoff-contract-boundary.md +58 -0
- package/docs/adrs/adr-0019-guild-quest-synchronization-and-authority-boundary.md +49 -0
- package/docs/adrs/index.md +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2070,6 +2070,554 @@ function createAiGameTutorialTrack(input) {
|
|
|
2070
2070
|
});
|
|
2071
2071
|
}
|
|
2072
2072
|
|
|
2073
|
+
// src/apprenticeship-handoffs.ts
|
|
2074
|
+
var AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID = "isekai.training.apprenticeship.enabled";
|
|
2075
|
+
var AI_GAME_APPRENTICESHIP_CONTRACT_VERSION = "1.0";
|
|
2076
|
+
var AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES = [
|
|
2077
|
+
"proposed",
|
|
2078
|
+
"active",
|
|
2079
|
+
"suspended",
|
|
2080
|
+
"completed",
|
|
2081
|
+
"revoked"
|
|
2082
|
+
];
|
|
2083
|
+
var AI_GAME_APPRENTICESHIP_SUPERVISION_MODES = [
|
|
2084
|
+
"direct",
|
|
2085
|
+
"delegated",
|
|
2086
|
+
"milestone"
|
|
2087
|
+
];
|
|
2088
|
+
var AI_GAME_APPRENTICESHIP_READINESS_STATES = [
|
|
2089
|
+
"ready",
|
|
2090
|
+
"needs-prerequisites",
|
|
2091
|
+
"institution-gated",
|
|
2092
|
+
"supervision-required",
|
|
2093
|
+
"blocked"
|
|
2094
|
+
];
|
|
2095
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS = [
|
|
2096
|
+
"spellcraft-system",
|
|
2097
|
+
"item-crafting-system",
|
|
2098
|
+
"dungeon-crafting-system"
|
|
2099
|
+
];
|
|
2100
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_KINDS = [
|
|
2101
|
+
"spellcraft",
|
|
2102
|
+
"item-crafting",
|
|
2103
|
+
"dungeon-crafting"
|
|
2104
|
+
];
|
|
2105
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS = [
|
|
2106
|
+
"learn",
|
|
2107
|
+
"practice",
|
|
2108
|
+
"refine",
|
|
2109
|
+
"commission"
|
|
2110
|
+
];
|
|
2111
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT = "request-only";
|
|
2112
|
+
var AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER = "player-system";
|
|
2113
|
+
function freezeReadonlyArray8(items) {
|
|
2114
|
+
return Object.freeze([...items]);
|
|
2115
|
+
}
|
|
2116
|
+
function assertNonEmptyString8(value, label) {
|
|
2117
|
+
if (value.trim().length === 0) {
|
|
2118
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
function assertIsoTimestamp4(value, label) {
|
|
2122
|
+
assertNonEmptyString8(value, label);
|
|
2123
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
2124
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
function assertIsoTimestampOrNull2(value, label) {
|
|
2128
|
+
if (value !== null) {
|
|
2129
|
+
assertIsoTimestamp4(value, label);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
function assertContractVersion7(value) {
|
|
2133
|
+
if (value !== AI_GAME_APPRENTICESHIP_CONTRACT_VERSION) {
|
|
2134
|
+
throw new Error(
|
|
2135
|
+
`contractVersion must be ${AI_GAME_APPRENTICESHIP_CONTRACT_VERSION}`
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function assertMember(value, values, label) {
|
|
2140
|
+
if (!values.includes(value)) {
|
|
2141
|
+
throw new Error(`${label} must be a supported apprenticeship value`);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
function createStringArray5(values, label) {
|
|
2145
|
+
values.forEach((value) => assertNonEmptyString8(value, `${label} entry`));
|
|
2146
|
+
return freezeReadonlyArray8(values);
|
|
2147
|
+
}
|
|
2148
|
+
function assertHandoffBase(input) {
|
|
2149
|
+
assertNonEmptyString8(input.handoffId, "handoffId");
|
|
2150
|
+
assertNonEmptyString8(input.requestId, "requestId");
|
|
2151
|
+
assertNonEmptyString8(input.apprenticeshipId, "apprenticeshipId");
|
|
2152
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2153
|
+
assertNonEmptyString8(input.supervisionId, "supervisionId");
|
|
2154
|
+
assertNonEmptyString8(input.readinessId, "readinessId");
|
|
2155
|
+
if (input.readinessState !== "ready") {
|
|
2156
|
+
throw new Error("readinessState must be ready for an apprenticeship handoff");
|
|
2157
|
+
}
|
|
2158
|
+
assertNonEmptyString8(input.apprenticeSubjectId, "apprenticeSubjectId");
|
|
2159
|
+
assertNonEmptyString8(input.disciplineCode, "disciplineCode");
|
|
2160
|
+
assertMember(
|
|
2161
|
+
input.intent,
|
|
2162
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
|
|
2163
|
+
"intent"
|
|
2164
|
+
);
|
|
2165
|
+
assertIsoTimestamp4(input.requestedAtIso, "requestedAtIso");
|
|
2166
|
+
}
|
|
2167
|
+
function isAiGameApprenticeshipReadinessState(value) {
|
|
2168
|
+
return AI_GAME_APPRENTICESHIP_READINESS_STATES.includes(value);
|
|
2169
|
+
}
|
|
2170
|
+
function createAiGameApprenticeshipSponsorship(input) {
|
|
2171
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2172
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2173
|
+
assertNonEmptyString8(input.apprenticeSubjectId, "apprenticeSubjectId");
|
|
2174
|
+
assertNonEmptyString8(input.sponsorSubjectId, "sponsorSubjectId");
|
|
2175
|
+
assertNonEmptyString8(input.institutionId, "institutionId");
|
|
2176
|
+
assertNonEmptyString8(input.disciplineCode, "disciplineCode");
|
|
2177
|
+
assertMember(
|
|
2178
|
+
input.status,
|
|
2179
|
+
AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
|
|
2180
|
+
"status"
|
|
2181
|
+
);
|
|
2182
|
+
assertIsoTimestamp4(input.issuedAtIso, "issuedAtIso");
|
|
2183
|
+
assertIsoTimestampOrNull2(input.expiresAtIso, "expiresAtIso");
|
|
2184
|
+
return Object.freeze({
|
|
2185
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2186
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2187
|
+
sponsorshipId: input.sponsorshipId,
|
|
2188
|
+
apprenticeSubjectId: input.apprenticeSubjectId,
|
|
2189
|
+
sponsorSubjectId: input.sponsorSubjectId,
|
|
2190
|
+
institutionId: input.institutionId,
|
|
2191
|
+
disciplineCode: input.disciplineCode,
|
|
2192
|
+
status: input.status,
|
|
2193
|
+
issuedAtIso: input.issuedAtIso,
|
|
2194
|
+
expiresAtIso: input.expiresAtIso,
|
|
2195
|
+
scopeCodes: createStringArray5(input.scopeCodes, "scopeCodes"),
|
|
2196
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
function createAiGameApprenticeshipSupervision(input) {
|
|
2200
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2201
|
+
assertNonEmptyString8(input.supervisionId, "supervisionId");
|
|
2202
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2203
|
+
assertNonEmptyString8(input.supervisorSubjectId, "supervisorSubjectId");
|
|
2204
|
+
assertMember(input.mode, AI_GAME_APPRENTICESHIP_SUPERVISION_MODES, "mode");
|
|
2205
|
+
assertIsoTimestamp4(input.startedAtIso, "startedAtIso");
|
|
2206
|
+
assertIsoTimestampOrNull2(input.endsAtIso, "endsAtIso");
|
|
2207
|
+
return Object.freeze({
|
|
2208
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2209
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2210
|
+
supervisionId: input.supervisionId,
|
|
2211
|
+
sponsorshipId: input.sponsorshipId,
|
|
2212
|
+
supervisorSubjectId: input.supervisorSubjectId,
|
|
2213
|
+
mode: input.mode,
|
|
2214
|
+
checkpointCodes: createStringArray5(input.checkpointCodes, "checkpointCodes"),
|
|
2215
|
+
startedAtIso: input.startedAtIso,
|
|
2216
|
+
endsAtIso: input.endsAtIso,
|
|
2217
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
function createAiGameApprenticeshipReadiness(input) {
|
|
2221
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2222
|
+
assertNonEmptyString8(input.readinessId, "readinessId");
|
|
2223
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2224
|
+
assertNonEmptyString8(input.disciplineCode, "disciplineCode");
|
|
2225
|
+
assertMember(input.state, AI_GAME_APPRENTICESHIP_READINESS_STATES, "state");
|
|
2226
|
+
if (!isTrainingTrustLevel(input.requiredTrustLevel)) {
|
|
2227
|
+
throw new Error("requiredTrustLevel must be a supported training trust level");
|
|
2228
|
+
}
|
|
2229
|
+
if (!isMccExpressionTrack(input.requiredTrack)) {
|
|
2230
|
+
throw new Error("requiredTrack must be a supported MCC expression track");
|
|
2231
|
+
}
|
|
2232
|
+
assertIsoTimestamp4(input.evaluatedAtIso, "evaluatedAtIso");
|
|
2233
|
+
if (input.state === "ready" && input.unmetPrerequisiteCodes.length > 0) {
|
|
2234
|
+
throw new Error("ready apprenticeship state cannot have unmet prerequisites");
|
|
2235
|
+
}
|
|
2236
|
+
return Object.freeze({
|
|
2237
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2238
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2239
|
+
readinessId: input.readinessId,
|
|
2240
|
+
sponsorshipId: input.sponsorshipId,
|
|
2241
|
+
disciplineCode: input.disciplineCode,
|
|
2242
|
+
state: input.state,
|
|
2243
|
+
requiredTrustLevel: input.requiredTrustLevel,
|
|
2244
|
+
requiredTrack: input.requiredTrack,
|
|
2245
|
+
supervisionRequired: input.supervisionRequired,
|
|
2246
|
+
unmetPrerequisiteCodes: createStringArray5(
|
|
2247
|
+
input.unmetPrerequisiteCodes,
|
|
2248
|
+
"unmetPrerequisiteCodes"
|
|
2249
|
+
),
|
|
2250
|
+
evaluatedAtIso: input.evaluatedAtIso,
|
|
2251
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
function createAiGameApprenticeshipHandoff(input) {
|
|
2255
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2256
|
+
assertHandoffBase(input);
|
|
2257
|
+
assertMember(input.kind, AI_GAME_APPRENTICESHIP_HANDOFF_KINDS, "kind");
|
|
2258
|
+
if (input.kind === "spellcraft") {
|
|
2259
|
+
if (!isMccExpressionTrack(input.requestedTrack)) {
|
|
2260
|
+
throw new Error("requestedTrack must be a supported MCC expression track");
|
|
2261
|
+
}
|
|
2262
|
+
if (input.recommendationId !== null && input.recommendationId !== void 0) {
|
|
2263
|
+
assertNonEmptyString8(input.recommendationId, "recommendationId");
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
if (input.kind === "item-crafting" && input.recipeFamilyCode !== null && input.recipeFamilyCode !== void 0) {
|
|
2267
|
+
assertNonEmptyString8(input.recipeFamilyCode, "recipeFamilyCode");
|
|
2268
|
+
}
|
|
2269
|
+
if (input.kind === "dungeon-crafting") {
|
|
2270
|
+
if (input.blueprintFamilyCode !== null && input.blueprintFamilyCode !== void 0) {
|
|
2271
|
+
assertNonEmptyString8(input.blueprintFamilyCode, "blueprintFamilyCode");
|
|
2272
|
+
}
|
|
2273
|
+
if (input.sealingObjectiveCode !== null && input.sealingObjectiveCode !== void 0) {
|
|
2274
|
+
assertNonEmptyString8(input.sealingObjectiveCode, "sealingObjectiveCode");
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
const base = {
|
|
2278
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2279
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2280
|
+
handoffId: input.handoffId,
|
|
2281
|
+
requestId: input.requestId,
|
|
2282
|
+
apprenticeshipId: input.apprenticeshipId,
|
|
2283
|
+
sponsorshipId: input.sponsorshipId,
|
|
2284
|
+
supervisionId: input.supervisionId,
|
|
2285
|
+
readinessId: input.readinessId,
|
|
2286
|
+
readinessState: input.readinessState,
|
|
2287
|
+
apprenticeSubjectId: input.apprenticeSubjectId,
|
|
2288
|
+
disciplineCode: input.disciplineCode,
|
|
2289
|
+
intent: input.intent,
|
|
2290
|
+
requestedAtIso: input.requestedAtIso,
|
|
2291
|
+
commitment: AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
|
|
2292
|
+
guidanceOwner: AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
|
|
2293
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2294
|
+
};
|
|
2295
|
+
if (input.kind === "spellcraft") {
|
|
2296
|
+
return Object.freeze({
|
|
2297
|
+
...base,
|
|
2298
|
+
kind: input.kind,
|
|
2299
|
+
targetSystem: "spellcraft-system",
|
|
2300
|
+
recommendationId: input.recommendationId ?? null,
|
|
2301
|
+
requestedTrack: input.requestedTrack
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
if (input.kind === "item-crafting") {
|
|
2305
|
+
return Object.freeze({
|
|
2306
|
+
...base,
|
|
2307
|
+
kind: input.kind,
|
|
2308
|
+
targetSystem: "item-crafting-system",
|
|
2309
|
+
recipeFamilyCode: input.recipeFamilyCode ?? null
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
return Object.freeze({
|
|
2313
|
+
...base,
|
|
2314
|
+
kind: input.kind,
|
|
2315
|
+
targetSystem: "dungeon-crafting-system",
|
|
2316
|
+
blueprintFamilyCode: input.blueprintFamilyCode ?? null,
|
|
2317
|
+
sealingObjectiveCode: input.sealingObjectiveCode ?? null
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
// src/guild-quests.ts
|
|
2322
|
+
var AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID = "isekai.player-system.guild-quests.enabled";
|
|
2323
|
+
var AI_GAME_GUILD_QUESTS_CONTRACT_VERSION = "1.0";
|
|
2324
|
+
var AI_GAME_GUILD_QUEST_STATUSES = [
|
|
2325
|
+
"offered",
|
|
2326
|
+
"accepted",
|
|
2327
|
+
"active",
|
|
2328
|
+
"completed",
|
|
2329
|
+
"failed",
|
|
2330
|
+
"abandoned",
|
|
2331
|
+
"expired"
|
|
2332
|
+
];
|
|
2333
|
+
var AI_GAME_GUILD_QUEST_OBJECTIVE_STATUSES = [
|
|
2334
|
+
"pending",
|
|
2335
|
+
"active",
|
|
2336
|
+
"completed",
|
|
2337
|
+
"failed"
|
|
2338
|
+
];
|
|
2339
|
+
var AI_GAME_GUILD_QUEST_REWARD_KINDS = [
|
|
2340
|
+
"currency",
|
|
2341
|
+
"item",
|
|
2342
|
+
"recipe",
|
|
2343
|
+
"reputation",
|
|
2344
|
+
"access"
|
|
2345
|
+
];
|
|
2346
|
+
var AI_GAME_GUILD_QUEST_SYSTEM_RECOMMENDATIONS = [
|
|
2347
|
+
"recommended",
|
|
2348
|
+
"optional",
|
|
2349
|
+
"not-recommended",
|
|
2350
|
+
"blocked"
|
|
2351
|
+
];
|
|
2352
|
+
function freezeReadonlyArray9(items) {
|
|
2353
|
+
return Object.freeze([...items]);
|
|
2354
|
+
}
|
|
2355
|
+
function isMember7(value, members) {
|
|
2356
|
+
return members.includes(value);
|
|
2357
|
+
}
|
|
2358
|
+
function assertNonEmptyString9(value, label) {
|
|
2359
|
+
if (value.trim().length === 0) {
|
|
2360
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
function assertIsoTimestamp5(value, label) {
|
|
2364
|
+
assertNonEmptyString9(value, label);
|
|
2365
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
2366
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
function assertPositiveInteger3(value, label) {
|
|
2370
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
2371
|
+
throw new Error(`${label} must be a positive integer`);
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
function assertNonNegativeInteger4(value, label) {
|
|
2375
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
2376
|
+
throw new Error(`${label} must be a non-negative integer`);
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
function assertContractVersion8(value) {
|
|
2380
|
+
if (value !== AI_GAME_GUILD_QUESTS_CONTRACT_VERSION) {
|
|
2381
|
+
throw new Error(
|
|
2382
|
+
`contractVersion must be ${AI_GAME_GUILD_QUESTS_CONTRACT_VERSION}`
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
function createStringArray6(values, label, requireAtLeastOne = false) {
|
|
2387
|
+
const result = freezeReadonlyArray9(values ?? []);
|
|
2388
|
+
result.forEach((value) => assertNonEmptyString9(value, `${label} entry`));
|
|
2389
|
+
if (requireAtLeastOne && result.length === 0) {
|
|
2390
|
+
throw new Error(`${label} must contain at least one value`);
|
|
2391
|
+
}
|
|
2392
|
+
return result;
|
|
2393
|
+
}
|
|
2394
|
+
function isAiGameGuildQuestStatus(value) {
|
|
2395
|
+
return isMember7(value, AI_GAME_GUILD_QUEST_STATUSES);
|
|
2396
|
+
}
|
|
2397
|
+
function isAiGameGuildQuestObjectiveStatus(value) {
|
|
2398
|
+
return isMember7(value, AI_GAME_GUILD_QUEST_OBJECTIVE_STATUSES);
|
|
2399
|
+
}
|
|
2400
|
+
function isAiGameGuildQuestRewardKind(value) {
|
|
2401
|
+
return isMember7(value, AI_GAME_GUILD_QUEST_REWARD_KINDS);
|
|
2402
|
+
}
|
|
2403
|
+
function isAiGameGuildQuestSystemRecommendation(value) {
|
|
2404
|
+
return isMember7(value, AI_GAME_GUILD_QUEST_SYSTEM_RECOMMENDATIONS);
|
|
2405
|
+
}
|
|
2406
|
+
function createAiGameGuildQuestObjectiveProgress(input) {
|
|
2407
|
+
assertNonEmptyString9(input.objectiveId, "objectiveId");
|
|
2408
|
+
assertNonEmptyString9(input.objectiveCode, "objectiveCode");
|
|
2409
|
+
assertNonEmptyString9(input.label, "label");
|
|
2410
|
+
assertIsoTimestamp5(input.updatedAtIso, "updatedAtIso");
|
|
2411
|
+
assertPositiveInteger3(input.targetCount, "targetCount");
|
|
2412
|
+
const currentCount = input.currentCount ?? 0;
|
|
2413
|
+
assertNonNegativeInteger4(currentCount, "currentCount");
|
|
2414
|
+
if (currentCount > input.targetCount) {
|
|
2415
|
+
throw new Error("currentCount must be less than or equal to targetCount");
|
|
2416
|
+
}
|
|
2417
|
+
if (!isAiGameGuildQuestObjectiveStatus(input.status)) {
|
|
2418
|
+
throw new Error("status must be a supported guild-quest objective status");
|
|
2419
|
+
}
|
|
2420
|
+
return Object.freeze({
|
|
2421
|
+
objectiveId: input.objectiveId,
|
|
2422
|
+
objectiveCode: input.objectiveCode,
|
|
2423
|
+
label: input.label,
|
|
2424
|
+
status: input.status,
|
|
2425
|
+
targetCount: input.targetCount,
|
|
2426
|
+
currentCount,
|
|
2427
|
+
updatedAtIso: input.updatedAtIso,
|
|
2428
|
+
reasonCodes: createStringArray6(input.reasonCodes, "reasonCodes")
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
function createAiGameGuildQuestProgress(input) {
|
|
2432
|
+
assertIsoTimestamp5(input.updatedAtIso, "updatedAtIso");
|
|
2433
|
+
if (!isAiGameGuildQuestStatus(input.status)) {
|
|
2434
|
+
throw new Error("status must be a supported guild-quest status");
|
|
2435
|
+
}
|
|
2436
|
+
if (input.objectives.length === 0) {
|
|
2437
|
+
throw new Error("objectives must contain at least one objective");
|
|
2438
|
+
}
|
|
2439
|
+
const objectives = input.objectives.map(
|
|
2440
|
+
(objective) => createAiGameGuildQuestObjectiveProgress(objective)
|
|
2441
|
+
);
|
|
2442
|
+
const objectiveIds = /* @__PURE__ */ new Set();
|
|
2443
|
+
for (const objective of objectives) {
|
|
2444
|
+
if (objectiveIds.has(objective.objectiveId)) {
|
|
2445
|
+
throw new Error("objectiveIds must be unique within a quest");
|
|
2446
|
+
}
|
|
2447
|
+
objectiveIds.add(objective.objectiveId);
|
|
2448
|
+
}
|
|
2449
|
+
return Object.freeze({
|
|
2450
|
+
status: input.status,
|
|
2451
|
+
objectives: freezeReadonlyArray9(objectives),
|
|
2452
|
+
updatedAtIso: input.updatedAtIso
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
function createAiGameGuildQuestFailure(input) {
|
|
2456
|
+
assertNonEmptyString9(input.failureId, "failureId");
|
|
2457
|
+
assertNonEmptyString9(input.code, "code");
|
|
2458
|
+
assertNonEmptyString9(input.summary, "summary");
|
|
2459
|
+
assertIsoTimestamp5(input.failedAtIso, "failedAtIso");
|
|
2460
|
+
return Object.freeze({
|
|
2461
|
+
failureId: input.failureId,
|
|
2462
|
+
code: input.code,
|
|
2463
|
+
summary: input.summary,
|
|
2464
|
+
failedAtIso: input.failedAtIso,
|
|
2465
|
+
retryable: input.retryable,
|
|
2466
|
+
consequenceReasonCodes: createStringArray6(
|
|
2467
|
+
input.consequenceReasonCodes,
|
|
2468
|
+
"consequenceReasonCodes"
|
|
2469
|
+
)
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
function createAiGameGuildQuestRewardPreview(input) {
|
|
2473
|
+
assertNonEmptyString9(input.previewId, "previewId");
|
|
2474
|
+
const entries = input.entries.map((entry) => {
|
|
2475
|
+
assertNonEmptyString9(entry.rewardId, "rewardId");
|
|
2476
|
+
assertNonEmptyString9(entry.label, "label");
|
|
2477
|
+
assertPositiveInteger3(entry.quantity, "quantity");
|
|
2478
|
+
if (!isAiGameGuildQuestRewardKind(entry.kind)) {
|
|
2479
|
+
throw new Error("kind must be a supported guild-quest reward kind");
|
|
2480
|
+
}
|
|
2481
|
+
return Object.freeze({
|
|
2482
|
+
rewardId: entry.rewardId,
|
|
2483
|
+
kind: entry.kind,
|
|
2484
|
+
label: entry.label,
|
|
2485
|
+
quantity: entry.quantity
|
|
2486
|
+
});
|
|
2487
|
+
});
|
|
2488
|
+
const rewardIds = /* @__PURE__ */ new Set();
|
|
2489
|
+
for (const entry of entries) {
|
|
2490
|
+
if (rewardIds.has(entry.rewardId)) {
|
|
2491
|
+
throw new Error("rewardIds must be unique within a reward preview");
|
|
2492
|
+
}
|
|
2493
|
+
rewardIds.add(entry.rewardId);
|
|
2494
|
+
}
|
|
2495
|
+
const expiresAtIso = input.expiresAtIso ?? null;
|
|
2496
|
+
if (expiresAtIso !== null) {
|
|
2497
|
+
assertIsoTimestamp5(expiresAtIso, "expiresAtIso");
|
|
2498
|
+
}
|
|
2499
|
+
return Object.freeze({
|
|
2500
|
+
previewId: input.previewId,
|
|
2501
|
+
authority: "guild",
|
|
2502
|
+
previewOnly: true,
|
|
2503
|
+
entries: freezeReadonlyArray9(entries),
|
|
2504
|
+
claimRequirementCodes: createStringArray6(
|
|
2505
|
+
input.claimRequirementCodes,
|
|
2506
|
+
"claimRequirementCodes",
|
|
2507
|
+
true
|
|
2508
|
+
),
|
|
2509
|
+
expiresAtIso
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
function createAiGameGuildQuest(input) {
|
|
2513
|
+
assertNonEmptyString9(input.questId, "questId");
|
|
2514
|
+
assertContractVersion8(
|
|
2515
|
+
input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION
|
|
2516
|
+
);
|
|
2517
|
+
assertNonEmptyString9(input.guildTruth.guildId, "guildId");
|
|
2518
|
+
assertNonEmptyString9(input.guildTruth.guildContractId, "guildContractId");
|
|
2519
|
+
assertNonEmptyString9(input.guildTruth.title, "title");
|
|
2520
|
+
assertNonEmptyString9(input.guildTruth.summary, "summary");
|
|
2521
|
+
assertPositiveInteger3(input.guildTruth.authorityRevision, "authorityRevision");
|
|
2522
|
+
if (!isAiGameGuildQuestStatus(input.guildTruth.status)) {
|
|
2523
|
+
throw new Error("status must be a supported guild-quest status");
|
|
2524
|
+
}
|
|
2525
|
+
const progress = createAiGameGuildQuestProgress(input.guildTruth.progress);
|
|
2526
|
+
if (progress.status !== input.guildTruth.status) {
|
|
2527
|
+
throw new Error("progress.status must match guildTruth.status");
|
|
2528
|
+
}
|
|
2529
|
+
const failure = input.guildTruth.failure ? createAiGameGuildQuestFailure(input.guildTruth.failure) : null;
|
|
2530
|
+
if (input.guildTruth.status === "failed" && failure === null) {
|
|
2531
|
+
throw new Error("failed guild quests must include failure details");
|
|
2532
|
+
}
|
|
2533
|
+
if (input.guildTruth.status !== "failed" && failure !== null) {
|
|
2534
|
+
throw new Error("failure details are only valid for failed guild quests");
|
|
2535
|
+
}
|
|
2536
|
+
const annotations = input.systemAnnotations ?? {};
|
|
2537
|
+
const recommendation = annotations.recommendation ?? "optional";
|
|
2538
|
+
if (!isAiGameGuildQuestSystemRecommendation(recommendation)) {
|
|
2539
|
+
throw new Error("recommendation must be a supported System annotation");
|
|
2540
|
+
}
|
|
2541
|
+
return Object.freeze({
|
|
2542
|
+
contractVersion: input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION,
|
|
2543
|
+
featureFlagId: AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID,
|
|
2544
|
+
questId: input.questId,
|
|
2545
|
+
guildTruth: Object.freeze({
|
|
2546
|
+
guildId: input.guildTruth.guildId,
|
|
2547
|
+
guildContractId: input.guildTruth.guildContractId,
|
|
2548
|
+
title: input.guildTruth.title,
|
|
2549
|
+
summary: input.guildTruth.summary,
|
|
2550
|
+
status: input.guildTruth.status,
|
|
2551
|
+
authorityRevision: input.guildTruth.authorityRevision,
|
|
2552
|
+
progress,
|
|
2553
|
+
failure,
|
|
2554
|
+
rewardPreview: createAiGameGuildQuestRewardPreview(
|
|
2555
|
+
input.guildTruth.rewardPreview
|
|
2556
|
+
)
|
|
2557
|
+
}),
|
|
2558
|
+
systemAnnotations: Object.freeze({
|
|
2559
|
+
recommendation,
|
|
2560
|
+
synergyCodes: createStringArray6(
|
|
2561
|
+
annotations.synergyCodes,
|
|
2562
|
+
"synergyCodes"
|
|
2563
|
+
),
|
|
2564
|
+
linkedMissionIds: createStringArray6(
|
|
2565
|
+
annotations.linkedMissionIds,
|
|
2566
|
+
"linkedMissionIds"
|
|
2567
|
+
),
|
|
2568
|
+
reasonCodes: createStringArray6(annotations.reasonCodes, "reasonCodes")
|
|
2569
|
+
})
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
function createAiGameGuildQuestSyncPayload(input) {
|
|
2573
|
+
assertNonEmptyString9(input.guildId, "guildId");
|
|
2574
|
+
assertPositiveInteger3(input.authorityRevision, "authorityRevision");
|
|
2575
|
+
assertIsoTimestamp5(input.syncedAtIso, "syncedAtIso");
|
|
2576
|
+
assertContractVersion8(
|
|
2577
|
+
input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION
|
|
2578
|
+
);
|
|
2579
|
+
const quests = (input.quests ?? []).map(
|
|
2580
|
+
(quest) => createAiGameGuildQuest(quest)
|
|
2581
|
+
);
|
|
2582
|
+
const questIds = /* @__PURE__ */ new Set();
|
|
2583
|
+
for (const quest of quests) {
|
|
2584
|
+
if (questIds.has(quest.questId)) {
|
|
2585
|
+
throw new Error("questIds must be unique within a sync payload");
|
|
2586
|
+
}
|
|
2587
|
+
if (quest.guildTruth.guildId !== input.guildId) {
|
|
2588
|
+
throw new Error("all quests in a sync payload must belong to guildId");
|
|
2589
|
+
}
|
|
2590
|
+
questIds.add(quest.questId);
|
|
2591
|
+
}
|
|
2592
|
+
const removedQuestIds = createStringArray6(
|
|
2593
|
+
input.removedQuestIds,
|
|
2594
|
+
"removedQuestIds"
|
|
2595
|
+
);
|
|
2596
|
+
if (new Set(removedQuestIds).size !== removedQuestIds.length) {
|
|
2597
|
+
throw new Error("removedQuestIds must be unique within a sync payload");
|
|
2598
|
+
}
|
|
2599
|
+
if (quests.length === 0 && removedQuestIds.length === 0) {
|
|
2600
|
+
throw new Error("sync payload must contain quests or removedQuestIds");
|
|
2601
|
+
}
|
|
2602
|
+
for (const removedQuestId of removedQuestIds) {
|
|
2603
|
+
if (questIds.has(removedQuestId)) {
|
|
2604
|
+
throw new Error("removedQuestIds cannot overlap quests");
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
return Object.freeze({
|
|
2608
|
+
contractVersion: input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION,
|
|
2609
|
+
featureFlagId: AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID,
|
|
2610
|
+
guildId: input.guildId,
|
|
2611
|
+
authorityRevision: input.authorityRevision,
|
|
2612
|
+
syncedAtIso: input.syncedAtIso,
|
|
2613
|
+
quests: freezeReadonlyArray9(quests),
|
|
2614
|
+
removedQuestIds
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
function assertAiGameGuildQuestsContractVersion(value) {
|
|
2618
|
+
assertContractVersion8(value);
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2073
2621
|
// src/world-events.ts
|
|
2074
2622
|
function isCanonicalWorldEvent(event) {
|
|
2075
2623
|
return event.recordType === "canonical";
|
|
@@ -2221,7 +2769,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
2221
2769
|
"private-or-low-witness-evidence",
|
|
2222
2770
|
"costly-pressure-event"
|
|
2223
2771
|
];
|
|
2224
|
-
function
|
|
2772
|
+
function isMember8(value, members) {
|
|
2225
2773
|
return members.includes(value);
|
|
2226
2774
|
}
|
|
2227
2775
|
function assertRecord(value, label) {
|
|
@@ -2262,7 +2810,7 @@ function normalizeTimestamp(value, label) {
|
|
|
2262
2810
|
}
|
|
2263
2811
|
function normalizeMember(value, members, label) {
|
|
2264
2812
|
const normalized = normalizeNonEmptyString(value, label);
|
|
2265
|
-
if (!
|
|
2813
|
+
if (!isMember8(normalized, members)) {
|
|
2266
2814
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
2267
2815
|
}
|
|
2268
2816
|
return normalized;
|
|
@@ -2395,13 +2943,13 @@ function normalizeDominantReads(value) {
|
|
|
2395
2943
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
2396
2944
|
}
|
|
2397
2945
|
function isQuietMeasureAxis(value) {
|
|
2398
|
-
return
|
|
2946
|
+
return isMember8(value, QUIET_MEASURE_AXES);
|
|
2399
2947
|
}
|
|
2400
2948
|
function isQuietMeasureMissionProbeMode(value) {
|
|
2401
|
-
return
|
|
2949
|
+
return isMember8(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
2402
2950
|
}
|
|
2403
2951
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
2404
|
-
return
|
|
2952
|
+
return isMember8(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
2405
2953
|
}
|
|
2406
2954
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
2407
2955
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -2899,6 +3447,16 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2899
3447
|
]);
|
|
2900
3448
|
export {
|
|
2901
3449
|
AI_GAME_ACTOR_ROLES,
|
|
3450
|
+
AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
3451
|
+
AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
3452
|
+
AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
|
|
3453
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
|
|
3454
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
|
|
3455
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_KINDS,
|
|
3456
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS,
|
|
3457
|
+
AI_GAME_APPRENTICESHIP_READINESS_STATES,
|
|
3458
|
+
AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
|
|
3459
|
+
AI_GAME_APPRENTICESHIP_SUPERVISION_MODES,
|
|
2902
3460
|
AI_GAME_ENV_PREFIX,
|
|
2903
3461
|
AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,
|
|
2904
3462
|
AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
|
|
@@ -2907,6 +3465,12 @@ export {
|
|
|
2907
3465
|
AI_GAME_GOSSIP_EXPORT_AUDIENCES,
|
|
2908
3466
|
AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
2909
3467
|
AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
3468
|
+
AI_GAME_GUILD_QUESTS_CONTRACT_VERSION,
|
|
3469
|
+
AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID,
|
|
3470
|
+
AI_GAME_GUILD_QUEST_OBJECTIVE_STATUSES,
|
|
3471
|
+
AI_GAME_GUILD_QUEST_REWARD_KINDS,
|
|
3472
|
+
AI_GAME_GUILD_QUEST_STATUSES,
|
|
3473
|
+
AI_GAME_GUILD_QUEST_SYSTEM_RECOMMENDATIONS,
|
|
2910
3474
|
AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
2911
3475
|
AI_GAME_IDENTITY_DISCLOSURE_POLICY,
|
|
2912
3476
|
AI_GAME_IDENTITY_FEATURE_FLAG_ID,
|
|
@@ -3019,12 +3583,23 @@ export {
|
|
|
3019
3583
|
QUIET_MEASURE_PERSPECTIVES,
|
|
3020
3584
|
QUIET_MEASURE_SIGNAL_BANDS,
|
|
3021
3585
|
aiGameFeatureFlags,
|
|
3586
|
+
assertAiGameGuildQuestsContractVersion,
|
|
3022
3587
|
assertAiGameIdentityProjectionContractVersion,
|
|
3023
3588
|
assertAiGameMissionContractVersion,
|
|
3024
3589
|
assertAiGameObservedEventLogContractVersion,
|
|
3025
3590
|
classifyAiGameTask,
|
|
3026
3591
|
createAiGameAcademicTrainingSnapshot,
|
|
3592
|
+
createAiGameApprenticeshipHandoff,
|
|
3593
|
+
createAiGameApprenticeshipReadiness,
|
|
3594
|
+
createAiGameApprenticeshipSponsorship,
|
|
3595
|
+
createAiGameApprenticeshipSupervision,
|
|
3027
3596
|
createAiGameGossipExport,
|
|
3597
|
+
createAiGameGuildQuest,
|
|
3598
|
+
createAiGameGuildQuestFailure,
|
|
3599
|
+
createAiGameGuildQuestObjectiveProgress,
|
|
3600
|
+
createAiGameGuildQuestProgress,
|
|
3601
|
+
createAiGameGuildQuestRewardPreview,
|
|
3602
|
+
createAiGameGuildQuestSyncPayload,
|
|
3028
3603
|
createAiGameIdentityProjectionContract,
|
|
3029
3604
|
createAiGameIdentitySelfProjection,
|
|
3030
3605
|
createAiGameIdentityTargetProjection,
|
|
@@ -3073,7 +3648,12 @@ export {
|
|
|
3073
3648
|
getAiGamePlayerSystemFocusModeContract,
|
|
3074
3649
|
getAiGamePlayerSystemGuidanceFallbackContract,
|
|
3075
3650
|
getAiGamePlayerSystemModuleContract,
|
|
3651
|
+
isAiGameApprenticeshipReadinessState,
|
|
3076
3652
|
isAiGameGossipExportAudience,
|
|
3653
|
+
isAiGameGuildQuestObjectiveStatus,
|
|
3654
|
+
isAiGameGuildQuestRewardKind,
|
|
3655
|
+
isAiGameGuildQuestStatus,
|
|
3656
|
+
isAiGameGuildQuestSystemRecommendation,
|
|
3077
3657
|
isAiGameIdentityKnowledgeState,
|
|
3078
3658
|
isAiGameIdentityProjectionRead,
|
|
3079
3659
|
isAiGameIdentityTargetCategory,
|