@standardagents/builder 0.36.3 → 0.37.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.
Files changed (40) hide show
  1. package/dist/built-in-routes.js +1333 -1034
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-CxelZw61.js → ApiKeysView-BhuT3pIF.js} +1 -1
  4. package/dist/client/{CenteredContentView-CeQNRQH8.js → CenteredContentView-CfgX3Ao3.js} +1 -1
  5. package/dist/client/{CompositionView-YO0nHsYV.js → CompositionView-B9FfWMHd.js} +1 -1
  6. package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-_Y_F2vcO.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-BqwwsXWJ.js} +1 -1
  7. package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-CtC06f6H.js → CopyButton.vue_vue_type_script_setup_true_lang-Cqm3Vt3E.js} +1 -1
  8. package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-CqaWkS63.js → DataTable.vue_vue_type_script_setup_true_lang-CA5qgsty.js} +1 -1
  9. package/dist/client/{JsonViewer-71rdOpyq.js → JsonViewer-ByQKCShF.js} +1 -1
  10. package/dist/client/{LoginView-CkDpPh8U.js → LoginView-J4qtHbQK.js} +1 -1
  11. package/dist/client/{MarketplaceView-UYrMBLon.js → MarketplaceView-CshdWDqp.js} +1 -1
  12. package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-B1HPGo8o.js → Modal.vue_vue_type_script_setup_true_lang-DKdB9A8Z.js} +1 -1
  13. package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-DejoTM9W.js → ModelModal.vue_vue_type_script_setup_true_lang-BAxaBZsx.js} +1 -1
  14. package/dist/client/{ModelsView-DKYzp2fJ.js → ModelsView-B_n306yk.js} +1 -1
  15. package/dist/client/{PromptEditView-BlYHZ0ao.js → PromptEditView-C85qRgsE.js} +1 -1
  16. package/dist/client/{PromptModal-B1neRzSc.js → PromptModal-PNpoJfqD.js} +1 -1
  17. package/dist/client/{PromptsView-C0Ez74j0.js → PromptsView-BKnfThIF.js} +1 -1
  18. package/dist/client/{ProvidersView-CFc4K0IC.js → ProvidersView-Df41VhHD.js} +1 -1
  19. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CtIBWHUR.js +22 -0
  20. package/dist/client/{ThreadsView-B1hFXL-4.js → ThreadsView-sjo5Rrcm.js} +1 -1
  21. package/dist/client/{ToolsView-B3KqeOZD.js → ToolsView-C0MH9x3N.js} +1 -1
  22. package/dist/client/{UsersView-CF1tomjI.js → UsersView--TQiJYP7.js} +1 -1
  23. package/dist/client/{VariablesView-CP0TDspK.js → VariablesView-BO3UljZu.js} +1 -1
  24. package/dist/client/assets/{ThreadInspectorPane-2QOWOtet.css → ThreadInspectorPane-D9ZMzSTn.css} +1 -1
  25. package/dist/client/{index-BTs3PMFs.js → index-BgZnQr8X.js} +2 -2
  26. package/dist/client/index.html +1 -1
  27. package/dist/{index-DUIfQjBW.d.ts → index-DceFbLG9.d.ts} +62 -2
  28. package/dist/index.d.ts +61 -3
  29. package/dist/index.js +10804 -10203
  30. package/dist/index.js.map +1 -1
  31. package/dist/packing.js +213 -161
  32. package/dist/packing.js.map +1 -1
  33. package/dist/plugin.js +537 -504
  34. package/dist/plugin.js.map +1 -1
  35. package/dist/runtime.d.ts +176 -39
  36. package/dist/runtime.js +10280 -9672
  37. package/dist/runtime.js.map +1 -1
  38. package/dist/test.d.ts +1 -1
  39. package/package.json +5 -5
  40. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CXbSQo2-.js +0 -23
@@ -26,7 +26,7 @@
26
26
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
27
27
  <link rel="icon" type="image/svg+xml" href="/agents/assets/img/favicon-9uH1rb2F.svg">
28
28
  <title>AgentBuilder Admin</title>
29
- <script type="module" crossorigin src="/agents/index-BTs3PMFs.js"></script>
29
+ <script type="module" crossorigin src="/agents/index-BgZnQr8X.js"></script>
30
30
  <link rel="modulepreload" crossorigin href="/agents/formkit-0eyyCEP_.js">
31
31
  <link rel="modulepreload" crossorigin href="/agents/vendor-TPZjEwCU.js">
32
32
  <link rel="modulepreload" crossorigin href="/agents/syntax-D-ZcovVx.js">
@@ -407,7 +407,7 @@ interface ThreadInstance {
407
407
  }>;
408
408
  hasBridge?(): Promise<boolean>;
409
409
  failPendingMessagesAndBroadcast?(): Promise<number>;
410
- settleTerminalFailure?(errorMessage: string): Promise<void>;
410
+ settleTerminalFailure?(errorMessage: string, threadId?: string): Promise<void>;
411
411
  notifyClientWaiting?(toolCallId: string, threadId: string, userId: string | null): Promise<void>;
412
412
  registerCodeExecutionBridge?(runId: string, bridge: {
413
413
  call(functionId: string, encodedArgs: unknown[]): Promise<unknown>;
@@ -1112,6 +1112,48 @@ interface FileStats {
1112
1112
  fileCount: number;
1113
1113
  }
1114
1114
 
1115
+ /**
1116
+ * Authentication middleware for protecting API routes
1117
+ *
1118
+ * Supports multiple authentication types:
1119
+ * - Super admin token (signed with ENCRYPTION_KEY)
1120
+ * - User session token (validated against DurableAgentBuilder)
1121
+ * - API key (validated against DurableAgentBuilder)
1122
+ */
1123
+ interface AuthUser {
1124
+ id: string;
1125
+ username: string;
1126
+ /** 'admin' | 'user' | 'api' (API-only: normal API access, no UI, no logs). */
1127
+ role: string;
1128
+ /**
1129
+ * Explicit permission grants (e.g. 'logs'). `null`/absent = legacy row with
1130
+ * no explicit set — see {@link hasPermission} for the fallback rules.
1131
+ */
1132
+ permissions?: string[] | null;
1133
+ platform_user_id?: string | null;
1134
+ email?: string | null;
1135
+ display_name?: string | null;
1136
+ avatar_url?: string | null;
1137
+ }
1138
+ interface AuthContext {
1139
+ user: AuthUser;
1140
+ authType: 'super_admin' | 'session' | 'api_key';
1141
+ }
1142
+ /**
1143
+ * Authenticate a request using various token types
1144
+ */
1145
+ declare function authenticate(request: Request, env: any): Promise<AuthContext | null>;
1146
+ /**
1147
+ * Middleware to require authentication
1148
+ * Returns 401 if not authenticated
1149
+ */
1150
+ declare function requireAuth(request: Request, env: any): Promise<AuthContext | Response>;
1151
+ /**
1152
+ * Middleware to require admin role
1153
+ * Returns 401 if not authenticated, 403 if not admin
1154
+ */
1155
+ declare function requireAdmin(request: Request, env: any): Promise<AuthContext | Response>;
1156
+
1115
1157
  /**
1116
1158
  * Router and endpoint definition module for AgentBuilder.
1117
1159
  *
@@ -1237,6 +1279,19 @@ interface LogDetails {
1237
1279
  */
1238
1280
  interface DurableThreadRpc {
1239
1281
  stop(): Promise<Response>;
1282
+ emergencyQuarantine?(input: {
1283
+ actionId: string;
1284
+ reason: string;
1285
+ source?: string;
1286
+ forensicHold?: boolean;
1287
+ observed?: Record<string, number>;
1288
+ }): Promise<unknown>;
1289
+ emergencyResume?(input: {
1290
+ actionId: string;
1291
+ reason: string;
1292
+ releaseForensicHold?: boolean;
1293
+ }): Promise<unknown>;
1294
+ getRuntimeSafetyStatus?(): Promise<unknown>;
1240
1295
  /** Newest non-empty user message on the thread, for thread-list previews. */
1241
1296
  getLatestUserMessagePreview(): Promise<string | null>;
1242
1297
  executeBlocking?(threadId: string, agentId: string, initial_messages?: unknown[], data?: unknown): Promise<{
@@ -1428,6 +1483,8 @@ interface ThreadRegistryEntry {
1428
1483
  executing?: boolean;
1429
1484
  /** Short excerpt of the most recent user message, for thread-list rows. */
1430
1485
  last_message_preview?: string | null;
1486
+ /** Unix seconds of the newest message on this thread (never bumped by background activity). */
1487
+ last_message_at?: number | null;
1431
1488
  }
1432
1489
  /**
1433
1490
  * RPC methods exposed by DurableAgentBuilder for external callers.
@@ -1640,6 +1697,7 @@ interface DurableAgentBuilderRpc {
1640
1697
  recordThreadActivity?(threadId: string, options?: {
1641
1698
  executing?: boolean;
1642
1699
  messagePreview?: string | null;
1700
+ messageAt?: number;
1643
1701
  }): Promise<void>;
1644
1702
  getThreadTreeIds?(threadId: string): Promise<string[]>;
1645
1703
  deleteThread(threadId: string): Promise<void>;
@@ -1680,6 +1738,8 @@ interface BuilderControllerContext<Env extends ThreadEnv = ThreadEnv> extends Om
1680
1738
  providerFactories?: Record<string, () => Promise<unknown>>;
1681
1739
  /** Namespaced registry for packed agent support */
1682
1740
  registry?: NamespacedRegistry;
1741
+ /** Authenticated caller, populated by the generated runtime router. */
1742
+ auth?: AuthContext | null;
1683
1743
  }
1684
1744
  /**
1685
1745
  * Builder-specific controller type with typed env.
@@ -1745,4 +1805,4 @@ declare function defineController<Env extends ThreadEnv = ThreadEnv>(controller:
1745
1805
  */
1746
1806
  declare function createThreadEndpointHandler<Env extends ThreadEnv = ThreadEnv>(handler: ThreadEndpointHandler): BuilderController<Env>;
1747
1807
 
1748
- export { type Agent as A, type BuilderController as B, CLIENT_STREAM_CHUNK_BYTES as C, type ImageContentPart as D, type Env as E, type FlowState as F, type GrepResult as G, type MultimodalContent as H, type ImageMetadata as I, type MessageContent as J, type LLMResponse as L, type Message as M, type RequestContext as R, type StorageBackend as S, type ToolCall as T, type BuilderControllerContext as a, type ThreadEndpointContext as b, createThreadEndpointHandler as c, defineController as d, type ThreadEnv as e, type BuilderThreadEndpointHandler as f, callClient as g, callClientStream as h, encodeStreamChunk as i, decodeStreamChunk as j, type ClientToolRequest as k, type ClientToolResponse as l, type ClientStreamRequest as m, type ClientStreamResponse as n, type ClientDuplex as o, type ClientForwarding as p, type ThreadInstance as q, type ThreadMetadata as r, supportsClientForwarding as s, type ToolResult as t, type FlowResult as u, type TelemetryEvent as v, type FileRecord as w, type AttachmentRef as x, type FileStats as y, type TextContentPart as z };
1808
+ export { type AuthUser as A, type BuilderController as B, CLIENT_STREAM_CHUNK_BYTES as C, type TelemetryEvent as D, type Env as E, type FlowState as F, type FileRecord as G, type AttachmentRef as H, type ImageMetadata as I, type GrepResult as J, type FileStats as K, type LLMResponse as L, type Message as M, type TextContentPart as N, type ImageContentPart as O, type MultimodalContent as P, type MessageContent as Q, type RequestContext as R, type StorageBackend as S, type ToolCall as T, type BuilderControllerContext as a, type ThreadEndpointContext as b, createThreadEndpointHandler as c, defineController as d, type ThreadEnv as e, type BuilderThreadEndpointHandler as f, authenticate as g, requireAdmin as h, type AuthContext as i, callClient as j, callClientStream as k, encodeStreamChunk as l, decodeStreamChunk as m, type ClientToolRequest as n, type ClientToolResponse as o, type ClientStreamRequest as p, type ClientStreamResponse as q, requireAuth as r, supportsClientForwarding as s, type ClientDuplex as t, type ClientForwarding as u, type Agent as v, type ThreadInstance as w, type ThreadMetadata as x, type ToolResult as y, type FlowResult as z };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ModelDefinition, AgentDefinition } from './runtime.js';
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';
2
+ export { AgentBuilderEnv, AgentBuilderEvent, 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, ThreadEventPayload, ThreadRegistryEntry, ThreadWatchdog, ThreadWatchdogState, ToolConfig, UpdateThreadParams, User, WatchdogCheckin, WatchdogProbeResult, buildImageDescription, canAccessThread, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isAdminOnlyApiRoute, isHostedInstance, isPublicApiRoute, isQualifiedName, isTrustedLocalDevelopmentRequest, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, 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-DUIfQjBW.js';
4
+ export { v as Agent, H as AttachmentRef, i as AuthContext, A as AuthUser, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, t as ClientDuplex, u as ClientForwarding, p as ClientStreamRequest, q as ClientStreamResponse, n as ClientToolRequest, o as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, G as FileRecord, K as FileStats, z as FlowResult, F as FlowState, J as GrepResult, O as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, Q as MessageContent, P as MultimodalContent, R as RequestContext, S as StorageBackend, D as TelemetryEvent, N as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, w as ThreadInstance, x as ThreadMetadata, T as ToolCall, y as ToolResult, g as authenticate, j as callClient, k as callClientStream, c as createThreadEndpointHandler, m as decodeStreamChunk, d as defineController, l as encodeStreamChunk, h as requireAdmin, r as requireAuth, s as supportsClientForwarding } from './index-DceFbLG9.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';
@@ -10,6 +10,64 @@ import 'vite';
10
10
  import '@cloudflare/workers-types';
11
11
  import 'zod';
12
12
 
13
+ /**
14
+ * The "visible terminal assistant" boundary, server side.
15
+ *
16
+ * A client's session-state reducer retires its provisional draft on exactly
17
+ * this class of record: a durable assistant message that is no longer pending,
18
+ * is not silent, and carries visible text. Unread state has to agree with that
19
+ * boundary — a thread is unread when a reply the user has not seen has landed,
20
+ * which is the same instant the draft stops being provisional. Anything the
21
+ * reducer refuses to treat as an answer must not stamp recency either:
22
+ *
23
+ * - Pending/streaming partials: the answer has not landed yet.
24
+ * - Empty assistant envelopes: interleaved-reasoning providers persist one at
25
+ * every reasoning/generation boundary mid-turn, and a tool-calling step
26
+ * persists one with tool_calls and no prose. Neither renders anywhere.
27
+ * - Reasoning-only records: reasoning lives in its own column and in content
28
+ * blocks that carry no `text`, so both flatten to an empty string here.
29
+ * - Silent rows: never rendered in any head.
30
+ *
31
+ * A FAILED record with visible text does stamp, matching the reducer: a
32
+ * terminal error message is a real, visible end state the user has not read.
33
+ * A failed record with no content is excluded by the empty-content rule.
34
+ *
35
+ * A record carrying TOOL CALLS is never terminal, no matter how much prose
36
+ * rides along with it: FlowEngine persists the step (content + tool_calls,
37
+ * status completed) BEFORE executing its tools, so a narrated preamble like
38
+ * "Let me check the repo…" is a mid-turn working step every client still
39
+ * renders under a Working indicator. Stamping it would re-mark the thread
40
+ * unread on every step of a narrated turn — the exact false-dot class this
41
+ * field exists to eliminate.
42
+ *
43
+ * Visibility is text OR attachments: an attachment-only reply (content null
44
+ * plus generated images) is a supported terminal answer shape that every head
45
+ * renders, so it must stamp even though its text flattens to empty.
46
+ */
47
+ declare function isVisibleTerminalAssistantMessage(message: Record<string, unknown> | null | undefined): boolean;
48
+ /**
49
+ * True when a column holding a JSON array (tool_calls, attachments) actually
50
+ * carries entries. Rows store these as JSON strings; in-memory records may
51
+ * hold real arrays. Unparseable non-empty strings count as present — failing
52
+ * toward "not terminal" for tool_calls is the safe direction, and attachments
53
+ * only reach here after the text check already failed.
54
+ */
55
+ declare function hasJsonArrayEntries(raw: unknown): boolean;
56
+ /**
57
+ * Visible text of a message record, matching the reducer's extractor: plain
58
+ * string content, or the concatenated `text` of content blocks. Blocks without
59
+ * a string `text` (reasoning, images, tool payloads) contribute nothing.
60
+ */
61
+ declare function assistantMessageText(content: unknown): string;
62
+ /**
63
+ * Unix SECONDS for a message record whose timestamps are stored in
64
+ * microseconds. Prefers the completion time over the creation time: a pending
65
+ * row is created when the request goes out, so `created_at` can precede the
66
+ * visible answer by the whole generation. Returns null when neither column
67
+ * holds a usable number, letting the registry fall back to its own clock.
68
+ */
69
+ declare function messageTimestampSeconds(message: Record<string, unknown> | null | undefined): number | null;
70
+
13
71
  /**
14
72
  * Options for generating a model file.
15
73
  */
@@ -157,4 +215,4 @@ declare function generatePromptFile(data: PromptFileData): string;
157
215
  */
158
216
  declare function generateAgentFile(data: AgentDefinition): string;
159
217
 
160
- export { AgentDefinition, ModelDefinition, generateAgentFile, generateModelFile, generatePromptFile };
218
+ export { AgentDefinition, ModelDefinition, assistantMessageText, generateAgentFile, generateModelFile, generatePromptFile, hasJsonArrayEntries, isVisibleTerminalAssistantMessage, messageTimestampSeconds };