@actalk/inkos-core 1.0.0 → 1.0.1-canary.19.1
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/package.json +1 -1
- package/dist/agents/choice-auditor.d.ts +0 -22
- package/dist/agents/choice-auditor.d.ts.map +0 -1
- package/dist/agents/choice-auditor.js +0 -101
- package/dist/agents/choice-auditor.js.map +0 -1
- package/dist/agents/choice-generator.d.ts +0 -57
- package/dist/agents/choice-generator.d.ts.map +0 -1
- package/dist/agents/choice-generator.js +0 -140
- package/dist/agents/choice-generator.js.map +0 -1
- package/dist/models/interactive-fiction.d.ts +0 -260
- package/dist/models/interactive-fiction.d.ts.map +0 -1
- package/dist/models/interactive-fiction.js +0 -45
- package/dist/models/interactive-fiction.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actalk/inkos-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-canary.19.1",
|
|
4
4
|
"description": "InkOS core engine — multi-agent novel writing pipeline with 33-dimension continuity audit, style cloning, and de-AI-ification",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-novel-writing",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseAgent } from "./base.js";
|
|
2
|
-
import type { GeneratedChoice } from "./choice-generator.js";
|
|
3
|
-
export interface ChoiceAuditIssue {
|
|
4
|
-
readonly category: "invalid_choice_count" | "duplicate_choice";
|
|
5
|
-
readonly description: string;
|
|
6
|
-
}
|
|
7
|
-
export interface AuditChoicesInput {
|
|
8
|
-
readonly chapterNumber: number;
|
|
9
|
-
readonly chapterEnding: string;
|
|
10
|
-
readonly language?: "zh" | "en";
|
|
11
|
-
readonly choices: ReadonlyArray<GeneratedChoice>;
|
|
12
|
-
}
|
|
13
|
-
export interface ChoiceAuditResult {
|
|
14
|
-
readonly passed: boolean;
|
|
15
|
-
readonly issues: ReadonlyArray<ChoiceAuditIssue>;
|
|
16
|
-
readonly choices: ReadonlyArray<GeneratedChoice>;
|
|
17
|
-
}
|
|
18
|
-
export declare class ChoiceAuditor extends BaseAgent {
|
|
19
|
-
get name(): string;
|
|
20
|
-
auditChoices(input: AuditChoicesInput): Promise<ChoiceAuditResult>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=choice-auditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"choice-auditor.d.ts","sourceRoot":"","sources":["../../src/agents/choice-auditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,GAAG,kBAAkB,CAAC;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CAClD;AAED,qBAAa,aAAc,SAAQ,SAAS;IAC1C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEK,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAmCzE"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { BaseAgent } from "./base.js";
|
|
2
|
-
export class ChoiceAuditor extends BaseAgent {
|
|
3
|
-
get name() {
|
|
4
|
-
return "choice-auditor";
|
|
5
|
-
}
|
|
6
|
-
async auditChoices(input) {
|
|
7
|
-
const issues = [];
|
|
8
|
-
if (input.choices.length < 2 || input.choices.length > 4) {
|
|
9
|
-
issues.push({
|
|
10
|
-
category: "invalid_choice_count",
|
|
11
|
-
description: input.language === "en"
|
|
12
|
-
? `Interactive chapters require 2-4 choices, but received ${input.choices.length}.`
|
|
13
|
-
: `互动章节必须提供 2-4 个选项,当前收到 ${input.choices.length} 个。`,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
for (let leftIndex = 0; leftIndex < input.choices.length; leftIndex += 1) {
|
|
17
|
-
for (let rightIndex = leftIndex + 1; rightIndex < input.choices.length; rightIndex += 1) {
|
|
18
|
-
const left = input.choices[leftIndex];
|
|
19
|
-
const right = input.choices[rightIndex];
|
|
20
|
-
if (!isNearDuplicateChoice(left, right)) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
issues.push({
|
|
24
|
-
category: "duplicate_choice",
|
|
25
|
-
description: input.language === "en"
|
|
26
|
-
? `Choice ${leftIndex + 1} and choice ${rightIndex + 1} are too similar to form a real branch.`
|
|
27
|
-
: `第 ${leftIndex + 1} 个和第 ${rightIndex + 1} 个选项过于相似,不能构成真实分叉。`,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
passed: issues.length === 0,
|
|
33
|
-
issues,
|
|
34
|
-
choices: input.choices,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function isNearDuplicateChoice(left, right) {
|
|
39
|
-
const leftGoal = normalizeText(left.immediateGoal);
|
|
40
|
-
const rightGoal = normalizeText(right.immediateGoal);
|
|
41
|
-
const sameGoal = Boolean(leftGoal && leftGoal === rightGoal);
|
|
42
|
-
const labelSimilarity = diceSimilarity(normalizeText(left.label), normalizeText(right.label));
|
|
43
|
-
const intentSimilarity = diceSimilarity(normalizeText(left.intent), normalizeText(right.intent));
|
|
44
|
-
const riskSimilarity = diceSimilarity(normalizeText(left.expectedRisk), normalizeText(right.expectedRisk));
|
|
45
|
-
const hookSimilarity = diceSimilarity(normalizeText(left.hookPressure), normalizeText(right.hookPressure));
|
|
46
|
-
const characterSimilarity = diceSimilarity(normalizeText(left.characterPressure), normalizeText(right.characterPressure));
|
|
47
|
-
const sameTone = normalizeText(left.tone) === normalizeText(right.tone);
|
|
48
|
-
return sameGoal && sameTone && (intentSimilarity >= 0.55
|
|
49
|
-
|| riskSimilarity >= 0.55
|
|
50
|
-
|| hookSimilarity >= 0.55
|
|
51
|
-
|| characterSimilarity >= 0.55
|
|
52
|
-
|| labelSimilarity >= 0.55);
|
|
53
|
-
}
|
|
54
|
-
function normalizeText(value) {
|
|
55
|
-
return value
|
|
56
|
-
.trim()
|
|
57
|
-
.toLowerCase()
|
|
58
|
-
.replace(/[^a-z0-9\u4e00-\u9fff]+/g, " ")
|
|
59
|
-
.replace(/\s+/g, " ")
|
|
60
|
-
.trim();
|
|
61
|
-
}
|
|
62
|
-
function diceSimilarity(left, right) {
|
|
63
|
-
if (!left || !right) {
|
|
64
|
-
return 0;
|
|
65
|
-
}
|
|
66
|
-
if (left === right) {
|
|
67
|
-
return 1;
|
|
68
|
-
}
|
|
69
|
-
const leftBigrams = buildBigrams(left);
|
|
70
|
-
const rightBigrams = buildBigrams(right);
|
|
71
|
-
const leftCount = countMapEntries(leftBigrams);
|
|
72
|
-
const rightCount = countMapEntries(rightBigrams);
|
|
73
|
-
if (leftCount === 0 || rightCount === 0) {
|
|
74
|
-
return 0;
|
|
75
|
-
}
|
|
76
|
-
let overlap = 0;
|
|
77
|
-
for (const [bigram, count] of leftBigrams) {
|
|
78
|
-
overlap += Math.min(count, rightBigrams.get(bigram) ?? 0);
|
|
79
|
-
}
|
|
80
|
-
return (2 * overlap) / (leftCount + rightCount);
|
|
81
|
-
}
|
|
82
|
-
function buildBigrams(value) {
|
|
83
|
-
const normalized = value.replace(/\s+/g, "");
|
|
84
|
-
const result = new Map();
|
|
85
|
-
if (normalized.length < 2) {
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
for (let index = 0; index <= normalized.length - 2; index += 1) {
|
|
89
|
-
const bigram = normalized.slice(index, index + 2);
|
|
90
|
-
result.set(bigram, (result.get(bigram) ?? 0) + 1);
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
function countMapEntries(value) {
|
|
95
|
-
let total = 0;
|
|
96
|
-
for (const count of value.values()) {
|
|
97
|
-
total += count;
|
|
98
|
-
}
|
|
99
|
-
return total;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=choice-auditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"choice-auditor.js","sourceRoot":"","sources":["../../src/agents/choice-auditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAqBtC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,IAAI,IAAI;QACN,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAwB;QACzC,MAAM,MAAM,GAAuB,EAAE,CAAC;QAEtC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzD,MAAM,CAAC,IAAI,CAAC;gBACV,QAAQ,EAAE,sBAAsB;gBAChC,WAAW,EAAE,KAAK,CAAC,QAAQ,KAAK,IAAI;oBAClC,CAAC,CAAC,0DAA0D,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG;oBACnF,CAAC,CAAC,yBAAyB,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK;aACvD,CAAC,CAAC;QACL,CAAC;QAED,KAAK,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AG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,eAAe,CAAC,KAAkC;IACzD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACnC,KAAK,IAAI,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { BaseAgent } from "./base.js";
|
|
3
|
-
export declare const GeneratedChoiceSchema: z.ZodObject<Omit<{
|
|
4
|
-
choiceId: z.ZodString;
|
|
5
|
-
fromNodeId: z.ZodString;
|
|
6
|
-
toNodeId: z.ZodString;
|
|
7
|
-
label: z.ZodString;
|
|
8
|
-
intent: z.ZodString;
|
|
9
|
-
immediateGoal: z.ZodString;
|
|
10
|
-
expectedCost: z.ZodString;
|
|
11
|
-
expectedRisk: z.ZodString;
|
|
12
|
-
hookPressure: z.ZodString;
|
|
13
|
-
characterPressure: z.ZodString;
|
|
14
|
-
tone: z.ZodString;
|
|
15
|
-
selected: z.ZodBoolean;
|
|
16
|
-
}, "choiceId" | "fromNodeId" | "toNodeId" | "selected">, "strip", z.ZodTypeAny, {
|
|
17
|
-
label: string;
|
|
18
|
-
intent: string;
|
|
19
|
-
immediateGoal: string;
|
|
20
|
-
expectedCost: string;
|
|
21
|
-
expectedRisk: string;
|
|
22
|
-
hookPressure: string;
|
|
23
|
-
characterPressure: string;
|
|
24
|
-
tone: string;
|
|
25
|
-
}, {
|
|
26
|
-
label: string;
|
|
27
|
-
intent: string;
|
|
28
|
-
immediateGoal: string;
|
|
29
|
-
expectedCost: string;
|
|
30
|
-
expectedRisk: string;
|
|
31
|
-
hookPressure: string;
|
|
32
|
-
characterPressure: string;
|
|
33
|
-
tone: string;
|
|
34
|
-
}>;
|
|
35
|
-
export type GeneratedChoice = z.infer<typeof GeneratedChoiceSchema>;
|
|
36
|
-
export interface GenerateChoicesInput {
|
|
37
|
-
readonly chapterNumber: number;
|
|
38
|
-
readonly chapterContent: string;
|
|
39
|
-
readonly language?: "zh" | "en";
|
|
40
|
-
readonly chapterIntent?: string;
|
|
41
|
-
readonly currentFocus?: string;
|
|
42
|
-
readonly hookPressure?: string;
|
|
43
|
-
readonly characterPressure?: string;
|
|
44
|
-
}
|
|
45
|
-
export interface GenerateChoicesOutput {
|
|
46
|
-
readonly choices: ReadonlyArray<GeneratedChoice>;
|
|
47
|
-
readonly tokenUsage?: {
|
|
48
|
-
readonly promptTokens: number;
|
|
49
|
-
readonly completionTokens: number;
|
|
50
|
-
readonly totalTokens: number;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export declare class ChoiceGeneratorAgent extends BaseAgent {
|
|
54
|
-
get name(): string;
|
|
55
|
-
generateChoices(input: GenerateChoicesInput): Promise<GenerateChoicesOutput>;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=choice-generator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"choice-generator.d.ts","sourceRoot":"","sources":["../../src/agents/choice-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEK,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA2DnF"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { BaseAgent } from "./base.js";
|
|
3
|
-
import { InteractiveChoiceSchema } from "../models/interactive-fiction.js";
|
|
4
|
-
export const GeneratedChoiceSchema = InteractiveChoiceSchema.omit({
|
|
5
|
-
choiceId: true,
|
|
6
|
-
fromNodeId: true,
|
|
7
|
-
toNodeId: true,
|
|
8
|
-
selected: true,
|
|
9
|
-
});
|
|
10
|
-
const GeneratedChoicesEnvelopeSchema = z.object({
|
|
11
|
-
choices: z.array(GeneratedChoiceSchema).min(2).max(4),
|
|
12
|
-
});
|
|
13
|
-
export class ChoiceGeneratorAgent extends BaseAgent {
|
|
14
|
-
get name() {
|
|
15
|
-
return "choice-generator";
|
|
16
|
-
}
|
|
17
|
-
async generateChoices(input) {
|
|
18
|
-
const language = input.language ?? "zh";
|
|
19
|
-
const systemPrompt = language === "en"
|
|
20
|
-
? [
|
|
21
|
-
"You generate 2-4 grounded reader-facing branch choices for an interactive novel.",
|
|
22
|
-
"Return JSON only in the shape:",
|
|
23
|
-
"{\"choices\":[{\"label\":\"...\",\"intent\":\"...\",\"immediateGoal\":\"...\",\"expectedCost\":\"...\",\"expectedRisk\":\"...\",\"hookPressure\":\"...\",\"characterPressure\":\"...\",\"tone\":\"...\"}]}",
|
|
24
|
-
"Rules:",
|
|
25
|
-
"- choices must be meaningfully different",
|
|
26
|
-
"- no joke or obviously bad options",
|
|
27
|
-
"- each choice must be grounded in the chapter ending",
|
|
28
|
-
"- keep labels concise",
|
|
29
|
-
].join("\n")
|
|
30
|
-
: [
|
|
31
|
-
"你负责为互动小说生成 2-4 个 grounded 的读者分支选项。",
|
|
32
|
-
"只返回 JSON,格式如下:",
|
|
33
|
-
"{\"choices\":[{\"label\":\"...\",\"intent\":\"...\",\"immediateGoal\":\"...\",\"expectedCost\":\"...\",\"expectedRisk\":\"...\",\"hookPressure\":\"...\",\"characterPressure\":\"...\",\"tone\":\"...\"}]}",
|
|
34
|
-
"规则:",
|
|
35
|
-
"- 选项必须真实分叉,不要三句同义改写",
|
|
36
|
-
"- 不要玩笑选项或明显废选项",
|
|
37
|
-
"- 所有选项都必须建立在章末局势上",
|
|
38
|
-
"- label 要短,其他字段要具体",
|
|
39
|
-
].join("\n");
|
|
40
|
-
const userPrompt = [
|
|
41
|
-
language === "en" ? `Chapter ${input.chapterNumber}` : `第${input.chapterNumber}章`,
|
|
42
|
-
"",
|
|
43
|
-
language === "en" ? "## Chapter Ending" : "## 章末内容",
|
|
44
|
-
input.chapterContent.slice(0, 5000),
|
|
45
|
-
"",
|
|
46
|
-
input.chapterIntent
|
|
47
|
-
? `${language === "en" ? "## Chapter Intent" : "## 当前章节意图"}\n${input.chapterIntent}`
|
|
48
|
-
: "",
|
|
49
|
-
input.currentFocus
|
|
50
|
-
? `${language === "en" ? "## Current Focus" : "## 当前焦点"}\n${input.currentFocus}`
|
|
51
|
-
: "",
|
|
52
|
-
input.hookPressure
|
|
53
|
-
? `${language === "en" ? "## Hook Pressure" : "## 伏笔压力"}\n${input.hookPressure}`
|
|
54
|
-
: "",
|
|
55
|
-
input.characterPressure
|
|
56
|
-
? `${language === "en" ? "## Character Pressure" : "## 人物压力"}\n${input.characterPressure}`
|
|
57
|
-
: "",
|
|
58
|
-
].filter(Boolean).join("\n");
|
|
59
|
-
const response = await this.chat([
|
|
60
|
-
{ role: "system", content: systemPrompt },
|
|
61
|
-
{ role: "user", content: userPrompt },
|
|
62
|
-
], { temperature: 0.6, maxTokens: 2048 });
|
|
63
|
-
const parsed = extractFirstValidJsonObject(response.content.trim());
|
|
64
|
-
const envelope = GeneratedChoicesEnvelopeSchema.parse(parsed);
|
|
65
|
-
return {
|
|
66
|
-
choices: envelope.choices,
|
|
67
|
-
tokenUsage: response.usage,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function extractFirstValidJsonObject(text) {
|
|
72
|
-
if (!text) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const direct = tryParseJson(text);
|
|
76
|
-
if (direct) {
|
|
77
|
-
return direct;
|
|
78
|
-
}
|
|
79
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
80
|
-
if (text[index] !== "{")
|
|
81
|
-
continue;
|
|
82
|
-
const candidate = extractBalancedJsonObject(text, index);
|
|
83
|
-
if (!candidate)
|
|
84
|
-
continue;
|
|
85
|
-
const parsed = tryParseJson(candidate);
|
|
86
|
-
if (parsed) {
|
|
87
|
-
return parsed;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
function tryParseJson(text) {
|
|
93
|
-
try {
|
|
94
|
-
return JSON.parse(text);
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function extractBalancedJsonObject(text, start) {
|
|
101
|
-
let depth = 0;
|
|
102
|
-
let inString = false;
|
|
103
|
-
let escaped = false;
|
|
104
|
-
for (let index = start; index < text.length; index += 1) {
|
|
105
|
-
const char = text[index];
|
|
106
|
-
if (inString) {
|
|
107
|
-
if (escaped) {
|
|
108
|
-
escaped = false;
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (char === "\\") {
|
|
112
|
-
escaped = true;
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (char === "\"") {
|
|
116
|
-
inString = false;
|
|
117
|
-
}
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
if (char === "\"") {
|
|
121
|
-
inString = true;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (char === "{") {
|
|
125
|
-
depth += 1;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (char === "}") {
|
|
129
|
-
depth -= 1;
|
|
130
|
-
if (depth === 0) {
|
|
131
|
-
return text.slice(start, index + 1);
|
|
132
|
-
}
|
|
133
|
-
if (depth < 0) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=choice-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"choice-generator.js","sourceRoot":"","sources":["../../src/agents/choice-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC,IAAI,CAAC;IAChE,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAGH,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,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SAAS;YACX,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC;YACnB,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,QAAQ,GAAG,IAAI,CAAC;YAChB,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,CAAC;YACX,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const InteractiveSnapshotRefSchema: z.ZodObject<{
|
|
3
|
-
chapterNumber: z.ZodNumber;
|
|
4
|
-
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
chapterNumber: number;
|
|
6
|
-
}, {
|
|
7
|
-
chapterNumber: number;
|
|
8
|
-
}>;
|
|
9
|
-
export type InteractiveSnapshotRef = z.infer<typeof InteractiveSnapshotRefSchema>;
|
|
10
|
-
export declare const InteractiveBranchNodeStatusSchema: z.ZodEnum<["active", "awaiting-choice", "dormant", "completed"]>;
|
|
11
|
-
export type InteractiveBranchNodeStatus = z.infer<typeof InteractiveBranchNodeStatusSchema>;
|
|
12
|
-
export declare const InteractiveBranchNodeSchema: z.ZodObject<{
|
|
13
|
-
nodeId: z.ZodString;
|
|
14
|
-
parentNodeId: z.ZodNullable<z.ZodString>;
|
|
15
|
-
sourceChapterId: z.ZodNullable<z.ZodString>;
|
|
16
|
-
sourceChapterNumber: z.ZodNumber;
|
|
17
|
-
branchDepth: z.ZodNumber;
|
|
18
|
-
branchLabel: z.ZodString;
|
|
19
|
-
status: z.ZodEnum<["active", "awaiting-choice", "dormant", "completed"]>;
|
|
20
|
-
snapshotRef: z.ZodObject<{
|
|
21
|
-
chapterNumber: z.ZodNumber;
|
|
22
|
-
}, "strip", z.ZodTypeAny, {
|
|
23
|
-
chapterNumber: number;
|
|
24
|
-
}, {
|
|
25
|
-
chapterNumber: number;
|
|
26
|
-
}>;
|
|
27
|
-
selectedChoiceId: z.ZodNullable<z.ZodString>;
|
|
28
|
-
chapterIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
29
|
-
displayPath: z.ZodString;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
status: "active" | "completed" | "awaiting-choice" | "dormant";
|
|
32
|
-
nodeId: string;
|
|
33
|
-
parentNodeId: string | null;
|
|
34
|
-
sourceChapterId: string | null;
|
|
35
|
-
sourceChapterNumber: number;
|
|
36
|
-
branchDepth: number;
|
|
37
|
-
branchLabel: string;
|
|
38
|
-
snapshotRef: {
|
|
39
|
-
chapterNumber: number;
|
|
40
|
-
};
|
|
41
|
-
selectedChoiceId: string | null;
|
|
42
|
-
chapterIds: string[];
|
|
43
|
-
displayPath: string;
|
|
44
|
-
}, {
|
|
45
|
-
status: "active" | "completed" | "awaiting-choice" | "dormant";
|
|
46
|
-
nodeId: string;
|
|
47
|
-
parentNodeId: string | null;
|
|
48
|
-
sourceChapterId: string | null;
|
|
49
|
-
sourceChapterNumber: number;
|
|
50
|
-
branchDepth: number;
|
|
51
|
-
branchLabel: string;
|
|
52
|
-
snapshotRef: {
|
|
53
|
-
chapterNumber: number;
|
|
54
|
-
};
|
|
55
|
-
selectedChoiceId: string | null;
|
|
56
|
-
displayPath: string;
|
|
57
|
-
chapterIds?: string[] | undefined;
|
|
58
|
-
}>;
|
|
59
|
-
export type InteractiveBranchNode = z.infer<typeof InteractiveBranchNodeSchema>;
|
|
60
|
-
export declare const InteractiveChoiceSchema: z.ZodObject<{
|
|
61
|
-
choiceId: z.ZodString;
|
|
62
|
-
fromNodeId: z.ZodString;
|
|
63
|
-
toNodeId: z.ZodString;
|
|
64
|
-
label: z.ZodString;
|
|
65
|
-
intent: z.ZodString;
|
|
66
|
-
immediateGoal: z.ZodString;
|
|
67
|
-
expectedCost: z.ZodString;
|
|
68
|
-
expectedRisk: z.ZodString;
|
|
69
|
-
hookPressure: z.ZodString;
|
|
70
|
-
characterPressure: z.ZodString;
|
|
71
|
-
tone: z.ZodString;
|
|
72
|
-
selected: z.ZodBoolean;
|
|
73
|
-
}, "strip", z.ZodTypeAny, {
|
|
74
|
-
choiceId: string;
|
|
75
|
-
fromNodeId: string;
|
|
76
|
-
toNodeId: string;
|
|
77
|
-
label: string;
|
|
78
|
-
intent: string;
|
|
79
|
-
immediateGoal: string;
|
|
80
|
-
expectedCost: string;
|
|
81
|
-
expectedRisk: string;
|
|
82
|
-
hookPressure: string;
|
|
83
|
-
characterPressure: string;
|
|
84
|
-
tone: string;
|
|
85
|
-
selected: boolean;
|
|
86
|
-
}, {
|
|
87
|
-
choiceId: string;
|
|
88
|
-
fromNodeId: string;
|
|
89
|
-
toNodeId: string;
|
|
90
|
-
label: string;
|
|
91
|
-
intent: string;
|
|
92
|
-
immediateGoal: string;
|
|
93
|
-
expectedCost: string;
|
|
94
|
-
expectedRisk: string;
|
|
95
|
-
hookPressure: string;
|
|
96
|
-
characterPressure: string;
|
|
97
|
-
tone: string;
|
|
98
|
-
selected: boolean;
|
|
99
|
-
}>;
|
|
100
|
-
export type InteractiveChoice = z.infer<typeof InteractiveChoiceSchema>;
|
|
101
|
-
export declare const InteractiveBranchTreeSchema: z.ZodObject<{
|
|
102
|
-
version: z.ZodLiteral<1>;
|
|
103
|
-
activeNodeId: z.ZodString;
|
|
104
|
-
rootNodeId: z.ZodString;
|
|
105
|
-
nodes: z.ZodArray<z.ZodObject<{
|
|
106
|
-
nodeId: z.ZodString;
|
|
107
|
-
parentNodeId: z.ZodNullable<z.ZodString>;
|
|
108
|
-
sourceChapterId: z.ZodNullable<z.ZodString>;
|
|
109
|
-
sourceChapterNumber: z.ZodNumber;
|
|
110
|
-
branchDepth: z.ZodNumber;
|
|
111
|
-
branchLabel: z.ZodString;
|
|
112
|
-
status: z.ZodEnum<["active", "awaiting-choice", "dormant", "completed"]>;
|
|
113
|
-
snapshotRef: z.ZodObject<{
|
|
114
|
-
chapterNumber: z.ZodNumber;
|
|
115
|
-
}, "strip", z.ZodTypeAny, {
|
|
116
|
-
chapterNumber: number;
|
|
117
|
-
}, {
|
|
118
|
-
chapterNumber: number;
|
|
119
|
-
}>;
|
|
120
|
-
selectedChoiceId: z.ZodNullable<z.ZodString>;
|
|
121
|
-
chapterIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
122
|
-
displayPath: z.ZodString;
|
|
123
|
-
}, "strip", z.ZodTypeAny, {
|
|
124
|
-
status: "active" | "completed" | "awaiting-choice" | "dormant";
|
|
125
|
-
nodeId: string;
|
|
126
|
-
parentNodeId: string | null;
|
|
127
|
-
sourceChapterId: string | null;
|
|
128
|
-
sourceChapterNumber: number;
|
|
129
|
-
branchDepth: number;
|
|
130
|
-
branchLabel: string;
|
|
131
|
-
snapshotRef: {
|
|
132
|
-
chapterNumber: number;
|
|
133
|
-
};
|
|
134
|
-
selectedChoiceId: string | null;
|
|
135
|
-
chapterIds: string[];
|
|
136
|
-
displayPath: string;
|
|
137
|
-
}, {
|
|
138
|
-
status: "active" | "completed" | "awaiting-choice" | "dormant";
|
|
139
|
-
nodeId: string;
|
|
140
|
-
parentNodeId: string | null;
|
|
141
|
-
sourceChapterId: string | null;
|
|
142
|
-
sourceChapterNumber: number;
|
|
143
|
-
branchDepth: number;
|
|
144
|
-
branchLabel: string;
|
|
145
|
-
snapshotRef: {
|
|
146
|
-
chapterNumber: number;
|
|
147
|
-
};
|
|
148
|
-
selectedChoiceId: string | null;
|
|
149
|
-
displayPath: string;
|
|
150
|
-
chapterIds?: string[] | undefined;
|
|
151
|
-
}>, "many">;
|
|
152
|
-
choices: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
153
|
-
choiceId: z.ZodString;
|
|
154
|
-
fromNodeId: z.ZodString;
|
|
155
|
-
toNodeId: z.ZodString;
|
|
156
|
-
label: z.ZodString;
|
|
157
|
-
intent: z.ZodString;
|
|
158
|
-
immediateGoal: z.ZodString;
|
|
159
|
-
expectedCost: z.ZodString;
|
|
160
|
-
expectedRisk: z.ZodString;
|
|
161
|
-
hookPressure: z.ZodString;
|
|
162
|
-
characterPressure: z.ZodString;
|
|
163
|
-
tone: z.ZodString;
|
|
164
|
-
selected: z.ZodBoolean;
|
|
165
|
-
}, "strip", z.ZodTypeAny, {
|
|
166
|
-
choiceId: string;
|
|
167
|
-
fromNodeId: string;
|
|
168
|
-
toNodeId: string;
|
|
169
|
-
label: string;
|
|
170
|
-
intent: string;
|
|
171
|
-
immediateGoal: string;
|
|
172
|
-
expectedCost: string;
|
|
173
|
-
expectedRisk: string;
|
|
174
|
-
hookPressure: string;
|
|
175
|
-
characterPressure: string;
|
|
176
|
-
tone: string;
|
|
177
|
-
selected: boolean;
|
|
178
|
-
}, {
|
|
179
|
-
choiceId: string;
|
|
180
|
-
fromNodeId: string;
|
|
181
|
-
toNodeId: string;
|
|
182
|
-
label: string;
|
|
183
|
-
intent: string;
|
|
184
|
-
immediateGoal: string;
|
|
185
|
-
expectedCost: string;
|
|
186
|
-
expectedRisk: string;
|
|
187
|
-
hookPressure: string;
|
|
188
|
-
characterPressure: string;
|
|
189
|
-
tone: string;
|
|
190
|
-
selected: boolean;
|
|
191
|
-
}>, "many">>;
|
|
192
|
-
}, "strip", z.ZodTypeAny, {
|
|
193
|
-
version: 1;
|
|
194
|
-
activeNodeId: string;
|
|
195
|
-
rootNodeId: string;
|
|
196
|
-
nodes: {
|
|
197
|
-
status: "active" | "completed" | "awaiting-choice" | "dormant";
|
|
198
|
-
nodeId: string;
|
|
199
|
-
parentNodeId: string | null;
|
|
200
|
-
sourceChapterId: string | null;
|
|
201
|
-
sourceChapterNumber: number;
|
|
202
|
-
branchDepth: number;
|
|
203
|
-
branchLabel: string;
|
|
204
|
-
snapshotRef: {
|
|
205
|
-
chapterNumber: number;
|
|
206
|
-
};
|
|
207
|
-
selectedChoiceId: string | null;
|
|
208
|
-
chapterIds: string[];
|
|
209
|
-
displayPath: string;
|
|
210
|
-
}[];
|
|
211
|
-
choices: {
|
|
212
|
-
choiceId: string;
|
|
213
|
-
fromNodeId: string;
|
|
214
|
-
toNodeId: string;
|
|
215
|
-
label: string;
|
|
216
|
-
intent: string;
|
|
217
|
-
immediateGoal: string;
|
|
218
|
-
expectedCost: string;
|
|
219
|
-
expectedRisk: string;
|
|
220
|
-
hookPressure: string;
|
|
221
|
-
characterPressure: string;
|
|
222
|
-
tone: string;
|
|
223
|
-
selected: boolean;
|
|
224
|
-
}[];
|
|
225
|
-
}, {
|
|
226
|
-
version: 1;
|
|
227
|
-
activeNodeId: string;
|
|
228
|
-
rootNodeId: string;
|
|
229
|
-
nodes: {
|
|
230
|
-
status: "active" | "completed" | "awaiting-choice" | "dormant";
|
|
231
|
-
nodeId: string;
|
|
232
|
-
parentNodeId: string | null;
|
|
233
|
-
sourceChapterId: string | null;
|
|
234
|
-
sourceChapterNumber: number;
|
|
235
|
-
branchDepth: number;
|
|
236
|
-
branchLabel: string;
|
|
237
|
-
snapshotRef: {
|
|
238
|
-
chapterNumber: number;
|
|
239
|
-
};
|
|
240
|
-
selectedChoiceId: string | null;
|
|
241
|
-
displayPath: string;
|
|
242
|
-
chapterIds?: string[] | undefined;
|
|
243
|
-
}[];
|
|
244
|
-
choices?: {
|
|
245
|
-
choiceId: string;
|
|
246
|
-
fromNodeId: string;
|
|
247
|
-
toNodeId: string;
|
|
248
|
-
label: string;
|
|
249
|
-
intent: string;
|
|
250
|
-
immediateGoal: string;
|
|
251
|
-
expectedCost: string;
|
|
252
|
-
expectedRisk: string;
|
|
253
|
-
hookPressure: string;
|
|
254
|
-
characterPressure: string;
|
|
255
|
-
tone: string;
|
|
256
|
-
selected: boolean;
|
|
257
|
-
}[] | undefined;
|
|
258
|
-
}>;
|
|
259
|
-
export type InteractiveBranchTree = z.infer<typeof InteractiveBranchTreeSchema>;
|
|
260
|
-
//# sourceMappingURL=interactive-fiction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-fiction.d.ts","sourceRoot":"","sources":["../../src/models/interactive-fiction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,4BAA4B;;;;;;EAEvC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,eAAO,MAAM,iCAAiC,kEAK5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAalC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const InteractiveSnapshotRefSchema = z.object({
|
|
3
|
-
chapterNumber: z.number().int().min(0),
|
|
4
|
-
});
|
|
5
|
-
export const InteractiveBranchNodeStatusSchema = z.enum([
|
|
6
|
-
"active",
|
|
7
|
-
"awaiting-choice",
|
|
8
|
-
"dormant",
|
|
9
|
-
"completed",
|
|
10
|
-
]);
|
|
11
|
-
export const InteractiveBranchNodeSchema = z.object({
|
|
12
|
-
nodeId: z.string().min(1),
|
|
13
|
-
parentNodeId: z.string().min(1).nullable(),
|
|
14
|
-
sourceChapterId: z.string().min(1).nullable(),
|
|
15
|
-
sourceChapterNumber: z.number().int().min(0),
|
|
16
|
-
branchDepth: z.number().int().min(0),
|
|
17
|
-
branchLabel: z.string().min(1),
|
|
18
|
-
status: InteractiveBranchNodeStatusSchema,
|
|
19
|
-
snapshotRef: InteractiveSnapshotRefSchema,
|
|
20
|
-
selectedChoiceId: z.string().min(1).nullable(),
|
|
21
|
-
chapterIds: z.array(z.string().min(1)).default([]),
|
|
22
|
-
displayPath: z.string().min(1),
|
|
23
|
-
});
|
|
24
|
-
export const InteractiveChoiceSchema = z.object({
|
|
25
|
-
choiceId: z.string().min(1),
|
|
26
|
-
fromNodeId: z.string().min(1),
|
|
27
|
-
toNodeId: z.string().min(1),
|
|
28
|
-
label: z.string().min(1),
|
|
29
|
-
intent: z.string().min(1),
|
|
30
|
-
immediateGoal: z.string().min(1),
|
|
31
|
-
expectedCost: z.string().min(1),
|
|
32
|
-
expectedRisk: z.string().min(1),
|
|
33
|
-
hookPressure: z.string().min(1),
|
|
34
|
-
characterPressure: z.string().min(1),
|
|
35
|
-
tone: z.string().min(1),
|
|
36
|
-
selected: z.boolean(),
|
|
37
|
-
});
|
|
38
|
-
export const InteractiveBranchTreeSchema = z.object({
|
|
39
|
-
version: z.literal(1),
|
|
40
|
-
activeNodeId: z.string().min(1),
|
|
41
|
-
rootNodeId: z.string().min(1),
|
|
42
|
-
nodes: z.array(InteractiveBranchNodeSchema).min(1),
|
|
43
|
-
choices: z.array(InteractiveChoiceSchema).default([]),
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=interactive-fiction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-fiction.js","sourceRoot":"","sources":["../../src/models/interactive-fiction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,IAAI,CAAC;IACtD,QAAQ;IACR,iBAAiB;IACjB,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC1C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7C,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;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