@probelabs/probe 0.6.0-rc125 → 0.6.0-rc127
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/README.md +1 -1
- package/build/agent/ProbeAgent.js +105 -8
- package/build/agent/hooks/HookManager.js +146 -0
- package/build/agent/hooks/index.js +1 -0
- package/build/agent/index.js +737 -36
- package/build/agent/storage/InMemoryStorageAdapter.js +49 -0
- package/build/agent/storage/StorageAdapter.js +51 -0
- package/build/agent/storage/index.js +2 -0
- package/build/index.js +8 -0
- package/cjs/agent/ProbeAgent.cjs +754 -53
- package/cjs/index.cjs +762 -53
- package/index.d.ts +95 -0
- package/package.json +2 -2
- package/src/agent/ProbeAgent.js +105 -8
- package/src/agent/hooks/HookManager.js +146 -0
- package/src/agent/hooks/index.js +1 -0
- package/src/agent/storage/InMemoryStorageAdapter.js +49 -0
- package/src/agent/storage/StorageAdapter.js +51 -0
- package/src/agent/storage/index.js +2 -0
- package/src/index.js +8 -0
package/cjs/index.cjs
CHANGED
|
@@ -24340,7 +24340,7 @@ var require_package = __commonJS({
|
|
|
24340
24340
|
module2.exports = {
|
|
24341
24341
|
name: "@aws-sdk/client-bedrock-runtime",
|
|
24342
24342
|
description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
|
|
24343
|
-
version: "3.
|
|
24343
|
+
version: "3.907.0",
|
|
24344
24344
|
scripts: {
|
|
24345
24345
|
build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
24346
24346
|
"build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
|
|
@@ -24359,21 +24359,21 @@ var require_package = __commonJS({
|
|
|
24359
24359
|
dependencies: {
|
|
24360
24360
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
24361
24361
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
24362
|
-
"@aws-sdk/core": "3.
|
|
24363
|
-
"@aws-sdk/credential-provider-node": "3.
|
|
24362
|
+
"@aws-sdk/core": "3.907.0",
|
|
24363
|
+
"@aws-sdk/credential-provider-node": "3.907.0",
|
|
24364
24364
|
"@aws-sdk/eventstream-handler-node": "3.901.0",
|
|
24365
24365
|
"@aws-sdk/middleware-eventstream": "3.901.0",
|
|
24366
24366
|
"@aws-sdk/middleware-host-header": "3.901.0",
|
|
24367
24367
|
"@aws-sdk/middleware-logger": "3.901.0",
|
|
24368
24368
|
"@aws-sdk/middleware-recursion-detection": "3.901.0",
|
|
24369
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
24369
|
+
"@aws-sdk/middleware-user-agent": "3.907.0",
|
|
24370
24370
|
"@aws-sdk/middleware-websocket": "3.901.0",
|
|
24371
24371
|
"@aws-sdk/region-config-resolver": "3.901.0",
|
|
24372
|
-
"@aws-sdk/token-providers": "3.
|
|
24372
|
+
"@aws-sdk/token-providers": "3.907.0",
|
|
24373
24373
|
"@aws-sdk/types": "3.901.0",
|
|
24374
24374
|
"@aws-sdk/util-endpoints": "3.901.0",
|
|
24375
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
24376
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
24375
|
+
"@aws-sdk/util-user-agent-browser": "3.907.0",
|
|
24376
|
+
"@aws-sdk/util-user-agent-node": "3.907.0",
|
|
24377
24377
|
"@smithy/config-resolver": "^4.3.0",
|
|
24378
24378
|
"@smithy/core": "^3.14.0",
|
|
24379
24379
|
"@smithy/eventstream-serde-browser": "^4.2.0",
|
|
@@ -25121,7 +25121,7 @@ var init_package = __esm({
|
|
|
25121
25121
|
"node_modules/@aws-sdk/nested-clients/package.json"() {
|
|
25122
25122
|
package_default = {
|
|
25123
25123
|
name: "@aws-sdk/nested-clients",
|
|
25124
|
-
version: "3.
|
|
25124
|
+
version: "3.907.0",
|
|
25125
25125
|
description: "Nested clients for AWS SDK packages.",
|
|
25126
25126
|
main: "./dist-cjs/index.js",
|
|
25127
25127
|
module: "./dist-es/index.js",
|
|
@@ -25150,16 +25150,16 @@ var init_package = __esm({
|
|
|
25150
25150
|
dependencies: {
|
|
25151
25151
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
25152
25152
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
25153
|
-
"@aws-sdk/core": "3.
|
|
25153
|
+
"@aws-sdk/core": "3.907.0",
|
|
25154
25154
|
"@aws-sdk/middleware-host-header": "3.901.0",
|
|
25155
25155
|
"@aws-sdk/middleware-logger": "3.901.0",
|
|
25156
25156
|
"@aws-sdk/middleware-recursion-detection": "3.901.0",
|
|
25157
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
25157
|
+
"@aws-sdk/middleware-user-agent": "3.907.0",
|
|
25158
25158
|
"@aws-sdk/region-config-resolver": "3.901.0",
|
|
25159
25159
|
"@aws-sdk/types": "3.901.0",
|
|
25160
25160
|
"@aws-sdk/util-endpoints": "3.901.0",
|
|
25161
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
25162
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
25161
|
+
"@aws-sdk/util-user-agent-browser": "3.907.0",
|
|
25162
|
+
"@aws-sdk/util-user-agent-node": "3.907.0",
|
|
25163
25163
|
"@smithy/config-resolver": "^4.3.0",
|
|
25164
25164
|
"@smithy/core": "^3.14.0",
|
|
25165
25165
|
"@smithy/fetch-http-handler": "^5.3.0",
|
|
@@ -26596,7 +26596,7 @@ var require_package2 = __commonJS({
|
|
|
26596
26596
|
module2.exports = {
|
|
26597
26597
|
name: "@aws-sdk/client-sso",
|
|
26598
26598
|
description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
|
|
26599
|
-
version: "3.
|
|
26599
|
+
version: "3.907.0",
|
|
26600
26600
|
scripts: {
|
|
26601
26601
|
build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
26602
26602
|
"build:cjs": "node ../../scripts/compilation/inline client-sso",
|
|
@@ -26615,16 +26615,16 @@ var require_package2 = __commonJS({
|
|
|
26615
26615
|
dependencies: {
|
|
26616
26616
|
"@aws-crypto/sha256-browser": "5.2.0",
|
|
26617
26617
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
26618
|
-
"@aws-sdk/core": "3.
|
|
26618
|
+
"@aws-sdk/core": "3.907.0",
|
|
26619
26619
|
"@aws-sdk/middleware-host-header": "3.901.0",
|
|
26620
26620
|
"@aws-sdk/middleware-logger": "3.901.0",
|
|
26621
26621
|
"@aws-sdk/middleware-recursion-detection": "3.901.0",
|
|
26622
|
-
"@aws-sdk/middleware-user-agent": "3.
|
|
26622
|
+
"@aws-sdk/middleware-user-agent": "3.907.0",
|
|
26623
26623
|
"@aws-sdk/region-config-resolver": "3.901.0",
|
|
26624
26624
|
"@aws-sdk/types": "3.901.0",
|
|
26625
26625
|
"@aws-sdk/util-endpoints": "3.901.0",
|
|
26626
|
-
"@aws-sdk/util-user-agent-browser": "3.
|
|
26627
|
-
"@aws-sdk/util-user-agent-node": "3.
|
|
26626
|
+
"@aws-sdk/util-user-agent-browser": "3.907.0",
|
|
26627
|
+
"@aws-sdk/util-user-agent-node": "3.907.0",
|
|
26628
26628
|
"@smithy/config-resolver": "^4.3.0",
|
|
26629
26629
|
"@smithy/core": "^3.14.0",
|
|
26630
26630
|
"@smithy/fetch-http-handler": "^5.3.0",
|
|
@@ -33872,7 +33872,7 @@ var init_BytePairEncodingCore = __esm({
|
|
|
33872
33872
|
var chatEnabledModels;
|
|
33873
33873
|
var init_modelsChatEnabled_gen = __esm({
|
|
33874
33874
|
"node_modules/gpt-tokenizer/esm/modelsChatEnabled.gen.js"() {
|
|
33875
|
-
chatEnabledModels = ["chatgpt-4o-latest", "codex-mini-latest", "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-3.5", "gpt-3.5-0301", "gpt-3.5-turbo", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k-0613", "gpt-3.5-turbo-instruct", "gpt-4", "gpt-4-0125-preview", "gpt-4-0314", "gpt-4-0613", "gpt-4-1106-preview", "gpt-4-1106-vision-preview", "gpt-4-32k", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-turbo-preview", "gpt-4.1", "gpt-4.1-2025-04-14", "gpt-4.1-mini", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano", "gpt-4.1-nano-2025-04-14", "gpt-4.5-preview", "gpt-4.5-preview-2025-02-27", "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-mini-search-preview", "gpt-4o-mini-search-preview-2025-03-11", "gpt-4o-search-preview", "gpt-4o-search-preview-2025-03-11", "o1", "o1-2024-12-17", "o1-mini", "o1-mini-2024-09-12", "o1-preview", "o1-preview-2024-09-12", "o1-pro", "o1-pro-2025-03-19", "o3", "o3-2025-04-16", "o3-mini", "o3-mini-2025-01-31", "o3-pro", "o3-pro-2025-06-10", "o4-mini", "o4-mini-2025-04-16"];
|
|
33875
|
+
chatEnabledModels = ["chatgpt-4o-latest", "codex-mini-latest", "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-3.5", "gpt-3.5-0301", "gpt-3.5-turbo", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k-0613", "gpt-3.5-turbo-instruct", "gpt-4", "gpt-4-0125-preview", "gpt-4-0314", "gpt-4-0613", "gpt-4-1106-preview", "gpt-4-1106-vision-preview", "gpt-4-32k", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-turbo-preview", "gpt-4.1", "gpt-4.1-2025-04-14", "gpt-4.1-mini", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano", "gpt-4.1-nano-2025-04-14", "gpt-4.5-preview", "gpt-4.5-preview-2025-02-27", "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-mini-search-preview", "gpt-4o-mini-search-preview-2025-03-11", "gpt-4o-search-preview", "gpt-4o-search-preview-2025-03-11", "gpt-5", "gpt-5-2025-08-07", "gpt-5-chat-latest", "gpt-5-codex", "gpt-5-mini", "gpt-5-mini-2025-08-07", "gpt-5-nano", "gpt-5-nano-2025-08-07", "gpt-5-pro", "gpt-5-pro-2025-10-06", "gpt-audio", "gpt-audio-2025-08-28", "gpt-audio-mini", "gpt-audio-mini-2025-10-06", "gpt-oss-120b", "gpt-oss-20b", "o1", "o1-2024-12-17", "o1-mini", "o1-mini-2024-09-12", "o1-preview", "o1-preview-2024-09-12", "o1-pro", "o1-pro-2025-03-19", "o3", "o3-2025-04-16", "o3-deep-research", "o3-deep-research-2025-06-26", "o3-mini", "o3-mini-2025-01-31", "o3-pro", "o3-pro-2025-06-10", "o4-mini", "o4-mini-2025-04-16", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26"];
|
|
33876
33876
|
}
|
|
33877
33877
|
});
|
|
33878
33878
|
|
|
@@ -34268,8 +34268,9 @@ var init_GptEncoding = __esm({
|
|
|
34268
34268
|
* Returns tokens assuming the 'gpt-3.5-turbo-0301' / 'gpt-4-0314' format.
|
|
34269
34269
|
* Based on OpenAI's guidelines: https://github.com/openai/openai-python/blob/main/chatml.md
|
|
34270
34270
|
* Also mentioned in section 6 of this document: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
|
|
34271
|
+
* @param encodeOptions Options controlling how special tokens are handled.
|
|
34271
34272
|
*/
|
|
34272
|
-
*encodeChatGenerator(chat, model = this.modelName) {
|
|
34273
|
+
*encodeChatGenerator(chat, model = this.modelName, encodeOptions) {
|
|
34273
34274
|
if (!model) {
|
|
34274
34275
|
throw new Error("Model name must be provided either during initialization or passed in to the method.");
|
|
34275
34276
|
}
|
|
@@ -34295,12 +34296,12 @@ var init_GptEncoding = __esm({
|
|
|
34295
34296
|
if (encodedRoleSeparator.length > 0) {
|
|
34296
34297
|
yield encodedRoleSeparator;
|
|
34297
34298
|
}
|
|
34298
|
-
yield* this.encodeGenerator(content);
|
|
34299
|
+
yield* this.encodeGenerator(content, encodeOptions);
|
|
34299
34300
|
yield [chatEndToken];
|
|
34300
34301
|
yield encodedMessageSeparator;
|
|
34301
34302
|
}
|
|
34302
34303
|
yield [chatStartToken];
|
|
34303
|
-
yield* this.encodeGenerator("assistant");
|
|
34304
|
+
yield* this.encodeGenerator("assistant", encodeOptions);
|
|
34304
34305
|
if (encodedRoleSeparator.length > 0) {
|
|
34305
34306
|
yield encodedRoleSeparator;
|
|
34306
34307
|
}
|
|
@@ -34311,15 +34312,20 @@ var init_GptEncoding = __esm({
|
|
|
34311
34312
|
* Returns tokens assuming the 'gpt-3.5-turbo-0301' / 'gpt-4-0314' format.
|
|
34312
34313
|
* Based on OpenAI's guidelines: https://github.com/openai/openai-python/blob/main/chatml.md
|
|
34313
34314
|
* Also mentioned in section 6 of this document: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
|
|
34315
|
+
* @param encodeOptions Options controlling how special tokens are handled.
|
|
34314
34316
|
*/
|
|
34315
|
-
encodeChat(chat, model = this.modelName) {
|
|
34316
|
-
return [...this.encodeChatGenerator(chat, model)].flat();
|
|
34317
|
+
encodeChat(chat, model = this.modelName, encodeOptions) {
|
|
34318
|
+
return [...this.encodeChatGenerator(chat, model, encodeOptions)].flat();
|
|
34317
34319
|
}
|
|
34318
34320
|
/**
|
|
34321
|
+
* Checks whether the provided input stays within the provided token limit.
|
|
34322
|
+
* @param input The string or chat messages to evaluate.
|
|
34323
|
+
* @param tokenLimit The maximum allowed number of tokens.
|
|
34324
|
+
* @param encodeOptions Options controlling how special tokens are handled.
|
|
34319
34325
|
* @returns {false | number} false if token limit is exceeded, otherwise the number of tokens
|
|
34320
34326
|
*/
|
|
34321
|
-
isWithinTokenLimit(input, tokenLimit) {
|
|
34322
|
-
const tokenGenerator = typeof input === "string" ? this.encodeGenerator(input) : this.encodeChatGenerator(input);
|
|
34327
|
+
isWithinTokenLimit(input, tokenLimit, encodeOptions) {
|
|
34328
|
+
const tokenGenerator = typeof input === "string" ? this.encodeGenerator(input, encodeOptions) : this.encodeChatGenerator(input, void 0, encodeOptions);
|
|
34323
34329
|
let count = 0;
|
|
34324
34330
|
for (const tokens of tokenGenerator) {
|
|
34325
34331
|
count += tokens.length;
|
|
@@ -34331,6 +34337,8 @@ var init_GptEncoding = __esm({
|
|
|
34331
34337
|
}
|
|
34332
34338
|
/**
|
|
34333
34339
|
* Counts the number of tokens in the input.
|
|
34340
|
+
* @param input The string or chat messages to evaluate.
|
|
34341
|
+
* @param encodeOptions Options controlling how special tokens are handled.
|
|
34334
34342
|
* @returns {number} The number of tokens.
|
|
34335
34343
|
*/
|
|
34336
34344
|
countTokens(input, encodeOptions) {
|
|
@@ -34344,7 +34352,7 @@ var init_GptEncoding = __esm({
|
|
|
34344
34352
|
}
|
|
34345
34353
|
return this.bytePairEncodingCoreProcessor.countNative(input, specialTokenConfig.allowedSpecial);
|
|
34346
34354
|
}
|
|
34347
|
-
const tokenGenerator = this.encodeChatGenerator(input);
|
|
34355
|
+
const tokenGenerator = this.encodeChatGenerator(input, void 0, encodeOptions);
|
|
34348
34356
|
let count = 0;
|
|
34349
34357
|
for (const tokens of tokenGenerator) {
|
|
34350
34358
|
count += tokens.length;
|
|
@@ -34782,6 +34790,226 @@ var init_tokenCounter = __esm({
|
|
|
34782
34790
|
}
|
|
34783
34791
|
});
|
|
34784
34792
|
|
|
34793
|
+
// src/agent/storage/StorageAdapter.js
|
|
34794
|
+
var StorageAdapter;
|
|
34795
|
+
var init_StorageAdapter = __esm({
|
|
34796
|
+
"src/agent/storage/StorageAdapter.js"() {
|
|
34797
|
+
"use strict";
|
|
34798
|
+
StorageAdapter = class {
|
|
34799
|
+
/**
|
|
34800
|
+
* Load conversation history for a session
|
|
34801
|
+
* @param {string} sessionId - Session identifier
|
|
34802
|
+
* @returns {Promise<Array<Object>>} Array of message objects with {role, content, ...}
|
|
34803
|
+
*/
|
|
34804
|
+
async loadHistory(sessionId) {
|
|
34805
|
+
throw new Error("StorageAdapter.loadHistory() must be implemented by subclass");
|
|
34806
|
+
}
|
|
34807
|
+
/**
|
|
34808
|
+
* Save a message to storage
|
|
34809
|
+
* @param {string} sessionId - Session identifier
|
|
34810
|
+
* @param {Object} message - Message object { role, content, ... }
|
|
34811
|
+
* @returns {Promise<void>}
|
|
34812
|
+
*/
|
|
34813
|
+
async saveMessage(sessionId, message) {
|
|
34814
|
+
throw new Error("StorageAdapter.saveMessage() must be implemented by subclass");
|
|
34815
|
+
}
|
|
34816
|
+
/**
|
|
34817
|
+
* Clear history for a session
|
|
34818
|
+
* @param {string} sessionId - Session identifier
|
|
34819
|
+
* @returns {Promise<void>}
|
|
34820
|
+
*/
|
|
34821
|
+
async clearHistory(sessionId) {
|
|
34822
|
+
throw new Error("StorageAdapter.clearHistory() must be implemented by subclass");
|
|
34823
|
+
}
|
|
34824
|
+
/**
|
|
34825
|
+
* Get session metadata (optional)
|
|
34826
|
+
* @param {string} sessionId - Session identifier
|
|
34827
|
+
* @returns {Promise<Object|null>} Session metadata or null
|
|
34828
|
+
*/
|
|
34829
|
+
async getSessionMetadata(sessionId) {
|
|
34830
|
+
return null;
|
|
34831
|
+
}
|
|
34832
|
+
/**
|
|
34833
|
+
* Update session activity timestamp (optional)
|
|
34834
|
+
* @param {string} sessionId - Session identifier
|
|
34835
|
+
* @returns {Promise<void>}
|
|
34836
|
+
*/
|
|
34837
|
+
async updateSessionActivity(sessionId) {
|
|
34838
|
+
}
|
|
34839
|
+
};
|
|
34840
|
+
}
|
|
34841
|
+
});
|
|
34842
|
+
|
|
34843
|
+
// src/agent/storage/InMemoryStorageAdapter.js
|
|
34844
|
+
var InMemoryStorageAdapter;
|
|
34845
|
+
var init_InMemoryStorageAdapter = __esm({
|
|
34846
|
+
"src/agent/storage/InMemoryStorageAdapter.js"() {
|
|
34847
|
+
"use strict";
|
|
34848
|
+
init_StorageAdapter();
|
|
34849
|
+
InMemoryStorageAdapter = class extends StorageAdapter {
|
|
34850
|
+
constructor() {
|
|
34851
|
+
super();
|
|
34852
|
+
this.sessions = /* @__PURE__ */ new Map();
|
|
34853
|
+
}
|
|
34854
|
+
async loadHistory(sessionId) {
|
|
34855
|
+
const session = this.sessions.get(sessionId);
|
|
34856
|
+
return session ? session.messages : [];
|
|
34857
|
+
}
|
|
34858
|
+
async saveMessage(sessionId, message) {
|
|
34859
|
+
if (!this.sessions.has(sessionId)) {
|
|
34860
|
+
this.sessions.set(sessionId, {
|
|
34861
|
+
messages: [],
|
|
34862
|
+
metadata: {
|
|
34863
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
34864
|
+
lastActivity: (/* @__PURE__ */ new Date()).toISOString()
|
|
34865
|
+
}
|
|
34866
|
+
});
|
|
34867
|
+
}
|
|
34868
|
+
const session = this.sessions.get(sessionId);
|
|
34869
|
+
session.messages.push(message);
|
|
34870
|
+
session.metadata.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
|
|
34871
|
+
}
|
|
34872
|
+
async clearHistory(sessionId) {
|
|
34873
|
+
this.sessions.delete(sessionId);
|
|
34874
|
+
}
|
|
34875
|
+
async getSessionMetadata(sessionId) {
|
|
34876
|
+
const session = this.sessions.get(sessionId);
|
|
34877
|
+
return session ? session.metadata : null;
|
|
34878
|
+
}
|
|
34879
|
+
async updateSessionActivity(sessionId) {
|
|
34880
|
+
const session = this.sessions.get(sessionId);
|
|
34881
|
+
if (session) {
|
|
34882
|
+
session.metadata.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
|
|
34883
|
+
}
|
|
34884
|
+
}
|
|
34885
|
+
};
|
|
34886
|
+
}
|
|
34887
|
+
});
|
|
34888
|
+
|
|
34889
|
+
// src/agent/hooks/HookManager.js
|
|
34890
|
+
var HookManager, HOOK_TYPES;
|
|
34891
|
+
var init_HookManager = __esm({
|
|
34892
|
+
"src/agent/hooks/HookManager.js"() {
|
|
34893
|
+
"use strict";
|
|
34894
|
+
HookManager = class {
|
|
34895
|
+
constructor() {
|
|
34896
|
+
this.hooks = /* @__PURE__ */ new Map();
|
|
34897
|
+
}
|
|
34898
|
+
/**
|
|
34899
|
+
* Register a hook callback
|
|
34900
|
+
* @param {string} hookName - Name of the hook
|
|
34901
|
+
* @param {Function} callback - Callback function
|
|
34902
|
+
* @returns {Function} Unregister function
|
|
34903
|
+
*/
|
|
34904
|
+
on(hookName, callback) {
|
|
34905
|
+
if (!this.hooks.has(hookName)) {
|
|
34906
|
+
this.hooks.set(hookName, /* @__PURE__ */ new Set());
|
|
34907
|
+
}
|
|
34908
|
+
this.hooks.get(hookName).add(callback);
|
|
34909
|
+
return () => this.off(hookName, callback);
|
|
34910
|
+
}
|
|
34911
|
+
/**
|
|
34912
|
+
* Register a one-time hook callback
|
|
34913
|
+
* @param {string} hookName - Name of the hook
|
|
34914
|
+
* @param {Function} callback - Callback function
|
|
34915
|
+
* @returns {Function} Unregister function
|
|
34916
|
+
*/
|
|
34917
|
+
once(hookName, callback) {
|
|
34918
|
+
const wrappedCallback = async (data2) => {
|
|
34919
|
+
this.off(hookName, wrappedCallback);
|
|
34920
|
+
await callback(data2);
|
|
34921
|
+
};
|
|
34922
|
+
return this.on(hookName, wrappedCallback);
|
|
34923
|
+
}
|
|
34924
|
+
/**
|
|
34925
|
+
* Unregister a hook callback
|
|
34926
|
+
* @param {string} hookName - Name of the hook
|
|
34927
|
+
* @param {Function} callback - Callback function
|
|
34928
|
+
*/
|
|
34929
|
+
off(hookName, callback) {
|
|
34930
|
+
const callbacks = this.hooks.get(hookName);
|
|
34931
|
+
if (callbacks) {
|
|
34932
|
+
callbacks.delete(callback);
|
|
34933
|
+
}
|
|
34934
|
+
}
|
|
34935
|
+
/**
|
|
34936
|
+
* Emit a hook event
|
|
34937
|
+
* @param {string} hookName - Name of the hook
|
|
34938
|
+
* @param {any} data - Data to pass to callbacks
|
|
34939
|
+
* @returns {Promise<void>}
|
|
34940
|
+
*/
|
|
34941
|
+
async emit(hookName, data2) {
|
|
34942
|
+
const callbacks = this.hooks.get(hookName);
|
|
34943
|
+
if (!callbacks || callbacks.size === 0) return;
|
|
34944
|
+
const promises = Array.from(callbacks).map((callback) => {
|
|
34945
|
+
try {
|
|
34946
|
+
return Promise.resolve(callback(data2));
|
|
34947
|
+
} catch (error2) {
|
|
34948
|
+
return Promise.reject(error2);
|
|
34949
|
+
}
|
|
34950
|
+
});
|
|
34951
|
+
const results = await Promise.allSettled(promises);
|
|
34952
|
+
results.forEach((result, index) => {
|
|
34953
|
+
if (result.status === "rejected") {
|
|
34954
|
+
console.error(`[HookManager] Error in hook "${hookName}" (callback ${index + 1}):`, result.reason);
|
|
34955
|
+
}
|
|
34956
|
+
});
|
|
34957
|
+
}
|
|
34958
|
+
/**
|
|
34959
|
+
* Clear all hooks or hooks for a specific event
|
|
34960
|
+
* @param {string} [hookName] - Optional hook name to clear
|
|
34961
|
+
*/
|
|
34962
|
+
clear(hookName) {
|
|
34963
|
+
if (hookName) {
|
|
34964
|
+
this.hooks.delete(hookName);
|
|
34965
|
+
} else {
|
|
34966
|
+
this.hooks.clear();
|
|
34967
|
+
}
|
|
34968
|
+
}
|
|
34969
|
+
/**
|
|
34970
|
+
* Get list of registered hook names
|
|
34971
|
+
* @returns {string[]} Array of hook names
|
|
34972
|
+
*/
|
|
34973
|
+
getHookNames() {
|
|
34974
|
+
return Array.from(this.hooks.keys());
|
|
34975
|
+
}
|
|
34976
|
+
/**
|
|
34977
|
+
* Get number of callbacks for a hook
|
|
34978
|
+
* @param {string} hookName - Name of the hook
|
|
34979
|
+
* @returns {number} Number of callbacks
|
|
34980
|
+
*/
|
|
34981
|
+
getCallbackCount(hookName) {
|
|
34982
|
+
const callbacks = this.hooks.get(hookName);
|
|
34983
|
+
return callbacks ? callbacks.size : 0;
|
|
34984
|
+
}
|
|
34985
|
+
};
|
|
34986
|
+
HOOK_TYPES = {
|
|
34987
|
+
// Lifecycle hooks
|
|
34988
|
+
AGENT_INITIALIZED: "agent:initialized",
|
|
34989
|
+
AGENT_CLEANUP: "agent:cleanup",
|
|
34990
|
+
// Message hooks
|
|
34991
|
+
MESSAGE_USER: "message:user",
|
|
34992
|
+
MESSAGE_ASSISTANT: "message:assistant",
|
|
34993
|
+
MESSAGE_SYSTEM: "message:system",
|
|
34994
|
+
// Tool execution hooks
|
|
34995
|
+
TOOL_START: "tool:start",
|
|
34996
|
+
TOOL_END: "tool:end",
|
|
34997
|
+
TOOL_ERROR: "tool:error",
|
|
34998
|
+
// AI streaming hooks
|
|
34999
|
+
AI_STREAM_START: "ai:stream:start",
|
|
35000
|
+
AI_STREAM_DELTA: "ai:stream:delta",
|
|
35001
|
+
AI_STREAM_END: "ai:stream:end",
|
|
35002
|
+
// Storage hooks
|
|
35003
|
+
STORAGE_LOAD: "storage:load",
|
|
35004
|
+
STORAGE_SAVE: "storage:save",
|
|
35005
|
+
STORAGE_CLEAR: "storage:clear",
|
|
35006
|
+
// Iteration hooks
|
|
35007
|
+
ITERATION_START: "iteration:start",
|
|
35008
|
+
ITERATION_END: "iteration:end"
|
|
35009
|
+
};
|
|
35010
|
+
}
|
|
35011
|
+
});
|
|
35012
|
+
|
|
34785
35013
|
// src/agent/xmlParsingUtils.js
|
|
34786
35014
|
function removeThinkingTags(xmlString) {
|
|
34787
35015
|
let result = xmlString;
|
|
@@ -53706,7 +53934,6 @@ var init_parser2 = __esm({
|
|
|
53706
53934
|
this.linkStyleStatement = this.RULE("linkStyleStatement", () => {
|
|
53707
53935
|
this.CONSUME(LinkStyleKeyword);
|
|
53708
53936
|
this.SUBRULE(this.linkStyleIndexList);
|
|
53709
|
-
this.OPTION1(() => this.CONSUME1(Newline));
|
|
53710
53937
|
this.SUBRULE(this.linkStylePairs);
|
|
53711
53938
|
this.OPTION2(() => this.CONSUME2(Newline));
|
|
53712
53939
|
});
|
|
@@ -54170,7 +54397,7 @@ var init_semantics = __esm({
|
|
|
54170
54397
|
}
|
|
54171
54398
|
const fnTok = ch.fn?.[0];
|
|
54172
54399
|
if (!fnTok) {
|
|
54173
|
-
this.ctx.errors.push({ line: modeTok2?.startLine ?? 1, column: modeTok2?.startColumn ?? 1, severity: "error", code: "FL-CLICK-CALL-NAME-MISSING", message: "'click \u2026 call' requires a function name.", hint:
|
|
54400
|
+
this.ctx.errors.push({ line: modeTok2?.startLine ?? 1, column: modeTok2?.startColumn ?? 1, severity: "error", code: "FL-CLICK-CALL-NAME-MISSING", message: "'click \u2026 call' requires a function name.", hint: "Example: click A call doThing()" });
|
|
54174
54401
|
}
|
|
54175
54402
|
const tipTok = ch.tooltip?.[0];
|
|
54176
54403
|
if (tipTok) {
|
|
@@ -54227,7 +54454,7 @@ var init_semantics = __esm({
|
|
|
54227
54454
|
severity: "error",
|
|
54228
54455
|
code: "FL-CLICK-CALL-NAME-MISSING",
|
|
54229
54456
|
message: "'click \u2026 call' requires a function name.",
|
|
54230
|
-
hint:
|
|
54457
|
+
hint: "Example: click A call doThing()"
|
|
54231
54458
|
});
|
|
54232
54459
|
}
|
|
54233
54460
|
return;
|
|
@@ -54308,6 +54535,8 @@ var init_semantics = __esm({
|
|
|
54308
54535
|
const linksHere = Array.isArray(ctx.link) ? ctx.link.length : 0;
|
|
54309
54536
|
if (linksHere > 0)
|
|
54310
54537
|
this.edgeCount += linksHere;
|
|
54538
|
+
if (ctx.link)
|
|
54539
|
+
ctx.link.forEach((ln) => this.visit(ln));
|
|
54311
54540
|
}
|
|
54312
54541
|
// Edge attribute object statements must target a known edge id
|
|
54313
54542
|
// Edge attribute statements are parsed as nodeStatements with a typed attrObject and no links.
|
|
@@ -54367,7 +54596,7 @@ var init_semantics = __esm({
|
|
|
54367
54596
|
severity: "error",
|
|
54368
54597
|
code: "FL-TYPED-SHAPE-UNKNOWN",
|
|
54369
54598
|
message: `Unknown shape '${v3}' in '@{ shape: \u2026 }'.`,
|
|
54370
|
-
hint:
|
|
54599
|
+
hint: 'Use one of: rect, rounded, stadium, subroutine, circle, cylinder, diamond, trapezoid, parallelogram, hexagon, "lean-l", "lean-r", icon, image'
|
|
54371
54600
|
});
|
|
54372
54601
|
} else {
|
|
54373
54602
|
const supportedByCli = /* @__PURE__ */ new Set(["rect", "round", "rounded", "diamond", "circle", "cylinder", "stadium", "subroutine", "lean-l", "lean-r"]);
|
|
@@ -54569,8 +54798,8 @@ var init_semantics = __esm({
|
|
|
54569
54798
|
column: t3.startColumn ?? 1,
|
|
54570
54799
|
severity: "error",
|
|
54571
54800
|
code: "FL-LABEL-PARENS-UNQUOTED",
|
|
54572
|
-
message: "Parentheses inside an unquoted label are not supported by Mermaid.
|
|
54573
|
-
hint: '
|
|
54801
|
+
message: "Parentheses inside an unquoted label are not supported by Mermaid.",
|
|
54802
|
+
hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and )'
|
|
54574
54803
|
});
|
|
54575
54804
|
}
|
|
54576
54805
|
}
|
|
@@ -54618,6 +54847,29 @@ var init_semantics = __esm({
|
|
|
54618
54847
|
}
|
|
54619
54848
|
}
|
|
54620
54849
|
}
|
|
54850
|
+
// Validate link specifics that Mermaid CLI enforces but our grammar may parse loosely
|
|
54851
|
+
link(ctx) {
|
|
54852
|
+
const inline = ctx.linkTextInline?.[0];
|
|
54853
|
+
if (inline) {
|
|
54854
|
+
const ch = inline.children || {};
|
|
54855
|
+
const parts = [].concat(ch.Identifier || []).concat(ch.Text || []).concat(ch.NumberLiteral || []).concat(ch.Pipe || []);
|
|
54856
|
+
if (parts.length) {
|
|
54857
|
+
const raw = parts.map((t3) => String(t3.image || "")).join("").trim();
|
|
54858
|
+
if (raw === "x" || raw === "o") {
|
|
54859
|
+
const p3 = parts[0];
|
|
54860
|
+
this.ctx.errors.push({
|
|
54861
|
+
line: p3.startLine ?? 1,
|
|
54862
|
+
column: p3.startColumn ?? 1,
|
|
54863
|
+
severity: "error",
|
|
54864
|
+
code: "FL-LINK-UNSUPPORTED-MARKER",
|
|
54865
|
+
message: `Unsupported one-sided link marker '${raw}'. Use symmetric '${raw}--${raw}' or a plain arrow with a label.`,
|
|
54866
|
+
hint: raw === "x" ? "Example: A x--x B (or) A --> B and label it: A --|Skipped|--> B" : "Example: A o--o B (or) A --> B",
|
|
54867
|
+
length: p3.image?.length ?? 1
|
|
54868
|
+
});
|
|
54869
|
+
}
|
|
54870
|
+
}
|
|
54871
|
+
}
|
|
54872
|
+
}
|
|
54621
54873
|
checkBackticksInContent(contentNodes) {
|
|
54622
54874
|
if (!contentNodes)
|
|
54623
54875
|
return;
|
|
@@ -54969,6 +55221,31 @@ function mapFlowchartParserError(err, text) {
|
|
|
54969
55221
|
}
|
|
54970
55222
|
}
|
|
54971
55223
|
}
|
|
55224
|
+
if (isInRule(err, "linkStylePairs") && tokType === "Newline") {
|
|
55225
|
+
const nextLine = Math.min(allLines.length, line + 1);
|
|
55226
|
+
const nxt = allLines[nextLine - 1] || "";
|
|
55227
|
+
const first2 = (nxt.match(/\S/) || { index: 0 }).index || 0;
|
|
55228
|
+
return {
|
|
55229
|
+
line: nextLine,
|
|
55230
|
+
column: Math.max(1, first2 + 1),
|
|
55231
|
+
severity: "error",
|
|
55232
|
+
code: "FL-LINKSTYLE-MULTILINE",
|
|
55233
|
+
message: "'linkStyle' styles must be on the same line as the indices.",
|
|
55234
|
+
hint: "Example: linkStyle 0,1 stroke:#f00,stroke-width:2px",
|
|
55235
|
+
length: 1
|
|
55236
|
+
};
|
|
55237
|
+
}
|
|
55238
|
+
if ((isInRule(err, "linkStyleIndexList") || isInRule(err, "linkStyleStatement")) && tokType === "Colon") {
|
|
55239
|
+
return {
|
|
55240
|
+
line,
|
|
55241
|
+
column,
|
|
55242
|
+
severity: "error",
|
|
55243
|
+
code: "FL-LINKSTYLE-RANGE-NOT-SUPPORTED",
|
|
55244
|
+
message: "Ranges in 'linkStyle' indices are not supported. Use comma-separated indices.",
|
|
55245
|
+
hint: "Example: linkStyle 0,1 stroke:#f00,stroke-width:2px",
|
|
55246
|
+
length: len
|
|
55247
|
+
};
|
|
55248
|
+
}
|
|
54972
55249
|
if (tokType === "QuotedString") {
|
|
54973
55250
|
const context = err?.context;
|
|
54974
55251
|
const inLinkRule = context?.ruleStack?.includes("linkTextInline") || context?.ruleStack?.includes("link") || false;
|
|
@@ -55015,6 +55292,17 @@ function mapFlowchartParserError(err, text) {
|
|
|
55015
55292
|
}
|
|
55016
55293
|
if (isInRule(err, "nodeShape") && err.name === "MismatchedTokenException") {
|
|
55017
55294
|
if (expecting(err, "SquareClose")) {
|
|
55295
|
+
if (tokType === "RoundOpen" || tokType === "RoundClose") {
|
|
55296
|
+
return {
|
|
55297
|
+
line,
|
|
55298
|
+
column,
|
|
55299
|
+
severity: "error",
|
|
55300
|
+
code: "FL-LABEL-PARENS-UNQUOTED",
|
|
55301
|
+
message: "Parentheses inside an unquoted label are not supported by Mermaid.",
|
|
55302
|
+
hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).',
|
|
55303
|
+
length: len
|
|
55304
|
+
};
|
|
55305
|
+
}
|
|
55018
55306
|
if (tokType === "QuotedString") {
|
|
55019
55307
|
return {
|
|
55020
55308
|
line,
|
|
@@ -55510,6 +55798,32 @@ ${br.example}`,
|
|
|
55510
55798
|
break;
|
|
55511
55799
|
}
|
|
55512
55800
|
}
|
|
55801
|
+
if (blk.label === "box" && openIdx !== -1) {
|
|
55802
|
+
let endIdx = -1;
|
|
55803
|
+
for (let i3 = openIdx + 1; i3 < lines2.length; i3++) {
|
|
55804
|
+
const raw = lines2[i3] || "";
|
|
55805
|
+
const ind = raw.match(/^(\s*)/)?.[1] || "";
|
|
55806
|
+
if (/^\s*end\s*$/.test(raw) && ind.length <= openIndent.length) {
|
|
55807
|
+
endIdx = i3;
|
|
55808
|
+
break;
|
|
55809
|
+
}
|
|
55810
|
+
}
|
|
55811
|
+
if (endIdx !== -1) {
|
|
55812
|
+
const body = lines2.slice(openIdx + 1, endIdx).map((s3) => (s3 || "").trim());
|
|
55813
|
+
const hasMsgWithActivation = body.some((s3) => /->/.test(s3) && /[+-]/.test(s3));
|
|
55814
|
+
if (hasMsgWithActivation) {
|
|
55815
|
+
return {
|
|
55816
|
+
line: openIdx + 1,
|
|
55817
|
+
column: 1,
|
|
55818
|
+
severity: "error",
|
|
55819
|
+
code: "SE-BOX-EMPTY",
|
|
55820
|
+
message: "Box block has no participant/actor declarations. Use 'rect' to group messages visually.",
|
|
55821
|
+
hint: "Replace 'box' with 'rect' if you want to group messages:\nrect rgb(240, 240, 255)\n A->>B: Message\n Note over A: Info\nend",
|
|
55822
|
+
length: 3
|
|
55823
|
+
};
|
|
55824
|
+
}
|
|
55825
|
+
}
|
|
55826
|
+
}
|
|
55513
55827
|
let caretLine = line;
|
|
55514
55828
|
if (openIdx !== -1) {
|
|
55515
55829
|
caretLine = lines2.length;
|
|
@@ -56849,7 +57163,7 @@ var init_validate3 = __esm({
|
|
|
56849
57163
|
function tokenize4(text) {
|
|
56850
57164
|
return ClassLexer.tokenize(text);
|
|
56851
57165
|
}
|
|
56852
|
-
var Identifier3, NumberLiteral4, ClassDiagramKeyword, DirectionKw, Direction2, ClassKw, AsKw, NoteKw, ForKw, RelCompToAgg, RelAggToComp, RelCompBoth, RelAggBoth, LollipopLeft, LollipopRight, RelExtends, RelComposition, RelAggregation, RelDependency, RelRealization, RelAssociation, RelDependencyLeft, RelRealizationLeft, RelExtendsRight, InvalidRelArrow, LCurly, RCurly, LParen2, RParen2, Colon4, Comma3, Visibility, LTlt, GTgt, GenericAngle, QuotedString4, BacktickName, SquareOpen2, SquareClose2, Comment4, WhiteSpace4, Newline4, allTokens4, ClassLexer;
|
|
57166
|
+
var Identifier3, NumberLiteral4, ClassDiagramKeyword, DirectionKw, Direction2, TitleKw, NamespaceKw, ClassKw, InterfaceKw, AsKw, NoteKw, ForKw, RelCompToAgg, RelAggToComp, RelCompBoth, RelAggBoth, LollipopLeft, LollipopRight, RelExtends, RelComposition, RelAggregation, RelDependency, RelRealization, RelAssociation, RelDependencyLeft, RelRealizationLeft, RelExtendsRight, InvalidRelArrow, LCurly, RCurly, LParen2, RParen2, Colon4, Comma3, Visibility, LTlt, GTgt, GenericAngle, QuotedString4, BacktickName, SquareOpen2, SquareClose2, Comment4, WhiteSpace4, Newline4, allTokens4, ClassLexer;
|
|
56853
57167
|
var init_lexer5 = __esm({
|
|
56854
57168
|
"node_modules/@probelabs/maid/out/diagrams/class/lexer.js"() {
|
|
56855
57169
|
init_api5();
|
|
@@ -56858,7 +57172,10 @@ var init_lexer5 = __esm({
|
|
|
56858
57172
|
ClassDiagramKeyword = createToken({ name: "ClassDiagramKeyword", pattern: /classDiagram/, longer_alt: Identifier3 });
|
|
56859
57173
|
DirectionKw = createToken({ name: "DirectionKw", pattern: /direction/, longer_alt: Identifier3 });
|
|
56860
57174
|
Direction2 = createToken({ name: "Direction", pattern: /LR|RL|TB|BT|TD/, longer_alt: Identifier3 });
|
|
57175
|
+
TitleKw = createToken({ name: "TitleKw", pattern: /title/, longer_alt: Identifier3 });
|
|
57176
|
+
NamespaceKw = createToken({ name: "NamespaceKw", pattern: /namespace/, longer_alt: Identifier3 });
|
|
56861
57177
|
ClassKw = createToken({ name: "ClassKw", pattern: /class/, longer_alt: Identifier3 });
|
|
57178
|
+
InterfaceKw = createToken({ name: "InterfaceKw", pattern: /interface\b/, longer_alt: Identifier3 });
|
|
56862
57179
|
AsKw = createToken({ name: "AsKw", pattern: /as/, longer_alt: Identifier3 });
|
|
56863
57180
|
NoteKw = createToken({ name: "NoteKw", pattern: /note/, longer_alt: Identifier3 });
|
|
56864
57181
|
ForKw = createToken({ name: "ForKw", pattern: /for/, longer_alt: Identifier3 });
|
|
@@ -56901,6 +57218,9 @@ var init_lexer5 = __esm({
|
|
|
56901
57218
|
// Keywords
|
|
56902
57219
|
ClassDiagramKeyword,
|
|
56903
57220
|
DirectionKw,
|
|
57221
|
+
TitleKw,
|
|
57222
|
+
NamespaceKw,
|
|
57223
|
+
InterfaceKw,
|
|
56904
57224
|
ClassKw,
|
|
56905
57225
|
AsKw,
|
|
56906
57226
|
NoteKw,
|
|
@@ -56969,8 +57289,11 @@ var init_parser5 = __esm({
|
|
|
56969
57289
|
});
|
|
56970
57290
|
this.statement = this.RULE("statement", () => {
|
|
56971
57291
|
this.OR([
|
|
57292
|
+
{ ALT: () => this.SUBRULE(this.titleStmt) },
|
|
56972
57293
|
{ ALT: () => this.SUBRULE(this.directionStmt) },
|
|
57294
|
+
{ ALT: () => this.SUBRULE(this.namespaceStmt) },
|
|
56973
57295
|
{ ALT: () => this.SUBRULE(this.classLine) },
|
|
57296
|
+
{ ALT: () => this.SUBRULE(this.interfaceLine) },
|
|
56974
57297
|
{ ALT: () => this.SUBRULE(this.relationStmt) },
|
|
56975
57298
|
{ ALT: () => this.SUBRULE(this.noteStmt) },
|
|
56976
57299
|
{ ALT: () => this.SUBRULE(this.memberAssignStmt) },
|
|
@@ -56982,6 +57305,43 @@ var init_parser5 = __esm({
|
|
|
56982
57305
|
this.CONSUME(Direction2);
|
|
56983
57306
|
this.OPTION(() => this.CONSUME(Newline4));
|
|
56984
57307
|
});
|
|
57308
|
+
this.titleStmt = this.RULE("titleStmt", () => {
|
|
57309
|
+
this.CONSUME(TitleKw);
|
|
57310
|
+
this.OR([
|
|
57311
|
+
{ ALT: () => this.CONSUME(QuotedString4) },
|
|
57312
|
+
{
|
|
57313
|
+
ALT: () => {
|
|
57314
|
+
this.AT_LEAST_ONE(() => {
|
|
57315
|
+
this.OR2([
|
|
57316
|
+
{ ALT: () => this.CONSUME(Identifier3) },
|
|
57317
|
+
{ ALT: () => this.CONSUME(NumberLiteral4) }
|
|
57318
|
+
]);
|
|
57319
|
+
});
|
|
57320
|
+
}
|
|
57321
|
+
}
|
|
57322
|
+
]);
|
|
57323
|
+
this.OPTION(() => this.CONSUME(Newline4));
|
|
57324
|
+
});
|
|
57325
|
+
this.namespaceStmt = this.RULE("namespaceStmt", () => {
|
|
57326
|
+
this.CONSUME(NamespaceKw);
|
|
57327
|
+
this.OR([
|
|
57328
|
+
{ ALT: () => this.CONSUME(QuotedString4) },
|
|
57329
|
+
{ ALT: () => this.CONSUME(Identifier3) }
|
|
57330
|
+
]);
|
|
57331
|
+
this.CONSUME(LCurly);
|
|
57332
|
+
this.MANY(() => {
|
|
57333
|
+
this.OR2([
|
|
57334
|
+
{ ALT: () => this.CONSUME(Newline4) },
|
|
57335
|
+
{ ALT: () => this.SUBRULE(this.classLine) },
|
|
57336
|
+
{ ALT: () => this.SUBRULE(this.interfaceLine) },
|
|
57337
|
+
{ ALT: () => this.SUBRULE(this.relationStmt) },
|
|
57338
|
+
{ ALT: () => this.SUBRULE(this.noteStmt) },
|
|
57339
|
+
{ ALT: () => this.SUBRULE(this.memberAssignStmt) }
|
|
57340
|
+
]);
|
|
57341
|
+
});
|
|
57342
|
+
this.CONSUME(RCurly);
|
|
57343
|
+
this.OPTION(() => this.CONSUME2(Newline4));
|
|
57344
|
+
});
|
|
56985
57345
|
this.classLine = this.RULE("classLine", () => {
|
|
56986
57346
|
this.CONSUME(ClassKw);
|
|
56987
57347
|
this.SUBRULE(this.classRef);
|
|
@@ -57020,6 +57380,44 @@ var init_parser5 = __esm({
|
|
|
57020
57380
|
}
|
|
57021
57381
|
]);
|
|
57022
57382
|
});
|
|
57383
|
+
this.interfaceLine = this.RULE("interfaceLine", () => {
|
|
57384
|
+
this.CONSUME(InterfaceKw);
|
|
57385
|
+
this.SUBRULE(this.classRef);
|
|
57386
|
+
this.OR([
|
|
57387
|
+
{
|
|
57388
|
+
ALT: () => {
|
|
57389
|
+
this.CONSUME(LCurly);
|
|
57390
|
+
this.MANY(() => {
|
|
57391
|
+
this.OR2([
|
|
57392
|
+
{ ALT: () => this.CONSUME3(Newline4) },
|
|
57393
|
+
{ ALT: () => this.SUBRULE(this.memberLineStmt) }
|
|
57394
|
+
]);
|
|
57395
|
+
});
|
|
57396
|
+
this.CONSUME(RCurly);
|
|
57397
|
+
this.OPTION(() => this.CONSUME(Newline4));
|
|
57398
|
+
}
|
|
57399
|
+
},
|
|
57400
|
+
{
|
|
57401
|
+
ALT: () => {
|
|
57402
|
+
this.OPTION1(() => {
|
|
57403
|
+
this.CONSUME(SquareOpen2);
|
|
57404
|
+
this.CONSUME(QuotedString4);
|
|
57405
|
+
this.CONSUME(SquareClose2);
|
|
57406
|
+
});
|
|
57407
|
+
this.OPTION2(() => {
|
|
57408
|
+
this.CONSUME(LTlt);
|
|
57409
|
+
this.CONSUME2(Identifier3);
|
|
57410
|
+
this.CONSUME(GTgt);
|
|
57411
|
+
});
|
|
57412
|
+
this.OPTION3(() => {
|
|
57413
|
+
this.CONSUME(AsKw);
|
|
57414
|
+
this.CONSUME3(Identifier3);
|
|
57415
|
+
});
|
|
57416
|
+
this.OPTION4(() => this.CONSUME2(Newline4));
|
|
57417
|
+
}
|
|
57418
|
+
}
|
|
57419
|
+
]);
|
|
57420
|
+
});
|
|
57023
57421
|
this.memberAssignStmt = this.RULE("memberAssignStmt", () => {
|
|
57024
57422
|
this.SUBRULE(this.classRef);
|
|
57025
57423
|
this.CONSUME(Colon4);
|
|
@@ -57189,6 +57587,31 @@ function validateClass(text, _options = {}) {
|
|
|
57189
57587
|
length: b3.image?.length ?? 1
|
|
57190
57588
|
});
|
|
57191
57589
|
}
|
|
57590
|
+
if (a3.tokenType === NamespaceKw && b3.tokenType === QuotedString4) {
|
|
57591
|
+
errs.push({
|
|
57592
|
+
line: b3.startLine ?? 1,
|
|
57593
|
+
column: b3.startColumn ?? 1,
|
|
57594
|
+
severity: "error",
|
|
57595
|
+
code: "CL-NAMESPACE-NAME-QUOTED",
|
|
57596
|
+
message: "Quoted namespace names are not supported by mermaid.js. Use an unquoted identifier.",
|
|
57597
|
+
hint: 'Change: namespace "ProbeAgent Core" { ... } \u2192 namespace ProbeAgentCore { ... }',
|
|
57598
|
+
length: b3.image?.length ?? 1
|
|
57599
|
+
});
|
|
57600
|
+
}
|
|
57601
|
+
if (a3.tokenType === InterfaceKw) {
|
|
57602
|
+
const prevToken = i3 > 0 ? tokList[i3 - 1] : null;
|
|
57603
|
+
if (!prevToken || prevToken.tokenType !== LTlt) {
|
|
57604
|
+
errs.push({
|
|
57605
|
+
line: a3.startLine ?? 1,
|
|
57606
|
+
column: a3.startColumn ?? 1,
|
|
57607
|
+
severity: "error",
|
|
57608
|
+
code: "CL-INTERFACE-KEYWORD-UNSUPPORTED",
|
|
57609
|
+
message: 'The "interface" keyword is not supported by mermaid.js. Use the <<interface>> annotation instead.',
|
|
57610
|
+
hint: 'Auto-fix converts to "class". Then manually add: <<interface>> ClassName after the class definition',
|
|
57611
|
+
length: a3.image?.length ?? 9
|
|
57612
|
+
});
|
|
57613
|
+
}
|
|
57614
|
+
}
|
|
57192
57615
|
}
|
|
57193
57616
|
for (const tk of tokList) {
|
|
57194
57617
|
if (tk.tokenType === InvalidRelArrow) {
|
|
@@ -57245,10 +57668,13 @@ function validateClass(text, _options = {}) {
|
|
|
57245
57668
|
const has2 = (code, line) => (prev || []).some((e3) => e3.code === code && e3.line === line && e3.severity === "error");
|
|
57246
57669
|
const lines = src.split(/\r?\n/);
|
|
57247
57670
|
const classDeclOpen = [];
|
|
57671
|
+
const namespaceDeclOpen = [];
|
|
57248
57672
|
for (let i3 = 0; i3 < lines.length; i3++) {
|
|
57249
57673
|
const raw = lines[i3] || "";
|
|
57250
57674
|
if (/^\s*class\b.*\{\s*$/.test(raw))
|
|
57251
57675
|
classDeclOpen.push(i3 + 1);
|
|
57676
|
+
if (/^\s*namespace\b.*\{\s*$/.test(raw))
|
|
57677
|
+
namespaceDeclOpen.push(i3 + 1);
|
|
57252
57678
|
}
|
|
57253
57679
|
if (classDeclOpen.length > 0) {
|
|
57254
57680
|
const hasClose = lines.some((l3) => /\}/.test(l3));
|
|
@@ -57257,6 +57683,13 @@ function validateClass(text, _options = {}) {
|
|
|
57257
57683
|
errors.push({ line: Math.max(1, lines.length), column: 1, severity: "error", code: "CL-BLOCK-MISSING-RBRACE", message: "Missing '}' to close class block.", hint: "Close the block: class Foo { ... }" });
|
|
57258
57684
|
}
|
|
57259
57685
|
}
|
|
57686
|
+
if (namespaceDeclOpen.length > 0) {
|
|
57687
|
+
const hasClose = lines.some((l3) => /\}/.test(l3));
|
|
57688
|
+
if (!hasClose && !has2("CL-NAMESPACE-MISSING-RBRACE", Math.max(1, lines.length))) {
|
|
57689
|
+
const last2 = namespaceDeclOpen[namespaceDeclOpen.length - 1];
|
|
57690
|
+
errors.push({ line: Math.max(1, lines.length), column: 1, severity: "error", code: "CL-NAMESPACE-MISSING-RBRACE", message: "Missing '}' to close namespace block.", hint: 'Close the block: namespace "Name" { ... }' });
|
|
57691
|
+
}
|
|
57692
|
+
}
|
|
57260
57693
|
return errors;
|
|
57261
57694
|
}
|
|
57262
57695
|
});
|
|
@@ -57911,6 +58344,10 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
57911
58344
|
edits.push(replaceRange(text, at(e3), e3.length ?? 2, "-->"));
|
|
57912
58345
|
continue;
|
|
57913
58346
|
}
|
|
58347
|
+
if (is("FL-LINK-UNSUPPORTED-MARKER", e3)) {
|
|
58348
|
+
edits.push(replaceRange(text, at(e3), e3.length ?? 1, ""));
|
|
58349
|
+
continue;
|
|
58350
|
+
}
|
|
57914
58351
|
if (is("FL-EDGE-LABEL-QUOTED", e3)) {
|
|
57915
58352
|
const lineText = lineTextAt(text, e3.line);
|
|
57916
58353
|
const col = Math.max(0, e3.column - 1);
|
|
@@ -57983,6 +58420,29 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
57983
58420
|
}
|
|
57984
58421
|
continue;
|
|
57985
58422
|
}
|
|
58423
|
+
if (is("CL-NAMESPACE-NAME-QUOTED", e3)) {
|
|
58424
|
+
const lineText = lineTextAt(text, e3.line);
|
|
58425
|
+
const nsIdx = lineText.indexOf("namespace");
|
|
58426
|
+
const startSearch = nsIdx >= 0 ? nsIdx + 9 : 0;
|
|
58427
|
+
const q1 = lineText.indexOf('"', startSearch);
|
|
58428
|
+
if (q1 !== -1) {
|
|
58429
|
+
const q22 = lineText.indexOf('"', q1 + 1);
|
|
58430
|
+
if (q22 > q1) {
|
|
58431
|
+
const namespaceName = lineText.slice(q1 + 1, q22);
|
|
58432
|
+
const validIdentifier = namespaceName.replace(/[^A-Za-z0-9_]/g, "");
|
|
58433
|
+
edits.push(replaceRange(text, { line: e3.line, column: q1 + 1 }, q22 - q1 + 1, validIdentifier));
|
|
58434
|
+
}
|
|
58435
|
+
}
|
|
58436
|
+
continue;
|
|
58437
|
+
}
|
|
58438
|
+
if (is("CL-INTERFACE-KEYWORD-UNSUPPORTED", e3)) {
|
|
58439
|
+
const lineText = lineTextAt(text, e3.line);
|
|
58440
|
+
const ifIdx = lineText.indexOf("interface");
|
|
58441
|
+
if (ifIdx !== -1) {
|
|
58442
|
+
edits.push(replaceRange(text, { line: e3.line, column: ifIdx + 1 }, 9, "class"));
|
|
58443
|
+
}
|
|
58444
|
+
continue;
|
|
58445
|
+
}
|
|
57986
58446
|
if (is("FL-LABEL-ESCAPED-QUOTE", e3)) {
|
|
57987
58447
|
const lineText = lineTextAt(text, e3.line);
|
|
57988
58448
|
const caret0 = Math.max(0, e3.column - 1);
|
|
@@ -58130,6 +58590,42 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
58130
58590
|
const msg = e3.message || "";
|
|
58131
58591
|
const lineText = lineTextAt(text, e3.line);
|
|
58132
58592
|
const caret0 = Math.max(0, e3.column - 1);
|
|
58593
|
+
{
|
|
58594
|
+
const openIdx = lineText.indexOf("([");
|
|
58595
|
+
if (openIdx !== -1) {
|
|
58596
|
+
const badClose = lineText.indexOf("})", openIdx + 2);
|
|
58597
|
+
if (badClose !== -1) {
|
|
58598
|
+
edits.push({ start: { line: e3.line, column: badClose + 1 }, end: { line: e3.line, column: badClose + 2 }, newText: "]" });
|
|
58599
|
+
patchedLines.add(e3.line);
|
|
58600
|
+
continue;
|
|
58601
|
+
}
|
|
58602
|
+
}
|
|
58603
|
+
}
|
|
58604
|
+
{
|
|
58605
|
+
const openIdx = lineText.indexOf("[(");
|
|
58606
|
+
if (openIdx !== -1) {
|
|
58607
|
+
const closePair = lineText.indexOf("))", openIdx + 2);
|
|
58608
|
+
if (closePair !== -1) {
|
|
58609
|
+
edits.push({ start: { line: e3.line, column: closePair + 2 }, end: { line: e3.line, column: closePair + 3 }, newText: "]" });
|
|
58610
|
+
patchedLines.add(e3.line);
|
|
58611
|
+
continue;
|
|
58612
|
+
}
|
|
58613
|
+
}
|
|
58614
|
+
}
|
|
58615
|
+
{
|
|
58616
|
+
const openPair = lineText.indexOf("([");
|
|
58617
|
+
if (openPair !== -1) {
|
|
58618
|
+
const badClose = lineText.indexOf("})", openPair + 2);
|
|
58619
|
+
if (badClose !== -1) {
|
|
58620
|
+
edits.push({ start: { line: e3.line, column: badClose + 1 }, end: { line: e3.line, column: badClose + 2 }, newText: "]" });
|
|
58621
|
+
continue;
|
|
58622
|
+
}
|
|
58623
|
+
}
|
|
58624
|
+
}
|
|
58625
|
+
if (/\(\[/.test(lineText) && lineText.indexOf("})", Math.max(0, caret0 - 1)) !== -1) {
|
|
58626
|
+
edits.push(replaceRange(text, at(e3), e3.length ?? 1, "]"));
|
|
58627
|
+
continue;
|
|
58628
|
+
}
|
|
58133
58629
|
if (msg.includes("opened '('") && msg.includes("closed with ']'")) {
|
|
58134
58630
|
const openIdx = lineText.lastIndexOf("(", caret0);
|
|
58135
58631
|
if (openIdx !== -1) {
|
|
@@ -58202,7 +58698,36 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
58202
58698
|
const caret0 = Math.max(0, e3.column - 1);
|
|
58203
58699
|
const msg = e3.message || "";
|
|
58204
58700
|
const bracketMatch = msg.match(/Unclosed '(.+?)'/);
|
|
58205
|
-
const expectedOpener = bracketMatch ? bracketMatch[1] : null;
|
|
58701
|
+
const expectedOpener = bracketMatch ? (bracketMatch[1] || "").trim() : null;
|
|
58702
|
+
if (expectedOpener === "((") {
|
|
58703
|
+
if (level === "all") {
|
|
58704
|
+
const openIdx = lineText.lastIndexOf("((", caret0);
|
|
58705
|
+
if (openIdx !== -1) {
|
|
58706
|
+
const contentStart = openIdx + 2;
|
|
58707
|
+
const picks = [];
|
|
58708
|
+
const pushIdx2 = (i3) => {
|
|
58709
|
+
if (i3 >= 0)
|
|
58710
|
+
picks.push(i3);
|
|
58711
|
+
};
|
|
58712
|
+
pushIdx2(lineText.indexOf("-", contentStart));
|
|
58713
|
+
pushIdx2(lineText.indexOf("=", contentStart));
|
|
58714
|
+
pushIdx2(lineText.indexOf(".", contentStart));
|
|
58715
|
+
pushIdx2(lineText.indexOf("|", contentStart));
|
|
58716
|
+
let insertIdx = picks.length ? Math.min(...picks) : lineText.length;
|
|
58717
|
+
const before = lineText.slice(0, openIdx);
|
|
58718
|
+
const m3 = before.match(/([A-Za-z0-9_]+)\s*$/);
|
|
58719
|
+
const inferred = m3 ? m3[1] : "";
|
|
58720
|
+
if (inferred) {
|
|
58721
|
+
edits.push({ start: { line: e3.line, column: contentStart + 1 }, end: { line: e3.line, column: insertIdx + 1 }, newText: inferred + "))" });
|
|
58722
|
+
patchedLines.add(e3.line);
|
|
58723
|
+
continue;
|
|
58724
|
+
}
|
|
58725
|
+
patchedLines.add(e3.line);
|
|
58726
|
+
continue;
|
|
58727
|
+
}
|
|
58728
|
+
}
|
|
58729
|
+
continue;
|
|
58730
|
+
}
|
|
58206
58731
|
const bracketMap = {
|
|
58207
58732
|
"[": "]",
|
|
58208
58733
|
"{": "}",
|
|
@@ -58288,6 +58813,14 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
58288
58813
|
patchedLines.add(e3.line);
|
|
58289
58814
|
continue;
|
|
58290
58815
|
}
|
|
58816
|
+
if (innerSeg.includes("(") || innerSeg.includes(")")) {
|
|
58817
|
+
const replaced = innerSeg.replace(/\(/g, "(").replace(/\)/g, ")");
|
|
58818
|
+
if (replaced !== innerSeg) {
|
|
58819
|
+
edits.push({ start: { line: e3.line, column: opened.idx + opened.len + 1 }, end: { line: e3.line, column: closerIdx + 1 }, newText: replaced });
|
|
58820
|
+
patchedLines.add(e3.line);
|
|
58821
|
+
continue;
|
|
58822
|
+
}
|
|
58823
|
+
}
|
|
58291
58824
|
}
|
|
58292
58825
|
}
|
|
58293
58826
|
if (patchedLines.has(e3.line)) {
|
|
@@ -58296,9 +58829,35 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
58296
58829
|
let closer = "]";
|
|
58297
58830
|
if (opened)
|
|
58298
58831
|
closer = opened.close;
|
|
58299
|
-
|
|
58300
|
-
|
|
58301
|
-
|
|
58832
|
+
if (closer === "]") {
|
|
58833
|
+
const openIdxSq = lineText.lastIndexOf("[", caret0);
|
|
58834
|
+
if (openIdxSq !== -1) {
|
|
58835
|
+
const picks = [];
|
|
58836
|
+
const pushIdx2 = (i3) => {
|
|
58837
|
+
if (i3 >= 0)
|
|
58838
|
+
picks.push(i3);
|
|
58839
|
+
};
|
|
58840
|
+
pushIdx2(lineText.indexOf("-", openIdxSq + 1));
|
|
58841
|
+
pushIdx2(lineText.indexOf("=", openIdxSq + 1));
|
|
58842
|
+
pushIdx2(lineText.indexOf(".", openIdxSq + 1));
|
|
58843
|
+
pushIdx2(lineText.indexOf("|", openIdxSq + 1));
|
|
58844
|
+
let ins = picks.length ? Math.min(...picks) : lineText.length;
|
|
58845
|
+
let tl = ins - 1;
|
|
58846
|
+
while (tl >= 0 && /\s/.test(lineText[tl]))
|
|
58847
|
+
tl--;
|
|
58848
|
+
const startCol2 = tl + 1 + 1;
|
|
58849
|
+
const endCol2 = ins + 1;
|
|
58850
|
+
edits.push({ start: { line: e3.line, column: startCol2 }, end: { line: e3.line, column: endCol2 }, newText: closer });
|
|
58851
|
+
} else {
|
|
58852
|
+
const avail = lineText.slice(caret0);
|
|
58853
|
+
const replaceLen = Math.min(closer.length, Math.max(1, avail.length));
|
|
58854
|
+
edits.push({ start: { line: e3.line, column: caret0 + 1 }, end: { line: e3.line, column: caret0 + 1 + replaceLen }, newText: closer });
|
|
58855
|
+
}
|
|
58856
|
+
} else {
|
|
58857
|
+
const avail = lineText.slice(caret0);
|
|
58858
|
+
const replaceLen = Math.min(closer.length, Math.max(1, avail.length));
|
|
58859
|
+
edits.push({ start: { line: e3.line, column: caret0 + 1 }, end: { line: e3.line, column: caret0 + 1 + replaceLen }, newText: closer });
|
|
58860
|
+
}
|
|
58302
58861
|
}
|
|
58303
58862
|
continue;
|
|
58304
58863
|
}
|
|
@@ -58430,9 +58989,11 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
58430
58989
|
if (core.length >= 2 && isSlashPair(left, right)) {
|
|
58431
58990
|
break;
|
|
58432
58991
|
}
|
|
58433
|
-
const
|
|
58434
|
-
|
|
58435
|
-
|
|
58992
|
+
const replaced = inner.replace(/\(/g, "(").replace(/\)/g, ")");
|
|
58993
|
+
if (replaced !== inner) {
|
|
58994
|
+
edits.push({ start: { line: e3.line, column: contentStart + 1 }, end: { line: e3.line, column: closeIdx + 1 }, newText: replaced });
|
|
58995
|
+
patchedLines.add(e3.line);
|
|
58996
|
+
}
|
|
58436
58997
|
break;
|
|
58437
58998
|
}
|
|
58438
58999
|
searchStart = openIdx + 1;
|
|
@@ -58589,14 +59150,33 @@ function computeFixes(text, errors, level = "safe") {
|
|
|
58589
59150
|
continue;
|
|
58590
59151
|
}
|
|
58591
59152
|
if (is("SE-BOX-EMPTY", e3)) {
|
|
58592
|
-
|
|
58593
|
-
|
|
58594
|
-
|
|
58595
|
-
|
|
58596
|
-
|
|
58597
|
-
|
|
58598
|
-
|
|
58599
|
-
|
|
59153
|
+
if (level === "all") {
|
|
59154
|
+
const lines = text.split(/\r?\n/);
|
|
59155
|
+
const boxIdx = Math.max(0, e3.line - 1);
|
|
59156
|
+
const boxLine = lines[boxIdx] || "";
|
|
59157
|
+
const openIndent = (boxLine.match(/^(\s*)/)?.[1] || "").length;
|
|
59158
|
+
let endIdx = -1;
|
|
59159
|
+
for (let i3 = boxIdx + 1; i3 < lines.length; i3++) {
|
|
59160
|
+
const raw = lines[i3] || "";
|
|
59161
|
+
const ind = (raw.match(/^(\s*)/)?.[1] || "").length;
|
|
59162
|
+
if (/^\s*end\s*$/.test(raw) && ind <= openIndent) {
|
|
59163
|
+
endIdx = i3;
|
|
59164
|
+
break;
|
|
59165
|
+
}
|
|
59166
|
+
}
|
|
59167
|
+
let hasMsgWithAct = false;
|
|
59168
|
+
if (endIdx !== -1) {
|
|
59169
|
+
const body = lines.slice(boxIdx + 1, endIdx).map((s3) => (s3 || "").trim());
|
|
59170
|
+
hasMsgWithAct = body.some((s3) => /->/.test(s3) && /[+-]/.test(s3));
|
|
59171
|
+
}
|
|
59172
|
+
if (!hasMsgWithAct) {
|
|
59173
|
+
const labelMatch = /^\s*box\s+(.+)$/.exec(boxLine);
|
|
59174
|
+
if (labelMatch) {
|
|
59175
|
+
const indent = boxLine.match(/^\s*/)?.[0] || "";
|
|
59176
|
+
const newLine = `${indent}rect rgb(240, 240, 255)`;
|
|
59177
|
+
edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line, column: boxLine.length + 1 }, newText: newLine });
|
|
59178
|
+
}
|
|
59179
|
+
}
|
|
58600
59180
|
}
|
|
58601
59181
|
continue;
|
|
58602
59182
|
}
|
|
@@ -58872,6 +59452,41 @@ ${indent}${tail}` });
|
|
|
58872
59452
|
}
|
|
58873
59453
|
}
|
|
58874
59454
|
edits.push(insertAt(text, { line: insIdx + 1, column: 1 }, `${openIndent}}
|
|
59455
|
+
`));
|
|
59456
|
+
continue;
|
|
59457
|
+
}
|
|
59458
|
+
if (is("CL-NAMESPACE-MISSING-RBRACE", e3)) {
|
|
59459
|
+
const lines = text.split(/\r?\n/);
|
|
59460
|
+
const curIdx = Math.max(0, e3.line - 1);
|
|
59461
|
+
const openerRe = /^(\s*)namespace\b.*\{\s*$/;
|
|
59462
|
+
let openIdx = -1;
|
|
59463
|
+
let openIndent = "";
|
|
59464
|
+
for (let i3 = curIdx; i3 >= 0; i3--) {
|
|
59465
|
+
const m3 = openerRe.exec(lines[i3] || "");
|
|
59466
|
+
if (m3) {
|
|
59467
|
+
openIdx = i3;
|
|
59468
|
+
openIndent = m3[1] || "";
|
|
59469
|
+
break;
|
|
59470
|
+
}
|
|
59471
|
+
}
|
|
59472
|
+
if (openIdx === -1) {
|
|
59473
|
+
const indent = inferIndentFromLine(lines[curIdx] || "");
|
|
59474
|
+
edits.push(insertAt(text, { line: curIdx + 1, column: 1 }, `${indent}}
|
|
59475
|
+
`));
|
|
59476
|
+
continue;
|
|
59477
|
+
}
|
|
59478
|
+
let insIdx = lines.length;
|
|
59479
|
+
for (let i3 = openIdx + 1; i3 < lines.length; i3++) {
|
|
59480
|
+
const raw = lines[i3] || "";
|
|
59481
|
+
if (raw.trim() === "")
|
|
59482
|
+
continue;
|
|
59483
|
+
const ind = inferIndentFromLine(raw);
|
|
59484
|
+
if (ind.length <= openIndent.length) {
|
|
59485
|
+
insIdx = i3;
|
|
59486
|
+
break;
|
|
59487
|
+
}
|
|
59488
|
+
}
|
|
59489
|
+
edits.push(insertAt(text, { line: insIdx + 1, column: 1 }, `${openIndent}}
|
|
58875
59490
|
`));
|
|
58876
59491
|
continue;
|
|
58877
59492
|
}
|
|
@@ -72856,6 +73471,8 @@ var init_ProbeAgent = __esm({
|
|
|
72856
73471
|
import_promises2 = require("fs/promises");
|
|
72857
73472
|
import_path9 = require("path");
|
|
72858
73473
|
init_tokenCounter();
|
|
73474
|
+
init_InMemoryStorageAdapter();
|
|
73475
|
+
init_HookManager();
|
|
72859
73476
|
init_tools2();
|
|
72860
73477
|
init_common();
|
|
72861
73478
|
init_probeTool();
|
|
@@ -72888,6 +73505,8 @@ var init_ProbeAgent = __esm({
|
|
|
72888
73505
|
* @param {string} [options.mcpConfigPath] - Path to MCP configuration file
|
|
72889
73506
|
* @param {Object} [options.mcpConfig] - MCP configuration object (overrides mcpConfigPath)
|
|
72890
73507
|
* @param {Array} [options.mcpServers] - Deprecated, use mcpConfig instead
|
|
73508
|
+
* @param {Object} [options.storageAdapter] - Custom storage adapter for history management
|
|
73509
|
+
* @param {Object} [options.hooks] - Hook callbacks for events (e.g., {'tool:start': callback})
|
|
72891
73510
|
*/
|
|
72892
73511
|
constructor(options = {}) {
|
|
72893
73512
|
this.sessionId = options.sessionId || (0, import_crypto5.randomUUID)();
|
|
@@ -72901,6 +73520,13 @@ var init_ProbeAgent = __esm({
|
|
|
72901
73520
|
this.maxResponseTokens = options.maxResponseTokens || parseInt(process.env.MAX_RESPONSE_TOKENS || "0", 10) || null;
|
|
72902
73521
|
this.maxIterations = options.maxIterations || null;
|
|
72903
73522
|
this.disableMermaidValidation = !!options.disableMermaidValidation;
|
|
73523
|
+
this.storageAdapter = options.storageAdapter || new InMemoryStorageAdapter();
|
|
73524
|
+
this.hooks = new HookManager();
|
|
73525
|
+
if (options.hooks) {
|
|
73526
|
+
for (const [hookName, callback] of Object.entries(options.hooks)) {
|
|
73527
|
+
this.hooks.on(hookName, callback);
|
|
73528
|
+
}
|
|
73529
|
+
}
|
|
72904
73530
|
this.enableBash = !!options.enableBash;
|
|
72905
73531
|
this.bashConfig = options.bashConfig || {};
|
|
72906
73532
|
if (options.allowedFolders && Array.isArray(options.allowedFolders)) {
|
|
@@ -72934,9 +73560,23 @@ var init_ProbeAgent = __esm({
|
|
|
72934
73560
|
}
|
|
72935
73561
|
/**
|
|
72936
73562
|
* Initialize the agent asynchronously (must be called after constructor)
|
|
72937
|
-
* This method initializes MCP and merges MCP tools into the tool list
|
|
73563
|
+
* This method initializes MCP and merges MCP tools into the tool list, and loads history from storage
|
|
72938
73564
|
*/
|
|
72939
73565
|
async initialize() {
|
|
73566
|
+
try {
|
|
73567
|
+
const history = await this.storageAdapter.loadHistory(this.sessionId);
|
|
73568
|
+
this.history = history;
|
|
73569
|
+
if (this.debug && history.length > 0) {
|
|
73570
|
+
console.log(`[DEBUG] Loaded ${history.length} messages from storage for session ${this.sessionId}`);
|
|
73571
|
+
}
|
|
73572
|
+
await this.hooks.emit(HOOK_TYPES.STORAGE_LOAD, {
|
|
73573
|
+
sessionId: this.sessionId,
|
|
73574
|
+
messages: history
|
|
73575
|
+
});
|
|
73576
|
+
} catch (error2) {
|
|
73577
|
+
console.error(`[ERROR] Failed to load history from storage:`, error2);
|
|
73578
|
+
this.history = [];
|
|
73579
|
+
}
|
|
72940
73580
|
if (this.enableMcp && !this._mcpInitialized) {
|
|
72941
73581
|
this._mcpInitialized = true;
|
|
72942
73582
|
try {
|
|
@@ -72969,6 +73609,10 @@ var init_ProbeAgent = __esm({
|
|
|
72969
73609
|
this.mcpBridge = null;
|
|
72970
73610
|
}
|
|
72971
73611
|
}
|
|
73612
|
+
await this.hooks.emit(HOOK_TYPES.AGENT_INITIALIZED, {
|
|
73613
|
+
sessionId: this.sessionId,
|
|
73614
|
+
agent: this
|
|
73615
|
+
});
|
|
72972
73616
|
}
|
|
72973
73617
|
/**
|
|
72974
73618
|
* Initialize tools with configuration
|
|
@@ -73020,7 +73664,7 @@ var init_ProbeAgent = __esm({
|
|
|
73020
73664
|
}
|
|
73021
73665
|
const anthropicApiKey = process.env.ANTHROPIC_API_KEY;
|
|
73022
73666
|
const openaiApiKey = process.env.OPENAI_API_KEY;
|
|
73023
|
-
const googleApiKey = process.env.GOOGLE_API_KEY;
|
|
73667
|
+
const googleApiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY || process.env.GOOGLE_API_KEY;
|
|
73024
73668
|
const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
|
73025
73669
|
const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
73026
73670
|
const awsRegion = process.env.AWS_REGION;
|
|
@@ -73068,7 +73712,7 @@ var init_ProbeAgent = __esm({
|
|
|
73068
73712
|
} else if (awsAccessKeyId && awsSecretAccessKey && awsRegion || awsApiKey) {
|
|
73069
73713
|
this.initializeBedrockModel(awsAccessKeyId, awsSecretAccessKey, awsRegion, awsSessionToken, awsApiKey, awsBedrockBaseUrl, modelName);
|
|
73070
73714
|
} else {
|
|
73071
|
-
throw new Error("No API key provided. Please set ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION), or AWS_BEDROCK_API_KEY environment variables.");
|
|
73715
|
+
throw new Error("No API key provided. Please set ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY (or GOOGLE_API_KEY), AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION), or AWS_BEDROCK_API_KEY environment variables.");
|
|
73072
73716
|
}
|
|
73073
73717
|
}
|
|
73074
73718
|
/**
|
|
@@ -73706,6 +74350,12 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
73706
74350
|
options = schemaOrOptions || {};
|
|
73707
74351
|
}
|
|
73708
74352
|
try {
|
|
74353
|
+
const oldHistoryLength = this.history.length;
|
|
74354
|
+
await this.hooks.emit(HOOK_TYPES.MESSAGE_USER, {
|
|
74355
|
+
sessionId: this.sessionId,
|
|
74356
|
+
message,
|
|
74357
|
+
images
|
|
74358
|
+
});
|
|
73709
74359
|
const systemMessage = await this.getSystemMessage();
|
|
73710
74360
|
let userMessage = { role: "user", content: message.trim() };
|
|
73711
74361
|
if (images && images.length > 0) {
|
|
@@ -73791,6 +74441,9 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
73791
74441
|
});
|
|
73792
74442
|
for await (const delta of result.textStream) {
|
|
73793
74443
|
assistantResponseContent += delta;
|
|
74444
|
+
if (options.onStream) {
|
|
74445
|
+
options.onStream(delta);
|
|
74446
|
+
}
|
|
73794
74447
|
}
|
|
73795
74448
|
const usage = await result.usage;
|
|
73796
74449
|
if (usage) {
|
|
@@ -73855,6 +74508,13 @@ You are working with a repository located at: ${searchDirectory}
|
|
|
73855
74508
|
const validation = attemptCompletionSchema.safeParse(params);
|
|
73856
74509
|
if (validation.success) {
|
|
73857
74510
|
finalResult = validation.data.result;
|
|
74511
|
+
if (options.onStream && finalResult) {
|
|
74512
|
+
const chunkSize = 50;
|
|
74513
|
+
for (let i3 = 0; i3 < finalResult.length; i3 += chunkSize) {
|
|
74514
|
+
const chunk = finalResult.slice(i3, Math.min(i3 + chunkSize, finalResult.length));
|
|
74515
|
+
options.onStream(chunk);
|
|
74516
|
+
}
|
|
74517
|
+
}
|
|
73858
74518
|
if (this.debug) console.log(`[DEBUG] Task completed successfully with result: ${finalResult.substring(0, 100)}...`);
|
|
73859
74519
|
} else {
|
|
73860
74520
|
console.error(`[ERROR] Invalid attempt_completion parameters:`, validation.error);
|
|
@@ -73929,7 +74589,9 @@ ${toolResultContent}
|
|
|
73929
74589
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
73930
74590
|
name: toolName,
|
|
73931
74591
|
args: toolParams,
|
|
73932
|
-
status: "started"
|
|
74592
|
+
status: "started",
|
|
74593
|
+
pauseStream: true
|
|
74594
|
+
// Signal to pause text streaming
|
|
73933
74595
|
});
|
|
73934
74596
|
const executeToolCall = async () => {
|
|
73935
74597
|
if (toolName === "delegate") {
|
|
@@ -74113,6 +74775,18 @@ IMPORTANT: When using <attempt_complete>, this must be the ONLY content in your
|
|
|
74113
74775
|
}
|
|
74114
74776
|
}
|
|
74115
74777
|
this.tokenCounter.updateHistory(this.history);
|
|
74778
|
+
try {
|
|
74779
|
+
const messagesToSave = currentMessages.slice(oldHistoryLength);
|
|
74780
|
+
for (const message2 of messagesToSave) {
|
|
74781
|
+
await this.storageAdapter.saveMessage(this.sessionId, message2);
|
|
74782
|
+
await this.hooks.emit(HOOK_TYPES.STORAGE_SAVE, {
|
|
74783
|
+
sessionId: this.sessionId,
|
|
74784
|
+
message: message2
|
|
74785
|
+
});
|
|
74786
|
+
}
|
|
74787
|
+
} catch (error2) {
|
|
74788
|
+
console.error(`[ERROR] Failed to save messages to storage:`, error2);
|
|
74789
|
+
}
|
|
74116
74790
|
const reachedMaxIterations = currentIteration >= maxIterations && !completionAttempted;
|
|
74117
74791
|
if (options.schema && !options._schemaFormatted && !completionAttempted && !reachedMaxIterations) {
|
|
74118
74792
|
if (this.debug) {
|
|
@@ -74477,10 +75151,18 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
74477
75151
|
/**
|
|
74478
75152
|
* Clear conversation history and reset counters
|
|
74479
75153
|
*/
|
|
74480
|
-
clearHistory() {
|
|
75154
|
+
async clearHistory() {
|
|
75155
|
+
try {
|
|
75156
|
+
await this.storageAdapter.clearHistory(this.sessionId);
|
|
75157
|
+
} catch (error2) {
|
|
75158
|
+
console.error(`[ERROR] Failed to clear history in storage:`, error2);
|
|
75159
|
+
}
|
|
74481
75160
|
this.history = [];
|
|
74482
75161
|
this.tokenCounter.clear();
|
|
74483
75162
|
clearToolExecutionData(this.sessionId);
|
|
75163
|
+
await this.hooks.emit(HOOK_TYPES.STORAGE_CLEAR, {
|
|
75164
|
+
sessionId: this.sessionId
|
|
75165
|
+
});
|
|
74484
75166
|
if (this.debug) {
|
|
74485
75167
|
console.log(`[DEBUG] Cleared conversation history and reset counters for session ${this.sessionId}`);
|
|
74486
75168
|
}
|
|
@@ -74739,13 +75421,34 @@ var init_simpleTelemetry = __esm({
|
|
|
74739
75421
|
}
|
|
74740
75422
|
});
|
|
74741
75423
|
|
|
75424
|
+
// src/agent/storage/index.js
|
|
75425
|
+
var init_storage = __esm({
|
|
75426
|
+
"src/agent/storage/index.js"() {
|
|
75427
|
+
"use strict";
|
|
75428
|
+
init_StorageAdapter();
|
|
75429
|
+
init_InMemoryStorageAdapter();
|
|
75430
|
+
}
|
|
75431
|
+
});
|
|
75432
|
+
|
|
75433
|
+
// src/agent/hooks/index.js
|
|
75434
|
+
var init_hooks = __esm({
|
|
75435
|
+
"src/agent/hooks/index.js"() {
|
|
75436
|
+
"use strict";
|
|
75437
|
+
init_HookManager();
|
|
75438
|
+
}
|
|
75439
|
+
});
|
|
75440
|
+
|
|
74742
75441
|
// src/index.js
|
|
74743
75442
|
var index_exports = {};
|
|
74744
75443
|
__export(index_exports, {
|
|
74745
75444
|
DEFAULT_SYSTEM_MESSAGE: () => DEFAULT_SYSTEM_MESSAGE,
|
|
75445
|
+
HOOK_TYPES: () => HOOK_TYPES,
|
|
75446
|
+
HookManager: () => HookManager,
|
|
75447
|
+
InMemoryStorageAdapter: () => InMemoryStorageAdapter,
|
|
74746
75448
|
ProbeAgent: () => ProbeAgent,
|
|
74747
75449
|
SimpleAppTracer: () => SimpleAppTracer,
|
|
74748
75450
|
SimpleTelemetry: () => SimpleTelemetry,
|
|
75451
|
+
StorageAdapter: () => StorageAdapter,
|
|
74749
75452
|
attemptCompletionSchema: () => attemptCompletionSchema,
|
|
74750
75453
|
attemptCompletionToolDefinition: () => attemptCompletionToolDefinition,
|
|
74751
75454
|
bashSchema: () => bashSchema,
|
|
@@ -74795,15 +75498,21 @@ var init_index = __esm({
|
|
|
74795
75498
|
init_ProbeAgent();
|
|
74796
75499
|
init_simpleTelemetry();
|
|
74797
75500
|
init_probeTool();
|
|
75501
|
+
init_storage();
|
|
75502
|
+
init_hooks();
|
|
74798
75503
|
}
|
|
74799
75504
|
});
|
|
74800
75505
|
init_index();
|
|
74801
75506
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74802
75507
|
0 && (module.exports = {
|
|
74803
75508
|
DEFAULT_SYSTEM_MESSAGE,
|
|
75509
|
+
HOOK_TYPES,
|
|
75510
|
+
HookManager,
|
|
75511
|
+
InMemoryStorageAdapter,
|
|
74804
75512
|
ProbeAgent,
|
|
74805
75513
|
SimpleAppTracer,
|
|
74806
75514
|
SimpleTelemetry,
|
|
75515
|
+
StorageAdapter,
|
|
74807
75516
|
attemptCompletionSchema,
|
|
74808
75517
|
attemptCompletionToolDefinition,
|
|
74809
75518
|
bashSchema,
|