@honcho-ai/claude-honcho 0.3.3 → 0.4.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/.claude-plugin/plugin.json +1 -1
- package/README.md +111 -335
- package/dist/hooks/pre-tool-honcho.js +551 -605
- package/dist/hooks/pre-tool-honcho.js.map +11 -9
- package/dist/hooks/save-user-message.js +1741 -1057
- package/dist/hooks/save-user-message.js.map +24 -19
- package/dist/hooks/session-end.js +559 -617
- package/dist/hooks/session-end.js.map +11 -9
- package/dist/hooks/session-start.js +1938 -1304
- package/dist/hooks/session-start.js.map +31 -22
- package/dist/hooks/stop.js +1785 -1157
- package/dist/hooks/stop.js.map +25 -19
- package/dist/hooks/user-prompt.js +696 -16571
- package/dist/hooks/user-prompt.js.map +13 -90
- package/dist/mcp-server.js +1689 -1676
- package/dist/mcp-server.js.map +23 -20
- package/dist/skills/backfill-runner.js +1824 -911
- package/dist/skills/backfill-runner.js.map +27 -20
- package/dist/skills/{setup-runner.js → pane-runner.js} +1910 -1020
- package/dist/{hooks/pre-compact.js.map → skills/pane-runner.js.map} +28 -24
- package/dist/skills/status-runner.js +1568 -753
- package/dist/skills/status-runner.js.map +23 -19
- package/hooks/hooks.json +10 -42
- package/hooks/register.tsx +574 -0
- package/package.json +1 -1
- package/skills/insights/SKILL.md +3 -7
- package/dist/hooks/post-tool-use.js +0 -16905
- package/dist/hooks/post-tool-use.js.map +0 -97
- package/dist/hooks/pre-compact.js +0 -17087
- package/dist/skills/setup-runner.js.map +0 -95
- package/scripts/honcho-statusline.sh +0 -101
- package/skills/briefing/SKILL.md +0 -20
- package/skills/config/SKILL.md +0 -288
- package/skills/import/SKILL.md +0 -73
- package/skills/setup/SKILL.md +0 -60
- package/skills/status/SKILL.md +0 -30
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
@@ -36,8 +37,9 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
36
37
|
// node_modules/@honcho-ai/sdk/dist/api-version.js
|
|
37
38
|
var require_api_version = __commonJS(function(exports) {
|
|
38
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.API_VERSION = undefined;
|
|
40
|
+
exports.VERSION = exports.API_VERSION = undefined;
|
|
40
41
|
exports.API_VERSION = "v3";
|
|
42
|
+
exports.VERSION = "2.9.0";
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
// node_modules/@honcho-ai/sdk/dist/http/errors.js
|
|
@@ -162,255 +164,6 @@ var require_errors = __commonJS(function(exports) {
|
|
|
162
164
|
}
|
|
163
165
|
});
|
|
164
166
|
|
|
165
|
-
// node_modules/@honcho-ai/sdk/dist/http/client.js
|
|
166
|
-
var require_client = __commonJS(function(exports) {
|
|
167
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
168
|
-
exports.HonchoHTTPClient = undefined;
|
|
169
|
-
var errors_1 = require_errors();
|
|
170
|
-
var DEFAULT_TIMEOUT = 60000;
|
|
171
|
-
var DEFAULT_MAX_RETRIES = 2;
|
|
172
|
-
var RETRY_STATUS_CODES = [429, 500, 502, 503, 504];
|
|
173
|
-
var INITIAL_RETRY_DELAY = 500;
|
|
174
|
-
|
|
175
|
-
class HonchoHTTPClient {
|
|
176
|
-
constructor(config) {
|
|
177
|
-
this.baseURL = config.baseURL.replace(/\/$/, "");
|
|
178
|
-
this.apiKey = config.apiKey;
|
|
179
|
-
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
180
|
-
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
181
|
-
this.defaultHeaders = {
|
|
182
|
-
"Content-Type": "application/json",
|
|
183
|
-
...config.defaultHeaders
|
|
184
|
-
};
|
|
185
|
-
this.defaultQuery = config.defaultQuery;
|
|
186
|
-
}
|
|
187
|
-
async request(method, path, options = {}) {
|
|
188
|
-
const url = this.buildURL(path, options.query);
|
|
189
|
-
const headers = this.buildHeaders(options.headers);
|
|
190
|
-
const timeout = options.timeout ?? this.timeout;
|
|
191
|
-
let lastError;
|
|
192
|
-
let attempt = 0;
|
|
193
|
-
while (attempt <= this.maxRetries) {
|
|
194
|
-
try {
|
|
195
|
-
const response = await this.fetchWithTimeout(url, {
|
|
196
|
-
method,
|
|
197
|
-
headers,
|
|
198
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
199
|
-
signal: options.signal
|
|
200
|
-
}, timeout);
|
|
201
|
-
if (response.ok) {
|
|
202
|
-
const text = await response.text();
|
|
203
|
-
if (!text) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
return JSON.parse(text);
|
|
207
|
-
}
|
|
208
|
-
const errorBody = await this.parseErrorBody(response);
|
|
209
|
-
const retryAfter = this.parseRetryAfter(response);
|
|
210
|
-
const error = (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody, retryAfter);
|
|
211
|
-
if (RETRY_STATUS_CODES.includes(response.status) && attempt < this.maxRetries) {
|
|
212
|
-
lastError = error;
|
|
213
|
-
await this.sleep(this.getRetryDelay(attempt, retryAfter));
|
|
214
|
-
attempt++;
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
throw error;
|
|
218
|
-
} catch (error) {
|
|
219
|
-
if (error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
220
|
-
if (attempt < this.maxRetries) {
|
|
221
|
-
lastError = error;
|
|
222
|
-
await this.sleep(this.getRetryDelay(attempt));
|
|
223
|
-
attempt++;
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (error instanceof errors_1.RateLimitError || error instanceof errors_1.ServerError || error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
228
|
-
throw error;
|
|
229
|
-
}
|
|
230
|
-
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
231
|
-
const connError = new errors_1.ConnectionError(error.message);
|
|
232
|
-
if (attempt < this.maxRetries) {
|
|
233
|
-
lastError = connError;
|
|
234
|
-
await this.sleep(this.getRetryDelay(attempt));
|
|
235
|
-
attempt++;
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
throw connError;
|
|
239
|
-
}
|
|
240
|
-
throw error;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
throw lastError || new Error("Request failed after retries");
|
|
244
|
-
}
|
|
245
|
-
async get(path, options) {
|
|
246
|
-
return this.request("GET", path, options);
|
|
247
|
-
}
|
|
248
|
-
async post(path, options) {
|
|
249
|
-
return this.request("POST", path, options);
|
|
250
|
-
}
|
|
251
|
-
async put(path, options) {
|
|
252
|
-
return this.request("PUT", path, options);
|
|
253
|
-
}
|
|
254
|
-
async patch(path, options) {
|
|
255
|
-
return this.request("PATCH", path, options);
|
|
256
|
-
}
|
|
257
|
-
async delete(path, options) {
|
|
258
|
-
return this.request("DELETE", path, options);
|
|
259
|
-
}
|
|
260
|
-
async stream(method, path, options = {}) {
|
|
261
|
-
const url = this.buildURL(path, options.query);
|
|
262
|
-
const headers = {
|
|
263
|
-
...this.buildHeaders(options.headers),
|
|
264
|
-
Accept: "text/event-stream"
|
|
265
|
-
};
|
|
266
|
-
const timeout = options.timeout ?? this.timeout;
|
|
267
|
-
const response = await this.fetchWithTimeout(url, {
|
|
268
|
-
method,
|
|
269
|
-
headers,
|
|
270
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
271
|
-
signal: options.signal
|
|
272
|
-
}, timeout);
|
|
273
|
-
if (!response.ok) {
|
|
274
|
-
const errorBody = await this.parseErrorBody(response);
|
|
275
|
-
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
276
|
-
}
|
|
277
|
-
return response;
|
|
278
|
-
}
|
|
279
|
-
async upload(path, formData, options = {}) {
|
|
280
|
-
const url = this.buildURL(path, options.query);
|
|
281
|
-
const headers = {};
|
|
282
|
-
if (this.apiKey) {
|
|
283
|
-
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
284
|
-
}
|
|
285
|
-
if (options.headers) {
|
|
286
|
-
Object.assign(headers, options.headers);
|
|
287
|
-
}
|
|
288
|
-
const timeout = options.timeout ?? this.timeout;
|
|
289
|
-
const response = await this.fetchWithTimeout(url, {
|
|
290
|
-
method: "POST",
|
|
291
|
-
headers,
|
|
292
|
-
body: formData,
|
|
293
|
-
signal: options.signal
|
|
294
|
-
}, timeout);
|
|
295
|
-
if (!response.ok) {
|
|
296
|
-
const errorBody = await this.parseErrorBody(response);
|
|
297
|
-
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
298
|
-
}
|
|
299
|
-
const text = await response.text();
|
|
300
|
-
if (!text) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
return JSON.parse(text);
|
|
304
|
-
}
|
|
305
|
-
buildURL(path, query) {
|
|
306
|
-
const url = new URL(path, this.baseURL);
|
|
307
|
-
const mergedQuery = {
|
|
308
|
-
...this.defaultQuery ?? {},
|
|
309
|
-
...query ?? {}
|
|
310
|
-
};
|
|
311
|
-
for (const [key, value] of Object.entries(mergedQuery)) {
|
|
312
|
-
if (value !== undefined) {
|
|
313
|
-
url.searchParams.set(key, String(value));
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return url.toString();
|
|
317
|
-
}
|
|
318
|
-
buildHeaders(extra) {
|
|
319
|
-
const headers = { ...this.defaultHeaders };
|
|
320
|
-
if (this.apiKey) {
|
|
321
|
-
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
322
|
-
}
|
|
323
|
-
if (extra) {
|
|
324
|
-
Object.assign(headers, extra);
|
|
325
|
-
}
|
|
326
|
-
return headers;
|
|
327
|
-
}
|
|
328
|
-
async fetchWithTimeout(url, init, timeout) {
|
|
329
|
-
const controller = new AbortController;
|
|
330
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
331
|
-
if (init.signal) {
|
|
332
|
-
init.signal.addEventListener("abort", () => controller.abort());
|
|
333
|
-
}
|
|
334
|
-
try {
|
|
335
|
-
const response = await fetch(url, {
|
|
336
|
-
...init,
|
|
337
|
-
signal: controller.signal
|
|
338
|
-
});
|
|
339
|
-
return response;
|
|
340
|
-
} catch (error) {
|
|
341
|
-
if (error instanceof DOMException && error.name === "AbortError") {
|
|
342
|
-
throw new errors_1.TimeoutError(`Request timed out after ${timeout}ms`);
|
|
343
|
-
}
|
|
344
|
-
throw error;
|
|
345
|
-
} finally {
|
|
346
|
-
clearTimeout(timeoutId);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
async parseErrorBody(response) {
|
|
350
|
-
try {
|
|
351
|
-
const body = await response.json();
|
|
352
|
-
return {
|
|
353
|
-
message: body.detail || body.message || body.error,
|
|
354
|
-
...body
|
|
355
|
-
};
|
|
356
|
-
} catch {
|
|
357
|
-
return { message: `HTTP ${response.status}` };
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
parseRetryAfter(response) {
|
|
361
|
-
const header = response.headers.get("Retry-After");
|
|
362
|
-
if (!header)
|
|
363
|
-
return;
|
|
364
|
-
const seconds = Number.parseInt(header, 10);
|
|
365
|
-
if (!Number.isNaN(seconds)) {
|
|
366
|
-
return seconds * 1000;
|
|
367
|
-
}
|
|
368
|
-
const date = Date.parse(header);
|
|
369
|
-
if (!Number.isNaN(date)) {
|
|
370
|
-
return Math.max(0, date - Date.now());
|
|
371
|
-
}
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
getRetryDelay(attempt, retryAfter) {
|
|
375
|
-
if (retryAfter) {
|
|
376
|
-
return retryAfter;
|
|
377
|
-
}
|
|
378
|
-
return INITIAL_RETRY_DELAY * 2 ** attempt;
|
|
379
|
-
}
|
|
380
|
-
sleep(ms) {
|
|
381
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
exports.HonchoHTTPClient = HonchoHTTPClient;
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// node_modules/@honcho-ai/sdk/dist/message.js
|
|
388
|
-
var require_message = __commonJS(function(exports) {
|
|
389
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
390
|
-
exports.Message = undefined;
|
|
391
|
-
|
|
392
|
-
class Message {
|
|
393
|
-
constructor(id, content, peerId, sessionId, workspaceId, metadata, createdAt, tokenCount) {
|
|
394
|
-
this.id = id;
|
|
395
|
-
this.content = content;
|
|
396
|
-
this.peerId = peerId;
|
|
397
|
-
this.sessionId = sessionId;
|
|
398
|
-
this.workspaceId = workspaceId;
|
|
399
|
-
this.metadata = metadata;
|
|
400
|
-
this.createdAt = createdAt;
|
|
401
|
-
this.tokenCount = tokenCount;
|
|
402
|
-
}
|
|
403
|
-
static fromApiResponse(data) {
|
|
404
|
-
return new Message(data.id, data.content, data.peer_id, data.session_id, data.workspace_id, data.metadata, data.created_at, data.token_count);
|
|
405
|
-
}
|
|
406
|
-
toString() {
|
|
407
|
-
const truncatedContent = this.content.length > 50 ? `${this.content.slice(0, 50)}...` : this.content;
|
|
408
|
-
return `Message(id='${this.id}', peerId='${this.peerId}', content='${truncatedContent}')`;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
exports.Message = Message;
|
|
412
|
-
});
|
|
413
|
-
|
|
414
167
|
// node_modules/@honcho-ai/sdk/dist/pagination.js
|
|
415
168
|
var require_pagination = __commonJS(function(exports) {
|
|
416
169
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -13690,9 +13443,10 @@ var require_zod = __commonJS(function(exports) {
|
|
|
13690
13443
|
// node_modules/@honcho-ai/sdk/dist/validation.js
|
|
13691
13444
|
var require_validation = __commonJS(function(exports) {
|
|
13692
13445
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13693
|
-
exports.ConclusionQueryParamsSchema = exports.LimitSchema = exports.WorkspaceConfigSchema = exports.WorkspaceMetadataSchema = exports.MessageAdditionToApiSchema = exports.MessageAdditionSchema = exports.PeerRemovalSchema = exports.PeerAdditionToApiSchema = exports.PeerAdditionSchema = exports.PeerCardContentSchema = exports.CardTargetSchema = exports.PeerGetRepresentationParamsSchema = exports.GetRepresentationParamsSchema = exports.FileUploadSchema = exports.QueueStatusOptionsSchema = exports.ContextParamsSchema = exports.RepresentationOptionsSchema = exports.ChatQuerySchema = exports.FilterSchema = exports.SearchQueryLikeSchema = exports.SearchQueryObjectSchema = exports.SearchQuerySchema = exports.MessageInputSchema = exports.MessageConfigurationSchema = exports.MessageMetadataSchema = exports.MessageContentSchema = exports.SessionPeerConfigSchema = exports.SessionIdSchema = exports.SessionConfigSchema = exports.DreamConfigSchema = exports.SummaryConfigSchema = exports.PeerCardConfigSchema = exports.ReasoningConfigSchema = exports.SessionMetadataSchema = exports.PeerIdSchema = exports.PeerConfigSchema = exports.PeerMetadataSchema = exports.HonchoConfigSchema = exports.WorkspaceIdSchema = undefined;
|
|
13446
|
+
exports.ConclusionQueryParamsSchema = exports.LimitSchema = exports.WorkspaceConfigSchema = exports.WorkspaceMetadataSchema = exports.MessageAdditionToApiSchema = exports.MessageAdditionSchema = exports.PeerRemovalSchema = exports.PeerAdditionToApiSchema = exports.PeerAdditionSchema = exports.PeerCardContentSchema = exports.CardTargetSchema = exports.PeerGetRepresentationParamsSchema = exports.GetRepresentationParamsSchema = exports.FileUploadSchema = exports.QueueStatusOptionsSchema = exports.ContextParamsSchema = exports.RepresentationOptionsSchema = exports.ChatQuerySchema = exports.FilterSchema = exports.SearchQueryLikeSchema = exports.SearchQueryObjectSchema = exports.SearchQuerySchema = exports.MessageInputSchema = exports.MessageConfigurationSchema = exports.MessageMetadataSchema = exports.MessageContentSchema = exports.SessionPeerConfigSchema = exports.SessionAllowlistSchema = exports.SessionScopesSchema = exports.ScopeSessionsSchema = exports.ScopeOptionSchema = exports.ScopeIdSchema = exports.SessionIdSchema = exports.SessionConfigSchema = exports.DialecticConfigSchema = exports.DreamConfigSchema = exports.SummaryConfigSchema = exports.PeerCardConfigSchema = exports.ReasoningConfigSchema = exports.SessionMetadataSchema = exports.PeerIdSchema = exports.PeerConfigSchema = exports.PeerMetadataSchema = exports.HonchoConfigSchema = exports.WorkspaceIdSchema = undefined;
|
|
13694
13447
|
exports.normalizeSearchQuery = normalizeSearchQuery;
|
|
13695
13448
|
exports.normalizeListOptions = normalizeListOptions;
|
|
13449
|
+
exports.scopeRecallFields = scopeRecallFields;
|
|
13696
13450
|
exports.peerConfigToApi = peerConfigToApi;
|
|
13697
13451
|
exports.peerConfigFromApi = peerConfigFromApi;
|
|
13698
13452
|
exports.workspaceConfigToApi = workspaceConfigToApi;
|
|
@@ -13702,7 +13456,7 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13702
13456
|
exports.messageConfigToApi = messageConfigToApi;
|
|
13703
13457
|
exports.messageConfigFromApi = messageConfigFromApi;
|
|
13704
13458
|
var zod_1 = require_zod();
|
|
13705
|
-
exports.WorkspaceIdSchema = zod_1.z.string().min(1, "Workspace ID must be a non-empty string").regex(/^[a-zA-Z0-9_-]+$/, "Workspace ID may only contain letters, numbers, underscores, and hyphens").max(
|
|
13459
|
+
exports.WorkspaceIdSchema = zod_1.z.string().min(1, "Workspace ID must be a non-empty string").regex(/^[a-zA-Z0-9_-]+$/, "Workspace ID may only contain letters, numbers, underscores, and hyphens").max(512, "Workspace ID can be at most 512 characters");
|
|
13706
13460
|
exports.HonchoConfigSchema = zod_1.z.object({
|
|
13707
13461
|
apiKey: zod_1.z.string().optional(),
|
|
13708
13462
|
environment: zod_1.z.enum(["local", "production"]).optional(),
|
|
@@ -13717,7 +13471,7 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13717
13471
|
exports.PeerConfigSchema = zod_1.z.object({
|
|
13718
13472
|
observeMe: zod_1.z.boolean().nullable().optional()
|
|
13719
13473
|
}).strict();
|
|
13720
|
-
exports.PeerIdSchema = zod_1.z.string().min(1, "Peer ID must be a non-empty string").regex(/^[a-zA-Z0-9_-]+$/, "Peer ID may only contain letters, numbers, underscores, and hyphens").max(
|
|
13474
|
+
exports.PeerIdSchema = zod_1.z.string().min(1, "Peer ID must be a non-empty string").regex(/^[a-zA-Z0-9_-]+$/, "Peer ID may only contain letters, numbers, underscores, and hyphens").max(512, "Peer ID can be at most 512 characters");
|
|
13721
13475
|
var PeerIdObjectSchema = zod_1.z.object({ id: exports.PeerIdSchema });
|
|
13722
13476
|
exports.SessionMetadataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
13723
13477
|
exports.ReasoningConfigSchema = zod_1.z.object({
|
|
@@ -13726,32 +13480,92 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13726
13480
|
}).strict();
|
|
13727
13481
|
exports.PeerCardConfigSchema = zod_1.z.object({
|
|
13728
13482
|
use: zod_1.z.boolean().nullable().optional(),
|
|
13729
|
-
create: zod_1.z.boolean().nullable().optional()
|
|
13483
|
+
create: zod_1.z.boolean().nullable().optional(),
|
|
13484
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
13730
13485
|
}).strict();
|
|
13731
13486
|
exports.SummaryConfigSchema = zod_1.z.object({
|
|
13732
13487
|
enabled: zod_1.z.boolean().nullable().optional(),
|
|
13733
13488
|
messagesPerShortSummary: zod_1.z.number().int().min(10).nullable().optional(),
|
|
13734
|
-
messagesPerLongSummary: zod_1.z.number().int().min(20).nullable().optional()
|
|
13489
|
+
messagesPerLongSummary: zod_1.z.number().int().min(20).nullable().optional(),
|
|
13490
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
13735
13491
|
}).strict();
|
|
13736
13492
|
exports.DreamConfigSchema = zod_1.z.object({
|
|
13737
|
-
enabled: zod_1.z.boolean().nullable().optional()
|
|
13493
|
+
enabled: zod_1.z.boolean().nullable().optional(),
|
|
13494
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
13495
|
+
}).strict();
|
|
13496
|
+
exports.DialecticConfigSchema = zod_1.z.object({
|
|
13497
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
13738
13498
|
}).strict();
|
|
13739
13499
|
exports.SessionConfigSchema = zod_1.z.object({
|
|
13500
|
+
customInstructions: zod_1.z.string().nullable().optional(),
|
|
13740
13501
|
reasoning: exports.ReasoningConfigSchema.nullable().optional(),
|
|
13741
13502
|
peerCard: exports.PeerCardConfigSchema.nullable().optional(),
|
|
13742
13503
|
summary: exports.SummaryConfigSchema.nullable().optional(),
|
|
13743
|
-
dream: exports.DreamConfigSchema.nullable().optional()
|
|
13504
|
+
dream: exports.DreamConfigSchema.nullable().optional(),
|
|
13505
|
+
dialectic: exports.DialecticConfigSchema.nullable().optional()
|
|
13744
13506
|
}).strict();
|
|
13745
|
-
exports.SessionIdSchema = zod_1.z.string().min(1, "Session ID must be a non-empty string").regex(/^[a-zA-Z0-9_-]+$/, "Session ID may only contain letters, numbers, underscores, and hyphens").max(
|
|
13507
|
+
exports.SessionIdSchema = zod_1.z.string().min(1, "Session ID must be a non-empty string").regex(/^[a-zA-Z0-9_-]+$/, "Session ID may only contain letters, numbers, underscores, and hyphens").max(512, "Session ID can be at most 512 characters");
|
|
13746
13508
|
var SessionIdObjectSchema = zod_1.z.object({ id: exports.SessionIdSchema });
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13509
|
+
var SCOPE_PEER_PREFIX = "scope.";
|
|
13510
|
+
var SCOPE_ID_MAX_LENGTH = 512 - SCOPE_PEER_PREFIX.length;
|
|
13511
|
+
function scopeIdIssues(value) {
|
|
13512
|
+
if (value.length < 1) {
|
|
13513
|
+
return ["Scope ID must be a non-empty string"];
|
|
13514
|
+
}
|
|
13515
|
+
if (value.length > SCOPE_ID_MAX_LENGTH) {
|
|
13516
|
+
return [`Scope ID can be at most ${SCOPE_ID_MAX_LENGTH} characters`];
|
|
13517
|
+
}
|
|
13518
|
+
if (value.startsWith(SCOPE_PEER_PREFIX)) {
|
|
13519
|
+
return [
|
|
13520
|
+
`Scope ID must not start with the reserved prefix '${SCOPE_PEER_PREFIX}' (scope IDs are unprefixed)`
|
|
13521
|
+
];
|
|
13522
|
+
}
|
|
13523
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(value)) {
|
|
13524
|
+
return [
|
|
13525
|
+
"Scope ID may only contain letters, numbers, underscores, and hyphens"
|
|
13526
|
+
];
|
|
13527
|
+
}
|
|
13528
|
+
return [];
|
|
13529
|
+
}
|
|
13530
|
+
function addScopeIdIssues(values, ctx) {
|
|
13531
|
+
for (const value of values) {
|
|
13532
|
+
for (const message of scopeIdIssues(value)) {
|
|
13533
|
+
ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message });
|
|
13534
|
+
}
|
|
13535
|
+
}
|
|
13536
|
+
}
|
|
13537
|
+
exports.ScopeIdSchema = zod_1.z.string().superRefine((val, ctx) => {
|
|
13538
|
+
addScopeIdIssues([val], ctx);
|
|
13539
|
+
});
|
|
13540
|
+
var ScopeIdLikeSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.object({ id: zod_1.z.string() })]);
|
|
13541
|
+
exports.ScopeOptionSchema = zod_1.z.union([ScopeIdLikeSchema, zod_1.z.array(ScopeIdLikeSchema)]).transform((val) => Array.isArray(val) ? val.map((entry) => typeof entry === "string" ? entry : entry.id) : typeof val === "string" ? val : val.id).superRefine((resolved, ctx) => {
|
|
13542
|
+
if (Array.isArray(resolved)) {
|
|
13543
|
+
if (resolved.length === 0) {
|
|
13544
|
+
ctx.addIssue({
|
|
13545
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13546
|
+
message: "scope must name at least one scope"
|
|
13547
|
+
});
|
|
13548
|
+
}
|
|
13549
|
+
if (resolved.length > 100) {
|
|
13550
|
+
ctx.addIssue({
|
|
13551
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13552
|
+
message: "scope can name at most 100 scopes"
|
|
13553
|
+
});
|
|
13554
|
+
}
|
|
13555
|
+
}
|
|
13556
|
+
addScopeIdIssues(Array.isArray(resolved) ? resolved : [resolved], ctx);
|
|
13557
|
+
});
|
|
13558
|
+
exports.ScopeSessionsSchema = zod_1.z.array(exports.SessionIdSchema).min(1, "At least one session must be given").max(100, "At most 100 sessions can be given per call");
|
|
13559
|
+
exports.SessionScopesSchema = zod_1.z.array(exports.ScopeIdSchema).min(1, "scopes must name at least one scope").max(100, "scopes can name at most 100 scopes");
|
|
13560
|
+
exports.SessionAllowlistSchema = zod_1.z.array(zod_1.z.union([exports.SessionIdSchema, SessionIdObjectSchema])).min(1, "sessions must name at least one session").max(1000, "sessions can name at most 1000 sessions").transform((vals) => vals.map((v) => typeof v === "string" ? v : v.id));
|
|
13561
|
+
exports.SessionPeerConfigSchema = zod_1.z.object({
|
|
13562
|
+
observeMe: zod_1.z.boolean().nullable().optional(),
|
|
13563
|
+
observeOthers: zod_1.z.boolean().nullable().optional()
|
|
13564
|
+
}).strict();
|
|
13565
|
+
exports.MessageContentSchema = zod_1.z.string().refine((content) => content === "" || content.trim().length > 0, "Message content cannot be only whitespace");
|
|
13566
|
+
exports.MessageMetadataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional();
|
|
13567
|
+
exports.MessageConfigurationSchema = zod_1.z.object({
|
|
13568
|
+
reasoning: exports.ReasoningConfigSchema.nullable().optional()
|
|
13755
13569
|
}).strict().nullable().optional();
|
|
13756
13570
|
exports.MessageInputSchema = zod_1.z.object({
|
|
13757
13571
|
peerId: exports.PeerIdSchema,
|
|
@@ -13791,12 +13605,41 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13791
13605
|
}
|
|
13792
13606
|
return { filters: input };
|
|
13793
13607
|
}
|
|
13608
|
+
function scopeRecallFields(options) {
|
|
13609
|
+
return {
|
|
13610
|
+
scope: options.scope,
|
|
13611
|
+
filters: options.sessions ? { session_id: options.sessions } : undefined
|
|
13612
|
+
};
|
|
13613
|
+
}
|
|
13614
|
+
function scopeExclusivityIssues(data, ctx) {
|
|
13615
|
+
if (data.scope === undefined) {
|
|
13616
|
+
return;
|
|
13617
|
+
}
|
|
13618
|
+
if (data.sessions !== undefined) {
|
|
13619
|
+
ctx.addIssue({
|
|
13620
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13621
|
+
message: "scope and sessions are mutually exclusive",
|
|
13622
|
+
path: ["sessions"]
|
|
13623
|
+
});
|
|
13624
|
+
}
|
|
13625
|
+
if (data.session !== undefined) {
|
|
13626
|
+
ctx.addIssue({
|
|
13627
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13628
|
+
message: "scope and session are mutually exclusive",
|
|
13629
|
+
path: ["session"]
|
|
13630
|
+
});
|
|
13631
|
+
}
|
|
13632
|
+
}
|
|
13794
13633
|
exports.ChatQuerySchema = zod_1.z.object({
|
|
13795
13634
|
query: exports.SearchQuerySchema,
|
|
13796
13635
|
target: zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional().transform((val) => val ? typeof val === "string" ? val : val.id : undefined),
|
|
13797
13636
|
session: zod_1.z.union([exports.SessionIdSchema, SessionIdObjectSchema]).optional().transform((val) => val ? typeof val === "string" ? val : val.id : undefined),
|
|
13798
|
-
|
|
13799
|
-
|
|
13637
|
+
scope: exports.ScopeOptionSchema.optional(),
|
|
13638
|
+
sessions: exports.SessionAllowlistSchema.optional(),
|
|
13639
|
+
reasoningLevel: zod_1.z.enum(["minimal", "low", "medium", "high", "max"]).optional(),
|
|
13640
|
+
responseFormat: zod_1.z.union([zod_1.z.instanceof(zod_1.z.ZodType), zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())]).optional(),
|
|
13641
|
+
includeEvidence: zod_1.z.boolean().optional()
|
|
13642
|
+
}).strict().superRefine(scopeExclusivityIssues);
|
|
13800
13643
|
exports.RepresentationOptionsSchema = zod_1.z.object({
|
|
13801
13644
|
searchQuery: exports.SearchQueryLikeSchema.optional(),
|
|
13802
13645
|
searchTopK: zod_1.z.number().int().min(1, "searchTopK must be at least 1").max(100, "searchTopK must be at most 100").optional(),
|
|
@@ -13809,9 +13652,32 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13809
13652
|
tokens: zod_1.z.int("Token limit must be an integer").optional(),
|
|
13810
13653
|
peerTarget: exports.PeerIdSchema.optional(),
|
|
13811
13654
|
peerPerspective: exports.PeerIdSchema.optional(),
|
|
13655
|
+
scope: exports.ScopeIdSchema.optional(),
|
|
13656
|
+
sessions: exports.SessionAllowlistSchema.optional(),
|
|
13812
13657
|
limitToSession: zod_1.z.boolean().optional(),
|
|
13813
13658
|
representationOptions: exports.RepresentationOptionsSchema.optional()
|
|
13814
13659
|
}).strict().superRefine((data, ctx) => {
|
|
13660
|
+
if (data.sessions && !data.peerTarget) {
|
|
13661
|
+
ctx.addIssue({
|
|
13662
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13663
|
+
message: "peerTarget is required when sessions is provided",
|
|
13664
|
+
path: ["sessions"]
|
|
13665
|
+
});
|
|
13666
|
+
}
|
|
13667
|
+
if (data.sessions && data.scope) {
|
|
13668
|
+
ctx.addIssue({
|
|
13669
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13670
|
+
message: "sessions and scope are mutually exclusive",
|
|
13671
|
+
path: ["sessions"]
|
|
13672
|
+
});
|
|
13673
|
+
}
|
|
13674
|
+
if (data.sessions && data.limitToSession) {
|
|
13675
|
+
ctx.addIssue({
|
|
13676
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13677
|
+
message: "sessions and limitToSession are mutually exclusive",
|
|
13678
|
+
path: ["sessions"]
|
|
13679
|
+
});
|
|
13680
|
+
}
|
|
13815
13681
|
if (data.representationOptions?.searchQuery && !data.peerTarget) {
|
|
13816
13682
|
ctx.addIssue({
|
|
13817
13683
|
code: zod_1.z.ZodIssueCode.custom,
|
|
@@ -13826,6 +13692,20 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13826
13692
|
path: ["peerPerspective"]
|
|
13827
13693
|
});
|
|
13828
13694
|
}
|
|
13695
|
+
if (data.scope && !data.peerTarget) {
|
|
13696
|
+
ctx.addIssue({
|
|
13697
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13698
|
+
message: "peerTarget is required when scope is provided",
|
|
13699
|
+
path: ["scope"]
|
|
13700
|
+
});
|
|
13701
|
+
}
|
|
13702
|
+
if (data.scope && data.peerPerspective) {
|
|
13703
|
+
ctx.addIssue({
|
|
13704
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
13705
|
+
message: "scope and peerPerspective are mutually exclusive",
|
|
13706
|
+
path: ["scope"]
|
|
13707
|
+
});
|
|
13708
|
+
}
|
|
13829
13709
|
});
|
|
13830
13710
|
exports.QueueStatusOptionsSchema = zod_1.z.object({
|
|
13831
13711
|
observer: zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional(),
|
|
@@ -13854,9 +13734,11 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13854
13734
|
}).strict();
|
|
13855
13735
|
exports.PeerGetRepresentationParamsSchema = zod_1.z.object({
|
|
13856
13736
|
session: zod_1.z.union([exports.SessionIdSchema, SessionIdObjectSchema]).optional(),
|
|
13737
|
+
scope: exports.ScopeOptionSchema.optional(),
|
|
13738
|
+
sessions: exports.SessionAllowlistSchema.optional(),
|
|
13857
13739
|
target: zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional(),
|
|
13858
13740
|
options: exports.RepresentationOptionsSchema.optional()
|
|
13859
|
-
}).strict();
|
|
13741
|
+
}).strict().superRefine(scopeExclusivityIssues);
|
|
13860
13742
|
exports.CardTargetSchema = zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional().transform((val) => val ? typeof val === "string" ? val : val.id : undefined);
|
|
13861
13743
|
exports.PeerCardContentSchema = zod_1.z.array(zod_1.z.string());
|
|
13862
13744
|
exports.PeerAdditionSchema = zod_1.z.union([
|
|
@@ -13917,7 +13799,8 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13917
13799
|
return;
|
|
13918
13800
|
return {
|
|
13919
13801
|
use: config.use,
|
|
13920
|
-
create: config.create
|
|
13802
|
+
create: config.create,
|
|
13803
|
+
custom_instructions: config.customInstructions
|
|
13921
13804
|
};
|
|
13922
13805
|
}
|
|
13923
13806
|
function peerCardConfigFromApi(config) {
|
|
@@ -13927,7 +13810,8 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13927
13810
|
return;
|
|
13928
13811
|
return {
|
|
13929
13812
|
use: config.use,
|
|
13930
|
-
create: config.create
|
|
13813
|
+
create: config.create,
|
|
13814
|
+
customInstructions: config.custom_instructions
|
|
13931
13815
|
};
|
|
13932
13816
|
}
|
|
13933
13817
|
function summaryConfigToApi(config) {
|
|
@@ -13938,7 +13822,8 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13938
13822
|
return {
|
|
13939
13823
|
enabled: config.enabled,
|
|
13940
13824
|
messages_per_short_summary: config.messagesPerShortSummary,
|
|
13941
|
-
messages_per_long_summary: config.messagesPerLongSummary
|
|
13825
|
+
messages_per_long_summary: config.messagesPerLongSummary,
|
|
13826
|
+
custom_instructions: config.customInstructions
|
|
13942
13827
|
};
|
|
13943
13828
|
}
|
|
13944
13829
|
function summaryConfigFromApi(config) {
|
|
@@ -13949,7 +13834,8 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13949
13834
|
return {
|
|
13950
13835
|
enabled: config.enabled,
|
|
13951
13836
|
messagesPerShortSummary: config.messages_per_short_summary,
|
|
13952
|
-
messagesPerLongSummary: config.messages_per_long_summary
|
|
13837
|
+
messagesPerLongSummary: config.messages_per_long_summary,
|
|
13838
|
+
customInstructions: config.custom_instructions
|
|
13953
13839
|
};
|
|
13954
13840
|
}
|
|
13955
13841
|
function dreamConfigToApi(config) {
|
|
@@ -13958,7 +13844,8 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13958
13844
|
if (config === undefined)
|
|
13959
13845
|
return;
|
|
13960
13846
|
return {
|
|
13961
|
-
enabled: config.enabled
|
|
13847
|
+
enabled: config.enabled,
|
|
13848
|
+
custom_instructions: config.customInstructions
|
|
13962
13849
|
};
|
|
13963
13850
|
}
|
|
13964
13851
|
function dreamConfigFromApi(config) {
|
|
@@ -13967,17 +13854,38 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13967
13854
|
if (config === undefined)
|
|
13968
13855
|
return;
|
|
13969
13856
|
return {
|
|
13970
|
-
enabled: config.enabled
|
|
13857
|
+
enabled: config.enabled,
|
|
13858
|
+
customInstructions: config.custom_instructions
|
|
13859
|
+
};
|
|
13860
|
+
}
|
|
13861
|
+
function dialecticConfigToApi(config) {
|
|
13862
|
+
if (config === null)
|
|
13863
|
+
return null;
|
|
13864
|
+
if (config === undefined)
|
|
13865
|
+
return;
|
|
13866
|
+
return {
|
|
13867
|
+
custom_instructions: config.customInstructions
|
|
13868
|
+
};
|
|
13869
|
+
}
|
|
13870
|
+
function dialecticConfigFromApi(config) {
|
|
13871
|
+
if (config === null)
|
|
13872
|
+
return null;
|
|
13873
|
+
if (config === undefined)
|
|
13874
|
+
return;
|
|
13875
|
+
return {
|
|
13876
|
+
customInstructions: config.custom_instructions
|
|
13971
13877
|
};
|
|
13972
13878
|
}
|
|
13973
13879
|
function workspaceConfigToApi(config) {
|
|
13974
13880
|
if (!config)
|
|
13975
13881
|
return;
|
|
13976
13882
|
return {
|
|
13883
|
+
custom_instructions: config.customInstructions,
|
|
13977
13884
|
reasoning: reasoningConfigToApi(config.reasoning),
|
|
13978
13885
|
peer_card: peerCardConfigToApi(config.peerCard),
|
|
13979
13886
|
summary: summaryConfigToApi(config.summary),
|
|
13980
|
-
dream: dreamConfigToApi(config.dream)
|
|
13887
|
+
dream: dreamConfigToApi(config.dream),
|
|
13888
|
+
dialectic: dialecticConfigToApi(config.dialectic)
|
|
13981
13889
|
};
|
|
13982
13890
|
}
|
|
13983
13891
|
function workspaceConfigFromApi(config) {
|
|
@@ -13985,20 +13893,24 @@ var require_validation = __commonJS(function(exports) {
|
|
|
13985
13893
|
return;
|
|
13986
13894
|
const apiConfig = config;
|
|
13987
13895
|
return {
|
|
13896
|
+
customInstructions: apiConfig.custom_instructions,
|
|
13988
13897
|
reasoning: reasoningConfigFromApi(apiConfig.reasoning),
|
|
13989
13898
|
peerCard: peerCardConfigFromApi(apiConfig.peer_card),
|
|
13990
13899
|
summary: summaryConfigFromApi(apiConfig.summary),
|
|
13991
|
-
dream: dreamConfigFromApi(apiConfig.dream)
|
|
13900
|
+
dream: dreamConfigFromApi(apiConfig.dream),
|
|
13901
|
+
dialectic: dialecticConfigFromApi(apiConfig.dialectic)
|
|
13992
13902
|
};
|
|
13993
13903
|
}
|
|
13994
13904
|
function sessionConfigToApi(config) {
|
|
13995
13905
|
if (!config)
|
|
13996
13906
|
return;
|
|
13997
13907
|
return {
|
|
13908
|
+
custom_instructions: config.customInstructions,
|
|
13998
13909
|
reasoning: reasoningConfigToApi(config.reasoning),
|
|
13999
13910
|
peer_card: peerCardConfigToApi(config.peerCard),
|
|
14000
13911
|
summary: summaryConfigToApi(config.summary),
|
|
14001
|
-
dream: dreamConfigToApi(config.dream)
|
|
13912
|
+
dream: dreamConfigToApi(config.dream),
|
|
13913
|
+
dialectic: dialecticConfigToApi(config.dialectic)
|
|
14002
13914
|
};
|
|
14003
13915
|
}
|
|
14004
13916
|
function sessionConfigFromApi(config) {
|
|
@@ -14006,10 +13918,12 @@ var require_validation = __commonJS(function(exports) {
|
|
|
14006
13918
|
return;
|
|
14007
13919
|
const apiConfig = config;
|
|
14008
13920
|
return {
|
|
13921
|
+
customInstructions: apiConfig.custom_instructions,
|
|
14009
13922
|
reasoning: reasoningConfigFromApi(apiConfig.reasoning),
|
|
14010
13923
|
peerCard: peerCardConfigFromApi(apiConfig.peer_card),
|
|
14011
13924
|
summary: summaryConfigFromApi(apiConfig.summary),
|
|
14012
|
-
dream: dreamConfigFromApi(apiConfig.dream)
|
|
13925
|
+
dream: dreamConfigFromApi(apiConfig.dream),
|
|
13926
|
+
dialectic: dialecticConfigFromApi(apiConfig.dialectic)
|
|
14013
13927
|
};
|
|
14014
13928
|
}
|
|
14015
13929
|
function messageConfigToApi(config) {
|
|
@@ -14081,10 +13995,12 @@ var require_validation = __commonJS(function(exports) {
|
|
|
14081
13995
|
});
|
|
14082
13996
|
exports.WorkspaceMetadataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
14083
13997
|
exports.WorkspaceConfigSchema = zod_1.z.object({
|
|
13998
|
+
customInstructions: zod_1.z.string().nullable().optional(),
|
|
14084
13999
|
reasoning: exports.ReasoningConfigSchema.nullable().optional(),
|
|
14085
14000
|
peerCard: exports.PeerCardConfigSchema.nullable().optional(),
|
|
14086
14001
|
summary: exports.SummaryConfigSchema.nullable().optional(),
|
|
14087
|
-
dream: exports.DreamConfigSchema.nullable().optional()
|
|
14002
|
+
dream: exports.DreamConfigSchema.nullable().optional(),
|
|
14003
|
+
dialectic: exports.DialecticConfigSchema.nullable().optional()
|
|
14088
14004
|
}).strict();
|
|
14089
14005
|
exports.LimitSchema = zod_1.z.number().int().min(1, "Limit must be a positive integer").max(100, "Limit must be less than or equal to 100");
|
|
14090
14006
|
exports.ConclusionQueryParamsSchema = zod_1.z.object({
|
|
@@ -14098,22 +14014,46 @@ var require_validation = __commonJS(function(exports) {
|
|
|
14098
14014
|
// node_modules/@honcho-ai/sdk/dist/conclusions.js
|
|
14099
14015
|
var require_conclusions = __commonJS(function(exports) {
|
|
14100
14016
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14101
|
-
exports.
|
|
14017
|
+
exports.WorkspaceConclusions = exports.ConclusionsView = exports.Conclusion = undefined;
|
|
14102
14018
|
var api_version_1 = require_api_version();
|
|
14019
|
+
var errors_1 = require_errors();
|
|
14103
14020
|
var pagination_1 = require_pagination();
|
|
14104
14021
|
var validation_1 = require_validation();
|
|
14022
|
+
var LIST_PAGE_CAP = 100;
|
|
14023
|
+
var VIEW_RESERVED_KEYS = [
|
|
14024
|
+
"observer",
|
|
14025
|
+
"observed",
|
|
14026
|
+
"observer_id",
|
|
14027
|
+
"observed_id"
|
|
14028
|
+
];
|
|
14029
|
+
function rejectReservedFilterKeys(filters, reserved) {
|
|
14030
|
+
if (!filters)
|
|
14031
|
+
return;
|
|
14032
|
+
const clash = reserved.filter((k) => (k in filters)).sort();
|
|
14033
|
+
if (clash.length > 0) {
|
|
14034
|
+
let guidance = "Choose the peer pair via peer.conclusions / peer.conclusionsOf(target)";
|
|
14035
|
+
if (reserved.includes("session") || reserved.includes("session_id")) {
|
|
14036
|
+
guidance += "; use the session option to filter by session";
|
|
14037
|
+
}
|
|
14038
|
+
throw new Error(`Filter key(s) ${clash.join(", ")} are managed by this conclusions view ` + `and cannot be passed in filters. ${guidance}.`);
|
|
14039
|
+
}
|
|
14040
|
+
}
|
|
14105
14041
|
|
|
14106
14042
|
class Conclusion {
|
|
14107
|
-
constructor(id, content, observerId, observedId, sessionId, createdAt) {
|
|
14043
|
+
constructor(id, content, observerId, observedId, sessionId, createdAt, level = "explicit", sourceIds = null, timesDerived = 1, sourceMessageIds = null) {
|
|
14108
14044
|
this.id = id;
|
|
14109
14045
|
this.content = content;
|
|
14110
14046
|
this.observerId = observerId;
|
|
14111
14047
|
this.observedId = observedId;
|
|
14112
14048
|
this.sessionId = sessionId;
|
|
14049
|
+
this.level = level;
|
|
14050
|
+
this.sourceIds = sourceIds;
|
|
14051
|
+
this.timesDerived = timesDerived;
|
|
14052
|
+
this.sourceMessageIds = sourceMessageIds;
|
|
14113
14053
|
this.createdAt = createdAt;
|
|
14114
14054
|
}
|
|
14115
14055
|
static fromApiResponse(data) {
|
|
14116
|
-
return new Conclusion(data.id, data.content, data.observer_id, data.observed_id, data.session_id, data.created_at);
|
|
14056
|
+
return new Conclusion(data.id, data.content, data.observer_id, data.observed_id, data.session_id, data.created_at, data.level, data.source_ids ?? null, data.times_derived ?? 1, data.source_message_ids ?? null);
|
|
14117
14057
|
}
|
|
14118
14058
|
toString() {
|
|
14119
14059
|
const truncatedContent = this.content.length > 50 ? `${this.content.slice(0, 50)}...` : this.content;
|
|
@@ -14122,7 +14062,7 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
14122
14062
|
}
|
|
14123
14063
|
exports.Conclusion = Conclusion;
|
|
14124
14064
|
|
|
14125
|
-
class
|
|
14065
|
+
class ConclusionsView {
|
|
14126
14066
|
constructor(http, workspaceId, observer, observed, ensureWorkspace = async () => {
|
|
14127
14067
|
return;
|
|
14128
14068
|
}) {
|
|
@@ -14151,6 +14091,26 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
14151
14091
|
await this._ensureWorkspace();
|
|
14152
14092
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions`, { body: params });
|
|
14153
14093
|
}
|
|
14094
|
+
async _get(conclusionId) {
|
|
14095
|
+
await this._ensureWorkspace();
|
|
14096
|
+
const item = await this._http.get(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/${conclusionId}`);
|
|
14097
|
+
if (item.observer_id !== this.observer || item.observed_id !== this.observed) {
|
|
14098
|
+
throw new errors_1.NotFoundError("Conclusion not found");
|
|
14099
|
+
}
|
|
14100
|
+
return item;
|
|
14101
|
+
}
|
|
14102
|
+
async _derived(conclusionId, params) {
|
|
14103
|
+
return this._list({
|
|
14104
|
+
filters: {
|
|
14105
|
+
source_ids: { contains: conclusionId },
|
|
14106
|
+
observer_id: this.observer,
|
|
14107
|
+
observed_id: this.observed
|
|
14108
|
+
},
|
|
14109
|
+
page: params.page,
|
|
14110
|
+
size: params.size,
|
|
14111
|
+
reverse: params.reverse
|
|
14112
|
+
});
|
|
14113
|
+
}
|
|
14154
14114
|
async _delete(conclusionId) {
|
|
14155
14115
|
await this._ensureWorkspace();
|
|
14156
14116
|
await this._http.delete(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/${conclusionId}`);
|
|
@@ -14160,14 +14120,18 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
14160
14120
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/peers/${peerId}/representation`, { body: params });
|
|
14161
14121
|
}
|
|
14162
14122
|
async list(options) {
|
|
14123
|
+
rejectReservedFilterKeys(options?.filters, [
|
|
14124
|
+
...VIEW_RESERVED_KEYS,
|
|
14125
|
+
"session",
|
|
14126
|
+
"session_id"
|
|
14127
|
+
]);
|
|
14163
14128
|
const resolvedSessionId = options?.session ? typeof options.session === "string" ? options.session : options.session.id : undefined;
|
|
14164
14129
|
const filters = {
|
|
14165
14130
|
observer_id: this.observer,
|
|
14166
|
-
observed_id: this.observed
|
|
14131
|
+
observed_id: this.observed,
|
|
14132
|
+
...resolvedSessionId ? { session_id: resolvedSessionId } : {},
|
|
14133
|
+
...options?.filters
|
|
14167
14134
|
};
|
|
14168
|
-
if (resolvedSessionId) {
|
|
14169
|
-
filters.session_id = resolvedSessionId;
|
|
14170
|
-
}
|
|
14171
14135
|
const reverse = options?.reverse;
|
|
14172
14136
|
const response = await this._list({
|
|
14173
14137
|
filters,
|
|
@@ -14180,19 +14144,55 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
14180
14144
|
};
|
|
14181
14145
|
return new pagination_1.Page(response, (item) => Conclusion.fromApiResponse(item), fetchNextPage);
|
|
14182
14146
|
}
|
|
14183
|
-
async query(query, topK = 10, distance) {
|
|
14184
|
-
|
|
14185
|
-
observer_id: this.observer,
|
|
14186
|
-
observed_id: this.observed
|
|
14187
|
-
};
|
|
14147
|
+
async query(query, topK = 10, distance, filters) {
|
|
14148
|
+
rejectReservedFilterKeys(filters, VIEW_RESERVED_KEYS);
|
|
14188
14149
|
const response = await this._query({
|
|
14189
14150
|
query,
|
|
14190
14151
|
top_k: topK,
|
|
14191
14152
|
distance,
|
|
14192
|
-
filters
|
|
14153
|
+
filters: {
|
|
14154
|
+
observer_id: this.observer,
|
|
14155
|
+
observed_id: this.observed,
|
|
14156
|
+
...filters
|
|
14157
|
+
}
|
|
14193
14158
|
});
|
|
14194
14159
|
return (response ?? []).map((item) => Conclusion.fromApiResponse(item));
|
|
14195
14160
|
}
|
|
14161
|
+
async get(conclusionId) {
|
|
14162
|
+
const response = await this._get(conclusionId);
|
|
14163
|
+
return Conclusion.fromApiResponse(response);
|
|
14164
|
+
}
|
|
14165
|
+
async getMany(conclusionIds) {
|
|
14166
|
+
if (conclusionIds.length === 0)
|
|
14167
|
+
return [];
|
|
14168
|
+
const conclusions = [];
|
|
14169
|
+
for (let start = 0;start < conclusionIds.length; start += LIST_PAGE_CAP) {
|
|
14170
|
+
const chunk = conclusionIds.slice(start, start + LIST_PAGE_CAP);
|
|
14171
|
+
const response = await this._list({
|
|
14172
|
+
filters: {
|
|
14173
|
+
id: { in: chunk },
|
|
14174
|
+
observer_id: this.observer,
|
|
14175
|
+
observed_id: this.observed
|
|
14176
|
+
},
|
|
14177
|
+
page: 1,
|
|
14178
|
+
size: chunk.length
|
|
14179
|
+
});
|
|
14180
|
+
conclusions.push(...(response.items ?? []).map((item) => Conclusion.fromApiResponse(item)));
|
|
14181
|
+
}
|
|
14182
|
+
return conclusions;
|
|
14183
|
+
}
|
|
14184
|
+
async derived(conclusionId, options) {
|
|
14185
|
+
const reverse = options?.reverse;
|
|
14186
|
+
const response = await this._derived(conclusionId, {
|
|
14187
|
+
page: options?.page ?? 1,
|
|
14188
|
+
size: options?.size ?? 50,
|
|
14189
|
+
reverse
|
|
14190
|
+
});
|
|
14191
|
+
const fetchNextPage = async (page, size) => {
|
|
14192
|
+
return this._derived(conclusionId, { page, size, reverse });
|
|
14193
|
+
};
|
|
14194
|
+
return new pagination_1.Page(response, (item) => Conclusion.fromApiResponse(item), fetchNextPage);
|
|
14195
|
+
}
|
|
14196
14196
|
async delete(conclusionId) {
|
|
14197
14197
|
await this._delete(conclusionId);
|
|
14198
14198
|
}
|
|
@@ -14227,10 +14227,300 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
14227
14227
|
return response.representation;
|
|
14228
14228
|
}
|
|
14229
14229
|
toString() {
|
|
14230
|
-
return `
|
|
14230
|
+
return `ConclusionsView(workspaceId='${this.workspaceId}', observer='${this.observer}', observed='${this.observed}')`;
|
|
14231
14231
|
}
|
|
14232
14232
|
}
|
|
14233
|
-
exports.
|
|
14233
|
+
exports.ConclusionsView = ConclusionsView;
|
|
14234
|
+
|
|
14235
|
+
class WorkspaceConclusions {
|
|
14236
|
+
constructor(http, workspaceId, ensureWorkspace = async () => {
|
|
14237
|
+
return;
|
|
14238
|
+
}) {
|
|
14239
|
+
this._http = http;
|
|
14240
|
+
this.workspaceId = workspaceId;
|
|
14241
|
+
this._ensureWorkspace = ensureWorkspace;
|
|
14242
|
+
}
|
|
14243
|
+
async _list(params) {
|
|
14244
|
+
await this._ensureWorkspace();
|
|
14245
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/list`, {
|
|
14246
|
+
body: params.filters ? { filters: params.filters } : undefined,
|
|
14247
|
+
query: {
|
|
14248
|
+
page: params.page,
|
|
14249
|
+
size: params.size,
|
|
14250
|
+
reverse: params.reverse ? "true" : undefined
|
|
14251
|
+
}
|
|
14252
|
+
});
|
|
14253
|
+
}
|
|
14254
|
+
async list(options) {
|
|
14255
|
+
const filters = options?.filters;
|
|
14256
|
+
const reverse = options?.reverse;
|
|
14257
|
+
const response = await this._list({
|
|
14258
|
+
filters,
|
|
14259
|
+
page: options?.page ?? 1,
|
|
14260
|
+
size: options?.size ?? 50,
|
|
14261
|
+
reverse
|
|
14262
|
+
});
|
|
14263
|
+
const fetchNextPage = async (page, size) => {
|
|
14264
|
+
return this._list({ filters, page, size, reverse });
|
|
14265
|
+
};
|
|
14266
|
+
return new pagination_1.Page(response, (item) => Conclusion.fromApiResponse(item), fetchNextPage);
|
|
14267
|
+
}
|
|
14268
|
+
async get(conclusionId) {
|
|
14269
|
+
await this._ensureWorkspace();
|
|
14270
|
+
const item = await this._http.get(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/${conclusionId}`);
|
|
14271
|
+
return Conclusion.fromApiResponse(item);
|
|
14272
|
+
}
|
|
14273
|
+
async getMany(conclusionIds) {
|
|
14274
|
+
if (conclusionIds.length === 0)
|
|
14275
|
+
return [];
|
|
14276
|
+
const conclusions = [];
|
|
14277
|
+
for (let start = 0;start < conclusionIds.length; start += LIST_PAGE_CAP) {
|
|
14278
|
+
const chunk = conclusionIds.slice(start, start + LIST_PAGE_CAP);
|
|
14279
|
+
const response = await this._list({
|
|
14280
|
+
filters: { id: { in: chunk } },
|
|
14281
|
+
page: 1,
|
|
14282
|
+
size: chunk.length
|
|
14283
|
+
});
|
|
14284
|
+
conclusions.push(...(response.items ?? []).map((item) => Conclusion.fromApiResponse(item)));
|
|
14285
|
+
}
|
|
14286
|
+
return conclusions;
|
|
14287
|
+
}
|
|
14288
|
+
toString() {
|
|
14289
|
+
return `WorkspaceConclusions(workspaceId='${this.workspaceId}')`;
|
|
14290
|
+
}
|
|
14291
|
+
}
|
|
14292
|
+
exports.WorkspaceConclusions = WorkspaceConclusions;
|
|
14293
|
+
});
|
|
14294
|
+
|
|
14295
|
+
// node_modules/@honcho-ai/sdk/dist/http/client.js
|
|
14296
|
+
var require_client = __commonJS(function(exports) {
|
|
14297
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14298
|
+
exports.HonchoHTTPClient = exports.HOST_HEADER = undefined;
|
|
14299
|
+
exports.defaultHostHeader = defaultHostHeader;
|
|
14300
|
+
var api_version_1 = require_api_version();
|
|
14301
|
+
var errors_1 = require_errors();
|
|
14302
|
+
var DEFAULT_TIMEOUT = 60000;
|
|
14303
|
+
var DEFAULT_MAX_RETRIES = 2;
|
|
14304
|
+
var RETRY_STATUS_CODES = [429, 500, 502, 503, 504];
|
|
14305
|
+
var INITIAL_RETRY_DELAY = 500;
|
|
14306
|
+
exports.HOST_HEADER = "X-Honcho-Host";
|
|
14307
|
+
function defaultHostHeader() {
|
|
14308
|
+
const product = `honcho-typescript/${api_version_1.VERSION}`;
|
|
14309
|
+
const platform = typeof process !== "undefined" && typeof process.platform === "string" ? process.platform : undefined;
|
|
14310
|
+
return platform ? `${product} (${platform})` : product;
|
|
14311
|
+
}
|
|
14312
|
+
|
|
14313
|
+
class HonchoHTTPClient {
|
|
14314
|
+
constructor(config) {
|
|
14315
|
+
this.baseURL = config.baseURL.replace(/\/$/, "");
|
|
14316
|
+
this.apiKey = config.apiKey;
|
|
14317
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
14318
|
+
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
14319
|
+
this.defaultHeaders = {
|
|
14320
|
+
"Content-Type": "application/json",
|
|
14321
|
+
[exports.HOST_HEADER]: defaultHostHeader(),
|
|
14322
|
+
...config.defaultHeaders
|
|
14323
|
+
};
|
|
14324
|
+
this.defaultQuery = config.defaultQuery;
|
|
14325
|
+
}
|
|
14326
|
+
async request(method, path, options = {}) {
|
|
14327
|
+
const url = this.buildURL(path, options.query);
|
|
14328
|
+
const headers = this.buildHeaders(options.headers);
|
|
14329
|
+
const timeout = options.timeout ?? this.timeout;
|
|
14330
|
+
let lastError;
|
|
14331
|
+
let attempt = 0;
|
|
14332
|
+
while (attempt <= this.maxRetries) {
|
|
14333
|
+
try {
|
|
14334
|
+
const response = await this.fetchWithTimeout(url, {
|
|
14335
|
+
method,
|
|
14336
|
+
headers,
|
|
14337
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
14338
|
+
signal: options.signal
|
|
14339
|
+
}, timeout);
|
|
14340
|
+
if (response.ok) {
|
|
14341
|
+
const text = await response.text();
|
|
14342
|
+
if (!text) {
|
|
14343
|
+
return;
|
|
14344
|
+
}
|
|
14345
|
+
return JSON.parse(text);
|
|
14346
|
+
}
|
|
14347
|
+
const errorBody = await this.parseErrorBody(response);
|
|
14348
|
+
const retryAfter = this.parseRetryAfter(response);
|
|
14349
|
+
const error = (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody, retryAfter);
|
|
14350
|
+
if (RETRY_STATUS_CODES.includes(response.status) && attempt < this.maxRetries) {
|
|
14351
|
+
lastError = error;
|
|
14352
|
+
await this.sleep(this.getRetryDelay(attempt, retryAfter));
|
|
14353
|
+
attempt++;
|
|
14354
|
+
continue;
|
|
14355
|
+
}
|
|
14356
|
+
throw error;
|
|
14357
|
+
} catch (error) {
|
|
14358
|
+
if (error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
14359
|
+
if (attempt < this.maxRetries) {
|
|
14360
|
+
lastError = error;
|
|
14361
|
+
await this.sleep(this.getRetryDelay(attempt));
|
|
14362
|
+
attempt++;
|
|
14363
|
+
continue;
|
|
14364
|
+
}
|
|
14365
|
+
}
|
|
14366
|
+
if (error instanceof errors_1.RateLimitError || error instanceof errors_1.ServerError || error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
14367
|
+
throw error;
|
|
14368
|
+
}
|
|
14369
|
+
throw error;
|
|
14370
|
+
}
|
|
14371
|
+
}
|
|
14372
|
+
throw lastError || new Error("Request failed after retries");
|
|
14373
|
+
}
|
|
14374
|
+
async get(path, options) {
|
|
14375
|
+
return this.request("GET", path, options);
|
|
14376
|
+
}
|
|
14377
|
+
async post(path, options) {
|
|
14378
|
+
return this.request("POST", path, options);
|
|
14379
|
+
}
|
|
14380
|
+
async put(path, options) {
|
|
14381
|
+
return this.request("PUT", path, options);
|
|
14382
|
+
}
|
|
14383
|
+
async patch(path, options) {
|
|
14384
|
+
return this.request("PATCH", path, options);
|
|
14385
|
+
}
|
|
14386
|
+
async delete(path, options) {
|
|
14387
|
+
return this.request("DELETE", path, options);
|
|
14388
|
+
}
|
|
14389
|
+
async stream(method, path, options = {}) {
|
|
14390
|
+
const url = this.buildURL(path, options.query);
|
|
14391
|
+
const headers = {
|
|
14392
|
+
...this.buildHeaders(options.headers),
|
|
14393
|
+
Accept: "text/event-stream"
|
|
14394
|
+
};
|
|
14395
|
+
const timeout = options.timeout ?? this.timeout;
|
|
14396
|
+
const response = await this.fetchWithTimeout(url, {
|
|
14397
|
+
method,
|
|
14398
|
+
headers,
|
|
14399
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
14400
|
+
signal: options.signal
|
|
14401
|
+
}, timeout);
|
|
14402
|
+
if (!response.ok) {
|
|
14403
|
+
const errorBody = await this.parseErrorBody(response);
|
|
14404
|
+
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
14405
|
+
}
|
|
14406
|
+
return response;
|
|
14407
|
+
}
|
|
14408
|
+
async upload(path, formData, options = {}) {
|
|
14409
|
+
const url = this.buildURL(path, options.query);
|
|
14410
|
+
const headers = {};
|
|
14411
|
+
if (this.apiKey) {
|
|
14412
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
14413
|
+
}
|
|
14414
|
+
if (options.headers) {
|
|
14415
|
+
Object.assign(headers, options.headers);
|
|
14416
|
+
}
|
|
14417
|
+
const timeout = options.timeout ?? this.timeout;
|
|
14418
|
+
const response = await this.fetchWithTimeout(url, {
|
|
14419
|
+
method: "POST",
|
|
14420
|
+
headers,
|
|
14421
|
+
body: formData,
|
|
14422
|
+
signal: options.signal
|
|
14423
|
+
}, timeout);
|
|
14424
|
+
if (!response.ok) {
|
|
14425
|
+
const errorBody = await this.parseErrorBody(response);
|
|
14426
|
+
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
14427
|
+
}
|
|
14428
|
+
const text = await response.text();
|
|
14429
|
+
if (!text) {
|
|
14430
|
+
return;
|
|
14431
|
+
}
|
|
14432
|
+
return JSON.parse(text);
|
|
14433
|
+
}
|
|
14434
|
+
buildURL(path, query) {
|
|
14435
|
+
const url = new URL(path, this.baseURL);
|
|
14436
|
+
const mergedQuery = {
|
|
14437
|
+
...this.defaultQuery ?? {},
|
|
14438
|
+
...query ?? {}
|
|
14439
|
+
};
|
|
14440
|
+
for (const [key, value] of Object.entries(mergedQuery)) {
|
|
14441
|
+
if (value === undefined) {
|
|
14442
|
+
continue;
|
|
14443
|
+
}
|
|
14444
|
+
if (Array.isArray(value)) {
|
|
14445
|
+
for (const entry of value) {
|
|
14446
|
+
url.searchParams.append(key, String(entry));
|
|
14447
|
+
}
|
|
14448
|
+
continue;
|
|
14449
|
+
}
|
|
14450
|
+
url.searchParams.set(key, String(value));
|
|
14451
|
+
}
|
|
14452
|
+
return url.toString();
|
|
14453
|
+
}
|
|
14454
|
+
buildHeaders(extra) {
|
|
14455
|
+
const headers = { ...this.defaultHeaders };
|
|
14456
|
+
if (this.apiKey) {
|
|
14457
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
14458
|
+
}
|
|
14459
|
+
if (extra) {
|
|
14460
|
+
Object.assign(headers, extra);
|
|
14461
|
+
}
|
|
14462
|
+
return headers;
|
|
14463
|
+
}
|
|
14464
|
+
async fetchWithTimeout(url, init, timeout) {
|
|
14465
|
+
const controller = new AbortController;
|
|
14466
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
14467
|
+
if (init.signal) {
|
|
14468
|
+
init.signal.addEventListener("abort", () => controller.abort());
|
|
14469
|
+
}
|
|
14470
|
+
try {
|
|
14471
|
+
const response = await fetch(url, {
|
|
14472
|
+
...init,
|
|
14473
|
+
signal: controller.signal
|
|
14474
|
+
});
|
|
14475
|
+
return response;
|
|
14476
|
+
} catch (error) {
|
|
14477
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
14478
|
+
throw new errors_1.TimeoutError(`Request timed out after ${timeout}ms`);
|
|
14479
|
+
}
|
|
14480
|
+
if (error instanceof TypeError) {
|
|
14481
|
+
throw new errors_1.ConnectionError(error.message);
|
|
14482
|
+
}
|
|
14483
|
+
throw error;
|
|
14484
|
+
} finally {
|
|
14485
|
+
clearTimeout(timeoutId);
|
|
14486
|
+
}
|
|
14487
|
+
}
|
|
14488
|
+
async parseErrorBody(response) {
|
|
14489
|
+
try {
|
|
14490
|
+
const body = await response.json();
|
|
14491
|
+
return {
|
|
14492
|
+
message: body.detail || body.message || body.error,
|
|
14493
|
+
...body
|
|
14494
|
+
};
|
|
14495
|
+
} catch {
|
|
14496
|
+
return { message: `HTTP ${response.status}` };
|
|
14497
|
+
}
|
|
14498
|
+
}
|
|
14499
|
+
parseRetryAfter(response) {
|
|
14500
|
+
const header = response.headers.get("Retry-After");
|
|
14501
|
+
if (!header)
|
|
14502
|
+
return;
|
|
14503
|
+
const seconds = Number.parseInt(header, 10);
|
|
14504
|
+
if (!Number.isNaN(seconds)) {
|
|
14505
|
+
return seconds * 1000;
|
|
14506
|
+
}
|
|
14507
|
+
const date = Date.parse(header);
|
|
14508
|
+
if (!Number.isNaN(date)) {
|
|
14509
|
+
return Math.max(0, date - Date.now());
|
|
14510
|
+
}
|
|
14511
|
+
return;
|
|
14512
|
+
}
|
|
14513
|
+
getRetryDelay(attempt, retryAfter) {
|
|
14514
|
+
if (retryAfter) {
|
|
14515
|
+
return retryAfter;
|
|
14516
|
+
}
|
|
14517
|
+
return INITIAL_RETRY_DELAY * 2 ** attempt;
|
|
14518
|
+
}
|
|
14519
|
+
sleep(ms) {
|
|
14520
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14521
|
+
}
|
|
14522
|
+
}
|
|
14523
|
+
exports.HonchoHTTPClient = HonchoHTTPClient;
|
|
14234
14524
|
});
|
|
14235
14525
|
|
|
14236
14526
|
// node_modules/@honcho-ai/sdk/dist/http/streaming.js
|
|
@@ -14283,10 +14573,14 @@ var require_streaming = __commonJS(function(exports) {
|
|
|
14283
14573
|
}
|
|
14284
14574
|
|
|
14285
14575
|
class DialecticStreamResponse {
|
|
14286
|
-
constructor(generator) {
|
|
14576
|
+
constructor(generator, evidenceSource) {
|
|
14287
14577
|
this.chunks = [];
|
|
14288
14578
|
this.consumed = false;
|
|
14289
14579
|
this.generator = generator;
|
|
14580
|
+
this.evidenceSource = evidenceSource;
|
|
14581
|
+
}
|
|
14582
|
+
get evidence() {
|
|
14583
|
+
return this.evidenceSource?.() ?? null;
|
|
14290
14584
|
}
|
|
14291
14585
|
async* [Symbol.asyncIterator]() {
|
|
14292
14586
|
if (this.consumed) {
|
|
@@ -14316,9 +14610,11 @@ var require_streaming = __commonJS(function(exports) {
|
|
|
14316
14610
|
}
|
|
14317
14611
|
exports.DialecticStreamResponse = DialecticStreamResponse;
|
|
14318
14612
|
function createDialecticStream(response) {
|
|
14613
|
+
let evidence = null;
|
|
14319
14614
|
async function* streamContent() {
|
|
14320
14615
|
for await (const chunk of parseSSE(response)) {
|
|
14321
14616
|
if (chunk.done) {
|
|
14617
|
+
evidence = chunk.evidence ?? null;
|
|
14322
14618
|
return;
|
|
14323
14619
|
}
|
|
14324
14620
|
const content = chunk.delta?.content;
|
|
@@ -14327,10 +14623,37 @@ var require_streaming = __commonJS(function(exports) {
|
|
|
14327
14623
|
}
|
|
14328
14624
|
}
|
|
14329
14625
|
}
|
|
14330
|
-
return new DialecticStreamResponse(streamContent());
|
|
14626
|
+
return new DialecticStreamResponse(streamContent(), () => evidence);
|
|
14331
14627
|
}
|
|
14332
14628
|
});
|
|
14333
14629
|
|
|
14630
|
+
// node_modules/@honcho-ai/sdk/dist/message.js
|
|
14631
|
+
var require_message = __commonJS(function(exports) {
|
|
14632
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14633
|
+
exports.Message = undefined;
|
|
14634
|
+
|
|
14635
|
+
class Message {
|
|
14636
|
+
constructor(id, content, peerId, sessionId, workspaceId, metadata, createdAt, tokenCount) {
|
|
14637
|
+
this.id = id;
|
|
14638
|
+
this.content = content;
|
|
14639
|
+
this.peerId = peerId;
|
|
14640
|
+
this.sessionId = sessionId;
|
|
14641
|
+
this.workspaceId = workspaceId;
|
|
14642
|
+
this.metadata = metadata;
|
|
14643
|
+
this.createdAt = createdAt;
|
|
14644
|
+
this.tokenCount = tokenCount;
|
|
14645
|
+
}
|
|
14646
|
+
static fromApiResponse(data) {
|
|
14647
|
+
return new Message(data.id, data.content, data.peer_id, data.session_id, data.workspace_id, data.metadata, data.created_at, data.token_count);
|
|
14648
|
+
}
|
|
14649
|
+
toString() {
|
|
14650
|
+
const truncatedContent = this.content.length > 50 ? `${this.content.slice(0, 50)}...` : this.content;
|
|
14651
|
+
return `Message(id='${this.id}', peerId='${this.peerId}', content='${truncatedContent}')`;
|
|
14652
|
+
}
|
|
14653
|
+
}
|
|
14654
|
+
exports.Message = Message;
|
|
14655
|
+
});
|
|
14656
|
+
|
|
14334
14657
|
// node_modules/@honcho-ai/sdk/dist/session_context.js
|
|
14335
14658
|
var require_session_context = __commonJS(function(exports) {
|
|
14336
14659
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -14505,12 +14828,18 @@ var require_session = __commonJS(function(exports) {
|
|
|
14505
14828
|
get createdAt() {
|
|
14506
14829
|
return this._createdAt;
|
|
14507
14830
|
}
|
|
14831
|
+
get uid() {
|
|
14832
|
+
return this._uid;
|
|
14833
|
+
}
|
|
14508
14834
|
get isActive() {
|
|
14509
14835
|
return this._isActive;
|
|
14510
14836
|
}
|
|
14837
|
+
get scopes() {
|
|
14838
|
+
return this._scopes;
|
|
14839
|
+
}
|
|
14511
14840
|
constructor(id, workspaceId, http, metadata, configuration, ensureWorkspace = async () => {
|
|
14512
14841
|
return;
|
|
14513
|
-
}, createdAt, isActive) {
|
|
14842
|
+
}, createdAt, isActive, uid, scopes) {
|
|
14514
14843
|
this.id = id;
|
|
14515
14844
|
this.workspaceId = workspaceId;
|
|
14516
14845
|
this._http = http;
|
|
@@ -14519,12 +14848,15 @@ var require_session = __commonJS(function(exports) {
|
|
|
14519
14848
|
this._ensureWorkspace = ensureWorkspace;
|
|
14520
14849
|
this._createdAt = createdAt;
|
|
14521
14850
|
this._isActive = isActive;
|
|
14851
|
+
this._uid = uid;
|
|
14852
|
+
this._scopes = scopes;
|
|
14522
14853
|
}
|
|
14523
14854
|
_applySessionResponse(session) {
|
|
14524
14855
|
this._metadata = session.metadata || {};
|
|
14525
14856
|
this._configuration = (0, validation_1.sessionConfigFromApi)(session.configuration) || {};
|
|
14526
14857
|
this._createdAt = session.created_at;
|
|
14527
14858
|
this._isActive = session.is_active;
|
|
14859
|
+
this._uid = session.uid;
|
|
14528
14860
|
}
|
|
14529
14861
|
async _getOrCreate(params) {
|
|
14530
14862
|
await this._ensureWorkspace();
|
|
@@ -14648,7 +14980,7 @@ var require_session = __commonJS(function(exports) {
|
|
|
14648
14980
|
}
|
|
14649
14981
|
async peers() {
|
|
14650
14982
|
const peersPage = await this._listPeers();
|
|
14651
|
-
return peersPage.items.map((peer) => new peer_1.Peer(peer.id, this.workspaceId, this._http, peer.metadata ?? undefined, (0, validation_1.peerConfigFromApi)(peer.configuration) ?? undefined, () => this._ensureWorkspace(), peer.created_at));
|
|
14983
|
+
return peersPage.items.map((peer) => new peer_1.Peer(peer.id, this.workspaceId, this._http, peer.metadata ?? undefined, (0, validation_1.peerConfigFromApi)(peer.configuration) ?? undefined, () => this._ensureWorkspace(), peer.created_at, peer.uid));
|
|
14652
14984
|
}
|
|
14653
14985
|
async getPeerConfiguration(peer) {
|
|
14654
14986
|
const peerId = typeof peer === "string" ? peer : peer.id;
|
|
@@ -14732,7 +15064,7 @@ var require_session = __commonJS(function(exports) {
|
|
|
14732
15064
|
}
|
|
14733
15065
|
async clone(messageId) {
|
|
14734
15066
|
const clonedSessionData = await this._clone(messageId ? { message_id: messageId } : undefined);
|
|
14735
|
-
return new Session(clonedSessionData.id, this.workspaceId, this._http, clonedSessionData.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(clonedSessionData.configuration) ?? undefined, () => this._ensureWorkspace(), clonedSessionData.created_at, clonedSessionData.is_active);
|
|
15067
|
+
return new Session(clonedSessionData.id, this.workspaceId, this._http, clonedSessionData.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(clonedSessionData.configuration) ?? undefined, () => this._ensureWorkspace(), clonedSessionData.created_at, clonedSessionData.is_active, clonedSessionData.uid);
|
|
14736
15068
|
}
|
|
14737
15069
|
async context(options) {
|
|
14738
15070
|
const opts = options || {};
|
|
@@ -14744,6 +15076,8 @@ var require_session = __commonJS(function(exports) {
|
|
|
14744
15076
|
tokens: opts.tokens,
|
|
14745
15077
|
peerTarget: peerTargetId,
|
|
14746
15078
|
peerPerspective: peerPerspectiveId,
|
|
15079
|
+
scope: opts.scope !== undefined ? (0, utils_1.resolveId)(opts.scope) : undefined,
|
|
15080
|
+
sessions: opts.sessions,
|
|
14747
15081
|
limitToSession: opts.limitToSession,
|
|
14748
15082
|
representationOptions: opts.representationOptions ? {
|
|
14749
15083
|
...opts.representationOptions,
|
|
@@ -14756,6 +15090,8 @@ var require_session = __commonJS(function(exports) {
|
|
|
14756
15090
|
search_query: searchQuery,
|
|
14757
15091
|
peer_target: contextParams.peerTarget,
|
|
14758
15092
|
peer_perspective: contextParams.peerPerspective,
|
|
15093
|
+
scope: contextParams.scope,
|
|
15094
|
+
sessions: contextParams.sessions,
|
|
14759
15095
|
limit_to_session: contextParams.limitToSession,
|
|
14760
15096
|
search_top_k: contextParams.representationOptions?.searchTopK,
|
|
14761
15097
|
search_max_distance: contextParams.representationOptions?.searchMaxDistance,
|
|
@@ -14872,6 +15208,7 @@ var require_session = __commonJS(function(exports) {
|
|
|
14872
15208
|
var require_peer = __commonJS(function(exports) {
|
|
14873
15209
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14874
15210
|
exports.Peer = exports.PeerContext = undefined;
|
|
15211
|
+
var zod_1 = require_zod();
|
|
14875
15212
|
var api_version_1 = require_api_version();
|
|
14876
15213
|
var conclusions_1 = require_conclusions();
|
|
14877
15214
|
var streaming_1 = require_streaming();
|
|
@@ -14906,9 +15243,12 @@ var require_peer = __commonJS(function(exports) {
|
|
|
14906
15243
|
get createdAt() {
|
|
14907
15244
|
return this._createdAt;
|
|
14908
15245
|
}
|
|
15246
|
+
get uid() {
|
|
15247
|
+
return this._uid;
|
|
15248
|
+
}
|
|
14909
15249
|
constructor(id, workspaceId, http, metadata, configuration, ensureWorkspace = async () => {
|
|
14910
15250
|
return;
|
|
14911
|
-
}, createdAt) {
|
|
15251
|
+
}, createdAt, uid) {
|
|
14912
15252
|
this.id = id;
|
|
14913
15253
|
this.workspaceId = workspaceId;
|
|
14914
15254
|
this._http = http;
|
|
@@ -14916,6 +15256,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
14916
15256
|
this._configuration = configuration;
|
|
14917
15257
|
this._ensureWorkspace = ensureWorkspace;
|
|
14918
15258
|
this._createdAt = createdAt;
|
|
15259
|
+
this._uid = uid;
|
|
14919
15260
|
}
|
|
14920
15261
|
async _getOrCreate(params) {
|
|
14921
15262
|
await this._ensureWorkspace();
|
|
@@ -14936,6 +15277,15 @@ var require_peer = __commonJS(function(exports) {
|
|
|
14936
15277
|
}
|
|
14937
15278
|
});
|
|
14938
15279
|
}
|
|
15280
|
+
static toResponseFormatSchema(responseFormat) {
|
|
15281
|
+
if (!responseFormat) {
|
|
15282
|
+
return;
|
|
15283
|
+
}
|
|
15284
|
+
if (responseFormat instanceof zod_1.ZodType) {
|
|
15285
|
+
return zod_1.z.toJSONSchema(responseFormat);
|
|
15286
|
+
}
|
|
15287
|
+
return responseFormat;
|
|
15288
|
+
}
|
|
14939
15289
|
async _chat(params) {
|
|
14940
15290
|
await this._ensureWorkspace();
|
|
14941
15291
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/peers/${this.id}/chat`, { body: params });
|
|
@@ -14977,19 +15327,28 @@ var require_peer = __commonJS(function(exports) {
|
|
|
14977
15327
|
query,
|
|
14978
15328
|
target: targetId,
|
|
14979
15329
|
session: resolvedSessionId,
|
|
14980
|
-
|
|
15330
|
+
scope: options?.scope,
|
|
15331
|
+
sessions: options?.sessions,
|
|
15332
|
+
reasoningLevel: options?.reasoningLevel,
|
|
15333
|
+
responseFormat: options?.responseFormat,
|
|
15334
|
+
includeEvidence: options?.includeEvidence
|
|
14981
15335
|
});
|
|
15336
|
+
const zodSchema = options?.responseFormat instanceof zod_1.ZodType ? options.responseFormat : undefined;
|
|
14982
15337
|
const response = await this._chat({
|
|
14983
15338
|
query: chatParams.query,
|
|
14984
15339
|
stream: false,
|
|
14985
15340
|
target: chatParams.target,
|
|
14986
15341
|
session_id: chatParams.session,
|
|
14987
|
-
|
|
15342
|
+
...(0, validation_1.scopeRecallFields)(chatParams),
|
|
15343
|
+
reasoning_level: chatParams.reasoningLevel,
|
|
15344
|
+
response_format: Peer.toResponseFormatSchema(options?.responseFormat),
|
|
15345
|
+
include_evidence: chatParams.includeEvidence ? true : undefined
|
|
14988
15346
|
});
|
|
14989
|
-
|
|
14990
|
-
|
|
15347
|
+
const content = response.content ? zodSchema ? zodSchema.parse(JSON.parse(response.content)) : response.content : null;
|
|
15348
|
+
if (!chatParams.includeEvidence) {
|
|
15349
|
+
return content;
|
|
14991
15350
|
}
|
|
14992
|
-
return response.
|
|
15351
|
+
return { content, evidence: response.evidence ?? null };
|
|
14993
15352
|
}
|
|
14994
15353
|
async chatStream(query, options) {
|
|
14995
15354
|
const targetId = options?.target ? typeof options.target === "string" ? options.target : options.target.id : undefined;
|
|
@@ -14998,13 +15357,20 @@ var require_peer = __commonJS(function(exports) {
|
|
|
14998
15357
|
query,
|
|
14999
15358
|
target: targetId,
|
|
15000
15359
|
session: resolvedSessionId,
|
|
15001
|
-
|
|
15360
|
+
scope: options?.scope,
|
|
15361
|
+
sessions: options?.sessions,
|
|
15362
|
+
reasoningLevel: options?.reasoningLevel,
|
|
15363
|
+
responseFormat: options?.responseFormat,
|
|
15364
|
+
includeEvidence: options?.includeEvidence
|
|
15002
15365
|
});
|
|
15003
15366
|
const response = await this._chatStream({
|
|
15004
15367
|
query: chatParams.query,
|
|
15005
15368
|
target: chatParams.target,
|
|
15006
15369
|
session_id: chatParams.session,
|
|
15007
|
-
|
|
15370
|
+
...(0, validation_1.scopeRecallFields)(chatParams),
|
|
15371
|
+
reasoning_level: chatParams.reasoningLevel,
|
|
15372
|
+
response_format: Peer.toResponseFormatSchema(options?.responseFormat),
|
|
15373
|
+
include_evidence: chatParams.includeEvidence ? true : undefined
|
|
15008
15374
|
});
|
|
15009
15375
|
return (0, streaming_1.createDialecticStream)(response);
|
|
15010
15376
|
}
|
|
@@ -15031,7 +15397,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15031
15397
|
reverse
|
|
15032
15398
|
});
|
|
15033
15399
|
};
|
|
15034
|
-
return new pagination_1.Page(sessionsPage, (session) => new session_1.Session(session.id, this.workspaceId, this._http, session.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(session.configuration) ?? undefined, () => this._ensureWorkspace(), session.created_at, session.is_active), fetchNextPage);
|
|
15400
|
+
return new pagination_1.Page(sessionsPage, (session) => new session_1.Session(session.id, this.workspaceId, this._http, session.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(session.configuration) ?? undefined, () => this._ensureWorkspace(), session.created_at, session.is_active, session.uid), fetchNextPage);
|
|
15035
15401
|
}
|
|
15036
15402
|
message(content, options) {
|
|
15037
15403
|
const validatedContent = validation_1.MessageContentSchema.parse(content);
|
|
@@ -15050,6 +15416,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15050
15416
|
const peer = await this._getOrCreate({ id: this.id });
|
|
15051
15417
|
this._metadata = peer.metadata || {};
|
|
15052
15418
|
this._createdAt = peer.created_at;
|
|
15419
|
+
this._uid = peer.uid;
|
|
15053
15420
|
return this._metadata;
|
|
15054
15421
|
}
|
|
15055
15422
|
async setMetadata(metadata) {
|
|
@@ -15061,6 +15428,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15061
15428
|
const peer = await this._getOrCreate({ id: this.id });
|
|
15062
15429
|
this._configuration = (0, validation_1.peerConfigFromApi)(peer.configuration) || {};
|
|
15063
15430
|
this._createdAt = peer.created_at;
|
|
15431
|
+
this._uid = peer.uid;
|
|
15064
15432
|
return this._configuration;
|
|
15065
15433
|
}
|
|
15066
15434
|
async setConfiguration(configuration) {
|
|
@@ -15073,6 +15441,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15073
15441
|
this._metadata = peer.metadata || {};
|
|
15074
15442
|
this._configuration = (0, validation_1.peerConfigFromApi)(peer.configuration) || {};
|
|
15075
15443
|
this._createdAt = peer.created_at;
|
|
15444
|
+
this._uid = peer.uid;
|
|
15076
15445
|
}
|
|
15077
15446
|
async search(query, options) {
|
|
15078
15447
|
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
@@ -15108,6 +15477,8 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15108
15477
|
const searchQuery = (0, validation_1.normalizeSearchQuery)(options?.searchQuery);
|
|
15109
15478
|
const getRepresentationParams = validation_1.PeerGetRepresentationParamsSchema.parse({
|
|
15110
15479
|
session: options?.session,
|
|
15480
|
+
scope: options?.scope,
|
|
15481
|
+
sessions: options?.sessions,
|
|
15111
15482
|
target: options?.target,
|
|
15112
15483
|
options: {
|
|
15113
15484
|
searchQuery,
|
|
@@ -15121,6 +15492,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15121
15492
|
const targetId = getRepresentationParams.target ? typeof getRepresentationParams.target === "string" ? getRepresentationParams.target : getRepresentationParams.target.id : undefined;
|
|
15122
15493
|
const response = await this._getRepresentation({
|
|
15123
15494
|
session_id: sessionId,
|
|
15495
|
+
...(0, validation_1.scopeRecallFields)(getRepresentationParams),
|
|
15124
15496
|
target: targetId,
|
|
15125
15497
|
search_query: searchQuery,
|
|
15126
15498
|
search_top_k: getRepresentationParams.options?.searchTopK,
|
|
@@ -15151,11 +15523,11 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15151
15523
|
return PeerContext.fromApiResponse(response);
|
|
15152
15524
|
}
|
|
15153
15525
|
get conclusions() {
|
|
15154
|
-
return new conclusions_1.
|
|
15526
|
+
return new conclusions_1.ConclusionsView(this._http, this.workspaceId, this.id, this.id, () => this._ensureWorkspace());
|
|
15155
15527
|
}
|
|
15156
15528
|
conclusionsOf(target) {
|
|
15157
15529
|
const targetId = typeof target === "string" ? target : target.id;
|
|
15158
|
-
return new conclusions_1.
|
|
15530
|
+
return new conclusions_1.ConclusionsView(this._http, this.workspaceId, this.id, targetId, () => this._ensureWorkspace());
|
|
15159
15531
|
}
|
|
15160
15532
|
toString() {
|
|
15161
15533
|
return `Peer(id='${this.id}')`;
|
|
@@ -15164,15 +15536,125 @@ var require_peer = __commonJS(function(exports) {
|
|
|
15164
15536
|
exports.Peer = Peer;
|
|
15165
15537
|
});
|
|
15166
15538
|
|
|
15539
|
+
// node_modules/@honcho-ai/sdk/dist/scope.js
|
|
15540
|
+
var require_scope = __commonJS(function(exports) {
|
|
15541
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15542
|
+
exports.Scope = undefined;
|
|
15543
|
+
var api_version_1 = require_api_version();
|
|
15544
|
+
var pagination_1 = require_pagination();
|
|
15545
|
+
var session_1 = require_session();
|
|
15546
|
+
var utils_1 = require_utils();
|
|
15547
|
+
var validation_1 = require_validation();
|
|
15548
|
+
|
|
15549
|
+
class Scope {
|
|
15550
|
+
get metadata() {
|
|
15551
|
+
return this._metadata;
|
|
15552
|
+
}
|
|
15553
|
+
get createdAt() {
|
|
15554
|
+
return this._createdAt;
|
|
15555
|
+
}
|
|
15556
|
+
get sessionCount() {
|
|
15557
|
+
return this._sessionCount;
|
|
15558
|
+
}
|
|
15559
|
+
constructor(id, workspaceId, http, metadata, ensureWorkspace = async () => {
|
|
15560
|
+
return;
|
|
15561
|
+
}, createdAt, sessionCount) {
|
|
15562
|
+
this.id = id;
|
|
15563
|
+
this.workspaceId = workspaceId;
|
|
15564
|
+
this._http = http;
|
|
15565
|
+
this._metadata = metadata;
|
|
15566
|
+
this._ensureWorkspace = ensureWorkspace;
|
|
15567
|
+
this._createdAt = createdAt;
|
|
15568
|
+
this._sessionCount = sessionCount;
|
|
15569
|
+
}
|
|
15570
|
+
get _basePath() {
|
|
15571
|
+
return `/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/scopes/${this.id}`;
|
|
15572
|
+
}
|
|
15573
|
+
async _addSessions(sessionIds) {
|
|
15574
|
+
await this._ensureWorkspace();
|
|
15575
|
+
await this._http.post(`${this._basePath}/sessions`, {
|
|
15576
|
+
body: { session_ids: sessionIds }
|
|
15577
|
+
});
|
|
15578
|
+
}
|
|
15579
|
+
async _removeSessions(sessionIds) {
|
|
15580
|
+
await this._ensureWorkspace();
|
|
15581
|
+
await this._http.post(`${this._basePath}/sessions/remove`, {
|
|
15582
|
+
body: { session_ids: sessionIds }
|
|
15583
|
+
});
|
|
15584
|
+
}
|
|
15585
|
+
async _removeSession(sessionId) {
|
|
15586
|
+
await this._ensureWorkspace();
|
|
15587
|
+
await this._http.delete(`${this._basePath}/sessions/${sessionId}`);
|
|
15588
|
+
}
|
|
15589
|
+
async _listSessions(params) {
|
|
15590
|
+
await this._ensureWorkspace();
|
|
15591
|
+
return this._http.post(`${this._basePath}/sessions/list`, {
|
|
15592
|
+
query: {
|
|
15593
|
+
page: params?.page,
|
|
15594
|
+
size: params?.size,
|
|
15595
|
+
reverse: params?.reverse ? "true" : undefined
|
|
15596
|
+
}
|
|
15597
|
+
});
|
|
15598
|
+
}
|
|
15599
|
+
async _getStatus() {
|
|
15600
|
+
await this._ensureWorkspace();
|
|
15601
|
+
return this._http.get(`${this._basePath}/status`);
|
|
15602
|
+
}
|
|
15603
|
+
async addSessions(sessions) {
|
|
15604
|
+
const sessionIds = validation_1.ScopeSessionsSchema.parse(sessions.map(utils_1.resolveId));
|
|
15605
|
+
await this._addSessions(sessionIds);
|
|
15606
|
+
}
|
|
15607
|
+
async removeSessions(sessions) {
|
|
15608
|
+
const sessionIds = validation_1.ScopeSessionsSchema.parse(sessions.map(utils_1.resolveId));
|
|
15609
|
+
await this._removeSessions(sessionIds);
|
|
15610
|
+
}
|
|
15611
|
+
async removeSession(session) {
|
|
15612
|
+
await this._removeSession(validation_1.SessionIdSchema.parse((0, utils_1.resolveId)(session)));
|
|
15613
|
+
}
|
|
15614
|
+
async sessions(options) {
|
|
15615
|
+
const reverse = options?.reverse;
|
|
15616
|
+
const sessionsPage = await this._listSessions({
|
|
15617
|
+
page: options?.page,
|
|
15618
|
+
size: options?.size,
|
|
15619
|
+
reverse
|
|
15620
|
+
});
|
|
15621
|
+
const fetchNextPage = async (page, size) => {
|
|
15622
|
+
return this._listSessions({ page, size, reverse });
|
|
15623
|
+
};
|
|
15624
|
+
return new pagination_1.Page(sessionsPage, (session) => new session_1.Session(session.id, this.workspaceId, this._http, session.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(session.configuration) ?? undefined, () => this._ensureWorkspace(), session.created_at, session.is_active, session.uid), fetchNextPage);
|
|
15625
|
+
}
|
|
15626
|
+
async status() {
|
|
15627
|
+
const response = await this._getStatus();
|
|
15628
|
+
return {
|
|
15629
|
+
backfillStatus: Object.fromEntries(Object.entries(response.backfill_status ?? {}).map(([sessionId, job]) => [
|
|
15630
|
+
sessionId,
|
|
15631
|
+
{
|
|
15632
|
+
state: job.state,
|
|
15633
|
+
updatedAt: job.updated_at,
|
|
15634
|
+
docsCopied: job.docs_copied
|
|
15635
|
+
}
|
|
15636
|
+
]))
|
|
15637
|
+
};
|
|
15638
|
+
}
|
|
15639
|
+
toString() {
|
|
15640
|
+
return `Scope(id='${this.id}', workspaceId='${this.workspaceId}')`;
|
|
15641
|
+
}
|
|
15642
|
+
}
|
|
15643
|
+
exports.Scope = Scope;
|
|
15644
|
+
});
|
|
15645
|
+
|
|
15167
15646
|
// node_modules/@honcho-ai/sdk/dist/client.js
|
|
15168
15647
|
var require_client2 = __commonJS(function(exports) {
|
|
15169
15648
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15170
15649
|
exports.Honcho = undefined;
|
|
15171
15650
|
var api_version_1 = require_api_version();
|
|
15651
|
+
var conclusions_1 = require_conclusions();
|
|
15172
15652
|
var client_1 = require_client();
|
|
15653
|
+
var streaming_1 = require_streaming();
|
|
15173
15654
|
var message_1 = require_message();
|
|
15174
15655
|
var pagination_1 = require_pagination();
|
|
15175
15656
|
var peer_1 = require_peer();
|
|
15657
|
+
var scope_1 = require_scope();
|
|
15176
15658
|
var session_1 = require_session();
|
|
15177
15659
|
var utils_1 = require_utils();
|
|
15178
15660
|
var validation_1 = require_validation();
|
|
@@ -15185,9 +15667,15 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15185
15667
|
get configuration() {
|
|
15186
15668
|
return this._configuration;
|
|
15187
15669
|
}
|
|
15670
|
+
get uid() {
|
|
15671
|
+
return this._uid;
|
|
15672
|
+
}
|
|
15188
15673
|
get http() {
|
|
15189
15674
|
return this._http;
|
|
15190
15675
|
}
|
|
15676
|
+
get conclusions() {
|
|
15677
|
+
return new conclusions_1.WorkspaceConclusions(this._http, this.workspaceId, () => this._ensureWorkspace());
|
|
15678
|
+
}
|
|
15191
15679
|
get baseURL() {
|
|
15192
15680
|
return this._http.baseURL;
|
|
15193
15681
|
}
|
|
@@ -15210,13 +15698,15 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15210
15698
|
});
|
|
15211
15699
|
}
|
|
15212
15700
|
async _getOrCreateWorkspace(id, params) {
|
|
15213
|
-
|
|
15701
|
+
const workspace = await this._http.post(`/${api_version_1.API_VERSION}/workspaces`, {
|
|
15214
15702
|
body: {
|
|
15215
15703
|
id,
|
|
15216
15704
|
metadata: params?.metadata,
|
|
15217
15705
|
configuration: (0, validation_1.workspaceConfigToApi)(params?.configuration)
|
|
15218
15706
|
}
|
|
15219
15707
|
});
|
|
15708
|
+
this._uid = workspace.uid;
|
|
15709
|
+
return workspace;
|
|
15220
15710
|
}
|
|
15221
15711
|
async _ensureWorkspace() {
|
|
15222
15712
|
if (!this._workspaceReady) {
|
|
@@ -15244,7 +15734,8 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15244
15734
|
},
|
|
15245
15735
|
query: {
|
|
15246
15736
|
page: params?.page,
|
|
15247
|
-
size: params?.size
|
|
15737
|
+
size: params?.size,
|
|
15738
|
+
reverse: params?.reverse ? "true" : undefined
|
|
15248
15739
|
}
|
|
15249
15740
|
});
|
|
15250
15741
|
}
|
|
@@ -15267,20 +15758,42 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15267
15758
|
query: {
|
|
15268
15759
|
page: params?.page,
|
|
15269
15760
|
size: params?.size,
|
|
15270
|
-
reverse: params?.reverse ? "true" : undefined
|
|
15761
|
+
reverse: params?.reverse ? "true" : undefined
|
|
15762
|
+
}
|
|
15763
|
+
});
|
|
15764
|
+
}
|
|
15765
|
+
async _getOrCreatePeer(workspaceId, params) {
|
|
15766
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/peers`, { body: params });
|
|
15767
|
+
}
|
|
15768
|
+
async _getOrCreateScope(workspaceId, params) {
|
|
15769
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/scopes`, { body: params });
|
|
15770
|
+
}
|
|
15771
|
+
async _getScope(workspaceId, scopeId) {
|
|
15772
|
+
return this._http.get(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/scopes/${scopeId}`);
|
|
15773
|
+
}
|
|
15774
|
+
async _listScopes(workspaceId, params) {
|
|
15775
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/scopes/list`, {
|
|
15776
|
+
body: { filters: params?.filters },
|
|
15777
|
+
query: {
|
|
15778
|
+
page: params?.page,
|
|
15779
|
+
size: params?.size,
|
|
15780
|
+
reverse: params?.reverse ? "true" : undefined,
|
|
15781
|
+
include_session_count: params?.includeSessionCount ? "true" : undefined
|
|
15271
15782
|
}
|
|
15272
15783
|
});
|
|
15273
15784
|
}
|
|
15274
|
-
async _getOrCreatePeer(workspaceId, params) {
|
|
15275
|
-
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/peers`, { body: params });
|
|
15276
|
-
}
|
|
15277
15785
|
async _listSessions(workspaceId, params) {
|
|
15278
15786
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/sessions/list`, {
|
|
15279
|
-
body: {
|
|
15787
|
+
body: {
|
|
15788
|
+
filters: params?.filters,
|
|
15789
|
+
scope: params?.scope,
|
|
15790
|
+
in_no_scope: params?.inNoScope ? true : undefined
|
|
15791
|
+
},
|
|
15280
15792
|
query: {
|
|
15281
15793
|
page: params?.page,
|
|
15282
15794
|
size: params?.size,
|
|
15283
|
-
reverse: params?.reverse ? "true" : undefined
|
|
15795
|
+
reverse: params?.reverse ? "true" : undefined,
|
|
15796
|
+
include_scopes: params?.includeScopes ? "true" : undefined
|
|
15284
15797
|
}
|
|
15285
15798
|
});
|
|
15286
15799
|
}
|
|
@@ -15289,7 +15802,22 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15289
15802
|
body: {
|
|
15290
15803
|
id: params.id,
|
|
15291
15804
|
metadata: params.metadata,
|
|
15292
|
-
configuration: (0, validation_1.sessionConfigToApi)(params.configuration)
|
|
15805
|
+
configuration: (0, validation_1.sessionConfigToApi)(params.configuration),
|
|
15806
|
+
peers: params.peers,
|
|
15807
|
+
scopes: params.scopes
|
|
15808
|
+
}
|
|
15809
|
+
});
|
|
15810
|
+
}
|
|
15811
|
+
async _workspaceChat(workspaceId, params) {
|
|
15812
|
+
await this._ensureWorkspace();
|
|
15813
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/chat`, { body: params });
|
|
15814
|
+
}
|
|
15815
|
+
async _workspaceChatStream(workspaceId, params) {
|
|
15816
|
+
await this._ensureWorkspace();
|
|
15817
|
+
return this._http.stream("POST", `/${api_version_1.API_VERSION}/workspaces/${workspaceId}/chat`, {
|
|
15818
|
+
body: {
|
|
15819
|
+
...params,
|
|
15820
|
+
stream: true
|
|
15293
15821
|
}
|
|
15294
15822
|
});
|
|
15295
15823
|
}
|
|
@@ -15303,7 +15831,7 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15303
15831
|
configuration: (0, validation_1.peerConfigToApi)(validatedConfiguration),
|
|
15304
15832
|
metadata: validatedMetadata
|
|
15305
15833
|
});
|
|
15306
|
-
return new peer_1.Peer(validatedId, this.workspaceId, this._http, peerData.metadata ?? undefined, (0, validation_1.peerConfigFromApi)(peerData.configuration) ?? undefined, () => this._ensureWorkspace(), peerData.created_at);
|
|
15834
|
+
return new peer_1.Peer(validatedId, this.workspaceId, this._http, peerData.metadata ?? undefined, (0, validation_1.peerConfigFromApi)(peerData.configuration) ?? undefined, () => this._ensureWorkspace(), peerData.created_at, peerData.uid);
|
|
15307
15835
|
}
|
|
15308
15836
|
async peers(options) {
|
|
15309
15837
|
await this._ensureWorkspace();
|
|
@@ -15329,19 +15857,55 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15329
15857
|
reverse
|
|
15330
15858
|
});
|
|
15331
15859
|
};
|
|
15332
|
-
return new pagination_1.Page(peersPage, (peer) => new peer_1.Peer(peer.id, this.workspaceId, this._http, peer.metadata ?? undefined, (0, validation_1.peerConfigFromApi)(peer.configuration) ?? undefined, () => this._ensureWorkspace(), peer.created_at), fetchNextPage);
|
|
15860
|
+
return new pagination_1.Page(peersPage, (peer) => new peer_1.Peer(peer.id, this.workspaceId, this._http, peer.metadata ?? undefined, (0, validation_1.peerConfigFromApi)(peer.configuration) ?? undefined, () => this._ensureWorkspace(), peer.created_at, peer.uid), fetchNextPage);
|
|
15333
15861
|
}
|
|
15334
15862
|
async session(id, options) {
|
|
15335
15863
|
await this._ensureWorkspace();
|
|
15336
15864
|
const validatedId = validation_1.SessionIdSchema.parse(id);
|
|
15337
15865
|
const validatedMetadata = options?.metadata ? validation_1.SessionMetadataSchema.parse(options.metadata) : undefined;
|
|
15338
15866
|
const validatedConfiguration = options?.configuration ? validation_1.SessionConfigSchema.parse(options.configuration) : undefined;
|
|
15867
|
+
const validatedPeers = options?.peers !== undefined ? validation_1.PeerAdditionToApiSchema.parse(options.peers) : undefined;
|
|
15868
|
+
const validatedScopes = options?.scopes !== undefined ? validation_1.SessionScopesSchema.parse(options.scopes.map(utils_1.resolveId)) : undefined;
|
|
15339
15869
|
const sessionData = await this._getOrCreateSession(this.workspaceId, {
|
|
15340
15870
|
id: validatedId,
|
|
15341
15871
|
configuration: validatedConfiguration,
|
|
15342
|
-
metadata: validatedMetadata
|
|
15872
|
+
metadata: validatedMetadata,
|
|
15873
|
+
peers: validatedPeers,
|
|
15874
|
+
scopes: validatedScopes
|
|
15875
|
+
});
|
|
15876
|
+
return new session_1.Session(validatedId, this.workspaceId, this._http, sessionData.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(sessionData.configuration) ?? undefined, () => this._ensureWorkspace(), sessionData.created_at, sessionData.is_active, sessionData.uid);
|
|
15877
|
+
}
|
|
15878
|
+
async scope(id, options) {
|
|
15879
|
+
await this._ensureWorkspace();
|
|
15880
|
+
const validatedId = validation_1.ScopeIdSchema.parse(id);
|
|
15881
|
+
const scopeData = await this._getOrCreateScope(this.workspaceId, {
|
|
15882
|
+
id: validatedId,
|
|
15883
|
+
metadata: options?.metadata
|
|
15884
|
+
});
|
|
15885
|
+
return new scope_1.Scope(validatedId, this.workspaceId, this._http, scopeData.metadata ?? undefined, () => this._ensureWorkspace(), scopeData.created_at);
|
|
15886
|
+
}
|
|
15887
|
+
async getScope(id) {
|
|
15888
|
+
await this._ensureWorkspace();
|
|
15889
|
+
const validatedId = validation_1.ScopeIdSchema.parse(id);
|
|
15890
|
+
const scopeData = await this._getScope(this.workspaceId, validatedId);
|
|
15891
|
+
return new scope_1.Scope(validatedId, this.workspaceId, this._http, scopeData.metadata ?? undefined, () => this._ensureWorkspace(), scopeData.created_at);
|
|
15892
|
+
}
|
|
15893
|
+
async scopes(options) {
|
|
15894
|
+
await this._ensureWorkspace();
|
|
15895
|
+
const listOptions = {
|
|
15896
|
+
filters: options?.filters ? validation_1.FilterSchema.parse(options.filters) : undefined,
|
|
15897
|
+
reverse: options?.reverse,
|
|
15898
|
+
includeSessionCount: options?.includeSessionCount
|
|
15899
|
+
};
|
|
15900
|
+
const scopesPage = await this._listScopes(this.workspaceId, {
|
|
15901
|
+
...listOptions,
|
|
15902
|
+
page: options?.page,
|
|
15903
|
+
size: options?.size
|
|
15343
15904
|
});
|
|
15344
|
-
|
|
15905
|
+
const fetchNextPage = async (page, size) => {
|
|
15906
|
+
return this._listScopes(this.workspaceId, { ...listOptions, page, size });
|
|
15907
|
+
};
|
|
15908
|
+
return new pagination_1.Page(scopesPage, (scope) => new scope_1.Scope(scope.id, this.workspaceId, this._http, scope.metadata ?? undefined, () => this._ensureWorkspace(), scope.created_at, scope.session_count), fetchNextPage);
|
|
15345
15909
|
}
|
|
15346
15910
|
async sessions(options) {
|
|
15347
15911
|
await this._ensureWorkspace();
|
|
@@ -15349,25 +15913,32 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15349
15913
|
"filters",
|
|
15350
15914
|
"page",
|
|
15351
15915
|
"size",
|
|
15352
|
-
"reverse"
|
|
15916
|
+
"reverse",
|
|
15917
|
+
"scope",
|
|
15918
|
+
"inNoScope",
|
|
15919
|
+
"includeScopes"
|
|
15353
15920
|
]);
|
|
15354
15921
|
const validatedFilter = normalizedOptions.filters ? validation_1.FilterSchema.parse(normalizedOptions.filters) : undefined;
|
|
15355
|
-
const
|
|
15356
|
-
const sessionsPage = await this._listSessions(this.workspaceId, {
|
|
15922
|
+
const listOptions = {
|
|
15357
15923
|
filters: validatedFilter,
|
|
15924
|
+
reverse: normalizedOptions.reverse,
|
|
15925
|
+
scope: normalizedOptions.scope,
|
|
15926
|
+
inNoScope: normalizedOptions.inNoScope,
|
|
15927
|
+
includeScopes: normalizedOptions.includeScopes
|
|
15928
|
+
};
|
|
15929
|
+
const sessionsPage = await this._listSessions(this.workspaceId, {
|
|
15930
|
+
...listOptions,
|
|
15358
15931
|
page: normalizedOptions.page,
|
|
15359
|
-
size: normalizedOptions.size
|
|
15360
|
-
reverse
|
|
15932
|
+
size: normalizedOptions.size
|
|
15361
15933
|
});
|
|
15362
15934
|
const fetchNextPage = async (page, size) => {
|
|
15363
15935
|
return this._listSessions(this.workspaceId, {
|
|
15364
|
-
|
|
15936
|
+
...listOptions,
|
|
15365
15937
|
page,
|
|
15366
|
-
size
|
|
15367
|
-
reverse
|
|
15938
|
+
size
|
|
15368
15939
|
});
|
|
15369
15940
|
};
|
|
15370
|
-
return new pagination_1.Page(sessionsPage, (session) => new session_1.Session(session.id, this.workspaceId, this._http, session.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(session.configuration) ?? undefined, () => this._ensureWorkspace(), session.created_at, session.is_active), fetchNextPage);
|
|
15941
|
+
return new pagination_1.Page(sessionsPage, (session) => new session_1.Session(session.id, this.workspaceId, this._http, session.metadata ?? undefined, (0, validation_1.sessionConfigFromApi)(session.configuration) ?? undefined, () => this._ensureWorkspace(), session.created_at, session.is_active, session.uid, session.scopes), fetchNextPage);
|
|
15371
15942
|
}
|
|
15372
15943
|
async getMetadata() {
|
|
15373
15944
|
await this._ensureWorkspace();
|
|
@@ -15407,19 +15978,23 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15407
15978
|
const normalizedOptions = (0, validation_1.normalizeListOptions)(options, [
|
|
15408
15979
|
"filters",
|
|
15409
15980
|
"page",
|
|
15410
|
-
"size"
|
|
15981
|
+
"size",
|
|
15982
|
+
"reverse"
|
|
15411
15983
|
]);
|
|
15412
15984
|
const validatedFilter = normalizedOptions.filters ? validation_1.FilterSchema.parse(normalizedOptions.filters) : undefined;
|
|
15985
|
+
const reverse = normalizedOptions.reverse;
|
|
15413
15986
|
const workspacesPage = await this._listWorkspaces({
|
|
15414
15987
|
filters: validatedFilter,
|
|
15415
15988
|
page: normalizedOptions.page,
|
|
15416
|
-
size: normalizedOptions.size
|
|
15989
|
+
size: normalizedOptions.size,
|
|
15990
|
+
reverse
|
|
15417
15991
|
});
|
|
15418
15992
|
const fetchNextPage = async (page, size) => {
|
|
15419
15993
|
return this._listWorkspaces({
|
|
15420
15994
|
filters: validatedFilter,
|
|
15421
15995
|
page,
|
|
15422
|
-
size
|
|
15996
|
+
size,
|
|
15997
|
+
reverse
|
|
15423
15998
|
});
|
|
15424
15999
|
};
|
|
15425
16000
|
return new pagination_1.Page(workspacesPage, (workspace) => workspace.id, fetchNextPage);
|
|
@@ -15431,14 +16006,47 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15431
16006
|
await this._ensureWorkspace();
|
|
15432
16007
|
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
15433
16008
|
const validatedFilters = options?.filters ? validation_1.FilterSchema.parse(options.filters) : undefined;
|
|
16009
|
+
const validatedScope = options?.scope !== undefined ? validation_1.ScopeIdSchema.parse((0, utils_1.resolveId)(options.scope)) : undefined;
|
|
15434
16010
|
const validatedLimit = options?.limit ? validation_1.LimitSchema.parse(options.limit) : undefined;
|
|
15435
16011
|
const response = await this._searchWorkspace(this.workspaceId, {
|
|
15436
16012
|
query: validatedQuery,
|
|
15437
16013
|
filters: validatedFilters,
|
|
16014
|
+
scope: validatedScope,
|
|
15438
16015
|
limit: validatedLimit
|
|
15439
16016
|
});
|
|
15440
16017
|
return response.map(message_1.Message.fromApiResponse);
|
|
15441
16018
|
}
|
|
16019
|
+
async chat(query, options) {
|
|
16020
|
+
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
16021
|
+
const resolvedSessionId = options?.session ? (0, utils_1.resolveId)(options.session) : undefined;
|
|
16022
|
+
const response = await this._workspaceChat(this.workspaceId, {
|
|
16023
|
+
query: validatedQuery,
|
|
16024
|
+
stream: false,
|
|
16025
|
+
session_id: resolvedSessionId,
|
|
16026
|
+
reasoning_level: options?.reasoningLevel,
|
|
16027
|
+
response_format: options?.responseFormat,
|
|
16028
|
+
scope: options?.scope,
|
|
16029
|
+
include_evidence: options?.includeEvidence ? true : undefined
|
|
16030
|
+
});
|
|
16031
|
+
const content = response.content || null;
|
|
16032
|
+
if (!options?.includeEvidence) {
|
|
16033
|
+
return content;
|
|
16034
|
+
}
|
|
16035
|
+
return { content, evidence: response.evidence ?? null };
|
|
16036
|
+
}
|
|
16037
|
+
async chatStream(query, options) {
|
|
16038
|
+
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
16039
|
+
const resolvedSessionId = options?.session ? (0, utils_1.resolveId)(options.session) : undefined;
|
|
16040
|
+
const response = await this._workspaceChatStream(this.workspaceId, {
|
|
16041
|
+
query: validatedQuery,
|
|
16042
|
+
session_id: resolvedSessionId,
|
|
16043
|
+
reasoning_level: options?.reasoningLevel,
|
|
16044
|
+
response_format: options?.responseFormat,
|
|
16045
|
+
scope: options?.scope,
|
|
16046
|
+
include_evidence: options?.includeEvidence ? true : undefined
|
|
16047
|
+
});
|
|
16048
|
+
return (0, streaming_1.createDialecticStream)(response);
|
|
16049
|
+
}
|
|
15442
16050
|
async queueStatus(options) {
|
|
15443
16051
|
await this._ensureWorkspace();
|
|
15444
16052
|
const observerId = options?.observer ? (0, utils_1.resolveId)(options.observer) : undefined;
|
|
@@ -15468,6 +16076,20 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15468
16076
|
}
|
|
15469
16077
|
});
|
|
15470
16078
|
}
|
|
16079
|
+
async dreams(options) {
|
|
16080
|
+
await this._ensureWorkspace();
|
|
16081
|
+
const body = {};
|
|
16082
|
+
if (options?.observed)
|
|
16083
|
+
body.observed_id = (0, utils_1.resolveId)(options.observed);
|
|
16084
|
+
if (options?.observer)
|
|
16085
|
+
body.observer_id = (0, utils_1.resolveId)(options.observer);
|
|
16086
|
+
const fetchPage = (page, size) => this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/dreams/list`, { body, query: { page, size } });
|
|
16087
|
+
return new pagination_1.Page(await fetchPage(options?.page, options?.size), undefined, fetchPage);
|
|
16088
|
+
}
|
|
16089
|
+
async getDream(runId) {
|
|
16090
|
+
await this._ensureWorkspace();
|
|
16091
|
+
return this._http.get(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/dreams/${runId}`);
|
|
16092
|
+
}
|
|
15471
16093
|
toString() {
|
|
15472
16094
|
return `Honcho(workspaceId='${this.workspaceId}', baseURL='${this._http.baseURL}')`;
|
|
15473
16095
|
}
|
|
@@ -15478,7 +16100,7 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
15478
16100
|
// node_modules/@honcho-ai/sdk/dist/index.js
|
|
15479
16101
|
var require_dist = __commonJS(function(exports) {
|
|
15480
16102
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15481
|
-
exports.Summary = exports.SessionSummaries = exports.SessionContext = exports.Session = exports.PeerContext = exports.Peer = exports.Page = exports.Message = exports.DialecticStreamResponse = exports.UnprocessableEntityError = exports.TimeoutError = exports.ServerError = exports.RateLimitError = exports.PermissionDeniedError = exports.NotFoundError = exports.HonchoError = exports.ConnectionError = exports.ConflictError = exports.BadRequestError = exports.AuthenticationError = exports.ConclusionScope = exports.Conclusion = exports.Honcho = undefined;
|
|
16103
|
+
exports.Summary = exports.SessionSummaries = exports.SessionContext = exports.Session = exports.Scope = exports.PeerContext = exports.Peer = exports.Page = exports.Message = exports.DialecticStreamResponse = exports.UnprocessableEntityError = exports.TimeoutError = exports.ServerError = exports.RateLimitError = exports.PermissionDeniedError = exports.NotFoundError = exports.HonchoError = exports.ConnectionError = exports.ConflictError = exports.BadRequestError = exports.AuthenticationError = exports.WorkspaceConclusions = exports.ConclusionsView = exports.ConclusionScope = exports.Conclusion = exports.Honcho = undefined;
|
|
15482
16104
|
var client_1 = require_client2();
|
|
15483
16105
|
Object.defineProperty(exports, "Honcho", { enumerable: true, get: function() {
|
|
15484
16106
|
return client_1.Honcho;
|
|
@@ -15488,7 +16110,13 @@ var require_dist = __commonJS(function(exports) {
|
|
|
15488
16110
|
return conclusions_1.Conclusion;
|
|
15489
16111
|
} });
|
|
15490
16112
|
Object.defineProperty(exports, "ConclusionScope", { enumerable: true, get: function() {
|
|
15491
|
-
return conclusions_1.
|
|
16113
|
+
return conclusions_1.ConclusionsView;
|
|
16114
|
+
} });
|
|
16115
|
+
Object.defineProperty(exports, "ConclusionsView", { enumerable: true, get: function() {
|
|
16116
|
+
return conclusions_1.ConclusionsView;
|
|
16117
|
+
} });
|
|
16118
|
+
Object.defineProperty(exports, "WorkspaceConclusions", { enumerable: true, get: function() {
|
|
16119
|
+
return conclusions_1.WorkspaceConclusions;
|
|
15492
16120
|
} });
|
|
15493
16121
|
var errors_1 = require_errors();
|
|
15494
16122
|
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function() {
|
|
@@ -15543,6 +16171,10 @@ var require_dist = __commonJS(function(exports) {
|
|
|
15543
16171
|
Object.defineProperty(exports, "PeerContext", { enumerable: true, get: function() {
|
|
15544
16172
|
return peer_1.PeerContext;
|
|
15545
16173
|
} });
|
|
16174
|
+
var scope_1 = require_scope();
|
|
16175
|
+
Object.defineProperty(exports, "Scope", { enumerable: true, get: function() {
|
|
16176
|
+
return scope_1.Scope;
|
|
16177
|
+
} });
|
|
15546
16178
|
var session_1 = require_session();
|
|
15547
16179
|
Object.defineProperty(exports, "Session", { enumerable: true, get: function() {
|
|
15548
16180
|
return session_1.Session;
|
|
@@ -15559,133 +16191,507 @@ var require_dist = __commonJS(function(exports) {
|
|
|
15559
16191
|
} });
|
|
15560
16192
|
});
|
|
15561
16193
|
|
|
15562
|
-
// src/skills/status.ts
|
|
15563
|
-
var import_sdk = __toESM(require_dist(), 1);
|
|
15564
|
-
|
|
15565
16194
|
// src/config.ts
|
|
15566
|
-
import {
|
|
15567
|
-
import { join as join3, basename, dirname, resolve, sep } from "path";
|
|
16195
|
+
import { join as join3, dirname as dirname2 } from "path";
|
|
15568
16196
|
import { fileURLToPath } from "url";
|
|
15569
|
-
import { existsSync as existsSync3,
|
|
16197
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
16198
|
+
|
|
16199
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/config.js
|
|
16200
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
16201
|
+
import { homedir } from "node:os";
|
|
16202
|
+
import { join as join2 } from "node:path";
|
|
16203
|
+
|
|
16204
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/legacy/v01.js
|
|
16205
|
+
var isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
16206
|
+
var str = (v) => typeof v === "string" && v ? v : undefined;
|
|
16207
|
+
function v01Reader(file, host) {
|
|
16208
|
+
const hosts = isObj(file.hosts) ? file.hosts : {};
|
|
16209
|
+
const v1 = typeof file.schemaVersion === "number" && file.schemaVersion >= 1;
|
|
16210
|
+
const pick = (b) => {
|
|
16211
|
+
const o = isObj(b) ? b : {};
|
|
16212
|
+
if (v1)
|
|
16213
|
+
return { apiKey: isObj(o.auth) ? str(o.auth.apiKey) : undefined, peerName: str(o.peerName), workspace: str(o.workspace), baseUrl: str(o.baseUrl) };
|
|
16214
|
+
return {
|
|
16215
|
+
apiKey: (isObj(o.auth) ? str(o.auth.apiKey) : undefined) ?? str(o.apiKey),
|
|
16216
|
+
peerName: str(o.peerName),
|
|
16217
|
+
workspace: str(o.workspace) ?? str(o.workspaceId),
|
|
16218
|
+
baseUrl: str(o.baseUrl) ?? str(o.environmentUrl) ?? (isObj(o.endpoint) ? str(o.endpoint.baseUrl) : undefined)
|
|
16219
|
+
};
|
|
16220
|
+
};
|
|
16221
|
+
const own = pick(hosts[host]);
|
|
16222
|
+
const top = pick(file);
|
|
16223
|
+
return {
|
|
16224
|
+
apiKey: own.apiKey ?? top.apiKey,
|
|
16225
|
+
peerName: own.peerName ?? top.peerName,
|
|
16226
|
+
workspace: own.workspace ?? top.workspace,
|
|
16227
|
+
aiPeer: isObj(hosts[host]) ? str(hosts[host].aiPeer) : undefined,
|
|
16228
|
+
baseUrl: own.baseUrl ?? top.baseUrl
|
|
16229
|
+
};
|
|
16230
|
+
}
|
|
15570
16231
|
|
|
15571
|
-
//
|
|
15572
|
-
import {
|
|
15573
|
-
import {
|
|
15574
|
-
|
|
15575
|
-
|
|
15576
|
-
|
|
16232
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/oauth.js
|
|
16233
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
16234
|
+
import { dirname, join } from "node:path";
|
|
16235
|
+
var OAUTH_DEVICE_URL = "https://api.honcho.dev/oauth/device_authorization";
|
|
16236
|
+
var OAUTH_TOKEN_URL = "https://api.honcho.dev/oauth/token";
|
|
16237
|
+
var OAUTH_SCOPE = "write";
|
|
16238
|
+
var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
16239
|
+
var SLOW_DOWN_STEP_S = 5;
|
|
16240
|
+
var DEFAULT_DEVICE_EXPIRES_S = 600;
|
|
16241
|
+
var REQUEST_TIMEOUT_MS = 1e4;
|
|
16242
|
+
var REFRESH_SKEW_S = 60;
|
|
16243
|
+
var LOCK_STALE_MS = REQUEST_TIMEOUT_MS + 5000;
|
|
16244
|
+
var LOCK_WAIT_MS = LOCK_STALE_MS + 5000;
|
|
16245
|
+
var PERMANENT_ERRORS = new Set(["invalid_grant", "invalid_client", "unauthorized_client"]);
|
|
16246
|
+
|
|
16247
|
+
class OAuthError extends Error {
|
|
16248
|
+
code;
|
|
16249
|
+
constructor(code, description) {
|
|
16250
|
+
super(description || code);
|
|
16251
|
+
this.code = code;
|
|
16252
|
+
this.name = "OAuthError";
|
|
16253
|
+
}
|
|
16254
|
+
}
|
|
16255
|
+
function isCloud(baseUrl) {
|
|
16256
|
+
return normalizeBaseUrl(baseUrl || DEFAULT_BASE_URL) === DEFAULT_BASE_URL;
|
|
16257
|
+
}
|
|
16258
|
+
function accessValid(t, skewS = REFRESH_SKEW_S, nowS = Date.now() / 1000) {
|
|
16259
|
+
return !!t?.accessToken && nowS < t.accessExpiresAt - skewS;
|
|
15577
16260
|
}
|
|
15578
|
-
function
|
|
16261
|
+
async function post(url, form, t) {
|
|
16262
|
+
const f = t?.fetch ?? fetch;
|
|
16263
|
+
let res;
|
|
15579
16264
|
try {
|
|
15580
|
-
|
|
16265
|
+
res = await f(url, {
|
|
16266
|
+
method: "POST",
|
|
16267
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
|
|
16268
|
+
body: new URLSearchParams(form).toString(),
|
|
16269
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
16270
|
+
});
|
|
16271
|
+
} catch (e) {
|
|
16272
|
+
throw new OAuthError("connection_error", `could not reach ${url}: ${e.message}`);
|
|
16273
|
+
}
|
|
16274
|
+
let body = null;
|
|
16275
|
+
try {
|
|
16276
|
+
body = await res.json();
|
|
15581
16277
|
} catch {
|
|
15582
|
-
|
|
16278
|
+
body = null;
|
|
15583
16279
|
}
|
|
16280
|
+
return { status: res.status, body };
|
|
15584
16281
|
}
|
|
15585
|
-
function
|
|
15586
|
-
|
|
15587
|
-
|
|
16282
|
+
function errorOf(r) {
|
|
16283
|
+
const b = r.body;
|
|
16284
|
+
if (b && typeof b === "object" && typeof b.error === "string")
|
|
16285
|
+
return new OAuthError(b.error, b.error_description);
|
|
16286
|
+
return new OAuthError("invalid_response");
|
|
16287
|
+
}
|
|
16288
|
+
function tokensFrom(body, clientId, prev) {
|
|
16289
|
+
if (!body || typeof body.access_token !== "string" || !Number.isFinite(Number(body.expires_in))) {
|
|
16290
|
+
throw new OAuthError("invalid_response", "malformed token response");
|
|
15588
16291
|
}
|
|
15589
|
-
const branch = gitCommand(cwd, "rev-parse --abbrev-ref HEAD") || "unknown";
|
|
15590
|
-
const commit = gitCommand(cwd, "rev-parse --short HEAD") || "unknown";
|
|
15591
|
-
const commitMessage = gitCommand(cwd, "log -1 --format=%s") || "";
|
|
15592
|
-
const statusOutput = gitCommand(cwd, "status --porcelain") || "";
|
|
15593
|
-
const isDirty = statusOutput.length > 0;
|
|
15594
|
-
const dirtyFiles = isDirty ? statusOutput.split(`
|
|
15595
|
-
`).filter((line) => line.trim()).map((line) => line.slice(3).trim()).slice(0, 20) : [];
|
|
15596
16292
|
return {
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
|
|
15602
|
-
timestamp: new Date().toISOString()
|
|
16293
|
+
accessToken: body.access_token,
|
|
16294
|
+
refreshToken: body.refresh_token || prev?.refreshToken || "",
|
|
16295
|
+
accessExpiresAt: Math.floor(Date.now() / 1000) + Number(body.expires_in),
|
|
16296
|
+
clientId,
|
|
16297
|
+
scope: body.scope || prev?.scope || OAUTH_SCOPE
|
|
15603
16298
|
};
|
|
15604
16299
|
}
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15615
|
-
|
|
16300
|
+
async function requestDeviceCode(opts) {
|
|
16301
|
+
const r = await post(opts.deviceUrl ?? OAUTH_DEVICE_URL, { client_id: opts.clientId, scope: OAUTH_SCOPE, source: opts.source }, opts);
|
|
16302
|
+
if (r.status !== 200)
|
|
16303
|
+
throw errorOf(r);
|
|
16304
|
+
const b = r.body;
|
|
16305
|
+
if (!b?.device_code || !b?.user_code || !b?.verification_uri) {
|
|
16306
|
+
throw new OAuthError("invalid_response", "malformed device authorization response");
|
|
16307
|
+
}
|
|
16308
|
+
return {
|
|
16309
|
+
deviceCode: b.device_code,
|
|
16310
|
+
userCode: b.user_code,
|
|
16311
|
+
verificationUri: b.verification_uri,
|
|
16312
|
+
verificationUriComplete: b.verification_uri_complete || b.verification_uri,
|
|
16313
|
+
expiresIn: Number(b.expires_in) > 0 ? Number(b.expires_in) : DEFAULT_DEVICE_EXPIRES_S,
|
|
16314
|
+
interval: Number(b.interval) || 5
|
|
16315
|
+
};
|
|
16316
|
+
}
|
|
16317
|
+
async function pollForToken(device, opts) {
|
|
16318
|
+
const clientId = opts.clientId;
|
|
16319
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
16320
|
+
const deadline = Date.now() + device.expiresIn * 1000;
|
|
16321
|
+
let interval = device.interval;
|
|
16322
|
+
while (true) {
|
|
16323
|
+
if (Date.now() >= deadline)
|
|
16324
|
+
throw new OAuthError("expired_token", "timed out waiting for approval");
|
|
16325
|
+
await sleep(interval * 1000);
|
|
16326
|
+
let r;
|
|
16327
|
+
try {
|
|
16328
|
+
r = await post(opts.tokenUrl ?? OAUTH_TOKEN_URL, { grant_type: DEVICE_GRANT_TYPE, device_code: device.deviceCode, client_id: clientId }, opts);
|
|
16329
|
+
} catch (e) {
|
|
16330
|
+
if (e instanceof OAuthError && e.code === "connection_error")
|
|
16331
|
+
continue;
|
|
16332
|
+
throw e;
|
|
16333
|
+
}
|
|
16334
|
+
if (r.status === 200)
|
|
16335
|
+
return tokensFrom(r.body, clientId);
|
|
16336
|
+
if (r.status >= 500)
|
|
16337
|
+
continue;
|
|
16338
|
+
const err = errorOf(r);
|
|
16339
|
+
if (err.code === "authorization_pending")
|
|
16340
|
+
continue;
|
|
16341
|
+
if (err.code === "slow_down") {
|
|
16342
|
+
interval += SLOW_DOWN_STEP_S;
|
|
16343
|
+
continue;
|
|
16344
|
+
}
|
|
16345
|
+
throw err;
|
|
15616
16346
|
}
|
|
15617
16347
|
}
|
|
15618
|
-
function
|
|
15619
|
-
|
|
15620
|
-
if (
|
|
16348
|
+
async function refreshAccessToken(prev, opts = {}) {
|
|
16349
|
+
const r = await post(opts.tokenUrl ?? OAUTH_TOKEN_URL, { grant_type: "refresh_token", refresh_token: prev.refreshToken, client_id: prev.clientId }, opts);
|
|
16350
|
+
if (r.status !== 200)
|
|
16351
|
+
throw errorOf(r);
|
|
16352
|
+
return tokensFrom(r.body, prev.clientId, prev);
|
|
16353
|
+
}
|
|
16354
|
+
function isObj2(v) {
|
|
16355
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
16356
|
+
}
|
|
16357
|
+
function asTokens(v) {
|
|
16358
|
+
if (!isObj2(v) || typeof v.accessToken !== "string" || !v.accessToken)
|
|
16359
|
+
return;
|
|
16360
|
+
return {
|
|
16361
|
+
accessToken: v.accessToken,
|
|
16362
|
+
refreshToken: typeof v.refreshToken === "string" ? v.refreshToken : "",
|
|
16363
|
+
accessExpiresAt: Number(v.accessExpiresAt) || 0,
|
|
16364
|
+
clientId: typeof v.clientId === "string" ? v.clientId : "",
|
|
16365
|
+
scope: typeof v.scope === "string" ? v.scope : ""
|
|
16366
|
+
};
|
|
16367
|
+
}
|
|
16368
|
+
function readFile(path) {
|
|
16369
|
+
if (!existsSync(path))
|
|
15621
16370
|
return {};
|
|
16371
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
16372
|
+
return isObj2(parsed) ? parsed : {};
|
|
16373
|
+
}
|
|
16374
|
+
function readGrant(file, host, legacy) {
|
|
16375
|
+
return asTokens(effectiveBlock(file, host, legacy).oauth);
|
|
16376
|
+
}
|
|
16377
|
+
function holderAlive(token, ageMs) {
|
|
16378
|
+
if (token === "")
|
|
16379
|
+
return ageMs < 1000;
|
|
16380
|
+
const pid = Number(token.split(":")[0]);
|
|
16381
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
16382
|
+
return true;
|
|
16383
|
+
try {
|
|
16384
|
+
process.kill(pid, 0);
|
|
16385
|
+
return true;
|
|
16386
|
+
} catch (e) {
|
|
16387
|
+
return e.code === "EPERM";
|
|
16388
|
+
}
|
|
16389
|
+
}
|
|
16390
|
+
async function withConfigLock(path, fn) {
|
|
16391
|
+
const lock = `${path}.lock`;
|
|
16392
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
16393
|
+
const start = Date.now();
|
|
16394
|
+
let fd;
|
|
16395
|
+
while (fd === undefined) {
|
|
16396
|
+
try {
|
|
16397
|
+
fd = openSync(lock, "wx", 384);
|
|
16398
|
+
} catch (e) {
|
|
16399
|
+
if (e.code !== "EEXIST")
|
|
16400
|
+
throw e;
|
|
16401
|
+
try {
|
|
16402
|
+
const age = Date.now() - statSync(lock).mtimeMs;
|
|
16403
|
+
if (age > LOCK_STALE_MS || !holderAlive(readFileSync(lock, "utf-8"), age))
|
|
16404
|
+
unlinkSync(lock);
|
|
16405
|
+
} catch {}
|
|
16406
|
+
if (Date.now() - start > LOCK_WAIT_MS)
|
|
16407
|
+
throw new Error(`timed out waiting for ${lock}`);
|
|
16408
|
+
await new Promise((r) => setTimeout(r, 50 + Math.random() * 50));
|
|
16409
|
+
}
|
|
16410
|
+
}
|
|
16411
|
+
const token = `${process.pid}:${Math.random().toString(36).slice(2)}`;
|
|
16412
|
+
try {
|
|
16413
|
+
writeFileSync(fd, token);
|
|
16414
|
+
return await fn();
|
|
16415
|
+
} finally {
|
|
16416
|
+
closeSync(fd);
|
|
16417
|
+
try {
|
|
16418
|
+
if (readFileSync(lock, "utf-8") === token)
|
|
16419
|
+
unlinkSync(lock);
|
|
16420
|
+
} catch {}
|
|
16421
|
+
}
|
|
16422
|
+
}
|
|
16423
|
+
function writeFileAtomic(path, data) {
|
|
16424
|
+
const tmp = join(dirname(path), `.${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2)}.tmp`);
|
|
16425
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2) + `
|
|
16426
|
+
`, { mode: 384 });
|
|
16427
|
+
renameSync(tmp, path);
|
|
16428
|
+
}
|
|
16429
|
+
async function updateConfigFile(path, mutate) {
|
|
16430
|
+
await withConfigLock(path, async () => {
|
|
16431
|
+
const file = readFile(path);
|
|
16432
|
+
mutate(file);
|
|
16433
|
+
writeFileAtomic(path, file);
|
|
16434
|
+
});
|
|
16435
|
+
}
|
|
16436
|
+
function setGrant(file, host, tokens) {
|
|
16437
|
+
const block = hostBlock(file, host);
|
|
16438
|
+
if (tokens)
|
|
16439
|
+
block.oauth = tokens;
|
|
16440
|
+
else
|
|
16441
|
+
delete block.oauth;
|
|
16442
|
+
}
|
|
16443
|
+
async function saveGrant(path, host, tokens) {
|
|
16444
|
+
await updateConfigFile(path, (file) => {
|
|
16445
|
+
setGrant(file, host, tokens);
|
|
16446
|
+
if (tokens) {
|
|
16447
|
+
const block = hostBlock(file, host);
|
|
16448
|
+
delete block.apiKey;
|
|
16449
|
+
delete block.baseUrl;
|
|
16450
|
+
}
|
|
16451
|
+
});
|
|
16452
|
+
}
|
|
16453
|
+
function serverOf(block, baseUrl, env) {
|
|
16454
|
+
return baseUrl ?? (env.HONCHO_BASE_URL || undefined) ?? (typeof block.baseUrl === "string" && block.baseUrl ? block.baseUrl : undefined);
|
|
16455
|
+
}
|
|
16456
|
+
function pickCredential(file, opts) {
|
|
16457
|
+
const env = opts.env ?? process.env;
|
|
16458
|
+
if (env.HONCHO_API_KEY)
|
|
16459
|
+
return { token: env.HONCHO_API_KEY, source: "env" };
|
|
16460
|
+
const block = effectiveBlock(file, opts.host, opts.legacy);
|
|
16461
|
+
const g = isCloud(serverOf(block, opts.baseUrl, env)) ? asTokens(block.oauth) : undefined;
|
|
16462
|
+
if (g)
|
|
16463
|
+
return { token: g.accessToken, source: "oauth", expiresAt: g.accessExpiresAt, ...accessValid(g, 0) ? {} : { expired: true } };
|
|
16464
|
+
return typeof block.apiKey === "string" && block.apiKey ? { token: block.apiKey, source: "apiKey" } : null;
|
|
16465
|
+
}
|
|
16466
|
+
async function ensureFreshCredential(opts) {
|
|
16467
|
+
const env = opts.env ?? process.env;
|
|
16468
|
+
if (env.HONCHO_API_KEY)
|
|
16469
|
+
return { token: env.HONCHO_API_KEY, source: "env" };
|
|
16470
|
+
let file;
|
|
16471
|
+
try {
|
|
16472
|
+
file = readFile(opts.path);
|
|
16473
|
+
} catch {
|
|
16474
|
+
file = {};
|
|
16475
|
+
}
|
|
16476
|
+
const block = effectiveBlock(file, opts.host, opts.legacy);
|
|
16477
|
+
const g = isCloud(serverOf(block, opts.baseUrl, env)) ? asTokens(block.oauth) : undefined;
|
|
16478
|
+
if (!g || accessValid(g) || !g.refreshToken)
|
|
16479
|
+
return pickCredential(file, opts);
|
|
16480
|
+
let error;
|
|
16481
|
+
try {
|
|
16482
|
+
await withConfigLock(opts.path, async () => {
|
|
16483
|
+
const current = readGrant(readFile(opts.path), opts.host, opts.legacy);
|
|
16484
|
+
if (!current || accessValid(current))
|
|
16485
|
+
return;
|
|
16486
|
+
const next = await refreshAccessToken(current, opts);
|
|
16487
|
+
const latest = readFile(opts.path);
|
|
16488
|
+
setGrant(latest, opts.host, next);
|
|
16489
|
+
writeFileAtomic(opts.path, latest);
|
|
16490
|
+
});
|
|
16491
|
+
} catch (e) {
|
|
16492
|
+
error = e instanceof OAuthError ? e.code : e.message;
|
|
15622
16493
|
}
|
|
15623
16494
|
try {
|
|
15624
|
-
|
|
16495
|
+
file = readFile(opts.path);
|
|
16496
|
+
} catch {}
|
|
16497
|
+
const cred = pickCredential(file, opts);
|
|
16498
|
+
if (cred && error) {
|
|
16499
|
+
cred.error = error;
|
|
16500
|
+
if (PERMANENT_ERRORS.has(error))
|
|
16501
|
+
cred.reauthRequired = true;
|
|
16502
|
+
}
|
|
16503
|
+
return cred;
|
|
16504
|
+
}
|
|
16505
|
+
|
|
16506
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/config.js
|
|
16507
|
+
var DEFAULT_BASE_URL = "https://api.honcho.dev";
|
|
16508
|
+
var CONFIG_SCHEMA_VERSION = 2;
|
|
16509
|
+
function isObj3(v) {
|
|
16510
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
16511
|
+
}
|
|
16512
|
+
function str2(v) {
|
|
16513
|
+
return typeof v === "string" && v ? v : undefined;
|
|
16514
|
+
}
|
|
16515
|
+
function normalizeBaseUrl(input) {
|
|
16516
|
+
let s = input.trim();
|
|
16517
|
+
if (!s)
|
|
16518
|
+
return s;
|
|
16519
|
+
if (!s.startsWith("http://") && !s.startsWith("https://")) {
|
|
16520
|
+
const host = s.split("/")[0].split(":")[0].toLowerCase();
|
|
16521
|
+
const local = host === "localhost" || host === "127.0.0.1" || host === "::1";
|
|
16522
|
+
s = `${local ? "http" : "https"}://${s}`;
|
|
16523
|
+
}
|
|
16524
|
+
try {
|
|
16525
|
+
const u = new URL(s);
|
|
16526
|
+
u.hostname = u.hostname.toLowerCase();
|
|
16527
|
+
const path = u.pathname === "/" ? "" : u.pathname.replace(/\/+$/, "");
|
|
16528
|
+
return `${u.protocol}//${u.host}${path}`;
|
|
16529
|
+
} catch {
|
|
16530
|
+
return s;
|
|
16531
|
+
}
|
|
16532
|
+
}
|
|
16533
|
+
function resolveConfig(file, opts) {
|
|
16534
|
+
const env = opts.env ?? process.env;
|
|
16535
|
+
const { host } = opts;
|
|
16536
|
+
const block = effectiveBlock(file, host, opts.legacy);
|
|
16537
|
+
return {
|
|
16538
|
+
host,
|
|
16539
|
+
peerName: str2(env.HONCHO_PEER_NAME) ?? str2(block.peerName) ?? str2(env.USER) ?? str2(env.USERNAME) ?? "user",
|
|
16540
|
+
workspace: str2(env.HONCHO_WORKSPACE) ?? str2(block.workspace) ?? opts.defaults?.workspace ?? host,
|
|
16541
|
+
aiPeer: str2(env.HONCHO_AI_PEER) ?? str2(block.aiPeer) ?? opts.defaults?.aiPeer ?? host,
|
|
16542
|
+
baseUrl: normalizeBaseUrl(str2(env.HONCHO_BASE_URL) ?? str2(block.baseUrl) ?? DEFAULT_BASE_URL),
|
|
16543
|
+
warnings: checkConfig(file).map((i) => i.message)
|
|
16544
|
+
};
|
|
16545
|
+
}
|
|
16546
|
+
function suggestPeerName(file, env = process.env) {
|
|
16547
|
+
const f = isObj3(file) ? file : {};
|
|
16548
|
+
const hosts = isObj3(f.hosts) ? f.hosts : {};
|
|
16549
|
+
const names = new Set(Object.values(hosts).map((b) => isObj3(b) ? str2(b.peerName) : undefined).filter(Boolean));
|
|
16550
|
+
if (names.size === 1)
|
|
16551
|
+
return [...names][0];
|
|
16552
|
+
return str2(f.peerName) ?? str2(env.USER) ?? str2(env.USERNAME) ?? "user";
|
|
16553
|
+
}
|
|
16554
|
+
function configPath(env = process.env) {
|
|
16555
|
+
if (env.HONCHO_CONFIG_PATH)
|
|
16556
|
+
return env.HONCHO_CONFIG_PATH;
|
|
16557
|
+
const home = env.HOME || env.USERPROFILE || homedir();
|
|
16558
|
+
return join2(home, ".honcho", "config.json");
|
|
16559
|
+
}
|
|
16560
|
+
function readConfigFile(env = process.env) {
|
|
16561
|
+
const path = configPath(env);
|
|
16562
|
+
if (!existsSync2(path))
|
|
16563
|
+
return {};
|
|
16564
|
+
try {
|
|
16565
|
+
const parsed = JSON.parse(readFileSync2(path, "utf-8"));
|
|
16566
|
+
return isObj3(parsed) ? parsed : {};
|
|
15625
16567
|
} catch {
|
|
15626
16568
|
return {};
|
|
15627
16569
|
}
|
|
15628
16570
|
}
|
|
15629
|
-
function
|
|
15630
|
-
|
|
15631
|
-
|
|
16571
|
+
async function saveHost(path, host, patch, legacy) {
|
|
16572
|
+
await updateConfigFile(path, (file) => {
|
|
16573
|
+
if (isNewer(file))
|
|
16574
|
+
throw new Error(`${path} was written by a newer Honcho plugin; update this one.`);
|
|
16575
|
+
const block = writeBlock(file, host, hostMigration(file, host, [], legacy));
|
|
16576
|
+
if ("baseUrl" in patch && !("apiKey" in patch) && !sameServer(patch.baseUrl, str2(block.baseUrl)))
|
|
16577
|
+
delete block.apiKey;
|
|
16578
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
16579
|
+
if (v === undefined)
|
|
16580
|
+
delete block[k];
|
|
16581
|
+
else
|
|
16582
|
+
block[k] = v;
|
|
16583
|
+
}
|
|
16584
|
+
block.schemaVersion = CONFIG_SCHEMA_VERSION;
|
|
16585
|
+
});
|
|
15632
16586
|
}
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
return
|
|
16587
|
+
var MOVABLE = ["apiKey", "peerName", "workspace", "aiPeer", "baseUrl"];
|
|
16588
|
+
function isNewer(file) {
|
|
16589
|
+
return isObj3(file) && typeof file.schemaVersion === "number" && file.schemaVersion > CONFIG_SCHEMA_VERSION;
|
|
15636
16590
|
}
|
|
15637
|
-
|
|
15638
|
-
"
|
|
15639
|
-
"summaries",
|
|
15640
|
-
"messageCount"
|
|
15641
|
-
]);
|
|
15642
|
-
var GIT_STATE_FILE = join2(CACHE_DIR, "git-state.json");
|
|
15643
|
-
var MAX_MESSAGE_SIZE = 24000;
|
|
15644
|
-
function chunkContent(content, maxSize = MAX_MESSAGE_SIZE) {
|
|
15645
|
-
if (content.length <= maxSize) {
|
|
15646
|
-
return [content];
|
|
15647
|
-
}
|
|
15648
|
-
const chunks = [];
|
|
15649
|
-
let remaining = content;
|
|
15650
|
-
while (remaining.length > 0) {
|
|
15651
|
-
if (remaining.length <= maxSize) {
|
|
15652
|
-
chunks.push(remaining);
|
|
15653
|
-
break;
|
|
15654
|
-
}
|
|
15655
|
-
let splitIndex = remaining.lastIndexOf(`
|
|
15656
|
-
`, maxSize);
|
|
15657
|
-
if (splitIndex <= 0 || splitIndex < maxSize * 0.25) {
|
|
15658
|
-
splitIndex = remaining.lastIndexOf(" ", maxSize);
|
|
15659
|
-
}
|
|
15660
|
-
if (splitIndex <= 0 || splitIndex < maxSize * 0.25) {
|
|
15661
|
-
splitIndex = maxSize;
|
|
15662
|
-
}
|
|
15663
|
-
chunks.push(remaining.slice(0, splitIndex));
|
|
15664
|
-
remaining = remaining.slice(splitIndex).trimStart();
|
|
15665
|
-
}
|
|
15666
|
-
if (chunks.length > 1) {
|
|
15667
|
-
return chunks.map((chunk, i) => `[Part ${i + 1}/${chunks.length}] ${chunk}`);
|
|
15668
|
-
}
|
|
15669
|
-
return chunks;
|
|
16591
|
+
function isMigrated(block) {
|
|
16592
|
+
return isObj3(block) && typeof block.schemaVersion === "number" && block.schemaVersion >= CONFIG_SCHEMA_VERSION;
|
|
15670
16593
|
}
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
|
|
15680
|
-
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
16594
|
+
function sameServer(a, b) {
|
|
16595
|
+
return normalizeBaseUrl(a ?? DEFAULT_BASE_URL) === normalizeBaseUrl(b ?? DEFAULT_BASE_URL);
|
|
16596
|
+
}
|
|
16597
|
+
var LEGACY_HOST_KEYS = ["auth", "endpoint", "environmentUrl", "workspaceId"];
|
|
16598
|
+
function isGrant(v) {
|
|
16599
|
+
return isObj3(v) && typeof v.accessToken === "string" && v.accessToken !== "";
|
|
16600
|
+
}
|
|
16601
|
+
function legacyGrantOf(b) {
|
|
16602
|
+
return !isGrant(b.oauth) && isObj3(b.auth) && isObj3(b.auth.oauth) ? b.auth.oauth : undefined;
|
|
16603
|
+
}
|
|
16604
|
+
function checkConfig(file) {
|
|
16605
|
+
if (!isObj3(file))
|
|
16606
|
+
return [];
|
|
16607
|
+
if (isNewer(file)) {
|
|
16608
|
+
return [{ path: "schemaVersion", message: `This file is schema version ${file.schemaVersion}, newer than this plugin understands; update the plugin.` }];
|
|
16609
|
+
}
|
|
16610
|
+
const issues = [];
|
|
16611
|
+
const hosts = isObj3(file.hosts) ? file.hosts : {};
|
|
16612
|
+
const byWorkspace = new Map;
|
|
16613
|
+
for (const h of Object.keys(hosts).filter((k) => isObj3(hosts[k]))) {
|
|
16614
|
+
const block = hosts[h];
|
|
16615
|
+
const peer = str2(block.peerName);
|
|
16616
|
+
if (!peer)
|
|
16617
|
+
continue;
|
|
16618
|
+
const ws = str2(block.workspace) ?? h;
|
|
16619
|
+
const peers = byWorkspace.get(ws) ?? new Map;
|
|
16620
|
+
peers.set(peer, [...peers.get(peer) ?? [], h]);
|
|
16621
|
+
byWorkspace.set(ws, peers);
|
|
16622
|
+
}
|
|
16623
|
+
for (const [ws, peers] of byWorkspace) {
|
|
16624
|
+
if (peers.size < 2)
|
|
16625
|
+
continue;
|
|
16626
|
+
const list = [...peers].map(([p, hs]) => `${hs.join(", ")}: "${p}"`).join("; ");
|
|
16627
|
+
issues.push({ path: "hosts", message: `Hosts in workspace "${ws}" use different peerNames (${list}), so the user is split across peers.` });
|
|
16628
|
+
}
|
|
16629
|
+
return issues;
|
|
16630
|
+
}
|
|
16631
|
+
function hostMigration(file, host, deadKeys = [], legacy = v01Reader) {
|
|
16632
|
+
if (isNewer(file))
|
|
16633
|
+
return { set: {}, remove: [] };
|
|
16634
|
+
const f = isObj3(file) ? file : {};
|
|
16635
|
+
const hosts = isObj3(f.hosts) ? f.hosts : {};
|
|
16636
|
+
const block = isObj3(hosts[host]) ? hosts[host] : {};
|
|
16637
|
+
const set = {};
|
|
16638
|
+
const drop = [];
|
|
16639
|
+
const grant = legacyGrantOf(block);
|
|
16640
|
+
if (grant)
|
|
16641
|
+
set.oauth = grant;
|
|
16642
|
+
if (!isMigrated(block)) {
|
|
16643
|
+
const old = { ...legacy(f, host) };
|
|
16644
|
+
const signedIn = isGrant(block.oauth) || grant !== undefined;
|
|
16645
|
+
if (old.baseUrl && sameServer(old.baseUrl, undefined))
|
|
16646
|
+
old.baseUrl = undefined;
|
|
16647
|
+
for (const key of MOVABLE) {
|
|
16648
|
+
if (signedIn && (key === "apiKey" || key === "baseUrl"))
|
|
16649
|
+
continue;
|
|
16650
|
+
if (old[key] !== undefined && block[key] !== old[key])
|
|
16651
|
+
set[key] = old[key];
|
|
16652
|
+
else if (old[key] === undefined && block[key] !== undefined)
|
|
16653
|
+
drop.push(key);
|
|
15685
16654
|
}
|
|
16655
|
+
set.schemaVersion = CONFIG_SCHEMA_VERSION;
|
|
15686
16656
|
}
|
|
16657
|
+
const remove = [...drop, ...LEGACY_HOST_KEYS, ...deadKeys].filter((k) => (k in block) && !(k in set));
|
|
16658
|
+
return { set, remove };
|
|
16659
|
+
}
|
|
16660
|
+
function effectiveBlock(file, host, legacy) {
|
|
16661
|
+
return writeBlock(structuredClone(isObj3(file) ? file : {}), host, hostMigration(file, host, [], legacy));
|
|
16662
|
+
}
|
|
16663
|
+
function hostBlock(file, host) {
|
|
16664
|
+
if (host === "__proto__" || host === "constructor" || host === "prototype")
|
|
16665
|
+
throw new Error(`invalid host name: ${host}`);
|
|
16666
|
+
if (!isObj3(file.hosts))
|
|
16667
|
+
file.hosts = {};
|
|
16668
|
+
return isObj3(file.hosts[host]) ? file.hosts[host] : file.hosts[host] = {};
|
|
16669
|
+
}
|
|
16670
|
+
function writeBlock(file, host, { set, remove }) {
|
|
16671
|
+
const block = hostBlock(file, host);
|
|
16672
|
+
Object.assign(block, set);
|
|
16673
|
+
for (const k of remove)
|
|
16674
|
+
delete block[k];
|
|
16675
|
+
return block;
|
|
15687
16676
|
}
|
|
15688
|
-
// node_modules/@honcho-ai/harness-plugin-core/
|
|
16677
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/legacy/claude-honcho.js
|
|
16678
|
+
var isObj4 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
16679
|
+
var str3 = (v) => typeof v === "string" && v ? v : undefined;
|
|
16680
|
+
function claudeHonchoReader(file, host) {
|
|
16681
|
+
const hosts = isObj4(file.hosts) ? file.hosts : {};
|
|
16682
|
+
const found = hosts[host] ?? hosts[host.replace(/_/g, "-")] ?? hosts[host.replace(/-/g, "_")];
|
|
16683
|
+
const block = isObj4(found) ? found : undefined;
|
|
16684
|
+
const endpoint = block?.endpoint ?? file.endpoint;
|
|
16685
|
+
const override = file.globalOverride === true;
|
|
16686
|
+
return {
|
|
16687
|
+
apiKey: str3(block?.apiKey) ?? str3(file.apiKey),
|
|
16688
|
+
baseUrl: str3(endpoint?.baseUrl)?.replace(/\/v3\/?$/, "") ?? (endpoint?.environment === "local" ? "http://localhost:8000" : undefined),
|
|
16689
|
+
peerName: str3(file.peerName),
|
|
16690
|
+
workspace: str3(override || !block ? file.workspace : block.workspace),
|
|
16691
|
+
aiPeer: str3(override ? file.aiPeer ?? block?.aiPeer : block ? block.aiPeer : file[host === "cursor" ? "cursorPeer" : "claudePeer"])
|
|
16692
|
+
};
|
|
16693
|
+
}
|
|
16694
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/telemetry.js
|
|
15689
16695
|
var HEADER_HOST = "X-Honcho-Host";
|
|
15690
16696
|
var HEADER_PLUGIN = "X-Honcho-Plugin";
|
|
15691
16697
|
var HEADER_AGENT_MODEL = "X-Honcho-Agent-Model";
|
|
@@ -15734,13 +16740,10 @@ function telemetryHeaders(id = {}, extra) {
|
|
|
15734
16740
|
return headers;
|
|
15735
16741
|
}
|
|
15736
16742
|
// src/config.ts
|
|
16743
|
+
var LEGACY = claudeHonchoReader;
|
|
15737
16744
|
function sanitizeForSessionName(s) {
|
|
15738
16745
|
return s.toLowerCase().replace(/[^a-z0-9-_]/g, "-");
|
|
15739
16746
|
}
|
|
15740
|
-
var HONCHO_BASE_URLS = {
|
|
15741
|
-
production: "https://api.honcho.dev/v3",
|
|
15742
|
-
local: "http://localhost:8000/v3"
|
|
15743
|
-
};
|
|
15744
16747
|
var _detectedHost = null;
|
|
15745
16748
|
function setDetectedHost(host) {
|
|
15746
16749
|
_detectedHost = host;
|
|
@@ -15758,34 +16761,14 @@ var DEFAULT_AI_PEER = {
|
|
|
15758
16761
|
claude_code: "claude",
|
|
15759
16762
|
obsidian: "honcho"
|
|
15760
16763
|
};
|
|
15761
|
-
function
|
|
15762
|
-
|
|
15763
|
-
return true;
|
|
15764
|
-
if (a == null || b == null)
|
|
15765
|
-
return a === b;
|
|
15766
|
-
if (typeof a !== typeof b)
|
|
15767
|
-
return false;
|
|
15768
|
-
if (typeof a !== "object")
|
|
15769
|
-
return false;
|
|
15770
|
-
const aObj = a;
|
|
15771
|
-
const bObj = b;
|
|
15772
|
-
const keys = new Set([...Object.keys(aObj), ...Object.keys(bObj)]);
|
|
15773
|
-
for (const key of keys) {
|
|
15774
|
-
if (!deepEqual(aObj[key], bObj[key]))
|
|
15775
|
-
return false;
|
|
15776
|
-
}
|
|
15777
|
-
return true;
|
|
16764
|
+
function getConfigPath() {
|
|
16765
|
+
return configPath();
|
|
15778
16766
|
}
|
|
15779
|
-
var CONFIG_DIR = join3(homedir2(), ".honcho");
|
|
15780
|
-
var CONFIG_FILE = join3(CONFIG_DIR, "config.json");
|
|
15781
16767
|
function getConfigDir() {
|
|
15782
|
-
return
|
|
15783
|
-
}
|
|
15784
|
-
function getConfigPath() {
|
|
15785
|
-
return CONFIG_FILE;
|
|
16768
|
+
return dirname2(configPath());
|
|
15786
16769
|
}
|
|
15787
16770
|
function configExists() {
|
|
15788
|
-
return existsSync3(
|
|
16771
|
+
return existsSync3(configPath());
|
|
15789
16772
|
}
|
|
15790
16773
|
function getPluginVersion() {
|
|
15791
16774
|
const root = process.env.CLAUDE_PLUGIN_ROOT;
|
|
@@ -15795,300 +16778,123 @@ function getPluginVersion() {
|
|
|
15795
16778
|
];
|
|
15796
16779
|
for (const manifest of candidates) {
|
|
15797
16780
|
try {
|
|
15798
|
-
const version = JSON.parse(
|
|
16781
|
+
const version = JSON.parse(readFileSync3(manifest, "utf-8")).version;
|
|
15799
16782
|
if (typeof version === "string" && version)
|
|
15800
16783
|
return version;
|
|
15801
16784
|
} catch {}
|
|
15802
16785
|
}
|
|
15803
16786
|
return "unknown";
|
|
15804
16787
|
}
|
|
15805
|
-
function
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
return resolveConfig2(raw, resolvedHost);
|
|
15812
|
-
} catch {}
|
|
15813
|
-
}
|
|
15814
|
-
return loadConfigFromEnv(resolvedHost);
|
|
16788
|
+
function legacyEndpoint(value) {
|
|
16789
|
+
if (value === "local")
|
|
16790
|
+
return "http://localhost:8000";
|
|
16791
|
+
if (value?.startsWith("http"))
|
|
16792
|
+
return value.replace(/\/v3\/?$/, "");
|
|
16793
|
+
return;
|
|
15815
16794
|
}
|
|
15816
|
-
function
|
|
15817
|
-
const
|
|
15818
|
-
const
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
if (
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
} else {
|
|
15831
|
-
workspace = process.env.HONCHO_WORKSPACE ?? raw.workspace ?? DEFAULT_WORKSPACE[host];
|
|
15832
|
-
if (host === "cursor") {
|
|
15833
|
-
aiPeer = raw.cursorPeer ?? DEFAULT_AI_PEER["cursor"];
|
|
15834
|
-
} else {
|
|
15835
|
-
aiPeer = raw.claudePeer ?? DEFAULT_AI_PEER["claude_code"];
|
|
15836
|
-
}
|
|
15837
|
-
}
|
|
15838
|
-
const config = {
|
|
15839
|
-
apiKey,
|
|
15840
|
-
peerName,
|
|
15841
|
-
workspace,
|
|
15842
|
-
aiPeer,
|
|
15843
|
-
sessionStrategy: hostBlock?.sessionStrategy ?? raw.sessionStrategy,
|
|
15844
|
-
sessionPeerPrefix: hostBlock?.sessionPeerPrefix ?? raw.sessionPeerPrefix,
|
|
15845
|
-
sessions: raw.sessions,
|
|
15846
|
-
saveMessages: hostBlock?.saveMessages ?? raw.saveMessages,
|
|
15847
|
-
saveToolUse: hostBlock?.saveToolUse ?? raw.saveToolUse,
|
|
15848
|
-
saveGitEvents: hostBlock?.saveGitEvents ?? raw.saveGitEvents,
|
|
15849
|
-
reasoningLevel: hostBlock?.reasoningLevel ?? raw.reasoningLevel,
|
|
15850
|
-
observationMode: hostBlock?.observationMode ?? raw.observationMode,
|
|
15851
|
-
messageUpload: hostBlock?.messageUpload ?? raw.messageUpload,
|
|
15852
|
-
contextRefresh: hostBlock?.contextRefresh ?? raw.contextRefresh,
|
|
15853
|
-
endpoint: hostBlock?.endpoint ?? raw.endpoint,
|
|
15854
|
-
redactPatterns: hostBlock?.redactPatterns ?? raw.redactPatterns,
|
|
15855
|
-
injection: hostBlock?.injection ?? raw.injection,
|
|
15856
|
-
rememberTool: hostBlock?.rememberTool ?? raw.rememberTool,
|
|
15857
|
-
enabled: hostBlock?.enabled ?? raw.enabled,
|
|
15858
|
-
logging: hostBlock?.logging ?? raw.logging,
|
|
15859
|
-
globalOverride: raw.globalOverride
|
|
15860
|
-
};
|
|
15861
|
-
return mergeWithEnvVars(config);
|
|
16795
|
+
function legacyEnv(host = getDetectedHost()) {
|
|
16796
|
+
const env = process.env;
|
|
16797
|
+
const peerVar = host === "cursor" ? "HONCHO_CURSOR_PEER" : "HONCHO_CLAUDE_PEER";
|
|
16798
|
+
const candidates = [
|
|
16799
|
+
["HONCHO_BASE_URL", "baseUrl", "HONCHO_ENDPOINT", legacyEndpoint(env.HONCHO_ENDPOINT)],
|
|
16800
|
+
["HONCHO_AI_PEER", "aiPeer", peerVar, env[peerVar] || undefined]
|
|
16801
|
+
];
|
|
16802
|
+
const set = candidates.filter(([newVar, , , value]) => value && !env[newVar]);
|
|
16803
|
+
if (!set.length)
|
|
16804
|
+
return {};
|
|
16805
|
+
const block = effectiveBlock(readConfigFile(), host, LEGACY);
|
|
16806
|
+
if (block.apiKey || block.oauth)
|
|
16807
|
+
return {};
|
|
16808
|
+
return Object.fromEntries(set.filter(([, setting]) => !block[setting]).map(([newVar, , oldVar, value]) => [newVar, [oldVar, value]]));
|
|
15862
16809
|
}
|
|
15863
|
-
function
|
|
15864
|
-
const
|
|
15865
|
-
if (!
|
|
15866
|
-
return
|
|
15867
|
-
}
|
|
15868
|
-
const resolvedHost = host ?? getDetectedHost();
|
|
15869
|
-
const peerName = process.env.HONCHO_PEER_NAME || process.env.USER || process.env.USERNAME || "user";
|
|
15870
|
-
const workspace = process.env.HONCHO_WORKSPACE || DEFAULT_WORKSPACE[resolvedHost];
|
|
15871
|
-
const hostPeerEnv = resolvedHost === "cursor" ? process.env.HONCHO_CURSOR_PEER : process.env.HONCHO_CLAUDE_PEER;
|
|
15872
|
-
const aiPeer = process.env.HONCHO_AI_PEER || hostPeerEnv || DEFAULT_AI_PEER[resolvedHost];
|
|
15873
|
-
const endpoint = process.env.HONCHO_ENDPOINT;
|
|
15874
|
-
const config = {
|
|
15875
|
-
apiKey,
|
|
15876
|
-
peerName,
|
|
15877
|
-
workspace,
|
|
15878
|
-
aiPeer,
|
|
15879
|
-
saveMessages: process.env.HONCHO_SAVE_MESSAGES !== "false",
|
|
15880
|
-
saveToolUse: process.env.HONCHO_SAVE_TOOL_USE === "true",
|
|
15881
|
-
saveGitEvents: process.env.HONCHO_SAVE_GIT_EVENTS === "true",
|
|
15882
|
-
enabled: process.env.HONCHO_ENABLED !== "false",
|
|
15883
|
-
logging: process.env.HONCHO_LOGGING !== "false"
|
|
15884
|
-
};
|
|
15885
|
-
if (endpoint) {
|
|
15886
|
-
if (endpoint === "local") {
|
|
15887
|
-
config.endpoint = { environment: "local" };
|
|
15888
|
-
} else if (endpoint.startsWith("http")) {
|
|
15889
|
-
config.endpoint = { baseUrl: endpoint };
|
|
15890
|
-
}
|
|
15891
|
-
}
|
|
15892
|
-
return config;
|
|
16810
|
+
function honchoEnv(host) {
|
|
16811
|
+
const legacy = Object.entries(legacyEnv(host));
|
|
16812
|
+
if (!legacy.length)
|
|
16813
|
+
return process.env;
|
|
16814
|
+
return { ...process.env, ...Object.fromEntries(legacy.map(([k, [, value]]) => [k, value])) };
|
|
15893
16815
|
}
|
|
15894
|
-
function
|
|
15895
|
-
|
|
15896
|
-
|
|
15897
|
-
|
|
15898
|
-
|
|
15899
|
-
|
|
15900
|
-
}
|
|
15901
|
-
if (process.env.HONCHO_ENABLED === "false") {
|
|
15902
|
-
config.enabled = false;
|
|
15903
|
-
}
|
|
15904
|
-
if (process.env.HONCHO_LOGGING === "false") {
|
|
15905
|
-
config.logging = false;
|
|
15906
|
-
}
|
|
15907
|
-
if (process.env.HONCHO_SAVE_TOOL_USE !== undefined) {
|
|
15908
|
-
config.saveToolUse = process.env.HONCHO_SAVE_TOOL_USE === "true";
|
|
15909
|
-
}
|
|
15910
|
-
if (process.env.HONCHO_SAVE_GIT_EVENTS !== undefined) {
|
|
15911
|
-
config.saveGitEvents = process.env.HONCHO_SAVE_GIT_EVENTS === "true";
|
|
15912
|
-
}
|
|
15913
|
-
return config;
|
|
16816
|
+
function resolveHost(host) {
|
|
16817
|
+
return resolveConfig(readConfigFile(), {
|
|
16818
|
+
host,
|
|
16819
|
+
env: honchoEnv(host),
|
|
16820
|
+
defaults: { workspace: DEFAULT_WORKSPACE[host], aiPeer: DEFAULT_AI_PEER[host] },
|
|
16821
|
+
legacy: LEGACY
|
|
16822
|
+
});
|
|
15914
16823
|
}
|
|
15915
|
-
function
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
const host = getDetectedHost();
|
|
15929
|
-
if (!existing.hosts)
|
|
15930
|
-
existing.hosts = {};
|
|
15931
|
-
const existingHost = existing.hosts[host] ?? {};
|
|
15932
|
-
const hostEntry = {};
|
|
15933
|
-
const setHostIfExplicit = (key, value, rootValue) => {
|
|
15934
|
-
if (value === undefined)
|
|
15935
|
-
return;
|
|
15936
|
-
const hasHostOverride = Object.prototype.hasOwnProperty.call(existingHost, key);
|
|
15937
|
-
if (hasHostOverride || !deepEqual(value, rootValue)) {
|
|
15938
|
-
hostEntry[key] = value;
|
|
15939
|
-
}
|
|
16824
|
+
function loadConfig2(host = getDetectedHost()) {
|
|
16825
|
+
const cfg = resolveHost(host);
|
|
16826
|
+
const cred = pickCredential(readConfigFile(), { host, baseUrl: cfg.baseUrl, env: honchoEnv(host), legacy: LEGACY });
|
|
16827
|
+
if (!cred)
|
|
16828
|
+
return null;
|
|
16829
|
+
const { token, ...authState } = cred;
|
|
16830
|
+
return {
|
|
16831
|
+
apiKey: token,
|
|
16832
|
+
auth: { ...authState, host },
|
|
16833
|
+
peerName: cfg.peerName,
|
|
16834
|
+
workspace: cfg.workspace,
|
|
16835
|
+
aiPeer: cfg.aiPeer,
|
|
16836
|
+
baseUrl: cfg.baseUrl
|
|
15940
16837
|
};
|
|
15941
|
-
setHostIfExplicit("workspace", config.workspace, existing.workspace ?? DEFAULT_WORKSPACE[host]);
|
|
15942
|
-
setHostIfExplicit("aiPeer", config.aiPeer, existing.aiPeer ?? DEFAULT_AI_PEER[host]);
|
|
15943
|
-
const enabledForSave = process.env.HONCHO_ENABLED === "false" && config.enabled === false ? existingHost.enabled : config.enabled;
|
|
15944
|
-
const loggingForSave = process.env.HONCHO_LOGGING === "false" && config.logging === false ? existingHost.logging : config.logging;
|
|
15945
|
-
setHostIfExplicit("enabled", enabledForSave, existing.enabled);
|
|
15946
|
-
setHostIfExplicit("logging", loggingForSave, existing.logging);
|
|
15947
|
-
setHostIfExplicit("saveMessages", config.saveMessages, existing.saveMessages);
|
|
15948
|
-
setHostIfExplicit("sessionStrategy", config.sessionStrategy, existing.sessionStrategy);
|
|
15949
|
-
setHostIfExplicit("sessionPeerPrefix", config.sessionPeerPrefix, existing.sessionPeerPrefix);
|
|
15950
|
-
setHostIfExplicit("reasoningLevel", config.reasoningLevel, existing.reasoningLevel);
|
|
15951
|
-
setHostIfExplicit("observationMode", config.observationMode, existing.observationMode);
|
|
15952
|
-
setHostIfExplicit("messageUpload", config.messageUpload, existing.messageUpload);
|
|
15953
|
-
setHostIfExplicit("contextRefresh", config.contextRefresh, existing.contextRefresh);
|
|
15954
|
-
setHostIfExplicit("redactPatterns", config.redactPatterns, existing.redactPatterns);
|
|
15955
|
-
setHostIfExplicit("endpoint", config.endpoint, existing.endpoint);
|
|
15956
|
-
setHostIfExplicit("injection", config.injection, existing.injection);
|
|
15957
|
-
setHostIfExplicit("rememberTool", config.rememberTool, existing.rememberTool);
|
|
15958
|
-
if (existingHost.apiKey !== undefined) {
|
|
15959
|
-
hostEntry.apiKey = existingHost.apiKey;
|
|
15960
|
-
}
|
|
15961
|
-
existing.hosts[host] = hostEntry;
|
|
15962
|
-
writeFileSync2(CONFIG_FILE, JSON.stringify(existing, null, 2));
|
|
15963
|
-
}
|
|
15964
|
-
function saveRootField(field, value) {
|
|
15965
|
-
if (!existsSync3(CONFIG_DIR)) {
|
|
15966
|
-
mkdirSync2(CONFIG_DIR, { recursive: true });
|
|
15967
|
-
}
|
|
15968
|
-
let existing = {};
|
|
15969
|
-
if (existsSync3(CONFIG_FILE)) {
|
|
15970
|
-
try {
|
|
15971
|
-
existing = JSON.parse(readFileSync2(CONFIG_FILE, "utf-8"));
|
|
15972
|
-
} catch {}
|
|
15973
|
-
}
|
|
15974
|
-
existing[field] = value;
|
|
15975
|
-
writeFileSync2(CONFIG_FILE, JSON.stringify(existing, null, 2));
|
|
15976
16838
|
}
|
|
15977
|
-
function
|
|
15978
|
-
|
|
16839
|
+
async function saveConfig(config, field) {
|
|
16840
|
+
const host = getDetectedHost();
|
|
16841
|
+
const env = honchoEnv(host);
|
|
16842
|
+
const write = (key, envVar) => key === field || !env[envVar];
|
|
16843
|
+
const patch = {};
|
|
16844
|
+
if (write("peerName", "HONCHO_PEER_NAME"))
|
|
16845
|
+
patch.peerName = config.peerName;
|
|
16846
|
+
if (write("workspace", "HONCHO_WORKSPACE"))
|
|
16847
|
+
patch.workspace = config.workspace === DEFAULT_WORKSPACE[host] ? undefined : config.workspace;
|
|
16848
|
+
if (write("aiPeer", "HONCHO_AI_PEER"))
|
|
16849
|
+
patch.aiPeer = config.aiPeer === DEFAULT_AI_PEER[host] ? undefined : config.aiPeer;
|
|
16850
|
+
if (write("baseUrl", "HONCHO_BASE_URL"))
|
|
16851
|
+
patch.baseUrl = config.baseUrl === DEFAULT_BASE_URL ? undefined : config.baseUrl;
|
|
16852
|
+
await saveHost(configPath(), host, patch, LEGACY);
|
|
15979
16853
|
}
|
|
15980
|
-
function
|
|
15981
|
-
|
|
16854
|
+
async function saveHostApiKey(key) {
|
|
16855
|
+
await saveHost(configPath(), getDetectedHost(), { apiKey: key }, LEGACY);
|
|
15982
16856
|
}
|
|
15983
|
-
function
|
|
15984
|
-
|
|
15985
|
-
const gitPath = join3(dir, ".git");
|
|
15986
|
-
if (!statSync(gitPath).isFile())
|
|
15987
|
-
return null;
|
|
15988
|
-
const match = readFileSync2(gitPath, "utf-8").match(/^gitdir:\s*(.+?)\s*$/m);
|
|
15989
|
-
if (!match)
|
|
15990
|
-
return null;
|
|
15991
|
-
const gitdir = resolve(dir, match[1]);
|
|
15992
|
-
const idx = gitdir.lastIndexOf(`${sep}worktrees${sep}`);
|
|
15993
|
-
if (idx === -1)
|
|
15994
|
-
return null;
|
|
15995
|
-
const gitContainer = gitdir.slice(0, idx);
|
|
15996
|
-
if (basename(gitContainer) === ".git")
|
|
15997
|
-
return dirname(gitContainer);
|
|
15998
|
-
if (gitContainer.endsWith(".git"))
|
|
15999
|
-
return gitContainer;
|
|
16000
|
-
return null;
|
|
16001
|
-
} catch {
|
|
16002
|
-
return null;
|
|
16003
|
-
}
|
|
16857
|
+
function getConfiguredOrigin(host = getDetectedHost()) {
|
|
16858
|
+
return resolveHost(host).baseUrl;
|
|
16004
16859
|
}
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
let dir = resolve(cwd);
|
|
16009
|
-
for (let i = 0;i < MAX_GIT_WALK_UP; i++) {
|
|
16010
|
-
if (existsSync3(join3(dir, ".git")))
|
|
16011
|
-
return resolveWorktreeMainRoot(dir);
|
|
16012
|
-
const parent = dirname(dir);
|
|
16013
|
-
if (parent === dir)
|
|
16014
|
-
break;
|
|
16015
|
-
dir = parent;
|
|
16016
|
-
}
|
|
16017
|
-
} catch {}
|
|
16018
|
-
return null;
|
|
16860
|
+
function getSessionName(sessionId) {
|
|
16861
|
+
const id = sessionId || process.env.CLAUDE_CODE_SESSION_ID;
|
|
16862
|
+
return id ? sanitizeForSessionName(id) : null;
|
|
16019
16863
|
}
|
|
16020
|
-
function
|
|
16021
|
-
const
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
return config.sessions[mr];
|
|
16029
|
-
return null;
|
|
16864
|
+
async function refreshCredential(config) {
|
|
16865
|
+
const host = config.auth?.host ?? getDetectedHost();
|
|
16866
|
+
const cred = await ensureFreshCredential({ path: configPath(), host, baseUrl: config.baseUrl, env: honchoEnv(host), legacy: LEGACY });
|
|
16867
|
+
if (!cred)
|
|
16868
|
+
return;
|
|
16869
|
+
const { token, ...authState } = cred;
|
|
16870
|
+
config.apiKey = token;
|
|
16871
|
+
config.auth = { ...authState, host };
|
|
16030
16872
|
}
|
|
16031
|
-
function
|
|
16032
|
-
const
|
|
16033
|
-
const
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16040
|
-
|
|
16041
|
-
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
case "chat-instance": {
|
|
16045
|
-
if (opts.instanceId) {
|
|
16046
|
-
return usePrefix ? `${peerPart}-chat-${opts.instanceId}` : `chat-${opts.instanceId}`;
|
|
16047
|
-
}
|
|
16048
|
-
return base;
|
|
16049
|
-
}
|
|
16050
|
-
case "per-directory":
|
|
16873
|
+
function describeAuth(config) {
|
|
16874
|
+
const a = config.auth;
|
|
16875
|
+
const expiry = () => {
|
|
16876
|
+
if (!a?.expiresAt)
|
|
16877
|
+
return "";
|
|
16878
|
+
const mins = Math.round((a.expiresAt - Date.now() / 1000) / 60);
|
|
16879
|
+
return mins > 0 ? ` (token refreshes in ${mins}m)` : " (token expired)";
|
|
16880
|
+
};
|
|
16881
|
+
switch (a?.source) {
|
|
16882
|
+
case "env":
|
|
16883
|
+
return "HONCHO_API_KEY env var";
|
|
16884
|
+
case "oauth":
|
|
16885
|
+
return `signed in with Honcho${expiry()}`;
|
|
16051
16886
|
default:
|
|
16052
|
-
return
|
|
16053
|
-
}
|
|
16054
|
-
}
|
|
16055
|
-
function getSessionName(cwd, instanceId) {
|
|
16056
|
-
const config = loadConfig2();
|
|
16057
|
-
const strategy = config?.sessionStrategy ?? "per-directory";
|
|
16058
|
-
const mainRoot = worktreeMainRootFor(cwd);
|
|
16059
|
-
if (strategy === "per-directory") {
|
|
16060
|
-
const configuredSession = getSessionForPath(cwd, mainRoot);
|
|
16061
|
-
if (configuredSession) {
|
|
16062
|
-
return configuredSession;
|
|
16063
|
-
}
|
|
16064
|
-
}
|
|
16065
|
-
let branch;
|
|
16066
|
-
if (strategy === "git-branch") {
|
|
16067
|
-
branch = captureGitState(cwd)?.branch;
|
|
16887
|
+
return "API key";
|
|
16068
16888
|
}
|
|
16069
|
-
let resolvedInstanceId;
|
|
16070
|
-
if (strategy === "chat-instance") {
|
|
16071
|
-
resolvedInstanceId = instanceId || getInstanceIdForCwd(cwd) || getClaudeInstanceId() || undefined;
|
|
16072
|
-
}
|
|
16073
|
-
return deriveSessionName(strategy, mainRoot ?? cwd, {
|
|
16074
|
-
peerName: config?.peerName,
|
|
16075
|
-
sessionPeerPrefix: config?.sessionPeerPrefix,
|
|
16076
|
-
branch,
|
|
16077
|
-
instanceId: resolvedInstanceId
|
|
16078
|
-
});
|
|
16079
16889
|
}
|
|
16080
|
-
function
|
|
16081
|
-
if (
|
|
16082
|
-
|
|
16083
|
-
return url.endsWith("/v3") ? url : `${url}/v3`;
|
|
16890
|
+
function getAuthNotice(config) {
|
|
16891
|
+
if (config.auth?.reauthRequired) {
|
|
16892
|
+
return "[honcho] Your Honcho sign-in has expired. Run /honcho setup to sign in again.";
|
|
16084
16893
|
}
|
|
16085
|
-
|
|
16086
|
-
return HONCHO_BASE_URLS.local;
|
|
16087
|
-
}
|
|
16088
|
-
return HONCHO_BASE_URLS.production;
|
|
16894
|
+
return;
|
|
16089
16895
|
}
|
|
16090
16896
|
function getHonchoBaseUrl(config) {
|
|
16091
|
-
return
|
|
16897
|
+
return `${config.baseUrl}/v3`;
|
|
16092
16898
|
}
|
|
16093
16899
|
function getTelemetryHeaders(host = getDetectedHost()) {
|
|
16094
16900
|
return telemetryHeaders({
|
|
@@ -16107,18 +16913,18 @@ function getHonchoClientOptions(config) {
|
|
|
16107
16913
|
defaultHeaders: getTelemetryHeaders()
|
|
16108
16914
|
};
|
|
16109
16915
|
}
|
|
16916
|
+
function isProductionEndpoint(config) {
|
|
16917
|
+
return config.baseUrl === DEFAULT_BASE_URL;
|
|
16918
|
+
}
|
|
16110
16919
|
function getEndpointInfo(config) {
|
|
16111
|
-
|
|
16112
|
-
return { type: "custom", url: config.endpoint.baseUrl };
|
|
16113
|
-
}
|
|
16114
|
-
if (config.endpoint?.environment === "local") {
|
|
16115
|
-
return { type: "local", url: HONCHO_BASE_URLS.local };
|
|
16116
|
-
}
|
|
16117
|
-
return { type: "production", url: HONCHO_BASE_URLS.production };
|
|
16920
|
+
return { type: isProductionEndpoint(config) ? "production" : "custom", url: config.baseUrl };
|
|
16118
16921
|
}
|
|
16119
|
-
|
|
16120
|
-
|
|
16121
|
-
|
|
16922
|
+
|
|
16923
|
+
// src/honcho-client.ts
|
|
16924
|
+
var import_sdk = __toESM(require_dist(), 1);
|
|
16925
|
+
async function createHonchoClient(config, overrides = {}) {
|
|
16926
|
+
await refreshCredential(config);
|
|
16927
|
+
return new import_sdk.Honcho({ ...getHonchoClientOptions(config), ...overrides });
|
|
16122
16928
|
}
|
|
16123
16929
|
|
|
16124
16930
|
// src/styles.ts
|
|
@@ -16178,6 +16984,11 @@ function listItem(text, indent = 0) {
|
|
|
16178
16984
|
const padding = " ".repeat(indent);
|
|
16179
16985
|
return `${padding}${colors.dim}${symbols.bullet}${colors.reset} ${text}`;
|
|
16180
16986
|
}
|
|
16987
|
+
function honchoSessionUrl(config, sessionName) {
|
|
16988
|
+
if (!isProductionEndpoint(config))
|
|
16989
|
+
return null;
|
|
16990
|
+
return `https://app.honcho.dev/explore?workspace=${encodeURIComponent(config.workspace)}&view=sessions&session=${encodeURIComponent(sessionName)}`;
|
|
16991
|
+
}
|
|
16181
16992
|
|
|
16182
16993
|
// src/skills/status.ts
|
|
16183
16994
|
async function status() {
|
|
@@ -16187,12 +16998,12 @@ async function status() {
|
|
|
16187
16998
|
const config = loadConfig2();
|
|
16188
16999
|
if (!config) {
|
|
16189
17000
|
console.log(warn("Not configured"));
|
|
16190
|
-
console.log(dim("
|
|
17001
|
+
console.log(dim("Run /honcho setup to sign in, or set the HONCHO_API_KEY environment variable"));
|
|
16191
17002
|
return;
|
|
16192
17003
|
}
|
|
16193
17004
|
const endpointInfo = getEndpointInfo(config);
|
|
16194
17005
|
try {
|
|
16195
|
-
const honcho =
|
|
17006
|
+
const honcho = await createHonchoClient(config);
|
|
16196
17007
|
const pingStart = Date.now();
|
|
16197
17008
|
const [queueResult, conclusionsResult] = await Promise.allSettled([
|
|
16198
17009
|
honcho.queueStatus(),
|
|
@@ -16204,8 +17015,12 @@ async function status() {
|
|
|
16204
17015
|
}
|
|
16205
17016
|
console.log(` ${label("Connection")}: ${success("connected")} ${dim(`(${latency}ms)`)}`);
|
|
16206
17017
|
console.log(` ${label("Workspace")}: ${config.workspace} ${dim(`@ ${endpointInfo.url}`)}`);
|
|
16207
|
-
console.log(` ${label("Session")}: ${getSessionName(
|
|
17018
|
+
console.log(` ${label("Session")}: ${getSessionName() ?? "unknown"}`);
|
|
16208
17019
|
console.log(` ${label("Peers")}: ${config.peerName} / ${config.aiPeer}`);
|
|
17020
|
+
console.log(` ${label("Auth")}: ${describeAuth(config)}`);
|
|
17021
|
+
const authNotice = getAuthNotice(config);
|
|
17022
|
+
if (authNotice)
|
|
17023
|
+
console.log(` ${warn(authNotice)}`);
|
|
16209
17024
|
if (queueResult.status === "fulfilled") {
|
|
16210
17025
|
const q = queueResult.value;
|
|
16211
17026
|
const total = q.totalWorkUnits ?? 0;
|
|
@@ -16232,7 +17047,7 @@ async function status() {
|
|
|
16232
17047
|
} catch (err) {
|
|
16233
17048
|
const message = err instanceof Error ? err.message : String(err);
|
|
16234
17049
|
if (message.includes("401") || message.includes("Unauthorized")) {
|
|
16235
|
-
console.log(` ${label("Connection")}: ${error("auth failed")} ${dim(
|
|
17050
|
+
console.log(` ${label("Connection")}: ${error("auth failed")} ${dim(`${describeAuth(config)}; run /honcho setup`)}`);
|
|
16236
17051
|
} else if (message.includes("ECONNREFUSED") || message.includes("fetch failed")) {
|
|
16237
17052
|
console.log(` ${label("Connection")}: ${error("unreachable")} ${dim(endpointInfo.url)}`);
|
|
16238
17053
|
} else {
|
|
@@ -16245,5 +17060,5 @@ async function status() {
|
|
|
16245
17060
|
// src/skills/status-runner.ts
|
|
16246
17061
|
await status();
|
|
16247
17062
|
|
|
16248
|
-
//# debugId=
|
|
17063
|
+
//# debugId=5A8CA8B319C3CE3F64756E2164756E21
|
|
16249
17064
|
//# sourceMappingURL=status-runner.js.map
|