@dexto/core 1.5.2 → 1.5.4
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/agent/DextoAgent.cjs +296 -2
- package/dist/agent/DextoAgent.d.ts +114 -0
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +287 -2
- package/dist/agent/schemas.d.ts +93 -21
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/approval/manager.cjs +16 -0
- package/dist/approval/manager.d.ts +10 -0
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +16 -0
- package/dist/approval/types.d.ts +11 -0
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/context/compaction/overflow.cjs +6 -10
- package/dist/context/compaction/overflow.d.ts +14 -11
- package/dist/context/compaction/overflow.d.ts.map +1 -1
- package/dist/context/compaction/overflow.js +6 -10
- package/dist/context/compaction/providers/reactive-overflow-provider.cjs +15 -0
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts +15 -0
- package/dist/context/compaction/providers/reactive-overflow-provider.d.ts.map +1 -1
- package/dist/context/compaction/providers/reactive-overflow-provider.js +15 -0
- package/dist/context/compaction/schemas.cjs +22 -2
- package/dist/context/compaction/schemas.d.ts +45 -0
- package/dist/context/compaction/schemas.d.ts.map +1 -1
- package/dist/context/compaction/schemas.js +22 -2
- package/dist/context/compaction/strategies/reactive-overflow.cjs +166 -26
- package/dist/context/compaction/strategies/reactive-overflow.d.ts +21 -0
- package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +1 -1
- package/dist/context/compaction/strategies/reactive-overflow.js +166 -26
- package/dist/context/manager.cjs +278 -31
- package/dist/context/manager.d.ts +192 -5
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +285 -32
- package/dist/context/types.d.ts +6 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +77 -11
- package/dist/context/utils.d.ts +86 -8
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +71 -11
- package/dist/events/index.cjs +7 -1
- package/dist/events/index.d.ts +58 -7
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +7 -1
- package/dist/filesystem/filesystem-service.cjs +18 -15
- package/dist/filesystem/filesystem-service.d.ts +3 -3
- package/dist/filesystem/filesystem-service.d.ts.map +1 -1
- package/dist/filesystem/filesystem-service.js +18 -15
- package/dist/filesystem/path-validator.cjs +16 -7
- package/dist/filesystem/path-validator.d.ts +10 -3
- package/dist/filesystem/path-validator.d.ts.map +1 -1
- package/dist/filesystem/path-validator.js +16 -7
- package/dist/filesystem/types.d.ts +4 -0
- package/dist/filesystem/types.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.cjs +19 -1
- package/dist/llm/executor/stream-processor.d.ts +3 -0
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +19 -1
- package/dist/llm/executor/turn-executor.cjs +219 -30
- package/dist/llm/executor/turn-executor.d.ts +62 -10
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +219 -30
- package/dist/llm/executor/types.d.ts +28 -0
- package/dist/llm/executor/types.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.cjs +36 -28
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +36 -28
- package/dist/llm/services/factory.cjs +3 -2
- package/dist/llm/services/factory.d.ts +3 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +3 -2
- package/dist/llm/services/vercel.cjs +34 -6
- package/dist/llm/services/vercel.d.ts +23 -3
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +34 -6
- package/dist/logger/v2/schemas.cjs +4 -0
- package/dist/logger/v2/schemas.d.ts +16 -0
- package/dist/logger/v2/schemas.d.ts.map +1 -1
- package/dist/logger/v2/schemas.js +4 -0
- package/dist/logger/v2/transport-factory.cjs +4 -1
- package/dist/logger/v2/transport-factory.d.ts.map +1 -1
- package/dist/logger/v2/transport-factory.js +4 -1
- package/dist/logger/v2/transports/silent-transport.cjs +33 -0
- package/dist/logger/v2/transports/silent-transport.d.ts +15 -0
- package/dist/logger/v2/transports/silent-transport.d.ts.map +1 -0
- package/dist/logger/v2/transports/silent-transport.js +10 -0
- package/dist/session/chat-session.cjs +20 -11
- package/dist/session/chat-session.d.ts +9 -4
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +20 -11
- package/dist/session/compaction-service.cjs +139 -0
- package/dist/session/compaction-service.d.ts +81 -0
- package/dist/session/compaction-service.d.ts.map +1 -0
- package/dist/session/compaction-service.js +106 -0
- package/dist/session/session-manager.cjs +146 -0
- package/dist/session/session-manager.d.ts +50 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +146 -0
- package/dist/session/title-generator.cjs +2 -2
- package/dist/session/title-generator.js +2 -2
- package/dist/systemPrompt/in-built-prompts.cjs +36 -0
- package/dist/systemPrompt/in-built-prompts.d.ts +18 -1
- package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
- package/dist/systemPrompt/in-built-prompts.js +25 -0
- package/dist/systemPrompt/manager.cjs +22 -0
- package/dist/systemPrompt/manager.d.ts +10 -0
- package/dist/systemPrompt/manager.d.ts.map +1 -1
- package/dist/systemPrompt/manager.js +22 -0
- package/dist/systemPrompt/registry.cjs +2 -1
- package/dist/systemPrompt/registry.d.ts +1 -1
- package/dist/systemPrompt/registry.d.ts.map +1 -1
- package/dist/systemPrompt/registry.js +2 -1
- package/dist/systemPrompt/schemas.cjs +7 -0
- package/dist/systemPrompt/schemas.d.ts +13 -13
- package/dist/systemPrompt/schemas.d.ts.map +1 -1
- package/dist/systemPrompt/schemas.js +7 -0
- package/dist/tools/error-codes.cjs +1 -0
- package/dist/tools/error-codes.d.ts +1 -0
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +1 -0
- package/dist/tools/errors.cjs +17 -0
- package/dist/tools/errors.d.ts +9 -0
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +17 -0
- package/dist/tools/internal-tools/provider.cjs +3 -2
- package/dist/tools/internal-tools/provider.d.ts +1 -1
- package/dist/tools/internal-tools/provider.d.ts.map +1 -1
- package/dist/tools/internal-tools/provider.js +3 -2
- package/dist/tools/tool-manager.cjs +77 -4
- package/dist/tools/tool-manager.d.ts +18 -0
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +78 -5
- package/dist/tools/types.d.ts +5 -3
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -494,6 +494,152 @@ class SessionManager {
|
|
|
494
494
|
sessionTTL: this.sessionTTL
|
|
495
495
|
};
|
|
496
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Get the raw session data for a session ID.
|
|
499
|
+
* This is used for accessing continuation fields and other metadata.
|
|
500
|
+
*
|
|
501
|
+
* @param sessionId The session ID
|
|
502
|
+
* @returns Session data if found, undefined otherwise
|
|
503
|
+
*/
|
|
504
|
+
async getSessionData(sessionId) {
|
|
505
|
+
await this.ensureInitialized();
|
|
506
|
+
const sessionKey = `session:${sessionId}`;
|
|
507
|
+
return await this.services.storageManager.getDatabase().get(sessionKey);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Creates a continuation session from a compacted session.
|
|
511
|
+
* The new session will have the summary as its first message.
|
|
512
|
+
*
|
|
513
|
+
* @param fromSessionId The session being compacted
|
|
514
|
+
* @returns The new session ID and ChatSession
|
|
515
|
+
*/
|
|
516
|
+
async createContinuationSession(fromSessionId) {
|
|
517
|
+
await this.ensureInitialized();
|
|
518
|
+
const fromSessionData = await this.getSessionData(fromSessionId);
|
|
519
|
+
if (!fromSessionData) {
|
|
520
|
+
throw SessionError.notFound(fromSessionId);
|
|
521
|
+
}
|
|
522
|
+
const activeSessionKeys = await this.services.storageManager.getDatabase().list("session:");
|
|
523
|
+
if (activeSessionKeys.length >= this.maxSessions) {
|
|
524
|
+
throw SessionError.maxSessionsExceeded(activeSessionKeys.length, this.maxSessions);
|
|
525
|
+
}
|
|
526
|
+
const newSessionId = randomUUID();
|
|
527
|
+
const originalLLMConfig = this.services.stateManager.getRuntimeConfig(fromSessionId).llm;
|
|
528
|
+
this.services.stateManager.updateLLM(originalLLMConfig, newSessionId);
|
|
529
|
+
const parentCompactionCount = fromSessionData.compactionCount ?? 0;
|
|
530
|
+
const newSessionData = {
|
|
531
|
+
id: newSessionId,
|
|
532
|
+
createdAt: Date.now(),
|
|
533
|
+
lastActivity: Date.now(),
|
|
534
|
+
messageCount: 0,
|
|
535
|
+
continuedFrom: fromSessionId,
|
|
536
|
+
compactionCount: parentCompactionCount + 1,
|
|
537
|
+
...fromSessionData.userId !== void 0 && { userId: fromSessionData.userId },
|
|
538
|
+
...fromSessionData.metadata && {
|
|
539
|
+
metadata: {
|
|
540
|
+
...fromSessionData.metadata,
|
|
541
|
+
title: fromSessionData.metadata?.title
|
|
542
|
+
// Preserve title
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
const sessionKey = `session:${newSessionId}`;
|
|
547
|
+
try {
|
|
548
|
+
await this.services.storageManager.getDatabase().set(sessionKey, newSessionData);
|
|
549
|
+
await this.services.storageManager.getCache().set(sessionKey, newSessionData, this.sessionTTL / 1e3);
|
|
550
|
+
} catch (error) {
|
|
551
|
+
this.services.stateManager.clearSessionOverride(newSessionId);
|
|
552
|
+
throw error;
|
|
553
|
+
}
|
|
554
|
+
const session = new ChatSession(
|
|
555
|
+
{ ...this.services, sessionManager: this },
|
|
556
|
+
newSessionId,
|
|
557
|
+
this.logger
|
|
558
|
+
);
|
|
559
|
+
try {
|
|
560
|
+
await session.init();
|
|
561
|
+
} catch (error) {
|
|
562
|
+
session.dispose();
|
|
563
|
+
await this.services.storageManager.getDatabase().delete(sessionKey);
|
|
564
|
+
await this.services.storageManager.getCache().delete(sessionKey);
|
|
565
|
+
this.services.stateManager.clearSessionOverride(newSessionId);
|
|
566
|
+
throw error;
|
|
567
|
+
}
|
|
568
|
+
this.sessions.set(newSessionId, session);
|
|
569
|
+
this.logger.info(
|
|
570
|
+
`Created continuation session ${newSessionId} from compacted session ${fromSessionId}`
|
|
571
|
+
);
|
|
572
|
+
return { sessionId: newSessionId, session };
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Marks a session as compacted and links it to its continuation session.
|
|
576
|
+
*
|
|
577
|
+
* @param sessionId The session being compacted
|
|
578
|
+
* @param continuedToId The new session created from compaction
|
|
579
|
+
*/
|
|
580
|
+
async markSessionCompacted(sessionId, continuedToId) {
|
|
581
|
+
await this.ensureInitialized();
|
|
582
|
+
const sessionKey = `session:${sessionId}`;
|
|
583
|
+
const sessionData = await this.services.storageManager.getDatabase().get(sessionKey);
|
|
584
|
+
if (!sessionData) {
|
|
585
|
+
throw SessionError.notFound(sessionId);
|
|
586
|
+
}
|
|
587
|
+
sessionData.continuedTo = continuedToId;
|
|
588
|
+
sessionData.compactedAt = Date.now();
|
|
589
|
+
sessionData.lastActivity = Date.now();
|
|
590
|
+
await this.services.storageManager.getDatabase().set(sessionKey, sessionData);
|
|
591
|
+
await this.services.storageManager.getCache().set(sessionKey, sessionData, this.sessionTTL / 1e3);
|
|
592
|
+
this.logger.debug(`Marked session ${sessionId} as compacted \u2192 ${continuedToId}`);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Gets the compaction count for a session.
|
|
596
|
+
* Returns 0 if the session has never been compacted.
|
|
597
|
+
*
|
|
598
|
+
* @param sessionId The session ID
|
|
599
|
+
* @returns Number of times this session chain has been compacted
|
|
600
|
+
*/
|
|
601
|
+
async getCompactionCount(sessionId) {
|
|
602
|
+
const sessionData = await this.getSessionData(sessionId);
|
|
603
|
+
return sessionData?.compactionCount ?? 0;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Gets the chain of linked sessions (ancestors and descendants).
|
|
607
|
+
* Returns sessions in chronological order (oldest first).
|
|
608
|
+
*
|
|
609
|
+
* @param sessionId Any session ID in the chain
|
|
610
|
+
* @returns Array of session data in the chain, ordered chronologically
|
|
611
|
+
*/
|
|
612
|
+
async getSessionChain(sessionId) {
|
|
613
|
+
await this.ensureInitialized();
|
|
614
|
+
const chain = [];
|
|
615
|
+
const visited = /* @__PURE__ */ new Set();
|
|
616
|
+
let currentData = await this.getSessionData(sessionId);
|
|
617
|
+
if (!currentData) {
|
|
618
|
+
return [];
|
|
619
|
+
}
|
|
620
|
+
while (currentData?.continuedFrom && !visited.has(currentData.continuedFrom)) {
|
|
621
|
+
visited.add(currentData.id);
|
|
622
|
+
const parent = await this.getSessionData(currentData.continuedFrom);
|
|
623
|
+
if (!parent) {
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
currentData = parent;
|
|
627
|
+
}
|
|
628
|
+
if (currentData && !visited.has(currentData.id)) {
|
|
629
|
+
visited.add(currentData.id);
|
|
630
|
+
}
|
|
631
|
+
visited.clear();
|
|
632
|
+
while (currentData && !visited.has(currentData.id)) {
|
|
633
|
+
visited.add(currentData.id);
|
|
634
|
+
chain.push(currentData);
|
|
635
|
+
if (currentData.continuedTo) {
|
|
636
|
+
currentData = await this.getSessionData(currentData.continuedTo);
|
|
637
|
+
} else {
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return chain;
|
|
642
|
+
}
|
|
497
643
|
/**
|
|
498
644
|
* Cleanup all sessions and resources.
|
|
499
645
|
* This should be called when shutting down the application.
|
|
@@ -52,11 +52,11 @@ async function generateSessionTitle(config, toolManager, systemPromptManager, re
|
|
|
52
52
|
"Message:",
|
|
53
53
|
sanitizeUserText(userText, 512)
|
|
54
54
|
].join("\n");
|
|
55
|
-
const
|
|
55
|
+
const streamResult = await tempService.stream(
|
|
56
56
|
instruction,
|
|
57
57
|
controller ? { signal: controller.signal } : void 0
|
|
58
58
|
);
|
|
59
|
-
const processed = postProcessTitle(
|
|
59
|
+
const processed = postProcessTitle(streamResult.text);
|
|
60
60
|
if (!processed) {
|
|
61
61
|
return { error: "LLM returned empty title" };
|
|
62
62
|
}
|
|
@@ -29,11 +29,11 @@ async function generateSessionTitle(config, toolManager, systemPromptManager, re
|
|
|
29
29
|
"Message:",
|
|
30
30
|
sanitizeUserText(userText, 512)
|
|
31
31
|
].join("\n");
|
|
32
|
-
const
|
|
32
|
+
const streamResult = await tempService.stream(
|
|
33
33
|
instruction,
|
|
34
34
|
controller ? { signal: controller.signal } : void 0
|
|
35
35
|
);
|
|
36
|
-
const processed = postProcessTitle(
|
|
36
|
+
const processed = postProcessTitle(streamResult.text);
|
|
37
37
|
if (!processed) {
|
|
38
38
|
return { error: "LLM returned empty title" };
|
|
39
39
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,10 +17,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var in_built_prompts_exports = {};
|
|
20
30
|
__export(in_built_prompts_exports, {
|
|
21
31
|
getCurrentDate: () => getCurrentDate,
|
|
32
|
+
getEnvironmentInfo: () => getEnvironmentInfo,
|
|
22
33
|
getResourceData: () => getResourceData
|
|
23
34
|
});
|
|
24
35
|
module.exports = __toCommonJS(in_built_prompts_exports);
|
|
@@ -26,6 +37,30 @@ async function getCurrentDate(_context) {
|
|
|
26
37
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
27
38
|
return `<date>Current date: ${date}</date>`;
|
|
28
39
|
}
|
|
40
|
+
async function getEnvironmentInfo(_context) {
|
|
41
|
+
if (typeof process === "undefined" || !process.cwd) {
|
|
42
|
+
return "<environment>Environment info not available in browser context</environment>";
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const [{ existsSync }, { platform }, { join }] = await Promise.all([
|
|
46
|
+
import("fs"),
|
|
47
|
+
import("os"),
|
|
48
|
+
import("path")
|
|
49
|
+
]);
|
|
50
|
+
const cwd = process.cwd();
|
|
51
|
+
const os = platform();
|
|
52
|
+
const isGitRepo = existsSync(join(cwd, ".git"));
|
|
53
|
+
const shell = process.env.SHELL || (os === "win32" ? "cmd.exe" : "/bin/sh");
|
|
54
|
+
return `<environment>
|
|
55
|
+
<cwd>${cwd}</cwd>
|
|
56
|
+
<platform>${os}</platform>
|
|
57
|
+
<is_git_repo>${isGitRepo}</is_git_repo>
|
|
58
|
+
<shell>${shell}</shell>
|
|
59
|
+
</environment>`;
|
|
60
|
+
} catch {
|
|
61
|
+
return "<environment>Environment info not available</environment>";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
29
64
|
async function getResourceData(context) {
|
|
30
65
|
const resources = await context.mcpManager.listAllResources();
|
|
31
66
|
if (!resources || resources.length === 0) {
|
|
@@ -58,5 +93,6 @@ ${parts.join("\n")}
|
|
|
58
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
94
|
0 && (module.exports = {
|
|
60
95
|
getCurrentDate,
|
|
96
|
+
getEnvironmentInfo,
|
|
61
97
|
getResourceData
|
|
62
98
|
});
|
|
@@ -10,8 +10,25 @@ import { DynamicContributorContext } from './types.js';
|
|
|
10
10
|
* - Place all dynamic prompt-generating functions in this file.
|
|
11
11
|
* - Also update the `registry.ts` file to register the new function.
|
|
12
12
|
* - Use XML tags to indicate the start and end of the dynamic prompt - they are known to improve performance
|
|
13
|
-
* - Each function should be named clearly to reflect its purpose (e.g., getCurrentDate,
|
|
13
|
+
* - Each function should be named clearly to reflect its purpose (e.g., getCurrentDate, getEnvironmentInfo).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current date (without time to prevent KV-cache invalidation).
|
|
14
17
|
*/
|
|
15
18
|
export declare function getCurrentDate(_context: DynamicContributorContext): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns environment information to help agents understand their execution context.
|
|
21
|
+
* This is kept separate from date to optimize caching (env info rarely changes).
|
|
22
|
+
*
|
|
23
|
+
* Includes:
|
|
24
|
+
* - Working directory (cwd)
|
|
25
|
+
* - Platform (os)
|
|
26
|
+
* - Whether the cwd is a git repository
|
|
27
|
+
* - Default shell
|
|
28
|
+
*
|
|
29
|
+
* Note: This function uses dynamic imports for Node.js modules to maintain browser compatibility.
|
|
30
|
+
* In browser environments, it returns a placeholder message.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getEnvironmentInfo(_context: DynamicContributorContext): Promise<string>;
|
|
16
33
|
export declare function getResourceData(context: DynamicContributorContext): Promise<string>;
|
|
17
34
|
//# sourceMappingURL=in-built-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-built-prompts.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/in-built-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;GAYG;AAEH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"in-built-prompts.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/in-built-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B7F;AAGD,wBAAsB,eAAe,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiCzF"}
|
|
@@ -3,6 +3,30 @@ async function getCurrentDate(_context) {
|
|
|
3
3
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
4
4
|
return `<date>Current date: ${date}</date>`;
|
|
5
5
|
}
|
|
6
|
+
async function getEnvironmentInfo(_context) {
|
|
7
|
+
if (typeof process === "undefined" || !process.cwd) {
|
|
8
|
+
return "<environment>Environment info not available in browser context</environment>";
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const [{ existsSync }, { platform }, { join }] = await Promise.all([
|
|
12
|
+
import("fs"),
|
|
13
|
+
import("os"),
|
|
14
|
+
import("path")
|
|
15
|
+
]);
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const os = platform();
|
|
18
|
+
const isGitRepo = existsSync(join(cwd, ".git"));
|
|
19
|
+
const shell = process.env.SHELL || (os === "win32" ? "cmd.exe" : "/bin/sh");
|
|
20
|
+
return `<environment>
|
|
21
|
+
<cwd>${cwd}</cwd>
|
|
22
|
+
<platform>${os}</platform>
|
|
23
|
+
<is_git_repo>${isGitRepo}</is_git_repo>
|
|
24
|
+
<shell>${shell}</shell>
|
|
25
|
+
</environment>`;
|
|
26
|
+
} catch {
|
|
27
|
+
return "<environment>Environment info not available</environment>";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
6
30
|
async function getResourceData(context) {
|
|
7
31
|
const resources = await context.mcpManager.listAllResources();
|
|
8
32
|
if (!resources || resources.length === 0) {
|
|
@@ -34,5 +58,6 @@ ${parts.join("\n")}
|
|
|
34
58
|
}
|
|
35
59
|
export {
|
|
36
60
|
getCurrentDate,
|
|
61
|
+
getEnvironmentInfo,
|
|
37
62
|
getResourceData
|
|
38
63
|
};
|
|
@@ -112,6 +112,28 @@ class SystemPromptManager {
|
|
|
112
112
|
getContributors() {
|
|
113
113
|
return this.contributors;
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Add a contributor dynamically after construction.
|
|
117
|
+
* The contributor will be inserted in priority order.
|
|
118
|
+
*/
|
|
119
|
+
addContributor(contributor) {
|
|
120
|
+
this.contributors.push(contributor);
|
|
121
|
+
this.contributors.sort((a, b) => a.priority - b.priority);
|
|
122
|
+
this.logger.debug(
|
|
123
|
+
`Added contributor: ${contributor.id} (priority: ${contributor.priority})`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Remove a contributor by ID.
|
|
128
|
+
* Returns true if removed, false if not found.
|
|
129
|
+
*/
|
|
130
|
+
removeContributor(id) {
|
|
131
|
+
const index = this.contributors.findIndex((c) => c.id === id);
|
|
132
|
+
if (index === -1) return false;
|
|
133
|
+
this.contributors.splice(index, 1);
|
|
134
|
+
this.logger.debug(`Removed contributor: ${id}`);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
115
137
|
}
|
|
116
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117
139
|
0 && (module.exports = {
|
|
@@ -21,5 +21,15 @@ export declare class SystemPromptManager {
|
|
|
21
21
|
* Expose current list of contributors (for inspection or testing).
|
|
22
22
|
*/
|
|
23
23
|
getContributors(): SystemPromptContributor[];
|
|
24
|
+
/**
|
|
25
|
+
* Add a contributor dynamically after construction.
|
|
26
|
+
* The contributor will be inserted in priority order.
|
|
27
|
+
*/
|
|
28
|
+
addContributor(contributor: SystemPromptContributor): void;
|
|
29
|
+
/**
|
|
30
|
+
* Remove a contributor by ID.
|
|
31
|
+
* Returns true if removed, false if not found.
|
|
32
|
+
*/
|
|
33
|
+
removeContributor(id: string): boolean;
|
|
24
34
|
}
|
|
25
35
|
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAA8B,MAAM,cAAc,CAAC;AAG5F,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D;;;GAGG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAe;gBAIzB,MAAM,EAAE,2BAA2B,EACnC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,MAAM,EAAE,YAAY;IAsCxB,OAAO,CAAC,iBAAiB;IAkCzB;;OAEG;IACG,KAAK,CAAC,GAAG,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IAa5D;;OAEG;IACH,eAAe,IAAI,uBAAuB,EAAE;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAA8B,MAAM,cAAc,CAAC;AAG5F,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D;;;GAGG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAe;gBAIzB,MAAM,EAAE,2BAA2B,EACnC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,MAAM,EAAE,YAAY;IAsCxB,OAAO,CAAC,iBAAiB;IAkCzB;;OAEG;IACG,KAAK,CAAC,GAAG,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IAa5D;;OAEG;IACH,eAAe,IAAI,uBAAuB,EAAE;IAI5C;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,uBAAuB,GAAG,IAAI;IAQ1D;;;OAGG;IACH,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;CAOzC"}
|
|
@@ -90,6 +90,28 @@ class SystemPromptManager {
|
|
|
90
90
|
getContributors() {
|
|
91
91
|
return this.contributors;
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Add a contributor dynamically after construction.
|
|
95
|
+
* The contributor will be inserted in priority order.
|
|
96
|
+
*/
|
|
97
|
+
addContributor(contributor) {
|
|
98
|
+
this.contributors.push(contributor);
|
|
99
|
+
this.contributors.sort((a, b) => a.priority - b.priority);
|
|
100
|
+
this.logger.debug(
|
|
101
|
+
`Added contributor: ${contributor.id} (priority: ${contributor.priority})`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Remove a contributor by ID.
|
|
106
|
+
* Returns true if removed, false if not found.
|
|
107
|
+
*/
|
|
108
|
+
removeContributor(id) {
|
|
109
|
+
const index = this.contributors.findIndex((c) => c.id === id);
|
|
110
|
+
if (index === -1) return false;
|
|
111
|
+
this.contributors.splice(index, 1);
|
|
112
|
+
this.logger.debug(`Removed contributor: ${id}`);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
93
115
|
}
|
|
94
116
|
export {
|
|
95
117
|
SystemPromptManager
|
|
@@ -34,9 +34,10 @@ __export(registry_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(registry_exports);
|
|
36
36
|
var handlers = __toESM(require("./in-built-prompts.js"), 1);
|
|
37
|
-
const PROMPT_GENERATOR_SOURCES = ["date", "resources"];
|
|
37
|
+
const PROMPT_GENERATOR_SOURCES = ["date", "env", "resources"];
|
|
38
38
|
const PROMPT_GENERATOR_REGISTRY = {
|
|
39
39
|
date: handlers.getCurrentDate,
|
|
40
|
+
env: handlers.getEnvironmentInfo,
|
|
40
41
|
resources: handlers.getResourceData
|
|
41
42
|
};
|
|
42
43
|
function getPromptGenerator(source) {
|
|
@@ -3,7 +3,7 @@ import { DynamicContributorContext } from './types.js';
|
|
|
3
3
|
* This file contains the registry of all the functions that can generate dynamic prompt pieces at runtime.
|
|
4
4
|
*/
|
|
5
5
|
export type DynamicPromptGenerator = (context: DynamicContributorContext) => Promise<string>;
|
|
6
|
-
export declare const PROMPT_GENERATOR_SOURCES: readonly ["date", "resources"];
|
|
6
|
+
export declare const PROMPT_GENERATOR_SOURCES: readonly ["date", "env", "resources"];
|
|
7
7
|
export type PromptGeneratorSource = (typeof PROMPT_GENERATOR_SOURCES)[number];
|
|
8
8
|
export declare const PROMPT_GENERATOR_REGISTRY: Record<PromptGeneratorSource, DynamicPromptGenerator>;
|
|
9
9
|
export declare function getPromptGenerator(source: PromptGeneratorSource): DynamicPromptGenerator | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAG7F,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAG7F,eAAO,MAAM,wBAAwB,uCAAwC,CAAC;AAE9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAG9E,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,CAI3F,CAAC;AAGF,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,qBAAqB,GAC9B,sBAAsB,GAAG,SAAS,CAEpC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "../chunk-PTJYTZNU.js";
|
|
2
2
|
import * as handlers from "./in-built-prompts.js";
|
|
3
|
-
const PROMPT_GENERATOR_SOURCES = ["date", "resources"];
|
|
3
|
+
const PROMPT_GENERATOR_SOURCES = ["date", "env", "resources"];
|
|
4
4
|
const PROMPT_GENERATOR_REGISTRY = {
|
|
5
5
|
date: handlers.getCurrentDate,
|
|
6
|
+
env: handlers.getEnvironmentInfo,
|
|
6
7
|
resources: handlers.getResourceData
|
|
7
8
|
};
|
|
8
9
|
function getPromptGenerator(source) {
|
|
@@ -102,6 +102,13 @@ const SystemPromptContributorsSchema = import_zod.z.object({
|
|
|
102
102
|
source: "date",
|
|
103
103
|
enabled: true
|
|
104
104
|
},
|
|
105
|
+
{
|
|
106
|
+
id: "env",
|
|
107
|
+
type: "dynamic",
|
|
108
|
+
priority: 15,
|
|
109
|
+
source: "env",
|
|
110
|
+
enabled: true
|
|
111
|
+
},
|
|
105
112
|
{
|
|
106
113
|
id: "resources",
|
|
107
114
|
type: "dynamic",
|
|
@@ -24,18 +24,18 @@ export declare const ContributorConfigSchema: z.ZodDiscriminatedUnion<"type", [z
|
|
|
24
24
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
25
25
|
} & {
|
|
26
26
|
type: z.ZodLiteral<"dynamic">;
|
|
27
|
-
source: z.ZodEnum<["date", "resources"]>;
|
|
27
|
+
source: z.ZodEnum<["date", "env", "resources"]>;
|
|
28
28
|
}, "strict", z.ZodTypeAny, {
|
|
29
29
|
type: "dynamic";
|
|
30
30
|
enabled: boolean;
|
|
31
31
|
id: string;
|
|
32
32
|
priority: number;
|
|
33
|
-
source: "date" | "resources";
|
|
33
|
+
source: "date" | "env" | "resources";
|
|
34
34
|
}, {
|
|
35
35
|
type: "dynamic";
|
|
36
36
|
id: string;
|
|
37
37
|
priority: number;
|
|
38
|
-
source: "date" | "resources";
|
|
38
|
+
source: "date" | "env" | "resources";
|
|
39
39
|
enabled?: boolean | undefined;
|
|
40
40
|
}>, z.ZodObject<{
|
|
41
41
|
id: z.ZodString;
|
|
@@ -118,18 +118,18 @@ export declare const SystemPromptContributorsSchema: z.ZodObject<{
|
|
|
118
118
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
119
119
|
} & {
|
|
120
120
|
type: z.ZodLiteral<"dynamic">;
|
|
121
|
-
source: z.ZodEnum<["date", "resources"]>;
|
|
121
|
+
source: z.ZodEnum<["date", "env", "resources"]>;
|
|
122
122
|
}, "strict", z.ZodTypeAny, {
|
|
123
123
|
type: "dynamic";
|
|
124
124
|
enabled: boolean;
|
|
125
125
|
id: string;
|
|
126
126
|
priority: number;
|
|
127
|
-
source: "date" | "resources";
|
|
127
|
+
source: "date" | "env" | "resources";
|
|
128
128
|
}, {
|
|
129
129
|
type: "dynamic";
|
|
130
130
|
id: string;
|
|
131
131
|
priority: number;
|
|
132
|
-
source: "date" | "resources";
|
|
132
|
+
source: "date" | "env" | "resources";
|
|
133
133
|
enabled?: boolean | undefined;
|
|
134
134
|
}>, z.ZodObject<{
|
|
135
135
|
id: z.ZodString;
|
|
@@ -196,7 +196,7 @@ export declare const SystemPromptContributorsSchema: z.ZodObject<{
|
|
|
196
196
|
enabled: boolean;
|
|
197
197
|
id: string;
|
|
198
198
|
priority: number;
|
|
199
|
-
source: "date" | "resources";
|
|
199
|
+
source: "date" | "env" | "resources";
|
|
200
200
|
} | {
|
|
201
201
|
type: "file";
|
|
202
202
|
options: {
|
|
@@ -222,7 +222,7 @@ export declare const SystemPromptContributorsSchema: z.ZodObject<{
|
|
|
222
222
|
type: "dynamic";
|
|
223
223
|
id: string;
|
|
224
224
|
priority: number;
|
|
225
|
-
source: "date" | "resources";
|
|
225
|
+
source: "date" | "env" | "resources";
|
|
226
226
|
enabled?: boolean | undefined;
|
|
227
227
|
} | {
|
|
228
228
|
type: "file";
|
|
@@ -273,18 +273,18 @@ export declare const SystemPromptConfigSchema: z.ZodBranded<z.ZodUnion<[z.ZodEff
|
|
|
273
273
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
274
274
|
} & {
|
|
275
275
|
type: z.ZodLiteral<"dynamic">;
|
|
276
|
-
source: z.ZodEnum<["date", "resources"]>;
|
|
276
|
+
source: z.ZodEnum<["date", "env", "resources"]>;
|
|
277
277
|
}, "strict", z.ZodTypeAny, {
|
|
278
278
|
type: "dynamic";
|
|
279
279
|
enabled: boolean;
|
|
280
280
|
id: string;
|
|
281
281
|
priority: number;
|
|
282
|
-
source: "date" | "resources";
|
|
282
|
+
source: "date" | "env" | "resources";
|
|
283
283
|
}, {
|
|
284
284
|
type: "dynamic";
|
|
285
285
|
id: string;
|
|
286
286
|
priority: number;
|
|
287
|
-
source: "date" | "resources";
|
|
287
|
+
source: "date" | "env" | "resources";
|
|
288
288
|
enabled?: boolean | undefined;
|
|
289
289
|
}>, z.ZodObject<{
|
|
290
290
|
id: z.ZodString;
|
|
@@ -351,7 +351,7 @@ export declare const SystemPromptConfigSchema: z.ZodBranded<z.ZodUnion<[z.ZodEff
|
|
|
351
351
|
enabled: boolean;
|
|
352
352
|
id: string;
|
|
353
353
|
priority: number;
|
|
354
|
-
source: "date" | "resources";
|
|
354
|
+
source: "date" | "env" | "resources";
|
|
355
355
|
} | {
|
|
356
356
|
type: "file";
|
|
357
357
|
options: {
|
|
@@ -377,7 +377,7 @@ export declare const SystemPromptConfigSchema: z.ZodBranded<z.ZodUnion<[z.ZodEff
|
|
|
377
377
|
type: "dynamic";
|
|
378
378
|
id: string;
|
|
379
379
|
priority: number;
|
|
380
|
-
source: "date" | "resources";
|
|
380
|
+
source: "date" | "env" | "resources";
|
|
381
381
|
enabled?: boolean | undefined;
|
|
382
382
|
} | {
|
|
383
383
|
type: "file";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0FxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkB/B,CAAC;AAGN,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAElF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0FxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkB/B,CAAC;AAGN,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAElF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B9B,CAAC;AAGd,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAUM,CAAC;AAG5C,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -27,6 +27,7 @@ var ToolErrorCode = /* @__PURE__ */ ((ToolErrorCode2) => {
|
|
|
27
27
|
ToolErrorCode2["EXECUTION_FAILED"] = "tools_execution_failed";
|
|
28
28
|
ToolErrorCode2["DIRECTORY_ACCESS_DENIED"] = "tools_directory_access_denied";
|
|
29
29
|
ToolErrorCode2["VALIDATION_FAILED"] = "tools_validation_failed";
|
|
30
|
+
ToolErrorCode2["FILE_MODIFIED_SINCE_PREVIEW"] = "tools_file_modified_since_preview";
|
|
30
31
|
ToolErrorCode2["CONFIRMATION_HANDLER_MISSING"] = "tools_confirmation_handler_missing";
|
|
31
32
|
ToolErrorCode2["CONFIRMATION_TIMEOUT"] = "tools_confirmation_timeout";
|
|
32
33
|
ToolErrorCode2["CONFIRMATION_CANCELLED"] = "tools_confirmation_cancelled";
|
|
@@ -8,6 +8,7 @@ export declare enum ToolErrorCode {
|
|
|
8
8
|
EXECUTION_FAILED = "tools_execution_failed",
|
|
9
9
|
DIRECTORY_ACCESS_DENIED = "tools_directory_access_denied",
|
|
10
10
|
VALIDATION_FAILED = "tools_validation_failed",
|
|
11
|
+
FILE_MODIFIED_SINCE_PREVIEW = "tools_file_modified_since_preview",
|
|
11
12
|
CONFIRMATION_HANDLER_MISSING = "tools_confirmation_handler_missing",
|
|
12
13
|
CONFIRMATION_TIMEOUT = "tools_confirmation_timeout",
|
|
13
14
|
CONFIRMATION_CANCELLED = "tools_confirmation_cancelled",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/tools/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,aAAa;IAErB,gBAAgB,2BAA2B;IAC3C,iBAAiB,4BAA4B;IAC7C,gBAAgB,2BAA2B;IAC3C,uBAAuB,kCAAkC;IAGzD,iBAAiB,4BAA4B;
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/tools/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,aAAa;IAErB,gBAAgB,2BAA2B;IAC3C,iBAAiB,4BAA4B;IAC7C,gBAAgB,2BAA2B;IAC3C,uBAAuB,kCAAkC;IAGzD,iBAAiB,4BAA4B;IAC7C,2BAA2B,sCAAsC;IAGjE,4BAA4B,uCAAuC;IACnE,oBAAoB,+BAA+B;IACnD,sBAAsB,iCAAiC;IAGvD,cAAc,yBAAyB;IACvC,iBAAiB,uBAAuB;IACxC,iBAAiB,uBAAuB;IAGxC,cAAc,yBAAyB;IACvC,gBAAgB,2BAA2B;IAG3C,4BAA4B,kCAAkC;IAC9D,uCAAuC,6CAA6C;CACvF"}
|
|
@@ -5,6 +5,7 @@ var ToolErrorCode = /* @__PURE__ */ ((ToolErrorCode2) => {
|
|
|
5
5
|
ToolErrorCode2["EXECUTION_FAILED"] = "tools_execution_failed";
|
|
6
6
|
ToolErrorCode2["DIRECTORY_ACCESS_DENIED"] = "tools_directory_access_denied";
|
|
7
7
|
ToolErrorCode2["VALIDATION_FAILED"] = "tools_validation_failed";
|
|
8
|
+
ToolErrorCode2["FILE_MODIFIED_SINCE_PREVIEW"] = "tools_file_modified_since_preview";
|
|
8
9
|
ToolErrorCode2["CONFIRMATION_HANDLER_MISSING"] = "tools_confirmation_handler_missing";
|
|
9
10
|
ToolErrorCode2["CONFIRMATION_TIMEOUT"] = "tools_confirmation_timeout";
|
|
10
11
|
ToolErrorCode2["CONFIRMATION_CANCELLED"] = "tools_confirmation_cancelled";
|
package/dist/tools/errors.cjs
CHANGED
|
@@ -103,6 +103,23 @@ class ToolError {
|
|
|
103
103
|
{ toolName, reason, ...context }
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* File was modified between preview and execute.
|
|
108
|
+
* This is a safety check to prevent corrupting user edits.
|
|
109
|
+
*/
|
|
110
|
+
static fileModifiedSincePreview(toolName, filePath) {
|
|
111
|
+
return new import_DextoRuntimeError.DextoRuntimeError(
|
|
112
|
+
import_error_codes.ToolErrorCode.FILE_MODIFIED_SINCE_PREVIEW,
|
|
113
|
+
import_types.ErrorScope.TOOLS,
|
|
114
|
+
import_types.ErrorType.USER,
|
|
115
|
+
`File '${filePath}' was modified since the preview was generated. Please read the file again and retry the operation.`,
|
|
116
|
+
{
|
|
117
|
+
toolName,
|
|
118
|
+
filePath,
|
|
119
|
+
recovery: "Read the file with read_file tool to get current content, then retry the edit."
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
106
123
|
/**
|
|
107
124
|
* Tool unauthorized access
|
|
108
125
|
*/
|
package/dist/tools/errors.d.ts
CHANGED
|
@@ -51,6 +51,15 @@ export declare class ToolError {
|
|
|
51
51
|
toolName: string;
|
|
52
52
|
reason: string;
|
|
53
53
|
}>;
|
|
54
|
+
/**
|
|
55
|
+
* File was modified between preview and execute.
|
|
56
|
+
* This is a safety check to prevent corrupting user edits.
|
|
57
|
+
*/
|
|
58
|
+
static fileModifiedSincePreview(toolName: string, filePath: string): DextoRuntimeError<{
|
|
59
|
+
toolName: string;
|
|
60
|
+
filePath: string;
|
|
61
|
+
recovery: string;
|
|
62
|
+
}>;
|
|
54
63
|
/**
|
|
55
64
|
* Tool unauthorized access
|
|
56
65
|
*/
|