@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
package/dist/mcp-server.js
CHANGED
|
@@ -6499,8 +6499,9 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
6499
6499
|
// node_modules/@honcho-ai/sdk/dist/api-version.js
|
|
6500
6500
|
var require_api_version = __commonJS(function(exports) {
|
|
6501
6501
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6502
|
-
exports.API_VERSION = undefined;
|
|
6502
|
+
exports.VERSION = exports.API_VERSION = undefined;
|
|
6503
6503
|
exports.API_VERSION = "v3";
|
|
6504
|
+
exports.VERSION = "2.9.0";
|
|
6504
6505
|
});
|
|
6505
6506
|
|
|
6506
6507
|
// node_modules/@honcho-ai/sdk/dist/http/errors.js
|
|
@@ -6625,255 +6626,6 @@ var require_errors2 = __commonJS(function(exports) {
|
|
|
6625
6626
|
}
|
|
6626
6627
|
});
|
|
6627
6628
|
|
|
6628
|
-
// node_modules/@honcho-ai/sdk/dist/http/client.js
|
|
6629
|
-
var require_client = __commonJS(function(exports) {
|
|
6630
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6631
|
-
exports.HonchoHTTPClient = undefined;
|
|
6632
|
-
var errors_1 = require_errors2();
|
|
6633
|
-
var DEFAULT_TIMEOUT = 60000;
|
|
6634
|
-
var DEFAULT_MAX_RETRIES = 2;
|
|
6635
|
-
var RETRY_STATUS_CODES = [429, 500, 502, 503, 504];
|
|
6636
|
-
var INITIAL_RETRY_DELAY = 500;
|
|
6637
|
-
|
|
6638
|
-
class HonchoHTTPClient {
|
|
6639
|
-
constructor(config) {
|
|
6640
|
-
this.baseURL = config.baseURL.replace(/\/$/, "");
|
|
6641
|
-
this.apiKey = config.apiKey;
|
|
6642
|
-
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
6643
|
-
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
6644
|
-
this.defaultHeaders = {
|
|
6645
|
-
"Content-Type": "application/json",
|
|
6646
|
-
...config.defaultHeaders
|
|
6647
|
-
};
|
|
6648
|
-
this.defaultQuery = config.defaultQuery;
|
|
6649
|
-
}
|
|
6650
|
-
async request(method, path, options = {}) {
|
|
6651
|
-
const url = this.buildURL(path, options.query);
|
|
6652
|
-
const headers = this.buildHeaders(options.headers);
|
|
6653
|
-
const timeout = options.timeout ?? this.timeout;
|
|
6654
|
-
let lastError;
|
|
6655
|
-
let attempt = 0;
|
|
6656
|
-
while (attempt <= this.maxRetries) {
|
|
6657
|
-
try {
|
|
6658
|
-
const response = await this.fetchWithTimeout(url, {
|
|
6659
|
-
method,
|
|
6660
|
-
headers,
|
|
6661
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
6662
|
-
signal: options.signal
|
|
6663
|
-
}, timeout);
|
|
6664
|
-
if (response.ok) {
|
|
6665
|
-
const text = await response.text();
|
|
6666
|
-
if (!text) {
|
|
6667
|
-
return;
|
|
6668
|
-
}
|
|
6669
|
-
return JSON.parse(text);
|
|
6670
|
-
}
|
|
6671
|
-
const errorBody = await this.parseErrorBody(response);
|
|
6672
|
-
const retryAfter = this.parseRetryAfter(response);
|
|
6673
|
-
const error = (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody, retryAfter);
|
|
6674
|
-
if (RETRY_STATUS_CODES.includes(response.status) && attempt < this.maxRetries) {
|
|
6675
|
-
lastError = error;
|
|
6676
|
-
await this.sleep(this.getRetryDelay(attempt, retryAfter));
|
|
6677
|
-
attempt++;
|
|
6678
|
-
continue;
|
|
6679
|
-
}
|
|
6680
|
-
throw error;
|
|
6681
|
-
} catch (error) {
|
|
6682
|
-
if (error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
6683
|
-
if (attempt < this.maxRetries) {
|
|
6684
|
-
lastError = error;
|
|
6685
|
-
await this.sleep(this.getRetryDelay(attempt));
|
|
6686
|
-
attempt++;
|
|
6687
|
-
continue;
|
|
6688
|
-
}
|
|
6689
|
-
}
|
|
6690
|
-
if (error instanceof errors_1.RateLimitError || error instanceof errors_1.ServerError || error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
6691
|
-
throw error;
|
|
6692
|
-
}
|
|
6693
|
-
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
6694
|
-
const connError = new errors_1.ConnectionError(error.message);
|
|
6695
|
-
if (attempt < this.maxRetries) {
|
|
6696
|
-
lastError = connError;
|
|
6697
|
-
await this.sleep(this.getRetryDelay(attempt));
|
|
6698
|
-
attempt++;
|
|
6699
|
-
continue;
|
|
6700
|
-
}
|
|
6701
|
-
throw connError;
|
|
6702
|
-
}
|
|
6703
|
-
throw error;
|
|
6704
|
-
}
|
|
6705
|
-
}
|
|
6706
|
-
throw lastError || new Error("Request failed after retries");
|
|
6707
|
-
}
|
|
6708
|
-
async get(path, options) {
|
|
6709
|
-
return this.request("GET", path, options);
|
|
6710
|
-
}
|
|
6711
|
-
async post(path, options) {
|
|
6712
|
-
return this.request("POST", path, options);
|
|
6713
|
-
}
|
|
6714
|
-
async put(path, options) {
|
|
6715
|
-
return this.request("PUT", path, options);
|
|
6716
|
-
}
|
|
6717
|
-
async patch(path, options) {
|
|
6718
|
-
return this.request("PATCH", path, options);
|
|
6719
|
-
}
|
|
6720
|
-
async delete(path, options) {
|
|
6721
|
-
return this.request("DELETE", path, options);
|
|
6722
|
-
}
|
|
6723
|
-
async stream(method, path, options = {}) {
|
|
6724
|
-
const url = this.buildURL(path, options.query);
|
|
6725
|
-
const headers = {
|
|
6726
|
-
...this.buildHeaders(options.headers),
|
|
6727
|
-
Accept: "text/event-stream"
|
|
6728
|
-
};
|
|
6729
|
-
const timeout = options.timeout ?? this.timeout;
|
|
6730
|
-
const response = await this.fetchWithTimeout(url, {
|
|
6731
|
-
method,
|
|
6732
|
-
headers,
|
|
6733
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
6734
|
-
signal: options.signal
|
|
6735
|
-
}, timeout);
|
|
6736
|
-
if (!response.ok) {
|
|
6737
|
-
const errorBody = await this.parseErrorBody(response);
|
|
6738
|
-
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
6739
|
-
}
|
|
6740
|
-
return response;
|
|
6741
|
-
}
|
|
6742
|
-
async upload(path, formData, options = {}) {
|
|
6743
|
-
const url = this.buildURL(path, options.query);
|
|
6744
|
-
const headers = {};
|
|
6745
|
-
if (this.apiKey) {
|
|
6746
|
-
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
6747
|
-
}
|
|
6748
|
-
if (options.headers) {
|
|
6749
|
-
Object.assign(headers, options.headers);
|
|
6750
|
-
}
|
|
6751
|
-
const timeout = options.timeout ?? this.timeout;
|
|
6752
|
-
const response = await this.fetchWithTimeout(url, {
|
|
6753
|
-
method: "POST",
|
|
6754
|
-
headers,
|
|
6755
|
-
body: formData,
|
|
6756
|
-
signal: options.signal
|
|
6757
|
-
}, timeout);
|
|
6758
|
-
if (!response.ok) {
|
|
6759
|
-
const errorBody = await this.parseErrorBody(response);
|
|
6760
|
-
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
6761
|
-
}
|
|
6762
|
-
const text = await response.text();
|
|
6763
|
-
if (!text) {
|
|
6764
|
-
return;
|
|
6765
|
-
}
|
|
6766
|
-
return JSON.parse(text);
|
|
6767
|
-
}
|
|
6768
|
-
buildURL(path, query) {
|
|
6769
|
-
const url = new URL(path, this.baseURL);
|
|
6770
|
-
const mergedQuery = {
|
|
6771
|
-
...this.defaultQuery ?? {},
|
|
6772
|
-
...query ?? {}
|
|
6773
|
-
};
|
|
6774
|
-
for (const [key, value] of Object.entries(mergedQuery)) {
|
|
6775
|
-
if (value !== undefined) {
|
|
6776
|
-
url.searchParams.set(key, String(value));
|
|
6777
|
-
}
|
|
6778
|
-
}
|
|
6779
|
-
return url.toString();
|
|
6780
|
-
}
|
|
6781
|
-
buildHeaders(extra) {
|
|
6782
|
-
const headers = { ...this.defaultHeaders };
|
|
6783
|
-
if (this.apiKey) {
|
|
6784
|
-
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
6785
|
-
}
|
|
6786
|
-
if (extra) {
|
|
6787
|
-
Object.assign(headers, extra);
|
|
6788
|
-
}
|
|
6789
|
-
return headers;
|
|
6790
|
-
}
|
|
6791
|
-
async fetchWithTimeout(url, init, timeout) {
|
|
6792
|
-
const controller = new AbortController;
|
|
6793
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
6794
|
-
if (init.signal) {
|
|
6795
|
-
init.signal.addEventListener("abort", () => controller.abort());
|
|
6796
|
-
}
|
|
6797
|
-
try {
|
|
6798
|
-
const response = await fetch(url, {
|
|
6799
|
-
...init,
|
|
6800
|
-
signal: controller.signal
|
|
6801
|
-
});
|
|
6802
|
-
return response;
|
|
6803
|
-
} catch (error) {
|
|
6804
|
-
if (error instanceof DOMException && error.name === "AbortError") {
|
|
6805
|
-
throw new errors_1.TimeoutError(`Request timed out after ${timeout}ms`);
|
|
6806
|
-
}
|
|
6807
|
-
throw error;
|
|
6808
|
-
} finally {
|
|
6809
|
-
clearTimeout(timeoutId);
|
|
6810
|
-
}
|
|
6811
|
-
}
|
|
6812
|
-
async parseErrorBody(response) {
|
|
6813
|
-
try {
|
|
6814
|
-
const body = await response.json();
|
|
6815
|
-
return {
|
|
6816
|
-
message: body.detail || body.message || body.error,
|
|
6817
|
-
...body
|
|
6818
|
-
};
|
|
6819
|
-
} catch {
|
|
6820
|
-
return { message: `HTTP ${response.status}` };
|
|
6821
|
-
}
|
|
6822
|
-
}
|
|
6823
|
-
parseRetryAfter(response) {
|
|
6824
|
-
const header = response.headers.get("Retry-After");
|
|
6825
|
-
if (!header)
|
|
6826
|
-
return;
|
|
6827
|
-
const seconds = Number.parseInt(header, 10);
|
|
6828
|
-
if (!Number.isNaN(seconds)) {
|
|
6829
|
-
return seconds * 1000;
|
|
6830
|
-
}
|
|
6831
|
-
const date = Date.parse(header);
|
|
6832
|
-
if (!Number.isNaN(date)) {
|
|
6833
|
-
return Math.max(0, date - Date.now());
|
|
6834
|
-
}
|
|
6835
|
-
return;
|
|
6836
|
-
}
|
|
6837
|
-
getRetryDelay(attempt, retryAfter) {
|
|
6838
|
-
if (retryAfter) {
|
|
6839
|
-
return retryAfter;
|
|
6840
|
-
}
|
|
6841
|
-
return INITIAL_RETRY_DELAY * 2 ** attempt;
|
|
6842
|
-
}
|
|
6843
|
-
sleep(ms) {
|
|
6844
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6845
|
-
}
|
|
6846
|
-
}
|
|
6847
|
-
exports.HonchoHTTPClient = HonchoHTTPClient;
|
|
6848
|
-
});
|
|
6849
|
-
|
|
6850
|
-
// node_modules/@honcho-ai/sdk/dist/message.js
|
|
6851
|
-
var require_message = __commonJS(function(exports) {
|
|
6852
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6853
|
-
exports.Message = undefined;
|
|
6854
|
-
|
|
6855
|
-
class Message {
|
|
6856
|
-
constructor(id, content, peerId, sessionId, workspaceId, metadata, createdAt, tokenCount) {
|
|
6857
|
-
this.id = id;
|
|
6858
|
-
this.content = content;
|
|
6859
|
-
this.peerId = peerId;
|
|
6860
|
-
this.sessionId = sessionId;
|
|
6861
|
-
this.workspaceId = workspaceId;
|
|
6862
|
-
this.metadata = metadata;
|
|
6863
|
-
this.createdAt = createdAt;
|
|
6864
|
-
this.tokenCount = tokenCount;
|
|
6865
|
-
}
|
|
6866
|
-
static fromApiResponse(data) {
|
|
6867
|
-
return new Message(data.id, data.content, data.peer_id, data.session_id, data.workspace_id, data.metadata, data.created_at, data.token_count);
|
|
6868
|
-
}
|
|
6869
|
-
toString() {
|
|
6870
|
-
const truncatedContent = this.content.length > 50 ? `${this.content.slice(0, 50)}...` : this.content;
|
|
6871
|
-
return `Message(id='${this.id}', peerId='${this.peerId}', content='${truncatedContent}')`;
|
|
6872
|
-
}
|
|
6873
|
-
}
|
|
6874
|
-
exports.Message = Message;
|
|
6875
|
-
});
|
|
6876
|
-
|
|
6877
6629
|
// node_modules/@honcho-ai/sdk/dist/pagination.js
|
|
6878
6630
|
var require_pagination = __commonJS(function(exports) {
|
|
6879
6631
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -20153,9 +19905,10 @@ var require_zod = __commonJS(function(exports) {
|
|
|
20153
19905
|
// node_modules/@honcho-ai/sdk/dist/validation.js
|
|
20154
19906
|
var require_validation2 = __commonJS(function(exports) {
|
|
20155
19907
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20156
|
-
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;
|
|
19908
|
+
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;
|
|
20157
19909
|
exports.normalizeSearchQuery = normalizeSearchQuery;
|
|
20158
19910
|
exports.normalizeListOptions = normalizeListOptions;
|
|
19911
|
+
exports.scopeRecallFields = scopeRecallFields;
|
|
20159
19912
|
exports.peerConfigToApi = peerConfigToApi;
|
|
20160
19913
|
exports.peerConfigFromApi = peerConfigFromApi;
|
|
20161
19914
|
exports.workspaceConfigToApi = workspaceConfigToApi;
|
|
@@ -20165,7 +19918,7 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20165
19918
|
exports.messageConfigToApi = messageConfigToApi;
|
|
20166
19919
|
exports.messageConfigFromApi = messageConfigFromApi;
|
|
20167
19920
|
var zod_1 = require_zod();
|
|
20168
|
-
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(
|
|
19921
|
+
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");
|
|
20169
19922
|
exports.HonchoConfigSchema = zod_1.z.object({
|
|
20170
19923
|
apiKey: zod_1.z.string().optional(),
|
|
20171
19924
|
environment: zod_1.z.enum(["local", "production"]).optional(),
|
|
@@ -20180,7 +19933,7 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20180
19933
|
exports.PeerConfigSchema = zod_1.z.object({
|
|
20181
19934
|
observeMe: zod_1.z.boolean().nullable().optional()
|
|
20182
19935
|
}).strict();
|
|
20183
|
-
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(
|
|
19936
|
+
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");
|
|
20184
19937
|
var PeerIdObjectSchema = zod_1.z.object({ id: exports.PeerIdSchema });
|
|
20185
19938
|
exports.SessionMetadataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
20186
19939
|
exports.ReasoningConfigSchema = zod_1.z.object({
|
|
@@ -20189,32 +19942,92 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20189
19942
|
}).strict();
|
|
20190
19943
|
exports.PeerCardConfigSchema = zod_1.z.object({
|
|
20191
19944
|
use: zod_1.z.boolean().nullable().optional(),
|
|
20192
|
-
create: zod_1.z.boolean().nullable().optional()
|
|
19945
|
+
create: zod_1.z.boolean().nullable().optional(),
|
|
19946
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
20193
19947
|
}).strict();
|
|
20194
19948
|
exports.SummaryConfigSchema = zod_1.z.object({
|
|
20195
19949
|
enabled: zod_1.z.boolean().nullable().optional(),
|
|
20196
19950
|
messagesPerShortSummary: zod_1.z.number().int().min(10).nullable().optional(),
|
|
20197
|
-
messagesPerLongSummary: zod_1.z.number().int().min(20).nullable().optional()
|
|
19951
|
+
messagesPerLongSummary: zod_1.z.number().int().min(20).nullable().optional(),
|
|
19952
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
20198
19953
|
}).strict();
|
|
20199
19954
|
exports.DreamConfigSchema = zod_1.z.object({
|
|
20200
|
-
enabled: zod_1.z.boolean().nullable().optional()
|
|
19955
|
+
enabled: zod_1.z.boolean().nullable().optional(),
|
|
19956
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
19957
|
+
}).strict();
|
|
19958
|
+
exports.DialecticConfigSchema = zod_1.z.object({
|
|
19959
|
+
customInstructions: zod_1.z.string().nullable().optional()
|
|
20201
19960
|
}).strict();
|
|
20202
19961
|
exports.SessionConfigSchema = zod_1.z.object({
|
|
19962
|
+
customInstructions: zod_1.z.string().nullable().optional(),
|
|
20203
19963
|
reasoning: exports.ReasoningConfigSchema.nullable().optional(),
|
|
20204
19964
|
peerCard: exports.PeerCardConfigSchema.nullable().optional(),
|
|
20205
19965
|
summary: exports.SummaryConfigSchema.nullable().optional(),
|
|
20206
|
-
dream: exports.DreamConfigSchema.nullable().optional()
|
|
19966
|
+
dream: exports.DreamConfigSchema.nullable().optional(),
|
|
19967
|
+
dialectic: exports.DialecticConfigSchema.nullable().optional()
|
|
20207
19968
|
}).strict();
|
|
20208
|
-
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(
|
|
19969
|
+
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");
|
|
20209
19970
|
var SessionIdObjectSchema = zod_1.z.object({ id: exports.SessionIdSchema });
|
|
20210
|
-
|
|
20211
|
-
|
|
20212
|
-
|
|
20213
|
-
|
|
20214
|
-
|
|
20215
|
-
|
|
20216
|
-
|
|
20217
|
-
|
|
19971
|
+
var SCOPE_PEER_PREFIX = "scope.";
|
|
19972
|
+
var SCOPE_ID_MAX_LENGTH = 512 - SCOPE_PEER_PREFIX.length;
|
|
19973
|
+
function scopeIdIssues(value) {
|
|
19974
|
+
if (value.length < 1) {
|
|
19975
|
+
return ["Scope ID must be a non-empty string"];
|
|
19976
|
+
}
|
|
19977
|
+
if (value.length > SCOPE_ID_MAX_LENGTH) {
|
|
19978
|
+
return [`Scope ID can be at most ${SCOPE_ID_MAX_LENGTH} characters`];
|
|
19979
|
+
}
|
|
19980
|
+
if (value.startsWith(SCOPE_PEER_PREFIX)) {
|
|
19981
|
+
return [
|
|
19982
|
+
`Scope ID must not start with the reserved prefix '${SCOPE_PEER_PREFIX}' (scope IDs are unprefixed)`
|
|
19983
|
+
];
|
|
19984
|
+
}
|
|
19985
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(value)) {
|
|
19986
|
+
return [
|
|
19987
|
+
"Scope ID may only contain letters, numbers, underscores, and hyphens"
|
|
19988
|
+
];
|
|
19989
|
+
}
|
|
19990
|
+
return [];
|
|
19991
|
+
}
|
|
19992
|
+
function addScopeIdIssues(values, ctx) {
|
|
19993
|
+
for (const value of values) {
|
|
19994
|
+
for (const message of scopeIdIssues(value)) {
|
|
19995
|
+
ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message });
|
|
19996
|
+
}
|
|
19997
|
+
}
|
|
19998
|
+
}
|
|
19999
|
+
exports.ScopeIdSchema = zod_1.z.string().superRefine((val, ctx) => {
|
|
20000
|
+
addScopeIdIssues([val], ctx);
|
|
20001
|
+
});
|
|
20002
|
+
var ScopeIdLikeSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.object({ id: zod_1.z.string() })]);
|
|
20003
|
+
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) => {
|
|
20004
|
+
if (Array.isArray(resolved)) {
|
|
20005
|
+
if (resolved.length === 0) {
|
|
20006
|
+
ctx.addIssue({
|
|
20007
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20008
|
+
message: "scope must name at least one scope"
|
|
20009
|
+
});
|
|
20010
|
+
}
|
|
20011
|
+
if (resolved.length > 100) {
|
|
20012
|
+
ctx.addIssue({
|
|
20013
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20014
|
+
message: "scope can name at most 100 scopes"
|
|
20015
|
+
});
|
|
20016
|
+
}
|
|
20017
|
+
}
|
|
20018
|
+
addScopeIdIssues(Array.isArray(resolved) ? resolved : [resolved], ctx);
|
|
20019
|
+
});
|
|
20020
|
+
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");
|
|
20021
|
+
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");
|
|
20022
|
+
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));
|
|
20023
|
+
exports.SessionPeerConfigSchema = zod_1.z.object({
|
|
20024
|
+
observeMe: zod_1.z.boolean().nullable().optional(),
|
|
20025
|
+
observeOthers: zod_1.z.boolean().nullable().optional()
|
|
20026
|
+
}).strict();
|
|
20027
|
+
exports.MessageContentSchema = zod_1.z.string().refine((content) => content === "" || content.trim().length > 0, "Message content cannot be only whitespace");
|
|
20028
|
+
exports.MessageMetadataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional();
|
|
20029
|
+
exports.MessageConfigurationSchema = zod_1.z.object({
|
|
20030
|
+
reasoning: exports.ReasoningConfigSchema.nullable().optional()
|
|
20218
20031
|
}).strict().nullable().optional();
|
|
20219
20032
|
exports.MessageInputSchema = zod_1.z.object({
|
|
20220
20033
|
peerId: exports.PeerIdSchema,
|
|
@@ -20254,12 +20067,41 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20254
20067
|
}
|
|
20255
20068
|
return { filters: input };
|
|
20256
20069
|
}
|
|
20070
|
+
function scopeRecallFields(options) {
|
|
20071
|
+
return {
|
|
20072
|
+
scope: options.scope,
|
|
20073
|
+
filters: options.sessions ? { session_id: options.sessions } : undefined
|
|
20074
|
+
};
|
|
20075
|
+
}
|
|
20076
|
+
function scopeExclusivityIssues(data, ctx) {
|
|
20077
|
+
if (data.scope === undefined) {
|
|
20078
|
+
return;
|
|
20079
|
+
}
|
|
20080
|
+
if (data.sessions !== undefined) {
|
|
20081
|
+
ctx.addIssue({
|
|
20082
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20083
|
+
message: "scope and sessions are mutually exclusive",
|
|
20084
|
+
path: ["sessions"]
|
|
20085
|
+
});
|
|
20086
|
+
}
|
|
20087
|
+
if (data.session !== undefined) {
|
|
20088
|
+
ctx.addIssue({
|
|
20089
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20090
|
+
message: "scope and session are mutually exclusive",
|
|
20091
|
+
path: ["session"]
|
|
20092
|
+
});
|
|
20093
|
+
}
|
|
20094
|
+
}
|
|
20257
20095
|
exports.ChatQuerySchema = zod_1.z.object({
|
|
20258
20096
|
query: exports.SearchQuerySchema,
|
|
20259
20097
|
target: zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional().transform((val) => val ? typeof val === "string" ? val : val.id : undefined),
|
|
20260
20098
|
session: zod_1.z.union([exports.SessionIdSchema, SessionIdObjectSchema]).optional().transform((val) => val ? typeof val === "string" ? val : val.id : undefined),
|
|
20261
|
-
|
|
20262
|
-
|
|
20099
|
+
scope: exports.ScopeOptionSchema.optional(),
|
|
20100
|
+
sessions: exports.SessionAllowlistSchema.optional(),
|
|
20101
|
+
reasoningLevel: zod_1.z.enum(["minimal", "low", "medium", "high", "max"]).optional(),
|
|
20102
|
+
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(),
|
|
20103
|
+
includeEvidence: zod_1.z.boolean().optional()
|
|
20104
|
+
}).strict().superRefine(scopeExclusivityIssues);
|
|
20263
20105
|
exports.RepresentationOptionsSchema = zod_1.z.object({
|
|
20264
20106
|
searchQuery: exports.SearchQueryLikeSchema.optional(),
|
|
20265
20107
|
searchTopK: zod_1.z.number().int().min(1, "searchTopK must be at least 1").max(100, "searchTopK must be at most 100").optional(),
|
|
@@ -20272,9 +20114,32 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20272
20114
|
tokens: zod_1.z.int("Token limit must be an integer").optional(),
|
|
20273
20115
|
peerTarget: exports.PeerIdSchema.optional(),
|
|
20274
20116
|
peerPerspective: exports.PeerIdSchema.optional(),
|
|
20117
|
+
scope: exports.ScopeIdSchema.optional(),
|
|
20118
|
+
sessions: exports.SessionAllowlistSchema.optional(),
|
|
20275
20119
|
limitToSession: zod_1.z.boolean().optional(),
|
|
20276
20120
|
representationOptions: exports.RepresentationOptionsSchema.optional()
|
|
20277
20121
|
}).strict().superRefine((data, ctx) => {
|
|
20122
|
+
if (data.sessions && !data.peerTarget) {
|
|
20123
|
+
ctx.addIssue({
|
|
20124
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20125
|
+
message: "peerTarget is required when sessions is provided",
|
|
20126
|
+
path: ["sessions"]
|
|
20127
|
+
});
|
|
20128
|
+
}
|
|
20129
|
+
if (data.sessions && data.scope) {
|
|
20130
|
+
ctx.addIssue({
|
|
20131
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20132
|
+
message: "sessions and scope are mutually exclusive",
|
|
20133
|
+
path: ["sessions"]
|
|
20134
|
+
});
|
|
20135
|
+
}
|
|
20136
|
+
if (data.sessions && data.limitToSession) {
|
|
20137
|
+
ctx.addIssue({
|
|
20138
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20139
|
+
message: "sessions and limitToSession are mutually exclusive",
|
|
20140
|
+
path: ["sessions"]
|
|
20141
|
+
});
|
|
20142
|
+
}
|
|
20278
20143
|
if (data.representationOptions?.searchQuery && !data.peerTarget) {
|
|
20279
20144
|
ctx.addIssue({
|
|
20280
20145
|
code: zod_1.z.ZodIssueCode.custom,
|
|
@@ -20289,6 +20154,20 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20289
20154
|
path: ["peerPerspective"]
|
|
20290
20155
|
});
|
|
20291
20156
|
}
|
|
20157
|
+
if (data.scope && !data.peerTarget) {
|
|
20158
|
+
ctx.addIssue({
|
|
20159
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20160
|
+
message: "peerTarget is required when scope is provided",
|
|
20161
|
+
path: ["scope"]
|
|
20162
|
+
});
|
|
20163
|
+
}
|
|
20164
|
+
if (data.scope && data.peerPerspective) {
|
|
20165
|
+
ctx.addIssue({
|
|
20166
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
20167
|
+
message: "scope and peerPerspective are mutually exclusive",
|
|
20168
|
+
path: ["scope"]
|
|
20169
|
+
});
|
|
20170
|
+
}
|
|
20292
20171
|
});
|
|
20293
20172
|
exports.QueueStatusOptionsSchema = zod_1.z.object({
|
|
20294
20173
|
observer: zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional(),
|
|
@@ -20317,9 +20196,11 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20317
20196
|
}).strict();
|
|
20318
20197
|
exports.PeerGetRepresentationParamsSchema = zod_1.z.object({
|
|
20319
20198
|
session: zod_1.z.union([exports.SessionIdSchema, SessionIdObjectSchema]).optional(),
|
|
20199
|
+
scope: exports.ScopeOptionSchema.optional(),
|
|
20200
|
+
sessions: exports.SessionAllowlistSchema.optional(),
|
|
20320
20201
|
target: zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional(),
|
|
20321
20202
|
options: exports.RepresentationOptionsSchema.optional()
|
|
20322
|
-
}).strict();
|
|
20203
|
+
}).strict().superRefine(scopeExclusivityIssues);
|
|
20323
20204
|
exports.CardTargetSchema = zod_1.z.union([exports.PeerIdSchema, PeerIdObjectSchema]).optional().transform((val) => val ? typeof val === "string" ? val : val.id : undefined);
|
|
20324
20205
|
exports.PeerCardContentSchema = zod_1.z.array(zod_1.z.string());
|
|
20325
20206
|
exports.PeerAdditionSchema = zod_1.z.union([
|
|
@@ -20380,7 +20261,8 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20380
20261
|
return;
|
|
20381
20262
|
return {
|
|
20382
20263
|
use: config.use,
|
|
20383
|
-
create: config.create
|
|
20264
|
+
create: config.create,
|
|
20265
|
+
custom_instructions: config.customInstructions
|
|
20384
20266
|
};
|
|
20385
20267
|
}
|
|
20386
20268
|
function peerCardConfigFromApi(config) {
|
|
@@ -20390,7 +20272,8 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20390
20272
|
return;
|
|
20391
20273
|
return {
|
|
20392
20274
|
use: config.use,
|
|
20393
|
-
create: config.create
|
|
20275
|
+
create: config.create,
|
|
20276
|
+
customInstructions: config.custom_instructions
|
|
20394
20277
|
};
|
|
20395
20278
|
}
|
|
20396
20279
|
function summaryConfigToApi(config) {
|
|
@@ -20401,7 +20284,8 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20401
20284
|
return {
|
|
20402
20285
|
enabled: config.enabled,
|
|
20403
20286
|
messages_per_short_summary: config.messagesPerShortSummary,
|
|
20404
|
-
messages_per_long_summary: config.messagesPerLongSummary
|
|
20287
|
+
messages_per_long_summary: config.messagesPerLongSummary,
|
|
20288
|
+
custom_instructions: config.customInstructions
|
|
20405
20289
|
};
|
|
20406
20290
|
}
|
|
20407
20291
|
function summaryConfigFromApi(config) {
|
|
@@ -20412,7 +20296,8 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20412
20296
|
return {
|
|
20413
20297
|
enabled: config.enabled,
|
|
20414
20298
|
messagesPerShortSummary: config.messages_per_short_summary,
|
|
20415
|
-
messagesPerLongSummary: config.messages_per_long_summary
|
|
20299
|
+
messagesPerLongSummary: config.messages_per_long_summary,
|
|
20300
|
+
customInstructions: config.custom_instructions
|
|
20416
20301
|
};
|
|
20417
20302
|
}
|
|
20418
20303
|
function dreamConfigToApi(config) {
|
|
@@ -20421,7 +20306,8 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20421
20306
|
if (config === undefined)
|
|
20422
20307
|
return;
|
|
20423
20308
|
return {
|
|
20424
|
-
enabled: config.enabled
|
|
20309
|
+
enabled: config.enabled,
|
|
20310
|
+
custom_instructions: config.customInstructions
|
|
20425
20311
|
};
|
|
20426
20312
|
}
|
|
20427
20313
|
function dreamConfigFromApi(config) {
|
|
@@ -20430,17 +20316,38 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20430
20316
|
if (config === undefined)
|
|
20431
20317
|
return;
|
|
20432
20318
|
return {
|
|
20433
|
-
enabled: config.enabled
|
|
20319
|
+
enabled: config.enabled,
|
|
20320
|
+
customInstructions: config.custom_instructions
|
|
20321
|
+
};
|
|
20322
|
+
}
|
|
20323
|
+
function dialecticConfigToApi(config) {
|
|
20324
|
+
if (config === null)
|
|
20325
|
+
return null;
|
|
20326
|
+
if (config === undefined)
|
|
20327
|
+
return;
|
|
20328
|
+
return {
|
|
20329
|
+
custom_instructions: config.customInstructions
|
|
20330
|
+
};
|
|
20331
|
+
}
|
|
20332
|
+
function dialecticConfigFromApi(config) {
|
|
20333
|
+
if (config === null)
|
|
20334
|
+
return null;
|
|
20335
|
+
if (config === undefined)
|
|
20336
|
+
return;
|
|
20337
|
+
return {
|
|
20338
|
+
customInstructions: config.custom_instructions
|
|
20434
20339
|
};
|
|
20435
20340
|
}
|
|
20436
20341
|
function workspaceConfigToApi(config) {
|
|
20437
20342
|
if (!config)
|
|
20438
20343
|
return;
|
|
20439
20344
|
return {
|
|
20345
|
+
custom_instructions: config.customInstructions,
|
|
20440
20346
|
reasoning: reasoningConfigToApi(config.reasoning),
|
|
20441
20347
|
peer_card: peerCardConfigToApi(config.peerCard),
|
|
20442
20348
|
summary: summaryConfigToApi(config.summary),
|
|
20443
|
-
dream: dreamConfigToApi(config.dream)
|
|
20349
|
+
dream: dreamConfigToApi(config.dream),
|
|
20350
|
+
dialectic: dialecticConfigToApi(config.dialectic)
|
|
20444
20351
|
};
|
|
20445
20352
|
}
|
|
20446
20353
|
function workspaceConfigFromApi(config) {
|
|
@@ -20448,20 +20355,24 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20448
20355
|
return;
|
|
20449
20356
|
const apiConfig = config;
|
|
20450
20357
|
return {
|
|
20358
|
+
customInstructions: apiConfig.custom_instructions,
|
|
20451
20359
|
reasoning: reasoningConfigFromApi(apiConfig.reasoning),
|
|
20452
20360
|
peerCard: peerCardConfigFromApi(apiConfig.peer_card),
|
|
20453
20361
|
summary: summaryConfigFromApi(apiConfig.summary),
|
|
20454
|
-
dream: dreamConfigFromApi(apiConfig.dream)
|
|
20362
|
+
dream: dreamConfigFromApi(apiConfig.dream),
|
|
20363
|
+
dialectic: dialecticConfigFromApi(apiConfig.dialectic)
|
|
20455
20364
|
};
|
|
20456
20365
|
}
|
|
20457
20366
|
function sessionConfigToApi(config) {
|
|
20458
20367
|
if (!config)
|
|
20459
20368
|
return;
|
|
20460
20369
|
return {
|
|
20370
|
+
custom_instructions: config.customInstructions,
|
|
20461
20371
|
reasoning: reasoningConfigToApi(config.reasoning),
|
|
20462
20372
|
peer_card: peerCardConfigToApi(config.peerCard),
|
|
20463
20373
|
summary: summaryConfigToApi(config.summary),
|
|
20464
|
-
dream: dreamConfigToApi(config.dream)
|
|
20374
|
+
dream: dreamConfigToApi(config.dream),
|
|
20375
|
+
dialectic: dialecticConfigToApi(config.dialectic)
|
|
20465
20376
|
};
|
|
20466
20377
|
}
|
|
20467
20378
|
function sessionConfigFromApi(config) {
|
|
@@ -20469,10 +20380,12 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20469
20380
|
return;
|
|
20470
20381
|
const apiConfig = config;
|
|
20471
20382
|
return {
|
|
20383
|
+
customInstructions: apiConfig.custom_instructions,
|
|
20472
20384
|
reasoning: reasoningConfigFromApi(apiConfig.reasoning),
|
|
20473
20385
|
peerCard: peerCardConfigFromApi(apiConfig.peer_card),
|
|
20474
20386
|
summary: summaryConfigFromApi(apiConfig.summary),
|
|
20475
|
-
dream: dreamConfigFromApi(apiConfig.dream)
|
|
20387
|
+
dream: dreamConfigFromApi(apiConfig.dream),
|
|
20388
|
+
dialectic: dialecticConfigFromApi(apiConfig.dialectic)
|
|
20476
20389
|
};
|
|
20477
20390
|
}
|
|
20478
20391
|
function messageConfigToApi(config) {
|
|
@@ -20544,10 +20457,12 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20544
20457
|
});
|
|
20545
20458
|
exports.WorkspaceMetadataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
20546
20459
|
exports.WorkspaceConfigSchema = zod_1.z.object({
|
|
20460
|
+
customInstructions: zod_1.z.string().nullable().optional(),
|
|
20547
20461
|
reasoning: exports.ReasoningConfigSchema.nullable().optional(),
|
|
20548
20462
|
peerCard: exports.PeerCardConfigSchema.nullable().optional(),
|
|
20549
20463
|
summary: exports.SummaryConfigSchema.nullable().optional(),
|
|
20550
|
-
dream: exports.DreamConfigSchema.nullable().optional()
|
|
20464
|
+
dream: exports.DreamConfigSchema.nullable().optional(),
|
|
20465
|
+
dialectic: exports.DialecticConfigSchema.nullable().optional()
|
|
20551
20466
|
}).strict();
|
|
20552
20467
|
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");
|
|
20553
20468
|
exports.ConclusionQueryParamsSchema = zod_1.z.object({
|
|
@@ -20561,22 +20476,46 @@ var require_validation2 = __commonJS(function(exports) {
|
|
|
20561
20476
|
// node_modules/@honcho-ai/sdk/dist/conclusions.js
|
|
20562
20477
|
var require_conclusions = __commonJS(function(exports) {
|
|
20563
20478
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20564
|
-
exports.
|
|
20479
|
+
exports.WorkspaceConclusions = exports.ConclusionsView = exports.Conclusion = undefined;
|
|
20565
20480
|
var api_version_1 = require_api_version();
|
|
20481
|
+
var errors_1 = require_errors2();
|
|
20566
20482
|
var pagination_1 = require_pagination();
|
|
20567
20483
|
var validation_1 = require_validation2();
|
|
20484
|
+
var LIST_PAGE_CAP = 100;
|
|
20485
|
+
var VIEW_RESERVED_KEYS = [
|
|
20486
|
+
"observer",
|
|
20487
|
+
"observed",
|
|
20488
|
+
"observer_id",
|
|
20489
|
+
"observed_id"
|
|
20490
|
+
];
|
|
20491
|
+
function rejectReservedFilterKeys(filters, reserved) {
|
|
20492
|
+
if (!filters)
|
|
20493
|
+
return;
|
|
20494
|
+
const clash = reserved.filter((k) => (k in filters)).sort();
|
|
20495
|
+
if (clash.length > 0) {
|
|
20496
|
+
let guidance = "Choose the peer pair via peer.conclusions / peer.conclusionsOf(target)";
|
|
20497
|
+
if (reserved.includes("session") || reserved.includes("session_id")) {
|
|
20498
|
+
guidance += "; use the session option to filter by session";
|
|
20499
|
+
}
|
|
20500
|
+
throw new Error(`Filter key(s) ${clash.join(", ")} are managed by this conclusions view ` + `and cannot be passed in filters. ${guidance}.`);
|
|
20501
|
+
}
|
|
20502
|
+
}
|
|
20568
20503
|
|
|
20569
20504
|
class Conclusion {
|
|
20570
|
-
constructor(id, content, observerId, observedId, sessionId, createdAt) {
|
|
20505
|
+
constructor(id, content, observerId, observedId, sessionId, createdAt, level = "explicit", sourceIds = null, timesDerived = 1, sourceMessageIds = null) {
|
|
20571
20506
|
this.id = id;
|
|
20572
20507
|
this.content = content;
|
|
20573
20508
|
this.observerId = observerId;
|
|
20574
20509
|
this.observedId = observedId;
|
|
20575
20510
|
this.sessionId = sessionId;
|
|
20511
|
+
this.level = level;
|
|
20512
|
+
this.sourceIds = sourceIds;
|
|
20513
|
+
this.timesDerived = timesDerived;
|
|
20514
|
+
this.sourceMessageIds = sourceMessageIds;
|
|
20576
20515
|
this.createdAt = createdAt;
|
|
20577
20516
|
}
|
|
20578
20517
|
static fromApiResponse(data) {
|
|
20579
|
-
return new Conclusion(data.id, data.content, data.observer_id, data.observed_id, data.session_id, data.created_at);
|
|
20518
|
+
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);
|
|
20580
20519
|
}
|
|
20581
20520
|
toString() {
|
|
20582
20521
|
const truncatedContent = this.content.length > 50 ? `${this.content.slice(0, 50)}...` : this.content;
|
|
@@ -20585,7 +20524,7 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
20585
20524
|
}
|
|
20586
20525
|
exports.Conclusion = Conclusion;
|
|
20587
20526
|
|
|
20588
|
-
class
|
|
20527
|
+
class ConclusionsView {
|
|
20589
20528
|
constructor(http, workspaceId, observer, observed, ensureWorkspace = async () => {
|
|
20590
20529
|
return;
|
|
20591
20530
|
}) {
|
|
@@ -20614,6 +20553,26 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
20614
20553
|
await this._ensureWorkspace();
|
|
20615
20554
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions`, { body: params });
|
|
20616
20555
|
}
|
|
20556
|
+
async _get(conclusionId) {
|
|
20557
|
+
await this._ensureWorkspace();
|
|
20558
|
+
const item = await this._http.get(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/${conclusionId}`);
|
|
20559
|
+
if (item.observer_id !== this.observer || item.observed_id !== this.observed) {
|
|
20560
|
+
throw new errors_1.NotFoundError("Conclusion not found");
|
|
20561
|
+
}
|
|
20562
|
+
return item;
|
|
20563
|
+
}
|
|
20564
|
+
async _derived(conclusionId, params) {
|
|
20565
|
+
return this._list({
|
|
20566
|
+
filters: {
|
|
20567
|
+
source_ids: { contains: conclusionId },
|
|
20568
|
+
observer_id: this.observer,
|
|
20569
|
+
observed_id: this.observed
|
|
20570
|
+
},
|
|
20571
|
+
page: params.page,
|
|
20572
|
+
size: params.size,
|
|
20573
|
+
reverse: params.reverse
|
|
20574
|
+
});
|
|
20575
|
+
}
|
|
20617
20576
|
async _delete(conclusionId) {
|
|
20618
20577
|
await this._ensureWorkspace();
|
|
20619
20578
|
await this._http.delete(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/${conclusionId}`);
|
|
@@ -20623,14 +20582,18 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
20623
20582
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/peers/${peerId}/representation`, { body: params });
|
|
20624
20583
|
}
|
|
20625
20584
|
async list(options) {
|
|
20585
|
+
rejectReservedFilterKeys(options?.filters, [
|
|
20586
|
+
...VIEW_RESERVED_KEYS,
|
|
20587
|
+
"session",
|
|
20588
|
+
"session_id"
|
|
20589
|
+
]);
|
|
20626
20590
|
const resolvedSessionId = options?.session ? typeof options.session === "string" ? options.session : options.session.id : undefined;
|
|
20627
20591
|
const filters = {
|
|
20628
20592
|
observer_id: this.observer,
|
|
20629
|
-
observed_id: this.observed
|
|
20593
|
+
observed_id: this.observed,
|
|
20594
|
+
...resolvedSessionId ? { session_id: resolvedSessionId } : {},
|
|
20595
|
+
...options?.filters
|
|
20630
20596
|
};
|
|
20631
|
-
if (resolvedSessionId) {
|
|
20632
|
-
filters.session_id = resolvedSessionId;
|
|
20633
|
-
}
|
|
20634
20597
|
const reverse = options?.reverse;
|
|
20635
20598
|
const response = await this._list({
|
|
20636
20599
|
filters,
|
|
@@ -20643,19 +20606,55 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
20643
20606
|
};
|
|
20644
20607
|
return new pagination_1.Page(response, (item) => Conclusion.fromApiResponse(item), fetchNextPage);
|
|
20645
20608
|
}
|
|
20646
|
-
async query(query, topK = 10, distance) {
|
|
20647
|
-
|
|
20648
|
-
observer_id: this.observer,
|
|
20649
|
-
observed_id: this.observed
|
|
20650
|
-
};
|
|
20609
|
+
async query(query, topK = 10, distance, filters) {
|
|
20610
|
+
rejectReservedFilterKeys(filters, VIEW_RESERVED_KEYS);
|
|
20651
20611
|
const response = await this._query({
|
|
20652
20612
|
query,
|
|
20653
20613
|
top_k: topK,
|
|
20654
20614
|
distance,
|
|
20655
|
-
filters
|
|
20615
|
+
filters: {
|
|
20616
|
+
observer_id: this.observer,
|
|
20617
|
+
observed_id: this.observed,
|
|
20618
|
+
...filters
|
|
20619
|
+
}
|
|
20656
20620
|
});
|
|
20657
20621
|
return (response ?? []).map((item) => Conclusion.fromApiResponse(item));
|
|
20658
20622
|
}
|
|
20623
|
+
async get(conclusionId) {
|
|
20624
|
+
const response = await this._get(conclusionId);
|
|
20625
|
+
return Conclusion.fromApiResponse(response);
|
|
20626
|
+
}
|
|
20627
|
+
async getMany(conclusionIds) {
|
|
20628
|
+
if (conclusionIds.length === 0)
|
|
20629
|
+
return [];
|
|
20630
|
+
const conclusions = [];
|
|
20631
|
+
for (let start = 0;start < conclusionIds.length; start += LIST_PAGE_CAP) {
|
|
20632
|
+
const chunk = conclusionIds.slice(start, start + LIST_PAGE_CAP);
|
|
20633
|
+
const response = await this._list({
|
|
20634
|
+
filters: {
|
|
20635
|
+
id: { in: chunk },
|
|
20636
|
+
observer_id: this.observer,
|
|
20637
|
+
observed_id: this.observed
|
|
20638
|
+
},
|
|
20639
|
+
page: 1,
|
|
20640
|
+
size: chunk.length
|
|
20641
|
+
});
|
|
20642
|
+
conclusions.push(...(response.items ?? []).map((item) => Conclusion.fromApiResponse(item)));
|
|
20643
|
+
}
|
|
20644
|
+
return conclusions;
|
|
20645
|
+
}
|
|
20646
|
+
async derived(conclusionId, options) {
|
|
20647
|
+
const reverse = options?.reverse;
|
|
20648
|
+
const response = await this._derived(conclusionId, {
|
|
20649
|
+
page: options?.page ?? 1,
|
|
20650
|
+
size: options?.size ?? 50,
|
|
20651
|
+
reverse
|
|
20652
|
+
});
|
|
20653
|
+
const fetchNextPage = async (page, size) => {
|
|
20654
|
+
return this._derived(conclusionId, { page, size, reverse });
|
|
20655
|
+
};
|
|
20656
|
+
return new pagination_1.Page(response, (item) => Conclusion.fromApiResponse(item), fetchNextPage);
|
|
20657
|
+
}
|
|
20659
20658
|
async delete(conclusionId) {
|
|
20660
20659
|
await this._delete(conclusionId);
|
|
20661
20660
|
}
|
|
@@ -20690,10 +20689,300 @@ var require_conclusions = __commonJS(function(exports) {
|
|
|
20690
20689
|
return response.representation;
|
|
20691
20690
|
}
|
|
20692
20691
|
toString() {
|
|
20693
|
-
return `
|
|
20692
|
+
return `ConclusionsView(workspaceId='${this.workspaceId}', observer='${this.observer}', observed='${this.observed}')`;
|
|
20694
20693
|
}
|
|
20695
20694
|
}
|
|
20696
|
-
exports.
|
|
20695
|
+
exports.ConclusionsView = ConclusionsView;
|
|
20696
|
+
|
|
20697
|
+
class WorkspaceConclusions {
|
|
20698
|
+
constructor(http, workspaceId, ensureWorkspace = async () => {
|
|
20699
|
+
return;
|
|
20700
|
+
}) {
|
|
20701
|
+
this._http = http;
|
|
20702
|
+
this.workspaceId = workspaceId;
|
|
20703
|
+
this._ensureWorkspace = ensureWorkspace;
|
|
20704
|
+
}
|
|
20705
|
+
async _list(params) {
|
|
20706
|
+
await this._ensureWorkspace();
|
|
20707
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/list`, {
|
|
20708
|
+
body: params.filters ? { filters: params.filters } : undefined,
|
|
20709
|
+
query: {
|
|
20710
|
+
page: params.page,
|
|
20711
|
+
size: params.size,
|
|
20712
|
+
reverse: params.reverse ? "true" : undefined
|
|
20713
|
+
}
|
|
20714
|
+
});
|
|
20715
|
+
}
|
|
20716
|
+
async list(options) {
|
|
20717
|
+
const filters = options?.filters;
|
|
20718
|
+
const reverse = options?.reverse;
|
|
20719
|
+
const response = await this._list({
|
|
20720
|
+
filters,
|
|
20721
|
+
page: options?.page ?? 1,
|
|
20722
|
+
size: options?.size ?? 50,
|
|
20723
|
+
reverse
|
|
20724
|
+
});
|
|
20725
|
+
const fetchNextPage = async (page, size) => {
|
|
20726
|
+
return this._list({ filters, page, size, reverse });
|
|
20727
|
+
};
|
|
20728
|
+
return new pagination_1.Page(response, (item) => Conclusion.fromApiResponse(item), fetchNextPage);
|
|
20729
|
+
}
|
|
20730
|
+
async get(conclusionId) {
|
|
20731
|
+
await this._ensureWorkspace();
|
|
20732
|
+
const item = await this._http.get(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/conclusions/${conclusionId}`);
|
|
20733
|
+
return Conclusion.fromApiResponse(item);
|
|
20734
|
+
}
|
|
20735
|
+
async getMany(conclusionIds) {
|
|
20736
|
+
if (conclusionIds.length === 0)
|
|
20737
|
+
return [];
|
|
20738
|
+
const conclusions = [];
|
|
20739
|
+
for (let start = 0;start < conclusionIds.length; start += LIST_PAGE_CAP) {
|
|
20740
|
+
const chunk = conclusionIds.slice(start, start + LIST_PAGE_CAP);
|
|
20741
|
+
const response = await this._list({
|
|
20742
|
+
filters: { id: { in: chunk } },
|
|
20743
|
+
page: 1,
|
|
20744
|
+
size: chunk.length
|
|
20745
|
+
});
|
|
20746
|
+
conclusions.push(...(response.items ?? []).map((item) => Conclusion.fromApiResponse(item)));
|
|
20747
|
+
}
|
|
20748
|
+
return conclusions;
|
|
20749
|
+
}
|
|
20750
|
+
toString() {
|
|
20751
|
+
return `WorkspaceConclusions(workspaceId='${this.workspaceId}')`;
|
|
20752
|
+
}
|
|
20753
|
+
}
|
|
20754
|
+
exports.WorkspaceConclusions = WorkspaceConclusions;
|
|
20755
|
+
});
|
|
20756
|
+
|
|
20757
|
+
// node_modules/@honcho-ai/sdk/dist/http/client.js
|
|
20758
|
+
var require_client = __commonJS(function(exports) {
|
|
20759
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20760
|
+
exports.HonchoHTTPClient = exports.HOST_HEADER = undefined;
|
|
20761
|
+
exports.defaultHostHeader = defaultHostHeader;
|
|
20762
|
+
var api_version_1 = require_api_version();
|
|
20763
|
+
var errors_1 = require_errors2();
|
|
20764
|
+
var DEFAULT_TIMEOUT = 60000;
|
|
20765
|
+
var DEFAULT_MAX_RETRIES = 2;
|
|
20766
|
+
var RETRY_STATUS_CODES = [429, 500, 502, 503, 504];
|
|
20767
|
+
var INITIAL_RETRY_DELAY = 500;
|
|
20768
|
+
exports.HOST_HEADER = "X-Honcho-Host";
|
|
20769
|
+
function defaultHostHeader() {
|
|
20770
|
+
const product = `honcho-typescript/${api_version_1.VERSION}`;
|
|
20771
|
+
const platform = typeof process !== "undefined" && typeof process.platform === "string" ? process.platform : undefined;
|
|
20772
|
+
return platform ? `${product} (${platform})` : product;
|
|
20773
|
+
}
|
|
20774
|
+
|
|
20775
|
+
class HonchoHTTPClient {
|
|
20776
|
+
constructor(config) {
|
|
20777
|
+
this.baseURL = config.baseURL.replace(/\/$/, "");
|
|
20778
|
+
this.apiKey = config.apiKey;
|
|
20779
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
20780
|
+
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
20781
|
+
this.defaultHeaders = {
|
|
20782
|
+
"Content-Type": "application/json",
|
|
20783
|
+
[exports.HOST_HEADER]: defaultHostHeader(),
|
|
20784
|
+
...config.defaultHeaders
|
|
20785
|
+
};
|
|
20786
|
+
this.defaultQuery = config.defaultQuery;
|
|
20787
|
+
}
|
|
20788
|
+
async request(method, path, options = {}) {
|
|
20789
|
+
const url = this.buildURL(path, options.query);
|
|
20790
|
+
const headers = this.buildHeaders(options.headers);
|
|
20791
|
+
const timeout = options.timeout ?? this.timeout;
|
|
20792
|
+
let lastError;
|
|
20793
|
+
let attempt = 0;
|
|
20794
|
+
while (attempt <= this.maxRetries) {
|
|
20795
|
+
try {
|
|
20796
|
+
const response = await this.fetchWithTimeout(url, {
|
|
20797
|
+
method,
|
|
20798
|
+
headers,
|
|
20799
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
20800
|
+
signal: options.signal
|
|
20801
|
+
}, timeout);
|
|
20802
|
+
if (response.ok) {
|
|
20803
|
+
const text = await response.text();
|
|
20804
|
+
if (!text) {
|
|
20805
|
+
return;
|
|
20806
|
+
}
|
|
20807
|
+
return JSON.parse(text);
|
|
20808
|
+
}
|
|
20809
|
+
const errorBody = await this.parseErrorBody(response);
|
|
20810
|
+
const retryAfter = this.parseRetryAfter(response);
|
|
20811
|
+
const error = (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody, retryAfter);
|
|
20812
|
+
if (RETRY_STATUS_CODES.includes(response.status) && attempt < this.maxRetries) {
|
|
20813
|
+
lastError = error;
|
|
20814
|
+
await this.sleep(this.getRetryDelay(attempt, retryAfter));
|
|
20815
|
+
attempt++;
|
|
20816
|
+
continue;
|
|
20817
|
+
}
|
|
20818
|
+
throw error;
|
|
20819
|
+
} catch (error) {
|
|
20820
|
+
if (error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
20821
|
+
if (attempt < this.maxRetries) {
|
|
20822
|
+
lastError = error;
|
|
20823
|
+
await this.sleep(this.getRetryDelay(attempt));
|
|
20824
|
+
attempt++;
|
|
20825
|
+
continue;
|
|
20826
|
+
}
|
|
20827
|
+
}
|
|
20828
|
+
if (error instanceof errors_1.RateLimitError || error instanceof errors_1.ServerError || error instanceof errors_1.TimeoutError || error instanceof errors_1.ConnectionError) {
|
|
20829
|
+
throw error;
|
|
20830
|
+
}
|
|
20831
|
+
throw error;
|
|
20832
|
+
}
|
|
20833
|
+
}
|
|
20834
|
+
throw lastError || new Error("Request failed after retries");
|
|
20835
|
+
}
|
|
20836
|
+
async get(path, options) {
|
|
20837
|
+
return this.request("GET", path, options);
|
|
20838
|
+
}
|
|
20839
|
+
async post(path, options) {
|
|
20840
|
+
return this.request("POST", path, options);
|
|
20841
|
+
}
|
|
20842
|
+
async put(path, options) {
|
|
20843
|
+
return this.request("PUT", path, options);
|
|
20844
|
+
}
|
|
20845
|
+
async patch(path, options) {
|
|
20846
|
+
return this.request("PATCH", path, options);
|
|
20847
|
+
}
|
|
20848
|
+
async delete(path, options) {
|
|
20849
|
+
return this.request("DELETE", path, options);
|
|
20850
|
+
}
|
|
20851
|
+
async stream(method, path, options = {}) {
|
|
20852
|
+
const url = this.buildURL(path, options.query);
|
|
20853
|
+
const headers = {
|
|
20854
|
+
...this.buildHeaders(options.headers),
|
|
20855
|
+
Accept: "text/event-stream"
|
|
20856
|
+
};
|
|
20857
|
+
const timeout = options.timeout ?? this.timeout;
|
|
20858
|
+
const response = await this.fetchWithTimeout(url, {
|
|
20859
|
+
method,
|
|
20860
|
+
headers,
|
|
20861
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
20862
|
+
signal: options.signal
|
|
20863
|
+
}, timeout);
|
|
20864
|
+
if (!response.ok) {
|
|
20865
|
+
const errorBody = await this.parseErrorBody(response);
|
|
20866
|
+
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
20867
|
+
}
|
|
20868
|
+
return response;
|
|
20869
|
+
}
|
|
20870
|
+
async upload(path, formData, options = {}) {
|
|
20871
|
+
const url = this.buildURL(path, options.query);
|
|
20872
|
+
const headers = {};
|
|
20873
|
+
if (this.apiKey) {
|
|
20874
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
20875
|
+
}
|
|
20876
|
+
if (options.headers) {
|
|
20877
|
+
Object.assign(headers, options.headers);
|
|
20878
|
+
}
|
|
20879
|
+
const timeout = options.timeout ?? this.timeout;
|
|
20880
|
+
const response = await this.fetchWithTimeout(url, {
|
|
20881
|
+
method: "POST",
|
|
20882
|
+
headers,
|
|
20883
|
+
body: formData,
|
|
20884
|
+
signal: options.signal
|
|
20885
|
+
}, timeout);
|
|
20886
|
+
if (!response.ok) {
|
|
20887
|
+
const errorBody = await this.parseErrorBody(response);
|
|
20888
|
+
throw (0, errors_1.createErrorFromResponse)(response.status, errorBody.message || `HTTP ${response.status}`, errorBody);
|
|
20889
|
+
}
|
|
20890
|
+
const text = await response.text();
|
|
20891
|
+
if (!text) {
|
|
20892
|
+
return;
|
|
20893
|
+
}
|
|
20894
|
+
return JSON.parse(text);
|
|
20895
|
+
}
|
|
20896
|
+
buildURL(path, query) {
|
|
20897
|
+
const url = new URL(path, this.baseURL);
|
|
20898
|
+
const mergedQuery = {
|
|
20899
|
+
...this.defaultQuery ?? {},
|
|
20900
|
+
...query ?? {}
|
|
20901
|
+
};
|
|
20902
|
+
for (const [key, value] of Object.entries(mergedQuery)) {
|
|
20903
|
+
if (value === undefined) {
|
|
20904
|
+
continue;
|
|
20905
|
+
}
|
|
20906
|
+
if (Array.isArray(value)) {
|
|
20907
|
+
for (const entry of value) {
|
|
20908
|
+
url.searchParams.append(key, String(entry));
|
|
20909
|
+
}
|
|
20910
|
+
continue;
|
|
20911
|
+
}
|
|
20912
|
+
url.searchParams.set(key, String(value));
|
|
20913
|
+
}
|
|
20914
|
+
return url.toString();
|
|
20915
|
+
}
|
|
20916
|
+
buildHeaders(extra) {
|
|
20917
|
+
const headers = { ...this.defaultHeaders };
|
|
20918
|
+
if (this.apiKey) {
|
|
20919
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
20920
|
+
}
|
|
20921
|
+
if (extra) {
|
|
20922
|
+
Object.assign(headers, extra);
|
|
20923
|
+
}
|
|
20924
|
+
return headers;
|
|
20925
|
+
}
|
|
20926
|
+
async fetchWithTimeout(url, init, timeout) {
|
|
20927
|
+
const controller = new AbortController;
|
|
20928
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
20929
|
+
if (init.signal) {
|
|
20930
|
+
init.signal.addEventListener("abort", () => controller.abort());
|
|
20931
|
+
}
|
|
20932
|
+
try {
|
|
20933
|
+
const response = await fetch(url, {
|
|
20934
|
+
...init,
|
|
20935
|
+
signal: controller.signal
|
|
20936
|
+
});
|
|
20937
|
+
return response;
|
|
20938
|
+
} catch (error) {
|
|
20939
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
20940
|
+
throw new errors_1.TimeoutError(`Request timed out after ${timeout}ms`);
|
|
20941
|
+
}
|
|
20942
|
+
if (error instanceof TypeError) {
|
|
20943
|
+
throw new errors_1.ConnectionError(error.message);
|
|
20944
|
+
}
|
|
20945
|
+
throw error;
|
|
20946
|
+
} finally {
|
|
20947
|
+
clearTimeout(timeoutId);
|
|
20948
|
+
}
|
|
20949
|
+
}
|
|
20950
|
+
async parseErrorBody(response) {
|
|
20951
|
+
try {
|
|
20952
|
+
const body = await response.json();
|
|
20953
|
+
return {
|
|
20954
|
+
message: body.detail || body.message || body.error,
|
|
20955
|
+
...body
|
|
20956
|
+
};
|
|
20957
|
+
} catch {
|
|
20958
|
+
return { message: `HTTP ${response.status}` };
|
|
20959
|
+
}
|
|
20960
|
+
}
|
|
20961
|
+
parseRetryAfter(response) {
|
|
20962
|
+
const header = response.headers.get("Retry-After");
|
|
20963
|
+
if (!header)
|
|
20964
|
+
return;
|
|
20965
|
+
const seconds = Number.parseInt(header, 10);
|
|
20966
|
+
if (!Number.isNaN(seconds)) {
|
|
20967
|
+
return seconds * 1000;
|
|
20968
|
+
}
|
|
20969
|
+
const date = Date.parse(header);
|
|
20970
|
+
if (!Number.isNaN(date)) {
|
|
20971
|
+
return Math.max(0, date - Date.now());
|
|
20972
|
+
}
|
|
20973
|
+
return;
|
|
20974
|
+
}
|
|
20975
|
+
getRetryDelay(attempt, retryAfter) {
|
|
20976
|
+
if (retryAfter) {
|
|
20977
|
+
return retryAfter;
|
|
20978
|
+
}
|
|
20979
|
+
return INITIAL_RETRY_DELAY * 2 ** attempt;
|
|
20980
|
+
}
|
|
20981
|
+
sleep(ms) {
|
|
20982
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
20983
|
+
}
|
|
20984
|
+
}
|
|
20985
|
+
exports.HonchoHTTPClient = HonchoHTTPClient;
|
|
20697
20986
|
});
|
|
20698
20987
|
|
|
20699
20988
|
// node_modules/@honcho-ai/sdk/dist/http/streaming.js
|
|
@@ -20746,10 +21035,14 @@ var require_streaming = __commonJS(function(exports) {
|
|
|
20746
21035
|
}
|
|
20747
21036
|
|
|
20748
21037
|
class DialecticStreamResponse {
|
|
20749
|
-
constructor(generator) {
|
|
21038
|
+
constructor(generator, evidenceSource) {
|
|
20750
21039
|
this.chunks = [];
|
|
20751
21040
|
this.consumed = false;
|
|
20752
21041
|
this.generator = generator;
|
|
21042
|
+
this.evidenceSource = evidenceSource;
|
|
21043
|
+
}
|
|
21044
|
+
get evidence() {
|
|
21045
|
+
return this.evidenceSource?.() ?? null;
|
|
20753
21046
|
}
|
|
20754
21047
|
async* [Symbol.asyncIterator]() {
|
|
20755
21048
|
if (this.consumed) {
|
|
@@ -20779,9 +21072,11 @@ var require_streaming = __commonJS(function(exports) {
|
|
|
20779
21072
|
}
|
|
20780
21073
|
exports.DialecticStreamResponse = DialecticStreamResponse;
|
|
20781
21074
|
function createDialecticStream(response) {
|
|
21075
|
+
let evidence = null;
|
|
20782
21076
|
async function* streamContent() {
|
|
20783
21077
|
for await (const chunk of parseSSE(response)) {
|
|
20784
21078
|
if (chunk.done) {
|
|
21079
|
+
evidence = chunk.evidence ?? null;
|
|
20785
21080
|
return;
|
|
20786
21081
|
}
|
|
20787
21082
|
const content = chunk.delta?.content;
|
|
@@ -20790,10 +21085,37 @@ var require_streaming = __commonJS(function(exports) {
|
|
|
20790
21085
|
}
|
|
20791
21086
|
}
|
|
20792
21087
|
}
|
|
20793
|
-
return new DialecticStreamResponse(streamContent());
|
|
21088
|
+
return new DialecticStreamResponse(streamContent(), () => evidence);
|
|
20794
21089
|
}
|
|
20795
21090
|
});
|
|
20796
21091
|
|
|
21092
|
+
// node_modules/@honcho-ai/sdk/dist/message.js
|
|
21093
|
+
var require_message = __commonJS(function(exports) {
|
|
21094
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21095
|
+
exports.Message = undefined;
|
|
21096
|
+
|
|
21097
|
+
class Message {
|
|
21098
|
+
constructor(id, content, peerId, sessionId, workspaceId, metadata, createdAt, tokenCount) {
|
|
21099
|
+
this.id = id;
|
|
21100
|
+
this.content = content;
|
|
21101
|
+
this.peerId = peerId;
|
|
21102
|
+
this.sessionId = sessionId;
|
|
21103
|
+
this.workspaceId = workspaceId;
|
|
21104
|
+
this.metadata = metadata;
|
|
21105
|
+
this.createdAt = createdAt;
|
|
21106
|
+
this.tokenCount = tokenCount;
|
|
21107
|
+
}
|
|
21108
|
+
static fromApiResponse(data) {
|
|
21109
|
+
return new Message(data.id, data.content, data.peer_id, data.session_id, data.workspace_id, data.metadata, data.created_at, data.token_count);
|
|
21110
|
+
}
|
|
21111
|
+
toString() {
|
|
21112
|
+
const truncatedContent = this.content.length > 50 ? `${this.content.slice(0, 50)}...` : this.content;
|
|
21113
|
+
return `Message(id='${this.id}', peerId='${this.peerId}', content='${truncatedContent}')`;
|
|
21114
|
+
}
|
|
21115
|
+
}
|
|
21116
|
+
exports.Message = Message;
|
|
21117
|
+
});
|
|
21118
|
+
|
|
20797
21119
|
// node_modules/@honcho-ai/sdk/dist/session_context.js
|
|
20798
21120
|
var require_session_context = __commonJS(function(exports) {
|
|
20799
21121
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -20968,12 +21290,18 @@ var require_session = __commonJS(function(exports) {
|
|
|
20968
21290
|
get createdAt() {
|
|
20969
21291
|
return this._createdAt;
|
|
20970
21292
|
}
|
|
21293
|
+
get uid() {
|
|
21294
|
+
return this._uid;
|
|
21295
|
+
}
|
|
20971
21296
|
get isActive() {
|
|
20972
21297
|
return this._isActive;
|
|
20973
21298
|
}
|
|
21299
|
+
get scopes() {
|
|
21300
|
+
return this._scopes;
|
|
21301
|
+
}
|
|
20974
21302
|
constructor(id, workspaceId, http, metadata, configuration, ensureWorkspace = async () => {
|
|
20975
21303
|
return;
|
|
20976
|
-
}, createdAt, isActive) {
|
|
21304
|
+
}, createdAt, isActive, uid, scopes) {
|
|
20977
21305
|
this.id = id;
|
|
20978
21306
|
this.workspaceId = workspaceId;
|
|
20979
21307
|
this._http = http;
|
|
@@ -20982,12 +21310,15 @@ var require_session = __commonJS(function(exports) {
|
|
|
20982
21310
|
this._ensureWorkspace = ensureWorkspace;
|
|
20983
21311
|
this._createdAt = createdAt;
|
|
20984
21312
|
this._isActive = isActive;
|
|
21313
|
+
this._uid = uid;
|
|
21314
|
+
this._scopes = scopes;
|
|
20985
21315
|
}
|
|
20986
21316
|
_applySessionResponse(session) {
|
|
20987
21317
|
this._metadata = session.metadata || {};
|
|
20988
21318
|
this._configuration = (0, validation_1.sessionConfigFromApi)(session.configuration) || {};
|
|
20989
21319
|
this._createdAt = session.created_at;
|
|
20990
21320
|
this._isActive = session.is_active;
|
|
21321
|
+
this._uid = session.uid;
|
|
20991
21322
|
}
|
|
20992
21323
|
async _getOrCreate(params) {
|
|
20993
21324
|
await this._ensureWorkspace();
|
|
@@ -21111,7 +21442,7 @@ var require_session = __commonJS(function(exports) {
|
|
|
21111
21442
|
}
|
|
21112
21443
|
async peers() {
|
|
21113
21444
|
const peersPage = await this._listPeers();
|
|
21114
|
-
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));
|
|
21445
|
+
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));
|
|
21115
21446
|
}
|
|
21116
21447
|
async getPeerConfiguration(peer) {
|
|
21117
21448
|
const peerId = typeof peer === "string" ? peer : peer.id;
|
|
@@ -21195,7 +21526,7 @@ var require_session = __commonJS(function(exports) {
|
|
|
21195
21526
|
}
|
|
21196
21527
|
async clone(messageId) {
|
|
21197
21528
|
const clonedSessionData = await this._clone(messageId ? { message_id: messageId } : undefined);
|
|
21198
|
-
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);
|
|
21529
|
+
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);
|
|
21199
21530
|
}
|
|
21200
21531
|
async context(options) {
|
|
21201
21532
|
const opts = options || {};
|
|
@@ -21207,6 +21538,8 @@ var require_session = __commonJS(function(exports) {
|
|
|
21207
21538
|
tokens: opts.tokens,
|
|
21208
21539
|
peerTarget: peerTargetId,
|
|
21209
21540
|
peerPerspective: peerPerspectiveId,
|
|
21541
|
+
scope: opts.scope !== undefined ? (0, utils_1.resolveId)(opts.scope) : undefined,
|
|
21542
|
+
sessions: opts.sessions,
|
|
21210
21543
|
limitToSession: opts.limitToSession,
|
|
21211
21544
|
representationOptions: opts.representationOptions ? {
|
|
21212
21545
|
...opts.representationOptions,
|
|
@@ -21219,6 +21552,8 @@ var require_session = __commonJS(function(exports) {
|
|
|
21219
21552
|
search_query: searchQuery,
|
|
21220
21553
|
peer_target: contextParams.peerTarget,
|
|
21221
21554
|
peer_perspective: contextParams.peerPerspective,
|
|
21555
|
+
scope: contextParams.scope,
|
|
21556
|
+
sessions: contextParams.sessions,
|
|
21222
21557
|
limit_to_session: contextParams.limitToSession,
|
|
21223
21558
|
search_top_k: contextParams.representationOptions?.searchTopK,
|
|
21224
21559
|
search_max_distance: contextParams.representationOptions?.searchMaxDistance,
|
|
@@ -21335,6 +21670,7 @@ var require_session = __commonJS(function(exports) {
|
|
|
21335
21670
|
var require_peer = __commonJS(function(exports) {
|
|
21336
21671
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21337
21672
|
exports.Peer = exports.PeerContext = undefined;
|
|
21673
|
+
var zod_1 = require_zod();
|
|
21338
21674
|
var api_version_1 = require_api_version();
|
|
21339
21675
|
var conclusions_1 = require_conclusions();
|
|
21340
21676
|
var streaming_1 = require_streaming();
|
|
@@ -21369,9 +21705,12 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21369
21705
|
get createdAt() {
|
|
21370
21706
|
return this._createdAt;
|
|
21371
21707
|
}
|
|
21708
|
+
get uid() {
|
|
21709
|
+
return this._uid;
|
|
21710
|
+
}
|
|
21372
21711
|
constructor(id, workspaceId, http, metadata, configuration, ensureWorkspace = async () => {
|
|
21373
21712
|
return;
|
|
21374
|
-
}, createdAt) {
|
|
21713
|
+
}, createdAt, uid) {
|
|
21375
21714
|
this.id = id;
|
|
21376
21715
|
this.workspaceId = workspaceId;
|
|
21377
21716
|
this._http = http;
|
|
@@ -21379,6 +21718,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21379
21718
|
this._configuration = configuration;
|
|
21380
21719
|
this._ensureWorkspace = ensureWorkspace;
|
|
21381
21720
|
this._createdAt = createdAt;
|
|
21721
|
+
this._uid = uid;
|
|
21382
21722
|
}
|
|
21383
21723
|
async _getOrCreate(params) {
|
|
21384
21724
|
await this._ensureWorkspace();
|
|
@@ -21399,6 +21739,15 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21399
21739
|
}
|
|
21400
21740
|
});
|
|
21401
21741
|
}
|
|
21742
|
+
static toResponseFormatSchema(responseFormat) {
|
|
21743
|
+
if (!responseFormat) {
|
|
21744
|
+
return;
|
|
21745
|
+
}
|
|
21746
|
+
if (responseFormat instanceof zod_1.ZodType) {
|
|
21747
|
+
return zod_1.z.toJSONSchema(responseFormat);
|
|
21748
|
+
}
|
|
21749
|
+
return responseFormat;
|
|
21750
|
+
}
|
|
21402
21751
|
async _chat(params) {
|
|
21403
21752
|
await this._ensureWorkspace();
|
|
21404
21753
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/peers/${this.id}/chat`, { body: params });
|
|
@@ -21440,19 +21789,28 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21440
21789
|
query,
|
|
21441
21790
|
target: targetId,
|
|
21442
21791
|
session: resolvedSessionId,
|
|
21443
|
-
|
|
21792
|
+
scope: options?.scope,
|
|
21793
|
+
sessions: options?.sessions,
|
|
21794
|
+
reasoningLevel: options?.reasoningLevel,
|
|
21795
|
+
responseFormat: options?.responseFormat,
|
|
21796
|
+
includeEvidence: options?.includeEvidence
|
|
21444
21797
|
});
|
|
21798
|
+
const zodSchema = options?.responseFormat instanceof zod_1.ZodType ? options.responseFormat : undefined;
|
|
21445
21799
|
const response = await this._chat({
|
|
21446
21800
|
query: chatParams.query,
|
|
21447
21801
|
stream: false,
|
|
21448
21802
|
target: chatParams.target,
|
|
21449
21803
|
session_id: chatParams.session,
|
|
21450
|
-
|
|
21804
|
+
...(0, validation_1.scopeRecallFields)(chatParams),
|
|
21805
|
+
reasoning_level: chatParams.reasoningLevel,
|
|
21806
|
+
response_format: Peer.toResponseFormatSchema(options?.responseFormat),
|
|
21807
|
+
include_evidence: chatParams.includeEvidence ? true : undefined
|
|
21451
21808
|
});
|
|
21452
|
-
|
|
21453
|
-
|
|
21809
|
+
const content = response.content ? zodSchema ? zodSchema.parse(JSON.parse(response.content)) : response.content : null;
|
|
21810
|
+
if (!chatParams.includeEvidence) {
|
|
21811
|
+
return content;
|
|
21454
21812
|
}
|
|
21455
|
-
return response.
|
|
21813
|
+
return { content, evidence: response.evidence ?? null };
|
|
21456
21814
|
}
|
|
21457
21815
|
async chatStream(query, options) {
|
|
21458
21816
|
const targetId = options?.target ? typeof options.target === "string" ? options.target : options.target.id : undefined;
|
|
@@ -21461,13 +21819,20 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21461
21819
|
query,
|
|
21462
21820
|
target: targetId,
|
|
21463
21821
|
session: resolvedSessionId,
|
|
21464
|
-
|
|
21822
|
+
scope: options?.scope,
|
|
21823
|
+
sessions: options?.sessions,
|
|
21824
|
+
reasoningLevel: options?.reasoningLevel,
|
|
21825
|
+
responseFormat: options?.responseFormat,
|
|
21826
|
+
includeEvidence: options?.includeEvidence
|
|
21465
21827
|
});
|
|
21466
21828
|
const response = await this._chatStream({
|
|
21467
21829
|
query: chatParams.query,
|
|
21468
21830
|
target: chatParams.target,
|
|
21469
21831
|
session_id: chatParams.session,
|
|
21470
|
-
|
|
21832
|
+
...(0, validation_1.scopeRecallFields)(chatParams),
|
|
21833
|
+
reasoning_level: chatParams.reasoningLevel,
|
|
21834
|
+
response_format: Peer.toResponseFormatSchema(options?.responseFormat),
|
|
21835
|
+
include_evidence: chatParams.includeEvidence ? true : undefined
|
|
21471
21836
|
});
|
|
21472
21837
|
return (0, streaming_1.createDialecticStream)(response);
|
|
21473
21838
|
}
|
|
@@ -21494,7 +21859,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21494
21859
|
reverse
|
|
21495
21860
|
});
|
|
21496
21861
|
};
|
|
21497
|
-
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);
|
|
21862
|
+
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);
|
|
21498
21863
|
}
|
|
21499
21864
|
message(content, options) {
|
|
21500
21865
|
const validatedContent = validation_1.MessageContentSchema.parse(content);
|
|
@@ -21513,6 +21878,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21513
21878
|
const peer = await this._getOrCreate({ id: this.id });
|
|
21514
21879
|
this._metadata = peer.metadata || {};
|
|
21515
21880
|
this._createdAt = peer.created_at;
|
|
21881
|
+
this._uid = peer.uid;
|
|
21516
21882
|
return this._metadata;
|
|
21517
21883
|
}
|
|
21518
21884
|
async setMetadata(metadata) {
|
|
@@ -21524,6 +21890,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21524
21890
|
const peer = await this._getOrCreate({ id: this.id });
|
|
21525
21891
|
this._configuration = (0, validation_1.peerConfigFromApi)(peer.configuration) || {};
|
|
21526
21892
|
this._createdAt = peer.created_at;
|
|
21893
|
+
this._uid = peer.uid;
|
|
21527
21894
|
return this._configuration;
|
|
21528
21895
|
}
|
|
21529
21896
|
async setConfiguration(configuration) {
|
|
@@ -21536,6 +21903,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21536
21903
|
this._metadata = peer.metadata || {};
|
|
21537
21904
|
this._configuration = (0, validation_1.peerConfigFromApi)(peer.configuration) || {};
|
|
21538
21905
|
this._createdAt = peer.created_at;
|
|
21906
|
+
this._uid = peer.uid;
|
|
21539
21907
|
}
|
|
21540
21908
|
async search(query, options) {
|
|
21541
21909
|
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
@@ -21571,6 +21939,8 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21571
21939
|
const searchQuery = (0, validation_1.normalizeSearchQuery)(options?.searchQuery);
|
|
21572
21940
|
const getRepresentationParams = validation_1.PeerGetRepresentationParamsSchema.parse({
|
|
21573
21941
|
session: options?.session,
|
|
21942
|
+
scope: options?.scope,
|
|
21943
|
+
sessions: options?.sessions,
|
|
21574
21944
|
target: options?.target,
|
|
21575
21945
|
options: {
|
|
21576
21946
|
searchQuery,
|
|
@@ -21584,6 +21954,7 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21584
21954
|
const targetId = getRepresentationParams.target ? typeof getRepresentationParams.target === "string" ? getRepresentationParams.target : getRepresentationParams.target.id : undefined;
|
|
21585
21955
|
const response = await this._getRepresentation({
|
|
21586
21956
|
session_id: sessionId,
|
|
21957
|
+
...(0, validation_1.scopeRecallFields)(getRepresentationParams),
|
|
21587
21958
|
target: targetId,
|
|
21588
21959
|
search_query: searchQuery,
|
|
21589
21960
|
search_top_k: getRepresentationParams.options?.searchTopK,
|
|
@@ -21614,17 +21985,124 @@ var require_peer = __commonJS(function(exports) {
|
|
|
21614
21985
|
return PeerContext.fromApiResponse(response);
|
|
21615
21986
|
}
|
|
21616
21987
|
get conclusions() {
|
|
21617
|
-
return new conclusions_1.
|
|
21988
|
+
return new conclusions_1.ConclusionsView(this._http, this.workspaceId, this.id, this.id, () => this._ensureWorkspace());
|
|
21989
|
+
}
|
|
21990
|
+
conclusionsOf(target) {
|
|
21991
|
+
const targetId = typeof target === "string" ? target : target.id;
|
|
21992
|
+
return new conclusions_1.ConclusionsView(this._http, this.workspaceId, this.id, targetId, () => this._ensureWorkspace());
|
|
21993
|
+
}
|
|
21994
|
+
toString() {
|
|
21995
|
+
return `Peer(id='${this.id}')`;
|
|
21996
|
+
}
|
|
21997
|
+
}
|
|
21998
|
+
exports.Peer = Peer;
|
|
21999
|
+
});
|
|
22000
|
+
|
|
22001
|
+
// node_modules/@honcho-ai/sdk/dist/scope.js
|
|
22002
|
+
var require_scope2 = __commonJS(function(exports) {
|
|
22003
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22004
|
+
exports.Scope = undefined;
|
|
22005
|
+
var api_version_1 = require_api_version();
|
|
22006
|
+
var pagination_1 = require_pagination();
|
|
22007
|
+
var session_1 = require_session();
|
|
22008
|
+
var utils_1 = require_utils2();
|
|
22009
|
+
var validation_1 = require_validation2();
|
|
22010
|
+
|
|
22011
|
+
class Scope {
|
|
22012
|
+
get metadata() {
|
|
22013
|
+
return this._metadata;
|
|
22014
|
+
}
|
|
22015
|
+
get createdAt() {
|
|
22016
|
+
return this._createdAt;
|
|
22017
|
+
}
|
|
22018
|
+
get sessionCount() {
|
|
22019
|
+
return this._sessionCount;
|
|
22020
|
+
}
|
|
22021
|
+
constructor(id, workspaceId, http, metadata, ensureWorkspace = async () => {
|
|
22022
|
+
return;
|
|
22023
|
+
}, createdAt, sessionCount) {
|
|
22024
|
+
this.id = id;
|
|
22025
|
+
this.workspaceId = workspaceId;
|
|
22026
|
+
this._http = http;
|
|
22027
|
+
this._metadata = metadata;
|
|
22028
|
+
this._ensureWorkspace = ensureWorkspace;
|
|
22029
|
+
this._createdAt = createdAt;
|
|
22030
|
+
this._sessionCount = sessionCount;
|
|
22031
|
+
}
|
|
22032
|
+
get _basePath() {
|
|
22033
|
+
return `/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/scopes/${this.id}`;
|
|
22034
|
+
}
|
|
22035
|
+
async _addSessions(sessionIds) {
|
|
22036
|
+
await this._ensureWorkspace();
|
|
22037
|
+
await this._http.post(`${this._basePath}/sessions`, {
|
|
22038
|
+
body: { session_ids: sessionIds }
|
|
22039
|
+
});
|
|
22040
|
+
}
|
|
22041
|
+
async _removeSessions(sessionIds) {
|
|
22042
|
+
await this._ensureWorkspace();
|
|
22043
|
+
await this._http.post(`${this._basePath}/sessions/remove`, {
|
|
22044
|
+
body: { session_ids: sessionIds }
|
|
22045
|
+
});
|
|
22046
|
+
}
|
|
22047
|
+
async _removeSession(sessionId) {
|
|
22048
|
+
await this._ensureWorkspace();
|
|
22049
|
+
await this._http.delete(`${this._basePath}/sessions/${sessionId}`);
|
|
22050
|
+
}
|
|
22051
|
+
async _listSessions(params) {
|
|
22052
|
+
await this._ensureWorkspace();
|
|
22053
|
+
return this._http.post(`${this._basePath}/sessions/list`, {
|
|
22054
|
+
query: {
|
|
22055
|
+
page: params?.page,
|
|
22056
|
+
size: params?.size,
|
|
22057
|
+
reverse: params?.reverse ? "true" : undefined
|
|
22058
|
+
}
|
|
22059
|
+
});
|
|
22060
|
+
}
|
|
22061
|
+
async _getStatus() {
|
|
22062
|
+
await this._ensureWorkspace();
|
|
22063
|
+
return this._http.get(`${this._basePath}/status`);
|
|
22064
|
+
}
|
|
22065
|
+
async addSessions(sessions) {
|
|
22066
|
+
const sessionIds = validation_1.ScopeSessionsSchema.parse(sessions.map(utils_1.resolveId));
|
|
22067
|
+
await this._addSessions(sessionIds);
|
|
22068
|
+
}
|
|
22069
|
+
async removeSessions(sessions) {
|
|
22070
|
+
const sessionIds = validation_1.ScopeSessionsSchema.parse(sessions.map(utils_1.resolveId));
|
|
22071
|
+
await this._removeSessions(sessionIds);
|
|
22072
|
+
}
|
|
22073
|
+
async removeSession(session) {
|
|
22074
|
+
await this._removeSession(validation_1.SessionIdSchema.parse((0, utils_1.resolveId)(session)));
|
|
22075
|
+
}
|
|
22076
|
+
async sessions(options) {
|
|
22077
|
+
const reverse = options?.reverse;
|
|
22078
|
+
const sessionsPage = await this._listSessions({
|
|
22079
|
+
page: options?.page,
|
|
22080
|
+
size: options?.size,
|
|
22081
|
+
reverse
|
|
22082
|
+
});
|
|
22083
|
+
const fetchNextPage = async (page, size) => {
|
|
22084
|
+
return this._listSessions({ page, size, reverse });
|
|
22085
|
+
};
|
|
22086
|
+
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);
|
|
21618
22087
|
}
|
|
21619
|
-
|
|
21620
|
-
const
|
|
21621
|
-
return
|
|
22088
|
+
async status() {
|
|
22089
|
+
const response = await this._getStatus();
|
|
22090
|
+
return {
|
|
22091
|
+
backfillStatus: Object.fromEntries(Object.entries(response.backfill_status ?? {}).map(([sessionId, job]) => [
|
|
22092
|
+
sessionId,
|
|
22093
|
+
{
|
|
22094
|
+
state: job.state,
|
|
22095
|
+
updatedAt: job.updated_at,
|
|
22096
|
+
docsCopied: job.docs_copied
|
|
22097
|
+
}
|
|
22098
|
+
]))
|
|
22099
|
+
};
|
|
21622
22100
|
}
|
|
21623
22101
|
toString() {
|
|
21624
|
-
return `
|
|
22102
|
+
return `Scope(id='${this.id}', workspaceId='${this.workspaceId}')`;
|
|
21625
22103
|
}
|
|
21626
22104
|
}
|
|
21627
|
-
exports.
|
|
22105
|
+
exports.Scope = Scope;
|
|
21628
22106
|
});
|
|
21629
22107
|
|
|
21630
22108
|
// node_modules/@honcho-ai/sdk/dist/client.js
|
|
@@ -21632,10 +22110,13 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21632
22110
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21633
22111
|
exports.Honcho = undefined;
|
|
21634
22112
|
var api_version_1 = require_api_version();
|
|
22113
|
+
var conclusions_1 = require_conclusions();
|
|
21635
22114
|
var client_1 = require_client();
|
|
22115
|
+
var streaming_1 = require_streaming();
|
|
21636
22116
|
var message_1 = require_message();
|
|
21637
22117
|
var pagination_1 = require_pagination();
|
|
21638
22118
|
var peer_1 = require_peer();
|
|
22119
|
+
var scope_1 = require_scope2();
|
|
21639
22120
|
var session_1 = require_session();
|
|
21640
22121
|
var utils_1 = require_utils2();
|
|
21641
22122
|
var validation_1 = require_validation2();
|
|
@@ -21648,9 +22129,15 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21648
22129
|
get configuration() {
|
|
21649
22130
|
return this._configuration;
|
|
21650
22131
|
}
|
|
22132
|
+
get uid() {
|
|
22133
|
+
return this._uid;
|
|
22134
|
+
}
|
|
21651
22135
|
get http() {
|
|
21652
22136
|
return this._http;
|
|
21653
22137
|
}
|
|
22138
|
+
get conclusions() {
|
|
22139
|
+
return new conclusions_1.WorkspaceConclusions(this._http, this.workspaceId, () => this._ensureWorkspace());
|
|
22140
|
+
}
|
|
21654
22141
|
get baseURL() {
|
|
21655
22142
|
return this._http.baseURL;
|
|
21656
22143
|
}
|
|
@@ -21673,13 +22160,15 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21673
22160
|
});
|
|
21674
22161
|
}
|
|
21675
22162
|
async _getOrCreateWorkspace(id, params) {
|
|
21676
|
-
|
|
22163
|
+
const workspace = await this._http.post(`/${api_version_1.API_VERSION}/workspaces`, {
|
|
21677
22164
|
body: {
|
|
21678
22165
|
id,
|
|
21679
22166
|
metadata: params?.metadata,
|
|
21680
22167
|
configuration: (0, validation_1.workspaceConfigToApi)(params?.configuration)
|
|
21681
22168
|
}
|
|
21682
22169
|
});
|
|
22170
|
+
this._uid = workspace.uid;
|
|
22171
|
+
return workspace;
|
|
21683
22172
|
}
|
|
21684
22173
|
async _ensureWorkspace() {
|
|
21685
22174
|
if (!this._workspaceReady) {
|
|
@@ -21707,7 +22196,8 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21707
22196
|
},
|
|
21708
22197
|
query: {
|
|
21709
22198
|
page: params?.page,
|
|
21710
|
-
size: params?.size
|
|
22199
|
+
size: params?.size,
|
|
22200
|
+
reverse: params?.reverse ? "true" : undefined
|
|
21711
22201
|
}
|
|
21712
22202
|
});
|
|
21713
22203
|
}
|
|
@@ -21737,13 +22227,35 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21737
22227
|
async _getOrCreatePeer(workspaceId, params) {
|
|
21738
22228
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/peers`, { body: params });
|
|
21739
22229
|
}
|
|
22230
|
+
async _getOrCreateScope(workspaceId, params) {
|
|
22231
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/scopes`, { body: params });
|
|
22232
|
+
}
|
|
22233
|
+
async _getScope(workspaceId, scopeId) {
|
|
22234
|
+
return this._http.get(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/scopes/${scopeId}`);
|
|
22235
|
+
}
|
|
22236
|
+
async _listScopes(workspaceId, params) {
|
|
22237
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/scopes/list`, {
|
|
22238
|
+
body: { filters: params?.filters },
|
|
22239
|
+
query: {
|
|
22240
|
+
page: params?.page,
|
|
22241
|
+
size: params?.size,
|
|
22242
|
+
reverse: params?.reverse ? "true" : undefined,
|
|
22243
|
+
include_session_count: params?.includeSessionCount ? "true" : undefined
|
|
22244
|
+
}
|
|
22245
|
+
});
|
|
22246
|
+
}
|
|
21740
22247
|
async _listSessions(workspaceId, params) {
|
|
21741
22248
|
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/sessions/list`, {
|
|
21742
|
-
body: {
|
|
22249
|
+
body: {
|
|
22250
|
+
filters: params?.filters,
|
|
22251
|
+
scope: params?.scope,
|
|
22252
|
+
in_no_scope: params?.inNoScope ? true : undefined
|
|
22253
|
+
},
|
|
21743
22254
|
query: {
|
|
21744
22255
|
page: params?.page,
|
|
21745
22256
|
size: params?.size,
|
|
21746
|
-
reverse: params?.reverse ? "true" : undefined
|
|
22257
|
+
reverse: params?.reverse ? "true" : undefined,
|
|
22258
|
+
include_scopes: params?.includeScopes ? "true" : undefined
|
|
21747
22259
|
}
|
|
21748
22260
|
});
|
|
21749
22261
|
}
|
|
@@ -21752,7 +22264,22 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21752
22264
|
body: {
|
|
21753
22265
|
id: params.id,
|
|
21754
22266
|
metadata: params.metadata,
|
|
21755
|
-
configuration: (0, validation_1.sessionConfigToApi)(params.configuration)
|
|
22267
|
+
configuration: (0, validation_1.sessionConfigToApi)(params.configuration),
|
|
22268
|
+
peers: params.peers,
|
|
22269
|
+
scopes: params.scopes
|
|
22270
|
+
}
|
|
22271
|
+
});
|
|
22272
|
+
}
|
|
22273
|
+
async _workspaceChat(workspaceId, params) {
|
|
22274
|
+
await this._ensureWorkspace();
|
|
22275
|
+
return this._http.post(`/${api_version_1.API_VERSION}/workspaces/${workspaceId}/chat`, { body: params });
|
|
22276
|
+
}
|
|
22277
|
+
async _workspaceChatStream(workspaceId, params) {
|
|
22278
|
+
await this._ensureWorkspace();
|
|
22279
|
+
return this._http.stream("POST", `/${api_version_1.API_VERSION}/workspaces/${workspaceId}/chat`, {
|
|
22280
|
+
body: {
|
|
22281
|
+
...params,
|
|
22282
|
+
stream: true
|
|
21756
22283
|
}
|
|
21757
22284
|
});
|
|
21758
22285
|
}
|
|
@@ -21766,7 +22293,7 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21766
22293
|
configuration: (0, validation_1.peerConfigToApi)(validatedConfiguration),
|
|
21767
22294
|
metadata: validatedMetadata
|
|
21768
22295
|
});
|
|
21769
|
-
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);
|
|
22296
|
+
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);
|
|
21770
22297
|
}
|
|
21771
22298
|
async peers(options) {
|
|
21772
22299
|
await this._ensureWorkspace();
|
|
@@ -21792,19 +22319,55 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21792
22319
|
reverse
|
|
21793
22320
|
});
|
|
21794
22321
|
};
|
|
21795
|
-
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);
|
|
22322
|
+
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);
|
|
21796
22323
|
}
|
|
21797
22324
|
async session(id, options) {
|
|
21798
22325
|
await this._ensureWorkspace();
|
|
21799
22326
|
const validatedId = validation_1.SessionIdSchema.parse(id);
|
|
21800
22327
|
const validatedMetadata = options?.metadata ? validation_1.SessionMetadataSchema.parse(options.metadata) : undefined;
|
|
21801
22328
|
const validatedConfiguration = options?.configuration ? validation_1.SessionConfigSchema.parse(options.configuration) : undefined;
|
|
22329
|
+
const validatedPeers = options?.peers !== undefined ? validation_1.PeerAdditionToApiSchema.parse(options.peers) : undefined;
|
|
22330
|
+
const validatedScopes = options?.scopes !== undefined ? validation_1.SessionScopesSchema.parse(options.scopes.map(utils_1.resolveId)) : undefined;
|
|
21802
22331
|
const sessionData = await this._getOrCreateSession(this.workspaceId, {
|
|
21803
22332
|
id: validatedId,
|
|
21804
22333
|
configuration: validatedConfiguration,
|
|
21805
|
-
metadata: validatedMetadata
|
|
22334
|
+
metadata: validatedMetadata,
|
|
22335
|
+
peers: validatedPeers,
|
|
22336
|
+
scopes: validatedScopes
|
|
22337
|
+
});
|
|
22338
|
+
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);
|
|
22339
|
+
}
|
|
22340
|
+
async scope(id, options) {
|
|
22341
|
+
await this._ensureWorkspace();
|
|
22342
|
+
const validatedId = validation_1.ScopeIdSchema.parse(id);
|
|
22343
|
+
const scopeData = await this._getOrCreateScope(this.workspaceId, {
|
|
22344
|
+
id: validatedId,
|
|
22345
|
+
metadata: options?.metadata
|
|
22346
|
+
});
|
|
22347
|
+
return new scope_1.Scope(validatedId, this.workspaceId, this._http, scopeData.metadata ?? undefined, () => this._ensureWorkspace(), scopeData.created_at);
|
|
22348
|
+
}
|
|
22349
|
+
async getScope(id) {
|
|
22350
|
+
await this._ensureWorkspace();
|
|
22351
|
+
const validatedId = validation_1.ScopeIdSchema.parse(id);
|
|
22352
|
+
const scopeData = await this._getScope(this.workspaceId, validatedId);
|
|
22353
|
+
return new scope_1.Scope(validatedId, this.workspaceId, this._http, scopeData.metadata ?? undefined, () => this._ensureWorkspace(), scopeData.created_at);
|
|
22354
|
+
}
|
|
22355
|
+
async scopes(options) {
|
|
22356
|
+
await this._ensureWorkspace();
|
|
22357
|
+
const listOptions = {
|
|
22358
|
+
filters: options?.filters ? validation_1.FilterSchema.parse(options.filters) : undefined,
|
|
22359
|
+
reverse: options?.reverse,
|
|
22360
|
+
includeSessionCount: options?.includeSessionCount
|
|
22361
|
+
};
|
|
22362
|
+
const scopesPage = await this._listScopes(this.workspaceId, {
|
|
22363
|
+
...listOptions,
|
|
22364
|
+
page: options?.page,
|
|
22365
|
+
size: options?.size
|
|
21806
22366
|
});
|
|
21807
|
-
|
|
22367
|
+
const fetchNextPage = async (page, size) => {
|
|
22368
|
+
return this._listScopes(this.workspaceId, { ...listOptions, page, size });
|
|
22369
|
+
};
|
|
22370
|
+
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);
|
|
21808
22371
|
}
|
|
21809
22372
|
async sessions(options) {
|
|
21810
22373
|
await this._ensureWorkspace();
|
|
@@ -21812,25 +22375,32 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21812
22375
|
"filters",
|
|
21813
22376
|
"page",
|
|
21814
22377
|
"size",
|
|
21815
|
-
"reverse"
|
|
22378
|
+
"reverse",
|
|
22379
|
+
"scope",
|
|
22380
|
+
"inNoScope",
|
|
22381
|
+
"includeScopes"
|
|
21816
22382
|
]);
|
|
21817
22383
|
const validatedFilter = normalizedOptions.filters ? validation_1.FilterSchema.parse(normalizedOptions.filters) : undefined;
|
|
21818
|
-
const
|
|
21819
|
-
const sessionsPage = await this._listSessions(this.workspaceId, {
|
|
22384
|
+
const listOptions = {
|
|
21820
22385
|
filters: validatedFilter,
|
|
22386
|
+
reverse: normalizedOptions.reverse,
|
|
22387
|
+
scope: normalizedOptions.scope,
|
|
22388
|
+
inNoScope: normalizedOptions.inNoScope,
|
|
22389
|
+
includeScopes: normalizedOptions.includeScopes
|
|
22390
|
+
};
|
|
22391
|
+
const sessionsPage = await this._listSessions(this.workspaceId, {
|
|
22392
|
+
...listOptions,
|
|
21821
22393
|
page: normalizedOptions.page,
|
|
21822
|
-
size: normalizedOptions.size
|
|
21823
|
-
reverse
|
|
22394
|
+
size: normalizedOptions.size
|
|
21824
22395
|
});
|
|
21825
22396
|
const fetchNextPage = async (page, size) => {
|
|
21826
22397
|
return this._listSessions(this.workspaceId, {
|
|
21827
|
-
|
|
22398
|
+
...listOptions,
|
|
21828
22399
|
page,
|
|
21829
|
-
size
|
|
21830
|
-
reverse
|
|
22400
|
+
size
|
|
21831
22401
|
});
|
|
21832
22402
|
};
|
|
21833
|
-
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);
|
|
22403
|
+
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);
|
|
21834
22404
|
}
|
|
21835
22405
|
async getMetadata() {
|
|
21836
22406
|
await this._ensureWorkspace();
|
|
@@ -21870,19 +22440,23 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21870
22440
|
const normalizedOptions = (0, validation_1.normalizeListOptions)(options, [
|
|
21871
22441
|
"filters",
|
|
21872
22442
|
"page",
|
|
21873
|
-
"size"
|
|
22443
|
+
"size",
|
|
22444
|
+
"reverse"
|
|
21874
22445
|
]);
|
|
21875
22446
|
const validatedFilter = normalizedOptions.filters ? validation_1.FilterSchema.parse(normalizedOptions.filters) : undefined;
|
|
22447
|
+
const reverse = normalizedOptions.reverse;
|
|
21876
22448
|
const workspacesPage = await this._listWorkspaces({
|
|
21877
22449
|
filters: validatedFilter,
|
|
21878
22450
|
page: normalizedOptions.page,
|
|
21879
|
-
size: normalizedOptions.size
|
|
22451
|
+
size: normalizedOptions.size,
|
|
22452
|
+
reverse
|
|
21880
22453
|
});
|
|
21881
22454
|
const fetchNextPage = async (page, size) => {
|
|
21882
22455
|
return this._listWorkspaces({
|
|
21883
22456
|
filters: validatedFilter,
|
|
21884
22457
|
page,
|
|
21885
|
-
size
|
|
22458
|
+
size,
|
|
22459
|
+
reverse
|
|
21886
22460
|
});
|
|
21887
22461
|
};
|
|
21888
22462
|
return new pagination_1.Page(workspacesPage, (workspace) => workspace.id, fetchNextPage);
|
|
@@ -21894,14 +22468,47 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21894
22468
|
await this._ensureWorkspace();
|
|
21895
22469
|
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
21896
22470
|
const validatedFilters = options?.filters ? validation_1.FilterSchema.parse(options.filters) : undefined;
|
|
22471
|
+
const validatedScope = options?.scope !== undefined ? validation_1.ScopeIdSchema.parse((0, utils_1.resolveId)(options.scope)) : undefined;
|
|
21897
22472
|
const validatedLimit = options?.limit ? validation_1.LimitSchema.parse(options.limit) : undefined;
|
|
21898
22473
|
const response = await this._searchWorkspace(this.workspaceId, {
|
|
21899
22474
|
query: validatedQuery,
|
|
21900
22475
|
filters: validatedFilters,
|
|
22476
|
+
scope: validatedScope,
|
|
21901
22477
|
limit: validatedLimit
|
|
21902
22478
|
});
|
|
21903
22479
|
return response.map(message_1.Message.fromApiResponse);
|
|
21904
22480
|
}
|
|
22481
|
+
async chat(query, options) {
|
|
22482
|
+
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
22483
|
+
const resolvedSessionId = options?.session ? (0, utils_1.resolveId)(options.session) : undefined;
|
|
22484
|
+
const response = await this._workspaceChat(this.workspaceId, {
|
|
22485
|
+
query: validatedQuery,
|
|
22486
|
+
stream: false,
|
|
22487
|
+
session_id: resolvedSessionId,
|
|
22488
|
+
reasoning_level: options?.reasoningLevel,
|
|
22489
|
+
response_format: options?.responseFormat,
|
|
22490
|
+
scope: options?.scope,
|
|
22491
|
+
include_evidence: options?.includeEvidence ? true : undefined
|
|
22492
|
+
});
|
|
22493
|
+
const content = response.content || null;
|
|
22494
|
+
if (!options?.includeEvidence) {
|
|
22495
|
+
return content;
|
|
22496
|
+
}
|
|
22497
|
+
return { content, evidence: response.evidence ?? null };
|
|
22498
|
+
}
|
|
22499
|
+
async chatStream(query, options) {
|
|
22500
|
+
const validatedQuery = validation_1.SearchQuerySchema.parse(query);
|
|
22501
|
+
const resolvedSessionId = options?.session ? (0, utils_1.resolveId)(options.session) : undefined;
|
|
22502
|
+
const response = await this._workspaceChatStream(this.workspaceId, {
|
|
22503
|
+
query: validatedQuery,
|
|
22504
|
+
session_id: resolvedSessionId,
|
|
22505
|
+
reasoning_level: options?.reasoningLevel,
|
|
22506
|
+
response_format: options?.responseFormat,
|
|
22507
|
+
scope: options?.scope,
|
|
22508
|
+
include_evidence: options?.includeEvidence ? true : undefined
|
|
22509
|
+
});
|
|
22510
|
+
return (0, streaming_1.createDialecticStream)(response);
|
|
22511
|
+
}
|
|
21905
22512
|
async queueStatus(options) {
|
|
21906
22513
|
await this._ensureWorkspace();
|
|
21907
22514
|
const observerId = options?.observer ? (0, utils_1.resolveId)(options.observer) : undefined;
|
|
@@ -21931,6 +22538,20 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21931
22538
|
}
|
|
21932
22539
|
});
|
|
21933
22540
|
}
|
|
22541
|
+
async dreams(options) {
|
|
22542
|
+
await this._ensureWorkspace();
|
|
22543
|
+
const body = {};
|
|
22544
|
+
if (options?.observed)
|
|
22545
|
+
body.observed_id = (0, utils_1.resolveId)(options.observed);
|
|
22546
|
+
if (options?.observer)
|
|
22547
|
+
body.observer_id = (0, utils_1.resolveId)(options.observer);
|
|
22548
|
+
const fetchPage = (page, size) => this._http.post(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/dreams/list`, { body, query: { page, size } });
|
|
22549
|
+
return new pagination_1.Page(await fetchPage(options?.page, options?.size), undefined, fetchPage);
|
|
22550
|
+
}
|
|
22551
|
+
async getDream(runId) {
|
|
22552
|
+
await this._ensureWorkspace();
|
|
22553
|
+
return this._http.get(`/${api_version_1.API_VERSION}/workspaces/${this.workspaceId}/dreams/${runId}`);
|
|
22554
|
+
}
|
|
21934
22555
|
toString() {
|
|
21935
22556
|
return `Honcho(workspaceId='${this.workspaceId}', baseURL='${this._http.baseURL}')`;
|
|
21936
22557
|
}
|
|
@@ -21941,7 +22562,7 @@ var require_client2 = __commonJS(function(exports) {
|
|
|
21941
22562
|
// node_modules/@honcho-ai/sdk/dist/index.js
|
|
21942
22563
|
var require_dist2 = __commonJS(function(exports) {
|
|
21943
22564
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21944
|
-
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;
|
|
22565
|
+
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;
|
|
21945
22566
|
var client_1 = require_client2();
|
|
21946
22567
|
Object.defineProperty(exports, "Honcho", { enumerable: true, get: function() {
|
|
21947
22568
|
return client_1.Honcho;
|
|
@@ -21951,7 +22572,13 @@ var require_dist2 = __commonJS(function(exports) {
|
|
|
21951
22572
|
return conclusions_1.Conclusion;
|
|
21952
22573
|
} });
|
|
21953
22574
|
Object.defineProperty(exports, "ConclusionScope", { enumerable: true, get: function() {
|
|
21954
|
-
return conclusions_1.
|
|
22575
|
+
return conclusions_1.ConclusionsView;
|
|
22576
|
+
} });
|
|
22577
|
+
Object.defineProperty(exports, "ConclusionsView", { enumerable: true, get: function() {
|
|
22578
|
+
return conclusions_1.ConclusionsView;
|
|
22579
|
+
} });
|
|
22580
|
+
Object.defineProperty(exports, "WorkspaceConclusions", { enumerable: true, get: function() {
|
|
22581
|
+
return conclusions_1.WorkspaceConclusions;
|
|
21955
22582
|
} });
|
|
21956
22583
|
var errors_1 = require_errors2();
|
|
21957
22584
|
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function() {
|
|
@@ -22006,6 +22633,10 @@ var require_dist2 = __commonJS(function(exports) {
|
|
|
22006
22633
|
Object.defineProperty(exports, "PeerContext", { enumerable: true, get: function() {
|
|
22007
22634
|
return peer_1.PeerContext;
|
|
22008
22635
|
} });
|
|
22636
|
+
var scope_1 = require_scope2();
|
|
22637
|
+
Object.defineProperty(exports, "Scope", { enumerable: true, get: function() {
|
|
22638
|
+
return scope_1.Scope;
|
|
22639
|
+
} });
|
|
22009
22640
|
var session_1 = require_session();
|
|
22010
22641
|
Object.defineProperty(exports, "Session", { enumerable: true, get: function() {
|
|
22011
22642
|
return session_1.Session;
|
|
@@ -25266,7 +25897,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
25266
25897
|
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
25267
25898
|
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
25268
25899
|
});
|
|
25269
|
-
function
|
|
25900
|
+
function object(shape, params) {
|
|
25270
25901
|
const def = {
|
|
25271
25902
|
type: "object",
|
|
25272
25903
|
get shape() {
|
|
@@ -25591,31 +26222,31 @@ var TaskCreationParamsSchema = looseObject({
|
|
|
25591
26222
|
ttl: number2().optional(),
|
|
25592
26223
|
pollInterval: number2().optional()
|
|
25593
26224
|
});
|
|
25594
|
-
var TaskMetadataSchema =
|
|
26225
|
+
var TaskMetadataSchema = object({
|
|
25595
26226
|
ttl: number2().optional()
|
|
25596
26227
|
});
|
|
25597
|
-
var RelatedTaskMetadataSchema =
|
|
26228
|
+
var RelatedTaskMetadataSchema = object({
|
|
25598
26229
|
taskId: string2()
|
|
25599
26230
|
});
|
|
25600
26231
|
var RequestMetaSchema = looseObject({
|
|
25601
26232
|
progressToken: ProgressTokenSchema.optional(),
|
|
25602
26233
|
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
25603
26234
|
});
|
|
25604
|
-
var BaseRequestParamsSchema =
|
|
26235
|
+
var BaseRequestParamsSchema = object({
|
|
25605
26236
|
_meta: RequestMetaSchema.optional()
|
|
25606
26237
|
});
|
|
25607
26238
|
var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
25608
26239
|
task: TaskMetadataSchema.optional()
|
|
25609
26240
|
});
|
|
25610
26241
|
var isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
|
|
25611
|
-
var RequestSchema =
|
|
26242
|
+
var RequestSchema = object({
|
|
25612
26243
|
method: string2(),
|
|
25613
26244
|
params: BaseRequestParamsSchema.loose().optional()
|
|
25614
26245
|
});
|
|
25615
|
-
var NotificationsParamsSchema =
|
|
26246
|
+
var NotificationsParamsSchema = object({
|
|
25616
26247
|
_meta: RequestMetaSchema.optional()
|
|
25617
26248
|
});
|
|
25618
|
-
var NotificationSchema =
|
|
26249
|
+
var NotificationSchema = object({
|
|
25619
26250
|
method: string2(),
|
|
25620
26251
|
params: NotificationsParamsSchema.loose().optional()
|
|
25621
26252
|
});
|
|
@@ -25623,18 +26254,18 @@ var ResultSchema = looseObject({
|
|
|
25623
26254
|
_meta: RequestMetaSchema.optional()
|
|
25624
26255
|
});
|
|
25625
26256
|
var RequestIdSchema = union([string2(), number2().int()]);
|
|
25626
|
-
var JSONRPCRequestSchema =
|
|
26257
|
+
var JSONRPCRequestSchema = object({
|
|
25627
26258
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
25628
26259
|
id: RequestIdSchema,
|
|
25629
26260
|
...RequestSchema.shape
|
|
25630
26261
|
}).strict();
|
|
25631
26262
|
var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
25632
|
-
var JSONRPCNotificationSchema =
|
|
26263
|
+
var JSONRPCNotificationSchema = object({
|
|
25633
26264
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
25634
26265
|
...NotificationSchema.shape
|
|
25635
26266
|
}).strict();
|
|
25636
26267
|
var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
25637
|
-
var JSONRPCResultResponseSchema =
|
|
26268
|
+
var JSONRPCResultResponseSchema = object({
|
|
25638
26269
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
25639
26270
|
id: RequestIdSchema,
|
|
25640
26271
|
result: ResultSchema
|
|
@@ -25651,10 +26282,10 @@ var ErrorCode;
|
|
|
25651
26282
|
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
25652
26283
|
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
25653
26284
|
})(ErrorCode || (ErrorCode = {}));
|
|
25654
|
-
var JSONRPCErrorResponseSchema =
|
|
26285
|
+
var JSONRPCErrorResponseSchema = object({
|
|
25655
26286
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
25656
26287
|
id: RequestIdSchema.optional(),
|
|
25657
|
-
error:
|
|
26288
|
+
error: object({
|
|
25658
26289
|
code: number2().int(),
|
|
25659
26290
|
message: string2(),
|
|
25660
26291
|
data: unknown().optional()
|
|
@@ -25677,16 +26308,16 @@ var CancelledNotificationSchema = NotificationSchema.extend({
|
|
|
25677
26308
|
method: literal("notifications/cancelled"),
|
|
25678
26309
|
params: CancelledNotificationParamsSchema
|
|
25679
26310
|
});
|
|
25680
|
-
var IconSchema =
|
|
26311
|
+
var IconSchema = object({
|
|
25681
26312
|
src: string2(),
|
|
25682
26313
|
mimeType: string2().optional(),
|
|
25683
26314
|
sizes: array(string2()).optional(),
|
|
25684
26315
|
theme: _enum(["light", "dark"]).optional()
|
|
25685
26316
|
});
|
|
25686
|
-
var IconsSchema =
|
|
26317
|
+
var IconsSchema = object({
|
|
25687
26318
|
icons: array(IconSchema).optional()
|
|
25688
26319
|
});
|
|
25689
|
-
var BaseMetadataSchema =
|
|
26320
|
+
var BaseMetadataSchema = object({
|
|
25690
26321
|
name: string2(),
|
|
25691
26322
|
title: string2().optional()
|
|
25692
26323
|
});
|
|
@@ -25697,7 +26328,7 @@ var ImplementationSchema = BaseMetadataSchema.extend({
|
|
|
25697
26328
|
websiteUrl: string2().optional(),
|
|
25698
26329
|
description: string2().optional()
|
|
25699
26330
|
});
|
|
25700
|
-
var FormElicitationCapabilitySchema = intersection(
|
|
26331
|
+
var FormElicitationCapabilitySchema = intersection(object({
|
|
25701
26332
|
applyDefaults: boolean2().optional()
|
|
25702
26333
|
}), record(string2(), unknown()));
|
|
25703
26334
|
var ElicitationCapabilitySchema = preprocess((value) => {
|
|
@@ -25707,7 +26338,7 @@ var ElicitationCapabilitySchema = preprocess((value) => {
|
|
|
25707
26338
|
}
|
|
25708
26339
|
}
|
|
25709
26340
|
return value;
|
|
25710
|
-
}, intersection(
|
|
26341
|
+
}, intersection(object({
|
|
25711
26342
|
form: FormElicitationCapabilitySchema.optional(),
|
|
25712
26343
|
url: AssertObjectSchema.optional()
|
|
25713
26344
|
}), record(string2(), unknown()).optional()));
|
|
@@ -25732,14 +26363,14 @@ var ServerTasksCapabilitySchema = looseObject({
|
|
|
25732
26363
|
}).optional()
|
|
25733
26364
|
}).optional()
|
|
25734
26365
|
});
|
|
25735
|
-
var ClientCapabilitiesSchema =
|
|
26366
|
+
var ClientCapabilitiesSchema = object({
|
|
25736
26367
|
experimental: record(string2(), AssertObjectSchema).optional(),
|
|
25737
|
-
sampling:
|
|
26368
|
+
sampling: object({
|
|
25738
26369
|
context: AssertObjectSchema.optional(),
|
|
25739
26370
|
tools: AssertObjectSchema.optional()
|
|
25740
26371
|
}).optional(),
|
|
25741
26372
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
25742
|
-
roots:
|
|
26373
|
+
roots: object({
|
|
25743
26374
|
listChanged: boolean2().optional()
|
|
25744
26375
|
}).optional(),
|
|
25745
26376
|
tasks: ClientTasksCapabilitySchema.optional(),
|
|
@@ -25754,18 +26385,18 @@ var InitializeRequestSchema = RequestSchema.extend({
|
|
|
25754
26385
|
method: literal("initialize"),
|
|
25755
26386
|
params: InitializeRequestParamsSchema
|
|
25756
26387
|
});
|
|
25757
|
-
var ServerCapabilitiesSchema =
|
|
26388
|
+
var ServerCapabilitiesSchema = object({
|
|
25758
26389
|
experimental: record(string2(), AssertObjectSchema).optional(),
|
|
25759
26390
|
logging: AssertObjectSchema.optional(),
|
|
25760
26391
|
completions: AssertObjectSchema.optional(),
|
|
25761
|
-
prompts:
|
|
26392
|
+
prompts: object({
|
|
25762
26393
|
listChanged: boolean2().optional()
|
|
25763
26394
|
}).optional(),
|
|
25764
|
-
resources:
|
|
26395
|
+
resources: object({
|
|
25765
26396
|
subscribe: boolean2().optional(),
|
|
25766
26397
|
listChanged: boolean2().optional()
|
|
25767
26398
|
}).optional(),
|
|
25768
|
-
tools:
|
|
26399
|
+
tools: object({
|
|
25769
26400
|
listChanged: boolean2().optional()
|
|
25770
26401
|
}).optional(),
|
|
25771
26402
|
tasks: ServerTasksCapabilitySchema.optional(),
|
|
@@ -25785,12 +26416,12 @@ var PingRequestSchema = RequestSchema.extend({
|
|
|
25785
26416
|
method: literal("ping"),
|
|
25786
26417
|
params: BaseRequestParamsSchema.optional()
|
|
25787
26418
|
});
|
|
25788
|
-
var ProgressSchema =
|
|
26419
|
+
var ProgressSchema = object({
|
|
25789
26420
|
progress: number2(),
|
|
25790
26421
|
total: optional(number2()),
|
|
25791
26422
|
message: optional(string2())
|
|
25792
26423
|
});
|
|
25793
|
-
var ProgressNotificationParamsSchema =
|
|
26424
|
+
var ProgressNotificationParamsSchema = object({
|
|
25794
26425
|
...NotificationsParamsSchema.shape,
|
|
25795
26426
|
...ProgressSchema.shape,
|
|
25796
26427
|
progressToken: ProgressTokenSchema
|
|
@@ -25809,7 +26440,7 @@ var PaginatedResultSchema = ResultSchema.extend({
|
|
|
25809
26440
|
nextCursor: CursorSchema.optional()
|
|
25810
26441
|
});
|
|
25811
26442
|
var TaskStatusSchema = _enum(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
25812
|
-
var TaskSchema =
|
|
26443
|
+
var TaskSchema = object({
|
|
25813
26444
|
taskId: string2(),
|
|
25814
26445
|
status: TaskStatusSchema,
|
|
25815
26446
|
ttl: union([number2(), _null3()]),
|
|
@@ -25853,7 +26484,7 @@ var CancelTaskRequestSchema = RequestSchema.extend({
|
|
|
25853
26484
|
})
|
|
25854
26485
|
});
|
|
25855
26486
|
var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
25856
|
-
var ResourceContentsSchema =
|
|
26487
|
+
var ResourceContentsSchema = object({
|
|
25857
26488
|
uri: string2(),
|
|
25858
26489
|
mimeType: optional(string2()),
|
|
25859
26490
|
_meta: record(string2(), unknown()).optional()
|
|
@@ -25873,12 +26504,12 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
25873
26504
|
blob: Base64Schema
|
|
25874
26505
|
});
|
|
25875
26506
|
var RoleSchema = _enum(["user", "assistant"]);
|
|
25876
|
-
var AnnotationsSchema =
|
|
26507
|
+
var AnnotationsSchema = object({
|
|
25877
26508
|
audience: array(RoleSchema).optional(),
|
|
25878
26509
|
priority: number2().min(0).max(1).optional(),
|
|
25879
26510
|
lastModified: datetime2({ offset: true }).optional()
|
|
25880
26511
|
});
|
|
25881
|
-
var ResourceSchema =
|
|
26512
|
+
var ResourceSchema = object({
|
|
25882
26513
|
...BaseMetadataSchema.shape,
|
|
25883
26514
|
...IconsSchema.shape,
|
|
25884
26515
|
uri: string2(),
|
|
@@ -25888,7 +26519,7 @@ var ResourceSchema = object2({
|
|
|
25888
26519
|
annotations: AnnotationsSchema.optional(),
|
|
25889
26520
|
_meta: optional(looseObject({}))
|
|
25890
26521
|
});
|
|
25891
|
-
var ResourceTemplateSchema =
|
|
26522
|
+
var ResourceTemplateSchema = object({
|
|
25892
26523
|
...BaseMetadataSchema.shape,
|
|
25893
26524
|
...IconsSchema.shape,
|
|
25894
26525
|
uriTemplate: string2(),
|
|
@@ -25941,12 +26572,12 @@ var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
|
25941
26572
|
method: literal("notifications/resources/updated"),
|
|
25942
26573
|
params: ResourceUpdatedNotificationParamsSchema
|
|
25943
26574
|
});
|
|
25944
|
-
var PromptArgumentSchema =
|
|
26575
|
+
var PromptArgumentSchema = object({
|
|
25945
26576
|
name: string2(),
|
|
25946
26577
|
description: optional(string2()),
|
|
25947
26578
|
required: optional(boolean2())
|
|
25948
26579
|
});
|
|
25949
|
-
var PromptSchema =
|
|
26580
|
+
var PromptSchema = object({
|
|
25950
26581
|
...BaseMetadataSchema.shape,
|
|
25951
26582
|
...IconsSchema.shape,
|
|
25952
26583
|
description: optional(string2()),
|
|
@@ -25967,34 +26598,34 @@ var GetPromptRequestSchema = RequestSchema.extend({
|
|
|
25967
26598
|
method: literal("prompts/get"),
|
|
25968
26599
|
params: GetPromptRequestParamsSchema
|
|
25969
26600
|
});
|
|
25970
|
-
var TextContentSchema =
|
|
26601
|
+
var TextContentSchema = object({
|
|
25971
26602
|
type: literal("text"),
|
|
25972
26603
|
text: string2(),
|
|
25973
26604
|
annotations: AnnotationsSchema.optional(),
|
|
25974
26605
|
_meta: record(string2(), unknown()).optional()
|
|
25975
26606
|
});
|
|
25976
|
-
var ImageContentSchema =
|
|
26607
|
+
var ImageContentSchema = object({
|
|
25977
26608
|
type: literal("image"),
|
|
25978
26609
|
data: Base64Schema,
|
|
25979
26610
|
mimeType: string2(),
|
|
25980
26611
|
annotations: AnnotationsSchema.optional(),
|
|
25981
26612
|
_meta: record(string2(), unknown()).optional()
|
|
25982
26613
|
});
|
|
25983
|
-
var AudioContentSchema =
|
|
26614
|
+
var AudioContentSchema = object({
|
|
25984
26615
|
type: literal("audio"),
|
|
25985
26616
|
data: Base64Schema,
|
|
25986
26617
|
mimeType: string2(),
|
|
25987
26618
|
annotations: AnnotationsSchema.optional(),
|
|
25988
26619
|
_meta: record(string2(), unknown()).optional()
|
|
25989
26620
|
});
|
|
25990
|
-
var ToolUseContentSchema =
|
|
26621
|
+
var ToolUseContentSchema = object({
|
|
25991
26622
|
type: literal("tool_use"),
|
|
25992
26623
|
name: string2(),
|
|
25993
26624
|
id: string2(),
|
|
25994
26625
|
input: record(string2(), unknown()),
|
|
25995
26626
|
_meta: record(string2(), unknown()).optional()
|
|
25996
26627
|
});
|
|
25997
|
-
var EmbeddedResourceSchema =
|
|
26628
|
+
var EmbeddedResourceSchema = object({
|
|
25998
26629
|
type: literal("resource"),
|
|
25999
26630
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
26000
26631
|
annotations: AnnotationsSchema.optional(),
|
|
@@ -26010,7 +26641,7 @@ var ContentBlockSchema = union([
|
|
|
26010
26641
|
ResourceLinkSchema,
|
|
26011
26642
|
EmbeddedResourceSchema
|
|
26012
26643
|
]);
|
|
26013
|
-
var PromptMessageSchema =
|
|
26644
|
+
var PromptMessageSchema = object({
|
|
26014
26645
|
role: RoleSchema,
|
|
26015
26646
|
content: ContentBlockSchema
|
|
26016
26647
|
});
|
|
@@ -26022,26 +26653,26 @@ var PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
|
26022
26653
|
method: literal("notifications/prompts/list_changed"),
|
|
26023
26654
|
params: NotificationsParamsSchema.optional()
|
|
26024
26655
|
});
|
|
26025
|
-
var ToolAnnotationsSchema =
|
|
26656
|
+
var ToolAnnotationsSchema = object({
|
|
26026
26657
|
title: string2().optional(),
|
|
26027
26658
|
readOnlyHint: boolean2().optional(),
|
|
26028
26659
|
destructiveHint: boolean2().optional(),
|
|
26029
26660
|
idempotentHint: boolean2().optional(),
|
|
26030
26661
|
openWorldHint: boolean2().optional()
|
|
26031
26662
|
});
|
|
26032
|
-
var ToolExecutionSchema =
|
|
26663
|
+
var ToolExecutionSchema = object({
|
|
26033
26664
|
taskSupport: _enum(["required", "optional", "forbidden"]).optional()
|
|
26034
26665
|
});
|
|
26035
|
-
var ToolSchema =
|
|
26666
|
+
var ToolSchema = object({
|
|
26036
26667
|
...BaseMetadataSchema.shape,
|
|
26037
26668
|
...IconsSchema.shape,
|
|
26038
26669
|
description: string2().optional(),
|
|
26039
|
-
inputSchema:
|
|
26670
|
+
inputSchema: object({
|
|
26040
26671
|
type: literal("object"),
|
|
26041
26672
|
properties: record(string2(), AssertObjectSchema).optional(),
|
|
26042
26673
|
required: array(string2()).optional()
|
|
26043
26674
|
}).catchall(unknown()),
|
|
26044
|
-
outputSchema:
|
|
26675
|
+
outputSchema: object({
|
|
26045
26676
|
type: literal("object"),
|
|
26046
26677
|
properties: record(string2(), AssertObjectSchema).optional(),
|
|
26047
26678
|
required: array(string2()).optional()
|
|
@@ -26076,7 +26707,7 @@ var ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
|
26076
26707
|
method: literal("notifications/tools/list_changed"),
|
|
26077
26708
|
params: NotificationsParamsSchema.optional()
|
|
26078
26709
|
});
|
|
26079
|
-
var ListChangedOptionsBaseSchema =
|
|
26710
|
+
var ListChangedOptionsBaseSchema = object({
|
|
26080
26711
|
autoRefresh: boolean2().default(true),
|
|
26081
26712
|
debounceMs: number2().int().nonnegative().default(300)
|
|
26082
26713
|
});
|
|
@@ -26097,23 +26728,23 @@ var LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
|
26097
26728
|
method: literal("notifications/message"),
|
|
26098
26729
|
params: LoggingMessageNotificationParamsSchema
|
|
26099
26730
|
});
|
|
26100
|
-
var ModelHintSchema =
|
|
26731
|
+
var ModelHintSchema = object({
|
|
26101
26732
|
name: string2().optional()
|
|
26102
26733
|
});
|
|
26103
|
-
var ModelPreferencesSchema =
|
|
26734
|
+
var ModelPreferencesSchema = object({
|
|
26104
26735
|
hints: array(ModelHintSchema).optional(),
|
|
26105
26736
|
costPriority: number2().min(0).max(1).optional(),
|
|
26106
26737
|
speedPriority: number2().min(0).max(1).optional(),
|
|
26107
26738
|
intelligencePriority: number2().min(0).max(1).optional()
|
|
26108
26739
|
});
|
|
26109
|
-
var ToolChoiceSchema =
|
|
26740
|
+
var ToolChoiceSchema = object({
|
|
26110
26741
|
mode: _enum(["auto", "required", "none"]).optional()
|
|
26111
26742
|
});
|
|
26112
|
-
var ToolResultContentSchema =
|
|
26743
|
+
var ToolResultContentSchema = object({
|
|
26113
26744
|
type: literal("tool_result"),
|
|
26114
26745
|
toolUseId: string2().describe("The unique identifier for the corresponding tool call."),
|
|
26115
26746
|
content: array(ContentBlockSchema).default([]),
|
|
26116
|
-
structuredContent:
|
|
26747
|
+
structuredContent: object({}).loose().optional(),
|
|
26117
26748
|
isError: boolean2().optional(),
|
|
26118
26749
|
_meta: record(string2(), unknown()).optional()
|
|
26119
26750
|
});
|
|
@@ -26125,7 +26756,7 @@ var SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
|
26125
26756
|
ToolUseContentSchema,
|
|
26126
26757
|
ToolResultContentSchema
|
|
26127
26758
|
]);
|
|
26128
|
-
var SamplingMessageSchema =
|
|
26759
|
+
var SamplingMessageSchema = object({
|
|
26129
26760
|
role: RoleSchema,
|
|
26130
26761
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
|
|
26131
26762
|
_meta: record(string2(), unknown()).optional()
|
|
@@ -26158,13 +26789,13 @@ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
26158
26789
|
role: RoleSchema,
|
|
26159
26790
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
26160
26791
|
});
|
|
26161
|
-
var BooleanSchemaSchema =
|
|
26792
|
+
var BooleanSchemaSchema = object({
|
|
26162
26793
|
type: literal("boolean"),
|
|
26163
26794
|
title: string2().optional(),
|
|
26164
26795
|
description: string2().optional(),
|
|
26165
26796
|
default: boolean2().optional()
|
|
26166
26797
|
});
|
|
26167
|
-
var StringSchemaSchema =
|
|
26798
|
+
var StringSchemaSchema = object({
|
|
26168
26799
|
type: literal("string"),
|
|
26169
26800
|
title: string2().optional(),
|
|
26170
26801
|
description: string2().optional(),
|
|
@@ -26173,7 +26804,7 @@ var StringSchemaSchema = object2({
|
|
|
26173
26804
|
format: _enum(["email", "uri", "date", "date-time"]).optional(),
|
|
26174
26805
|
default: string2().optional()
|
|
26175
26806
|
});
|
|
26176
|
-
var NumberSchemaSchema =
|
|
26807
|
+
var NumberSchemaSchema = object({
|
|
26177
26808
|
type: _enum(["number", "integer"]),
|
|
26178
26809
|
title: string2().optional(),
|
|
26179
26810
|
description: string2().optional(),
|
|
@@ -26181,24 +26812,24 @@ var NumberSchemaSchema = object2({
|
|
|
26181
26812
|
maximum: number2().optional(),
|
|
26182
26813
|
default: number2().optional()
|
|
26183
26814
|
});
|
|
26184
|
-
var UntitledSingleSelectEnumSchemaSchema =
|
|
26815
|
+
var UntitledSingleSelectEnumSchemaSchema = object({
|
|
26185
26816
|
type: literal("string"),
|
|
26186
26817
|
title: string2().optional(),
|
|
26187
26818
|
description: string2().optional(),
|
|
26188
26819
|
enum: array(string2()),
|
|
26189
26820
|
default: string2().optional()
|
|
26190
26821
|
});
|
|
26191
|
-
var TitledSingleSelectEnumSchemaSchema =
|
|
26822
|
+
var TitledSingleSelectEnumSchemaSchema = object({
|
|
26192
26823
|
type: literal("string"),
|
|
26193
26824
|
title: string2().optional(),
|
|
26194
26825
|
description: string2().optional(),
|
|
26195
|
-
oneOf: array(
|
|
26826
|
+
oneOf: array(object({
|
|
26196
26827
|
const: string2(),
|
|
26197
26828
|
title: string2()
|
|
26198
26829
|
})),
|
|
26199
26830
|
default: string2().optional()
|
|
26200
26831
|
});
|
|
26201
|
-
var LegacyTitledEnumSchemaSchema =
|
|
26832
|
+
var LegacyTitledEnumSchemaSchema = object({
|
|
26202
26833
|
type: literal("string"),
|
|
26203
26834
|
title: string2().optional(),
|
|
26204
26835
|
description: string2().optional(),
|
|
@@ -26207,26 +26838,26 @@ var LegacyTitledEnumSchemaSchema = object2({
|
|
|
26207
26838
|
default: string2().optional()
|
|
26208
26839
|
});
|
|
26209
26840
|
var SingleSelectEnumSchemaSchema = union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
|
|
26210
|
-
var UntitledMultiSelectEnumSchemaSchema =
|
|
26841
|
+
var UntitledMultiSelectEnumSchemaSchema = object({
|
|
26211
26842
|
type: literal("array"),
|
|
26212
26843
|
title: string2().optional(),
|
|
26213
26844
|
description: string2().optional(),
|
|
26214
26845
|
minItems: number2().optional(),
|
|
26215
26846
|
maxItems: number2().optional(),
|
|
26216
|
-
items:
|
|
26847
|
+
items: object({
|
|
26217
26848
|
type: literal("string"),
|
|
26218
26849
|
enum: array(string2())
|
|
26219
26850
|
}),
|
|
26220
26851
|
default: array(string2()).optional()
|
|
26221
26852
|
});
|
|
26222
|
-
var TitledMultiSelectEnumSchemaSchema =
|
|
26853
|
+
var TitledMultiSelectEnumSchemaSchema = object({
|
|
26223
26854
|
type: literal("array"),
|
|
26224
26855
|
title: string2().optional(),
|
|
26225
26856
|
description: string2().optional(),
|
|
26226
26857
|
minItems: number2().optional(),
|
|
26227
26858
|
maxItems: number2().optional(),
|
|
26228
|
-
items:
|
|
26229
|
-
anyOf: array(
|
|
26859
|
+
items: object({
|
|
26860
|
+
anyOf: array(object({
|
|
26230
26861
|
const: string2(),
|
|
26231
26862
|
title: string2()
|
|
26232
26863
|
}))
|
|
@@ -26239,7 +26870,7 @@ var PrimitiveSchemaDefinitionSchema = union([EnumSchemaSchema, BooleanSchemaSche
|
|
|
26239
26870
|
var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
26240
26871
|
mode: literal("form").optional(),
|
|
26241
26872
|
message: string2(),
|
|
26242
|
-
requestedSchema:
|
|
26873
|
+
requestedSchema: object({
|
|
26243
26874
|
type: literal("object"),
|
|
26244
26875
|
properties: record(string2(), PrimitiveSchemaDefinitionSchema),
|
|
26245
26876
|
required: array(string2()).optional()
|
|
@@ -26267,21 +26898,21 @@ var ElicitResultSchema = ResultSchema.extend({
|
|
|
26267
26898
|
action: _enum(["accept", "decline", "cancel"]),
|
|
26268
26899
|
content: preprocess((val) => val === null ? undefined : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
|
|
26269
26900
|
});
|
|
26270
|
-
var ResourceTemplateReferenceSchema =
|
|
26901
|
+
var ResourceTemplateReferenceSchema = object({
|
|
26271
26902
|
type: literal("ref/resource"),
|
|
26272
26903
|
uri: string2()
|
|
26273
26904
|
});
|
|
26274
|
-
var PromptReferenceSchema =
|
|
26905
|
+
var PromptReferenceSchema = object({
|
|
26275
26906
|
type: literal("ref/prompt"),
|
|
26276
26907
|
name: string2()
|
|
26277
26908
|
});
|
|
26278
26909
|
var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
26279
26910
|
ref: union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
26280
|
-
argument:
|
|
26911
|
+
argument: object({
|
|
26281
26912
|
name: string2(),
|
|
26282
26913
|
value: string2()
|
|
26283
26914
|
}),
|
|
26284
|
-
context:
|
|
26915
|
+
context: object({
|
|
26285
26916
|
arguments: record(string2(), string2()).optional()
|
|
26286
26917
|
}).optional()
|
|
26287
26918
|
});
|
|
@@ -26296,7 +26927,7 @@ var CompleteResultSchema = ResultSchema.extend({
|
|
|
26296
26927
|
hasMore: optional(boolean2())
|
|
26297
26928
|
})
|
|
26298
26929
|
});
|
|
26299
|
-
var RootSchema =
|
|
26930
|
+
var RootSchema = object({
|
|
26300
26931
|
uri: string2().startsWith("file://"),
|
|
26301
26932
|
name: string2().optional(),
|
|
26302
26933
|
_meta: record(string2(), unknown()).optional()
|
|
@@ -27863,278 +28494,453 @@ class StdioServerTransport {
|
|
|
27863
28494
|
}
|
|
27864
28495
|
|
|
27865
28496
|
// src/mcp/server.ts
|
|
27866
|
-
var
|
|
27867
|
-
import { readFileSync as
|
|
28497
|
+
var import_sdk2 = __toESM(require_dist2(), 1);
|
|
28498
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
27868
28499
|
|
|
27869
28500
|
// src/config.ts
|
|
27870
|
-
import {
|
|
27871
|
-
import { join as join3, basename, dirname, resolve, sep } from "path";
|
|
28501
|
+
import { join as join3, dirname as dirname2 } from "path";
|
|
27872
28502
|
import { fileURLToPath } from "url";
|
|
27873
|
-
import { existsSync as existsSync3,
|
|
27874
|
-
|
|
27875
|
-
//
|
|
27876
|
-
import {
|
|
27877
|
-
import {
|
|
27878
|
-
import { join } from "path";
|
|
27879
|
-
|
|
27880
|
-
|
|
28503
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
28504
|
+
|
|
28505
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/config.js
|
|
28506
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
28507
|
+
import { homedir } from "node:os";
|
|
28508
|
+
import { join as join2 } from "node:path";
|
|
28509
|
+
|
|
28510
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/legacy/v01.js
|
|
28511
|
+
var isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
28512
|
+
var str = (v) => typeof v === "string" && v ? v : undefined;
|
|
28513
|
+
function v01Reader(file, host) {
|
|
28514
|
+
const hosts = isObj(file.hosts) ? file.hosts : {};
|
|
28515
|
+
const v1 = typeof file.schemaVersion === "number" && file.schemaVersion >= 1;
|
|
28516
|
+
const pick = (b) => {
|
|
28517
|
+
const o = isObj(b) ? b : {};
|
|
28518
|
+
if (v1)
|
|
28519
|
+
return { apiKey: isObj(o.auth) ? str(o.auth.apiKey) : undefined, peerName: str(o.peerName), workspace: str(o.workspace), baseUrl: str(o.baseUrl) };
|
|
28520
|
+
return {
|
|
28521
|
+
apiKey: (isObj(o.auth) ? str(o.auth.apiKey) : undefined) ?? str(o.apiKey),
|
|
28522
|
+
peerName: str(o.peerName),
|
|
28523
|
+
workspace: str(o.workspace) ?? str(o.workspaceId),
|
|
28524
|
+
baseUrl: str(o.baseUrl) ?? str(o.environmentUrl) ?? (isObj(o.endpoint) ? str(o.endpoint.baseUrl) : undefined)
|
|
28525
|
+
};
|
|
28526
|
+
};
|
|
28527
|
+
const own = pick(hosts[host]);
|
|
28528
|
+
const top = pick(file);
|
|
28529
|
+
return {
|
|
28530
|
+
apiKey: own.apiKey ?? top.apiKey,
|
|
28531
|
+
peerName: own.peerName ?? top.peerName,
|
|
28532
|
+
workspace: own.workspace ?? top.workspace,
|
|
28533
|
+
aiPeer: isObj(hosts[host]) ? str(hosts[host].aiPeer) : undefined,
|
|
28534
|
+
baseUrl: own.baseUrl ?? top.baseUrl
|
|
28535
|
+
};
|
|
28536
|
+
}
|
|
28537
|
+
|
|
28538
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/oauth.js
|
|
28539
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
28540
|
+
import { dirname, join } from "node:path";
|
|
28541
|
+
var OAUTH_TOKEN_URL = "https://api.honcho.dev/oauth/token";
|
|
28542
|
+
var OAUTH_SCOPE = "write";
|
|
28543
|
+
var REQUEST_TIMEOUT_MS = 1e4;
|
|
28544
|
+
var REFRESH_SKEW_S = 60;
|
|
28545
|
+
var LOCK_STALE_MS = REQUEST_TIMEOUT_MS + 5000;
|
|
28546
|
+
var LOCK_WAIT_MS = LOCK_STALE_MS + 5000;
|
|
28547
|
+
var PERMANENT_ERRORS = new Set(["invalid_grant", "invalid_client", "unauthorized_client"]);
|
|
28548
|
+
|
|
28549
|
+
class OAuthError extends Error {
|
|
28550
|
+
code;
|
|
28551
|
+
constructor(code, description) {
|
|
28552
|
+
super(description || code);
|
|
28553
|
+
this.code = code;
|
|
28554
|
+
this.name = "OAuthError";
|
|
28555
|
+
}
|
|
28556
|
+
}
|
|
28557
|
+
function isCloud(baseUrl) {
|
|
28558
|
+
return normalizeBaseUrl(baseUrl || DEFAULT_BASE_URL) === DEFAULT_BASE_URL;
|
|
27881
28559
|
}
|
|
27882
|
-
function
|
|
28560
|
+
function accessValid(t, skewS = REFRESH_SKEW_S, nowS = Date.now() / 1000) {
|
|
28561
|
+
return !!t?.accessToken && nowS < t.accessExpiresAt - skewS;
|
|
28562
|
+
}
|
|
28563
|
+
async function post(url, form, t) {
|
|
28564
|
+
const f = t?.fetch ?? fetch;
|
|
28565
|
+
let res;
|
|
28566
|
+
try {
|
|
28567
|
+
res = await f(url, {
|
|
28568
|
+
method: "POST",
|
|
28569
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
|
|
28570
|
+
body: new URLSearchParams(form).toString(),
|
|
28571
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
28572
|
+
});
|
|
28573
|
+
} catch (e) {
|
|
28574
|
+
throw new OAuthError("connection_error", `could not reach ${url}: ${e.message}`);
|
|
28575
|
+
}
|
|
28576
|
+
let body = null;
|
|
27883
28577
|
try {
|
|
27884
|
-
|
|
28578
|
+
body = await res.json();
|
|
27885
28579
|
} catch {
|
|
27886
|
-
|
|
28580
|
+
body = null;
|
|
27887
28581
|
}
|
|
28582
|
+
return { status: res.status, body };
|
|
27888
28583
|
}
|
|
27889
|
-
function
|
|
27890
|
-
|
|
27891
|
-
|
|
28584
|
+
function errorOf(r) {
|
|
28585
|
+
const b = r.body;
|
|
28586
|
+
if (b && typeof b === "object" && typeof b.error === "string")
|
|
28587
|
+
return new OAuthError(b.error, b.error_description);
|
|
28588
|
+
return new OAuthError("invalid_response");
|
|
28589
|
+
}
|
|
28590
|
+
function tokensFrom(body, clientId, prev) {
|
|
28591
|
+
if (!body || typeof body.access_token !== "string" || !Number.isFinite(Number(body.expires_in))) {
|
|
28592
|
+
throw new OAuthError("invalid_response", "malformed token response");
|
|
27892
28593
|
}
|
|
27893
|
-
const branch = gitCommand(cwd, "rev-parse --abbrev-ref HEAD") || "unknown";
|
|
27894
|
-
const commit = gitCommand(cwd, "rev-parse --short HEAD") || "unknown";
|
|
27895
|
-
const commitMessage = gitCommand(cwd, "log -1 --format=%s") || "";
|
|
27896
|
-
const statusOutput = gitCommand(cwd, "status --porcelain") || "";
|
|
27897
|
-
const isDirty = statusOutput.length > 0;
|
|
27898
|
-
const dirtyFiles = isDirty ? statusOutput.split(`
|
|
27899
|
-
`).filter((line) => line.trim()).map((line) => line.slice(3).trim()).slice(0, 20) : [];
|
|
27900
28594
|
return {
|
|
27901
|
-
|
|
27902
|
-
|
|
27903
|
-
|
|
27904
|
-
|
|
27905
|
-
|
|
27906
|
-
timestamp: new Date().toISOString()
|
|
28595
|
+
accessToken: body.access_token,
|
|
28596
|
+
refreshToken: body.refresh_token || prev?.refreshToken || "",
|
|
28597
|
+
accessExpiresAt: Math.floor(Date.now() / 1000) + Number(body.expires_in),
|
|
28598
|
+
clientId,
|
|
28599
|
+
scope: body.scope || prev?.scope || OAUTH_SCOPE
|
|
27907
28600
|
};
|
|
27908
28601
|
}
|
|
27909
|
-
|
|
27910
|
-
|
|
27911
|
-
|
|
27912
|
-
|
|
27913
|
-
|
|
27914
|
-
var CACHE_DIR = join2(homedir(), ".honcho");
|
|
27915
|
-
var ID_CACHE_FILE = join2(CACHE_DIR, "cache.json");
|
|
27916
|
-
var CONTEXT_CACHE_FILE = join2(CACHE_DIR, "context-cache.json");
|
|
27917
|
-
function ensureCacheDir() {
|
|
27918
|
-
if (!existsSync2(CACHE_DIR)) {
|
|
27919
|
-
mkdirSync(CACHE_DIR, { recursive: true });
|
|
27920
|
-
}
|
|
28602
|
+
async function refreshAccessToken(prev, opts = {}) {
|
|
28603
|
+
const r = await post(opts.tokenUrl ?? OAUTH_TOKEN_URL, { grant_type: "refresh_token", refresh_token: prev.refreshToken, client_id: prev.clientId }, opts);
|
|
28604
|
+
if (r.status !== 200)
|
|
28605
|
+
throw errorOf(r);
|
|
28606
|
+
return tokensFrom(r.body, prev.clientId, prev);
|
|
27921
28607
|
}
|
|
27922
|
-
function
|
|
27923
|
-
|
|
27924
|
-
|
|
27925
|
-
|
|
27926
|
-
|
|
27927
|
-
|
|
27928
|
-
|
|
27929
|
-
|
|
28608
|
+
function isObj2(v) {
|
|
28609
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
28610
|
+
}
|
|
28611
|
+
function asTokens(v) {
|
|
28612
|
+
if (!isObj2(v) || typeof v.accessToken !== "string" || !v.accessToken)
|
|
28613
|
+
return;
|
|
28614
|
+
return {
|
|
28615
|
+
accessToken: v.accessToken,
|
|
28616
|
+
refreshToken: typeof v.refreshToken === "string" ? v.refreshToken : "",
|
|
28617
|
+
accessExpiresAt: Number(v.accessExpiresAt) || 0,
|
|
28618
|
+
clientId: typeof v.clientId === "string" ? v.clientId : "",
|
|
28619
|
+
scope: typeof v.scope === "string" ? v.scope : ""
|
|
28620
|
+
};
|
|
28621
|
+
}
|
|
28622
|
+
function readFile(path) {
|
|
28623
|
+
if (!existsSync(path))
|
|
27930
28624
|
return {};
|
|
27931
|
-
|
|
28625
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
28626
|
+
return isObj2(parsed) ? parsed : {};
|
|
27932
28627
|
}
|
|
27933
|
-
function
|
|
27934
|
-
|
|
27935
|
-
writeFileSync(ID_CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
28628
|
+
function readGrant(file, host, legacy) {
|
|
28629
|
+
return asTokens(effectiveBlock(file, host, legacy).oauth);
|
|
27936
28630
|
}
|
|
27937
|
-
function
|
|
27938
|
-
|
|
27939
|
-
|
|
27940
|
-
|
|
27941
|
-
|
|
27942
|
-
|
|
28631
|
+
function holderAlive(token, ageMs) {
|
|
28632
|
+
if (token === "")
|
|
28633
|
+
return ageMs < 1000;
|
|
28634
|
+
const pid = Number(token.split(":")[0]);
|
|
28635
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
28636
|
+
return true;
|
|
28637
|
+
try {
|
|
28638
|
+
process.kill(pid, 0);
|
|
28639
|
+
return true;
|
|
28640
|
+
} catch (e) {
|
|
28641
|
+
return e.code === "EPERM";
|
|
28642
|
+
}
|
|
27943
28643
|
}
|
|
27944
|
-
function
|
|
27945
|
-
const
|
|
27946
|
-
|
|
27947
|
-
|
|
27948
|
-
let
|
|
27949
|
-
|
|
27950
|
-
|
|
27951
|
-
|
|
28644
|
+
async function withConfigLock(path, fn) {
|
|
28645
|
+
const lock = `${path}.lock`;
|
|
28646
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
28647
|
+
const start = Date.now();
|
|
28648
|
+
let fd;
|
|
28649
|
+
while (fd === undefined) {
|
|
28650
|
+
try {
|
|
28651
|
+
fd = openSync(lock, "wx", 384);
|
|
28652
|
+
} catch (e) {
|
|
28653
|
+
if (e.code !== "EEXIST")
|
|
28654
|
+
throw e;
|
|
28655
|
+
try {
|
|
28656
|
+
const age = Date.now() - statSync(lock).mtimeMs;
|
|
28657
|
+
if (age > LOCK_STALE_MS || !holderAlive(readFileSync(lock, "utf-8"), age))
|
|
28658
|
+
unlinkSync(lock);
|
|
28659
|
+
} catch {}
|
|
28660
|
+
if (Date.now() - start > LOCK_WAIT_MS)
|
|
28661
|
+
throw new Error(`timed out waiting for ${lock}`);
|
|
28662
|
+
await new Promise((r) => setTimeout(r, 50 + Math.random() * 50));
|
|
27952
28663
|
}
|
|
27953
28664
|
}
|
|
27954
|
-
|
|
28665
|
+
const token = `${process.pid}:${Math.random().toString(36).slice(2)}`;
|
|
28666
|
+
try {
|
|
28667
|
+
writeFileSync(fd, token);
|
|
28668
|
+
return await fn();
|
|
28669
|
+
} finally {
|
|
28670
|
+
closeSync(fd);
|
|
28671
|
+
try {
|
|
28672
|
+
if (readFileSync(lock, "utf-8") === token)
|
|
28673
|
+
unlinkSync(lock);
|
|
28674
|
+
} catch {}
|
|
28675
|
+
}
|
|
27955
28676
|
}
|
|
27956
|
-
function
|
|
27957
|
-
const
|
|
27958
|
-
|
|
28677
|
+
function writeFileAtomic(path, data) {
|
|
28678
|
+
const tmp = join(dirname(path), `.${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2)}.tmp`);
|
|
28679
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2) + `
|
|
28680
|
+
`, { mode: 384 });
|
|
28681
|
+
renameSync(tmp, path);
|
|
27959
28682
|
}
|
|
27960
|
-
function
|
|
27961
|
-
|
|
27962
|
-
|
|
27963
|
-
|
|
28683
|
+
async function updateConfigFile(path, mutate) {
|
|
28684
|
+
await withConfigLock(path, async () => {
|
|
28685
|
+
const file = readFile(path);
|
|
28686
|
+
mutate(file);
|
|
28687
|
+
writeFileAtomic(path, file);
|
|
28688
|
+
});
|
|
27964
28689
|
}
|
|
27965
|
-
function
|
|
27966
|
-
const
|
|
27967
|
-
|
|
28690
|
+
function setGrant(file, host, tokens) {
|
|
28691
|
+
const block = hostBlock(file, host);
|
|
28692
|
+
if (tokens)
|
|
28693
|
+
block.oauth = tokens;
|
|
28694
|
+
else
|
|
28695
|
+
delete block.oauth;
|
|
27968
28696
|
}
|
|
27969
|
-
|
|
27970
|
-
"
|
|
27971
|
-
|
|
27972
|
-
|
|
27973
|
-
|
|
27974
|
-
|
|
27975
|
-
|
|
27976
|
-
|
|
27977
|
-
|
|
27978
|
-
|
|
28697
|
+
function serverOf(block, baseUrl, env) {
|
|
28698
|
+
return baseUrl ?? (env.HONCHO_BASE_URL || undefined) ?? (typeof block.baseUrl === "string" && block.baseUrl ? block.baseUrl : undefined);
|
|
28699
|
+
}
|
|
28700
|
+
function pickCredential(file, opts) {
|
|
28701
|
+
const env = opts.env ?? process.env;
|
|
28702
|
+
if (env.HONCHO_API_KEY)
|
|
28703
|
+
return { token: env.HONCHO_API_KEY, source: "env" };
|
|
28704
|
+
const block = effectiveBlock(file, opts.host, opts.legacy);
|
|
28705
|
+
const g = isCloud(serverOf(block, opts.baseUrl, env)) ? asTokens(block.oauth) : undefined;
|
|
28706
|
+
if (g)
|
|
28707
|
+
return { token: g.accessToken, source: "oauth", expiresAt: g.accessExpiresAt, ...accessValid(g, 0) ? {} : { expired: true } };
|
|
28708
|
+
return typeof block.apiKey === "string" && block.apiKey ? { token: block.apiKey, source: "apiKey" } : null;
|
|
28709
|
+
}
|
|
28710
|
+
async function ensureFreshCredential(opts) {
|
|
28711
|
+
const env = opts.env ?? process.env;
|
|
28712
|
+
if (env.HONCHO_API_KEY)
|
|
28713
|
+
return { token: env.HONCHO_API_KEY, source: "env" };
|
|
28714
|
+
let file;
|
|
27979
28715
|
try {
|
|
27980
|
-
|
|
27981
|
-
let cleaned = false;
|
|
27982
|
-
for (const key of Object.keys(raw)) {
|
|
27983
|
-
if (!CONTEXT_CACHE_KNOWN_KEYS.has(key)) {
|
|
27984
|
-
delete raw[key];
|
|
27985
|
-
cleaned = true;
|
|
27986
|
-
}
|
|
27987
|
-
}
|
|
27988
|
-
if (cleaned) {
|
|
27989
|
-
writeFileSync(CONTEXT_CACHE_FILE, JSON.stringify(raw, null, 2));
|
|
27990
|
-
}
|
|
27991
|
-
return raw;
|
|
28716
|
+
file = readFile(opts.path);
|
|
27992
28717
|
} catch {
|
|
27993
|
-
|
|
28718
|
+
file = {};
|
|
28719
|
+
}
|
|
28720
|
+
const block = effectiveBlock(file, opts.host, opts.legacy);
|
|
28721
|
+
const g = isCloud(serverOf(block, opts.baseUrl, env)) ? asTokens(block.oauth) : undefined;
|
|
28722
|
+
if (!g || accessValid(g) || !g.refreshToken)
|
|
28723
|
+
return pickCredential(file, opts);
|
|
28724
|
+
let error;
|
|
28725
|
+
try {
|
|
28726
|
+
await withConfigLock(opts.path, async () => {
|
|
28727
|
+
const current = readGrant(readFile(opts.path), opts.host, opts.legacy);
|
|
28728
|
+
if (!current || accessValid(current))
|
|
28729
|
+
return;
|
|
28730
|
+
const next = await refreshAccessToken(current, opts);
|
|
28731
|
+
const latest = readFile(opts.path);
|
|
28732
|
+
setGrant(latest, opts.host, next);
|
|
28733
|
+
writeFileAtomic(opts.path, latest);
|
|
28734
|
+
});
|
|
28735
|
+
} catch (e) {
|
|
28736
|
+
error = e instanceof OAuthError ? e.code : e.message;
|
|
27994
28737
|
}
|
|
28738
|
+
try {
|
|
28739
|
+
file = readFile(opts.path);
|
|
28740
|
+
} catch {}
|
|
28741
|
+
const cred = pickCredential(file, opts);
|
|
28742
|
+
if (cred && error) {
|
|
28743
|
+
cred.error = error;
|
|
28744
|
+
if (PERMANENT_ERRORS.has(error))
|
|
28745
|
+
cred.reauthRequired = true;
|
|
28746
|
+
}
|
|
28747
|
+
return cred;
|
|
28748
|
+
}
|
|
28749
|
+
|
|
28750
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/config.js
|
|
28751
|
+
var DEFAULT_BASE_URL = "https://api.honcho.dev";
|
|
28752
|
+
var CONFIG_SCHEMA_VERSION = 2;
|
|
28753
|
+
function isObj3(v) {
|
|
28754
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
27995
28755
|
}
|
|
27996
|
-
function
|
|
27997
|
-
|
|
27998
|
-
writeFileSync(CONTEXT_CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
28756
|
+
function str2(v) {
|
|
28757
|
+
return typeof v === "string" && v ? v : undefined;
|
|
27999
28758
|
}
|
|
28000
|
-
function
|
|
28001
|
-
|
|
28002
|
-
|
|
28003
|
-
|
|
28004
|
-
|
|
28759
|
+
function normalizeBaseUrl(input) {
|
|
28760
|
+
let s = input.trim();
|
|
28761
|
+
if (!s)
|
|
28762
|
+
return s;
|
|
28763
|
+
if (!s.startsWith("http://") && !s.startsWith("https://")) {
|
|
28764
|
+
const host = s.split("/")[0].split(":")[0].toLowerCase();
|
|
28765
|
+
const local = host === "localhost" || host === "127.0.0.1" || host === "::1";
|
|
28766
|
+
s = `${local ? "http" : "https"}://${s}`;
|
|
28767
|
+
}
|
|
28768
|
+
try {
|
|
28769
|
+
const u = new URL(s);
|
|
28770
|
+
u.hostname = u.hostname.toLowerCase();
|
|
28771
|
+
const path = u.pathname === "/" ? "" : u.pathname.replace(/\/+$/, "");
|
|
28772
|
+
return `${u.protocol}//${u.host}${path}`;
|
|
28773
|
+
} catch {
|
|
28774
|
+
return s;
|
|
28775
|
+
}
|
|
28005
28776
|
}
|
|
28006
|
-
function
|
|
28007
|
-
const
|
|
28008
|
-
|
|
28777
|
+
function resolveConfig(file, opts) {
|
|
28778
|
+
const env = opts.env ?? process.env;
|
|
28779
|
+
const { host } = opts;
|
|
28780
|
+
const block = effectiveBlock(file, host, opts.legacy);
|
|
28781
|
+
return {
|
|
28782
|
+
host,
|
|
28783
|
+
peerName: str2(env.HONCHO_PEER_NAME) ?? str2(block.peerName) ?? str2(env.USER) ?? str2(env.USERNAME) ?? "user",
|
|
28784
|
+
workspace: str2(env.HONCHO_WORKSPACE) ?? str2(block.workspace) ?? opts.defaults?.workspace ?? host,
|
|
28785
|
+
aiPeer: str2(env.HONCHO_AI_PEER) ?? str2(block.aiPeer) ?? opts.defaults?.aiPeer ?? host,
|
|
28786
|
+
baseUrl: normalizeBaseUrl(str2(env.HONCHO_BASE_URL) ?? str2(block.baseUrl) ?? DEFAULT_BASE_URL),
|
|
28787
|
+
warnings: checkConfig(file).map((i) => i.message)
|
|
28788
|
+
};
|
|
28009
28789
|
}
|
|
28010
|
-
function
|
|
28011
|
-
|
|
28012
|
-
|
|
28013
|
-
|
|
28790
|
+
function configPath(env = process.env) {
|
|
28791
|
+
if (env.HONCHO_CONFIG_PATH)
|
|
28792
|
+
return env.HONCHO_CONFIG_PATH;
|
|
28793
|
+
const home = env.HOME || env.USERPROFILE || homedir();
|
|
28794
|
+
return join2(home, ".honcho", "config.json");
|
|
28014
28795
|
}
|
|
28015
|
-
|
|
28016
|
-
|
|
28017
|
-
|
|
28018
|
-
if (!existsSync2(GIT_STATE_FILE)) {
|
|
28796
|
+
function readConfigFile(env = process.env) {
|
|
28797
|
+
const path = configPath(env);
|
|
28798
|
+
if (!existsSync2(path))
|
|
28019
28799
|
return {};
|
|
28020
|
-
}
|
|
28021
28800
|
try {
|
|
28022
|
-
|
|
28801
|
+
const parsed = JSON.parse(readFileSync2(path, "utf-8"));
|
|
28802
|
+
return isObj3(parsed) ? parsed : {};
|
|
28023
28803
|
} catch {
|
|
28024
28804
|
return {};
|
|
28025
28805
|
}
|
|
28026
28806
|
}
|
|
28027
|
-
function
|
|
28028
|
-
|
|
28029
|
-
|
|
28807
|
+
async function saveHost(path, host, patch, legacy) {
|
|
28808
|
+
await updateConfigFile(path, (file) => {
|
|
28809
|
+
if (isNewer(file))
|
|
28810
|
+
throw new Error(`${path} was written by a newer Honcho plugin; update this one.`);
|
|
28811
|
+
const block = writeBlock(file, host, hostMigration(file, host, [], legacy));
|
|
28812
|
+
if ("baseUrl" in patch && !("apiKey" in patch) && !sameServer(patch.baseUrl, str2(block.baseUrl)))
|
|
28813
|
+
delete block.apiKey;
|
|
28814
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
28815
|
+
if (v === undefined)
|
|
28816
|
+
delete block[k];
|
|
28817
|
+
else
|
|
28818
|
+
block[k] = v;
|
|
28819
|
+
}
|
|
28820
|
+
block.schemaVersion = CONFIG_SCHEMA_VERSION;
|
|
28821
|
+
});
|
|
28030
28822
|
}
|
|
28031
|
-
|
|
28032
|
-
|
|
28033
|
-
return
|
|
28823
|
+
var MOVABLE = ["apiKey", "peerName", "workspace", "aiPeer", "baseUrl"];
|
|
28824
|
+
function isNewer(file) {
|
|
28825
|
+
return isObj3(file) && typeof file.schemaVersion === "number" && file.schemaVersion > CONFIG_SCHEMA_VERSION;
|
|
28034
28826
|
}
|
|
28035
|
-
function
|
|
28036
|
-
|
|
28037
|
-
cache[cwd] = state;
|
|
28038
|
-
saveGitStateCache(cache);
|
|
28827
|
+
function isMigrated(block) {
|
|
28828
|
+
return isObj3(block) && typeof block.schemaVersion === "number" && block.schemaVersion >= CONFIG_SCHEMA_VERSION;
|
|
28039
28829
|
}
|
|
28040
|
-
function
|
|
28041
|
-
|
|
28042
|
-
if (!previous) {
|
|
28043
|
-
changes.push({
|
|
28044
|
-
type: "initial",
|
|
28045
|
-
description: `Session started on branch '${current.branch}' at ${current.commit}`
|
|
28046
|
-
});
|
|
28047
|
-
return changes;
|
|
28048
|
-
}
|
|
28049
|
-
if (previous.branch !== current.branch) {
|
|
28050
|
-
changes.push({
|
|
28051
|
-
type: "branch_switch",
|
|
28052
|
-
description: `Branch switched from '${previous.branch}' to '${current.branch}'`,
|
|
28053
|
-
from: previous.branch,
|
|
28054
|
-
to: current.branch
|
|
28055
|
-
});
|
|
28056
|
-
}
|
|
28057
|
-
if (previous.commit !== current.commit) {
|
|
28058
|
-
changes.push({
|
|
28059
|
-
type: "new_commits",
|
|
28060
|
-
description: `New commit: ${current.commit} - ${current.commitMessage}`,
|
|
28061
|
-
from: previous.commit,
|
|
28062
|
-
to: current.commit
|
|
28063
|
-
});
|
|
28064
|
-
}
|
|
28065
|
-
if (!previous.isDirty && current.isDirty) {
|
|
28066
|
-
changes.push({
|
|
28067
|
-
type: "files_changed",
|
|
28068
|
-
description: `Uncommitted changes detected: ${current.dirtyFiles.slice(0, 5).join(", ")}${current.dirtyFiles.length > 5 ? "..." : ""}`
|
|
28069
|
-
});
|
|
28070
|
-
}
|
|
28071
|
-
return changes;
|
|
28830
|
+
function sameServer(a, b) {
|
|
28831
|
+
return normalizeBaseUrl(a ?? DEFAULT_BASE_URL) === normalizeBaseUrl(b ?? DEFAULT_BASE_URL);
|
|
28072
28832
|
}
|
|
28073
|
-
var
|
|
28074
|
-
function
|
|
28075
|
-
|
|
28076
|
-
|
|
28077
|
-
|
|
28078
|
-
|
|
28079
|
-
|
|
28080
|
-
|
|
28081
|
-
|
|
28082
|
-
|
|
28083
|
-
|
|
28084
|
-
}
|
|
28085
|
-
|
|
28086
|
-
|
|
28087
|
-
|
|
28088
|
-
|
|
28089
|
-
|
|
28090
|
-
|
|
28091
|
-
|
|
28092
|
-
|
|
28093
|
-
|
|
28094
|
-
|
|
28833
|
+
var LEGACY_HOST_KEYS = ["auth", "endpoint", "environmentUrl", "workspaceId"];
|
|
28834
|
+
function isGrant(v) {
|
|
28835
|
+
return isObj3(v) && typeof v.accessToken === "string" && v.accessToken !== "";
|
|
28836
|
+
}
|
|
28837
|
+
function legacyGrantOf(b) {
|
|
28838
|
+
return !isGrant(b.oauth) && isObj3(b.auth) && isObj3(b.auth.oauth) ? b.auth.oauth : undefined;
|
|
28839
|
+
}
|
|
28840
|
+
function checkConfig(file) {
|
|
28841
|
+
if (!isObj3(file))
|
|
28842
|
+
return [];
|
|
28843
|
+
if (isNewer(file)) {
|
|
28844
|
+
return [{ path: "schemaVersion", message: `This file is schema version ${file.schemaVersion}, newer than this plugin understands; update the plugin.` }];
|
|
28845
|
+
}
|
|
28846
|
+
const issues = [];
|
|
28847
|
+
const hosts = isObj3(file.hosts) ? file.hosts : {};
|
|
28848
|
+
const byWorkspace = new Map;
|
|
28849
|
+
for (const h of Object.keys(hosts).filter((k) => isObj3(hosts[k]))) {
|
|
28850
|
+
const block = hosts[h];
|
|
28851
|
+
const peer = str2(block.peerName);
|
|
28852
|
+
if (!peer)
|
|
28853
|
+
continue;
|
|
28854
|
+
const ws = str2(block.workspace) ?? h;
|
|
28855
|
+
const peers = byWorkspace.get(ws) ?? new Map;
|
|
28856
|
+
peers.set(peer, [...peers.get(peer) ?? [], h]);
|
|
28857
|
+
byWorkspace.set(ws, peers);
|
|
28095
28858
|
}
|
|
28096
|
-
|
|
28097
|
-
|
|
28859
|
+
for (const [ws, peers] of byWorkspace) {
|
|
28860
|
+
if (peers.size < 2)
|
|
28861
|
+
continue;
|
|
28862
|
+
const list = [...peers].map(([p, hs]) => `${hs.join(", ")}: "${p}"`).join("; ");
|
|
28863
|
+
issues.push({ path: "hosts", message: `Hosts in workspace "${ws}" use different peerNames (${list}), so the user is split across peers.` });
|
|
28098
28864
|
}
|
|
28099
|
-
return
|
|
28865
|
+
return issues;
|
|
28100
28866
|
}
|
|
28101
|
-
|
|
28102
|
-
|
|
28103
|
-
|
|
28104
|
-
|
|
28105
|
-
|
|
28106
|
-
|
|
28107
|
-
|
|
28108
|
-
|
|
28109
|
-
|
|
28110
|
-
|
|
28111
|
-
|
|
28112
|
-
|
|
28113
|
-
|
|
28114
|
-
|
|
28867
|
+
function hostMigration(file, host, deadKeys = [], legacy = v01Reader) {
|
|
28868
|
+
if (isNewer(file))
|
|
28869
|
+
return { set: {}, remove: [] };
|
|
28870
|
+
const f = isObj3(file) ? file : {};
|
|
28871
|
+
const hosts = isObj3(f.hosts) ? f.hosts : {};
|
|
28872
|
+
const block = isObj3(hosts[host]) ? hosts[host] : {};
|
|
28873
|
+
const set = {};
|
|
28874
|
+
const drop = [];
|
|
28875
|
+
const grant = legacyGrantOf(block);
|
|
28876
|
+
if (grant)
|
|
28877
|
+
set.oauth = grant;
|
|
28878
|
+
if (!isMigrated(block)) {
|
|
28879
|
+
const old = { ...legacy(f, host) };
|
|
28880
|
+
const signedIn = isGrant(block.oauth) || grant !== undefined;
|
|
28881
|
+
if (old.baseUrl && sameServer(old.baseUrl, undefined))
|
|
28882
|
+
old.baseUrl = undefined;
|
|
28883
|
+
for (const key of MOVABLE) {
|
|
28884
|
+
if (signedIn && (key === "apiKey" || key === "baseUrl"))
|
|
28885
|
+
continue;
|
|
28886
|
+
if (old[key] !== undefined && block[key] !== old[key])
|
|
28887
|
+
set[key] = old[key];
|
|
28888
|
+
else if (old[key] === undefined && block[key] !== undefined)
|
|
28889
|
+
drop.push(key);
|
|
28115
28890
|
}
|
|
28891
|
+
set.schemaVersion = CONFIG_SCHEMA_VERSION;
|
|
28116
28892
|
}
|
|
28893
|
+
const remove = [...drop, ...LEGACY_HOST_KEYS, ...deadKeys].filter((k) => (k in block) && !(k in set));
|
|
28894
|
+
return { set, remove };
|
|
28117
28895
|
}
|
|
28118
|
-
function
|
|
28119
|
-
|
|
28120
|
-
writeFileSync(ID_CACHE_FILE, "{}");
|
|
28896
|
+
function effectiveBlock(file, host, legacy) {
|
|
28897
|
+
return writeBlock(structuredClone(isObj3(file) ? file : {}), host, hostMigration(file, host, [], legacy));
|
|
28121
28898
|
}
|
|
28122
|
-
function
|
|
28123
|
-
|
|
28124
|
-
|
|
28125
|
-
|
|
28899
|
+
function hostBlock(file, host) {
|
|
28900
|
+
if (host === "__proto__" || host === "constructor" || host === "prototype")
|
|
28901
|
+
throw new Error(`invalid host name: ${host}`);
|
|
28902
|
+
if (!isObj3(file.hosts))
|
|
28903
|
+
file.hosts = {};
|
|
28904
|
+
return isObj3(file.hosts[host]) ? file.hosts[host] : file.hosts[host] = {};
|
|
28126
28905
|
}
|
|
28127
|
-
function
|
|
28128
|
-
const
|
|
28129
|
-
|
|
28130
|
-
|
|
28906
|
+
function writeBlock(file, host, { set, remove }) {
|
|
28907
|
+
const block = hostBlock(file, host);
|
|
28908
|
+
Object.assign(block, set);
|
|
28909
|
+
for (const k of remove)
|
|
28910
|
+
delete block[k];
|
|
28911
|
+
return block;
|
|
28912
|
+
}
|
|
28913
|
+
async function migrateHost(path, host, deadKeys = [], legacy) {
|
|
28914
|
+
const peek = hostMigration(readConfigFile({ HONCHO_CONFIG_PATH: path }), host, deadKeys, legacy);
|
|
28915
|
+
if (!Object.keys(peek.set).length && !peek.remove.length)
|
|
28916
|
+
return [];
|
|
28917
|
+
let changed = [];
|
|
28918
|
+
await updateConfigFile(path, (file) => {
|
|
28919
|
+
const m = hostMigration(file, host, deadKeys, legacy);
|
|
28920
|
+
changed = [...Object.keys(m.set).filter((k) => k !== "schemaVersion"), ...m.remove.map((k) => `-${k}`)];
|
|
28921
|
+
if (Object.keys(m.set).length || m.remove.length)
|
|
28922
|
+
writeBlock(file, host, m);
|
|
28923
|
+
});
|
|
28924
|
+
return changed;
|
|
28131
28925
|
}
|
|
28132
|
-
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
28926
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/legacy/claude-honcho.js
|
|
28927
|
+
var isObj4 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
28928
|
+
var str3 = (v) => typeof v === "string" && v ? v : undefined;
|
|
28929
|
+
function claudeHonchoReader(file, host) {
|
|
28930
|
+
const hosts = isObj4(file.hosts) ? file.hosts : {};
|
|
28931
|
+
const found = hosts[host] ?? hosts[host.replace(/_/g, "-")] ?? hosts[host.replace(/-/g, "_")];
|
|
28932
|
+
const block = isObj4(found) ? found : undefined;
|
|
28933
|
+
const endpoint = block?.endpoint ?? file.endpoint;
|
|
28934
|
+
const override = file.globalOverride === true;
|
|
28935
|
+
return {
|
|
28936
|
+
apiKey: str3(block?.apiKey) ?? str3(file.apiKey),
|
|
28937
|
+
baseUrl: str3(endpoint?.baseUrl)?.replace(/\/v3\/?$/, "") ?? (endpoint?.environment === "local" ? "http://localhost:8000" : undefined),
|
|
28938
|
+
peerName: str3(file.peerName),
|
|
28939
|
+
workspace: str3(override || !block ? file.workspace : block.workspace),
|
|
28940
|
+
aiPeer: str3(override ? file.aiPeer ?? block?.aiPeer : block ? block.aiPeer : file[host === "cursor" ? "cursorPeer" : "claudePeer"])
|
|
28941
|
+
};
|
|
28136
28942
|
}
|
|
28137
|
-
// node_modules/@honcho-ai/harness-plugin-core/
|
|
28943
|
+
// node_modules/@honcho-ai/harness-plugin-core/dist/telemetry.js
|
|
28138
28944
|
var HEADER_HOST = "X-Honcho-Host";
|
|
28139
28945
|
var HEADER_PLUGIN = "X-Honcho-Plugin";
|
|
28140
28946
|
var HEADER_AGENT_MODEL = "X-Honcho-Agent-Model";
|
|
@@ -28183,31 +28989,10 @@ function telemetryHeaders(id = {}, extra) {
|
|
|
28183
28989
|
return headers;
|
|
28184
28990
|
}
|
|
28185
28991
|
// src/config.ts
|
|
28992
|
+
var LEGACY = claudeHonchoReader;
|
|
28186
28993
|
function sanitizeForSessionName(s) {
|
|
28187
28994
|
return s.toLowerCase().replace(/[^a-z0-9-_]/g, "-");
|
|
28188
28995
|
}
|
|
28189
|
-
var SESSION_START_COMPONENTS = ["directives", "summary", "peerCard", "peerRepresentation", "briefing"];
|
|
28190
|
-
var PER_TURN_COMPONENTS = ["userContext", "assistantContext", "sessionContext", "dialectic"];
|
|
28191
|
-
function normalizePerTurn(components) {
|
|
28192
|
-
return components.map((c) => c === "context" ? "userContext" : c);
|
|
28193
|
-
}
|
|
28194
|
-
var DEFAULT_INJECTION = {
|
|
28195
|
-
sessionStart: ["directives", "summary", "peerCard"],
|
|
28196
|
-
perTurn: ["userContext"],
|
|
28197
|
-
showContents: [],
|
|
28198
|
-
searchTopK: 10,
|
|
28199
|
-
maxConclusions: 15,
|
|
28200
|
-
searchMaxDistance: 0.6,
|
|
28201
|
-
searchQuerySource: "prompt",
|
|
28202
|
-
sessionContextTokens: 1500,
|
|
28203
|
-
dialecticTemplate: "Return a compact, factual list of anything from the user's history — preferences, prior decisions, relevant past work — that would help with the following. Write in the third person as background notes; do not address the user, ask questions, or offer next steps. If nothing relevant exists, say so in one line. Relevant to: %{user_query}",
|
|
28204
|
-
dialecticReasoning: "medium"
|
|
28205
|
-
};
|
|
28206
|
-
var REASONING_LEVELS = ["minimal", "low", "medium", "high", "max"];
|
|
28207
|
-
var HONCHO_BASE_URLS = {
|
|
28208
|
-
production: "https://api.honcho.dev/v3",
|
|
28209
|
-
local: "http://localhost:8000/v3"
|
|
28210
|
-
};
|
|
28211
28996
|
var _detectedHost = null;
|
|
28212
28997
|
function setDetectedHost(host) {
|
|
28213
28998
|
_detectedHost = host;
|
|
@@ -28235,13 +29020,6 @@ var DEFAULT_AI_PEER = {
|
|
|
28235
29020
|
claude_code: "claude",
|
|
28236
29021
|
obsidian: "honcho"
|
|
28237
29022
|
};
|
|
28238
|
-
function coerceBoolean(value) {
|
|
28239
|
-
if (typeof value === "string") {
|
|
28240
|
-
const v = value.trim().toLowerCase();
|
|
28241
|
-
return v !== "false" && v !== "0" && v !== "";
|
|
28242
|
-
}
|
|
28243
|
-
return Boolean(value);
|
|
28244
|
-
}
|
|
28245
29023
|
var _stdinText = null;
|
|
28246
29024
|
function cacheStdin(text) {
|
|
28247
29025
|
_stdinText = text;
|
|
@@ -28268,31 +29046,14 @@ async function initHook() {
|
|
|
28268
29046
|
process.exit(0);
|
|
28269
29047
|
setDetectedHost(detectHost(input));
|
|
28270
29048
|
}
|
|
28271
|
-
function deepEqual(a, b) {
|
|
28272
|
-
if (a === b)
|
|
28273
|
-
return true;
|
|
28274
|
-
if (a == null || b == null)
|
|
28275
|
-
return a === b;
|
|
28276
|
-
if (typeof a !== typeof b)
|
|
28277
|
-
return false;
|
|
28278
|
-
if (typeof a !== "object")
|
|
28279
|
-
return false;
|
|
28280
|
-
const aObj = a;
|
|
28281
|
-
const bObj = b;
|
|
28282
|
-
const keys = new Set([...Object.keys(aObj), ...Object.keys(bObj)]);
|
|
28283
|
-
for (const key of keys) {
|
|
28284
|
-
if (!deepEqual(aObj[key], bObj[key]))
|
|
28285
|
-
return false;
|
|
28286
|
-
}
|
|
28287
|
-
return true;
|
|
28288
|
-
}
|
|
28289
|
-
var CONFIG_DIR = join3(homedir2(), ".honcho");
|
|
28290
|
-
var CONFIG_FILE = join3(CONFIG_DIR, "config.json");
|
|
28291
29049
|
function getConfigPath() {
|
|
28292
|
-
return
|
|
29050
|
+
return configPath();
|
|
29051
|
+
}
|
|
29052
|
+
function getConfigDir() {
|
|
29053
|
+
return dirname2(configPath());
|
|
28293
29054
|
}
|
|
28294
29055
|
function configExists() {
|
|
28295
|
-
return existsSync3(
|
|
29056
|
+
return existsSync3(configPath());
|
|
28296
29057
|
}
|
|
28297
29058
|
function getPluginVersion() {
|
|
28298
29059
|
const root = process.env.CLAUDE_PLUGIN_ROOT;
|
|
@@ -28302,330 +29063,142 @@ function getPluginVersion() {
|
|
|
28302
29063
|
];
|
|
28303
29064
|
for (const manifest of candidates) {
|
|
28304
29065
|
try {
|
|
28305
|
-
const version = JSON.parse(
|
|
29066
|
+
const version = JSON.parse(readFileSync3(manifest, "utf-8")).version;
|
|
28306
29067
|
if (typeof version === "string" && version)
|
|
28307
29068
|
return version;
|
|
28308
29069
|
} catch {}
|
|
28309
29070
|
}
|
|
28310
29071
|
return "unknown";
|
|
28311
29072
|
}
|
|
28312
|
-
function
|
|
28313
|
-
|
|
28314
|
-
|
|
28315
|
-
|
|
28316
|
-
|
|
28317
|
-
|
|
28318
|
-
return resolveConfig2(raw, resolvedHost);
|
|
28319
|
-
} catch {}
|
|
28320
|
-
}
|
|
28321
|
-
return loadConfigFromEnv(resolvedHost);
|
|
28322
|
-
}
|
|
28323
|
-
function resolveConfig2(raw, host) {
|
|
28324
|
-
const hostBlock = raw.hosts?.[host] ?? raw.hosts?.[host.replace(/_/g, "-")] ?? raw.hosts?.[host.replace(/-/g, "_")];
|
|
28325
|
-
const apiKey = process.env.HONCHO_API_KEY || hostBlock?.apiKey || raw.apiKey;
|
|
28326
|
-
if (!apiKey)
|
|
28327
|
-
return null;
|
|
28328
|
-
const peerName = raw.peerName || process.env.HONCHO_PEER_NAME || process.env.USER || process.env.USERNAME || "user";
|
|
28329
|
-
let workspace;
|
|
28330
|
-
let aiPeer;
|
|
28331
|
-
if (raw.globalOverride === true) {
|
|
28332
|
-
workspace = raw.workspace ?? DEFAULT_WORKSPACE[host];
|
|
28333
|
-
aiPeer = raw.aiPeer ?? hostBlock?.aiPeer ?? DEFAULT_AI_PEER[host];
|
|
28334
|
-
} else if (hostBlock) {
|
|
28335
|
-
workspace = hostBlock.workspace ?? DEFAULT_WORKSPACE[host];
|
|
28336
|
-
aiPeer = hostBlock.aiPeer ?? DEFAULT_AI_PEER[host];
|
|
28337
|
-
} else {
|
|
28338
|
-
workspace = process.env.HONCHO_WORKSPACE ?? raw.workspace ?? DEFAULT_WORKSPACE[host];
|
|
28339
|
-
if (host === "cursor") {
|
|
28340
|
-
aiPeer = raw.cursorPeer ?? DEFAULT_AI_PEER["cursor"];
|
|
28341
|
-
} else {
|
|
28342
|
-
aiPeer = raw.claudePeer ?? DEFAULT_AI_PEER["claude_code"];
|
|
28343
|
-
}
|
|
28344
|
-
}
|
|
28345
|
-
const config = {
|
|
28346
|
-
apiKey,
|
|
28347
|
-
peerName,
|
|
28348
|
-
workspace,
|
|
28349
|
-
aiPeer,
|
|
28350
|
-
sessionStrategy: hostBlock?.sessionStrategy ?? raw.sessionStrategy,
|
|
28351
|
-
sessionPeerPrefix: hostBlock?.sessionPeerPrefix ?? raw.sessionPeerPrefix,
|
|
28352
|
-
sessions: raw.sessions,
|
|
28353
|
-
saveMessages: hostBlock?.saveMessages ?? raw.saveMessages,
|
|
28354
|
-
saveToolUse: hostBlock?.saveToolUse ?? raw.saveToolUse,
|
|
28355
|
-
saveGitEvents: hostBlock?.saveGitEvents ?? raw.saveGitEvents,
|
|
28356
|
-
reasoningLevel: hostBlock?.reasoningLevel ?? raw.reasoningLevel,
|
|
28357
|
-
observationMode: hostBlock?.observationMode ?? raw.observationMode,
|
|
28358
|
-
messageUpload: hostBlock?.messageUpload ?? raw.messageUpload,
|
|
28359
|
-
contextRefresh: hostBlock?.contextRefresh ?? raw.contextRefresh,
|
|
28360
|
-
endpoint: hostBlock?.endpoint ?? raw.endpoint,
|
|
28361
|
-
redactPatterns: hostBlock?.redactPatterns ?? raw.redactPatterns,
|
|
28362
|
-
injection: hostBlock?.injection ?? raw.injection,
|
|
28363
|
-
rememberTool: hostBlock?.rememberTool ?? raw.rememberTool,
|
|
28364
|
-
enabled: hostBlock?.enabled ?? raw.enabled,
|
|
28365
|
-
logging: hostBlock?.logging ?? raw.logging,
|
|
28366
|
-
globalOverride: raw.globalOverride
|
|
28367
|
-
};
|
|
28368
|
-
return mergeWithEnvVars(config);
|
|
28369
|
-
}
|
|
28370
|
-
function loadConfigFromEnv(host) {
|
|
28371
|
-
const apiKey = process.env.HONCHO_API_KEY;
|
|
28372
|
-
if (!apiKey) {
|
|
28373
|
-
return null;
|
|
28374
|
-
}
|
|
28375
|
-
const resolvedHost = host ?? getDetectedHost();
|
|
28376
|
-
const peerName = process.env.HONCHO_PEER_NAME || process.env.USER || process.env.USERNAME || "user";
|
|
28377
|
-
const workspace = process.env.HONCHO_WORKSPACE || DEFAULT_WORKSPACE[resolvedHost];
|
|
28378
|
-
const hostPeerEnv = resolvedHost === "cursor" ? process.env.HONCHO_CURSOR_PEER : process.env.HONCHO_CLAUDE_PEER;
|
|
28379
|
-
const aiPeer = process.env.HONCHO_AI_PEER || hostPeerEnv || DEFAULT_AI_PEER[resolvedHost];
|
|
28380
|
-
const endpoint = process.env.HONCHO_ENDPOINT;
|
|
28381
|
-
const config = {
|
|
28382
|
-
apiKey,
|
|
28383
|
-
peerName,
|
|
28384
|
-
workspace,
|
|
28385
|
-
aiPeer,
|
|
28386
|
-
saveMessages: process.env.HONCHO_SAVE_MESSAGES !== "false",
|
|
28387
|
-
saveToolUse: process.env.HONCHO_SAVE_TOOL_USE === "true",
|
|
28388
|
-
saveGitEvents: process.env.HONCHO_SAVE_GIT_EVENTS === "true",
|
|
28389
|
-
enabled: process.env.HONCHO_ENABLED !== "false",
|
|
28390
|
-
logging: process.env.HONCHO_LOGGING !== "false"
|
|
28391
|
-
};
|
|
28392
|
-
if (endpoint) {
|
|
28393
|
-
if (endpoint === "local") {
|
|
28394
|
-
config.endpoint = { environment: "local" };
|
|
28395
|
-
} else if (endpoint.startsWith("http")) {
|
|
28396
|
-
config.endpoint = { baseUrl: endpoint };
|
|
28397
|
-
}
|
|
28398
|
-
}
|
|
28399
|
-
return config;
|
|
28400
|
-
}
|
|
28401
|
-
function mergeWithEnvVars(config) {
|
|
28402
|
-
if (process.env.HONCHO_API_KEY) {
|
|
28403
|
-
config.apiKey = process.env.HONCHO_API_KEY;
|
|
28404
|
-
}
|
|
28405
|
-
if (process.env.HONCHO_PEER_NAME) {
|
|
28406
|
-
config.peerName = process.env.HONCHO_PEER_NAME;
|
|
28407
|
-
}
|
|
28408
|
-
if (process.env.HONCHO_ENABLED === "false") {
|
|
28409
|
-
config.enabled = false;
|
|
28410
|
-
}
|
|
28411
|
-
if (process.env.HONCHO_LOGGING === "false") {
|
|
28412
|
-
config.logging = false;
|
|
28413
|
-
}
|
|
28414
|
-
if (process.env.HONCHO_SAVE_TOOL_USE !== undefined) {
|
|
28415
|
-
config.saveToolUse = process.env.HONCHO_SAVE_TOOL_USE === "true";
|
|
28416
|
-
}
|
|
28417
|
-
if (process.env.HONCHO_SAVE_GIT_EVENTS !== undefined) {
|
|
28418
|
-
config.saveGitEvents = process.env.HONCHO_SAVE_GIT_EVENTS === "true";
|
|
28419
|
-
}
|
|
28420
|
-
return config;
|
|
28421
|
-
}
|
|
28422
|
-
function saveConfig(config) {
|
|
28423
|
-
if (!existsSync3(CONFIG_DIR)) {
|
|
28424
|
-
mkdirSync2(CONFIG_DIR, { recursive: true });
|
|
28425
|
-
}
|
|
28426
|
-
let existing = {};
|
|
28427
|
-
if (existsSync3(CONFIG_FILE)) {
|
|
28428
|
-
try {
|
|
28429
|
-
existing = JSON.parse(readFileSync2(CONFIG_FILE, "utf-8"));
|
|
28430
|
-
} catch {}
|
|
28431
|
-
}
|
|
28432
|
-
if (config.sessions !== undefined) {
|
|
28433
|
-
existing.sessions = config.sessions;
|
|
28434
|
-
}
|
|
28435
|
-
const host = getDetectedHost();
|
|
28436
|
-
if (!existing.hosts)
|
|
28437
|
-
existing.hosts = {};
|
|
28438
|
-
const existingHost = existing.hosts[host] ?? {};
|
|
28439
|
-
const hostEntry = {};
|
|
28440
|
-
const setHostIfExplicit = (key, value, rootValue) => {
|
|
28441
|
-
if (value === undefined)
|
|
28442
|
-
return;
|
|
28443
|
-
const hasHostOverride = Object.prototype.hasOwnProperty.call(existingHost, key);
|
|
28444
|
-
if (hasHostOverride || !deepEqual(value, rootValue)) {
|
|
28445
|
-
hostEntry[key] = value;
|
|
28446
|
-
}
|
|
28447
|
-
};
|
|
28448
|
-
setHostIfExplicit("workspace", config.workspace, existing.workspace ?? DEFAULT_WORKSPACE[host]);
|
|
28449
|
-
setHostIfExplicit("aiPeer", config.aiPeer, existing.aiPeer ?? DEFAULT_AI_PEER[host]);
|
|
28450
|
-
const enabledForSave = process.env.HONCHO_ENABLED === "false" && config.enabled === false ? existingHost.enabled : config.enabled;
|
|
28451
|
-
const loggingForSave = process.env.HONCHO_LOGGING === "false" && config.logging === false ? existingHost.logging : config.logging;
|
|
28452
|
-
setHostIfExplicit("enabled", enabledForSave, existing.enabled);
|
|
28453
|
-
setHostIfExplicit("logging", loggingForSave, existing.logging);
|
|
28454
|
-
setHostIfExplicit("saveMessages", config.saveMessages, existing.saveMessages);
|
|
28455
|
-
setHostIfExplicit("sessionStrategy", config.sessionStrategy, existing.sessionStrategy);
|
|
28456
|
-
setHostIfExplicit("sessionPeerPrefix", config.sessionPeerPrefix, existing.sessionPeerPrefix);
|
|
28457
|
-
setHostIfExplicit("reasoningLevel", config.reasoningLevel, existing.reasoningLevel);
|
|
28458
|
-
setHostIfExplicit("observationMode", config.observationMode, existing.observationMode);
|
|
28459
|
-
setHostIfExplicit("messageUpload", config.messageUpload, existing.messageUpload);
|
|
28460
|
-
setHostIfExplicit("contextRefresh", config.contextRefresh, existing.contextRefresh);
|
|
28461
|
-
setHostIfExplicit("redactPatterns", config.redactPatterns, existing.redactPatterns);
|
|
28462
|
-
setHostIfExplicit("endpoint", config.endpoint, existing.endpoint);
|
|
28463
|
-
setHostIfExplicit("injection", config.injection, existing.injection);
|
|
28464
|
-
setHostIfExplicit("rememberTool", config.rememberTool, existing.rememberTool);
|
|
28465
|
-
if (existingHost.apiKey !== undefined) {
|
|
28466
|
-
hostEntry.apiKey = existingHost.apiKey;
|
|
28467
|
-
}
|
|
28468
|
-
existing.hosts[host] = hostEntry;
|
|
28469
|
-
writeFileSync2(CONFIG_FILE, JSON.stringify(existing, null, 2));
|
|
28470
|
-
}
|
|
28471
|
-
function saveRootField(field, value) {
|
|
28472
|
-
if (!existsSync3(CONFIG_DIR)) {
|
|
28473
|
-
mkdirSync2(CONFIG_DIR, { recursive: true });
|
|
28474
|
-
}
|
|
28475
|
-
let existing = {};
|
|
28476
|
-
if (existsSync3(CONFIG_FILE)) {
|
|
28477
|
-
try {
|
|
28478
|
-
existing = JSON.parse(readFileSync2(CONFIG_FILE, "utf-8"));
|
|
28479
|
-
} catch {}
|
|
28480
|
-
}
|
|
28481
|
-
existing[field] = value;
|
|
28482
|
-
writeFileSync2(CONFIG_FILE, JSON.stringify(existing, null, 2));
|
|
28483
|
-
}
|
|
28484
|
-
function resolveWorktreeMainRoot(dir) {
|
|
28485
|
-
try {
|
|
28486
|
-
const gitPath = join3(dir, ".git");
|
|
28487
|
-
if (!statSync(gitPath).isFile())
|
|
28488
|
-
return null;
|
|
28489
|
-
const match = readFileSync2(gitPath, "utf-8").match(/^gitdir:\s*(.+?)\s*$/m);
|
|
28490
|
-
if (!match)
|
|
28491
|
-
return null;
|
|
28492
|
-
const gitdir = resolve(dir, match[1]);
|
|
28493
|
-
const idx = gitdir.lastIndexOf(`${sep}worktrees${sep}`);
|
|
28494
|
-
if (idx === -1)
|
|
28495
|
-
return null;
|
|
28496
|
-
const gitContainer = gitdir.slice(0, idx);
|
|
28497
|
-
if (basename(gitContainer) === ".git")
|
|
28498
|
-
return dirname(gitContainer);
|
|
28499
|
-
if (gitContainer.endsWith(".git"))
|
|
28500
|
-
return gitContainer;
|
|
28501
|
-
return null;
|
|
28502
|
-
} catch {
|
|
28503
|
-
return null;
|
|
28504
|
-
}
|
|
28505
|
-
}
|
|
28506
|
-
var MAX_GIT_WALK_UP = 12;
|
|
28507
|
-
function worktreeMainRootFor(cwd) {
|
|
28508
|
-
try {
|
|
28509
|
-
let dir = resolve(cwd);
|
|
28510
|
-
for (let i = 0;i < MAX_GIT_WALK_UP; i++) {
|
|
28511
|
-
if (existsSync3(join3(dir, ".git")))
|
|
28512
|
-
return resolveWorktreeMainRoot(dir);
|
|
28513
|
-
const parent = dirname(dir);
|
|
28514
|
-
if (parent === dir)
|
|
28515
|
-
break;
|
|
28516
|
-
dir = parent;
|
|
28517
|
-
}
|
|
28518
|
-
} catch {}
|
|
28519
|
-
return null;
|
|
28520
|
-
}
|
|
28521
|
-
function getSessionForPath(cwd, mainRoot) {
|
|
28522
|
-
const config = loadConfig2();
|
|
28523
|
-
if (!config?.sessions)
|
|
28524
|
-
return null;
|
|
28525
|
-
if (config.sessions[cwd])
|
|
28526
|
-
return config.sessions[cwd];
|
|
28527
|
-
const mr = mainRoot === undefined ? worktreeMainRootFor(cwd) : mainRoot;
|
|
28528
|
-
if (mr && config.sessions[mr])
|
|
28529
|
-
return config.sessions[mr];
|
|
28530
|
-
return null;
|
|
29073
|
+
function legacyEndpoint(value) {
|
|
29074
|
+
if (value === "local")
|
|
29075
|
+
return "http://localhost:8000";
|
|
29076
|
+
if (value?.startsWith("http"))
|
|
29077
|
+
return value.replace(/\/v3\/?$/, "");
|
|
29078
|
+
return;
|
|
28531
29079
|
}
|
|
28532
|
-
function
|
|
28533
|
-
const
|
|
28534
|
-
const
|
|
28535
|
-
const
|
|
28536
|
-
|
|
28537
|
-
|
|
28538
|
-
|
|
28539
|
-
|
|
28540
|
-
|
|
28541
|
-
|
|
28542
|
-
|
|
28543
|
-
|
|
28544
|
-
}
|
|
28545
|
-
|
|
28546
|
-
if (opts.instanceId) {
|
|
28547
|
-
return usePrefix ? `${peerPart}-chat-${opts.instanceId}` : `chat-${opts.instanceId}`;
|
|
28548
|
-
}
|
|
28549
|
-
return base;
|
|
28550
|
-
}
|
|
28551
|
-
case "per-directory":
|
|
28552
|
-
default:
|
|
28553
|
-
return base;
|
|
28554
|
-
}
|
|
29080
|
+
function legacyEnv(host = getDetectedHost()) {
|
|
29081
|
+
const env = process.env;
|
|
29082
|
+
const peerVar = host === "cursor" ? "HONCHO_CURSOR_PEER" : "HONCHO_CLAUDE_PEER";
|
|
29083
|
+
const candidates = [
|
|
29084
|
+
["HONCHO_BASE_URL", "baseUrl", "HONCHO_ENDPOINT", legacyEndpoint(env.HONCHO_ENDPOINT)],
|
|
29085
|
+
["HONCHO_AI_PEER", "aiPeer", peerVar, env[peerVar] || undefined]
|
|
29086
|
+
];
|
|
29087
|
+
const set = candidates.filter(([newVar, , , value]) => value && !env[newVar]);
|
|
29088
|
+
if (!set.length)
|
|
29089
|
+
return {};
|
|
29090
|
+
const block = effectiveBlock(readConfigFile(), host, LEGACY);
|
|
29091
|
+
if (block.apiKey || block.oauth)
|
|
29092
|
+
return {};
|
|
29093
|
+
return Object.fromEntries(set.filter(([, setting]) => !block[setting]).map(([newVar, , oldVar, value]) => [newVar, [oldVar, value]]));
|
|
28555
29094
|
}
|
|
28556
|
-
function
|
|
28557
|
-
const
|
|
28558
|
-
|
|
28559
|
-
|
|
28560
|
-
|
|
28561
|
-
|
|
28562
|
-
|
|
28563
|
-
|
|
28564
|
-
|
|
28565
|
-
|
|
28566
|
-
|
|
28567
|
-
|
|
28568
|
-
branch = captureGitState(cwd)?.branch;
|
|
28569
|
-
}
|
|
28570
|
-
let resolvedInstanceId;
|
|
28571
|
-
if (strategy === "chat-instance") {
|
|
28572
|
-
resolvedInstanceId = instanceId || getInstanceIdForCwd(cwd) || getClaudeInstanceId() || undefined;
|
|
28573
|
-
}
|
|
28574
|
-
return deriveSessionName(strategy, mainRoot ?? cwd, {
|
|
28575
|
-
peerName: config?.peerName,
|
|
28576
|
-
sessionPeerPrefix: config?.sessionPeerPrefix,
|
|
28577
|
-
branch,
|
|
28578
|
-
instanceId: resolvedInstanceId
|
|
29095
|
+
function honchoEnv(host) {
|
|
29096
|
+
const legacy = Object.entries(legacyEnv(host));
|
|
29097
|
+
if (!legacy.length)
|
|
29098
|
+
return process.env;
|
|
29099
|
+
return { ...process.env, ...Object.fromEntries(legacy.map(([k, [, value]]) => [k, value])) };
|
|
29100
|
+
}
|
|
29101
|
+
function resolveHost(host) {
|
|
29102
|
+
return resolveConfig(readConfigFile(), {
|
|
29103
|
+
host,
|
|
29104
|
+
env: honchoEnv(host),
|
|
29105
|
+
defaults: { workspace: DEFAULT_WORKSPACE[host], aiPeer: DEFAULT_AI_PEER[host] },
|
|
29106
|
+
legacy: LEGACY
|
|
28579
29107
|
});
|
|
28580
29108
|
}
|
|
28581
|
-
function
|
|
28582
|
-
|
|
28583
|
-
|
|
28584
|
-
|
|
28585
|
-
|
|
28586
|
-
|
|
28587
|
-
|
|
28588
|
-
config.sessions[cwd] = sessionName;
|
|
28589
|
-
saveConfig(config);
|
|
29109
|
+
function isLoggingEnabled(host = getDetectedHost()) {
|
|
29110
|
+
if (process.env.HONCHO_LOGGING === "false")
|
|
29111
|
+
return false;
|
|
29112
|
+
const file = readConfigFile();
|
|
29113
|
+
const hosts = file.hosts && typeof file.hosts === "object" ? file.hosts : {};
|
|
29114
|
+
const own = [hosts[host], hosts[host.replace(/_/g, "-")]].map((block) => block && typeof block === "object" ? block.logging : undefined).find((v) => v !== undefined);
|
|
29115
|
+
return (own ?? file.logging) !== false;
|
|
28590
29116
|
}
|
|
28591
|
-
function
|
|
28592
|
-
const
|
|
28593
|
-
const
|
|
28594
|
-
|
|
28595
|
-
|
|
28596
|
-
|
|
29117
|
+
function loadConfig2(host = getDetectedHost()) {
|
|
29118
|
+
const cfg = resolveHost(host);
|
|
29119
|
+
const cred = pickCredential(readConfigFile(), { host, baseUrl: cfg.baseUrl, env: honchoEnv(host), legacy: LEGACY });
|
|
29120
|
+
if (!cred)
|
|
29121
|
+
return null;
|
|
29122
|
+
const { token, ...authState } = cred;
|
|
29123
|
+
return {
|
|
29124
|
+
apiKey: token,
|
|
29125
|
+
auth: { ...authState, host },
|
|
29126
|
+
peerName: cfg.peerName,
|
|
29127
|
+
workspace: cfg.workspace,
|
|
29128
|
+
aiPeer: cfg.aiPeer,
|
|
29129
|
+
baseUrl: cfg.baseUrl
|
|
29130
|
+
};
|
|
28597
29131
|
}
|
|
28598
|
-
function
|
|
28599
|
-
const
|
|
28600
|
-
|
|
29132
|
+
async function saveConfig(config, field) {
|
|
29133
|
+
const host = getDetectedHost();
|
|
29134
|
+
const env = honchoEnv(host);
|
|
29135
|
+
const write = (key, envVar) => key === field || !env[envVar];
|
|
29136
|
+
const patch = {};
|
|
29137
|
+
if (write("peerName", "HONCHO_PEER_NAME"))
|
|
29138
|
+
patch.peerName = config.peerName;
|
|
29139
|
+
if (write("workspace", "HONCHO_WORKSPACE"))
|
|
29140
|
+
patch.workspace = config.workspace === DEFAULT_WORKSPACE[host] ? undefined : config.workspace;
|
|
29141
|
+
if (write("aiPeer", "HONCHO_AI_PEER"))
|
|
29142
|
+
patch.aiPeer = config.aiPeer === DEFAULT_AI_PEER[host] ? undefined : config.aiPeer;
|
|
29143
|
+
if (write("baseUrl", "HONCHO_BASE_URL"))
|
|
29144
|
+
patch.baseUrl = config.baseUrl === DEFAULT_BASE_URL ? undefined : config.baseUrl;
|
|
29145
|
+
await saveHost(configPath(), host, patch, LEGACY);
|
|
28601
29146
|
}
|
|
28602
|
-
function
|
|
28603
|
-
|
|
28604
|
-
return config?.enabled !== false;
|
|
29147
|
+
function getConfigIssues(host = getDetectedHost()) {
|
|
29148
|
+
return checkConfig(readConfigFile()).filter((i) => i.path === "schemaVersion" || i.path === "hosts" && i.message.includes(host)).map((i) => i.message);
|
|
28605
29149
|
}
|
|
28606
|
-
|
|
28607
|
-
|
|
28608
|
-
|
|
28609
|
-
|
|
29150
|
+
var DEAD_HOST_KEYS = [
|
|
29151
|
+
"sessionStrategy",
|
|
29152
|
+
"sessionPeerPrefix",
|
|
29153
|
+
"sessions",
|
|
29154
|
+
"injection",
|
|
29155
|
+
"contextRefresh",
|
|
29156
|
+
"messageUpload",
|
|
29157
|
+
"reasoningLevel",
|
|
29158
|
+
"statusline",
|
|
29159
|
+
"saveToolUse",
|
|
29160
|
+
"saveGitEvents",
|
|
29161
|
+
"redactPatterns",
|
|
29162
|
+
"rememberTool",
|
|
29163
|
+
"observationMode",
|
|
29164
|
+
"saveMessages",
|
|
29165
|
+
"enabled",
|
|
29166
|
+
"globalOverride",
|
|
29167
|
+
"linkedHosts"
|
|
29168
|
+
];
|
|
29169
|
+
async function migrateConfig(host = getDetectedHost()) {
|
|
28610
29170
|
try {
|
|
28611
|
-
const
|
|
28612
|
-
|
|
28613
|
-
|
|
28614
|
-
|
|
28615
|
-
|
|
29171
|
+
const changed = await migrateHost(configPath(), host, DEAD_HOST_KEYS, LEGACY);
|
|
29172
|
+
if (changed.length)
|
|
29173
|
+
return `[honcho] Moved your Honcho settings into hosts.${host} in ~/.honcho/config.json.`;
|
|
29174
|
+
} catch {}
|
|
29175
|
+
return;
|
|
28616
29176
|
}
|
|
28617
|
-
function
|
|
28618
|
-
|
|
28619
|
-
|
|
28620
|
-
|
|
28621
|
-
|
|
28622
|
-
|
|
28623
|
-
|
|
29177
|
+
function getSessionName(sessionId) {
|
|
29178
|
+
const id = sessionId || process.env.CLAUDE_CODE_SESSION_ID;
|
|
29179
|
+
return id ? sanitizeForSessionName(id) : null;
|
|
29180
|
+
}
|
|
29181
|
+
function getKnownHosts() {
|
|
29182
|
+
const hosts = readConfigFile().hosts;
|
|
29183
|
+
return hosts && typeof hosts === "object" ? Object.keys(hosts) : [];
|
|
29184
|
+
}
|
|
29185
|
+
async function refreshCredential(config) {
|
|
29186
|
+
const host = config.auth?.host ?? getDetectedHost();
|
|
29187
|
+
const cred = await ensureFreshCredential({ path: configPath(), host, baseUrl: config.baseUrl, env: honchoEnv(host), legacy: LEGACY });
|
|
29188
|
+
if (!cred)
|
|
29189
|
+
return;
|
|
29190
|
+
const { token, ...authState } = cred;
|
|
29191
|
+
config.apiKey = token;
|
|
29192
|
+
config.auth = { ...authState, host };
|
|
29193
|
+
}
|
|
29194
|
+
function getAuthNotice(config) {
|
|
29195
|
+
if (config.auth?.reauthRequired) {
|
|
29196
|
+
return "[honcho] Your Honcho sign-in has expired. Run /honcho setup to sign in again.";
|
|
28624
29197
|
}
|
|
28625
|
-
return
|
|
29198
|
+
return;
|
|
28626
29199
|
}
|
|
28627
29200
|
function getHonchoBaseUrl(config) {
|
|
28628
|
-
return
|
|
29201
|
+
return `${config.baseUrl}/v3`;
|
|
28629
29202
|
}
|
|
28630
29203
|
function getTelemetryHeaders(host = getDetectedHost()) {
|
|
28631
29204
|
return telemetryHeaders({
|
|
@@ -28644,64 +29217,21 @@ function getHonchoClientOptions(config) {
|
|
|
28644
29217
|
defaultHeaders: getTelemetryHeaders()
|
|
28645
29218
|
};
|
|
28646
29219
|
}
|
|
28647
|
-
function
|
|
28648
|
-
|
|
28649
|
-
return { type: "custom", url: config.endpoint.baseUrl };
|
|
28650
|
-
}
|
|
28651
|
-
if (config.endpoint?.environment === "local") {
|
|
28652
|
-
return { type: "local", url: HONCHO_BASE_URLS.local };
|
|
28653
|
-
}
|
|
28654
|
-
return { type: "production", url: HONCHO_BASE_URLS.production };
|
|
29220
|
+
function isProductionEndpoint(config) {
|
|
29221
|
+
return config.baseUrl === DEFAULT_BASE_URL;
|
|
28655
29222
|
}
|
|
28656
|
-
|
|
28657
|
-
|
|
28658
|
-
return config.observationMode ?? "unified";
|
|
29223
|
+
function getEndpointInfo(config) {
|
|
29224
|
+
return { type: isProductionEndpoint(config) ? "production" : "custom", url: config.baseUrl };
|
|
28659
29225
|
}
|
|
28660
29226
|
|
|
28661
|
-
// src/
|
|
28662
|
-
var
|
|
28663
|
-
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
},
|
|
28667
|
-
{
|
|
28668
|
-
pattern: /(--(?:password|passwd|pwd|token|api-?key|secret|auth)[= ])(?:"[^"]*"|'[^']*'|[^\s;|&"']+)/gi,
|
|
28669
|
-
replacement: "$1***"
|
|
28670
|
-
},
|
|
28671
|
-
{
|
|
28672
|
-
pattern: /(authorization:\s*(?:bearer|basic|token)\s+)[^\s"']+/gi,
|
|
28673
|
-
replacement: "$1***"
|
|
28674
|
-
},
|
|
28675
|
-
{
|
|
28676
|
-
pattern: /([a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:)[^@\s]+@/gi,
|
|
28677
|
-
replacement: "$1***@"
|
|
28678
|
-
},
|
|
28679
|
-
{
|
|
28680
|
-
pattern: /\b(?:hch[_-]?[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16}|sk-[A-Za-z0-9_-]{16,}|(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|glpat-[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{36})\b/g,
|
|
28681
|
-
replacement: "***"
|
|
28682
|
-
}
|
|
28683
|
-
];
|
|
28684
|
-
function validateRedactPattern(source) {
|
|
28685
|
-
try {
|
|
28686
|
-
new RegExp(source);
|
|
28687
|
-
return null;
|
|
28688
|
-
} catch (e) {
|
|
28689
|
-
return `Invalid regex ${JSON.stringify(source)}: ${e instanceof Error ? e.message : String(e)}`;
|
|
28690
|
-
}
|
|
29227
|
+
// src/honcho-client.ts
|
|
29228
|
+
var import_sdk = __toESM(require_dist2(), 1);
|
|
29229
|
+
async function createHonchoClient(config, overrides = {}) {
|
|
29230
|
+
await refreshCredential(config);
|
|
29231
|
+
return new import_sdk.Honcho({ ...getHonchoClientOptions(config), ...overrides });
|
|
28691
29232
|
}
|
|
28692
|
-
function
|
|
28693
|
-
|
|
28694
|
-
for (const rule of DEFAULT_RULES) {
|
|
28695
|
-
result = result.replace(rule.pattern, rule.replacement);
|
|
28696
|
-
}
|
|
28697
|
-
for (const source of extraPatterns ?? []) {
|
|
28698
|
-
try {
|
|
28699
|
-
result = result.replace(new RegExp(source, "gi"), "***");
|
|
28700
|
-
} catch {
|
|
28701
|
-
continue;
|
|
28702
|
-
}
|
|
28703
|
-
}
|
|
28704
|
-
return result;
|
|
29233
|
+
function setClientApiKey(honcho, token) {
|
|
29234
|
+
honcho.http.apiKey = token;
|
|
28705
29235
|
}
|
|
28706
29236
|
|
|
28707
29237
|
// src/styles.ts
|
|
@@ -28716,8 +29246,10 @@ var symbols = {
|
|
|
28716
29246
|
pipe: String.fromCodePoint(9474),
|
|
28717
29247
|
sparkle: String.fromCodePoint(10022)
|
|
28718
29248
|
};
|
|
28719
|
-
function honchoSessionUrl(
|
|
28720
|
-
|
|
29249
|
+
function honchoSessionUrl(config, sessionName) {
|
|
29250
|
+
if (!isProductionEndpoint(config))
|
|
29251
|
+
return null;
|
|
29252
|
+
return `https://app.honcho.dev/explore?workspace=${encodeURIComponent(config.workspace)}&view=sessions&session=${encodeURIComponent(sessionName)}`;
|
|
28721
29253
|
}
|
|
28722
29254
|
|
|
28723
29255
|
// src/mcp/server.ts
|
|
@@ -28725,23 +29257,14 @@ var ENV_SHADOW_MAP = {
|
|
|
28725
29257
|
peerName: "HONCHO_PEER_NAME",
|
|
28726
29258
|
workspace: "HONCHO_WORKSPACE",
|
|
28727
29259
|
aiPeer: "HONCHO_AI_PEER",
|
|
28728
|
-
|
|
28729
|
-
logging: "HONCHO_LOGGING",
|
|
28730
|
-
saveMessages: "HONCHO_SAVE_MESSAGES",
|
|
28731
|
-
"endpoint.baseUrl": "HONCHO_ENDPOINT",
|
|
28732
|
-
"endpoint.environment": "HONCHO_ENDPOINT"
|
|
29260
|
+
baseUrl: "HONCHO_BASE_URL"
|
|
28733
29261
|
};
|
|
28734
|
-
var DANGEROUS_FIELDS = new Set(["workspace", "
|
|
29262
|
+
var DANGEROUS_FIELDS = new Set(["workspace", "baseUrl"]);
|
|
28735
29263
|
var SESSION_AFFECTING_FIELDS = new Set([
|
|
28736
29264
|
"workspace",
|
|
28737
29265
|
"aiPeer",
|
|
28738
29266
|
"peerName",
|
|
28739
|
-
"
|
|
28740
|
-
"sessionPeerPrefix",
|
|
28741
|
-
"endpoint.environment",
|
|
28742
|
-
"endpoint.baseUrl",
|
|
28743
|
-
"globalOverride",
|
|
28744
|
-
"observationMode"
|
|
29267
|
+
"baseUrl"
|
|
28745
29268
|
]);
|
|
28746
29269
|
function renderCard(rows, title) {
|
|
28747
29270
|
const labelWidth = 12;
|
|
@@ -28758,7 +29281,7 @@ function renderCard(rows, title) {
|
|
|
28758
29281
|
return [top, blank, ...body, blank, bot].join(`
|
|
28759
29282
|
`);
|
|
28760
29283
|
}
|
|
28761
|
-
function handleGetConfig(
|
|
29284
|
+
function handleGetConfig() {
|
|
28762
29285
|
const cfg = loadConfig2();
|
|
28763
29286
|
const host = getDetectedHost();
|
|
28764
29287
|
const cfgPath = getConfigPath();
|
|
@@ -28766,35 +29289,19 @@ function handleGetConfig(cwd) {
|
|
|
28766
29289
|
let rawFile = {};
|
|
28767
29290
|
if (cfgExists) {
|
|
28768
29291
|
try {
|
|
28769
|
-
rawFile = JSON.parse(
|
|
29292
|
+
rawFile = JSON.parse(readFileSync4(cfgPath, "utf-8"));
|
|
28770
29293
|
} catch {}
|
|
28771
29294
|
}
|
|
28772
|
-
const globalOverride = rawFile.globalOverride === true;
|
|
28773
29295
|
const resolved = cfg ? {
|
|
28774
29296
|
peerName: cfg.peerName,
|
|
28775
29297
|
aiPeer: cfg.aiPeer,
|
|
28776
29298
|
workspace: cfg.workspace,
|
|
28777
|
-
endpoint: getEndpointInfo(cfg)
|
|
28778
|
-
globalOverride,
|
|
28779
|
-
sessionStrategy: cfg.sessionStrategy ?? "per-directory",
|
|
28780
|
-
sessionPeerPrefix: cfg.sessionPeerPrefix !== false,
|
|
28781
|
-
sessions: cfg.sessions ?? {},
|
|
28782
|
-
messageUpload: cfg.messageUpload ?? {},
|
|
28783
|
-
contextRefresh: cfg.contextRefresh ?? {},
|
|
28784
|
-
reasoningLevel: cfg.reasoningLevel ?? "medium",
|
|
28785
|
-
observationMode: cfg.observationMode ?? "unified",
|
|
28786
|
-
statusline: cfg.statusline ?? "on",
|
|
28787
|
-
redactPatterns: cfg.redactPatterns ?? [],
|
|
28788
|
-
injection: cfg.injection ?? {},
|
|
28789
|
-
rememberTool: cfg.rememberTool === true,
|
|
28790
|
-
enabled: cfg.enabled !== false,
|
|
28791
|
-
logging: cfg.logging !== false,
|
|
28792
|
-
saveMessages: cfg.saveMessages !== false
|
|
29299
|
+
endpoint: getEndpointInfo(cfg)
|
|
28793
29300
|
} : null;
|
|
28794
|
-
const sessionName = cfg ? getSessionName(
|
|
29301
|
+
const sessionName = cfg ? getSessionName() : null;
|
|
28795
29302
|
const endpointInfo = cfg ? getEndpointInfo(cfg) : null;
|
|
28796
29303
|
const endpointLabel = endpointInfo ? endpointInfo.type === "production" ? "platform" : endpointInfo.type : null;
|
|
28797
|
-
const sessionUrl = cfg && sessionName ? honchoSessionUrl(cfg
|
|
29304
|
+
const sessionUrl = cfg && sessionName ? honchoSessionUrl(cfg, sessionName) : null;
|
|
28798
29305
|
const current = cfg ? {
|
|
28799
29306
|
workspace: cfg.workspace,
|
|
28800
29307
|
session: sessionName,
|
|
@@ -28817,47 +29324,32 @@ function handleGetConfig(cwd) {
|
|
|
28817
29324
|
otherHosts
|
|
28818
29325
|
};
|
|
28819
29326
|
const warnings = [];
|
|
28820
|
-
const hasHostsBlock = !!rawFile.hosts?.[host];
|
|
28821
|
-
const hostSpecificFields = new Set(["workspace", "aiPeer"]);
|
|
28822
29327
|
for (const [field, envVar] of Object.entries(ENV_SHADOW_MAP)) {
|
|
28823
29328
|
const envVal = process.env[envVar];
|
|
28824
|
-
if (
|
|
28825
|
-
continue;
|
|
28826
|
-
if (hasHostsBlock && hostSpecificFields.has(field)) {
|
|
28827
|
-
warnings.push(`env var ${envVar}="${envVal}" is set but ignored (hosts block takes precedence). Remove it from your shell config.`);
|
|
28828
|
-
} else {
|
|
29329
|
+
if (envVal)
|
|
28829
29330
|
warnings.push(`${field} is shadowed by env var ${envVar}="${envVal}"`);
|
|
28830
|
-
|
|
29331
|
+
}
|
|
29332
|
+
for (const [envVar, [oldVar, value]] of Object.entries(legacyEnv(host))) {
|
|
29333
|
+
const field = Object.keys(ENV_SHADOW_MAP).find((f) => ENV_SHADOW_MAP[f] === envVar);
|
|
29334
|
+
warnings.push(`${field} comes from the older env var ${oldVar}="${value}"; setting ${field} with set_config replaces it.`);
|
|
28831
29335
|
}
|
|
28832
29336
|
const envApiKey = process.env.HONCHO_API_KEY;
|
|
28833
|
-
|
|
29337
|
+
const fileApiKey = rawFile.hosts?.[host]?.apiKey;
|
|
29338
|
+
if (envApiKey && fileApiKey) {
|
|
28834
29339
|
const mask = (k) => `${k.slice(0, 10)}…${k.slice(-4)}`;
|
|
28835
|
-
if (envApiKey !==
|
|
28836
|
-
warnings.push(`HONCHO_API_KEY env var (${mask(envApiKey)}) overrides config.json apiKey (${mask(
|
|
29340
|
+
if (envApiKey !== fileApiKey) {
|
|
29341
|
+
warnings.push(`HONCHO_API_KEY env var (${mask(envApiKey)}) overrides config.json apiKey (${mask(fileApiKey)}) and is the key actually in use. ` + `An API key selects the Honcho environment, so reads/writes go to the env var's environment, NOT the one config.json names. ` + `Unset HONCHO_API_KEY in your shell to use config.json's key.`);
|
|
28837
29342
|
} else {
|
|
28838
29343
|
warnings.push(`apiKey is also set via HONCHO_API_KEY env var (identical value). The env var takes precedence at runtime.`);
|
|
28839
29344
|
}
|
|
28840
29345
|
}
|
|
28841
|
-
|
|
28842
|
-
|
|
28843
|
-
}
|
|
28844
|
-
if (cfgExists && rawFile.hosts && rawFile.workspace && rawFile.globalOverride === undefined) {
|
|
28845
|
-
warnings.push("Config has flat 'workspace' alongside hosts block but no 'globalOverride' set. The flat field is unused. Set globalOverride=true to apply it globally, or remove it.");
|
|
28846
|
-
}
|
|
28847
|
-
const strategyLabels = {
|
|
28848
|
-
"per-directory": "per directory",
|
|
28849
|
-
"git-branch": "per git branch",
|
|
28850
|
-
"chat-instance": "per chat"
|
|
28851
|
-
};
|
|
28852
|
-
const hostLabel = endpointInfo ? endpointInfo.type === "production" ? `platform (app.honcho.dev)` : endpointInfo.type === "local" ? `local (${endpointInfo.url})` : endpointInfo.url : "unknown";
|
|
29346
|
+
warnings.push(...getConfigIssues(host));
|
|
29347
|
+
const hostLabel = endpointInfo ? endpointInfo.type === "production" ? `platform (app.honcho.dev)` : endpointInfo.url : "unknown";
|
|
28853
29348
|
const card = cfg ? renderCard([
|
|
28854
29349
|
["workspace", cfg.workspace],
|
|
28855
29350
|
["session", sessionName ?? "unknown"],
|
|
28856
|
-
["mapping", strategyLabels[cfg.sessionStrategy ?? "per-directory"] ?? cfg.sessionStrategy ?? "per directory"],
|
|
28857
29351
|
["peer", `${cfg.peerName} / ${cfg.aiPeer}`],
|
|
28858
|
-
["host", hostLabel]
|
|
28859
|
-
["messages", cfg.saveMessages !== false ? "saving enabled" : "saving disabled"],
|
|
28860
|
-
["obs mode", cfg.observationMode ?? "unified"]
|
|
29352
|
+
["host", hostLabel]
|
|
28861
29353
|
], "current honcho config") : null;
|
|
28862
29354
|
return {
|
|
28863
29355
|
content: [{
|
|
@@ -28866,32 +29358,7 @@ function handleGetConfig(cwd) {
|
|
|
28866
29358
|
}]
|
|
28867
29359
|
};
|
|
28868
29360
|
}
|
|
28869
|
-
function
|
|
28870
|
-
let v = value;
|
|
28871
|
-
if (typeof v === "string") {
|
|
28872
|
-
try {
|
|
28873
|
-
v = JSON.parse(v);
|
|
28874
|
-
} catch {
|
|
28875
|
-
return null;
|
|
28876
|
-
}
|
|
28877
|
-
}
|
|
28878
|
-
return Array.isArray(v) ? v.map(String) : null;
|
|
28879
|
-
}
|
|
28880
|
-
function validateComponentArray(value, allowed, field) {
|
|
28881
|
-
const example = JSON.stringify(allowed.slice(0, 2));
|
|
28882
|
-
const err = (msg) => ({
|
|
28883
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: msg }, null, 2) }],
|
|
28884
|
-
isError: true
|
|
28885
|
-
});
|
|
28886
|
-
const arr = coerceStringArray(value);
|
|
28887
|
-
if (!arr)
|
|
28888
|
-
return err(`${field} must be an array of component names, e.g. ${example}`);
|
|
28889
|
-
const bad = arr.filter((v) => !allowed.includes(v));
|
|
28890
|
-
if (bad.length)
|
|
28891
|
-
return err(`${field} entries must be one of: ${allowed.join(", ")} (got: ${bad.join(", ")})`);
|
|
28892
|
-
return arr;
|
|
28893
|
-
}
|
|
28894
|
-
function handleSetConfig(args) {
|
|
29361
|
+
async function handleSetConfig(args) {
|
|
28895
29362
|
const field = args.field;
|
|
28896
29363
|
if (typeof field !== "string" || !field) {
|
|
28897
29364
|
return {
|
|
@@ -28904,8 +29371,7 @@ function handleSetConfig(args) {
|
|
|
28904
29371
|
if (DANGEROUS_FIELDS.has(field) && !confirm) {
|
|
28905
29372
|
const descriptions = {
|
|
28906
29373
|
workspace: "Switches to a different workspace.",
|
|
28907
|
-
|
|
28908
|
-
"endpoint.baseUrl": "Switches the Honcho backend URL."
|
|
29374
|
+
baseUrl: "Switches the Honcho backend URL."
|
|
28909
29375
|
};
|
|
28910
29376
|
return {
|
|
28911
29377
|
content: [{
|
|
@@ -28930,7 +29396,6 @@ function handleSetConfig(args) {
|
|
|
28930
29396
|
};
|
|
28931
29397
|
}
|
|
28932
29398
|
let previousValue;
|
|
28933
|
-
let cacheInvalidation = null;
|
|
28934
29399
|
const warnings = [];
|
|
28935
29400
|
const shadowEnv = ENV_SHADOW_MAP[field];
|
|
28936
29401
|
if (shadowEnv && process.env[shadowEnv]) {
|
|
@@ -28940,301 +29405,19 @@ function handleSetConfig(args) {
|
|
|
28940
29405
|
case "peerName":
|
|
28941
29406
|
previousValue = cfg.peerName;
|
|
28942
29407
|
cfg.peerName = String(value);
|
|
28943
|
-
saveRootField("peerName", cfg.peerName);
|
|
28944
|
-
clearPeerCache();
|
|
28945
|
-
clearUserContextOnly();
|
|
28946
|
-
if (String(value) !== String(previousValue) && Object.keys(cfg.sessions ?? {}).length > 0) {
|
|
28947
|
-
warnings.push(`${Object.keys(cfg.sessions ?? {}).length} session override(s) kept under their existing names; only newly created sessions use the new naming. Use sessions.set/sessions.remove to adjust individual mappings.`);
|
|
28948
|
-
}
|
|
28949
|
-
cacheInvalidation = { cleared: ["peer IDs", "user context"], reason: "Peer name changed" };
|
|
28950
29408
|
break;
|
|
28951
29409
|
case "aiPeer":
|
|
28952
29410
|
previousValue = cfg.aiPeer;
|
|
28953
29411
|
cfg.aiPeer = String(value);
|
|
28954
|
-
clearPeerCache();
|
|
28955
|
-
clearClaudeContextOnly();
|
|
28956
|
-
cacheInvalidation = { cleared: ["peer IDs", "claude context"], reason: "AI peer changed" };
|
|
28957
29412
|
break;
|
|
28958
29413
|
case "workspace":
|
|
28959
29414
|
previousValue = cfg.workspace;
|
|
28960
29415
|
cfg.workspace = String(value);
|
|
28961
|
-
if (String(value) !== String(previousValue)) {
|
|
28962
|
-
clearIdCache();
|
|
28963
|
-
clearUserContextOnly();
|
|
28964
|
-
clearClaudeContextOnly();
|
|
28965
|
-
cacheInvalidation = { cleared: ["all IDs", "all context"], reason: "Workspace changed" };
|
|
28966
|
-
}
|
|
28967
|
-
break;
|
|
28968
|
-
case "endpoint.environment": {
|
|
28969
|
-
previousValue = cfg.endpoint?.environment;
|
|
28970
|
-
if (!cfg.endpoint)
|
|
28971
|
-
cfg.endpoint = {};
|
|
28972
|
-
const envVal = String(value) === "platform" ? "production" : String(value);
|
|
28973
|
-
cfg.endpoint.environment = envVal;
|
|
28974
|
-
cfg.endpoint.baseUrl = undefined;
|
|
28975
|
-
saveRootField("endpoint", cfg.endpoint);
|
|
28976
|
-
clearIdCache();
|
|
28977
|
-
clearUserContextOnly();
|
|
28978
|
-
clearClaudeContextOnly();
|
|
28979
|
-
cacheInvalidation = { cleared: ["all IDs", "all context"], reason: "Endpoint changed" };
|
|
28980
|
-
break;
|
|
28981
|
-
}
|
|
28982
|
-
case "endpoint.baseUrl":
|
|
28983
|
-
previousValue = cfg.endpoint?.baseUrl;
|
|
28984
|
-
if (!cfg.endpoint)
|
|
28985
|
-
cfg.endpoint = {};
|
|
28986
|
-
cfg.endpoint.baseUrl = String(value);
|
|
28987
|
-
cfg.endpoint.environment = undefined;
|
|
28988
|
-
saveRootField("endpoint", cfg.endpoint);
|
|
28989
|
-
clearIdCache();
|
|
28990
|
-
clearUserContextOnly();
|
|
28991
|
-
clearClaudeContextOnly();
|
|
28992
|
-
cacheInvalidation = { cleared: ["all IDs", "all context"], reason: "Endpoint URL changed" };
|
|
28993
|
-
break;
|
|
28994
|
-
case "sessionStrategy": {
|
|
28995
|
-
const prevStrategy = cfg.sessionStrategy ?? "per-directory";
|
|
28996
|
-
previousValue = prevStrategy;
|
|
28997
|
-
cfg.sessionStrategy = String(value);
|
|
28998
|
-
if (String(value) !== prevStrategy && String(value) !== "per-directory" && Object.keys(cfg.sessions ?? {}).length > 0) {
|
|
28999
|
-
warnings.push(`${Object.keys(cfg.sessions ?? {}).length} session override(s) kept but inactive: overrides only apply under the per-directory strategy.`);
|
|
29000
|
-
}
|
|
29001
|
-
break;
|
|
29002
|
-
}
|
|
29003
|
-
case "sessionPeerPrefix": {
|
|
29004
|
-
const prevPrefix = cfg.sessionPeerPrefix !== false;
|
|
29005
|
-
previousValue = prevPrefix;
|
|
29006
|
-
cfg.sessionPeerPrefix = coerceBoolean(value);
|
|
29007
|
-
if (cfg.sessionPeerPrefix !== prevPrefix && Object.keys(cfg.sessions ?? {}).length > 0) {
|
|
29008
|
-
warnings.push(`${Object.keys(cfg.sessions ?? {}).length} session override(s) kept under their existing names; only newly created sessions use the new naming. Use sessions.set/sessions.remove to adjust individual mappings.`);
|
|
29009
|
-
}
|
|
29010
|
-
break;
|
|
29011
|
-
}
|
|
29012
|
-
case "globalOverride":
|
|
29013
|
-
previousValue = cfg.globalOverride ?? false;
|
|
29014
|
-
cfg.globalOverride = coerceBoolean(value);
|
|
29015
|
-
saveRootField("globalOverride", cfg.globalOverride);
|
|
29016
|
-
break;
|
|
29017
|
-
case "enabled":
|
|
29018
|
-
previousValue = cfg.enabled;
|
|
29019
|
-
cfg.enabled = coerceBoolean(value);
|
|
29020
|
-
break;
|
|
29021
|
-
case "logging":
|
|
29022
|
-
previousValue = cfg.logging;
|
|
29023
|
-
cfg.logging = coerceBoolean(value);
|
|
29024
|
-
break;
|
|
29025
|
-
case "saveMessages":
|
|
29026
|
-
previousValue = cfg.saveMessages;
|
|
29027
|
-
cfg.saveMessages = coerceBoolean(value);
|
|
29028
|
-
break;
|
|
29029
|
-
case "messageUpload.maxUserTokens":
|
|
29030
|
-
previousValue = cfg.messageUpload?.maxUserTokens;
|
|
29031
|
-
if (!cfg.messageUpload)
|
|
29032
|
-
cfg.messageUpload = {};
|
|
29033
|
-
cfg.messageUpload.maxUserTokens = value === null ? undefined : Number(value);
|
|
29034
|
-
break;
|
|
29035
|
-
case "messageUpload.maxAssistantTokens":
|
|
29036
|
-
previousValue = cfg.messageUpload?.maxAssistantTokens;
|
|
29037
|
-
if (!cfg.messageUpload)
|
|
29038
|
-
cfg.messageUpload = {};
|
|
29039
|
-
cfg.messageUpload.maxAssistantTokens = value === null ? undefined : Number(value);
|
|
29040
|
-
break;
|
|
29041
|
-
case "messageUpload.summarizeAssistant":
|
|
29042
|
-
previousValue = cfg.messageUpload?.summarizeAssistant;
|
|
29043
|
-
if (!cfg.messageUpload)
|
|
29044
|
-
cfg.messageUpload = {};
|
|
29045
|
-
cfg.messageUpload.summarizeAssistant = coerceBoolean(value);
|
|
29046
|
-
break;
|
|
29047
|
-
case "contextRefresh.messageThreshold":
|
|
29048
|
-
previousValue = cfg.contextRefresh?.messageThreshold;
|
|
29049
|
-
if (!cfg.contextRefresh)
|
|
29050
|
-
cfg.contextRefresh = {};
|
|
29051
|
-
cfg.contextRefresh.messageThreshold = Number(value);
|
|
29052
|
-
break;
|
|
29053
|
-
case "contextRefresh.ttlSeconds":
|
|
29054
|
-
previousValue = cfg.contextRefresh?.ttlSeconds;
|
|
29055
|
-
if (!cfg.contextRefresh)
|
|
29056
|
-
cfg.contextRefresh = {};
|
|
29057
|
-
cfg.contextRefresh.ttlSeconds = Number(value);
|
|
29058
|
-
break;
|
|
29059
|
-
case "contextRefresh.skipDialectic":
|
|
29060
|
-
previousValue = cfg.contextRefresh?.skipDialectic;
|
|
29061
|
-
if (!cfg.contextRefresh)
|
|
29062
|
-
cfg.contextRefresh = {};
|
|
29063
|
-
cfg.contextRefresh.skipDialectic = coerceBoolean(value);
|
|
29064
|
-
break;
|
|
29065
|
-
case "reasoningLevel":
|
|
29066
|
-
previousValue = cfg.reasoningLevel ?? "medium";
|
|
29067
|
-
cfg.reasoningLevel = String(value);
|
|
29068
|
-
break;
|
|
29069
|
-
case "observationMode":
|
|
29070
|
-
previousValue = cfg.observationMode ?? "unified";
|
|
29071
|
-
cfg.observationMode = String(value);
|
|
29072
|
-
break;
|
|
29073
|
-
case "statusline": {
|
|
29074
|
-
const mode = String(value).toLowerCase();
|
|
29075
|
-
if (mode !== "on" && mode !== "off") {
|
|
29076
|
-
return {
|
|
29077
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: "statusline must be one of: on, off" }, null, 2) }],
|
|
29078
|
-
isError: true
|
|
29079
|
-
};
|
|
29080
|
-
}
|
|
29081
|
-
previousValue = cfg.statusline ?? "on";
|
|
29082
|
-
cfg.statusline = mode;
|
|
29083
|
-
saveRootField("statusline", cfg.statusline);
|
|
29084
|
-
break;
|
|
29085
|
-
}
|
|
29086
|
-
case "redactPatterns": {
|
|
29087
|
-
const arr = coerceStringArray(value);
|
|
29088
|
-
if (!arr) {
|
|
29089
|
-
return {
|
|
29090
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: "redactPatterns must be an array of regex strings" }, null, 2) }],
|
|
29091
|
-
isError: true
|
|
29092
|
-
};
|
|
29093
|
-
}
|
|
29094
|
-
for (const source of arr) {
|
|
29095
|
-
const err = validateRedactPattern(source);
|
|
29096
|
-
if (err) {
|
|
29097
|
-
return {
|
|
29098
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: err }, null, 2) }],
|
|
29099
|
-
isError: true
|
|
29100
|
-
};
|
|
29101
|
-
}
|
|
29102
|
-
}
|
|
29103
|
-
previousValue = cfg.redactPatterns;
|
|
29104
|
-
cfg.redactPatterns = arr;
|
|
29105
|
-
break;
|
|
29106
|
-
}
|
|
29107
|
-
case "injection.sessionStart": {
|
|
29108
|
-
const arr = validateComponentArray(value, SESSION_START_COMPONENTS, field);
|
|
29109
|
-
if (!Array.isArray(arr))
|
|
29110
|
-
return arr;
|
|
29111
|
-
previousValue = cfg.injection?.sessionStart;
|
|
29112
|
-
if (!cfg.injection)
|
|
29113
|
-
cfg.injection = {};
|
|
29114
|
-
cfg.injection.sessionStart = arr;
|
|
29115
|
-
break;
|
|
29116
|
-
}
|
|
29117
|
-
case "injection.perTurn": {
|
|
29118
|
-
const raw = coerceStringArray(value);
|
|
29119
|
-
const arr = validateComponentArray(raw ? normalizePerTurn(raw) : value, PER_TURN_COMPONENTS, field);
|
|
29120
|
-
if (!Array.isArray(arr))
|
|
29121
|
-
return arr;
|
|
29122
|
-
previousValue = cfg.injection?.perTurn;
|
|
29123
|
-
if (!cfg.injection)
|
|
29124
|
-
cfg.injection = {};
|
|
29125
|
-
cfg.injection.perTurn = arr;
|
|
29126
|
-
break;
|
|
29127
|
-
}
|
|
29128
|
-
case "injection.showContents": {
|
|
29129
|
-
const raw = coerceStringArray(value);
|
|
29130
|
-
const arr = validateComponentArray(raw ? normalizePerTurn(raw) : value, PER_TURN_COMPONENTS, field);
|
|
29131
|
-
if (!Array.isArray(arr))
|
|
29132
|
-
return arr;
|
|
29133
|
-
previousValue = cfg.injection?.showContents;
|
|
29134
|
-
if (!cfg.injection)
|
|
29135
|
-
cfg.injection = {};
|
|
29136
|
-
cfg.injection.showContents = arr;
|
|
29137
|
-
break;
|
|
29138
|
-
}
|
|
29139
|
-
case "injection.searchTopK":
|
|
29140
|
-
previousValue = cfg.injection?.searchTopK;
|
|
29141
|
-
if (!cfg.injection)
|
|
29142
|
-
cfg.injection = {};
|
|
29143
|
-
cfg.injection.searchTopK = Number(value);
|
|
29144
|
-
break;
|
|
29145
|
-
case "injection.maxConclusions":
|
|
29146
|
-
previousValue = cfg.injection?.maxConclusions;
|
|
29147
|
-
if (!cfg.injection)
|
|
29148
|
-
cfg.injection = {};
|
|
29149
|
-
cfg.injection.maxConclusions = Number(value);
|
|
29150
|
-
break;
|
|
29151
|
-
case "injection.searchMaxDistance":
|
|
29152
|
-
previousValue = cfg.injection?.searchMaxDistance;
|
|
29153
|
-
if (!cfg.injection)
|
|
29154
|
-
cfg.injection = {};
|
|
29155
|
-
cfg.injection.searchMaxDistance = Number(value);
|
|
29156
|
-
break;
|
|
29157
|
-
case "injection.sessionContextTokens": {
|
|
29158
|
-
const tokens = Number(value);
|
|
29159
|
-
if (!Number.isFinite(tokens) || tokens <= 0) {
|
|
29160
|
-
return {
|
|
29161
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: "injection.sessionContextTokens must be a positive number" }, null, 2) }],
|
|
29162
|
-
isError: true
|
|
29163
|
-
};
|
|
29164
|
-
}
|
|
29165
|
-
previousValue = cfg.injection?.sessionContextTokens;
|
|
29166
|
-
if (!cfg.injection)
|
|
29167
|
-
cfg.injection = {};
|
|
29168
|
-
cfg.injection.sessionContextTokens = tokens;
|
|
29169
|
-
break;
|
|
29170
|
-
}
|
|
29171
|
-
case "rememberTool":
|
|
29172
|
-
previousValue = cfg.rememberTool;
|
|
29173
|
-
cfg.rememberTool = coerceBoolean(value);
|
|
29174
|
-
break;
|
|
29175
|
-
case "injection.searchQuerySource":
|
|
29176
|
-
if (value !== "topics" && value !== "prompt") {
|
|
29177
|
-
return {
|
|
29178
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: `injection.searchQuerySource must be "topics" or "prompt"` }, null, 2) }],
|
|
29179
|
-
isError: true
|
|
29180
|
-
};
|
|
29181
|
-
}
|
|
29182
|
-
previousValue = cfg.injection?.searchQuerySource;
|
|
29183
|
-
if (!cfg.injection)
|
|
29184
|
-
cfg.injection = {};
|
|
29185
|
-
cfg.injection.searchQuerySource = value;
|
|
29186
|
-
break;
|
|
29187
|
-
case "injection.dialecticTemplate":
|
|
29188
|
-
previousValue = cfg.injection?.dialecticTemplate;
|
|
29189
|
-
if (!cfg.injection)
|
|
29190
|
-
cfg.injection = {};
|
|
29191
|
-
cfg.injection.dialecticTemplate = String(value);
|
|
29192
|
-
break;
|
|
29193
|
-
case "injection.dialecticReasoning": {
|
|
29194
|
-
const level = String(value);
|
|
29195
|
-
if (!REASONING_LEVELS.includes(level)) {
|
|
29196
|
-
return {
|
|
29197
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: `injection.dialecticReasoning must be one of: ${REASONING_LEVELS.join(", ")}` }, null, 2) }],
|
|
29198
|
-
isError: true
|
|
29199
|
-
};
|
|
29200
|
-
}
|
|
29201
|
-
previousValue = cfg.injection?.dialecticReasoning;
|
|
29202
|
-
if (!cfg.injection)
|
|
29203
|
-
cfg.injection = {};
|
|
29204
|
-
cfg.injection.dialecticReasoning = level;
|
|
29205
|
-
break;
|
|
29206
|
-
}
|
|
29207
|
-
case "sessions.set": {
|
|
29208
|
-
const obj = value;
|
|
29209
|
-
const path = obj?.path;
|
|
29210
|
-
const sName = obj?.name;
|
|
29211
|
-
if (typeof path !== "string" || !path || typeof sName !== "string" || !sName) {
|
|
29212
|
-
return {
|
|
29213
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: "sessions.set requires {path: string, name: string}" }, null, 2) }],
|
|
29214
|
-
isError: true
|
|
29215
|
-
};
|
|
29216
|
-
}
|
|
29217
|
-
if (!cfg.sessions)
|
|
29218
|
-
cfg.sessions = {};
|
|
29219
|
-
previousValue = cfg.sessions[path] ?? null;
|
|
29220
|
-
cfg.sessions[path] = sName;
|
|
29221
29416
|
break;
|
|
29222
|
-
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
const rPath = obj?.path;
|
|
29226
|
-
if (typeof rPath !== "string" || !rPath) {
|
|
29227
|
-
return {
|
|
29228
|
-
content: [{ type: "text", text: JSON.stringify({ success: false, error: "sessions.remove requires {path: string}" }, null, 2) }],
|
|
29229
|
-
isError: true
|
|
29230
|
-
};
|
|
29231
|
-
}
|
|
29232
|
-
if (!cfg.sessions)
|
|
29233
|
-
cfg.sessions = {};
|
|
29234
|
-
previousValue = cfg.sessions[rPath] ?? null;
|
|
29235
|
-
delete cfg.sessions[rPath];
|
|
29417
|
+
case "baseUrl":
|
|
29418
|
+
previousValue = cfg.baseUrl;
|
|
29419
|
+
cfg.baseUrl = String(value);
|
|
29236
29420
|
break;
|
|
29237
|
-
}
|
|
29238
29421
|
default:
|
|
29239
29422
|
return {
|
|
29240
29423
|
content: [{
|
|
@@ -29244,32 +29427,20 @@ function handleSetConfig(args) {
|
|
|
29244
29427
|
isError: true
|
|
29245
29428
|
};
|
|
29246
29429
|
}
|
|
29247
|
-
saveConfig(cfg);
|
|
29430
|
+
await saveConfig(cfg, field);
|
|
29431
|
+
if (!loadConfig2()) {
|
|
29432
|
+
warnings.push(`No credential is saved for ${cfg.baseUrl} (an API key is dropped when the server changes). Run /honcho setup to add one.`);
|
|
29433
|
+
}
|
|
29248
29434
|
const endpointInfo = getEndpointInfo(cfg);
|
|
29249
29435
|
const resolved = {
|
|
29250
29436
|
peerName: cfg.peerName,
|
|
29251
29437
|
aiPeer: cfg.aiPeer,
|
|
29252
29438
|
workspace: cfg.workspace,
|
|
29253
|
-
endpoint: endpointInfo
|
|
29254
|
-
sessionStrategy: cfg.sessionStrategy ?? "per-directory",
|
|
29255
|
-
sessionPeerPrefix: cfg.sessionPeerPrefix !== false,
|
|
29256
|
-
sessions: cfg.sessions ?? {},
|
|
29257
|
-
messageUpload: cfg.messageUpload ?? {},
|
|
29258
|
-
contextRefresh: cfg.contextRefresh ?? {},
|
|
29259
|
-
reasoningLevel: cfg.reasoningLevel ?? "medium",
|
|
29260
|
-
observationMode: cfg.observationMode ?? "unified",
|
|
29261
|
-
statusline: cfg.statusline ?? "on",
|
|
29262
|
-
redactPatterns: cfg.redactPatterns ?? [],
|
|
29263
|
-
injection: cfg.injection ?? {},
|
|
29264
|
-
rememberTool: cfg.rememberTool === true,
|
|
29265
|
-
enabled: cfg.enabled !== false,
|
|
29266
|
-
logging: cfg.logging !== false,
|
|
29267
|
-
saveMessages: cfg.saveMessages !== false
|
|
29439
|
+
endpoint: endpointInfo
|
|
29268
29440
|
};
|
|
29269
29441
|
const restartWarning = SESSION_AFFECTING_FIELDS.has(field) ? "Close and restart all active Claude Code sessions. Open sessions still use the previous config and will write to the wrong Honcho session." : undefined;
|
|
29270
|
-
const
|
|
29271
|
-
const
|
|
29272
|
-
const sessionUrl = newSessionName ? honchoSessionUrl(cfg.workspace, newSessionName) : undefined;
|
|
29442
|
+
const newSessionName = SESSION_AFFECTING_FIELDS.has(field) ? getSessionName() : undefined;
|
|
29443
|
+
const sessionUrl = newSessionName ? honchoSessionUrl(cfg, newSessionName) ?? undefined : undefined;
|
|
29273
29444
|
return {
|
|
29274
29445
|
content: [{
|
|
29275
29446
|
type: "text",
|
|
@@ -29278,7 +29449,6 @@ function handleSetConfig(args) {
|
|
|
29278
29449
|
field,
|
|
29279
29450
|
previousValue,
|
|
29280
29451
|
newValue: value,
|
|
29281
|
-
cacheInvalidation,
|
|
29282
29452
|
restartWarning,
|
|
29283
29453
|
sessionUrl,
|
|
29284
29454
|
warnings: warnings.length ? warnings : undefined,
|
|
@@ -29288,36 +29458,36 @@ function handleSetConfig(args) {
|
|
|
29288
29458
|
};
|
|
29289
29459
|
}
|
|
29290
29460
|
var DIALECTIC_TIMEOUT_MS = 120000;
|
|
29291
|
-
var
|
|
29292
|
-
|
|
29293
|
-
|
|
29294
|
-
|
|
29295
|
-
|
|
29296
|
-
|
|
29297
|
-
|
|
29298
|
-
|
|
29299
|
-
|
|
29300
|
-
|
|
29301
|
-
items: { type: "string" },
|
|
29302
|
-
minItems: 1,
|
|
29303
|
-
maxItems: REMEMBER_MAX_QUERIES,
|
|
29304
|
-
description: `1–${REMEMBER_MAX_QUERIES} natural-language questions about the user, dispatched concurrently.`
|
|
29305
|
-
},
|
|
29306
|
-
reasoning_level: {
|
|
29307
|
-
type: "string",
|
|
29308
|
-
enum: [...REMEMBER_REASONING_LEVELS],
|
|
29309
|
-
description: "Reasoning budget applied to every query in this call. 'low' = quick lookups, " + "'medium' = general recall, 'high' = complex reasoning over the user's context."
|
|
29310
|
-
}
|
|
29311
|
-
},
|
|
29312
|
-
required: ["queries", "reasoning_level"]
|
|
29313
|
-
}
|
|
29461
|
+
var DERIVED_ONLY = { level: { in: ["deductive", "inductive", "contradiction"] } };
|
|
29462
|
+
function parseScope(value) {
|
|
29463
|
+
const names = (Array.isArray(value) ? value : [value]).filter((v) => typeof v === "string" && v.trim() !== "").map((v) => v.trim());
|
|
29464
|
+
if (names.length === 0)
|
|
29465
|
+
return;
|
|
29466
|
+
return names.length === 1 ? names[0] : names;
|
|
29467
|
+
}
|
|
29468
|
+
var NOT_CONFIGURED_RESULT = {
|
|
29469
|
+
content: [{ type: "text", text: "Honcho isn't configured; run /honcho setup to connect it, then try again." }],
|
|
29470
|
+
isError: true
|
|
29314
29471
|
};
|
|
29472
|
+
function createClients() {
|
|
29473
|
+
const config = loadConfig2();
|
|
29474
|
+
if (!config)
|
|
29475
|
+
return null;
|
|
29476
|
+
return {
|
|
29477
|
+
config,
|
|
29478
|
+
honcho: new import_sdk2.Honcho(getHonchoClientOptions(config)),
|
|
29479
|
+
honchoDialectic: new import_sdk2.Honcho({
|
|
29480
|
+
...getHonchoClientOptions(config),
|
|
29481
|
+
timeout: DIALECTIC_TIMEOUT_MS,
|
|
29482
|
+
maxRetries: 0
|
|
29483
|
+
})
|
|
29484
|
+
};
|
|
29485
|
+
}
|
|
29315
29486
|
async function runMcpServer() {
|
|
29316
29487
|
setDetectedHost("claude_code");
|
|
29317
|
-
|
|
29318
|
-
if (!
|
|
29319
|
-
console.error("[honcho-mcp] Not configured. Run
|
|
29320
|
-
process.exit(1);
|
|
29488
|
+
let clients = createClients();
|
|
29489
|
+
if (!clients) {
|
|
29490
|
+
console.error("[honcho-mcp] Not configured. Run /honcho setup");
|
|
29321
29491
|
}
|
|
29322
29492
|
const server = new Server({
|
|
29323
29493
|
name: "honcho",
|
|
@@ -29327,20 +29497,12 @@ async function runMcpServer() {
|
|
|
29327
29497
|
tools: {}
|
|
29328
29498
|
}
|
|
29329
29499
|
});
|
|
29330
|
-
const honcho = new import_sdk.Honcho(getHonchoClientOptions(config));
|
|
29331
|
-
const honchoDialectic = new import_sdk.Honcho({
|
|
29332
|
-
...getHonchoClientOptions(config),
|
|
29333
|
-
timeout: DIALECTIC_TIMEOUT_MS,
|
|
29334
|
-
maxRetries: 0
|
|
29335
|
-
});
|
|
29336
|
-
const rememberEnabled = config.rememberTool === true;
|
|
29337
29500
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
29338
29501
|
return {
|
|
29339
29502
|
tools: [
|
|
29340
|
-
...rememberEnabled ? [REMEMBER_TOOL] : [],
|
|
29341
29503
|
{
|
|
29342
29504
|
name: "search",
|
|
29343
|
-
description: "Semantic search across messages and
|
|
29505
|
+
description: "Semantic search across messages and derived conclusions. Messages are searched across all sessions by default; use scope='session' for this chat's session only. Conclusions are always searched workspace-wide.",
|
|
29344
29506
|
inputSchema: {
|
|
29345
29507
|
type: "object",
|
|
29346
29508
|
properties: {
|
|
@@ -29356,8 +29518,8 @@ async function runMcpServer() {
|
|
|
29356
29518
|
scope: {
|
|
29357
29519
|
type: "string",
|
|
29358
29520
|
enum: ["session", "workspace"],
|
|
29359
|
-
description: "Search scope. '
|
|
29360
|
-
default: "
|
|
29521
|
+
description: "Search scope. 'workspace' (default) searches all sessions. 'session' searches only this Claude Code chat's session.",
|
|
29522
|
+
default: "workspace"
|
|
29361
29523
|
}
|
|
29362
29524
|
},
|
|
29363
29525
|
required: ["query"]
|
|
@@ -29365,18 +29527,27 @@ async function runMcpServer() {
|
|
|
29365
29527
|
},
|
|
29366
29528
|
{
|
|
29367
29529
|
name: "chat",
|
|
29368
|
-
description: "
|
|
29530
|
+
description: "Ask Honcho a question and get a reasoned answer from memory. By default it answers about the user from everything Honcho knows about them. " + "Pass `scope` to answer only from the sessions in one or more scopes (each Claude Code chat is in a scope for its git repository and one for its machine). " + "Pass `workspace: true` to ask about the whole workspace — every peer, not just the user.",
|
|
29369
29531
|
inputSchema: {
|
|
29370
29532
|
type: "object",
|
|
29371
29533
|
properties: {
|
|
29372
29534
|
query: {
|
|
29373
29535
|
type: "string",
|
|
29374
|
-
description: "Natural language question
|
|
29536
|
+
description: "Natural language question"
|
|
29537
|
+
},
|
|
29538
|
+
scope: {
|
|
29539
|
+
anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
|
|
29540
|
+
description: "Scope name, or several, to limit the answer to (e.g. a repository or machine name)."
|
|
29541
|
+
},
|
|
29542
|
+
workspace: {
|
|
29543
|
+
type: "boolean",
|
|
29544
|
+
description: "Ask across the whole workspace instead of about the user. Combine with `scope` to limit it.",
|
|
29545
|
+
default: false
|
|
29375
29546
|
},
|
|
29376
29547
|
reasoning_level: {
|
|
29377
29548
|
type: "string",
|
|
29378
29549
|
enum: ["minimal", "low", "medium", "high", "max"],
|
|
29379
|
-
description: "Reasoning budget for this query. Use 'low' for simple lookups, 'medium' for general questions, 'high'/'max' for complex reasoning
|
|
29550
|
+
description: "Reasoning budget for this query. Use 'low' for simple lookups, 'medium' for general questions, 'high'/'max' for complex reasoning. Defaults to 'medium'."
|
|
29380
29551
|
}
|
|
29381
29552
|
},
|
|
29382
29553
|
required: ["query"]
|
|
@@ -29398,7 +29569,7 @@ async function runMcpServer() {
|
|
|
29398
29569
|
},
|
|
29399
29570
|
{
|
|
29400
29571
|
name: "list_conclusions",
|
|
29401
|
-
description: "List conclusions Honcho has
|
|
29572
|
+
description: "List conclusions Honcho has derived about the user (explicit conclusions are excluded). Use this to review what is remembered before creating duplicates, or to find IDs for deletion.",
|
|
29402
29573
|
inputSchema: {
|
|
29403
29574
|
type: "object",
|
|
29404
29575
|
properties: {
|
|
@@ -29417,7 +29588,7 @@ async function runMcpServer() {
|
|
|
29417
29588
|
},
|
|
29418
29589
|
{
|
|
29419
29590
|
name: "query_conclusions",
|
|
29420
|
-
description: "Semantically search conclusions Honcho has
|
|
29591
|
+
description: "Semantically search conclusions Honcho has derived about the user (explicit conclusions are excluded). Returns IDs usable with delete_conclusion — much faster than paging list_conclusions when looking for something specific.",
|
|
29421
29592
|
inputSchema: {
|
|
29422
29593
|
type: "object",
|
|
29423
29594
|
properties: {
|
|
@@ -29448,36 +29619,6 @@ async function runMcpServer() {
|
|
|
29448
29619
|
required: ["id"]
|
|
29449
29620
|
}
|
|
29450
29621
|
},
|
|
29451
|
-
{
|
|
29452
|
-
name: "get_briefing",
|
|
29453
|
-
description: "Load the session briefing: the stored long summary of this session plus the user's peer card (identity/attribute profile). " + "Call this once at the start of a session when the session-start directives ask for it, or any time you need to catch up on where the session left off.",
|
|
29454
|
-
inputSchema: {
|
|
29455
|
-
type: "object",
|
|
29456
|
-
properties: {}
|
|
29457
|
-
}
|
|
29458
|
-
},
|
|
29459
|
-
{
|
|
29460
|
-
name: "get_context",
|
|
29461
|
-
description: "Retrieve the full context object (representation + peer card) from Honcho for the current user. Scoped by observation mode.",
|
|
29462
|
-
inputSchema: {
|
|
29463
|
-
type: "object",
|
|
29464
|
-
properties: {
|
|
29465
|
-
max_conclusions: {
|
|
29466
|
-
type: "number",
|
|
29467
|
-
description: "Max conclusions to include (default: 25)",
|
|
29468
|
-
default: 25
|
|
29469
|
-
}
|
|
29470
|
-
}
|
|
29471
|
-
}
|
|
29472
|
-
},
|
|
29473
|
-
{
|
|
29474
|
-
name: "get_representation",
|
|
29475
|
-
description: "Retrieve the user's representation string from Honcho. Lighter-weight than get_context.",
|
|
29476
|
-
inputSchema: {
|
|
29477
|
-
type: "object",
|
|
29478
|
-
properties: {}
|
|
29479
|
-
}
|
|
29480
|
-
},
|
|
29481
29622
|
{
|
|
29482
29623
|
name: "get_config",
|
|
29483
29624
|
description: "Get the current Honcho plugin configuration, cache state, and diagnostic warnings",
|
|
@@ -29488,7 +29629,7 @@ async function runMcpServer() {
|
|
|
29488
29629
|
},
|
|
29489
29630
|
{
|
|
29490
29631
|
name: "set_config",
|
|
29491
|
-
description: "Update a Honcho plugin configuration field. Dangerous changes (workspace,
|
|
29632
|
+
description: "Update a Honcho plugin configuration field. Dangerous changes (workspace, baseUrl) require confirm=true.",
|
|
29492
29633
|
inputSchema: {
|
|
29493
29634
|
type: "object",
|
|
29494
29635
|
properties: {
|
|
@@ -29499,44 +29640,15 @@ async function runMcpServer() {
|
|
|
29499
29640
|
"peerName",
|
|
29500
29641
|
"aiPeer",
|
|
29501
29642
|
"workspace",
|
|
29502
|
-
"
|
|
29503
|
-
"endpoint.environment",
|
|
29504
|
-
"endpoint.baseUrl",
|
|
29505
|
-
"sessionStrategy",
|
|
29506
|
-
"sessionPeerPrefix",
|
|
29507
|
-
"enabled",
|
|
29508
|
-
"logging",
|
|
29509
|
-
"saveMessages",
|
|
29510
|
-
"messageUpload.maxUserTokens",
|
|
29511
|
-
"messageUpload.maxAssistantTokens",
|
|
29512
|
-
"messageUpload.summarizeAssistant",
|
|
29513
|
-
"contextRefresh.messageThreshold",
|
|
29514
|
-
"contextRefresh.ttlSeconds",
|
|
29515
|
-
"contextRefresh.skipDialectic",
|
|
29516
|
-
"reasoningLevel",
|
|
29517
|
-
"observationMode",
|
|
29518
|
-
"redactPatterns",
|
|
29519
|
-
"injection.sessionStart",
|
|
29520
|
-
"injection.perTurn",
|
|
29521
|
-
"injection.showContents",
|
|
29522
|
-
"injection.searchTopK",
|
|
29523
|
-
"injection.maxConclusions",
|
|
29524
|
-
"injection.searchMaxDistance",
|
|
29525
|
-
"injection.searchQuerySource",
|
|
29526
|
-
"injection.sessionContextTokens",
|
|
29527
|
-
"injection.dialecticTemplate",
|
|
29528
|
-
"injection.dialecticReasoning",
|
|
29529
|
-
"rememberTool",
|
|
29530
|
-
"sessions.set",
|
|
29531
|
-
"sessions.remove"
|
|
29643
|
+
"baseUrl"
|
|
29532
29644
|
]
|
|
29533
29645
|
},
|
|
29534
29646
|
value: {
|
|
29535
|
-
description:
|
|
29647
|
+
description: "New value."
|
|
29536
29648
|
},
|
|
29537
29649
|
confirm: {
|
|
29538
29650
|
type: "boolean",
|
|
29539
|
-
description: "Required true for dangerous changes (workspace,
|
|
29651
|
+
description: "Required true for dangerous changes (workspace, baseUrl). Without it, returns a warning instead of applying."
|
|
29540
29652
|
}
|
|
29541
29653
|
},
|
|
29542
29654
|
required: ["field", "value"]
|
|
@@ -29547,22 +29659,28 @@ async function runMcpServer() {
|
|
|
29547
29659
|
});
|
|
29548
29660
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
29549
29661
|
const { name, arguments: args } = request.params;
|
|
29550
|
-
|
|
29662
|
+
clients ??= createClients();
|
|
29663
|
+
if (!clients) {
|
|
29664
|
+
return NOT_CONFIGURED_RESULT;
|
|
29665
|
+
}
|
|
29666
|
+
const { config, honcho, honchoDialectic } = clients;
|
|
29667
|
+
await refreshCredential(config);
|
|
29668
|
+
setClientApiKey(honcho, config.apiKey);
|
|
29669
|
+
setClientApiKey(honchoDialectic, config.apiKey);
|
|
29551
29670
|
if (name === "get_config") {
|
|
29552
|
-
return handleGetConfig(
|
|
29671
|
+
return handleGetConfig();
|
|
29553
29672
|
}
|
|
29554
29673
|
if (name === "set_config") {
|
|
29555
29674
|
return handleSetConfig(args);
|
|
29556
29675
|
}
|
|
29557
29676
|
if (name === "list_conclusions" || name === "delete_conclusion" || name === "query_conclusions") {
|
|
29558
29677
|
try {
|
|
29559
|
-
const
|
|
29560
|
-
const
|
|
29561
|
-
const conclusionScope = scopePeer.conclusionsOf(config.peerName);
|
|
29678
|
+
const userPeer = await honcho.peer(config.peerName);
|
|
29679
|
+
const conclusionScope = userPeer.conclusionsOf(config.peerName);
|
|
29562
29680
|
if (name === "list_conclusions") {
|
|
29563
29681
|
const page = args?.page ?? 1;
|
|
29564
29682
|
const size = Math.min(args?.size ?? 20, 100);
|
|
29565
|
-
const result = await conclusionScope.list({ page, size });
|
|
29683
|
+
const result = await conclusionScope.list({ page, size, filters: DERIVED_ONLY });
|
|
29566
29684
|
const items = result.items.map((c) => ({
|
|
29567
29685
|
id: c.id,
|
|
29568
29686
|
content: c.content,
|
|
@@ -29578,7 +29696,7 @@ async function runMcpServer() {
|
|
|
29578
29696
|
if (name === "query_conclusions") {
|
|
29579
29697
|
const query = args?.query;
|
|
29580
29698
|
const topK = Math.min(args?.top_k ?? 10, 50);
|
|
29581
|
-
const conclusions = await conclusionScope.query(query, topK);
|
|
29699
|
+
const conclusions = await conclusionScope.query(query, topK, undefined, DERIVED_ONLY);
|
|
29582
29700
|
const items = conclusions.map((c) => ({
|
|
29583
29701
|
id: c.id,
|
|
29584
29702
|
content: c.content,
|
|
@@ -29600,23 +29718,25 @@ async function runMcpServer() {
|
|
|
29600
29718
|
};
|
|
29601
29719
|
}
|
|
29602
29720
|
}
|
|
29603
|
-
const sessionName = getSessionName(
|
|
29721
|
+
const sessionName = getSessionName();
|
|
29722
|
+
const needsSession = name === "create_conclusion" || name === "search" && args?.scope === "session";
|
|
29723
|
+
if (!sessionName && needsSession) {
|
|
29724
|
+
return {
|
|
29725
|
+
content: [{ type: "text", text: "Error: no Claude Code session id available" }],
|
|
29726
|
+
isError: true
|
|
29727
|
+
};
|
|
29728
|
+
}
|
|
29604
29729
|
try {
|
|
29605
|
-
const session = await honcho.session(sessionName);
|
|
29606
|
-
const observationMode = getObservationMode(config);
|
|
29730
|
+
const session = needsSession && sessionName ? await honcho.session(sessionName) : undefined;
|
|
29607
29731
|
const userPeer = await honcho.peer(config.peerName);
|
|
29608
|
-
const
|
|
29609
|
-
const activePeer = observationMode === "unified" ? userPeer : aiPeer;
|
|
29610
|
-
const chatTarget = observationMode === "unified" ? undefined : config.peerName;
|
|
29611
|
-
const contextTarget = observationMode === "unified" ? undefined : config.peerName;
|
|
29732
|
+
const scope = parseScope(args?.scope);
|
|
29612
29733
|
switch (name) {
|
|
29613
29734
|
case "search": {
|
|
29614
29735
|
const query = args?.query;
|
|
29615
29736
|
const limit = args?.limit ?? 10;
|
|
29616
|
-
const scope = args?.scope ?? "session";
|
|
29617
29737
|
const [messages, conclusions] = await Promise.all([
|
|
29618
|
-
|
|
29619
|
-
|
|
29738
|
+
session ? session.search(query, { limit }) : honcho.search(query, { limit }),
|
|
29739
|
+
userPeer.conclusionsOf(config.peerName).query(query, limit, undefined, DERIVED_ONLY).catch(() => [])
|
|
29620
29740
|
]);
|
|
29621
29741
|
const results = {
|
|
29622
29742
|
messages: messages.map((msg) => ({
|
|
@@ -29641,16 +29761,21 @@ async function runMcpServer() {
|
|
|
29641
29761
|
}
|
|
29642
29762
|
case "chat": {
|
|
29643
29763
|
const query = args?.query;
|
|
29644
|
-
const reasoningLevel = args?.reasoning_level ??
|
|
29764
|
+
const reasoningLevel = args?.reasoning_level ?? "medium";
|
|
29645
29765
|
let deadlineTimer;
|
|
29646
29766
|
const deadline = new Promise((_, reject) => {
|
|
29647
29767
|
deadlineTimer = setTimeout(() => reject(new Error(`Dialectic call exceeded ${DIALECTIC_TIMEOUT_MS}ms`)), DIALECTIC_TIMEOUT_MS);
|
|
29648
29768
|
});
|
|
29649
29769
|
const chatFlow = (async () => {
|
|
29650
|
-
|
|
29770
|
+
if (args?.workspace === true) {
|
|
29771
|
+
return honchoDialectic.chat(query, {
|
|
29772
|
+
...scope ? { scope } : {},
|
|
29773
|
+
reasoningLevel
|
|
29774
|
+
});
|
|
29775
|
+
}
|
|
29776
|
+
const dialecticPeer = await honchoDialectic.peer(userPeer.id);
|
|
29651
29777
|
return dialecticPeer.chat(query, {
|
|
29652
|
-
...
|
|
29653
|
-
session,
|
|
29778
|
+
...scope ? { scope } : {},
|
|
29654
29779
|
reasoningLevel
|
|
29655
29780
|
});
|
|
29656
29781
|
})();
|
|
@@ -29669,77 +29794,9 @@ async function runMcpServer() {
|
|
|
29669
29794
|
chatFlow.catch(() => {});
|
|
29670
29795
|
}
|
|
29671
29796
|
}
|
|
29672
|
-
case "honcho_remember": {
|
|
29673
|
-
const queries = Array.isArray(args?.queries) ? args.queries.map(String).map((q) => q.trim()).filter(Boolean) : [];
|
|
29674
|
-
const reasoningLevel = args?.reasoning_level;
|
|
29675
|
-
if (queries.length === 0) {
|
|
29676
|
-
return {
|
|
29677
|
-
content: [{ type: "text", text: "honcho_remember requires a non-empty `queries` array." }],
|
|
29678
|
-
isError: true
|
|
29679
|
-
};
|
|
29680
|
-
}
|
|
29681
|
-
if (queries.length > REMEMBER_MAX_QUERIES) {
|
|
29682
|
-
return {
|
|
29683
|
-
content: [{ type: "text", text: `honcho_remember accepts at most ${REMEMBER_MAX_QUERIES} queries (got ${queries.length}).` }],
|
|
29684
|
-
isError: true
|
|
29685
|
-
};
|
|
29686
|
-
}
|
|
29687
|
-
if (!REMEMBER_REASONING_LEVELS.includes(reasoningLevel)) {
|
|
29688
|
-
return {
|
|
29689
|
-
content: [{ type: "text", text: `reasoning_level must be one of: ${REMEMBER_REASONING_LEVELS.join(", ")}` }],
|
|
29690
|
-
isError: true
|
|
29691
|
-
};
|
|
29692
|
-
}
|
|
29693
|
-
let deadlineTimer;
|
|
29694
|
-
const deadline = new Promise((_, reject) => {
|
|
29695
|
-
deadlineTimer = setTimeout(() => reject(new Error(`honcho_remember exceeded ${DIALECTIC_TIMEOUT_MS}ms`)), DIALECTIC_TIMEOUT_MS);
|
|
29696
|
-
});
|
|
29697
|
-
const batchStart = Date.now();
|
|
29698
|
-
const fanOut = (async () => {
|
|
29699
|
-
const dialecticPeer = await honchoDialectic.peer(activePeer.id);
|
|
29700
|
-
return Promise.allSettled(queries.map(async (q) => {
|
|
29701
|
-
const qStart = Date.now();
|
|
29702
|
-
const answer = await dialecticPeer.chat(q, {
|
|
29703
|
-
...chatTarget ? { target: chatTarget } : {},
|
|
29704
|
-
session,
|
|
29705
|
-
reasoningLevel
|
|
29706
|
-
});
|
|
29707
|
-
return { answer, ms: Date.now() - qStart };
|
|
29708
|
-
}));
|
|
29709
|
-
})();
|
|
29710
|
-
try {
|
|
29711
|
-
const settled = await Promise.race([fanOut, deadline]);
|
|
29712
|
-
const totalMs = Date.now() - batchStart;
|
|
29713
|
-
const secs = (ms) => `${(ms / 1000).toFixed(1)}s`;
|
|
29714
|
-
const hits = settled.filter((r) => r.status === "fulfilled" && r.value.answer).length;
|
|
29715
|
-
const header = `recalled ${hits} insight${hits === 1 ? "" : "s"} · ` + `${queries.length} dialectic${queries.length === 1 ? "" : "s"} @ ${reasoningLevel} · ${secs(totalMs)}`;
|
|
29716
|
-
const blocks = settled.map((r, i) => {
|
|
29717
|
-
const label = `q${i + 1} "${queries[i]}"`;
|
|
29718
|
-
if (r.status === "rejected") {
|
|
29719
|
-
const msg = r.reason instanceof Error ? r.reason.message : String(r.reason);
|
|
29720
|
-
return `${label} — failed
|
|
29721
|
-
→ (error: ${msg})`;
|
|
29722
|
-
}
|
|
29723
|
-
const { answer, ms } = r.value;
|
|
29724
|
-
const body = answer && answer.trim() ? answer.trim() : "(no memory found)";
|
|
29725
|
-
return `${label} — ${secs(ms)}
|
|
29726
|
-
→ ${body}`;
|
|
29727
|
-
});
|
|
29728
|
-
return {
|
|
29729
|
-
content: [{ type: "text", text: `${header}
|
|
29730
|
-
|
|
29731
|
-
${blocks.join(`
|
|
29732
|
-
|
|
29733
|
-
`)}` }]
|
|
29734
|
-
};
|
|
29735
|
-
} finally {
|
|
29736
|
-
clearTimeout(deadlineTimer);
|
|
29737
|
-
fanOut.catch(() => {});
|
|
29738
|
-
}
|
|
29739
|
-
}
|
|
29740
29797
|
case "create_conclusion": {
|
|
29741
29798
|
const content = args?.content;
|
|
29742
|
-
const conclusions = await
|
|
29799
|
+
const conclusions = await userPeer.conclusionsOf(config.peerName).create({
|
|
29743
29800
|
content,
|
|
29744
29801
|
sessionId: session.id
|
|
29745
29802
|
});
|
|
@@ -29752,50 +29809,6 @@ ${blocks.join(`
|
|
|
29752
29809
|
]
|
|
29753
29810
|
};
|
|
29754
29811
|
}
|
|
29755
|
-
case "get_briefing": {
|
|
29756
|
-
const [summariesResult, ctxResult] = await Promise.allSettled([
|
|
29757
|
-
session.summaries(),
|
|
29758
|
-
activePeer.context({
|
|
29759
|
-
...contextTarget ? { target: contextTarget } : {},
|
|
29760
|
-
maxConclusions: 25,
|
|
29761
|
-
includeMostFrequent: true
|
|
29762
|
-
})
|
|
29763
|
-
]);
|
|
29764
|
-
const summary = summariesResult.status === "fulfilled" ? summariesResult.value?.longSummary?.content?.trim() : null;
|
|
29765
|
-
const card = ctxResult.status === "fulfilled" ? (ctxResult.value?.peerCard ?? []).filter((item) => item?.trim()) : [];
|
|
29766
|
-
const parts = [];
|
|
29767
|
-
if (summary)
|
|
29768
|
-
parts.push(`## Session summary
|
|
29769
|
-
${summary}`);
|
|
29770
|
-
if (card.length)
|
|
29771
|
-
parts.push(`## Peer card (${card.length} items)
|
|
29772
|
-
${card.map((item) => `- ${item}`).join(`
|
|
29773
|
-
`)}`);
|
|
29774
|
-
if (parts.length === 0)
|
|
29775
|
-
parts.push("No briefing available yet — no stored session summary or peer card.");
|
|
29776
|
-
return {
|
|
29777
|
-
content: [{ type: "text", text: parts.join(`
|
|
29778
|
-
|
|
29779
|
-
`) }]
|
|
29780
|
-
};
|
|
29781
|
-
}
|
|
29782
|
-
case "get_context": {
|
|
29783
|
-
const maxConclusions = args?.max_conclusions ?? 25;
|
|
29784
|
-
const ctx = await activePeer.context({
|
|
29785
|
-
...contextTarget ? { target: contextTarget } : {},
|
|
29786
|
-
maxConclusions,
|
|
29787
|
-
includeMostFrequent: true
|
|
29788
|
-
});
|
|
29789
|
-
return {
|
|
29790
|
-
content: [{ type: "text", text: JSON.stringify(ctx, null, 2) }]
|
|
29791
|
-
};
|
|
29792
|
-
}
|
|
29793
|
-
case "get_representation": {
|
|
29794
|
-
const rep = await activePeer.representation(contextTarget ? { target: contextTarget } : undefined);
|
|
29795
|
-
return {
|
|
29796
|
-
content: [{ type: "text", text: typeof rep === "string" ? rep : JSON.stringify(rep, null, 2) }]
|
|
29797
|
-
};
|
|
29798
|
-
}
|
|
29799
29812
|
default:
|
|
29800
29813
|
return {
|
|
29801
29814
|
content: [
|
|
@@ -29826,5 +29839,5 @@ ${card.map((item) => `- ${item}`).join(`
|
|
|
29826
29839
|
// mcp-server.ts
|
|
29827
29840
|
await runMcpServer();
|
|
29828
29841
|
|
|
29829
|
-
//# debugId=
|
|
29842
|
+
//# debugId=1E81E5A00B44292F64756E2164756E21
|
|
29830
29843
|
//# sourceMappingURL=mcp-server.js.map
|