@standardagents/builder 0.27.2 → 0.27.3
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 +18 -1
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-DJ7B8CTp.d.ts → index-DReIS8eP.d.ts} +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.js +23 -1
- 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, h as ThreadMetadata, i as ToolResult, 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 { 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, c as createThreadEndpointHandler, d as defineController } from './index-
|
|
1
|
+
import { e as ThreadEnv, A as Agent, h as ThreadMetadata, i as ToolResult, 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-DReIS8eP.js';
|
|
2
|
+
export { 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, c as createThreadEndpointHandler, d as defineController } from './index-DReIS8eP.js';
|
|
3
3
|
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, ClientToolRequest, ClientToolResponse, 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, 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';
|
|
@@ -1124,6 +1124,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1124
1124
|
* Broadcast a custom event to all connected message WebSocket clients
|
|
1125
1125
|
* Used by tools via emitThreadEvent() to send user-defined events
|
|
1126
1126
|
*/
|
|
1127
|
+
emitThreadEvent(_threadId: string, type: string, data: unknown): void;
|
|
1127
1128
|
private broadcastEvent;
|
|
1128
1129
|
/**
|
|
1129
1130
|
* WebSocket Hibernation API handler for incoming messages
|
package/dist/runtime.js
CHANGED
|
@@ -12694,6 +12694,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
12694
12694
|
_executionState = null;
|
|
12695
12695
|
_childrenCache = [];
|
|
12696
12696
|
_terminatedCache = null;
|
|
12697
|
+
_pendingEventDeliveries = /* @__PURE__ */ new Set();
|
|
12697
12698
|
constructor(flowState, threadInstance, metadata, runtimeContext = {}) {
|
|
12698
12699
|
this._flowState = flowState;
|
|
12699
12700
|
this._threadInstance = threadInstance;
|
|
@@ -13145,6 +13146,22 @@ var init_ThreadStateImpl = __esm({
|
|
|
13145
13146
|
emit(event, data) {
|
|
13146
13147
|
if (this._flowState?.emitEvent) {
|
|
13147
13148
|
this._flowState.emitEvent(event, data);
|
|
13149
|
+
return;
|
|
13150
|
+
}
|
|
13151
|
+
if (this._threadInstance.emitThreadEvent) {
|
|
13152
|
+
const delivery = this._threadInstance.emitThreadEvent(this.threadId, event, data);
|
|
13153
|
+
if (delivery && typeof delivery.then === "function") {
|
|
13154
|
+
const pending = Promise.resolve(delivery).catch((error) => {
|
|
13155
|
+
console.error(`[ThreadState] Custom event "${event}" delivery failed:`, error);
|
|
13156
|
+
}).finally(() => this._pendingEventDeliveries.delete(pending));
|
|
13157
|
+
this._pendingEventDeliveries.add(pending);
|
|
13158
|
+
}
|
|
13159
|
+
}
|
|
13160
|
+
}
|
|
13161
|
+
/** Runtime-only drain used by thread endpoint wrappers before responding. */
|
|
13162
|
+
async flushPendingEventDeliveries() {
|
|
13163
|
+
while (this._pendingEventDeliveries.size > 0) {
|
|
13164
|
+
await Promise.all([...this._pendingEventDeliveries]);
|
|
13148
13165
|
}
|
|
13149
13166
|
}
|
|
13150
13167
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -13915,7 +13932,9 @@ function createThreadEndpointHandler(handler) {
|
|
|
13915
13932
|
}
|
|
13916
13933
|
endpointParams[key === "_" ? "*" : key] = value;
|
|
13917
13934
|
}
|
|
13918
|
-
|
|
13935
|
+
const response = await handler(req, threadState, endpointParams);
|
|
13936
|
+
await threadState.flushPendingEventDeliveries();
|
|
13937
|
+
return response;
|
|
13919
13938
|
} catch (error) {
|
|
13920
13939
|
console.error(`Error in thread endpoint for ${threadId}:`, error);
|
|
13921
13940
|
return Response.json(
|
|
@@ -20026,6 +20045,9 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20026
20045
|
* Broadcast a custom event to all connected message WebSocket clients
|
|
20027
20046
|
* Used by tools via emitThreadEvent() to send user-defined events
|
|
20028
20047
|
*/
|
|
20048
|
+
emitThreadEvent(_threadId, type, data) {
|
|
20049
|
+
this.broadcastEvent(type, data);
|
|
20050
|
+
}
|
|
20029
20051
|
broadcastEvent(type, data) {
|
|
20030
20052
|
const payload = JSON.stringify({
|
|
20031
20053
|
type: "event",
|