MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / wrapReadTextWithError

Function wrapReadTextWithError

packages/agent-core/test/session/init.test.ts:757–777  ·  view source on GitHub ↗

* Wrap a Kaos so every `readText` (and `readLines`, which reads via * `readText` in the ACP bridge) rejects with `cause`. Used to simulate the * Zed ACP `fs/readTextFile` "Internal error" path that broke session bootstrap * before AGENTS.md loading was rerouted onto the persistence kaos.

(inner: Kaos, cause: Error)

Source from the content-addressed store, hash-verified

755 * before AGENTS.md loading was rerouted onto the persistence kaos.
756 */
757function wrapReadTextWithError(inner: Kaos, cause: Error): Kaos {
758 return new Proxy(inner, {
759 get(target, prop, receiver) {
760 if (prop === 'readText') {
761 return async () => {
762 throw cause;
763 };
764 }
765 if (prop === 'readLines') {
766 return async function* () {
767 yield* [];
768 throw cause;
769 };
770 }
771 if (prop === 'withCwd') {
772 return (cwd: string) => wrapReadTextWithError(target.withCwd(cwd), cause);
773 }
774 return Reflect.get(target, prop, receiver);
775 },
776 });
777}

Callers 2

init.test.tsFile · 0.85
getFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected