MCPcopy Create free account
hub / github.com/YunYouJun/advjs / loadScript

Method loadScript

packages/core/src/engine/runtime.ts:75–92  ·  view source on GitHub ↗

* Load a script from markdown content

(content: string, scriptPath: string, sessionId?: string)

Source from the content-addressed store, hash-verified

73 return this.advanceToNextDisplayable()
74 }
75
76 /**
77 * Make a choice at the current choices node
78 */
79 async choose(choiceIndex: number): Promise<FormattedOutput | null> {
80 if (!this.ast || !this.session)
81 return null
82
83 if (this.session.status !== 'waiting_choice')
84 return null
85
86 const currentNode = this.ast.children[this.session.currentIndex]
87 if (currentNode?.type !== 'choices')
88 return null
89
90 const choices = currentNode as AdvAst.Choices
91 if (choiceIndex < 1 || choiceIndex > choices.choices.length)
92 return null
93
94 // Record the choice
95 this.session.choices[this.session.currentIndex] = choiceIndex

Callers 2

interactivePlayFunction · 0.80
runtime.test.tsFile · 0.80

Calls 5

normalizeSessionMethod · 0.95
parseAstFunction · 0.90
getOrCreateMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected