@1presence/bridge 0.16.0 → 0.18.0
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/dist/claude.js +1 -1
- package/dist/config.js +63 -27
- package/package.json +1 -1
package/dist/claude.js
CHANGED
|
@@ -170,7 +170,7 @@ function spawnClaude(params) {
|
|
|
170
170
|
'--tools', '',
|
|
171
171
|
'--setting-sources', '',
|
|
172
172
|
'--allowedTools', 'mcp__1presence__*',
|
|
173
|
-
'--system-prompt', systemPromptPath,
|
|
173
|
+
'--system-prompt-file', systemPromptPath,
|
|
174
174
|
'--mcp-config', mcpConfigPath,
|
|
175
175
|
'--strict-mcp-config',
|
|
176
176
|
];
|
package/dist/config.js
CHANGED
|
@@ -90,45 +90,81 @@ const PROMPT_TIMEOUT_MS = 10_000;
|
|
|
90
90
|
const DEFAULT_OPTION_NUM = 1;
|
|
91
91
|
function promptForModel(defaultModel) {
|
|
92
92
|
return new Promise((resolve) => {
|
|
93
|
-
const
|
|
93
|
+
const initialIdx = Math.max(0, MODEL_OPTIONS.findIndex((o) => o.num === DEFAULT_OPTION_NUM));
|
|
94
|
+
let idx = initialIdx;
|
|
94
95
|
process.stdout.write('\nWhich Claude model should the bridge use?\n');
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
process.stdout.write(` (↑/↓ to move, Enter to select, 1–${MODEL_OPTIONS.length} to jump, auto-selects in ${PROMPT_TIMEOUT_MS / 1000}s)\n`);
|
|
97
|
+
let rendered = 0;
|
|
98
|
+
const render = () => {
|
|
99
|
+
if (rendered > 0)
|
|
100
|
+
process.stdout.write(`\x1b[${rendered}A`);
|
|
101
|
+
rendered = 0;
|
|
102
|
+
for (let i = 0; i < MODEL_OPTIONS.length; i++) {
|
|
103
|
+
const opt = MODEL_OPTIONS[i];
|
|
104
|
+
const active = i === idx;
|
|
105
|
+
const marker = active ? '›' : ' ';
|
|
106
|
+
const suffix = opt.num === 1 && defaultModel ? ` (${defaultModel})` : '';
|
|
107
|
+
const text = ` ${marker} ${opt.num}) ${opt.label}${suffix}`;
|
|
108
|
+
const line = active ? `\x1b[1;36m${text}\x1b[0m` : text;
|
|
109
|
+
process.stdout.write(`\x1b[2K${line}\n`);
|
|
110
|
+
rendered++;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
render();
|
|
114
|
+
(0, readline_1.emitKeypressEvents)(process.stdin);
|
|
115
|
+
const wasRaw = process.stdin.isRaw;
|
|
116
|
+
if (process.stdin.isTTY)
|
|
117
|
+
process.stdin.setRawMode(true);
|
|
118
|
+
process.stdin.resume();
|
|
102
119
|
let settled = false;
|
|
120
|
+
const cleanup = () => {
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
process.stdin.removeListener('keypress', onKey);
|
|
123
|
+
if (process.stdin.isTTY)
|
|
124
|
+
process.stdin.setRawMode(!!wasRaw);
|
|
125
|
+
process.stdin.pause();
|
|
126
|
+
};
|
|
103
127
|
const finish = (model) => {
|
|
104
128
|
if (settled)
|
|
105
129
|
return;
|
|
106
130
|
settled = true;
|
|
107
|
-
|
|
108
|
-
rl.close();
|
|
131
|
+
cleanup();
|
|
109
132
|
resolve(model);
|
|
110
133
|
};
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
process.stdout.write(`\n(timed out — using option ${DEFAULT_OPTION_NUM})\n`);
|
|
114
|
-
finish(def.model);
|
|
115
|
-
}, PROMPT_TIMEOUT_MS);
|
|
116
|
-
rl.question(' choice: ', (answer) => {
|
|
117
|
-
const trimmed = answer.trim();
|
|
118
|
-
if (!trimmed) {
|
|
119
|
-
const def = MODEL_OPTIONS.find((o) => o.num === DEFAULT_OPTION_NUM);
|
|
120
|
-
finish(def.model);
|
|
134
|
+
const onKey = (_str, key) => {
|
|
135
|
+
if (!key)
|
|
121
136
|
return;
|
|
137
|
+
if (key.ctrl && key.name === 'c') {
|
|
138
|
+
cleanup();
|
|
139
|
+
process.stdout.write('\n');
|
|
140
|
+
process.exit(130);
|
|
122
141
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
finish(opt.model);
|
|
142
|
+
if (key.name === 'up' || key.name === 'k') {
|
|
143
|
+
idx = (idx - 1 + MODEL_OPTIONS.length) % MODEL_OPTIONS.length;
|
|
144
|
+
render();
|
|
127
145
|
return;
|
|
128
146
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
147
|
+
if (key.name === 'down' || key.name === 'j') {
|
|
148
|
+
idx = (idx + 1) % MODEL_OPTIONS.length;
|
|
149
|
+
render();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (key.name === 'return' || key.name === 'enter') {
|
|
153
|
+
finish(MODEL_OPTIONS[idx].model);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const n = Number(key.sequence ?? '');
|
|
157
|
+
if (Number.isInteger(n) && n >= 1 && n <= MODEL_OPTIONS.length) {
|
|
158
|
+
idx = n - 1;
|
|
159
|
+
render();
|
|
160
|
+
finish(MODEL_OPTIONS[idx].model);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
process.stdin.on('keypress', onKey);
|
|
164
|
+
const timer = setTimeout(() => {
|
|
165
|
+
process.stdout.write(`\n(timed out — using option ${MODEL_OPTIONS[idx].num})\n`);
|
|
166
|
+
finish(MODEL_OPTIONS[idx].model);
|
|
167
|
+
}, PROMPT_TIMEOUT_MS);
|
|
132
168
|
});
|
|
133
169
|
}
|
|
134
170
|
/**
|