@standardagents/builder 0.20.1 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-in-routes.js +190 -1
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-Bug9ATQX.d.ts → index-CpuS9hHJ.d.ts} +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +210 -2
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +1 -0
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +73 -3
- package/dist/runtime.js +209 -2
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +4 -4
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as ThreadEnv, h as ThreadMetadata, M as Message, l as FileRecord, F as FlowState, n as FileStats, G as GrepResult, m as AttachmentRef, r as MessageContent, E as Env, g as ThreadInstance } from './index-
|
|
2
|
-
export { A as Agent, f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, j as FlowResult, p as ImageContentPart, I as ImageMetadata, L as LLMResponse, q as MultimodalContent, R as RequestContext, S as StorageBackend, k as TelemetryEvent, o as TextContentPart, b as ThreadEndpointContext, T as ToolCall, i as ToolResult, c as createThreadEndpointHandler, d as defineController } from './index-
|
|
1
|
+
import { e as ThreadEnv, h as ThreadMetadata, M as Message, l as FileRecord, F as FlowState, n as FileStats, G as GrepResult, m as AttachmentRef, r as MessageContent, E as Env, g as ThreadInstance } from './index-CpuS9hHJ.js';
|
|
2
|
+
export { A as Agent, f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, j as FlowResult, p as ImageContentPart, I as ImageMetadata, L as LLMResponse, q as MultimodalContent, R as RequestContext, S as StorageBackend, k as TelemetryEvent, o as TextContentPart, b as ThreadEndpointContext, T as ToolCall, i as ToolResult, c as createThreadEndpointHandler, d as defineController } from './index-CpuS9hHJ.js';
|
|
3
3
|
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, PromptEnvPart, VariableDefinition, SubpromptConfig as SubpromptConfig$1, PromptToolConfig as PromptToolConfig$1, SubagentToolConfig as SubagentToolConfig$1, ReasoningConfig, SideConfig as SideConfig$1, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart, NamespaceContext, DefinitionLoader } from '@standardagents/spec';
|
|
4
4
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, PromptInput, PromptTextPart, ProviderAssistantMessage, ProviderError, ProviderErrorCode, ProviderFactory, ProviderFactoryConfig, ProviderFinishReason, ProviderGeneratedImage, ProviderMessage, ProviderMessageContent, ModelCapabilities as ProviderModelCapabilities, ProviderReasoningDetail, ProviderRequest, ProviderResponse, ProviderStreamChunk, ProviderSystemMessage, ProviderTool, ProviderToolCallPart, ProviderToolMessage, ProviderToolResultContent, ProviderUsage, ProviderUserMessage, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel } from '@standardagents/spec';
|
|
5
5
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
@@ -1140,6 +1140,31 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1140
1140
|
success: boolean;
|
|
1141
1141
|
error: any;
|
|
1142
1142
|
}>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Move or rename a file or directory (RPC method).
|
|
1145
|
+
* Relocates inline files, chunked files, and whole directory subtrees.
|
|
1146
|
+
*/
|
|
1147
|
+
moveFile(sourcePath: string, destinationPath: string): Promise<{
|
|
1148
|
+
success: boolean;
|
|
1149
|
+
file: any;
|
|
1150
|
+
error?: undefined;
|
|
1151
|
+
} | {
|
|
1152
|
+
success: boolean;
|
|
1153
|
+
error: any;
|
|
1154
|
+
file?: undefined;
|
|
1155
|
+
}>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Rename a file or directory in place (RPC method).
|
|
1158
|
+
*/
|
|
1159
|
+
renameFile(path: string, newName: string): Promise<{
|
|
1160
|
+
success: boolean;
|
|
1161
|
+
file: any;
|
|
1162
|
+
error?: undefined;
|
|
1163
|
+
} | {
|
|
1164
|
+
success: boolean;
|
|
1165
|
+
error: any;
|
|
1166
|
+
file?: undefined;
|
|
1167
|
+
}>;
|
|
1143
1168
|
/**
|
|
1144
1169
|
* Get file storage statistics (RPC method)
|
|
1145
1170
|
*/
|
|
@@ -1489,6 +1514,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1489
1514
|
* Delete a thread from the registry.
|
|
1490
1515
|
*/
|
|
1491
1516
|
deleteThread(id: string): Promise<boolean>;
|
|
1517
|
+
/**
|
|
1518
|
+
* Delete all singleton AgentBuilder storage for platform-owned teardown.
|
|
1519
|
+
* Used when the hosting platform expires a preview branch deployment after
|
|
1520
|
+
* all thread Durable Objects have already been wiped.
|
|
1521
|
+
*/
|
|
1522
|
+
deleteAllStorage(): Promise<{
|
|
1523
|
+
success: boolean;
|
|
1524
|
+
message: string;
|
|
1525
|
+
}>;
|
|
1492
1526
|
/**
|
|
1493
1527
|
* Get a thread tree (root + all descendants) in child-first order.
|
|
1494
1528
|
*
|
|
@@ -2573,6 +2607,42 @@ declare function readdir(flow: FlowState, path: string): Promise<FileRecord[]>;
|
|
|
2573
2607
|
* ```
|
|
2574
2608
|
*/
|
|
2575
2609
|
declare function rmdir(flow: FlowState, path: string): Promise<void>;
|
|
2610
|
+
/**
|
|
2611
|
+
* Move or rename a file or directory to a new path.
|
|
2612
|
+
*
|
|
2613
|
+
* Works for files (inline or chunked) and directories (the whole subtree is
|
|
2614
|
+
* relocated). The destination must not already exist.
|
|
2615
|
+
*
|
|
2616
|
+
* @param flow - The current FlowState
|
|
2617
|
+
* @param sourcePath - Existing file or directory path
|
|
2618
|
+
* @param destinationPath - New path
|
|
2619
|
+
* @returns The moved file record at its new path
|
|
2620
|
+
*
|
|
2621
|
+
* @example
|
|
2622
|
+
* ```typescript
|
|
2623
|
+
* import { move } from '@standardagents/builder';
|
|
2624
|
+
*
|
|
2625
|
+
* await move(flow, "/drafts/post.md", "/published/post.md");
|
|
2626
|
+
* await move(flow, "/tmp/work", "/archive/2024/work");
|
|
2627
|
+
* ```
|
|
2628
|
+
*/
|
|
2629
|
+
declare function move(flow: FlowState, sourcePath: string, destinationPath: string): Promise<FileRecord>;
|
|
2630
|
+
/**
|
|
2631
|
+
* Rename a file or directory in place, keeping it in the same directory.
|
|
2632
|
+
*
|
|
2633
|
+
* @param flow - The current FlowState
|
|
2634
|
+
* @param path - Existing file or directory path
|
|
2635
|
+
* @param newName - New name (must not contain path separators)
|
|
2636
|
+
* @returns The renamed file record at its new path
|
|
2637
|
+
*
|
|
2638
|
+
* @example
|
|
2639
|
+
* ```typescript
|
|
2640
|
+
* import { rename } from '@standardagents/builder';
|
|
2641
|
+
*
|
|
2642
|
+
* await rename(flow, "/notes/draft.txt", "final.txt");
|
|
2643
|
+
* ```
|
|
2644
|
+
*/
|
|
2645
|
+
declare function rename(flow: FlowState, path: string, newName: string): Promise<FileRecord>;
|
|
2576
2646
|
/**
|
|
2577
2647
|
* Get file storage statistics
|
|
2578
2648
|
*
|
|
@@ -3213,4 +3283,4 @@ declare function createNamespaceContext(agentDef: {
|
|
|
3213
3283
|
*/
|
|
3214
3284
|
declare function isQualifiedName(name: string): boolean;
|
|
3215
3285
|
|
|
3216
|
-
export { type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, Env, FileRecord, FileStats, FlowState, FlowStateSdk, type FlowStateWithSdk, GrepResult, type ImageContextConfig, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, Message, MessageContent, type ModelDefinition, NamespaceResolutionError, NamespacedRegistry, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type PromptToolConfig, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, ProviderRegistry, type ProviderTextPart, type SessionToolBinding, type SessionToolConfig, type SideConfig, type SubagentToolConfig, type SubpromptConfig, ThreadEnv, ThreadInstance, ThreadMetadata, type ThreadRegistryEntry, type ToolConfig, type UpdateThreadParams, type User, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|
|
3286
|
+
export { type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, Env, FileRecord, FileStats, FlowState, FlowStateSdk, type FlowStateWithSdk, GrepResult, type ImageContextConfig, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, Message, MessageContent, type ModelDefinition, NamespaceResolutionError, NamespacedRegistry, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type PromptToolConfig, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, ProviderRegistry, type ProviderTextPart, type SessionToolBinding, type SessionToolConfig, type SideConfig, type SubagentToolConfig, type SubpromptConfig, ThreadEnv, ThreadInstance, ThreadMetadata, type ThreadRegistryEntry, type ToolConfig, type UpdateThreadParams, type User, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|
package/dist/runtime.js
CHANGED
|
@@ -2504,7 +2504,9 @@ __export(files_exports, {
|
|
|
2504
2504
|
dirname: () => dirname,
|
|
2505
2505
|
isTextMimeType: () => isTextMimeType,
|
|
2506
2506
|
normalizePath: () => normalizePath,
|
|
2507
|
-
|
|
2507
|
+
resolveRenameDestination: () => resolveRenameDestination,
|
|
2508
|
+
rowToFileRecord: () => rowToFileRecord,
|
|
2509
|
+
validateMovePaths: () => validateMovePaths
|
|
2508
2510
|
});
|
|
2509
2511
|
function isTextMimeType(mimeType) {
|
|
2510
2512
|
if (mimeType.startsWith("text/")) return true;
|
|
@@ -2537,6 +2539,33 @@ function dirname(path) {
|
|
|
2537
2539
|
if (lastSlash <= 0) return "/";
|
|
2538
2540
|
return normalized.slice(0, lastSlash);
|
|
2539
2541
|
}
|
|
2542
|
+
function validateMovePaths(source, destination, isDirectory) {
|
|
2543
|
+
if (source === "/") {
|
|
2544
|
+
throw new Error("Cannot move the root directory");
|
|
2545
|
+
}
|
|
2546
|
+
if (destination === "/") {
|
|
2547
|
+
throw new Error("Cannot move over the root directory");
|
|
2548
|
+
}
|
|
2549
|
+
if (isDirectory && destination.startsWith(source + "/")) {
|
|
2550
|
+
throw new Error(
|
|
2551
|
+
"Cannot move a directory into itself or one of its descendants"
|
|
2552
|
+
);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
function resolveRenameDestination(path, newName) {
|
|
2556
|
+
if (typeof newName !== "string" || newName.length === 0) {
|
|
2557
|
+
throw new Error("New name must be a non-empty string");
|
|
2558
|
+
}
|
|
2559
|
+
if (newName.includes("/")) {
|
|
2560
|
+
throw new Error("New name must not contain path separators");
|
|
2561
|
+
}
|
|
2562
|
+
if (newName === "." || newName === "..") {
|
|
2563
|
+
throw new Error("New name must not be '.' or '..'");
|
|
2564
|
+
}
|
|
2565
|
+
const normalized = normalizePath(path);
|
|
2566
|
+
const parent = dirname(normalized);
|
|
2567
|
+
return parent === "/" ? `/${newName}` : `${parent}/${newName}`;
|
|
2568
|
+
}
|
|
2540
2569
|
function rowToFileRecord(row) {
|
|
2541
2570
|
return {
|
|
2542
2571
|
path: row.path,
|
|
@@ -3013,6 +3042,94 @@ var init_files = __esm({
|
|
|
3013
3042
|
normalizedPath
|
|
3014
3043
|
);
|
|
3015
3044
|
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Move (or rename) a file or directory from one path to another.
|
|
3047
|
+
*
|
|
3048
|
+
* Works for inline files, chunked files, and directories. Moving a
|
|
3049
|
+
* directory relocates the directory marker and every descendant entry,
|
|
3050
|
+
* preserving their relative layout. The destination must not already
|
|
3051
|
+
* exist, and a directory cannot be moved into itself or one of its own
|
|
3052
|
+
* descendants.
|
|
3053
|
+
*
|
|
3054
|
+
* Implementation note: the `file_chunks` table has a foreign key on
|
|
3055
|
+
* `files(path)` with `ON DELETE CASCADE`, and there is no `ON UPDATE`
|
|
3056
|
+
* action. To keep referential integrity intact (foreign key enforcement
|
|
3057
|
+
* is on in Durable Object SQLite), we copy the affected rows to their new
|
|
3058
|
+
* paths first, then delete the originals — the cascade removes the old
|
|
3059
|
+
* chunks, while the freshly copied chunks already point at the new file
|
|
3060
|
+
* rows. This never leaves an orphaned chunk mid-operation.
|
|
3061
|
+
*/
|
|
3062
|
+
async move(sourcePath, destinationPath) {
|
|
3063
|
+
const source = normalizePath(sourcePath);
|
|
3064
|
+
const destination = normalizePath(destinationPath);
|
|
3065
|
+
if (source === destination) {
|
|
3066
|
+
const existing = await this.stat(source);
|
|
3067
|
+
if (!existing) {
|
|
3068
|
+
throw new Error(`Source path does not exist: ${source}`);
|
|
3069
|
+
}
|
|
3070
|
+
return existing;
|
|
3071
|
+
}
|
|
3072
|
+
const record = await this.stat(source);
|
|
3073
|
+
if (!record) {
|
|
3074
|
+
throw new Error(`Source path does not exist: ${source}`);
|
|
3075
|
+
}
|
|
3076
|
+
validateMovePaths(source, destination, record.isDirectory);
|
|
3077
|
+
const destPrefix = destination + "/";
|
|
3078
|
+
const collision = await this.sql.exec(
|
|
3079
|
+
`SELECT COUNT(*) as count FROM files WHERE path = ? OR path LIKE ? || '%'`,
|
|
3080
|
+
destination,
|
|
3081
|
+
destPrefix
|
|
3082
|
+
);
|
|
3083
|
+
if (collision.one().count > 0) {
|
|
3084
|
+
throw new Error(`Destination already exists: ${destination}`);
|
|
3085
|
+
}
|
|
3086
|
+
const sourcePrefix = source + "/";
|
|
3087
|
+
const sourceLen = source.length;
|
|
3088
|
+
const destName = basename(destination);
|
|
3089
|
+
await this.sql.exec(
|
|
3090
|
+
`INSERT INTO files (path, name, mime_type, storage, location, data, content, size, metadata, thumbnail, is_directory, created_at, width, height, is_chunked, chunk_count)
|
|
3091
|
+
SELECT ? || SUBSTR(path, ? + 1), name, mime_type, storage, location, data, content, size, metadata, thumbnail, is_directory, created_at, width, height, is_chunked, chunk_count
|
|
3092
|
+
FROM files
|
|
3093
|
+
WHERE path = ? OR path LIKE ? || '%'`,
|
|
3094
|
+
destination,
|
|
3095
|
+
sourceLen,
|
|
3096
|
+
source,
|
|
3097
|
+
sourcePrefix
|
|
3098
|
+
);
|
|
3099
|
+
await this.sql.exec(
|
|
3100
|
+
`INSERT INTO file_chunks (file_path, chunk_index, data)
|
|
3101
|
+
SELECT ? || SUBSTR(file_path, ? + 1), chunk_index, data
|
|
3102
|
+
FROM file_chunks
|
|
3103
|
+
WHERE file_path = ? OR file_path LIKE ? || '%'`,
|
|
3104
|
+
destination,
|
|
3105
|
+
sourceLen,
|
|
3106
|
+
source,
|
|
3107
|
+
sourcePrefix
|
|
3108
|
+
);
|
|
3109
|
+
await this.sql.exec(
|
|
3110
|
+
`DELETE FROM files WHERE path = ? OR path LIKE ? || '%'`,
|
|
3111
|
+
source,
|
|
3112
|
+
sourcePrefix
|
|
3113
|
+
);
|
|
3114
|
+
await this.sql.exec(
|
|
3115
|
+
`UPDATE files SET name = ? WHERE path = ?`,
|
|
3116
|
+
destName,
|
|
3117
|
+
destination
|
|
3118
|
+
);
|
|
3119
|
+
const moved = await this.stat(destination);
|
|
3120
|
+
if (!moved) {
|
|
3121
|
+
throw new Error(`Failed to move ${source} to ${destination}`);
|
|
3122
|
+
}
|
|
3123
|
+
return moved;
|
|
3124
|
+
}
|
|
3125
|
+
/**
|
|
3126
|
+
* Rename a file or directory in place, keeping it in the same parent
|
|
3127
|
+
* directory. `newName` must be a bare file name with no path separators.
|
|
3128
|
+
*/
|
|
3129
|
+
async rename(path, newName) {
|
|
3130
|
+
const destination = resolveRenameDestination(path, newName);
|
|
3131
|
+
return this.move(normalizePath(path), destination);
|
|
3132
|
+
}
|
|
3016
3133
|
/**
|
|
3017
3134
|
* Get storage statistics
|
|
3018
3135
|
*/
|
|
@@ -9855,6 +9972,22 @@ async function rmdir(flow, path) {
|
|
|
9855
9972
|
throw new Error(result.error || "Failed to remove directory");
|
|
9856
9973
|
}
|
|
9857
9974
|
}
|
|
9975
|
+
async function move(flow, sourcePath, destinationPath) {
|
|
9976
|
+
const instance = flow.thread.instance;
|
|
9977
|
+
const result = await instance.moveFile(sourcePath, destinationPath);
|
|
9978
|
+
if (!result.success) {
|
|
9979
|
+
throw new Error(result.error || "Failed to move file");
|
|
9980
|
+
}
|
|
9981
|
+
return result.file;
|
|
9982
|
+
}
|
|
9983
|
+
async function rename(flow, path, newName) {
|
|
9984
|
+
const instance = flow.thread.instance;
|
|
9985
|
+
const result = await instance.renameFile(path, newName);
|
|
9986
|
+
if (!result.success) {
|
|
9987
|
+
throw new Error(result.error || "Failed to rename file");
|
|
9988
|
+
}
|
|
9989
|
+
return result.file;
|
|
9990
|
+
}
|
|
9858
9991
|
async function getFileStats(flow) {
|
|
9859
9992
|
const instance = flow.thread.instance;
|
|
9860
9993
|
const result = await instance.getFileStats();
|
|
@@ -12480,6 +12613,20 @@ var init_ThreadStateImpl = __esm({
|
|
|
12480
12613
|
async rmdirFile(path) {
|
|
12481
12614
|
await this._threadInstance.rmdirFile(path);
|
|
12482
12615
|
}
|
|
12616
|
+
async moveFile(sourcePath, destinationPath) {
|
|
12617
|
+
const result = await this._threadInstance.moveFile(sourcePath, destinationPath);
|
|
12618
|
+
if (!result.success || !result.file) {
|
|
12619
|
+
throw new Error(result.error || "Failed to move file");
|
|
12620
|
+
}
|
|
12621
|
+
return this._mapFileRecord(result.file);
|
|
12622
|
+
}
|
|
12623
|
+
async renameFile(path, newName) {
|
|
12624
|
+
const result = await this._threadInstance.renameFile(path, newName);
|
|
12625
|
+
if (!result.success || !result.file) {
|
|
12626
|
+
throw new Error(result.error || "Failed to rename file");
|
|
12627
|
+
}
|
|
12628
|
+
return this._mapFileRecord(result.file);
|
|
12629
|
+
}
|
|
12483
12630
|
async getFileStats() {
|
|
12484
12631
|
const stats = await this._threadInstance.getFileStats();
|
|
12485
12632
|
return {
|
|
@@ -14769,6 +14916,11 @@ function createEndpointThreadStateBridge(state) {
|
|
|
14769
14916
|
unlinkFile: (path) => state.unlinkFile(normalizeEndpointThreadPath(path)),
|
|
14770
14917
|
mkdirFile: (path) => state.mkdirFile(normalizeEndpointThreadPath(path)),
|
|
14771
14918
|
rmdirFile: (path) => state.rmdirFile(normalizeEndpointThreadPath(path)),
|
|
14919
|
+
moveFile: (sourcePath, destinationPath) => state.moveFile(
|
|
14920
|
+
normalizeEndpointThreadPath(sourcePath),
|
|
14921
|
+
normalizeEndpointThreadPath(destinationPath)
|
|
14922
|
+
),
|
|
14923
|
+
renameFile: (path, newName) => state.renameFile(normalizeEndpointThreadPath(path), newName),
|
|
14772
14924
|
getFileStats: () => state.getFileStats(),
|
|
14773
14925
|
grepFiles: (pattern) => state.grepFiles(pattern),
|
|
14774
14926
|
findFiles: (pattern) => state.findFiles(pattern),
|
|
@@ -18888,6 +19040,43 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18888
19040
|
return { success: false, error: error.message };
|
|
18889
19041
|
}
|
|
18890
19042
|
}
|
|
19043
|
+
/**
|
|
19044
|
+
* Move or rename a file or directory (RPC method).
|
|
19045
|
+
* Relocates inline files, chunked files, and whole directory subtrees.
|
|
19046
|
+
*/
|
|
19047
|
+
async moveFile(sourcePath, destinationPath) {
|
|
19048
|
+
await this.ensureMigrated();
|
|
19049
|
+
try {
|
|
19050
|
+
const { normalizePath: normalizePath2 } = await Promise.resolve().then(() => (init_files(), files_exports));
|
|
19051
|
+
const fs = this.getFileStorage();
|
|
19052
|
+
const from = normalizePath2(sourcePath);
|
|
19053
|
+
const record = await fs.move(sourcePath, destinationPath);
|
|
19054
|
+
this.broadcastEvent("file_deleted", { path: from });
|
|
19055
|
+
this.broadcastEvent("file_created", { path: record.path, file: record });
|
|
19056
|
+
return { success: true, file: record };
|
|
19057
|
+
} catch (error) {
|
|
19058
|
+
console.error("Error in moveFile:", error);
|
|
19059
|
+
return { success: false, error: error.message };
|
|
19060
|
+
}
|
|
19061
|
+
}
|
|
19062
|
+
/**
|
|
19063
|
+
* Rename a file or directory in place (RPC method).
|
|
19064
|
+
*/
|
|
19065
|
+
async renameFile(path, newName) {
|
|
19066
|
+
await this.ensureMigrated();
|
|
19067
|
+
try {
|
|
19068
|
+
const { normalizePath: normalizePath2 } = await Promise.resolve().then(() => (init_files(), files_exports));
|
|
19069
|
+
const fs = this.getFileStorage();
|
|
19070
|
+
const from = normalizePath2(path);
|
|
19071
|
+
const record = await fs.rename(path, newName);
|
|
19072
|
+
this.broadcastEvent("file_deleted", { path: from });
|
|
19073
|
+
this.broadcastEvent("file_created", { path: record.path, file: record });
|
|
19074
|
+
return { success: true, file: record };
|
|
19075
|
+
} catch (error) {
|
|
19076
|
+
console.error("Error in renameFile:", error);
|
|
19077
|
+
return { success: false, error: error.message };
|
|
19078
|
+
}
|
|
19079
|
+
}
|
|
18891
19080
|
/**
|
|
18892
19081
|
* Get file storage statistics (RPC method)
|
|
18893
19082
|
*/
|
|
@@ -20235,6 +20424,24 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
20235
20424
|
this.broadcastEvent({ type: "thread_deleted", threadId: id });
|
|
20236
20425
|
return true;
|
|
20237
20426
|
}
|
|
20427
|
+
/**
|
|
20428
|
+
* Delete all singleton AgentBuilder storage for platform-owned teardown.
|
|
20429
|
+
* Used when the hosting platform expires a preview branch deployment after
|
|
20430
|
+
* all thread Durable Objects have already been wiped.
|
|
20431
|
+
*/
|
|
20432
|
+
async deleteAllStorage() {
|
|
20433
|
+
for (const ws of Array.from(this.eventSockets)) {
|
|
20434
|
+
try {
|
|
20435
|
+
ws.close(1e3, "Instance deleted");
|
|
20436
|
+
} catch {
|
|
20437
|
+
}
|
|
20438
|
+
}
|
|
20439
|
+
this.eventSockets.clear();
|
|
20440
|
+
await this.ctx.storage.deleteAlarm();
|
|
20441
|
+
await this.ctx.storage.deleteAll();
|
|
20442
|
+
this.migratedToVersion = null;
|
|
20443
|
+
return { success: true, message: "AgentBuilder storage completely deleted" };
|
|
20444
|
+
}
|
|
20238
20445
|
/**
|
|
20239
20446
|
* Get a thread tree (root + all descendants) in child-first order.
|
|
20240
20447
|
*
|
|
@@ -22214,6 +22421,6 @@ init_context();
|
|
|
22214
22421
|
init_ProviderRegistry();
|
|
22215
22422
|
init_types2();
|
|
22216
22423
|
|
|
22217
|
-
export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, FlowStateSdk, NamespaceResolutionError, ProviderRegistry, authenticate, buildImageDescription, cat, createNamespaceContext, createThreadEndpointHandler, defineController2 as defineController, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|
|
22424
|
+
export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, FlowStateSdk, NamespaceResolutionError, ProviderRegistry, authenticate, buildImageDescription, cat, createNamespaceContext, createThreadEndpointHandler, defineController2 as defineController, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|
|
22218
22425
|
//# sourceMappingURL=runtime.js.map
|
|
22219
22426
|
//# sourceMappingURL=runtime.js.map
|