@contextstream/mcp-server 0.3.36 → 0.3.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +302 -55
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4144,6 +4144,7 @@ async function request(config, path7, options = {}) {
|
|
|
4144
4144
|
const url = `${apiUrl.replace(/\/$/, "")}${apiPath}`;
|
|
4145
4145
|
const maxRetries = options.retries ?? MAX_RETRIES;
|
|
4146
4146
|
const baseDelay = options.retryDelay ?? BASE_DELAY;
|
|
4147
|
+
const timeoutMs = typeof options.timeoutMs === "number" && options.timeoutMs > 0 ? options.timeoutMs : 18e4;
|
|
4147
4148
|
const headers = {
|
|
4148
4149
|
"Content-Type": "application/json",
|
|
4149
4150
|
"User-Agent": userAgent
|
|
@@ -4162,7 +4163,7 @@ async function request(config, path7, options = {}) {
|
|
|
4162
4163
|
let lastError = null;
|
|
4163
4164
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
4164
4165
|
const controller = new AbortController();
|
|
4165
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
4166
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
4166
4167
|
if (options.signal) {
|
|
4167
4168
|
options.signal.addEventListener("abort", () => controller.abort());
|
|
4168
4169
|
}
|
|
@@ -4176,7 +4177,8 @@ async function request(config, path7, options = {}) {
|
|
|
4176
4177
|
if (options.signal?.aborted) {
|
|
4177
4178
|
throw new HttpError(0, "Request cancelled by user");
|
|
4178
4179
|
}
|
|
4179
|
-
|
|
4180
|
+
const seconds = Math.ceil(timeoutMs / 1e3);
|
|
4181
|
+
throw new HttpError(0, `Request timeout after ${seconds} seconds`);
|
|
4180
4182
|
}
|
|
4181
4183
|
lastError = new HttpError(0, error?.message || "Network error");
|
|
4182
4184
|
if (attempt < maxRetries) {
|
|
@@ -4197,7 +4199,12 @@ async function request(config, path7, options = {}) {
|
|
|
4197
4199
|
if (!response.ok) {
|
|
4198
4200
|
const rateLimit = parseRateLimitHeaders(response.headers);
|
|
4199
4201
|
const enrichedPayload = attachRateLimit(payload, rateLimit);
|
|
4200
|
-
const message =
|
|
4202
|
+
const message = rewriteNotFoundMessage({
|
|
4203
|
+
status: response.status,
|
|
4204
|
+
path: apiPath,
|
|
4205
|
+
message: extractErrorMessage(enrichedPayload, response.statusText),
|
|
4206
|
+
payload: enrichedPayload
|
|
4207
|
+
});
|
|
4201
4208
|
lastError = new HttpError(response.status, message, enrichedPayload);
|
|
4202
4209
|
const apiCode = extractErrorCode(enrichedPayload);
|
|
4203
4210
|
if (apiCode) lastError.code = apiCode;
|
|
@@ -4279,6 +4286,19 @@ function extractErrorCode(payload) {
|
|
|
4279
4286
|
if (typeof payload.code === "string" && payload.code.trim()) return payload.code.trim();
|
|
4280
4287
|
return null;
|
|
4281
4288
|
}
|
|
4289
|
+
function detectIntegrationProvider(path7) {
|
|
4290
|
+
if (/\/github(\/|$)/i.test(path7)) return "github";
|
|
4291
|
+
if (/\/slack(\/|$)/i.test(path7)) return "slack";
|
|
4292
|
+
return null;
|
|
4293
|
+
}
|
|
4294
|
+
function rewriteNotFoundMessage(input) {
|
|
4295
|
+
if (input.status !== 404) return input.message;
|
|
4296
|
+
const provider = detectIntegrationProvider(input.path);
|
|
4297
|
+
if (!provider) return input.message;
|
|
4298
|
+
if (!/\/workspaces\//i.test(input.path)) return input.message;
|
|
4299
|
+
const label = provider === "github" ? "GitHub" : "Slack";
|
|
4300
|
+
return `${label} integration is not connected for this workspace. Connect ${label} in workspace integrations and retry. If you intended a different workspace, pass workspace_id.`;
|
|
4301
|
+
}
|
|
4282
4302
|
|
|
4283
4303
|
// src/files.ts
|
|
4284
4304
|
import * as fs from "fs";
|
|
@@ -4676,6 +4696,20 @@ var CacheKeys = {
|
|
|
4676
4696
|
};
|
|
4677
4697
|
var globalCache = new MemoryCache();
|
|
4678
4698
|
|
|
4699
|
+
// src/version.ts
|
|
4700
|
+
import { createRequire } from "module";
|
|
4701
|
+
function getVersion() {
|
|
4702
|
+
try {
|
|
4703
|
+
const require2 = createRequire(import.meta.url);
|
|
4704
|
+
const pkg = require2("../package.json");
|
|
4705
|
+
const version = pkg?.version;
|
|
4706
|
+
if (typeof version === "string" && version.trim()) return version.trim();
|
|
4707
|
+
} catch {
|
|
4708
|
+
}
|
|
4709
|
+
return "unknown";
|
|
4710
|
+
}
|
|
4711
|
+
var VERSION = getVersion();
|
|
4712
|
+
|
|
4679
4713
|
// src/client.ts
|
|
4680
4714
|
var uuidSchema = external_exports.string().uuid();
|
|
4681
4715
|
function unwrapApiResponse(result) {
|
|
@@ -4709,6 +4743,8 @@ function normalizeNodeType(input) {
|
|
|
4709
4743
|
);
|
|
4710
4744
|
}
|
|
4711
4745
|
}
|
|
4746
|
+
var AI_PLAN_TIMEOUT_MS = 5e4;
|
|
4747
|
+
var AI_PLAN_RETRIES = 0;
|
|
4712
4748
|
var ContextStreamClient = class {
|
|
4713
4749
|
constructor(config) {
|
|
4714
4750
|
this.config = config;
|
|
@@ -4745,6 +4781,28 @@ var ContextStreamClient = class {
|
|
|
4745
4781
|
project_id: input.project_id || defaultProjectId
|
|
4746
4782
|
};
|
|
4747
4783
|
}
|
|
4784
|
+
coerceUuid(value) {
|
|
4785
|
+
if (!value) return void 0;
|
|
4786
|
+
try {
|
|
4787
|
+
uuidSchema.parse(value);
|
|
4788
|
+
return value;
|
|
4789
|
+
} catch {
|
|
4790
|
+
return void 0;
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
requireNonEmpty(value, field, tool) {
|
|
4794
|
+
const text = String(value ?? "").trim();
|
|
4795
|
+
if (!text) {
|
|
4796
|
+
throw new HttpError(400, `${field} is required for ${tool}`);
|
|
4797
|
+
}
|
|
4798
|
+
return text;
|
|
4799
|
+
}
|
|
4800
|
+
isBadRequestDeserialization(error) {
|
|
4801
|
+
if (!(error instanceof HttpError)) return false;
|
|
4802
|
+
if (String(error.code || "").toUpperCase() !== "BAD_REQUEST") return false;
|
|
4803
|
+
const message = String(error.message || "").toLowerCase();
|
|
4804
|
+
return message.includes("deserialize") || message.includes("deserial");
|
|
4805
|
+
}
|
|
4748
4806
|
// Auth
|
|
4749
4807
|
me() {
|
|
4750
4808
|
return request(this.config, "/auth/me");
|
|
@@ -4785,9 +4843,9 @@ var ContextStreamClient = class {
|
|
|
4785
4843
|
const suffix = query.toString() ? `?${query.toString()}` : "";
|
|
4786
4844
|
return request(this.config, `/workspaces${suffix}`);
|
|
4787
4845
|
}
|
|
4788
|
-
async createWorkspace(input) {
|
|
4846
|
+
async createWorkspace(input, options) {
|
|
4789
4847
|
const result = await request(this.config, "/workspaces", { body: input });
|
|
4790
|
-
return unwrapApiResponse(result);
|
|
4848
|
+
return options?.unwrap === false ? result : unwrapApiResponse(result);
|
|
4791
4849
|
}
|
|
4792
4850
|
async updateWorkspace(workspaceId, input) {
|
|
4793
4851
|
uuidSchema.parse(workspaceId);
|
|
@@ -4812,10 +4870,10 @@ var ContextStreamClient = class {
|
|
|
4812
4870
|
const suffix = query.toString() ? `?${query.toString()}` : "";
|
|
4813
4871
|
return request(this.config, `/projects${suffix}`);
|
|
4814
4872
|
}
|
|
4815
|
-
async createProject(input) {
|
|
4873
|
+
async createProject(input, options) {
|
|
4816
4874
|
const payload = this.withDefaults(input);
|
|
4817
4875
|
const result = await request(this.config, "/projects", { body: payload });
|
|
4818
|
-
return unwrapApiResponse(result);
|
|
4876
|
+
return options?.unwrap === false ? result : unwrapApiResponse(result);
|
|
4819
4877
|
}
|
|
4820
4878
|
async updateProject(projectId, input) {
|
|
4821
4879
|
uuidSchema.parse(projectId);
|
|
@@ -4936,44 +4994,233 @@ var ContextStreamClient = class {
|
|
|
4936
4994
|
const withDefaults = this.withDefaults(params || {});
|
|
4937
4995
|
if (withDefaults.workspace_id) query.set("workspace_id", withDefaults.workspace_id);
|
|
4938
4996
|
if (withDefaults.project_id) query.set("project_id", withDefaults.project_id);
|
|
4997
|
+
if (params?.category) query.set("category", params.category);
|
|
4939
4998
|
if (params?.limit) query.set("limit", String(params.limit));
|
|
4940
4999
|
const suffix = query.toString() ? `?${query.toString()}` : "";
|
|
4941
5000
|
return request(this.config, `/memory/search/decisions${suffix}`, { method: "GET" });
|
|
4942
5001
|
}
|
|
4943
5002
|
// Graph
|
|
4944
5003
|
graphRelated(body) {
|
|
4945
|
-
|
|
5004
|
+
const withDefaults = this.withDefaults(body);
|
|
5005
|
+
const apiBody = {
|
|
5006
|
+
node_id: withDefaults.node_id,
|
|
5007
|
+
relation_types: body.relation_types,
|
|
5008
|
+
max_depth: body.max_depth ?? body.limit,
|
|
5009
|
+
workspace_id: withDefaults.workspace_id,
|
|
5010
|
+
project_id: withDefaults.project_id
|
|
5011
|
+
};
|
|
5012
|
+
return request(this.config, "/graph/knowledge/related", { body: apiBody });
|
|
4946
5013
|
}
|
|
4947
5014
|
graphPath(body) {
|
|
4948
|
-
|
|
5015
|
+
const withDefaults = this.withDefaults(body);
|
|
5016
|
+
const from = body.from ?? withDefaults.source_id;
|
|
5017
|
+
const to = body.to ?? withDefaults.target_id;
|
|
5018
|
+
const apiBody = {
|
|
5019
|
+
from,
|
|
5020
|
+
to,
|
|
5021
|
+
max_depth: body.max_depth,
|
|
5022
|
+
workspace_id: withDefaults.workspace_id,
|
|
5023
|
+
project_id: withDefaults.project_id
|
|
5024
|
+
};
|
|
5025
|
+
return request(this.config, "/graph/knowledge/path", { body: apiBody });
|
|
4949
5026
|
}
|
|
4950
5027
|
graphDecisions(body) {
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
5028
|
+
const withDefaults = this.withDefaults(body || {});
|
|
5029
|
+
const now = /* @__PURE__ */ new Date();
|
|
5030
|
+
const defaultFrom = new Date(now);
|
|
5031
|
+
defaultFrom.setUTCFullYear(now.getUTCFullYear() - 5);
|
|
5032
|
+
const apiBody = {
|
|
5033
|
+
workspace_id: withDefaults.workspace_id,
|
|
5034
|
+
project_id: withDefaults.project_id,
|
|
5035
|
+
category: body?.category ?? "general",
|
|
5036
|
+
from: body?.from ?? defaultFrom.toISOString(),
|
|
5037
|
+
to: body?.to ?? now.toISOString()
|
|
5038
|
+
};
|
|
5039
|
+
return request(this.config, "/graph/knowledge/decisions", { body: apiBody });
|
|
5040
|
+
}
|
|
5041
|
+
async graphDependencies(body) {
|
|
5042
|
+
const rawType = String(body.target?.type ?? "").toLowerCase();
|
|
5043
|
+
let targetType = "function";
|
|
5044
|
+
switch (rawType) {
|
|
5045
|
+
case "module":
|
|
5046
|
+
case "file":
|
|
5047
|
+
case "path":
|
|
5048
|
+
targetType = "module";
|
|
5049
|
+
break;
|
|
5050
|
+
case "type":
|
|
5051
|
+
targetType = "type";
|
|
5052
|
+
break;
|
|
5053
|
+
case "variable":
|
|
5054
|
+
case "var":
|
|
5055
|
+
case "const":
|
|
5056
|
+
targetType = "variable";
|
|
5057
|
+
break;
|
|
5058
|
+
case "function":
|
|
5059
|
+
case "method":
|
|
5060
|
+
targetType = "function";
|
|
5061
|
+
break;
|
|
5062
|
+
default:
|
|
5063
|
+
targetType = "function";
|
|
5064
|
+
}
|
|
5065
|
+
const target = targetType === "module" ? { type: targetType, path: body.target.path ?? body.target.id } : { type: targetType, id: body.target.id };
|
|
5066
|
+
return request(this.config, "/graph/dependencies", {
|
|
5067
|
+
body: {
|
|
5068
|
+
target,
|
|
5069
|
+
max_depth: body.max_depth,
|
|
5070
|
+
include_transitive: body.include_transitive
|
|
5071
|
+
}
|
|
5072
|
+
});
|
|
4955
5073
|
}
|
|
4956
5074
|
graphCallPath(body) {
|
|
4957
|
-
|
|
5075
|
+
const apiBody = {
|
|
5076
|
+
from_function_id: body.from_function_id ?? body.source?.id,
|
|
5077
|
+
to_function_id: body.to_function_id ?? body.target?.id,
|
|
5078
|
+
max_depth: body.max_depth
|
|
5079
|
+
};
|
|
5080
|
+
return request(this.config, "/graph/call-paths", { body: apiBody });
|
|
4958
5081
|
}
|
|
4959
5082
|
graphImpact(body) {
|
|
4960
|
-
|
|
5083
|
+
const targetId = body.target_id ?? body.target?.id;
|
|
5084
|
+
const elementName = body.element_name ?? body.target?.id ?? body.target?.type ?? "unknown";
|
|
5085
|
+
const apiBody = {
|
|
5086
|
+
change_type: body.change_type ?? "modify_signature",
|
|
5087
|
+
target_id: targetId,
|
|
5088
|
+
element_name: elementName
|
|
5089
|
+
};
|
|
5090
|
+
return request(this.config, "/graph/impact-analysis", { body: apiBody });
|
|
4961
5091
|
}
|
|
4962
5092
|
// AI
|
|
5093
|
+
buildAiContextRequest(input) {
|
|
5094
|
+
const payload = {
|
|
5095
|
+
query: input.query
|
|
5096
|
+
};
|
|
5097
|
+
if (input.project_id) payload.project_id = input.project_id;
|
|
5098
|
+
if (typeof input.max_tokens === "number") payload.max_tokens = input.max_tokens;
|
|
5099
|
+
if (typeof input.token_budget === "number") payload.token_budget = input.token_budget;
|
|
5100
|
+
if (typeof input.token_soft_limit === "number") payload.token_soft_limit = input.token_soft_limit;
|
|
5101
|
+
if (typeof input.include_dependencies === "boolean") {
|
|
5102
|
+
payload.include_dependencies = input.include_dependencies;
|
|
5103
|
+
}
|
|
5104
|
+
if (typeof input.include_tests === "boolean") {
|
|
5105
|
+
payload.include_tests = input.include_tests;
|
|
5106
|
+
}
|
|
5107
|
+
const rawLimit = typeof input.max_sections === "number" ? input.max_sections : input.limit;
|
|
5108
|
+
if (typeof rawLimit === "number" && Number.isFinite(rawLimit)) {
|
|
5109
|
+
const bounded = Math.max(1, Math.min(20, Math.floor(rawLimit)));
|
|
5110
|
+
payload.max_sections = bounded;
|
|
5111
|
+
}
|
|
5112
|
+
return payload;
|
|
5113
|
+
}
|
|
5114
|
+
buildAiPlanRequest(input) {
|
|
5115
|
+
const requirements = input.requirements ?? input.description;
|
|
5116
|
+
if (!requirements || !requirements.trim()) {
|
|
5117
|
+
throw new Error("description is required for ai_plan");
|
|
5118
|
+
}
|
|
5119
|
+
const payload = {
|
|
5120
|
+
requirements
|
|
5121
|
+
};
|
|
5122
|
+
if (input.project_id) payload.project_id = input.project_id;
|
|
5123
|
+
if (typeof input.max_steps === "number") payload.max_steps = input.max_steps;
|
|
5124
|
+
if (input.context) payload.context = input.context;
|
|
5125
|
+
if (input.constraints) payload.constraints = input.constraints;
|
|
5126
|
+
return payload;
|
|
5127
|
+
}
|
|
5128
|
+
normalizeTaskGranularity(value) {
|
|
5129
|
+
if (!value) return void 0;
|
|
5130
|
+
const normalized = value.trim().toLowerCase();
|
|
5131
|
+
if (normalized === "low" || normalized === "medium" || normalized === "high") {
|
|
5132
|
+
return normalized;
|
|
5133
|
+
}
|
|
5134
|
+
if (normalized === "coarse" || normalized === "broad") return "low";
|
|
5135
|
+
if (normalized === "fine" || normalized === "detailed") return "high";
|
|
5136
|
+
return void 0;
|
|
5137
|
+
}
|
|
5138
|
+
buildAiTasksRequest(input) {
|
|
5139
|
+
const plan = input.plan ?? input.description;
|
|
5140
|
+
if (!plan || !plan.trim()) {
|
|
5141
|
+
throw new Error("description is required for ai_tasks");
|
|
5142
|
+
}
|
|
5143
|
+
const payload = {
|
|
5144
|
+
plan
|
|
5145
|
+
};
|
|
5146
|
+
if (input.project_id) payload.project_id = input.project_id;
|
|
5147
|
+
const granularity = this.normalizeTaskGranularity(input.granularity);
|
|
5148
|
+
if (granularity) payload.granularity = granularity;
|
|
5149
|
+
if (typeof input.max_tasks === "number") payload.max_tasks = input.max_tasks;
|
|
5150
|
+
if (typeof input.include_estimates === "boolean") {
|
|
5151
|
+
payload.include_estimates = input.include_estimates;
|
|
5152
|
+
}
|
|
5153
|
+
return payload;
|
|
5154
|
+
}
|
|
4963
5155
|
aiContext(body) {
|
|
4964
|
-
|
|
5156
|
+
const { query, project_id, limit, workspace_id } = this.withDefaults(body);
|
|
5157
|
+
const safeQuery = this.requireNonEmpty(query, "query", "ai_context");
|
|
5158
|
+
const safeProjectId = this.coerceUuid(project_id);
|
|
5159
|
+
const payload = this.buildAiContextRequest({ query: safeQuery, project_id: safeProjectId, limit });
|
|
5160
|
+
return request(this.config, "/ai/context", { body: payload, workspaceId: workspace_id }).catch((error) => {
|
|
5161
|
+
if (this.isBadRequestDeserialization(error)) {
|
|
5162
|
+
const minimalPayload = this.buildAiContextRequest({ query: safeQuery });
|
|
5163
|
+
return request(this.config, "/ai/context", { body: minimalPayload, workspaceId: workspace_id });
|
|
5164
|
+
}
|
|
5165
|
+
throw error;
|
|
5166
|
+
});
|
|
4965
5167
|
}
|
|
4966
5168
|
aiEmbeddings(body) {
|
|
4967
5169
|
return request(this.config, "/ai/embeddings", { body });
|
|
4968
5170
|
}
|
|
4969
5171
|
aiPlan(body) {
|
|
4970
|
-
|
|
5172
|
+
const { description, project_id } = this.withDefaults(body);
|
|
5173
|
+
const safeDescription = this.requireNonEmpty(description, "description", "ai_plan");
|
|
5174
|
+
const safeProjectId = this.coerceUuid(project_id);
|
|
5175
|
+
const payload = this.buildAiPlanRequest({ description: safeDescription, project_id: safeProjectId });
|
|
5176
|
+
const requestOptions = { body: payload, timeoutMs: AI_PLAN_TIMEOUT_MS, retries: AI_PLAN_RETRIES };
|
|
5177
|
+
return request(this.config, "/ai/plan/generate", requestOptions).catch((error) => {
|
|
5178
|
+
if (this.isBadRequestDeserialization(error)) {
|
|
5179
|
+
const minimalPayload = this.buildAiPlanRequest({ description: safeDescription });
|
|
5180
|
+
return request(this.config, "/ai/plan/generate", {
|
|
5181
|
+
body: minimalPayload,
|
|
5182
|
+
timeoutMs: AI_PLAN_TIMEOUT_MS,
|
|
5183
|
+
retries: AI_PLAN_RETRIES
|
|
5184
|
+
});
|
|
5185
|
+
}
|
|
5186
|
+
if (error instanceof HttpError && error.status === 0 && /timeout/i.test(error.message)) {
|
|
5187
|
+
const seconds = Math.ceil(AI_PLAN_TIMEOUT_MS / 1e3);
|
|
5188
|
+
throw new HttpError(
|
|
5189
|
+
503,
|
|
5190
|
+
`AI plan generation timed out after ${seconds} seconds. Try a shorter description, reduce max_steps, or retry later.`
|
|
5191
|
+
);
|
|
5192
|
+
}
|
|
5193
|
+
throw error;
|
|
5194
|
+
});
|
|
4971
5195
|
}
|
|
4972
5196
|
aiTasks(body) {
|
|
4973
|
-
|
|
5197
|
+
if (!body.description && body.plan_id) {
|
|
5198
|
+
throw new Error("plan_id is not supported for ai_tasks; provide description instead.");
|
|
5199
|
+
}
|
|
5200
|
+
const { description, project_id, granularity } = this.withDefaults(body);
|
|
5201
|
+
const safeDescription = this.requireNonEmpty(description, "description", "ai_tasks");
|
|
5202
|
+
const safeProjectId = this.coerceUuid(project_id);
|
|
5203
|
+
const payload = this.buildAiTasksRequest({ description: safeDescription, project_id: safeProjectId, granularity });
|
|
5204
|
+
return request(this.config, "/ai/tasks/generate", { body: payload }).catch((error) => {
|
|
5205
|
+
if (this.isBadRequestDeserialization(error)) {
|
|
5206
|
+
const minimalPayload = this.buildAiTasksRequest({ description: safeDescription });
|
|
5207
|
+
return request(this.config, "/ai/tasks/generate", { body: minimalPayload });
|
|
5208
|
+
}
|
|
5209
|
+
throw error;
|
|
5210
|
+
});
|
|
4974
5211
|
}
|
|
4975
5212
|
aiEnhancedContext(body) {
|
|
4976
|
-
|
|
5213
|
+
const { query, project_id, limit, workspace_id } = this.withDefaults(body);
|
|
5214
|
+
const safeQuery = this.requireNonEmpty(query, "query", "ai_enhanced_context");
|
|
5215
|
+
const safeProjectId = this.coerceUuid(project_id);
|
|
5216
|
+
const payload = this.buildAiContextRequest({ query: safeQuery, project_id: safeProjectId, limit });
|
|
5217
|
+
return request(this.config, "/ai/context/enhanced", { body: payload, workspaceId: workspace_id }).catch((error) => {
|
|
5218
|
+
if (this.isBadRequestDeserialization(error)) {
|
|
5219
|
+
const minimalPayload = this.buildAiContextRequest({ query: safeQuery });
|
|
5220
|
+
return request(this.config, "/ai/context/enhanced", { body: minimalPayload, workspaceId: workspace_id });
|
|
5221
|
+
}
|
|
5222
|
+
throw error;
|
|
5223
|
+
});
|
|
4977
5224
|
}
|
|
4978
5225
|
// Project extended operations (with caching)
|
|
4979
5226
|
async getProject(projectId) {
|
|
@@ -5126,11 +5373,11 @@ var ContextStreamClient = class {
|
|
|
5126
5373
|
return request(this.config, `/memory/search/summary/${workspaceId}`, { method: "GET" });
|
|
5127
5374
|
}
|
|
5128
5375
|
// Graph extended operations
|
|
5129
|
-
findCircularDependencies(projectId) {
|
|
5376
|
+
async findCircularDependencies(projectId) {
|
|
5130
5377
|
uuidSchema.parse(projectId);
|
|
5131
5378
|
return request(this.config, `/graph/circular-dependencies/${projectId}`, { method: "GET" });
|
|
5132
5379
|
}
|
|
5133
|
-
findUnusedCode(projectId) {
|
|
5380
|
+
async findUnusedCode(projectId) {
|
|
5134
5381
|
uuidSchema.parse(projectId);
|
|
5135
5382
|
return request(this.config, `/graph/unused-code/${projectId}`, { method: "GET" });
|
|
5136
5383
|
}
|
|
@@ -5429,7 +5676,8 @@ var ContextStreamClient = class {
|
|
|
5429
5676
|
project_id: params.project_id,
|
|
5430
5677
|
session_id: params.session_id,
|
|
5431
5678
|
include_recent_memory: params.include_recent_memory ?? true,
|
|
5432
|
-
include_decisions: params.include_decisions ?? true
|
|
5679
|
+
include_decisions: params.include_decisions ?? true,
|
|
5680
|
+
client_version: VERSION
|
|
5433
5681
|
}
|
|
5434
5682
|
});
|
|
5435
5683
|
const contextData = "data" in result && result.data ? result.data : result;
|
|
@@ -5600,6 +5848,25 @@ var ContextStreamClient = class {
|
|
|
5600
5848
|
}
|
|
5601
5849
|
});
|
|
5602
5850
|
}
|
|
5851
|
+
/**
|
|
5852
|
+
* Remember something using the session/remember endpoint.
|
|
5853
|
+
* This is a simpler interface than captureContext and supports await_indexing.
|
|
5854
|
+
*/
|
|
5855
|
+
async sessionRemember(params) {
|
|
5856
|
+
const withDefaults = this.withDefaults(params);
|
|
5857
|
+
if (!withDefaults.workspace_id) {
|
|
5858
|
+
throw new Error("workspace_id is required for session_remember. Set defaultWorkspaceId in config or provide workspace_id.");
|
|
5859
|
+
}
|
|
5860
|
+
return request(this.config, "/session/remember", {
|
|
5861
|
+
body: {
|
|
5862
|
+
content: params.content,
|
|
5863
|
+
workspace_id: withDefaults.workspace_id,
|
|
5864
|
+
project_id: withDefaults.project_id,
|
|
5865
|
+
importance: params.importance,
|
|
5866
|
+
await_indexing: params.await_indexing
|
|
5867
|
+
}
|
|
5868
|
+
});
|
|
5869
|
+
}
|
|
5603
5870
|
/**
|
|
5604
5871
|
* Search memory with automatic context enrichment.
|
|
5605
5872
|
* Returns both direct matches and related context.
|
|
@@ -6900,20 +7167,6 @@ ${options.workspaceId ? `# Workspace ID: ${options.workspaceId}` : ""}
|
|
|
6900
7167
|
};
|
|
6901
7168
|
}
|
|
6902
7169
|
|
|
6903
|
-
// src/version.ts
|
|
6904
|
-
import { createRequire } from "module";
|
|
6905
|
-
function getVersion() {
|
|
6906
|
-
try {
|
|
6907
|
-
const require2 = createRequire(import.meta.url);
|
|
6908
|
-
const pkg = require2("../package.json");
|
|
6909
|
-
const version = pkg?.version;
|
|
6910
|
-
if (typeof version === "string" && version.trim()) return version.trim();
|
|
6911
|
-
} catch {
|
|
6912
|
-
}
|
|
6913
|
-
return "unknown";
|
|
6914
|
-
}
|
|
6915
|
-
var VERSION = getVersion();
|
|
6916
|
-
|
|
6917
7170
|
// src/tools.ts
|
|
6918
7171
|
var LESSON_DEDUP_WINDOW_MS = 2 * 60 * 1e3;
|
|
6919
7172
|
var recentLessonCaptures = /* @__PURE__ */ new Map();
|
|
@@ -7263,7 +7516,8 @@ Upgrade: ${upgradeUrl}` : "";
|
|
|
7263
7516
|
},
|
|
7264
7517
|
async (input) => {
|
|
7265
7518
|
const result = await client.deleteWorkspace(input.workspace_id);
|
|
7266
|
-
|
|
7519
|
+
const normalized = result || { success: true, data: { id: input.workspace_id, deleted: true }, error: null, metadata: {} };
|
|
7520
|
+
return { content: [{ type: "text", text: formatContent(normalized) }], structuredContent: toStructured(normalized) };
|
|
7267
7521
|
}
|
|
7268
7522
|
);
|
|
7269
7523
|
registerTool(
|
|
@@ -7322,7 +7576,8 @@ Upgrade: ${upgradeUrl}` : "";
|
|
|
7322
7576
|
},
|
|
7323
7577
|
async (input) => {
|
|
7324
7578
|
const result = await client.deleteProject(input.project_id);
|
|
7325
|
-
|
|
7579
|
+
const normalized = result || { success: true, data: { id: input.project_id, deleted: true }, error: null, metadata: {} };
|
|
7580
|
+
return { content: [{ type: "text", text: formatContent(normalized) }], structuredContent: toStructured(normalized) };
|
|
7326
7581
|
}
|
|
7327
7582
|
);
|
|
7328
7583
|
registerTool(
|
|
@@ -7495,6 +7750,7 @@ Upgrade: ${upgradeUrl}` : "";
|
|
|
7495
7750
|
inputSchema: external_exports.object({
|
|
7496
7751
|
workspace_id: external_exports.string().uuid().optional(),
|
|
7497
7752
|
project_id: external_exports.string().uuid().optional(),
|
|
7753
|
+
category: external_exports.string().optional().describe("Optional category filter. If not specified, returns all decisions regardless of category."),
|
|
7498
7754
|
limit: external_exports.number().optional()
|
|
7499
7755
|
})
|
|
7500
7756
|
},
|
|
@@ -7526,8 +7782,8 @@ Upgrade: ${upgradeUrl}` : "";
|
|
|
7526
7782
|
title: "Knowledge path",
|
|
7527
7783
|
description: "Find path between two nodes",
|
|
7528
7784
|
inputSchema: external_exports.object({
|
|
7529
|
-
source_id: external_exports.string(),
|
|
7530
|
-
target_id: external_exports.string(),
|
|
7785
|
+
source_id: external_exports.string().uuid(),
|
|
7786
|
+
target_id: external_exports.string().uuid(),
|
|
7531
7787
|
workspace_id: external_exports.string().uuid().optional(),
|
|
7532
7788
|
project_id: external_exports.string().uuid().optional()
|
|
7533
7789
|
})
|
|
@@ -8701,7 +8957,8 @@ Example: "Remember that I prefer TypeScript strict mode" or "Remember we decided
|
|
|
8701
8957
|
content: external_exports.string().describe("What to remember (natural language)"),
|
|
8702
8958
|
workspace_id: external_exports.string().uuid().optional(),
|
|
8703
8959
|
project_id: external_exports.string().uuid().optional(),
|
|
8704
|
-
importance: external_exports.enum(["low", "medium", "high"]).optional()
|
|
8960
|
+
importance: external_exports.enum(["low", "medium", "high"]).optional(),
|
|
8961
|
+
await_indexing: external_exports.boolean().optional().describe("If true, wait for indexing to complete before returning. This ensures the content is immediately searchable.")
|
|
8705
8962
|
})
|
|
8706
8963
|
},
|
|
8707
8964
|
async (input) => {
|
|
@@ -8720,22 +8977,12 @@ Example: "Remember that I prefer TypeScript strict mode" or "Remember we decided
|
|
|
8720
8977
|
isError: true
|
|
8721
8978
|
};
|
|
8722
8979
|
}
|
|
8723
|
-
const
|
|
8724
|
-
|
|
8725
|
-
if (lowerContent.includes("prefer") || lowerContent.includes("like") || lowerContent.includes("always")) {
|
|
8726
|
-
eventType = "preference";
|
|
8727
|
-
} else if (lowerContent.includes("decided") || lowerContent.includes("decision") || lowerContent.includes("chose")) {
|
|
8728
|
-
eventType = "decision";
|
|
8729
|
-
} else if (lowerContent.includes("todo") || lowerContent.includes("task") || lowerContent.includes("need to")) {
|
|
8730
|
-
eventType = "task";
|
|
8731
|
-
}
|
|
8732
|
-
const result = await client.captureContext({
|
|
8980
|
+
const result = await client.sessionRemember({
|
|
8981
|
+
content: input.content,
|
|
8733
8982
|
workspace_id: workspaceId,
|
|
8734
8983
|
project_id: projectId,
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
content: input.content,
|
|
8738
|
-
importance: input.importance || "medium"
|
|
8984
|
+
importance: input.importance,
|
|
8985
|
+
await_indexing: input.await_indexing
|
|
8739
8986
|
});
|
|
8740
8987
|
return { content: [{ type: "text", text: `Remembered: ${input.content.slice(0, 100)}...` }], structuredContent: toStructured(result) };
|
|
8741
8988
|
}
|
package/package.json
CHANGED