@kylewadegrove/cutline-mcp-cli 0.7.0 → 0.7.1

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.
@@ -904,6 +904,9 @@ async function cfRegenAssumptions(input, doc) {
904
904
  async function cfRegenExperiments(input, doc) {
905
905
  return callCF("regenExperiments", { input, doc }, 9e4);
906
906
  }
907
+ async function cfGenerateEmbeddings(texts, taskType = "RETRIEVAL_DOCUMENT") {
908
+ return proxy("embeddings.generate", { texts, taskType });
909
+ }
907
910
  async function cfExplorationAgent(message, context) {
908
911
  return callCF("explorationAgent", { message, context }, 12e4);
909
912
  }
@@ -1059,6 +1062,7 @@ export {
1059
1062
  cfPremortemChatAgent,
1060
1063
  cfRegenAssumptions,
1061
1064
  cfRegenExperiments,
1065
+ cfGenerateEmbeddings,
1062
1066
  cfExplorationAgent,
1063
1067
  cfConsultingDiscoveryAgent,
1064
1068
  cfCreateLinearIssues,
@@ -23,6 +23,7 @@ import {
23
23
  cfCreateLinearIssues,
24
24
  cfGenerateAnswer,
25
25
  cfGenerateChatSuggestion,
26
+ cfGenerateEmbeddings,
26
27
  cfGenerateExplorationResponse,
27
28
  cfGenerateTemplateResponse,
28
29
  cfGenerateTrialRun,
@@ -71,7 +72,7 @@ import {
71
72
  upsertEntities,
72
73
  upsertNodes,
73
74
  validateRequestSize
74
- } from "./chunk-XKS3J74N.js";
75
+ } from "./chunk-TJTE5Q2C.js";
75
76
  import {
76
77
  GraphTraverser,
77
78
  computeGenericGraphMetrics,
@@ -85,10 +86,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
85
86
  import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError } from "@modelcontextprotocol/sdk/types.js";
86
87
 
87
88
  // ../mcp/dist/mcp/src/context-graph/embeddings.js
88
- import { GoogleAuth } from "google-auth-library";
89
- var EMBEDDING_MODEL = "text-embedding-005";
90
89
  var EMBEDDING_DIMENSIONS = 768;
91
- var DEFAULT_LOCATION = process.env.VERTEX_LOCATION || "us-central1";
92
90
  var QUERY_EMBED_CACHE_SIZE = 20;
93
91
  var QUERY_EMBED_CACHE_TTL = 30 * 60 * 1e3;
94
92
  var queryEmbedCache = /* @__PURE__ */ new Map();
@@ -113,17 +111,6 @@ function setQueryEmbedCached(query, result) {
113
111
  }
114
112
  queryEmbedCache.set(query, { result, fetchedAt: Date.now() });
115
113
  }
116
- async function resolveProjectId() {
117
- if (process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT) {
118
- return process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
119
- }
120
- try {
121
- const auth = new GoogleAuth();
122
- return await auth.getProjectId();
123
- } catch (err) {
124
- throw new Error(`Unable to resolve Google Cloud project id: ${err?.message ?? err}`);
125
- }
126
- }
127
114
  async function generateEmbedding(text) {
128
115
  const results = await generateEmbeddings([text]);
129
116
  return {
@@ -133,93 +120,40 @@ async function generateEmbedding(text) {
133
120
  }
134
121
  async function generateEmbeddings(texts) {
135
122
  if (texts.length === 0) {
136
- return { embeddings: [], model: EMBEDDING_MODEL };
123
+ return { embeddings: [], model: "text-embedding-005" };
137
124
  }
138
- const project = await resolveProjectId();
139
- const location = DEFAULT_LOCATION;
140
- const endpoint = `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/google/models/${EMBEDDING_MODEL}:predict`;
141
- const auth = new GoogleAuth({
142
- scopes: ["https://www.googleapis.com/auth/cloud-platform"]
143
- });
144
- const client = await auth.getClient();
145
- const batchSize = 5;
146
- const allEmbeddings = [];
147
- for (let i = 0; i < texts.length; i += batchSize) {
148
- const batch = texts.slice(i, i + batchSize);
149
- const requestBody = {
150
- instances: batch.map((text) => ({
151
- content: text,
152
- task_type: "RETRIEVAL_DOCUMENT"
153
- // Optimized for retrieval
154
- }))
125
+ try {
126
+ return await cfGenerateEmbeddings(texts, "RETRIEVAL_DOCUMENT");
127
+ } catch (error) {
128
+ console.error("Embedding proxy error:", error);
129
+ return {
130
+ embeddings: texts.map(() => new Array(EMBEDDING_DIMENSIONS).fill(0)),
131
+ model: "text-embedding-005"
155
132
  };
156
- try {
157
- const response = await client.request({
158
- url: endpoint,
159
- method: "POST",
160
- data: requestBody
161
- });
162
- const data = response.data;
163
- const predictions = data.predictions || [];
164
- for (const pred of predictions) {
165
- const embedding = pred.embeddings?.values || [];
166
- allEmbeddings.push(embedding);
167
- }
168
- } catch (error) {
169
- console.error("Embedding API error:", error);
170
- for (let j = 0; j < batch.length; j++) {
171
- allEmbeddings.push(new Array(EMBEDDING_DIMENSIONS).fill(0));
172
- }
173
- }
174
133
  }
175
- return {
176
- embeddings: allEmbeddings,
177
- model: EMBEDDING_MODEL
178
- };
179
134
  }
180
135
  async function generateQueryEmbedding(query) {
181
136
  const cached = getQueryEmbedCached(query);
182
137
  if (cached)
183
138
  return cached;
184
- const result = await generateQueryEmbeddingUncached(query);
185
- if (result.embedding.some((v) => v !== 0)) {
186
- setQueryEmbedCached(query, result);
187
- }
188
- return result;
189
- }
190
- async function generateQueryEmbeddingUncached(query) {
191
- const project = await resolveProjectId();
192
- const location = DEFAULT_LOCATION;
193
- const endpoint = `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/google/models/${EMBEDDING_MODEL}:predict`;
194
- const auth = new GoogleAuth({
195
- scopes: ["https://www.googleapis.com/auth/cloud-platform"]
196
- });
197
- const client = await auth.getClient();
198
- const requestBody = {
199
- instances: [{
200
- content: query,
201
- task_type: "RETRIEVAL_QUERY"
202
- }]
203
- };
139
+ let result;
204
140
  try {
205
- const response = await client.request({
206
- url: endpoint,
207
- method: "POST",
208
- data: requestBody
209
- });
210
- const data = response.data;
211
- const embedding = data.predictions?.[0]?.embeddings?.values || [];
212
- return {
213
- embedding,
141
+ const resp = await cfGenerateEmbeddings([query], "RETRIEVAL_QUERY");
142
+ result = {
143
+ embedding: resp.embeddings[0] || new Array(EMBEDDING_DIMENSIONS).fill(0),
214
144
  dimensions: EMBEDDING_DIMENSIONS
215
145
  };
216
146
  } catch (error) {
217
- console.error("Query embedding error:", error);
218
- return {
147
+ console.error("Query embedding proxy error:", error);
148
+ result = {
219
149
  embedding: new Array(EMBEDDING_DIMENSIONS).fill(0),
220
150
  dimensions: EMBEDDING_DIMENSIONS
221
151
  };
222
152
  }
153
+ if (result.embedding.some((v) => v !== 0)) {
154
+ setQueryEmbedCached(query, result);
155
+ }
156
+ return result;
223
157
  }
224
158
  function cosineSimilarity(a, b) {
225
159
  if (a.length !== b.length || a.length === 0)
@@ -2820,7 +2754,7 @@ async function propagateConstraints(productId, sourceEntityId, targetEntityId, s
2820
2754
 
2821
2755
  // ../mcp/dist/src/orchestrator/agents/shared/vertex.js
2822
2756
  import { VertexAI } from "@google-cloud/vertexai";
2823
- import { GoogleAuth as GoogleAuth2 } from "google-auth-library";
2757
+ import { GoogleAuth } from "google-auth-library";
2824
2758
  import { Buffer } from "node:buffer";
2825
2759
 
2826
2760
  // ../mcp/dist/src/shared/circuit-breaker.js
@@ -2978,7 +2912,7 @@ function estimateCostUsd(model, tokensIn, tokensOut) {
2978
2912
  return Math.round((tokensIn * price.inputPerM + tokensOut * price.outputPerM) / 1e6 * 1e6) / 1e6;
2979
2913
  }
2980
2914
  var DEFAULT_MODEL_ID = process.env.MODEL_ID || "gemini-2.5-pro";
2981
- var DEFAULT_LOCATION2 = process.env.VERTEX_LOCATION || "us-central1";
2915
+ var DEFAULT_LOCATION = process.env.VERTEX_LOCATION || "us-central1";
2982
2916
  var VERBOSE = (process.env.AGENT_LOG_VERBOSE ?? process.env.PREMORTEM_LOG_VERBOSE) === "true";
2983
2917
  var PREVIEW = process.env.AGENT_LOG_PREVIEW === "true";
2984
2918
  var PREVIEW_LIMIT = Math.max(0, parseInt(process.env.AGENT_LOG_PREVIEW_LIMIT || "400", 10) || 400);
@@ -3064,9 +2998,9 @@ async function retryWithBackoff(fn, opts) {
3064
2998
  throw lastErr;
3065
2999
  }
3066
3000
  async function generateStructuredContent(options) {
3067
- const project = await resolveProjectId2();
3001
+ const project = await resolveProjectId();
3068
3002
  const modelId = options.modelId || DEFAULT_MODEL_ID;
3069
- const location = options.location || DEFAULT_LOCATION2;
3003
+ const location = options.location || DEFAULT_LOCATION;
3070
3004
  const vertex = new VertexAI({ project, location });
3071
3005
  const fullSystem = `${GLOBAL_SYSTEM_PROMPT}
3072
3006
 
@@ -3312,12 +3246,12 @@ var GLOBAL_SYSTEM_PROMPT = [
3312
3246
  "- Keep rationales crisp (8\u201330 words), focusing on evidence, base rates, and key assumptions.",
3313
3247
  "- No marketing language, no boilerplate, no code fences, no markdown\u2014only the required JSON/plain text."
3314
3248
  ].join("\n");
3315
- async function resolveProjectId2() {
3249
+ async function resolveProjectId() {
3316
3250
  if (process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT) {
3317
3251
  return process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
3318
3252
  }
3319
3253
  try {
3320
- const auth = new GoogleAuth2();
3254
+ const auth = new GoogleAuth();
3321
3255
  return await auth.getProjectId();
3322
3256
  } catch (err) {
3323
3257
  throw new Error(`Unable to resolve Google Cloud project id: ${err?.message ?? err}`);
@@ -11,6 +11,7 @@ import {
11
11
  cfExplorationAgent,
12
12
  cfGenerateAnswer,
13
13
  cfGenerateChatSuggestion,
14
+ cfGenerateEmbeddings,
14
15
  cfGenerateExplorationResponse,
15
16
  cfGenerateTemplateResponse,
16
17
  cfGenerateTrialRun,
@@ -75,7 +76,7 @@ import {
75
76
  upsertEdges,
76
77
  upsertEntities,
77
78
  upsertNodes
78
- } from "./chunk-XKS3J74N.js";
79
+ } from "./chunk-TJTE5Q2C.js";
79
80
  export {
80
81
  addEdges,
81
82
  addEntity,
@@ -89,6 +90,7 @@ export {
89
90
  cfExplorationAgent,
90
91
  cfGenerateAnswer,
91
92
  cfGenerateChatSuggestion,
93
+ cfGenerateEmbeddings,
92
94
  cfGenerateExplorationResponse,
93
95
  cfGenerateTemplateResponse,
94
96
  cfGenerateTrialRun,
@@ -14,7 +14,7 @@ import {
14
14
  requirePremiumWithAutoAuth,
15
15
  updateExplorationSession,
16
16
  validateRequestSize
17
- } from "./chunk-XKS3J74N.js";
17
+ } from "./chunk-TJTE5Q2C.js";
18
18
 
19
19
  // ../mcp/dist/mcp/src/exploration-server.js
20
20
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -13,7 +13,7 @@ import {
13
13
  requirePremiumWithAutoAuth,
14
14
  validateAuth,
15
15
  validateRequestSize
16
- } from "./chunk-XKS3J74N.js";
16
+ } from "./chunk-TJTE5Q2C.js";
17
17
 
18
18
  // ../mcp/dist/mcp/src/integrations-server.js
19
19
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -13,7 +13,7 @@ import {
13
13
  mapErrorToMcp,
14
14
  requirePremiumWithAutoAuth,
15
15
  validateRequestSize
16
- } from "./chunk-XKS3J74N.js";
16
+ } from "./chunk-TJTE5Q2C.js";
17
17
 
18
18
  // ../mcp/dist/mcp/src/output-server.js
19
19
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -27,7 +27,7 @@ import {
27
27
  updatePremortem,
28
28
  validateAuth,
29
29
  validateRequestSize
30
- } from "./chunk-XKS3J74N.js";
30
+ } from "./chunk-TJTE5Q2C.js";
31
31
 
32
32
  // ../mcp/dist/mcp/src/premortem-server.js
33
33
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -21,7 +21,7 @@ import {
21
21
  requirePremiumWithAutoAuth,
22
22
  validateAuth,
23
23
  validateRequestSize
24
- } from "./chunk-XKS3J74N.js";
24
+ } from "./chunk-TJTE5Q2C.js";
25
25
 
26
26
  // ../mcp/dist/mcp/src/tools-server.js
27
27
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kylewadegrove/cutline-mcp-cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "CLI and MCP servers for Cutline — authenticate, then run constraint-aware MCP servers in Cursor or any MCP client.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",