@standardagents/builder 0.32.0 → 0.33.0
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 +34 -1
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-1AMgutkG.d.ts → index-CqhPhqAI.d.ts} +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -9
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +20 -2
- package/dist/runtime.js +65 -9
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1234,6 +1234,8 @@ interface LogDetails {
|
|
|
1234
1234
|
*/
|
|
1235
1235
|
interface DurableThreadRpc {
|
|
1236
1236
|
stop(): Promise<Response>;
|
|
1237
|
+
/** Newest non-empty user message on the thread, for thread-list previews. */
|
|
1238
|
+
getLatestUserMessagePreview(): Promise<string | null>;
|
|
1237
1239
|
executeBlocking?(threadId: string, agentId: string, initial_messages?: unknown[], data?: unknown): Promise<{
|
|
1238
1240
|
status: "success" | "error";
|
|
1239
1241
|
result?: string;
|
|
@@ -1624,6 +1626,11 @@ interface DurableAgentBuilderRpc {
|
|
|
1624
1626
|
email: string | null;
|
|
1625
1627
|
thread_count: number;
|
|
1626
1628
|
}>>;
|
|
1629
|
+
/** Fill previews for threads that predate preview tracking (bulk, idempotent). */
|
|
1630
|
+
backfillThreadPreviews?(entries: Array<{
|
|
1631
|
+
id: string;
|
|
1632
|
+
preview: string | null;
|
|
1633
|
+
}>): Promise<void>;
|
|
1627
1634
|
/** Stamp thread activity / executing state for thread-list recency + status. */
|
|
1628
1635
|
recordThreadActivity?(threadId: string, options?: {
|
|
1629
1636
|
executing?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModelDefinition, AgentDefinition } from './runtime.js';
|
|
2
2
|
export { AgentBuilderEnv, AuthContext, AuthUser, BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, FlowStateSdk, FlowStateWithSdk, HubClientInfo, ImageContextConfig, InjectMessageOptions, LLMProviderInterface, NamespaceResolutionError, PromptContent, PromptDefinition, PromptIncludePart, PromptPart, PromptToolConfig, Provider, ProviderContentPart, ProviderFilePart, ProviderImagePart, ProviderRegistry, ProviderTextPart, SessionToolBinding, SessionToolConfig, SideConfig, SubagentToolConfig, SubpromptConfig, ThreadRegistryEntry, ThreadWatchdog, ThreadWatchdogState, ToolConfig, UpdateThreadParams, User, WatchdogCheckin, WatchdogProbeResult, 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 } from './runtime.js';
|
|
3
3
|
export { AgentPluginOptions, agentbuilder, builder } from './plugin.js';
|
|
4
|
-
export { A as Agent, x as AttachmentRef, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, m as ClientStreamRequest, n as ClientStreamResponse, k as ClientToolRequest, l as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, w as FileRecord, y as FileStats, u as FlowResult, F as FlowState, G as GrepResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, J as MessageContent, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, q as ThreadInstance, r as ThreadMetadata, T as ToolCall, t as ToolResult, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-
|
|
4
|
+
export { A as Agent, x as AttachmentRef, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, m as ClientStreamRequest, n as ClientStreamResponse, k as ClientToolRequest, l as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, w as FileRecord, y as FileStats, u as FlowResult, F as FlowState, G as GrepResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, J as MessageContent, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, q as ThreadInstance, r as ThreadMetadata, T as ToolCall, t as ToolResult, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-CqhPhqAI.js';
|
|
5
5
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, PromptInput, PromptTextPart, ProviderAssistantMessage, ProviderConfigSlot, ProviderConfigSlots, ProviderConfigValueSource, ProviderDefinition, ProviderError, ProviderErrorCode, ProviderFactory, ProviderFactoryConfig, ProviderFinishReason, ProviderGeneratedImage, ProviderMessage, ProviderMessageContent, ProviderMethodOverrides, ModelCapabilities as ProviderModelCapabilities, ProviderOverride, ProviderOverrideContext, ProviderReasoningDetail, ProviderRequest, ProviderResponse, ProviderStreamChunk, ProviderSyncOverride, ProviderSystemMessage, ProviderTool, ProviderToolCallPart, ProviderToolMessage, ProviderToolResultContent, ProviderUsage, ProviderUserMessage, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineProvider, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue } from '@standardagents/spec';
|
|
6
6
|
export { C as ConstituentItem, D as DiscoveredPackage, N as NamespacedRegistry, P as PackingAnalysis, a as PackingOptions, b as PackingResult, c as UnpackOptions, d as UnpackResult } from './types-Bpe7IANZ.js';
|
|
7
7
|
export { D as DiscoveryConfig, P as PackageDiscoveryService, d as discoverPackages } from './discovery-DiMJWisl.js';
|
package/dist/index.js
CHANGED
|
@@ -26198,9 +26198,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
26198
26198
|
* Each migration is run in order, starting from the current version + 1.
|
|
26199
26199
|
*/
|
|
26200
26200
|
async runMigrations(fromVersion) {
|
|
26201
|
-
for (const
|
|
26202
|
-
if (
|
|
26203
|
-
await
|
|
26201
|
+
for (const migration50 of migrations) {
|
|
26202
|
+
if (migration50.version > fromVersion) {
|
|
26203
|
+
await migration50.up(this.ctx.storage.sql);
|
|
26204
26204
|
}
|
|
26205
26205
|
}
|
|
26206
26206
|
}
|
|
@@ -29616,6 +29616,27 @@ ${resultContent}${attachmentSummary}`;
|
|
|
29616
29616
|
);
|
|
29617
29617
|
}
|
|
29618
29618
|
}
|
|
29619
|
+
/**
|
|
29620
|
+
* The newest non-empty user message on this thread, for thread-list previews.
|
|
29621
|
+
* Returns null when the thread has none. The Durable Object does not know its
|
|
29622
|
+
* own thread id, so the caller is the one that stamps the registry.
|
|
29623
|
+
*/
|
|
29624
|
+
async getLatestUserMessagePreview() {
|
|
29625
|
+
await this.ensureMigrated();
|
|
29626
|
+
try {
|
|
29627
|
+
const rows = this.ctx.storage.sql.exec(
|
|
29628
|
+
`SELECT content FROM messages
|
|
29629
|
+
WHERE role = 'user'
|
|
29630
|
+
AND content IS NOT NULL AND content != ''
|
|
29631
|
+
AND subagent_id IS NULL
|
|
29632
|
+
AND (silent IS NULL OR silent = 0)
|
|
29633
|
+
ORDER BY created_at DESC LIMIT 1`
|
|
29634
|
+
).toArray();
|
|
29635
|
+
return rows[0]?.content ?? null;
|
|
29636
|
+
} catch {
|
|
29637
|
+
return null;
|
|
29638
|
+
}
|
|
29639
|
+
}
|
|
29619
29640
|
/** Arm the standing watchdog for an execution start. One pending row max. */
|
|
29620
29641
|
async armExecutionWatchdog(threadId) {
|
|
29621
29642
|
try {
|
|
@@ -31599,9 +31620,23 @@ var migration48 = {
|
|
|
31599
31620
|
}
|
|
31600
31621
|
};
|
|
31601
31622
|
|
|
31623
|
+
// src/durable-objects/agentbuilder-migrations/0015_clear_envelope_previews.ts
|
|
31624
|
+
var migration49 = {
|
|
31625
|
+
version: 15,
|
|
31626
|
+
async up(sql) {
|
|
31627
|
+
sql.exec(
|
|
31628
|
+
`UPDATE threads SET last_message_preview = NULL
|
|
31629
|
+
WHERE last_message_preview LIKE 'Subagent (reference: %'`
|
|
31630
|
+
);
|
|
31631
|
+
sql.exec(`
|
|
31632
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '15')
|
|
31633
|
+
`);
|
|
31634
|
+
}
|
|
31635
|
+
};
|
|
31636
|
+
|
|
31602
31637
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
31603
|
-
var migrations2 = [migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48];
|
|
31604
|
-
var LATEST_SCHEMA_VERSION2 =
|
|
31638
|
+
var migrations2 = [migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48, migration49];
|
|
31639
|
+
var LATEST_SCHEMA_VERSION2 = 15;
|
|
31605
31640
|
|
|
31606
31641
|
// src/utils/crypto.ts
|
|
31607
31642
|
var CryptoUtil = class {
|
|
@@ -31802,6 +31837,7 @@ function parseStoredPermissions(value) {
|
|
|
31802
31837
|
}
|
|
31803
31838
|
var EXECUTING_STALE_AFTER_SECONDS = 15 * 60;
|
|
31804
31839
|
var THREAD_PREVIEW_MAX_CHARS = 140;
|
|
31840
|
+
var isRuntimeSubagentEnvelope = (content) => /^Subagent \(reference: /.test(content.trimStart());
|
|
31805
31841
|
var buildThreadPreview = (content) => {
|
|
31806
31842
|
const collapsed = content.replace(/\s+/g, " ").trim();
|
|
31807
31843
|
if (!collapsed) return null;
|
|
@@ -32376,9 +32412,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
32376
32412
|
}
|
|
32377
32413
|
}
|
|
32378
32414
|
async runMigrations(fromVersion) {
|
|
32379
|
-
for (const
|
|
32380
|
-
if (
|
|
32381
|
-
await
|
|
32415
|
+
for (const migration50 of migrations2) {
|
|
32416
|
+
if (migration50.version > fromVersion) {
|
|
32417
|
+
await migration50.up(this.ctx.storage.sql);
|
|
32382
32418
|
}
|
|
32383
32419
|
}
|
|
32384
32420
|
}
|
|
@@ -32694,7 +32730,7 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
32694
32730
|
await this.ensureMigrated();
|
|
32695
32731
|
const now = Math.floor(Date.now() / 1e3);
|
|
32696
32732
|
const executing = options?.executing;
|
|
32697
|
-
const preview = typeof options?.messagePreview === "string" ? buildThreadPreview(options.messagePreview) : void 0;
|
|
32733
|
+
const preview = typeof options?.messagePreview === "string" && !isRuntimeSubagentEnvelope(options.messagePreview) ? buildThreadPreview(options.messagePreview) : void 0;
|
|
32698
32734
|
await this.ctx.storage.sql.exec(
|
|
32699
32735
|
`UPDATE threads
|
|
32700
32736
|
SET last_activity_at = ?
|
|
@@ -32736,6 +32772,26 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
32736
32772
|
...preview !== void 0 ? { last_message_preview: preview } : {}
|
|
32737
32773
|
});
|
|
32738
32774
|
}
|
|
32775
|
+
/**
|
|
32776
|
+
* Fill in previews for threads that predate preview tracking. Callers read
|
|
32777
|
+
* each thread's newest user message and stamp the results here in one batch.
|
|
32778
|
+
*
|
|
32779
|
+
* A thread with no user message is stamped with an empty string rather than
|
|
32780
|
+
* left NULL: NULL means "not looked at yet", so without the sentinel an
|
|
32781
|
+
* empty thread would be re-read on every list request forever.
|
|
32782
|
+
*/
|
|
32783
|
+
async backfillThreadPreviews(entries) {
|
|
32784
|
+
if (entries.length === 0) return;
|
|
32785
|
+
await this.ensureMigrated();
|
|
32786
|
+
for (const entry of entries) {
|
|
32787
|
+
const preview = typeof entry.preview === "string" && !isRuntimeSubagentEnvelope(entry.preview) ? buildThreadPreview(entry.preview) ?? "" : "";
|
|
32788
|
+
await this.ctx.storage.sql.exec(
|
|
32789
|
+
`UPDATE threads SET last_message_preview = ? WHERE id = ? AND last_message_preview IS NULL`,
|
|
32790
|
+
preview,
|
|
32791
|
+
entry.id
|
|
32792
|
+
);
|
|
32793
|
+
}
|
|
32794
|
+
}
|
|
32739
32795
|
/**
|
|
32740
32796
|
* Delete a thread from the registry.
|
|
32741
32797
|
*/
|