@plasius/ai-game 0.6.2 → 0.6.3
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 +16 -0
- package/README.md +23 -0
- package/dist/index.cjs +278 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -1
- package/dist/index.d.ts +119 -1
- package/dist/index.js +263 -0
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0018-apprenticeship-handoff-contract-boundary.md +58 -0
- package/docs/adrs/index.md +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2070,6 +2070,254 @@ 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
|
+
|
|
2073
2321
|
// src/world-events.ts
|
|
2074
2322
|
function isCanonicalWorldEvent(event) {
|
|
2075
2323
|
return event.recordType === "canonical";
|
|
@@ -2899,6 +3147,16 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2899
3147
|
]);
|
|
2900
3148
|
export {
|
|
2901
3149
|
AI_GAME_ACTOR_ROLES,
|
|
3150
|
+
AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
3151
|
+
AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
3152
|
+
AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
|
|
3153
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
|
|
3154
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
|
|
3155
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_KINDS,
|
|
3156
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS,
|
|
3157
|
+
AI_GAME_APPRENTICESHIP_READINESS_STATES,
|
|
3158
|
+
AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
|
|
3159
|
+
AI_GAME_APPRENTICESHIP_SUPERVISION_MODES,
|
|
2902
3160
|
AI_GAME_ENV_PREFIX,
|
|
2903
3161
|
AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,
|
|
2904
3162
|
AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
|
|
@@ -3024,6 +3282,10 @@ export {
|
|
|
3024
3282
|
assertAiGameObservedEventLogContractVersion,
|
|
3025
3283
|
classifyAiGameTask,
|
|
3026
3284
|
createAiGameAcademicTrainingSnapshot,
|
|
3285
|
+
createAiGameApprenticeshipHandoff,
|
|
3286
|
+
createAiGameApprenticeshipReadiness,
|
|
3287
|
+
createAiGameApprenticeshipSponsorship,
|
|
3288
|
+
createAiGameApprenticeshipSupervision,
|
|
3027
3289
|
createAiGameGossipExport,
|
|
3028
3290
|
createAiGameIdentityProjectionContract,
|
|
3029
3291
|
createAiGameIdentitySelfProjection,
|
|
@@ -3073,6 +3335,7 @@ export {
|
|
|
3073
3335
|
getAiGamePlayerSystemFocusModeContract,
|
|
3074
3336
|
getAiGamePlayerSystemGuidanceFallbackContract,
|
|
3075
3337
|
getAiGamePlayerSystemModuleContract,
|
|
3338
|
+
isAiGameApprenticeshipReadinessState,
|
|
3076
3339
|
isAiGameGossipExportAudience,
|
|
3077
3340
|
isAiGameIdentityKnowledgeState,
|
|
3078
3341
|
isAiGameIdentityProjectionRead,
|