qualiloop 0.1.0 → 0.2.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/connect.js CHANGED
@@ -18,7 +18,9 @@ const credential = (client, options, forProject) => {
18
18
  return { token: setupToken, project: forProject ? options.project : undefined };
19
19
  const token = client.token();
20
20
  if (!token) {
21
- throw new ApiError('Sign in with `qualiloop login`, or set QUALILOOP_SETUP_TOKEN from the project\'s Coding agent settings.', 401, EXIT.auth);
21
+ throw new ApiError(client.kind === 'cli'
22
+ ? 'Sign in with `qualiloop login`, or set QUALILOOP_SETUP_TOKEN from the project\'s Coding agent settings.'
23
+ : 'Not signed in: call sign_in, then qualiloop_status until it shows the user signed in. Or set QUALILOOP_SETUP_TOKEN from the project\'s Coding agent settings.', 401, EXIT.auth);
22
24
  }
23
25
  if (!forProject)
24
26
  return { token };
@@ -161,8 +163,38 @@ export const start = async (client, options) => {
161
163
  const env = await writeEnv(client, { project: project.number, file: options.file });
162
164
  return { project, created, default_set, env };
163
165
  };
166
+ export const MODES = ['endpoint', 'dify', 'async_session', 'browser', 'elevenlabs', 'gohighlevel'];
167
+ export const SECRET_FIELDS = {
168
+ observability: ['public_key', 'secret_key', 'api_key'],
169
+ elevenlabs: ['api_key'],
170
+ gohighlevel: ['private_token'],
171
+ browser: ['browserbase_context_id'],
172
+ };
173
+ export const resolveSecrets = (body, envFile) => {
174
+ for (const [block, names] of Object.entries(SECRET_FIELDS)) {
175
+ const section = body[block];
176
+ if (!section || typeof section !== 'object')
177
+ continue;
178
+ const fields = section;
179
+ for (const name of names) {
180
+ const variable = fields[`${name}_env`];
181
+ if (variable === undefined)
182
+ continue;
183
+ delete fields[`${name}_env`];
184
+ if (typeof variable !== 'string' || !variable) {
185
+ throw new ApiError(`${block}.${name}_env names the variable that holds ${block}.${name}.`, 400, EXIT.usage);
186
+ }
187
+ const value = readEnvValue(variable, envFile);
188
+ if (!value) {
189
+ throw new ApiError(`${variable} is not set in the environment${envFile ? ` or in ${envFile}` : ''}.`, 400, EXIT.usage);
190
+ }
191
+ fields[name] = value;
192
+ }
193
+ }
194
+ };
164
195
  export const saveTarget = async (client, options, input) => {
165
196
  const { auth_header_name, auth_header_env, auth_header_prefix, env_file, ...body } = input;
197
+ resolveSecrets(body, env_file);
166
198
  if (auth_header_name && auth_header_env) {
167
199
  const value = readEnvValue(auth_header_env, env_file);
168
200
  if (!value) {
@@ -176,6 +208,68 @@ export const saveTarget = async (client, options, input) => {
176
208
  });
177
209
  return saved;
178
210
  };
211
+ export const updateTarget = async (client, options, settings, nothingGiven = 'Give at least one setting to change.') => {
212
+ const body = Object.fromEntries(Object.entries(settings).filter(([, value]) => value !== undefined));
213
+ if (!Object.keys(body).length)
214
+ throw new ApiError(nothingGiven, 400, EXIT.usage);
215
+ const current = await call(client, 'GET', '/project', options);
216
+ if (!current.target) {
217
+ throw new ApiError('No connection is saved for this project yet. Save it first, with these settings in the same request if you like.', 400, EXIT.usage);
218
+ }
219
+ return call(client, 'PUT', '/target', { ...options, body });
220
+ };
221
+ export const targetAddress = (target) => {
222
+ if (!target)
223
+ return 'none yet';
224
+ const block = (name) => (target[name] ?? {});
225
+ switch (target.mode) {
226
+ case 'browser':
227
+ return `browser, ${String(block('browser').chat_page_url ?? '')}`;
228
+ case 'elevenlabs': {
229
+ const agent = block('elevenlabs');
230
+ return `ElevenLabs agent ${String(agent.agent_name || agent.agent_id || '')}`.trim();
231
+ }
232
+ case 'gohighlevel':
233
+ return `GoHighLevel location ${String(block('gohighlevel').location_id ?? '')}`;
234
+ case 'async_session':
235
+ return 'session endpoint';
236
+ case 'dify':
237
+ return `Dify, ${String(target.base_url ?? '')}`;
238
+ default:
239
+ return String(target.base_url ?? '');
240
+ }
241
+ };
242
+ export const setLimits = async (client, options, limits) => {
243
+ if (limits.max_parallel_conversations === undefined && limits.reply_timeout_seconds === undefined) {
244
+ const current = await call(client, 'GET', '/project', options);
245
+ return { project: current.project, target: current.target ?? null };
246
+ }
247
+ return updateTarget(client, options, { max_parallel_conversations: limits.max_parallel_conversations, reply_timeout_seconds: limits.reply_timeout_seconds }, 'Give the conversations at once, the reply timeout, or both.');
248
+ };
249
+ export const setTraces = async (client, options, settings) => {
250
+ const timing = {
251
+ trace_fetch_delay_seconds: settings.delay_seconds,
252
+ trace_fetch_interval_seconds: settings.interval_seconds,
253
+ trace_fetch_max_wait_seconds: settings.max_wait_seconds,
254
+ };
255
+ const timingGiven = Object.values(timing).some((value) => value !== undefined);
256
+ if (settings.enabled === undefined && !timingGiven) {
257
+ throw new ApiError('Say on or off, or give the delay, the interval or the max wait.', 400, EXIT.usage);
258
+ }
259
+ const result = {};
260
+ if (settings.enabled !== undefined) {
261
+ const updated = await updateProject(client, options, { traces_disabled: !settings.enabled });
262
+ const project = updated.project;
263
+ result.project = { number: project.number, name: project.name };
264
+ result.traces_disabled = project.traces_disabled ?? !settings.enabled;
265
+ }
266
+ if (timingGiven) {
267
+ const saved = await updateTarget(client, options, timing);
268
+ result.project = saved.project;
269
+ result.target = saved.target;
270
+ }
271
+ return result;
272
+ };
179
273
  export const saveKnowledge = (client, options, body, overwrite) => {
180
274
  const payload = overwrite && body && typeof body === 'object' ? { ...body, overwrite: true } : body;
181
275
  return call(client, 'PUT', '/knowledge', { ...options, body: payload });
@@ -225,7 +319,10 @@ export const knowledgeRender = (result) => {
225
319
  return lines.join('\n');
226
320
  };
227
321
  export const TRACE_FIELDS_GONE = 'Trace fields are no longer needed: QualiLoop reads the system prompts and tools from each trace by their role. Send the prompts with `qualiloop connect knowledge --file <json>`.';
228
- export const setLive = (client, options, body) => call(client, 'PUT', '/live', { ...options, body });
322
+ export const setLive = (client, options, settings) => call(client, 'PUT', '/live', {
323
+ ...options,
324
+ body: Object.fromEntries(Object.entries(settings).filter(([, value]) => value !== undefined)),
325
+ });
229
326
  export const checkTraces = (client, options, sessionId) => call(client, 'POST', '/check-traces', {
230
327
  ...options,
231
328
  body: { session_id: sessionId },
package/dist/export.js ADDED
@@ -0,0 +1,114 @@
1
+ import { ApiError, EXIT } from './api.js';
2
+ const lines = (items, row) => items.map((item) => JSON.stringify(row(item))).join('\n');
3
+ const quoted = (value) => `"${value.replace(/"/g, '""')}"`;
4
+ export const EXPORT_FORMATS = [
5
+ {
6
+ id: 'openai-chat-jsonl',
7
+ label: 'OpenAI Chat JSONL',
8
+ extension: 'jsonl',
9
+ render: (items) => lines(items, (item) => ({
10
+ messages: [
11
+ { role: 'user', content: item.user_msg },
12
+ { role: 'assistant', content: item.human_gold_answer },
13
+ ],
14
+ metadata: {
15
+ conversation_id: item.conversation_id,
16
+ turn_index: item.turn_index,
17
+ guardrails_violation: item.guardrails_violation,
18
+ },
19
+ })),
20
+ },
21
+ {
22
+ id: 'openai-completion-jsonl',
23
+ label: 'OpenAI Completion JSONL',
24
+ extension: 'jsonl',
25
+ render: (items) => lines(items, (item) => ({ prompt: `${item.user_msg}\nAI:`, completion: ` ${item.human_gold_answer}\n` })),
26
+ },
27
+ {
28
+ id: 'anthropic-jsonl',
29
+ label: 'Anthropic Claude JSONL',
30
+ extension: 'jsonl',
31
+ render: (items) => lines(items, (item) => ({
32
+ system: 'You are a helpful assistant.',
33
+ input: item.user_msg,
34
+ output: item.human_gold_answer,
35
+ metadata: { conversation_id: item.conversation_id },
36
+ })),
37
+ },
38
+ {
39
+ id: 'csv',
40
+ label: 'CSV (prompt, completion)',
41
+ extension: 'csv',
42
+ render: (items) => [
43
+ 'conversation_id,turn_index,prompt,completion',
44
+ ...items.map((item) => [quoted(item.conversation_id), item.turn_index, quoted(item.user_msg), quoted(item.human_gold_answer)].join(',')),
45
+ ].join('\n'),
46
+ },
47
+ {
48
+ id: 'tsv',
49
+ label: 'TSV (prompt, completion)',
50
+ extension: 'tsv',
51
+ render: (items) => [
52
+ 'conversation_id\tturn_index\tprompt\tcompletion',
53
+ ...items.map((item) => `${item.conversation_id}\t${item.turn_index}\t${item.user_msg}\t${item.human_gold_answer}`),
54
+ ].join('\n'),
55
+ },
56
+ {
57
+ id: 'qa-json',
58
+ label: 'QA JSON array',
59
+ extension: 'json',
60
+ render: (items) => JSON.stringify(items.map((item) => ({ question: item.user_msg, answer: item.human_gold_answer })), null, 2),
61
+ },
62
+ {
63
+ id: 'prompt-completion',
64
+ label: 'Prompt + Completion plain text',
65
+ extension: 'txt',
66
+ render: (items) => items.map((item) => `Prompt:\n${item.user_msg}\n\nCompletion:\n${item.human_gold_answer}\n----`).join('\n'),
67
+ },
68
+ {
69
+ id: 'instruction-json',
70
+ label: 'Instruction JSON (instruction/input/output)',
71
+ extension: 'jsonl',
72
+ render: (items) => lines(items, (item) => ({ instruction: item.user_msg, input: '', output: item.human_gold_answer })),
73
+ },
74
+ {
75
+ id: 'cot-jsonl',
76
+ label: 'Chain-of-thought JSONL',
77
+ extension: 'jsonl',
78
+ render: (items) => lines(items, (item) => ({
79
+ question: item.user_msg,
80
+ answer: item.human_gold_answer,
81
+ reasoning: '[[ADD_REASONING_HERE]]',
82
+ })),
83
+ },
84
+ {
85
+ id: 'json-batching',
86
+ label: 'Batch JSON',
87
+ extension: 'json',
88
+ render: (items) => JSON.stringify({ generated_at: new Date().toISOString(), total: items.length, pairs: items }, null, 2),
89
+ },
90
+ ];
91
+ const DATE = /^\d{4}-\d{2}-\d{2}$/;
92
+ export const dateOr = (given, daysBack) => {
93
+ if (given !== undefined) {
94
+ if (!DATE.test(given))
95
+ throw new ApiError(`${given} is not a date like 2026-11-17.`, 400, EXIT.usage);
96
+ return given;
97
+ }
98
+ const day = new Date();
99
+ day.setUTCDate(day.getUTCDate() - daysBack);
100
+ return day.toISOString().slice(0, 10);
101
+ };
102
+ export const exportFormat = (id) => {
103
+ const found = EXPORT_FORMATS.find((item) => item.id === id);
104
+ if (!found) {
105
+ throw new ApiError(`Unknown format ${id}. Formats: ${EXPORT_FORMATS.map((item) => item.id).join(', ')}.`, 400, EXIT.usage);
106
+ }
107
+ return found;
108
+ };
109
+ export const fetchCorrectedPairs = async (client, project, from, to) => {
110
+ const shown = await client.action('get_project', { project });
111
+ const found = await client.request('GET', `/v1/projects/by-number/${shown.number}`);
112
+ const data = await client.request('GET', `/v1/export/project/${found.id}?start_date=${from}&end_date=${to}`);
113
+ return { number: shown.number, name: shown.name, items: data.items ?? [] };
114
+ };
@@ -11,21 +11,35 @@ import { compareBatch, waitForBatch } from '../workflows.js';
11
11
  export const LOCAL_INSTRUCTIONS = `Use these tools when the user asks to test their agent, read why a test or a release gate failed, look at the problems QualiLoop found, write or run tests, report a change to the agent, or connect an agent in this codebase to QualiLoop.
12
12
 
13
13
  - After changing the agent's system prompts, tools or documentation in the code: connect_save_agent_context with the new texts, which records the change; after changing anything else: report_change. Then run_suite (or run_tests), then wait_for_runs, then list_problems for the runs that failed, then get_conversation to read the evidence.
14
- - To connect an agent: connect_agent with the project the user named (it writes the key into .env and returns the steps), then follow the steps; use connect_write_env for keys, never print a key. Give every connect tool the project number (connect_projects lists them); each answer names the project it acted on. With QUALILOOP_SETUP_TOKEN set, the tools use that token's own project.
15
- - If a tool says you are not signed in, call sign_in and ask the user to approve it in the browser.`;
14
+ - To connect an agent: connect_agent with the project the user named (it writes the key into .env and returns the steps), then follow the steps; use connect_write_env for keys, never print a key. Give every connect tool the project number (connect_projects lists them); each answer names the project it acted on. With QUALILOOP_SETUP_TOKEN set, the tools use that token's own project. Once connect_check passes, go on with the steps' next steps: connect_set_limits fitted to the agent, the free first exploration, then offer to generate and run the Core suite.
15
+ - If a tool says you are not signed in, call sign_in and ask the user to approve it in the browser. Do not ask them to tell you when they are done: call qualiloop_status, which waits for the approval, until it shows them signed in.`;
16
16
  export const INSTRUCTIONS = [bundledGuide(), '## On this machine', LOCAL_INSTRUCTIONS]
17
17
  .filter(Boolean)
18
18
  .join('\n\n');
19
+ const STATUS_WAIT_SECONDS = 60;
20
+ const STATUS_WAIT_MAX_SECONDS = 300;
19
21
  const LOCAL_TOOLS = [
20
22
  {
21
23
  name: 'qualiloop_status',
22
- description: 'Who is signed in to which QualiLoop, and the default project. Call it first if a tool says you are not signed in, or to check that a sign_in finished.',
23
- inputSchema: { type: 'object', properties: {}, additionalProperties: false },
24
+ description: 'Who is signed in to which QualiLoop, and the default project. Call it first if a tool says you are not signed in, and after sign_in to wait for the approval: while a sign-in waits, it waits with it (up to wait_seconds) and answers once the user has approved.',
25
+ inputSchema: {
26
+ type: 'object',
27
+ properties: {
28
+ wait_seconds: {
29
+ type: 'integer',
30
+ minimum: 0,
31
+ maximum: STATUS_WAIT_MAX_SECONDS,
32
+ default: STATUS_WAIT_SECONDS,
33
+ description: 'While a sign-in waits for approval, most seconds to wait for it.',
34
+ },
35
+ },
36
+ additionalProperties: false,
37
+ },
24
38
  annotations: { readOnlyHint: true },
25
39
  },
26
40
  {
27
41
  name: 'sign_in',
28
- description: 'Sign this MCP server (and the qualiloop CLI) in to QualiLoop. Opens the approval page in the user\'s browser and returns the link and a code. Tell the user to approve it there and check the code; then call qualiloop_status until it shows them signed in.',
42
+ description: "Sign this MCP server (and the qualiloop CLI) in to QualiLoop. Opens the approval page in the user's browser and returns the link and a code. Tell the user to approve it there and check the code (a new user creates an account from that page first); then call qualiloop_status, which waits for the approval, until it shows them signed in. Do not ask the user to say when they are done.",
29
43
  inputSchema: { type: 'object', properties: {}, additionalProperties: false },
30
44
  },
31
45
  {
@@ -100,26 +114,76 @@ const LOCAL_TOOLS = [
100
114
  },
101
115
  {
102
116
  name: 'connect_save_target',
103
- description: 'Save the endpoint QualiLoop calls to test the agent, and where it reads traces. Never put a secret in the arguments: give auth_header_name and auth_header_env, the variable holding its value (read here from the environment or env_file). The other fields are those of PUT /v1/setup/target in the skill: response_text_path, payload_template, variables, unique_variables, start_conversation, observability, max_parallel_conversations, reply_timeout_seconds.',
117
+ description: "Save how QualiLoop reaches the agent, and where it reads traces. mode: endpoint (the default when base_url is given), dify (the app's Dify preset: Dify's chat address unless base_url names a self-hosted one, its request body, the API key as auth header Authorization), async_session (a session endpoint: async_session holds the protocol, with operations init and send), browser (QualiLoop types into the chat page: browser.chat_page_url and browser.input_selector), elevenlabs (elevenlabs.api_key and agent_id; QualiLoop reads the agent's prompt and success criteria) or gohighlevel (gohighlevel.private_token and location_id). Only the endpoint mode reads a trace source. Never put a secret in the arguments: give auth_header_name and auth_header_env for the header, and <field>_env in a block for its secret (elevenlabs.api_key_env, gohighlevel.private_token_env, browser.browserbase_context_id_env, observability.secret_key_env, observability.api_key_env), the variable holding it, read here from the environment or env_file. system_prompt and grounding_documentation (async_session and browser, which carry no trace) become the project's Connection settings sources. The other fields are those of PUT /v1/setup/target in the skill. Fields left out keep what is saved; with no mode and no base_url the saved connection's settings change.",
104
118
  inputSchema: {
105
119
  type: 'object',
106
120
  properties: {
107
121
  project: { type: 'integer', description: "The project's number." },
122
+ mode: { type: 'string', enum: ['endpoint', 'dify', 'async_session', 'browser', 'elevenlabs', 'gohighlevel'] },
108
123
  base_url: { type: 'string', description: 'The full address of the endpoint, reachable from the internet.' },
109
124
  auth_header_name: { type: 'string', description: 'Such as X-Agent-Secret or Authorization.' },
110
125
  auth_header_env: { type: 'string', description: 'The variable holding the header value, such as QUALILOOP_AGENT_SECRET.' },
111
126
  auth_header_prefix: { type: 'string', description: 'Put before the value, such as "Bearer ".' },
112
- env_file: { type: 'string', default: '.env', description: 'Where to read the variable when the environment lacks it.' },
127
+ env_file: { type: 'string', default: '.env', description: 'Where to read a variable when the environment lacks it.' },
113
128
  response_text_path: { type: 'string' },
114
129
  payload_template: { type: 'string' },
115
130
  variables: { type: 'object', additionalProperties: { type: 'array', items: { type: 'string' } } },
116
131
  unique_variables: { type: 'array', items: { type: 'string' } },
117
132
  start_conversation: { type: ['object', 'null'] },
118
- observability: { type: 'object' },
133
+ observability: {
134
+ type: 'object',
135
+ description: 'Endpoint mode only. Where traces are read: provider otel (QualiLoop tracing, the default), langfuse (host, public_key, secret_key_env), langsmith (api_key_env, host, project) or none (no traces); session_id_path optional.',
136
+ },
119
137
  max_parallel_conversations: { type: 'integer' },
120
138
  reply_timeout_seconds: { type: 'integer' },
139
+ name: { type: 'string', minLength: 3, description: "The agent's name, as the connection settings show it." },
140
+ trace_fetch_delay_seconds: { type: 'integer', minimum: 0, maximum: 120 },
141
+ trace_fetch_interval_seconds: { type: 'integer', minimum: 1, maximum: 60 },
142
+ trace_fetch_max_wait_seconds: { type: 'integer', minimum: 0, maximum: 600 },
143
+ async_session: { type: 'object', description: 'async_session mode: the session protocol, with operations init and send.' },
144
+ system_prompt: { type: 'string', description: "async_session and browser modes: the agent's system prompt, verbatim." },
145
+ grounding_documentation: { type: 'string', description: 'async_session and browser modes: the documents the agent answers from.' },
146
+ browser: {
147
+ type: 'object',
148
+ description: 'browser mode: chat_page_url, input_selector, send_button_selector, submit_method (auto, enter_key, button), wait_timeout_seconds (5 to 300), browserbase_context_id_env.',
149
+ },
150
+ elevenlabs: {
151
+ type: 'object',
152
+ description: 'elevenlabs mode: api_key_env, agent_id, region (global, us, eu, in, sg), default_voice_id, max_reply_ms (0 turns the slow reply check off). Giving agent_id again reads the agent afresh.',
153
+ },
154
+ gohighlevel: {
155
+ type: 'object',
156
+ description: 'gohighlevel mode: private_token_env, location_id, channel (Live_Chat, WhatsApp, SMS, Instagram, Facebook), agent_id, reply_timeout_seconds (10 to 300), poll_interval_seconds (1 to 30), observability_enabled.',
157
+ },
158
+ },
159
+ additionalProperties: false,
160
+ },
161
+ },
162
+ {
163
+ name: 'connect_set_limits',
164
+ description: "Set how hard QualiLoop drives the saved endpoint, to fit what the agent can take: max_parallel_conversations, the most conversations at once (0 removes the limit), and reply_timeout_seconds, the most seconds one reply may take. Give one or both; every other setting of the endpoint stays. Give neither to read the saved values. Set them before the first exploration or tests.",
165
+ inputSchema: {
166
+ type: 'object',
167
+ properties: {
168
+ project: { type: 'integer', description: "The project's number." },
169
+ max_parallel_conversations: { type: 'integer', minimum: 0, maximum: 100 },
170
+ reply_timeout_seconds: { type: 'integer', minimum: 1, maximum: 600 },
171
+ },
172
+ additionalProperties: false,
173
+ },
174
+ },
175
+ {
176
+ name: 'connect_set_traces',
177
+ description: "Whether scoring uses the agent's traces, and how long QualiLoop waits for a conversation's traces once its last turn is done. enabled false scores without traces (admins). The timing changes the saved endpoint only: the first look after delay_seconds, then one every interval_seconds, stopping after max_wait_seconds. Give any of them; the rest stays.",
178
+ inputSchema: {
179
+ type: 'object',
180
+ properties: {
181
+ project: { type: 'integer', description: "The project's number." },
182
+ enabled: { type: 'boolean' },
183
+ delay_seconds: { type: 'integer', minimum: 0, maximum: 120 },
184
+ interval_seconds: { type: 'integer', minimum: 1, maximum: 60 },
185
+ max_wait_seconds: { type: 'integer', minimum: 0, maximum: 600 },
121
186
  },
122
- required: ['base_url'],
123
187
  additionalProperties: false,
124
188
  },
125
189
  },
@@ -207,12 +271,19 @@ const LOCAL_TOOLS = [
207
271
  },
208
272
  {
209
273
  name: 'connect_set_live',
210
- description: "Turn the project's live traffic on or off: real users' conversations, sent through QualiLoop tracing, recorded and judged. Ask the user first; it sends real users' data. Admins only.",
274
+ description: "Turn the project's live traffic on or off: real users' conversations, sent through QualiLoop tracing, recorded and judged. Ask the user first; it sends real users' data. Admins only. Only when the user asks about how much is stored or scored: collect_percent, scoring_enabled, score_percent, and limits per day, week or month (turn_limit for stored turns, score_limit for scored conversations; null removes a limit). Left out, what is saved stays.",
211
275
  inputSchema: {
212
276
  type: 'object',
213
277
  properties: {
214
278
  project: { type: 'integer', description: "The project's number." },
215
279
  enabled: { type: 'boolean' },
280
+ collect_percent: { type: 'integer', minimum: 0, maximum: 100, description: 'Share of new live conversations stored.' },
281
+ scoring_enabled: { type: 'boolean', description: 'Score stored live conversations.' },
282
+ score_percent: { type: 'integer', minimum: 0, maximum: 100, description: 'Share of stored live conversations scored.' },
283
+ turn_limit: { type: ['integer', 'null'], minimum: 0, description: 'The most live turns stored per period; null removes the limit.' },
284
+ turn_limit_period: { type: 'string', enum: ['day', 'week', 'month'] },
285
+ score_limit: { type: ['integer', 'null'], minimum: 0, description: 'The most live conversations scored per period; null removes the limit.' },
286
+ score_limit_period: { type: 'string', enum: ['day', 'week', 'month'] },
216
287
  },
217
288
  required: ['enabled'],
218
289
  additionalProperties: false,
@@ -274,6 +345,18 @@ export const createServer = (client = new QualiloopClient()) => {
274
345
  const named = args.project;
275
346
  switch (name) {
276
347
  case 'qualiloop_status': {
348
+ const waiting = pendingSignIn;
349
+ if (!client.isSignedIn() && waiting?.settled && !waiting.error) {
350
+ const seconds = Math.min(STATUS_WAIT_MAX_SECONDS, Math.max(0, Number(args.wait_seconds ?? STATUS_WAIT_SECONDS)));
351
+ let timer;
352
+ await Promise.race([
353
+ waiting.settled,
354
+ new Promise((resolve) => {
355
+ timer = setTimeout(resolve, seconds * 1000);
356
+ }),
357
+ ]);
358
+ clearTimeout(timer);
359
+ }
277
360
  const stored = storedCredentials(client.url);
278
361
  if (!client.isSignedIn()) {
279
362
  return {
@@ -282,7 +365,7 @@ export const createServer = (client = new QualiloopClient()) => {
282
365
  sign_in: pendingSignIn?.error
283
366
  ? `The last sign-in failed: ${pendingSignIn.error}`
284
367
  : pendingSignIn
285
- ? `Waiting for approval at ${pendingSignIn.url} (code ${pendingSignIn.code}).`
368
+ ? `Waiting for approval at ${pendingSignIn.url} (code ${pendingSignIn.code}). Call qualiloop_status again; do not ask the user to say when they are done.`
286
369
  : 'Call sign_in.',
287
370
  };
288
371
  }
@@ -301,12 +384,13 @@ export const createServer = (client = new QualiloopClient()) => {
301
384
  if (client.isSignedIn())
302
385
  return { signed_in: true, url: client.url };
303
386
  pendingSignIn = {};
387
+ let settled = Promise.resolve();
304
388
  const started = new Promise((resolve) => {
305
- login(client, {
389
+ settled = login(client, {
306
390
  client: 'mcp',
307
391
  again: 'Call sign_in again.',
308
392
  onStarted: ({ url, code }) => {
309
- pendingSignIn = { url, code };
393
+ pendingSignIn = { url, code, settled };
310
394
  resolve(pendingSignIn);
311
395
  },
312
396
  }).then(() => {
@@ -323,7 +407,7 @@ export const createServer = (client = new QualiloopClient()) => {
323
407
  return {
324
408
  approve_at: pending.url,
325
409
  code: pending.code,
326
- next_step: 'Ask the user to open the link (it opened in their browser if one is available), check that the page shows this code, and approve. Then call qualiloop_status.',
410
+ next_step: 'Tell the user to open the link (it opened in their browser if one is available), check that the page shows this code, and approve; with no account yet, they create one from that page. Do not ask them to tell you when they are done: call qualiloop_status now, which waits up to a minute for the approval, and again each time it answers signed_in false.',
327
411
  };
328
412
  }
329
413
  case 'wait_for_runs': {
@@ -384,6 +468,11 @@ export const createServer = (client = new QualiloopClient()) => {
384
468
  env_file: insideWorkspace(String(env_file ?? '.env')),
385
469
  });
386
470
  }
471
+ case 'connect_set_limits':
472
+ return connect.setLimits(client, { project: named }, {
473
+ max_parallel_conversations: args.max_parallel_conversations,
474
+ reply_timeout_seconds: args.reply_timeout_seconds,
475
+ });
387
476
  case 'connect_save_agent_context': {
388
477
  const { project: _ignored, file, overwrite, ...inline } = args;
389
478
  const body = file ? connect.readJson(insideWorkspace(String(file))) : inline;
@@ -393,8 +482,20 @@ export const createServer = (client = new QualiloopClient()) => {
393
482
  return connect.checkTraces(client, { project: named }, String(args.session_id));
394
483
  case 'connect_check':
395
484
  return connect.check(client, { project: named });
396
- case 'connect_set_live':
397
- return connect.setLive(client, { project: named }, { enabled: Boolean(args.enabled) });
485
+ case 'connect_set_live': {
486
+ const { project: _ignored, enabled, ...limits } = args;
487
+ return connect.setLive(client, { project: named }, {
488
+ ...limits,
489
+ enabled: Boolean(enabled),
490
+ });
491
+ }
492
+ case 'connect_set_traces':
493
+ return connect.setTraces(client, { project: named }, {
494
+ enabled: args.enabled,
495
+ delay_seconds: args.delay_seconds,
496
+ interval_seconds: args.interval_seconds,
497
+ max_wait_seconds: args.max_wait_seconds,
498
+ });
398
499
  default:
399
500
  throw new Error(`Unknown tool ${name}.`);
400
501
  }
package/package.json CHANGED
@@ -1,48 +1,49 @@
1
- {
2
- "name": "qualiloop",
3
- "version": "0.1.0",
4
- "description": "QualiLoop from the terminal, scripts, CI and coding agents: run tests and release gates, read problems, write tests. The qualiloop CLI and its MCP server.",
5
- "license": "Apache-2.0",
6
- "homepage": "https://www.qualiloop.com",
7
- "keywords": [
8
- "qualiloop",
9
- "ai-agent",
10
- "llm",
11
- "testing",
12
- "evaluation",
13
- "release-gate",
14
- "ci",
15
- "cli",
16
- "mcp",
17
- "mcp-server"
18
- ],
19
- "type": "module",
20
- "bin": {
21
- "qualiloop": "dist/cli.js",
22
- "ql": "dist/cli.js"
23
- },
24
- "files": [
25
- "dist",
26
- "README.md",
27
- "LICENSE"
28
- ],
29
- "scripts": {
30
- "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
31
- "build": "npm run clean && tsc -p tsconfig.json && node scripts/copy-catalog.mjs",
32
- "type-check": "tsc -p tsconfig.json --noEmit",
33
- "test": "npm run build && node --test test/unit.test.mjs test/smoke.test.mjs",
34
- "start": "node dist/cli.js",
35
- "prepack": "npm run build"
36
- },
37
- "engines": {
38
- "node": ">=20"
39
- },
40
- "dependencies": {
41
- "@modelcontextprotocol/sdk": "1.32.1",
42
- "commander": "14.0.3"
43
- },
44
- "devDependencies": {
45
- "@types/node": "22.20.5",
46
- "typescript": "5.9.3"
47
- }
48
- }
1
+ {
2
+ "name": "qualiloop",
3
+ "version": "0.2.0",
4
+ "mcpName": "com.qualiloop/qualiloop",
5
+ "description": "QualiLoop from the terminal, scripts, CI and coding agents: run tests and release gates, read problems, write tests. The qualiloop CLI and its MCP server.",
6
+ "license": "Apache-2.0",
7
+ "homepage": "https://www.qualiloop.com",
8
+ "keywords": [
9
+ "qualiloop",
10
+ "ai-agent",
11
+ "llm",
12
+ "testing",
13
+ "evaluation",
14
+ "release-gate",
15
+ "ci",
16
+ "cli",
17
+ "mcp",
18
+ "mcp-server"
19
+ ],
20
+ "type": "module",
21
+ "bin": {
22
+ "qualiloop": "dist/cli.js",
23
+ "ql": "dist/cli.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "scripts": {
31
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
32
+ "build": "npm run clean && tsc -p tsconfig.json && node scripts/copy-catalog.mjs",
33
+ "type-check": "tsc -p tsconfig.json --noEmit",
34
+ "test": "npm run build && node --test test/unit.test.mjs test/smoke.test.mjs",
35
+ "start": "node dist/cli.js",
36
+ "prepack": "npm run build"
37
+ },
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "1.32.1",
43
+ "commander": "14.0.3"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "22.20.5",
47
+ "typescript": "5.9.3"
48
+ }
49
+ }