@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
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-
|
|
2
|
-
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-
|
|
1
|
+
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-CqhPhqAI.js';
|
|
2
|
+
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, 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';
|
|
3
3
|
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, CredentialGrant, SkillMetadata, SkillFileInput, 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, ThreadState, 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';
|
|
@@ -1248,6 +1248,12 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1248
1248
|
* turn that triggered it.
|
|
1249
1249
|
*/
|
|
1250
1250
|
private recordRegistryActivity;
|
|
1251
|
+
/**
|
|
1252
|
+
* The newest non-empty user message on this thread, for thread-list previews.
|
|
1253
|
+
* Returns null when the thread has none. The Durable Object does not know its
|
|
1254
|
+
* own thread id, so the caller is the one that stamps the registry.
|
|
1255
|
+
*/
|
|
1256
|
+
getLatestUserMessagePreview(): Promise<string | null>;
|
|
1251
1257
|
/** Arm the standing watchdog for an execution start. One pending row max. */
|
|
1252
1258
|
private armExecutionWatchdog;
|
|
1253
1259
|
/** Disarm on clean execution end. Completed check rows are noise, not history. */
|
|
@@ -2074,6 +2080,18 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
2074
2080
|
executing?: boolean;
|
|
2075
2081
|
messagePreview?: string | null;
|
|
2076
2082
|
}): Promise<void>;
|
|
2083
|
+
/**
|
|
2084
|
+
* Fill in previews for threads that predate preview tracking. Callers read
|
|
2085
|
+
* each thread's newest user message and stamp the results here in one batch.
|
|
2086
|
+
*
|
|
2087
|
+
* A thread with no user message is stamped with an empty string rather than
|
|
2088
|
+
* left NULL: NULL means "not looked at yet", so without the sentinel an
|
|
2089
|
+
* empty thread would be re-read on every list request forever.
|
|
2090
|
+
*/
|
|
2091
|
+
backfillThreadPreviews(entries: Array<{
|
|
2092
|
+
id: string;
|
|
2093
|
+
preview: string | null;
|
|
2094
|
+
}>): Promise<void>;
|
|
2077
2095
|
/**
|
|
2078
2096
|
* Delete a thread from the registry.
|
|
2079
2097
|
*/
|
package/dist/runtime.js
CHANGED
|
@@ -17790,9 +17790,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
17790
17790
|
* Each migration is run in order, starting from the current version + 1.
|
|
17791
17791
|
*/
|
|
17792
17792
|
async runMigrations(fromVersion) {
|
|
17793
|
-
for (const
|
|
17794
|
-
if (
|
|
17795
|
-
await
|
|
17793
|
+
for (const migration50 of migrations) {
|
|
17794
|
+
if (migration50.version > fromVersion) {
|
|
17795
|
+
await migration50.up(this.ctx.storage.sql);
|
|
17796
17796
|
}
|
|
17797
17797
|
}
|
|
17798
17798
|
}
|
|
@@ -21208,6 +21208,27 @@ ${resultContent}${attachmentSummary}`;
|
|
|
21208
21208
|
);
|
|
21209
21209
|
}
|
|
21210
21210
|
}
|
|
21211
|
+
/**
|
|
21212
|
+
* The newest non-empty user message on this thread, for thread-list previews.
|
|
21213
|
+
* Returns null when the thread has none. The Durable Object does not know its
|
|
21214
|
+
* own thread id, so the caller is the one that stamps the registry.
|
|
21215
|
+
*/
|
|
21216
|
+
async getLatestUserMessagePreview() {
|
|
21217
|
+
await this.ensureMigrated();
|
|
21218
|
+
try {
|
|
21219
|
+
const rows = this.ctx.storage.sql.exec(
|
|
21220
|
+
`SELECT content FROM messages
|
|
21221
|
+
WHERE role = 'user'
|
|
21222
|
+
AND content IS NOT NULL AND content != ''
|
|
21223
|
+
AND subagent_id IS NULL
|
|
21224
|
+
AND (silent IS NULL OR silent = 0)
|
|
21225
|
+
ORDER BY created_at DESC LIMIT 1`
|
|
21226
|
+
).toArray();
|
|
21227
|
+
return rows[0]?.content ?? null;
|
|
21228
|
+
} catch {
|
|
21229
|
+
return null;
|
|
21230
|
+
}
|
|
21231
|
+
}
|
|
21211
21232
|
/** Arm the standing watchdog for an execution start. One pending row max. */
|
|
21212
21233
|
async armExecutionWatchdog(threadId) {
|
|
21213
21234
|
try {
|
|
@@ -23191,9 +23212,23 @@ var migration48 = {
|
|
|
23191
23212
|
}
|
|
23192
23213
|
};
|
|
23193
23214
|
|
|
23215
|
+
// src/durable-objects/agentbuilder-migrations/0015_clear_envelope_previews.ts
|
|
23216
|
+
var migration49 = {
|
|
23217
|
+
version: 15,
|
|
23218
|
+
async up(sql) {
|
|
23219
|
+
sql.exec(
|
|
23220
|
+
`UPDATE threads SET last_message_preview = NULL
|
|
23221
|
+
WHERE last_message_preview LIKE 'Subagent (reference: %'`
|
|
23222
|
+
);
|
|
23223
|
+
sql.exec(`
|
|
23224
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '15')
|
|
23225
|
+
`);
|
|
23226
|
+
}
|
|
23227
|
+
};
|
|
23228
|
+
|
|
23194
23229
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
23195
|
-
var migrations2 = [migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48];
|
|
23196
|
-
var LATEST_SCHEMA_VERSION2 =
|
|
23230
|
+
var migrations2 = [migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48, migration49];
|
|
23231
|
+
var LATEST_SCHEMA_VERSION2 = 15;
|
|
23197
23232
|
|
|
23198
23233
|
// src/utils/crypto.ts
|
|
23199
23234
|
var CryptoUtil = class {
|
|
@@ -23394,6 +23429,7 @@ function parseStoredPermissions(value) {
|
|
|
23394
23429
|
}
|
|
23395
23430
|
var EXECUTING_STALE_AFTER_SECONDS = 15 * 60;
|
|
23396
23431
|
var THREAD_PREVIEW_MAX_CHARS = 140;
|
|
23432
|
+
var isRuntimeSubagentEnvelope = (content) => /^Subagent \(reference: /.test(content.trimStart());
|
|
23397
23433
|
var buildThreadPreview = (content) => {
|
|
23398
23434
|
const collapsed = content.replace(/\s+/g, " ").trim();
|
|
23399
23435
|
if (!collapsed) return null;
|
|
@@ -23968,9 +24004,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
23968
24004
|
}
|
|
23969
24005
|
}
|
|
23970
24006
|
async runMigrations(fromVersion) {
|
|
23971
|
-
for (const
|
|
23972
|
-
if (
|
|
23973
|
-
await
|
|
24007
|
+
for (const migration50 of migrations2) {
|
|
24008
|
+
if (migration50.version > fromVersion) {
|
|
24009
|
+
await migration50.up(this.ctx.storage.sql);
|
|
23974
24010
|
}
|
|
23975
24011
|
}
|
|
23976
24012
|
}
|
|
@@ -24286,7 +24322,7 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
24286
24322
|
await this.ensureMigrated();
|
|
24287
24323
|
const now = Math.floor(Date.now() / 1e3);
|
|
24288
24324
|
const executing = options?.executing;
|
|
24289
|
-
const preview = typeof options?.messagePreview === "string" ? buildThreadPreview(options.messagePreview) : void 0;
|
|
24325
|
+
const preview = typeof options?.messagePreview === "string" && !isRuntimeSubagentEnvelope(options.messagePreview) ? buildThreadPreview(options.messagePreview) : void 0;
|
|
24290
24326
|
await this.ctx.storage.sql.exec(
|
|
24291
24327
|
`UPDATE threads
|
|
24292
24328
|
SET last_activity_at = ?
|
|
@@ -24328,6 +24364,26 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
24328
24364
|
...preview !== void 0 ? { last_message_preview: preview } : {}
|
|
24329
24365
|
});
|
|
24330
24366
|
}
|
|
24367
|
+
/**
|
|
24368
|
+
* Fill in previews for threads that predate preview tracking. Callers read
|
|
24369
|
+
* each thread's newest user message and stamp the results here in one batch.
|
|
24370
|
+
*
|
|
24371
|
+
* A thread with no user message is stamped with an empty string rather than
|
|
24372
|
+
* left NULL: NULL means "not looked at yet", so without the sentinel an
|
|
24373
|
+
* empty thread would be re-read on every list request forever.
|
|
24374
|
+
*/
|
|
24375
|
+
async backfillThreadPreviews(entries) {
|
|
24376
|
+
if (entries.length === 0) return;
|
|
24377
|
+
await this.ensureMigrated();
|
|
24378
|
+
for (const entry of entries) {
|
|
24379
|
+
const preview = typeof entry.preview === "string" && !isRuntimeSubagentEnvelope(entry.preview) ? buildThreadPreview(entry.preview) ?? "" : "";
|
|
24380
|
+
await this.ctx.storage.sql.exec(
|
|
24381
|
+
`UPDATE threads SET last_message_preview = ? WHERE id = ? AND last_message_preview IS NULL`,
|
|
24382
|
+
preview,
|
|
24383
|
+
entry.id
|
|
24384
|
+
);
|
|
24385
|
+
}
|
|
24386
|
+
}
|
|
24331
24387
|
/**
|
|
24332
24388
|
* Delete a thread from the registry.
|
|
24333
24389
|
*/
|