@hasna/testers 0.0.33 → 0.0.34
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/cli/index.js +667 -259
- package/dist/mcp/http.d.ts +2 -1
- package/dist/mcp/http.d.ts.map +1 -1
- package/dist/mcp/index.js +691 -279
- package/dist/server/index.js +477 -263
- package/package.json +1 -1
- package/dist/lib/browser-compat.d.ts +0 -14
- package/dist/lib/browser-compat.d.ts.map +0 -1
package/dist/mcp/index.js
CHANGED
|
@@ -5399,9 +5399,9 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
5399
5399
|
const batch = rows.slice(offset, offset + batchSize);
|
|
5400
5400
|
try {
|
|
5401
5401
|
if (isAsyncAdapter(target)) {
|
|
5402
|
-
await batchUpsertPg(target, table, columns, updateCols, pkColumns, batch);
|
|
5402
|
+
await batchUpsertPg(target, table, columns, updateCols, pkColumns, batch, columns.includes(conflictColumn) ? conflictColumn : undefined);
|
|
5403
5403
|
} else {
|
|
5404
|
-
batchUpsertSqlite(target, table, columns, updateCols, pkColumns, batch);
|
|
5404
|
+
batchUpsertSqlite(target, table, columns, updateCols, pkColumns, batch, columns.includes(conflictColumn) ? conflictColumn : undefined);
|
|
5405
5405
|
}
|
|
5406
5406
|
result.rowsWritten += batch.length;
|
|
5407
5407
|
} catch (err) {
|
|
@@ -5448,7 +5448,7 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
5448
5448
|
}
|
|
5449
5449
|
return results;
|
|
5450
5450
|
}
|
|
5451
|
-
async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, batch) {
|
|
5451
|
+
async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, batch, conflictColumn) {
|
|
5452
5452
|
if (batch.length === 0)
|
|
5453
5453
|
return;
|
|
5454
5454
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
@@ -5458,20 +5458,22 @@ async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, ba
|
|
|
5458
5458
|
}).join(", ");
|
|
5459
5459
|
const pkList = primaryKeys.map((c) => `"${c}"`).join(", ");
|
|
5460
5460
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
5461
|
+
const whereClause = conflictColumn && updateCols.includes(conflictColumn) ? ` WHERE "${table}"."${conflictColumn}" IS NULL OR EXCLUDED."${conflictColumn}" >= "${table}"."${conflictColumn}"` : "";
|
|
5461
5462
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
5462
|
-
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
5463
|
+
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}${whereClause}`;
|
|
5463
5464
|
const params = batch.flatMap((row) => columns.map((c) => row[c] ?? null));
|
|
5464
5465
|
await target.run(sql, ...params);
|
|
5465
5466
|
}
|
|
5466
|
-
function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batch) {
|
|
5467
|
+
function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batch, conflictColumn) {
|
|
5467
5468
|
if (batch.length === 0)
|
|
5468
5469
|
return;
|
|
5469
5470
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
5470
5471
|
const valuePlaceholders = batch.map(() => `(${columns.map(() => "?").join(", ")})`).join(", ");
|
|
5471
5472
|
const pkList = primaryKeys.map((c) => `"${c}"`).join(", ");
|
|
5472
5473
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
5474
|
+
const whereClause = conflictColumn && updateCols.includes(conflictColumn) ? ` WHERE "${table}"."${conflictColumn}" IS NULL OR EXCLUDED."${conflictColumn}" >= "${table}"."${conflictColumn}"` : "";
|
|
5473
5475
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
5474
|
-
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
5476
|
+
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}${whereClause}`;
|
|
5475
5477
|
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
5476
5478
|
target.run(sql, ...params);
|
|
5477
5479
|
}
|
|
@@ -5696,7 +5698,7 @@ class SyncProgressTracker {
|
|
|
5696
5698
|
}
|
|
5697
5699
|
}
|
|
5698
5700
|
}
|
|
5699
|
-
function registerCloudTools(server, serviceName) {
|
|
5701
|
+
function registerCloudTools(server, serviceName, opts = {}) {
|
|
5700
5702
|
server.tool(`${serviceName}_cloud_status`, "Show cloud configuration and connection health", {}, async () => {
|
|
5701
5703
|
const config = getCloudConfig();
|
|
5702
5704
|
const lines = [
|
|
@@ -5729,8 +5731,13 @@ function registerCloudTools(server, serviceName) {
|
|
|
5729
5731
|
isError: true
|
|
5730
5732
|
};
|
|
5731
5733
|
}
|
|
5732
|
-
const local = new SqliteAdapter(getDbPath(serviceName));
|
|
5734
|
+
const local = new SqliteAdapter(opts.dbPath ?? getDbPath(serviceName));
|
|
5733
5735
|
const cloud = new PgAdapterAsync(getConnectionString(serviceName));
|
|
5736
|
+
if (opts.migrations?.length) {
|
|
5737
|
+
for (const sql of opts.migrations) {
|
|
5738
|
+
await cloud.run(sql);
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5734
5741
|
const tableList = tablesStr ? tablesStr.split(",").map((t) => t.trim()) : listSqliteTables(local);
|
|
5735
5742
|
const results = await syncPush(local, cloud, { tables: tableList });
|
|
5736
5743
|
local.close();
|
|
@@ -5752,7 +5759,7 @@ function registerCloudTools(server, serviceName) {
|
|
|
5752
5759
|
isError: true
|
|
5753
5760
|
};
|
|
5754
5761
|
}
|
|
5755
|
-
const local = new SqliteAdapter(getDbPath(serviceName));
|
|
5762
|
+
const local = new SqliteAdapter(opts.dbPath ?? getDbPath(serviceName));
|
|
5756
5763
|
const cloud = new PgAdapterAsync(getConnectionString(serviceName));
|
|
5757
5764
|
let tableList;
|
|
5758
5765
|
if (tablesStr) {
|
|
@@ -34698,27 +34705,34 @@ var init_v3 = __esm(() => {
|
|
|
34698
34705
|
|
|
34699
34706
|
// node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
|
|
34700
34707
|
function noop(_arg) {}
|
|
34701
|
-
function createParser(
|
|
34702
|
-
if (typeof
|
|
34703
|
-
throw new TypeError("`
|
|
34704
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } =
|
|
34705
|
-
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
34708
|
+
function createParser(config2) {
|
|
34709
|
+
if (typeof config2 == "function")
|
|
34710
|
+
throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
|
|
34711
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
34712
|
+
let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
|
|
34706
34713
|
function feed(chunk) {
|
|
34714
|
+
if (terminated)
|
|
34715
|
+
throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
|
|
34707
34716
|
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
34708
34717
|
const trailing2 = processLines(chunk);
|
|
34709
|
-
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
34718
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
34710
34719
|
return;
|
|
34711
34720
|
}
|
|
34712
34721
|
if (chunk.indexOf(`
|
|
34713
34722
|
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
34714
|
-
pendingFragments.push(chunk);
|
|
34723
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
34715
34724
|
return;
|
|
34716
34725
|
}
|
|
34717
34726
|
pendingFragments.push(chunk);
|
|
34718
34727
|
const input = pendingFragments.join("");
|
|
34719
|
-
pendingFragments.length = 0;
|
|
34728
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
34720
34729
|
const trailing = processLines(input);
|
|
34721
|
-
trailing !== "" && pendingFragments.push(trailing);
|
|
34730
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
34731
|
+
}
|
|
34732
|
+
function checkBufferSize() {
|
|
34733
|
+
maxBufferSize !== undefined && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = undefined, data = "", dataLines = 0, eventType = undefined, onError(new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
34734
|
+
type: "max-buffer-size-exceeded"
|
|
34735
|
+
}))));
|
|
34722
34736
|
}
|
|
34723
34737
|
function processLines(chunk) {
|
|
34724
34738
|
let searchIndex = 0;
|
|
@@ -34830,7 +34844,7 @@ ${value}`, dataLines++;
|
|
|
34830
34844
|
const incompleteLine = pendingFragments.join("");
|
|
34831
34845
|
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
34832
34846
|
}
|
|
34833
|
-
isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0;
|
|
34847
|
+
isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
34834
34848
|
}
|
|
34835
34849
|
return { feed, reset };
|
|
34836
34850
|
}
|
|
@@ -34854,7 +34868,7 @@ var EventSourceParserStream;
|
|
|
34854
34868
|
var init_stream = __esm(() => {
|
|
34855
34869
|
init_dist3();
|
|
34856
34870
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
34857
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
34871
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
34858
34872
|
let parser;
|
|
34859
34873
|
super({
|
|
34860
34874
|
start(controller) {
|
|
@@ -34863,10 +34877,11 @@ var init_stream = __esm(() => {
|
|
|
34863
34877
|
controller.enqueue(event);
|
|
34864
34878
|
},
|
|
34865
34879
|
onError(error40) {
|
|
34866
|
-
onError
|
|
34880
|
+
typeof onError == "function" && onError(error40), (onError === "terminate" || error40.type === "max-buffer-size-exceeded") && controller.error(error40);
|
|
34867
34881
|
},
|
|
34868
34882
|
onRetry,
|
|
34869
|
-
onComment
|
|
34883
|
+
onComment,
|
|
34884
|
+
maxBufferSize
|
|
34870
34885
|
});
|
|
34871
34886
|
},
|
|
34872
34887
|
transform(chunk) {
|
|
@@ -36305,7 +36320,7 @@ var DelayedPromise = class {
|
|
|
36305
36320
|
});
|
|
36306
36321
|
}
|
|
36307
36322
|
return () => `${prefix}${separator}${generator()}`;
|
|
36308
|
-
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
36323
|
+
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.27", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
36309
36324
|
url: url2,
|
|
36310
36325
|
headers = {},
|
|
36311
36326
|
successfulResponseHandler,
|
|
@@ -38444,7 +38459,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
38444
38459
|
"ai-model-id": this.modelId
|
|
38445
38460
|
};
|
|
38446
38461
|
}
|
|
38447
|
-
}, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.
|
|
38462
|
+
}, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.120", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
38448
38463
|
var init_dist5 = __esm(() => {
|
|
38449
38464
|
init_dist4();
|
|
38450
38465
|
init_dist2();
|
|
@@ -38483,13 +38498,15 @@ var init_dist5 = __esm(() => {
|
|
|
38483
38498
|
message,
|
|
38484
38499
|
statusCode = 500,
|
|
38485
38500
|
cause,
|
|
38486
|
-
generationId
|
|
38501
|
+
generationId,
|
|
38502
|
+
isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500)
|
|
38487
38503
|
}) {
|
|
38488
38504
|
super(generationId ? `${message} [${generationId}]` : message);
|
|
38489
38505
|
this[_a17] = true;
|
|
38490
38506
|
this.statusCode = statusCode;
|
|
38491
38507
|
this.cause = cause;
|
|
38492
38508
|
this.generationId = generationId;
|
|
38509
|
+
this.isRetryable = isRetryable;
|
|
38493
38510
|
}
|
|
38494
38511
|
static isInstance(error40) {
|
|
38495
38512
|
return _GatewayError.hasMarker(error40);
|
|
@@ -39012,62 +39029,11 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
39012
39029
|
gateway = createGatewayProvider();
|
|
39013
39030
|
});
|
|
39014
39031
|
|
|
39015
|
-
// node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
39016
|
-
var require_globalThis = __commonJS((exports) => {
|
|
39017
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39018
|
-
exports._globalThis = undefined;
|
|
39019
|
-
exports._globalThis = typeof globalThis === "object" ? globalThis : global;
|
|
39020
|
-
});
|
|
39021
|
-
|
|
39022
|
-
// node_modules/@opentelemetry/api/build/src/platform/node/index.js
|
|
39023
|
-
var require_node = __commonJS((exports) => {
|
|
39024
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
39025
|
-
if (k2 === undefined)
|
|
39026
|
-
k2 = k;
|
|
39027
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
39028
|
-
return m[k];
|
|
39029
|
-
} });
|
|
39030
|
-
} : function(o, m, k, k2) {
|
|
39031
|
-
if (k2 === undefined)
|
|
39032
|
-
k2 = k;
|
|
39033
|
-
o[k2] = m[k];
|
|
39034
|
-
});
|
|
39035
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
39036
|
-
for (var p in m)
|
|
39037
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
39038
|
-
__createBinding(exports2, m, p);
|
|
39039
|
-
};
|
|
39040
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39041
|
-
__exportStar(require_globalThis(), exports);
|
|
39042
|
-
});
|
|
39043
|
-
|
|
39044
|
-
// node_modules/@opentelemetry/api/build/src/platform/index.js
|
|
39045
|
-
var require_platform = __commonJS((exports) => {
|
|
39046
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
39047
|
-
if (k2 === undefined)
|
|
39048
|
-
k2 = k;
|
|
39049
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
39050
|
-
return m[k];
|
|
39051
|
-
} });
|
|
39052
|
-
} : function(o, m, k, k2) {
|
|
39053
|
-
if (k2 === undefined)
|
|
39054
|
-
k2 = k;
|
|
39055
|
-
o[k2] = m[k];
|
|
39056
|
-
});
|
|
39057
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
39058
|
-
for (var p in m)
|
|
39059
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
39060
|
-
__createBinding(exports2, m, p);
|
|
39061
|
-
};
|
|
39062
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39063
|
-
__exportStar(require_node(), exports);
|
|
39064
|
-
});
|
|
39065
|
-
|
|
39066
39032
|
// node_modules/@opentelemetry/api/build/src/version.js
|
|
39067
39033
|
var require_version = __commonJS((exports) => {
|
|
39068
39034
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39069
39035
|
exports.VERSION = undefined;
|
|
39070
|
-
exports.VERSION = "1.9.
|
|
39036
|
+
exports.VERSION = "1.9.1";
|
|
39071
39037
|
});
|
|
39072
39038
|
|
|
39073
39039
|
// node_modules/@opentelemetry/api/build/src/internal/semver.js
|
|
@@ -39145,12 +39111,11 @@ var require_semver = __commonJS((exports) => {
|
|
|
39145
39111
|
var require_global_utils = __commonJS((exports) => {
|
|
39146
39112
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39147
39113
|
exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
|
|
39148
|
-
var platform_1 = require_platform();
|
|
39149
39114
|
var version_1 = require_version();
|
|
39150
39115
|
var semver_1 = require_semver();
|
|
39151
39116
|
var major = version_1.VERSION.split(".")[0];
|
|
39152
39117
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
|
|
39153
|
-
var _global =
|
|
39118
|
+
var _global = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
|
|
39154
39119
|
function registerGlobal(type, instance, diag, allowOverride = false) {
|
|
39155
39120
|
var _a16;
|
|
39156
39121
|
const api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a16 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a16 !== undefined ? _a16 : {
|
|
@@ -39222,8 +39187,7 @@ var require_ComponentLogger = __commonJS((exports) => {
|
|
|
39222
39187
|
if (!logger) {
|
|
39223
39188
|
return;
|
|
39224
39189
|
}
|
|
39225
|
-
|
|
39226
|
-
return logger[funcName](...args);
|
|
39190
|
+
return logger[funcName](namespace, ...args);
|
|
39227
39191
|
}
|
|
39228
39192
|
});
|
|
39229
39193
|
|
|
@@ -39284,6 +39248,12 @@ var require_diag = __commonJS((exports) => {
|
|
|
39284
39248
|
var API_NAME = "diag";
|
|
39285
39249
|
|
|
39286
39250
|
class DiagAPI {
|
|
39251
|
+
static instance() {
|
|
39252
|
+
if (!this._instance) {
|
|
39253
|
+
this._instance = new DiagAPI;
|
|
39254
|
+
}
|
|
39255
|
+
return this._instance;
|
|
39256
|
+
}
|
|
39287
39257
|
constructor() {
|
|
39288
39258
|
function _logProxy(funcName) {
|
|
39289
39259
|
return function(...args) {
|
|
@@ -39328,12 +39298,6 @@ var require_diag = __commonJS((exports) => {
|
|
|
39328
39298
|
self2.warn = _logProxy("warn");
|
|
39329
39299
|
self2.error = _logProxy("error");
|
|
39330
39300
|
}
|
|
39331
|
-
static instance() {
|
|
39332
|
-
if (!this._instance) {
|
|
39333
|
-
this._instance = new DiagAPI;
|
|
39334
|
-
}
|
|
39335
|
-
return this._instance;
|
|
39336
|
-
}
|
|
39337
39301
|
}
|
|
39338
39302
|
exports.DiagAPI = DiagAPI;
|
|
39339
39303
|
});
|
|
@@ -39355,7 +39319,7 @@ var require_baggage_impl = __commonJS((exports) => {
|
|
|
39355
39319
|
return Object.assign({}, entry);
|
|
39356
39320
|
}
|
|
39357
39321
|
getAllEntries() {
|
|
39358
|
-
return Array.from(this._entries.entries())
|
|
39322
|
+
return Array.from(this._entries.entries());
|
|
39359
39323
|
}
|
|
39360
39324
|
setEntry(key, entry) {
|
|
39361
39325
|
const newBaggage = new BaggageImpl(this._entries);
|
|
@@ -39447,7 +39411,7 @@ var require_context = __commonJS((exports) => {
|
|
|
39447
39411
|
// node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
|
|
39448
39412
|
var require_consoleLogger = __commonJS((exports) => {
|
|
39449
39413
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39450
|
-
exports.DiagConsoleLogger = undefined;
|
|
39414
|
+
exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
|
|
39451
39415
|
var consoleMap = [
|
|
39452
39416
|
{ n: "error", c: "error" },
|
|
39453
39417
|
{ n: "warn", c: "warn" },
|
|
@@ -39455,19 +39419,39 @@ var require_consoleLogger = __commonJS((exports) => {
|
|
|
39455
39419
|
{ n: "debug", c: "debug" },
|
|
39456
39420
|
{ n: "verbose", c: "trace" }
|
|
39457
39421
|
];
|
|
39422
|
+
exports._originalConsoleMethods = {};
|
|
39423
|
+
if (typeof console !== "undefined") {
|
|
39424
|
+
const keys = [
|
|
39425
|
+
"error",
|
|
39426
|
+
"warn",
|
|
39427
|
+
"info",
|
|
39428
|
+
"debug",
|
|
39429
|
+
"trace",
|
|
39430
|
+
"log"
|
|
39431
|
+
];
|
|
39432
|
+
for (const key of keys) {
|
|
39433
|
+
if (typeof console[key] === "function") {
|
|
39434
|
+
exports._originalConsoleMethods[key] = console[key];
|
|
39435
|
+
}
|
|
39436
|
+
}
|
|
39437
|
+
}
|
|
39458
39438
|
|
|
39459
39439
|
class DiagConsoleLogger {
|
|
39460
39440
|
constructor() {
|
|
39461
39441
|
function _consoleFunc(funcName) {
|
|
39462
39442
|
return function(...args) {
|
|
39463
|
-
|
|
39464
|
-
|
|
39443
|
+
let theFunc = exports._originalConsoleMethods[funcName];
|
|
39444
|
+
if (typeof theFunc !== "function") {
|
|
39445
|
+
theFunc = exports._originalConsoleMethods["log"];
|
|
39446
|
+
}
|
|
39447
|
+
if (typeof theFunc !== "function" && console) {
|
|
39448
|
+
theFunc = console[funcName];
|
|
39465
39449
|
if (typeof theFunc !== "function") {
|
|
39466
39450
|
theFunc = console.log;
|
|
39467
39451
|
}
|
|
39468
|
-
|
|
39469
|
-
|
|
39470
|
-
|
|
39452
|
+
}
|
|
39453
|
+
if (typeof theFunc === "function") {
|
|
39454
|
+
return theFunc.apply(console, args);
|
|
39471
39455
|
}
|
|
39472
39456
|
};
|
|
39473
39457
|
}
|
|
@@ -39705,8 +39689,8 @@ var require_NonRecordingSpan = __commonJS((exports) => {
|
|
|
39705
39689
|
var invalid_span_constants_1 = require_invalid_span_constants();
|
|
39706
39690
|
|
|
39707
39691
|
class NonRecordingSpan {
|
|
39708
|
-
constructor(
|
|
39709
|
-
this._spanContext =
|
|
39692
|
+
constructor(spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
|
|
39693
|
+
this._spanContext = spanContext;
|
|
39710
39694
|
}
|
|
39711
39695
|
spanContext() {
|
|
39712
39696
|
return this._spanContext;
|
|
@@ -39782,14 +39766,126 @@ var require_spancontext_utils = __commonJS((exports) => {
|
|
|
39782
39766
|
exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
|
|
39783
39767
|
var invalid_span_constants_1 = require_invalid_span_constants();
|
|
39784
39768
|
var NonRecordingSpan_1 = require_NonRecordingSpan();
|
|
39785
|
-
var
|
|
39786
|
-
|
|
39769
|
+
var isHex = new Uint8Array([
|
|
39770
|
+
0,
|
|
39771
|
+
0,
|
|
39772
|
+
0,
|
|
39773
|
+
0,
|
|
39774
|
+
0,
|
|
39775
|
+
0,
|
|
39776
|
+
0,
|
|
39777
|
+
0,
|
|
39778
|
+
0,
|
|
39779
|
+
0,
|
|
39780
|
+
0,
|
|
39781
|
+
0,
|
|
39782
|
+
0,
|
|
39783
|
+
0,
|
|
39784
|
+
0,
|
|
39785
|
+
0,
|
|
39786
|
+
0,
|
|
39787
|
+
0,
|
|
39788
|
+
0,
|
|
39789
|
+
0,
|
|
39790
|
+
0,
|
|
39791
|
+
0,
|
|
39792
|
+
0,
|
|
39793
|
+
0,
|
|
39794
|
+
0,
|
|
39795
|
+
0,
|
|
39796
|
+
0,
|
|
39797
|
+
0,
|
|
39798
|
+
0,
|
|
39799
|
+
0,
|
|
39800
|
+
0,
|
|
39801
|
+
0,
|
|
39802
|
+
0,
|
|
39803
|
+
0,
|
|
39804
|
+
0,
|
|
39805
|
+
0,
|
|
39806
|
+
0,
|
|
39807
|
+
0,
|
|
39808
|
+
0,
|
|
39809
|
+
0,
|
|
39810
|
+
0,
|
|
39811
|
+
0,
|
|
39812
|
+
0,
|
|
39813
|
+
0,
|
|
39814
|
+
0,
|
|
39815
|
+
0,
|
|
39816
|
+
0,
|
|
39817
|
+
0,
|
|
39818
|
+
1,
|
|
39819
|
+
1,
|
|
39820
|
+
1,
|
|
39821
|
+
1,
|
|
39822
|
+
1,
|
|
39823
|
+
1,
|
|
39824
|
+
1,
|
|
39825
|
+
1,
|
|
39826
|
+
1,
|
|
39827
|
+
1,
|
|
39828
|
+
0,
|
|
39829
|
+
0,
|
|
39830
|
+
0,
|
|
39831
|
+
0,
|
|
39832
|
+
0,
|
|
39833
|
+
0,
|
|
39834
|
+
0,
|
|
39835
|
+
1,
|
|
39836
|
+
1,
|
|
39837
|
+
1,
|
|
39838
|
+
1,
|
|
39839
|
+
1,
|
|
39840
|
+
1,
|
|
39841
|
+
0,
|
|
39842
|
+
0,
|
|
39843
|
+
0,
|
|
39844
|
+
0,
|
|
39845
|
+
0,
|
|
39846
|
+
0,
|
|
39847
|
+
0,
|
|
39848
|
+
0,
|
|
39849
|
+
0,
|
|
39850
|
+
0,
|
|
39851
|
+
0,
|
|
39852
|
+
0,
|
|
39853
|
+
0,
|
|
39854
|
+
0,
|
|
39855
|
+
0,
|
|
39856
|
+
0,
|
|
39857
|
+
0,
|
|
39858
|
+
0,
|
|
39859
|
+
0,
|
|
39860
|
+
0,
|
|
39861
|
+
0,
|
|
39862
|
+
0,
|
|
39863
|
+
0,
|
|
39864
|
+
0,
|
|
39865
|
+
0,
|
|
39866
|
+
0,
|
|
39867
|
+
1,
|
|
39868
|
+
1,
|
|
39869
|
+
1,
|
|
39870
|
+
1,
|
|
39871
|
+
1,
|
|
39872
|
+
1
|
|
39873
|
+
]);
|
|
39874
|
+
function isValidHex(id, length) {
|
|
39875
|
+
if (typeof id !== "string" || id.length !== length)
|
|
39876
|
+
return false;
|
|
39877
|
+
let r = 0;
|
|
39878
|
+
for (let i = 0;i < id.length; i += 4) {
|
|
39879
|
+
r += (isHex[id.charCodeAt(i)] | 0) + (isHex[id.charCodeAt(i + 1)] | 0) + (isHex[id.charCodeAt(i + 2)] | 0) + (isHex[id.charCodeAt(i + 3)] | 0);
|
|
39880
|
+
}
|
|
39881
|
+
return r === length;
|
|
39882
|
+
}
|
|
39787
39883
|
function isValidTraceId(traceId) {
|
|
39788
|
-
return
|
|
39884
|
+
return isValidHex(traceId, 32) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
|
|
39789
39885
|
}
|
|
39790
39886
|
exports.isValidTraceId = isValidTraceId;
|
|
39791
39887
|
function isValidSpanId(spanId) {
|
|
39792
|
-
return
|
|
39888
|
+
return isValidHex(spanId, 16) && spanId !== invalid_span_constants_1.INVALID_SPANID;
|
|
39793
39889
|
}
|
|
39794
39890
|
exports.isValidSpanId = isValidSpanId;
|
|
39795
39891
|
function isSpanContextValid(spanContext) {
|
|
@@ -39849,7 +39945,7 @@ var require_NoopTracer = __commonJS((exports) => {
|
|
|
39849
39945
|
}
|
|
39850
39946
|
exports.NoopTracer = NoopTracer;
|
|
39851
39947
|
function isSpanContext(spanContext) {
|
|
39852
|
-
return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
|
|
39948
|
+
return spanContext !== null && typeof spanContext === "object" && "spanId" in spanContext && typeof spanContext["spanId"] === "string" && "traceId" in spanContext && typeof spanContext["traceId"] === "string" && "traceFlags" in spanContext && typeof spanContext["traceFlags"] === "number";
|
|
39853
39949
|
}
|
|
39854
39950
|
});
|
|
39855
39951
|
|
|
@@ -39861,8 +39957,8 @@ var require_ProxyTracer = __commonJS((exports) => {
|
|
|
39861
39957
|
var NOOP_TRACER = new NoopTracer_1.NoopTracer;
|
|
39862
39958
|
|
|
39863
39959
|
class ProxyTracer {
|
|
39864
|
-
constructor(
|
|
39865
|
-
this._provider =
|
|
39960
|
+
constructor(provider, name15, version2, options) {
|
|
39961
|
+
this._provider = provider;
|
|
39866
39962
|
this.name = name15;
|
|
39867
39963
|
this.version = version2;
|
|
39868
39964
|
this.options = options;
|
|
@@ -40022,7 +40118,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
40022
40118
|
return this._internalState.get(key);
|
|
40023
40119
|
}
|
|
40024
40120
|
serialize() {
|
|
40025
|
-
return this.
|
|
40121
|
+
return Array.from(this._internalState.keys()).reduceRight((agg, key) => {
|
|
40026
40122
|
agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
|
|
40027
40123
|
return agg;
|
|
40028
40124
|
}, []).join(LIST_MEMBERS_SEPARATOR);
|
|
@@ -40030,7 +40126,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
40030
40126
|
_parse(rawTraceState) {
|
|
40031
40127
|
if (rawTraceState.length > MAX_TRACE_STATE_LEN)
|
|
40032
40128
|
return;
|
|
40033
|
-
this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).
|
|
40129
|
+
this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reduceRight((agg, part) => {
|
|
40034
40130
|
const listMember = part.trim();
|
|
40035
40131
|
const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
|
|
40036
40132
|
if (i !== -1) {
|
|
@@ -41130,7 +41226,10 @@ function convertToLanguageModelMessage({
|
|
|
41130
41226
|
type: "tool-result",
|
|
41131
41227
|
toolCallId: part.toolCallId,
|
|
41132
41228
|
toolName: part.toolName,
|
|
41133
|
-
output: mapToolResultOutput(
|
|
41229
|
+
output: mapToolResultOutput({
|
|
41230
|
+
output: part.output,
|
|
41231
|
+
downloadedAssets
|
|
41232
|
+
}),
|
|
41134
41233
|
providerOptions
|
|
41135
41234
|
};
|
|
41136
41235
|
}
|
|
@@ -41149,7 +41248,10 @@ function convertToLanguageModelMessage({
|
|
|
41149
41248
|
type: "tool-result",
|
|
41150
41249
|
toolCallId: part.toolCallId,
|
|
41151
41250
|
toolName: part.toolName,
|
|
41152
|
-
output: mapToolResultOutput(
|
|
41251
|
+
output: mapToolResultOutput({
|
|
41252
|
+
output: part.output,
|
|
41253
|
+
downloadedAssets
|
|
41254
|
+
}),
|
|
41153
41255
|
providerOptions: part.providerOptions
|
|
41154
41256
|
};
|
|
41155
41257
|
}
|
|
@@ -41173,15 +41275,44 @@ function convertToLanguageModelMessage({
|
|
|
41173
41275
|
}
|
|
41174
41276
|
}
|
|
41175
41277
|
async function downloadAssets(messages, download2, supportedUrls) {
|
|
41176
|
-
|
|
41177
|
-
|
|
41178
|
-
|
|
41179
|
-
|
|
41180
|
-
|
|
41181
|
-
|
|
41182
|
-
|
|
41183
|
-
|
|
41278
|
+
var _a21;
|
|
41279
|
+
const downloadableFiles = [];
|
|
41280
|
+
for (const message of messages) {
|
|
41281
|
+
if (message.role === "user" && Array.isArray(message.content)) {
|
|
41282
|
+
for (const part of message.content) {
|
|
41283
|
+
if (part.type === "image" || part.type === "file") {
|
|
41284
|
+
downloadableFiles.push({
|
|
41285
|
+
data: part.type === "image" ? part.image : part.data,
|
|
41286
|
+
mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
|
|
41287
|
+
});
|
|
41288
|
+
}
|
|
41289
|
+
}
|
|
41290
|
+
}
|
|
41291
|
+
if (message.role === "tool" || message.role === "assistant") {
|
|
41292
|
+
if (!Array.isArray(message.content)) {
|
|
41293
|
+
continue;
|
|
41294
|
+
}
|
|
41295
|
+
for (const part of message.content) {
|
|
41296
|
+
if (part.type !== "tool-result") {
|
|
41297
|
+
continue;
|
|
41298
|
+
}
|
|
41299
|
+
if (part.output.type !== "content") {
|
|
41300
|
+
continue;
|
|
41301
|
+
}
|
|
41302
|
+
for (const contentPart of part.output.value) {
|
|
41303
|
+
if (contentPart.type === "image-url" || contentPart.type === "file-url") {
|
|
41304
|
+
downloadableFiles.push({
|
|
41305
|
+
data: new URL(contentPart.url),
|
|
41306
|
+
mediaType: contentPart.type === "image-url" ? "image/*" : undefined
|
|
41307
|
+
});
|
|
41308
|
+
}
|
|
41309
|
+
}
|
|
41310
|
+
}
|
|
41184
41311
|
}
|
|
41312
|
+
}
|
|
41313
|
+
const plannedDownloads = downloadableFiles.map((part) => {
|
|
41314
|
+
const mediaType = part.mediaType;
|
|
41315
|
+
const { data } = convertToLanguageModelV3DataContent(part.data);
|
|
41185
41316
|
return { mediaType, data };
|
|
41186
41317
|
}).filter((part) => part.data instanceof URL).map((part) => ({
|
|
41187
41318
|
url: part.data,
|
|
@@ -41255,13 +41386,41 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
|
41255
41386
|
}
|
|
41256
41387
|
}
|
|
41257
41388
|
}
|
|
41258
|
-
function mapToolResultOutput(
|
|
41389
|
+
function mapToolResultOutput({
|
|
41390
|
+
output,
|
|
41391
|
+
downloadedAssets
|
|
41392
|
+
}) {
|
|
41259
41393
|
if (output.type !== "content") {
|
|
41260
41394
|
return output;
|
|
41261
41395
|
}
|
|
41262
41396
|
return {
|
|
41263
41397
|
type: "content",
|
|
41264
41398
|
value: output.value.map((item) => {
|
|
41399
|
+
var _a21, _b16;
|
|
41400
|
+
if (item.type === "image-url") {
|
|
41401
|
+
const downloadedFile = downloadedAssets[new URL(item.url).toString()];
|
|
41402
|
+
if (downloadedFile) {
|
|
41403
|
+
return {
|
|
41404
|
+
type: "image-data",
|
|
41405
|
+
data: convertDataContentToBase64String(downloadedFile.data),
|
|
41406
|
+
mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
|
|
41407
|
+
providerOptions: item.providerOptions
|
|
41408
|
+
};
|
|
41409
|
+
}
|
|
41410
|
+
return item;
|
|
41411
|
+
}
|
|
41412
|
+
if (item.type === "file-url") {
|
|
41413
|
+
const downloadedFile = downloadedAssets[new URL(item.url).toString()];
|
|
41414
|
+
if (downloadedFile) {
|
|
41415
|
+
return {
|
|
41416
|
+
type: "file-data",
|
|
41417
|
+
data: convertDataContentToBase64String(downloadedFile.data),
|
|
41418
|
+
mediaType: (_b16 = downloadedFile.mediaType) != null ? _b16 : "application/octet-stream",
|
|
41419
|
+
providerOptions: item.providerOptions
|
|
41420
|
+
};
|
|
41421
|
+
}
|
|
41422
|
+
return item;
|
|
41423
|
+
}
|
|
41265
41424
|
if (item.type !== "media") {
|
|
41266
41425
|
return item;
|
|
41267
41426
|
}
|
|
@@ -41814,7 +41973,7 @@ function getRetryDelayInMs({
|
|
|
41814
41973
|
error: error40,
|
|
41815
41974
|
exponentialBackoffDelay
|
|
41816
41975
|
}) {
|
|
41817
|
-
const headers = error40.responseHeaders;
|
|
41976
|
+
const headers = APICallError.isInstance(error40) ? error40.responseHeaders : APICallError.isInstance(error40.cause) ? error40.cause.responseHeaders : undefined;
|
|
41818
41977
|
if (!headers)
|
|
41819
41978
|
return exponentialBackoffDelay;
|
|
41820
41979
|
let ms;
|
|
@@ -41864,7 +42023,7 @@ async function _retryWithExponentialBackoff(f, {
|
|
|
41864
42023
|
errors: newErrors
|
|
41865
42024
|
});
|
|
41866
42025
|
}
|
|
41867
|
-
if (error40 instanceof Error && APICallError.isInstance(error40) && error40.isRetryable === true && tryNumber <= maxRetries) {
|
|
42026
|
+
if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
|
|
41868
42027
|
await delay(getRetryDelayInMs({
|
|
41869
42028
|
error: error40,
|
|
41870
42029
|
exponentialBackoffDelay: delayInMs
|
|
@@ -42082,7 +42241,8 @@ async function executeToolCall({
|
|
|
42082
42241
|
input,
|
|
42083
42242
|
error: error40,
|
|
42084
42243
|
dynamic: tool2.type === "dynamic",
|
|
42085
|
-
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
42244
|
+
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
|
|
42245
|
+
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
42086
42246
|
};
|
|
42087
42247
|
}
|
|
42088
42248
|
const durationMs = now2() - startTime;
|
|
@@ -42112,7 +42272,8 @@ async function executeToolCall({
|
|
|
42112
42272
|
input,
|
|
42113
42273
|
output,
|
|
42114
42274
|
dynamic: tool2.type === "dynamic",
|
|
42115
|
-
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
42275
|
+
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
|
|
42276
|
+
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
42116
42277
|
};
|
|
42117
42278
|
}
|
|
42118
42279
|
});
|
|
@@ -42477,15 +42638,6 @@ async function parsePartialJson(jsonText) {
|
|
|
42477
42638
|
}
|
|
42478
42639
|
return { value: undefined, state: "failed-parse" };
|
|
42479
42640
|
}
|
|
42480
|
-
function mergeToolProviderMetadata(toolMetadata, callMetadata) {
|
|
42481
|
-
if (toolMetadata == null) {
|
|
42482
|
-
return callMetadata;
|
|
42483
|
-
}
|
|
42484
|
-
if (callMetadata == null) {
|
|
42485
|
-
return toolMetadata;
|
|
42486
|
-
}
|
|
42487
|
-
return { ...toolMetadata, ...callMetadata };
|
|
42488
|
-
}
|
|
42489
42641
|
async function parseToolCall({
|
|
42490
42642
|
toolCall,
|
|
42491
42643
|
tools,
|
|
@@ -42493,7 +42645,6 @@ async function parseToolCall({
|
|
|
42493
42645
|
system,
|
|
42494
42646
|
messages
|
|
42495
42647
|
}) {
|
|
42496
|
-
var _a21, _b16;
|
|
42497
42648
|
try {
|
|
42498
42649
|
if (tools == null) {
|
|
42499
42650
|
if (toolCall.providerExecuted && toolCall.dynamic) {
|
|
@@ -42534,6 +42685,7 @@ async function parseToolCall({
|
|
|
42534
42685
|
} catch (error40) {
|
|
42535
42686
|
const parsedInput = await safeParseJSON({ text: toolCall.input });
|
|
42536
42687
|
const input = parsedInput.success ? parsedInput.value : toolCall.input;
|
|
42688
|
+
const tool2 = tools == null ? undefined : tools[toolCall.toolName];
|
|
42537
42689
|
return {
|
|
42538
42690
|
type: "tool-call",
|
|
42539
42691
|
toolCallId: toolCall.toolCallId,
|
|
@@ -42542,9 +42694,10 @@ async function parseToolCall({
|
|
|
42542
42694
|
dynamic: true,
|
|
42543
42695
|
invalid: true,
|
|
42544
42696
|
error: error40,
|
|
42545
|
-
title:
|
|
42697
|
+
title: tool2 == null ? undefined : tool2.title,
|
|
42546
42698
|
providerExecuted: toolCall.providerExecuted,
|
|
42547
|
-
providerMetadata:
|
|
42699
|
+
providerMetadata: toolCall.providerMetadata,
|
|
42700
|
+
...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
|
|
42548
42701
|
};
|
|
42549
42702
|
}
|
|
42550
42703
|
}
|
|
@@ -42591,14 +42744,14 @@ async function doParseToolCall({
|
|
|
42591
42744
|
cause: parseResult.error
|
|
42592
42745
|
});
|
|
42593
42746
|
}
|
|
42594
|
-
const mergedProviderMetadata = mergeToolProviderMetadata(tool2.providerMetadata, toolCall.providerMetadata);
|
|
42595
42747
|
return tool2.type === "dynamic" ? {
|
|
42596
42748
|
type: "tool-call",
|
|
42597
42749
|
toolCallId: toolCall.toolCallId,
|
|
42598
42750
|
toolName: toolCall.toolName,
|
|
42599
42751
|
input: parseResult.value,
|
|
42600
42752
|
providerExecuted: toolCall.providerExecuted,
|
|
42601
|
-
providerMetadata:
|
|
42753
|
+
providerMetadata: toolCall.providerMetadata,
|
|
42754
|
+
...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
|
|
42602
42755
|
dynamic: true,
|
|
42603
42756
|
title: tool2.title
|
|
42604
42757
|
} : {
|
|
@@ -42607,7 +42760,8 @@ async function doParseToolCall({
|
|
|
42607
42760
|
toolName,
|
|
42608
42761
|
input: parseResult.value,
|
|
42609
42762
|
providerExecuted: toolCall.providerExecuted,
|
|
42610
|
-
providerMetadata:
|
|
42763
|
+
providerMetadata: toolCall.providerMetadata,
|
|
42764
|
+
...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
|
|
42611
42765
|
title: tool2.title
|
|
42612
42766
|
};
|
|
42613
42767
|
}
|
|
@@ -43439,7 +43593,8 @@ function asContent({
|
|
|
43439
43593
|
error: part.result,
|
|
43440
43594
|
providerExecuted: true,
|
|
43441
43595
|
dynamic: part.dynamic,
|
|
43442
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
43596
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43597
|
+
...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
|
|
43443
43598
|
});
|
|
43444
43599
|
} else {
|
|
43445
43600
|
contentParts.push({
|
|
@@ -43450,7 +43605,8 @@ function asContent({
|
|
|
43450
43605
|
output: part.result,
|
|
43451
43606
|
providerExecuted: true,
|
|
43452
43607
|
dynamic: part.dynamic,
|
|
43453
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
43608
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43609
|
+
...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
|
|
43454
43610
|
});
|
|
43455
43611
|
}
|
|
43456
43612
|
break;
|
|
@@ -43464,7 +43620,8 @@ function asContent({
|
|
|
43464
43620
|
error: part.result,
|
|
43465
43621
|
providerExecuted: true,
|
|
43466
43622
|
dynamic: toolCall.dynamic,
|
|
43467
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
43623
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43624
|
+
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
43468
43625
|
});
|
|
43469
43626
|
} else {
|
|
43470
43627
|
contentParts.push({
|
|
@@ -43475,7 +43632,8 @@ function asContent({
|
|
|
43475
43632
|
output: part.result,
|
|
43476
43633
|
providerExecuted: true,
|
|
43477
43634
|
dynamic: toolCall.dynamic,
|
|
43478
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
43635
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43636
|
+
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
43479
43637
|
});
|
|
43480
43638
|
}
|
|
43481
43639
|
break;
|
|
@@ -43689,6 +43847,9 @@ function processUIMessageStream({
|
|
|
43689
43847
|
if (options.title !== undefined) {
|
|
43690
43848
|
anyPart.title = options.title;
|
|
43691
43849
|
}
|
|
43850
|
+
if (options.toolMetadata !== undefined) {
|
|
43851
|
+
anyPart.toolMetadata = options.toolMetadata;
|
|
43852
|
+
}
|
|
43692
43853
|
anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
|
|
43693
43854
|
const providerMetadata = anyOptions.providerMetadata;
|
|
43694
43855
|
if (providerMetadata != null) {
|
|
@@ -43705,6 +43866,7 @@ function processUIMessageStream({
|
|
|
43705
43866
|
toolCallId: options.toolCallId,
|
|
43706
43867
|
state: options.state,
|
|
43707
43868
|
title: options.title,
|
|
43869
|
+
...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
|
|
43708
43870
|
input: anyOptions.input,
|
|
43709
43871
|
output: anyOptions.output,
|
|
43710
43872
|
rawInput: anyOptions.rawInput,
|
|
@@ -43732,6 +43894,9 @@ function processUIMessageStream({
|
|
|
43732
43894
|
if (options.title !== undefined) {
|
|
43733
43895
|
anyPart.title = options.title;
|
|
43734
43896
|
}
|
|
43897
|
+
if (options.toolMetadata !== undefined) {
|
|
43898
|
+
anyPart.toolMetadata = options.toolMetadata;
|
|
43899
|
+
}
|
|
43735
43900
|
anyPart.providerExecuted = (_b23 = anyOptions.providerExecuted) != null ? _b23 : part.providerExecuted;
|
|
43736
43901
|
const providerMetadata = anyOptions.providerMetadata;
|
|
43737
43902
|
if (providerMetadata != null) {
|
|
@@ -43754,6 +43919,7 @@ function processUIMessageStream({
|
|
|
43754
43919
|
preliminary: anyOptions.preliminary,
|
|
43755
43920
|
providerExecuted: anyOptions.providerExecuted,
|
|
43756
43921
|
title: options.title,
|
|
43922
|
+
...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
|
|
43757
43923
|
...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
|
|
43758
43924
|
...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
43759
43925
|
});
|
|
@@ -43898,7 +44064,8 @@ function processUIMessageStream({
|
|
|
43898
44064
|
toolName: chunk.toolName,
|
|
43899
44065
|
index: toolInvocations.length,
|
|
43900
44066
|
dynamic: chunk.dynamic,
|
|
43901
|
-
title: chunk.title
|
|
44067
|
+
title: chunk.title,
|
|
44068
|
+
toolMetadata: chunk.toolMetadata
|
|
43902
44069
|
};
|
|
43903
44070
|
if (chunk.dynamic) {
|
|
43904
44071
|
updateDynamicToolPart({
|
|
@@ -43908,6 +44075,7 @@ function processUIMessageStream({
|
|
|
43908
44075
|
input: undefined,
|
|
43909
44076
|
providerExecuted: chunk.providerExecuted,
|
|
43910
44077
|
title: chunk.title,
|
|
44078
|
+
toolMetadata: chunk.toolMetadata,
|
|
43911
44079
|
providerMetadata: chunk.providerMetadata
|
|
43912
44080
|
});
|
|
43913
44081
|
} else {
|
|
@@ -43918,6 +44086,7 @@ function processUIMessageStream({
|
|
|
43918
44086
|
input: undefined,
|
|
43919
44087
|
providerExecuted: chunk.providerExecuted,
|
|
43920
44088
|
title: chunk.title,
|
|
44089
|
+
toolMetadata: chunk.toolMetadata,
|
|
43921
44090
|
providerMetadata: chunk.providerMetadata
|
|
43922
44091
|
});
|
|
43923
44092
|
}
|
|
@@ -43941,7 +44110,8 @@ function processUIMessageStream({
|
|
|
43941
44110
|
toolName: partialToolCall.toolName,
|
|
43942
44111
|
state: "input-streaming",
|
|
43943
44112
|
input: partialArgs,
|
|
43944
|
-
title: partialToolCall.title
|
|
44113
|
+
title: partialToolCall.title,
|
|
44114
|
+
toolMetadata: partialToolCall.toolMetadata
|
|
43945
44115
|
});
|
|
43946
44116
|
} else {
|
|
43947
44117
|
updateToolPart({
|
|
@@ -43949,7 +44119,8 @@ function processUIMessageStream({
|
|
|
43949
44119
|
toolName: partialToolCall.toolName,
|
|
43950
44120
|
state: "input-streaming",
|
|
43951
44121
|
input: partialArgs,
|
|
43952
|
-
title: partialToolCall.title
|
|
44122
|
+
title: partialToolCall.title,
|
|
44123
|
+
toolMetadata: partialToolCall.toolMetadata
|
|
43953
44124
|
});
|
|
43954
44125
|
}
|
|
43955
44126
|
write();
|
|
@@ -43964,7 +44135,8 @@ function processUIMessageStream({
|
|
|
43964
44135
|
input: chunk.input,
|
|
43965
44136
|
providerExecuted: chunk.providerExecuted,
|
|
43966
44137
|
providerMetadata: chunk.providerMetadata,
|
|
43967
|
-
title: chunk.title
|
|
44138
|
+
title: chunk.title,
|
|
44139
|
+
toolMetadata: chunk.toolMetadata
|
|
43968
44140
|
});
|
|
43969
44141
|
} else {
|
|
43970
44142
|
updateToolPart({
|
|
@@ -43974,7 +44146,8 @@ function processUIMessageStream({
|
|
|
43974
44146
|
input: chunk.input,
|
|
43975
44147
|
providerExecuted: chunk.providerExecuted,
|
|
43976
44148
|
providerMetadata: chunk.providerMetadata,
|
|
43977
|
-
title: chunk.title
|
|
44149
|
+
title: chunk.title,
|
|
44150
|
+
toolMetadata: chunk.toolMetadata
|
|
43978
44151
|
});
|
|
43979
44152
|
}
|
|
43980
44153
|
write();
|
|
@@ -43996,7 +44169,8 @@ function processUIMessageStream({
|
|
|
43996
44169
|
input: chunk.input,
|
|
43997
44170
|
errorText: chunk.errorText,
|
|
43998
44171
|
providerExecuted: chunk.providerExecuted,
|
|
43999
|
-
providerMetadata: chunk.providerMetadata
|
|
44172
|
+
providerMetadata: chunk.providerMetadata,
|
|
44173
|
+
toolMetadata: chunk.toolMetadata
|
|
44000
44174
|
});
|
|
44001
44175
|
} else {
|
|
44002
44176
|
updateToolPart({
|
|
@@ -44007,7 +44181,8 @@ function processUIMessageStream({
|
|
|
44007
44181
|
rawInput: chunk.input,
|
|
44008
44182
|
errorText: chunk.errorText,
|
|
44009
44183
|
providerExecuted: chunk.providerExecuted,
|
|
44010
|
-
providerMetadata: chunk.providerMetadata
|
|
44184
|
+
providerMetadata: chunk.providerMetadata,
|
|
44185
|
+
toolMetadata: chunk.toolMetadata
|
|
44011
44186
|
});
|
|
44012
44187
|
}
|
|
44013
44188
|
write();
|
|
@@ -44038,7 +44213,8 @@ function processUIMessageStream({
|
|
|
44038
44213
|
preliminary: chunk.preliminary,
|
|
44039
44214
|
providerExecuted: chunk.providerExecuted,
|
|
44040
44215
|
providerMetadata: chunk.providerMetadata,
|
|
44041
|
-
title: toolInvocation.title
|
|
44216
|
+
title: toolInvocation.title,
|
|
44217
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
44042
44218
|
});
|
|
44043
44219
|
} else {
|
|
44044
44220
|
updateToolPart({
|
|
@@ -44050,7 +44226,8 @@ function processUIMessageStream({
|
|
|
44050
44226
|
providerExecuted: chunk.providerExecuted,
|
|
44051
44227
|
preliminary: chunk.preliminary,
|
|
44052
44228
|
providerMetadata: chunk.providerMetadata,
|
|
44053
|
-
title: toolInvocation.title
|
|
44229
|
+
title: toolInvocation.title,
|
|
44230
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
44054
44231
|
});
|
|
44055
44232
|
}
|
|
44056
44233
|
write();
|
|
@@ -44067,7 +44244,8 @@ function processUIMessageStream({
|
|
|
44067
44244
|
errorText: chunk.errorText,
|
|
44068
44245
|
providerExecuted: chunk.providerExecuted,
|
|
44069
44246
|
providerMetadata: chunk.providerMetadata,
|
|
44070
|
-
title: toolInvocation.title
|
|
44247
|
+
title: toolInvocation.title,
|
|
44248
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
44071
44249
|
});
|
|
44072
44250
|
} else {
|
|
44073
44251
|
updateToolPart({
|
|
@@ -44079,7 +44257,8 @@ function processUIMessageStream({
|
|
|
44079
44257
|
errorText: chunk.errorText,
|
|
44080
44258
|
providerExecuted: chunk.providerExecuted,
|
|
44081
44259
|
providerMetadata: chunk.providerMetadata,
|
|
44082
|
-
title: toolInvocation.title
|
|
44260
|
+
title: toolInvocation.title,
|
|
44261
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
44083
44262
|
});
|
|
44084
44263
|
}
|
|
44085
44264
|
write();
|
|
@@ -44537,7 +44716,8 @@ function runToolsTransformation({
|
|
|
44537
44716
|
input: toolCall.input,
|
|
44538
44717
|
error: getErrorMessage2(toolCall.error),
|
|
44539
44718
|
dynamic: true,
|
|
44540
|
-
title: toolCall.title
|
|
44719
|
+
title: toolCall.title,
|
|
44720
|
+
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
44541
44721
|
});
|
|
44542
44722
|
break;
|
|
44543
44723
|
}
|
|
@@ -44605,6 +44785,7 @@ function runToolsTransformation({
|
|
|
44605
44785
|
}
|
|
44606
44786
|
case "tool-result": {
|
|
44607
44787
|
const toolName = chunk.toolName;
|
|
44788
|
+
const toolCall = toolCallsByToolCallId.get(chunk.toolCallId);
|
|
44608
44789
|
if (chunk.isError) {
|
|
44609
44790
|
toolResultsStreamController.enqueue({
|
|
44610
44791
|
type: "tool-error",
|
|
@@ -44614,7 +44795,8 @@ function runToolsTransformation({
|
|
|
44614
44795
|
providerExecuted: true,
|
|
44615
44796
|
error: chunk.result,
|
|
44616
44797
|
dynamic: chunk.dynamic,
|
|
44617
|
-
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
44798
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},
|
|
44799
|
+
...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
44618
44800
|
});
|
|
44619
44801
|
} else {
|
|
44620
44802
|
controller.enqueue({
|
|
@@ -44625,7 +44807,8 @@ function runToolsTransformation({
|
|
|
44625
44807
|
output: chunk.result,
|
|
44626
44808
|
providerExecuted: true,
|
|
44627
44809
|
dynamic: chunk.dynamic,
|
|
44628
|
-
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
44810
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},
|
|
44811
|
+
...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
44629
44812
|
});
|
|
44630
44813
|
}
|
|
44631
44814
|
break;
|
|
@@ -45408,7 +45591,7 @@ async function embed({
|
|
|
45408
45591
|
}),
|
|
45409
45592
|
tracer,
|
|
45410
45593
|
fn: async (doEmbedSpan) => {
|
|
45411
|
-
var _a21;
|
|
45594
|
+
var _a21, _b16;
|
|
45412
45595
|
const modelResponse = await model.doEmbed({
|
|
45413
45596
|
values: [value],
|
|
45414
45597
|
abortSignal,
|
|
@@ -45429,7 +45612,7 @@ async function embed({
|
|
|
45429
45612
|
return {
|
|
45430
45613
|
embedding: embedding2,
|
|
45431
45614
|
usage: usage2,
|
|
45432
|
-
warnings: modelResponse.warnings,
|
|
45615
|
+
warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
|
|
45433
45616
|
providerMetadata: modelResponse.providerMetadata,
|
|
45434
45617
|
response: modelResponse.response
|
|
45435
45618
|
};
|
|
@@ -45525,7 +45708,7 @@ async function embedMany({
|
|
|
45525
45708
|
}),
|
|
45526
45709
|
tracer,
|
|
45527
45710
|
fn: async (doEmbedSpan) => {
|
|
45528
|
-
var _a222;
|
|
45711
|
+
var _a222, _b16;
|
|
45529
45712
|
const modelResponse = await model.doEmbed({
|
|
45530
45713
|
values,
|
|
45531
45714
|
abortSignal,
|
|
@@ -45546,7 +45729,7 @@ async function embedMany({
|
|
|
45546
45729
|
return {
|
|
45547
45730
|
embeddings: embeddings3,
|
|
45548
45731
|
usage: usage2,
|
|
45549
|
-
warnings: modelResponse.warnings,
|
|
45732
|
+
warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
|
|
45550
45733
|
providerMetadata: modelResponse.providerMetadata,
|
|
45551
45734
|
response: modelResponse.response
|
|
45552
45735
|
};
|
|
@@ -45603,7 +45786,7 @@ async function embedMany({
|
|
|
45603
45786
|
}),
|
|
45604
45787
|
tracer,
|
|
45605
45788
|
fn: async (doEmbedSpan) => {
|
|
45606
|
-
var _a222;
|
|
45789
|
+
var _a222, _b16;
|
|
45607
45790
|
const modelResponse = await model.doEmbed({
|
|
45608
45791
|
values: chunk,
|
|
45609
45792
|
abortSignal,
|
|
@@ -45624,7 +45807,7 @@ async function embedMany({
|
|
|
45624
45807
|
return {
|
|
45625
45808
|
embeddings: embeddings2,
|
|
45626
45809
|
usage,
|
|
45627
|
-
warnings: modelResponse.warnings,
|
|
45810
|
+
warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
|
|
45628
45811
|
providerMetadata: modelResponse.providerMetadata,
|
|
45629
45812
|
response: modelResponse.response
|
|
45630
45813
|
};
|
|
@@ -47738,7 +47921,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
47738
47921
|
const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
|
|
47739
47922
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
47740
47923
|
return bytes.slice(id3Size + 10);
|
|
47741
|
-
}, VERSION3 = "6.0.
|
|
47924
|
+
}, VERSION3 = "6.0.191", download = async ({
|
|
47742
47925
|
url: url2,
|
|
47743
47926
|
maxBytes,
|
|
47744
47927
|
abortSignal
|
|
@@ -48246,7 +48429,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
48246
48429
|
}
|
|
48247
48430
|
return this._output;
|
|
48248
48431
|
}
|
|
48249
|
-
}, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
|
|
48432
|
+
}, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
|
|
48250
48433
|
constructor({
|
|
48251
48434
|
model,
|
|
48252
48435
|
telemetry,
|
|
@@ -49494,6 +49677,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49494
49677
|
toolName: part.toolName,
|
|
49495
49678
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
49496
49679
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
49680
|
+
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
49497
49681
|
...dynamic != null ? { dynamic } : {},
|
|
49498
49682
|
...part.title != null ? { title: part.title } : {}
|
|
49499
49683
|
});
|
|
@@ -49517,6 +49701,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49517
49701
|
input: part.input,
|
|
49518
49702
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
49519
49703
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
49704
|
+
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
49520
49705
|
...dynamic != null ? { dynamic } : {},
|
|
49521
49706
|
errorText: onError(part.error),
|
|
49522
49707
|
...part.title != null ? { title: part.title } : {}
|
|
@@ -49529,6 +49714,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49529
49714
|
input: part.input,
|
|
49530
49715
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
49531
49716
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
49717
|
+
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
49532
49718
|
...dynamic != null ? { dynamic } : {},
|
|
49533
49719
|
...part.title != null ? { title: part.title } : {}
|
|
49534
49720
|
});
|
|
@@ -49551,6 +49737,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49551
49737
|
output: part.output,
|
|
49552
49738
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
49553
49739
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
49740
|
+
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
49554
49741
|
...part.preliminary != null ? { preliminary: part.preliminary } : {},
|
|
49555
49742
|
...dynamic != null ? { dynamic } : {}
|
|
49556
49743
|
});
|
|
@@ -49564,6 +49751,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49564
49751
|
errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) : onError(part.error),
|
|
49565
49752
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
49566
49753
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
49754
|
+
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
49567
49755
|
...dynamic != null ? { dynamic } : {}
|
|
49568
49756
|
});
|
|
49569
49757
|
break;
|
|
@@ -49737,10 +49925,21 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49737
49925
|
...options
|
|
49738
49926
|
};
|
|
49739
49927
|
const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
|
|
49740
|
-
const {
|
|
49928
|
+
const {
|
|
49929
|
+
instructions,
|
|
49930
|
+
allowSystemInMessages,
|
|
49931
|
+
messages,
|
|
49932
|
+
prompt,
|
|
49933
|
+
...callArgs
|
|
49934
|
+
} = preparedCallArgs;
|
|
49741
49935
|
return {
|
|
49742
49936
|
...callArgs,
|
|
49743
|
-
...{
|
|
49937
|
+
...{
|
|
49938
|
+
system: instructions,
|
|
49939
|
+
allowSystemInMessages,
|
|
49940
|
+
messages,
|
|
49941
|
+
prompt
|
|
49942
|
+
}
|
|
49744
49943
|
};
|
|
49745
49944
|
}
|
|
49746
49945
|
mergeOnStepFinishCallbacks(methodCallback) {
|
|
@@ -49781,7 +49980,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
49781
49980
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
49782
49981
|
});
|
|
49783
49982
|
}
|
|
49784
|
-
}, uiMessagesSchema, DefaultEmbedResult = class {
|
|
49983
|
+
}, toolMetadataSchema2, uiMessagesSchema, DefaultEmbedResult = class {
|
|
49785
49984
|
constructor(options) {
|
|
49786
49985
|
this.value = options.value;
|
|
49787
49986
|
this.embedding = options.embedding;
|
|
@@ -51289,6 +51488,7 @@ var init_dist6 = __esm(() => {
|
|
|
51289
51488
|
init_dist5();
|
|
51290
51489
|
init_dist2();
|
|
51291
51490
|
init_dist2();
|
|
51491
|
+
init_dist5();
|
|
51292
51492
|
init_dist4();
|
|
51293
51493
|
init_dist4();
|
|
51294
51494
|
init_dist4();
|
|
@@ -52148,6 +52348,7 @@ var init_dist6 = __esm(() => {
|
|
|
52148
52348
|
"x-vercel-ai-ui-message-stream": "v1",
|
|
52149
52349
|
"x-accel-buffering": "no"
|
|
52150
52350
|
};
|
|
52351
|
+
toolMetadataSchema = exports_external3.record(exports_external3.string(), jsonValueSchema.optional());
|
|
52151
52352
|
uiMessageChunkSchema = lazySchema(() => zodSchema(exports_external3.union([
|
|
52152
52353
|
exports_external3.strictObject({
|
|
52153
52354
|
type: exports_external3.literal("text-start"),
|
|
@@ -52175,6 +52376,7 @@ var init_dist6 = __esm(() => {
|
|
|
52175
52376
|
toolName: exports_external3.string(),
|
|
52176
52377
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52177
52378
|
providerMetadata: providerMetadataSchema.optional(),
|
|
52379
|
+
toolMetadata: toolMetadataSchema.optional(),
|
|
52178
52380
|
dynamic: exports_external3.boolean().optional(),
|
|
52179
52381
|
title: exports_external3.string().optional()
|
|
52180
52382
|
}),
|
|
@@ -52190,6 +52392,7 @@ var init_dist6 = __esm(() => {
|
|
|
52190
52392
|
input: exports_external3.unknown(),
|
|
52191
52393
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52192
52394
|
providerMetadata: providerMetadataSchema.optional(),
|
|
52395
|
+
toolMetadata: toolMetadataSchema.optional(),
|
|
52193
52396
|
dynamic: exports_external3.boolean().optional(),
|
|
52194
52397
|
title: exports_external3.string().optional()
|
|
52195
52398
|
}),
|
|
@@ -52200,6 +52403,7 @@ var init_dist6 = __esm(() => {
|
|
|
52200
52403
|
input: exports_external3.unknown(),
|
|
52201
52404
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52202
52405
|
providerMetadata: providerMetadataSchema.optional(),
|
|
52406
|
+
toolMetadata: toolMetadataSchema.optional(),
|
|
52203
52407
|
dynamic: exports_external3.boolean().optional(),
|
|
52204
52408
|
errorText: exports_external3.string(),
|
|
52205
52409
|
title: exports_external3.string().optional()
|
|
@@ -52215,6 +52419,7 @@ var init_dist6 = __esm(() => {
|
|
|
52215
52419
|
output: exports_external3.unknown(),
|
|
52216
52420
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52217
52421
|
providerMetadata: providerMetadataSchema.optional(),
|
|
52422
|
+
toolMetadata: toolMetadataSchema.optional(),
|
|
52218
52423
|
dynamic: exports_external3.boolean().optional(),
|
|
52219
52424
|
preliminary: exports_external3.boolean().optional()
|
|
52220
52425
|
}),
|
|
@@ -52224,6 +52429,7 @@ var init_dist6 = __esm(() => {
|
|
|
52224
52429
|
errorText: exports_external3.string(),
|
|
52225
52430
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52226
52431
|
providerMetadata: providerMetadataSchema.optional(),
|
|
52432
|
+
toolMetadata: toolMetadataSchema.optional(),
|
|
52227
52433
|
dynamic: exports_external3.boolean().optional()
|
|
52228
52434
|
}),
|
|
52229
52435
|
exports_external3.strictObject({
|
|
@@ -52311,6 +52517,7 @@ var init_dist6 = __esm(() => {
|
|
|
52311
52517
|
prefix: "aitxt",
|
|
52312
52518
|
size: 24
|
|
52313
52519
|
});
|
|
52520
|
+
toolMetadataSchema2 = exports_external3.record(exports_external3.string(), jsonValueSchema.optional());
|
|
52314
52521
|
uiMessagesSchema = lazySchema(() => zodSchema(exports_external3.array(exports_external3.object({
|
|
52315
52522
|
id: exports_external3.string(),
|
|
52316
52523
|
role: exports_external3.enum(["system", "user", "assistant"]),
|
|
@@ -52362,6 +52569,7 @@ var init_dist6 = __esm(() => {
|
|
|
52362
52569
|
type: exports_external3.literal("dynamic-tool"),
|
|
52363
52570
|
toolName: exports_external3.string(),
|
|
52364
52571
|
toolCallId: exports_external3.string(),
|
|
52572
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52365
52573
|
state: exports_external3.literal("input-streaming"),
|
|
52366
52574
|
input: exports_external3.unknown().optional(),
|
|
52367
52575
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52374,6 +52582,7 @@ var init_dist6 = __esm(() => {
|
|
|
52374
52582
|
type: exports_external3.literal("dynamic-tool"),
|
|
52375
52583
|
toolName: exports_external3.string(),
|
|
52376
52584
|
toolCallId: exports_external3.string(),
|
|
52585
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52377
52586
|
state: exports_external3.literal("input-available"),
|
|
52378
52587
|
input: exports_external3.unknown(),
|
|
52379
52588
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52386,6 +52595,7 @@ var init_dist6 = __esm(() => {
|
|
|
52386
52595
|
type: exports_external3.literal("dynamic-tool"),
|
|
52387
52596
|
toolName: exports_external3.string(),
|
|
52388
52597
|
toolCallId: exports_external3.string(),
|
|
52598
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52389
52599
|
state: exports_external3.literal("approval-requested"),
|
|
52390
52600
|
input: exports_external3.unknown(),
|
|
52391
52601
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52402,6 +52612,7 @@ var init_dist6 = __esm(() => {
|
|
|
52402
52612
|
type: exports_external3.literal("dynamic-tool"),
|
|
52403
52613
|
toolName: exports_external3.string(),
|
|
52404
52614
|
toolCallId: exports_external3.string(),
|
|
52615
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52405
52616
|
state: exports_external3.literal("approval-responded"),
|
|
52406
52617
|
input: exports_external3.unknown(),
|
|
52407
52618
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52418,6 +52629,7 @@ var init_dist6 = __esm(() => {
|
|
|
52418
52629
|
type: exports_external3.literal("dynamic-tool"),
|
|
52419
52630
|
toolName: exports_external3.string(),
|
|
52420
52631
|
toolCallId: exports_external3.string(),
|
|
52632
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52421
52633
|
state: exports_external3.literal("output-available"),
|
|
52422
52634
|
input: exports_external3.unknown(),
|
|
52423
52635
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52436,8 +52648,9 @@ var init_dist6 = __esm(() => {
|
|
|
52436
52648
|
type: exports_external3.literal("dynamic-tool"),
|
|
52437
52649
|
toolName: exports_external3.string(),
|
|
52438
52650
|
toolCallId: exports_external3.string(),
|
|
52651
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52439
52652
|
state: exports_external3.literal("output-error"),
|
|
52440
|
-
input: exports_external3.unknown(),
|
|
52653
|
+
input: exports_external3.unknown().optional(),
|
|
52441
52654
|
rawInput: exports_external3.unknown().optional(),
|
|
52442
52655
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52443
52656
|
output: exports_external3.never().optional(),
|
|
@@ -52454,6 +52667,7 @@ var init_dist6 = __esm(() => {
|
|
|
52454
52667
|
type: exports_external3.literal("dynamic-tool"),
|
|
52455
52668
|
toolName: exports_external3.string(),
|
|
52456
52669
|
toolCallId: exports_external3.string(),
|
|
52670
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52457
52671
|
state: exports_external3.literal("output-denied"),
|
|
52458
52672
|
input: exports_external3.unknown(),
|
|
52459
52673
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52469,6 +52683,7 @@ var init_dist6 = __esm(() => {
|
|
|
52469
52683
|
exports_external3.object({
|
|
52470
52684
|
type: exports_external3.string().startsWith("tool-"),
|
|
52471
52685
|
toolCallId: exports_external3.string(),
|
|
52686
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52472
52687
|
state: exports_external3.literal("input-streaming"),
|
|
52473
52688
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52474
52689
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
@@ -52480,6 +52695,7 @@ var init_dist6 = __esm(() => {
|
|
|
52480
52695
|
exports_external3.object({
|
|
52481
52696
|
type: exports_external3.string().startsWith("tool-"),
|
|
52482
52697
|
toolCallId: exports_external3.string(),
|
|
52698
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52483
52699
|
state: exports_external3.literal("input-available"),
|
|
52484
52700
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52485
52701
|
input: exports_external3.unknown(),
|
|
@@ -52491,6 +52707,7 @@ var init_dist6 = __esm(() => {
|
|
|
52491
52707
|
exports_external3.object({
|
|
52492
52708
|
type: exports_external3.string().startsWith("tool-"),
|
|
52493
52709
|
toolCallId: exports_external3.string(),
|
|
52710
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52494
52711
|
state: exports_external3.literal("approval-requested"),
|
|
52495
52712
|
input: exports_external3.unknown(),
|
|
52496
52713
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52506,6 +52723,7 @@ var init_dist6 = __esm(() => {
|
|
|
52506
52723
|
exports_external3.object({
|
|
52507
52724
|
type: exports_external3.string().startsWith("tool-"),
|
|
52508
52725
|
toolCallId: exports_external3.string(),
|
|
52726
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52509
52727
|
state: exports_external3.literal("approval-responded"),
|
|
52510
52728
|
input: exports_external3.unknown(),
|
|
52511
52729
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -52521,6 +52739,7 @@ var init_dist6 = __esm(() => {
|
|
|
52521
52739
|
exports_external3.object({
|
|
52522
52740
|
type: exports_external3.string().startsWith("tool-"),
|
|
52523
52741
|
toolCallId: exports_external3.string(),
|
|
52742
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52524
52743
|
state: exports_external3.literal("output-available"),
|
|
52525
52744
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52526
52745
|
input: exports_external3.unknown(),
|
|
@@ -52538,9 +52757,10 @@ var init_dist6 = __esm(() => {
|
|
|
52538
52757
|
exports_external3.object({
|
|
52539
52758
|
type: exports_external3.string().startsWith("tool-"),
|
|
52540
52759
|
toolCallId: exports_external3.string(),
|
|
52760
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52541
52761
|
state: exports_external3.literal("output-error"),
|
|
52542
52762
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52543
|
-
input: exports_external3.unknown(),
|
|
52763
|
+
input: exports_external3.unknown().optional(),
|
|
52544
52764
|
rawInput: exports_external3.unknown().optional(),
|
|
52545
52765
|
output: exports_external3.never().optional(),
|
|
52546
52766
|
errorText: exports_external3.string(),
|
|
@@ -52555,6 +52775,7 @@ var init_dist6 = __esm(() => {
|
|
|
52555
52775
|
exports_external3.object({
|
|
52556
52776
|
type: exports_external3.string().startsWith("tool-"),
|
|
52557
52777
|
toolCallId: exports_external3.string(),
|
|
52778
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
52558
52779
|
state: exports_external3.literal("output-denied"),
|
|
52559
52780
|
providerExecuted: exports_external3.boolean().optional(),
|
|
52560
52781
|
input: exports_external3.unknown(),
|
|
@@ -53044,52 +53265,54 @@ import { promises as fsPromises } from "fs";
|
|
|
53044
53265
|
import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
53045
53266
|
import { promises as fs2 } from "fs";
|
|
53046
53267
|
import { homedir as homedir22 } from "os";
|
|
53047
|
-
import { dirname as dirname3, join as
|
|
53268
|
+
import { dirname as dirname3, join as join62 } from "path";
|
|
53048
53269
|
import { exec } from "child_process";
|
|
53049
53270
|
import { promisify } from "util";
|
|
53050
|
-
import { readFileSync as
|
|
53271
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
53051
53272
|
import { webcrypto as crypto2 } from "crypto";
|
|
53052
|
-
import { existsSync as
|
|
53053
|
-
import { join as
|
|
53273
|
+
import { existsSync as existsSync5, writeFileSync as writeFileSync4, readFileSync as readFileSync3, mkdirSync as mkdirSync32 } from "fs";
|
|
53274
|
+
import { join as join52 } from "path";
|
|
53054
53275
|
import { Database as Database4 } from "bun:sqlite";
|
|
53055
53276
|
import { existsSync as existsSync11, mkdirSync as mkdirSync9 } from "fs";
|
|
53056
53277
|
import { dirname as dirname4, join as join14, resolve as resolve2 } from "path";
|
|
53057
|
-
import { existsSync as existsSync22, writeFileSync as
|
|
53278
|
+
import { existsSync as existsSync22, writeFileSync as writeFileSync3 } from "fs";
|
|
53058
53279
|
import { join as join22 } from "path";
|
|
53059
|
-
import {
|
|
53060
|
-
import {
|
|
53061
|
-
import {
|
|
53062
|
-
import { join as join32, dirname as dirname22 } from "path";
|
|
53280
|
+
import { execFileSync } from "child_process";
|
|
53281
|
+
import { writeFileSync as writeFileSync22, existsSync as existsSync32, readFileSync as readFileSync5 } from "fs";
|
|
53282
|
+
import { join as join32 } from "path";
|
|
53063
53283
|
import { hostname as hostname3 } from "os";
|
|
53284
|
+
import { existsSync as existsSync42, readFileSync as readFileSync22, writeFileSync as writeFileSync32, mkdirSync as mkdirSync22 } from "fs";
|
|
53285
|
+
import { homedir as homedir11 } from "os";
|
|
53286
|
+
import { join as join42, dirname as dirname22 } from "path";
|
|
53064
53287
|
import { Buffer as Buffer2 } from "buffer";
|
|
53065
53288
|
import * as zlib from "zlib";
|
|
53066
53289
|
import { Readable } from "stream";
|
|
53067
53290
|
import { Writable } from "stream";
|
|
53068
53291
|
import { createHash as createHash2 } from "crypto";
|
|
53069
|
-
import { mkdirSync as mkdirSync4, statSync, writeFileSync as
|
|
53070
|
-
import { dirname as dirname42, join as
|
|
53292
|
+
import { mkdirSync as mkdirSync4, statSync, writeFileSync as writeFileSync5 } from "fs";
|
|
53293
|
+
import { dirname as dirname42, join as join72, relative as relative2 } from "path";
|
|
53071
53294
|
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
53072
|
-
import { existsSync as
|
|
53073
|
-
import { basename, join as
|
|
53295
|
+
import { existsSync as existsSync72, readdirSync as readdirSync3, readFileSync as readFileSync52, statSync as statSync2 } from "fs";
|
|
53296
|
+
import { basename, join as join82, resolve as resolve22 } from "path";
|
|
53074
53297
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
53075
|
-
import { existsSync as
|
|
53076
|
-
import { dirname as dirname5, join as
|
|
53298
|
+
import { existsSync as existsSync82, readFileSync as readFileSync6, writeFileSync as writeFileSync6, mkdirSync as mkdirSync52 } from "fs";
|
|
53299
|
+
import { dirname as dirname5, join as join92 } from "path";
|
|
53077
53300
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
53078
|
-
import { existsSync as
|
|
53079
|
-
import { join as
|
|
53301
|
+
import { existsSync as existsSync112 } from "fs";
|
|
53302
|
+
import { join as join122 } from "path";
|
|
53080
53303
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
53081
|
-
import { existsSync as existsSync82 } from "fs";
|
|
53082
|
-
import { homedir as homedir32, hostname as hostname22, platform as platform2, type } from "os";
|
|
53083
|
-
import { join as join92 } from "path";
|
|
53084
53304
|
import { existsSync as existsSync92 } from "fs";
|
|
53085
|
-
import {
|
|
53305
|
+
import { homedir as homedir32, hostname as hostname22, platform as platform2, type } from "os";
|
|
53086
53306
|
import { join as join102 } from "path";
|
|
53087
|
-
import {
|
|
53088
|
-
import {
|
|
53307
|
+
import { existsSync as existsSync102 } from "fs";
|
|
53308
|
+
import { execSync as execSync2 } from "child_process";
|
|
53309
|
+
import { join as join112 } from "path";
|
|
53310
|
+
import { execSync as execSync22 } from "child_process";
|
|
53311
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
53089
53312
|
import { mkdirSync as mkdirSync62 } from "fs";
|
|
53090
|
-
import { dirname as dirname6, join as
|
|
53313
|
+
import { dirname as dirname6, join as join132 } from "path";
|
|
53091
53314
|
import { fileURLToPath } from "url";
|
|
53092
|
-
import { existsSync as
|
|
53315
|
+
import { existsSync as existsSync12 } from "fs";
|
|
53093
53316
|
function __accessProp3(key) {
|
|
53094
53317
|
return this[key];
|
|
53095
53318
|
}
|
|
@@ -53266,14 +53489,25 @@ function uuid5() {
|
|
|
53266
53489
|
function isGitRepo(path) {
|
|
53267
53490
|
return existsSync22(join22(path, ".git"));
|
|
53268
53491
|
}
|
|
53492
|
+
function getCurrentBranch(path) {
|
|
53493
|
+
return execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
53494
|
+
cwd: path,
|
|
53495
|
+
stdio: "pipe",
|
|
53496
|
+
encoding: "utf-8",
|
|
53497
|
+
env: process.env
|
|
53498
|
+
}).trim();
|
|
53499
|
+
}
|
|
53500
|
+
function bootstrapPathsToStage(path) {
|
|
53501
|
+
return BOOTSTRAP_PATHS.filter((entry) => existsSync22(join22(path, entry)));
|
|
53502
|
+
}
|
|
53269
53503
|
function gitInit(project) {
|
|
53270
53504
|
const { path, name: name21, id, slug } = project;
|
|
53271
53505
|
if (isGitRepo(path))
|
|
53272
53506
|
return;
|
|
53273
|
-
|
|
53507
|
+
execFileSync("git", ["init", "-b", "main"], { cwd: path, stdio: "pipe", env: process.env });
|
|
53274
53508
|
const gitignorePath = join22(path, ".gitignore");
|
|
53275
53509
|
if (!existsSync22(gitignorePath)) {
|
|
53276
|
-
|
|
53510
|
+
writeFileSync3(gitignorePath, GITIGNORE_TEMPLATE, "utf-8");
|
|
53277
53511
|
}
|
|
53278
53512
|
const projectJson = {
|
|
53279
53513
|
id,
|
|
@@ -53282,26 +53516,18 @@ function gitInit(project) {
|
|
|
53282
53516
|
created_at: project.created_at,
|
|
53283
53517
|
integrations: project.integrations ?? {}
|
|
53284
53518
|
};
|
|
53285
|
-
|
|
53519
|
+
writeFileSync3(join22(path, ".project.json"), JSON.stringify(projectJson, null, 2) + `
|
|
53286
53520
|
`, "utf-8");
|
|
53287
|
-
|
|
53288
|
-
|
|
53521
|
+
const staged = bootstrapPathsToStage(path);
|
|
53522
|
+
if (staged.length === 0)
|
|
53523
|
+
return;
|
|
53524
|
+
execFileSync("git", ["add", ...staged], { cwd: path, stdio: "pipe", env: process.env });
|
|
53525
|
+
execFileSync("git", ["commit", "-m", `chore: init project ${name21}`], {
|
|
53289
53526
|
cwd: path,
|
|
53290
53527
|
stdio: "pipe",
|
|
53291
53528
|
env: { ...process.env, GIT_AUTHOR_NAME: "open-projects", GIT_COMMITTER_NAME: "open-projects" }
|
|
53292
53529
|
});
|
|
53293
53530
|
}
|
|
53294
|
-
function getConfig() {
|
|
53295
|
-
if (existsSync32(CONFIG_PATH3)) {
|
|
53296
|
-
try {
|
|
53297
|
-
const user = JSON.parse(readFileSync4(CONFIG_PATH3, "utf-8"));
|
|
53298
|
-
return { ...DEFAULTS, ...user };
|
|
53299
|
-
} catch {
|
|
53300
|
-
return { ...DEFAULTS };
|
|
53301
|
-
}
|
|
53302
|
-
}
|
|
53303
|
-
return { ...DEFAULTS };
|
|
53304
|
-
}
|
|
53305
53531
|
function rowToWorkdir(row) {
|
|
53306
53532
|
return {
|
|
53307
53533
|
...row,
|
|
@@ -53345,6 +53571,176 @@ function removeWorkdir(projectId, path, db2) {
|
|
|
53345
53571
|
const d = db2 || getDatabase2();
|
|
53346
53572
|
d.run("DELETE FROM project_workdirs WHERE project_id = ? AND path = ?", [projectId, path]);
|
|
53347
53573
|
}
|
|
53574
|
+
function markWorkdirGenerated(projectId, path, db2) {
|
|
53575
|
+
const d = db2 || getDatabase2();
|
|
53576
|
+
d.run("UPDATE project_workdirs SET claude_md_generated = 1, agents_md_generated = 1 WHERE project_id = ? AND path = ?", [projectId, path]);
|
|
53577
|
+
}
|
|
53578
|
+
function buildWorkdirList(workdirs, currentPath) {
|
|
53579
|
+
return workdirs.map((w) => {
|
|
53580
|
+
const isCurrent = w.path === currentPath;
|
|
53581
|
+
const primary = w.is_primary ? " (primary)" : "";
|
|
53582
|
+
const current = isCurrent ? " \u2190 you are here" : "";
|
|
53583
|
+
return `- \`${w.path}\` [${w.label}]${primary}${current} *(machine: ${w.machine_id})*`;
|
|
53584
|
+
}).join(`
|
|
53585
|
+
`);
|
|
53586
|
+
}
|
|
53587
|
+
function claudeMdContent(project, workdir, allWorkdirs) {
|
|
53588
|
+
const otherDirs = allWorkdirs.filter((w) => w.path !== workdir.path);
|
|
53589
|
+
const otherSection = otherDirs.length ? `
|
|
53590
|
+
## Other Working Directories
|
|
53591
|
+
${buildWorkdirList(otherDirs, workdir.path)}
|
|
53592
|
+
` : "";
|
|
53593
|
+
const integrations = Object.keys(project.integrations).length ? `
|
|
53594
|
+
## Integrations
|
|
53595
|
+
${Object.entries(project.integrations).filter(([, v]) => v).map(([k, v]) => `- **${k}:** \`${v}\``).join(`
|
|
53596
|
+
`)}
|
|
53597
|
+
` : "";
|
|
53598
|
+
const tags = project.tags.length ? `
|
|
53599
|
+
**Tags:** ${project.tags.join(", ")}` : "";
|
|
53600
|
+
return `# Project: ${project.name}
|
|
53601
|
+
|
|
53602
|
+
> ${project.description ?? `Working directory for project **${project.name}**`}
|
|
53603
|
+
${tags}
|
|
53604
|
+
|
|
53605
|
+
## Working Directory
|
|
53606
|
+
|
|
53607
|
+
You are working in the **${workdir.label}** directory for this project:
|
|
53608
|
+
|
|
53609
|
+
\`\`\`
|
|
53610
|
+
${workdir.path}
|
|
53611
|
+
\`\`\`
|
|
53612
|
+
|
|
53613
|
+
**Write all code to this directory.** Do not write to other project directories unless explicitly instructed.
|
|
53614
|
+
|
|
53615
|
+
## Project Metadata
|
|
53616
|
+
|
|
53617
|
+
| Field | Value |
|
|
53618
|
+
|-------|-------|
|
|
53619
|
+
| ID | \`${project.id}\` |
|
|
53620
|
+
| Slug | \`${project.slug}\` |
|
|
53621
|
+
| Label | \`${workdir.label}\` |
|
|
53622
|
+
| Machine | \`${workdir.machine_id}\` |
|
|
53623
|
+
| Status | ${project.status} |
|
|
53624
|
+
${project.git_remote ? `| Git Remote | ${project.git_remote} |` : ""}
|
|
53625
|
+
${project.s3_bucket ? `| S3 Bucket | \`${project.s3_bucket}\` |` : ""}
|
|
53626
|
+
${integrations}${otherSection}
|
|
53627
|
+
## All Working Directories
|
|
53628
|
+
|
|
53629
|
+
${buildWorkdirList(allWorkdirs, workdir.path)}
|
|
53630
|
+
|
|
53631
|
+
## Instructions for AI Agents
|
|
53632
|
+
|
|
53633
|
+
1. **Write code in \`${workdir.path}\`** \u2014 this is your working directory for this session.
|
|
53634
|
+
2. Use \`projects sync ${project.slug}\` to push changes to S3.
|
|
53635
|
+
3. Use \`projects git ${project.slug} <args>\` to run git commands.
|
|
53636
|
+
4. If you need to switch to a different workdir, call \`projects_open\` with the project ID.
|
|
53637
|
+
|
|
53638
|
+
---
|
|
53639
|
+
*Generated by open-projects. Regenerate: \`projects workdir generate ${project.slug}\`*
|
|
53640
|
+
`.trimStart();
|
|
53641
|
+
}
|
|
53642
|
+
function agentsMdContent(project, workdir, allWorkdirs) {
|
|
53643
|
+
const otherDirs = allWorkdirs.filter((w) => w.path !== workdir.path);
|
|
53644
|
+
return `---
|
|
53645
|
+
project_id: ${project.id}
|
|
53646
|
+
project_slug: ${project.slug}
|
|
53647
|
+
project_name: ${project.name}
|
|
53648
|
+
working_directory: ${workdir.path}
|
|
53649
|
+
label: ${workdir.label}
|
|
53650
|
+
machine_id: ${workdir.machine_id}
|
|
53651
|
+
is_primary: ${workdir.is_primary}
|
|
53652
|
+
---
|
|
53653
|
+
|
|
53654
|
+
# ${project.name} \u2014 Agent Instructions
|
|
53655
|
+
|
|
53656
|
+
## Scope
|
|
53657
|
+
|
|
53658
|
+
This agent session is scoped to the **${workdir.label}** working directory:
|
|
53659
|
+
|
|
53660
|
+
\`\`\`
|
|
53661
|
+
${workdir.path}
|
|
53662
|
+
\`\`\`
|
|
53663
|
+
|
|
53664
|
+
**Only write files inside this directory** unless the user explicitly asks you to work elsewhere.
|
|
53665
|
+
${otherDirs.length ? `
|
|
53666
|
+
## Other workdirs for this project
|
|
53667
|
+
|
|
53668
|
+
${otherDirs.map((w) => `- \`${w.path}\` [${w.label}] on ${w.machine_id}`).join(`
|
|
53669
|
+
`)}
|
|
53670
|
+
` : ""}
|
|
53671
|
+
## Quick Reference
|
|
53672
|
+
|
|
53673
|
+
\`\`\`bash
|
|
53674
|
+
# Open this project
|
|
53675
|
+
cd ${workdir.path}
|
|
53676
|
+
|
|
53677
|
+
# Sync to S3
|
|
53678
|
+
projects sync ${project.slug}
|
|
53679
|
+
|
|
53680
|
+
# Git operations
|
|
53681
|
+
projects git ${project.slug} status
|
|
53682
|
+
projects git ${project.slug} log --oneline -10
|
|
53683
|
+
\`\`\`
|
|
53684
|
+
${Object.keys(project.integrations).length ? `
|
|
53685
|
+
## Service IDs
|
|
53686
|
+
|
|
53687
|
+
${Object.entries(project.integrations).filter(([, v]) => v).map(([k, v]) => `- **${k}:** \`${v}\``).join(`
|
|
53688
|
+
`)}
|
|
53689
|
+
` : ""}
|
|
53690
|
+
---
|
|
53691
|
+
*Generated by open-projects ${new Date().toISOString().slice(0, 10)}*
|
|
53692
|
+
`.trimStart();
|
|
53693
|
+
}
|
|
53694
|
+
function generateForWorkdir(project, workdir, allWorkdirs, options = {}) {
|
|
53695
|
+
const claudeMd = claudeMdContent(project, workdir, allWorkdirs);
|
|
53696
|
+
const agentsMd = agentsMdContent(project, workdir, allWorkdirs);
|
|
53697
|
+
const claudePath = join32(workdir.path, "CLAUDE.md");
|
|
53698
|
+
const agentsPath = join32(workdir.path, "AGENTS.md");
|
|
53699
|
+
let written = false;
|
|
53700
|
+
if (!options.dryRun && existsSync32(workdir.path)) {
|
|
53701
|
+
if (existsSync32(claudePath) && !options.force) {
|
|
53702
|
+
const existing = readFileSync5(claudePath, "utf-8");
|
|
53703
|
+
if (existing.includes("Generated by open-projects")) {
|
|
53704
|
+
writeFileSync22(claudePath, claudeMd, "utf-8");
|
|
53705
|
+
} else {
|
|
53706
|
+
const separator = `
|
|
53707
|
+
|
|
53708
|
+
---
|
|
53709
|
+
|
|
53710
|
+
<!-- open-projects -->
|
|
53711
|
+
`;
|
|
53712
|
+
const marker21 = "<!-- open-projects -->";
|
|
53713
|
+
if (existing.includes(marker21)) {
|
|
53714
|
+
const before = existing.slice(0, existing.indexOf(marker21) - separator.length + 1);
|
|
53715
|
+
writeFileSync22(claudePath, before + separator + claudeMd, "utf-8");
|
|
53716
|
+
} else {
|
|
53717
|
+
writeFileSync22(claudePath, existing.trimEnd() + separator + claudeMd, "utf-8");
|
|
53718
|
+
}
|
|
53719
|
+
}
|
|
53720
|
+
} else {
|
|
53721
|
+
writeFileSync22(claudePath, claudeMd, "utf-8");
|
|
53722
|
+
}
|
|
53723
|
+
writeFileSync22(agentsPath, agentsMd, "utf-8");
|
|
53724
|
+
markWorkdirGenerated(project.id, workdir.path, options.db);
|
|
53725
|
+
written = true;
|
|
53726
|
+
}
|
|
53727
|
+
return { path: workdir.path, claude_md: claudeMd, agents_md: agentsMd, written };
|
|
53728
|
+
}
|
|
53729
|
+
function generateAllWorkdirs(project, options = {}) {
|
|
53730
|
+
const workdirs = listWorkdirs(project.id, options.db);
|
|
53731
|
+
return workdirs.map((w) => generateForWorkdir(project, w, workdirs, options));
|
|
53732
|
+
}
|
|
53733
|
+
function getConfig() {
|
|
53734
|
+
if (existsSync42(CONFIG_PATH3)) {
|
|
53735
|
+
try {
|
|
53736
|
+
const user = JSON.parse(readFileSync22(CONFIG_PATH3, "utf-8"));
|
|
53737
|
+
return { ...DEFAULTS, ...user };
|
|
53738
|
+
} catch {
|
|
53739
|
+
return { ...DEFAULTS };
|
|
53740
|
+
}
|
|
53741
|
+
}
|
|
53742
|
+
return { ...DEFAULTS };
|
|
53743
|
+
}
|
|
53348
53744
|
function generateProjectId() {
|
|
53349
53745
|
return `prj_${nanoid3()}`;
|
|
53350
53746
|
}
|
|
@@ -53352,12 +53748,10 @@ function slugify2(name21) {
|
|
|
53352
53748
|
return name21.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
53353
53749
|
}
|
|
53354
53750
|
function scaffoldProject(path) {
|
|
53355
|
-
if (existsSync42(path))
|
|
53356
|
-
return;
|
|
53357
53751
|
mkdirSync32(path, { recursive: true });
|
|
53358
53752
|
const config2 = getConfig();
|
|
53359
53753
|
for (const dir of config2.scaffold_dirs || ["data", "scripts", "assets", "docs"]) {
|
|
53360
|
-
mkdirSync32(
|
|
53754
|
+
mkdirSync32(join52(path, dir), { recursive: true });
|
|
53361
53755
|
}
|
|
53362
53756
|
}
|
|
53363
53757
|
function ensureUniqueSlug(base, db2, excludeId) {
|
|
@@ -53408,6 +53802,9 @@ function createProject2(input, db2) {
|
|
|
53408
53802
|
try {
|
|
53409
53803
|
addWorkdir({ project_id: id, path: input.path, label: "main", is_primary: true }, d);
|
|
53410
53804
|
} catch {}
|
|
53805
|
+
try {
|
|
53806
|
+
generateAllWorkdirs(project, { db: d });
|
|
53807
|
+
} catch {}
|
|
53411
53808
|
const shouldGitInit = input.git_init !== false;
|
|
53412
53809
|
if (shouldGitInit) {
|
|
53413
53810
|
try {
|
|
@@ -53513,10 +53910,10 @@ function setIntegrations(id, integrations, db2) {
|
|
|
53513
53910
|
id
|
|
53514
53911
|
]);
|
|
53515
53912
|
try {
|
|
53516
|
-
const jsonPath =
|
|
53517
|
-
if (
|
|
53518
|
-
const existing = JSON.parse(
|
|
53519
|
-
|
|
53913
|
+
const jsonPath = join52(project.path, ".project.json");
|
|
53914
|
+
if (existsSync5(jsonPath)) {
|
|
53915
|
+
const existing = JSON.parse(readFileSync3(jsonPath, "utf-8"));
|
|
53916
|
+
writeFileSync4(jsonPath, JSON.stringify({ ...existing, integrations: merged }, null, 2) + `
|
|
53520
53917
|
`, "utf-8");
|
|
53521
53918
|
}
|
|
53522
53919
|
} catch {}
|
|
@@ -54590,7 +54987,7 @@ async function collectLocalFiles(rootPath) {
|
|
|
54590
54987
|
async function walk(dir) {
|
|
54591
54988
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
54592
54989
|
for (const entry of entries) {
|
|
54593
|
-
const fullPath =
|
|
54990
|
+
const fullPath = join72(dir, entry.name);
|
|
54594
54991
|
if (entry.isDirectory()) {
|
|
54595
54992
|
await walk(fullPath);
|
|
54596
54993
|
} else if (entry.isFile()) {
|
|
@@ -54662,7 +55059,7 @@ async function syncProject(project, options = {}) {
|
|
|
54662
55059
|
continue;
|
|
54663
55060
|
}
|
|
54664
55061
|
try {
|
|
54665
|
-
const data = await readFile2(
|
|
55062
|
+
const data = await readFile2(join72(project.path, relPath));
|
|
54666
55063
|
await client.send(new PutObjectCommand({
|
|
54667
55064
|
Bucket: bucket,
|
|
54668
55065
|
Key: s3Key,
|
|
@@ -54700,9 +55097,9 @@ async function syncProject(project, options = {}) {
|
|
|
54700
55097
|
chunks.push(chunk);
|
|
54701
55098
|
}
|
|
54702
55099
|
const data = Buffer.concat(chunks);
|
|
54703
|
-
const localPath =
|
|
55100
|
+
const localPath = join72(project.path, relPath);
|
|
54704
55101
|
mkdirSync4(dirname42(localPath), { recursive: true });
|
|
54705
|
-
|
|
55102
|
+
writeFileSync5(localPath, data);
|
|
54706
55103
|
log(`pull: ${relPath} (${data.length}B)`);
|
|
54707
55104
|
result.pulled++;
|
|
54708
55105
|
result.bytes += data.length;
|
|
@@ -54723,18 +55120,18 @@ async function syncProject(project, options = {}) {
|
|
|
54723
55120
|
return result;
|
|
54724
55121
|
}
|
|
54725
55122
|
function inferProjectName(projectPath) {
|
|
54726
|
-
const pkgPath =
|
|
54727
|
-
if (
|
|
55123
|
+
const pkgPath = join82(projectPath, "package.json");
|
|
55124
|
+
if (existsSync72(pkgPath)) {
|
|
54728
55125
|
try {
|
|
54729
|
-
const pkg = JSON.parse(
|
|
55126
|
+
const pkg = JSON.parse(readFileSync52(pkgPath, "utf-8"));
|
|
54730
55127
|
if (pkg.name)
|
|
54731
55128
|
return pkg.name.replace(/^@[^/]+\//, "");
|
|
54732
55129
|
} catch {}
|
|
54733
55130
|
}
|
|
54734
|
-
const projPath =
|
|
54735
|
-
if (
|
|
55131
|
+
const projPath = join82(projectPath, ".project.json");
|
|
55132
|
+
if (existsSync72(projPath)) {
|
|
54736
55133
|
try {
|
|
54737
|
-
const p2 = JSON.parse(
|
|
55134
|
+
const p2 = JSON.parse(readFileSync52(projPath, "utf-8"));
|
|
54738
55135
|
if (p2.name)
|
|
54739
55136
|
return p2.name;
|
|
54740
55137
|
} catch {}
|
|
@@ -54742,11 +55139,11 @@ function inferProjectName(projectPath) {
|
|
|
54742
55139
|
return basename(projectPath);
|
|
54743
55140
|
}
|
|
54744
55141
|
function inferGitRemote(projectPath) {
|
|
54745
|
-
const gitConfigPath =
|
|
54746
|
-
if (!
|
|
55142
|
+
const gitConfigPath = join82(projectPath, ".git", "config");
|
|
55143
|
+
if (!existsSync72(gitConfigPath))
|
|
54747
55144
|
return;
|
|
54748
55145
|
try {
|
|
54749
|
-
const config2 =
|
|
55146
|
+
const config2 = readFileSync52(gitConfigPath, "utf-8");
|
|
54750
55147
|
const match = config2.match(/\[remote "origin"\][\s\S]*?url\s*=\s*(.+)/);
|
|
54751
55148
|
return match?.[1]?.trim();
|
|
54752
55149
|
} catch {
|
|
@@ -54756,7 +55153,7 @@ function inferGitRemote(projectPath) {
|
|
|
54756
55153
|
async function importProject(projectPath, options = {}) {
|
|
54757
55154
|
const absPath = resolve22(projectPath);
|
|
54758
55155
|
const log = options.onProgress ?? (() => {});
|
|
54759
|
-
if (!
|
|
55156
|
+
if (!existsSync72(absPath)) {
|
|
54760
55157
|
return { error: `Path does not exist: ${absPath}` };
|
|
54761
55158
|
}
|
|
54762
55159
|
const stat = statSync2(absPath);
|
|
@@ -54791,7 +55188,7 @@ async function importBulk(dirPath, options = {}) {
|
|
|
54791
55188
|
const absDir = resolve22(dirPath);
|
|
54792
55189
|
const result = { imported: [], skipped: [], errors: [] };
|
|
54793
55190
|
const log = options.onProgress ?? (() => {});
|
|
54794
|
-
if (!
|
|
55191
|
+
if (!existsSync72(absDir)) {
|
|
54795
55192
|
result.errors.push({ path: absDir, error: "Directory does not exist" });
|
|
54796
55193
|
return result;
|
|
54797
55194
|
}
|
|
@@ -54799,7 +55196,7 @@ async function importBulk(dirPath, options = {}) {
|
|
|
54799
55196
|
const dirs = entries.filter((e2) => e2.isDirectory() && !e2.name.startsWith("."));
|
|
54800
55197
|
log(`Found ${dirs.length} subdirectories in ${absDir}`);
|
|
54801
55198
|
for (const entry of dirs) {
|
|
54802
|
-
const subPath =
|
|
55199
|
+
const subPath = join82(absDir, entry.name);
|
|
54803
55200
|
const res = await importProject(subPath, options);
|
|
54804
55201
|
if (res.project) {
|
|
54805
55202
|
result.imported.push(res.project);
|
|
@@ -54834,7 +55231,8 @@ function publishProject(name21, path, options = {}) {
|
|
|
54834
55231
|
} else {
|
|
54835
55232
|
execFileSync2("git", ["remote", "add", "origin", remote], { cwd: path, stdio: "pipe", env: process.env });
|
|
54836
55233
|
}
|
|
54837
|
-
|
|
55234
|
+
const branch = getCurrentBranch(path);
|
|
55235
|
+
execFileSync2("git", ["push", "-u", "origin", branch, "--quiet"], { cwd: path, stdio: "pipe", env: process.env });
|
|
54838
55236
|
pushed = true;
|
|
54839
55237
|
} catch {}
|
|
54840
55238
|
}
|
|
@@ -54860,14 +55258,14 @@ function getGitHubUrl(path) {
|
|
|
54860
55258
|
}
|
|
54861
55259
|
}
|
|
54862
55260
|
function getScheduleConfig() {
|
|
54863
|
-
if (!
|
|
55261
|
+
if (!existsSync82(CONFIG_PATH22)) {
|
|
54864
55262
|
return { enabled: false, interval: "daily", direction: "both" };
|
|
54865
55263
|
}
|
|
54866
|
-
return JSON.parse(
|
|
55264
|
+
return JSON.parse(readFileSync6(CONFIG_PATH22, "utf-8"));
|
|
54867
55265
|
}
|
|
54868
55266
|
function saveScheduleConfig(config2) {
|
|
54869
55267
|
mkdirSync52(dirname5(CONFIG_PATH22), { recursive: true });
|
|
54870
|
-
|
|
55268
|
+
writeFileSync6(CONFIG_PATH22, JSON.stringify(config2, null, 2) + `
|
|
54871
55269
|
`, "utf-8");
|
|
54872
55270
|
}
|
|
54873
55271
|
async function syncAll(direction = "both", onProgress) {
|
|
@@ -54897,7 +55295,7 @@ async function syncAll(direction = "both", onProgress) {
|
|
|
54897
55295
|
function getMachineProfile() {
|
|
54898
55296
|
const host = (process.env["HOSTNAME"] || hostname22()).split(".")[0] || hostname22();
|
|
54899
55297
|
const currentPlatform = platform2();
|
|
54900
|
-
const workspaceRoot = currentPlatform === "darwin" ?
|
|
55298
|
+
const workspaceRoot = currentPlatform === "darwin" ? join102(homedir32(), "Workspace") : join102(homedir32(), "workspace");
|
|
54901
55299
|
return {
|
|
54902
55300
|
hostname: host,
|
|
54903
55301
|
platform: currentPlatform,
|
|
@@ -54924,7 +55322,7 @@ function commandAvailability(command, versionArgs = ["--version"]) {
|
|
|
54924
55322
|
return { command, available: true, path: commandPath, version: version2 };
|
|
54925
55323
|
}
|
|
54926
55324
|
function pathExists(path) {
|
|
54927
|
-
return
|
|
55325
|
+
return existsSync92(path);
|
|
54928
55326
|
}
|
|
54929
55327
|
function classifyMachine(host, currentPlatform) {
|
|
54930
55328
|
if (host === "apple01")
|
|
@@ -54938,10 +55336,10 @@ function classifyMachine(host, currentPlatform) {
|
|
|
54938
55336
|
return "unknown";
|
|
54939
55337
|
}
|
|
54940
55338
|
function gitStatus(path) {
|
|
54941
|
-
if (!
|
|
55339
|
+
if (!existsSync102(join112(path, ".git")))
|
|
54942
55340
|
return "not a repo";
|
|
54943
55341
|
try {
|
|
54944
|
-
const out =
|
|
55342
|
+
const out = execSync2("git status --porcelain", { cwd: path, stdio: "pipe", encoding: "utf-8" }).trim();
|
|
54945
55343
|
if (!out)
|
|
54946
55344
|
return "clean";
|
|
54947
55345
|
const n2 = out.split(`
|
|
@@ -54952,17 +55350,17 @@ function gitStatus(path) {
|
|
|
54952
55350
|
}
|
|
54953
55351
|
}
|
|
54954
55352
|
function dirSize(path) {
|
|
54955
|
-
if (!
|
|
55353
|
+
if (!existsSync102(path))
|
|
54956
55354
|
return 0;
|
|
54957
55355
|
try {
|
|
54958
|
-
const out =
|
|
55356
|
+
const out = execSync2(`du -sb -- "${path}" 2>/dev/null || du -sk -- "${path}" 2>/dev/null`, { stdio: "pipe", encoding: "utf-8" }).trim();
|
|
54959
55357
|
return parseInt(out.split("\t")[0] ?? "0", 10);
|
|
54960
55358
|
} catch {
|
|
54961
55359
|
return 0;
|
|
54962
55360
|
}
|
|
54963
55361
|
}
|
|
54964
55362
|
function getProjectStatus(project) {
|
|
54965
|
-
const pathExists2 =
|
|
55363
|
+
const pathExists2 = existsSync102(project.path);
|
|
54966
55364
|
const workdirs = listWorkdirs(project.id);
|
|
54967
55365
|
const lastSync = getDatabase2().query("SELECT completed_at FROM sync_log WHERE project_id = ? AND status = 'completed' ORDER BY completed_at DESC LIMIT 1").get(project.id)?.completed_at ?? null;
|
|
54968
55366
|
return {
|
|
@@ -54975,18 +55373,21 @@ function getProjectStatus(project) {
|
|
|
54975
55373
|
};
|
|
54976
55374
|
}
|
|
54977
55375
|
function run(cmd) {
|
|
54978
|
-
return
|
|
55376
|
+
return execSync22(cmd, { encoding: "utf-8", stdio: "pipe" }).trim();
|
|
54979
55377
|
}
|
|
54980
55378
|
function getTmuxSessionName(project) {
|
|
54981
|
-
|
|
54982
|
-
if (project.path?.includes("opensourcedev")) {
|
|
54983
|
-
const normalized = raw.replace(/^proj-/, "");
|
|
54984
|
-
return normalized.startsWith("open-") ? normalized : `open-${normalized}`;
|
|
54985
|
-
}
|
|
54986
|
-
return raw;
|
|
55379
|
+
return project.slug || project.name;
|
|
54987
55380
|
}
|
|
54988
55381
|
function listSessions() {
|
|
54989
|
-
|
|
55382
|
+
let output = "";
|
|
55383
|
+
try {
|
|
55384
|
+
output = run("tmux list-sessions -F '#{session_name}:#{session_group}:#{session_windows}:#{session_attached}'");
|
|
55385
|
+
} catch (err) {
|
|
55386
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
55387
|
+
if (message.includes("no server running"))
|
|
55388
|
+
return [];
|
|
55389
|
+
throw err;
|
|
55390
|
+
}
|
|
54990
55391
|
return output.split(`
|
|
54991
55392
|
`).filter(Boolean).map((line) => {
|
|
54992
55393
|
const [name21, group, windows, attached] = line.split(":");
|
|
@@ -55094,7 +55495,7 @@ function getProjectLocations(project) {
|
|
|
55094
55495
|
const currentMachine = getMachineId();
|
|
55095
55496
|
return listWorkdirs(project.id).map((workdir) => ({
|
|
55096
55497
|
...workdir,
|
|
55097
|
-
exists:
|
|
55498
|
+
exists: existsSync112(workdir.path),
|
|
55098
55499
|
currentMachine: workdir.machine_id === currentMachine,
|
|
55099
55500
|
recommended: workdir.is_primary || workdir.path === project.path
|
|
55100
55501
|
}));
|
|
@@ -55131,7 +55532,7 @@ function buildProjectContext(project) {
|
|
|
55131
55532
|
};
|
|
55132
55533
|
}
|
|
55133
55534
|
function getGitContext(path) {
|
|
55134
|
-
if (!
|
|
55535
|
+
if (!existsSync112(join122(path, ".git"))) {
|
|
55135
55536
|
return { isRepo: false, branch: null, dirtyCount: null, remote: null };
|
|
55136
55537
|
}
|
|
55137
55538
|
return {
|
|
@@ -55174,7 +55575,7 @@ function setupMachineReport(options = {}) {
|
|
|
55174
55575
|
const dryRun = options.dryRun !== false;
|
|
55175
55576
|
const checks3 = [];
|
|
55176
55577
|
const dbDir = dirname6(getDbPath2());
|
|
55177
|
-
const cloudConfig =
|
|
55578
|
+
const cloudConfig = join132(process.env["HOME"] || "~", ".hasna", "cloud", "config.json");
|
|
55178
55579
|
checks3.push(pathCheck("PROJECTS_DATA_DIR", "projects data dir", dbDir, options));
|
|
55179
55580
|
checks3.push(pathCheck("WORKSPACE_ROOT", "workspace root", machine.workspaceRoot, options));
|
|
55180
55581
|
checks3.push(commandCheck("bun", ["--version"], "Bun runtime"));
|
|
@@ -55235,8 +55636,8 @@ function commandCheck(command, versionArgs, label, missingStatus = "error") {
|
|
|
55235
55636
|
}
|
|
55236
55637
|
function packageVersion() {
|
|
55237
55638
|
try {
|
|
55238
|
-
const pkgPath =
|
|
55239
|
-
return JSON.parse(
|
|
55639
|
+
const pkgPath = join132(dirname6(fileURLToPath(import.meta.url)), "..", "..", "package.json");
|
|
55640
|
+
return JSON.parse(readFileSync7(pkgPath, "utf-8")).version || "0.0.0";
|
|
55240
55641
|
} catch {
|
|
55241
55642
|
return "0.0.0";
|
|
55242
55643
|
}
|
|
@@ -55250,7 +55651,7 @@ function findStaleIssues(project) {
|
|
|
55250
55651
|
const issues = [];
|
|
55251
55652
|
const currentMachine = getMachineId();
|
|
55252
55653
|
for (const p2 of projects) {
|
|
55253
|
-
if (p2.status === "active" && !
|
|
55654
|
+
if (p2.status === "active" && !existsSync12(p2.path)) {
|
|
55254
55655
|
issues.push({
|
|
55255
55656
|
code: "PROJECT_PATH_MISSING",
|
|
55256
55657
|
severity: "error",
|
|
@@ -55261,7 +55662,7 @@ function findStaleIssues(project) {
|
|
|
55261
55662
|
});
|
|
55262
55663
|
}
|
|
55263
55664
|
for (const workdir of listWorkdirs(p2.id)) {
|
|
55264
|
-
if (workdir.machine_id === currentMachine && !
|
|
55665
|
+
if (workdir.machine_id === currentMachine && !existsSync12(workdir.path)) {
|
|
55265
55666
|
issues.push({
|
|
55266
55667
|
code: "WORKDIR_PATH_MISSING",
|
|
55267
55668
|
severity: "warn",
|
|
@@ -56203,7 +56604,7 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
|
|
|
56203
56604
|
}
|
|
56204
56605
|
const credentials = await fromWebToken({
|
|
56205
56606
|
...init,
|
|
56206
|
-
webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
|
|
56607
|
+
webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync4(webIdentityTokenFile, { encoding: "ascii" }),
|
|
56207
56608
|
roleArn,
|
|
56208
56609
|
roleSessionName
|
|
56209
56610
|
})(awsIdentityProperties);
|
|
@@ -56290,7 +56691,7 @@ coverage/
|
|
|
56290
56691
|
# Cache
|
|
56291
56692
|
.cache/
|
|
56292
56693
|
.turbo/
|
|
56293
|
-
`, CONFIG_PATH3, DEFAULTS, nanoid3, import_protocol_http, addExpectContinueMiddlewareOptions, getAddExpectContinuePlugin = (options) => ({
|
|
56694
|
+
`, BOOTSTRAP_PATHS, CONFIG_PATH3, DEFAULTS, nanoid3, import_protocol_http, addExpectContinueMiddlewareOptions, getAddExpectContinuePlugin = (options) => ({
|
|
56294
56695
|
applyToStack: (clientStack) => {
|
|
56295
56696
|
clientStack.add(addExpectContinueMiddleware(options), addExpectContinueMiddlewareOptions);
|
|
56296
56697
|
}
|
|
@@ -74101,7 +74502,7 @@ More information can be found at: https://a.co/c895JFp`);
|
|
|
74101
74502
|
};
|
|
74102
74503
|
});
|
|
74103
74504
|
require_dist_cjs41 = __commonJS3((exports) => {
|
|
74104
|
-
var __dirname2 = "/
|
|
74505
|
+
var __dirname2 = "/Users/hasna/Workspace/hasna/opensource/open-projects/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
|
|
74105
74506
|
var node_os = __require3("os");
|
|
74106
74507
|
var node_process = __require3("process");
|
|
74107
74508
|
var utilConfigProvider = require_dist_cjs28();
|
|
@@ -77771,10 +78172,10 @@ More information can be found at: https://a.co/c895JFp`);
|
|
|
77771
78172
|
await fs2.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
77772
78173
|
}
|
|
77773
78174
|
getTokenFilePath() {
|
|
77774
|
-
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ??
|
|
78175
|
+
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join62(homedir22(), ".aws", "login", "cache");
|
|
77775
78176
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
77776
78177
|
const loginSessionSha256 = createHash("sha256").update(loginSessionBytes).digest("hex");
|
|
77777
|
-
return
|
|
78178
|
+
return join62(directory, `${loginSessionSha256}.json`);
|
|
77778
78179
|
}
|
|
77779
78180
|
derToRawSignature(derSignature) {
|
|
77780
78181
|
let offset = 2;
|
|
@@ -78075,7 +78476,18 @@ More information can be found at: https://a.co/c895JFp`);
|
|
|
78075
78476
|
INSERT OR IGNORE INTO _migrations (id) VALUES (4);
|
|
78076
78477
|
`
|
|
78077
78478
|
];
|
|
78078
|
-
|
|
78479
|
+
BOOTSTRAP_PATHS = [
|
|
78480
|
+
".gitignore",
|
|
78481
|
+
".project.json",
|
|
78482
|
+
"CLAUDE.md",
|
|
78483
|
+
"AGENTS.md",
|
|
78484
|
+
"README.md",
|
|
78485
|
+
"docs",
|
|
78486
|
+
"data",
|
|
78487
|
+
"scripts",
|
|
78488
|
+
"assets"
|
|
78489
|
+
];
|
|
78490
|
+
CONFIG_PATH3 = join42(homedir11(), ".hasna", "projects", "config.json");
|
|
78079
78491
|
DEFAULTS = {
|
|
78080
78492
|
default_path: process.cwd(),
|
|
78081
78493
|
default_github_org: "hasnaxyz",
|
|
@@ -83861,7 +84273,7 @@ More information can be found at: https://a.co/c895JFp`);
|
|
|
83861
84273
|
}).s("AmazonS3", "PutObject", {}).n("S3Client", "PutObjectCommand").sc(PutObject$).build() {
|
|
83862
84274
|
};
|
|
83863
84275
|
MAX_FILE_SIZE = 100 * 1024 * 1024;
|
|
83864
|
-
CONFIG_PATH22 =
|
|
84276
|
+
CONFIG_PATH22 = join92(process.env["HOME"] || "~", ".hasna", "projects", "scheduler.json");
|
|
83865
84277
|
SPARK_MACHINES = new Set(["spark01", "spark02"]);
|
|
83866
84278
|
});
|
|
83867
84279
|
|
|
@@ -84852,12 +85264,12 @@ __export(exports_contacts_connector, {
|
|
|
84852
85264
|
});
|
|
84853
85265
|
function getContactsDb() {
|
|
84854
85266
|
const { Database: Database5 } = __require("bun:sqlite");
|
|
84855
|
-
const { existsSync:
|
|
85267
|
+
const { existsSync: existsSync13 } = __require("fs");
|
|
84856
85268
|
const { join: join15 } = __require("path");
|
|
84857
85269
|
const { homedir: homedir7 } = __require("os");
|
|
84858
85270
|
const envPath = process.env["HASNA_CONTACTS_DB_PATH"] ?? process.env["OPEN_CONTACTS_DB"];
|
|
84859
85271
|
const dbPath = envPath ?? join15(homedir7(), ".hasna", "contacts", "contacts.db");
|
|
84860
|
-
if (!
|
|
85272
|
+
if (!existsSync13(dbPath))
|
|
84861
85273
|
return null;
|
|
84862
85274
|
const db2 = new Database5(dbPath, { readonly: true });
|
|
84863
85275
|
return db2;
|
|
@@ -86537,12 +86949,12 @@ function buildServer() {
|
|
|
86537
86949
|
}
|
|
86538
86950
|
if (!resolvedUrl)
|
|
86539
86951
|
return errorResponse(new Error("No URL provided and no default environment set. Pass url or env."));
|
|
86540
|
-
const { execSync:
|
|
86952
|
+
const { execSync: execSync3 } = await import("child_process");
|
|
86541
86953
|
let diffOutput = "";
|
|
86542
86954
|
try {
|
|
86543
86955
|
const ref = baseRef ?? "HEAD";
|
|
86544
|
-
const stagedOut =
|
|
86545
|
-
const unstagedOut =
|
|
86956
|
+
const stagedOut = execSync3(`git diff --cached --name-only`, { cwd: process.cwd(), encoding: "utf-8" }).trim();
|
|
86957
|
+
const unstagedOut = execSync3(`git diff --name-only ${ref}`, { cwd: process.cwd(), encoding: "utf-8" }).trim();
|
|
86546
86958
|
diffOutput = [stagedOut, unstagedOut].filter(Boolean).join(`
|
|
86547
86959
|
`);
|
|
86548
86960
|
} catch {
|
|
@@ -86679,8 +87091,8 @@ function buildServer() {
|
|
|
86679
87091
|
let allFiles = [...filePaths];
|
|
86680
87092
|
if (includeAutoDetect) {
|
|
86681
87093
|
try {
|
|
86682
|
-
const { execSync:
|
|
86683
|
-
const diffOutput =
|
|
87094
|
+
const { execSync: execSync3 } = await import("child_process");
|
|
87095
|
+
const diffOutput = execSync3("git diff --name-only HEAD", { encoding: "utf-8", cwd: process.cwd() }).trim();
|
|
86684
87096
|
const gitFiles = diffOutput.split(`
|
|
86685
87097
|
`).filter(Boolean);
|
|
86686
87098
|
allFiles = [...new Set([...allFiles, ...gitFiles])];
|
|
@@ -87225,7 +87637,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
87225
87637
|
// src/mcp/http.ts
|
|
87226
87638
|
import { createServer } from "http";
|
|
87227
87639
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
87228
|
-
var DEFAULT_MCP_HTTP_PORT =
|
|
87640
|
+
var DEFAULT_MCP_HTTP_PORT = 8880;
|
|
87229
87641
|
var DEFAULT_HOST = "127.0.0.1";
|
|
87230
87642
|
function resolveMcpHttpPort(explicitPort) {
|
|
87231
87643
|
if (explicitPort !== undefined && !Number.isNaN(explicitPort))
|
|
@@ -87247,8 +87659,8 @@ function parseCliPort(args) {
|
|
|
87247
87659
|
}
|
|
87248
87660
|
return;
|
|
87249
87661
|
}
|
|
87250
|
-
function
|
|
87251
|
-
return args.includes("--
|
|
87662
|
+
function isStdioMode(args) {
|
|
87663
|
+
return args.includes("--stdio") || process.env.MCP_STDIO === "1";
|
|
87252
87664
|
}
|
|
87253
87665
|
async function readJsonBody(req) {
|
|
87254
87666
|
const chunks = [];
|
|
@@ -87336,14 +87748,14 @@ process.on("uncaughtException", (err) => {
|
|
|
87336
87748
|
});
|
|
87337
87749
|
async function main() {
|
|
87338
87750
|
const args = process.argv.slice(2);
|
|
87339
|
-
if (
|
|
87340
|
-
|
|
87751
|
+
if (isStdioMode(args)) {
|
|
87752
|
+
const { buildServer: buildServer2 } = await Promise.resolve().then(() => (init_server(), exports_server));
|
|
87753
|
+
const server = buildServer2();
|
|
87754
|
+
const transport = new StdioServerTransport;
|
|
87755
|
+
await server.connect(transport);
|
|
87341
87756
|
return;
|
|
87342
87757
|
}
|
|
87343
|
-
|
|
87344
|
-
const server = buildServer2();
|
|
87345
|
-
const transport = new StdioServerTransport;
|
|
87346
|
-
await server.connect(transport);
|
|
87758
|
+
await startMcpHttpServer({ name: "testers", port: parseCliPort(args) });
|
|
87347
87759
|
}
|
|
87348
87760
|
main().catch((error40) => {
|
|
87349
87761
|
console.error("Failed to start testers:", error40);
|