MCPcopy
hub / github.com/electerm/electerm / createPromptWs

Function createPromptWs

test/unit-ci/session-ssh.spec.js:141–170  ·  view source on GitHub ↗
(promptResponder, options = {})

Source from the content-addressed store, hash-verified

139}
140
141function createPromptWs (promptResponder, options = {}) {
142 const {
143 includeConfirmPrompts = false,
144 defaultConfirmResponse = ['trust']
145 } = options
146 const prompts = []
147 let pendingOptions
148 return {
149 prompts,
150 s (payload) {
151 if (payload && payload.action === 'session-interactive') {
152 pendingOptions = payload.options
153 if (includeConfirmPrompts || payload.options?.mode !== 'confirm') {
154 prompts.push(payload.options)
155 }
156 }
157 },
158 once (handler) {
159 const currentOptions = pendingOptions
160 queueMicrotask(() => {
161 handler({
162 results: currentOptions?.mode === 'confirm' && !includeConfirmPrompts
163 ? defaultConfirmResponse
164 : promptResponder(currentOptions, prompts)
165 })
166 })
167 },
168 close () {}
169 }
170}
171
172function publicKeyOnlyAuth (publicKey) {
173 return (ctx) => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected