@neuroverseos/governance 0.3.0 → 0.3.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.
Files changed (105) hide show
  1. package/README.md +20 -0
  2. package/package.json +16 -3
  3. package/policies/content-moderation-rules.txt +8 -0
  4. package/policies/marketing-rules.txt +8 -0
  5. package/policies/science-research-rules.txt +11 -0
  6. package/policies/social-media-rules.txt +7 -0
  7. package/policies/strict-rules.txt +8 -0
  8. package/policies/trading-rules.txt +8 -0
  9. package/simulate.html +1899 -0
  10. package/dist/adapters/autoresearch.cjs +0 -196
  11. package/dist/adapters/autoresearch.d.cts +0 -103
  12. package/dist/adapters/autoresearch.d.ts +0 -103
  13. package/dist/adapters/autoresearch.js +0 -7
  14. package/dist/adapters/express.cjs +0 -1114
  15. package/dist/adapters/express.d.cts +0 -66
  16. package/dist/adapters/express.d.ts +0 -66
  17. package/dist/adapters/express.js +0 -12
  18. package/dist/adapters/index.cjs +0 -1669
  19. package/dist/adapters/index.d.cts +0 -6
  20. package/dist/adapters/index.d.ts +0 -6
  21. package/dist/adapters/index.js +0 -46
  22. package/dist/adapters/langchain.cjs +0 -1155
  23. package/dist/adapters/langchain.d.cts +0 -89
  24. package/dist/adapters/langchain.d.ts +0 -89
  25. package/dist/adapters/langchain.js +0 -16
  26. package/dist/adapters/openai.cjs +0 -1185
  27. package/dist/adapters/openai.d.cts +0 -99
  28. package/dist/adapters/openai.d.ts +0 -99
  29. package/dist/adapters/openai.js +0 -16
  30. package/dist/adapters/openclaw.cjs +0 -1177
  31. package/dist/adapters/openclaw.d.cts +0 -99
  32. package/dist/adapters/openclaw.d.ts +0 -99
  33. package/dist/adapters/openclaw.js +0 -16
  34. package/dist/bootstrap-GXVDZNF7.js +0 -114
  35. package/dist/build-P42YFKQV.js +0 -339
  36. package/dist/chunk-2NICNKOM.js +0 -100
  37. package/dist/chunk-2PQU3VAN.js +0 -131
  38. package/dist/chunk-4A7LISES.js +0 -324
  39. package/dist/chunk-4JRYGIO7.js +0 -727
  40. package/dist/chunk-4NGDRRQH.js +0 -10
  41. package/dist/chunk-4QXB6PEO.js +0 -232
  42. package/dist/chunk-6CZSKEY5.js +0 -164
  43. package/dist/chunk-7P3S7MAY.js +0 -1090
  44. package/dist/chunk-A5W4GNQO.js +0 -130
  45. package/dist/chunk-AKW5YVCE.js +0 -96
  46. package/dist/chunk-BUWWN2NX.js +0 -192
  47. package/dist/chunk-COT5XS4V.js +0 -109
  48. package/dist/chunk-ER62HNGF.js +0 -139
  49. package/dist/chunk-FYS2CBUW.js +0 -304
  50. package/dist/chunk-GR6DGCZ2.js +0 -340
  51. package/dist/chunk-I3RRAYK2.js +0 -11
  52. package/dist/chunk-JZPQGIKR.js +0 -79
  53. package/dist/chunk-MWDQ4MJB.js +0 -11
  54. package/dist/chunk-NF5POFCI.js +0 -622
  55. package/dist/chunk-OGL7QXZS.js +0 -608
  56. package/dist/chunk-OT6PXH54.js +0 -61
  57. package/dist/chunk-PDOZHZWL.js +0 -225
  58. package/dist/chunk-Q6O7ZLO2.js +0 -62
  59. package/dist/chunk-QPASI2BR.js +0 -187
  60. package/dist/chunk-T5EUJQE5.js +0 -172
  61. package/dist/chunk-XPDMYECO.js +0 -642
  62. package/dist/chunk-YZFATT7X.js +0 -9
  63. package/dist/cli/neuroverse.cjs +0 -11448
  64. package/dist/cli/neuroverse.d.cts +0 -1
  65. package/dist/cli/neuroverse.d.ts +0 -1
  66. package/dist/cli/neuroverse.js +0 -196
  67. package/dist/cli/plan.cjs +0 -1599
  68. package/dist/cli/plan.d.cts +0 -20
  69. package/dist/cli/plan.d.ts +0 -20
  70. package/dist/cli/plan.js +0 -361
  71. package/dist/cli/run.cjs +0 -1746
  72. package/dist/cli/run.d.cts +0 -20
  73. package/dist/cli/run.d.ts +0 -20
  74. package/dist/cli/run.js +0 -143
  75. package/dist/configure-ai-TK67ZWZL.js +0 -132
  76. package/dist/derive-TLIV4OOU.js +0 -152
  77. package/dist/doctor-XPDLEYXN.js +0 -171
  78. package/dist/explain-IDCRWMPX.js +0 -70
  79. package/dist/guard-RV65TT4L.js +0 -96
  80. package/dist/guard-contract-WZx__PmU.d.cts +0 -709
  81. package/dist/guard-contract-WZx__PmU.d.ts +0 -709
  82. package/dist/guard-engine-JLTUARGU.js +0 -10
  83. package/dist/impact-XPECYRLH.js +0 -59
  84. package/dist/improve-GPUBKTEA.js +0 -85
  85. package/dist/index.cjs +0 -6273
  86. package/dist/index.d.cts +0 -1616
  87. package/dist/index.d.ts +0 -1616
  88. package/dist/index.js +0 -379
  89. package/dist/infer-world-7GVZWFX4.js +0 -543
  90. package/dist/init-PKPIYHYE.js +0 -144
  91. package/dist/init-world-VWMQZQC7.js +0 -223
  92. package/dist/mcp-server-FPVSU32Z.js +0 -13
  93. package/dist/model-adapter-BB7G4MFI.js +0 -11
  94. package/dist/playground-E664U4T6.js +0 -550
  95. package/dist/redteam-Z7WREJ44.js +0 -357
  96. package/dist/session-EKTRSR7C.js +0 -14
  97. package/dist/simulate-VDOYQFRO.js +0 -108
  98. package/dist/test-OGXJK4QU.js +0 -217
  99. package/dist/trace-JVF67VR3.js +0 -166
  100. package/dist/validate-LLBWVPGV.js +0 -81
  101. package/dist/validate-engine-UIABSIHD.js +0 -7
  102. package/dist/world-LAXO6DOX.js +0 -378
  103. package/dist/world-loader-HMPTOEA2.js +0 -9
  104. package/dist/worlds/autoresearch.nv-world.md +0 -230
  105. package/dist/worlds/derivation-world.nv-world.md +0 -278
@@ -1,100 +0,0 @@
1
- import {
2
- evaluateGuard
3
- } from "./chunk-4JRYGIO7.js";
4
- import {
5
- loadWorld
6
- } from "./chunk-JZPQGIKR.js";
7
-
8
- // src/adapters/express.ts
9
- function methodToCategory(method) {
10
- switch (method.toUpperCase()) {
11
- case "GET":
12
- case "HEAD":
13
- case "OPTIONS":
14
- return "read";
15
- case "POST":
16
- case "PUT":
17
- case "PATCH":
18
- return "write";
19
- case "DELETE":
20
- return "delete";
21
- default:
22
- return "other";
23
- }
24
- }
25
- function defaultMapRequest(req) {
26
- const method = (req.method ?? "GET").toUpperCase();
27
- const path = req.path ?? req.url ?? "/";
28
- return {
29
- intent: `${method} ${path}`,
30
- tool: "http",
31
- scope: path,
32
- actionCategory: methodToCategory(method),
33
- direction: "input",
34
- args: {
35
- method,
36
- path,
37
- ...req.params ?? {},
38
- ...req.query ?? {}
39
- }
40
- };
41
- }
42
- function defaultOnBlock(verdict, _req, res, statusCode) {
43
- const body = {
44
- error: "Governance policy violation",
45
- reason: verdict.reason ?? "Action not permitted",
46
- ruleId: verdict.ruleId,
47
- status: verdict.status
48
- };
49
- if (res.status && res.json) {
50
- res.status(statusCode).json(body);
51
- } else if (res.send) {
52
- res.statusCode = statusCode;
53
- res.send(JSON.stringify(body));
54
- } else if (res.end) {
55
- res.statusCode = statusCode;
56
- res.end();
57
- }
58
- }
59
- async function createGovernanceMiddleware(worldPath, options) {
60
- const world = await loadWorld(worldPath);
61
- return createGovernanceMiddlewareFromWorld(world, options);
62
- }
63
- function createGovernanceMiddlewareFromWorld(world, options = {}) {
64
- const engineOptions = {
65
- trace: options.trace ?? false,
66
- level: options.level
67
- };
68
- const mapRequest = options.mapRequest ?? defaultMapRequest;
69
- const blockStatusCode = options.blockStatusCode ?? 403;
70
- return async function neuroVerseGovernance(req, res, next) {
71
- try {
72
- const event = mapRequest(req);
73
- const verdict = evaluateGuard(event, world, engineOptions);
74
- options.onEvaluate?.(verdict, event, req);
75
- if (verdict.status === "ALLOW") {
76
- next();
77
- return;
78
- }
79
- if (verdict.status === "PAUSE") {
80
- const approved = await options.onPause?.(verdict, req);
81
- if (approved) {
82
- next();
83
- return;
84
- }
85
- }
86
- if (options.onBlock) {
87
- options.onBlock(verdict, req, res);
88
- } else {
89
- defaultOnBlock(verdict, req, res, blockStatusCode);
90
- }
91
- } catch (err) {
92
- next(err);
93
- }
94
- };
95
- }
96
-
97
- export {
98
- createGovernanceMiddleware,
99
- createGovernanceMiddlewareFromWorld
100
- };
@@ -1,131 +0,0 @@
1
- import {
2
- evaluateGuard
3
- } from "./chunk-4JRYGIO7.js";
4
- import {
5
- advancePlan,
6
- evaluatePlan,
7
- getPlanProgress
8
- } from "./chunk-4QXB6PEO.js";
9
- import {
10
- loadWorld
11
- } from "./chunk-JZPQGIKR.js";
12
-
13
- // src/adapters/openclaw.ts
14
- var GovernanceBlockedError = class extends Error {
15
- verdict;
16
- action;
17
- constructor(verdict, action) {
18
- super(`[NeuroVerse] BLOCKED: ${verdict.reason ?? verdict.ruleId ?? "governance rule"}`);
19
- this.name = "GovernanceBlockedError";
20
- this.verdict = verdict;
21
- this.action = action;
22
- }
23
- };
24
- function defaultMapAction(action, direction) {
25
- return {
26
- intent: action.type,
27
- tool: action.tool ?? action.type,
28
- args: action.input,
29
- direction,
30
- scope: typeof action.input?.path === "string" ? action.input.path : typeof action.input?.url === "string" ? action.input.url : void 0
31
- };
32
- }
33
- var NeuroVersePlugin = class {
34
- name = "neuroverse-governance";
35
- world;
36
- options;
37
- engineOptions;
38
- mapAction;
39
- activePlan;
40
- constructor(world, options = {}) {
41
- this.world = world;
42
- this.options = options;
43
- this.activePlan = options.plan;
44
- this.engineOptions = {
45
- trace: options.trace ?? false,
46
- level: options.level,
47
- plan: this.activePlan
48
- };
49
- this.mapAction = options.mapAction ?? defaultMapAction;
50
- }
51
- /**
52
- * Evaluate an action before execution.
53
- *
54
- * @throws GovernanceBlockedError if BLOCKED
55
- * @returns HookResult with verdict details
56
- */
57
- beforeAction(action) {
58
- const event = this.mapAction(action, "input");
59
- this.engineOptions.plan = this.activePlan;
60
- const verdict = evaluateGuard(event, this.world, this.engineOptions);
61
- const result = {
62
- allowed: verdict.status === "ALLOW",
63
- verdict,
64
- action
65
- };
66
- this.options.onEvaluate?.(result);
67
- if (verdict.status === "BLOCK") {
68
- throw new GovernanceBlockedError(verdict, action);
69
- }
70
- if (verdict.status === "ALLOW" && this.activePlan) {
71
- const planVerdict = evaluatePlan(event, this.activePlan);
72
- if (planVerdict.matchedStep) {
73
- const advResult = advancePlan(this.activePlan, planVerdict.matchedStep);
74
- if (advResult.success && advResult.plan) {
75
- this.activePlan = advResult.plan;
76
- this.engineOptions.plan = this.activePlan;
77
- }
78
- const progress = getPlanProgress(this.activePlan);
79
- this.options.onPlanProgress?.(progress);
80
- if (progress.completed === progress.total) {
81
- this.options.onPlanComplete?.();
82
- }
83
- }
84
- }
85
- return result;
86
- }
87
- /**
88
- * Evaluate an action's output (post-execution governance).
89
- * Only runs if evaluateOutputs is enabled.
90
- *
91
- * @returns HookResult or null if output evaluation is disabled
92
- */
93
- afterAction(action, _output) {
94
- if (!this.options.evaluateOutputs) return null;
95
- const event = this.mapAction(action, "output");
96
- const verdict = evaluateGuard(event, this.world, this.engineOptions);
97
- const result = {
98
- allowed: verdict.status === "ALLOW",
99
- verdict,
100
- action
101
- };
102
- this.options.onEvaluate?.(result);
103
- if (verdict.status === "BLOCK") {
104
- throw new GovernanceBlockedError(verdict, action);
105
- }
106
- return result;
107
- }
108
- /**
109
- * Get the plugin hooks object for agent.use().
110
- */
111
- hooks() {
112
- return {
113
- beforeAction: (action) => this.beforeAction(action),
114
- afterAction: (action, output) => this.afterAction(action, output)
115
- };
116
- }
117
- };
118
- async function createNeuroVersePlugin(worldPath, options) {
119
- const world = await loadWorld(worldPath);
120
- return new NeuroVersePlugin(world, options);
121
- }
122
- function createNeuroVersePluginFromWorld(world, options) {
123
- return new NeuroVersePlugin(world, options);
124
- }
125
-
126
- export {
127
- GovernanceBlockedError,
128
- NeuroVersePlugin,
129
- createNeuroVersePlugin,
130
- createNeuroVersePluginFromWorld
131
- };
@@ -1,324 +0,0 @@
1
- import {
2
- evaluateGuard
3
- } from "./chunk-4JRYGIO7.js";
4
- import {
5
- advancePlan,
6
- evaluatePlan,
7
- getPlanProgress
8
- } from "./chunk-4QXB6PEO.js";
9
- import {
10
- loadWorld
11
- } from "./chunk-JZPQGIKR.js";
12
-
13
- // src/runtime/session.ts
14
- async function defaultToolExecutor(name, args) {
15
- return `Tool "${name}" executed successfully with args: ${JSON.stringify(args)}`;
16
- }
17
- var SessionManager = class {
18
- config;
19
- state;
20
- engineOptions;
21
- executor;
22
- constructor(config) {
23
- this.config = config;
24
- this.executor = config.toolExecutor ?? defaultToolExecutor;
25
- this.engineOptions = {
26
- trace: config.trace ?? false,
27
- level: config.level,
28
- plan: config.plan
29
- };
30
- this.state = {
31
- active: false,
32
- world: config.world,
33
- plan: config.plan,
34
- progress: config.plan ? getPlanProgress(config.plan) : void 0,
35
- actionsEvaluated: 0,
36
- actionsAllowed: 0,
37
- actionsBlocked: 0,
38
- actionsPaused: 0
39
- };
40
- }
41
- /**
42
- * Initialize the session — load world from disk if needed.
43
- */
44
- async start() {
45
- if (this.config.worldPath && !this.config.world) {
46
- this.state.world = await loadWorld(this.config.worldPath);
47
- }
48
- if (!this.state.world) {
49
- throw new Error("No world provided. Use --world or pass a world definition.");
50
- }
51
- this.state.active = true;
52
- return this.getState();
53
- }
54
- /**
55
- * Evaluate a single event against governance.
56
- * Returns the verdict without executing anything.
57
- */
58
- evaluate(event) {
59
- this.engineOptions.plan = this.state.plan;
60
- const verdict = evaluateGuard(event, this.state.world, this.engineOptions);
61
- this.state.actionsEvaluated++;
62
- if (verdict.status === "ALLOW") this.state.actionsAllowed++;
63
- if (verdict.status === "BLOCK") this.state.actionsBlocked++;
64
- if (verdict.status === "PAUSE") this.state.actionsPaused++;
65
- this.config.onVerdict?.(verdict, event);
66
- return verdict;
67
- }
68
- /**
69
- * Evaluate and execute a tool call.
70
- * Returns the execution result or block reason.
71
- */
72
- async executeToolCall(toolCall) {
73
- let args;
74
- try {
75
- args = JSON.parse(toolCall.function.arguments);
76
- } catch {
77
- args = { raw: toolCall.function.arguments };
78
- }
79
- const event = {
80
- intent: toolCall.function.name,
81
- tool: toolCall.function.name,
82
- args,
83
- direction: "input"
84
- };
85
- const verdict = this.evaluate(event);
86
- if (verdict.status === "BLOCK") {
87
- return { allowed: false, verdict };
88
- }
89
- if (verdict.status === "PAUSE") {
90
- return { allowed: false, verdict };
91
- }
92
- const result = await this.executor(toolCall.function.name, args);
93
- this.config.onToolResult?.(toolCall.function.name, result);
94
- if (this.state.plan) {
95
- const planVerdict = evaluatePlan(event, this.state.plan);
96
- if (planVerdict.matchedStep) {
97
- const advResult = advancePlan(this.state.plan, planVerdict.matchedStep);
98
- if (advResult.success && advResult.plan) {
99
- this.state.plan = advResult.plan;
100
- this.engineOptions.plan = this.state.plan;
101
- }
102
- this.state.progress = getPlanProgress(this.state.plan);
103
- this.config.onPlanProgress?.(this.state.progress);
104
- if (this.state.progress.completed === this.state.progress.total) {
105
- this.config.onPlanComplete?.();
106
- }
107
- }
108
- }
109
- return { allowed: true, verdict, result };
110
- }
111
- /**
112
- * Process a model response — evaluate and execute all tool calls.
113
- * Returns results for each tool call.
114
- */
115
- async processModelResponse(response, model) {
116
- if (response.toolCalls.length === 0) {
117
- return response;
118
- }
119
- for (const toolCall of response.toolCalls) {
120
- const { allowed, verdict, result } = await this.executeToolCall(toolCall);
121
- if (allowed && result) {
122
- const nextResponse = await model.sendToolResult(toolCall.id, result);
123
- if (nextResponse.toolCalls.length > 0) {
124
- return this.processModelResponse(nextResponse, model);
125
- }
126
- return nextResponse;
127
- } else {
128
- const reason = verdict.reason ?? "Action blocked by governance.";
129
- const nextResponse = await model.sendBlockedResult(toolCall.id, reason);
130
- if (nextResponse.toolCalls.length > 0) {
131
- return this.processModelResponse(nextResponse, model);
132
- }
133
- return nextResponse;
134
- }
135
- }
136
- return response;
137
- }
138
- /** Get current session state. */
139
- getState() {
140
- return { ...this.state };
141
- }
142
- /** Stop the session. */
143
- stop() {
144
- this.state.active = false;
145
- return this.getState();
146
- }
147
- };
148
- async function runPipeMode(config) {
149
- const session = new SessionManager(config);
150
- await session.start();
151
- const state = session.getState();
152
- process.stderr.write(`[neuroverse] Pipe mode active
153
- `);
154
- process.stderr.write(`[neuroverse] World: ${state.world.world.name}
155
- `);
156
- if (state.plan) {
157
- process.stderr.write(`[neuroverse] Plan: ${state.plan.plan_id} (${state.plan.objective})
158
- `);
159
- }
160
- return new Promise((resolve, reject) => {
161
- let buffer = "";
162
- process.stdin.setEncoding("utf-8");
163
- process.stdin.on("data", (chunk) => {
164
- buffer += chunk;
165
- const lines = buffer.split("\n");
166
- buffer = lines.pop() ?? "";
167
- for (const line of lines) {
168
- const trimmed = line.trim();
169
- if (!trimmed) continue;
170
- try {
171
- const event = JSON.parse(trimmed);
172
- if (!event.intent) {
173
- process.stderr.write(`[neuroverse] Warning: event missing "intent" field
174
- `);
175
- continue;
176
- }
177
- const verdict = session.evaluate(event);
178
- process.stdout.write(JSON.stringify(verdict) + "\n");
179
- } catch (err) {
180
- process.stderr.write(`[neuroverse] Error parsing line: ${err}
181
- `);
182
- }
183
- }
184
- });
185
- process.stdin.on("end", () => {
186
- if (buffer.trim()) {
187
- try {
188
- const event = JSON.parse(buffer.trim());
189
- if (event.intent) {
190
- const verdict = session.evaluate(event);
191
- process.stdout.write(JSON.stringify(verdict) + "\n");
192
- }
193
- } catch {
194
- }
195
- }
196
- const finalState = session.stop();
197
- process.stderr.write(
198
- `[neuroverse] Session complete: ${finalState.actionsEvaluated} evaluated, ${finalState.actionsAllowed} allowed, ${finalState.actionsBlocked} blocked, ${finalState.actionsPaused} paused
199
- `
200
- );
201
- resolve();
202
- });
203
- process.stdin.on("error", reject);
204
- });
205
- }
206
- async function runInteractiveMode(config, model) {
207
- const session = new SessionManager(config);
208
- await session.start();
209
- const state = session.getState();
210
- process.stdout.write("\n");
211
- process.stdout.write(` World: ${state.world.world.name}
212
- `);
213
- if (state.plan) {
214
- process.stdout.write(` Plan: ${state.plan.plan_id}
215
- `);
216
- process.stdout.write(` Goal: ${state.plan.objective}
217
- `);
218
- process.stdout.write(` Steps: ${state.progress?.total ?? 0}
219
- `);
220
- }
221
- process.stdout.write(` Type "exit" to end session.
222
- `);
223
- process.stdout.write("\n");
224
- const readline = await import("readline");
225
- const rl = readline.createInterface({
226
- input: process.stdin,
227
- output: process.stdout,
228
- prompt: "> "
229
- });
230
- const printProgress = () => {
231
- const s = session.getState();
232
- if (s.progress) {
233
- process.stdout.write(
234
- ` [plan: ${s.progress.completed}/${s.progress.total} (${s.progress.percentage}%)]
235
- `
236
- );
237
- }
238
- };
239
- rl.prompt();
240
- rl.on("line", async (input) => {
241
- const trimmed = input.trim();
242
- if (!trimmed) {
243
- rl.prompt();
244
- return;
245
- }
246
- if (trimmed === "exit" || trimmed === "quit") {
247
- const finalState = session.stop();
248
- process.stdout.write("\n");
249
- process.stdout.write(` Session complete.
250
- `);
251
- process.stdout.write(` Actions: ${finalState.actionsEvaluated} evaluated`);
252
- process.stdout.write(`, ${finalState.actionsAllowed} allowed`);
253
- process.stdout.write(`, ${finalState.actionsBlocked} blocked
254
- `);
255
- if (finalState.progress) {
256
- process.stdout.write(
257
- ` Plan: ${finalState.progress.completed}/${finalState.progress.total} steps completed
258
- `
259
- );
260
- }
261
- process.stdout.write("\n");
262
- rl.close();
263
- return;
264
- }
265
- if (trimmed === "status") {
266
- const s = session.getState();
267
- process.stdout.write(`
268
- World: ${s.world.world.name}
269
- `);
270
- process.stdout.write(` Actions: ${s.actionsEvaluated} evaluated
271
- `);
272
- process.stdout.write(` Allowed: ${s.actionsAllowed} | Blocked: ${s.actionsBlocked} | Paused: ${s.actionsPaused}
273
- `);
274
- if (s.progress && s.plan) {
275
- process.stdout.write(` Plan: ${s.plan.plan_id} \u2014 ${s.progress.completed}/${s.progress.total} (${s.progress.percentage}%)
276
- `);
277
- for (const step of s.plan.steps) {
278
- const icon = step.status === "completed" ? "[x]" : "[ ]";
279
- process.stdout.write(` ${icon} ${step.label}
280
- `);
281
- }
282
- }
283
- process.stdout.write("\n");
284
- rl.prompt();
285
- return;
286
- }
287
- try {
288
- const response = await model.chat(trimmed);
289
- if (response.toolCalls.length > 0) {
290
- const finalResponse = await session.processModelResponse(response, model);
291
- if (finalResponse.content) {
292
- process.stdout.write(`
293
- ${finalResponse.content}
294
-
295
- `);
296
- }
297
- printProgress();
298
- } else if (response.content) {
299
- process.stdout.write(`
300
- ${response.content}
301
-
302
- `);
303
- }
304
- } catch (err) {
305
- process.stderr.write(`
306
- Error: ${err}
307
-
308
- `);
309
- }
310
- rl.prompt();
311
- });
312
- rl.on("close", () => {
313
- session.stop();
314
- });
315
- return new Promise((resolve) => {
316
- rl.on("close", resolve);
317
- });
318
- }
319
-
320
- export {
321
- SessionManager,
322
- runPipeMode,
323
- runInteractiveMode
324
- };